@pracht/cli 1.2.0 → 1.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +85 -0
- package/dist/{build-BzQAQjuy.mjs → build-DkP2ffu9.mjs} +11 -1
- package/dist/{build-metadata-IABPFFKk.mjs → build-metadata-BOChHO8g.mjs} +11 -2
- package/dist/{doctor-BcoqyBk-.mjs → doctor-CwQJjJ83.mjs} +1 -1
- package/dist/{generate-BXkePCIx.mjs → generate-C9AMSGsv.mjs} +141 -142
- package/dist/index.mjs +5 -5
- package/dist/{inspect-DIjjCfs3.mjs → inspect-MseHPU9s.mjs} +4 -9
- package/dist/{project-DydjqBoS.mjs → project-BdMiN3s7.mjs} +5 -12
- package/dist/{verification-Dfl3X4Zo.mjs → verification-Dwf1ZuNn.mjs} +116 -108
- package/dist/{verify-CObGxWtW.mjs → verify-o0G5Xuff.mjs} +1 -1
- package/package.json +9 -2
- package/src/build-metadata.ts +0 -86
- package/src/build-shared.ts +0 -179
- package/src/commands/build.ts +0 -132
- package/src/commands/dev.ts +0 -27
- package/src/commands/doctor.ts +0 -33
- package/src/commands/generate.ts +0 -678
- package/src/commands/inspect.ts +0 -214
- package/src/commands/verify.ts +0 -37
- package/src/constants.ts +0 -32
- package/src/index.ts +0 -21
- package/src/manifest.ts +0 -166
- package/src/project.ts +0 -171
- package/src/utils.ts +0 -72
- package/src/verification.ts +0 -710
- package/test/pracht-cli.test.js +0 -633
- package/tsdown.config.ts +0 -8
- /package/dist/{manifest-DGq1n5LT.mjs → manifest-Bs5hp3gA.mjs} +0 -0
package/src/utils.ts
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import { HTTP_METHODS, type HttpMethod } from "./constants.js";
|
|
2
|
-
|
|
3
|
-
export function quote(value: string): string {
|
|
4
|
-
return JSON.stringify(value);
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
export function ensureTrailingNewline(value: string): string {
|
|
8
|
-
return value.endsWith("\n") ? value : `${value}\n`;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export function parseCommaList(value: string | string[] | boolean | undefined): string[] {
|
|
12
|
-
if (!value || typeof value === "boolean") return [];
|
|
13
|
-
const values = Array.isArray(value) ? value : [value];
|
|
14
|
-
return values
|
|
15
|
-
.flatMap((entry) => String(entry).split(","))
|
|
16
|
-
.map((entry) => entry.trim())
|
|
17
|
-
.filter(Boolean);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export function parseApiMethods(value: string | string[] | boolean | undefined): HttpMethod[] {
|
|
21
|
-
const methods = parseCommaList(value);
|
|
22
|
-
const normalized =
|
|
23
|
-
methods.length === 0
|
|
24
|
-
? (["GET"] as HttpMethod[])
|
|
25
|
-
: methods.map((entry) => entry.toUpperCase() as HttpMethod);
|
|
26
|
-
|
|
27
|
-
for (const method of normalized) {
|
|
28
|
-
if (!HTTP_METHODS.has(method)) {
|
|
29
|
-
throw new Error(`Unsupported HTTP method "${method}".`);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
return [...new Set(normalized)];
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export function requireEnum(
|
|
37
|
-
value: string | undefined,
|
|
38
|
-
key: string,
|
|
39
|
-
allowed: string[],
|
|
40
|
-
fallback: string,
|
|
41
|
-
): string {
|
|
42
|
-
const val = value ?? fallback;
|
|
43
|
-
if (!allowed.includes(val)) {
|
|
44
|
-
throw new Error(`Invalid value for --${key}. Expected one of ${allowed.join(", ")}.`);
|
|
45
|
-
}
|
|
46
|
-
return val;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export function requirePositiveInteger(
|
|
50
|
-
value: string | undefined,
|
|
51
|
-
key: string,
|
|
52
|
-
fallback: number,
|
|
53
|
-
): number {
|
|
54
|
-
const parsed = value == null ? fallback : Number.parseInt(value, 10);
|
|
55
|
-
if (!Number.isInteger(parsed) || parsed <= 0) {
|
|
56
|
-
throw new Error(`--${key} must be a positive integer.`);
|
|
57
|
-
}
|
|
58
|
-
return parsed;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
export function handleCliError(error: unknown, { json }: { json: boolean }): never {
|
|
62
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
63
|
-
if (json) {
|
|
64
|
-
console.error(JSON.stringify({ ok: false, error: message }, null, 2));
|
|
65
|
-
} else {
|
|
66
|
-
console.error(message);
|
|
67
|
-
if (error instanceof Error && error.stack && process.env.DEBUG) {
|
|
68
|
-
console.error(error.stack);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
process.exit(1);
|
|
72
|
-
}
|