aberlaas 2.9.0 → 2.11.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/bin/aberlaas.js +1 -1
- package/configs/eslint.js +3 -0
- package/configs/lintstaged.js +2 -24
- package/configs/prettier.js +3 -4
- package/configs/stylelint.js +3 -41
- package/configs/vite.js +2 -41
- package/{main.js → lib/main.js} +26 -30
- package/package.json +37 -45
- package/commands/ci/index.js +0 -47
- package/commands/compress/dummy.js +0 -11
- package/commands/compress/index.js +0 -41
- package/commands/compress/png.js +0 -49
- package/commands/init/helper.js +0 -192
- package/commands/init/index.js +0 -59
- package/commands/init/module.js +0 -111
- package/commands/init/monorepo.js +0 -261
- package/commands/lint/circleci.js +0 -81
- package/commands/lint/css.js +0 -73
- package/commands/lint/helpers/prettier.js +0 -54
- package/commands/lint/index.js +0 -50
- package/commands/lint/js.js +0 -73
- package/commands/lint/json.js +0 -60
- package/commands/lint/yml.js +0 -62
- package/commands/precommit/index.js +0 -33
- package/commands/readme/index.js +0 -181
- package/commands/setup/circleci.js +0 -60
- package/commands/setup/github.js +0 -42
- package/commands/setup/helpers/circleci.js +0 -43
- package/commands/setup/helpers/github.js +0 -72
- package/commands/setup/helpers/npm.js +0 -16
- package/commands/setup/helpers/ssh.js +0 -77
- package/commands/setup/index.js +0 -52
- package/commands/setup/renovate.js +0 -54
- package/commands/test/index.js +0 -124
- package/configs/eslint.cjs +0 -154
- package/configs/node.cjs +0 -9
- package/configs/vite/test/setupFiles/captureOutput.js +0 -4
- package/configs/vite/test/setupFiles/dedent.js +0 -4
- package/configs/vite/test/setupFiles/fit-xit-fdescribe-xdescribe.js +0 -13
- package/configs/vite/test/setupFiles/jest-extended.js +0 -10
- package/configs/vite/test/setupFiles/testName.js +0 -9
- package/helper.js +0 -115
- package/templates/LICENSE +0 -9
- package/templates/_circleci/config.yml +0 -42
- package/templates/_eslintignore.conf +0 -12
- package/templates/_eslintrc.cjs +0 -3
- package/templates/_gitattributes +0 -4
- package/templates/_github/README.template.md +0 -7
- package/templates/_github/renovate.json +0 -3
- package/templates/_gitignore +0 -29
- package/templates/_yarnrc.yml +0 -15
- package/templates/lerna.json +0 -6
- package/templates/lib/__tests__/main.js +0 -13
- package/templates/lib/main.js +0 -5
- package/templates/lintstaged.config.js +0 -5
- package/templates/prettier.config.js +0 -5
- package/templates/scripts/ci +0 -6
- package/templates/scripts/compress +0 -4
- package/templates/scripts/docs/build +0 -4
- package/templates/scripts/docs/build-prod +0 -4
- package/templates/scripts/docs/cms +0 -4
- package/templates/scripts/docs/serve +0 -4
- package/templates/scripts/hooks/pre-commit +0 -11
- package/templates/scripts/lib/release +0 -5
- package/templates/scripts/lib/test +0 -5
- package/templates/scripts/lib/test-watch +0 -5
- package/templates/scripts/lint +0 -4
- package/templates/scripts/lint-fix +0 -4
- package/templates/stylelint.config.js +0 -5
- package/templates/vite.config.js +0 -5
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { _, got } from 'golgoth';
|
|
2
|
-
import { firostError } from 'firost';
|
|
3
|
-
|
|
4
|
-
export default {
|
|
5
|
-
/**
|
|
6
|
-
* Returns the CircleCI token saved in ENV
|
|
7
|
-
* @returns {string} The CircleCI token
|
|
8
|
-
**/
|
|
9
|
-
token() {
|
|
10
|
-
return process.env.CIRCLECI_TOKEN;
|
|
11
|
-
},
|
|
12
|
-
/**
|
|
13
|
-
* Check if a CircleCI token is available
|
|
14
|
-
* @returns {boolean} True if a token is defined
|
|
15
|
-
**/
|
|
16
|
-
hasToken() {
|
|
17
|
-
return !!this.token();
|
|
18
|
-
},
|
|
19
|
-
/**
|
|
20
|
-
* Make a call to the CircleCI v1 API
|
|
21
|
-
* @param {string} urlPath Part of the url after the /api/v1.1/
|
|
22
|
-
* @param {object} userGotOptions Options to pass to the got call
|
|
23
|
-
* @returns {object} Object returned by the API
|
|
24
|
-
**/
|
|
25
|
-
async api(urlPath, userGotOptions = {}) {
|
|
26
|
-
const token = this.token();
|
|
27
|
-
const apiUrl = `https://circleci.com/api/v1.1/${urlPath}?circle-token=${token}`;
|
|
28
|
-
const defaultGotOptions = {
|
|
29
|
-
responseType: 'json',
|
|
30
|
-
};
|
|
31
|
-
const gotOptions = _.merge({}, defaultGotOptions, userGotOptions);
|
|
32
|
-
try {
|
|
33
|
-
const response = await this.__got(apiUrl, gotOptions);
|
|
34
|
-
return response.body;
|
|
35
|
-
} catch (error) {
|
|
36
|
-
throw firostError(
|
|
37
|
-
'ERROR_CIRCLECI',
|
|
38
|
-
"Can't connect to CircleCI API. Check that you have a valid CIRCLECI_TOKEN",
|
|
39
|
-
);
|
|
40
|
-
}
|
|
41
|
-
},
|
|
42
|
-
__got: got,
|
|
43
|
-
};
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import { run } from 'firost';
|
|
2
|
-
import { Octokit } from '@octokit/rest';
|
|
3
|
-
import parseGithubUrl from 'parse-github-repo-url';
|
|
4
|
-
import { _ } from 'golgoth';
|
|
5
|
-
|
|
6
|
-
export default {
|
|
7
|
-
/**
|
|
8
|
-
* Returns the GitHub token saved in ENV
|
|
9
|
-
* @returns {string} The GitHub token
|
|
10
|
-
**/
|
|
11
|
-
token() {
|
|
12
|
-
return process.env.GITHUB_TOKEN;
|
|
13
|
-
},
|
|
14
|
-
/**
|
|
15
|
-
* Check if a GitHub token is available
|
|
16
|
-
* @returns {boolean} True if a token is defined
|
|
17
|
-
**/
|
|
18
|
-
hasToken() {
|
|
19
|
-
return !!this.token();
|
|
20
|
-
},
|
|
21
|
-
/**
|
|
22
|
-
* Returns some data from the git config
|
|
23
|
-
* @returns {object} Object with .username, .repo and .email keys
|
|
24
|
-
**/
|
|
25
|
-
async repoData() {
|
|
26
|
-
if (this.__cache.repoData) {
|
|
27
|
-
return this.__cache.repoData;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
const email = await this.config('user.email');
|
|
31
|
-
const remoteUrl = await this.config('remote.origin.url');
|
|
32
|
-
const [username, repo] = parseGithubUrl(remoteUrl);
|
|
33
|
-
|
|
34
|
-
const result = { username, repo, email };
|
|
35
|
-
this.__cache.githubData = result;
|
|
36
|
-
return result;
|
|
37
|
-
},
|
|
38
|
-
/**
|
|
39
|
-
* Return the value of a git config
|
|
40
|
-
* @param {string} key Config key
|
|
41
|
-
* @returns {string} Config value
|
|
42
|
-
**/
|
|
43
|
-
async config(key) {
|
|
44
|
-
const response = await this.__run(`git config ${key}`, {
|
|
45
|
-
stdout: false,
|
|
46
|
-
});
|
|
47
|
-
return response.stdout;
|
|
48
|
-
},
|
|
49
|
-
/**
|
|
50
|
-
* Wraps Octokit and return the results
|
|
51
|
-
* @param {string} methodPath Path of the method to call
|
|
52
|
-
* @param {object} options Options to pass to the method
|
|
53
|
-
* @returns {*} Response from the API
|
|
54
|
-
**/
|
|
55
|
-
async octokit(methodPath, options) {
|
|
56
|
-
// Instanciate Octokit if not available
|
|
57
|
-
if (!this.__cache.octokit) {
|
|
58
|
-
const githubToken = this.token();
|
|
59
|
-
this.__cache.octokit = new this.__Octokit({
|
|
60
|
-
auth: githubToken,
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
const octokit = this.__cache.octokit;
|
|
65
|
-
const method = _.get(octokit, methodPath);
|
|
66
|
-
const response = await method(options);
|
|
67
|
-
return response.data;
|
|
68
|
-
},
|
|
69
|
-
__run: run,
|
|
70
|
-
__Octokit: Octokit,
|
|
71
|
-
__cache: {},
|
|
72
|
-
};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
export default {
|
|
2
|
-
/**
|
|
3
|
-
* Returns the npm token saved in ENV
|
|
4
|
-
* @returns {string} The npm token
|
|
5
|
-
**/
|
|
6
|
-
token() {
|
|
7
|
-
return process.env.NPM_TOKEN;
|
|
8
|
-
},
|
|
9
|
-
/**
|
|
10
|
-
* Check if a npm token is available
|
|
11
|
-
* @returns {boolean} True if a token is defined
|
|
12
|
-
**/
|
|
13
|
-
hasToken() {
|
|
14
|
-
return !!this.token();
|
|
15
|
-
},
|
|
16
|
-
};
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import path from 'path';
|
|
2
|
-
import { _ } from 'golgoth';
|
|
3
|
-
import { exists, mkdirp, read, run, which } from 'firost';
|
|
4
|
-
import helper from '../../../helper.js';
|
|
5
|
-
import githubHelper from './github.js';
|
|
6
|
-
|
|
7
|
-
export default {
|
|
8
|
-
/**
|
|
9
|
-
* Check if ssh-keygen is available
|
|
10
|
-
* @returns {boolean} True if available, false otherwise
|
|
11
|
-
**/
|
|
12
|
-
async hasBinary() {
|
|
13
|
-
const sshKeygenPath = await this.__which('ssh-keygen');
|
|
14
|
-
return !!sshKeygenPath;
|
|
15
|
-
},
|
|
16
|
-
/**
|
|
17
|
-
* Returns SSH keys (generate them if needed)
|
|
18
|
-
* @returns {object} Object with .public, .private and .privateFingerprint
|
|
19
|
-
**/
|
|
20
|
-
async getKeys() {
|
|
21
|
-
const keyPath = helper.hostPath('./tmp/ssh/key');
|
|
22
|
-
|
|
23
|
-
// Generating keys if do not exist
|
|
24
|
-
const keyExists = await exists(keyPath);
|
|
25
|
-
if (!keyExists) {
|
|
26
|
-
await this.generateKeys(keyPath);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
const publicKeyPath = `${keyPath}.pub`;
|
|
30
|
-
const publicKey = await read(publicKeyPath);
|
|
31
|
-
const privateKey = await read(keyPath);
|
|
32
|
-
const privateFingerprint = await this.getFingerprint(keyPath);
|
|
33
|
-
|
|
34
|
-
return {
|
|
35
|
-
public: publicKey,
|
|
36
|
-
private: privateKey,
|
|
37
|
-
privateFingerprint,
|
|
38
|
-
};
|
|
39
|
-
},
|
|
40
|
-
/**
|
|
41
|
-
* Generate SSH keys
|
|
42
|
-
* @param {string} keyPath Path to the public key
|
|
43
|
-
**/
|
|
44
|
-
async generateKeys(keyPath) {
|
|
45
|
-
const keyDirectory = path.dirname(keyPath);
|
|
46
|
-
await mkdirp(keyDirectory);
|
|
47
|
-
const { email: keyEmail } = await githubHelper.repoData();
|
|
48
|
-
const sshKeygenArguments = [
|
|
49
|
-
'-m PEM',
|
|
50
|
-
'-t rsa',
|
|
51
|
-
`-C ${keyEmail}`,
|
|
52
|
-
`-f ${keyPath}`,
|
|
53
|
-
"-N ''",
|
|
54
|
-
];
|
|
55
|
-
const command = `ssh-keygen ${sshKeygenArguments.join(' ')}`;
|
|
56
|
-
// Need to run in shell mode, otherwise does not understand the empty
|
|
57
|
-
// passphrase
|
|
58
|
-
await this.__run(command, { shell: true, stdout: false });
|
|
59
|
-
},
|
|
60
|
-
/**
|
|
61
|
-
* Returns the md5 fingerprint from a key path
|
|
62
|
-
* @param {string} keyPath Filepath to the key file
|
|
63
|
-
* @returns {string} Fingerprint as used by CircleCI and GitHub
|
|
64
|
-
**/
|
|
65
|
-
async getFingerprint(keyPath) {
|
|
66
|
-
const command = `ssh-keygen -E md5 -l -f ${keyPath}`;
|
|
67
|
-
const result = await this.__run(command, { stdout: false });
|
|
68
|
-
return _.chain(result)
|
|
69
|
-
.get('stdout')
|
|
70
|
-
.split(' ')
|
|
71
|
-
.nth(1)
|
|
72
|
-
.replace('MD5:', '')
|
|
73
|
-
.value();
|
|
74
|
-
},
|
|
75
|
-
__which: which,
|
|
76
|
-
__run: run,
|
|
77
|
-
};
|
package/commands/setup/index.js
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { _ } from 'golgoth';
|
|
2
|
-
import github from './github.js';
|
|
3
|
-
import circleci from './circleci.js';
|
|
4
|
-
import renovate from './renovate.js';
|
|
5
|
-
|
|
6
|
-
export default {
|
|
7
|
-
/**
|
|
8
|
-
* Enable external services.
|
|
9
|
-
* Will enable CircleCI, GitHub and Renovate by default.
|
|
10
|
-
* @param {object} cliArgs CLI Argument object, as created by minimist
|
|
11
|
-
**/
|
|
12
|
-
async run(cliArgs = {}) {
|
|
13
|
-
const defaultServices = {
|
|
14
|
-
circleci: true,
|
|
15
|
-
renovate: true,
|
|
16
|
-
github: true,
|
|
17
|
-
};
|
|
18
|
-
const cliServices = _.omit(cliArgs, ['_']);
|
|
19
|
-
const servicesToEnable = {
|
|
20
|
-
...defaultServices,
|
|
21
|
-
...cliServices,
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
if (servicesToEnable.github) {
|
|
25
|
-
await this.github();
|
|
26
|
-
}
|
|
27
|
-
if (servicesToEnable.circleci) {
|
|
28
|
-
await this.circleci();
|
|
29
|
-
}
|
|
30
|
-
if (servicesToEnable.renovate) {
|
|
31
|
-
await this.renovate();
|
|
32
|
-
}
|
|
33
|
-
},
|
|
34
|
-
/**
|
|
35
|
-
* Configure GitHub
|
|
36
|
-
**/
|
|
37
|
-
async github() {
|
|
38
|
-
await github.enable();
|
|
39
|
-
},
|
|
40
|
-
/**
|
|
41
|
-
* Enable CircleCI
|
|
42
|
-
**/
|
|
43
|
-
async circleci() {
|
|
44
|
-
await circleci.enable();
|
|
45
|
-
},
|
|
46
|
-
/**
|
|
47
|
-
* Enable renovate
|
|
48
|
-
**/
|
|
49
|
-
async renovate() {
|
|
50
|
-
await renovate.enable();
|
|
51
|
-
},
|
|
52
|
-
};
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { consoleError, consoleSuccess } from 'firost';
|
|
2
|
-
import githubHelper from './helpers/github.js';
|
|
3
|
-
|
|
4
|
-
export default {
|
|
5
|
-
renovateId: 2471197,
|
|
6
|
-
/**
|
|
7
|
-
* Returns the GitHub repository Id
|
|
8
|
-
* @returns {number} Repository Id
|
|
9
|
-
**/
|
|
10
|
-
async getRepositoryId() {
|
|
11
|
-
const { username, repo } = await githubHelper.repoData();
|
|
12
|
-
const { id } = await githubHelper.octokit('repos.get', {
|
|
13
|
-
owner: username,
|
|
14
|
-
repo,
|
|
15
|
-
});
|
|
16
|
-
return id;
|
|
17
|
-
},
|
|
18
|
-
/**
|
|
19
|
-
* Attempt to automatically add the current repo to renovate, otherwise
|
|
20
|
-
* display the link to do it manually
|
|
21
|
-
* @returns {boolean} True if enabled, false otherwise
|
|
22
|
-
**/
|
|
23
|
-
async enable() {
|
|
24
|
-
const { username, repo } = await githubHelper.repoData();
|
|
25
|
-
const manualUrl = `https://github.com/settings/installations/${this.renovateId}`;
|
|
26
|
-
const renovateDashboardUrl = `https://app.renovatebot.com/dashboard#github/${username}/${repo}`;
|
|
27
|
-
|
|
28
|
-
// Fail early if no token available
|
|
29
|
-
if (!githubHelper.hasToken()) {
|
|
30
|
-
this.__consoleError(
|
|
31
|
-
`[renovate]: No GITHUB_TOKEN found, please visit ${manualUrl} to enable manually.`,
|
|
32
|
-
);
|
|
33
|
-
return false;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
try {
|
|
37
|
-
const repositoryId = await this.getRepositoryId();
|
|
38
|
-
await githubHelper.octokit('apps.addRepoToInstallation', {
|
|
39
|
-
installation_id: this.renovateId,
|
|
40
|
-
repository_id: repositoryId,
|
|
41
|
-
});
|
|
42
|
-
} catch (err) {
|
|
43
|
-
this.__consoleError(
|
|
44
|
-
`Renovate is not installed with this GitHub account, please visit ${manualUrl} to install it first.`,
|
|
45
|
-
);
|
|
46
|
-
return false;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
this.__consoleSuccess(`Renovate enabled: ${renovateDashboardUrl}`);
|
|
50
|
-
return true;
|
|
51
|
-
},
|
|
52
|
-
__consoleSuccess: consoleSuccess,
|
|
53
|
-
__consoleError: consoleError,
|
|
54
|
-
};
|
package/commands/test/index.js
DELETED
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
import { createVitest, registerConsoleShortcuts } from 'vitest/node';
|
|
2
|
-
import { firostError, firostImport } from 'firost';
|
|
3
|
-
import { _ } from 'golgoth';
|
|
4
|
-
import helper from '../../helper.js';
|
|
5
|
-
|
|
6
|
-
export default {
|
|
7
|
-
/**
|
|
8
|
-
* Test all files using Vitest
|
|
9
|
-
* Usage:
|
|
10
|
-
* $ aberlaas test # Test all files
|
|
11
|
-
* $ aberlaas test ./path/to/__tests__/file.js # Test specific files
|
|
12
|
-
* $ aberlaas test ./path/to/file.js # Test specific files
|
|
13
|
-
* $ aberlaas test --related # Test all related files
|
|
14
|
-
* $ aberlaas test --failFast # Stop early as soon as one test fails
|
|
15
|
-
* $ aberlaas test --flags # Flags passed to vitest
|
|
16
|
-
* @param {object} cliArgs CLI Argument object, as created by minimist
|
|
17
|
-
* @returns {boolean} true on success
|
|
18
|
-
**/
|
|
19
|
-
async run(cliArgs = {}) {
|
|
20
|
-
const options = await this.vitestOptions(cliArgs);
|
|
21
|
-
const isWatchMode = !!options.watch;
|
|
22
|
-
const isRelatedMode = options.related?.length > 0;
|
|
23
|
-
let files = _.isEmpty(cliArgs._) ? [helper.hostPath()] : cliArgs._;
|
|
24
|
-
// If --related is passed, the list of files will already by in the .related
|
|
25
|
-
// key, and need to be removed from the files
|
|
26
|
-
if (isRelatedMode) files = [];
|
|
27
|
-
|
|
28
|
-
// Vitest will change process.exitCode, so we save it to revert it later
|
|
29
|
-
const initialExitCode = process.exitCode;
|
|
30
|
-
|
|
31
|
-
const vitest = await createVitest('test', options);
|
|
32
|
-
|
|
33
|
-
// Enable keyboard interaction in watch mode
|
|
34
|
-
if (isWatchMode) {
|
|
35
|
-
registerConsoleShortcuts(vitest);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
try {
|
|
39
|
-
await vitest.start(files);
|
|
40
|
-
} catch (err) {
|
|
41
|
-
// We can safely swallow the VITEST_FILES_NOT_FOUND error. It's ok to
|
|
42
|
-
// continue if no files are found
|
|
43
|
-
if (err.code != 'VITEST_FILES_NOT_FOUND') {
|
|
44
|
-
throw err;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
const testsAreFailing = process.exitCode == 1;
|
|
49
|
-
process.exitCode = initialExitCode;
|
|
50
|
-
|
|
51
|
-
if (isWatchMode) {
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
// Stop vitest, it doesn't stop itself by default
|
|
56
|
-
await vitest.close();
|
|
57
|
-
|
|
58
|
-
if (testsAreFailing) {
|
|
59
|
-
throw firostError('ERROR_TEST_FAIL', 'Tests are failing');
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
return true;
|
|
63
|
-
},
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* Transform all aberlaas test cli options into suitable vitest options
|
|
67
|
-
* @param {object} cliArgs CLI Argument object, as created by minimist
|
|
68
|
-
* @returns {Array} Array of options for vitest
|
|
69
|
-
**/
|
|
70
|
-
async vitestOptions(cliArgs = {}) {
|
|
71
|
-
// Options that have special meaning in aberlaas and shouldn't be passed
|
|
72
|
-
// as-is to vitest
|
|
73
|
-
const specialMeaningCliArgs = [
|
|
74
|
-
'_',
|
|
75
|
-
'config',
|
|
76
|
-
'failFast',
|
|
77
|
-
'related',
|
|
78
|
-
'exclude',
|
|
79
|
-
];
|
|
80
|
-
|
|
81
|
-
// Reading base options from the config file
|
|
82
|
-
const configFile = await helper.configFile(
|
|
83
|
-
cliArgs.config,
|
|
84
|
-
'vite.config.js',
|
|
85
|
-
'configs/vite.js',
|
|
86
|
-
);
|
|
87
|
-
const optionsFromConfig = (await firostImport(configFile)).test;
|
|
88
|
-
|
|
89
|
-
// Enhancing options with custom CLI arguments
|
|
90
|
-
const optionsFromAberlaas = {
|
|
91
|
-
// We always allow fit/fdescribe, even in CI. Those errors will be caught
|
|
92
|
-
// by the lint command instead
|
|
93
|
-
allowOnly: true,
|
|
94
|
-
};
|
|
95
|
-
// --failFast stops early as soon as one test fails
|
|
96
|
-
if (cliArgs.failFast) {
|
|
97
|
-
optionsFromAberlaas.bail = 1;
|
|
98
|
-
}
|
|
99
|
-
// --related runs also related files
|
|
100
|
-
// Note (2024-10-01): The related option is not documented, but should
|
|
101
|
-
// contain the list of files.
|
|
102
|
-
if (cliArgs.related) {
|
|
103
|
-
optionsFromAberlaas.related = cliArgs._;
|
|
104
|
-
}
|
|
105
|
-
// --exclude arguments should be added to the existing list of exclude
|
|
106
|
-
// patterns
|
|
107
|
-
// TODO: Add test for that
|
|
108
|
-
if (cliArgs.exclude) {
|
|
109
|
-
optionsFromAberlaas.exclude = [
|
|
110
|
-
...optionsFromConfig.exclude,
|
|
111
|
-
cliArgs.exclude,
|
|
112
|
-
];
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
// Passing other CLI options directly to vitest
|
|
116
|
-
const optionsFromCli = _.omit(cliArgs, specialMeaningCliArgs);
|
|
117
|
-
|
|
118
|
-
return {
|
|
119
|
-
...optionsFromConfig,
|
|
120
|
-
...optionsFromAberlaas,
|
|
121
|
-
...optionsFromCli,
|
|
122
|
-
};
|
|
123
|
-
},
|
|
124
|
-
};
|
package/configs/eslint.cjs
DELETED
|
@@ -1,154 +0,0 @@
|
|
|
1
|
-
// Note: ESLint doesn't support ESM configuration as of 2024-02-19. This file
|
|
2
|
-
// needs to stay as a CommonJS file
|
|
3
|
-
const nodeConfig = require('./node.cjs');
|
|
4
|
-
|
|
5
|
-
module.exports = {
|
|
6
|
-
env: { browser: true, es2023: true, node: true },
|
|
7
|
-
parserOptions: { sourceType: 'module', ecmaVersion: 'latest' },
|
|
8
|
-
extends: [
|
|
9
|
-
'eslint:recommended',
|
|
10
|
-
'plugin:n/recommended',
|
|
11
|
-
'plugin:import/recommended',
|
|
12
|
-
'plugin:prettier/recommended',
|
|
13
|
-
],
|
|
14
|
-
settings: {
|
|
15
|
-
// eslint-plugin-import doesn't currently support the "exports" syntax in
|
|
16
|
-
// package.json. This is supposed to allow mapping between custom
|
|
17
|
-
// entrypoints and files on disk.
|
|
18
|
-
// For example, it doesn't understand "import * from 'vitest/config';" as
|
|
19
|
-
// "vitest/config/" isn't really an existing filepath, but a mapping defined
|
|
20
|
-
// in vitest package.json
|
|
21
|
-
//
|
|
22
|
-
// Until this is fixed (see
|
|
23
|
-
// https://github.com/import-js/eslint-plugin-import/issues/2430)
|
|
24
|
-
// we manually define the most common extensions
|
|
25
|
-
'import/resolver': {
|
|
26
|
-
node: { extensions: ['.js', '.cjs', '.mjs', '.d.ts'] },
|
|
27
|
-
},
|
|
28
|
-
},
|
|
29
|
-
plugins: ['jsdoc', 'prettier'],
|
|
30
|
-
rules: {
|
|
31
|
-
'dot-notation': ['error'],
|
|
32
|
-
'max-len': [
|
|
33
|
-
'error',
|
|
34
|
-
{
|
|
35
|
-
code: 80,
|
|
36
|
-
ignoreComments: true,
|
|
37
|
-
ignoreRegExpLiterals: true,
|
|
38
|
-
ignoreStrings: true,
|
|
39
|
-
ignoreTemplateLiterals: true,
|
|
40
|
-
ignoreTrailingComments: true,
|
|
41
|
-
ignoreUrls: true,
|
|
42
|
-
// Ignore long lines in test headers, allowing us to write descriptive
|
|
43
|
-
// tests
|
|
44
|
-
ignorePattern: '^\\s*it\\(',
|
|
45
|
-
},
|
|
46
|
-
],
|
|
47
|
-
'no-console': ['off'],
|
|
48
|
-
'no-irregular-whitespace': ['error', { skipRegExps: true }],
|
|
49
|
-
'no-restricted-properties': [
|
|
50
|
-
'error',
|
|
51
|
-
{
|
|
52
|
-
object: 'module',
|
|
53
|
-
property: 'export',
|
|
54
|
-
message: 'Typo: Use module.exports instead',
|
|
55
|
-
},
|
|
56
|
-
{
|
|
57
|
-
object: '_',
|
|
58
|
-
property: 'contains',
|
|
59
|
-
message: 'Typo: Use _.includes instead',
|
|
60
|
-
},
|
|
61
|
-
],
|
|
62
|
-
'no-unused-vars': [
|
|
63
|
-
'error',
|
|
64
|
-
{ argsIgnorePattern: '^_.', varsIgnorePattern: '^_.' },
|
|
65
|
-
],
|
|
66
|
-
'no-shadow': ['error'],
|
|
67
|
-
'object-shorthand': ['error', 'always'],
|
|
68
|
-
// TODO: Should be updated to consistent-as-needed when
|
|
69
|
-
// https://github.com/prettier/prettier/issues/6064 is fixed
|
|
70
|
-
'quote-props': ['error', 'as-needed'],
|
|
71
|
-
quotes: ['error', 'single', { avoidEscape: true }],
|
|
72
|
-
// Used to sort the members inside an import statement
|
|
73
|
-
// Example:
|
|
74
|
-
// import { foo, bar } from 'something';
|
|
75
|
-
// => import { bar, foo } from 'something'
|
|
76
|
-
'sort-imports': ['error', { ignoreDeclarationSort: true }],
|
|
77
|
-
// Node
|
|
78
|
-
'n/no-unsupported-features/es-syntax': [
|
|
79
|
-
'error',
|
|
80
|
-
{ version: `>=${nodeConfig.nodeVersion}` },
|
|
81
|
-
],
|
|
82
|
-
// Import
|
|
83
|
-
'import/first': ['error'],
|
|
84
|
-
'import/no-cycle': ['error'],
|
|
85
|
-
'import/order': ['error'],
|
|
86
|
-
'import/newline-after-import': ['error'],
|
|
87
|
-
// JSDoc
|
|
88
|
-
'jsdoc/check-param-names': ['warn'],
|
|
89
|
-
'jsdoc/check-types': ['warn'],
|
|
90
|
-
'jsdoc/no-undefined-types': ['warn'],
|
|
91
|
-
'jsdoc/check-alignment': ['warn'],
|
|
92
|
-
'jsdoc/check-examples': ['off'],
|
|
93
|
-
'jsdoc/check-syntax': ['warn'],
|
|
94
|
-
'jsdoc/check-tag-names': ['warn'],
|
|
95
|
-
'jsdoc/require-jsdoc': ['warn'],
|
|
96
|
-
'jsdoc/require-param': ['warn'],
|
|
97
|
-
'jsdoc/require-param-description': ['warn'],
|
|
98
|
-
'jsdoc/require-param-name': ['warn'],
|
|
99
|
-
'jsdoc/require-param-type': ['warn'],
|
|
100
|
-
'jsdoc/require-returns': ['warn'],
|
|
101
|
-
'jsdoc/require-returns-check': ['warn'],
|
|
102
|
-
'jsdoc/require-returns-description': ['warn'],
|
|
103
|
-
'jsdoc/require-returns-type': ['warn'],
|
|
104
|
-
'jsdoc/valid-types': ['warn'],
|
|
105
|
-
// Prettier
|
|
106
|
-
'prettier/prettier': 'error',
|
|
107
|
-
},
|
|
108
|
-
overrides: [
|
|
109
|
-
// Vitest
|
|
110
|
-
{
|
|
111
|
-
files: ['**/__tests__/**/*.js'],
|
|
112
|
-
env: { 'vitest-globals/env': true },
|
|
113
|
-
globals: {
|
|
114
|
-
// Test name
|
|
115
|
-
testName: false,
|
|
116
|
-
// Shorter method names
|
|
117
|
-
fit: false,
|
|
118
|
-
fdescribe: false,
|
|
119
|
-
xit: false,
|
|
120
|
-
xdescribe: false,
|
|
121
|
-
|
|
122
|
-
captureOutput: false,
|
|
123
|
-
dedent: false,
|
|
124
|
-
},
|
|
125
|
-
extends: [
|
|
126
|
-
'plugin:vitest/recommended',
|
|
127
|
-
'plugin:vitest-globals/recommended',
|
|
128
|
-
],
|
|
129
|
-
rules: {
|
|
130
|
-
'no-restricted-globals': [
|
|
131
|
-
'error',
|
|
132
|
-
{ name: 'fit', message: 'No focused test' },
|
|
133
|
-
{ name: 'fdescribe', message: 'No focused tests' },
|
|
134
|
-
{ name: 'xit', message: 'No skipped test' },
|
|
135
|
-
{ name: 'xdescribe', message: 'No skipped tests' },
|
|
136
|
-
],
|
|
137
|
-
// In tests, we like to have the variable 'current' hold the object
|
|
138
|
-
// under test. The import/no-named-as-default-member would have warned
|
|
139
|
-
// us about using current.foo rather than foo directly, so we disable
|
|
140
|
-
// it.
|
|
141
|
-
'import/no-named-as-default-member': ['off'],
|
|
142
|
-
'vitest/consistent-test-it': ['warn', { fn: 'it' }],
|
|
143
|
-
// Disabling vitest/no-identical-title
|
|
144
|
-
// It can make eslint crash when used with fit/xit/fdescribe/xdescribe
|
|
145
|
-
// See: https://github.com/veritem/eslint-plugin-vitest/issues/310
|
|
146
|
-
'vitest/no-identical-title': ['off'],
|
|
147
|
-
'vitest/prefer-to-contain': ['error'],
|
|
148
|
-
},
|
|
149
|
-
},
|
|
150
|
-
// no-process-exit
|
|
151
|
-
// We need to send clear exit codes in yarn run scripts
|
|
152
|
-
{ files: ['**/scripts/**/*.js'], rules: { 'no-process-exit': ['off'] } },
|
|
153
|
-
],
|
|
154
|
-
};
|
package/configs/node.cjs
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
// Note: This file must still be in .cjs as it is require()d by eslintrc.cjs,
|
|
2
|
-
// which we also have to keep in cjs format
|
|
3
|
-
module.exports = {
|
|
4
|
-
nodeVersion: '18.18.0', // Also see templates/_circleci/config.yml
|
|
5
|
-
yarnVersion: '4.0.2',
|
|
6
|
-
norskaVersion: '2.9.0',
|
|
7
|
-
norskaThemeDocsVersion: '5.0.3',
|
|
8
|
-
lernaVersion: '4.0.0',
|
|
9
|
-
};
|
|
@@ -1,13 +0,0 @@
|
|
|
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;
|
|
@@ -1,10 +0,0 @@
|
|
|
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);
|
|
@@ -1,9 +0,0 @@
|
|
|
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
|
-
});
|