@apollion-dsi/scripts 0.9.0 → 0.9.2
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/CHANGELOG.md +25 -0
- package/coverage/clover.xml +20 -12
- package/coverage/coverage-final.json +8 -7
- package/coverage/lcov-report/config/env.ts.html +2 -2
- package/coverage/lcov-report/config/index.html +1 -1
- package/coverage/lcov-report/config/paths.ts.html +1 -1
- package/coverage/lcov-report/config/shared.ts.html +1 -1
- package/coverage/lcov-report/index.html +17 -17
- package/coverage/lcov-report/utils/buildWrapperArgs.ts.html +196 -0
- package/coverage/lcov-report/utils/checkRequiredFiles.ts.html +1 -1
- package/coverage/lcov-report/utils/formatWebpackMessages.ts.html +1 -1
- package/coverage/lcov-report/utils/getPublicUrlOrPath.ts.html +1 -1
- package/coverage/lcov-report/utils/index.html +23 -8
- package/coverage/lcov-report/utils/resolveBin.ts.html +1 -1
- package/coverage/lcov.info +22 -2
- package/lib/bin.js +0 -0
- package/lib/command/lint.js +12 -16
- package/lib/command/lint.js.map +1 -1
- package/lib/command/prettier.js +9 -14
- package/lib/command/prettier.js.map +1 -1
- package/lib/utils/buildWrapperArgs.d.ts +32 -0
- package/lib/utils/buildWrapperArgs.js +39 -0
- package/lib/utils/buildWrapperArgs.js.map +1 -0
- package/llms.txt +8 -3
- package/package.json +2 -2
- package/src/__tests__/buildWrapperArgs.test.ts +73 -0
- package/src/command/lint.ts +12 -16
- package/src/command/prettier.ts +9 -14
- package/src/utils/buildWrapperArgs.ts +37 -0
- /package/{README.md → README.MD} +0 -0
package/src/command/lint.ts
CHANGED
|
@@ -1,30 +1,26 @@
|
|
|
1
1
|
import spawn from 'cross-spawn';
|
|
2
2
|
|
|
3
|
+
import { buildWrapperArgs } from '../utils/buildWrapperArgs';
|
|
3
4
|
import { resolveBin } from '../utils/resolveBin';
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
|
-
* `scripts lint` — ESLint over `src
|
|
7
|
-
*
|
|
7
|
+
* `scripts lint` — ESLint over `src`. ESLint 9 flat config uses
|
|
8
|
+
* `eslint.config.js#files` for filtering (no `--ext`).
|
|
8
9
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
10
|
+
* Flag args pass through; the default `src` target is always appended
|
|
11
|
+
* so the common case (`scripts lint --fix`, `scripts lint
|
|
12
|
+
* --max-warnings 0`, `scripts lint -- --fix`) Just Works. Consumers
|
|
13
|
+
* that need a different target should call `eslint` directly from
|
|
14
|
+
* `node_modules/.bin`.
|
|
12
15
|
*/
|
|
13
16
|
const eslintBin = resolveBin('eslint');
|
|
14
17
|
|
|
15
18
|
const userArgs = process.argv.slice(2);
|
|
16
19
|
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
if (userArgs.length === 0) {
|
|
22
|
-
args = ['src', '--quiet'];
|
|
23
|
-
} else if (userProvidedPath) {
|
|
24
|
-
args = userArgs;
|
|
25
|
-
} else {
|
|
26
|
-
args = [...userArgs, 'src'];
|
|
27
|
-
}
|
|
20
|
+
const args = buildWrapperArgs(userArgs, {
|
|
21
|
+
defaults: ['src', '--quiet'],
|
|
22
|
+
target: 'src',
|
|
23
|
+
});
|
|
28
24
|
|
|
29
25
|
const result = spawn.sync(process.execPath, [eslintBin, ...args], { stdio: 'inherit' });
|
|
30
26
|
|
package/src/command/prettier.ts
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import spawn from 'cross-spawn';
|
|
2
2
|
|
|
3
|
+
import { buildWrapperArgs } from '../utils/buildWrapperArgs';
|
|
3
4
|
import { resolveBin } from '../utils/resolveBin';
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* `scripts prettier` — `--check` over `src/**\/*.{ts,tsx,json,css,md}`.
|
|
7
8
|
*
|
|
8
|
-
* Flag
|
|
9
|
-
*
|
|
10
|
-
*
|
|
9
|
+
* Flag args pass through; the default glob is always appended so
|
|
10
|
+
* `scripts prettier --write` Just Works. Consumers that need a
|
|
11
|
+
* different target should call `prettier` directly from
|
|
12
|
+
* `node_modules/.bin`.
|
|
11
13
|
*/
|
|
12
14
|
const prettierBin = resolveBin('prettier');
|
|
13
15
|
|
|
@@ -15,17 +17,10 @@ const DEFAULT_GLOB = 'src/**/*.{ts,tsx,json,css,md}';
|
|
|
15
17
|
|
|
16
18
|
const userArgs = process.argv.slice(2);
|
|
17
19
|
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
if (userArgs.length === 0) {
|
|
23
|
-
args = ['--check', DEFAULT_GLOB];
|
|
24
|
-
} else if (userProvidedPath) {
|
|
25
|
-
args = userArgs;
|
|
26
|
-
} else {
|
|
27
|
-
args = [...userArgs, DEFAULT_GLOB];
|
|
28
|
-
}
|
|
20
|
+
const args = buildWrapperArgs(userArgs, {
|
|
21
|
+
defaults: ['--check', DEFAULT_GLOB],
|
|
22
|
+
target: DEFAULT_GLOB,
|
|
23
|
+
});
|
|
29
24
|
|
|
30
25
|
const result = spawn.sync(process.execPath, [prettierBin, ...args], { stdio: 'inherit' });
|
|
31
26
|
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Build the argv passed to an underlying CLI (eslint, prettier) for a
|
|
3
|
+
* `scripts <cmd>` wrapper, from the user-provided argv.
|
|
4
|
+
*
|
|
5
|
+
* - Empty input → `defaults` verbatim (the canonical no-args
|
|
6
|
+
* invocation, e.g. `['src', '--quiet']` for lint).
|
|
7
|
+
* - Non-empty input → user args (with the POSIX `--` end-of-options
|
|
8
|
+
* marker removed) followed by `target`.
|
|
9
|
+
*
|
|
10
|
+
* The previous heuristic tried to detect "user-provided path" by
|
|
11
|
+
* scanning for any argv entry not starting with `-`, then handed full
|
|
12
|
+
* control to the user. That broke two real consumer invocations:
|
|
13
|
+
*
|
|
14
|
+
* 1. `scripts lint --max-warnings 0` — the `0` value of the flag was
|
|
15
|
+
* misread as a path, so `src` was dropped and ESLint ran with no
|
|
16
|
+
* files.
|
|
17
|
+
* 2. `scripts lint -- --fix` — every arg started with `-`, so `src`
|
|
18
|
+
* was appended, but the surviving `--` separator forced ESLint to
|
|
19
|
+
* treat `--fix` and `src` as positional files.
|
|
20
|
+
*
|
|
21
|
+
* The wrapper is intentionally narrow: pass flags, get the default
|
|
22
|
+
* target. Consumers that need a non-default target should invoke the
|
|
23
|
+
* underlying CLI directly (`node_modules/.bin/eslint <path>`).
|
|
24
|
+
*
|
|
25
|
+
* @param userArgs - argv after `scripts <cmd>` (i.e. `process.argv.slice(2)`).
|
|
26
|
+
* @param options.defaults - argv to use when `userArgs` is empty.
|
|
27
|
+
* @param options.target - path/glob appended after user flags otherwise.
|
|
28
|
+
*/
|
|
29
|
+
export function buildWrapperArgs(userArgs: string[], options: { defaults: string[]; target: string }): string[] {
|
|
30
|
+
if (userArgs.length === 0) {
|
|
31
|
+
return [...options.defaults];
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const passthrough = userArgs.filter((a) => a !== '--');
|
|
35
|
+
|
|
36
|
+
return [...passthrough, options.target];
|
|
37
|
+
}
|
/package/{README.md → README.MD}
RENAMED
|
File without changes
|