@naturalcycles/dev-lib 13.41.0 → 13.42.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.
@@ -6,6 +6,7 @@
6
6
 
7
7
  const micromatch = require('micromatch')
8
8
  const fs = require('node:fs')
9
+ const { execSync } = require('node:child_process')
9
10
  const {
10
11
  prettierDirs,
11
12
  prettierExtensionsExclusive,
@@ -85,6 +86,20 @@ const linters = {
85
86
 
86
87
  return [`${dir}/resources/ktlint -F ${filesList}`]
87
88
  },
89
+
90
+ './.github/**/*.{yml,yaml}': match => {
91
+ if (!match.length) return []
92
+
93
+ if (!canRunBinary('actionlint')) {
94
+ console.log(
95
+ `actionlint is not installed and won't be run.\nThis is how to install it: https://github.com/rhysd/actionlint/blob/main/docs/install.md`,
96
+ )
97
+ return []
98
+ }
99
+
100
+ // run actionlint on all files at once, as it's fast anyway
101
+ return [`actionlint`]
102
+ },
88
103
  }
89
104
 
90
105
  // /scripts are separate, cause they require separate tsconfig.json
@@ -125,4 +140,13 @@ if (fs.existsSync(`./e2e`)) {
125
140
  })
126
141
  }
127
142
 
143
+ function canRunBinary(name) {
144
+ try {
145
+ execSync(`which ${name}`)
146
+ return true
147
+ } catch {
148
+ return false
149
+ }
150
+ }
151
+
128
152
  module.exports = linters
@@ -1,4 +1,4 @@
1
1
  /**
2
- * We run eslint BEFORE Prettier, because eslint can delete e.g unused imports.
2
+ * Run all linters.
3
3
  */
4
4
  export declare function lintAllCommand(): Promise<void>;
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.lintAllCommand = void 0;
4
4
  const tslib_1 = require("tslib");
5
+ const node_child_process_1 = require("node:child_process");
5
6
  const node_fs_1 = tslib_1.__importDefault(require("node:fs"));
6
7
  const js_lib_1 = require("@naturalcycles/js-lib");
7
8
  const nodejs_lib_1 = require("@naturalcycles/nodejs-lib");
@@ -10,7 +11,7 @@ const prettier_util_1 = require("../util/prettier.util");
10
11
  const stylelint_util_1 = require("../util/stylelint.util");
11
12
  const eslint_all_command_1 = require("./eslint-all.command");
12
13
  /**
13
- * We run eslint BEFORE Prettier, because eslint can delete e.g unused imports.
14
+ * Run all linters.
14
15
  */
15
16
  async function lintAllCommand() {
16
17
  const started = Date.now();
@@ -24,7 +25,25 @@ async function lintAllCommand() {
24
25
  default: false,
25
26
  },
26
27
  }).argv;
28
+ if (canRunBinary('actionlint')) {
29
+ const env_1 = { stack: [], error: void 0, hasError: false };
30
+ try {
31
+ const _ = tslib_1.__addDisposableResource(env_1, (0, js_lib_1._blockTimer)('actionlint'), false);
32
+ (0, nodejs_lib_1.execVoidCommandSync)(`actionlint`);
33
+ }
34
+ catch (e_1) {
35
+ env_1.error = e_1;
36
+ env_1.hasError = true;
37
+ }
38
+ finally {
39
+ tslib_1.__disposeResources(env_1);
40
+ }
41
+ }
42
+ else {
43
+ console.log(`actionlint is not installed and won't be run.\nThis is how to install it: https://github.com/rhysd/actionlint/blob/main/docs/install.md`);
44
+ }
27
45
  const hadChangesBefore = (0, nodejs_lib_1.gitHasUncommittedChanges)();
46
+ // We run eslint BEFORE Prettier, because eslint can delete e.g unused imports.
28
47
  await (0, eslint_all_command_1.eslintAllCommand)();
29
48
  if (node_fs_1.default.existsSync(`node_modules/stylelint`) &&
30
49
  node_fs_1.default.existsSync(`node_modules/stylelint-config-standard-scss`)) {
@@ -59,3 +78,12 @@ async function lintAllCommand() {
59
78
  }
60
79
  }
61
80
  exports.lintAllCommand = lintAllCommand;
81
+ function canRunBinary(name) {
82
+ try {
83
+ (0, node_child_process_1.execSync)(`which ${name}`);
84
+ return true;
85
+ }
86
+ catch {
87
+ return false;
88
+ }
89
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@naturalcycles/dev-lib",
3
- "version": "13.41.0",
3
+ "version": "13.42.0",
4
4
  "scripts": {
5
5
  "prepare": "husky install",
6
6
  "tsn-debug": "tsn testScript.ts",
@@ -51,6 +51,7 @@
51
51
  "husky": "^8.0.1",
52
52
  "jest-junit": "^16.0.0",
53
53
  "lint-staged": "^14.0.0",
54
+ "micromatch": "^4.0.5",
54
55
  "mitm": "^1.7.0",
55
56
  "prettier": "^3.0.0",
56
57
  "timekeeper": "^2.2.0",
@@ -61,7 +62,7 @@
61
62
  "devDependencies": {
62
63
  "jest": "^29.0.0",
63
64
  "stylelint": "^15.0.0",
64
- "stylelint-config-standard-scss": "^10.0.0"
65
+ "stylelint-config-standard-scss": "^11.0.0"
65
66
  },
66
67
  "files": [
67
68
  "dist",
package/readme.md CHANGED
@@ -137,7 +137,7 @@ If you need to execute shards **in parallel**, you can follow e.g
137
137
 
138
138
  #### Lint commands
139
139
 
140
- - `lint-all`: runs ESLint, Stylelint, Prettier, in the right order.
140
+ - `lint-all`: runs ESLint, Stylelint, Prettier, actionlint, ktlint in the right order.
141
141
 
142
142
  - `--commitOnChanges` will commit lint-modified changes and push them
143
143
  - `--failOnChanges` will exit with status 1 in the end (will fail the command)