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
@@ -0,0 +1,57 @@
1
+ import * as prettier from 'prettier';
2
+ import helper from '../../../helper.js';
3
+ import firostError from 'firost/error.js';
4
+ import write from 'firost/write.js';
5
+ import read from 'firost/read.js';
6
+ import pMap from 'golgoth/pMap.js';
7
+ import _ from 'golgoth/lodash.js';
8
+
9
+ /**
10
+ * Fix all files using prettier
11
+ * @param {Array} inputFiles Files to auto-fix
12
+ **/
13
+ export async function fix(inputFiles) {
14
+ // Config file
15
+ const configFile = await helper.configFile(
16
+ null,
17
+ '.prettierrc.cjs',
18
+ 'lib/configs/prettier.cjs',
19
+ );
20
+ const config = await prettier.resolveConfig(configFile);
21
+
22
+ const errors = [];
23
+
24
+ // Read all files, run them through the formatter and save them back to disk
25
+ // If any emits error, store the errors and display them all in one output
26
+ await pMap(
27
+ inputFiles,
28
+ async (filepath) => {
29
+ try {
30
+ const content = await read(filepath);
31
+ const options = { ...config, filepath };
32
+ const result = await prettier.format(content, options);
33
+ await write(result, filepath);
34
+ } catch (error) {
35
+ const message = error.toString();
36
+ errors.push({ filepath, message });
37
+ }
38
+ },
39
+ { concurrency: 10 },
40
+ );
41
+
42
+ if (!_.isEmpty(errors)) {
43
+ let formattedErrors = '';
44
+ _.each(errors, (error) => {
45
+ formattedErrors = `${formattedErrors}${error.filepath}\n\n${error.message}\n\n`;
46
+ });
47
+
48
+ throw firostError(
49
+ 'LINT_ERROR_FIX_PRETTIER',
50
+ `Some files could not be automatically fixed:\n\n${formattedErrors}`,
51
+ );
52
+ }
53
+ }
54
+
55
+ export default {
56
+ fix,
57
+ };
@@ -1,18 +1,20 @@
1
- const _ = require('golgoth/lodash');
2
- const pMap = require('golgoth/pMap');
3
- const consoleError = require('firost/consoleError');
4
- const firostError = require('firost/error');
5
- const run = require('firost/run');
6
- const helper = require('../../helper.js');
1
+ import _ from 'golgoth/lodash.js';
2
+ import pMap from 'golgoth/pMap.js';
3
+ import consoleError from 'firost/consoleError.js';
4
+ import firostError from 'firost/error.js';
5
+ import linterCircleCI from './circleci.js';
6
+ import linterCss from './css.js';
7
+ import linterJson from './json.js';
8
+ import linterJs from './js.js';
9
+ import linterYml from './yml.js';
7
10
 
