使用没有package.json的任务运行器 [英] Using a task runner without package.json
问题描述
我正在评估任务运行者,特别是Grunt和Gulp,但是我不喜欢他们两个:事实上他们需要一个 package.json
文件为您的项目。这是即使您的项目可能不是首先npm项目。在我的例子中,我已经使用 composer.json
,它基本上完全一样。
I结束创建我的 package.json
像这样:
{
name:myproject,
version:0.0.0,
devDependencies:{
grunt:〜0.4.5,
grunt-phpcs:〜0.2.3,
grunt-phplint:0.0.5,
grunt-phpdocumentor:〜0.4.1
}
}
请注意,我没有保留版本号,因为这是不必要的开销尽管如此,我可以在执行 npm install
之后运行我的grunt任务。我觉得我应该可以不用这个文件。我读过可以在不使用 package.json
的情况下使用Grunt,但我认为您必须手动安装节点模块,这会花费更多的开销。 Gulp也不例外,或者至少我没有发现相反的证据。所以问题是,有没有任何跑步者不需要你定义你的项目的元数据两次,只需要一个文件,而不是太大出血的边缘?
回答我自己,我能找到的唯一符合我要求的东西是 bldr 。它基于PHP,使用composer作为包管理后端,并且不会劫持您可能已经使用的 composer.json
,因为它使用 bldr .json
代替。它也不要求你将元数据添加到描述你的bldr依赖关系的文件中。以下是一个示例依赖项文件(摘自 http://docs.bldr.io/en/latest
{
require:{
acme / demo-block:@stable
}
}
然后,当你运行 bldr install
时,你的依赖被安装,你可以运行你的bldr任务。
I'm evaluating task runners, Grunt and Gulp in particular, but there's one thing I dislike about both of them: the fact that they require a package.json
file for your project. This is even though your project might not even be an npm project in the first place. In my case, I'm already using composer.json
, which basically does the exact same thing.
I ended up creating my package.json
like this:
{
"name": "myproject",
"version": "0.0.0",
"devDependencies": {
"grunt": "~0.4.5",
"grunt-phpcs": "~0.2.3",
"grunt-phplint": "0.0.5",
"grunt-phpdocumentor": "~0.4.1"
}
}
Note that I'm not maintaining the version number, as that is unnecessary overhead. This works though, in the sense that I can run my grunt tasks after executing npm install
. I feel that I should be able to do without this file though. I read that it's possible to use Grunt without a package.json
, but my take is that you'd then have to install the node modules manually, which is more overhead. Gulp is no different, or at least I found no evidence to the contrary.
So the question is, are there any task runners that don't require you to define your project's metadata twice, need only a single file, and are not too bleeding edge?
Answering myself, the only thing I could find that seems to fit my requirements is bldr. It is PHP based, uses composer as package management backend, and does it without hijacking the composer.json
you might already be using, as it uses bldr.json
instead. It also does not require you to add metadata to the file that describes your bldr dependencies. Here's an example dependencies file (taken from http://docs.bldr.io/en/latest/blocks.html):
{
"require": {
"acme/demo-block": "@stable"
}
}
Then, when you run bldr install
, your dependencies are installed and you can run your bldr tasks.
这篇关于使用没有package.json的任务运行器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!