New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

ci-task-runner

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ci-task-runner - npm Package Compare versions

Comparing version 1.0.0-beta2 to 1.0.0

example/dist/.ci-task-runner-cache.json

8

lib/repository.js

@@ -126,3 +126,3 @@ const path = require('path');

if (type === 'git') {
cmd = `git log --pretty=format:"%h" -1 -- ${basename}`;
cmd = `git log --pretty=format:"%h" -1 -- ${JSON.stringify(basename)}`;
runner = exec(cmd, {

@@ -132,3 +132,3 @@ cwd

} else if (type === 'svn') {
cmd = `svn log --limit 1 --xml ${basename}`;
cmd = `svn log --limit 1 --xml ${JSON.stringify(basename)}`;
runner = exec(cmd, {

@@ -142,7 +142,7 @@ cwd

} else {
runner = Promise.reject(`does not support "${type}".`);
runner = Promise.reject(new Error(`does not support "${type}".`));
}
runner.catch(errors => {
console.error(`"${target}": the file is not in the repository.`);
errors.message = `"${target}" is not in the repository: ${errors.message}`;
return Promise.reject(errors);

@@ -149,0 +149,0 @@ });

@@ -22,3 +22,5 @@ const fs = require('fs');

// 子进程继承父进程的环境变量
options = defaultsDeep({}, options, { env: process.env });
options = defaultsDeep({}, options, {
env: process.env
});
options.env[WORKER_ENV] = '1';

@@ -68,3 +70,3 @@

} else {
callback(new Error(`"${command}": child process exited with code ${code}.`));
callback(new Error(`exec "${command}": child process exited with code ${code}`));
}

@@ -77,3 +79,3 @@ });

timer = setTimeout(() => {
callback(new Error(`"${command}": child process timeout.`));
callback(new Error(`exec "${command}": child process timeout`));
child.kill();

@@ -94,3 +96,3 @@ }, options.timeout);

if (errors) {
console.error(`> ${command}`);
errors.messsage = `exec "${command}": ${errors.messsage}`;
reject(errors);

@@ -97,0 +99,0 @@ } else {

{
"name": "ci-task-runner",
"version": "1.0.0-beta2",
"description": "支持增量与多进程的构建任务调度器",
"main": "src/index.js",
"bin": "bin/ci-task-runner",
"scripts": {
"example": "bin/ci-task-runner --config example/.ci-task-runner.json",
"parallel-test": "node test/file/parallel/index.js",
"tasks-test": "bin/ci-task-runner --config test/file/tasks/.ci-task-runner.json",
"test": "export TEST_DIST=$PWD/test/dist && mocha --recursive --bail 'test/**/*test.js'",
"posttest": "npm run example && npm run tasks-test",
"clear": "rm -rf example/dist & rm -rf test/dist",
"new-test": "npm run clear && npm run test"
},
"repository": {
"type": "git",
"url": "git+https://github.com/aui/ci-task-runner.git"
},
"engines": {
"node": ">= 6.0.0"
},
"keywords": [
"webpack",
"gulp",
"grunt",
"ci",
"git",
"svn",
"task",
"build"
],
"author": "糖饼",
"license": "ISC",
"bugs": {
"url": "https://github.com/aui/ci-task-runner/issues"
},
"homepage": "https://github.com/aui/ci-task-runner#readme",
"dependencies": {
"commander": "^2.9.0",
"lodash.defaultsdeep": "^4.6.0"
},
"devDependencies": {
"jquery": "^3.1.1",
"mocha": "^3.1.2",
"webpack": "^1.13.3"
}
}
"name": "ci-task-runner",
"version": "1.0.0",
"description": "在 CI 上运行的、支持增量与多进程并行构建任务调度程序",
"main": "src/index.js",
"bin": "bin/ci-task-runner",
"scripts": {
"example": "node bin/ci-task-runner --config example/.ci-task-runner.json",
"parallel-test": "node test/file/parallel/index.js",
"tasks-test": "node bin/ci-task-runner --config test/file/tasks/.ci-task-runner.json",
"test": "export TEST_DIST=$PWD/test/dist && istanbul cover node_modules/mocha/bin/_mocha -- --recursive --bail 'test/**/*test.js'",
"posttest": "npm run example && npm run tasks-test",
"clear": "rm -rf example/dist & rm -rf test/dist",
"new-test": "npm run clear && npm run test",
"coverage": "cat ./coverage/lcov.info | coveralls"
},
"repository": {
"type": "git",
"url": "git+https://github.com/aui/ci-task-runner.git"
},
"engines": {
"node": ">= 6.0.0"
},
"keywords": [
"webpack",
"gulp",
"grunt",
"ci",
"git",
"svn",
"task",
"build"
],
"author": "糖饼",
"license": "MIT",
"bugs": {
"url": "https://github.com/aui/ci-task-runner/issues"
},
"homepage": "https://github.com/aui/ci-task-runner#readme",
"dependencies": {
"commander": "^2.9.0",
"lodash.defaultsdeep": "^4.6.0"
},
"devDependencies": {
"jquery": "^3.1.1",
"mocha": "^3.1.2",
"webpack": "^1.13.3",
"istanbul": "^0.4.5",
"coveralls": "^2.13.0"
}
}
# ci-task-runner
[![NPM Version][npm-image]][npm-url]
[![NPM Downloads][downloads-image]][downloads-url]
[![Node.js Version][node-version-image]][node-version-url]
[![Build Status][travis-ci-image]][travis-ci-url]
[![NPM Version](https://img.shields.io/npm/v/ci-task-runner.svg)](https://npmjs.org/package/ci-task-runner)
[![NPM Downloads](http://img.shields.io/npm/dm/ci-task-runner.svg)](https://npmjs.org/package/ci-task-runner)
[![Node.js Version](https://img.shields.io/node/v/ci-task-runner.svg)](http://nodejs.org/download/)
[![Travis-ci](https://travis-ci.org/huanleguang/ci-task-runner.svg?branch=master)](https://travis-ci.org/huanleguang/ci-task-runner)
[![Coverage Status](https://coveralls.io/repos/github/huanleguang/ci-task-runner/badge.svg)](https://coveralls.io/github/huanleguang/ci-task-runner)
这是一个基于 NodeJS 编写的多进程构建任务调度器,它支持增量与并行构建,可以大幅度提高服务器端构建速度。
[[English]](./README.md) - [[简体中文]](./README.ZH-CN.md)
ci-task-runner 作为一个通用的任务调度器,它并不是为了取代 Jenkins、Gitlab-CI 等持续集成工具或 Webpack、Gulp 等构建程序,而是提高它们运行任务的速度。
This is a multiprocess building tasks scheduler, which is written based on NodeJS. It supports the increment and parallel building and can improve the speed of server building largely.
> “我们将一个大型前端项目迁移到持续集成系统进行构建后,每修改一个小文件都需要近 10 分钟的时间才能完成构建完成,于是我们开发了 ci-task-runner,将这个过程缩短到 10 秒左右”
As a common task scheduler, Ci-task-runner enhances the running speed of the tools such as Jenkins, Gitlab-CI or Webpack, Gulp rather than take place of them.
## 原理
> "After moving a large frond-end program to this continuous integration system for building, we took around 10 minutes to modify every minor file. We had to develop this ci-task-runner which reduces the time to 1 minutes."
1\. **增量构建**:
## Principle
在中大型项目中,如果因为修改一个小文件就需要全量构建,这样构建速度必然会非常慢。为了解决这个问题,ci-task-runner 会对比 Git 或 Svn 的提交记录,只构建有差异的文件。
1\. **Incremental Building**:
2\. **并行构建**:
Medium and large project needs full dose building if a little file has changed, in this way the building speed will be very slow. For sloving this problem, ci-task-runner diff commit logs of Git or Svn and building changed file.
如果有多个任务需要执行,ci-task-runner 会根据当前服务器 CPU 核心的数量启动新的进程,以多进程并行运行的方式加快任务完成。
2\. **Parallel Building**:
## 安装
If multiple tasks be executed, ci-task-runner will initiate a new process according to current server's CPU quantities, using mutiprocess parallel building to finish tasks quickly.
## Installation
```shell
npm install ci-task-runner@1.0.0-beta2 -g
npm install ci-task-runner -g
```
## 入门
## Basic Usage
Ci-task-runner's tasks are defined in the JSON, in the project to create a new `.ci-task-runner.json` file, example:
ci-task-runner 的任务都是在 JSON 配置文件定义的,在项目中新建一个 `.ci-task-runner.json` 配置,范例:
```json

@@ -43,4 +45,5 @@ {

然后在项目目录运行命令即可执行上述定义的 `tasks`:
And then run the command in the project directory to perform the above defined `tasks`
```shell

@@ -50,15 +53,15 @@ ci-task-runner

上述例子中:仓库中的 mod1、mod2、mod3 目录有变更则会依次执行 `cd ${taskPath} && webpack --color`。
Above-mentioned: mod1、mod2、mod3 will run `cd ${taskPath} && webpack --color` ordered by catelogue changed.
通过入门教程可以看到,ci-task-runner 的任务概念与其他任务运行器最大的不同是:每一个任务都是基于代码仓库中的文件或文件夹。
According basic usage, the most difference between the task concept of ci-task-runner and other task executors is that each task is based on a file or folder in the code repository.
> 在服务器上可以使用 CI 工具启动 ci-task-runner,参考: [持续集成](#持续集成)。
> Using CI tools run ci-task-runner On the server, reference: [Continuous integration](#continuous-integration).
## 配置
## Configuration
### `tasks`
任务目标列表。目标可以是仓库中的任意目录或文件。
Task target list, the target can be any directory or file in the repository.
简写形式:`{string[]}`
Simplified: `{string[]}`

@@ -71,3 +74,3 @@ ```json

进阶形式:`{Object[]}`
Advanced: `{Object[]}`

@@ -89,30 +92,29 @@ ```json

1. [`dependencies`](#dependencies) 与 [`program`](#program) 会继承顶层的配置,也可以覆盖它们
2. [`tasks`](#tasks) 支持配置并行任务,参考 [多进程并行任务](#多进程并行任务)
1. [`dependencies`](#dependencies) and [`program`](#program) will inherit the top of the configuration, or cover it.
2. [`tasks`](#tasks) support configure parallel tasks, reference: [Mutiprocess Parallel Tasks](#mutiprocess-parallel-tasks).
### `cache`
ci-task-runner cache files write path, used to save the last task info. Default: `ci-task-runner-cache.json`
ci-task-runner 缓存文件写入路径,用来保存上一次任务的信息。默认为:`.ci-task-runner-cache.json`
> Ignore `.ci-task-runner-cache.json` in repository.
> 请在代码仓库库中忽略 `.ci-task-runner-cache.json`。
### `dependencies`
任务目标外部依赖列表。如果任务目标依赖了目录外的库,可以在此手动指定依赖,这样外部库的变更也可以触发任务运行。
Task target external dependency list. If the task target relies on a library outside the directory, you can specify the dependency manually, so that changes to the external library can also trigger the task to run.
> ci-task-runner 使用 Git 或 Svn 来实现变更检测,所以其路径必须已经受版本管理。
> ci-task-runner use Git or Svn to realize changed detection, so the path must already be versioned
### `repository`
设置仓库的类型。支持 git 与 svn。
Setting the type of repository. Support Git and Svn.
### `parallel`
设置最大并行进程数。默认值为 `require('os').cpus().length`。
Set the maximum number of parallel progress. Default: `require('os').cpus().length`.
### `program`
执行任务的程序配置。
Running task's configuration.
简写形式:`{string}`
Simplified: `{string}`

@@ -125,3 +127,3 @@ ```json

进阶形式:`{Object}`
Advanced: `{Object}`

@@ -142,27 +144,27 @@ ```json

设置执行的命令。
Setting start command.
> 程序会将 `${options.cwd}/node_modules/.bin` 与 `${process.cwd()}/node_modules/.bin` 加入到环境变量 `PATH` 中,因此可以像 `npm scripts` 一样运行安装在本地的命令。
> program will put `${options.cwd}/node_modules/.bin` and `${process.cwd()}/node_modules/.bin` in environment variable `PATH`, like `npm scripts` install on local.
#### `program.options`
进程配置。参考:[child_process.exec](https://nodejs.org/api/child_process.html#child_process_child_process_exec_command_options_callback)。
Progress configuration. Reference: [child_process.exec](https://nodejs.org/api/child_process.html#child_process_child_process_exec_command_options_callback).
> `program.options` 中的 `timeout` 字段生效后会终止进程,并且抛出错误。这点和 `child_process.exec` 不一样,它只抛出错误。
> The `timeout` field in `program.options` takes effect and terminates the process and throws an error. `child_process.exec` only throw error.
#### 变量
#### Variable
`program` 支持的字符串变量:
`program` supporting string variable.
* `${taskName}` 任务名称
* `${taskPath}` 任务目标绝对路径
* `${taskDirname}` 等同于 `path.diranme(taskPath)`,[详情](https://nodejs.org/api/path.html#path_path_dirname_path)
* `${taskName}` task name
* `${taskPath}` task target absolute path
* `${taskDirname}` equal to `path.diranme(taskPath)`,[detail](https://nodejs.org/api/path.html#path_path_dirname_path)
## 配置范例
## Configuration Example
### 多进程并行任务
### Mutiprocess Parallel Tasks
如果任务之间没有依赖,可以开启多进程运行任务,这样能够充分利用多核 CPU 加速运行。
If tasks have no dependencies in each other, it can open mutiprocess run task, then take full advantage of multi-core CPU accelerating running.
tasks 最外层的任务名是串行运行,如果遇到数组则会并行运行:
Tasks outside task name is serial run, if array will parallel running:

@@ -178,5 +180,5 @@ ```json

上述例子中:当 dll 构建完成后,mod1、mod2、mod3 会以多线程的方式并行构建。
Above-mentioned: when dll has build, mod1、mod2、mod3 will parallel building by multi-thread.
### 依赖变更触发构建
### Change Dependencies Trigger Buliding

@@ -193,5 +195,5 @@ ```json

上述例子中:当 dll 和 package.json 变更后,无论其他任务目标是否有修改都会被强制构建。
Above-mentioned: when dll and package.json has changed, whatever other task's target has changed or not it will be forced to building.
### 自动更新 Npm 包
### Auto Updating Npm Packages

@@ -215,9 +217,9 @@ ```json

上述例子中:当 package.json 变更后,则会执行 `npm install` 安装项目依赖,让项目保持最新。
Above-mentioned: when package.json has changed, it will run `npm install` to install dependencies to keep project up-to-date.
## 持续集成
## Continuous integration
使用 CI 工具来在服务器上运行 ci-task-runner。
Using CI tool to run ci-task-runner on server-site.
**相关工具:**
**About:**

@@ -228,13 +230,8 @@ * gitlab: gitlab-ci

CI 工具配置请参考相应的文档。
CI configuration can refer to relative API.
> Webpack 遇到错误没退出的问题解决方案:[Webpack configuration.bail](http://webpack.github.io/docs/configuration.html#bail)
> Webpack throw error but didn't exit: [Webpack configuration.bail](http://webpack.github.io/docs/configuration.html#bail)
[npm-image]: https://img.shields.io/npm/v/ci-task-runner.svg
[npm-url]: https://npmjs.org/package/ci-task-runner
[node-version-image]: https://img.shields.io/node/v/ci-task-runner.svg
[node-version-url]: http://nodejs.org/download/
[downloads-image]: https://img.shields.io/npm/dm/ci-task-runner.svg
[downloads-url]: https://npmjs.org/package/ci-task-runner
[travis-ci-image]: https://travis-ci.org/aui/ci-task-runner.svg?branch=master
[travis-ci-url]: https://travis-ci.org/aui/ci-task-runner
## License
[MIT](./LICENSE)

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc