
Security News
vlt Launches "reproduce": A New Tool Challenging the Limits of Package Provenance
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
ci-task-runner
Advanced tools
支持增量与多进程的构建任务调度器,大幅度提升 CI 服务器构建速度。
npm install ci-task-runner -g
1. 切换到项目目录,运行:
ci-task-runner --init
程序会在当前目录生成配置文件:.ci-task-runner.json。
2. 运行 ci-task-runner
ci-task-runner
在服务器上可以使用 CI 工具启动 ci-task-runner,参考: 持续集成。
.ci-task-runner.json 文件范例:
{
"tasks": ["mod1", "mod2", "mod3"],
"cache": ".ci-task-runner-cache.json",
"repository": "git",
"program": "cd ${taskPath} && webpack --color"
}
上述例子中:仓库中的 mod1、mod2、mod3 有变更则会执行 cd ${taskPath} && webpack --color
。
tasks
任务目标列表。目标可以是仓库中的任意目录或文件。
简写形式:{string[]}
{
"tasks": ["mod1", "mod2", "mod3"]
}
对象形式:{Object[]}
{
"tasks": [
"mod1",
"mod2",
{
"name": "mod3",
"dependencies": ["common/v1"],
"program": "cd ${taskPath} && gulp"
},
["mod4", "mod5"]
]
}
dependencies
与 program
会继承顶层的配置tasks
支持配置并行任务,参考 多进程并行构建cache
ci-task-runner 缓存文件保存路径,用来保存上一次构建的信息。默认为:.ci-task-runner-cache.json
请在版本库中忽略
.ci-task-runner-cache.json
。
dependencies
任务目标外部依赖列表。如果任务目标依赖了目录外的库,可以在此手动指定依赖,这样外部库的更新也可以触发任务构建。
ci-task-runner 使用 Git 或 Svn 来实现变更检测,所以其路径必须已经受版本管理。如果想监控 node_modules 的变更,可以指定:
"dependencies": ["package.json"]
。
repository
设置仓库的类型。支持 git 与 svn。
parallel
设置最大并行进程数。默认值为 require('os').cpus().length
。
program
构建器配置。
简写形式:{string}
{
"program": "cd ${taskPath} && node build.js"
}
对象形式:{Object}
{
"program": {
"command": "node build.js",
"options": {
"timeout": 360000
}
}
}
program.command
设置执行的构建命令。
程序会将
${options.cwd}/node_modules/.bin
与${process.cwd()}/node_modules/.bin
加入到环境变量PATH
中,因此可以像npm scripts
一样运行安装在本地的命令。
program.options
构建器进程配置。构建器会在子进程中运行,在这里设置进程的选项。参考:child_process.exec。
program.options
中的timeout
字段生效后会终止进程,并且抛出错误。这点和child_process.exec
不一样,它只抛出错误。
program
支持的字符串变量:
${taskName}
任务名称${taskPath}
任务目标绝对路径${taskDirname}
等同于 path.diranme(taskPath)
,详情如果任务之间没有依赖,可以开启多进程构建,这样能够充分利用多核 CPU 加速构建。
tasks 最外层的任务名是串行运行,如果遇到数组则会并行运行:
{
"tasks": ["dll", ["mod1", "mod2", "mod3"]],
"cache": "dist/.ci-task-runner-cache.json",
"repository": "git",
"program": "cd ${taskPath} && webpack --color"
}
上述例子中:当 dll 构建完成后,mod1、mod2、mod3 会以多线程的方式并行构建。
{
"tasks": ["dll", ["mod1", "mod2", "mod3"]],
"dependencies": ["dll", "package.json"],
"cache": "dist/.ci-task-runner-cache.json",
"repository": "git",
"program": "cd ${taskPath} && webpack --color"
}
上述例子中:当 dll 和 package.json 变更后,无论其他任务目标是否有修改都会被强制构建。
{
"tasks": [
{
"name": "package.json",
"program": "npm install"
},
"dll",
["mod1", "mod2", "mod3"]
],
"dependencies": ["package.json", "dll"],
"cache": "dist/.ci-task-runner-cache.json",
"repository": "git",
"program": "cd ${taskPath} && webpack --color"
}
上述例子中:当 package.json 变更后,则会执行 npm install
安装项目依赖,让项目保持最新。
使用 CI 工具来在服务器上运行 ci-task-runner。
相关工具:
CI 工具配置请参考相应的文档。
Webpack 遇到错误没退出的问题:Webpack configuration.bail
FAQs
this is a multiprocess building tasks scheduler
The npm package ci-task-runner receives a total of 5 weekly downloads. As such, ci-task-runner popularity was classified as not popular.
We found that ci-task-runner demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
Research
Security News
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
Research
The Socket Research Team discovered a malicious npm package, '@ton-wallet/create', stealing cryptocurrency wallet keys from developers and users in the TON ecosystem.