aberlaas 2.0.0 → 2.2.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 (81) hide show
  1. package/README.md +126 -4
  2. package/bin/{aberlaas → aberlaas.js} +1 -1
  3. package/commands/ci/autoRelease.js +9 -8
  4. package/commands/ci/index.js +10 -10
  5. package/commands/compress/dummy.js +11 -0
  6. package/commands/compress/index.js +10 -19
  7. package/commands/compress/png.js +22 -13
  8. package/commands/{init.js → init/index.js} +51 -31
  9. package/commands/lint/circleci.js +10 -11
  10. package/commands/lint/css.js +33 -25
  11. package/commands/lint/helpers/prettier.js +57 -0
  12. package/commands/lint/index.js +18 -48
  13. package/commands/lint/js.js +40 -52
  14. package/commands/lint/json.js +14 -12
  15. package/commands/lint/yml.js +16 -13
  16. package/commands/{precommit.js → precommit/index.js} +7 -7
  17. package/commands/readme/index.js +16 -16
  18. package/commands/{release.js → release/index.js} +5 -6
  19. package/commands/setup/autoRelease/envVars.js +9 -8
  20. package/commands/setup/autoRelease/index.js +12 -11
  21. package/commands/setup/autoRelease/privateKey.js +6 -5
  22. package/commands/setup/autoRelease/publicKey.js +8 -7
  23. package/commands/setup/circleci.js +9 -8
  24. package/commands/setup/github.js +6 -5
  25. package/commands/setup/helpers/circleci.js +6 -5
  26. package/commands/setup/helpers/github.js +6 -5
  27. package/commands/setup/helpers/npm.js +1 -1
  28. package/commands/setup/helpers/ssh.js +11 -10
  29. package/commands/setup/index.js +6 -6
  30. package/commands/setup/renovate.js +7 -6
  31. package/commands/test/index.js +83 -0
  32. package/configs/{eslint.js → eslint.cjs} +77 -29
  33. package/configs/{lintstaged.js → lintstaged.cjs} +7 -1
  34. package/configs/node.cjs +5 -0
  35. package/configs/vite/test/setupFiles/captureOutput.js +4 -0
  36. package/configs/vite/test/setupFiles/dedent.js +4 -0
  37. package/configs/vite/test/setupFiles/fit-xit-fdescribe-xdescribe.js +13 -0
  38. package/configs/vite/test/setupFiles/jest-extended.js +10 -0
  39. package/configs/vite/test/setupFiles/testName.js +9 -0
  40. package/configs/vite.js +25 -0
  41. package/helper.js +49 -38
  42. package/main.js +28 -22
  43. package/package.json +30 -23
  44. package/scripts/postinstall +15 -0
  45. package/templates/_circleci/config.yml +1 -1
  46. package/templates/_eslintignore.conf +1 -1
  47. package/templates/_eslintrc.cjs +3 -0
  48. package/templates/_lintstagedrc.cjs +4 -0
  49. package/templates/_prettierrc.cjs +4 -0
  50. package/templates/_stylelintrc.cjs +4 -0
  51. package/templates/_yarnrc.yml +9 -0
  52. package/templates/lib/__tests__/main.js +2 -2
  53. package/templates/lib/main.js +1 -1
  54. package/templates/scripts/{husky-precommit → compress} +1 -1
  55. package/templates/scripts/hooks/pre-commit +11 -0
  56. package/templates/vite.config.js +4 -0
  57. package/commands/test.js +0 -92
  58. package/configs/husky.js +0 -5
  59. package/configs/jest/index.js +0 -49
  60. package/configs/jest/jest-extended.js +0 -3
  61. package/configs/jest/setupFileAfterEnv.js +0 -13
  62. package/configs/jest/sharedState.js +0 -14
  63. package/configs/jest/testEnvironment.js +0 -46
  64. package/configs/jest.js +0 -1
  65. package/configs/node.js +0 -3
  66. package/lib/configs/deprecated.js +0 -17
  67. package/lib/configs/eslint.js +0 -2
  68. package/lib/configs/husky.js +0 -2
  69. package/lib/configs/jest.js +0 -2
  70. package/lib/configs/lintstaged.js +0 -2
  71. package/lib/configs/prettier.js +0 -2
  72. package/lib/configs/stylelint.js +0 -2
  73. package/templates/_eslintrc.js +0 -3
  74. package/templates/_huskyrc.js +0 -4
  75. package/templates/_lintstagedrc.js +0 -4
  76. package/templates/_prettierrc.js +0 -4
  77. package/templates/_stylelintrc.js +0 -4
  78. package/templates/babel.config.js +0 -3
  79. package/templates/jest.config.js +0 -4
  80. /package/configs/{prettier.js → prettier.cjs} +0 -0
  81. /package/configs/{stylelint.js → stylelint.cjs} +0 -0