8
- module.exports = {
9
- types: {
10
- circleci: './circleci',
11
- css: './css',
12
- json: './json',
13
- js: './js',
14
- yml: './yml',
15
- yaml: './yml', // Alias --yaml for --yml
11
+ export default {
12
+ linters: {
13
+ circleci: linterCircleCI,
14
+ css: linterCss,
15
+ json: linterJson,
16
+ js: linterJs,
17
+ yml: linterYml,
16
18
  },
17
19
  /**
18
20
  * Wrapper to lint all supported formats
@@ -20,7 +22,7 @@ module.exports = {
20
22
  * @returns {boolean} True on success
21
23
  **/
22
24
  async run(cliArgs) {
23
- const allTypesKeys = _.keys(this.types);
25
+ const allTypesKeys = _.keys(this.linters);
24
26
  const userTypes = _.intersection(_.keys(cliArgs), allTypesKeys);
25
27
  const typesToLint = _.isEmpty(userTypes) ? allTypesKeys : userTypes;
26
28
 
@@ -30,7 +32,7 @@ module.exports = {
30
32
  try {
31
33
  const configFile = _.get(cliArgs, `config.${type}`);
32
34
  const userPatterns = _.get(cliArgs, '_');
33
- const linter = require(this.types[type]);
35
+ const linter = this.linters[type];
34
36
 
35
37
  await linter[methodName](userPatterns, configFile);
36
38
  } catch (error) {
@@ -45,37 +47,5 @@ module.exports = {
45
47
 
46
48
  return true;
47
49
  },
48
- /**
49
- * Find all relevant files of the specified extension in the host
50
- * Note: Should be used by child classes
51
- * @param {Array} safeListExtension List of allowed extensions to keep
52
- * @param {Array} userPatterns Patterns to narrow the search down
53
- * @returns {Array} Array of files
54
- **/
55
- async getInputFiles(safeListExtension, userPatterns = []) {
56
- const inputPatterns = _.isEmpty(userPatterns) ? '.' : userPatterns;
57
- return await helper.findHostFiles(inputPatterns, safeListExtension);
58
- },
59
- /**
60
- * Fix all files using prettier
61
- * Note: Will be called by child classes
62
- * Note: Prettier does not output any information as to why it failed, so
63
- * we'll manually run the command on each file individually so we can catch
64
- * the file that errors and display it
65
- * @param {Array} inputFiles Files to auto-fix
66
- **/
67
- async fixWithPrettier(inputFiles) {
68
- const binary = await helper.which('prettier');
69
- const options = ['--write', ...inputFiles];
70
- try {
71
- const command = `${binary} ${options.join(' ')}`;
72
- await run(command, { stdout: false });
73
- } catch (err) {
74
- throw firostError(
75
- 'LINT_ERROR_FIX_PRETTIER',
76
- 'Some files could not be automatically fixed.\nPlease run `yarn run lint` to further debug'
77
- );
78
- }
79
- },
80
50
  __consoleError: consoleError,
81
51
  };
@@ -1,76 +1,65 @@
1
- const helper = require('../../helper.js');
2
- const lint = require('./index.js');
3
- const _ = require('golgoth/lodash');
4
- const firostError = require('firost/error');
5
- const readJson = require('firost/readJson');
6
- const exists = require('firost/exists');
7
- const run = require('firost/run');
8
- module.exports = {
1
+ import helper from '../../helper.js';
2
+ import _ from 'golgoth/lodash.js';
3
+ import firostError from 'firost/error.js';
4
+ import { ESLint } from 'eslint';
5
+
6
+ export default {
9
7
  /**
10
8
  * Find all relevant files
11
9
  * @param {Array} userPatterns Patterns to narrow the search down
12
10
  * @returns {Array} Array of files
13
11
  **/
14
12
  async getInputFiles(userPatterns) {
15
- // Check all JavaScript files and all files defined in .bin in package.json
16
- const allJsFiles = await lint.getInputFiles(['.js'], userPatterns);
17
- const allBinFiles = await this.getBinFiles();
18
-
19
- return [...allJsFiles, ...allBinFiles];
20
- },
21
- /**
22
- * Returns the list of all bin files defined in the package.json
23
- * @returns {Array} List of bin files
24
- **/
25
- async getBinFiles() {
26
- const packagePath = helper.hostPath('package.json');
27
- const hasPackage = await exists(packagePath);
28
- if (!hasPackage) {
29
- return [];
30
- }
31
- const packageContent = await readJson(packagePath);
32
- return _.chain(packageContent)
33
- .get('bin', {})
34
- .values()
35
- .map((filepath) => {
36
- return helper.hostPath(filepath);
37
- })
38
- .value();
13
+ const filePatterns = _.isEmpty(userPatterns) ? ['./**/*.js'] : userPatterns;
14
+ return await helper.findHostFiles(filePatterns, ['.js']);
39
15
  },
40
16
  /**
41
17
  * Lint all files and display results.
42
18
  * @param {Array} userPatterns Patterns to narrow the search down
43
19
  * @param {string} userConfigFile Custom config file to use
44
- * @param {Array} additionalOptions Other options to pass to the eslint CLI
20
+ * @param {object} userOptions Options to pass to ESLint, including fix
45
21
  * @returns {boolean} True on success
46
22
  **/
47
- async run(userPatterns, userConfigFile, additionalOptions = []) {
23
+ async run(userPatterns, userConfigFile, userOptions = {}) {
24
+ // Options
25
+ const options = { fix: false, ...userOptions };
26
+
27
+ // Files to lint
48
28
  const files = await this.getInputFiles(userPatterns);
49
29
  if (_.isEmpty(files)) {
50
30
  return true;
51
31
  }
52
32
 
33
+ // Config file
53
34
  const configFile = await helper.configFile(
54
35
  userConfigFile,
55
- '.eslintrc.js',
56
- 'lib/configs/eslint.js'
36
+ '.eslintrc.cjs',
37
+ 'lib/configs/eslint.cjs',
57
38
  );
58
- const pluginResolveDir = helper.aberlaasRoot();
59
- const options = [
60
- ...files,
61
- ...additionalOptions,
62
- '--color',
63
- `--config=${configFile}`,
64
- `--resolve-plugins-relative-to=${pluginResolveDir}`,
65
- ];
66
- const binary = await helper.which('eslint');
67
39
 
68
- try {
69
- await run(`${binary} ${options.join(' ')}`, { stdout: false });
70
- } catch (error) {
71
- throw firostError('JavaScriptLintError', error.stdout);
40
+ // Run the actual lint
41
+ const eslint = new ESLint({
42
+ overrideConfigFile: configFile,
43
+ resolvePluginsRelativeTo: helper.aberlaasRoot(),
44
+ ...options,
45
+ });
46
+ const results = await eslint.lintFiles(files);
47
+
48
+ // Fix
49
+ if (options.fix) {
50
+ await ESLint.outputFixes(results);
51
+ }
52
+
53
+ // All good, we can stop
54
+ const errorCount = _.chain(results).map('errorCount').sum().value();
55
+ if (errorCount == 0) {
56
+ return true;
72
57
  }
73
- return true;
58
+
59
+ // Format errors
60
+ const formatter = await eslint.loadFormatter('stylish');
61
+ const errorText = formatter.format(results);
62
+ throw firostError('JavaScriptLintError', errorText);
74
63
  },
75
64
  /**
76
65
  * Autofix files in place
@@ -79,7 +68,6 @@ module.exports = {
79
68
  * @returns {boolean} True on success
80
69
  **/
81
70
  async fix(userPatterns, userConfigFile) {
82
- return await this.run(userPatterns, userConfigFile, ['--fix']);
71
+ return await this.run(userPatterns, userConfigFile, { fix: true });
83
72
  },
84
- __run: run,
85
73
  };
@@ -1,19 +1,22 @@
1
- const helper = require('../../helper.js');
2
- const path = require('path');
3
- const lint = require('./index.js');
4
- const _ = require('golgoth/lodash');
5
- const pMap = require('golgoth/pMap');
6
- const firostError = require('firost/error');
7
- const read = require('firost/read');
1
+ import helper from '../../helper.js';
2
+ import { fix as prettierFix } from './helpers/prettier.js';
3
+ import path from 'path';
4
+ import _ from 'golgoth/lodash.js';
5
+ import pMap from 'golgoth/pMap.js';
6
+ import firostError from 'firost/error.js';
7
+ import read from 'firost/read.js';
8
8
 
9
- module.exports = {
9
+ export default {
10
10
  /**
11
11
  * Find all relevant files
12
12
  * @param {Array} userPatterns Patterns to narrow the search down
13
13
  * @returns {Array} Array of files
14
14
  **/
15
15
  async getInputFiles(userPatterns) {
16
- return await lint.getInputFiles(['.json'], userPatterns);
16
+ const filePatterns = _.isEmpty(userPatterns)
17
+ ? ['./**/*.json']
18
+ : userPatterns;
19
+ return await helper.findHostFiles(filePatterns, ['.json']);
17
20
  },
18
21
  /**
19
22
  * Lint all files and display results.
@@ -30,7 +33,7 @@ module.exports = {
30
33
  const errorMessages = [];
31
34
  await pMap(files, async (filepath) => {
32
35
  try {
33
- this.__parse(await read(filepath));
36
+ JSON.parse(await read(filepath));
34
37
  } catch (error) {
35
38
  hasErrors = true;
36
39
  const relativePath = path.relative(helper.hostRoot(), filepath);
@@ -54,7 +57,6 @@ module.exports = {
54
57
  if (_.isEmpty(files)) {
55
58
  return true;
56
59
  }
57
- await lint.fixWithPrettier(files);
60
+ await prettierFix(files);
58
61
  },
59
- __parse: JSON.parse,
60
62
  };
@@ -1,19 +1,23 @@
1
- const lint = require('./index.js');
2
- const helper = require('../../helper.js');
3
- const firostError = require('firost/error');
4
- const read = require('firost/read');
5
- const _ = require('golgoth/lodash');
6
- const pMap = require('golgoth/pMap');
7
- const yamlLint = require('yaml-lint');
8
- const path = require('path');
9
- module.exports = {
1
+ import helper from '../../helper.js';
2
+ import { fix as prettierFix } from './helpers/prettier.js';
3
+ import firostError from 'firost/error.js';
4
+ import read from 'firost/read.js';
5
+ import _ from 'golgoth/lodash.js';
6
+ import pMap from 'golgoth/pMap.js';
7
+ import yamlLint from 'yaml-lint';
8
+ import path from 'path';
9
+
10
+ export default {
10
11
  /**
11
12
  * Find all relevant files
12
13
  * @param {Array} userPatterns Patterns to narrow the search down
13
14
  * @returns {Array} Array of files
14
15
  **/
15
16
  async getInputFiles(userPatterns) {
16
- return await lint.getInputFiles(['.yml', '.yaml'], userPatterns);
17
+ const filePatterns = _.isEmpty(userPatterns)
18
+ ? ['./**/*.yml', './**/*.yaml']
19
+ : userPatterns;
20
+ return await helper.findHostFiles(filePatterns, ['.yml', '.yaml']);
17
21
  },
18
22
  /**
19
23
  * Lint all files and display results.
@@ -31,7 +35,7 @@ module.exports = {
31
35
  await pMap(files, async (filepath) => {
32
36
  const input = await read(filepath);
33
37
  try {
34
- await this.__lint(input);
38
+ await yamlLint.lint(input);
35
39
  } catch (error) {
36
40
  hasErrors = true;
37
41
  const relativePath = path.relative(helper.hostRoot(), filepath);
@@ -55,7 +59,6 @@ module.exports = {
55
59
  if (_.isEmpty(files)) {
56
60
  return true;
57
61
  }
58
- await lint.fixWithPrettier(files);
62
+ await prettierFix(files);
59
63
  },
60
- __lint: yamlLint.lint,
61
64
  };
@@ -1,14 +1,14 @@
1
- const lintStaged = require('lint-staged');
2
- const firostError = require('firost/error');
3
- const helper = require('../helper');
1
+ import lintStaged from 'lint-staged';
2
+ import firostError from 'firost/error.js';
3
+ import helper from '../../helper.js';
4
4
 
5
- module.exports = {
5
+ export default {
6
6
  async run(cliArgs) {
7
7
  // Config
8
8
  const configPath = await helper.configFile(
9
9
  cliArgs.config,
10
- '.lintstagedrc.js',
11
- 'lib/configs/lintstaged.js'
10
+ '.lintstagedrc.cjs',
11
+ 'lib/configs/lintstaged.cjs',
12
12
  );
13
13
 
14
14
  try {
@@ -19,7 +19,7 @@ module.exports = {
19
19
  if (!result) {
20
20
  throw firostError(
21
21
  'ERROR_PRECOMMIT_LINT_FAILED',
22
- 'Precommit linting failed'
22
+ 'Precommit linting failed',
23
23
  );
24
24
  }
25
25
  } catch (error) {
@@ -1,16 +1,16 @@
1
- const helper = require('../../helper.js');
2
- const _ = require('golgoth/lodash');
3
- const pMap = require('golgoth/pMap');
4
- const readJson = require('firost/readJson');
5
- const read = require('firost/read');
6
- const write = require('firost/write');
7
- const glob = require('firost/glob');
8
- const exists = require('firost/exists');
9
- const path = require('path');
10
- const frontMatter = require('front-matter');
11
- const dedent = require('golgoth/dedent');
12
-
13
- module.exports = {
1
+ import helper from '../../helper.js';
2
+ import _ from 'golgoth/lodash.js';
3
+ import pMap from 'golgoth/pMap.js';
4
+ import readJson from 'firost/readJson.js';
5
+ import read from 'firost/read.js';
6
+ import write from 'firost/write.js';
7
+ import glob from 'firost/glob.js';
8
+ import exists from 'firost/exists.js';
9
+ import path from 'path';
10
+ import frontMatter from 'front-matter';
11
+ import dedent from 'golgoth/dedent.js';
12
+
13
+ export default {
14
14
  /**
15
15
  * Update the main README.md based on the template and the documentation
16
16
  * @param {object} cliArgs CLI Argument object, as created by minimist
@@ -59,7 +59,7 @@ module.exports = {
59
59
  }
60
60
 
61
61
  const aberlaasDefaultTemplate = helper.aberlaasPath(
62
- 'templates/_github/README.template.md'
62
+ 'templates/_github/README.template.md',
63
63
  );
64
64
  return await read(aberlaasDefaultTemplate);
65
65
  },
@@ -141,7 +141,7 @@ module.exports = {
141
141
  const packagePath = await this.getPackagePath(cliArgs);
142
142
  const moduleReadmePath = path.resolve(
143
143
  path.dirname(packagePath),
144
- 'README.md'
144
+ 'README.md',
145
145
  );
146
146
 
147
147
  const readmes = _.uniq([hostReadmePath, moduleReadmePath]);
@@ -169,7 +169,7 @@ module.exports = {
169
169
  const key = match.groups.key;
170
170
  convertedSource = convertedSource.replace(
171
171
  `{${key}}`,
172
- _.get(data, key, '')
172
+ _.get(data, key, ''),
173
173
  );
174
174
  });
175
175
  return convertedSource;
@@ -1,10 +1,9 @@
1
- /* eslint-disable jest/no-jest-import */
2
- const _ = require('golgoth/_');
3
- const run = require('firost/run');
4
- const readJson = require('firost/readJson');
5
- const helper = require('../helper');
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';
6
5
 
7
- module.exports = {
6
+ export default {
8
7
  /**
9
8
  * Release the host package.
10
9
  * @param {object} cliArgs CLI Argument object, as created by minimist
@@ -1,10 +1,11 @@
1
- const circleciHelper = require('../helpers/circleci.js');
2
- const githubHelper = require('../helpers/github.js');
3
- const npmHelper = require('../helpers/npm.js');
4
- const consoleInfo = require('firost/consoleInfo');
5
- const consoleSuccess = require('firost/consoleSuccess');
6
- const pMap = require('golgoth/pMap');
7
- module.exports = {
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 {
8
9
  /**
9
10
  * Save an ENV variable to CircleCI
10
11
  * @param {string} name Name of the ENV variable
@@ -17,7 +18,7 @@ module.exports = {
17
18
  `project/github/${username}/${repo}/envvar/${name}`,
18
19
  {
19
20
  method: 'delete',
20
- }
21
+ },
21
22
  );
22
23
  } catch (err) {
23
24
  // Ignoring the error, it means the ENV var wasn't set in the first place
@@ -1,13 +1,14 @@
1
- const envVars = require('./envVars.js');
2
- const privateKey = require('./privateKey.js');
3
- const publicKey = require('./publicKey.js');
4
- const sshHelper = require('../helpers/ssh.js');
5
- const npmHelper = require('../helpers/npm.js');
6
- const githubHelper = require('../helpers/github.js');
7
- const circleciHelper = require('../helpers/circleci.js');
8
- const _ = require('golgoth/lodash');
9
- const consoleError = require('firost/consoleError');
10
- module.exports = {
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 {
11
12
  /**
12
13
  * Enable autoRelease by configuring CircleCI and GitHub
13
14
  * @returns {boolean} True if enabled, false otherwise
@@ -17,7 +18,7 @@ module.exports = {
17
18
  const validationErrors = await this.validationErrors();
18
19
  if (!_.isEmpty(validationErrors)) {
19
20
  this.__consoleError(
20
- '[autoRelease] Please fix the following errors and try again:'
21
+ '[autoRelease] Please fix the following errors and try again:',
21
22
  );
22
23
  _.each(validationErrors, (error) => {
23
24
  this.__consoleError(error);
@@ -1,8 +1,9 @@
1
- const circleciHelper = require('../helpers/circleci.js');
2
- const githubHelper = require('../helpers/github.js');
3
- const sshHelper = require('../helpers/ssh.js');
4
- const consoleSuccess = require('firost/consoleSuccess');
5
- module.exports = {
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 {
6
7
  /**
7
8
  * Save a private SSH key on CircleCI.
8
9
  * The CircleCI API does not allow checking if a SSH key has been defined,
@@ -1,10 +1,11 @@
1
- const githubHelper = require('../helpers/github.js');
2
- const sshHelper = require('../helpers/ssh.js');
3
- const _ = require('golgoth/lodash');
4
- const consoleInfo = require('firost/consoleInfo');
5
- const consoleSuccess = require('firost/consoleSuccess');
6
- const consoleError = require('firost/consoleError');
7
- module.exports = {
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 {
8
9
  /**
9
10
  * Check if SSH public key is already added to GitHub
10
11
  * @returns {boolean} True if already enabled, false otherwise
@@ -1,10 +1,11 @@
1
- const githubHelper = require('./helpers/github.js');
2
- const circleCiHelper = require('./helpers/circleci.js');
3
- const _ = require('golgoth/lodash');
4
- const consoleInfo = require('firost/consoleInfo');
5
- const consoleSuccess = require('firost/consoleSuccess');
6
- const consoleError = require('firost/consoleError');
7
- module.exports = {
1
+ import githubHelper from './helpers/github.js';
2
+ import circleCiHelper from './helpers/circleci.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 {
8
9
  /**
9
10
  * Attempt to automatically follow the repo in CircleCI if possible, otherwise
10
11
  * display the link to follow it manually
@@ -18,7 +19,7 @@ module.exports = {
18
19
  // Fail early if no token available
19
20
  if (!circleCiHelper.hasToken()) {
20
21
  this.__consoleError(
21
- `[circleci]: No CIRCLECI_TOKEN found, please visit ${followUrl} to enable manually.`
22
+ `[circleci]: No CIRCLECI_TOKEN found, please visit ${followUrl} to enable manually.`,
22
23
  );
23
24
  return false;
24
25
  }
@@ -1,7 +1,8 @@
1
- const githubHelper = require('./helpers/github.js');
2
- const consoleSuccess = require('firost/consoleSuccess');
3
- const consoleError = require('firost/consoleError');
4
- module.exports = {
1
+ import githubHelper from './helpers/github.js';
2
+ import consoleSuccess from 'firost/consoleSuccess.js';
3
+ import consoleError from 'firost/consoleError.js';
4
+
5
+ export default {
5
6
  /**
6
7
  * Configure the GitHub repo with default settings:
7
8
  * - Do not enable merge commits on PR
@@ -16,7 +17,7 @@ module.exports = {
16
17
  // Fail early if no token available
17
18
  if (!githubHelper.hasToken()) {
18
19
  this.__consoleError(
19
- `[github]: No GITHUB_TOKEN found, please visit ${manualUrl} to configure manually.`
20
+ `[github]: No GITHUB_TOKEN found, please visit ${manualUrl} to configure manually.`,
20
21
  );
21
22
  return false;
22
23
  }
@@ -1,7 +1,8 @@
1
- const got = require('golgoth/got');
2
- const _ = require('golgoth/lodash');
3
- const firostError = require('firost/error');
4
- module.exports = {
1
+ import got from 'golgoth/got.js';
2
+ import _ from 'golgoth/lodash.js';
3
+ import firostError from 'firost/error.js';
4
+
5
+ export default {
5
6
  /**
6
7
  * Returns the CircleCI token saved in ENV
7
8
  * @returns {string} The CircleCI token
@@ -35,7 +36,7 @@ module.exports = {
35
36
  } catch (error) {
36
37
  throw firostError(
37
38
  'ERROR_CIRCLECI',
38
- "Can't connect to CircleCI API. Check that you have a valid CIRCLECI_TOKEN"
39
+ "Can't connect to CircleCI API. Check that you have a valid CIRCLECI_TOKEN",
39
40
  );
40
41
  }
41
42
  },