@naturalcycles/dev-lib 15.27.5 → 15.28.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.
- package/cfg/_cnst.js +1 -0
- package/cfg/lint-staged.config.js +29 -0
- package/dist/lint.util.d.ts +3 -0
- package/dist/lint.util.js +16 -1
- package/package.json +1 -1
package/cfg/_cnst.js
CHANGED
|
@@ -15,12 +15,16 @@ console.log(`lint-staged.config.js runs on node ${node} ${platform} ${arch}`)
|
|
|
15
15
|
const fs = require('node:fs')
|
|
16
16
|
const micromatch = require('micromatch')
|
|
17
17
|
const { execSync } = require('node:child_process')
|
|
18
|
+
const { _assert, semver2 } = require('@naturalcycles/js-lib')
|
|
19
|
+
const { exec2 } = require('@naturalcycles/nodejs-lib')
|
|
20
|
+
|
|
18
21
|
const {
|
|
19
22
|
prettierDirs,
|
|
20
23
|
prettierExtensionsExclusive,
|
|
21
24
|
prettierExtensionsAll,
|
|
22
25
|
stylelintExtensions,
|
|
23
26
|
lintExclude,
|
|
27
|
+
minActionlintVersion,
|
|
24
28
|
} = require('./_cnst')
|
|
25
29
|
|
|
26
30
|
const prettierConfigPath = [`prettier.config.js`].find(fs.existsSync)
|
|
@@ -129,6 +133,8 @@ const linters = {
|
|
|
129
133
|
return []
|
|
130
134
|
}
|
|
131
135
|
|
|
136
|
+
requireActionlintVersion()
|
|
137
|
+
|
|
132
138
|
// run actionlint on all files at once, as it's fast anyway
|
|
133
139
|
return [`actionlint`]
|
|
134
140
|
},
|
|
@@ -192,4 +198,27 @@ function canRunBinary(name) {
|
|
|
192
198
|
}
|
|
193
199
|
}
|
|
194
200
|
|
|
201
|
+
function requireActionlintVersion() {
|
|
202
|
+
const version = getActionLintVersion()
|
|
203
|
+
if (!version) {
|
|
204
|
+
return
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
console.log(`actionlint version: ${version}`)
|
|
208
|
+
|
|
209
|
+
_assert(
|
|
210
|
+
semver2(version).isSameOrAfter(minActionlintVersion),
|
|
211
|
+
`actionlint needs to be updated. Min accepted version: ${minActionlintVersion}, local version: ${version}\nThis is how to install/update it: https://github.com/rhysd/actionlint/blob/main/docs/install.md`,
|
|
212
|
+
)
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
function getActionLintVersion() {
|
|
216
|
+
try {
|
|
217
|
+
return exec2.exec('actionlint --version').split('\n')[0]
|
|
218
|
+
} catch (err) {
|
|
219
|
+
console.log(err)
|
|
220
|
+
return undefined
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
|
|
195
224
|
module.exports = linters
|
package/dist/lint.util.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { SemVerString } from '@naturalcycles/js-lib';
|
|
1
2
|
/**
|
|
2
3
|
* Run all linters.
|
|
3
4
|
*/
|
|
@@ -14,5 +15,7 @@ export declare function runPrettier(): void;
|
|
|
14
15
|
export declare function stylelintAll(): void;
|
|
15
16
|
export declare function lintStagedCommand(): Promise<void>;
|
|
16
17
|
export declare function runCommitlintCommand(): void;
|
|
18
|
+
export declare function requireActionlintVersion(): void;
|
|
19
|
+
export declare function getActionLintVersion(): SemVerString | undefined;
|
|
17
20
|
export declare function runBiome(fix?: boolean): void;
|
|
18
21
|
export {};
|
package/dist/lint.util.js
CHANGED
|
@@ -6,6 +6,8 @@ exports.runPrettier = runPrettier;
|
|
|
6
6
|
exports.stylelintAll = stylelintAll;
|
|
7
7
|
exports.lintStagedCommand = lintStagedCommand;
|
|
8
8
|
exports.runCommitlintCommand = runCommitlintCommand;
|
|
9
|
+
exports.requireActionlintVersion = requireActionlintVersion;
|
|
10
|
+
exports.getActionLintVersion = getActionLintVersion;
|
|
9
11
|
exports.runBiome = runBiome;
|
|
10
12
|
const tslib_1 = require("tslib");
|
|
11
13
|
const node_child_process_1 = tslib_1.__importDefault(require("node:child_process"));
|
|
@@ -14,7 +16,7 @@ const js_lib_1 = require("@naturalcycles/js-lib");
|
|
|
14
16
|
const nodejs_lib_1 = require("@naturalcycles/nodejs-lib");
|
|
15
17
|
const yargs_1 = tslib_1.__importDefault(require("yargs"));
|
|
16
18
|
const paths_1 = require("./paths");
|
|
17
|
-
const { prettierDirs, prettierExtensionsAll, stylelintExtensions, eslintExtensions, lintExclude, } = require('../cfg/_cnst');
|
|
19
|
+
const { prettierDirs, prettierExtensionsAll, stylelintExtensions, eslintExtensions, lintExclude, minActionlintVersion, } = require('../cfg/_cnst');
|
|
18
20
|
/**
|
|
19
21
|
* Run all linters.
|
|
20
22
|
*/
|
|
@@ -229,12 +231,25 @@ function runActionLint() {
|
|
|
229
231
|
if (!node_fs_1.default.existsSync('.github/workflows'))
|
|
230
232
|
return;
|
|
231
233
|
if (canRunBinary('actionlint')) {
|
|
234
|
+
requireActionlintVersion();
|
|
232
235
|
nodejs_lib_1.exec2.spawn(`actionlint`);
|
|
233
236
|
}
|
|
234
237
|
else {
|
|
235
238
|
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`);
|
|
236
239
|
}
|
|
237
240
|
}
|
|
241
|
+
function requireActionlintVersion() {
|
|
242
|
+
const version = getActionLintVersion();
|
|
243
|
+
if (!version) {
|
|
244
|
+
return;
|
|
245
|
+
}
|
|
246
|
+
(0, js_lib_1._assert)((0, js_lib_1.semver2)(version).isSameOrAfter(minActionlintVersion), `actionlint needs to be updated. Min accepted version: ${minActionlintVersion}, local version: ${version}\nThis is how to install/update it: https://github.com/rhysd/actionlint/blob/main/docs/install.md`);
|
|
247
|
+
}
|
|
248
|
+
function getActionLintVersion() {
|
|
249
|
+
if (!canRunBinary('actionlint'))
|
|
250
|
+
return;
|
|
251
|
+
return nodejs_lib_1.exec2.exec('actionlint --version').split('\n')[0];
|
|
252
|
+
}
|
|
238
253
|
function runBiome(fix = true) {
|
|
239
254
|
// if (!fs.existsSync(`node_modules/@biomejs/biome`)) {
|
|
240
255
|
// if (verbose) {
|