spec-controller 0.1.0-alpha.9 → 0.1.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/README.md +18 -11
- package/dist/cli-allocate/cli.d.ts +2 -0
- package/dist/cli-allocate/cli.d.ts.map +1 -0
- package/dist/cli-allocate/cli.js +61 -0
- package/dist/cli-allocate/cli.js.map +1 -0
- package/dist/cli-allocate/readHistory.d.ts +14 -0
- package/dist/cli-allocate/readHistory.d.ts.map +1 -0
- package/dist/cli-allocate/readHistory.js +109 -0
- package/dist/cli-allocate/readHistory.js.map +1 -0
- package/dist/cli-allocate/readParts.d.ts +2 -0
- package/dist/cli-allocate/readParts.d.ts.map +1 -0
- package/dist/cli-allocate/readParts.js +23 -0
- package/dist/cli-allocate/readParts.js.map +1 -0
- package/dist/cli-allocate/readTree.d.ts +5 -0
- package/dist/cli-allocate/readTree.d.ts.map +1 -0
- package/dist/cli-allocate/readTree.js +74 -0
- package/dist/cli-allocate/readTree.js.map +1 -0
- package/dist/cli-allocate/refStore.d.ts +2 -0
- package/dist/cli-allocate/refStore.d.ts.map +1 -0
- package/dist/cli-allocate/refStore.js +35 -0
- package/dist/cli-allocate/refStore.js.map +1 -0
- package/dist/cli-allocate/request.d.ts +9 -0
- package/dist/cli-allocate/request.d.ts.map +1 -0
- package/dist/cli-allocate/request.js +23 -0
- package/dist/cli-allocate/request.js.map +1 -0
- package/dist/cli-allocate/stderr.d.ts +7 -0
- package/dist/cli-allocate/stderr.d.ts.map +1 -0
- package/dist/cli-allocate/stderr.js +32 -0
- package/dist/cli-allocate/stderr.js.map +1 -0
- package/dist/cli-allocate/unreadable.d.ts +13 -0
- package/dist/cli-allocate/unreadable.d.ts.map +1 -0
- package/dist/cli-allocate/unreadable.js +37 -0
- package/dist/cli-allocate/unreadable.js.map +1 -0
- package/dist/cli-args.d.ts +15 -70
- package/dist/cli-args.d.ts.map +1 -1
- package/dist/cli-args.js +167 -85
- package/dist/cli-args.js.map +1 -1
- package/dist/cli-balance/cli.d.ts +1 -82
- package/dist/cli-balance/cli.d.ts.map +1 -1
- package/dist/cli-balance/cli.js +86 -397
- package/dist/cli-balance/cli.js.map +1 -1
- package/dist/cli-balance/emit/format.d.ts +18 -39
- package/dist/cli-balance/emit/format.d.ts.map +1 -1
- package/dist/cli-balance/emit/format.js +32 -63
- package/dist/cli-balance/emit/format.js.map +1 -1
- package/dist/cli-balance/emit/writer.d.ts +2 -34
- package/dist/cli-balance/emit/writer.d.ts.map +1 -1
- package/dist/cli-balance/emit/writer.js +62 -37
- package/dist/cli-balance/emit/writer.js.map +1 -1
- package/dist/cli-balance/exitStatus.d.ts +2 -0
- package/dist/cli-balance/exitStatus.d.ts.map +1 -0
- package/dist/cli-balance/exitStatus.js +5 -0
- package/dist/cli-balance/exitStatus.js.map +1 -0
- package/dist/cli-balance/inputsRead.d.ts +11 -0
- package/dist/cli-balance/inputsRead.d.ts.map +1 -0
- package/dist/cli-balance/inputsRead.js +54 -0
- package/dist/cli-balance/inputsRead.js.map +1 -0
- package/dist/cli-balance/reRender.d.ts +8 -0
- package/dist/cli-balance/reRender.d.ts.map +1 -0
- package/dist/cli-balance/reRender.js +21 -0
- package/dist/cli-balance/reRender.js.map +1 -0
- package/dist/cli-balance/unreadableInputs.d.ts +15 -0
- package/dist/cli-balance/unreadableInputs.d.ts.map +1 -0
- package/dist/cli-balance/unreadableInputs.js +100 -0
- package/dist/cli-balance/unreadableInputs.js.map +1 -0
- package/dist/cli-registry.d.ts +16 -71
- package/dist/cli-registry.d.ts.map +1 -1
- package/dist/cli-registry.js +71 -136
- package/dist/cli-registry.js.map +1 -1
- package/dist/cli.d.ts +0 -21
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +1 -85
- package/dist/cli.js.map +1 -1
- package/dist/deferralTags.d.ts +0 -14
- package/dist/deferralTags.d.ts.map +1 -1
- package/dist/deferralTags.js +0 -14
- package/dist/deferralTags.js.map +1 -1
- package/dist/host.d.ts +10 -41
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +99 -50
- package/dist/host.js.map +1 -1
- package/dist/ingest/ciSourcePaths.d.ts +0 -39
- package/dist/ingest/ciSourcePaths.d.ts.map +1 -1
- package/dist/ingest/ciSourcePaths.js +1 -39
- package/dist/ingest/ciSourcePaths.js.map +1 -1
- package/dist/ingest/gherkinValidation.d.ts +0 -80
- package/dist/ingest/gherkinValidation.d.ts.map +1 -1
- package/dist/ingest/gherkinValidation.js +3 -82
- package/dist/ingest/gherkinValidation.js.map +1 -1
- package/dist/ingest/ingestQualityChecks.d.ts +8 -93
- package/dist/ingest/ingestQualityChecks.d.ts.map +1 -1
- package/dist/ingest/ingestQualityChecks.js +61 -224
- package/dist/ingest/ingestQualityChecks.js.map +1 -1
- package/dist/ingest/ingestScenarios.d.ts +0 -45
- package/dist/ingest/ingestScenarios.d.ts.map +1 -1
- package/dist/ingest/ingestScenarios.js +24 -110
- package/dist/ingest/ingestScenarios.js.map +1 -1
- package/dist/ingest/inputShapes.d.ts +16 -0
- package/dist/ingest/inputShapes.d.ts.map +1 -0
- package/dist/ingest/inputShapes.js +114 -0
- package/dist/ingest/inputShapes.js.map +1 -0
- package/dist/main.d.ts +2 -0
- package/dist/main.d.ts.map +1 -0
- package/dist/main.js +93 -0
- package/dist/main.js.map +1 -0
- package/dist/messages.d.ts +223 -0
- package/dist/messages.d.ts.map +1 -0
- package/dist/messages.js +319 -0
- package/dist/messages.js.map +1 -0
- package/dist/outputLocation.d.ts +23 -0
- package/dist/outputLocation.d.ts.map +1 -0
- package/dist/outputLocation.js +139 -0
- package/dist/outputLocation.js.map +1 -0
- package/dist/run-management/keptRun.d.ts +8 -109
- package/dist/run-management/keptRun.d.ts.map +1 -1
- package/dist/run-management/keptRun.js +49 -89
- package/dist/run-management/keptRun.js.map +1 -1
- package/dist/run-management/resolveRunInputs.d.ts +0 -67
- package/dist/run-management/resolveRunInputs.d.ts.map +1 -1
- package/dist/run-management/resolveRunInputs.js +13 -117
- package/dist/run-management/resolveRunInputs.js.map +1 -1
- package/dist/storedRun.d.ts +6 -0
- package/dist/storedRun.d.ts.map +1 -0
- package/dist/storedRun.js +27 -0
- package/dist/storedRun.js.map +1 -0
- package/package.json +2 -2
- package/dist/corpus/cli.d.ts +0 -34
- package/dist/corpus/cli.d.ts.map +0 -1
- package/dist/corpus/cli.js +0 -125
- package/dist/corpus/cli.js.map +0 -1
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { APP_MESSAGES, AppMessage, UNREADABLE_SUBJECTS } from "../messages.js";
|
|
2
|
+
export class UnreadableInput extends Error {
|
|
3
|
+
path;
|
|
4
|
+
reason;
|
|
5
|
+
name = "UnreadableInput";
|
|
6
|
+
subject;
|
|
7
|
+
constructor(what, path, reason) {
|
|
8
|
+
const subject = UNREADABLE_SUBJECTS[what];
|
|
9
|
+
super(path === ""
|
|
10
|
+
? APP_MESSAGES[AppMessage.CouldNotBeRead](subject, reason)
|
|
11
|
+
: APP_MESSAGES[AppMessage.CouldNotBeReadAt](subject, path, reason));
|
|
12
|
+
this.path = path;
|
|
13
|
+
this.reason = reason;
|
|
14
|
+
this.subject = subject;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
export function readOrRefuse(what, path, read) {
|
|
18
|
+
try {
|
|
19
|
+
return read();
|
|
20
|
+
}
|
|
21
|
+
catch (err) {
|
|
22
|
+
return refuse(what, path, err);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
export function refuse(what, path, err) {
|
|
26
|
+
const errno = err;
|
|
27
|
+
if (!(err instanceof Error) || typeof errno.code !== "string")
|
|
28
|
+
throw err;
|
|
29
|
+
throw new UnreadableInput(what, errno.path ?? path, err.message);
|
|
30
|
+
}
|
|
31
|
+
export function refusalLine(refusal) {
|
|
32
|
+
return APP_MESSAGES[AppMessage.UsageError]("allocate", refusal.message);
|
|
33
|
+
}
|
|
34
|
+
export function firstLine(text) {
|
|
35
|
+
return text.split("\n")[0] ?? "";
|
|
36
|
+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C;IACzE,MAAM,IAAI,eAAe,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,IAAI,IAAI,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;AACnE,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,OAAwB;IAClD,OAAO,YAAY,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC,UAAU,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;AAC1E,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,IAAY;IACpC,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;AACnC,CAAC"}
|
package/dist/cli-args.d.ts
CHANGED
|
@@ -1,73 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
*
|
|
4
|
-
* WHY IT IS ITS OWN MODULE (3F-3300). Both halves lived inside `cli-balance/cli.ts` while
|
|
5
|
-
* `balance` was the only command — `parseArgs` private to it, `checkUnknownFlags` exported for
|
|
6
|
-
* its own `@unit` arm. A second command needs both, and the two ways of giving it them were
|
|
7
|
-
* worse than moving them: copying `parseArgs` would put a second reading of argv in a tree whose
|
|
8
|
-
* whole subject is second readings, and importing them from `cli-balance/cli.ts` would have the
|
|
9
|
-
* corpus command pull the entire reconcile ingest chain into memory to answer a question about
|
|
10
|
-
* feature files.
|
|
11
|
-
*
|
|
12
|
-
* THE BOUNDING IS PER-COMMAND, which is what makes "accepted = registry = help" hold for every
|
|
13
|
-
* command rather than for the one this code was written beside. `checkUnknownFlags` took the
|
|
14
|
-
* registry and looked `balance` up inside itself; the command is a parameter now, exactly as it
|
|
15
|
-
* became one for `renderCommandHelp` (3F-3298). @SCN-CLI-009's scenario is unchanged and still
|
|
16
|
-
* asks about `balance`: what a second command gets is the same bounding BY CONSTRUCTION, and the
|
|
17
|
-
* residual — that an unregistered flag to `tags` is unproven by a scenario of its own — is named
|
|
18
|
-
* on 3F-3286 rather than left silent.
|
|
19
|
-
*/
|
|
20
|
-
import type { CliRegistry } from "./cli-registry.js";
|
|
21
|
-
/**
|
|
22
|
-
* Parse `--flag value` pairs from a command's argv into a record, keys with the `--` stripped.
|
|
23
|
-
*
|
|
24
|
-
* A flag whose next token is another flag (or absent) records the string `"true"`, which is how
|
|
25
|
-
* the boolean flags — `--strict`, `--help` — are recognised: presence is what matters, so callers
|
|
26
|
-
* read them with `!== undefined`.
|
|
27
|
-
*
|
|
28
|
-
* PERMISSIVE BY ITSELF, AND BOUNDED BY THE CALLER. It records whatever it is given, including a
|
|
29
|
-
* flag no registry names; `checkUnknownFlags` below is what turns that into a usage error. The
|
|
30
|
-
* split is deliberate — the parse has no opinion about which command it is reading for, and the
|
|
31
|
-
* bounding has nothing else to do.
|
|
32
|
-
*/
|
|
1
|
+
import type { CliRegistry, FlagSpec } from "./cli-registry.js";
|
|
2
|
+
export declare function asksForHelp(argv: readonly string[]): boolean;
|
|
33
3
|
export declare function parseArgs(argv: readonly string[]): Record<string, string>;
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
* parse sees only the command's own args.
|
|
48
|
-
*
|
|
49
|
-
* A COMMAND THE REGISTRY DOES NOT NAME ACCEPTS NOTHING, which is the honest reading rather than a
|
|
50
|
-
* degenerate one: an unregistered command has no scope, so every flag given to it is outside it.
|
|
51
|
-
* The dispatcher refuses such a command before this is ever reached, so the case is unreachable
|
|
52
|
-
* today and stated here so it cannot become a silent "accept everything" later.
|
|
53
|
-
*
|
|
54
|
-
* IT NAMES THE VERSION THAT REFUSED, AND THAT IS FOR THE PINNED READER (3F-3105, @SCN-CLI-009).
|
|
55
|
-
* A consumer pins spec-controller and then moves their own tree; the pinned reader is handed argv
|
|
56
|
-
* it was published too early — or too late — to understand, and an unadorned "unknown flag" is
|
|
57
|
-
* indistinguishable from a typo. Naming the running version makes version skew legible from the CI
|
|
58
|
-
* log alone, and naming the bump says what to do about it. `toolVersion` is a PARAMETER rather than
|
|
59
|
-
* a read performed here so this stays pure and `@unit`-testable; the callers pass
|
|
60
|
-
* `resolveToolIdentity().toolVersion`, the same value the report provenance carries.
|
|
61
|
-
*
|
|
62
|
-
* WHY THE PRODUCT SAYS THIS AND NOT THE CONSUMER. spec-controller's own repository is a consumer of
|
|
63
|
-
* its published self, and the ruling there is that it does NOT wrap itself — a dependency, a `run:`
|
|
64
|
-
* step, and the verdict its exit code gives. A consumer-side translator turning exit 2 into a skew
|
|
65
|
-
* refusal is exactly that forbidden wrapper, and no other adopter could write one either. So the
|
|
66
|
-
* refusal is the tool's own, which makes it universal rather than local.
|
|
67
|
-
*
|
|
68
|
-
* THE STATUS DOES NOT MOVE. The caller still routes this to stderr and exit 2. A mistyped `--strcit`
|
|
69
|
-
* is still a usage fault, and giving skew its own status would cost every adopter the ordinary
|
|
70
|
-
* reading to serve the rarer one.
|
|
71
|
-
*/
|
|
4
|
+
export type ValueFlagSpec = FlagSpec & {
|
|
5
|
+
arg: string;
|
|
6
|
+
};
|
|
7
|
+
export declare function valueFlagsOf(flags: readonly FlagSpec[]): Map<string, ValueFlagSpec>;
|
|
8
|
+
export declare function givenValue(next: string | undefined): string | undefined;
|
|
9
|
+
export declare function checkMissingValues(argv: readonly string[], registry: CliRegistry, command: string): string | null;
|
|
10
|
+
export declare function missingValueRefusal(given: string, flag: ValueFlagSpec, scope: string): string;
|
|
11
|
+
export declare function checkArgvShape(argv: readonly string[], registry: CliRegistry, command: string): string | null;
|
|
12
|
+
export declare function positionalArguments(argv: readonly string[], registry: CliRegistry, command: string): string[];
|
|
13
|
+
export declare function givenTwiceRefusal(given: string, scope: string): string;
|
|
14
|
+
export declare function isEqualsForm(token: string): boolean;
|
|
15
|
+
export declare function equalsFormRefusal(token: string, flags: ReadonlyMap<string, FlagSpec>, scope: string): string;
|
|
16
|
+
export declare function checkMisplacedHostModifiers(args: Record<string, string>, registry: CliRegistry, command: string): string | null;
|
|
72
17
|
export declare function checkUnknownFlags(args: Record<string, string>, registry: CliRegistry, command: string, toolVersion: string): string | null;
|
|
73
18
|
//# sourceMappingURL=cli-args.d.ts.map
|
package/dist/cli-args.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli-args.d.ts","sourceRoot":"","sources":["../src/cli-args.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"cli-args.d.ts","sourceRoot":"","sources":["../src/cli-args.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAe,QAAQ,EAAkB,MAAM,mBAAmB,CAAC;AAG5F,wBAAgB,WAAW,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG,OAAO,CAE5D;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAgBzE;AAED,MAAM,MAAM,aAAa,GAAG,QAAQ,GAAG;IAAE,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC;AAMvD,wBAAgB,YAAY,CAAC,KAAK,EAAE,SAAS,QAAQ,EAAE,GAAG,GAAG,CAAC,MAAM,EAAE,aAAa,CAAC,CAOnF;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAEvE;AAED,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,SAAS,MAAM,EAAE,EACvB,QAAQ,EAAE,WAAW,EACrB,OAAO,EAAE,MAAM,GACd,MAAM,GAAG,IAAI,CASf;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAK7F;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,EAAE,QAAQ,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAW7G;AAuBD,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,EAAE,QAAQ,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,CAS7G;AA2BD,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAEtE;AAcD,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAEnD;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,CAAC,MAAM,EAAE,QAAQ,CAAC,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAQ5G;AAkCD,wBAAgB,2BAA2B,CACzC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC5B,QAAQ,EAAE,WAAW,EACrB,OAAO,EAAE,MAAM,GACd,MAAM,GAAG,IAAI,CAKf;AAED,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC5B,QAAQ,EAAE,WAAW,EACrB,OAAO,EAAE,MAAM,EACf,WAAW,EAAE,MAAM,GAClB,MAAM,GAAG,IAAI,CAaf"}
|
package/dist/cli-args.js
CHANGED
|
@@ -1,34 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
* `balance` was the only command — `parseArgs` private to it, `checkUnknownFlags` exported for
|
|
6
|
-
* its own `@unit` arm. A second command needs both, and the two ways of giving it them were
|
|
7
|
-
* worse than moving them: copying `parseArgs` would put a second reading of argv in a tree whose
|
|
8
|
-
* whole subject is second readings, and importing them from `cli-balance/cli.ts` would have the
|
|
9
|
-
* corpus command pull the entire reconcile ingest chain into memory to answer a question about
|
|
10
|
-
* feature files.
|
|
11
|
-
*
|
|
12
|
-
* THE BOUNDING IS PER-COMMAND, which is what makes "accepted = registry = help" hold for every
|
|
13
|
-
* command rather than for the one this code was written beside. `checkUnknownFlags` took the
|
|
14
|
-
* registry and looked `balance` up inside itself; the command is a parameter now, exactly as it
|
|
15
|
-
* became one for `renderCommandHelp` (3F-3298). @SCN-CLI-009's scenario is unchanged and still
|
|
16
|
-
* asks about `balance`: what a second command gets is the same bounding BY CONSTRUCTION, and the
|
|
17
|
-
* residual — that an unregistered flag to `tags` is unproven by a scenario of its own — is named
|
|
18
|
-
* on 3F-3286 rather than left silent.
|
|
19
|
-
*/
|
|
20
|
-
/**
|
|
21
|
-
* Parse `--flag value` pairs from a command's argv into a record, keys with the `--` stripped.
|
|
22
|
-
*
|
|
23
|
-
* A flag whose next token is another flag (or absent) records the string `"true"`, which is how
|
|
24
|
-
* the boolean flags — `--strict`, `--help` — are recognised: presence is what matters, so callers
|
|
25
|
-
* read them with `!== undefined`.
|
|
26
|
-
*
|
|
27
|
-
* PERMISSIVE BY ITSELF, AND BOUNDED BY THE CALLER. It records whatever it is given, including a
|
|
28
|
-
* flag no registry names; `checkUnknownFlags` below is what turns that into a usage error. The
|
|
29
|
-
* split is deliberate — the parse has no opinion about which command it is reading for, and the
|
|
30
|
-
* bounding has nothing else to do.
|
|
31
|
-
*/
|
|
1
|
+
import { APP_MESSAGES, AppMessage } from "./messages.js";
|
|
2
|
+
export function asksForHelp(argv) {
|
|
3
|
+
return argv.includes("--help") || argv.includes("-h");
|
|
4
|
+
}
|
|
32
5
|
export function parseArgs(argv) {
|
|
33
6
|
const args = {};
|
|
34
7
|
for (let i = 0; i < argv.length; i++) {
|
|
@@ -47,68 +20,177 @@ export function parseArgs(argv) {
|
|
|
47
20
|
}
|
|
48
21
|
return args;
|
|
49
22
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
23
|
+
function takesValue(flag) {
|
|
24
|
+
return flag.arg !== undefined;
|
|
25
|
+
}
|
|
26
|
+
export function valueFlagsOf(flags) {
|
|
27
|
+
const valueFlags = new Map();
|
|
28
|
+
for (const flag of flags) {
|
|
29
|
+
if (!takesValue(flag))
|
|
30
|
+
continue;
|
|
31
|
+
for (const name of [flag.name, ...(flag.aliases ?? [])])
|
|
32
|
+
valueFlags.set(name, flag);
|
|
33
|
+
}
|
|
34
|
+
return valueFlags;
|
|
35
|
+
}
|
|
36
|
+
export function givenValue(next) {
|
|
37
|
+
return next === undefined || next === "" || next.startsWith("--") ? undefined : next;
|
|
38
|
+
}
|
|
39
|
+
export function checkMissingValues(argv, registry, command) {
|
|
40
|
+
const valueFlags = valueFlagsOf(commandEntry(registry, command).flags);
|
|
41
|
+
for (const [i, token] of argv.entries()) {
|
|
42
|
+
const flag = valueFlags.get(token);
|
|
43
|
+
if (flag !== undefined && givenValue(argv[i + 1]) === undefined) {
|
|
44
|
+
return missingValueRefusal(token, flag, `spec-controller ${command}`);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
export function missingValueRefusal(given, flag, scope) {
|
|
50
|
+
return (`${APP_MESSAGES[AppMessage.MissingValue](given, scope, flag.arg)}\n` +
|
|
51
|
+
APP_MESSAGES[AppMessage.SeeFlagsAndValues](scope));
|
|
52
|
+
}
|
|
53
|
+
export function checkArgvShape(argv, registry, command) {
|
|
54
|
+
const scope = flagScopeOf(registry, command);
|
|
55
|
+
const seen = new Set();
|
|
56
|
+
const positionals = positionalsOf(registry, command);
|
|
57
|
+
const walk = { scope, seen, positionals, slotsLeft: positionals.length };
|
|
58
|
+
for (let i = 0; i < argv.length; i++) {
|
|
59
|
+
const read = readToken(argv, i, walk, command);
|
|
60
|
+
if (typeof read === "string")
|
|
61
|
+
return read;
|
|
62
|
+
i += read;
|
|
63
|
+
}
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
function positionalsOf(registry, command) {
|
|
67
|
+
return commandEntry(registry, command).positionals ?? [];
|
|
68
|
+
}
|
|
69
|
+
function commandEntry(registry, command) {
|
|
70
|
+
return registry.commands.find((c) => c.name === command) ?? { flags: [] };
|
|
71
|
+
}
|
|
72
|
+
function bareName(name) {
|
|
73
|
+
return name.replace(/^-+/, "");
|
|
74
|
+
}
|
|
75
|
+
export function positionalArguments(argv, registry, command) {
|
|
76
|
+
const scope = flagScopeOf(registry, command);
|
|
77
|
+
const words = [];
|
|
78
|
+
for (let i = 0; i < argv.length; i++) {
|
|
79
|
+
const token = argv[i] ?? "";
|
|
80
|
+
if (!isFlagShaped(token))
|
|
81
|
+
words.push(token);
|
|
82
|
+
else if (scope.get(token)?.arg !== undefined)
|
|
83
|
+
i++;
|
|
84
|
+
}
|
|
85
|
+
return words;
|
|
86
|
+
}
|
|
87
|
+
function readToken(argv, i, walk, command) {
|
|
88
|
+
const token = argv[i] ?? "";
|
|
89
|
+
const next = argv[i + 1];
|
|
90
|
+
if (isEqualsForm(token))
|
|
91
|
+
return equalsFormRefusal(token, walk.scope, `spec-controller ${command}`);
|
|
92
|
+
if (!isFlagShaped(token) && !walk.scope.has(token))
|
|
93
|
+
return positionalRead(token, walk, command);
|
|
94
|
+
const flag = walk.scope.get(token);
|
|
95
|
+
if (flag === undefined)
|
|
96
|
+
return valueTokensAfter(undefined, next);
|
|
97
|
+
return registeredFlagRefusal(flag, token, next, walk, command) ?? valueTokensAfter(flag, next);
|
|
98
|
+
}
|
|
99
|
+
function registeredFlagRefusal(flag, token, next, walk, command) {
|
|
100
|
+
if (walk.seen.has(flag) && flag.repeatable !== true)
|
|
101
|
+
return givenTwiceRefusal(token, `spec-controller ${command}`);
|
|
102
|
+
walk.seen.add(flag);
|
|
103
|
+
if (flag.arg === undefined && next !== undefined && !isFlagShaped(next) && !walk.scope.has(next) && walk.slotsLeft === 0) {
|
|
104
|
+
return takesNoValueRefusal(token, next, command);
|
|
105
|
+
}
|
|
106
|
+
return undefined;
|
|
107
|
+
}
|
|
108
|
+
export function givenTwiceRefusal(given, scope) {
|
|
109
|
+
return `${APP_MESSAGES[AppMessage.GivenTwice](given, scope)}\n${APP_MESSAGES[AppMessage.SeeFlags](scope)}`;
|
|
110
|
+
}
|
|
111
|
+
function flagScopeOf(registry, command) {
|
|
112
|
+
const scope = new Map();
|
|
113
|
+
for (const flag of commandEntry(registry, command).flags) {
|
|
114
|
+
for (const name of [flag.name, ...(flag.aliases ?? [])])
|
|
115
|
+
scope.set(name, flag);
|
|
116
|
+
}
|
|
117
|
+
return scope;
|
|
118
|
+
}
|
|
119
|
+
function isFlagShaped(token) {
|
|
120
|
+
return token.startsWith("--");
|
|
121
|
+
}
|
|
122
|
+
export function isEqualsForm(token) {
|
|
123
|
+
return isFlagShaped(token) && token.includes("=");
|
|
124
|
+
}
|
|
125
|
+
export function equalsFormRefusal(token, flags, scope) {
|
|
126
|
+
const at = token.indexOf("=");
|
|
127
|
+
const name = token.slice(0, at);
|
|
128
|
+
const value = token.slice(at + 1);
|
|
129
|
+
const flag = flags.get(name);
|
|
130
|
+
const spelling = flag !== undefined && flag.arg === undefined ? name : `${name} ${value === "" ? (flag?.arg ?? "<value>") : value}`;
|
|
131
|
+
return `${APP_MESSAGES[AppMessage.EqualsForm](token, scope, spelling)}\n${APP_MESSAGES[AppMessage.SeeFlags](scope)}`;
|
|
132
|
+
}
|
|
133
|
+
function valueTokensAfter(flag, next) {
|
|
134
|
+
if (next === undefined || isFlagShaped(next))
|
|
135
|
+
return 0;
|
|
136
|
+
return flag === undefined || flag.arg !== undefined ? 1 : 0;
|
|
137
|
+
}
|
|
138
|
+
function takesNoValueRefusal(flag, value, command) {
|
|
139
|
+
const scope = `spec-controller ${command}`;
|
|
140
|
+
return (`${APP_MESSAGES[AppMessage.TakesNoValue](flag, scope, value)}\n` +
|
|
141
|
+
APP_MESSAGES[AppMessage.SeeFlagsAndValues](scope));
|
|
142
|
+
}
|
|
143
|
+
function positionalRead(token, walk, command) {
|
|
144
|
+
if (walk.slotsLeft === 0) {
|
|
145
|
+
return walk.positionals.length === 0 ? notAFlagRefusal(token, command) : extraPositionalRefusal(token, walk, command);
|
|
146
|
+
}
|
|
147
|
+
walk.slotsLeft--;
|
|
148
|
+
return 0;
|
|
149
|
+
}
|
|
150
|
+
function extraPositionalRefusal(token, walk, command) {
|
|
151
|
+
const takes = walk.positionals.map((positional) => positional.name).join(" ");
|
|
152
|
+
const scope = `spec-controller ${command}`;
|
|
153
|
+
return `${APP_MESSAGES[AppMessage.ExtraArgument](token, scope, takes)}\n${APP_MESSAGES[AppMessage.SeeArguments](scope)}`;
|
|
154
|
+
}
|
|
155
|
+
function notAFlagRefusal(token, command) {
|
|
156
|
+
const scope = `spec-controller ${command}`;
|
|
157
|
+
return `${APP_MESSAGES[AppMessage.NotAFlag](token, scope)}\n${APP_MESSAGES[AppMessage.SeeFlags](scope)}`;
|
|
158
|
+
}
|
|
159
|
+
export function checkMisplacedHostModifiers(args, registry, command) {
|
|
160
|
+
const modifiers = new Set(registry.global.map((flag) => bareName(flag.name)));
|
|
161
|
+
const key = Object.keys(args).find((k) => modifiers.has(k));
|
|
162
|
+
if (key === undefined)
|
|
163
|
+
return null;
|
|
164
|
+
return `${APP_MESSAGES[AppMessage.MisplacedModifier](`--${key}`, command)}\n${APP_MESSAGES[AppMessage.SeeModifiers]()}`;
|
|
165
|
+
}
|
|
88
166
|
export function checkUnknownFlags(args, registry, command, toolVersion) {
|
|
89
|
-
|
|
90
|
-
// stripped so it compares against the parse's `--`-stripped keys (e.g. "--features" and "-h"
|
|
91
|
-
// become "features" and "h"). Built from the registry alone — the single source — so
|
|
92
|
-
// "accepted = registry" holds by construction.
|
|
93
|
-
const entry = registry.commands.find((c) => c.name === command);
|
|
167
|
+
const entry = commandEntry(registry, command);
|
|
94
168
|
const accepted = new Set();
|
|
95
|
-
for (const flag of entry
|
|
96
|
-
accepted.add(flag.name
|
|
169
|
+
for (const flag of entry.flags) {
|
|
170
|
+
accepted.add(bareName(flag.name));
|
|
97
171
|
for (const alias of flag.aliases ?? [])
|
|
98
|
-
accepted.add(alias
|
|
172
|
+
accepted.add(bareName(alias));
|
|
99
173
|
}
|
|
100
|
-
// The FIRST parsed flag not in the accepted set is the reported error (Object.keys is argv
|
|
101
|
-
// order, so this is deterministic). The message names the flag WITH its dashes, and the command
|
|
102
|
-
// whose scope refused it — a consumer running two commands needs to know which help to open.
|
|
103
174
|
for (const key of Object.keys(args)) {
|
|
104
175
|
if (!accepted.has(key)) {
|
|
105
|
-
return (
|
|
106
|
-
`${toolVersion}, and that flag is not in its ${command} scope.\n` +
|
|
107
|
-
`If this version is pinned, the pin and the tree it is reading have drifted apart: ` +
|
|
108
|
-
`bump the pin to a version whose '${command}' accepts --${key}.\n` +
|
|
109
|
-
`Otherwise run 'spec-controller ${command} --help' to see the flags this version accepts.`);
|
|
176
|
+
return retiredFlagRefusal(entry, key, command, toolVersion) ?? unknownFlagRefusal(`--${key}`, command, toolVersion);
|
|
110
177
|
}
|
|
111
178
|
}
|
|
112
179
|
return null;
|
|
113
180
|
}
|
|
181
|
+
function unknownFlagRefusal(flag, command, toolVersion) {
|
|
182
|
+
const scope = `spec-controller ${command}`;
|
|
183
|
+
return (`${APP_MESSAGES[AppMessage.UnknownFlag](flag, scope, toolVersion, command)}\n` +
|
|
184
|
+
`${APP_MESSAGES[AppMessage.PinDrifted](command, flag)}\n` +
|
|
185
|
+
APP_MESSAGES[AppMessage.OtherwiseSeeFlags](scope));
|
|
186
|
+
}
|
|
187
|
+
function retiredFlagRefusal(entry, key, command, toolVersion) {
|
|
188
|
+
const retired = entry.retiredFlags?.find((flag) => bareName(flag.name) === key);
|
|
189
|
+
if (retired === undefined)
|
|
190
|
+
return undefined;
|
|
191
|
+
const scope = `spec-controller ${command}`;
|
|
192
|
+
return (`${APP_MESSAGES[AppMessage.RetiredFlag](retired.name, scope, retired.retiredIn, toolVersion)}\n` +
|
|
193
|
+
`${APP_MESSAGES[AppMessage.DoNotPinRetired]()} ${retired.replacement}\n` +
|
|
194
|
+
APP_MESSAGES[AppMessage.SeeFlags](scope));
|
|
195
|
+
}
|
|
114
196
|
//# sourceMappingURL=cli-args.js.map
|
package/dist/cli-args.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli-args.js","sourceRoot":"","sources":["../src/cli-args.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"cli-args.js","sourceRoot":"","sources":["../src/cli-args.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAEzD,MAAM,UAAU,WAAW,CAAC,IAAuB;IACjD,OAAO,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;AACxD,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,IAAuB;IAC/C,MAAM,IAAI,GAA2B,EAAE,CAAC;IACxC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACrC,MAAM,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,IAAI,CAAC,KAAK,SAAS,IAAI,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;YAC1C,MAAM,GAAG,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;YACvB,M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C5E,MAAM,KAAK,GAAG,mBAAmB,OAAO,EAAE,CAAC;IAC3C,OAAO,CACL,GAAG,YAAY,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,WAAW,EAAE,OAAO,CAAC,IAAI;QAC9E,GAAG,YAAY,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC,OAAO,EAAE,IAAI,CAAC,IAAI;QACzD,YAAY,CAAC,UAAU,CAAC,iBAAiB,CAAC,CAAC,KAAK,CAAC,CAClD,CAAC;AACJ,CAAC;AAED,SAAS,kBAAkB,CACzB,KAAmB,EACnB,GAAW,EACX,OAAe,EACf,WAAmB;IAEnB,MAAM,OAAO,GAAG,KAAK,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC;IAChF,IAAI,OAAO,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IAC5C,MAAM,KAAK,GAAG,mBAAmB,OAAO,EAAE,CAAC;IAC3C,OAAO,CACL,GAAG,YAAY,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,KAAK,EAAE,OAAO,CAAC,SAAS,EAAE,WAAW,CAAC,IAAI;QAChG,GAAG,YAAY,CAAC,UAAU,CAAC,eAAe,CAAC,EAAE,IAAI,OAAO,CAAC,WAAW,IAAI;QACxE,YAAY,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,CACzC,CAAC;AACJ,CAAC"}
|
|
@@ -1,87 +1,6 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The balance CLI — thin wiring over the reconciler seams. The orchestration half of
|
|
3
|
-
* the old cli.ts: arg parsing, the render-from-JSON mode, and the reconcile →
|
|
4
|
-
* census → provenance → plan → write sequence. The impure file reads it calls
|
|
5
|
-
* (runReconcile + the read* siblings) live in ingest/ingestQualityChecks.ts; the output
|
|
6
|
-
* plan/write in ./emit; the git-derived run inputs in run-management/resolveRunInputs.ts.
|
|
7
|
-
*
|
|
8
|
-
* Usage:
|
|
9
|
-
* pnpm reconcile [--features <dir>] [--vitest <report.json>]
|
|
10
|
-
* [--cucumber <report.json>] [--ci-steps <record.json>]
|
|
11
|
-
* [--ci <ci.yml>]
|
|
12
|
-
* [--format <fmt>[:<path>]]
|
|
13
|
-
*/
|
|
14
|
-
/**
|
|
15
|
-
* The legacy-`--json` guard at the CLI edge (@SCN-FMT-006). The earlier
|
|
16
|
-
* `--json <path>` flag is removed; supplying it must fail fast with a migration hint to
|
|
17
|
-
* `--format json:<path>`, so the removed flag never silently no-ops and drops output. PURE
|
|
18
|
-
* and `@unit`-testable: the removed flag is NOT a `--format` spec (planOutput never sees
|
|
19
|
-
* it), so the guard reads the parsed args directly and returns the typed migration-hint
|
|
20
|
-
* error message when `--json` is present — routed to stderr + a non-zero exit by main(),
|
|
21
|
-
* the same handling planOutput's typed error gets (the shared error surface) — else null.
|
|
22
|
-
*/
|
|
23
1
|
export declare function checkLegacyJson(args: Record<string, string>): string | null;
|
|
24
|
-
/**
|
|
25
|
-
* Source the provenance "Target repo:" name for a run (@SCN-RPT-001 Update —
|
|
26
|
-
* Fork A). The operator's `--target` is recorded VERBATIM — no resolution — defaulting to
|
|
27
|
-
* `"unknown-target"` when omitted (parallel to `sourceSha`'s `"unknown"`; the facts
|
|
28
|
-
* artefact is self-describing, so the line always renders). PURE and `@unit`-testable at
|
|
29
|
-
* the CLI edge, like `checkLegacyJson`. It never inspects `--features`: the prior
|
|
30
|
-
* `basename(dirname(--features))` resolution (the deleted `resolveTarget`) and its
|
|
31
|
-
* degenerate `.` are impossible now — the target is only ever the given value or the
|
|
32
|
-
* explicit default.
|
|
33
|
-
*/
|
|
34
2
|
export declare function sourceTarget(args: Record<string, string>): string;
|
|
35
|
-
/**
|
|
36
|
-
* Guard the supplied input-file/dir flags at the CLI edge (@SCN-CLI-002). A
|
|
37
|
-
* mistyped `--vitest` / `--cucumber` / `--features` / `--ci` / `--package-json`
|
|
38
|
-
* pointing at a non-existent path used to reconcile silently against ZERO evidence —
|
|
39
|
-
* a terrifying false all-red report meaning "you forgot the reports", not "your code
|
|
40
|
-
* is broken" (the dogfooding fault). These flags are Examples of ONE boundary
|
|
41
|
-
* rule: a supplied-but-absent input path is a hard error, and a flag added to the set
|
|
42
|
-
* inherits it rather than restating it. Scope is existence only
|
|
43
|
-
* (readability / file-vs-dir type-correctness out of scope; `exists` covers the dir
|
|
44
|
-
* flag and the file flags alike).
|
|
45
|
-
*
|
|
46
|
-
* PURE and `@unit`-testable like `checkLegacyJson` / `sourceTarget`: reads the parsed
|
|
47
|
-
* args + an injected `exists` fn (no fs), returns the FIRST supplied-but-absent
|
|
48
|
-
* `(flag, path)` as a typed error naming both — routed to stderr + a non-zero exit by
|
|
49
|
-
* `refuseUnreadableInputs` (the shared typed-error surface) — else null. An OMITTED flag is not an
|
|
50
|
-
* error (legitimately optional: simply no evidence of that kind).
|
|
51
|
-
*/
|
|
52
3
|
export declare function checkInputsExist(args: Record<string, string>, exists: (path: string) => boolean): string | null;
|
|
53
|
-
/**
|
|
54
|
-
* Guard the READABILITY of the supplied JSON inputs at the CLI edge (@SCN-CLI-014).
|
|
55
|
-
* `checkInputsExist` already guards their PRESENCE — but a path that is present yet
|
|
56
|
-
* UNPARSEABLE fell straight through it: the reader threw mid-parse, nothing caught it, and
|
|
57
|
-
* the process hit Node's default exit 1 — the code reserved for a genuine OUT-OF-BALANCE
|
|
58
|
-
* verdict. A crashed invocation was therefore indistinguishable, by exit code, from an
|
|
59
|
-
* honest disagreement (3F-1742). An input the tool cannot read is a USAGE fault: exit 2,
|
|
60
|
-
* sibling to a missing path (@SCN-CLI-002) and an unrecognised flag (@SCN-CLI-009).
|
|
61
|
-
*
|
|
62
|
-
* PURE and `@unit`-testable like its sibling guards: reads the parsed args + an injected
|
|
63
|
-
* `read` fn (no fs), returns the FIRST supplied-but-unparseable `(flag, path, failure)` as
|
|
64
|
-
* a typed error naming all three — routed to stderr + exit 2 by `refuseUnreadableInputs` — else null.
|
|
65
|
-
* An omitted flag is not an error, and an unreadable file (a race after the existence
|
|
66
|
-
* check) reports as the same input fault rather than escaping as a crash.
|
|
67
|
-
*/
|
|
68
4
|
export declare function checkInputsParse(args: Record<string, string>, read: (path: string) => string): string | null;
|
|
69
|
-
|
|
70
|
-
* Guard the readability of `--render-from-json` at the CLI edge (@SCN-CLI-015). The
|
|
71
|
-
* render-from-saved-JSON branch RETURNS before the input guards ever run, so it honoured
|
|
72
|
-
* NEITHER: a missing path crashed to `ENOENT` and a malformed file to `SyntaxError`, both
|
|
73
|
-
* landing on Node's default exit 1 — the out-of-balance code (3F-1764).
|
|
74
|
-
*
|
|
75
|
-
* The missing-path case was a live violation of @SCN-CLI-002's own shipped principle: a
|
|
76
|
-
* supplied input path that does not exist is a hard error at exit 2, enforced for the five
|
|
77
|
-
* evidence flags and not for this one. The CLI shipped a guard that half-honoured its Rule.
|
|
78
|
-
*
|
|
79
|
-
* MISSING and UNPARSEABLE are two Examples of one boundary rule — an input the tool cannot
|
|
80
|
-
* read is a usage error, never a verdict — so one guard covers both. PURE and
|
|
81
|
-
* `@unit`-testable like its siblings: the parsed args + an injected `read` (no fs), which
|
|
82
|
-
* throws for an absent/unreadable path exactly as `readFileSync` does. An OMITTED flag is
|
|
83
|
-
* not an error (the ordinary reconcile path).
|
|
84
|
-
*/
|
|
85
|
-
export declare function checkRenderFromJson(args: Record<string, string>, read: (path: string) => string): string | null;
|
|
86
|
-
export declare function runBalance(argv: string[]): void;
|
|
5
|
+
export declare function runBalance(argv: string[], ownRunDir?: string): boolean;
|
|
87
6
|
//# sourceMappingURL=cli.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../src/cli-balance/cli.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../src/cli-balance/cli.ts"],"names":[],"mappings":"AAgDA,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,GAAG,IAAI,CAK3E;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,CAEjE;AAaD,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC5B,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,GAChC,MAAM,GAAG,IAAI,CAWf;AAMD,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC5B,IAAI,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,GAC7B,MAAM,GAAG,IAAI,CAkBf;AAqBD,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAEtE"}
|