@naturalcycles/dev-lib 18.4.6 → 18.4.8
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/dist/lint.util.js +15 -3
- package/package.json +2 -2
package/dist/lint.util.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { execSync } from 'node:child_process';
|
|
2
2
|
import { existsSync } from 'node:fs';
|
|
3
3
|
import { _assert, _isTruthy, _since, _truncate, semver2 } from '@naturalcycles/js-lib';
|
|
4
|
-
import { _yargs, boldGrey, dimGrey, exec2, git2 } from '@naturalcycles/nodejs-lib';
|
|
4
|
+
import { _yargs, boldGrey, dimGrey, exec2, fs2, git2 } from '@naturalcycles/nodejs-lib';
|
|
5
|
+
import { createRequire } from 'node:module';
|
|
6
|
+
import path from 'node:path';
|
|
5
7
|
import { eslintExtensions, lintExclude, minActionlintVersion, prettierDirs, prettierExtensionsAll, stylelintExtensions, } from '../cfg/_cnst.js';
|
|
6
8
|
import { cfgDir, scriptsDir } from './paths.js';
|
|
7
9
|
/**
|
|
@@ -131,8 +133,9 @@ export function runPrettier() {
|
|
|
131
133
|
const prettierConfigPath = [`./prettier.config.js`].find(f => existsSync(f));
|
|
132
134
|
if (!prettierConfigPath)
|
|
133
135
|
return;
|
|
136
|
+
const prettierPath = findPackageBinPath('prettier', 'prettier');
|
|
134
137
|
// prettier --write 'src/**/*.{js,ts,css,scss,graphql}'
|
|
135
|
-
exec2.spawn(
|
|
138
|
+
exec2.spawn(prettierPath, {
|
|
136
139
|
args: [`--write`, `--log-level=warn`, `--config`, prettierConfigPath, ...prettierPaths],
|
|
137
140
|
shell: false,
|
|
138
141
|
});
|
|
@@ -153,6 +156,7 @@ export function stylelintAll() {
|
|
|
153
156
|
const config = [`./stylelint.config.js`].find(f => existsSync(f));
|
|
154
157
|
if (!config)
|
|
155
158
|
return;
|
|
159
|
+
// todo: findPackageBinPath('stylelint', 'stylelint')
|
|
156
160
|
exec2.spawn('stylelint', {
|
|
157
161
|
args: [fix ? `--fix` : '', `--allow-empty-input`, `--config`, config, ...stylelintPaths].filter(Boolean),
|
|
158
162
|
shell: false,
|
|
@@ -179,6 +183,7 @@ export function runCommitlintCommand() {
|
|
|
179
183
|
const env = {
|
|
180
184
|
GIT_BRANCH: git2.getCurrentBranchName(),
|
|
181
185
|
};
|
|
186
|
+
// todo: findPackageBinPath('@commitlint/cli', 'commitlint')
|
|
182
187
|
// await execWithArgs(`commitlint`, [`--edit`, editMsg, `--config`, config], { env })
|
|
183
188
|
exec2.spawn(`node ./node_modules/.bin/commitlint --edit ${editMsg} --config ${config}`, {
|
|
184
189
|
env,
|
|
@@ -230,8 +235,9 @@ export function runBiome(fix = true) {
|
|
|
230
235
|
console.log(`biome is skipped, because ./biome.jsonc is not present`);
|
|
231
236
|
return;
|
|
232
237
|
}
|
|
238
|
+
const biomePath = findPackageBinPath('@biomejs/biome', 'biome');
|
|
233
239
|
const dirs = [`src`, `scripts`, `e2e`].filter(d => existsSync(d));
|
|
234
|
-
exec2.spawn(
|
|
240
|
+
exec2.spawn(biomePath, {
|
|
235
241
|
args: [`lint`, fix && '--write', fix && '--unsafe', '--no-errors-on-unmatched', ...dirs].filter(_isTruthy),
|
|
236
242
|
logFinish: false,
|
|
237
243
|
shell: false,
|
|
@@ -254,3 +260,9 @@ function gitStatus() {
|
|
|
254
260
|
}
|
|
255
261
|
catch { }
|
|
256
262
|
}
|
|
263
|
+
const require = createRequire(import.meta.url);
|
|
264
|
+
function findPackageBinPath(pkg, cmd) {
|
|
265
|
+
const packageJsonPath = require.resolve(`${pkg}/package.json`);
|
|
266
|
+
const { bin } = fs2.readJson(packageJsonPath);
|
|
267
|
+
return path.join(path.dirname(packageJsonPath), typeof bin === 'string' ? bin : bin[cmd]);
|
|
268
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@naturalcycles/dev-lib",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "18.4.
|
|
4
|
+
"version": "18.4.8",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"@biomejs/biome": "^1",
|
|
7
7
|
"@commitlint/cli": "^19",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"vue-eslint-parser": "^10"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
|
-
"@types/mitm": "^1
|
|
35
|
+
"@types/mitm": "^1",
|
|
36
36
|
"stylelint": "^16",
|
|
37
37
|
"stylelint-config-standard-scss": "^14"
|
|
38
38
|
},
|