@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,127 +0,0 @@
|
|
|
1
|
-
import { basename } from 'node:path';
|
|
2
|
-
import { ensurePnpmBuildPolicy, mergeMissing, updatePackageJson, writeProjectFileIfMissing } from "./install.js";
|
|
3
|
-
import { detectDependency } from "./package-json.js";
|
|
4
|
-
const dependencies = {
|
|
5
|
-
react: '19.2.3',
|
|
6
|
-
'react-dom': '19.2.3',
|
|
7
|
-
};
|
|
8
|
-
const devDependencies = {
|
|
9
|
-
'@types/react': '19.2.7',
|
|
10
|
-
'@types/react-dom': '19.2.3',
|
|
11
|
-
'@vitejs/plugin-react': '5.1.2',
|
|
12
|
-
typescript: '6.0.3',
|
|
13
|
-
vite: '7.3.0',
|
|
14
|
-
};
|
|
15
|
-
function packageName(projectRoot) {
|
|
16
|
-
const normalized = basename(projectRoot).toLowerCase().replace(/[^a-z0-9._-]+/gu, '-');
|
|
17
|
-
return normalized || 'specdest-app';
|
|
18
|
-
}
|
|
19
|
-
async function installVite(projectRoot, context) {
|
|
20
|
-
await updatePackageJson(projectRoot, (pkg) => ({
|
|
21
|
-
...pkg,
|
|
22
|
-
name: pkg.name ?? packageName(projectRoot),
|
|
23
|
-
private: pkg.private ?? true,
|
|
24
|
-
type: pkg.type ?? 'module',
|
|
25
|
-
packageManager: pkg.packageManager ?? 'pnpm@11.6.0',
|
|
26
|
-
engines: {
|
|
27
|
-
...pkg.engines,
|
|
28
|
-
node: pkg.engines?.node ?? '>=24.0.0',
|
|
29
|
-
pnpm: pkg.engines?.pnpm ?? '>=11.0.0',
|
|
30
|
-
},
|
|
31
|
-
scripts: mergeMissing(pkg.scripts, {
|
|
32
|
-
dev: 'vite',
|
|
33
|
-
build: 'tsc -b && vite build',
|
|
34
|
-
typecheck: 'tsc -b',
|
|
35
|
-
preview: 'vite preview',
|
|
36
|
-
}),
|
|
37
|
-
dependencies: mergeMissing(pkg.dependencies, dependencies),
|
|
38
|
-
devDependencies: mergeMissing(pkg.devDependencies, devDependencies),
|
|
39
|
-
}));
|
|
40
|
-
await ensurePnpmBuildPolicy(projectRoot);
|
|
41
|
-
await writeProjectFileIfMissing(projectRoot, 'index.html', `<!doctype html>
|
|
42
|
-
<html lang="en">
|
|
43
|
-
<head><meta charset="UTF-8" /><meta name="viewport" content="width=device-width, initial-scale=1.0" /></head>
|
|
44
|
-
<body><div id="root"></div><script type="module" src="/src/main.tsx"></script></body>
|
|
45
|
-
</html>
|
|
46
|
-
`);
|
|
47
|
-
await writeProjectFileIfMissing(projectRoot, 'src/main.tsx', `import { StrictMode } from 'react';
|
|
48
|
-
import { createRoot } from 'react-dom/client';
|
|
49
|
-
import App from './App';
|
|
50
|
-
|
|
51
|
-
createRoot(document.getElementById('root')!).render(
|
|
52
|
-
<StrictMode>
|
|
53
|
-
<App />
|
|
54
|
-
</StrictMode>,
|
|
55
|
-
);
|
|
56
|
-
`);
|
|
57
|
-
await writeProjectFileIfMissing(projectRoot, 'src/App.tsx', `export default function App() {
|
|
58
|
-
return <main>Specdest app</main>;
|
|
59
|
-
}
|
|
60
|
-
`);
|
|
61
|
-
await writeProjectFileIfMissing(projectRoot, 'vite.config.ts', `import { defineConfig } from 'vite';
|
|
62
|
-
import react from '@vitejs/plugin-react';
|
|
63
|
-
|
|
64
|
-
export default defineConfig({ plugins: [react()] });
|
|
65
|
-
`);
|
|
66
|
-
await writeProjectFileIfMissing(projectRoot, 'tsconfig.json', `{
|
|
67
|
-
"files": [],
|
|
68
|
-
"references": [
|
|
69
|
-
{ "path": "./tsconfig.app.json" },
|
|
70
|
-
{ "path": "./tsconfig.node.json" }
|
|
71
|
-
]
|
|
72
|
-
}
|
|
73
|
-
`);
|
|
74
|
-
await writeProjectFileIfMissing(projectRoot, 'tsconfig.app.json', `{
|
|
75
|
-
"compilerOptions": {
|
|
76
|
-
"target": "ES2022",
|
|
77
|
-
"useDefineForClassFields": true,
|
|
78
|
-
"lib": ["ES2022", "DOM", "DOM.Iterable"],
|
|
79
|
-
"skipLibCheck": true,
|
|
80
|
-
"module": "ESNext",
|
|
81
|
-
"moduleResolution": "Bundler",
|
|
82
|
-
"allowImportingTsExtensions": true,
|
|
83
|
-
"resolveJsonModule": true,
|
|
84
|
-
"isolatedModules": true,
|
|
85
|
-
"noEmit": true,
|
|
86
|
-
"jsx": "react-jsx",
|
|
87
|
-
"strict": true
|
|
88
|
-
},
|
|
89
|
-
"include": ["src"]
|
|
90
|
-
}
|
|
91
|
-
`);
|
|
92
|
-
await writeProjectFileIfMissing(projectRoot, 'tsconfig.node.json', `{
|
|
93
|
-
"compilerOptions": {
|
|
94
|
-
"composite": true,
|
|
95
|
-
"skipLibCheck": true,
|
|
96
|
-
"module": "ESNext",
|
|
97
|
-
"moduleResolution": "Bundler",
|
|
98
|
-
"allowImportingTsExtensions": true,
|
|
99
|
-
"noEmit": true
|
|
100
|
-
},
|
|
101
|
-
"include": ["vite.config.ts"]
|
|
102
|
-
}
|
|
103
|
-
`);
|
|
104
|
-
await context.runCommand('pnpm', ['install', '--no-frozen-lockfile'], { cwd: projectRoot });
|
|
105
|
-
}
|
|
106
|
-
export const viteRecipe = {
|
|
107
|
-
id: 'vite',
|
|
108
|
-
recipeVersion: '1.2.0',
|
|
109
|
-
role: 'frontend',
|
|
110
|
-
setupRequirements: [
|
|
111
|
-
{ kind: 'package', packageId: 'oxlint', required: true },
|
|
112
|
-
{ kind: 'package', packageId: 'husky', required: true, when: 'git' },
|
|
113
|
-
],
|
|
114
|
-
conflicts: ['expo'],
|
|
115
|
-
async detect(projectRoot) {
|
|
116
|
-
return await detectDependency(projectRoot, 'vite', 'Vite');
|
|
117
|
-
},
|
|
118
|
-
async apply(projectRoot, detection, _resolution, context) {
|
|
119
|
-
if (detection.present) {
|
|
120
|
-
if (!detection.compatible)
|
|
121
|
-
throw new Error(detection.reason ?? 'Existing Vite setup is not compatible.');
|
|
122
|
-
return { source: 'adopted' };
|
|
123
|
-
}
|
|
124
|
-
await installVite(projectRoot, context);
|
|
125
|
-
return { source: 'installed' };
|
|
126
|
-
},
|
|
127
|
-
};
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { installPackageJsonPatch } from "./install.js";
|
|
2
|
-
import { detectDependency } from "./package-json.js";
|
|
3
|
-
export const vitestRecipe = {
|
|
4
|
-
id: 'vitest',
|
|
5
|
-
recipeVersion: '1.1.0',
|
|
6
|
-
role: 'integration',
|
|
7
|
-
requires: ['vite'],
|
|
8
|
-
async detect(projectRoot) {
|
|
9
|
-
return await detectDependency(projectRoot, 'vitest', 'Vitest');
|
|
10
|
-
},
|
|
11
|
-
async apply(projectRoot, detection, _resolution, context) {
|
|
12
|
-
if (detection.present)
|
|
13
|
-
return { source: 'adopted' };
|
|
14
|
-
await installPackageJsonPatch(projectRoot, context.runCommand, {
|
|
15
|
-
devDependencies: { vitest: '4.1.0' },
|
|
16
|
-
scripts: { test: 'vitest run', 'test:watch': 'vitest' },
|
|
17
|
-
});
|
|
18
|
-
return { source: 'installed' };
|
|
19
|
-
},
|
|
20
|
-
};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { installPackageJsonPatch } from "./install.js";
|
|
2
|
-
import { detectDependency } from "./package-json.js";
|
|
3
|
-
export const zodRecipe = {
|
|
4
|
-
id: 'zod',
|
|
5
|
-
recipeVersion: '1.1.0',
|
|
6
|
-
role: 'integration',
|
|
7
|
-
async detect(projectRoot) {
|
|
8
|
-
return await detectDependency(projectRoot, 'zod', 'Zod');
|
|
9
|
-
},
|
|
10
|
-
async apply(projectRoot, detection, _resolution, context) {
|
|
11
|
-
if (detection.present)
|
|
12
|
-
return { source: 'adopted' };
|
|
13
|
-
await installPackageJsonPatch(projectRoot, context.runCommand, {
|
|
14
|
-
dependencies: { zod: '4.3.6' },
|
|
15
|
-
});
|
|
16
|
-
return { source: 'installed' };
|
|
17
|
-
},
|
|
18
|
-
};
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
export type CheckerDiagnostic = {
|
|
2
|
-
path?: string;
|
|
3
|
-
line?: number;
|
|
4
|
-
column?: number;
|
|
5
|
-
message: string;
|
|
6
|
-
};
|
|
7
|
-
export declare function collectCheckerDiagnostics(output: {
|
|
8
|
-
stdout?: string;
|
|
9
|
-
stderr?: string;
|
|
10
|
-
}): CheckerDiagnostic[];
|
|
11
|
-
export declare function formatCheckerDiagnostics(diagnostics: CheckerDiagnostic[]): string;
|
|
12
|
-
export declare function runWithConcurrency<T, R>(items: T[], limit: number, worker: (item: T, index: number) => Promise<R>): Promise<R[]>;
|
|
13
|
-
export declare function canonicalCheck(projectRoot: string, source: any, options?: any): Promise<{
|
|
14
|
-
exitCode: number;
|
|
15
|
-
results: any;
|
|
16
|
-
executions: never[];
|
|
17
|
-
versionProblems: {
|
|
18
|
-
id: any;
|
|
19
|
-
installedVersion: any;
|
|
20
|
-
requiredVersion: any;
|
|
21
|
-
contentMismatch: boolean;
|
|
22
|
-
}[];
|
|
23
|
-
} | {
|
|
24
|
-
exitCode: number;
|
|
25
|
-
results: {
|
|
26
|
-
[k: string]: any;
|
|
27
|
-
};
|
|
28
|
-
executions: {
|
|
29
|
-
ids: any[];
|
|
30
|
-
checkerPath: any;
|
|
31
|
-
exitCode: any;
|
|
32
|
-
stdout: any;
|
|
33
|
-
stderr: any;
|
|
34
|
-
diagnostics: CheckerDiagnostic[];
|
|
35
|
-
}[];
|
|
36
|
-
versionProblems?: undefined;
|
|
37
|
-
}>;
|
|
@@ -1,231 +0,0 @@
|
|
|
1
|
-
import { spawn } from 'node:child_process';
|
|
2
|
-
import { readdirSync } from 'node:fs';
|
|
3
|
-
import { automationPolicyFindings } from "./automation-policy.js";
|
|
4
|
-
import { projectFromCwd } from "./supabase-local.js";
|
|
5
|
-
import { clientOnlyBoundaryViolations } from "./client-only-boundary.js";
|
|
6
|
-
import { readRuleProfile } from "./project-context.js";
|
|
7
|
-
import { loadCanonicalProjectContext, prepareCanonicalManifest } from "./project-runtime.js";
|
|
8
|
-
import { assertPredefinedPackageState } from "./predefined-packages/health.js";
|
|
9
|
-
import { readInstalledState, writeChecksState } from "./state.js";
|
|
10
|
-
function diagnosticFromLine(rawLine) {
|
|
11
|
-
const line = rawLine.trim().replace(/^-\s+/u, '');
|
|
12
|
-
if (!line || /^#\s/u.test(line) || /\b(?:ok|not applicable|not affected)$/iu.test(line))
|
|
13
|
-
return null;
|
|
14
|
-
const located = line.match(/^(.+?):(\d+)(?::(\d+))?(?::|\s)+(.*)$/u);
|
|
15
|
-
if (located) {
|
|
16
|
-
return {
|
|
17
|
-
path: located[1],
|
|
18
|
-
line: Number(located[2]),
|
|
19
|
-
...(located[3] ? { column: Number(located[3]) } : {}),
|
|
20
|
-
message: located[4],
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
const fileOnly = line.match(/^([^:]+\.[A-Za-z0-9]+):\s+(.+)$/u);
|
|
24
|
-
if (fileOnly)
|
|
25
|
-
return { path: fileOnly[1], message: fileOnly[2] };
|
|
26
|
-
return { message: line };
|
|
27
|
-
}
|
|
28
|
-
export function collectCheckerDiagnostics(output) {
|
|
29
|
-
const diagnostics = [];
|
|
30
|
-
const seen = new Set();
|
|
31
|
-
for (const stream of [output.stdout ?? '', output.stderr ?? '']) {
|
|
32
|
-
for (const rawLine of stream.split(/\r?\n/u)) {
|
|
33
|
-
const diagnostic = diagnosticFromLine(rawLine);
|
|
34
|
-
if (!diagnostic)
|
|
35
|
-
continue;
|
|
36
|
-
const key = JSON.stringify(diagnostic);
|
|
37
|
-
if (!seen.has(key)) {
|
|
38
|
-
seen.add(key);
|
|
39
|
-
diagnostics.push(diagnostic);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
return diagnostics;
|
|
44
|
-
}
|
|
45
|
-
export function formatCheckerDiagnostics(diagnostics) {
|
|
46
|
-
return diagnostics
|
|
47
|
-
.map((diagnostic) => {
|
|
48
|
-
if (!diagnostic.path)
|
|
49
|
-
return ` ${diagnostic.message}\n`;
|
|
50
|
-
const location = [diagnostic.path, diagnostic.line, diagnostic.column]
|
|
51
|
-
.filter((value) => value !== undefined)
|
|
52
|
-
.join(':');
|
|
53
|
-
return ` ${location}\n ${diagnostic.message}\n`;
|
|
54
|
-
})
|
|
55
|
-
.join('');
|
|
56
|
-
}
|
|
57
|
-
function execute(command, args, cwd) {
|
|
58
|
-
return new Promise((resolve, reject) => {
|
|
59
|
-
const child = spawn(command, args, { cwd, stdio: ['ignore', 'pipe', 'pipe'] });
|
|
60
|
-
let stdout = '';
|
|
61
|
-
let stderr = '';
|
|
62
|
-
child.stdout.setEncoding('utf8');
|
|
63
|
-
child.stderr.setEncoding('utf8');
|
|
64
|
-
child.stdout.on('data', (chunk) => {
|
|
65
|
-
stdout += chunk;
|
|
66
|
-
});
|
|
67
|
-
child.stderr.on('data', (chunk) => {
|
|
68
|
-
stderr += chunk;
|
|
69
|
-
});
|
|
70
|
-
child.on('error', reject);
|
|
71
|
-
child.on('close', (code) => resolve({ exitCode: code ?? 1, stdout, stderr }));
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
export async function runWithConcurrency(items, limit, worker) {
|
|
75
|
-
const concurrency = Math.max(1, Math.min(Math.floor(limit), items.length || 1));
|
|
76
|
-
const results = new Array(items.length);
|
|
77
|
-
let nextIndex = 0;
|
|
78
|
-
await Promise.all(Array.from({ length: concurrency }, async () => {
|
|
79
|
-
while (nextIndex < items.length) {
|
|
80
|
-
const index = nextIndex++;
|
|
81
|
-
results[index] = await worker(items[index], index);
|
|
82
|
-
}
|
|
83
|
-
}));
|
|
84
|
-
return results;
|
|
85
|
-
}
|
|
86
|
-
export async function canonicalCheck(projectRoot, source, options = {}) {
|
|
87
|
-
await assertPredefinedPackageState(projectRoot);
|
|
88
|
-
const current = await readInstalledState(projectRoot);
|
|
89
|
-
const { applicable, canonicalCheckRoot, checkerRuntimeRoot } = await loadCanonicalProjectContext(projectRoot, source, { offline: false, withCheckers: true, refresh: true });
|
|
90
|
-
const byId = new Map(applicable.map((entry) => [entry.id, entry]));
|
|
91
|
-
// Fail closed before invoking any checker if its installed contract is stale.
|
|
92
|
-
// A cached validator may otherwise report PASS against obsolete requirements.
|
|
93
|
-
const versionProblems = applicable.flatMap((entry) => {
|
|
94
|
-
if ((entry.enforcement ?? 'guidance') === 'guidance')
|
|
95
|
-
return [];
|
|
96
|
-
const installed = current.installed[entry.id];
|
|
97
|
-
if (!installed || installed.kind !== 'rule')
|
|
98
|
-
return [];
|
|
99
|
-
if (installed.version === entry.version && installed.contentHash === entry.contentHash)
|
|
100
|
-
return [];
|
|
101
|
-
return [
|
|
102
|
-
{
|
|
103
|
-
id: entry.id,
|
|
104
|
-
installedVersion: installed.version ?? 'unknown',
|
|
105
|
-
requiredVersion: entry.version,
|
|
106
|
-
contentMismatch: installed.version === entry.version,
|
|
107
|
-
},
|
|
108
|
-
];
|
|
109
|
-
});
|
|
110
|
-
if (versionProblems.length) {
|
|
111
|
-
const results = Object.fromEntries(versionProblems.map((problem) => {
|
|
112
|
-
const message = `STALE RULE ${problem.id}: installed ${problem.installedVersion}, canonical ${problem.requiredVersion}${problem.contentMismatch ? ' (content hash differs)' : ''}. Run \`pnpm exec specdest sync\` and commit .spd/installed.json.`;
|
|
113
|
-
return [
|
|
114
|
-
problem.id,
|
|
115
|
-
{ status: 'fail', exitCode: 1, stderr: message, diagnostics: [{ message }] },
|
|
116
|
-
];
|
|
117
|
-
}));
|
|
118
|
-
return { exitCode: 1, results, executions: [], versionProblems };
|
|
119
|
-
}
|
|
120
|
-
const results = {};
|
|
121
|
-
const groups = new Map();
|
|
122
|
-
const executor = options.executor ?? execute;
|
|
123
|
-
const targetMode = options.mode ?? 'full';
|
|
124
|
-
let targetFiles = options.files ?? null;
|
|
125
|
-
if (targetMode === 'staged' && targetFiles === null) {
|
|
126
|
-
const staged = await executor('git', ['diff', '--cached', '--name-only', '-z', '--diff-filter=ACMR'], projectRoot);
|
|
127
|
-
if (staged.exitCode !== 0)
|
|
128
|
-
throw new Error(staged.stderr || 'Unable to read staged files');
|
|
129
|
-
targetFiles = staged.stdout.split('\0').filter(Boolean);
|
|
130
|
-
}
|
|
131
|
-
const normalizedTargetFiles = (targetFiles ?? []).map((file) => String(file).replaceAll('\\', '/'));
|
|
132
|
-
let exitCode = 0;
|
|
133
|
-
if (projectFromCwd(projectRoot)) {
|
|
134
|
-
const scripts = readdirSync(`${projectRoot}/scripts`, { recursive: true, withFileTypes: true })
|
|
135
|
-
.filter((entry) => entry.isFile())
|
|
136
|
-
.map((entry) => `scripts/${entry.parentPath.replace(`${projectRoot}/scripts/`, '')}/${entry.name}`.replace('scripts//', 'scripts/'));
|
|
137
|
-
const violations = automationPolicyFindings(projectRoot, ['package-scripts.yml', ...scripts]);
|
|
138
|
-
results['automation-gateway'] = {
|
|
139
|
-
status: violations.length ? 'fail' : 'pass',
|
|
140
|
-
exitCode: violations.length ? 1 : 0,
|
|
141
|
-
stderr: violations.join('\n'),
|
|
142
|
-
diagnostics: violations.map((message) => ({ message })),
|
|
143
|
-
};
|
|
144
|
-
if (violations.length)
|
|
145
|
-
exitCode = 1;
|
|
146
|
-
}
|
|
147
|
-
const profile = await readRuleProfile(projectRoot);
|
|
148
|
-
if (profile.capabilities.includes('client-only')) {
|
|
149
|
-
const findings = await clientOnlyBoundaryViolations(projectRoot);
|
|
150
|
-
results['client-only-boundary'] = {
|
|
151
|
-
status: findings.length ? 'fail' : 'pass',
|
|
152
|
-
exitCode: findings.length ? 1 : 0,
|
|
153
|
-
stderr: findings.join('\n'),
|
|
154
|
-
diagnostics: findings.map((message) => ({ message })),
|
|
155
|
-
};
|
|
156
|
-
if (findings.length)
|
|
157
|
-
exitCode = 1;
|
|
158
|
-
}
|
|
159
|
-
for (const [id, installed] of Object.entries(current.installed).sort(([a], [b]) => a.localeCompare(b))) {
|
|
160
|
-
const entry = byId.get(id);
|
|
161
|
-
if (!entry || installed.kind !== 'rule')
|
|
162
|
-
continue;
|
|
163
|
-
const prepared = await prepareCanonicalManifest(source, entry, canonicalCheckRoot, checkerRuntimeRoot);
|
|
164
|
-
if (!prepared?.checkerPath) {
|
|
165
|
-
if ((entry.enforcement ?? 'guidance') === 'guidance')
|
|
166
|
-
continue;
|
|
167
|
-
results[id] = {
|
|
168
|
-
status: 'fail',
|
|
169
|
-
exitCode: 1,
|
|
170
|
-
stderr: 'Canonical checker unavailable for enforced installed rule.',
|
|
171
|
-
};
|
|
172
|
-
exitCode = 1;
|
|
173
|
-
continue;
|
|
174
|
-
}
|
|
175
|
-
if (prepared.execution === 'manual')
|
|
176
|
-
continue;
|
|
177
|
-
const baseKey = prepared.checkerKey ??
|
|
178
|
-
`path:${prepared.checkerPath}:${JSON.stringify(prepared.checkerArgs ?? [])}`;
|
|
179
|
-
const key = `${baseKey}:targeting:${prepared.targeting?.scope ?? 'repository'}:execution:${prepared.execution ?? 'automatic'}`;
|
|
180
|
-
const group = groups.get(key) ?? {
|
|
181
|
-
checkerPath: prepared.checkerPath,
|
|
182
|
-
checkerArgs: prepared.checkerArgs ?? [],
|
|
183
|
-
targeting: prepared.targeting ?? { scope: 'repository' },
|
|
184
|
-
ids: [],
|
|
185
|
-
};
|
|
186
|
-
group.ids.push(id);
|
|
187
|
-
groups.set(key, group);
|
|
188
|
-
}
|
|
189
|
-
const groupExecutions = await runWithConcurrency([...groups.values()], options.concurrency ?? 6, async (group) => {
|
|
190
|
-
const args = [group.checkerPath, ...group.checkerArgs];
|
|
191
|
-
if (targetMode !== 'full' && group.targeting.scope !== 'repository') {
|
|
192
|
-
args.push('--target-mode', targetMode);
|
|
193
|
-
for (const file of normalizedTargetFiles)
|
|
194
|
-
args.push('--target-file', file);
|
|
195
|
-
}
|
|
196
|
-
const execution = await executor('node', args, projectRoot);
|
|
197
|
-
return { group, execution };
|
|
198
|
-
});
|
|
199
|
-
for (const { group, execution } of groupExecutions) {
|
|
200
|
-
const diagnostics = collectCheckerDiagnostics(execution);
|
|
201
|
-
const result = {
|
|
202
|
-
status: execution.exitCode === 0 ? 'pass' : 'fail',
|
|
203
|
-
...execution,
|
|
204
|
-
diagnostics,
|
|
205
|
-
};
|
|
206
|
-
for (const id of group.ids)
|
|
207
|
-
results[id] = result;
|
|
208
|
-
if (execution.exitCode !== 0)
|
|
209
|
-
exitCode = 1;
|
|
210
|
-
}
|
|
211
|
-
const orderedResults = Object.fromEntries(Object.entries(results).sort(([a], [b]) => a.localeCompare(b)));
|
|
212
|
-
if (targetMode === 'full') {
|
|
213
|
-
await writeChecksState(projectRoot, {
|
|
214
|
-
schemaVersion: 2,
|
|
215
|
-
checkedAt: new Date().toISOString(),
|
|
216
|
-
results: Object.fromEntries(Object.entries(orderedResults).map(([id, result]) => [id, { status: result.status }])),
|
|
217
|
-
});
|
|
218
|
-
}
|
|
219
|
-
return {
|
|
220
|
-
exitCode,
|
|
221
|
-
results: orderedResults,
|
|
222
|
-
executions: groupExecutions.map(({ group, execution }) => ({
|
|
223
|
-
ids: [...group.ids].sort(),
|
|
224
|
-
checkerPath: group.checkerPath,
|
|
225
|
-
exitCode: execution.exitCode,
|
|
226
|
-
stdout: execution.stdout,
|
|
227
|
-
stderr: execution.stderr,
|
|
228
|
-
diagnostics: collectCheckerDiagnostics(execution),
|
|
229
|
-
})),
|
|
230
|
-
};
|
|
231
|
-
}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
export declare const RULE_PROFILE_RELATIVE_PATH = ".spd/rules.json";
|
|
2
|
-
export declare const PROJECT_TYPES: readonly string[];
|
|
3
|
-
export declare const EMPTY_RULE_PROFILE: Readonly<{
|
|
4
|
-
schemaVersion: 1;
|
|
5
|
-
projectType: null;
|
|
6
|
-
capabilities: never[];
|
|
7
|
-
include: never[];
|
|
8
|
-
exclude: never[];
|
|
9
|
-
}>;
|
|
10
|
-
export declare function validateRuleProfile(profile: unknown): {
|
|
11
|
-
schemaVersion: number;
|
|
12
|
-
projectType: string | null;
|
|
13
|
-
capabilities: unknown[];
|
|
14
|
-
include: unknown[];
|
|
15
|
-
exclude: {
|
|
16
|
-
id: string;
|
|
17
|
-
reason: string;
|
|
18
|
-
}[];
|
|
19
|
-
};
|
|
20
|
-
export declare function readRuleProfile(projectRoot: string): Promise<{
|
|
21
|
-
schemaVersion: number;
|
|
22
|
-
projectType: string | null;
|
|
23
|
-
capabilities: unknown[];
|
|
24
|
-
include: unknown[];
|
|
25
|
-
exclude: {
|
|
26
|
-
id: string;
|
|
27
|
-
reason: string;
|
|
28
|
-
}[];
|
|
29
|
-
}>;
|
|
30
|
-
export declare function assertKnownRuleOverrides(entries: any[], profile: any): void;
|
|
31
|
-
export declare function resolveProjectType(stack: string | null, profile?: any): any;
|
|
32
|
-
export declare const STACK_PACKAGES: Record<string, string[]>;
|
|
33
|
-
export declare function ruleApplies(entry: any, stack: string | null, profile?: any, packageIds?: Iterable<string>): boolean;
|
|
34
|
-
export declare function projectRuleApplies(entry: any, stack: string | null, profile?: any, entries?: any[], packageIds?: Iterable<string>): any;
|
|
35
|
-
export declare function applicableCatalogEntries(entries: any[], stack: string | null, profile?: any, packageIds?: Iterable<string>): any[];
|
|
36
|
-
export declare function detectProjectStack(projectRoot: string): Promise<string | null>;
|
|
37
|
-
export declare function resolveProjectStack(projectRoot: string): Promise<any>;
|
|
38
|
-
export declare function loadProjectContext(projectRoot: string, entries: any[]): Promise<{
|
|
39
|
-
stack: any;
|
|
40
|
-
profile: {
|
|
41
|
-
schemaVersion: number;
|
|
42
|
-
projectType: string | null;
|
|
43
|
-
capabilities: unknown[];
|
|
44
|
-
include: unknown[];
|
|
45
|
-
exclude: {
|
|
46
|
-
id: string;
|
|
47
|
-
reason: string;
|
|
48
|
-
}[];
|
|
49
|
-
};
|
|
50
|
-
projectType: any;
|
|
51
|
-
applicable: any[];
|
|
52
|
-
}>;
|