Comparing version 1.19.0 to 2.0.0
2.0.0 / 2022-06-03 | ||
================== | ||
**others** | ||
* [[`cb2f2f2`](http://github.com/eggjs/egg-ci/commit/cb2f2f2605bfb0765c6b0802fdb1f98c0e69c5b1)] - 📦 NEW: Only support GitHub Action and Node.js 14 (#37) (fengmk2 <<fengmk2@gmail.com>>) | ||
1.19.0 / 2021-09-16 | ||
@@ -3,0 +9,0 @@ ================== |
140
install.js
'use strict'; | ||
const nunjucks = require('nunjucks'); | ||
const path = require('path'); | ||
const fs = require('fs'); | ||
const nunjucks = require('nunjucks'); | ||
@@ -33,127 +33,39 @@ const engine = nunjucks.configure({ | ||
const config = Object.assign({ | ||
type: 'travis, appveyor, github', // default is travis, appveyor and github | ||
version: '', | ||
npminstall: true, | ||
const config = { | ||
version: '14, 16, 18', | ||
os: 'linux, windows, macos', | ||
npminstall: false, | ||
// auto detect nyc_output/*.json files, please use on travis windows platfrom | ||
nyc: false, | ||
license: false, | ||
}, pkg.ci); | ||
if (!('afterScript' in config)) { | ||
const codecovCMD = config.nyc ? 'codecov --disable=gcov -f .nyc_output/*.json' : 'codecov'; | ||
if (config.npminstall) { | ||
config.afterScript = ` | ||
after_script: | ||
- npminstall codecov && ${codecovCMD} | ||
`.trim(); | ||
} else { | ||
config.afterScript = ` | ||
after_script: | ||
- npm i codecov && ${codecovCMD} | ||
`.trim(); | ||
} | ||
} | ||
command: 'ci', | ||
...pkg.ci, | ||
}; | ||
config.types = arrayify(config.type); | ||
config.versions = arrayify(config.version); | ||
if (config.services) config.services = arrayify(config.services); | ||
if (config.versions.length === 0) { | ||
const installNode = pkg.engines && (pkg.engines['install-node'] || | ||
pkg.engines['install-alinode']); | ||
if (!installNode) { | ||
// default version is LTS | ||
config.versions = [ '8', '10', '12' ]; | ||
} | ||
} | ||
// if (config.services) config.services = arrayify(config.services); | ||
const defaultOS = { | ||
travis: '', | ||
'azure-pipelines': 'linux, windows, macos', | ||
github: 'linux, windows, macos', | ||
}; | ||
const os = arrayify(config.os).map(name => { | ||
if (name === 'linux') name = 'ubuntu'; | ||
return `${name}-latest`; | ||
}); | ||
if (pkg.ci && pkg.ci.os) { | ||
config.os = Object.assign(defaultOS, pkg.ci.os); | ||
} else { | ||
config.os = defaultOS; | ||
} | ||
for (const platfrom in config.os) { | ||
config.os[platfrom] = arrayify(config.os[platfrom]); | ||
} | ||
if (config.os && config.os.travis && config.os.travis.length === 0) { | ||
config.os.travis = null; | ||
} | ||
const ymlContent = getTpl('github.yml') | ||
.replace('{{github_node_version}}', config.versions.join(', ')) | ||
.replace('{{github_os}}', os.join(', ')) | ||
.replace('{{github_command_ci}}', config.command) | ||
.replace('{{github_npm_install}}', config.npminstall ? 'npm i -g npminstall && npminstall' : 'npm i'); | ||
const ymlName = '.github/workflows/nodejs.yml'; | ||
const ymlPath = path.join(root, ymlName); | ||
fs.mkdirSync(path.dirname(ymlPath), { recursive: true }); | ||
fs.writeFileSync(ymlPath, ymlContent); | ||
console.log(`[egg-ci] create ${ymlPath} success`); | ||
const originCommand = config.command; | ||
if (typeof originCommand === 'string') { | ||
config.command = { | ||
travis: originCommand, | ||
appveyor: originCommand, | ||
github: originCommand, | ||
'azure-pipelines': originCommand, | ||
}; | ||
} | ||
config.command = Object.assign({ | ||
travis: 'ci', | ||
appveyor: 'test', | ||
'azure-pipelines': 'ci', | ||
github: 'ci', | ||
}, config.command); | ||
let ymlName = ''; | ||
let ymlContent = ''; | ||
let ymlName2 = ''; | ||
let ymlContent2 = ''; | ||
for (const type of config.types) { | ||
if (type === 'travis') { | ||
ymlContent = engine.renderString(getTpl('travis'), config); | ||
ymlName = '.travis.yml'; | ||
} else if (type === 'appveyor') { | ||
ymlContent = engine.renderString(getTpl('appveyor'), config); | ||
ymlName = 'appveyor.yml'; | ||
} else if (type === 'github') { | ||
const os = config.os.github.map(name => { | ||
if (name === 'linux') name = 'ubuntu'; | ||
return `${name}-latest`; | ||
}); | ||
ymlContent = getTpl('github.yml') | ||
.replace('{{github_node_version}}', config.versions.join(', ')) | ||
.replace('{{github_os}}', os.join(', ')) | ||
.replace('{{github_command_ci}}', config.command.github) | ||
.replace('{{github_npm_install}}', config.npminstall ? 'npm i -g npminstall && npminstall' : 'npm i'); | ||
ymlName = '.github/workflows/nodejs.yml'; | ||
let dir = path.join(root, '.github'); | ||
if (!fs.existsSync(dir)) fs.mkdirSync(dir); | ||
dir = path.join(root, '.github', 'workflows'); | ||
if (!fs.existsSync(dir)) fs.mkdirSync(dir); | ||
} else if (type === 'azure-pipelines') { | ||
ymlContent = engine.renderString(getTpl('azure-pipelines.yml'), config); | ||
ymlName = 'azure-pipelines.yml'; | ||
ymlContent2 = engine.renderString(getTpl('azure-pipelines.template.yml'), config); | ||
ymlName2 = 'azure-pipelines.template.yml'; | ||
} else { | ||
throw new Error(`${type} type not support`); | ||
} | ||
const ymlPath = path.join(root, ymlName); | ||
fs.writeFileSync(ymlPath, ymlContent); | ||
console.log(`[egg-ci] create ${ymlPath} success`); | ||
if (ymlName2) { | ||
const ymlPath2 = path.join(root, ymlName2); | ||
fs.writeFileSync(ymlPath2, ymlContent2); | ||
console.log(`[egg-ci] create ${ymlPath2} success`); | ||
} | ||
} | ||
if (config.license) { | ||
let data = { | ||
const data = { | ||
year: '2017', | ||
fullname: 'Alibaba Group Holding Limited and other contributors.', | ||
...config.license, | ||
}; | ||
if (typeof config.license === 'object') { | ||
data = Object.assign(data, config.license); | ||
} | ||
if (Number(data.year) < new Date().getFullYear()) { | ||
data.year = `${data.year}-present`; | ||
} | ||
data.year = `${data.year}-present`; | ||
const licenseContent = engine.renderString(getTpl('license'), data); | ||
@@ -160,0 +72,0 @@ const licensePath = path.join(root, 'LICENSE'); |
{ | ||
"name": "egg-ci", | ||
"version": "1.19.0", | ||
"version": "2.0.0", | ||
"description": "Auto gen ci config file", | ||
@@ -11,5 +11,6 @@ "main": "index.js", | ||
"scripts": { | ||
"contributor": "git-contributor", | ||
"env": "node -e 'console.log(process.env)'", | ||
"test": "ava", | ||
"cov": "nyc ava && nyc report --reporter=json --reporter=lcov", | ||
"test": "node--test", | ||
"cov": "c8 node--test && c8 report --reporter=json --reporter=lcov", | ||
"lint": "eslint *.js test --fix", | ||
@@ -19,12 +20,10 @@ "ci": "npm run lint && npm run cov", | ||
"postinstall": "node install.js", | ||
"postinstall-local": "CI_ROOT_FOR_TEST=$PWD node install.js", | ||
"autod": "autod -w --prefix='^'" | ||
"postinstall-local": "CI_ROOT_FOR_TEST=$PWD node install.js" | ||
}, | ||
"keywords": [ | ||
"egg", | ||
"travis", | ||
"appveyor", | ||
"github action", | ||
"ci" | ||
], | ||
"author": "fengmk2 <fengmk2@gmail.com> (https://fengmk2.com)", | ||
"author": "fengmk2 <fengmk2@gmail.com> (https://github.com/fengmk2)", | ||
"repository": { | ||
@@ -42,23 +41,14 @@ "type": "git", | ||
"devDependencies": { | ||
"autod": "2", | ||
"ava": "^0.25.0", | ||
"eslint": "3", | ||
"eslint-config-egg": "3", | ||
"nyc": "10", | ||
"rimraf": "^2.6.2" | ||
"c8": "7", | ||
"eslint": "8", | ||
"eslint-config-egg": "11", | ||
"git-contributor": "1", | ||
"test": "3" | ||
}, | ||
"engine": { | ||
"node": ">=8.0.0" | ||
"node": ">=14.0.0" | ||
}, | ||
"ava": { | ||
"files": [ | ||
"test/**/*.test.js" | ||
] | ||
}, | ||
"ci": { | ||
"type": "github", | ||
"version": "10, 12, 14, 16", | ||
"os": { | ||
"github": "linux, macos, windows" | ||
}, | ||
"version": "14, 16, 18", | ||
"os": "linux, macos, windows", | ||
"nyc": true, | ||
@@ -65,0 +55,0 @@ "license": { |
@@ -5,6 +5,4 @@ egg-ci | ||
[![NPM version][npm-image]][npm-url] | ||
[![build status][travis-image]][travis-url] | ||
[![Build Status](https://dev.azure.com/eggjs/egg/_apis/build/status/eggjs.egg-ci)](https://dev.azure.com/eggjs/egg/_build/latest?definitionId=3) | ||
[![Node.js CI](https://github.com/eggjs/egg-ci/actions/workflows/nodejs.yml/badge.svg)](https://github.com/eggjs/egg-ci/actions/workflows/nodejs.yml) | ||
[![Test coverage][codecov-image]][codecov-url] | ||
[![David deps][david-image]][david-url] | ||
[![npm download][download-image]][download-url] | ||
@@ -14,12 +12,8 @@ | ||
[npm-url]: https://npmjs.org/package/egg-ci | ||
[travis-image]: https://img.shields.io/travis/eggjs/egg-ci.svg?style=flat-square | ||
[travis-url]: https://travis-ci.org/eggjs/egg-ci | ||
[codecov-image]: https://codecov.io/github/eggjs/egg-ci/coverage.svg?branch=master | ||
[codecov-url]: https://codecov.io/github/eggjs/egg-ci?branch=master | ||
[david-image]: https://img.shields.io/david/eggjs/egg-ci.svg?style=flat-square | ||
[david-url]: https://david-dm.org/eggjs/egg-ci | ||
[download-image]: https://img.shields.io/npm/dm/egg-ci.svg?style=flat-square | ||
[download-url]: https://npmjs.org/package/egg-ci | ||
Auto gen ci config file. | ||
Auto gen [GitHub Action](https://github.com/features/actions) ci config file. | ||
@@ -38,17 +32,7 @@ ## Installation | ||
"ci": { | ||
"type": "github", // default ci env type is 'travis, appveyor', also support 'github, azure-pipelines' | ||
"os": { | ||
"travis": "linux", // travis support 'linux', 'osx' and 'windows' operation system, default is 'linux' | ||
"azure-pipelines": "linux, windows, macos", // azure-pipelines support 'linux, windows, macos', default is 'linux, windows, macos' | ||
"github": "linux, windows, macos" | ||
}, | ||
"npminstall": true, // use `npminstall` or `npm install`, default is true | ||
"version": "12, 14, 16", // test LTS node version by default | ||
"os": "linux, windows, macos", | ||
"npminstall": false, // use `npminstall` or `npm install`, default is false | ||
"version": "14, 16, 18", // test LTS node version by default | ||
// npm ci command | ||
"command": { | ||
"travis": "ci", | ||
"appveyor": "test", | ||
"azure-pipelines": "ci", | ||
"github": "ci" | ||
}, | ||
"command": "ci", | ||
"services": "redis-server, mysql", // custom service | ||
@@ -66,1 +50,12 @@ "license": false // generate license | ||
[MIT](LICENSE) | ||
<!-- GITCONTRIBUTOR_START --> | ||
## Contributors | ||
|[<img src="https://avatars.githubusercontent.com/u/156269?v=4" width="100px;"/><br/><sub><b>fengmk2</b></sub>](https://github.com/fengmk2)<br/>|[<img src="https://avatars.githubusercontent.com/u/227713?v=4" width="100px;"/><br/><sub><b>atian25</b></sub>](https://github.com/atian25)<br/>|[<img src="https://avatars.githubusercontent.com/u/985607?v=4" width="100px;"/><br/><sub><b>dead-horse</b></sub>](https://github.com/dead-horse)<br/>|[<img src="https://avatars.githubusercontent.com/u/360661?v=4" width="100px;"/><br/><sub><b>popomore</b></sub>](https://github.com/popomore)<br/>|[<img src="https://avatars.githubusercontent.com/u/5243774?v=4" width="100px;"/><br/><sub><b>ngot</b></sub>](https://github.com/ngot)<br/>|[<img src="https://avatars.githubusercontent.com/u/958063?v=4" width="100px;"/><br/><sub><b>thonatos</b></sub>](https://github.com/thonatos)<br/>| | ||
| :---: | :---: | :---: | :---: | :---: | :---: | | ||
[<img src="https://avatars.githubusercontent.com/in/9426?v=4" width="100px;"/><br/><sub><b>azure-pipelines[bot]</b></sub>](https://github.com/apps/azure-pipelines)<br/>|[<img src="https://avatars.githubusercontent.com/u/26563778?v=4" width="100px;"/><br/><sub><b>ahungrynoob</b></sub>](https://github.com/ahungrynoob)<br/>|[<img src="https://avatars.githubusercontent.com/u/24246985?v=4" width="100px;"/><br/><sub><b>zhennann</b></sub>](https://github.com/zhennann)<br/> | ||
This project follows the git-contributor [spec](https://github.com/xudafeng/git-contributor), auto updated at `Fri Jun 03 2022 17:58:16 GMT+0800`. | ||
<!-- GITCONTRIBUTOR_END --> |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5
14956
7
71
58