@devbie/fewbie-cli 1.9.0 → 1.11.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 +20 -2
- package/dist/commands/modules/adapters.d.ts +7 -0
- package/dist/commands/modules/adapters.js +116 -0
- package/dist/commands/modules/adapters.js.map +1 -0
- package/dist/lib/i18n-contract.d.ts +28 -0
- package/dist/lib/i18n-contract.js +236 -0
- package/dist/lib/i18n-contract.js.map +1 -0
- package/dist/lib/template-ownership.js +2 -0
- package/dist/lib/template-ownership.js.map +1 -1
- package/dist/program.js +15 -0
- package/dist/program.js.map +1 -1
- package/dist/registry/forgot-password/contract.json +49 -0
- package/dist/registry/forgot-password/item.json +74 -0
- package/dist/registry/login-page/contract.json +50 -0
- package/dist/registry/login-page/item.json +75 -0
- package/dist/registry/preferences-settings/contract.json +37 -0
- package/dist/registry/preferences-settings/item.json +62 -0
- package/dist/registry/profile-settings/contract.json +30 -0
- package/dist/registry/profile-settings/item.json +55 -0
- package/dist/registry/security-settings/contract.json +52 -0
- package/dist/registry/security-settings/item.json +77 -0
- package/dist/registry/source.d.ts +2 -0
- package/dist/registry/source.js +22 -6
- package/dist/registry/source.js.map +1 -1
- package/package.json +3 -1
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/r/registry-item.json",
|
|
3
|
+
"name": "security-settings",
|
|
4
|
+
"type": "registry:block",
|
|
5
|
+
"title": "Security settings cards",
|
|
6
|
+
"description": "Account security cards: active sessions with per-row sign-out, and authenticator-app enrollment with a QR code and enable/disable flows. Transport and cache invalidation stay in the host.",
|
|
7
|
+
"postInstall": "Render <SecuritySettings labels={...} twoFactorEnabled={...} port={...} /> inside your settings shell. The host supplies translated labels, a sessions/two-factor port and an optional formatDateTime; onSessionsChanged/onTwoFactorChanged let it refresh its cache. Requires the shadcn ui primitives badge, button, card, input and label.",
|
|
8
|
+
"x-fewbie.contract": {
|
|
9
|
+
"version": "1.0.0",
|
|
10
|
+
"framework": "^1.7.0",
|
|
11
|
+
"entry": "src/modules/security-settings/index.ts",
|
|
12
|
+
"labels": [
|
|
13
|
+
"activeSessions",
|
|
14
|
+
"loadingSessions",
|
|
15
|
+
"loadSessionsFailed",
|
|
16
|
+
"noSessions",
|
|
17
|
+
"unknownDevice",
|
|
18
|
+
"thisDevice",
|
|
19
|
+
"signOutSession",
|
|
20
|
+
"twoFactorTitle",
|
|
21
|
+
"statusEnabled",
|
|
22
|
+
"statusDisabled",
|
|
23
|
+
"twoFactorDesc",
|
|
24
|
+
"qrAlt",
|
|
25
|
+
"scanQr",
|
|
26
|
+
"enterCode",
|
|
27
|
+
"confirmEnable",
|
|
28
|
+
"currentPassword",
|
|
29
|
+
"passwordPlaceholder",
|
|
30
|
+
"or",
|
|
31
|
+
"authenticatorCode",
|
|
32
|
+
"disable",
|
|
33
|
+
"disableTwoFactor",
|
|
34
|
+
"setupWithApp",
|
|
35
|
+
"cancel",
|
|
36
|
+
"retry",
|
|
37
|
+
"actionFailed"
|
|
38
|
+
],
|
|
39
|
+
"ports": [
|
|
40
|
+
"listSessions",
|
|
41
|
+
"revokeSession",
|
|
42
|
+
"setupTwoFactor",
|
|
43
|
+
"enableTwoFactor",
|
|
44
|
+
"disableTwoFactor"
|
|
45
|
+
],
|
|
46
|
+
"ui": [
|
|
47
|
+
"badge",
|
|
48
|
+
"button",
|
|
49
|
+
"card",
|
|
50
|
+
"input",
|
|
51
|
+
"label"
|
|
52
|
+
],
|
|
53
|
+
"states": [
|
|
54
|
+
"loading",
|
|
55
|
+
"error",
|
|
56
|
+
"empty",
|
|
57
|
+
"ready"
|
|
58
|
+
]
|
|
59
|
+
},
|
|
60
|
+
"files": [
|
|
61
|
+
{
|
|
62
|
+
"path": "src/modules/security-settings/index.ts",
|
|
63
|
+
"content": "export { SecuritySettings } from \"./security-settings\";\nexport type {\n SecuritySession,\n SecuritySettingsLabels,\n SecuritySettingsPort,\n SecuritySettingsProps,\n SecurityTwoFactorSetup,\n} from \"./types\";\n",
|
|
64
|
+
"type": "registry:block"
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
"path": "src/modules/security-settings/types.ts",
|
|
68
|
+
"content": "/**\n * Every string the cards render. The host supplies translated copy.\n */\nexport interface SecuritySettingsLabels {\n activeSessions: string;\n loadingSessions: string;\n loadSessionsFailed: string;\n noSessions: string;\n unknownDevice: string;\n thisDevice: string;\n signOutSession: string;\n twoFactorTitle: string;\n statusEnabled: string;\n statusDisabled: string;\n twoFactorDesc: string;\n qrAlt: string;\n scanQr: string;\n enterCode: string;\n confirmEnable: string;\n currentPassword: string;\n passwordPlaceholder: string;\n or: string;\n authenticatorCode: string;\n disable: string;\n disableTwoFactor: string;\n setupWithApp: string;\n cancel: string;\n retry: string;\n actionFailed: string;\n}\n\n/** One active session row, trimmed to what the card displays. */\nexport interface SecuritySession {\n id: number;\n browser?: string;\n operatingSystem?: string;\n isCurrentSession?: boolean;\n ipAddress?: string;\n city?: string;\n region?: string;\n countryCode?: string;\n createdAt: string;\n}\n\nexport interface SecurityTwoFactorSetup {\n qrCodeDataUrl: string;\n secret: string;\n}\n\n/**\n * Host-owned transport. The module never calls fetch or a query library: the\n * host decides how to reach its backend and what to do after each mutation.\n */\nexport interface SecuritySettingsPort {\n listSessions(): Promise<{ records: SecuritySession[] }>;\n revokeSession(id: number): Promise<void>;\n setupTwoFactor(): Promise<SecurityTwoFactorSetup>;\n enableTwoFactor(code: string): Promise<void>;\n disableTwoFactor(input: { password?: string; code?: string }): Promise<void>;\n}\n\nexport interface SecuritySettingsProps {\n labels: SecuritySettingsLabels;\n /** True when the account already has an authenticator app enrolled. */\n twoFactorEnabled: boolean;\n /**\n * Formats a session timestamp for display. The host owns locale formatting;\n * the module falls back to `toLocaleString` when omitted.\n */\n formatDateTime?: (iso: string) => string;\n port: SecuritySettingsPort;\n /** Called after a session was revoked so the host can refresh its cache. */\n onSessionsChanged?: () => void;\n /** Called after two-factor was enabled or disabled so the host can refresh. */\n onTwoFactorChanged?: () => void;\n}\n",
|
|
69
|
+
"type": "registry:block"
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
"path": "src/modules/security-settings/security-settings.tsx",
|
|
73
|
+
"content": "\"use client\";\n\nimport { useCallback, useEffect, useRef, useState } from \"react\";\n\nimport { Badge } from \"@/components/ui/badge\";\nimport { Button } from \"@/components/ui/button\";\nimport { Card, CardContent, CardHeader, CardTitle } from \"@/components/ui/card\";\nimport { Input } from \"@/components/ui/input\";\nimport { Label } from \"@/components/ui/label\";\nimport type { SecuritySession, SecuritySettingsProps, SecurityTwoFactorSetup } from \"./types\";\n\nconst CODE_LENGTH = 6;\n\nfunction Spinner() {\n return (\n <span\n aria-hidden=\"true\"\n className=\"h-4 w-4 animate-spin rounded-full border-2 border-current border-t-transparent\"\n />\n );\n}\n\nfunction MonitorIcon() {\n return (\n <svg\n aria-hidden=\"true\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n className=\"h-4 w-4\"\n >\n <rect x=\"2\" y=\"3\" width=\"20\" height=\"14\" rx=\"2\" />\n <path d=\"M8 21h8M12 17v4\" />\n </svg>\n );\n}\n\nfunction ShieldCheckIcon() {\n return (\n <svg\n aria-hidden=\"true\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n className=\"h-4 w-4 text-green-600\"\n >\n <path d=\"M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10Z\" />\n <path d=\"m9 12 2 2 4-4\" />\n </svg>\n );\n}\n\nfunction ShieldOffIcon() {\n return (\n <svg\n aria-hidden=\"true\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n className=\"h-4 w-4\"\n >\n <path d=\"M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10Z\" />\n <path d=\"m4 4 16 16\" />\n </svg>\n );\n}\n\nfunction TrashIcon() {\n return (\n <svg\n aria-hidden=\"true\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n className=\"h-4 w-4\"\n >\n <path d=\"M3 6h18M8 6V4h8v2M19 6l-1 14H6L5 6M10 11v5M14 11v5\" />\n </svg>\n );\n}\n\n/** Format the location parts carried on a session row. */\nfunction formatLocation(session: SecuritySession): string {\n return [session.city, session.region, session.countryCode].filter(Boolean).join(\", \");\n}\n\n/**\n * Account security cards: active sessions with per-row sign-out, and\n * authenticator-app enrollment. The host owns transport, cache invalidation\n * and toasts; the module only renders and reports through callbacks.\n */\nexport function SecuritySettings({\n labels,\n twoFactorEnabled,\n formatDateTime,\n port,\n onSessionsChanged,\n onTwoFactorChanged,\n}: SecuritySettingsProps) {\n // Keep the port reachable from the mount effect without re-running it when\n // the host re-creates its callback objects on every render.\n const portRef = useRef(port);\n useEffect(() => {\n portRef.current = port;\n }, [port]);\n\n const [sessions, setSessions] = useState<SecuritySession[] | null>(null);\n const [sessionsPending, setSessionsPending] = useState(true);\n const [sessionsFailed, setSessionsFailed] = useState(false);\n const [revokingId, setRevokingId] = useState<number | null>(null);\n const [actionError, setActionError] = useState<string | null>(null);\n\n const [setupData, setSetupData] = useState<SecurityTwoFactorSetup | null>(null);\n const [setupPending, setSetupPending] = useState(false);\n const [enableCode, setEnableCode] = useState(\"\");\n const [enablePending, setEnablePending] = useState(false);\n const [disableMode, setDisableMode] = useState(false);\n const [disablePassword, setDisablePassword] = useState(\"\");\n const [disableCode, setDisableCode] = useState(\"\");\n const [disablePending, setDisablePending] = useState(false);\n\n const loadSessions = useCallback(async (): Promise<void> => {\n try {\n const result = await portRef.current.listSessions();\n setSessions(result.records);\n setSessionsFailed(false);\n } catch {\n setSessionsFailed(true);\n } finally {\n setSessionsPending(false);\n }\n }, []);\n\n useEffect(() => {\n void loadSessions();\n }, [loadSessions]);\n\n function retrySessions(): void {\n setSessionsPending(true);\n setSessionsFailed(false);\n void loadSessions();\n }\n\n const formatDate = formatDateTime ?? ((iso: string) => new Date(iso).toLocaleString());\n\n async function handleRevoke(id: number): Promise<void> {\n if (revokingId !== null) return;\n setRevokingId(id);\n setActionError(null);\n try {\n await port.revokeSession(id);\n onSessionsChanged?.();\n await loadSessions();\n } catch {\n setActionError(labels.actionFailed);\n } finally {\n setRevokingId(null);\n }\n }\n\n async function handleSetup(): Promise<void> {\n if (setupPending) return;\n setSetupPending(true);\n setActionError(null);\n try {\n setSetupData(await port.setupTwoFactor());\n } catch {\n setActionError(labels.actionFailed);\n } finally {\n setSetupPending(false);\n }\n }\n\n async function handleEnable(): Promise<void> {\n if (enablePending) return;\n setEnablePending(true);\n setActionError(null);\n try {\n await port.enableTwoFactor(enableCode);\n setSetupData(null);\n setEnableCode(\"\");\n onTwoFactorChanged?.();\n } catch {\n setActionError(labels.actionFailed);\n } finally {\n setEnablePending(false);\n }\n }\n\n async function handleDisable(): Promise<void> {\n if (disablePending) return;\n setDisablePending(true);\n setActionError(null);\n try {\n await port.disableTwoFactor(disablePassword ? { password: disablePassword } : { code: disableCode });\n setDisableMode(false);\n setDisablePassword(\"\");\n setDisableCode(\"\");\n onTwoFactorChanged?.();\n } catch {\n setActionError(labels.actionFailed);\n } finally {\n setDisablePending(false);\n }\n }\n\n return (\n <div className=\"grid max-w-3xl gap-6\">\n <Card>\n <CardHeader>\n <CardTitle className=\"flex items-center gap-2 text-base\">\n <MonitorIcon />\n {labels.activeSessions}\n </CardTitle>\n </CardHeader>\n <CardContent>\n {sessionsPending ? (\n <div className=\"flex items-center gap-2 text-sm text-muted-foreground\">\n <Spinner />\n {labels.loadingSessions}\n </div>\n ) : sessionsFailed ? (\n <div className=\"flex flex-wrap items-center gap-2 text-sm text-destructive\">\n {labels.loadSessionsFailed}\n <Button type=\"button\" variant=\"link\" size=\"sm\" className=\"h-auto p-0\" onClick={retrySessions}>\n {labels.retry}\n </Button>\n </div>\n ) : !sessions?.length ? (\n <p className=\"text-sm text-muted-foreground\">{labels.noSessions}</p>\n ) : (\n <ul className=\"divide-y\">\n {sessions.map((session) => (\n <li key={session.id} className=\"flex items-center justify-between gap-4 py-3 first:pt-0 last:pb-0\">\n <div className=\"min-w-0\">\n <div className=\"flex items-center gap-2\">\n <p className=\"truncate text-sm font-medium\">\n {[session.browser, session.operatingSystem].filter(Boolean).join(\" · \") || labels.unknownDevice}\n </p>\n {session.isCurrentSession && (\n <Badge variant=\"outline\" className=\"border-green-200 bg-green-50 text-green-700\">\n {labels.thisDevice}\n </Badge>\n )}\n </div>\n <p className=\"mt-0.5 truncate text-xs text-muted-foreground\">\n {[session.ipAddress, formatLocation(session)].filter(Boolean).join(\" · \")} ·{\" \"}\n {formatDate(session.createdAt)}\n </p>\n </div>\n {!session.isCurrentSession && (\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"icon\"\n aria-label={labels.signOutSession}\n disabled={revokingId !== null}\n onClick={() => void handleRevoke(session.id)}\n >\n {revokingId === session.id ? <Spinner /> : <TrashIcon />}\n </Button>\n )}\n </li>\n ))}\n </ul>\n )}\n </CardContent>\n </Card>\n\n <Card>\n <CardHeader>\n <CardTitle className=\"flex items-center justify-between gap-2 text-base\">\n <span className=\"flex items-center gap-2\">\n {twoFactorEnabled ? <ShieldCheckIcon /> : <ShieldOffIcon />}\n {labels.twoFactorTitle}\n </span>\n <Badge variant={twoFactorEnabled ? \"default\" : \"outline\"}>\n {twoFactorEnabled ? labels.statusEnabled : labels.statusDisabled}\n </Badge>\n </CardTitle>\n </CardHeader>\n <CardContent className=\"space-y-4\">\n <p className=\"text-sm text-muted-foreground\">{labels.twoFactorDesc}</p>\n\n {/* Enrollment flow: QR code plus code confirmation */}\n {setupData && (\n <div className=\"space-y-4 rounded-md border bg-muted/30 p-4\">\n <div className=\"flex flex-col items-center gap-3 sm:flex-row sm:items-start\">\n {/* eslint-disable-next-line @next/next/no-img-element */}\n <img\n src={setupData.qrCodeDataUrl}\n alt={labels.qrAlt}\n className=\"h-40 w-40 rounded-md border bg-white p-2\"\n />\n <div className=\"min-w-0 space-y-2\">\n <p className=\"text-xs text-muted-foreground\">{labels.scanQr}</p>\n <p className=\"break-all rounded bg-background p-2 font-mono text-xs\">{setupData.secret}</p>\n </div>\n </div>\n <div className=\"space-y-2\">\n <Label htmlFor=\"security-settings-enable-code\">{labels.enterCode}</Label>\n <Input\n id=\"security-settings-enable-code\"\n inputMode=\"numeric\"\n autoComplete=\"one-time-code\"\n value={enableCode}\n onChange={(event) => setEnableCode(event.target.value.replace(/\\D/g, \"\").slice(0, CODE_LENGTH))}\n placeholder=\"123456\"\n />\n </div>\n <div className=\"flex justify-end gap-2\">\n <Button\n type=\"button\"\n variant=\"outline\"\n onClick={() => {\n setSetupData(null);\n setEnableCode(\"\");\n }}\n disabled={enablePending}\n >\n {labels.cancel}\n </Button>\n <Button\n type=\"button\"\n onClick={() => void handleEnable()}\n disabled={enablePending || enableCode.length !== CODE_LENGTH}\n >\n {enablePending ? <Spinner /> : labels.confirmEnable}\n </Button>\n </div>\n </div>\n )}\n\n {/* Disable flow: prove identity with password or a current code */}\n {disableMode && (\n <div className=\"space-y-4 rounded-md border bg-muted/30 p-4\">\n <div className=\"space-y-2\">\n <Label htmlFor=\"security-settings-disable-password\">{labels.currentPassword}</Label>\n <Input\n id=\"security-settings-disable-password\"\n type=\"password\"\n autoComplete=\"current-password\"\n value={disablePassword}\n onChange={(event) => {\n setDisablePassword(event.target.value);\n setDisableCode(\"\");\n }}\n placeholder={labels.passwordPlaceholder}\n />\n </div>\n <p className=\"text-center text-xs text-muted-foreground\">{labels.or}</p>\n <div className=\"space-y-2\">\n <Label htmlFor=\"security-settings-disable-code\">{labels.authenticatorCode}</Label>\n <Input\n id=\"security-settings-disable-code\"\n inputMode=\"numeric\"\n autoComplete=\"one-time-code\"\n value={disableCode}\n onChange={(event) => {\n setDisableCode(event.target.value.replace(/\\D/g, \"\").slice(0, CODE_LENGTH));\n setDisablePassword(\"\");\n }}\n placeholder=\"123456\"\n />\n </div>\n <div className=\"flex justify-end gap-2\">\n <Button\n type=\"button\"\n variant=\"outline\"\n onClick={() => {\n setDisableMode(false);\n setDisablePassword(\"\");\n setDisableCode(\"\");\n }}\n disabled={disablePending}\n >\n {labels.cancel}\n </Button>\n <Button\n type=\"button\"\n variant=\"destructive\"\n onClick={() => void handleDisable()}\n disabled={disablePending || (!disablePassword && disableCode.length !== CODE_LENGTH)}\n >\n {disablePending ? <Spinner /> : labels.disable}\n </Button>\n </div>\n </div>\n )}\n\n {actionError && <p className=\"text-sm text-destructive\">{actionError}</p>}\n\n {/* Idle actions */}\n {!setupData && !disableMode && (\n <div>\n {twoFactorEnabled ? (\n <Button type=\"button\" variant=\"outline\" onClick={() => setDisableMode(true)}>\n {labels.disableTwoFactor}\n </Button>\n ) : (\n <Button type=\"button\" onClick={() => void handleSetup()} disabled={setupPending}>\n {setupPending ? <Spinner /> : labels.setupWithApp}\n </Button>\n )}\n </div>\n )}\n </CardContent>\n </Card>\n </div>\n );\n}\n",
|
|
74
|
+
"type": "registry:block"
|
|
75
|
+
}
|
|
76
|
+
]
|
|
77
|
+
}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
export declare const REGISTRY_ITEMS_DIR = "packages/modules";
|
|
1
2
|
export declare function isRegistryRoot(candidate: string): Promise<boolean>;
|
|
3
|
+
export declare function locateItemsDir(checkout: string): Promise<string | null>;
|
|
2
4
|
export declare function resolveRegistryRoot(projectRoot?: string): Promise<string>;
|
|
3
5
|
export interface RegistryContext {
|
|
4
6
|
root: string;
|
package/dist/registry/source.js
CHANGED
|
@@ -3,7 +3,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.REGISTRY_ITEMS_DIR = void 0;
|
|
6
7
|
exports.isRegistryRoot = isRegistryRoot;
|
|
8
|
+
exports.locateItemsDir = locateItemsDir;
|
|
7
9
|
exports.resolveRegistryRoot = resolveRegistryRoot;
|
|
8
10
|
exports.resolveRegistryContext = resolveRegistryContext;
|
|
9
11
|
const node_crypto_1 = __importDefault(require("node:crypto"));
|
|
@@ -15,6 +17,7 @@ const modules_file_1 = require("../lib/modules-file");
|
|
|
15
17
|
const git_commit_1 = require("../lib/git-commit");
|
|
16
18
|
const REGISTRY_PATH_ENV = "FEWBIE_REGISTRY_PATH";
|
|
17
19
|
const REGISTRY_CACHE_ENV = "FEWBIE_REGISTRY_CACHE_DIR";
|
|
20
|
+
exports.REGISTRY_ITEMS_DIR = "packages/modules";
|
|
18
21
|
async function isRegistryRoot(candidate) {
|
|
19
22
|
let entries;
|
|
20
23
|
try {
|
|
@@ -35,6 +38,17 @@ async function isRegistryRoot(candidate) {
|
|
|
35
38
|
}
|
|
36
39
|
return false;
|
|
37
40
|
}
|
|
41
|
+
async function locateItemsDir(checkout) {
|
|
42
|
+
const container = node_path_1.default.join(checkout, exports.REGISTRY_ITEMS_DIR);
|
|
43
|
+
if (await isRegistryRoot(container))
|
|
44
|
+
return container;
|
|
45
|
+
if (await isRegistryRoot(checkout))
|
|
46
|
+
return checkout;
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
function expectedRegistryShape() {
|
|
50
|
+
return `${node_path_1.default.join(exports.REGISTRY_ITEMS_DIR, "<item>", "item.json")} or <item>/item.json`;
|
|
51
|
+
}
|
|
38
52
|
function assertSafeRef(ref) {
|
|
39
53
|
if (ref.startsWith("-") || /\s/.test(ref)) {
|
|
40
54
|
throw new cli_kit_1.CliError(`Invalid registry ref '${ref}': pass a branch, tag or commit without whitespace.`);
|
|
@@ -63,19 +77,21 @@ async function syncGitRegistry(url, ref) {
|
|
|
63
77
|
catch (error) {
|
|
64
78
|
throw new cli_kit_1.CliError(`Failed to fetch registry ${url}${ref ? `#${ref}` : ""}: ${error.message}`);
|
|
65
79
|
}
|
|
66
|
-
|
|
67
|
-
|
|
80
|
+
const itemsDir = await locateItemsDir(cacheDir);
|
|
81
|
+
if (itemsDir === null) {
|
|
82
|
+
throw new cli_kit_1.CliError(`Registry ${url}${ref ? `#${ref}` : ""} has no items (expected ${expectedRegistryShape()}).`);
|
|
68
83
|
}
|
|
69
|
-
return
|
|
84
|
+
return itemsDir;
|
|
70
85
|
}
|
|
71
86
|
async function resolveRegistryRoot(projectRoot) {
|
|
72
87
|
const override = process.env[REGISTRY_PATH_ENV];
|
|
73
88
|
if (override) {
|
|
74
89
|
const candidate = node_path_1.default.resolve(override);
|
|
75
|
-
|
|
76
|
-
|
|
90
|
+
const itemsDir = await locateItemsDir(candidate);
|
|
91
|
+
if (itemsDir === null) {
|
|
92
|
+
throw new cli_kit_1.CliError(`${REGISTRY_PATH_ENV} '${candidate}' is not a registry root (no ${expectedRegistryShape()}).`);
|
|
77
93
|
}
|
|
78
|
-
return
|
|
94
|
+
return itemsDir;
|
|
79
95
|
}
|
|
80
96
|
if (projectRoot) {
|
|
81
97
|
const declaration = await (0, modules_file_1.readRegistryDeclaration)(projectRoot);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"source.js","sourceRoot":"","sources":["../../src/registry/source.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"source.js","sourceRoot":"","sources":["../../src/registry/source.ts"],"names":[],"mappings":";;;;;;AAuBA,wCAgBC;AAOD,wCAKC;AA8DD,kDA0BC;AAUD,wDAGC;AAxJD,8DAAiC;AACjC,gEAAkC;AAClC,sDAAyB;AACzB,0DAA6B;AAE7B,6CAAoE;AACpE,sDAA8D;AAC9D,kDAAmD;AAGnD,MAAM,iBAAiB,GAAG,sBAAsB,CAAC;AAEjD,MAAM,kBAAkB,GAAG,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ontend framework CLI",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "worldzhy",
|
|
@@ -25,6 +25,8 @@
|
|
|
25
25
|
"check:template-drift": "node --import tsx scripts/check-template-drift.ts",
|
|
26
26
|
"check:template-deps": "node --import tsx scripts/check-template-deps.ts",
|
|
27
27
|
"check:registry-dist": "node --import tsx scripts/check-registry-dist.ts",
|
|
28
|
+
"registry:sync": "node --import tsx scripts/sync-registry-snapshot.ts",
|
|
29
|
+
"check:registry-snapshot": "node --import tsx scripts/check-registry-snapshot.ts",
|
|
28
30
|
"prepublishOnly": "npm run build"
|
|
29
31
|
},
|
|
30
32
|
"dependencies": {
|