@naturalcycles/dev-lib 18.4.7 → 18.4.9

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/dist/lint.util.js +15 -3
  2. package/package.json +3 -3
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
+ import { createRequire } from 'node:module';
4
+ import path from 'node:path';
3
5
  import { _assert, _isTruthy, _since, _truncate, semver2 } from '@naturalcycles/js-lib';
4
- import { _yargs, boldGrey, dimGrey, exec2, git2 } from '@naturalcycles/nodejs-lib';
6
+ import { _yargs, boldGrey, dimGrey, exec2, fs2, git2 } from '@naturalcycles/nodejs-lib';
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('prettier', {
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(`node_modules/.bin/biome`, {
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.7",
4
+ "version": "18.4.9",
5
5
  "dependencies": {
6
6
  "@biomejs/biome": "^1",
7
7
  "@commitlint/cli": "^19",
@@ -22,7 +22,7 @@
22
22
  "eslint-plugin-vue": "^10",
23
23
  "globals": "^16",
24
24
  "husky": "^9",
25
- "lint-staged": "^15",
25
+ "lint-staged": "^16",
26
26
  "micromatch": "^4",
27
27
  "mitm": "^1",
28
28
  "prettier": "^3",
@@ -34,7 +34,7 @@
34
34
  "devDependencies": {
35
35
  "@types/mitm": "^1",
36
36
  "stylelint": "^16",
37
- "stylelint-config-standard-scss": "^14"
37
+ "stylelint-config-standard-scss": "^15"
38
38
  },
39
39
  "files": [
40
40
  "dist",