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.
Files changed (55) hide show
  1. package/LICENSE +9 -0
  2. package/README.md +1 -19
  3. package/commands/ci/index.js +14 -99
  4. package/commands/init/index.js +322 -205
  5. package/commands/lint/css.js +2 -2
  6. package/commands/lint/helpers/prettier.js +2 -2
  7. package/commands/lint/index.js +3 -2
  8. package/commands/lint/js.js +1 -1
  9. package/commands/precommit/index.js +4 -3
  10. package/commands/setup/index.js +0 -12
  11. package/commands/test/index.js +56 -48
  12. package/configs/eslint.cjs +9 -2
  13. package/configs/lintstaged.js +25 -0
  14. package/configs/node.cjs +4 -0
  15. package/configs/{prettier.cjs → prettier.js} +1 -1
  16. package/configs/{stylelint.cjs → stylelint.js} +1 -1
  17. package/configs/vite.js +9 -2
  18. package/main.js +31 -2
  19. package/package.json +24 -23
  20. package/templates/_circleci/config.yml +0 -1
  21. package/templates/_eslintignore.conf +4 -1
  22. package/templates/_gitattributes +4 -0
  23. package/templates/_gitignore +29 -0
  24. package/templates/lerna.json +6 -0
  25. package/templates/lib/__tests__/main.js +7 -5
  26. package/templates/lib/main.js +2 -2
  27. package/templates/lintstaged.config.js +4 -0
  28. package/templates/prettier.config.js +4 -0
  29. package/templates/scripts/ci +3 -1
  30. package/templates/scripts/compress +2 -2
  31. package/templates/scripts/docs/build +4 -0
  32. package/templates/scripts/docs/build-prod +4 -0
  33. package/templates/scripts/docs/cms +4 -0
  34. package/templates/scripts/docs/serve +4 -0
  35. package/templates/scripts/hooks/pre-commit +1 -1
  36. package/templates/scripts/lib/release +5 -0
  37. package/templates/scripts/lib/test +4 -0
  38. package/templates/scripts/lib/test-watch +4 -0
  39. package/templates/scripts/lint +2 -2
  40. package/templates/scripts/lint-fix +2 -2
  41. package/templates/stylelint.config.js +4 -0
  42. package/templates/vite.config.js +2 -2
  43. package/commands/ci/autoRelease.js +0 -143
  44. package/commands/release/index.js +0 -76
  45. package/commands/setup/autoRelease/envVars.js +0 -56
  46. package/commands/setup/autoRelease/index.js +0 -59
  47. package/commands/setup/autoRelease/privateKey.js +0 -41
  48. package/commands/setup/autoRelease/publicKey.js +0 -55
  49. package/configs/lintstaged.cjs +0 -31
  50. package/templates/_lintstagedrc.cjs +0 -4
  51. package/templates/_prettierrc.cjs +0 -4
  52. package/templates/_stylelintrc.cjs +0 -4
  53. package/templates/scripts/release +0 -4
  54. package/templates/scripts/test +0 -4
  55. 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`, `.stylelintrc.js` and `jest.config.js` are local
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
 
@@ -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
- 'auto-release': false,
94
- 'cpu-count': 2,
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
- await this.displayVersion();
103
-
104
- const scripts = await this.scriptsToRun();
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
- // Attempt to release the package if --auto-release is set
119
- if (args['auto-release']) {
120
- await this.autoRelease();
38
+ if (args.lint) {
39
+ await this.__runLint();
121
40
  }
122
41
 
123
42
  return true;
124
43
  },
125
- /**
126
- * Attempt to perform an auto-release
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
  };