aberlaas 2.1.0 → 2.3.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 +125 -20
- package/commands/ci/index.js +14 -99
- package/commands/compress/dummy.js +11 -0
- package/commands/compress/index.js +5 -14
- package/commands/compress/png.js +18 -9
- package/commands/init/index.js +23 -7
- package/commands/lint/css.js +27 -21
- package/commands/lint/helpers/prettier.js +40 -12
- package/commands/lint/index.js +1 -1
- package/commands/lint/js.js +3 -4
- package/commands/lint/json.js +6 -5
- package/commands/lint/yml.js +6 -5
- package/commands/precommit/index.js +4 -3
- package/commands/setup/index.js +0 -12
- package/commands/test/index.js +50 -49
- package/configs/eslint.cjs +20 -3
- package/configs/lintstaged.js +25 -0
- package/configs/node.cjs +1 -0
- package/configs/{prettier.cjs → prettier.js} +1 -1
- package/configs/{stylelint.cjs → stylelint.js} +1 -1
- package/configs/vite.js +9 -2
- package/helper.js +13 -0
- package/main.js +0 -2
- package/package.json +10 -16
- package/templates/_circleci/config.yml +0 -1
- package/templates/_eslintignore.conf +4 -1
- package/templates/_gitattributes +3 -0
- package/templates/_gitignore +28 -0
- package/templates/_yarnrc.yml +9 -0
- package/templates/lintstaged.config.js +4 -0
- package/templates/prettier.config.js +4 -0
- package/templates/scripts/compress +4 -0
- package/templates/scripts/hooks/pre-commit +1 -1
- package/templates/stylelint.config.js +4 -0
- 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/jest/index.cjs +0 -52
- package/configs/jest/jest-extended.cjs +0 -3
- package/configs/jest/setupFileAfterEnv.cjs +0 -13
- package/configs/jest/sharedState.cjs +0 -14
- package/configs/jest/testEnvironment.cjs +0 -46
- package/configs/jest.cjs +0 -1
- package/configs/lintstaged.cjs +0 -25
- package/templates/_lintstagedrc.cjs +0 -4
- package/templates/_prettierrc.cjs +0 -4
- package/templates/_stylelintrc.cjs +0 -4
- package/templates/jest.config.cjs +0 -4
|
@@ -1,143 +0,0 @@
|
|
|
1
|
-
import release from '../release/index.js';
|
|
2
|
-
import consoleInfo from 'firost/consoleInfo.js';
|
|
3
|
-
import _ from 'golgoth/lodash.js';
|
|
4
|
-
import run from 'firost/run.js';
|
|
5
|
-
import write from 'firost/write.js';
|
|
6
|
-
import exists from 'firost/exists.js';
|
|
7
|
-
import helper from '../../helper.js';
|
|
8
|
-
|
|
9
|
-
export default {
|
|
10
|
-
/**
|
|
11
|
-
* Run a git command in the repo
|
|
12
|
-
*
|
|
13
|
-
* @param {string} gitCommand Git command to run
|
|
14
|
-
* @returns {string} Command output
|
|
15
|
-
*/
|
|
16
|
-
async gitRun(gitCommand) {
|
|
17
|
-
const repoPath = helper.hostPath();
|
|
18
|
-
const result = await run(`cd ${repoPath} && ${gitCommand}`, {
|
|
19
|
-
shell: true,
|
|
20
|
-
stdout: false,
|
|
21
|
-
});
|
|
22
|
-
return result.stdout;
|
|
23
|
-
},
|
|
24
|
-
/**
|
|
25
|
-
* Set a git config value only if wasn't set before
|
|
26
|
-
* @param {string} name Name of the config
|
|
27
|
-
* @param {string} value Value of the config
|
|
28
|
-
**/
|
|
29
|
-
async gitConfigSet(name, value) {
|
|
30
|
-
// We test to see if there is already a value. If no, we write it
|
|
31
|
-
try {
|
|
32
|
-
await this.gitRun(`git config ${name}`);
|
|
33
|
-
} catch (err) {
|
|
34
|
-
await this.gitRun(`git config ${name} ${value}`);
|
|
35
|
-
}
|
|
36
|
-
},
|
|
37
|
-
/**
|
|
38
|
-
* Returns the latest tag of the repo
|
|
39
|
-
*
|
|
40
|
-
* @returns {string} Latest tag
|
|
41
|
-
**/
|
|
42
|
-
async gitGetLatestTag() {
|
|
43
|
-
const allTags = await this.gitRun('git tag -l --sort=creatordate');
|
|
44
|
-
return _.chain(allTags).split('\n').last().value();
|
|
45
|
-
},
|
|
46
|
-
/**
|
|
47
|
-
* Returns an array of all commit description since last release
|
|
48
|
-
*
|
|
49
|
-
* @returns {Array} List of all commit description
|
|
50
|
-
**/
|
|
51
|
-
async getCommitsSinceLastRelease() {
|
|
52
|
-
const latestTag = await this.gitGetLatestTag();
|
|
53
|
-
const range = latestTag ? `${latestTag}..HEAD` : 'HEAD';
|
|
54
|
-
const commitList = await this.gitRun(`git log ${range} --format=%B`);
|
|
55
|
-
return _.chain(commitList).split('\n').compact().reverse().value();
|
|
56
|
-
},
|
|
57
|
-
/**
|
|
58
|
-
* Determines what version should be released based on the commits since the
|
|
59
|
-
* last release
|
|
60
|
-
* @returns {string|boolean} False if no release, otherwise minor or patch
|
|
61
|
-
**/
|
|
62
|
-
async getReleaseVersion() {
|
|
63
|
-
const commits = await this.getCommitsSinceLastRelease();
|
|
64
|
-
const status = {
|
|
65
|
-
isMinor: false,
|
|
66
|
-
isPatch: false,
|
|
67
|
-
};
|
|
68
|
-
_.each(commits, (commit) => {
|
|
69
|
-
const isMinor = _.startsWith(commit, 'feat(');
|
|
70
|
-
const isPatch = _.startsWith(commit, 'fix(');
|
|
71
|
-
status.isMinor = status.isMinor || isMinor;
|
|
72
|
-
status.isPatch = status.isPatch || isPatch;
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
if (status.isMinor) {
|
|
76
|
-
return 'minor';
|
|
77
|
-
}
|
|
78
|
-
if (status.isPatch) {
|
|
79
|
-
return 'patch';
|
|
80
|
-
}
|
|
81
|
-
return false;
|
|
82
|
-
},
|
|
83
|
-
/**
|
|
84
|
-
* Run the auto-release script.
|
|
85
|
-
* If there had been any feat() of fix() commits since last release,
|
|
86
|
-
* automatically release a new one
|
|
87
|
-
**/
|
|
88
|
-
async run() {
|
|
89
|
-
this.__consoleInfo('Attempt to auto-release...');
|
|
90
|
-
|
|
91
|
-
const releaseVersion = await this.getReleaseVersion();
|
|
92
|
-
// Don't release if no relevant changes
|
|
93
|
-
if (!releaseVersion) {
|
|
94
|
-
this.__consoleInfo('No relevant commits since last release.');
|
|
95
|
-
return;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
this.__consoleInfo(`Releasing a ${releaseVersion} version`);
|
|
99
|
-
await this.configureGit();
|
|
100
|
-
await this.configureNpm();
|
|
101
|
-
|
|
102
|
-
const releaseArguments = {
|
|
103
|
-
_: [releaseVersion],
|
|
104
|
-
test: false,
|
|
105
|
-
};
|
|
106
|
-
await this.__releaseRun(releaseArguments);
|
|
107
|
-
},
|
|
108
|
-
/**
|
|
109
|
-
* Set git user name and email
|
|
110
|
-
* */
|
|
111
|
-
async configureGit() {
|
|
112
|
-
const email = this.getEnvVar('GIT_USER_EMAIL');
|
|
113
|
-
const name = this.getEnvVar('GIT_USER_NAME');
|
|
114
|
-
await this.gitConfigSet('user.email', email);
|
|
115
|
-
await this.gitConfigSet('user.name', name);
|
|
116
|
-
},
|
|
117
|
-
/**
|
|
118
|
-
* Write a ~/.npmrc with the token
|
|
119
|
-
* @returns {boolean} true on success, false if already a .npmrc
|
|
120
|
-
**/
|
|
121
|
-
async configureNpm() {
|
|
122
|
-
const npmRcPath = '~/.npmrc';
|
|
123
|
-
if (await this.__exists(npmRcPath)) {
|
|
124
|
-
return false;
|
|
125
|
-
}
|
|
126
|
-
const token = this.getEnvVar('NPM_TOKEN');
|
|
127
|
-
const content = `//registry.npmjs.org/:_authToken=${token}`;
|
|
128
|
-
await this.__write(content, npmRcPath);
|
|
129
|
-
return true;
|
|
130
|
-
},
|
|
131
|
-
/**
|
|
132
|
-
* Return an ENV var value
|
|
133
|
-
* @param {string} key ENV var key
|
|
134
|
-
* @returns {string} ENV var value
|
|
135
|
-
**/
|
|
136
|
-
getEnvVar(key) {
|
|
137
|
-
return _.get(process, `env.${key}`);
|
|
138
|
-
},
|
|
139
|
-
__releaseRun: release.run.bind(release),
|
|
140
|
-
__consoleInfo: consoleInfo,
|
|
141
|
-
__write: write,
|
|
142
|
-
__exists: exists,
|
|
143
|
-
};
|
|
@@ -1,76 +0,0 @@
|
|
|
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';
|
|
5
|
-
|
|
6
|
-
export default {
|
|
7
|
-
/**
|
|
8
|
-
* Release the host package.
|
|
9
|
-
* @param {object} cliArgs CLI Argument object, as created by minimist
|
|
10
|
-
* @returns {boolean} True on success, false otherwise
|
|
11
|
-
**/
|
|
12
|
-
async run(cliArgs = {}) {
|
|
13
|
-
this.fixNpmRegistry();
|
|
14
|
-
await this.fetchOrigin();
|
|
15
|
-
|
|
16
|
-
const binary = await helper.which('np');
|
|
17
|
-
const npOptions = await this.getNpArguments(cliArgs);
|
|
18
|
-
const command = `FORCE_COLOR=1 ${binary} ${npOptions}`;
|
|
19
|
-
await this.__run(command, {
|
|
20
|
-
stdin: true,
|
|
21
|
-
shell: true,
|
|
22
|
-
});
|
|
23
|
-
},
|
|
24
|
-
/**
|
|
25
|
-
* Returns the CLI options to pass to np
|
|
26
|
-
* @param {object} cliArgs CLI Argument object, as created by minimist
|
|
27
|
-
* @returns {string} Arguments to pass to np
|
|
28
|
-
**/
|
|
29
|
-
async getNpArguments(cliArgs = {}) {
|
|
30
|
-
const options = [
|
|
31
|
-
cliArgs._,
|
|
32
|
-
'--no-release-draft',
|
|
33
|
-
'--no-2fa',
|
|
34
|
-
'--any-branch',
|
|
35
|
-
];
|
|
36
|
-
const packageJson = await this.getHostPackageJson();
|
|
37
|
-
|
|
38
|
-
// Skip tests if called with --no-test or if no scripts.test entry
|
|
39
|
-
const cliTestStatus = _.get(cliArgs, 'test', true);
|
|
40
|
-
const cliPackageStatus = _.get(packageJson, 'scripts.test', false);
|
|
41
|
-
if (!cliTestStatus || !cliPackageStatus) {
|
|
42
|
-
options.push('--no-tests');
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
// Run in preview mode if --dry-run is set
|
|
46
|
-
const isDryRun = _.get(cliArgs, 'dry-run', false);
|
|
47
|
-
if (isDryRun) {
|
|
48
|
-
options.push('--preview');
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
return _.chain(options).compact().join(' ').value();
|
|
52
|
-
},
|
|
53
|
-
/**
|
|
54
|
-
* Yarn changes the npm_config_registry value, preventing npm publish to
|
|
55
|
-
* actually work. We revert it to its default value for publishing to work
|
|
56
|
-
**/
|
|
57
|
-
fixNpmRegistry() {
|
|
58
|
-
// eslint-disable-next-line camelcase
|
|
59
|
-
process.env.npm_config_registry = 'https://registry.npmjs.org/';
|
|
60
|
-
},
|
|
61
|
-
/**
|
|
62
|
-
* Fetches origin information, so np can correctly keep the branch up to date
|
|
63
|
-
**/
|
|
64
|
-
async fetchOrigin() {
|
|
65
|
-
await this.__run('git fetch --all', { stdout: false });
|
|
66
|
-
},
|
|
67
|
-
/**
|
|
68
|
-
* Returns the content of the host package.json
|
|
69
|
-
* @returns {object} The content of the host package.json
|
|
70
|
-
**/
|
|
71
|
-
async getHostPackageJson() {
|
|
72
|
-
return await this.__readJson(helper.hostPath('package.json'));
|
|
73
|
-
},
|
|
74
|
-
__run: run,
|
|
75
|
-
__readJson: readJson,
|
|
76
|
-
};
|
|
@@ -1,56 +0,0 @@
|
|
|
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 {
|
|
9
|
-
/**
|
|
10
|
-
* Save an ENV variable to CircleCI
|
|
11
|
-
* @param {string} name Name of the ENV variable
|
|
12
|
-
* @param {string} value Value of the ENV variable
|
|
13
|
-
**/
|
|
14
|
-
async saveEnvVar(name, value) {
|
|
15
|
-
const { username, repo } = await githubHelper.repoData();
|
|
16
|
-
try {
|
|
17
|
-
await circleciHelper.api(
|
|
18
|
-
`project/github/${username}/${repo}/envvar/${name}`,
|
|
19
|
-
{
|
|
20
|
-
method: 'delete',
|
|
21
|
-
},
|
|
22
|
-
);
|
|
23
|
-
} catch (err) {
|
|
24
|
-
// Ignoring the error, it means the ENV var wasn't set in the first place
|
|
25
|
-
}
|
|
26
|
-
await circleciHelper.api(`project/github/${username}/${repo}/envvar`, {
|
|
27
|
-
method: 'post',
|
|
28
|
-
json: {
|
|
29
|
-
name,
|
|
30
|
-
value,
|
|
31
|
-
},
|
|
32
|
-
});
|
|
33
|
-
this.__consoleSuccess(`${name} saved on CircleCI`);
|
|
34
|
-
},
|
|
35
|
-
/**
|
|
36
|
-
* Save ENV Variables to CircleCI
|
|
37
|
-
**/
|
|
38
|
-
async enable() {
|
|
39
|
-
// Vars to save
|
|
40
|
-
const npmToken = npmHelper.token();
|
|
41
|
-
const gitUserEmail = await githubHelper.config('user.email');
|
|
42
|
-
const gitUserName = await githubHelper.config('user.name');
|
|
43
|
-
const vars = [
|
|
44
|
-
{ name: 'NPM_TOKEN', value: npmToken },
|
|
45
|
-
{ name: 'GIT_USER_EMAIL', value: gitUserEmail },
|
|
46
|
-
{ name: 'GIT_USER_NAME', value: gitUserName },
|
|
47
|
-
];
|
|
48
|
-
|
|
49
|
-
// Saving them in parallel
|
|
50
|
-
await pMap(vars, async ({ name, value }) => {
|
|
51
|
-
await this.saveEnvVar(name, value);
|
|
52
|
-
});
|
|
53
|
-
},
|
|
54
|
-
__consoleInfo: consoleInfo,
|
|
55
|
-
__consoleSuccess: consoleSuccess,
|
|
56
|
-
};
|
|
@@ -1,59 +0,0 @@
|
|
|
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 {
|
|
12
|
-
/**
|
|
13
|
-
* Enable autoRelease by configuring CircleCI and GitHub
|
|
14
|
-
* @returns {boolean} True if enabled, false otherwise
|
|
15
|
-
**/
|
|
16
|
-
async enable() {
|
|
17
|
-
// Fail early if we're missing the required tokens
|
|
18
|
-
const validationErrors = await this.validationErrors();
|
|
19
|
-
if (!_.isEmpty(validationErrors)) {
|
|
20
|
-
this.__consoleError(
|
|
21
|
-
'[autoRelease] Please fix the following errors and try again:',
|
|
22
|
-
);
|
|
23
|
-
_.each(validationErrors, (error) => {
|
|
24
|
-
this.__consoleError(error);
|
|
25
|
-
});
|
|
26
|
-
return false;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
await this.__envVarsEnable();
|
|
30
|
-
await this.__privateKeyEnable();
|
|
31
|
-
await this.__publicKeyEnable();
|
|
32
|
-
},
|
|
33
|
-
/**
|
|
34
|
-
* Returns an array of error messages for every token/binary missing
|
|
35
|
-
* @returns {Array} List of error messages
|
|
36
|
-
**/
|
|
37
|
-
async validationErrors() {
|
|
38
|
-
const validationErrors = [];
|
|
39
|
-
if (!circleciHelper.hasToken()) {
|
|
40
|
-
validationErrors.push('You need a CIRCLECI_TOKEN');
|
|
41
|
-
}
|
|
42
|
-
if (!npmHelper.hasToken()) {
|
|
43
|
-
validationErrors.push('You need a NPM_TOKEN');
|
|
44
|
-
}
|
|
45
|
-
if (!githubHelper.hasToken()) {
|
|
46
|
-
validationErrors.push('You need a GITHUB_TOKEN');
|
|
47
|
-
}
|
|
48
|
-
if (!sshHelper.hasBinary()) {
|
|
49
|
-
validationErrors.push('You need ssh-keygen available in your $PATH');
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
return validationErrors;
|
|
53
|
-
},
|
|
54
|
-
__consoleError: consoleError,
|
|
55
|
-
__envVarsEnable: envVars.enable.bind(envVars),
|
|
56
|
-
__privateKeyEnable: privateKey.enable.bind(privateKey),
|
|
57
|
-
__publicKeyEnable: publicKey.enable.bind(publicKey),
|
|
58
|
-
__cache: {},
|
|
59
|
-
};
|
|
@@ -1,41 +0,0 @@
|
|
|
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 {
|
|
7
|
-
/**
|
|
8
|
-
* Save a private SSH key on CircleCI.
|
|
9
|
-
* The CircleCI API does not allow checking if a SSH key has been defined,
|
|
10
|
-
* so we will need to re-add it each time. But to avoid creating duplicates,
|
|
11
|
-
* we will delete any key with the same fingerprint first
|
|
12
|
-
**/
|
|
13
|
-
async enable() {
|
|
14
|
-
const keys = await sshHelper.getKeys();
|
|
15
|
-
const privateKey = keys.private;
|
|
16
|
-
const privateFingerprint = keys.privateFingerprint;
|
|
17
|
-
const { username, repo } = await githubHelper.repoData();
|
|
18
|
-
const hostname = 'github.com';
|
|
19
|
-
|
|
20
|
-
// Delete it first
|
|
21
|
-
await circleciHelper.api(`project/github/${username}/${repo}/ssh-key`, {
|
|
22
|
-
method: 'delete',
|
|
23
|
-
json: {
|
|
24
|
-
fingerprint: privateFingerprint,
|
|
25
|
-
hostname,
|
|
26
|
-
},
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
// Then, add it
|
|
30
|
-
await circleciHelper.api(`project/github/${username}/${repo}/ssh-key`, {
|
|
31
|
-
method: 'post',
|
|
32
|
-
json: {
|
|
33
|
-
hostname,
|
|
34
|
-
private_key: privateKey,
|
|
35
|
-
},
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
this.__consoleSuccess('SSH private key force saved on CircleCI');
|
|
39
|
-
},
|
|
40
|
-
__consoleSuccess: consoleSuccess,
|
|
41
|
-
};
|
|
@@ -1,55 +0,0 @@
|
|
|
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 {
|
|
9
|
-
/**
|
|
10
|
-
* Check if SSH public key is already added to GitHub
|
|
11
|
-
* @returns {boolean} True if already enabled, false otherwise
|
|
12
|
-
**/
|
|
13
|
-
async isEnabled() {
|
|
14
|
-
const { username: owner, repo } = await githubHelper.repoData();
|
|
15
|
-
const keys = await githubHelper.octokit('repos.listDeployKeys', {
|
|
16
|
-
owner,
|
|
17
|
-
repo,
|
|
18
|
-
});
|
|
19
|
-
const { public: publicKey } = await sshHelper.getKeys();
|
|
20
|
-
// GitHub does not save the email as part of the key, so we shave it off our
|
|
21
|
-
// key
|
|
22
|
-
const truncatedKey = _.chain(publicKey)
|
|
23
|
-
.split(' ')
|
|
24
|
-
.slice(0, 2)
|
|
25
|
-
.join(' ')
|
|
26
|
-
.value();
|
|
27
|
-
|
|
28
|
-
const foundKey = _.find(keys, { key: truncatedKey });
|
|
29
|
-
return !!foundKey;
|
|
30
|
-
},
|
|
31
|
-
/**
|
|
32
|
-
* Add the SSH public key to GitHub
|
|
33
|
-
* @returns {boolean} True on success
|
|
34
|
-
**/
|
|
35
|
-
async enable() {
|
|
36
|
-
if (await this.isEnabled()) {
|
|
37
|
-
this.__consoleInfo('SSH public key already saved on GitHub');
|
|
38
|
-
return true;
|
|
39
|
-
}
|
|
40
|
-
const { public: key } = await sshHelper.getKeys();
|
|
41
|
-
const { username: owner, repo } = await githubHelper.repoData();
|
|
42
|
-
await githubHelper.octokit('repos.createDeployKey', {
|
|
43
|
-
owner,
|
|
44
|
-
repo,
|
|
45
|
-
key,
|
|
46
|
-
title: 'aberlaas - Push from CircleCI',
|
|
47
|
-
read_only: false,
|
|
48
|
-
});
|
|
49
|
-
this.__consoleSuccess('SSH public key saved on GitHub');
|
|
50
|
-
return true;
|
|
51
|
-
},
|
|
52
|
-
__consoleInfo: consoleInfo,
|
|
53
|
-
__consoleSuccess: consoleSuccess,
|
|
54
|
-
__consoleError: consoleError,
|
|
55
|
-
};
|
package/configs/jest/index.cjs
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
const path = require('path');
|
|
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
|
-
module.exports = {
|
|
6
|
-
// Custom environment that automatically set testName and allow for --failFast
|
|
7
|
-
testEnvironment,
|
|
8
|
-
|
|
9
|
-
// Use additional Jest plugins
|
|
10
|
-
setupFilesAfterEnv: [jestExtendedPath, setupFileAfterEnv],
|
|
11
|
-
|
|
12
|
-
// We need to set rootDir to the host directory, otherwise Jest will assume
|
|
13
|
-
// test are to be looked for in the directory that contains the config (ie.
|
|
14
|
-
// aberlaas).
|
|
15
|
-
rootDir: process.cwd(),
|
|
16
|
-
|
|
17
|
-
// Tests should be in a __tests__ folder
|
|
18
|
-
testMatch: ['**/__tests__/**/*.js?(x)'],
|
|
19
|
-
|
|
20
|
-
// By default watch mode watches for changes in all directories, and whenever
|
|
21
|
-
// a test file or associated code file changes, it re-runs tests.
|
|
22
|
-
// This can cause useless re-render of tests when it catches changes in
|
|
23
|
-
// directories like ./tmp, etc, so we exclude such directories
|
|
24
|
-
// watchPathIgnorePatterns only accept RegExp and not globs, so we have to
|
|
25
|
-
// deal with ((.*)/)? to express any depth of folders
|
|
26
|
-
watchPathIgnorePatterns: [
|
|
27
|
-
'<rootDir>/((.*)/)?node_modules/',
|
|
28
|
-
'<rootDir>/((.*)/)?tmp/',
|
|
29
|
-
'<rootDir>/((.*)/)?templates/',
|
|
30
|
-
],
|
|
31
|
-
testPathIgnorePatterns: [
|
|
32
|
-
'<rootDir>/((.*)/)?fixtures/',
|
|
33
|
-
'<rootDir>/((.*)/)?tmp/',
|
|
34
|
-
'<rootDir>/((.*)/)?templates/',
|
|
35
|
-
],
|
|
36
|
-
|
|
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: {},
|
|
47
|
-
|
|
48
|
-
bail: true,
|
|
49
|
-
|
|
50
|
-
resetMocks: true,
|
|
51
|
-
restoreMocks: true,
|
|
52
|
-
};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/* eslint-disable jest/no-jasmine-globals,no-global-assign */
|
|
2
|
-
const captureOutput = require('firost/captureOutput');
|
|
3
|
-
const dedent = require('dedent');
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Add new globals to each test file:
|
|
7
|
-
* - captureOutput accepts a callback that will be executed with all output
|
|
8
|
-
* silenced and returned instead
|
|
9
|
-
* - dedent (https://github.com/dmnd/dedent) to enter multiline strings without
|
|
10
|
-
* the indentation
|
|
11
|
-
**/
|
|
12
|
-
global.captureOutput = captureOutput;
|
|
13
|
-
global.dedent = dedent;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Jest environments are sandboxed by test suite. To be able to fail fast and
|
|
3
|
-
* stop all tests as soon as one of them failed, we are using this file as an
|
|
4
|
-
* external singleton.
|
|
5
|
-
**/
|
|
6
|
-
module.exports = {
|
|
7
|
-
__skipAllTests: false,
|
|
8
|
-
skipAllTests() {
|
|
9
|
-
this.__skipAllTests = true;
|
|
10
|
-
},
|
|
11
|
-
shouldSkipAllTests() {
|
|
12
|
-
return this.__skipAllTests;
|
|
13
|
-
},
|
|
14
|
-
};
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
const NodeEnvironment = require('jest-environment-node');
|
|
2
|
-
const shouldFailFast = process.env.ABERLAAS_TEST_FAIL_FAST;
|
|
3
|
-
const sharedState = require('./sharedState.cjs');
|
|
4
|
-
|
|
5
|
-
class AberlaasEnvironment extends NodeEnvironment {
|
|
6
|
-
async handleTestEvent(event, _state) {
|
|
7
|
-
this.failFast(event);
|
|
8
|
-
this.setTestName(event);
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* If one test fails, we skip all other tests
|
|
12
|
-
* @param {object} event As fired by handleTestEvent
|
|
13
|
-
*/
|
|
14
|
-
failFast(event) {
|
|
15
|
-
// Do nothing if --failFast is not passed
|
|
16
|
-
if (!shouldFailFast) {
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
// Whenever a test is failing, we update the shared state to skip all other
|
|
21
|
-
// tests
|
|
22
|
-
const eventName = event.name;
|
|
23
|
-
const isTestFailing = eventName == 'test_fn_failure';
|
|
24
|
-
const isTestStarting = eventName === 'test_start';
|
|
25
|
-
|
|
26
|
-
if (isTestFailing) {
|
|
27
|
-
sharedState.skipAllTests();
|
|
28
|
-
}
|
|
29
|
-
if (isTestStarting && sharedState.shouldSkipAllTests()) {
|
|
30
|
-
event.test.mode = 'skip';
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* When a test starts, we set the global variable testName to the name of the
|
|
35
|
-
* test
|
|
36
|
-
* @param {object} event As fired by handleTestEvent
|
|
37
|
-
**/
|
|
38
|
-
setTestName(event) {
|
|
39
|
-
const eventName = event.name;
|
|
40
|
-
if (eventName === 'test_start') {
|
|
41
|
-
this.global.testName = event.test.name;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
module.exports = AberlaasEnvironment;
|
package/configs/jest.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
module.exports = require('./jest/index.cjs');
|
package/configs/lintstaged.cjs
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
const pkg = require(`${process.cwd()}/package.json`);
|
|
2
|
-
|
|
3
|
-
// We update the README.md and ./lib/README.md whenever documentation changes
|
|
4
|
-
const aberlaasRunCommands = [
|
|
5
|
-
'yarn run aberlaas readme',
|
|
6
|
-
'git add ./README.md ./lib/README.md',
|
|
7
|
-
];
|
|
8
|
-
const result = {
|
|
9
|
-
'.github/README.template.md': aberlaasRunCommands,
|
|
10
|
-
'docs/src/**/*.md': aberlaasRunCommands,
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
// Linting and autofixing supported files
|
|
14
|
-
if (pkg.scripts && pkg.scripts.lint) {
|
|
15
|
-
result['*.css'] = ['yarn run lint:fix --css'];
|
|
16
|
-
result['*.{yml,yaml}'] = ['yarn run lint:fix --yml'];
|
|
17
|
-
result['.circleci/config.yml'] = ['yarn run lint --circleci'];
|
|
18
|
-
result['*.json'] = ['yarn run lint:fix --json'];
|
|
19
|
-
result['*.js'] = ['yarn run lint:fix --js'];
|
|
20
|
-
}
|
|
21
|
-
// Testing changed js files
|
|
22
|
-
if (pkg.scripts && pkg.scripts.test) {
|
|
23
|
-
result['./lib/**/*.js'] = ['yarn run test --failFast --related'];
|
|
24
|
-
}
|
|
25
|
-
module.exports = result;
|