@component-compass/cli 0.1.4 → 0.1.6
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/cli/help.d.ts +4 -0
- package/dist/cli/help.js +58 -0
- package/dist/cli/help.js.map +1 -0
- package/dist/cli/parse.d.ts +14 -0
- package/dist/cli/parse.js +78 -0
- package/dist/cli/parse.js.map +1 -0
- package/dist/cli/suggest.d.ts +4 -0
- package/dist/cli/suggest.js +38 -0
- package/dist/cli/suggest.js.map +1 -0
- package/dist/cli.js +114 -111
- package/dist/cli.js.map +1 -1
- package/dist/commands/auth.d.ts +9 -2
- package/dist/commands/auth.js +94 -25
- package/dist/commands/auth.js.map +1 -1
- package/dist/commands/init.d.ts +6 -1
- package/dist/commands/init.js +86 -30
- package/dist/commands/init.js.map +1 -1
- package/dist/manifest/barrel-parser.js +22 -12
- package/dist/manifest/barrel-parser.js.map +1 -1
- package/dist/manifest/lazy-resolver.d.ts +5 -22
- package/dist/manifest/lazy-resolver.js +14 -46
- package/dist/manifest/lazy-resolver.js.map +1 -1
- package/dist/prompts/adapter.d.ts +43 -0
- package/dist/prompts/adapter.js +32 -0
- package/dist/prompts/adapter.js.map +1 -0
- package/dist/reporter/stdout.d.ts +2 -1
- package/dist/reporter/stdout.js +14 -13
- package/dist/reporter/stdout.js.map +1 -1
- package/dist/util/color.d.ts +24 -0
- package/dist/util/color.js +45 -0
- package/dist/util/color.js.map +1 -0
- package/dist/util/interactive.d.ts +17 -0
- package/dist/util/interactive.js +19 -0
- package/dist/util/interactive.js.map +1 -0
- package/dist/util/log.d.ts +3 -1
- package/dist/util/log.js +6 -3
- package/dist/util/log.js.map +1 -1
- package/dist/util/version.d.ts +7 -0
- package/dist/util/version.js +13 -0
- package/dist/util/version.js.map +1 -0
- package/package.json +10 -9
package/dist/cli/help.js
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
const TOP = `component-compass <command> [options]
|
|
2
|
+
|
|
3
|
+
Commands:
|
|
4
|
+
scan Scan repo and write component-compass.json
|
|
5
|
+
init Scaffold component-compass.config.json
|
|
6
|
+
auth Sign in / out of a Component Compass host (login | logout | status)
|
|
7
|
+
db import Backfill ~/.cc-artifacts/ (or <dir>) into a deployed host
|
|
8
|
+
|
|
9
|
+
Run \`compass <command> --help\` for command-specific options.
|
|
10
|
+
|
|
11
|
+
Other:
|
|
12
|
+
--help, -h
|
|
13
|
+
--version, -v
|
|
14
|
+
`;
|
|
15
|
+
const SCAN = `compass scan [options]
|
|
16
|
+
|
|
17
|
+
Scan the repo and write component-compass.json.
|
|
18
|
+
|
|
19
|
+
Options:
|
|
20
|
+
--config <path> Override config path (default: ./component-compass.config.json)
|
|
21
|
+
--output <path> Override output path
|
|
22
|
+
--capture-values Force capture literal prop values
|
|
23
|
+
--quiet Suppress STDOUT summary
|
|
24
|
+
--json Print JSON to stdout (implies --quiet)
|
|
25
|
+
--repo-id <value> Override repo identifier in the artifact
|
|
26
|
+
--upload Also POST the scan to the configured host
|
|
27
|
+
--host <url> Override host URL (else COMPASS_HOST env, else config.host)
|
|
28
|
+
`;
|
|
29
|
+
const INIT = `compass init [options]
|
|
30
|
+
|
|
31
|
+
Scaffold component-compass.config.json. Interactive when run in a terminal.
|
|
32
|
+
|
|
33
|
+
Options:
|
|
34
|
+
--output <path> Config output path (default: ./component-compass.config.json)
|
|
35
|
+
--framework <name> Pre-select a framework (repeatable): react | vue | lit | html | wc
|
|
36
|
+
--repo-id <value> Repo identifier (default: derived from package.json / dir)
|
|
37
|
+
-y, --yes Accept defaults without prompting (non-interactive)
|
|
38
|
+
`;
|
|
39
|
+
const AUTH = `compass auth <login|logout|status> [--host <url>]
|
|
40
|
+
|
|
41
|
+
login Device-flow browser login; stores tokens in ~/.config/compass/hosts.json
|
|
42
|
+
logout Remove stored tokens for a host
|
|
43
|
+
status Show the signed-in identity
|
|
44
|
+
`;
|
|
45
|
+
const DB = `compass db import [dir] [--host <url>]
|
|
46
|
+
|
|
47
|
+
Backfill artifacts from ~/.cc-artifacts/ (or <dir>) into a deployed host.
|
|
48
|
+
`;
|
|
49
|
+
const REGISTRY = { scan: SCAN, init: INIT, auth: AUTH, db: DB };
|
|
50
|
+
/** Top-level overview: `compass`, `compass --help`. */
|
|
51
|
+
export function topHelp() {
|
|
52
|
+
return TOP;
|
|
53
|
+
}
|
|
54
|
+
/** Per-command usage: `compass <cmd> --help`. Falls back to the overview. */
|
|
55
|
+
export function commandHelp(command) {
|
|
56
|
+
return REGISTRY[command] ?? TOP;
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=help.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"help.js","sourceRoot":"","sources":["../../src/cli/help.ts"],"names":[],"mappings":"AAAA,MAAM,GAAG,GAAG;;;;;;;;;;;;;CAaX,CAAC;AAEF,MAAM,IAAI,GAAG;;;;;;;;;;;;;CAaZ,CAAC;AAEF,MAAM,IAAI,GAAG;;;;;;;;;CASZ,CAAC;AAEF,MAAM,IAAI,GAAG;;;;;CAKZ,CAAC;AAEF,MAAM,EAAE,GAAG;;;CAGV,CAAC;AAEF,MAAM,QAAQ,GAA2B,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC;AAExF,uDAAuD;AACvD,MAAM,UAAU,OAAO;IACrB,OAAO,GAAG,CAAC;AACb,CAAC;AAED,6EAA6E;AAC7E,MAAM,UAAU,WAAW,CAAC,OAAe;IACzC,OAAO,QAAQ,CAAC,OAAO,CAAC,IAAI,GAAG,CAAC;AAClC,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/** A user-facing CLI error: its message is printed and `exitCode` is returned. */
|
|
2
|
+
export declare class CliError extends Error {
|
|
3
|
+
exitCode: number;
|
|
4
|
+
constructor(message: string, exitCode?: number);
|
|
5
|
+
}
|
|
6
|
+
export declare const KNOWN_COMMANDS: readonly ["scan", "init", "auth", "db"];
|
|
7
|
+
export type ParsedCommand = {
|
|
8
|
+
values: Record<string, string | boolean | string[] | undefined>;
|
|
9
|
+
positionals: string[];
|
|
10
|
+
};
|
|
11
|
+
/** Parse one command's argv in strict mode, mapping failures to a CliError. */
|
|
12
|
+
export declare function parseCommand(command: string, argv: string[]): ParsedCommand;
|
|
13
|
+
/** Message for an unrecognised top-level command, with a nearest-match hint. */
|
|
14
|
+
export declare function unknownCommandMessage(command: string): string;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { parseArgs } from "node:util";
|
|
2
|
+
import { nearestMatch } from "./suggest.js";
|
|
3
|
+
/** A user-facing CLI error: its message is printed and `exitCode` is returned. */
|
|
4
|
+
export class CliError extends Error {
|
|
5
|
+
exitCode;
|
|
6
|
+
constructor(message, exitCode = 2) {
|
|
7
|
+
super(message);
|
|
8
|
+
this.exitCode = exitCode;
|
|
9
|
+
this.name = "CliError";
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
export const KNOWN_COMMANDS = ["scan", "init", "auth", "db"];
|
|
13
|
+
const SCAN_OPTIONS = {
|
|
14
|
+
config: { type: "string" },
|
|
15
|
+
output: { type: "string" },
|
|
16
|
+
"capture-values": { type: "boolean" },
|
|
17
|
+
quiet: { type: "boolean" },
|
|
18
|
+
json: { type: "boolean" },
|
|
19
|
+
"repo-id": { type: "string" },
|
|
20
|
+
upload: { type: "boolean" },
|
|
21
|
+
host: { type: "string" },
|
|
22
|
+
};
|
|
23
|
+
const INIT_OPTIONS = {
|
|
24
|
+
output: { type: "string" },
|
|
25
|
+
framework: { type: "string", multiple: true },
|
|
26
|
+
"repo-id": { type: "string" },
|
|
27
|
+
yes: { type: "boolean", short: "y" },
|
|
28
|
+
};
|
|
29
|
+
const AUTH_OPTIONS = { host: { type: "string" } };
|
|
30
|
+
const DB_OPTIONS = { host: { type: "string" } };
|
|
31
|
+
const COMMANDS = {
|
|
32
|
+
scan: { options: SCAN_OPTIONS, allowPositionals: false },
|
|
33
|
+
init: { options: INIT_OPTIONS, allowPositionals: false },
|
|
34
|
+
auth: { options: AUTH_OPTIONS, allowPositionals: true },
|
|
35
|
+
db: { options: DB_OPTIONS, allowPositionals: true },
|
|
36
|
+
};
|
|
37
|
+
/** Parse one command's argv in strict mode, mapping failures to a CliError. */
|
|
38
|
+
export function parseCommand(command, argv) {
|
|
39
|
+
const spec = COMMANDS[command];
|
|
40
|
+
if (!spec)
|
|
41
|
+
throw new CliError(unknownCommandMessage(command));
|
|
42
|
+
try {
|
|
43
|
+
const { values, positionals } = parseArgs({
|
|
44
|
+
args: argv,
|
|
45
|
+
options: spec.options,
|
|
46
|
+
allowPositionals: spec.allowPositionals,
|
|
47
|
+
strict: true,
|
|
48
|
+
});
|
|
49
|
+
const parsedValues = values;
|
|
50
|
+
return { values: parsedValues, positionals: [...positionals] };
|
|
51
|
+
}
|
|
52
|
+
catch (err) {
|
|
53
|
+
throw toCliError(err, command, spec.options);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
/** Message for an unrecognised top-level command, with a nearest-match hint. */
|
|
57
|
+
export function unknownCommandMessage(command) {
|
|
58
|
+
const suggestion = nearestMatch(command, KNOWN_COMMANDS);
|
|
59
|
+
const hint = suggestion ? ` Did you mean '${suggestion}'?` : "";
|
|
60
|
+
return `Unknown command '${command}'.${hint} Run \`compass --help\`.`;
|
|
61
|
+
}
|
|
62
|
+
function toCliError(err, command, options) {
|
|
63
|
+
const e = err;
|
|
64
|
+
if (e.code === "ERR_PARSE_ARGS_UNKNOWN_OPTION") {
|
|
65
|
+
const bad = extractUnknownOption(e.message ?? "");
|
|
66
|
+
const names = Object.keys(options).map((o) => `--${o}`);
|
|
67
|
+
const suggestion = bad ? nearestMatch(bad, names) : undefined;
|
|
68
|
+
const hint = suggestion ? ` Did you mean '${suggestion}'?` : "";
|
|
69
|
+
return new CliError(`Unknown option '${bad ?? "(option)"}' for \`compass ${command}\`.${hint}`);
|
|
70
|
+
}
|
|
71
|
+
return new CliError(`${e.message ?? `Invalid arguments for \`compass ${command}\``} (run \`compass ${command} --help\`).`);
|
|
72
|
+
}
|
|
73
|
+
/** Node phrases the error as: Unknown option '--ouput'. To specify ... */
|
|
74
|
+
function extractUnknownOption(message) {
|
|
75
|
+
const m = message.match(/Unknown option '([^']+)'/);
|
|
76
|
+
return m?.[1];
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=parse.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse.js","sourceRoot":"","sources":["../../src/cli/parse.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAwB,MAAM,WAAW,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAI5C,kFAAkF;AAClF,MAAM,OAAO,QAAS,SAAQ,KAAK;IAGxB;IAFT,YACE,OAAe,EACR,WAAW,CAAC;QAEnB,KAAK,CAAC,OAAO,CAAC,CAAC;QAFR,aAAQ,GAAR,QAAQ,CAAI;QAGnB,IAAI,CAAC,IAAI,GAAG,UAAU,CAAC;IACzB,CAAC;CACF;AAED,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,CAAU,CAAC;AAEtE,MAAM,YAAY,GAAG;IACnB,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;IAC1B,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;IAC1B,gBAAgB,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE;IACrC,KAAK,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE;IAC1B,IAAI,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE;IACzB,SAAS,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;IAC7B,MAAM,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE;IAC3B,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;CACD,CAAC;AAE1B,MA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G,CAAC;IACD,OAAO,IAAI,QAAQ,CACjB,GAAG,CAAC,CAAC,OAAO,IAAI,mCAAmC,OAAO,IAAI,mBAAmB,OAAO,aAAa,CACtG,CAAC;AACJ,CAAC;AAED,0EAA0E;AAC1E,SAAS,oBAAoB,CAAC,OAAe;IAC3C,MAAM,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC,0BAA0B,CAAC,CAAC;IACpD,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/** Levenshtein edit distance between two strings. */
|
|
2
|
+
export declare function editDistance(a: string, b: string): number;
|
|
3
|
+
/** Closest candidate within `maxDistance` edits, or undefined. */
|
|
4
|
+
export declare function nearestMatch(input: string, candidates: readonly string[], maxDistance?: number): string | undefined;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/** Levenshtein edit distance between two strings. */
|
|
2
|
+
export function editDistance(a, b) {
|
|
3
|
+
const m = a.length;
|
|
4
|
+
const n = b.length;
|
|
5
|
+
if (m === 0)
|
|
6
|
+
return n;
|
|
7
|
+
if (n === 0)
|
|
8
|
+
return m;
|
|
9
|
+
let prev = [];
|
|
10
|
+
for (let j = 0; j <= n; j++)
|
|
11
|
+
prev[j] = j;
|
|
12
|
+
for (let i = 1; i <= m; i++) {
|
|
13
|
+
const curr = [i];
|
|
14
|
+
for (let j = 1; j <= n; j++) {
|
|
15
|
+
const cost = a.charAt(i - 1) === b.charAt(j - 1) ? 0 : 1;
|
|
16
|
+
const del = (prev[j] ?? 0) + 1;
|
|
17
|
+
const ins = (curr[j - 1] ?? 0) + 1;
|
|
18
|
+
const sub = (prev[j - 1] ?? 0) + cost;
|
|
19
|
+
curr[j] = Math.min(del, ins, sub);
|
|
20
|
+
}
|
|
21
|
+
prev = curr;
|
|
22
|
+
}
|
|
23
|
+
return prev[n] ?? 0;
|
|
24
|
+
}
|
|
25
|
+
/** Closest candidate within `maxDistance` edits, or undefined. */
|
|
26
|
+
export function nearestMatch(input, candidates, maxDistance = 2) {
|
|
27
|
+
let best;
|
|
28
|
+
let bestDist = maxDistance + 1;
|
|
29
|
+
for (const candidate of candidates) {
|
|
30
|
+
const d = editDistance(input, candidate);
|
|
31
|
+
if (d < bestDist) {
|
|
32
|
+
bestDist = d;
|
|
33
|
+
best = candidate;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return best;
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=suggest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"suggest.js","sourceRoot":"","sources":["../../src/cli/suggest.ts"],"names":[],"mappings":"AAAA,qDAAqD;AACrD,MAAM,UAAU,YAAY,CAAC,CAAS,EAAE,CAAS;IAC/C,MAAM,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC;IACnB,MAAM,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC;IACnB,IAAI,CAAC,KAAK,CAAC;QAAE,OAAO,CAAC,CAAC;IACtB,IAAI,CAAC,KAAK,CAAC;QAAE,OAAO,CAAC,CAAC;IAEtB,IAAI,IAAI,GAAa,EAAE,CAAC;IACxB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE;QAAE,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IAEzC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QAC5B,MAAM,IAAI,GAAa,CAAC,CAAC,CAAC,CAAC;QAC3B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;YAC5B,MAAM,IAAI,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YACzD,MAAM,GAAG,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC;YAC/B,MAAM,GAAG,GAAG,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC;YACnC,MAAM,GAAG,GAAG,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC;YACtC,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;QACpC,CAAC;QACD,IAAI,GAAG,IAAI,CAAC;IACd,CAAC;IACD,OAAO,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;AACtB,CAAC;AAED,kEAAkE;AAClE,MAAM,UAAU,YAAY,CAC1B,KAAa,EACb,UAA6B,EAC7B,WAAW,GAAG,CAAC;IAEf,IAAI,IAAwB,CAAC;IAC7B,IAAI,QAAQ,GAAG,WAAW,GAAG,CAAC,CAAC;IAC/B,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;QACnC,MAAM,CAAC,GAAG,YAAY,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;QACzC,IAAI,CAAC,GAAG,QAAQ,EAAE,CAAC;YACjB,QAAQ,GAAG,CAAC,CAAC;YACb,IAAI,GAAG,SAAS,CAAC;QACnB,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
|
package/dist/cli.js
CHANGED
|
@@ -3,137 +3,140 @@ import { runScan, scanExitCode } from "./commands/scan.js";
|
|
|
3
3
|
import { runInit } from "./commands/init.js";
|
|
4
4
|
import { Logger } from "./util/log.js";
|
|
5
5
|
import { errorStack } from "@component-compass/ast-utils";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
--capture-values Force capture literal prop values
|
|
19
|
-
--quiet Suppress STDOUT summary
|
|
20
|
-
--json Print JSON to stdout (implies --quiet)
|
|
21
|
-
--repo-id <value> Override repo identifier in the artifact (else env COMPONENT_COMPASS_REPO_ID, git remote, package.json name, or cwd hash)
|
|
22
|
-
--upload Also POST the scan to the configured host
|
|
23
|
-
--host <url> Override host URL (else COMPASS_HOST env, else config.host)
|
|
24
|
-
|
|
25
|
-
Auth:
|
|
26
|
-
auth login [--host URL] Device-flow browser login; stores tokens in ~/.config/compass/hosts.json
|
|
27
|
-
auth logout [--host URL] Remove stored tokens for a host
|
|
28
|
-
auth status [--host URL] Show the signed-in identity
|
|
29
|
-
|
|
30
|
-
Other:
|
|
31
|
-
--help, -h
|
|
32
|
-
--version, -v
|
|
33
|
-
`;
|
|
6
|
+
import { readVersion } from "./util/version.js";
|
|
7
|
+
import { topHelp, commandHelp } from "./cli/help.js";
|
|
8
|
+
import { parseCommand, KNOWN_COMMANDS, unknownCommandMessage, CliError } from "./cli/parse.js";
|
|
9
|
+
import { resolve } from "node:path";
|
|
10
|
+
import { isInteractive } from "./util/interactive.js";
|
|
11
|
+
import { clackAdapter, PromptCancelledError } from "./prompts/adapter.js";
|
|
12
|
+
function isKnownCommand(cmd) {
|
|
13
|
+
return KNOWN_COMMANDS.includes(cmd);
|
|
14
|
+
}
|
|
15
|
+
function wantsHelp(args) {
|
|
16
|
+
return args.includes("--help") || args.includes("-h");
|
|
17
|
+
}
|
|
34
18
|
async function main(argv) {
|
|
35
19
|
const log = new Logger(false);
|
|
36
|
-
if (argv
|
|
37
|
-
process.stdout.write(
|
|
20
|
+
if (argv[0] === undefined) {
|
|
21
|
+
process.stdout.write(topHelp());
|
|
38
22
|
return 0;
|
|
39
23
|
}
|
|
40
|
-
if (argv.includes("--
|
|
41
|
-
process.stdout.write(
|
|
24
|
+
if (argv.includes("--version") || argv.includes("-v")) {
|
|
25
|
+
process.stdout.write(`${readVersion()}\n`);
|
|
42
26
|
return 0;
|
|
43
27
|
}
|
|
44
28
|
const [cmd, ...rest] = argv;
|
|
45
|
-
if (
|
|
46
|
-
process.stdout.write(
|
|
29
|
+
if (cmd === undefined || cmd === "--help" || cmd === "-h") {
|
|
30
|
+
process.stdout.write(topHelp());
|
|
47
31
|
return 0;
|
|
48
32
|
}
|
|
49
|
-
if (cmd
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
scanOpts.outputOverride = flags.output;
|
|
57
|
-
if (flags.captureValues)
|
|
58
|
-
scanOpts.captureValuesOverride = true;
|
|
59
|
-
if (flags.repoId)
|
|
60
|
-
scanOpts.repoId = flags.repoId;
|
|
61
|
-
if (flags.upload)
|
|
62
|
-
scanOpts.upload = true;
|
|
63
|
-
if (flags.host)
|
|
64
|
-
scanOpts.hostOverride = flags.host;
|
|
65
|
-
const result = await runScan(scanOpts);
|
|
66
|
-
return scanExitCode(result);
|
|
33
|
+
if (!isKnownCommand(cmd)) {
|
|
34
|
+
log.error(unknownCommandMessage(cmd));
|
|
35
|
+
return 2;
|
|
36
|
+
}
|
|
37
|
+
if (wantsHelp(rest)) {
|
|
38
|
+
process.stdout.write(commandHelp(cmd));
|
|
39
|
+
return 0;
|
|
67
40
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
41
|
+
try {
|
|
42
|
+
switch (cmd) {
|
|
43
|
+
case "scan":
|
|
44
|
+
return await runScanCommand(rest);
|
|
45
|
+
case "init":
|
|
46
|
+
return await runInitCommand(rest);
|
|
47
|
+
case "auth": {
|
|
48
|
+
const { runAuth } = await import("./commands/auth.js");
|
|
49
|
+
const interactive = isInteractive();
|
|
50
|
+
return await runAuth(rest, { ...(interactive ? { interactive, prompts: clackAdapter } : {}) });
|
|
51
|
+
}
|
|
52
|
+
case "db":
|
|
53
|
+
return await runDbCommand(rest, log);
|
|
72
54
|
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
55
|
+
}
|
|
56
|
+
catch (err) {
|
|
57
|
+
if (err instanceof CliError) {
|
|
58
|
+
log.error(err.message);
|
|
59
|
+
return err.exitCode;
|
|
76
60
|
}
|
|
61
|
+
throw err;
|
|
77
62
|
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
63
|
+
return 2; // isKnownCommand makes the switch exhaustive; satisfies the type checker.
|
|
64
|
+
}
|
|
65
|
+
async function runScanCommand(rest) {
|
|
66
|
+
const { values } = parseCommand("scan", rest);
|
|
67
|
+
const { config, quiet, json, output, "capture-values": captureValues, "repo-id": repoId, upload, host, } = values;
|
|
68
|
+
const scanOpts = {
|
|
69
|
+
configPath: typeof config === "string" ? config : "./component-compass.config.json",
|
|
70
|
+
quiet: Boolean(quiet || json),
|
|
71
|
+
};
|
|
72
|
+
if (typeof output === "string")
|
|
73
|
+
scanOpts.outputOverride = output;
|
|
74
|
+
if (captureValues)
|
|
75
|
+
scanOpts.captureValuesOverride = true;
|
|
76
|
+
if (typeof repoId === "string")
|
|
77
|
+
scanOpts.repoId = repoId;
|
|
78
|
+
if (upload)
|
|
79
|
+
scanOpts.upload = true;
|
|
80
|
+
if (typeof host === "string")
|
|
81
|
+
scanOpts.hostOverride = host;
|
|
82
|
+
return scanExitCode(await runScan(scanOpts));
|
|
83
|
+
}
|
|
84
|
+
async function runInitCommand(rest) {
|
|
85
|
+
const { values } = parseCommand("init", rest);
|
|
86
|
+
const { yes, output, "repo-id": repoId, framework } = values;
|
|
87
|
+
const interactive = isInteractive({ yes: Boolean(yes) });
|
|
88
|
+
const initOpts = { cwd: process.cwd(), interactive };
|
|
89
|
+
if (interactive)
|
|
90
|
+
initOpts.prompts = clackAdapter;
|
|
91
|
+
if (typeof output === "string")
|
|
92
|
+
initOpts.outputPath = resolve(process.cwd(), output);
|
|
93
|
+
if (typeof repoId === "string")
|
|
94
|
+
initOpts.repoId = repoId;
|
|
95
|
+
const frameworks = parseFrameworks(framework);
|
|
96
|
+
if (frameworks)
|
|
97
|
+
initOpts.frameworks = frameworks;
|
|
98
|
+
try {
|
|
99
|
+
await runInit(initOpts);
|
|
100
|
+
return 0;
|
|
81
101
|
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
const { runDbImport } = await import("./commands/db-import.js");
|
|
87
|
-
const dirArg = subRest.find((a) => !a.startsWith("-") && a !== "import");
|
|
88
|
-
const r = await runDbImport({
|
|
89
|
-
...(dirArg !== undefined ? { dir: dirArg } : {}),
|
|
90
|
-
...(flags.host !== undefined ? { hostOverride: flags.host } : {}),
|
|
91
|
-
});
|
|
92
|
-
return r.exitCode;
|
|
102
|
+
catch (err) {
|
|
103
|
+
if (err instanceof PromptCancelledError) {
|
|
104
|
+
process.stderr.write("Cancelled.\n");
|
|
105
|
+
return 130;
|
|
93
106
|
}
|
|
94
|
-
|
|
95
|
-
return
|
|
107
|
+
process.stderr.write(`init failed: ${errorStack(err)}\n`);
|
|
108
|
+
return 1;
|
|
96
109
|
}
|
|
97
|
-
log.error(`Unknown command: ${cmd}\n${HELP}`);
|
|
98
|
-
return 2;
|
|
99
110
|
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
if (
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
}
|
|
111
|
-
else if (a === "--output") {
|
|
112
|
-
const next = args[++i];
|
|
113
|
-
if (next)
|
|
114
|
-
out.output = next;
|
|
115
|
-
}
|
|
116
|
-
else if (a === "--capture-values")
|
|
117
|
-
out.captureValues = true;
|
|
118
|
-
else if (a === "--quiet")
|
|
119
|
-
out.quiet = true;
|
|
120
|
-
else if (a === "--json")
|
|
121
|
-
out.json = true;
|
|
122
|
-
else if (a === "--repo-id") {
|
|
123
|
-
const next = args[++i];
|
|
124
|
-
if (next)
|
|
125
|
-
out.repoId = next;
|
|
126
|
-
}
|
|
127
|
-
else if (a === "--upload")
|
|
128
|
-
out.upload = true;
|
|
129
|
-
else if (a === "--host") {
|
|
130
|
-
const next = args[++i];
|
|
131
|
-
if (next)
|
|
132
|
-
out.host = next;
|
|
133
|
-
}
|
|
111
|
+
const VALID_FRAMEWORKS = ["react", "vue", "lit", "html", "wc"];
|
|
112
|
+
function parseFrameworks(raw) {
|
|
113
|
+
if (!Array.isArray(raw))
|
|
114
|
+
return undefined;
|
|
115
|
+
const out = [];
|
|
116
|
+
for (const r of raw) {
|
|
117
|
+
if (VALID_FRAMEWORKS.includes(r))
|
|
118
|
+
out.push(r);
|
|
119
|
+
else
|
|
120
|
+
throw new CliError(`Unknown --framework '${r}'. Valid: ${VALID_FRAMEWORKS.join(", ")}.`);
|
|
134
121
|
}
|
|
135
122
|
return out;
|
|
136
123
|
}
|
|
124
|
+
async function runDbCommand(rest, log) {
|
|
125
|
+
const sub = rest[0];
|
|
126
|
+
if (sub !== "import") {
|
|
127
|
+
log.error(`Unknown db subcommand: ${sub ?? "(none)"}. Run \`compass db --help\`.`);
|
|
128
|
+
return 2;
|
|
129
|
+
}
|
|
130
|
+
const { values, positionals } = parseCommand("db", rest);
|
|
131
|
+
const dirArg = positionals.find((p) => p !== "import");
|
|
132
|
+
const { host } = values;
|
|
133
|
+
const { runDbImport } = await import("./commands/db-import.js");
|
|
134
|
+
const r = await runDbImport({
|
|
135
|
+
...(dirArg !== undefined ? { dir: dirArg } : {}),
|
|
136
|
+
...(typeof host === "string" ? { hostOverride: host } : {}),
|
|
137
|
+
});
|
|
138
|
+
return r.exitCode;
|
|
139
|
+
}
|
|
137
140
|
main(process.argv.slice(2)).then((code) => process.exit(code), (err) => {
|
|
138
141
|
process.stderr.write(`Unhandled error: ${errorStack(err)}\n`);
|
|
139
142
|
process.exit(1);
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":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,CAAC,GAAG,MAAM,WAAW,CAAC;QAC1B,GAAG,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAChD,GAAG,CAAC,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAC5D,CAAC,CAAC;IACH,OAAO,CAAC,CAAC,QAAQ,CAAC;AACpB,CAAC;AAED,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAC9B,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAC5B,CAAC,GAAG,EAAE,EAAE;IACN,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,oBAAoB,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAC9D,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CACF,CAAC"}
|
package/dist/commands/auth.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type PromptAdapter } from "../prompts/adapter.js";
|
|
1
2
|
type StoreOpt = {
|
|
2
3
|
filePath?: string;
|
|
3
4
|
};
|
|
@@ -6,6 +7,7 @@ export declare function runAuthLogin(opts: {
|
|
|
6
7
|
store?: StoreOpt;
|
|
7
8
|
sleep?: (ms: number) => Promise<void>;
|
|
8
9
|
now?: () => number;
|
|
10
|
+
prompts?: PromptAdapter;
|
|
9
11
|
}): Promise<number>;
|
|
10
12
|
export declare function runAuthStatus(opts: {
|
|
11
13
|
host?: string;
|
|
@@ -19,8 +21,13 @@ export declare function runAuthLogout(opts: {
|
|
|
19
21
|
env?: NodeJS.ProcessEnv;
|
|
20
22
|
write?: (s: string) => void;
|
|
21
23
|
}): Promise<number>;
|
|
22
|
-
|
|
24
|
+
type AuthDeps = {
|
|
23
25
|
env?: NodeJS.ProcessEnv;
|
|
24
26
|
store?: StoreOpt;
|
|
25
|
-
|
|
27
|
+
interactive?: boolean;
|
|
28
|
+
prompts?: PromptAdapter;
|
|
29
|
+
sleep?: (ms: number) => Promise<void>;
|
|
30
|
+
now?: () => number;
|
|
31
|
+
};
|
|
32
|
+
export declare function runAuth(argv: string[], deps?: AuthDeps): Promise<number>;
|
|
26
33
|
export {};
|