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.
Files changed (70) hide show
  1. package/bin/aberlaas.js +1 -1
  2. package/configs/eslint.js +3 -0
  3. package/configs/lintstaged.js +2 -24
  4. package/configs/prettier.js +3 -4
  5. package/configs/stylelint.js +3 -41
  6. package/configs/vite.js +2 -41
  7. package/{main.js → lib/main.js} +26 -30
  8. package/package.json +37 -45
  9. package/commands/ci/index.js +0 -47
  10. package/commands/compress/dummy.js +0 -11
  11. package/commands/compress/index.js +0 -41
  12. package/commands/compress/png.js +0 -49
  13. package/commands/init/helper.js +0 -192
  14. package/commands/init/index.js +0 -59
  15. package/commands/init/module.js +0 -111
  16. package/commands/init/monorepo.js +0 -261
  17. package/commands/lint/circleci.js +0 -81
  18. package/commands/lint/css.js +0 -73
  19. package/commands/lint/helpers/prettier.js +0 -54
  20. package/commands/lint/index.js +0 -50
  21. package/commands/lint/js.js +0 -73
  22. package/commands/lint/json.js +0 -60
  23. package/commands/lint/yml.js +0 -62
  24. package/commands/precommit/index.js +0 -33
  25. package/commands/readme/index.js +0 -181
  26. package/commands/setup/circleci.js +0 -60
  27. package/commands/setup/github.js +0 -42
  28. package/commands/setup/helpers/circleci.js +0 -43
  29. package/commands/setup/helpers/github.js +0 -72
  30. package/commands/setup/helpers/npm.js +0 -16
  31. package/commands/setup/helpers/ssh.js +0 -77
  32. package/commands/setup/index.js +0 -52
  33. package/commands/setup/renovate.js +0 -54
  34. package/commands/test/index.js +0 -124
  35. package/configs/eslint.cjs +0 -154
  36. package/configs/node.cjs +0 -9
  37. package/configs/vite/test/setupFiles/captureOutput.js +0 -4
  38. package/configs/vite/test/setupFiles/dedent.js +0 -4
  39. package/configs/vite/test/setupFiles/fit-xit-fdescribe-xdescribe.js +0 -13
  40. package/configs/vite/test/setupFiles/jest-extended.js +0 -10
  41. package/configs/vite/test/setupFiles/testName.js +0 -9
  42. package/helper.js +0 -115
  43. package/templates/LICENSE +0 -9
  44. package/templates/_circleci/config.yml +0 -42
  45. package/templates/_eslintignore.conf +0 -12
  46. package/templates/_eslintrc.cjs +0 -3
  47. package/templates/_gitattributes +0 -4
  48. package/templates/_github/README.template.md +0 -7
  49. package/templates/_github/renovate.json +0 -3
  50. package/templates/_gitignore +0 -29
  51. package/templates/_yarnrc.yml +0 -15
  52. package/templates/lerna.json +0 -6
  53. package/templates/lib/__tests__/main.js +0 -13
  54. package/templates/lib/main.js +0 -5
  55. package/templates/lintstaged.config.js +0 -5
  56. package/templates/prettier.config.js +0 -5
  57. package/templates/scripts/ci +0 -6
  58. package/templates/scripts/compress +0 -4
  59. package/templates/scripts/docs/build +0 -4
  60. package/templates/scripts/docs/build-prod +0 -4
  61. package/templates/scripts/docs/cms +0 -4
  62. package/templates/scripts/docs/serve +0 -4
  63. package/templates/scripts/hooks/pre-commit +0 -11
  64. package/templates/scripts/lib/release +0 -5
  65. package/templates/scripts/lib/test +0 -5
  66. package/templates/scripts/lib/test-watch +0 -5
  67. package/templates/scripts/lint +0 -4
  68. package/templates/scripts/lint-fix +0 -4
  69. package/templates/stylelint.config.js +0 -5
  70. package/templates/vite.config.js +0 -5
package/bin/aberlaas.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import aberlaas from '../main.js';
2
+ import aberlaas from '../lib/main.js';
3
3
 
