aberlaas 2.0.0 → 2.1.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/README.md +2 -3
- package/bin/{aberlaas → aberlaas.js} +1 -1
- package/commands/ci/autoRelease.js +9 -8
- package/commands/ci/index.js +10 -10
- package/commands/compress/index.js +6 -6
- package/commands/compress/png.js +5 -5
- package/commands/{init.js → init/index.js} +47 -31
- package/commands/lint/circleci.js +10 -11
- package/commands/lint/css.js +12 -10
- package/commands/lint/helpers/prettier.js +29 -0
- package/commands/lint/index.js +18 -48
- package/commands/lint/js.js +40 -51
- package/commands/lint/json.js +11 -10
- package/commands/lint/yml.js +13 -11
- package/commands/{precommit.js → precommit/index.js} +7 -7
- package/commands/readme/index.js +16 -16
- package/commands/{release.js → release/index.js} +5 -6
- package/commands/setup/autoRelease/envVars.js +9 -8
- package/commands/setup/autoRelease/index.js +12 -11
- package/commands/setup/autoRelease/privateKey.js +6 -5
- package/commands/setup/autoRelease/publicKey.js +8 -7
- package/commands/setup/circleci.js +9 -8
- package/commands/setup/github.js +6 -5
- package/commands/setup/helpers/circleci.js +6 -5
- package/commands/setup/helpers/github.js +6 -5
- package/commands/setup/helpers/npm.js +1 -1
- package/commands/setup/helpers/ssh.js +11 -10
- package/commands/setup/index.js +6 -6
- package/commands/setup/renovate.js +7 -6
- package/commands/test/index.js +84 -0
- package/configs/{eslint.js → eslint.cjs} +63 -30
- package/configs/jest/{index.js → index.cjs} +13 -10
- package/configs/jest/{testEnvironment.js → testEnvironment.cjs} +1 -1
- package/configs/jest.cjs +1 -0
- package/configs/{lintstaged.js → lintstaged.cjs} +1 -1
- package/configs/node.cjs +5 -0
- package/configs/vite/test/setupFiles/captureOutput.js +4 -0
- package/configs/vite/test/setupFiles/dedent.js +4 -0
- package/configs/vite/test/setupFiles/fit-xit-fdescribe-xdescribe.js +13 -0
- package/configs/vite/test/setupFiles/jest-extended.js +10 -0
- package/configs/vite/test/setupFiles/testName.js +9 -0
- package/configs/vite.js +25 -0
- package/helper.js +37 -39
- package/main.js +28 -22
- package/package.json +33 -21
- package/scripts/postinstall +15 -0
- package/templates/_circleci/config.yml +1 -1
- package/templates/_eslintignore.conf +1 -1
- package/templates/_eslintrc.cjs +3 -0
- package/templates/_lintstagedrc.cjs +4 -0
- package/templates/_prettierrc.cjs +4 -0
- package/templates/_stylelintrc.cjs +4 -0
- package/templates/jest.config.cjs +4 -0
- package/templates/lib/__tests__/main.js +2 -2
- package/templates/lib/main.js +1 -1
- package/templates/scripts/hooks/pre-commit +11 -0
- package/templates/vite.config.js +4 -0
- package/commands/test.js +0 -92
- package/configs/husky.js +0 -5
- package/configs/jest.js +0 -1
- package/configs/node.js +0 -3
- package/lib/configs/deprecated.js +0 -17
- package/lib/configs/eslint.js +0 -2
- package/lib/configs/husky.js +0 -2
- package/lib/configs/jest.js +0 -2
- package/lib/configs/lintstaged.js +0 -2
- package/lib/configs/prettier.js +0 -2
- package/lib/configs/stylelint.js +0 -2
- package/templates/_eslintrc.js +0 -3
- package/templates/_huskyrc.js +0 -4
- package/templates/_lintstagedrc.js +0 -4
- package/templates/_prettierrc.js +0 -4
- package/templates/_stylelintrc.js +0 -4
- package/templates/babel.config.js +0 -3
- package/templates/jest.config.js +0 -4
- package/templates/scripts/husky-precommit +0 -4
- /package/configs/jest/{jest-extended.js → jest-extended.cjs} +0 -0
- /package/configs/jest/{setupFileAfterEnv.js → setupFileAfterEnv.cjs} +0 -0
- /package/configs/jest/{sharedState.js → sharedState.cjs} +0 -0
- /package/configs/{prettier.js → prettier.cjs} +0 -0
- /package/configs/{stylelint.js → stylelint.cjs} +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const path = require('path');
|
|
2
|
-
const jestExtendedPath = path.resolve(__dirname, './jest-extended.
|
|
3
|
-
const setupFileAfterEnv = path.resolve(__dirname, './setupFileAfterEnv.
|
|
4
|
-
const testEnvironment = path.resolve(__dirname, './testEnvironment.
|
|
2
|
+
const jestExtendedPath = path.resolve(__dirname, './jest-extended.cjs');
|
|
3
|
+
const setupFileAfterEnv = path.resolve(__dirname, './setupFileAfterEnv.cjs');
|
|
4
|
+
const testEnvironment = path.resolve(__dirname, './testEnvironment.cjs');
|
|
5
5
|
module.exports = {
|
|
6
6
|
// Custom environment that automatically set testName and allow for --failFast
|
|
7
7
|
testEnvironment,
|
|
@@ -34,13 +34,16 @@ module.exports = {
|
|
|
34
34
|
'<rootDir>/((.*)/)?templates/',
|
|
35
35
|
],
|
|
36
36
|
|
|
37
|
-
moduleNameMapper: {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
},
|
|
37
|
+
// moduleNameMapper: {
|
|
38
|
+
// // When using lodash-es (which is treeshakeable, thus preferable in front-end
|
|
39
|
+
// // envs), it will fail in tests as it isn't compiled to ES5.
|
|
40
|
+
// // So, we make jest load the full lodash instead. Note that the lib still
|
|
41
|
+
// // needs to be added as a devDependency
|
|
42
|
+
// '^lodash-es$': 'lodash',
|
|
43
|
+
// },
|
|
44
|
+
|
|
45
|
+
// Make sure we don't transform source code and use the default ESM code
|
|
46
|
+
transform: {},
|
|
44
47
|
|
|
45
48
|
bail: true,
|
|
46
49
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const NodeEnvironment = require('jest-environment-node');
|
|
2
2
|
const shouldFailFast = process.env.ABERLAAS_TEST_FAIL_FAST;
|
|
3
|
-
const sharedState = require('./sharedState.
|
|
3
|
+
const sharedState = require('./sharedState.cjs');
|
|
4
4
|
|
|
5
5
|
class AberlaasEnvironment extends NodeEnvironment {
|
|
6
6
|
async handleTestEvent(event, _state) {
|
package/configs/jest.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('./jest/index.cjs');
|
|
@@ -20,6 +20,6 @@ if (pkg.scripts && pkg.scripts.lint) {
|
|
|
20
20
|
}
|
|
21
21
|
// Testing changed js files
|
|
22
22
|
if (pkg.scripts && pkg.scripts.test) {
|
|
23
|
-
result['./lib/**/*.js'] = ['yarn run test --failFast --
|
|
23
|
+
result['./lib/**/*.js'] = ['yarn run test --failFast --related'];
|
|
24
24
|
}
|
|
25
25
|
module.exports = result;
|
package/configs/node.cjs
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Add faster to type aliases:
|
|
3
|
+
* - fit, ftest, fdescribe: To focus specific tests
|
|
4
|
+
* - xit, xtest, xdescribe: To skip specific tests
|
|
5
|
+
**/
|
|
6
|
+
|
|
7
|
+
globalThis.fit = globalThis.it.only;
|
|
8
|
+
globalThis.ftest = globalThis.test.only;
|
|
9
|
+
globalThis.fdescribe = globalThis.describe.only;
|
|
10
|
+
|
|
11
|
+
globalThis.xit = globalThis.it.skip;
|
|
12
|
+
globalThis.xtest = globalThis.test.skip;
|
|
13
|
+
globalThis.xdescribe = globalThis.describe.skip;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// We use extended matchers from jest-extended in vitest
|
|
2
|
+
// It includes matcher like .toStartWith, .toBeEmpty, etc
|
|
3
|
+
// See: https://github.com/jest-community/jest-extended
|
|
4
|
+
//
|
|
5
|
+
// The expect.extend() from Vitest is compatible with the one from Jest, so
|
|
6
|
+
// setup is straightforward
|
|
7
|
+
import { expect } from 'vitest';
|
|
8
|
+
import * as matchers from 'jest-extended';
|
|
9
|
+
|
|
10
|
+
expect.extend(matchers);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/* global beforeEach, expect */
|
|
2
|
+
/**
|
|
3
|
+
* Make the variable `testName` contain the name of the current test in each
|
|
4
|
+
* test
|
|
5
|
+
**/
|
|
6
|
+
beforeEach(() => {
|
|
7
|
+
const fullName = expect.getState().currentTestName;
|
|
8
|
+
globalThis.testName = fullName.split(' > ').pop();
|
|
9
|
+
});
|
package/configs/vite.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { configDefaults, defineConfig } from 'vitest/config';
|
|
2
|
+
const configDir = new URL('./vite/', import.meta.url).pathname;
|
|
3
|
+
|
|
4
|
+
export default defineConfig({
|
|
5
|
+
test: {
|
|
6
|
+
// Make describe, it, beforeEach and other globally available
|
|
7
|
+
globals: true,
|
|
8
|
+
// Tests should be in a __tests__ folder next to their code
|
|
9
|
+
include: ['**/__tests__/**/*.js?(x)'],
|
|
10
|
+
// We ignore temporary folders from the tests
|
|
11
|
+
exclude: [...configDefaults.exclude, '**/tmp/**'],
|
|
12
|
+
watchExclude: [...configDefaults.watchExclude, '**/tmp/**'],
|
|
13
|
+
// Restore mocks after each tests
|
|
14
|
+
restoreMocks: true,
|
|
15
|
+
|
|
16
|
+
// Run before each test file
|
|
17
|
+
setupFiles: [
|
|
18
|
+
`${configDir}/test/setupFiles/dedent.js`,
|
|
19
|
+
`${configDir}/test/setupFiles/captureOutput.js`,
|
|
20
|
+
`${configDir}/test/setupFiles/fit-xit-fdescribe-xdescribe.js`,
|
|
21
|
+
`${configDir}/test/setupFiles/jest-extended.js`,
|
|
22
|
+
`${configDir}/test/setupFiles/testName.js`,
|
|
23
|
+
],
|
|
24
|
+
},
|
|
25
|
+
});
|
package/helper.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import path from 'path';
|
|
2
|
+
import _ from 'golgoth/lodash.js';
|
|
3
|
+
import run from 'firost/run.js';
|
|
4
|
+
import glob from 'firost/glob.js';
|
|
5
|
+
import exists from 'firost/exists.js';
|
|
6
|
+
import findUp from 'find-up';
|
|
7
|
+
import * as url from 'url';
|
|
8
|
+
|
|
9
|
+
export default {
|
|
8
10
|
/**
|
|
9
11
|
* Return absolute path to the host dir
|
|
10
12
|
* @returns {string} Absolute path to host dir
|
|
@@ -25,7 +27,7 @@ module.exports = {
|
|
|
25
27
|
* @returns {string} Absolute path to aberlaas dir
|
|
26
28
|
**/
|
|
27
29
|
aberlaasRoot() {
|
|
28
|
-
return
|
|
30
|
+
return url.fileURLToPath(new URL('.', import.meta.url));
|
|
29
31
|
},
|
|
30
32
|
/**
|
|
31
33
|
* Return an absolute path to a file in the aberlaas directory
|
|
@@ -115,35 +117,39 @@ module.exports = {
|
|
|
115
117
|
|
|
116
118
|
/**
|
|
117
119
|
* Returns path to a specific binary.
|
|
118
|
-
*
|
|
119
|
-
*
|
|
120
|
+
*
|
|
121
|
+
* Knowing the path to a specific binary is not trivial:
|
|
122
|
+
* - Aberlaas dependencies should be in node_modules/aberlaas/.bin
|
|
123
|
+
* - Host dependencies should be in node_modules/.bin
|
|
124
|
+
*
|
|
125
|
+
* There are some special cases:
|
|
126
|
+
* - If both aberlaas and host use the same dependency version, it will be
|
|
127
|
+
* hoisted to the host
|
|
128
|
+
* - If they use different versions, priority should be given to the one in
|
|
129
|
+
* aberlaas
|
|
130
|
+
* - Mono-repo setup and yarn link will move dependencies out of
|
|
131
|
+
* node_modules/.bin
|
|
132
|
+
*
|
|
133
|
+
* For those reasons, we defer to running yarn bin to get the exact path to
|
|
134
|
+
* the binary, and check in order of importance in aberlaas first, and then in
|
|
135
|
+
* the host
|
|
136
|
+
*
|
|
120
137
|
* @param {string} bin Binary name
|
|
121
138
|
* @returns {string} Path to the binary
|
|
122
139
|
**/
|
|
123
140
|
async which(bin) {
|
|
124
|
-
|
|
125
|
-
const
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
if (hostPath) {
|
|
130
|
-
return stripAnsi(hostPath);
|
|
131
|
-
}
|
|
141
|
+
const binaryPathSuffix = `./node_modules/.bin/${bin}`;
|
|
142
|
+
const pathsToTest = [
|
|
143
|
+
this.aberlaasPath(binaryPathSuffix),
|
|
144
|
+
this.hostPath(binaryPathSuffix),
|
|
145
|
+
];
|
|
132
146
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
{
|
|
137
|
-
shell: true,
|
|
138
|
-
stdout: false,
|
|
139
|
-
stderr: false,
|
|
147
|
+
for (const binaryPath of pathsToTest) {
|
|
148
|
+
if (await exists(binaryPath)) {
|
|
149
|
+
return binaryPath;
|
|
140
150
|
}
|
|
141
|
-
);
|
|
142
|
-
if (aberlaasPath) {
|
|
143
|
-
return stripAnsi(aberlaasPath);
|
|
144
151
|
}
|
|
145
|
-
|
|
146
|
-
return null;
|
|
152
|
+
return false;
|
|
147
153
|
},
|
|
148
154
|
/**
|
|
149
155
|
* Run a specific script through yarn run
|
|
@@ -151,14 +157,6 @@ module.exports = {
|
|
|
151
157
|
* @returns {object} Result of the run, including .sterr and .stdout
|
|
152
158
|
**/
|
|
153
159
|
async yarnRun(scriptName) {
|
|
154
|
-
|
|
155
|
-
process.chdir(this.hostRoot());
|
|
156
|
-
|
|
157
|
-
try {
|
|
158
|
-
return await run(`yarn run ${scriptName}`);
|
|
159
|
-
} finally {
|
|
160
|
-
process.chdir(currentDir);
|
|
161
|
-
}
|
|
160
|
+
return await run(`yarn run ${scriptName}`, { cwd: this.hostRoot() });
|
|
162
161
|
},
|
|
163
|
-
__run: run,
|
|
164
162
|
};
|
package/main.js
CHANGED
|
@@ -1,27 +1,34 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import minimist from 'minimist';
|
|
2
|
+
import consoleError from 'firost/consoleError.js';
|
|
3
|
+
import exit from 'firost/exit.js';
|
|
4
|
+
import _ from 'golgoth/lodash.js';
|
|
5
|
+
import commandCi from './commands/ci/index.js';
|
|
6
|
+
import commandCompress from './commands/compress/index.js';
|
|
7
|
+
import commandInit from './commands/init/index.js';
|
|
8
|
+
import commandPrecommit from './commands/precommit/index.js';
|
|
9
|
+
import commandRelease from './commands/release/index.js';
|
|
10
|
+
import commandTest from './commands/test/index.js';
|
|
11
|
+
import commandLint from './commands/lint/index.js';
|
|
12
|
+
import commandReadme from './commands/readme/index.js';
|
|
13
|
+
import commandSetup from './commands/setup/index.js';
|
|
5
14
|
|
|
6
|
-
|
|
15
|
+
export default {
|
|
7
16
|
/**
|
|
8
17
|
* List of allowed commands to run
|
|
9
18
|
* @returns {Array} List of allowed commands to run
|
|
10
19
|
**/
|
|
11
|
-
|
|
12
|
-
return
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
'test',
|
|
24
|
-
];
|
|
20
|
+
allCommands() {
|
|
21
|
+
return {
|
|
22
|
+
ci: commandCi,
|
|
23
|
+
compress: commandCompress,
|
|
24
|
+
init: commandInit,
|
|
25
|
+
lint: commandLint,
|
|
26
|
+
precommit: commandPrecommit,
|
|
27
|
+
readme: commandReadme,
|
|
28
|
+
release: commandRelease,
|
|
29
|
+
setup: commandSetup,
|
|
30
|
+
test: commandTest,
|
|
31
|
+
};
|
|
25
32
|
},
|
|
26
33
|
/**
|
|
27
34
|
* Run the command specified on the command-line, along with specific
|
|
@@ -34,7 +41,8 @@ module.exports = {
|
|
|
34
41
|
});
|
|
35
42
|
|
|
36
43
|
const commandName = args._[0];
|
|
37
|
-
|
|
44
|
+
const command = this.allCommands()[commandName];
|
|
45
|
+
if (!command) {
|
|
38
46
|
this.__consoleError(`Unknown command ${commandName}`);
|
|
39
47
|
this.__exit(1);
|
|
40
48
|
return;
|
|
@@ -44,7 +52,6 @@ module.exports = {
|
|
|
44
52
|
args._ = _.drop(args._, 1);
|
|
45
53
|
|
|
46
54
|
try {
|
|
47
|
-
const command = this.__require(`./commands/${commandName}`);
|
|
48
55
|
await command.run(args);
|
|
49
56
|
} catch (err) {
|
|
50
57
|
this.__consoleError(err.message);
|
|
@@ -53,5 +60,4 @@ module.exports = {
|
|
|
53
60
|
},
|
|
54
61
|
__consoleError: consoleError,
|
|
55
62
|
__exit: exit,
|
|
56
|
-
__require: require,
|
|
57
63
|
};
|
package/package.json
CHANGED
|
@@ -1,59 +1,66 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "aberlaas",
|
|
3
|
+
"type": "module",
|
|
3
4
|
"description": "Scaffold your JavaScript projects with tests, lint and release scripts",
|
|
4
|
-
"version": "2.
|
|
5
|
+
"version": "2.1.0",
|
|
5
6
|
"repository": "pixelastic/aberlaas",
|
|
6
7
|
"homepage": "https://projects.pixelastic.com/aberlaas/",
|
|
7
8
|
"author": "Tim Carry (@pixelastic)",
|
|
8
9
|
"license": "MIT",
|
|
9
|
-
"
|
|
10
|
+
"exports": {
|
|
11
|
+
".": "./main.js",
|
|
12
|
+
"./configs/lintstaged.cjs": "./configs/lintstaged.cjs",
|
|
13
|
+
"./configs/prettier.cjs": "./configs/prettier.cjs",
|
|
14
|
+
"./configs/styleling.cjs": "./configs/styleling.cjs"
|
|
15
|
+
},
|
|
10
16
|
"files": [
|
|
11
17
|
"bin/",
|
|
12
18
|
"lib/",
|
|
19
|
+
"scripts/",
|
|
13
20
|
"*.js",
|
|
14
|
-
"commands/*.js",
|
|
15
21
|
"commands/ci/*.js",
|
|
16
22
|
"commands/compress/*.js",
|
|
23
|
+
"commands/init/*.js",
|
|
17
24
|
"commands/lint/*.js",
|
|
25
|
+
"commands/lint/helpers/*.js",
|
|
26
|
+
"commands/precommit/*.js",
|
|
18
27
|
"commands/readme/*.js",
|
|
28
|
+
"commands/release/*.js",
|
|
19
29
|
"commands/setup/*.js",
|
|
20
30
|
"commands/setup/autoRelease/*.js",
|
|
21
31
|
"commands/setup/helpers/*.js",
|
|
32
|
+
"commands/test/*.js",
|
|
22
33
|
"configs/",
|
|
23
34
|
"templates/"
|
|
24
35
|
],
|
|
25
36
|
"bin": {
|
|
26
|
-
"aberlaas": "bin/aberlaas"
|
|
27
|
-
"aberlass": "bin/aberlaas",
|
|
28
|
-
"aberlas": "bin/aberlaas"
|
|
37
|
+
"aberlaas": "bin/aberlaas.js"
|
|
29
38
|
},
|
|
30
39
|
"dependencies": {
|
|
31
40
|
"@octokit/rest": "18.12.0",
|
|
32
41
|
"ci-info": "3.9.0",
|
|
33
42
|
"dedent": "1.5.1",
|
|
34
|
-
"eslint": "
|
|
35
|
-
"eslint-config-prettier": "
|
|
36
|
-
"eslint-plugin-jest": "24.7.0",
|
|
43
|
+
"eslint": "8.54.0",
|
|
44
|
+
"eslint-config-prettier": "9.0.0",
|
|
37
45
|
"eslint-plugin-jsdoc": "46.9.0",
|
|
38
|
-
"eslint-plugin-
|
|
39
|
-
"eslint-plugin-prettier": "
|
|
46
|
+
"eslint-plugin-n": "16.3.1",
|
|
47
|
+
"eslint-plugin-prettier": "5.0.1",
|
|
48
|
+
"eslint-plugin-vitest": "0.3.10",
|
|
49
|
+
"eslint-plugin-vitest-globals": "1.4.0",
|
|
40
50
|
"find-up": "5.0.0",
|
|
41
|
-
"firost": "
|
|
51
|
+
"firost": "3.1.0",
|
|
42
52
|
"front-matter": "4.0.2",
|
|
53
|
+
"gilmore": "0.1.0",
|
|
43
54
|
"golgoth": "2.1.0",
|
|
44
|
-
"
|
|
45
|
-
"jest": "27.5.1",
|
|
46
|
-
"jest-environment-node": "27.5.1",
|
|
47
|
-
"jest-expect-message": "1.1.3",
|
|
48
|
-
"jest-extended": "0.11.5",
|
|
55
|
+
"jest-extended": "4.0.2",
|
|
49
56
|
"lint-staged": "11.2.6",
|
|
50
57
|
"minimist": "1.2.8",
|
|
51
58
|
"np": "7.7.0",
|
|
52
59
|
"parse-github-repo-url": "1.4.1",
|
|
53
|
-
"prettier": "
|
|
60
|
+
"prettier": "3.1.0",
|
|
54
61
|
"std-mocks": "1.0.1",
|
|
55
|
-
"strip-ansi": "6.0.1",
|
|
56
62
|
"stylelint": "13.13.1",
|
|
63
|
+
"vitest": "1.0.4",
|
|
57
64
|
"yaml-lint": "1.7.0"
|
|
58
65
|
},
|
|
59
66
|
"engines": {
|
|
@@ -67,7 +74,12 @@
|
|
|
67
74
|
"release": "../scripts/release",
|
|
68
75
|
"serve": "../scripts/docs/serve",
|
|
69
76
|
"test": "../scripts/lib/test",
|
|
70
|
-
"test:watch": "../scripts/lib/test-watch"
|
|
77
|
+
"test:watch": "../scripts/lib/test-watch",
|
|
78
|
+
"postinstall": "./scripts/postinstall"
|
|
79
|
+
},
|
|
80
|
+
"devDependencies": {
|
|
81
|
+
"eslint-plugin-import": "2.29.0",
|
|
82
|
+
"eslint-plugin-vitest": "0.3.10"
|
|
71
83
|
},
|
|
72
|
-
"gitHead": "
|
|
84
|
+
"gitHead": "5d021891b8ba9c030747a3bc7bf20d86c85422db"
|
|
73
85
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# This script *should be* automatically run when aberlaas in installed
|
|
3
|
+
# It will configure the local git repository to use ./scripts/hooks (if it
|
|
4
|
+
# exists) for git hooks
|
|
5
|
+
#
|
|
6
|
+
# Note that npm/yarn/etc might have caching mechanisms that will prevent this
|
|
7
|
+
# script from running in some circumstances. It's not (and will never be)
|
|
8
|
+
# a bulletproof approach, but should cover the most basic needs.
|
|
9
|
+
#
|
|
10
|
+
# In case hooks no longer trigger, you will need to manually run:
|
|
11
|
+
# $ git config core.hooksPath scripts/hooks
|
|
12
|
+
|
|
13
|
+
if [ ! -d "./scripts/hooks" ]; then
|
|
14
|
+
git config core.hooksPath scripts/hooks
|
|
15
|
+
fi
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import current from '../main.js';
|
|
2
2
|
|
|
3
3
|
describe('current', () => {
|
|
4
4
|
it('should do something', async () => {
|
|
@@ -6,6 +6,6 @@ describe('current', () => {
|
|
|
6
6
|
|
|
7
7
|
const actual = current.run(input);
|
|
8
8
|
|
|
9
|
-
expect(actual).
|
|
9
|
+
expect(actual).toBe(true);
|
|
10
10
|
});
|
|
11
11
|
});
|
package/templates/lib/main.js
CHANGED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
#!/usr/bin/env sh
|
|
2
|
+
# This script *should be* automatically triggered before each git commit.
|
|
3
|
+
#
|
|
4
|
+
# If it doesn't work, make sure your local git repo is configured to use
|
|
5
|
+
# ./scripts/hooks as the base directory for git hooks.
|
|
6
|
+
#
|
|
7
|
+
# If not, run:
|
|
8
|
+
# $ git config core.hooksPath scripts/hooks
|
|
9
|
+
set -e
|
|
10
|
+
|
|
11
|
+
aberlaas precommit "$@"
|
package/commands/test.js
DELETED
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
/* eslint-disable jest/no-jest-import */
|
|
2
|
-
const helper = require('../helper');
|
|
3
|
-
const _ = require('golgoth/lodash');
|
|
4
|
-
|
|
5
|
-
module.exports = {
|
|
6
|
-
/**
|
|
7
|
-
* Transform all aberlaas test cli options into suitable jest-cli options
|
|
8
|
-
* @param {object} cliArgs CLI Argument object, as created by minimist
|
|
9
|
-
* @returns {Array} Array of cli arguments and values
|
|
10
|
-
**/
|
|
11
|
-
async jestCliArguments(cliArgs = {}) {
|
|
12
|
-
const args = {
|
|
13
|
-
...cliArgs,
|
|
14
|
-
cache: false,
|
|
15
|
-
passWithNoTests: true,
|
|
16
|
-
};
|
|
17
|
-
// Default list of files
|
|
18
|
-
if (_.isEmpty(args._)) {
|
|
19
|
-
args._ = [helper.hostPath()];
|
|
20
|
-
}
|
|
21
|
-
// Config file
|
|
22
|
-
args.config = await helper.configFile(
|
|
23
|
-
cliArgs.config,
|
|
24
|
-
'jest.config.js',
|
|
25
|
-
'lib/configs/jest.js'
|
|
26
|
-
);
|
|
27
|
-
// Set no-watchman when watching
|
|
28
|
-
if (args.watch) {
|
|
29
|
-
args.watchman = false;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
// Handle additional --failFast switch to stop after one test fails
|
|
33
|
-
if (args.failFast) {
|
|
34
|
-
delete args.failFast;
|
|
35
|
-
this.setEnv('ABERLAAS_TEST_FAIL_FAST', true);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
// Convert to array of cli arguments
|
|
39
|
-
return _.transform(
|
|
40
|
-
args,
|
|
41
|
-
(result, value, key) => {
|
|
42
|
-
if (key === '_') {
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
if (value === true) {
|
|
46
|
-
result.push(`--${key}`);
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
49
|
-
if (value === false) {
|
|
50
|
-
result.push(`--no-${key}`);
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
result.push(`--${key}`);
|
|
54
|
-
result.push(`${value}`);
|
|
55
|
-
},
|
|
56
|
-
[...args._]
|
|
57
|
-
);
|
|
58
|
-
},
|
|
59
|
-
/**
|
|
60
|
-
* Test all files using Jest
|
|
61
|
-
* @param {object} cliArgs CLI Argument object, as created by minimist
|
|
62
|
-
**/
|
|
63
|
-
async run(cliArgs) {
|
|
64
|
-
const options = await this.jestCliArguments(cliArgs);
|
|
65
|
-
await this.__jestRun(options);
|
|
66
|
-
},
|
|
67
|
-
/**
|
|
68
|
-
* Wrapper method around jest.run. Using a wrapper here makes it easier to
|
|
69
|
-
* mock the call in our tests. Because we are using jest itself to test this
|
|
70
|
-
* file, mocking jest from inside of it is not practical, so we need to wrap
|
|
71
|
-
* it.
|
|
72
|
-
* @param {object} options CLI Options to pass to jest.run
|
|
73
|
-
**/
|
|
74
|
-
async __jestRun(options) {
|
|
75
|
-
// We lazy-load jest here because importing it at the top kinda confuses
|
|
76
|
-
// Jest when we're running tests and complaining about cyclical
|
|
77
|
-
// dependencies. So we're loading it only when needed.
|
|
78
|
-
if (!this.__jest) {
|
|
79
|
-
this.__jest = require('jest');
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
await this.__jest.run(options);
|
|
83
|
-
},
|
|
84
|
-
/**
|
|
85
|
-
* Set an environment variable to a specific value
|
|
86
|
-
* @param {string} key Key entry
|
|
87
|
-
* @param {string} value Value to set
|
|
88
|
-
**/
|
|
89
|
-
setEnv(key, value) {
|
|
90
|
-
process.env[key] = value;
|
|
91
|
-
},
|
|
92
|
-
};
|
package/configs/husky.js
DELETED
package/configs/jest.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
module.exports = require('./jest/index.js');
|
package/configs/node.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* In July 2021, I moved the repository to a monorepo holding the docs. The path
|
|
3
|
-
* to the config files changed, no longer referencing the ./lib. This break all
|
|
4
|
-
* usage, so I added this proxy, with a deprecation notice.
|
|
5
|
-
*
|
|
6
|
-
* Require the correct file, but display a warning about what file to change
|
|
7
|
-
* @param {string} hostPath Example: jest.config.js
|
|
8
|
-
* @param {string} aberlaasPath Example configs/jest.js
|
|
9
|
-
* @returns {object} Config file object
|
|
10
|
-
**/
|
|
11
|
-
module.exports = (hostPath, aberlaasPath) => {
|
|
12
|
-
console.info(
|
|
13
|
-
`Please update your ${hostPath} to require aberlaas/${aberlaasPath} instead of aberlaas/lib/${aberlaasPath}`
|
|
14
|
-
);
|
|
15
|
-
|
|
16
|
-
return require(`../../${aberlaasPath}`);
|
|
17
|
-
};
|
package/lib/configs/eslint.js
DELETED