|
1 |
| -const {concurrent, series} = require('nps-utils') |
| 1 | +const { |
| 2 | + concurrent, |
| 3 | + crossEnv, |
| 4 | + ifNotWindows, |
| 5 | + ifWindows, |
| 6 | + mkdirp, |
| 7 | + series, |
| 8 | + setColors, |
| 9 | +} = require('nps-utils') |
| 10 | +const pjson = require('./package.json') |
| 11 | +const release = pjson.devDependencies.typedoc ? ['ci.release.semantic-release', 'ci.release.typedoc'] : ['ci.release.semantic-release'] |
| 12 | +const script = (script, description) => description ? {script, description} : {script} |
| 13 | +const hidden = script => ({script, hiddenFromHelp: true}) |
| 14 | +const unixOrWindows = (unix, windows) => series(ifNotWindows(unix), ifWindows(windows)) |
| 15 | + |
| 16 | +setColors(['dim']) |
| 17 | + |
| 18 | +let ciTests = [ |
| 19 | + 'ci.test.eslint', |
| 20 | + 'ci.test.mocha', |
| 21 | + 'ci.test.tslint', |
| 22 | +] |
2 | 23 |
|
3 | 24 | module.exports = {
|
4 | 25 | scripts: {
|
5 | 26 | build: 'rm -rf lib && tsc',
|
6 | 27 | lint: {
|
7 | 28 | default: concurrent.nps('lint.eslint', 'lint.commitlint', 'lint.tsc', 'lint.tslint'),
|
8 |
| - eslint: { |
9 |
| - script: 'eslint .', |
10 |
| - description: 'lint js files', |
11 |
| - }, |
12 |
| - commitlint: { |
13 |
| - script: 'commitlint --from origin/master', |
14 |
| - description: 'ensure that commits are in valid conventional-changelog format', |
15 |
| - }, |
16 |
| - tsc: { |
17 |
| - script: 'tsc -p test --noEmit', |
18 |
| - description: 'syntax check with tsc', |
19 |
| - }, |
20 |
| - tslint: { |
21 |
| - script: 'tslint -p test', |
22 |
| - description: 'lint ts files', |
23 |
| - }, |
| 29 | + eslint: script('eslint .', 'lint js files'), |
| 30 | + commitlint: script('commitlint --from origin/master', 'ensure that commits are in valid conventional-changelog format'), |
| 31 | + tsc: script('tsc -p test --noEmit', 'syntax check with tsc'), |
| 32 | + tslint: script('tslint -p test', 'lint ts files'), |
24 | 33 | },
|
25 | 34 | test: {
|
26 |
| - default: { |
27 |
| - script: concurrent.nps('lint', 'test.mocha'), |
28 |
| - description: 'lint and run all tests', |
29 |
| - }, |
| 35 | + default: script(concurrent.nps('lint', 'test.mocha'), 'lint and run all tests'), |
| 36 | + series: script(series.nps('lint', 'test.mocha'), 'lint and run all tests in series'), |
30 | 37 | mocha: {
|
31 |
| - script: 'mocha "test/**/*.test.ts"', |
32 |
| - description: 'run all mocha tests', |
| 38 | + default: script('mocha --forbid-only "test/**/*.test.ts"', 'run all mocha tests'), |
| 39 | + coverage: { |
| 40 | + default: hidden(series.nps('test.mocha.nyc nps test.mocha', 'test.mocha.coverage.report')), |
| 41 | + report: hidden(series('nps "test.mocha.nyc report --reporter text-lcov" > coverage.lcov')), |
| 42 | + }, |
| 43 | + junit: hidden(series( |
| 44 | + crossEnv('MOCHA_FILE="reports/mocha.xml" ') + series.nps('test.mocha.nyc nps \\"test.mocha --reporter mocha-junit-reporter\\"'), |
| 45 | + series.nps('test.mocha.coverage.report'), |
| 46 | + )), |
| 47 | + nyc: hidden('nyc --nycrc-path node_modules/@dxcli/dev-nyc-config/.nycrc'), |
33 | 48 | },
|
34 | 49 | },
|
35 | 50 | ci: {
|
36 |
| - default: { |
37 |
| - script: concurrent.nps( |
38 |
| - 'ci.mocha', |
39 |
| - 'ci.eslint', |
40 |
| - 'ci.tslint', |
| 51 | + test: { |
| 52 | + default: hidden(series( |
| 53 | + mkdirp('reports'), |
| 54 | + unixOrWindows( |
| 55 | + concurrent.nps(...ciTests), |
| 56 | + series.nps(...ciTests), |
| 57 | + ), |
| 58 | + )), |
| 59 | + mocha: hidden( |
| 60 | + unixOrWindows( |
| 61 | + series.nps('test.mocha.junit'), |
| 62 | + series.nps('test.mocha.coverage'), |
| 63 | + ) |
| 64 | + ), |
| 65 | + eslint: hidden( |
| 66 | + unixOrWindows( |
| 67 | + series.nps('lint.eslint --format junit --output-file reports/eslint.xml'), |
| 68 | + series.nps('lint.eslint'), |
| 69 | + ) |
| 70 | + ), |
| 71 | + tslint: hidden( |
| 72 | + unixOrWindows( |
| 73 | + series.nps('lint.tslint --format junit > reports/tslint.xml'), |
| 74 | + series.nps('lint.tslint'), |
| 75 | + ) |
41 | 76 | ),
|
42 |
| - hiddenFromHelp: true, |
43 |
| - }, |
44 |
| - mocha: { |
45 |
| - default: { |
46 |
| - script: series.nps('ci.mocha.test', 'ci.mocha.report'), |
47 |
| - hiddenFromHelp: true, |
48 |
| - }, |
49 |
| - test: { |
50 |
| - script: 'MOCHA_FILE="reports/mocha.xml" nps "ci.mocha.nyc nps \\"test.mocha --reporter mocha-junit-reporter\\""', |
51 |
| - hiddenFromHelp: true, |
52 |
| - }, |
53 |
| - report: { |
54 |
| - script: series.nps('ci.mocha.nyc report --reporter text-lcov > coverage.lcov'), |
55 |
| - hiddenFromHelp: true, |
56 |
| - }, |
57 |
| - nyc: { |
58 |
| - script: 'nyc --nycrc-path node_modules/@dxcli/dev-nyc-config/.nycrc', |
59 |
| - hiddenFromHelp: true, |
60 |
| - }, |
61 |
| - }, |
62 |
| - eslint: { |
63 |
| - script: series.nps('lint.eslint --format junit --output-file reports/eslint.xml'), |
64 |
| - hiddenFromHelp: true, |
65 |
| - }, |
66 |
| - tslint: { |
67 |
| - script: series.nps('lint.tslint --format junit > reports/tslint.xml'), |
68 |
| - hiddenFromHelp: true, |
69 | 77 | },
|
| 78 | + typedoc: hidden('typedoc --out /tmp/docs src/index.ts --excludeNotExported --mode file'), |
70 | 79 | release: {
|
71 |
| - script: 'dxcli-dev-semantic-release', |
72 |
| - hiddenFromHelp: true, |
| 80 | + default: hidden(series.nps(...release)), |
| 81 | + 'semantic-release': hidden('semantic-release -e @dxcli/dev-semantic-release'), |
| 82 | + typedoc: hidden(series( |
| 83 | + 'git clone -b gh-pages $CIRCLE_REPOSITORY_URL gh-pages', |
| 84 | + 'nps ci.typedoc', |
| 85 | + 'rm -rf ./gh-pages/*', |
| 86 | + 'mv /tmp/docs/* ./gh-pages', |
| 87 | + 'cd gh-pages && git add . && git commit -m "updates from $CIRCLE_SHA1 [skip ci]" && git push', |
| 88 | + )), |
73 | 89 | },
|
74 | 90 | },
|
75 | 91 | },
|
|
0 commit comments