4
4
  (async () => {
5
5
  await aberlaas.run(process.argv.slice(2));
@@ -0,0 +1,3 @@
1
+ import config from 'aberlaas-lint/configs/eslint';
2
+
3
+ export default config;
@@ -1,25 +1,3 @@
1
- const readmeCommands = [
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;
@@ -1,4 +1,3 @@
1
- export default {
2
- singleQuote: true,
3
- printWidth: 80,
4
- };
1
+ import config from 'aberlaas-lint/configs/prettier';
2
+
3
+ export default config;
@@ -1,41 +1,3 @@
1
- // Initially exported from
2
- // https://github.com/stylelint/stylelint-config-recommended/blob/master/index.js
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 { defaultExclude, defineConfig } from 'vitest/config';
1
+ import config from 'aberlaas-test/configs/vite';
2
2
 
3
- const aberlaasVitestExclude = [...defaultExclude, '**/tmp/**'];
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;
@@ -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
- * List of allowed commands to run
17
- * @returns {Array} List of allowed commands to run
18
- **/
19
- allCommands() {
20
- return {
21
- ci: commandCi,
22
- compress: commandCompress,
23
- init: commandInit,
24
- lint: commandLint,
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
- * INIT_CWD is always set to the directory where the command was called, but
37
- * because scripts in child workspaces are actually calling scripts in the
38
- * root workspace, that value is overwritten. This is why we save the original
39
- * calling directory in ABERLAAS_CWD, and use that value if available.
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.allCommands()[commandName];
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.9.0",
5
+ "version": "2.11.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
- "*.js"
25
+ "lib/*.js"
26
26
  ],
27
27
  "exports": {
28
- ".": "./main.js",
29
- "./configs/vite": "./configs/vite.js",
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
- "@octokit/rest": "18.12.0",
38
- "ci-info": "3.9.0",
39
- "dedent": "1.5.1",
40
- "eslint": "8.57.0",
41
- "eslint-config-prettier": "9.1.0",
42
- "eslint-plugin-import": "2.29.1",
43
- "eslint-plugin-jsdoc": "46.10.1",
44
- "eslint-plugin-n": "16.6.2",
45
- "eslint-plugin-prettier": "5.1.3",
46
- "eslint-plugin-vitest": "0.4.1",
47
- "eslint-plugin-vitest-globals": "1.5.0",
48
- "find-up": "5.0.0",
49
- "firost": "3.5.0",
50
- "front-matter": "4.0.2",
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.11.0",
39
+ "aberlaas-compress": "^2.10.0",
40
+ "aberlaas-helper": "^2.10.0",
41
+ "aberlaas-init": "^2.10.0",
42
+ "aberlaas-lint": "^2.11.0",
43
+ "aberlaas-precommit": "^2.10.0",
44
+ "aberlaas-readme": "^2.10.0",
45
+ "aberlaas-setup": "^2.11.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
- "np": "7.7.0",
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": "ABERLAAS_CWD=$INIT_CWD yarn g:build",
69
- "build:prod": "ABERLAAS_CWD=$INIT_CWD yarn g:build:prod",
70
- "cms": "ABERLAAS_CWD=$INIT_CWD yarn g:cms",
71
- "serve": "ABERLAAS_CWD=$INIT_CWD yarn g:serve",
72
- "release": "ABERLAAS_CWD=$INIT_CWD yarn g:release",
73
- "test": "ABERLAAS_CWD=$INIT_CWD yarn g:test",
74
- "test:watch": "ABERLAAS_CWD=$INIT_CWD yarn g:test:watch",
75
- "test:meta": "ABERLAAS_CWD=$INIT_CWD yarn g:test:meta",
76
- "compress": "ABERLAAS_CWD=$INIT_CWD yarn g:compress",
77
- "lint": "ABERLAAS_CWD=$INIT_CWD yarn g:lint",
78
- "lint:fix": "ABERLAAS_CWD=$INIT_CWD yarn g:lint:fix",
79
- "postinstall": "./scripts/postinstall"
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": "26cb1b6e33199730ccfb693ef92584f35cfa2aea"
73
+ "gitHead": "ae26d72ed4782af9545d664b65c7eb5305a88335"
82
74
  }
@@ -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
- };
@@ -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
- };