package/package.json CHANGED
@@ -1,59 +1,65 @@
1
1
  {
2
2
  "name": "aberlaas",
3
+ "type": "module",
3
4
  "description": "Scaffold your JavaScript projects with tests, lint and release scripts",
4
- "version": "2.0.0",
5
+ "version": "2.2.0",
5
6
  "repository": "pixelastic/aberlaas",
6
7
  "homepage": "https://projects.pixelastic.com/aberlaas/",
7
8
  "author": "Tim Carry (@pixelastic)",
8
9
  "license": "MIT",
9
- "main": "main.js",
10
+ "exports": {
11
+ ".": "./main.js",
12
+ "./configs/lintstaged.cjs": "./configs/lintstaged.cjs",
13
+ "./configs/prettier.cjs": "./configs/prettier.cjs",
14
+ "./configs/styleling.cjs": "./configs/styleling.cjs"
15
+ },
10
16
  "files": [
11
17
  "bin/",
12
18
  "lib/",
19
+ "scripts/",
13
20
  "*.js",
14
- "commands/*.js",
15
21
  "commands/ci/*.js",
16
22
  "commands/compress/*.js",
23
+ "commands/init/*.js",
17
24
  "commands/lint/*.js",
25
+ "commands/lint/helpers/*.js",
26
+ "commands/precommit/*.js",
18
27
  "commands/readme/*.js",
28
+ "commands/release/*.js",
19
29
  "commands/setup/*.js",
20
30
  "commands/setup/autoRelease/*.js",
21
31
  "commands/setup/helpers/*.js",
32
+ "commands/test/*.js",
22
33
  "configs/",
23
34
  "templates/"
24
35
  ],
25
- "bin": {
26
- "aberlaas": "bin/aberlaas",
27
- "aberlass": "bin/aberlaas",
28
- "aberlas": "bin/aberlaas"
29
- },
36
+ "bin": "bin/aberlaas.js",
30
37
  "dependencies": {
31
38
  "@octokit/rest": "18.12.0",
32
39
  "ci-info": "3.9.0",
33
40
  "dedent": "1.5.1",
34
- "eslint": "7.32.0",
35
- "eslint-config-prettier": "8.10.0",
36
- "eslint-plugin-jest": "24.7.0",
41
+ "eslint": "8.54.0",
42
+ "eslint-config-prettier": "9.0.0",
43
+ "eslint-plugin-import": "2.29.0",
37
44
  "eslint-plugin-jsdoc": "46.9.0",
38
- "eslint-plugin-node": "11.1.0",
39
- "eslint-plugin-prettier": "3.4.1",
45
+ "eslint-plugin-n": "16.3.1",
46
+ "eslint-plugin-prettier": "5.0.1",
47
+ "eslint-plugin-vitest": "0.3.10",
48
+ "eslint-plugin-vitest-globals": "1.4.0",
40
49
  "find-up": "5.0.0",
41
- "firost": "2.17.0",
50
+ "firost": "3.1.0",
42
51
  "front-matter": "4.0.2",
52
+ "gilmore": "0.1.0",
43
53
  "golgoth": "2.1.0",
44
- "husky": "4.3.8",
45
- "jest": "27.5.1",
46
- "jest-environment-node": "27.5.1",
47
- "jest-expect-message": "1.1.3",
48
- "jest-extended": "0.11.5",
54
+ "jest-extended": "4.0.2",
49
55
  "lint-staged": "11.2.6",
50
56
  "minimist": "1.2.8",
51
57
  "np": "7.7.0",
52
58
  "parse-github-repo-url": "1.4.1",
53
- "prettier": "2.8.8",
59
+ "prettier": "3.1.0",
54
60
  "std-mocks": "1.0.1",
55
- "strip-ansi": "6.0.1",
56
61
  "stylelint": "13.13.1",
62
+ "vitest": "1.0.4",
57
63
  "yaml-lint": "1.7.0"
58
64
  },
59
65
  "engines": {
@@ -67,7 +73,8 @@
67
73
  "release": "../scripts/release",
68
74
  "serve": "../scripts/docs/serve",
69
75
  "test": "../scripts/lib/test",
70
- "test:watch": "../scripts/lib/test-watch"
76
+ "test:watch": "../scripts/lib/test-watch",
77
+ "postinstall": "./scripts/postinstall"
71
78
  },
72
- "gitHead": "f600de65f2f1f916d5ad2e5b8d63438770586efa"
79
+ "gitHead": "bbf9f5024d007deca00abf451ddf879c876d80aa"
73
80
  }
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env bash
2
+ # This script *should be* automatically run when aberlaas in installed
3
+ # It will configure the local git repository to use ./scripts/hooks (if it
4
+ # exists) for git hooks
5
+ #
6
+ # Note that npm/yarn/etc might have caching mechanisms that will prevent this
7
+ # script from running in some circumstances. It's not (and will never be)
8
+ # a bulletproof approach, but should cover the most basic needs.
9
+ #
10
+ # In case hooks no longer trigger, you will need to manually run:
11
+ # $ git config core.hooksPath scripts/hooks
12
+
13
+ if [ ! -d "./scripts/hooks" ]; then
14
+ git config core.hooksPath scripts/hooks
15
+ fi
@@ -3,7 +3,7 @@ version: 2.1
3
3
  aliases:
