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
package/commands/lint/yml.js
CHANGED
|
@@ -1,19 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import helper from '../../helper.js';
|
|
2
|
+
import { fix as prettierFix } from './helpers/prettier.js';
|
|
3
|
+
import firostError from 'firost/error.js';
|
|
4
|
+
import read from 'firost/read.js';
|
|
5
|
+
import _ from 'golgoth/lodash.js';
|
|
6
|
+
import pMap from 'golgoth/pMap.js';
|
|
7
|
+
import yamlLint from 'yaml-lint';
|
|
8
|
+
import path from 'path';
|
|
9
|
+
|
|
10
|
+
export default {
|
|
10
11
|
/**
|
|
11
12
|
* Find all relevant files
|
|
12
13
|
* @param {Array} userPatterns Patterns to narrow the search down
|
|
13
14
|
* @returns {Array} Array of files
|
|
14
15
|
**/
|
|
15
16
|
async getInputFiles(userPatterns) {
|
|
16
|
-
return await
|
|
17
|
+
return await helper.findHostFiles(userPatterns, ['.yml', '.yaml']);
|
|
17
18
|
},
|
|
18
19
|
/**
|
|
19
20
|
* Lint all files and display results.
|
|
@@ -55,7 +56,8 @@ module.exports = {
|
|
|
55
56
|
if (_.isEmpty(files)) {
|
|
56
57
|
return true;
|
|
57
58
|
}
|
|
58
|
-
await
|
|
59
|
+
await this.__prettierFix(files);
|
|
59
60
|
},
|
|
61
|
+
__prettierFix: prettierFix,
|
|
60
62
|
__lint: yamlLint.lint,
|
|
61
63
|
};
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import lintStaged from 'lint-staged';
|
|
2
|
+
import firostError from 'firost/error.js';
|
|
3
|
+
import helper from '../../helper.js';
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
export default {
|
|
6
6
|
async run(cliArgs) {
|
|
7
7
|
// Config
|
|
8
8
|
const configPath = await helper.configFile(
|
|
9
9
|
cliArgs.config,
|
|
10
|
-
'.lintstagedrc.
|
|
11
|
-
'lib/configs/lintstaged.
|
|
10
|
+
'.lintstagedrc.cjs',
|
|
11
|
+
'lib/configs/lintstaged.cjs',
|
|
12
12
|
);
|
|
13
13
|
|
|
14
14
|
try {
|
|
@@ -19,7 +19,7 @@ module.exports = {
|
|
|
19
19
|
if (!result) {
|
|
20
20
|
throw firostError(
|
|
21
21
|
'ERROR_PRECOMMIT_LINT_FAILED',
|
|
22
|
-
'Precommit linting failed'
|
|
22
|
+
'Precommit linting failed',
|
|
23
23
|
);
|
|
24
24
|
}
|
|
25
25
|
} catch (error) {
|
package/commands/readme/index.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
import helper from '../../helper.js';
|
|
2
|
+
import _ from 'golgoth/lodash.js';
|
|
3
|
+
import pMap from 'golgoth/pMap.js';
|
|
4
|
+
import readJson from 'firost/readJson.js';
|
|
5
|
+
import read from 'firost/read.js';
|
|
6
|
+
import write from 'firost/write.js';
|
|
7
|
+
import glob from 'firost/glob.js';
|
|
8
|
+
import exists from 'firost/exists.js';
|
|
9
|
+
import path from 'path';
|
|
10
|
+
import frontMatter from 'front-matter';
|
|
11
|
+
import dedent from 'golgoth/dedent.js';
|
|
12
|
+
|
|
13
|
+
export default {
|
|
14
14
|
/**
|
|
15
15
|
* Update the main README.md based on the template and the documentation
|
|
16
16
|
* @param {object} cliArgs CLI Argument object, as created by minimist
|
|
@@ -59,7 +59,7 @@ module.exports = {
|
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
const aberlaasDefaultTemplate = helper.aberlaasPath(
|
|
62
|
-
'templates/_github/README.template.md'
|
|
62
|
+
'templates/_github/README.template.md',
|
|
63
63
|
);
|
|
64
64
|
return await read(aberlaasDefaultTemplate);
|
|
65
65
|
},
|
|
@@ -141,7 +141,7 @@ module.exports = {
|
|
|
141
141
|
const packagePath = await this.getPackagePath(cliArgs);
|
|
142
142
|
const moduleReadmePath = path.resolve(
|
|
143
143
|
path.dirname(packagePath),
|
|
144
|
-
'README.md'
|
|
144
|
+
'README.md',
|
|
145
145
|
);
|
|
146
146
|
|
|
147
147
|
const readmes = _.uniq([hostReadmePath, moduleReadmePath]);
|
|
@@ -169,7 +169,7 @@ module.exports = {
|
|
|
169
169
|
const key = match.groups.key;
|
|
170
170
|
convertedSource = convertedSource.replace(
|
|
171
171
|
`{${key}}`,
|
|
172
|
-
_.get(data, key, '')
|
|
172
|
+
_.get(data, key, ''),
|
|
173
173
|
);
|
|
174
174
|
});
|
|
175
175
|
return convertedSource;
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const helper = require('../helper');
|
|
1
|
+
import _ from 'golgoth/lodash.js';
|
|
2
|
+
import run from 'firost/run.js';
|
|
3
|
+
import readJson from 'firost/readJson.js';
|
|
4
|
+
import helper from '../../helper.js';
|
|
6
5
|
|
|
7
|
-
|
|
6
|
+
export default {
|
|
8
7
|
/**
|
|
9
8
|
* Release the host package.
|
|
10
9
|
* @param {object} cliArgs CLI Argument object, as created by minimist
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import circleciHelper from '../helpers/circleci.js';
|
|
2
|
+
import githubHelper from '../helpers/github.js';
|
|
3
|
+
import npmHelper from '../helpers/npm.js';
|
|
4
|
+
import consoleInfo from 'firost/consoleInfo.js';
|
|
5
|
+
import consoleSuccess from 'firost/consoleSuccess.js';
|
|
6
|
+
import pMap from 'golgoth/pMap.js';
|
|
7
|
+
|
|
8
|
+
export default {
|
|
8
9
|
/**
|
|
9
10
|
* Save an ENV variable to CircleCI
|
|
10
11
|
* @param {string} name Name of the ENV variable
|
|
@@ -17,7 +18,7 @@ module.exports = {
|
|
|
17
18
|
`project/github/${username}/${repo}/envvar/${name}`,
|
|
18
19
|
{
|
|
19
20
|
method: 'delete',
|
|
20
|
-
}
|
|
21
|
+
},
|
|
21
22
|
);
|
|
22
23
|
} catch (err) {
|
|
23
24
|
// Ignoring the error, it means the ENV var wasn't set in the first place
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
import envVars from './envVars.js';
|
|
2
|
+
import privateKey from './privateKey.js';
|
|
3
|
+
import publicKey from './publicKey.js';
|
|
4
|
+
import sshHelper from '../helpers/ssh.js';
|
|
5
|
+
import npmHelper from '../helpers/npm.js';
|
|
6
|
+
import githubHelper from '../helpers/github.js';
|
|
7
|
+
import circleciHelper from '../helpers/circleci.js';
|
|
8
|
+
import _ from 'golgoth/lodash.js';
|
|
9
|
+
import consoleError from 'firost/consoleError.js';
|
|
10
|
+
|
|
11
|
+
export default {
|
|
11
12
|
/**
|
|
12
13
|
* Enable autoRelease by configuring CircleCI and GitHub
|
|
13
14
|
* @returns {boolean} True if enabled, false otherwise
|
|
@@ -17,7 +18,7 @@ module.exports = {
|
|
|
17
18
|
const validationErrors = await this.validationErrors();
|
|
18
19
|
if (!_.isEmpty(validationErrors)) {
|
|
19
20
|
this.__consoleError(
|
|
20
|
-
'[autoRelease] Please fix the following errors and try again:'
|
|
21
|
+
'[autoRelease] Please fix the following errors and try again:',
|
|
21
22
|
);
|
|
22
23
|
_.each(validationErrors, (error) => {
|
|
23
24
|
this.__consoleError(error);
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import circleciHelper from '../helpers/circleci.js';
|
|
2
|
+
import githubHelper from '../helpers/github.js';
|
|
3
|
+
import sshHelper from '../helpers/ssh.js';
|
|
4
|
+
import consoleSuccess from 'firost/consoleSuccess.js';
|
|
5
|
+
|
|
6
|
+
export default {
|
|
6
7
|
/**
|
|
7
8
|
* Save a private SSH key on CircleCI.
|
|
8
9
|
* The CircleCI API does not allow checking if a SSH key has been defined,
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import githubHelper from '../helpers/github.js';
|
|
2
|
+
import sshHelper from '../helpers/ssh.js';
|
|
3
|
+
import _ from 'golgoth/lodash.js';
|
|
4
|
+
import consoleInfo from 'firost/consoleInfo.js';
|
|
5
|
+
import consoleSuccess from 'firost/consoleSuccess.js';
|
|
6
|
+
import consoleError from 'firost/consoleError.js';
|
|
7
|
+
|
|
8
|
+
export default {
|
|
8
9
|
/**
|
|
9
10
|
* Check if SSH public key is already added to GitHub
|
|
10
11
|
* @returns {boolean} True if already enabled, false otherwise
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import githubHelper from './helpers/github.js';
|
|
2
|
+
import circleCiHelper from './helpers/circleci.js';
|
|
3
|
+
import _ from 'golgoth/lodash.js';
|
|
4
|
+
import consoleInfo from 'firost/consoleInfo.js';
|
|
5
|
+
import consoleSuccess from 'firost/consoleSuccess.js';
|
|
6
|
+
import consoleError from 'firost/consoleError.js';
|
|
7
|
+
|
|
8
|
+
export default {
|
|
8
9
|
/**
|
|
9
10
|
* Attempt to automatically follow the repo in CircleCI if possible, otherwise
|
|
10
11
|
* display the link to follow it manually
|
|
@@ -18,7 +19,7 @@ module.exports = {
|
|
|
18
19
|
// Fail early if no token available
|
|
19
20
|
if (!circleCiHelper.hasToken()) {
|
|
20
21
|
this.__consoleError(
|
|
21
|
-
`[circleci]: No CIRCLECI_TOKEN found, please visit ${followUrl} to enable manually
|
|
22
|
+
`[circleci]: No CIRCLECI_TOKEN found, please visit ${followUrl} to enable manually.`,
|
|
22
23
|
);
|
|
23
24
|
return false;
|
|
24
25
|
}
|
package/commands/setup/github.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import githubHelper from './helpers/github.js';
|
|
2
|
+
import consoleSuccess from 'firost/consoleSuccess.js';
|
|
3
|
+
import consoleError from 'firost/consoleError.js';
|
|
4
|
+
|
|
5
|
+
export default {
|
|
5
6
|
/**
|
|
6
7
|
* Configure the GitHub repo with default settings:
|
|
7
8
|
* - Do not enable merge commits on PR
|
|
@@ -16,7 +17,7 @@ module.exports = {
|
|
|
16
17
|
// Fail early if no token available
|
|
17
18
|
if (!githubHelper.hasToken()) {
|
|
18
19
|
this.__consoleError(
|
|
19
|
-
`[github]: No GITHUB_TOKEN found, please visit ${manualUrl} to configure manually
|
|
20
|
+
`[github]: No GITHUB_TOKEN found, please visit ${manualUrl} to configure manually.`,
|
|
20
21
|
);
|
|
21
22
|
return false;
|
|
22
23
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import got from 'golgoth/got.js';
|
|
2
|
+
import _ from 'golgoth/lodash.js';
|
|
3
|
+
import firostError from 'firost/error.js';
|
|
4
|
+
|
|
5
|
+
export default {
|
|
5
6
|
/**
|
|
6
7
|
* Returns the CircleCI token saved in ENV
|
|
7
8
|
* @returns {string} The CircleCI token
|
|
@@ -35,7 +36,7 @@ module.exports = {
|
|
|
35
36
|
} catch (error) {
|
|
36
37
|
throw firostError(
|
|
37
38
|
'ERROR_CIRCLECI',
|
|
38
|
-
"Can't connect to CircleCI API. Check that you have a valid CIRCLECI_TOKEN"
|
|
39
|
+
"Can't connect to CircleCI API. Check that you have a valid CIRCLECI_TOKEN",
|
|
39
40
|
);
|
|
40
41
|
}
|
|
41
42
|
},
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import run from 'firost/run.js';
|
|
2
|
+
import { Octokit } from '@octokit/rest';
|
|
3
|
+
import parseGithubUrl from 'parse-github-repo-url';
|
|
4
|
+
import _ from 'golgoth/lodash.js';
|
|
5
|
+
|
|
6
|
+
export default {
|
|
6
7
|
/**
|
|
7
8
|
* Returns the GitHub token saved in ENV
|
|
8
9
|
* @returns {string} The GitHub token
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
import helper from '../../../helper.js';
|
|
2
|
+
import githubHelper from './github.js';
|
|
3
|
+
import _ from 'golgoth/lodash.js';
|
|
4
|
+
import which from 'firost/which.js';
|
|
5
|
+
import exists from 'firost/exists.js';
|
|
6
|
+
import read from 'firost/read.js';
|
|
7
|
+
import run from 'firost/run.js';
|
|
8
|
+
import mkdirp from 'firost/mkdirp.js';
|
|
9
|
+
import path from 'path';
|
|
10
|
+
|
|
11
|
+
export default {
|
|
11
12
|
/**
|
|
12
13
|
* Check if ssh-keygen is available
|
|
13
14
|
* @returns {boolean} True if available, false otherwise
|
package/commands/setup/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import github from './github.js';
|
|
2
|
+
import circleci from './circleci.js';
|
|
3
|
+
import renovate from './renovate.js';
|
|
4
|
+
import autoRelease from './autoRelease/index.js';
|
|
5
|
+
import _ from 'golgoth/lodash.js';
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
export default {
|
|
8
8
|
/**
|
|
9
9
|
* Enable external services.
|
|
10
10
|
* Will enable CircleCI, GitHub and Renovate by default.
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import githubHelper from './helpers/github.js';
|
|
2
|
+
import consoleSuccess from 'firost/consoleSuccess.js';
|
|
3
|
+
import consoleError from 'firost/consoleError.js';
|
|
4
|
+
|
|
5
|
+
export default {
|
|
5
6
|
renovateId: 2471197,
|
|
6
7
|
/**
|
|
7
8
|
* Returns the GitHub repository Id
|
|
@@ -28,7 +29,7 @@ module.exports = {
|
|
|
28
29
|
// Fail early if no token available
|
|
29
30
|
if (!githubHelper.hasToken()) {
|
|
30
31
|
this.__consoleError(
|
|
31
|
-
`[renovate]: No GITHUB_TOKEN found, please visit ${manualUrl} to enable manually
|
|
32
|
+
`[renovate]: No GITHUB_TOKEN found, please visit ${manualUrl} to enable manually.`,
|
|
32
33
|
);
|
|
33
34
|
return false;
|
|
34
35
|
}
|
|
@@ -41,7 +42,7 @@ module.exports = {
|
|
|
41
42
|
});
|
|
42
43
|
} catch (err) {
|
|
43
44
|
this.__consoleError(
|
|
44
|
-
`Renovate is not installed with this GitHub account, please visit ${manualUrl} to install it first
|
|
45
|
+
`Renovate is not installed with this GitHub account, please visit ${manualUrl} to install it first.`,
|
|
45
46
|
);
|
|
46
47
|
return false;
|
|
47
48
|
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import helper from '../../helper.js';
|
|
2
|
+
import run from 'firost/run.js';
|
|
3
|
+
import _ from 'golgoth/lodash.js';
|
|
4
|
+
|
|
5
|
+
export default {
|
|
6
|
+
/**
|
|
7
|
+
* Test all files using Vitest
|
|
8
|
+
* Usage:
|
|
9
|
+
* $ aberlaas test # Test all files
|
|
10
|
+
* $ aberlaas test ./path/to/__tests__/file.js # Test specific files
|
|
11
|
+
* $ aberlaas test ./path/to/file.js # Test specific files
|
|
12
|
+
* $ aberlaas test --related # Test all related files
|
|
13
|
+
* $ aberlaas test --failFast # Stop early as soon as one test fails
|
|
14
|
+
* $ aberlaas test --flags # Flags passed to vitest
|
|
15
|
+
* @param {object} cliArgs CLI Argument object, as created by minimist
|
|
16
|
+
* @returns {boolean} true on success
|
|
17
|
+
**/
|
|
18
|
+
async run(cliArgs) {
|
|
19
|
+
const options = await this.vitestCliOptions(cliArgs);
|
|
20
|
+
const binary = await helper.which('vitest');
|
|
21
|
+
|
|
22
|
+
await run(`${binary} ${options.join(' ')}`, { stdin: true });
|
|
23
|
+
return true;
|
|
24
|
+
},
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Transform all aberlaas test cli options into suitable vitest CLI options
|
|
28
|
+
* @param {object} cliArgs CLI Argument object, as created by minimist
|
|
29
|
+
* @returns {Array} Array of cli arguments and values
|
|
30
|
+
**/
|
|
31
|
+
async vitestCliOptions(cliArgs = {}) {
|
|
32
|
+
// Options that have special meaning in aberlaas and shouldn't be passed
|
|
33
|
+
// as-is to vitest
|
|
34
|
+
const aberlaasOptions = ['_', 'watch', 'config', 'failFast', 'related'];
|
|
35
|
+
|
|
36
|
+
// Input files
|
|
37
|
+
const inputFiles = _.isEmpty(cliArgs._) ? [helper.hostPath()] : cliArgs._;
|
|
38
|
+
const vitestOptions = [...inputFiles];
|
|
39
|
+
|
|
40
|
+
// Run "vitest related" when --related is passed
|
|
41
|
+
if (cliArgs.related) {
|
|
42
|
+
vitestOptions.unshift('related');
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// Stop early as soon as one test fails
|
|
46
|
+
if (cliArgs.failFast) {
|
|
47
|
+
vitestOptions.push('--bail=1');
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// Disable watch by default
|
|
51
|
+
vitestOptions.push(cliArgs.watch ? '--watch=true' : '--watch=false');
|
|
52
|
+
|
|
53
|
+
// Allow a success, even if no files are passed
|
|
54
|
+
vitestOptions.push('--passWithNoTests');
|
|
55
|
+
|
|
56
|
+
// Hide skipped tests, allowing less noisy debug with fit/fdescribe
|
|
57
|
+
vitestOptions.push('--hideSkippedTests');
|
|
58
|
+
|
|
59
|
+
// Config file
|
|
60
|
+
const configFile = await helper.configFile(
|
|
61
|
+
cliArgs.config,
|
|
62
|
+
'vite.config.js',
|
|
63
|
+
'lib/configs/vite.js',
|
|
64
|
+
);
|
|
65
|
+
vitestOptions.push(`--config=${configFile}`);
|
|
66
|
+
|
|
67
|
+
// Pass any unknown options to vitest
|
|
68
|
+
_.each(cliArgs, (argValue, argKey) => {
|
|
69
|
+
// Skip keys that we already handled
|
|
70
|
+
if (_.includes(aberlaasOptions, argKey)) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
if (argValue === true) {
|
|
75
|
+
vitestOptions.push(`--${argKey}`);
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
vitestOptions.push(`--${argKey}=${argValue}`);
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
return vitestOptions;
|
|
83
|
+
},
|
|
84
|
+
};
|
|
@@ -1,27 +1,21 @@
|
|
|
1
|
-
const nodeConfig = require('./node');
|
|
1
|
+
const nodeConfig = require('./node.cjs');
|
|
2
2
|
module.exports = {
|
|
3
3
|
env: {
|
|
4
4
|
browser: true,
|
|
5
|
-
|
|
5
|
+
es2023: true,
|
|
6
6
|
node: true,
|
|
7
|
-
jest: true,
|
|
8
7
|
},
|
|
9
8
|
parserOptions: {
|
|
10
|
-
|
|
9
|
+
sourceType: 'module',
|
|
10
|
+
ecmaVersion: 'latest',
|
|
11
11
|
},
|
|
12
12
|
extends: [
|
|
13
13
|
'eslint:recommended',
|
|
14
|
-
'plugin:
|
|
15
|
-
'plugin:
|
|
14
|
+
'plugin:n/recommended',
|
|
15
|
+
'plugin:import/recommended',
|
|
16
16
|
'plugin:prettier/recommended',
|
|
17
17
|
],
|
|
18
|
-
|
|
19
|
-
// Additional Jest globals added by Aberlaas
|
|
20
|
-
testName: false,
|
|
21
|
-
captureOutput: false,
|
|
22
|
-
dedent: false,
|
|
23
|
-
},
|
|
24
|
-
plugins: ['jest', 'jsdoc', 'prettier'],
|
|
18
|
+
plugins: ['jsdoc', 'prettier'],
|
|
25
19
|
rules: {
|
|
26
20
|
'dot-notation': ['error'],
|
|
27
21
|
'max-len': [
|
|
@@ -63,33 +57,20 @@ module.exports = {
|
|
|
63
57
|
'quote-props': ['error', 'as-needed'],
|
|
64
58
|
quotes: ['error', 'single', { avoidEscape: true }],
|
|
65
59
|
// Node
|
|
66
|
-
'
|
|
67
|
-
'error',
|
|
68
|
-
{
|
|
69
|
-
version: `>=${nodeConfig.nodeVersion}`,
|
|
70
|
-
},
|
|
71
|
-
],
|
|
72
|
-
'node/no-unsupported-features/node-builtins': [
|
|
60
|
+
'n/no-unsupported-features/es-syntax': [
|
|
73
61
|
'error',
|
|
74
62
|
{
|
|
75
63
|
version: `>=${nodeConfig.nodeVersion}`,
|
|
76
64
|
},
|
|
77
65
|
],
|
|
78
|
-
//
|
|
79
|
-
'
|
|
80
|
-
'jest/no-test-prefixes': 0,
|
|
81
|
-
'jest/prefer-called-with': 0,
|
|
82
|
-
'jest/prefer-spy-on': ['error'],
|
|
83
|
-
'jest/prefer-todo': 0,
|
|
84
|
-
'jest/prefer-to-contain': ['error'],
|
|
85
|
-
'jest/prefer-to-have-length': ['error'],
|
|
86
|
-
'jest/valid-title': ['error'],
|
|
66
|
+
// Import
|
|
67
|
+
'import/no-cycle': ['error'],
|
|
87
68
|
// JSDoc
|
|
88
69
|
'jsdoc/check-param-names': ['warn'],
|
|
89
70
|
'jsdoc/check-types': ['warn'],
|
|
90
71
|
'jsdoc/no-undefined-types': ['warn'],
|
|
91
72
|
'jsdoc/check-alignment': ['warn'],
|
|
92
|
-
'jsdoc/check-examples': ['
|
|
73
|
+
'jsdoc/check-examples': ['off'],
|
|
93
74
|
'jsdoc/check-syntax': ['warn'],
|
|
94
75
|
'jsdoc/check-tag-names': ['warn'],
|
|
95
76
|
'jsdoc/require-jsdoc': ['warn'],
|
|
@@ -106,6 +87,58 @@ module.exports = {
|
|
|
106
87
|
'prettier/prettier': 'error',
|
|
107
88
|
},
|
|
108
89
|
overrides: [
|
|
90
|
+
// Vitest
|
|
91
|
+
{
|
|
92
|
+
files: ['**/__tests__/**/*.js'],
|
|
93
|
+
env: {
|
|
94
|
+
'vitest-globals/env': true,
|
|
95
|
+
},
|
|
96
|
+
globals: {
|
|
97
|
+
// Test name
|
|
98
|
+
testName: false,
|
|
99
|
+
// Shorter method names
|
|
100
|
+
fit: false,
|
|
101
|
+
ftest: false,
|
|
102
|
+
fdescribe: false,
|
|
103
|
+
xit: false,
|
|
104
|
+
xtest: false,
|
|
105
|
+
xdescribe: false,
|
|
106
|
+
|
|
107
|
+
captureOutput: false,
|
|
108
|
+
dedent: false,
|
|
109
|
+
},
|
|
110
|
+
extends: [
|
|
111
|
+
'plugin:vitest/recommended',
|
|
112
|
+
'plugin:vitest-globals/recommended',
|
|
113
|
+
],
|
|
114
|
+
rules: {
|
|
115
|
+
'no-restricted-globals': [
|
|
116
|
+
'warn',
|
|
117
|
+
{
|
|
118
|
+
name: 'fit',
|
|
119
|
+
message: 'No focused test',
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
name: 'fdescribe',
|
|
123
|
+
message: 'No focused tests',
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
name: 'xit',
|
|
127
|
+
message: 'No skipped test',
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
name: 'xdescribe',
|
|
131
|
+
message: 'No skipped tests',
|
|
132
|
+
},
|
|
133
|
+
],
|
|
134
|
+
'vitest/consistent-test-it': ['warn', { fn: 'it' }],
|
|
135
|
+
// Disabling vitest/no-identical-title
|
|
136
|
+
// It can make eslint crash when used with fit/xit/fdescribe/xdescribe
|
|
137
|
+
// See: https://github.com/veritem/eslint-plugin-vitest/issues/310
|
|
138
|
+
'vitest/no-identical-title': ['off'],
|
|
139
|
+
'vitest/prefer-to-contain': ['error'],
|
|
140
|
+
},
|
|
141
|
+
},
|
|
109
142
|
// no-process-exit
|
|
110
143
|
// We need to send clear exit codes in yarn run scripts
|
|
111
144
|
{
|