aberlaas 2.8.0 → 2.10.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 -171
- 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 -33
- 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
package/bin/aberlaas.js
CHANGED
package/configs/lintstaged.js
CHANGED
|
@@ -1,25 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
'yarn run aberlaas readme',
|
|
3
|
-
'git add ./README.md ./lib/README.md',
|
|
4
|
-
];
|
|
1
|
+
import config from 'aberlaas-precommit/configs/lintstaged';
|
|
5
2
|
|
|
6
|
-
export default
|
|
7
|
-
// Lint
|
|
8
|
-
'*.css': ['yarn run lint:fix --css'],
|
|
9
|
-
'*.{yml,yaml}': ['yarn run lint:fix --yml'],
|
|
10
|
-
'.circleci/config.yml': ['yarn run lint --circleci'],
|
|
11
|
-
'*.json': ['yarn run lint:fix --json'],
|
|
12
|
-
'*.js': ['yarn run lint:fix --js'],
|
|
13
|
-
|
|
14
|
-
// Test
|
|
15
|
-
'./lib/**/*.js': ['FORCE_COLOR=1 yarn run test --failFast --related'],
|
|
16
|
-
|
|
17
|
-
// Compress
|
|
18
|
-
'*.png': ['yarn run compress --png'],
|
|
19
|
-
|
|
20
|
-
// Documentation
|
|
21
|
-
// Update the README whenever the documentation, or the README template
|
|
22
|
-
// changes
|
|
23
|
-
'docs/src/**/*.md': readmeCommands,
|
|
24
|
-
'.github/README.template.md': readmeCommands,
|
|
25
|
-
};
|
|
3
|
+
export default config;
|
package/configs/prettier.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
1
|
+
import config from 'aberlaas-lint/configs/prettier';
|
|
2
|
+
|
|
3
|
+
export default config;
|
package/configs/stylelint.js
CHANGED
|
@@ -1,41 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export default
|
|
4
|
-
rules: {
|
|
5
|
-
'at-rule-no-unknown': [
|
|
6
|
-
true,
|
|
7
|
-
{
|
|
8
|
-
ignoreAtRules: ['screen', 'tailwind'],
|
|
9
|
-
},
|
|
10
|
-
],
|
|
11
|
-
'block-no-empty': true,
|
|
12
|
-
'block-opening-brace-space-before': ['always'],
|
|
13
|
-
'color-no-invalid-hex': true,
|
|
14
|
-
'comment-no-empty': true,
|
|
15
|
-
'declaration-block-no-duplicate-properties': [
|
|
16
|
-
true,
|
|
17
|
-
{
|
|
18
|
-
ignore: ['consecutive-duplicates-with-different-values'],
|
|
19
|
-
},
|
|
20
|
-
],
|
|
21
|
-
'declaration-block-no-redundant-longhand-properties': true,
|
|
22
|
-
'declaration-block-no-shorthand-property-overrides': true,
|
|
23
|
-
'declaration-block-trailing-semicolon': ['always'],
|
|
24
|
-
'font-family-no-duplicate-names': true,
|
|
25
|
-
'function-calc-no-unspaced-operator': true,
|
|
26
|
-
'function-linear-gradient-no-nonstandard-direction': true,
|
|
27
|
-
'keyframe-declaration-no-important': true,
|
|
28
|
-
'media-feature-name-no-unknown': true,
|
|
29
|
-
'no-empty-source': true,
|
|
30
|
-
'no-extra-semicolons': true,
|
|
31
|
-
'no-invalid-double-slash-comments': true,
|
|
32
|
-
'property-no-unknown': true,
|
|
33
|
-
'selector-pseudo-class-no-unknown': true,
|
|
34
|
-
'selector-pseudo-element-no-unknown': true,
|
|
35
|
-
'selector-type-no-unknown': true,
|
|
36
|
-
'string-quotes': 'single',
|
|
37
|
-
'shorthand-property-no-redundant-values': true,
|
|
38
|
-
'string-no-newline': true,
|
|
39
|
-
'unit-no-unknown': true,
|
|
40
|
-
},
|
|
41
|
-
};
|
|
1
|
+
import config from 'aberlaas-lint/configs/stylelint';
|
|
2
|
+
|
|
3
|
+
export default config;
|
package/configs/vite.js
CHANGED
|
@@ -1,42 +1,3 @@
|
|
|
1
|
-
import
|
|
1
|
+
import config from 'aberlaas-test/configs/vite';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const configDir = new URL('./vite/', import.meta.url).pathname;
|
|
6
|
-
|
|
7
|
-
export default defineConfig({
|
|
8
|
-
test: {
|
|
9
|
-
// vitest default is to run in watch mode, we revert that
|
|
10
|
-
watch: false,
|
|
11
|
-
// Allow a success, even if no files are passed
|
|
12
|
-
passWithNoTests: true,
|
|
13
|
-
// Hide skipped tests, allowing less noisy debug with fit/fdescribe
|
|
14
|
-
hideSkippedTests: true,
|
|
15
|
-
|
|
16
|
-
// Tests should be in a __tests__ folder next to their code
|
|
17
|
-
include: ['**/__tests__/**/*.js?(x)'],
|
|
18
|
-
// We ignore temporary folders from the tests
|
|
19
|
-
exclude: aberlaasVitestExclude,
|
|
20
|
-
// Restore mocks after each tests
|
|
21
|
-
restoreMocks: true,
|
|
22
|
-
|
|
23
|
-
// Make describe, it, beforeEach and other globally available
|
|
24
|
-
globals: true,
|
|
25
|
-
// Run before each test file
|
|
26
|
-
setupFiles: [
|
|
27
|
-
`${configDir}/test/setupFiles/dedent.js`,
|
|
28
|
-
`${configDir}/test/setupFiles/captureOutput.js`,
|
|
29
|
-
`${configDir}/test/setupFiles/fit-xit-fdescribe-xdescribe.js`,
|
|
30
|
-
`${configDir}/test/setupFiles/jest-extended.js`,
|
|
31
|
-
`${configDir}/test/setupFiles/testName.js`,
|
|
32
|
-
],
|
|
33
|
-
},
|
|
34
|
-
server: {
|
|
35
|
-
watch: {
|
|
36
|
-
// Vitest 2.0 uses vite watcher, so files to exclude from watching are at
|
|
37
|
-
// the server level
|
|
38
|
-
// Source: https://vitest.dev/guide/migration.html#removal-of-the-watchexclude-option
|
|
39
|
-
ignored: aberlaasVitestExclude,
|
|
40
|
-
},
|
|
41
|
-
},
|
|
42
|
-
});
|
|
3
|
+
export default config;
|
package/{main.js → lib/main.js}
RENAMED
|
@@ -1,45 +1,40 @@
|
|
|
1
1
|
import path from 'path';
|
|
2
2
|
import minimist from 'minimist';
|
|
3
|
-
import { absolute, consoleError, env, exit } from 'firost';
|
|
3
|
+
import { absolute, consoleError, env, exit, firostImport } from 'firost';
|
|
4
4
|
import { _ } from 'golgoth';
|
|
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 commandTest from './commands/test/index.js';
|
|
10
|
-
import commandLint from './commands/lint/index.js';
|
|
11
|
-
import commandReadme from './commands/readme/index.js';
|
|
12
|
-
import commandSetup from './commands/setup/index.js';
|
|
13
5
|
|
|
14
6
|
export default {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
precommit: commandPrecommit,
|
|
26
|
-
readme: commandReadme,
|
|
27
|
-
setup: commandSetup,
|
|
28
|
-
test: commandTest,
|
|
7
|
+
async getCommand(commandName) {
|
|
8
|
+
const mapping = {
|
|
9
|
+
ci: 'aberlaas-ci',
|
|
10
|
+
compress: 'aberlaas-compress',
|
|
11
|
+
init: 'aberlaas-init',
|
|
12
|
+
lint: 'aberlaas-lint',
|
|
13
|
+
precommit: 'aberlaas-precommit',
|
|
14
|
+
readme: 'aberlaas-readme',
|
|
15
|
+
setup: 'aberlaas-setup',
|
|
16
|
+
test: 'aberlaas-test',
|
|
29
17
|
};
|
|
18
|
+
const commandModuleName = mapping[commandName];
|
|
19
|
+
if (!commandModuleName) {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return await firostImport(commandModuleName);
|
|
30
24
|
},
|
|
31
25
|
/**
|
|
32
26
|
* Converts a list of filepaths to absolute filepaths
|
|
33
27
|
* Note: We want to be able to call commands like "aberlaas lint" from the
|
|
34
28
|
* workspace root or any child workspace. We also want to be able to use
|
|
35
29
|
* relative or absolute filepaths as arguments.
|
|
36
|
-
*
|
|
37
|
-
* because scripts in child workspaces are actually calling scripts in the
|
|
38
|
-
* root workspace, that value is overwritten. This is
|
|
39
|
-
* calling directory in ABERLAAS_CWD,
|
|
30
|
+
* Yarn always sets INIT_CWD to the directory where the command was called,
|
|
31
|
+
* but because scripts in child workspaces are actually calling scripts in the
|
|
32
|
+
* root workspace, through the g: syntax, that value is overwritten. This is
|
|
33
|
+
* why we save the original calling directory in ABERLAAS_CWD, in our
|
|
34
|
+
* package.json script definitions and use that value if available.
|
|
40
35
|
* @param {Array} filepaths Array of filepaths
|
|
41
36
|
* @returns {Array} Array of absolute filepaths
|
|
42
|
-
|
|
37
|
+
*/
|
|
43
38
|
convertFilepathsToAbsolute(filepaths) {
|
|
44
39
|
const callingDirectory =
|
|
45
40
|
this.__env('ABERLAAS_CWD') || this.__env('INIT_CWD');
|
|
@@ -56,14 +51,15 @@ export default {
|
|
|
56
51
|
* Run the command specified on the command-line, along with specific
|
|
57
52
|
* arguments
|
|
58
53
|
* @param {Array} rawArgs CLI args
|
|
59
|
-
|
|
54
|
+
*/
|
|
60
55
|
async run(rawArgs) {
|
|
61
56
|
const args = minimist(rawArgs, {
|
|
62
57
|
boolean: true,
|
|
63
58
|
});
|
|
64
59
|
|
|
65
60
|
const commandName = args._[0];
|
|
66
|
-
const command = this.
|
|
61
|
+
const command = await this.getCommand(commandName);
|
|
62
|
+
|
|
67
63
|
if (!command) {
|
|
68
64
|
this.__consoleError(`Unknown command ${commandName}`);
|
|
69
65
|
this.__exit(1);
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "aberlaas",
|
|
3
3
|
"type": "module",
|
|
4
4
|
"description": "Scaffold your JavaScript projects with tests, lint and release scripts",
|
|
5
|
-
"version": "2.
|
|
5
|
+
"version": "2.10.0",
|
|
6
6
|
"repository": "pixelastic/aberlaas",
|
|
7
7
|
"homepage": "https://projects.pixelastic.com/aberlaas/",
|
|
8
8
|
"author": "Tim Carry (@pixelastic)",
|
|
@@ -22,61 +22,53 @@
|
|
|
22
22
|
"configs/",
|
|
23
23
|
"scripts/",
|
|
24
24
|
"templates/",
|
|
25
|
-
"
|
|
25
|
+
"lib/*.js"
|
|
26
26
|
],
|
|
27
27
|
"exports": {
|
|
28
|
-
".": "./main.js",
|
|
29
|
-
"./configs/
|
|
28
|
+
".": "./lib/main.js",
|
|
29
|
+
"./configs/eslint": "./configs/eslint.js",
|
|
30
30
|
"./configs/lintstaged": "./configs/lintstaged.js",
|
|
31
31
|
"./configs/prettier": "./configs/prettier.js",
|
|
32
|
-
"./configs/stylelint": "./configs/stylelint.js"
|
|
32
|
+
"./configs/stylelint": "./configs/stylelint.js",
|
|
33
|
+
"./configs/vite": "./configs/vite.js"
|
|
33
34
|
},
|
|
34
|
-
"main": "./main.js",
|
|
35
|
+
"main": "./lib/main.js",
|
|
35
36
|
"bin": "bin/aberlaas.js",
|
|
36
37
|
"dependencies": {
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"gilmore": "0.2.0",
|
|
52
|
-
"golgoth": "2.1.0",
|
|
53
|
-
"jest-extended": "4.0.2",
|
|
54
|
-
"lint-staged": "11.2.6",
|
|
38
|
+
"aberlaas-ci": "^2.10.0",
|
|
39
|
+
"aberlaas-compress": "^2.10.0",
|
|
40
|
+
"aberlaas-helper": "^2.10.0",
|
|
41
|
+
"aberlaas-init": "^2.10.0",
|
|
42
|
+
"aberlaas-lint": "^2.10.0",
|
|
43
|
+
"aberlaas-precommit": "^2.10.0",
|
|
44
|
+
"aberlaas-readme": "^2.10.0",
|
|
45
|
+
"aberlaas-setup": "^2.10.0",
|
|
46
|
+
"aberlaas-test": "^2.10.0",
|
|
47
|
+
"aberlaas-versions": "^2.10.0",
|
|
48
|
+
"dedent": "1.5.3",
|
|
49
|
+
"firost": "4.3.0",
|
|
50
|
+
"gilmore": "1.0.0",
|
|
51
|
+
"golgoth": "2.4.0",
|
|
55
52
|
"minimist": "1.2.8",
|
|
56
|
-
"
|
|
57
|
-
"parse-github-repo-url": "1.4.1",
|
|
58
|
-
"prettier": "3.2.5",
|
|
59
|
-
"std-mocks": "1.0.1",
|
|
60
|
-
"stylelint": "13.13.1",
|
|
61
|
-
"vitest": "2.1.1",
|
|
62
|
-
"yaml-lint": "1.7.0"
|
|
53
|
+
"std-mocks": "2.0.0"
|
|
63
54
|
},
|
|
64
55
|
"engines": {
|
|
65
|
-
"node": ">=18"
|
|
56
|
+
"node": ">=18.18.0"
|
|
66
57
|
},
|
|
67
58
|
"scripts": {
|
|
68
|
-
"build": "
|
|
69
|
-
"build:prod": "
|
|
70
|
-
"cms": "
|
|
71
|
-
"serve": "
|
|
72
|
-
"
|
|
73
|
-
"
|
|
74
|
-
"
|
|
75
|
-
"test:meta": "
|
|
76
|
-
"
|
|
77
|
-
"
|
|
78
|
-
"
|
|
79
|
-
"
|
|
59
|
+
"build": "../../scripts/local/build",
|
|
60
|
+
"build:prod": "../../scripts/local/build-prod",
|
|
61
|
+
"cms": "../../scripts/local/cms",
|
|
62
|
+
"serve": "../../scripts/local/serve",
|
|
63
|
+
"ci": "../../scripts/local/ci",
|
|
64
|
+
"release": "../../scripts/local/release",
|
|
65
|
+
"update": "node ../../scripts/meta/update.js",
|
|
66
|
+
"test:meta": "../../scripts/local/test-meta",
|
|
67
|
+
"test": "../../scripts/local/test",
|
|
68
|
+
"test:watch": "../../scripts/local/test-watch",
|
|
69
|
+
"compress": "../../scripts/local/compress",
|
|
70
|
+
"lint": "../../scripts/local/lint",
|
|
71
|
+
"lint:fix": "../../scripts/local/lint-fix"
|
|
80
72
|
},
|
|
81
|
-
"gitHead": "
|
|
73
|
+
"gitHead": "bcdaf87c198a588e02b5539c222f611e356d3079"
|
|
82
74
|
}
|
package/commands/ci/index.js
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import ciInfo from 'ci-info';
|
|
2
|
-
import { consoleInfo, run } from 'firost';
|
|
3
|
-
import commandTest from '../test/index.js';
|
|
4
|
-
import commandLint from '../lint/index.js';
|
|
5
|
-
|
|
6
|
-
export default {
|
|
7
|
-
/**
|
|
8
|
-
* Checks if currently running on a CI server
|
|
9
|
-
* @returns {boolean} True if on a CI server
|
|
10
|
-
**/
|
|
11
|
-
isCI() {
|
|
12
|
-
return ciInfo.isCI;
|
|
13
|
-
},
|
|
14
|
-
/**
|
|
15
|
-
* Run CI scripts and fail the job if any fails
|
|
16
|
-
* Runs lint and test by default, but can be changed with --no-test and
|
|
17
|
-
* --no-lint
|
|
18
|
-
* @param {object} cliArgs CLI Argument object, as created by minimist
|
|
19
|
-
* @returns {boolean} True on success, throws on error
|
|
20
|
-
**/
|
|
21
|
-
async run(cliArgs = {}) {
|
|
22
|
-
const args = {
|
|
23
|
-
test: true,
|
|
24
|
-
lint: true,
|
|
25
|
-
...cliArgs,
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
if (!this.isCI()) {
|
|
29
|
-
this.__consoleInfo('Current system is not a CI, skipping');
|
|
30
|
-
return true;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
if (args.test) {
|
|
34
|
-
await this.__runTest();
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
if (args.lint) {
|
|
38
|
-
await this.__runLint();
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
return true;
|
|
42
|
-
},
|
|
43
|
-
__runTest: commandTest.run.bind(commandTest),
|
|
44
|
-
__runLint: commandLint.run.bind(commandLint),
|
|
45
|
-
__run: run,
|
|
46
|
-
__consoleInfo: consoleInfo,
|
|
47
|
-
};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This is a temporary, dummy file to be able to test the top-level
|
|
3
|
-
* compress.run() function. I assume I'll add more compression types in addition
|
|
4
|
-
* to png, so this dummy compress is just to test that all compress are
|
|
5
|
-
* correctly called, but it doesn't do anything
|
|
6
|
-
**/
|
|
7
|
-
export default {
|
|
8
|
-
async run() {
|
|
9
|
-
return true;
|
|
10
|
-
},
|
|
11
|
-
};
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { _, pMap } from 'golgoth';
|
|
2
|
-
import { consoleError, firostError } from 'firost';
|
|
3
|
-
import compressPng from './png.js';
|
|
4
|
-
import compressDummy from './dummy.js';
|
|
5
|
-
|
|
6
|
-
export default {
|
|
7
|
-
types: {
|
|
8
|
-
png: compressPng,
|
|
9
|
-
dummy: compressDummy,
|
|
10
|
-
},
|
|
11
|
-
/**
|
|
12
|
-
* Wrapper to compress all supported formats
|
|
13
|
-
* @param {object} cliArgs CLI Argument object, as created by minimist
|
|
14
|
-
* @returns {boolean} True on success
|
|
15
|
-
**/
|
|
16
|
-
async run(cliArgs) {
|
|
17
|
-
const allTypesKeys = _.keys(this.types);
|
|
18
|
-
const userTypes = _.intersection(_.keys(cliArgs), allTypesKeys);
|
|
19
|
-
const typesToCompress = _.isEmpty(userTypes) ? allTypesKeys : userTypes;
|
|
20
|
-
|
|
21
|
-
let hasErrors = false;
|
|
22
|
-
await pMap(typesToCompress, async (type) => {
|
|
23
|
-
try {
|
|
24
|
-
const userPatterns = _.get(cliArgs, '_');
|
|
25
|
-
const compresser = this.types[type];
|
|
26
|
-
|
|
27
|
-
await compresser.run(userPatterns);
|
|
28
|
-
} catch (error) {
|
|
29
|
-
this.__consoleError(error.message);
|
|
30
|
-
hasErrors = true;
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
if (hasErrors) {
|
|
35
|
-
throw firostError('ERROR_COMPRESS', 'Error while compressing files');
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
return true;
|
|
39
|
-
},
|
|
40
|
-
__consoleError: consoleError,
|
|
41
|
-
};
|
package/commands/compress/png.js
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { _ } from 'golgoth';
|
|
2
|
-
import { firostError, run, which } from 'firost';
|
|
3
|
-
import helper from '../../helper.js';
|
|
4
|
-
|
|
5
|
-
export default {
|
|
6
|
-
/**
|
|
7
|
-
* Find the png files to compress
|
|
8
|
-
* @param {Array} userPatterns Patterns to narrow the search down
|
|
9
|
-
* @returns {Array} Array of files
|
|
10
|
-
**/
|
|
11
|
-
async getInputFiles(userPatterns) {
|
|
12
|
-
const filePatterns = _.isEmpty(userPatterns)
|
|
13
|
-
? ['./**/*.png']
|
|
14
|
-
: userPatterns;
|
|
15
|
-
return await helper.findHostFiles(filePatterns, ['.png']);
|
|
16
|
-
},
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
|
|
20
|
-
* Returns path to the binary to execute
|
|
21
|
-
* @returns {string|boolean} Path to the binary, or false if not found
|
|
22
|
-
**/
|
|
23
|
-
async getBinaryPath() {
|
|
24
|
-
return await this.__which('pngmin');
|
|
25
|
-
},
|
|
26
|
-
/**
|
|
27
|
-
* Compress files
|
|
28
|
-
* @param {Array} userPatterns Patterns to narrow the search down
|
|
29
|
-
* @returns {boolean} True on success
|
|
30
|
-
**/
|
|
31
|
-
async run(userPatterns) {
|
|
32
|
-
// Stop early if no bin
|
|
33
|
-
const binaryPath = await this.getBinaryPath();
|
|
34
|
-
if (!binaryPath) {
|
|
35
|
-
return true;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
try {
|
|
39
|
-
const files = await this.getInputFiles(userPatterns);
|
|
40
|
-
const command = `${binaryPath} ${files.join(' ')}`;
|
|
41
|
-
await run(command, { stdout: false });
|
|
42
|
-
} catch (error) {
|
|
43
|
-
throw firostError('PngCompressError', error.message);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
return true;
|
|
47
|
-
},
|
|
48
|
-
__which: which,
|
|
49
|
-
};
|
package/commands/init/helper.js
DELETED
|
@@ -1,171 +0,0 @@
|
|
|
1
|
-
import path from 'path';
|
|
2
|
-
import Gilmore from 'gilmore';
|
|
3
|
-
import { copy, error as firostError, isFile, move, read, write } from 'firost';
|
|
4
|
-
import { _ } from 'golgoth';
|
|
5
|
-
import helper from '../../helper.js';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* This hold functions shared for both the monorepo and simple init scenarios
|
|
9
|
-
**/
|
|
10
|
-
export default {
|
|
11
|
-
/**
|
|
12
|
-
* Return name of the current project, as the name of the current directory
|
|
13
|
-
* @returns {string} Name of the project
|
|
14
|
-
**/
|
|
15
|
-
getProjectName() {
|
|
16
|
-
return path.basename(helper.hostRoot());
|
|
17
|
-
},
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Return the name of the current author based on the GitHub project owner
|
|
21
|
-
* @returns {string} Name of the author, or __placeholder__ if undefined
|
|
22
|
-
**/
|
|
23
|
-
async getProjectAuthor() {
|
|
24
|
-
const repo = this.__getRepo();
|
|
25
|
-
return (await repo.githubRepoOwner()) || '__placeholder__';
|
|
26
|
-
},
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Copy a config template to the host
|
|
30
|
-
* @param {string} source Path to source file, relative to aberlaas
|
|
31
|
-
* @param {string} destination Path to destination file, relative to the host
|
|
32
|
-
* @returns {boolean} False if can't copy file, true otherwise
|
|
33
|
-
**/
|
|
34
|
-
async copyToHost(source, destination) {
|
|
35
|
-
const absoluteSource = helper.aberlaasPath(source);
|
|
36
|
-
const absoluteDestination = helper.hostPath(destination);
|
|
37
|
-
|
|
38
|
-
// Source file does not exist
|
|
39
|
-
if (!(await isFile(absoluteSource))) {
|
|
40
|
-
throw firostError(
|
|
41
|
-
'ERROR_INIT_COPY_FILE',
|
|
42
|
-
`Unable to locate ${absoluteSource} file`,
|
|
43
|
-
);
|
|
44
|
-
}
|
|
45
|
-
// Destination file already exist
|
|
46
|
-
if (await isFile(absoluteDestination)) {
|
|
47
|
-
// Do nothing if content is already the same
|
|
48
|
-
const sourceContent = await read(absoluteSource);
|
|
49
|
-
const destinationContent = await read(absoluteDestination);
|
|
50
|
-
if (sourceContent === destinationContent) {
|
|
51
|
-
return true;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
// Otherwise create a backup
|
|
55
|
-
const backupDestination = `${absoluteDestination}.backup`;
|
|
56
|
-
await move(absoluteDestination, backupDestination);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
await copy(absoluteSource, absoluteDestination);
|
|
60
|
-
|
|
61
|
-
return true;
|
|
62
|
-
},
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Add MIT license file
|
|
66
|
-
* @param {string} hostFilepath Path to the LICENSE file, relative to the host
|
|
67
|
-
**/
|
|
68
|
-
async addLicenseFile(hostFilepath) {
|
|
69
|
-
// Start by adding a template
|
|
70
|
-
await this.copyToHost('templates/LICENSE', hostFilepath);
|
|
71
|
-
|
|
72
|
-
// Replace placeholder with real value
|
|
73
|
-
const licensePath = helper.hostPath(hostFilepath);
|
|
74
|
-
const author = await this.getProjectAuthor();
|
|
75
|
-
const templateContent = await read(licensePath);
|
|
76
|
-
const actualContent = _.replace(templateContent, '{author}', author);
|
|
77
|
-
|
|
78
|
-
// Write it again
|
|
79
|
-
await write(actualContent, licensePath);
|
|
80
|
-
},
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* Add default script files
|
|
84
|
-
**/
|
|
85
|
-
async addScripts() {
|
|
86
|
-
// Common
|
|
87
|
-
await this.copyToHost('templates/scripts/ci', 'scripts/ci');
|
|
88
|
-
await this.copyToHost('templates/scripts/compress', 'scripts/compress');
|
|
89
|
-
await this.copyToHost('templates/scripts/lint', 'scripts/lint');
|
|
90
|
-
await this.copyToHost('templates/scripts/lint-fix', 'scripts/lint-fix');
|
|
91
|
-
|
|
92
|
-
// Hooks
|
|
93
|
-
await this.copyToHost(
|
|
94
|
-
'./templates/scripts/hooks/pre-commit',
|
|
95
|
-
'./scripts/hooks/pre-commit',
|
|
96
|
-
);
|
|
97
|
-
|
|
98
|
-
// Lib
|
|
99
|
-
await this.copyToHost(
|
|
100
|
-
'templates/scripts/lib/release',
|
|
101
|
-
'scripts/lib/release',
|
|
102
|
-
);
|
|
103
|
-
await this.copyToHost('templates/scripts/lib/test', 'scripts/lib/test');
|
|
104
|
-
await this.copyToHost(
|
|
105
|
-
'templates/scripts/lib/test-watch',
|
|
106
|
-
'scripts/lib/test-watch',
|
|
107
|
-
);
|
|
108
|
-
},
|
|
109
|
-
|
|
110
|
-
/**
|
|
111
|
-
* Add config files to the host. Each config files reference the default
|
|
112
|
-
* aberlaas config for its tool. This pattern allow end-users to use aberlaas
|
|
113
|
-
* default rules and overwrite them as they see fit
|
|
114
|
-
**/
|
|
115
|
-
async addConfigFiles() {
|
|
116
|
-
// Git
|
|
117
|
-
await this.copyToHost('./templates/_gitignore', './.gitignore');
|
|
118
|
-
await this.copyToHost('./templates/_gitattributes', './.gitattributes');
|
|
119
|
-
|
|
120
|
-
// Yarn
|
|
121
|
-
await this.copyToHost('templates/_yarnrc.yml', '.yarnrc.yml');
|
|
122
|
-
|
|
123
|
-
// ESLint
|
|
124
|
-
await this.copyToHost('templates/_eslintrc.cjs', '.eslintrc.cjs');
|
|
125
|
-
await this.copyToHost('templates/_eslintignore.conf', '.eslintignore');
|
|
126
|
-
|
|
127
|
-
// Lint-staged
|
|
128
|
-
await this.copyToHost(
|
|
129
|
-
'templates/lintstaged.config.js',
|
|
130
|
-
'lintstaged.config.js',
|
|
131
|
-
);
|
|
132
|
-
|
|
133
|
-
// Vite
|
|
134
|
-
await this.copyToHost('templates/vite.config.js', 'vite.config.js');
|
|
135
|
-
|
|
136
|
-
// Prettier
|
|
137
|
-
await this.copyToHost('templates/prettier.config.js', 'prettier.config.js');
|
|
138
|
-
|
|
139
|
-
// Stylelint
|
|
140
|
-
await this.copyToHost(
|
|
141
|
-
'templates/stylelint.config.js',
|
|
142
|
-
'stylelint.config.js',
|
|
143
|
-
);
|
|
144
|
-
|
|
145
|
-
// Renovate
|
|
146
|
-
await this.copyToHost(
|
|
147
|
-
'templates/_github/renovate.json',
|
|
148
|
-
'.github/renovate.json',
|
|
149
|
-
);
|
|
150
|
-
|
|
151
|
-
// CircleCI
|
|
152
|
-
await this.copyToHost(
|
|
153
|
-
'templates/_circleci/config.yml',
|
|
154
|
-
'.circleci/config.yml',
|
|
155
|
-
);
|
|
156
|
-
},
|
|
157
|
-
|
|
158
|
-
/**
|
|
159
|
-
* Add default files required to have the minimum lib module
|
|
160
|
-
**/
|
|
161
|
-
async addLibFiles() {
|
|
162
|
-
await this.copyToHost('templates/lib/main.js', 'lib/main.js');
|
|
163
|
-
await this.copyToHost(
|
|
164
|
-
'templates/lib/__tests__/main.js',
|
|
165
|
-
'lib/__tests__/main.js',
|
|
166
|
-
);
|
|
167
|
-
},
|
|
168
|
-
__getRepo() {
|
|
169
|
-
return new Gilmore(helper.hostRoot());
|
|
170
|
-
},
|
|
171
|
-
};
|