4
4
  - &defaults
5
5
  docker:
6
- - image: cimg/node:14.17.0
6
+ - image: cimg/node:18.18.0
7
7
  - &restore_cache
8
8
  restore_cache:
9
9
  key: yarn-cache-{{ checksum "yarn.lock" }}
@@ -1,4 +1,4 @@
1
- # Hidden files (.prettierrc.js, .huskyrc.js, etc) are ignored by default by ESLint
1
+ # Hidden files (.prettierrc.js, etc) are ignored by default by ESLint
2
2
  # The following line will unignore them
3
3
  !.*
4
4
 
@@ -0,0 +1,3 @@
1
+ module.exports = {
2
+ extends: ['./node_modules/aberlaas/configs/eslint.cjs'],
3
+ };
@@ -0,0 +1,4 @@
1
+ const config = require('aberlaas/configs/lintstaged.cjs');
2
+ module.exports = {
3
+ ...config,
4
+ };
@@ -0,0 +1,4 @@
1
+ const config = require('aberlaas/configs/prettier.cjs');
2
+ module.exports = {
3
+ ...config,
4
+ };
@@ -0,0 +1,4 @@
1
+ const config = require('aberlaas/configs/stylelint.cjs');
2
+ module.exports = {
3
+ ...config,
4
+ };
@@ -0,0 +1,9 @@
1
+ compressionLevel: 0
2
+
3
+ defaultSemverRangePrefix: ''
4
+
5
+ enableGlobalCache: true
6
+
7
+ nmMode: hardlinks-local
8
+
9
+ nodeLinker: node-modules
@@ -1,4 +1,4 @@
1
- const current = require('../main.js');
1
+ import current from '../main.js';
2
2
 
