@toiroakr/lines-db 0.10.0 → 0.10.1
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 +7 -0
- package/bin/cli.mjs +229 -121
- package/package.json +3 -11
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# @toiroakr/lines-db
|
|
2
2
|
|
|
3
|
+
## 0.10.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 4587fb2: Remove the `js-yaml: '>=4.2.0'` pnpm override. It forced `@manypkg/get-packages` (via `read-yaml-file@1.1.0`, a transitive dependency of `@changesets/cli`) onto js-yaml 4, whose `yaml.safeLoad` was removed, breaking `pnpm changeset version` and the release workflow. Both js-yaml security advisories the override addressed (quadratic-complexity DoS and prototype pollution in merge handling) are already patched in the 3.x line at 3.15.0, so removing the override lets pnpm resolve that dependency to a safe 3.x release without forcing an incompatible major on affected consumers.
|
|
8
|
+
- 5450665: Remove the optional `valibot` peerDependency. The library only relies on the `@standard-schema/spec` interface at runtime and in its public types, so no schema library needs to be declared as a peer dependency.
|
|
9
|
+
|
|
3
10
|
## 0.10.0
|
|
4
11
|
|
|
5
12
|
### Minor Changes
|
package/bin/cli.mjs
CHANGED
|
@@ -5018,7 +5018,7 @@ function superRefine(fn, params) {
|
|
|
5018
5018
|
return /* @__PURE__ */ _superRefine(fn, params);
|
|
5019
5019
|
}
|
|
5020
5020
|
//#endregion
|
|
5021
|
-
//#region ../node_modules/.pnpm/politty@0.
|
|
5021
|
+
//#region ../node_modules/.pnpm/politty@0.11.0_zod@4.4.3/node_modules/politty/dist/arg-registry-BeLLAW5-.js
|
|
5022
5022
|
/**
|
|
5023
5023
|
* Custom registry for politty argument metadata
|
|
5024
5024
|
* This avoids polluting Zod's GlobalMeta
|
|
@@ -5038,7 +5038,7 @@ function getArgMeta$1(schema) {
|
|
|
5038
5038
|
return argRegistry.get(schema);
|
|
5039
5039
|
}
|
|
5040
5040
|
//#endregion
|
|
5041
|
-
//#region ../node_modules/.pnpm/politty@0.
|
|
5041
|
+
//#region ../node_modules/.pnpm/politty@0.11.0_zod@4.4.3/node_modules/politty/dist/schema-extractor-DnOTAjV_.js
|
|
5042
5042
|
/**
|
|
5043
5043
|
* Marker property for LazyCommand identification
|
|
5044
5044
|
*/
|
|
@@ -5592,7 +5592,7 @@ function getExtractedFields(command) {
|
|
|
5592
5592
|
return extractFields(command.args);
|
|
5593
5593
|
}
|
|
5594
5594
|
//#endregion
|
|
5595
|
-
//#region ../node_modules/.pnpm/politty@0.
|
|
5595
|
+
//#region ../node_modules/.pnpm/politty@0.11.0_zod@4.4.3/node_modules/politty/dist/log-collector-DK32-73m.js
|
|
5596
5596
|
/**
|
|
5597
5597
|
* Mapping from log level to output stream
|
|
5598
5598
|
*/
|
|
@@ -5704,7 +5704,7 @@ function emptyLogs() {
|
|
|
5704
5704
|
return { entries: [] };
|
|
5705
5705
|
}
|
|
5706
5706
|
//#endregion
|
|
5707
|
-
//#region ../node_modules/.pnpm/politty@0.
|
|
5707
|
+
//#region ../node_modules/.pnpm/politty@0.11.0_zod@4.4.3/node_modules/politty/dist/logger-DbDkjdfO.js
|
|
5708
5708
|
/**
|
|
5709
5709
|
* Check if color output should be disabled
|
|
5710
5710
|
*/
|
|
@@ -5774,7 +5774,7 @@ const symbols = {
|
|
|
5774
5774
|
arrow: styles.gray("→")
|
|
5775
5775
|
};
|
|
5776
5776
|
//#endregion
|
|
5777
|
-
//#region ../node_modules/.pnpm/politty@0.
|
|
5777
|
+
//#region ../node_modules/.pnpm/politty@0.11.0_zod@4.4.3/node_modules/politty/dist/runner-Z7R_XvAV.js
|
|
5778
5778
|
/**
|
|
5779
5779
|
* Wrap an args object with a Proxy that allows dual-case access.
|
|
5780
5780
|
*
|
|
@@ -6840,7 +6840,7 @@ function checkDuplicateNegations(extracted, commandPath) {
|
|
|
6840
6840
|
if (camelVariant !== alias) claim(camelVariant, field.name, "alias");
|
|
6841
6841
|
}
|
|
6842
6842
|
}
|
|
6843
|
-
if (field.type === "boolean" && field.negation
|
|
6843
|
+
if (field.type === "boolean" && field.negation === true) {
|
|
6844
6844
|
const defaultKebab = `no-${field.cliName}`;
|
|
6845
6845
|
claim(defaultKebab, field.name, "default negation");
|
|
6846
6846
|
const camelBase = toCamelCase(field.cliName);
|
|
@@ -7040,6 +7040,75 @@ function validateCrossSchemaCollisions(extractedA, extractedB) {
|
|
|
7040
7040
|
if (existing && existing !== field.name) throw new CaseVariantCollisionError(`Global field "${existing}" and command field "${field.name}" are case variants of each other and would collide.`);
|
|
7041
7041
|
}
|
|
7042
7042
|
}
|
|
7043
|
+
function resolveLongOption(arg, lookup) {
|
|
7044
|
+
const withoutDashes = arg.includes("=") ? arg.slice(2, arg.indexOf("=")) : arg.slice(2);
|
|
7045
|
+
if (!arg.includes("=")) {
|
|
7046
|
+
const negatedField = lookup.negationMap.get(withoutDashes);
|
|
7047
|
+
if (negatedField && lookup.booleanFlags.has(negatedField)) return {
|
|
7048
|
+
resolvedName: negatedField,
|
|
7049
|
+
withoutDashes,
|
|
7050
|
+
isNegated: true,
|
|
7051
|
+
isCustomNegation: true,
|
|
7052
|
+
isSuppressedNegation: false
|
|
7053
|
+
};
|
|
7054
|
+
}
|
|
7055
|
+
const hasEquals = arg.includes("=");
|
|
7056
|
+
if (!hasEquals && withoutDashes.startsWith("no-")) {
|
|
7057
|
+
const flagName = withoutDashes.slice(3);
|
|
7058
|
+
if (flagName === flagName.toLowerCase()) {
|
|
7059
|
+
const resolvedName = lookup.aliasMap.get(flagName) ?? flagName;
|
|
7060
|
+
if (lookup.booleanFlags.has(resolvedName)) {
|
|
7061
|
+
const asIsResolved = lookup.aliasMap.get(withoutDashes) ?? withoutDashes;
|
|
7062
|
+
if (!lookup.definedNames.has(asIsResolved)) {
|
|
7063
|
+
if (lookup.defaultNegationDisabledFields.has(resolvedName)) return {
|
|
7064
|
+
resolvedName,
|
|
7065
|
+
withoutDashes,
|
|
7066
|
+
isNegated: false,
|
|
7067
|
+
isCustomNegation: false,
|
|
7068
|
+
isSuppressedNegation: true
|
|
7069
|
+
};
|
|
7070
|
+
return {
|
|
7071
|
+
resolvedName,
|
|
7072
|
+
withoutDashes,
|
|
7073
|
+
isNegated: true,
|
|
7074
|
+
isCustomNegation: false,
|
|
7075
|
+
isSuppressedNegation: false
|
|
7076
|
+
};
|
|
7077
|
+
}
|
|
7078
|
+
}
|
|
7079
|
+
}
|
|
7080
|
+
}
|
|
7081
|
+
if (!hasEquals && withoutDashes.length > 2 && withoutDashes.startsWith("no") && /[A-Z]/.test(withoutDashes[2])) {
|
|
7082
|
+
const camelFlagName = withoutDashes[2].toLowerCase() + withoutDashes.slice(3);
|
|
7083
|
+
const resolvedName = lookup.aliasMap.get(camelFlagName) ?? camelFlagName;
|
|
7084
|
+
if (lookup.booleanFlags.has(resolvedName)) {
|
|
7085
|
+
const asIsResolved = lookup.aliasMap.get(withoutDashes) ?? withoutDashes;
|
|
7086
|
+
if (!lookup.definedNames.has(asIsResolved)) {
|
|
7087
|
+
if (lookup.defaultNegationDisabledFields.has(resolvedName)) return {
|
|
7088
|
+
resolvedName,
|
|
7089
|
+
withoutDashes,
|
|
7090
|
+
isNegated: false,
|
|
7091
|
+
isCustomNegation: false,
|
|
7092
|
+
isSuppressedNegation: true
|
|
7093
|
+
};
|
|
7094
|
+
return {
|
|
7095
|
+
resolvedName,
|
|
7096
|
+
withoutDashes,
|
|
7097
|
+
isNegated: true,
|
|
7098
|
+
isCustomNegation: false,
|
|
7099
|
+
isSuppressedNegation: false
|
|
7100
|
+
};
|
|
7101
|
+
}
|
|
7102
|
+
}
|
|
7103
|
+
}
|
|
7104
|
+
return {
|
|
7105
|
+
resolvedName: lookup.aliasMap.get(withoutDashes) ?? withoutDashes,
|
|
7106
|
+
withoutDashes,
|
|
7107
|
+
isNegated: false,
|
|
7108
|
+
isCustomNegation: false,
|
|
7109
|
+
isSuppressedNegation: false
|
|
7110
|
+
};
|
|
7111
|
+
}
|
|
7043
7112
|
/**
|
|
7044
7113
|
* Parse argv into a flat record
|
|
7045
7114
|
*
|
|
@@ -7049,7 +7118,7 @@ function validateCrossSchemaCollisions(extractedA, extractedB) {
|
|
|
7049
7118
|
* - Combined short options: -abc (treated as -a -b -c if all are boolean)
|
|
7050
7119
|
* - Positional arguments
|
|
7051
7120
|
* - -- to stop parsing options
|
|
7052
|
-
* - Boolean negation: --no-flag, --noFlag (requires `booleanFlags`)
|
|
7121
|
+
* - Boolean negation: --no-flag, --noFlag (requires `booleanFlags` and `negation: true`)
|
|
7053
7122
|
*
|
|
7054
7123
|
* **Note:** When using negation detection (`--noFlag` / `--no-flag`),
|
|
7055
7124
|
* supply `definedNames` so that options whose names happen to start with
|
|
@@ -7062,7 +7131,14 @@ function validateCrossSchemaCollisions(extractedA, extractedB) {
|
|
|
7062
7131
|
* @returns Parsed arguments
|
|
7063
7132
|
*/
|
|
7064
7133
|
function parseArgv(argv, options = {}) {
|
|
7065
|
-
const { aliasMap = /* @__PURE__ */ new Map(), booleanFlags = /* @__PURE__ */ new Set(), arrayFlags = /* @__PURE__ */ new Set(), definedNames = /* @__PURE__ */ new Set(), negationMap = /* @__PURE__ */ new Map(),
|
|
7134
|
+
const { aliasMap = /* @__PURE__ */ new Map(), booleanFlags = /* @__PURE__ */ new Set(), arrayFlags = /* @__PURE__ */ new Set(), definedNames = /* @__PURE__ */ new Set(), negationMap = /* @__PURE__ */ new Map(), defaultNegationDisabledFields: configuredDefaultNegationDisabledFields } = options;
|
|
7135
|
+
const longOptionLookup = {
|
|
7136
|
+
aliasMap,
|
|
7137
|
+
booleanFlags,
|
|
7138
|
+
definedNames,
|
|
7139
|
+
negationMap,
|
|
7140
|
+
defaultNegationDisabledFields: configuredDefaultNegationDisabledFields ?? new Set(booleanFlags)
|
|
7141
|
+
};
|
|
7066
7142
|
const result = {
|
|
7067
7143
|
options: {},
|
|
7068
7144
|
positionals: [],
|
|
@@ -7093,39 +7169,16 @@ function parseArgv(argv, options = {}) {
|
|
|
7093
7169
|
}
|
|
7094
7170
|
if (arg.startsWith("--")) {
|
|
7095
7171
|
const withoutDashes = arg.slice(2);
|
|
7096
|
-
|
|
7097
|
-
|
|
7098
|
-
|
|
7099
|
-
|
|
7100
|
-
|
|
7101
|
-
continue;
|
|
7102
|
-
}
|
|
7103
|
-
}
|
|
7104
|
-
if (withoutDashes.startsWith("no-")) {
|
|
7105
|
-
const flagName = withoutDashes.slice(3);
|
|
7106
|
-
if (flagName === flagName.toLowerCase()) {
|
|
7107
|
-
const resolvedName = aliasMap.get(flagName) ?? flagName;
|
|
7108
|
-
if (booleanFlags.has(resolvedName) && !customNegatedFields.has(resolvedName)) {
|
|
7109
|
-
const asIsResolved = aliasMap.get(withoutDashes) ?? withoutDashes;
|
|
7110
|
-
if (!definedNames.has(asIsResolved)) {
|
|
7111
|
-
setOption(flagName, false);
|
|
7112
|
-
i++;
|
|
7113
|
-
continue;
|
|
7114
|
-
}
|
|
7115
|
-
}
|
|
7116
|
-
}
|
|
7172
|
+
const resolution = resolveLongOption(arg, longOptionLookup);
|
|
7173
|
+
if (resolution.isSuppressedNegation) {
|
|
7174
|
+
setOption(resolution.withoutDashes, true);
|
|
7175
|
+
i++;
|
|
7176
|
+
continue;
|
|
7117
7177
|
}
|
|
7118
|
-
if (
|
|
7119
|
-
|
|
7120
|
-
|
|
7121
|
-
|
|
7122
|
-
const asIsResolved = aliasMap.get(withoutDashes) ?? withoutDashes;
|
|
7123
|
-
if (!definedNames.has(asIsResolved)) {
|
|
7124
|
-
setOption(camelFlagName, false);
|
|
7125
|
-
i++;
|
|
7126
|
-
continue;
|
|
7127
|
-
}
|
|
7128
|
-
}
|
|
7178
|
+
if (resolution.isNegated) {
|
|
7179
|
+
setOption(resolution.resolvedName, false);
|
|
7180
|
+
i++;
|
|
7181
|
+
continue;
|
|
7129
7182
|
}
|
|
7130
7183
|
const eqIndex = withoutDashes.indexOf("=");
|
|
7131
7184
|
if (eqIndex !== -1) {
|
|
@@ -7192,7 +7245,7 @@ function buildParserOptions(extracted) {
|
|
|
7192
7245
|
const arrayFlags = /* @__PURE__ */ new Set();
|
|
7193
7246
|
const definedNames = /* @__PURE__ */ new Set();
|
|
7194
7247
|
const negationMap = /* @__PURE__ */ new Map();
|
|
7195
|
-
const
|
|
7248
|
+
const defaultNegationDisabledFields = /* @__PURE__ */ new Set();
|
|
7196
7249
|
for (const field of extracted.fields) definedNames.add(field.name);
|
|
7197
7250
|
for (const field of extracted.fields) {
|
|
7198
7251
|
if (field.cliName !== field.name) aliasMap.set(field.cliName, field.name);
|
|
@@ -7207,8 +7260,8 @@ function buildParserOptions(extracted) {
|
|
|
7207
7260
|
if (camelVariant !== field.name && !definedNames.has(camelVariant) && !aliasMap.has(camelVariant)) aliasMap.set(camelVariant, field.name);
|
|
7208
7261
|
if (field.type === "boolean") booleanFlags.add(field.name);
|
|
7209
7262
|
if (field.type === "array") arrayFlags.add(field.name);
|
|
7210
|
-
if (field.type === "boolean" &&
|
|
7211
|
-
|
|
7263
|
+
if (field.type === "boolean" && field.negation !== true) {
|
|
7264
|
+
defaultNegationDisabledFields.add(field.name);
|
|
7212
7265
|
if (typeof field.negation === "string") {
|
|
7213
7266
|
negationMap.set(field.negation, field.name);
|
|
7214
7267
|
if (field.negation.includes("-")) {
|
|
@@ -7224,7 +7277,7 @@ function buildParserOptions(extracted) {
|
|
|
7224
7277
|
arrayFlags,
|
|
7225
7278
|
definedNames,
|
|
7226
7279
|
negationMap,
|
|
7227
|
-
|
|
7280
|
+
defaultNegationDisabledFields
|
|
7228
7281
|
};
|
|
7229
7282
|
}
|
|
7230
7283
|
/**
|
|
@@ -7252,17 +7305,18 @@ function mergeWithPositionals(parsed, extracted) {
|
|
|
7252
7305
|
* Shared by scanForSubcommand, separateGlobalArgs, and findFirstPositional.
|
|
7253
7306
|
*/
|
|
7254
7307
|
function buildGlobalFlagLookup(globalExtracted) {
|
|
7255
|
-
const { aliasMap = /* @__PURE__ */ new Map(), booleanFlags = /* @__PURE__ */ new Set(), negationMap = /* @__PURE__ */ new Map(),
|
|
7308
|
+
const { aliasMap = /* @__PURE__ */ new Map(), booleanFlags = /* @__PURE__ */ new Set(), definedNames = /* @__PURE__ */ new Set(), negationMap = /* @__PURE__ */ new Map(), defaultNegationDisabledFields = /* @__PURE__ */ new Set() } = buildParserOptions(globalExtracted);
|
|
7256
7309
|
const shortAliases = /* @__PURE__ */ new Set();
|
|
7257
7310
|
for (const field of globalExtracted.fields) for (const alias of getAllAliases(field)) if (alias.length === 1) shortAliases.add(alias);
|
|
7258
7311
|
return {
|
|
7259
7312
|
aliasMap,
|
|
7260
7313
|
booleanFlags,
|
|
7314
|
+
definedNames,
|
|
7261
7315
|
flagNames: new Set(globalExtracted.fields.map((f) => f.name)),
|
|
7262
7316
|
cliNames: new Set(globalExtracted.fields.map((f) => f.cliName)),
|
|
7263
7317
|
aliases: shortAliases,
|
|
7264
7318
|
negationMap,
|
|
7265
|
-
|
|
7319
|
+
defaultNegationDisabledFields
|
|
7266
7320
|
};
|
|
7267
7321
|
}
|
|
7268
7322
|
/**
|
|
@@ -7270,43 +7324,27 @@ function buildGlobalFlagLookup(globalExtracted) {
|
|
|
7270
7324
|
* against global flag lookup. Returns the resolved camelCase name and whether
|
|
7271
7325
|
* it is a known global flag.
|
|
7272
7326
|
*
|
|
7273
|
-
* `isSuppressedNegation` is true when the token matches a default
|
|
7274
|
-
* form
|
|
7327
|
+
* `isSuppressedNegation` is true when the token matches a disabled default
|
|
7328
|
+
* `--no-X` form on the target field.
|
|
7275
7329
|
* The caller may use this to keep argv scanning past such tokens (so a
|
|
7276
7330
|
* trailing subcommand is still detected) even though they no longer negate.
|
|
7277
7331
|
*/
|
|
7278
7332
|
function resolveGlobalLongOption(arg, lookup) {
|
|
7279
|
-
const
|
|
7280
|
-
|
|
7281
|
-
|
|
7282
|
-
resolvedName: customNegated,
|
|
7333
|
+
const { resolvedName, withoutDashes, isNegated, isCustomNegation, isSuppressedNegation } = resolveLongOption(arg, lookup);
|
|
7334
|
+
if (isSuppressedNegation) return {
|
|
7335
|
+
resolvedName,
|
|
7283
7336
|
withoutDashes,
|
|
7284
|
-
isNegated:
|
|
7285
|
-
isGlobal:
|
|
7286
|
-
isSuppressedNegation
|
|
7337
|
+
isNegated: false,
|
|
7338
|
+
isGlobal: false,
|
|
7339
|
+
isSuppressedNegation
|
|
7287
7340
|
};
|
|
7288
|
-
const
|
|
7289
|
-
const camelNegated = !kebabNegated && withoutDashes.length > 2 && withoutDashes.startsWith("no") && /[A-Z]/.test(withoutDashes[2]);
|
|
7290
|
-
if (kebabNegated || camelNegated) {
|
|
7291
|
-
const literalResolved = lookup.aliasMap.get(withoutDashes) ?? withoutDashes;
|
|
7292
|
-
if (lookup.flagNames.has(literalResolved) || lookup.cliNames.has(withoutDashes)) return {
|
|
7293
|
-
resolvedName: literalResolved,
|
|
7294
|
-
withoutDashes,
|
|
7295
|
-
isNegated: false,
|
|
7296
|
-
isGlobal: true,
|
|
7297
|
-
isSuppressedNegation: false
|
|
7298
|
-
};
|
|
7299
|
-
}
|
|
7300
|
-
const defaultIsNegated = kebabNegated || camelNegated;
|
|
7301
|
-
const flagName = kebabNegated ? withoutDashes.slice(3) : camelNegated ? withoutDashes[2].toLowerCase() + withoutDashes.slice(3) : withoutDashes;
|
|
7302
|
-
const resolvedName = lookup.aliasMap.get(flagName) ?? flagName;
|
|
7303
|
-
const suppressDefaultNegation = defaultIsNegated && lookup.customNegatedFields.has(resolvedName);
|
|
7341
|
+
const flagName = isNegated && !isCustomNegation ? withoutDashes.startsWith("no-") ? withoutDashes.slice(3) : withoutDashes[2].toLowerCase() + withoutDashes.slice(3) : withoutDashes;
|
|
7304
7342
|
return {
|
|
7305
7343
|
resolvedName,
|
|
7306
7344
|
withoutDashes,
|
|
7307
|
-
isNegated
|
|
7308
|
-
isGlobal:
|
|
7309
|
-
isSuppressedNegation:
|
|
7345
|
+
isNegated,
|
|
7346
|
+
isGlobal: lookup.flagNames.has(resolvedName) || lookup.cliNames.has(withoutDashes) || lookup.cliNames.has(flagName),
|
|
7347
|
+
isSuppressedNegation: false
|
|
7310
7348
|
};
|
|
7311
7349
|
}
|
|
7312
7350
|
/**
|
|
@@ -7418,15 +7456,17 @@ const BUILTIN_FLAGS = /* @__PURE__ */ new Set([
|
|
|
7418
7456
|
* Without globalExtracted, no flag is global, so any leading flag halts the
|
|
7419
7457
|
* scan and a positional is only found when it precedes every flag.
|
|
7420
7458
|
*/
|
|
7421
|
-
function findFirstPositionalIndex(argv, globalExtracted) {
|
|
7459
|
+
function findFirstPositionalIndex(argv, globalExtracted, options = {}) {
|
|
7460
|
+
const stopOnSuppressedNegation = options.stopOnSuppressedNegation === true || globalExtracted?.unknownKeysMode === "strict";
|
|
7422
7461
|
const lookup = globalExtracted ? buildGlobalFlagLookup(globalExtracted) : {
|
|
7423
7462
|
aliasMap: /* @__PURE__ */ new Map(),
|
|
7424
7463
|
booleanFlags: /* @__PURE__ */ new Set(),
|
|
7464
|
+
definedNames: /* @__PURE__ */ new Set(),
|
|
7425
7465
|
flagNames: /* @__PURE__ */ new Set(),
|
|
7426
7466
|
cliNames: /* @__PURE__ */ new Set(),
|
|
7427
7467
|
aliases: /* @__PURE__ */ new Set(),
|
|
7428
7468
|
negationMap: /* @__PURE__ */ new Map(),
|
|
7429
|
-
|
|
7469
|
+
defaultNegationDisabledFields: /* @__PURE__ */ new Set()
|
|
7430
7470
|
};
|
|
7431
7471
|
for (let i = 0; i < argv.length; i++) {
|
|
7432
7472
|
const arg = argv[i];
|
|
@@ -7438,7 +7478,10 @@ function findFirstPositionalIndex(argv, globalExtracted) {
|
|
|
7438
7478
|
if (shouldConsumeValue(arg, resolvedName, isNegated, argv[i + 1], lookup.booleanFlags)) i++;
|
|
7439
7479
|
continue;
|
|
7440
7480
|
}
|
|
7441
|
-
if (isSuppressedNegation)
|
|
7481
|
+
if (isSuppressedNegation) {
|
|
7482
|
+
if (stopOnSuppressedNegation) return -1;
|
|
7483
|
+
continue;
|
|
7484
|
+
}
|
|
7442
7485
|
return -1;
|
|
7443
7486
|
}
|
|
7444
7487
|
const withoutDash = arg.includes("=") ? arg.slice(1, arg.indexOf("=")) : arg.slice(1);
|
|
@@ -7486,7 +7529,9 @@ function parseArgs(argv, command, options = {}) {
|
|
|
7486
7529
|
remainingArgs: scanResult.tokensAfterSubcommand,
|
|
7487
7530
|
rawArgs: {},
|
|
7488
7531
|
positionals: [],
|
|
7532
|
+
rest: [],
|
|
7489
7533
|
unknownFlags: scanResult.suppressedTokens,
|
|
7534
|
+
unknownGlobalFlags: scanResult.suppressedTokens,
|
|
7490
7535
|
rawGlobalArgs
|
|
7491
7536
|
};
|
|
7492
7537
|
}
|
|
@@ -7500,6 +7545,7 @@ function parseArgs(argv, command, options = {}) {
|
|
|
7500
7545
|
remainingArgs: argv.slice(1),
|
|
7501
7546
|
rawArgs: {},
|
|
7502
7547
|
positionals: [],
|
|
7548
|
+
rest: [],
|
|
7503
7549
|
unknownFlags: []
|
|
7504
7550
|
};
|
|
7505
7551
|
}
|
|
@@ -7516,6 +7562,15 @@ function parseArgs(argv, command, options = {}) {
|
|
|
7516
7562
|
if (options.globalExtracted) validateCrossSchemaCollisions(options.globalExtracted, extracted);
|
|
7517
7563
|
}
|
|
7518
7564
|
}
|
|
7565
|
+
let commandArgv = argv;
|
|
7566
|
+
let rawGlobalArgs;
|
|
7567
|
+
let suppressedGlobalFlags = [];
|
|
7568
|
+
if (options.globalExtracted) {
|
|
7569
|
+
const { separated, globalParsed, suppressedTokens } = separateGlobalArgs(argv, options.globalExtracted, extracted);
|
|
7570
|
+
commandArgv = separated;
|
|
7571
|
+
rawGlobalArgs = globalParsed;
|
|
7572
|
+
suppressedGlobalFlags = suppressedTokens;
|
|
7573
|
+
}
|
|
7519
7574
|
const ddIdx = argv.indexOf("--");
|
|
7520
7575
|
const flagScanArgv = ddIdx >= 0 ? argv.slice(0, ddIdx) : argv;
|
|
7521
7576
|
const hasUserDefinedH = extracted?.fields.some((f) => f.overrideBuiltinAlias === true && getAllAliases(f).includes("H")) ?? false;
|
|
@@ -7531,26 +7586,27 @@ function parseArgs(argv, command, options = {}) {
|
|
|
7531
7586
|
remainingArgs: [],
|
|
7532
7587
|
rawArgs: {},
|
|
7533
7588
|
positionals: [],
|
|
7534
|
-
|
|
7535
|
-
};
|
|
7536
|
-
let commandArgv = argv;
|
|
7537
|
-
let rawGlobalArgs;
|
|
7538
|
-
if (options.globalExtracted) {
|
|
7539
|
-
const { separated, globalParsed } = separateGlobalArgs(argv, options.globalExtracted, extracted);
|
|
7540
|
-
commandArgv = separated;
|
|
7541
|
-
rawGlobalArgs = globalParsed;
|
|
7542
|
-
}
|
|
7543
|
-
if (!extracted) return {
|
|
7544
|
-
helpRequested: false,
|
|
7545
|
-
helpAllRequested: false,
|
|
7546
|
-
versionRequested: false,
|
|
7547
|
-
subCommand: void 0,
|
|
7548
|
-
remainingArgs: [],
|
|
7549
|
-
rawArgs: {},
|
|
7550
|
-
positionals: [],
|
|
7589
|
+
rest: [],
|
|
7551
7590
|
unknownFlags: [],
|
|
7591
|
+
unknownGlobalFlags: suppressedGlobalFlags,
|
|
7552
7592
|
rawGlobalArgs
|
|
7553
7593
|
};
|
|
7594
|
+
if (!extracted) {
|
|
7595
|
+
const ddIdx = commandArgv.indexOf("--");
|
|
7596
|
+
return {
|
|
7597
|
+
helpRequested: false,
|
|
7598
|
+
helpAllRequested: false,
|
|
7599
|
+
versionRequested: false,
|
|
7600
|
+
subCommand: void 0,
|
|
7601
|
+
remainingArgs: [],
|
|
7602
|
+
rawArgs: {},
|
|
7603
|
+
positionals: ddIdx >= 0 ? commandArgv.slice(0, ddIdx) : commandArgv,
|
|
7604
|
+
rest: ddIdx >= 0 ? commandArgv.slice(ddIdx + 1) : [],
|
|
7605
|
+
unknownFlags: [],
|
|
7606
|
+
unknownGlobalFlags: suppressedGlobalFlags,
|
|
7607
|
+
rawGlobalArgs
|
|
7608
|
+
};
|
|
7609
|
+
}
|
|
7554
7610
|
const parserOptions = buildParserOptions(extracted);
|
|
7555
7611
|
const parsed = parseArgv(commandArgv, parserOptions);
|
|
7556
7612
|
const rawArgs = mergeWithPositionals(parsed, extracted);
|
|
@@ -7583,7 +7639,9 @@ function parseArgs(argv, command, options = {}) {
|
|
|
7583
7639
|
remainingArgs: [],
|
|
7584
7640
|
rawArgs,
|
|
7585
7641
|
positionals: parsed.positionals,
|
|
7642
|
+
rest: parsed.rest,
|
|
7586
7643
|
unknownFlags,
|
|
7644
|
+
unknownGlobalFlags: suppressedGlobalFlags,
|
|
7587
7645
|
extractedFields: extracted,
|
|
7588
7646
|
rawGlobalArgs
|
|
7589
7647
|
};
|
|
@@ -7611,9 +7669,21 @@ function separateGlobalArgs(argv, globalExtracted, localExtracted) {
|
|
|
7611
7669
|
const lookup = buildGlobalFlagLookup(globalExtracted);
|
|
7612
7670
|
const localFieldNames = new Set(localExtracted?.fields.map((f) => f.name) ?? []);
|
|
7613
7671
|
const localCliNames = new Set(localExtracted?.fields.map((f) => f.cliName) ?? []);
|
|
7614
|
-
const
|
|
7672
|
+
const localParserOptions = localExtracted ? buildParserOptions(localExtracted) : void 0;
|
|
7673
|
+
const localAliasMapKeys = new Set(localParserOptions?.aliasMap?.keys() ?? []);
|
|
7674
|
+
const localNegationMapKeys = new Set(localParserOptions?.negationMap?.keys() ?? []);
|
|
7675
|
+
const localDefaultNegationKeys = /* @__PURE__ */ new Set();
|
|
7676
|
+
for (const field of localExtracted?.fields ?? []) {
|
|
7677
|
+
if (field.type !== "boolean" || field.negation !== true) continue;
|
|
7678
|
+
for (const name of [field.cliName, ...getAllAliases(field)]) {
|
|
7679
|
+
const kebab = `no-${name}`;
|
|
7680
|
+
localDefaultNegationKeys.add(kebab);
|
|
7681
|
+
localDefaultNegationKeys.add(toCamelCase(kebab));
|
|
7682
|
+
}
|
|
7683
|
+
}
|
|
7615
7684
|
const globalTokens = [];
|
|
7616
7685
|
const commandTokens = [];
|
|
7686
|
+
const suppressedTokens = [];
|
|
7617
7687
|
for (let i = 0; i < argv.length; i++) {
|
|
7618
7688
|
const arg = argv[i];
|
|
7619
7689
|
if (arg === "--") {
|
|
@@ -7621,13 +7691,17 @@ function separateGlobalArgs(argv, globalExtracted, localExtracted) {
|
|
|
7621
7691
|
break;
|
|
7622
7692
|
}
|
|
7623
7693
|
if (arg.startsWith("--")) {
|
|
7624
|
-
const { resolvedName, withoutDashes, isNegated, isGlobal } = resolveGlobalLongOption(arg, lookup);
|
|
7694
|
+
const { resolvedName, withoutDashes, isNegated, isGlobal, isSuppressedNegation } = resolveGlobalLongOption(arg, lookup);
|
|
7625
7695
|
const flagName = resolvedName;
|
|
7626
|
-
const isLocalCollision = localFieldNames.has(withoutDashes) || localFieldNames.has(flagName) || localCliNames.has(withoutDashes) || localCliNames.has(flagName) || localAliasMapKeys.has(withoutDashes) || localAliasMapKeys.has(flagName);
|
|
7696
|
+
const isLocalCollision = localFieldNames.has(withoutDashes) || localFieldNames.has(flagName) || localCliNames.has(withoutDashes) || localCliNames.has(flagName) || localAliasMapKeys.has(withoutDashes) || localAliasMapKeys.has(flagName) || localNegationMapKeys.has(withoutDashes) || localNegationMapKeys.has(flagName) || localDefaultNegationKeys.has(withoutDashes);
|
|
7627
7697
|
if (isGlobal && !isLocalCollision) {
|
|
7628
7698
|
i += collectGlobalFlag(argv, i, resolvedName, isNegated, lookup.booleanFlags, globalTokens) - 1;
|
|
7629
7699
|
continue;
|
|
7630
7700
|
}
|
|
7701
|
+
if (isSuppressedNegation && !isLocalCollision) {
|
|
7702
|
+
suppressedTokens.push(arg.includes("=") ? arg.slice(2, arg.indexOf("=")) : arg.slice(2));
|
|
7703
|
+
continue;
|
|
7704
|
+
}
|
|
7631
7705
|
} else if (arg.startsWith("-") && arg.length > 1) {
|
|
7632
7706
|
const withoutDash = arg.includes("=") ? arg.slice(1, arg.indexOf("=")) : arg.slice(1);
|
|
7633
7707
|
if (withoutDash.length === 1) {
|
|
@@ -7642,7 +7716,8 @@ function separateGlobalArgs(argv, globalExtracted, localExtracted) {
|
|
|
7642
7716
|
}
|
|
7643
7717
|
return {
|
|
7644
7718
|
separated: commandTokens,
|
|
7645
|
-
globalParsed: parseGlobalArgs(globalTokens, globalExtracted)
|
|
7719
|
+
globalParsed: parseGlobalArgs(globalTokens, globalExtracted),
|
|
7720
|
+
suppressedTokens
|
|
7646
7721
|
};
|
|
7647
7722
|
}
|
|
7648
7723
|
/**
|
|
@@ -7756,7 +7831,8 @@ async function runEffects(validatedArgs, extracted, globalArgs) {
|
|
|
7756
7831
|
*/
|
|
7757
7832
|
const defaultLogger = {
|
|
7758
7833
|
log: (message) => console.log(message),
|
|
7759
|
-
error: (message) => console.error(message)
|
|
7834
|
+
error: (message) => console.error(message),
|
|
7835
|
+
warn: (message) => console.warn(message)
|
|
7760
7836
|
};
|
|
7761
7837
|
/**
|
|
7762
7838
|
* Hidden internal subcommands (e.g. `__refresh-completion`) are spawned
|
|
@@ -7820,10 +7896,10 @@ async function runMain(command, options = {}) {
|
|
|
7820
7896
|
effectiveOptions = rest;
|
|
7821
7897
|
}
|
|
7822
7898
|
const globalExtracted = extractAndValidateGlobal(effectiveOptions);
|
|
7823
|
-
if (effectiveOptions.onUnknownSubcommand && !isInternalSubcommandInvocation(command, argv, globalExtractedForBypass)) {
|
|
7899
|
+
if (effectiveOptions.onUnknownSubcommand && !command.run && !isInternalSubcommandInvocation(command, argv, globalExtractedForBypass)) {
|
|
7824
7900
|
const knownSubCommands = listSubCommandNamesWithAliases(command);
|
|
7825
7901
|
if (knownSubCommands.size > 0) {
|
|
7826
|
-
const positionalIndex = findFirstPositionalIndex(argv, globalExtracted);
|
|
7902
|
+
const positionalIndex = findFirstPositionalIndex(argv, globalExtracted, { stopOnSuppressedNegation: globalExtracted?.unknownKeysMode !== "passthrough" });
|
|
7827
7903
|
const name = positionalIndex >= 0 ? argv[positionalIndex] : void 0;
|
|
7828
7904
|
if (name && !knownSubCommands.has(name)) {
|
|
7829
7905
|
const forwardArgs = argv.slice(positionalIndex + 1);
|
|
@@ -7913,10 +7989,10 @@ async function runCommandInternal(command, argv, options = {}) {
|
|
|
7913
7989
|
...parseResult.rawGlobalArgs
|
|
7914
7990
|
};
|
|
7915
7991
|
const nestedCommandPath = context.commandPath ?? [];
|
|
7916
|
-
if (options.onUnknownSubcommand && nestedCommandPath.length > 0) {
|
|
7992
|
+
if (options.onUnknownSubcommand && !command.run && nestedCommandPath.length > 0) {
|
|
7917
7993
|
const knownSubCommands = listSubCommandNamesWithAliases(command);
|
|
7918
7994
|
if (knownSubCommands.size > 0) {
|
|
7919
|
-
const positionalIndex = findFirstPositionalIndex(argv, options._globalExtracted);
|
|
7995
|
+
const positionalIndex = findFirstPositionalIndex(argv, options._globalExtracted, { stopOnSuppressedNegation: options._globalExtracted?.unknownKeysMode !== "passthrough" });
|
|
7920
7996
|
const name = positionalIndex >= 0 ? argv[positionalIndex] : void 0;
|
|
7921
7997
|
if (name && !knownSubCommands.has(name)) {
|
|
7922
7998
|
const forwardArgs = argv.slice(positionalIndex + 1);
|
|
@@ -7982,6 +8058,22 @@ async function runCommandInternal(command, argv, options = {}) {
|
|
|
7982
8058
|
logs: getCurrentLogs()
|
|
7983
8059
|
};
|
|
7984
8060
|
}
|
|
8061
|
+
if (parseResult.unknownGlobalFlags && parseResult.unknownGlobalFlags.length > 0) {
|
|
8062
|
+
const globalMode = context.globalExtracted?.unknownKeysMode ?? "strip";
|
|
8063
|
+
if (globalMode === "strict") {
|
|
8064
|
+
collector?.stop();
|
|
8065
|
+
return {
|
|
8066
|
+
success: false,
|
|
8067
|
+
error: /* @__PURE__ */ new Error(`Unknown flags: ${parseResult.unknownGlobalFlags.join(", ")}`),
|
|
8068
|
+
exitCode: 1,
|
|
8069
|
+
logs: getCurrentLogs()
|
|
8070
|
+
};
|
|
8071
|
+
}
|
|
8072
|
+
if (globalMode === "strip") {
|
|
8073
|
+
const knownGlobalFlags = context.globalExtracted?.fields.map((f) => f.name) ?? [];
|
|
8074
|
+
for (const flag of parseResult.unknownGlobalFlags) logger.error(formatUnknownFlagWarning(flag, knownGlobalFlags));
|
|
8075
|
+
}
|
|
8076
|
+
}
|
|
7985
8077
|
if (parseResult.versionRequested) {
|
|
7986
8078
|
const version = context.rootVersion;
|
|
7987
8079
|
if (version) logger.log(version);
|
|
@@ -7994,22 +8086,6 @@ async function runCommandInternal(command, argv, options = {}) {
|
|
|
7994
8086
|
};
|
|
7995
8087
|
}
|
|
7996
8088
|
if (parseResult.subCommand) {
|
|
7997
|
-
if (parseResult.unknownFlags.length > 0) {
|
|
7998
|
-
const globalMode = context.globalExtracted?.unknownKeysMode ?? "strip";
|
|
7999
|
-
if (globalMode === "strict") {
|
|
8000
|
-
collector?.stop();
|
|
8001
|
-
return {
|
|
8002
|
-
success: false,
|
|
8003
|
-
error: /* @__PURE__ */ new Error(`Unknown flags: ${parseResult.unknownFlags.join(", ")}`),
|
|
8004
|
-
exitCode: 1,
|
|
8005
|
-
logs: getCurrentLogs()
|
|
8006
|
-
};
|
|
8007
|
-
}
|
|
8008
|
-
if (globalMode === "strip") {
|
|
8009
|
-
const knownGlobalFlags = context.globalExtracted?.fields.map((f) => f.name) ?? [];
|
|
8010
|
-
for (const flag of parseResult.unknownFlags) logger.error(formatUnknownFlagWarning(flag, knownGlobalFlags));
|
|
8011
|
-
}
|
|
8012
|
-
}
|
|
8013
8089
|
const resolved = await resolveSubcommandWithAlias(command, parseResult.subCommand);
|
|
8014
8090
|
if (resolved) {
|
|
8015
8091
|
const subContext = {
|
|
@@ -8028,7 +8104,12 @@ async function runCommandInternal(command, argv, options = {}) {
|
|
|
8028
8104
|
});
|
|
8029
8105
|
}
|
|
8030
8106
|
}
|
|
8031
|
-
|
|
8107
|
+
const positionalFields = parseResult.extractedFields?.fields.filter((f) => f.positional) ?? [];
|
|
8108
|
+
const hasArrayPositional = positionalFields.some((f) => f.type === "array");
|
|
8109
|
+
const allPositionals = [...parseResult.positionals, ...parseResult.rest];
|
|
8110
|
+
const extraPositionals = hasArrayPositional ? [] : allPositionals.slice(positionalFields.length);
|
|
8111
|
+
const unconsumedRegulars = hasArrayPositional ? [] : parseResult.positionals.slice(positionalFields.length);
|
|
8112
|
+
if (listSubCommands(command).length > 0 && !parseResult.subCommand && !command.run && extraPositionals.length === 0) {
|
|
8032
8113
|
const help = generateHelp(command, {
|
|
8033
8114
|
showSubcommands: options.showSubcommands ?? true,
|
|
8034
8115
|
context
|
|
@@ -8055,6 +8136,33 @@ async function runCommandInternal(command, argv, options = {}) {
|
|
|
8055
8136
|
};
|
|
8056
8137
|
} else if (unknownKeysMode === "strip") for (const flag of parseResult.unknownFlags) logger.error(formatUnknownFlagWarning(flag, knownFlags));
|
|
8057
8138
|
}
|
|
8139
|
+
if (extraPositionals.length > 0) {
|
|
8140
|
+
const subCmdNames = listSubCommandNamesWithAliases(command);
|
|
8141
|
+
if (subCmdNames.size > 0) {
|
|
8142
|
+
const unknownCmd = unconsumedRegulars.find((t) => !t.startsWith("-") && !subCmdNames.has(t));
|
|
8143
|
+
if (unknownCmd) {
|
|
8144
|
+
const similar = findSimilar(unknownCmd, [...subCmdNames]);
|
|
8145
|
+
const suggestion = similar.length > 0 ? ` Did you mean: ${similar.join(", ")}?` : "";
|
|
8146
|
+
collector?.stop();
|
|
8147
|
+
return {
|
|
8148
|
+
success: false,
|
|
8149
|
+
error: /* @__PURE__ */ new Error(`Unknown subcommand: ${unknownCmd}${suggestion ? `.${suggestion}` : ""}`),
|
|
8150
|
+
exitCode: 1,
|
|
8151
|
+
logs: getCurrentLogs()
|
|
8152
|
+
};
|
|
8153
|
+
}
|
|
8154
|
+
}
|
|
8155
|
+
const unknownKeysMode = parseResult.extractedFields?.unknownKeysMode ?? "strip";
|
|
8156
|
+
if (unknownKeysMode === "strict") {
|
|
8157
|
+
collector?.stop();
|
|
8158
|
+
return {
|
|
8159
|
+
success: false,
|
|
8160
|
+
error: /* @__PURE__ */ new Error(`Unexpected positional argument${extraPositionals.length > 1 ? "s" : ""}: ${extraPositionals.join(", ")}`),
|
|
8161
|
+
exitCode: 1,
|
|
8162
|
+
logs: getCurrentLogs()
|
|
8163
|
+
};
|
|
8164
|
+
} else if (unknownKeysMode === "strip") for (const positional of extraPositionals) (logger.warn ?? logger.error)(`Warning: Unexpected positional argument: ${positional}`);
|
|
8165
|
+
}
|
|
8058
8166
|
let validatedGlobalArgs = {};
|
|
8059
8167
|
const isCompletionInvocation = command.name === "__complete";
|
|
8060
8168
|
if (options.globalArgs && options._globalExtracted && !isCompletionInvocation) {
|
|
@@ -8159,7 +8267,7 @@ function extractAndValidateGlobal(options) {
|
|
|
8159
8267
|
return extracted;
|
|
8160
8268
|
}
|
|
8161
8269
|
//#endregion
|
|
8162
|
-
//#region ../node_modules/.pnpm/politty@0.
|
|
8270
|
+
//#region ../node_modules/.pnpm/politty@0.11.0_zod@4.4.3/node_modules/politty/dist/command-B4yA4LXX.js
|
|
8163
8271
|
function defineCommand(config) {
|
|
8164
8272
|
return {
|
|
8165
8273
|
name: config.name,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@toiroakr/lines-db",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.1",
|
|
4
4
|
"description": "A database implementation that treats JSONL files as tables using SQLite",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"types": "./dist/index.d.mts",
|
|
@@ -40,23 +40,15 @@
|
|
|
40
40
|
"homepage": "https://github.com/toiroakr/lines-db#readme",
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@types/node": "24.13.2",
|
|
43
|
-
"politty": "0.
|
|
43
|
+
"politty": "0.11.0",
|
|
44
44
|
"publint": "0.3.21",
|
|
45
45
|
"tsdown": "0.22.3",
|
|
46
46
|
"type-fest": "5.7.0",
|
|
47
47
|
"typescript": "6.0.3",
|
|
48
|
-
"valibot": "1.4.
|
|
48
|
+
"valibot": "1.4.2",
|
|
49
49
|
"vitest": "4.1.9",
|
|
50
50
|
"zod": "4.4.3"
|
|
51
51
|
},
|
|
52
|
-
"peerDependencies": {
|
|
53
|
-
"valibot": ">=1.0.0"
|
|
54
|
-
},
|
|
55
|
-
"peerDependenciesMeta": {
|
|
56
|
-
"valibot": {
|
|
57
|
-
"optional": true
|
|
58
|
-
}
|
|
59
|
-
},
|
|
60
52
|
"dependencies": {
|
|
61
53
|
"@standard-schema/spec": "^1.0.0",
|
|
62
54
|
"amaro": "^1.1.10"
|