aberlaas-ci 2.19.0 → 2.20.1

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 (2) hide show
  1. package/lib/main.js +77 -34
  2. package/package.json +18 -21
package/lib/main.js CHANGED
@@ -1,9 +1,44 @@
1
+ import { consoleInfo, firostError, run as firostRun } from 'firost';
2
+ import { yarnRun } from 'aberlaas-helper';
1
3
  import ciInfo from 'ci-info';
2
- import { firostError, run } from 'firost';
3
- import commandTest from 'aberlaas-test';
4
- import commandLint from 'aberlaas-lint';
5
4
 
6
- export default {
5
+ export let __;
6
+
7
+ /**
8
+ * Run CI scripts and fail the job if any fails
9
+ * Runs lint and test by default, but can be changed with --no-test and
10
+ * --no-lint
11
+ * @param {object} cliArgs CLI Argument object, as created by minimist
12
+ * @returns {boolean} True on success, throws on error
13
+ */
14
+ export async function run(cliArgs = {}) {
15
+ const args = {
16
+ test: true,
17
+ lint: true,
18
+ ...cliArgs,
19
+ };
20
+
21
+ if (!__.isCI()) {
22
+ throw firostError(
23
+ 'ABERLAAS_CI_NOT_CI_ENVIRONMENT',
24
+ 'Current system is not a CI. Use CI=1 to force',
25
+ );
26
+ }
27
+
28
+ await __.displayVersions();
29
+
30
+ if (args.test) {
31
+ await __.yarnRunTest();
32
+ }
33
+
34
+ if (args.lint) {
35
+ await __.yarnRunLint();
36
+ }
37
+
38
+ return true;
39
+ }
40
+
41
+ __ = {
7
42
  /**
8
43
  * Checks if currently running on a CI server
9
44
  * @returns {boolean} True if on a CI server
@@ -12,37 +47,45 @@ export default {
12
47
  return ciInfo.isCI;
13
48
  },
14
49
  /**
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
50
+ * Displays the current versions of Node.js and Yarn by executing version commands
20
51
  */
21
- async run(cliArgs = {}) {
22
- const args = {
23
- test: true,
24
- lint: true,
25
- ...cliArgs,
26
- };
27
-
28
- if (!this.isCI()) {
29
- throw firostError(
30
- 'ERROR_CI',
31
- 'Current system is not a CI. Use CI=1 to force',
32
- );
33
- }
34
-
35
- if (args.test) {
36
- await this.__runTest();
37
- }
38
-
39
- if (args.lint) {
40
- await this.__runLint();
41
- }
42
-
52
+ async displayVersions() {
53
+ const nodeVersion = await __.runCommand('node --version');
54
+ const yarnVersion = await __.runCommand('yarn --version');
55
+ __.consoleInfo(`node ${nodeVersion}, yarn ${yarnVersion}`);
56
+ },
57
+ /**
58
+ * Executes a command asynchronously and returns the stdout output
59
+ * @param {string} command - The command to execute
60
+ * @returns {string} The stdout output of the executed command
61
+ */
62
+ async runCommand(command) {
63
+ const { stdout } = await __.firostRun(command, {
64
+ stdout: false,
65
+ });
66
+ return stdout;
67
+ },
68
+ /**
69
+ * Runs the test suite via yarn run test
70
+ * @returns {boolean} True on success
71
+ */
72
+ async yarnRunTest() {
73
+ await __.yarnRun('test');
43
74
  return true;
44
75
  },
45
- __runTest: commandTest.run.bind(commandTest),
46
- __runLint: commandLint.run.bind(commandLint),
47
- __run: run,
76
+ /**
77
+ * Runs linting via yarn run lint
78
+ * @returns {boolean} True on success
79
+ */
80
+ async yarnRunLint() {
81
+ await __.yarnRun('lint');
82
+ return true;
83
+ },
84
+ consoleInfo,
85
+ firostRun,
86
+ yarnRun,
87
+ };
88
+
89
+ export default {
90
+ run,
48
91
  };
package/package.json CHANGED
@@ -1,8 +1,9 @@
1
1
  {
2
2
  "name": "aberlaas-ci",
3
3
  "type": "module",
4
+ "sideEffects": false,
4
5
  "description": "aberlaas ci command: Run tests and lint on each commit on the CI",
5
- "version": "2.19.0",
6
+ "version": "2.20.1",
6
7
  "repository": "pixelastic/aberlaas",
7
8
  "homepage": "https://projects.pixelastic.com/aberlaas/",
8
9
  "author": "Tim Carry (@pixelastic)",
@@ -17,26 +18,22 @@
17
18
  "engines": {
18
19
  "node": ">=18.18.0"
19
20
  },
20
- "scripts": {
21
- "build": "../../scripts/local/build",
22
- "build:prod": "../../scripts/local/build-prod",
23
- "cms": "../../scripts/local/cms",
24
- "serve": "../../scripts/local/serve",
25
- "ci": "../../scripts/local/ci",
26
- "release": "../../scripts/local/release",
27
- "update-dependencies": "node ../../scripts/meta/update-dependencies.js",
28
- "test:meta": "../../scripts/local/test-meta",
29
- "test": "../../scripts/local/test",
30
- "test:": "../../scripts/local/test-",
31
- "compress": "../../scripts/local/compress",
32
- "lint": "../../scripts/local/lint",
33
- "lint:fix": "../../scripts/local/lint-fix"
34
- },
35
21
  "dependencies": {
36
- "aberlaas-lint": "^2.19.0",
37
- "aberlaas-test": "^2.18.1",
38
- "ci-info": "4.1.0",
39
- "firost": "5.2.1"
22
+ "aberlaas-helper": "workspace:*",
23
+ "ci-info": "4.3.1",
24
+ "firost": "5.5.1"
40
25
  },
41
- "gitHead": "11175e8d126f535dc73a3aa942acd79f450d74c4"
26
+ "scripts": {
27
+ "build": "cd ../docs && yarn run build",
28
+ "build:prod": "cd ../docs && yarn run build:prod",
29
+ "cms": "cd ../docs && yarn run cms",
30
+ "serve": "cd ../docs && yarn run serve",
31
+ "release": "cd ../.. && ./scripts/release",
32
+ "test:meta": "cd ../.. && ./scripts/test-meta",
33
+ "test": "cd ../.. && ./scripts/test",
34
+ "test:watch": "cd ../.. && ./scripts/test-watch",
35
+ "compress": "cd ../.. && ./scripts/compress",
36
+ "lint": "cd ../.. && ./scripts/lint",
37
+ "lint:fix": "cd ../.. && ./scripts/lint-fix"
38
+ }
42
39
  }