3
3
  describe('current', () => {
4
4
  it('should do something', async () => {
@@ -6,6 +6,6 @@ describe('current', () => {
6
6
 
7
7
  const actual = current.run(input);
8
8
 
9
- expect(actual).toEqual(true);
9
+ expect(actual).toBe(true);
10
10
  });
11
11
  });
@@ -1,4 +1,4 @@
1
- module.exports = {
1
+ export default {
2
2
  run() {
3
3
  return true;
4
4
  },
@@ -1,4 +1,4 @@
1
1
  #!/usr/bin/env sh
2
2
  set -e
3
3
 
4
- aberlaas precommit "$@"
4
+ aberlaas compress "$@"
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env sh
2
+ # This script *should be* automatically triggered before each git commit.
3
+ #
4
+ # If it doesn't work, make sure your local git repo is configured to use
5
+ # ./scripts/hooks as the base directory for git hooks.
6
+ #
7
+ # If not, run:
8
+ # $ git config core.hooksPath scripts/hooks
9
+ set -e
10
+
11
+ aberlaas precommit "$@"
@@ -0,0 +1,4 @@
1
+ import viteConfig from 'aberlaas/configs/vite.js';
2
+ export default {
3
+ ...viteConfig,
4
+ };
package/commands/test.js DELETED
@@ -1,92 +0,0 @@
1
- /* eslint-disable jest/no-jest-import */
2
- const helper = require('../helper');
3
- const _ = require('golgoth/lodash');
4
-
5
- module.exports = {
6
- /**
7
- * Transform all aberlaas test cli options into suitable jest-cli options
8
- * @param {object} cliArgs CLI Argument object, as created by minimist
9
- * @returns {Array} Array of cli arguments and values
10
- **/
11
- async jestCliArguments(cliArgs = {}) {
12
- const args = {
13
- ...cliArgs,
14
- cache: false,
15
- passWithNoTests: true,
16
- };
17
- // Default list of files
18
- if (_.isEmpty(args._)) {
19
- args._ = [helper.hostPath()];
20
- }
21
- // Config file
22
- args.config = await helper.configFile(
23
- cliArgs.config,
24
- 'jest.config.js',
25
- 'lib/configs/jest.js'
26
- );
27
- // Set no-watchman when watching
28
- if (args.watch) {
29
- args.watchman = false;
30
- }
31
-
32
- // Handle additional --failFast switch to stop after one test fails
33
- if (args.failFast) {
34
- delete args.failFast;
35
- this.setEnv('ABERLAAS_TEST_FAIL_FAST', true);
36
- }
37
-
38
- // Convert to array of cli arguments
39
- return _.transform(
40
- args,
41
- (result, value, key) => {
42
- if (key === '_') {
43
- return;
44
- }
45
- if (value === true) {
46
- result.push(`--${key}`);
47
- return;
48
- }
49
- if (value === false) {
50
- result.push(`--no-${key}`);
51
- return;
52
- }
53
- result.push(`--${key}`);
54
- result.push(`${value}`);
55
- },
56
- [...args._]
57
- );
58
- },
59
- /**
60
- * Test all files using Jest
61
- * @param {object} cliArgs CLI Argument object, as created by minimist
62
- **/
63
- async run(cliArgs) {
64
- const options = await this.jestCliArguments(cliArgs);
65
- await this.__jestRun(options);
66
- },
67
- /**
68
- * Wrapper method around jest.run. Using a wrapper here makes it easier to
69
- * mock the call in our tests. Because we are using jest itself to test this
70
- * file, mocking jest from inside of it is not practical, so we need to wrap
71
- * it.
72
- * @param {object} options CLI Options to pass to jest.run
73
- **/
74
- async __jestRun(options) {
75
- // We lazy-load jest here because importing it at the top kinda confuses
76
- // Jest when we're running tests and complaining about cyclical
77
- // dependencies. So we're loading it only when needed.
78
- if (!this.__jest) {
79
- this.__jest = require('jest');
80
- }
81
-
82
- await this.__jest.run(options);
83
- },
84
- /**
85
- * Set an environment variable to a specific value
86
- * @param {string} key Key entry
87
- * @param {string} value Value to set
88
- **/
89
- setEnv(key, value) {
90
- process.env[key] = value;
91
- },
92
- };
package/configs/husky.js DELETED
@@ -1,5 +0,0 @@
1
- module.exports = {
2
- hooks: {
3
- 'pre-commit': 'yarn run husky:precommit',
4
- },
5
- };
@@ -1,49 +0,0 @@
1
- const path = require('path');
2
- const jestExtendedPath = path.resolve(__dirname, './jest-extended.js');
3
- const setupFileAfterEnv = path.resolve(__dirname, './setupFileAfterEnv.js');
4
- const testEnvironment = path.resolve(__dirname, './testEnvironment.js');
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
- bail: true,
46
-
47
- resetMocks: true,
48
- restoreMocks: true,
49
- };
@@ -1,3 +0,0 @@
1
- // This is a proxy to make sure we load the plugin no matter where it is
2
- // installed
3
- module.exports = require('jest-extended');
@@ -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.js');
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.js DELETED
@@ -1 +0,0 @@
1
- module.exports = require('./jest/index.js');
package/configs/node.js DELETED
@@ -1,3 +0,0 @@
1
- module.exports = {
2
- nodeVersion: '14.17.0', // Also see templates/_circleci/config.yml
3
- };
@@ -1,17 +0,0 @@
1
- /**
2
- * In July 2021, I moved the repository to a monorepo holding the docs. The path
3
- * to the config files changed, no longer referencing the ./lib. This break all
4
- * usage, so I added this proxy, with a deprecation notice.
5
- *
6
- * Require the correct file, but display a warning about what file to change
7
- * @param {string} hostPath Example: jest.config.js
8
- * @param {string} aberlaasPath Example configs/jest.js
9
- * @returns {object} Config file object
10
- **/
11
- module.exports = (hostPath, aberlaasPath) => {
12
- console.info(
13
- `Please update your ${hostPath} to require aberlaas/${aberlaasPath} instead of aberlaas/lib/${aberlaasPath}`
14
- );
15
-
16
- return require(`../../${aberlaasPath}`);
17
- };
@@ -1,2 +0,0 @@
1
- const deprecated = require('./deprecated.js');
2
- module.exports = deprecated('.eslintrc.js', 'configs/eslint.js');
@@ -1,2 +0,0 @@
1
- const deprecated = require('./deprecated.js');
2
- module.exports = deprecated('.huskyrc.js', 'configs/husky.js');
@@ -1,2 +0,0 @@
1
- const deprecated = require('./deprecated.js');
2
- module.exports = deprecated('jest.config.js', 'configs/jest.js');
@@ -1,2 +0,0 @@
1
- const deprecated = require('./deprecated.js');
2
- module.exports = deprecated('.lintstagedrc.js', 'configs/lintstaged.js');
@@ -1,2 +0,0 @@
1
- const deprecated = require('./deprecated.js');
2
- module.exports = deprecated('.prettierrc.js', 'configs/prettier.js');
@@ -1,2 +0,0 @@
1
- const deprecated = require('./deprecated.js');
2
- module.exports = deprecated('.stylelintrc.js', 'configs/stylelint.js');
@@ -1,3 +0,0 @@
1
- module.exports = {
2
- extends: ['./node_modules/aberlaas/configs/eslint.js'],
3
- };
@@ -1,4 +0,0 @@
1
- const config = require('aberlaas/configs/husky.js');
2
- module.exports = {
3
- ...config,
4
- };
@@ -1,4 +0,0 @@
1
- const config = require('aberlaas/configs/lintstaged.js');
2
- module.exports = {
3
- ...config,
4
- };
@@ -1,4 +0,0 @@
1
- const config = require('aberlaas/configs/prettier.js');
2
- module.exports = {
3
- ...config,
4
- };
@@ -1,4 +0,0 @@
1
- const config = require('aberlaas/configs/stylelint.js');
2
- module.exports = {
3
- ...config,
4
- };
@@ -1,3 +0,0 @@
1
- module.exports = {
2
- presets: ['aberlaas/configs/babel.js'],
3
- };
@@ -1,4 +0,0 @@
1
- const config = require('aberlaas/configs/jest.js');
2
- module.exports = {
3
- ...config,
4
- };
File without changes
File without changes