@specdest/devkit 0.4.8 → 0.4.10
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 +26 -24
- package/dist/npm/canonical-project.d.ts +12 -1
- package/dist/npm/canonical-project.js +10 -4
- package/dist/npm/canonical-source.d.ts +14 -2
- package/dist/npm/canonical-source.js +46 -14
- package/dist/npm/catalog-snapshot.d.ts +32 -26
- package/dist/npm/catalog-snapshot.js +11 -4
- package/dist/npm/cli.js +5 -2
- package/dist/npm/client-only-boundary.d.ts +1 -0
- package/dist/npm/client-only-boundary.js +29 -0
- package/dist/npm/commands.d.ts +6 -0
- package/dist/npm/commands.js +33 -8
- package/dist/npm/flow.js +52 -18
- package/dist/npm/git-catalog.d.ts +33 -32
- package/dist/npm/git-catalog.js +49 -17
- package/dist/npm/index.d.ts +0 -1
- package/dist/npm/index.js +13 -3
- package/dist/npm/installer-primitives.d.ts +3 -3
- package/dist/npm/predefined-packages/expo.js +5 -1
- package/dist/npm/predefined-packages/index.d.ts +1 -0
- package/dist/npm/predefined-packages/index.js +44 -3
- package/dist/npm/predefined-packages/install.js +3 -2
- package/dist/npm/predefined-packages/supabase.js +297 -26
- package/dist/npm/predefined-packages/types.d.ts +7 -0
- package/dist/npm/predefined-packages/vite.js +5 -1
- package/dist/npm/project-check.d.ts +8 -0
- package/dist/npm/project-check.js +52 -7
- package/dist/npm/project-context.d.ts +14 -4
- package/dist/npm/project-context.js +37 -18
- package/dist/npm/project-rules.d.ts +4 -1
- package/dist/npm/project-rules.js +15 -6
- package/dist/npm/project-runtime.d.ts +4 -1
- package/dist/npm/project-runtime.js +19 -5
- package/dist/npm/project-status.js +17 -3
- package/dist/npm/project-sync.js +13 -5
- package/dist/npm/remote-installer.d.ts +35 -4
- package/dist/npm/remote-installer.js +75 -36
- package/dist/npm/rule-id-migrations.d.ts +6 -0
- package/dist/npm/rule-id-migrations.js +19 -0
- package/dist/npm/schemas.d.ts +64 -0
- package/dist/npm/schemas.js +194 -0
- package/dist/npm/slack.d.ts +16 -0
- package/dist/npm/slack.js +131 -0
- package/dist/npm/state.js +71 -22
- package/dist/npm/supabase-local.d.ts +2 -0
- package/dist/npm/supabase-local.js +62 -0
- package/package.json +9 -7
- package/dist/npm/fuzz.d.ts +0 -138
- package/dist/npm/fuzz.js +0 -327
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export type SlackTransport = typeof fetch;
|
|
2
|
+
type Io = {
|
|
3
|
+
stdout: {
|
|
4
|
+
write: (s: string) => void;
|
|
5
|
+
};
|
|
6
|
+
stderr: {
|
|
7
|
+
write: (s: string) => void;
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
export declare function sendSlackFiles(args: string[], io?: Io, options?: {
|
|
11
|
+
cwd?: string;
|
|
12
|
+
home?: string;
|
|
13
|
+
env?: NodeJS.ProcessEnv;
|
|
14
|
+
transport?: SlackTransport;
|
|
15
|
+
}): Promise<number>;
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { readFile, stat } from 'node:fs/promises';
|
|
2
|
+
import { basename, isAbsolute, resolve } from 'node:path';
|
|
3
|
+
import { homedir } from 'node:os';
|
|
4
|
+
function parseArgs(args) {
|
|
5
|
+
if (args[0] !== 'send')
|
|
6
|
+
throw new Error('Usage: specdest slack send [--message text] [--thread timestamp] <files...>');
|
|
7
|
+
let message = 'Development artifacts';
|
|
8
|
+
let thread;
|
|
9
|
+
const paths = [];
|
|
10
|
+
for (let i = 1; i < args.length; i++) {
|
|
11
|
+
if ((args[i] === '--message' || args[i] === '--thread') && args[i + 1]) {
|
|
12
|
+
if (args[i] === '--message')
|
|
13
|
+
message = args[++i];
|
|
14
|
+
else
|
|
15
|
+
thread = args[++i];
|
|
16
|
+
}
|
|
17
|
+
else if (args[i].startsWith('-'))
|
|
18
|
+
throw new Error(`Unknown option: ${args[i]}`);
|
|
19
|
+
else
|
|
20
|
+
paths.push(args[i]);
|
|
21
|
+
}
|
|
22
|
+
if (!paths.length)
|
|
23
|
+
throw new Error('Specify at least one file');
|
|
24
|
+
if (thread && !/^\d+\.\d+$/.test(thread))
|
|
25
|
+
throw new Error('Invalid Slack thread timestamp');
|
|
26
|
+
return { paths, message, thread };
|
|
27
|
+
}
|
|
28
|
+
async function readEnvFile(path) {
|
|
29
|
+
let content;
|
|
30
|
+
try {
|
|
31
|
+
content = await readFile(path, 'utf8');
|
|
32
|
+
}
|
|
33
|
+
catch (error) {
|
|
34
|
+
if (error.code === 'ENOENT')
|
|
35
|
+
return {};
|
|
36
|
+
throw error;
|
|
37
|
+
}
|
|
38
|
+
const values = {};
|
|
39
|
+
for (const line of content.split(/\r?\n/)) {
|
|
40
|
+
const match = line.match(/^\s*(?:export\s+)?(SLACK_BOT_TOKEN|SLACK_CHANNEL_ID)=(.*)$/);
|
|
41
|
+
if (match)
|
|
42
|
+
values[match[1]] = match[2].trim().replace(/^['"]|['"]$/g, '');
|
|
43
|
+
}
|
|
44
|
+
return values;
|
|
45
|
+
}
|
|
46
|
+
async function slackCredentials(cwd, env, home) {
|
|
47
|
+
const local = await readEnvFile(resolve(cwd, '.env.e2e.local'));
|
|
48
|
+
const shared = await readEnvFile(resolve(home, '.config/specdest/slack.env'));
|
|
49
|
+
const token = env.SLACK_BOT_TOKEN?.trim() || local.SLACK_BOT_TOKEN || shared.SLACK_BOT_TOKEN;
|
|
50
|
+
if (!token)
|
|
51
|
+
throw new Error('Slack token missing: set SLACK_BOT_TOKEN or configure .env.e2e.local or ~/.config/specdest/slack.env');
|
|
52
|
+
return { token, channel: env.SLACK_CHANNEL_ID?.trim() || local.SLACK_CHANNEL_ID };
|
|
53
|
+
}
|
|
54
|
+
async function slackJson(transport, token, method, params) {
|
|
55
|
+
const response = await transport(`https://slack.com/api/${method}`, {
|
|
56
|
+
method: 'POST',
|
|
57
|
+
headers: {
|
|
58
|
+
Authorization: `Bearer ${token}`,
|
|
59
|
+
'Content-Type': 'application/x-www-form-urlencoded',
|
|
60
|
+
},
|
|
61
|
+
body: new URLSearchParams(params),
|
|
62
|
+
signal: AbortSignal.timeout(30000),
|
|
63
|
+
});
|
|
64
|
+
if (!response.ok)
|
|
65
|
+
throw new Error(`Slack ${method} HTTP ${response.status}`);
|
|
66
|
+
const data = (await response.json());
|
|
67
|
+
if (!data.ok)
|
|
68
|
+
throw new Error(`Slack ${method}: ${data.error ?? 'unknown error'}`);
|
|
69
|
+
return data;
|
|
70
|
+
}
|
|
71
|
+
export async function sendSlackFiles(args, io = process, options = {}) {
|
|
72
|
+
try {
|
|
73
|
+
const { paths, message, thread } = parseArgs(args);
|
|
74
|
+
const cwd = options.cwd ?? process.cwd();
|
|
75
|
+
const env = options.env ?? process.env;
|
|
76
|
+
const { token, channel: envChannel } = await slackCredentials(cwd, env, options.home ?? homedir());
|
|
77
|
+
let projectChannel;
|
|
78
|
+
if (!envChannel) {
|
|
79
|
+
try {
|
|
80
|
+
const configuration = JSON.parse(await readFile(resolve(cwd, '.spd/config.json'), 'utf8'));
|
|
81
|
+
projectChannel = configuration.slack?.channel;
|
|
82
|
+
}
|
|
83
|
+
catch (error) {
|
|
84
|
+
if (error.code !== 'ENOENT')
|
|
85
|
+
throw error;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
const channel = envChannel || projectChannel;
|
|
89
|
+
if (typeof channel !== 'string' || !/^[CGD][A-Z0-9]+$/.test(channel))
|
|
90
|
+
throw new Error('Set SLACK_CHANNEL_ID or slack.channel in .spd/config.json');
|
|
91
|
+
const files = await Promise.all(paths.map(async (path) => {
|
|
92
|
+
const absolute = isAbsolute(path) ? path : resolve(cwd, path);
|
|
93
|
+
const metadata = await stat(absolute);
|
|
94
|
+
if (!metadata.isFile() || metadata.size === 0)
|
|
95
|
+
throw new Error(`Not a nonempty file: ${path}`);
|
|
96
|
+
return { name: basename(path), data: await readFile(absolute) };
|
|
97
|
+
}));
|
|
98
|
+
const transport = options.transport ?? fetch;
|
|
99
|
+
const parent = thread ??
|
|
100
|
+
(await slackJson(transport, token, 'chat.postMessage', { channel, text: message })).ts;
|
|
101
|
+
if (!parent)
|
|
102
|
+
throw new Error('Slack did not return a thread timestamp');
|
|
103
|
+
for (const file of files) {
|
|
104
|
+
const slot = await slackJson(transport, token, 'files.getUploadURLExternal', {
|
|
105
|
+
filename: file.name,
|
|
106
|
+
length: String(file.data.length),
|
|
107
|
+
});
|
|
108
|
+
if (!slot.upload_url || !slot.file_id)
|
|
109
|
+
throw new Error('Slack did not return a file upload URL');
|
|
110
|
+
const response = await transport(slot.upload_url, {
|
|
111
|
+
method: 'POST',
|
|
112
|
+
body: file.data,
|
|
113
|
+
signal: AbortSignal.timeout(60000),
|
|
114
|
+
});
|
|
115
|
+
if (!response.ok)
|
|
116
|
+
throw new Error(`Slack file upload HTTP ${response.status}`);
|
|
117
|
+
await slackJson(transport, token, 'files.completeUploadExternal', {
|
|
118
|
+
files: JSON.stringify([{ id: slot.file_id, title: file.name }]),
|
|
119
|
+
channel_id: channel,
|
|
120
|
+
thread_ts: parent,
|
|
121
|
+
});
|
|
122
|
+
io.stdout.write(`Uploaded ${file.name}\n`);
|
|
123
|
+
}
|
|
124
|
+
io.stdout.write(`Slack thread: ${parent}\n`);
|
|
125
|
+
return 0;
|
|
126
|
+
}
|
|
127
|
+
catch (error) {
|
|
128
|
+
io.stderr.write(`${error instanceof Error ? error.message : String(error)}\n`);
|
|
129
|
+
return 1;
|
|
130
|
+
}
|
|
131
|
+
}
|
package/dist/npm/state.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { access, mkdir, readFile, readdir, rename, writeFile } from 'node:fs/promises';
|
|
2
2
|
import { dirname, join } from 'node:path';
|
|
3
|
+
import { ChecksStateSchema, InstalledStateSchema, parseWithSchema } from "./schemas.js";
|
|
4
|
+
import { migrateRuleId, migrateRuleIdList, migrateRuleIdMap } from "./rule-id-migrations.js";
|
|
3
5
|
export const STATE_SCHEMA_VERSION = 2;
|
|
4
6
|
export const CHECKS_SCHEMA_VERSION = 2;
|
|
5
7
|
export const METADATA_DIRECTORY = '.spd';
|
|
@@ -15,6 +17,29 @@ const JSON_LINE_WIDTH = 100;
|
|
|
15
17
|
function clone(value) {
|
|
16
18
|
return JSON.parse(JSON.stringify(value));
|
|
17
19
|
}
|
|
20
|
+
function migrateInstalledStateRuleIds(state) {
|
|
21
|
+
const installed = Object.fromEntries(Object.entries(migrateRuleIdMap(state.installed ?? {})).map(([id, raw]) => {
|
|
22
|
+
const entry = clone(raw);
|
|
23
|
+
if (Array.isArray(entry.check?.command) &&
|
|
24
|
+
entry.check.command[0] === 'specdest-cache' &&
|
|
25
|
+
typeof entry.check.command[1] === 'string') {
|
|
26
|
+
entry.check.command[1] = migrateRuleId(entry.check.command[1]);
|
|
27
|
+
}
|
|
28
|
+
return [id, entry];
|
|
29
|
+
}));
|
|
30
|
+
return {
|
|
31
|
+
...state,
|
|
32
|
+
requested: migrateRuleIdList(state.requested ?? []),
|
|
33
|
+
installed,
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
function migrateChecksStateRuleIds(state) {
|
|
37
|
+
return {
|
|
38
|
+
...state,
|
|
39
|
+
results: migrateRuleIdMap(state.results ?? {}),
|
|
40
|
+
...(state.ownership ? { ownership: migrateRuleIdMap(state.ownership) } : {}),
|
|
41
|
+
};
|
|
42
|
+
}
|
|
18
43
|
function isOmittedJsonValue(value) {
|
|
19
44
|
return value === undefined || ['function', 'symbol'].includes(typeof value);
|
|
20
45
|
}
|
|
@@ -28,7 +53,9 @@ function formatJsonValue(value, depth = 0, { arrayItem = false } = {}) {
|
|
|
28
53
|
if (Array.isArray(value)) {
|
|
29
54
|
if (!value.length)
|
|
30
55
|
return '[]';
|
|
31
|
-
const primitive = value.every((item) => isOmittedJsonValue(item) ||
|
|
56
|
+
const primitive = value.every((item) => isOmittedJsonValue(item) ||
|
|
57
|
+
item === null ||
|
|
58
|
+
['string', 'number', 'boolean'].includes(typeof item));
|
|
32
59
|
if (primitive) {
|
|
33
60
|
const inline = `[${value.map((item) => formatJsonValue(item, depth + 1, { arrayItem: true })).join(', ')}]`;
|
|
34
61
|
if (indent.length + inline.length <= JSON_LINE_WIDTH)
|
|
@@ -62,7 +89,7 @@ async function listRelativeFiles(root, directory = '') {
|
|
|
62
89
|
for (const entry of entries.sort((a, b) => a.name.localeCompare(b.name))) {
|
|
63
90
|
const relativePath = directory ? join(directory, entry.name) : entry.name;
|
|
64
91
|
if (entry.isDirectory())
|
|
65
|
-
files.push(...await listRelativeFiles(root, relativePath));
|
|
92
|
+
files.push(...(await listRelativeFiles(root, relativePath)));
|
|
66
93
|
else
|
|
67
94
|
files.push(relativePath);
|
|
68
95
|
}
|
|
@@ -117,42 +144,55 @@ async function writeJsonAtomic(filePath, value) {
|
|
|
117
144
|
await rename(temp, filePath);
|
|
118
145
|
}
|
|
119
146
|
function validId(value) {
|
|
120
|
-
return Boolean(typeof value === 'string' &&
|
|
147
|
+
return Boolean(typeof value === 'string' &&
|
|
148
|
+
value &&
|
|
121
149
|
value.split('-').every((part) => part && /^[A-Za-z0-9_]+$/u.test(part)));
|
|
122
150
|
}
|
|
123
151
|
function validateInstalledState(state) {
|
|
124
|
-
const
|
|
125
|
-
const
|
|
126
|
-
|
|
152
|
+
const parsed = parseWithSchema(InstalledStateSchema, state, '.spd/installed.json state');
|
|
153
|
+
const legacy = parsed.schemaVersion === 1;
|
|
154
|
+
const current = parsed.schemaVersion === STATE_SCHEMA_VERSION;
|
|
155
|
+
if (!legacy && !current)
|
|
127
156
|
throw new Error('Invalid .spd/installed.json state');
|
|
128
|
-
|
|
129
|
-
|
|
157
|
+
if (current &&
|
|
158
|
+
(!Array.isArray(parsed.requested) ||
|
|
159
|
+
parsed.requested.some((id) => !validId(id) || !parsed.installed[id]))) {
|
|
130
160
|
throw new Error('Invalid .spd/installed.json requested roots');
|
|
131
161
|
}
|
|
132
|
-
return
|
|
162
|
+
return parsed;
|
|
133
163
|
}
|
|
134
164
|
function validateChecksState(state) {
|
|
135
|
-
const
|
|
136
|
-
const
|
|
137
|
-
|
|
165
|
+
const parsed = parseWithSchema(ChecksStateSchema, state, '.spd/state.json state');
|
|
166
|
+
const legacy = parsed.schemaVersion === 1;
|
|
167
|
+
const current = parsed.schemaVersion === CHECKS_SCHEMA_VERSION;
|
|
168
|
+
if (!legacy && !current)
|
|
138
169
|
throw new Error('Invalid .spd/state.json state');
|
|
139
|
-
|
|
140
|
-
|
|
170
|
+
if (legacy &&
|
|
171
|
+
parsed.checkedAt !== undefined &&
|
|
172
|
+
parsed.checkedAt !== null &&
|
|
173
|
+
typeof parsed.checkedAt !== 'string') {
|
|
141
174
|
throw new Error('Invalid .spd/state.json checkedAt');
|
|
142
175
|
}
|
|
143
|
-
return
|
|
176
|
+
return parsed;
|
|
144
177
|
}
|
|
145
178
|
export async function readInstalledState(projectRoot) {
|
|
146
179
|
await ensureMetadataNamespace(projectRoot);
|
|
147
|
-
const
|
|
148
|
-
|
|
180
|
+
const path = join(projectRoot, INSTALLED_RELATIVE_PATH);
|
|
181
|
+
const raw = await readJsonOrDefault(path, EMPTY_INSTALLED);
|
|
182
|
+
const state = validateInstalledState(raw);
|
|
183
|
+
if (state.schemaVersion !== STATE_SCHEMA_VERSION)
|
|
184
|
+
return state;
|
|
185
|
+
const migrated = migrateInstalledStateRuleIds(state);
|
|
186
|
+
if (JSON.stringify(migrated) !== JSON.stringify(state))
|
|
187
|
+
await writeJsonAtomic(path, migrated);
|
|
188
|
+
return validateInstalledState(migrated);
|
|
149
189
|
}
|
|
150
190
|
export async function writeInstalledState(projectRoot, state) {
|
|
151
191
|
await ensureMetadataNamespace(projectRoot);
|
|
152
192
|
validateInstalledState(state);
|
|
153
193
|
if (state.schemaVersion !== STATE_SCHEMA_VERSION)
|
|
154
194
|
throw new Error('Cannot write legacy .spd/installed.json state');
|
|
155
|
-
await writeJsonAtomic(join(projectRoot, INSTALLED_RELATIVE_PATH), state);
|
|
195
|
+
await writeJsonAtomic(join(projectRoot, INSTALLED_RELATIVE_PATH), migrateInstalledStateRuleIds(state));
|
|
156
196
|
}
|
|
157
197
|
export async function readChecksState(projectRoot) {
|
|
158
198
|
await ensureMetadataNamespace(projectRoot);
|
|
@@ -166,17 +206,26 @@ export async function readChecksState(projectRoot) {
|
|
|
166
206
|
throw error;
|
|
167
207
|
state = await readJsonOrDefault(join(projectRoot, LEGACY_CHECKS_RELATIVE_PATH), EMPTY_CHECKS);
|
|
168
208
|
}
|
|
169
|
-
|
|
209
|
+
const validated = validateChecksState(state);
|
|
210
|
+
if (validated.schemaVersion !== CHECKS_SCHEMA_VERSION)
|
|
211
|
+
return validated;
|
|
212
|
+
const migrated = migrateChecksStateRuleIds(validated);
|
|
213
|
+
if (JSON.stringify(migrated) !== JSON.stringify(validated))
|
|
214
|
+
await writeJsonAtomic(statePath, migrated);
|
|
215
|
+
return validateChecksState(migrated);
|
|
170
216
|
}
|
|
171
217
|
export async function writeChecksState(projectRoot, state) {
|
|
172
218
|
await ensureMetadataNamespace(projectRoot);
|
|
173
219
|
validateChecksState(state);
|
|
174
220
|
if (state.schemaVersion !== CHECKS_SCHEMA_VERSION)
|
|
175
221
|
throw new Error('Cannot write legacy .spd/state.json state');
|
|
176
|
-
const current = await readJsonOrDefault(join(projectRoot, STATE_RELATIVE_PATH), {
|
|
177
|
-
|
|
222
|
+
const current = migrateChecksStateRuleIds(await readJsonOrDefault(join(projectRoot, STATE_RELATIVE_PATH), {
|
|
223
|
+
schemaVersion: CHECKS_SCHEMA_VERSION,
|
|
224
|
+
results: {},
|
|
225
|
+
}));
|
|
226
|
+
await writeJsonAtomic(join(projectRoot, STATE_RELATIVE_PATH), migrateChecksStateRuleIds({
|
|
178
227
|
...current,
|
|
179
228
|
...state,
|
|
180
229
|
schemaVersion: CHECKS_SCHEMA_VERSION,
|
|
181
|
-
});
|
|
230
|
+
}));
|
|
182
231
|
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { spawnSync } from 'node:child_process';
|
|
2
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
3
|
+
import { resolve } from 'node:path';
|
|
4
|
+
const OPERATIONS = new Set(['status', 'start', 'stop']);
|
|
5
|
+
const ID = /^[a-f0-9]{32}$/;
|
|
6
|
+
// Use the Supabase project's declared identity rather than a checkout-path heuristic.
|
|
7
|
+
const PROJECT_IDS = {
|
|
8
|
+
mykone: 'mycone-app',
|
|
9
|
+
one_and_only: 'one_and_only',
|
|
10
|
+
};
|
|
11
|
+
export function projectFromCwd(cwd) {
|
|
12
|
+
const config = resolve(cwd, 'supabase/config.toml');
|
|
13
|
+
if (!existsSync(config))
|
|
14
|
+
return undefined;
|
|
15
|
+
const match = /^project_id\s*=\s*"([^"]+)"\s*$/mu.exec(readFileSync(config, 'utf8'));
|
|
16
|
+
return match ? PROJECT_IDS[match[1]] : undefined;
|
|
17
|
+
}
|
|
18
|
+
export function runSupabaseLocal(args, cwd = process.cwd()) {
|
|
19
|
+
if (args[0] === 'result' && args.length === 2 && ID.test(args[1])) {
|
|
20
|
+
const queue = process.env.SPECDEST_HOST_CLI_QUEUE;
|
|
21
|
+
if (!queue) {
|
|
22
|
+
process.stderr.write('Host queue not configured.\n');
|
|
23
|
+
return 2;
|
|
24
|
+
}
|
|
25
|
+
const file = resolve(queue, 'outbox', `${args[1]}.json`);
|
|
26
|
+
if (!existsSync(file)) {
|
|
27
|
+
process.stdout.write('Pending or unavailable.\n');
|
|
28
|
+
return 3;
|
|
29
|
+
}
|
|
30
|
+
const result = JSON.parse(readFileSync(file, 'utf8'));
|
|
31
|
+
if (result.stdout)
|
|
32
|
+
process.stdout.write(result.stdout);
|
|
33
|
+
if (result.stderr)
|
|
34
|
+
process.stderr.write(result.stderr);
|
|
35
|
+
if (result.error)
|
|
36
|
+
process.stderr.write(`${result.error}\n`);
|
|
37
|
+
return typeof result.exit_code === 'number' ? result.exit_code : 1;
|
|
38
|
+
}
|
|
39
|
+
if (args.length !== 1 || !OPERATIONS.has(args[0])) {
|
|
40
|
+
process.stderr.write('Usage: specdest supabase <status|start|stop|result ID>\n');
|
|
41
|
+
return 2;
|
|
42
|
+
}
|
|
43
|
+
if (!existsSync(resolve(cwd, 'supabase/config.toml'))) {
|
|
44
|
+
process.stderr.write('Run from a Supabase project root.\n');
|
|
45
|
+
return 2;
|
|
46
|
+
}
|
|
47
|
+
const project = projectFromCwd(cwd);
|
|
48
|
+
if (!project) {
|
|
49
|
+
process.stderr.write('Project is not registered with the restricted Controller gateway.\n');
|
|
50
|
+
return 2;
|
|
51
|
+
}
|
|
52
|
+
// Prefer the generic macOS gateway when its client is installed in Local Coder.
|
|
53
|
+
if (process.env.SPECDEST_HOST_CLI_QUEUE && existsSync('/usr/local/bin/host-cli')) {
|
|
54
|
+
const result = spawnSync('/usr/local/bin/host-cli', [project, 'nps', `local.db.${args[0]}`], {
|
|
55
|
+
stdio: 'inherit',
|
|
56
|
+
shell: false,
|
|
57
|
+
});
|
|
58
|
+
return result.status ?? 1;
|
|
59
|
+
}
|
|
60
|
+
process.stderr.write('Controller host gateway unavailable; no legacy fallback.\n');
|
|
61
|
+
return 1;
|
|
62
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@specdest/devkit",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.10",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"bin": {
|
|
6
6
|
"specdest": "dist/npm/cli.js"
|
|
@@ -21,9 +21,10 @@
|
|
|
21
21
|
},
|
|
22
22
|
"scripts": {
|
|
23
23
|
"test": "node --test test/*.test.js",
|
|
24
|
+
"db:validate": "node scripts/validate-db-command-aliases.mjs",
|
|
24
25
|
"test:acceptance": "node scripts/fresh-project-acceptance.mjs",
|
|
25
|
-
"lint": "
|
|
26
|
-
"check": "pnpm run lint && pnpm run rules:validate && pnpm run rules:audit && pnpm run typecheck && pnpm run test",
|
|
26
|
+
"lint": "oxlint src",
|
|
27
|
+
"check": "pnpm run lint && pnpm run format:check && pnpm run rules:validate && pnpm run rules:audit && pnpm run typecheck && pnpm run test",
|
|
27
28
|
"rules:validate": "node scripts/validate-rule-authoring.mjs",
|
|
28
29
|
"catalog:snapshot": "node scripts/export-catalog-snapshot.mjs",
|
|
29
30
|
"release:preflight": "node scripts/release-preflight.mjs",
|
|
@@ -37,14 +38,15 @@
|
|
|
37
38
|
"rules:audit:write": "node scripts/generate-rule-audit.mjs",
|
|
38
39
|
"typecheck:checkers": "node scripts/typecheck-checkers.mjs",
|
|
39
40
|
"build": "node -e \"require('node:fs').rmSync('dist/npm',{recursive:true,force:true})\" && tsc -p tsconfig.build.json",
|
|
40
|
-
"prepack": "pnpm run build"
|
|
41
|
+
"prepack": "pnpm run build",
|
|
42
|
+
"format:check": "oxfmt --check src/*.ts",
|
|
43
|
+
"format": "oxfmt --write src/*.ts"
|
|
41
44
|
},
|
|
42
45
|
"devDependencies": {
|
|
43
46
|
"@types/node": "^24.0.0",
|
|
44
47
|
"typescript": "^6.0.0",
|
|
48
|
+
"oxlint": "1.82.0",
|
|
49
|
+
"oxfmt": "0.54.0",
|
|
45
50
|
"zod": "^4.6.4"
|
|
46
|
-
},
|
|
47
|
-
"dependencies": {
|
|
48
|
-
"fast-check": "^4.10.0"
|
|
49
51
|
}
|
|
50
52
|
}
|
package/dist/npm/fuzz.d.ts
DELETED
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
export function zodArbitrary(schema: any): any;
|
|
2
|
-
export function amplifySchema(schema: any, sample: any): ({
|
|
3
|
-
path: any;
|
|
4
|
-
label: string | number | boolean | null[] | undefined[];
|
|
5
|
-
value: string | number | boolean | null[] | undefined[];
|
|
6
|
-
accepted: any;
|
|
7
|
-
concern: string | null;
|
|
8
|
-
} | {
|
|
9
|
-
path: any;
|
|
10
|
-
label: string | any[];
|
|
11
|
-
value: string | any[];
|
|
12
|
-
accepted: any;
|
|
13
|
-
concern: null;
|
|
14
|
-
} | {
|
|
15
|
-
path: any;
|
|
16
|
-
label: string | boolean | null | undefined;
|
|
17
|
-
value: string | boolean | null | undefined;
|
|
18
|
-
accepted: any;
|
|
19
|
-
concern: null;
|
|
20
|
-
})[];
|
|
21
|
-
export function fuzzSchema(schema: any, { seed, numRuns }?: {
|
|
22
|
-
seed?: number | undefined;
|
|
23
|
-
numRuns?: number | undefined;
|
|
24
|
-
}): {
|
|
25
|
-
status: string;
|
|
26
|
-
reason: any;
|
|
27
|
-
seed?: undefined;
|
|
28
|
-
cases?: undefined;
|
|
29
|
-
path?: undefined;
|
|
30
|
-
counterexample?: undefined;
|
|
31
|
-
} | {
|
|
32
|
-
status: string;
|
|
33
|
-
seed: number;
|
|
34
|
-
cases: any[];
|
|
35
|
-
reason?: undefined;
|
|
36
|
-
path?: undefined;
|
|
37
|
-
counterexample?: undefined;
|
|
38
|
-
} | {
|
|
39
|
-
status: string;
|
|
40
|
-
seed: number;
|
|
41
|
-
path: string | null;
|
|
42
|
-
counterexample: any;
|
|
43
|
-
cases: any[];
|
|
44
|
-
reason?: undefined;
|
|
45
|
-
};
|
|
46
|
-
export function discoverFuzzTargets(projectRoot: any): Promise<any>;
|
|
47
|
-
export function runFuzz(projectRoot: any, { seed }?: {
|
|
48
|
-
seed?: number | undefined;
|
|
49
|
-
}): Promise<{
|
|
50
|
-
seed: number;
|
|
51
|
-
targets: any;
|
|
52
|
-
results: ({
|
|
53
|
-
status: string;
|
|
54
|
-
reason: any;
|
|
55
|
-
seed?: undefined;
|
|
56
|
-
cases?: undefined;
|
|
57
|
-
path?: undefined;
|
|
58
|
-
counterexample?: undefined;
|
|
59
|
-
module: any;
|
|
60
|
-
name: string;
|
|
61
|
-
} | {
|
|
62
|
-
status: string;
|
|
63
|
-
seed: number;
|
|
64
|
-
cases: any[];
|
|
65
|
-
reason?: undefined;
|
|
66
|
-
path?: undefined;
|
|
67
|
-
counterexample?: undefined;
|
|
68
|
-
module: any;
|
|
69
|
-
name: string;
|
|
70
|
-
} | {
|
|
71
|
-
status: string;
|
|
72
|
-
seed: number;
|
|
73
|
-
path: string | null;
|
|
74
|
-
counterexample: any;
|
|
75
|
-
cases: any[];
|
|
76
|
-
reason?: undefined;
|
|
77
|
-
module: any;
|
|
78
|
-
name: string;
|
|
79
|
-
})[];
|
|
80
|
-
failed: ({
|
|
81
|
-
status: string;
|
|
82
|
-
reason: any;
|
|
83
|
-
seed?: undefined;
|
|
84
|
-
cases?: undefined;
|
|
85
|
-
path?: undefined;
|
|
86
|
-
counterexample?: undefined;
|
|
87
|
-
module: any;
|
|
88
|
-
name: string;
|
|
89
|
-
} | {
|
|
90
|
-
status: string;
|
|
91
|
-
seed: number;
|
|
92
|
-
cases: any[];
|
|
93
|
-
reason?: undefined;
|
|
94
|
-
path?: undefined;
|
|
95
|
-
counterexample?: undefined;
|
|
96
|
-
module: any;
|
|
97
|
-
name: string;
|
|
98
|
-
} | {
|
|
99
|
-
status: string;
|
|
100
|
-
seed: number;
|
|
101
|
-
path: string | null;
|
|
102
|
-
counterexample: any;
|
|
103
|
-
cases: any[];
|
|
104
|
-
reason?: undefined;
|
|
105
|
-
module: any;
|
|
106
|
-
name: string;
|
|
107
|
-
})[];
|
|
108
|
-
unsupported: ({
|
|
109
|
-
status: string;
|
|
110
|
-
reason: any;
|
|
111
|
-
seed?: undefined;
|
|
112
|
-
cases?: undefined;
|
|
113
|
-
path?: undefined;
|
|
114
|
-
counterexample?: undefined;
|
|
115
|
-
module: any;
|
|
116
|
-
name: string;
|
|
117
|
-
} | {
|
|
118
|
-
status: string;
|
|
119
|
-
seed: number;
|
|
120
|
-
cases: any[];
|
|
121
|
-
reason?: undefined;
|
|
122
|
-
path?: undefined;
|
|
123
|
-
counterexample?: undefined;
|
|
124
|
-
module: any;
|
|
125
|
-
name: string;
|
|
126
|
-
} | {
|
|
127
|
-
status: string;
|
|
128
|
-
seed: number;
|
|
129
|
-
path: string | null;
|
|
130
|
-
counterexample: any;
|
|
131
|
-
cases: any[];
|
|
132
|
-
reason?: undefined;
|
|
133
|
-
module: any;
|
|
134
|
-
name: string;
|
|
135
|
-
})[];
|
|
136
|
-
}>;
|
|
137
|
-
export function createFuzzCommandHandler(projectRoot?: string): (args: any, io: any) => Promise<0 | 1 | 2>;
|
|
138
|
-
export const FUZZ_DEFAULT_SEED: 20260914;
|