简体   繁体   English

在多个项目中更新Gruntfile.js和Package.json

[英]Update Gruntfile.js and Package.json across multiple projects

I am new to the world of grunt but I feel like there must be a way to do this. 我是刚进入咕gr声世界的人,但我觉得必须有一种方法可以做到这一点。 Hopefully I can explain my issue in a way that makes sense so you can be of assistance. 希望我能以一种有意义的方式解释我的问题,以便您能有所帮助。

Essentially, I have a git project, including a gruntfile, that I use to start all new websites. 本质上,我有一个git项目,其中包括一个gruntfile,用于启动所有新网站。 I clone the project, delete the .git folder and setup a new project in bitbucket for it. 我克隆了项目,删除了.git文件夹,并在bitbucket中为其设置了一个新项目。 Over time I have had to make some modifications to the gruntfile and it is annoying to go back to an old project where I hadn't made those modifications. 随着时间的流逝,我不得不对gruntfile进行一些修改,而回到一个我没有进行这些修改的旧项目中,这很烦人。 Is there a recommended way to ensure that my template is up to date on all of my projects? 有没有推荐的方法来确保我的模板在所有项目中都是最新的?

Things to note: 注意事项:

1) I am familiar with grunt scaffolding but I have never used it, is this the use case for it? 1)我熟悉咕unt咕aff的脚手架,但我从未使用过,这是它的用例吗?

2) my projects live in bitbucket and are private. 2)我的项目生活在bitbucket中,并且是私有的。 My initial solution to this problem was to use grunt curl and pull the latest and overwrite the previous gruntfile 我对这个问题的最初解决方案是使用grunt curl并拉出最新的并覆盖以前的gruntfile

3) The issue with #2 is that I would need to put my username/password in the path and can't figure out how to prompt the user, even if I do and they enter the login incorrectly bitbucket still returns something (a bad login page) and this would overwrite my gruntfile. 3)#2的问题是我需要将我的用户名/密码放在路径中,并且无法弄清楚如何提示用户,即使我这样做并且他们输入错误的信息,bitbucket仍然会返回一些信息(这很糟糕登录页面),这将覆盖我的gruntfile。

Thanks in advance! 提前致谢! I appreciate anyones input 我感谢任何人的投入

I assume you are using git with bitbucket. 我假设您将git与bitbucket一起使用。 If that is the case you can do a pull from a master repo that contains your template grunt file in each of your project repositories for the desired effect. 如果是这种情况,您可以从每个项目存储库中都包含模板grunt文件的主存储库中提取信息,以达到所需的效果。

See this answer for how to pull from a remote repo. 请参阅此答案以了解如何从远程回购中提取信息。

remote repo q 远程回购q

Since you only care about merging in changes from the Gruntfile.js you can pull it specifically from the remote template repo. 由于您只关心合并Gruntfile.js中的更改,因此可以专门从远程模板存储库中提取更改。 I'd suggest following this pattern assuming you add the remote reference to you template repo when necessary: 我建议遵循此模式,假设您在必要时将远程引用添加到模板存储库中:

  1. From you project repo create a new branch 从您的项目仓库中创建一个新分支
  2. Pull the Gruntfile.js from the template repo 从模板仓库中提取Gruntfile.js
  3. Resolve any merge conflicts 解决任何合并冲突
  4. Merge with master 与主人合并

See the last answer on this question for how to pull a single file: fetch a single file 有关如何提取单个文件,请参阅此问题的最后一个答案: 获取单个文件

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM