@specdest/devkit 0.4.19 → 0.4.20
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 +105 -28
- package/dist/npm/cli.js +16 -26
- package/dist/npm/index.js +4 -1
- package/dist/npm/native/specdest-darwin-arm64 +0 -0
- package/dist/npm/native/specdest-darwin-x64 +0 -0
- package/dist/npm/native/specdest-linux-arm64 +0 -0
- package/dist/npm/native/specdest-linux-x64 +0 -0
- package/package.json +8 -5
- package/dist/npm/automation-policy.d.ts +0 -2
- package/dist/npm/automation-policy.js +0 -30
- package/dist/npm/canonical-project-operations.d.ts +0 -5
- package/dist/npm/canonical-project-operations.js +0 -5
- package/dist/npm/canonical-project.d.ts +0 -21
- package/dist/npm/canonical-project.js +0 -115
- package/dist/npm/catalog-snapshot.d.ts +0 -53
- package/dist/npm/catalog-snapshot.js +0 -35
- package/dist/npm/client-only-boundary.d.ts +0 -1
- package/dist/npm/client-only-boundary.js +0 -29
- package/dist/npm/commands.d.ts +0 -16
- package/dist/npm/commands.js +0 -194
- package/dist/npm/git-catalog.d.ts +0 -40
- package/dist/npm/git-catalog.js +0 -222
- package/dist/npm/github-doppler-secrets.d.ts +0 -8
- package/dist/npm/github-doppler-secrets.js +0 -156
- package/dist/npm/host-automation.d.ts +0 -9
- package/dist/npm/host-automation.js +0 -87
- package/dist/npm/installer-primitives.d.ts +0 -3
- package/dist/npm/installer-primitives.js +0 -50
- package/dist/npm/predefined-packages/abac.d.ts +0 -2
- package/dist/npm/predefined-packages/abac.js +0 -45
- package/dist/npm/predefined-packages/admin-ui-templates/AdminAccessAssignments.tsx.template +0 -67
- package/dist/npm/predefined-packages/admin-ui-templates/AdminConfirmDialog.tsx.template +0 -46
- package/dist/npm/predefined-packages/admin-ui-templates/AdminDataTable.tsx.template +0 -49
- package/dist/npm/predefined-packages/admin-ui-templates/AdminDetailLayout.tsx.template +0 -15
- package/dist/npm/predefined-packages/admin-ui-templates/AdminEmptyState.tsx.template +0 -17
- package/dist/npm/predefined-packages/admin-ui-templates/AdminFilterBar.tsx.template +0 -16
- package/dist/npm/predefined-packages/admin-ui-templates/AdminFormLayout.tsx.template +0 -19
- package/dist/npm/predefined-packages/admin-ui-templates/AdminMembershipManager.tsx.template +0 -56
- package/dist/npm/predefined-packages/admin-ui-templates/AdminPage.tsx.template +0 -19
- package/dist/npm/predefined-packages/admin-ui-templates/AdminPageHeader.tsx.template +0 -19
- package/dist/npm/predefined-packages/admin-ui-templates/AdminPagination.tsx.template +0 -20
- package/dist/npm/predefined-packages/admin-ui-templates/AdminPermissionMatrix.tsx.template +0 -54
- package/dist/npm/predefined-packages/admin-ui-templates/AdminRoleManager.tsx.template +0 -81
- package/dist/npm/predefined-packages/admin-ui-templates/AdminShell.tsx.template +0 -20
- package/dist/npm/predefined-packages/admin-ui-templates/AdminSidebar.tsx.template +0 -18
- package/dist/npm/predefined-packages/admin-ui-templates/AdminStatCard.tsx.template +0 -22
- package/dist/npm/predefined-packages/admin-ui.d.ts +0 -2
- package/dist/npm/predefined-packages/admin-ui.js +0 -83
- package/dist/npm/predefined-packages/auth-templates/README.md.template +0 -9
- package/dist/npm/predefined-packages/auth-templates/convex.ts.template +0 -18
- package/dist/npm/predefined-packages/auth-templates/identity.ts.template +0 -2
- package/dist/npm/predefined-packages/auth-templates/supabase.ts.template +0 -36
- package/dist/npm/predefined-packages/auth.d.ts +0 -2
- package/dist/npm/predefined-packages/auth.js +0 -36
- package/dist/npm/predefined-packages/convex.d.ts +0 -2
- package/dist/npm/predefined-packages/convex.js +0 -53
- package/dist/npm/predefined-packages/expo.d.ts +0 -2
- package/dist/npm/predefined-packages/expo.js +0 -88
- package/dist/npm/predefined-packages/firebase-hosting.d.ts +0 -2
- package/dist/npm/predefined-packages/firebase-hosting.js +0 -24
- package/dist/npm/predefined-packages/health.d.ts +0 -10
- package/dist/npm/predefined-packages/health.js +0 -52
- package/dist/npm/predefined-packages/husky.d.ts +0 -2
- package/dist/npm/predefined-packages/husky.js +0 -57
- package/dist/npm/predefined-packages/index.d.ts +0 -12
- package/dist/npm/predefined-packages/index.js +0 -97
- package/dist/npm/predefined-packages/install.d.ts +0 -19
- package/dist/npm/predefined-packages/install.js +0 -86
- package/dist/npm/predefined-packages/local-logging.d.ts +0 -2
- package/dist/npm/predefined-packages/local-logging.js +0 -17
- package/dist/npm/predefined-packages/logging.d.ts +0 -2
- package/dist/npm/predefined-packages/logging.js +0 -21
- package/dist/npm/predefined-packages/multi-tenancy.d.ts +0 -2
- package/dist/npm/predefined-packages/multi-tenancy.js +0 -37
- package/dist/npm/predefined-packages/nps.d.ts +0 -2
- package/dist/npm/predefined-packages/nps.js +0 -32
- package/dist/npm/predefined-packages/oxfmt.d.ts +0 -2
- package/dist/npm/predefined-packages/oxfmt.js +0 -22
- package/dist/npm/predefined-packages/oxlint.d.ts +0 -2
- package/dist/npm/predefined-packages/oxlint.js +0 -35
- package/dist/npm/predefined-packages/package-json.d.ts +0 -3
- package/dist/npm/predefined-packages/package-json.js +0 -61
- package/dist/npm/predefined-packages/payments.d.ts +0 -2
- package/dist/npm/predefined-packages/payments.js +0 -31
- package/dist/npm/predefined-packages/playwright.d.ts +0 -2
- package/dist/npm/predefined-packages/playwright.js +0 -35
- package/dist/npm/predefined-packages/project-signals.d.ts +0 -4
- package/dist/npm/predefined-packages/project-signals.js +0 -39
- package/dist/npm/predefined-packages/registry.d.ts +0 -3
- package/dist/npm/predefined-packages/registry.js +0 -65
- package/dist/npm/predefined-packages/resolver.d.ts +0 -8
- package/dist/npm/predefined-packages/resolver.js +0 -35
- package/dist/npm/predefined-packages/security-templates/README.md.template +0 -15
- package/dist/npm/predefined-packages/security-templates/convex-authorization.ts.template +0 -109
- package/dist/npm/predefined-packages/security-templates/permissions.ts.template +0 -40
- package/dist/npm/predefined-packages/security-templates/supabase-admin-rpc.sql.template +0 -54
- package/dist/npm/predefined-packages/security-templates/supabase-authorization.sql.template +0 -138
- package/dist/npm/predefined-packages/security-templates/supabase-posts-example.sql.template +0 -39
- package/dist/npm/predefined-packages/sentry.d.ts +0 -2
- package/dist/npm/predefined-packages/sentry.js +0 -29
- package/dist/npm/predefined-packages/shadcn.d.ts +0 -2
- package/dist/npm/predefined-packages/shadcn.js +0 -23
- package/dist/npm/predefined-packages/storybook.d.ts +0 -2
- package/dist/npm/predefined-packages/storybook.js +0 -25
- package/dist/npm/predefined-packages/stryker.d.ts +0 -2
- package/dist/npm/predefined-packages/stryker.js +0 -48
- package/dist/npm/predefined-packages/supabase.d.ts +0 -2
- package/dist/npm/predefined-packages/supabase.js +0 -355
- package/dist/npm/predefined-packages/tailwind.d.ts +0 -2
- package/dist/npm/predefined-packages/tailwind.js +0 -18
- package/dist/npm/predefined-packages/tanstack-form.d.ts +0 -2
- package/dist/npm/predefined-packages/tanstack-form.js +0 -19
- package/dist/npm/predefined-packages/tanstack-query.d.ts +0 -2
- package/dist/npm/predefined-packages/tanstack-query.js +0 -15
- package/dist/npm/predefined-packages/tanstack-router.d.ts +0 -2
- package/dist/npm/predefined-packages/tanstack-router.js +0 -18
- package/dist/npm/predefined-packages/tenant-templates/README.md.template +0 -11
- package/dist/npm/predefined-packages/tenant-templates/tenant-context.ts.template +0 -22
- package/dist/npm/predefined-packages/types.d.ts +0 -38
- package/dist/npm/predefined-packages/types.js +0 -1
- package/dist/npm/predefined-packages/vite.d.ts +0 -2
- package/dist/npm/predefined-packages/vite.js +0 -127
- package/dist/npm/predefined-packages/vitest.d.ts +0 -2
- package/dist/npm/predefined-packages/vitest.js +0 -20
- package/dist/npm/predefined-packages/zod.d.ts +0 -2
- package/dist/npm/predefined-packages/zod.js +0 -18
- package/dist/npm/project-check.d.ts +0 -37
- package/dist/npm/project-check.js +0 -231
- package/dist/npm/project-context.d.ts +0 -52
- package/dist/npm/project-context.js +0 -211
- package/dist/npm/project-install-guard.d.ts +0 -2
- package/dist/npm/project-install-guard.js +0 -51
- package/dist/npm/project-rules.d.ts +0 -25
- package/dist/npm/project-rules.js +0 -106
- package/dist/npm/project-runtime.d.ts +0 -21
- package/dist/npm/project-runtime.js +0 -41
- package/dist/npm/project-status.d.ts +0 -32
- package/dist/npm/project-status.js +0 -70
- package/dist/npm/project-sync.d.ts +0 -7
- package/dist/npm/project-sync.js +0 -143
- package/dist/npm/remote-installer.d.ts +0 -35
- package/dist/npm/remote-installer.js +0 -351
- package/dist/npm/rule-id-migrations.d.ts +0 -6
- package/dist/npm/rule-id-migrations.js +0 -19
- package/dist/npm/slack.d.ts +0 -16
- package/dist/npm/slack.js +0 -135
- package/dist/npm/snapshot/config.d.ts +0 -10
- package/dist/npm/snapshot/config.js +0 -24
- package/dist/npm/snapshot/policy.d.ts +0 -1
- package/dist/npm/snapshot/policy.js +0 -64
- package/dist/npm/snapshot/restore.d.ts +0 -10
- package/dist/npm/snapshot/restore.js +0 -19
- package/dist/npm/snapshot/sql.d.ts +0 -2
- package/dist/npm/snapshot/sql.js +0 -113
- package/dist/npm/snapshot/storage.d.ts +0 -8
- package/dist/npm/snapshot/storage.js +0 -70
- package/dist/npm/snapshot/verify.d.ts +0 -11
- package/dist/npm/snapshot/verify.js +0 -13
- package/dist/npm/snapshot-cli.d.ts +0 -6
- package/dist/npm/snapshot-cli.js +0 -45
- package/dist/npm/state.d.ts +0 -14
- package/dist/npm/state.js +0 -269
- package/dist/npm/supabase-local.d.ts +0 -2
- package/dist/npm/supabase-local.js +0 -63
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { readdir, readFile } from 'node:fs/promises';
|
|
2
|
-
import { join } from 'node:path';
|
|
3
|
-
const forbiddenCommands = /\b(?:supabase\s+(?:db\s+(?:push|reset|diff|schema|migration)|migration\s+|functions\s+deploy)|nps\s+db\.(?:migrate|push|release|schema))\b/u;
|
|
4
|
-
export async function clientOnlyBoundaryViolations(projectRoot) {
|
|
5
|
-
const findings = [];
|
|
6
|
-
try {
|
|
7
|
-
const entries = await readdir(join(projectRoot, 'supabase'));
|
|
8
|
-
if (entries.length)
|
|
9
|
-
findings.push('supabase/: client-only projects cannot own a Supabase backend directory');
|
|
10
|
-
}
|
|
11
|
-
catch (error) {
|
|
12
|
-
if (!(error instanceof Error && 'code' in error && error.code === 'ENOENT'))
|
|
13
|
-
throw error;
|
|
14
|
-
}
|
|
15
|
-
for (const file of ['package-scripts.yml', 'package.json']) {
|
|
16
|
-
let content;
|
|
17
|
-
try {
|
|
18
|
-
content = await readFile(join(projectRoot, file), 'utf8');
|
|
19
|
-
}
|
|
20
|
-
catch (error) {
|
|
21
|
-
if (error instanceof Error && 'code' in error && error.code === 'ENOENT')
|
|
22
|
-
continue;
|
|
23
|
-
throw error;
|
|
24
|
-
}
|
|
25
|
-
if (forbiddenCommands.test(content))
|
|
26
|
-
findings.push(`${file}: backend database or deployment command is forbidden in a client-only project`);
|
|
27
|
-
}
|
|
28
|
-
return findings;
|
|
29
|
-
}
|
package/dist/npm/commands.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
export declare function checkFlags(args: string[]): {
|
|
2
|
-
refresh: boolean;
|
|
3
|
-
json: boolean;
|
|
4
|
-
details: boolean;
|
|
5
|
-
mode: "full" | "staged" | "files";
|
|
6
|
-
files: string[] | null;
|
|
7
|
-
};
|
|
8
|
-
export declare function createCanonicalCommandHandlers(projectRoot?: string, options?: any): {
|
|
9
|
-
add: (args: string[], io: any) => Promise<0 | 1 | 2>;
|
|
10
|
-
status: (args: string[], io: any) => Promise<0 | 1>;
|
|
11
|
-
sync: (args: string[], io: any) => Promise<0 | 2>;
|
|
12
|
-
check: (args: string[], io: any) => Promise<number>;
|
|
13
|
-
rules: (args: string[], io: any) => Promise<number>;
|
|
14
|
-
'ai-instruction': (args: string[], io: any) => Promise<0 | 2>;
|
|
15
|
-
doctor: (args: string[], io: any) => Promise<0 | 1 | 2>;
|
|
16
|
-
};
|
package/dist/npm/commands.js
DELETED
|
@@ -1,194 +0,0 @@
|
|
|
1
|
-
import { createCanonicalSource } from "./canonical-source.js";
|
|
2
|
-
import { canonicalCheck, formatCheckerDiagnostics } from "./project-check.js";
|
|
3
|
-
import { aiInstructionText, canonicalRules } from "./project-rules.js";
|
|
4
|
-
import { canonicalDoctor, canonicalStatus } from "./project-status.js";
|
|
5
|
-
import { addPredefinedPackage } from "./predefined-packages/index.js";
|
|
6
|
-
import { canonicalSync } from "./project-sync.js";
|
|
7
|
-
function flags(args) {
|
|
8
|
-
const known = new Set(['--refresh', '--json']);
|
|
9
|
-
for (const arg of args)
|
|
10
|
-
if (!known.has(arg))
|
|
11
|
-
throw new Error(`Unknown option: ${arg}`);
|
|
12
|
-
return { refresh: args.includes('--refresh'), json: args.includes('--json') };
|
|
13
|
-
}
|
|
14
|
-
export function checkFlags(args) {
|
|
15
|
-
const result = {
|
|
16
|
-
refresh: false,
|
|
17
|
-
json: false,
|
|
18
|
-
details: false,
|
|
19
|
-
mode: 'full',
|
|
20
|
-
files: null,
|
|
21
|
-
};
|
|
22
|
-
const remaining = [];
|
|
23
|
-
for (const arg of args) {
|
|
24
|
-
if (arg === '--refresh')
|
|
25
|
-
result.refresh = true;
|
|
26
|
-
else if (arg === '--json')
|
|
27
|
-
result.json = true;
|
|
28
|
-
else if (arg === '--details')
|
|
29
|
-
result.details = true;
|
|
30
|
-
else
|
|
31
|
-
remaining.push(arg);
|
|
32
|
-
}
|
|
33
|
-
if (remaining.includes('--staged') && remaining.includes('--files'))
|
|
34
|
-
throw new Error('Use either --staged or --files, not both');
|
|
35
|
-
if (remaining.includes('--staged')) {
|
|
36
|
-
if (remaining.length !== 1)
|
|
37
|
-
throw new Error('Usage: specdest check [--refresh] [--json] [--details] [--staged | --files <path...>]');
|
|
38
|
-
result.mode = 'staged';
|
|
39
|
-
return result;
|
|
40
|
-
}
|
|
41
|
-
const filesIndex = remaining.indexOf('--files');
|
|
42
|
-
if (filesIndex >= 0) {
|
|
43
|
-
if (filesIndex !== 0 || remaining.length < 2)
|
|
44
|
-
throw new Error('Usage: specdest check [--refresh] [--json] [--details] [--staged | --files <path...>]');
|
|
45
|
-
result.mode = 'files';
|
|
46
|
-
result.files = remaining.slice(1);
|
|
47
|
-
return result;
|
|
48
|
-
}
|
|
49
|
-
if (remaining.length)
|
|
50
|
-
throw new Error(`Unknown option: ${remaining[0]}`);
|
|
51
|
-
return result;
|
|
52
|
-
}
|
|
53
|
-
function rulesFlags(args) {
|
|
54
|
-
const result = {
|
|
55
|
-
json: false,
|
|
56
|
-
ids: [],
|
|
57
|
-
categories: [],
|
|
58
|
-
failed: false,
|
|
59
|
-
};
|
|
60
|
-
for (let index = 0; index < args.length; index += 1) {
|
|
61
|
-
const arg = args[index];
|
|
62
|
-
if (arg === '--json')
|
|
63
|
-
result.json = true;
|
|
64
|
-
else if (arg === '--failed')
|
|
65
|
-
result.failed = true;
|
|
66
|
-
else if (arg === '--id' && args[index + 1])
|
|
67
|
-
result.ids.push(args[++index]);
|
|
68
|
-
else if (arg === '--category' && args[index + 1])
|
|
69
|
-
result.categories.push(args[++index]);
|
|
70
|
-
else
|
|
71
|
-
throw new Error(`Unknown option: ${arg}`);
|
|
72
|
-
}
|
|
73
|
-
return result;
|
|
74
|
-
}
|
|
75
|
-
export function createCanonicalCommandHandlers(projectRoot = process.cwd(), options = {}) {
|
|
76
|
-
const source = options.source ?? createCanonicalSource(options);
|
|
77
|
-
return {
|
|
78
|
-
add: async (args, io) => {
|
|
79
|
-
if (args.length !== 1) {
|
|
80
|
-
io.stderr.write('Usage: specdest add <package>\n');
|
|
81
|
-
return 2;
|
|
82
|
-
}
|
|
83
|
-
try {
|
|
84
|
-
const result = await addPredefinedPackage(projectRoot, args[0]);
|
|
85
|
-
const setup = result.setupPackages?.length
|
|
86
|
-
? `; ensured stack setup: ${result.setupPackages.join(', ')}`
|
|
87
|
-
: '';
|
|
88
|
-
io.stdout.write(result.changed
|
|
89
|
-
? `Registered ${result.id} (recipe ${result.recipeVersion}, detected ${result.detectedVersion ?? 'unknown'}, ${result.source})${setup}\n`
|
|
90
|
-
: `${result.id} already registered (recipe ${result.recipeVersion}, detected ${result.detectedVersion ?? 'unknown'}); no changes${setup}.\n`);
|
|
91
|
-
return 0;
|
|
92
|
-
}
|
|
93
|
-
catch (error) {
|
|
94
|
-
io.stderr.write(`${error.message}\n`);
|
|
95
|
-
return 1;
|
|
96
|
-
}
|
|
97
|
-
},
|
|
98
|
-
status: async (args, io) => {
|
|
99
|
-
const parsed = flags(args);
|
|
100
|
-
const result = await canonicalStatus(projectRoot, source, { refresh: parsed.refresh });
|
|
101
|
-
if (parsed.json)
|
|
102
|
-
io.stdout.write(`${JSON.stringify(result, null, 2)}\n`);
|
|
103
|
-
else {
|
|
104
|
-
io.stdout.write(`Stack: ${result.stack ?? 'unknown'}\nApplicable: ${result.totals.applicable} Current: ${result.totals.current} Missing: ${result.totals.missing} Outdated: ${result.totals.outdated}\n`);
|
|
105
|
-
if (result.packages.length)
|
|
106
|
-
io.stdout.write(`Packages: ${result.packages.map((item) => `${item.id}@${item.detectedVersion ?? 'unknown'} (recipe ${item.recipeVersion ?? 'unknown'})`).join(', ')}\n`);
|
|
107
|
-
for (const issue of result.packageIssues)
|
|
108
|
-
io.stderr.write(`FAIL ${issue}\n`);
|
|
109
|
-
}
|
|
110
|
-
return result.totals.missing || result.totals.outdated || result.packageIssues.length ? 1 : 0;
|
|
111
|
-
},
|
|
112
|
-
sync: async (args, io) => {
|
|
113
|
-
if (args.length) {
|
|
114
|
-
io.stderr.write('Usage: specdest sync\n');
|
|
115
|
-
return 2;
|
|
116
|
-
}
|
|
117
|
-
const result = await canonicalSync(projectRoot, source);
|
|
118
|
-
io.stdout.write(`Synced ${result.applicable} applicable rules; ${result.changed.length} changed.\n`);
|
|
119
|
-
for (const item of result.changed)
|
|
120
|
-
io.stdout.write(`${item.action.toUpperCase()} ${item.id}@${item.version}\n`);
|
|
121
|
-
return 0;
|
|
122
|
-
},
|
|
123
|
-
check: async (args, io) => {
|
|
124
|
-
let parsed;
|
|
125
|
-
try {
|
|
126
|
-
parsed = checkFlags(args);
|
|
127
|
-
}
|
|
128
|
-
catch (error) {
|
|
129
|
-
io.stderr.write(`${error.message}\n`);
|
|
130
|
-
return 2;
|
|
131
|
-
}
|
|
132
|
-
const result = await canonicalCheck(projectRoot, source, parsed);
|
|
133
|
-
if (result.versionProblems?.length && !parsed.json) {
|
|
134
|
-
for (const problem of result.versionProblems) {
|
|
135
|
-
io.stderr.write(`FAIL stale rule ${problem.id}: installed ${problem.installedVersion}, canonical ${problem.requiredVersion}${problem.contentMismatch ? ' (content hash mismatch)' : ''}.\n`);
|
|
136
|
-
}
|
|
137
|
-
io.stderr.write('No validators executed. Run `pnpm exec specdest sync`, commit `.spd/installed.json`, then retry.\n');
|
|
138
|
-
}
|
|
139
|
-
if (parsed.json) {
|
|
140
|
-
io.stdout.write(`${JSON.stringify(result, null, 2)}\n`);
|
|
141
|
-
return result.exitCode;
|
|
142
|
-
}
|
|
143
|
-
for (const [id, check] of Object.entries(result.results)) {
|
|
144
|
-
io.stdout.write(`${check.status.toUpperCase()} ${id}\n`);
|
|
145
|
-
}
|
|
146
|
-
if (parsed.details) {
|
|
147
|
-
for (const execution of result.executions.filter((item) => item.exitCode !== 0)) {
|
|
148
|
-
io.stderr.write(`\nChecker failure (${execution.ids.join(', ')}):\n`);
|
|
149
|
-
const details = formatCheckerDiagnostics(execution.diagnostics);
|
|
150
|
-
if (details)
|
|
151
|
-
io.stderr.write(details);
|
|
152
|
-
else
|
|
153
|
-
io.stderr.write(' Checker failed without diagnostic output.\n');
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
return result.exitCode;
|
|
157
|
-
},
|
|
158
|
-
rules: async (args, io) => {
|
|
159
|
-
const parsed = rulesFlags(args);
|
|
160
|
-
const result = await canonicalRules(projectRoot, source, parsed);
|
|
161
|
-
if (parsed.json)
|
|
162
|
-
io.stdout.write(`${JSON.stringify(result, null, 2)}\n`);
|
|
163
|
-
else {
|
|
164
|
-
for (const rule of result.rules) {
|
|
165
|
-
const body = result.detail ? rule.content.trim() : rule.summary;
|
|
166
|
-
const composition = rule.composedOf.length
|
|
167
|
-
? `\nComposed of: ${rule.composedOf.join(', ')}`
|
|
168
|
-
: '';
|
|
169
|
-
io.stdout.write(`## ${rule.id} — ${rule.name}\n${body}${composition}\n\n`);
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
return 0;
|
|
173
|
-
},
|
|
174
|
-
'ai-instruction': async (args, io) => {
|
|
175
|
-
if (args.length) {
|
|
176
|
-
io.stderr.write('Usage: specdest ai-instruction\n');
|
|
177
|
-
return 2;
|
|
178
|
-
}
|
|
179
|
-
io.stdout.write(`${aiInstructionText()}\n`);
|
|
180
|
-
return 0;
|
|
181
|
-
},
|
|
182
|
-
doctor: async (args, io) => {
|
|
183
|
-
if (args.length) {
|
|
184
|
-
io.stderr.write('Usage: specdest doctor\n');
|
|
185
|
-
return 2;
|
|
186
|
-
}
|
|
187
|
-
const result = await canonicalDoctor(projectRoot, source);
|
|
188
|
-
io.stdout.write(`Cache: ${result.cacheRoot}\nStack: ${result.stack ?? 'unknown'}\n`);
|
|
189
|
-
for (const issue of result.issues)
|
|
190
|
-
io.stderr.write(`FAIL ${issue}\n`);
|
|
191
|
-
return result.ok ? 0 : 1;
|
|
192
|
-
},
|
|
193
|
-
};
|
|
194
|
-
}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
type ProjectProfiles = Record<string, {
|
|
2
|
-
ruleIds: string[];
|
|
3
|
-
}>;
|
|
4
|
-
type GitCatalogEntry = {
|
|
5
|
-
id: string;
|
|
6
|
-
kind: 'rule' | 'module';
|
|
7
|
-
version: string;
|
|
8
|
-
name: string;
|
|
9
|
-
content: string;
|
|
10
|
-
order: number;
|
|
11
|
-
source: string;
|
|
12
|
-
revision: string;
|
|
13
|
-
contentHash: string;
|
|
14
|
-
summary?: string;
|
|
15
|
-
category?: string;
|
|
16
|
-
scope?: string;
|
|
17
|
-
labels?: string[];
|
|
18
|
-
enforcement?: string;
|
|
19
|
-
legacyInstalledIds?: string[];
|
|
20
|
-
applicableStacks?: string[];
|
|
21
|
-
requiredPackages?: string[];
|
|
22
|
-
requiredCapabilities?: string[];
|
|
23
|
-
composedOf?: string[];
|
|
24
|
-
notApplicableRuleIds?: string[];
|
|
25
|
-
projectProfiles?: ProjectProfiles;
|
|
26
|
-
ai?: unknown;
|
|
27
|
-
verification?: unknown;
|
|
28
|
-
};
|
|
29
|
-
export declare function buildGitCatalog({ modulesRoot, repositoryRevision, }: {
|
|
30
|
-
modulesRoot: string;
|
|
31
|
-
repositoryRevision?: string;
|
|
32
|
-
}): Promise<{
|
|
33
|
-
schemaVersion: number;
|
|
34
|
-
package: {
|
|
35
|
-
name: string;
|
|
36
|
-
version: string;
|
|
37
|
-
};
|
|
38
|
-
entries: GitCatalogEntry[];
|
|
39
|
-
}>;
|
|
40
|
-
export {};
|
package/dist/npm/git-catalog.js
DELETED
|
@@ -1,222 +0,0 @@
|
|
|
1
|
-
import { createHash } from 'node:crypto';
|
|
2
|
-
import { readdir, readFile } from 'node:fs/promises';
|
|
3
|
-
import { join } from 'node:path';
|
|
4
|
-
import { CanonicalManifestSchema, parseWithSchema } from "./schemas.js";
|
|
5
|
-
const sha256 = (value) => createHash('sha256').update(value).digest('hex');
|
|
6
|
-
const legacyImplementationFamilies = new Map([
|
|
7
|
-
['abac-permissions-supabase', ['abac-permissions-convex', 'abac-permissions-supabase']],
|
|
8
|
-
[
|
|
9
|
-
'layers-and-contracts',
|
|
10
|
-
['layers-and-contracts', 'layers-and-contracts-convex', 'layers-and-contracts-supabase'],
|
|
11
|
-
],
|
|
12
|
-
['unit-test-rules', ['unit-test-rules', 'unit-test-rules-convex', 'unit-test-rules-supabase']],
|
|
13
|
-
[
|
|
14
|
-
'unit-test-rules-supabase',
|
|
15
|
-
['unit-test-rules', 'unit-test-rules-convex', 'unit-test-rules-supabase'],
|
|
16
|
-
],
|
|
17
|
-
]);
|
|
18
|
-
function legacyImplementationIds(manifest) {
|
|
19
|
-
const implementation = manifest.checker?.implementation;
|
|
20
|
-
if (!implementation || implementation === manifest.id)
|
|
21
|
-
return [];
|
|
22
|
-
return legacyImplementationFamilies.get(implementation) ?? [implementation];
|
|
23
|
-
}
|
|
24
|
-
async function moduleFiles(root) {
|
|
25
|
-
const files = [];
|
|
26
|
-
const walk = async (dir, prefix = '') => {
|
|
27
|
-
for (const entry of (await readdir(dir, { withFileTypes: true })).sort((a, b) => a.name.localeCompare(b.name))) {
|
|
28
|
-
const relative = prefix ? `${prefix}/${entry.name}` : entry.name;
|
|
29
|
-
if (entry.isDirectory())
|
|
30
|
-
await walk(join(dir, entry.name), relative);
|
|
31
|
-
else if (entry.isFile())
|
|
32
|
-
files.push({ path: relative, content: await readFile(join(dir, entry.name), 'utf8') });
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
await walk(root);
|
|
36
|
-
return files.sort((a, b) => a.path.localeCompare(b.path));
|
|
37
|
-
}
|
|
38
|
-
function title(content, id) {
|
|
39
|
-
return content.match(/^#\s+(.+)$/mu)?.[1]?.trim() || id;
|
|
40
|
-
}
|
|
41
|
-
function summary(content, fallback) {
|
|
42
|
-
const normalized = String(content ?? '').replace(/\r\n?/gu, '\n');
|
|
43
|
-
const intent = normalized.match(/(?:^|\n)## Intent\s*\n+([^#][\s\S]*?)(?=\n## |$)/u)?.[1]?.trim();
|
|
44
|
-
const source = intent ||
|
|
45
|
-
normalized
|
|
46
|
-
.split('\n')
|
|
47
|
-
.map((line) => line.trim())
|
|
48
|
-
.find((line) => line && !line.startsWith('#')) ||
|
|
49
|
-
fallback;
|
|
50
|
-
return source
|
|
51
|
-
.replace(/^\*\*Rule:\*\*\s*/u, '')
|
|
52
|
-
.replace(/\s+/gu, ' ')
|
|
53
|
-
.slice(0, 240)
|
|
54
|
-
.trim();
|
|
55
|
-
}
|
|
56
|
-
function canonicalVersion(manifest) {
|
|
57
|
-
const version = String(manifest.version ?? '');
|
|
58
|
-
if (!/^\d+\.\d+\.\d+$/u.test(version)) {
|
|
59
|
-
throw new Error(`Canonical catalog entry requires SemVer version: ${manifest.id}`);
|
|
60
|
-
}
|
|
61
|
-
return version;
|
|
62
|
-
}
|
|
63
|
-
function catalogKind(manifest) {
|
|
64
|
-
const kind = manifest.kind ?? 'rule';
|
|
65
|
-
if (!['rule', 'module'].includes(kind))
|
|
66
|
-
throw new Error(`Invalid canonical kind: ${manifest.id}`);
|
|
67
|
-
return kind;
|
|
68
|
-
}
|
|
69
|
-
function notApplicableRuleIds(manifest) {
|
|
70
|
-
if (!Array.isArray(manifest.notApplicableRuleIds))
|
|
71
|
-
return undefined;
|
|
72
|
-
return [...new Set(manifest.notApplicableRuleIds.map(String))].sort();
|
|
73
|
-
}
|
|
74
|
-
function projectProfiles(manifest) {
|
|
75
|
-
if (!manifest.projectProfiles)
|
|
76
|
-
return undefined;
|
|
77
|
-
if (typeof manifest.projectProfiles !== 'object' || Array.isArray(manifest.projectProfiles)) {
|
|
78
|
-
throw new Error(`Invalid projectProfiles: ${manifest.id}`);
|
|
79
|
-
}
|
|
80
|
-
return Object.fromEntries(Object.entries(manifest.projectProfiles)
|
|
81
|
-
.sort(([a], [b]) => a.localeCompare(b))
|
|
82
|
-
.map(([name, definition]) => {
|
|
83
|
-
if (!definition || !Array.isArray(definition.ruleIds) || definition.ruleIds.length === 0) {
|
|
84
|
-
throw new Error(`Invalid project profile: ${manifest.id}:${name}`);
|
|
85
|
-
}
|
|
86
|
-
return [name, { ruleIds: [...new Set(definition.ruleIds.map(String))].sort() }];
|
|
87
|
-
}));
|
|
88
|
-
}
|
|
89
|
-
function stringList(value) {
|
|
90
|
-
if (!Array.isArray(value) || value.length === 0)
|
|
91
|
-
return undefined;
|
|
92
|
-
return [
|
|
93
|
-
...new Set(value
|
|
94
|
-
.map(String)
|
|
95
|
-
.map((item) => item.trim())
|
|
96
|
-
.filter(Boolean)),
|
|
97
|
-
].sort();
|
|
98
|
-
}
|
|
99
|
-
function applicableStacks(manifest) {
|
|
100
|
-
if (!Array.isArray(manifest.applicableStacks) || manifest.applicableStacks.length === 0)
|
|
101
|
-
return undefined;
|
|
102
|
-
return [...new Set(manifest.applicableStacks.map(String))].sort();
|
|
103
|
-
}
|
|
104
|
-
function requiredPackages(manifest) {
|
|
105
|
-
return stringList(manifest.requiredPackages);
|
|
106
|
-
}
|
|
107
|
-
function validateRuleApplicability(manifest) {
|
|
108
|
-
if (manifest.scope !== 'Stack-specific')
|
|
109
|
-
return;
|
|
110
|
-
if (!applicableStacks(manifest) && !requiredPackages(manifest)) {
|
|
111
|
-
throw new Error(`Stack-specific rule requires applicableStacks or requiredPackages: ${manifest.id}`);
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
export async function buildGitCatalog({ modulesRoot, repositoryRevision = 'working-tree', }) {
|
|
115
|
-
const directories = (await readdir(modulesRoot, { withFileTypes: true }))
|
|
116
|
-
.filter((entry) => entry.isDirectory())
|
|
117
|
-
.sort((a, b) => a.name.localeCompare(b.name));
|
|
118
|
-
const modules = [];
|
|
119
|
-
for (const directory of directories) {
|
|
120
|
-
const root = join(modulesRoot, directory.name);
|
|
121
|
-
const files = await moduleFiles(root);
|
|
122
|
-
const manifestFile = files.find((file) => file.path === 'manifest.json');
|
|
123
|
-
if (!manifestFile)
|
|
124
|
-
throw new Error(`Missing manifest.json: ${directory.name}`);
|
|
125
|
-
const manifest = parseWithSchema(CanonicalManifestSchema, JSON.parse(manifestFile.content), `canonical manifest ${directory.name}`);
|
|
126
|
-
if (manifest.id !== directory.name)
|
|
127
|
-
throw new Error(`Module id/path mismatch: ${directory.name}`);
|
|
128
|
-
modules.push({ files, manifest, ownContentHash: sha256(JSON.stringify(files)) });
|
|
129
|
-
}
|
|
130
|
-
const canonicalCheckHash = modules.find(({ manifest }) => manifest.id === 'canonical-check')?.ownContentHash ?? null;
|
|
131
|
-
const entries = [];
|
|
132
|
-
for (const { files, manifest, ownContentHash } of modules) {
|
|
133
|
-
const contentHash = manifest.checker?.path && canonicalCheckHash
|
|
134
|
-
? sha256(JSON.stringify({ ownContentHash, canonicalCheckHash }))
|
|
135
|
-
: ownContentHash;
|
|
136
|
-
const guidance = files.find((file) => /(^|\/)rule\.md$/u.test(file.path) || /(^|\/)SKILL\.md$/u.test(file.path))?.content ?? '';
|
|
137
|
-
const kind = catalogKind(manifest);
|
|
138
|
-
if (kind === 'rule')
|
|
139
|
-
validateRuleApplicability(manifest);
|
|
140
|
-
entries.push({
|
|
141
|
-
id: manifest.id,
|
|
142
|
-
kind,
|
|
143
|
-
version: canonicalVersion(manifest),
|
|
144
|
-
name: title(guidance, manifest.id),
|
|
145
|
-
content: guidance,
|
|
146
|
-
...(kind === 'rule' ? { summary: summary(guidance, manifest.name ?? manifest.id) } : {}),
|
|
147
|
-
...(kind === 'rule' && manifest.category ? { category: String(manifest.category) } : {}),
|
|
148
|
-
...(kind === 'rule' && manifest.scope ? { scope: String(manifest.scope) } : {}),
|
|
149
|
-
...(kind === 'rule' && stringList(manifest.labels)
|
|
150
|
-
? { labels: stringList(manifest.labels) }
|
|
151
|
-
: {}),
|
|
152
|
-
order: entries.length + 1,
|
|
153
|
-
source: 'private-devkit-git',
|
|
154
|
-
revision: repositoryRevision,
|
|
155
|
-
contentHash,
|
|
156
|
-
...(kind === 'rule' ? { legacyInstalledIds: legacyImplementationIds(manifest) } : {}),
|
|
157
|
-
...(kind === 'rule' ? { enforcement: String(manifest.enforcement ?? 'guidance') } : {}),
|
|
158
|
-
...(kind === 'rule' && applicableStacks(manifest)
|
|
159
|
-
? { applicableStacks: applicableStacks(manifest) }
|
|
160
|
-
: {}),
|
|
161
|
-
...(kind === 'rule' && requiredPackages(manifest)
|
|
162
|
-
? { requiredPackages: requiredPackages(manifest) }
|
|
163
|
-
: {}),
|
|
164
|
-
...(kind === 'rule' && stringList(manifest.requiredCapabilities)
|
|
165
|
-
? { requiredCapabilities: stringList(manifest.requiredCapabilities) }
|
|
166
|
-
: {}),
|
|
167
|
-
...(kind === 'rule' && manifest.ai ? { ai: manifest.ai } : {}),
|
|
168
|
-
...(kind === 'rule' && manifest.verification ? { verification: manifest.verification } : {}),
|
|
169
|
-
...(kind === 'rule' && stringList(manifest.composedOf)
|
|
170
|
-
? { composedOf: stringList(manifest.composedOf) }
|
|
171
|
-
: {}),
|
|
172
|
-
...(kind === 'module' && notApplicableRuleIds(manifest)
|
|
173
|
-
? { notApplicableRuleIds: notApplicableRuleIds(manifest) }
|
|
174
|
-
: {}),
|
|
175
|
-
...(kind === 'module' && projectProfiles(manifest)
|
|
176
|
-
? { projectProfiles: projectProfiles(manifest) }
|
|
177
|
-
: {}),
|
|
178
|
-
});
|
|
179
|
-
}
|
|
180
|
-
const ruleIds = new Set(entries.filter((entry) => entry.kind === 'rule').map((entry) => entry.id));
|
|
181
|
-
for (const entry of entries) {
|
|
182
|
-
for (const ruleId of entry.notApplicableRuleIds ?? []) {
|
|
183
|
-
if (!ruleIds.has(ruleId))
|
|
184
|
-
throw new Error(`Unknown not-applicable rule: ${entry.id}:${ruleId}`);
|
|
185
|
-
}
|
|
186
|
-
for (const [profileName, definition] of Object.entries(entry.projectProfiles ?? {})) {
|
|
187
|
-
for (const ruleId of definition.ruleIds) {
|
|
188
|
-
if (!ruleIds.has(ruleId))
|
|
189
|
-
throw new Error(`Unknown project-profile rule: ${entry.id}:${profileName}:${ruleId}`);
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
for (const childId of entry.composedOf ?? []) {
|
|
193
|
-
if (!ruleIds.has(childId))
|
|
194
|
-
throw new Error(`Unknown composed rule: ${entry.id}:${childId}`);
|
|
195
|
-
if (childId === entry.id)
|
|
196
|
-
throw new Error(`Rule cannot compose itself: ${entry.id}`);
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
const composition = new Map(entries
|
|
200
|
-
.filter((entry) => entry.kind === 'rule')
|
|
201
|
-
.map((entry) => [entry.id, entry.composedOf ?? []]));
|
|
202
|
-
const visiting = new Set();
|
|
203
|
-
const visited = new Set();
|
|
204
|
-
const visit = (id) => {
|
|
205
|
-
if (visiting.has(id))
|
|
206
|
-
throw new Error(`Rule composition cycle: ${id}`);
|
|
207
|
-
if (visited.has(id))
|
|
208
|
-
return;
|
|
209
|
-
visiting.add(id);
|
|
210
|
-
for (const childId of composition.get(id) ?? [])
|
|
211
|
-
visit(childId);
|
|
212
|
-
visiting.delete(id);
|
|
213
|
-
visited.add(id);
|
|
214
|
-
};
|
|
215
|
-
for (const id of composition.keys())
|
|
216
|
-
visit(id);
|
|
217
|
-
return {
|
|
218
|
-
schemaVersion: 1,
|
|
219
|
-
package: { name: '@specdest/devkit', version: repositoryRevision },
|
|
220
|
-
entries,
|
|
221
|
-
};
|
|
222
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
type Runner = (binary: string, args: string[], input?: string) => {
|
|
2
|
-
status: number | null;
|
|
3
|
-
stdout: string;
|
|
4
|
-
error?: Error;
|
|
5
|
-
};
|
|
6
|
-
type Output = Pick<typeof process, 'stdout' | 'stderr'>;
|
|
7
|
-
export declare function runGitHubDopplerSecrets(args: string[], io?: Output, runner?: Runner): Promise<number>;
|
|
8
|
-
export {};
|
|
@@ -1,156 +0,0 @@
|
|
|
1
|
-
import { spawnSync } from 'node:child_process';
|
|
2
|
-
const realRunner = (binary, args, input) => {
|
|
3
|
-
const result = spawnSync(binary, args, {
|
|
4
|
-
encoding: 'utf8',
|
|
5
|
-
...(input !== undefined ? { input } : {}),
|
|
6
|
-
maxBuffer: 8 * 1024 * 1024,
|
|
7
|
-
timeout: 30_000,
|
|
8
|
-
});
|
|
9
|
-
return {
|
|
10
|
-
status: result.status,
|
|
11
|
-
stdout: result.stdout ?? '',
|
|
12
|
-
...(result.error ? { error: result.error } : {}),
|
|
13
|
-
};
|
|
14
|
-
};
|
|
15
|
-
const HELP = [
|
|
16
|
-
'Usage:',
|
|
17
|
-
' specdest secrets github check --repo OWNER/REPO --project PROJECT --config CONFIG (--name KEY ... | --all)',
|
|
18
|
-
' specdest secrets github push --repo OWNER/REPO --project PROJECT --config CONFIG (--name KEY ... | --all) [--apply] [--confirm-all]',
|
|
19
|
-
'',
|
|
20
|
-
'check compares names/presence only; GitHub never returns secret values.',
|
|
21
|
-
'push defaults to dry-run; --apply replaces selected GitHub Actions secrets from Doppler.',
|
|
22
|
-
'--all --apply requires --confirm-all. One-way Doppler to GitHub only; reverse sync is deliberately unsupported.',
|
|
23
|
-
].join('\n') + '\n';
|
|
24
|
-
function parse(args) {
|
|
25
|
-
const [provider, operation, ...rest] = args;
|
|
26
|
-
if (provider !== 'github' || (operation !== 'check' && operation !== 'push')) {
|
|
27
|
-
throw new Error(HELP);
|
|
28
|
-
}
|
|
29
|
-
const flags = new Map();
|
|
30
|
-
const names = [];
|
|
31
|
-
let all = false;
|
|
32
|
-
let apply = false;
|
|
33
|
-
let confirmAll = false;
|
|
34
|
-
for (let i = 0; i < rest.length; i++) {
|
|
35
|
-
const flag = rest[i];
|
|
36
|
-
if (flag === '--all')
|
|
37
|
-
all = true;
|
|
38
|
-
else if (flag === '--apply')
|
|
39
|
-
apply = true;
|
|
40
|
-
else if (flag === '--confirm-all')
|
|
41
|
-
confirmAll = true;
|
|
42
|
-
else if (['--repo', '--project', '--config', '--name'].includes(flag ?? '')) {
|
|
43
|
-
const value = rest[++i];
|
|
44
|
-
if (!value || value.startsWith('--'))
|
|
45
|
-
throw new Error('Missing value for ' + flag);
|
|
46
|
-
if (flag === '--name')
|
|
47
|
-
names.push(value);
|
|
48
|
-
else
|
|
49
|
-
flags.set(flag, value);
|
|
50
|
-
}
|
|
51
|
-
else
|
|
52
|
-
throw new Error('Unknown option: ' + flag);
|
|
53
|
-
}
|
|
54
|
-
const repo = flags.get('--repo') ?? '';
|
|
55
|
-
const project = flags.get('--project') ?? '';
|
|
56
|
-
const config = flags.get('--config') ?? '';
|
|
57
|
-
if (!/^[\w.-]+\/[\w.-]+$/.test(repo) ||
|
|
58
|
-
!/^[\w.-]+$/.test(project) ||
|
|
59
|
-
!/^[\w.-]+$/.test(config) ||
|
|
60
|
-
all === names.length > 0) {
|
|
61
|
-
throw new Error(HELP);
|
|
62
|
-
}
|
|
63
|
-
if (names.some((name) => !/^[A-Za-z_][A-Za-z0-9_]*$/.test(name))) {
|
|
64
|
-
throw new Error('Invalid GitHub secret name.');
|
|
65
|
-
}
|
|
66
|
-
if (operation === 'check' && (apply || confirmAll))
|
|
67
|
-
throw new Error('check is read-only.');
|
|
68
|
-
if (confirmAll && (!all || !apply))
|
|
69
|
-
throw new Error('--confirm-all requires --all --apply.');
|
|
70
|
-
return { operation, repo, project, config, names: [...new Set(names)], all, apply, confirmAll };
|
|
71
|
-
}
|
|
72
|
-
function execute(runner, binary, args, input) {
|
|
73
|
-
const result = runner(binary, args, input);
|
|
74
|
-
if (result.status !== 0 || result.error) {
|
|
75
|
-
// Provider stderr can contain credential values or token-bearing URLs.
|
|
76
|
-
throw new Error(binary + ' failed. Check local authentication and permissions.');
|
|
77
|
-
}
|
|
78
|
-
return result.stdout;
|
|
79
|
-
}
|
|
80
|
-
export async function runGitHubDopplerSecrets(args, io = process, runner = realRunner) {
|
|
81
|
-
if (args.includes('--help') || args.includes('-h')) {
|
|
82
|
-
io.stdout.write(HELP);
|
|
83
|
-
return 0;
|
|
84
|
-
}
|
|
85
|
-
try {
|
|
86
|
-
const options = parse(args);
|
|
87
|
-
if (options.operation === 'push' && options.all && options.apply && !options.confirmAll) {
|
|
88
|
-
throw new Error('Bulk overwrite requires --confirm-all.');
|
|
89
|
-
}
|
|
90
|
-
const rawNames = execute(runner, 'doppler', [
|
|
91
|
-
'secrets',
|
|
92
|
-
'--only-names',
|
|
93
|
-
'--json',
|
|
94
|
-
'--project',
|
|
95
|
-
options.project,
|
|
96
|
-
'--config',
|
|
97
|
-
options.config,
|
|
98
|
-
]);
|
|
99
|
-
const nameData = JSON.parse(rawNames);
|
|
100
|
-
if (typeof nameData !== 'object' || nameData === null || Array.isArray(nameData)) {
|
|
101
|
-
throw new Error('Unexpected Doppler secret names response.');
|
|
102
|
-
}
|
|
103
|
-
const names = Object.keys(nameData);
|
|
104
|
-
const selected = options.all ? names.sort() : options.names;
|
|
105
|
-
if (!selected.length || selected.some((key) => !names.includes(key))) {
|
|
106
|
-
throw new Error('Selected Doppler secret names are missing.');
|
|
107
|
-
}
|
|
108
|
-
const restricted = selected.find((key) => !/^[A-Za-z_][A-Za-z0-9_]*$/.test(key) || /^DOPPLER_/.test(key) || key === 'GITHUB_TOKEN');
|
|
109
|
-
if (restricted) {
|
|
110
|
-
throw new Error('Reserved or invalid GitHub secret name selected: ' + restricted);
|
|
111
|
-
}
|
|
112
|
-
const listing = execute(runner, 'gh', ['secret', 'list', '--repo', options.repo]);
|
|
113
|
-
const githubNames = new Set(listing
|
|
114
|
-
.split('\n')
|
|
115
|
-
.map((line) => line.trim().split(/\s+/)[0])
|
|
116
|
-
.filter(Boolean));
|
|
117
|
-
for (const key of selected) {
|
|
118
|
-
io.stdout.write(key + ': ' + (githubNames.has(key) ? 'present (value uncheckable)' : 'missing') + '\n');
|
|
119
|
-
}
|
|
120
|
-
if (options.operation === 'check')
|
|
121
|
-
return selected.every((key) => githubNames.has(key)) ? 0 : 1;
|
|
122
|
-
if (!options.apply) {
|
|
123
|
-
io.stdout.write('DRY RUN: no GitHub secrets changed. Add --apply to overwrite selected values.\n');
|
|
124
|
-
return 0;
|
|
125
|
-
}
|
|
126
|
-
// Retrieve values only for a caller-authorized write; never for check/dry-run.
|
|
127
|
-
const rawValues = execute(runner, 'doppler', [
|
|
128
|
-
'secrets',
|
|
129
|
-
'download',
|
|
130
|
-
'--no-file',
|
|
131
|
-
'--format',
|
|
132
|
-
'json',
|
|
133
|
-
'--project',
|
|
134
|
-
options.project,
|
|
135
|
-
'--config',
|
|
136
|
-
options.config,
|
|
137
|
-
]);
|
|
138
|
-
const valueData = JSON.parse(rawValues);
|
|
139
|
-
if (typeof valueData !== 'object' || valueData === null || Array.isArray(valueData)) {
|
|
140
|
-
throw new Error('Unexpected Doppler values response.');
|
|
141
|
-
}
|
|
142
|
-
const values = valueData;
|
|
143
|
-
if (selected.some((key) => typeof values[key] !== 'string')) {
|
|
144
|
-
throw new Error('Selected Doppler values are unavailable.');
|
|
145
|
-
}
|
|
146
|
-
for (const key of selected) {
|
|
147
|
-
execute(runner, 'gh', ['secret', 'set', key, '--repo', options.repo], values[key]);
|
|
148
|
-
io.stdout.write(key + ': updated\n');
|
|
149
|
-
}
|
|
150
|
-
return 0;
|
|
151
|
-
}
|
|
152
|
-
catch (error) {
|
|
153
|
-
io.stderr.write((error instanceof Error ? error.message : 'Secret sync failed.') + '\n');
|
|
154
|
-
return 2;
|
|
155
|
-
}
|
|
156
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { spawnSync } from 'node:child_process';
|
|
2
|
-
declare const TOOLS: {
|
|
3
|
-
readonly device: "agent-device";
|
|
4
|
-
readonly browser: "agent-browser";
|
|
5
|
-
readonly 'jev-browser': "jev-browser";
|
|
6
|
-
};
|
|
7
|
-
/** Forward unchanged arguments through Controller's queue, or its trusted NPS host context. */
|
|
8
|
-
export declare function runHostAutomation(command: keyof typeof TOOLS, args: string[], cwd?: string, invoke?: typeof spawnSync, gatewayExists?: (path: string) => boolean, env?: Record<string, string | undefined>): number;
|
|
9
|
-
export {};
|