aberlaas 2.2.0 → 2.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +9 -0
- package/README.md +1 -19
- package/commands/ci/index.js +14 -99
- package/commands/init/index.js +322 -205
- package/commands/lint/css.js +2 -2
- package/commands/lint/helpers/prettier.js +2 -2
- package/commands/lint/index.js +3 -2
- package/commands/lint/js.js +1 -1
- package/commands/precommit/index.js +4 -3
- package/commands/setup/index.js +0 -12
- package/commands/test/index.js +56 -48
- package/configs/eslint.cjs +9 -2
- package/configs/lintstaged.js +25 -0
- package/configs/node.cjs +4 -0
- package/configs/{prettier.cjs → prettier.js} +1 -1
- package/configs/{stylelint.cjs → stylelint.js} +1 -1
- package/configs/vite.js +9 -2
- package/main.js +31 -2
- package/package.json +24 -23
- package/templates/_circleci/config.yml +0 -1
- package/templates/_eslintignore.conf +4 -1
- package/templates/_gitattributes +4 -0
- package/templates/_gitignore +29 -0
- package/templates/lerna.json +6 -0
- package/templates/lib/__tests__/main.js +7 -5
- package/templates/lib/main.js +2 -2
- package/templates/lintstaged.config.js +4 -0
- package/templates/prettier.config.js +4 -0
- package/templates/scripts/ci +3 -1
- package/templates/scripts/compress +2 -2
- package/templates/scripts/docs/build +4 -0
- package/templates/scripts/docs/build-prod +4 -0
- package/templates/scripts/docs/cms +4 -0
- package/templates/scripts/docs/serve +4 -0
- package/templates/scripts/hooks/pre-commit +1 -1
- package/templates/scripts/lib/release +5 -0
- package/templates/scripts/lib/test +4 -0
- package/templates/scripts/lib/test-watch +4 -0
- package/templates/scripts/lint +2 -2
- package/templates/scripts/lint-fix +2 -2
- package/templates/stylelint.config.js +4 -0
- package/templates/vite.config.js +2 -2
- package/commands/ci/autoRelease.js +0 -143
- package/commands/release/index.js +0 -76
- package/commands/setup/autoRelease/envVars.js +0 -56
- package/commands/setup/autoRelease/index.js +0 -59
- package/commands/setup/autoRelease/privateKey.js +0 -41
- package/commands/setup/autoRelease/publicKey.js +0 -55
- package/configs/lintstaged.cjs +0 -31
- package/templates/_lintstagedrc.cjs +0 -4
- package/templates/_prettierrc.cjs +0 -4
- package/templates/_stylelintrc.cjs +0 -4
- package/templates/scripts/release +0 -4
- package/templates/scripts/test +0 -4
- package/templates/scripts/test-watch +0 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) {author}
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
|
+
|
|
7
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
CHANGED
|
@@ -161,24 +161,6 @@ what most free CI tier offer). If you have access to higher end machines, you
|
|
|
161
161
|
can update this value by passing the `--cpu-count=X` flag to your `aberlaas ci`
|
|
162
162
|
call.
|
|
163
163
|
|
|
164
|
-
### Auto-Releasing
|
|
165
|
-
|
|
166
|
-
As an optional feature, you can have aberlaas automatically release a new
|
|
167
|
-
version of your module from the CI environment when relevant.
|
|
168
|
-
|
|
169
|
-
The CI will then check all the commits since the last release. If any commit is
|
|
170
|
-
a `feat()` it will release a new minor version; it any commit is a `fix()` it
|
|
171
|
-
will release a new patch version. For major release, you'll have to do it
|
|
172
|
-
manually.
|
|
173
|
-
|
|
174
|
-
This option is not enabled by default. If you need it, you need to follow those
|
|
175
|
-
steps:
|
|
176
|
-
|
|
177
|
-
- Run `aberlaas setup --auto-release`. It will setup the required `ENV` variables
|
|
178
|
-
and ssh keys
|
|
179
|
-
- Update your `aberlaas ci` script to `aberlaas ci --auto-release`
|
|
180
|
-
- Uncomment the `add_ssh_keys` in your `.circleci.yml` file
|
|
181
|
-
|
|
182
164
|
## File structure
|
|
183
165
|
|
|
184
166
|
`./lib/configs` contain the default configuration for all the tools. They are
|
|
@@ -188,7 +170,7 @@ exported by the package and thus can be `require`d in userland.
|
|
|
188
170
|
extends the configuration exported in the previous files. Copying files to
|
|
189
171
|
userland allows user to change the files if they want to change the behavior.
|
|
190
172
|
|
|
191
|
-
`.eslintrc.js`,
|
|
173
|
+
`.eslintrc.js`, `stylelint.config.js` and `vite.config.js` are local
|
|
192
174
|
configuration files for `aberlaas` itself. They eat their own dog food by
|
|
193
175
|
referencing the same configs as above.
|
|
194
176
|
|
package/commands/ci/index.js
CHANGED
|
@@ -1,21 +1,10 @@
|
|
|
1
|
-
import helper from '../../helper.js';
|
|
2
1
|
import ciInfo from 'ci-info';
|
|
3
|
-
import _ from 'golgoth/lodash.js';
|
|
4
|
-
import pMap from 'golgoth/pMap.js';
|
|
5
|
-
import readJson from 'firost/readJson.js';
|
|
6
2
|
import run from 'firost/run.js';
|
|
3
|
+
import commandTest from '../test/index.js';
|
|
4
|
+
import commandLint from '../lint/index.js';
|
|
7
5
|
import consoleInfo from 'firost/consoleInfo.js';
|
|
8
|
-
import autoRelease from './autoRelease.js';
|
|
9
6
|
|
|
10
7
|
export default {
|
|
11
|
-
/**
|
|
12
|
-
* Return the value of an environment variable
|
|
13
|
-
* @param {string} key Name of the variable
|
|
14
|
-
* @returns {*} Key value
|
|
15
|
-
**/
|
|
16
|
-
getEnv(key) {
|
|
17
|
-
return _.get(process, `env.${key}`);
|
|
18
|
-
},
|
|
19
8
|
/**
|
|
20
9
|
* Checks if currently running on a CI server
|
|
21
10
|
* @returns {boolean} True if on a CI server
|
|
@@ -23,111 +12,37 @@ export default {
|
|
|
23
12
|
isCI() {
|
|
24
13
|
return ciInfo.isCI;
|
|
25
14
|
},
|
|
26
|
-
/**
|
|
27
|
-
* Checks if currently running on CircleCI
|
|
28
|
-
* @returns {boolean} True if on CircleCI
|
|
29
|
-
**/
|
|
30
|
-
isCircleCI() {
|
|
31
|
-
return ciInfo.CIRCLE;
|
|
32
|
-
},
|
|
33
|
-
/**
|
|
34
|
-
* Checks if currently on a PR
|
|
35
|
-
* @returns {boolean} True if on a PR
|
|
36
|
-
**/
|
|
37
|
-
isPR() {
|
|
38
|
-
return ciInfo.isPR;
|
|
39
|
-
},
|
|
40
|
-
/**
|
|
41
|
-
* Return the name of the originating branch of the PR
|
|
42
|
-
* @returns {string} Name of the PR branch
|
|
43
|
-
**/
|
|
44
|
-
prBranch() {
|
|
45
|
-
if (!this.isPR()) {
|
|
46
|
-
return false;
|
|
47
|
-
}
|
|
48
|
-
if (this.isCircleCI()) {
|
|
49
|
-
return this.getEnv('CIRCLE_BRANCH');
|
|
50
|
-
}
|
|
51
|
-
return false;
|
|
52
|
-
},
|
|
53
|
-
/**
|
|
54
|
-
* Returns the list of scripts defined in the package.json
|
|
55
|
-
* @returns {Array} List of scripts defined
|
|
56
|
-
**/
|
|
57
|
-
async availableScripts() {
|
|
58
|
-
// Get scripts in package.json
|
|
59
|
-
const currentPackage = await readJson(helper.hostPath('package.json'));
|
|
60
|
-
return _.chain(currentPackage).get('scripts').keys().value();
|
|
61
|
-
},
|
|
62
|
-
/**
|
|
63
|
-
* Returns a list of available scripts to run
|
|
64
|
-
* @returns {Array} List of scripts to run
|
|
65
|
-
**/
|
|
66
|
-
async scriptsToRun() {
|
|
67
|
-
const availableScripts = await this.availableScripts();
|
|
68
|
-
|
|
69
|
-
// Get potential scripts to run
|
|
70
|
-
const potentialScripts = ['test', 'lint', 'build:prod'];
|
|
71
|
-
|
|
72
|
-
return _.intersection(potentialScripts, availableScripts);
|
|
73
|
-
},
|
|
74
|
-
/**
|
|
75
|
-
* Display the current node and yarn versions
|
|
76
|
-
**/
|
|
77
|
-
async displayVersion() {
|
|
78
|
-
const { stdout: nodeVersion } = await this.__run('node --version', {
|
|
79
|
-
stdout: false,
|
|
80
|
-
});
|
|
81
|
-
const { stdout: yarnVersion } = await this.__run('yarn --version', {
|
|
82
|
-
stdout: false,
|
|
83
|
-
});
|
|
84
|
-
this.__consoleInfo(`node ${nodeVersion}, yarn v${yarnVersion}`);
|
|
85
|
-
},
|
|
86
15
|
/**
|
|
87
16
|
* Run CI scripts and fail the job if any fails
|
|
17
|
+
* Runs lint and test by default, but can be changed with --no-test and
|
|
18
|
+
* --no-lint
|
|
88
19
|
* @param {object} cliArgs CLI Argument object, as created by minimist
|
|
89
20
|
* @returns {boolean} True on success, throws on error
|
|
90
21
|
**/
|
|
91
22
|
async run(cliArgs = {}) {
|
|
92
23
|
const args = {
|
|
93
|
-
|
|
94
|
-
|
|
24
|
+
test: true,
|
|
25
|
+
lint: true,
|
|
95
26
|
...cliArgs,
|
|
96
27
|
};
|
|
97
28
|
|
|
98
29
|
if (!this.isCI()) {
|
|
30
|
+
this.__consoleInfo('Current system is not a CI, skipping');
|
|
99
31
|
return true;
|
|
100
32
|
}
|
|
101
33
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
await pMap(
|
|
106
|
-
scripts,
|
|
107
|
-
async (scriptName) => {
|
|
108
|
-
let command = scriptName;
|
|
109
|
-
if (command === 'test') {
|
|
110
|
-
command = `test --maxWorkers=${args['cpu-count']}`;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
await helper.yarnRun(command);
|
|
114
|
-
},
|
|
115
|
-
{ concurrency: 1 },
|
|
116
|
-
);
|
|
34
|
+
if (args.test) {
|
|
35
|
+
await this.__runTest();
|
|
36
|
+
}
|
|
117
37
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
await this.autoRelease();
|
|
38
|
+
if (args.lint) {
|
|
39
|
+
await this.__runLint();
|
|
121
40
|
}
|
|
122
41
|
|
|
123
42
|
return true;
|
|
124
43
|
},
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
**/
|
|
128
|
-
async autoRelease() {
|
|
129
|
-
await autoRelease.run();
|
|
130
|
-
},
|
|
44
|
+
__runTest: commandTest.run.bind(commandTest),
|
|
45
|
+
__runLint: commandLint.run.bind(commandLint),
|
|
131
46
|
__run: run,
|
|
132
47
|
__consoleInfo: consoleInfo,
|
|
133
48
|
};
|