@holo-js/cli 0.1.9 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin/holo.mjs +165 -81
- package/dist/broadcast-WI6PJS5P.mjs +203 -0
- package/dist/broadcast-YWS4N5QU.mjs +203 -0
- package/dist/{cache-ETOIQ5IG.mjs → cache-KWNQECAA.mjs} +6 -6
- package/dist/cache-QARFSW4F.mjs +66 -0
- package/dist/{cache-migrations-2GGI4TJK.mjs → cache-migrations-3OXR4FN5.mjs} +50 -30
- package/dist/cache-migrations-MDFMDVTK.mjs +173 -0
- package/dist/{chunk-IMOGEKB4.mjs → chunk-2DKQKZML.mjs} +188 -106
- package/dist/{chunk-7JR73TOH.mjs → chunk-2RGJTPYF.mjs} +36 -25
- package/dist/{chunk-ASTSSSL2.mjs → chunk-EWYXSN2C.mjs} +75 -122
- package/dist/{chunk-F4MT6GBK.mjs → chunk-FGQ2I2YH.mjs} +1 -1
- package/dist/chunk-I7QBCEV7.mjs +33 -0
- package/dist/{chunk-R6BWRY3E.mjs → chunk-ILU426CF.mjs} +3 -1
- package/dist/{chunk-HB4Q7VYK.mjs → chunk-IUDD5FYL.mjs} +28 -273
- package/dist/{chunk-WRZFATUT.mjs → chunk-KWRIBHC3.mjs} +229 -142
- package/dist/{chunk-57SJ566R.mjs → chunk-LBJAJLKU.mjs} +1 -1
- package/dist/{chunk-BAFQ2GOA.mjs → chunk-LXGQCG56.mjs} +1 -1
- package/dist/{chunk-SRPGIWCF.mjs → chunk-ONKESAQA.mjs} +2 -2
- package/dist/chunk-QA7TP5EO.mjs +448 -0
- package/dist/chunk-UPZH6KCF.mjs +3306 -0
- package/dist/{chunk-5EU32E7X.mjs → chunk-VRGB6DIS.mjs} +116 -12
- package/dist/{config-ARLE6PKR.mjs → config-TWEO2R4N.mjs} +3 -3
- package/dist/{dev-6RG5SSZ7.mjs → dev-2OULECTU.mjs} +7 -7
- package/dist/dev-PJMEGTAC.mjs +42 -0
- package/dist/{discovery-FCVGQQVD.mjs → discovery-7FXND7Y6.mjs} +3 -3
- package/dist/{generators-UI2LJK3O.mjs → generators-4BP7B47W.mjs} +11 -34
- package/dist/generators-Z4XLSMC7.mjs +520 -0
- package/dist/index.mjs +167 -83
- package/dist/{media-migrations-JQSDCC7S.mjs → media-migrations-BFEL7NFG.mjs} +9 -20
- package/dist/media-migrations-VR7DLLR6.mjs +106 -0
- package/dist/{queue-BY3PLH4I.mjs → queue-SVOJPTRO.mjs} +10 -10
- package/dist/queue-YCBQTCYI.mjs +625 -0
- package/dist/{queue-migrations-YZUKEZK7.mjs → queue-migrations-HPXOO3NA.mjs} +13 -12
- package/dist/queue-migrations-X4P7FZKJ.mjs +167 -0
- package/dist/{runtime-BI343WHS.mjs → runtime-CPKR663Y.mjs} +9 -9
- package/dist/runtime-GIE56H47.mjs +57 -0
- package/dist/{runtime-ZKD6URAV.mjs → runtime-GSXF4NB3.mjs} +1 -1
- package/dist/runtime-worker.d.ts +2 -0
- package/dist/runtime-worker.mjs +242 -0
- package/dist/{scaffold-UBOS2NZR.mjs → scaffold-3QPGYQEQ.mjs} +9 -5
- package/dist/scaffold-RGAAHC6I.mjs +139 -0
- package/dist/{security-TYPVOYGF.mjs → security-7H5TNHZY.mjs} +6 -6
- package/dist/security-BZGD6ONY.mjs +71 -0
- package/package.json +9 -7
- package/dist/broadcast-VR46UZEL.mjs +0 -84
- package/dist/chunk-ZXDU7RHU.mjs +0 -9
|
@@ -0,0 +1,448 @@
|
|
|
1
|
+
import {
|
|
2
|
+
prepareProjectDiscovery
|
|
3
|
+
} from "./chunk-2RGJTPYF.mjs";
|
|
4
|
+
import {
|
|
5
|
+
syncManagedDriverDependencies
|
|
6
|
+
} from "./chunk-KWRIBHC3.mjs";
|
|
7
|
+
import {
|
|
8
|
+
ensureGeneratedSchemaPlaceholder,
|
|
9
|
+
ensureProjectConfig
|
|
10
|
+
} from "./chunk-ONKESAQA.mjs";
|
|
11
|
+
import {
|
|
12
|
+
renderFrameworkRunner
|
|
13
|
+
} from "./chunk-2DKQKZML.mjs";
|
|
14
|
+
import {
|
|
15
|
+
readTextFile,
|
|
16
|
+
writeTextFile
|
|
17
|
+
} from "./chunk-ILU426CF.mjs";
|
|
18
|
+
|
|
19
|
+
// src/dev.ts
|
|
20
|
+
import { spawnSync, spawn } from "child_process";
|
|
21
|
+
import { watch } from "fs";
|
|
22
|
+
import { readdir, stat } from "fs/promises";
|
|
23
|
+
import { join, dirname, relative, resolve } from "path";
|
|
24
|
+
import { readFile } from "fs/promises";
|
|
25
|
+
async function fileExists(path) {
|
|
26
|
+
try {
|
|
27
|
+
await stat(path);
|
|
28
|
+
return true;
|
|
29
|
+
} catch {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
async function resolveProjectPackageManager(projectRoot) {
|
|
34
|
+
const packageJsonPath = join(projectRoot, "package.json");
|
|
35
|
+
const packageJson = await readTextFile(packageJsonPath);
|
|
36
|
+
if (packageJson) {
|
|
37
|
+
try {
|
|
38
|
+
const parsed = JSON.parse(packageJson);
|
|
39
|
+
const packageManager = typeof parsed.packageManager === "string" ? parsed.packageManager.split("@")[0] : void 0;
|
|
40
|
+
if (packageManager === "bun" || packageManager === "npm" || packageManager === "pnpm" || packageManager === "yarn") {
|
|
41
|
+
return packageManager;
|
|
42
|
+
}
|
|
43
|
+
} catch {
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
if (await fileExists(join(projectRoot, "bun.lock"))) {
|
|
47
|
+
return "bun";
|
|
48
|
+
}
|
|
49
|
+
if (await fileExists(join(projectRoot, "pnpm-lock.yaml"))) {
|
|
50
|
+
return "pnpm";
|
|
51
|
+
}
|
|
52
|
+
if (await fileExists(join(projectRoot, "yarn.lock"))) {
|
|
53
|
+
return "yarn";
|
|
54
|
+
}
|
|
55
|
+
if (await fileExists(join(projectRoot, "package-lock.json"))) {
|
|
56
|
+
return "npm";
|
|
57
|
+
}
|
|
58
|
+
return "bun";
|
|
59
|
+
}
|
|
60
|
+
async function resolvePackageManagerCommand(projectRoot, scriptName) {
|
|
61
|
+
const packageManager = await resolveProjectPackageManager(projectRoot);
|
|
62
|
+
return {
|
|
63
|
+
command: packageManager,
|
|
64
|
+
args: ["run", scriptName]
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
async function resolvePackageManagerInstallInvocation(projectRoot) {
|
|
68
|
+
const packageManager = await resolveProjectPackageManager(projectRoot);
|
|
69
|
+
return {
|
|
70
|
+
command: packageManager,
|
|
71
|
+
args: ["install"]
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
async function runProjectLifecycleScript(io, projectRoot, scriptName, spawn2 = spawnSync) {
|
|
75
|
+
const invocation = await resolvePackageManagerCommand(projectRoot, scriptName);
|
|
76
|
+
const result = spawn2(invocation.command, [...invocation.args], {
|
|
77
|
+
cwd: projectRoot,
|
|
78
|
+
encoding: "utf8",
|
|
79
|
+
env: process.env
|
|
80
|
+
});
|
|
81
|
+
if (result.stdout) {
|
|
82
|
+
io.stdout.write(result.stdout);
|
|
83
|
+
}
|
|
84
|
+
if (result.stderr) {
|
|
85
|
+
io.stderr.write(result.stderr);
|
|
86
|
+
}
|
|
87
|
+
if (result.status !== 0) {
|
|
88
|
+
throw new Error(result.stderr?.trim() || result.stdout?.trim() || `Project script "${scriptName}" failed.`);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
async function runProjectDependencyInstall(io, projectRoot, spawn2 = spawnSync) {
|
|
92
|
+
const invocation = await resolvePackageManagerInstallInvocation(projectRoot);
|
|
93
|
+
const result = spawn2(invocation.command, [...invocation.args], {
|
|
94
|
+
cwd: projectRoot,
|
|
95
|
+
encoding: "utf8",
|
|
96
|
+
env: process.env
|
|
97
|
+
});
|
|
98
|
+
if (result.stdout) {
|
|
99
|
+
io.stdout.write(result.stdout);
|
|
100
|
+
}
|
|
101
|
+
if (result.stderr) {
|
|
102
|
+
io.stderr.write(result.stderr);
|
|
103
|
+
}
|
|
104
|
+
if (result.status !== 0) {
|
|
105
|
+
throw new Error(result.stderr?.trim() || result.stdout?.trim() || "Project dependency installation failed.");
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
var FRAMEWORK_SYNC_DEFINITIONS = [
|
|
109
|
+
{
|
|
110
|
+
framework: "nuxt",
|
|
111
|
+
commands: {
|
|
112
|
+
bun: ["bun", "x", "nuxt", "prepare"],
|
|
113
|
+
npm: ["npm", "exec", "--", "nuxt", "prepare"],
|
|
114
|
+
pnpm: ["pnpm", "exec", "nuxt", "prepare"],
|
|
115
|
+
yarn: ["yarn", "run", "nuxt", "prepare"]
|
|
116
|
+
},
|
|
117
|
+
errorLabel: "nuxt prepare"
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
framework: "sveltekit",
|
|
121
|
+
commands: {
|
|
122
|
+
bun: ["bun", "x", "svelte-kit", "sync"],
|
|
123
|
+
npm: ["npm", "exec", "--", "svelte-kit", "sync"],
|
|
124
|
+
pnpm: ["pnpm", "exec", "svelte-kit", "sync"],
|
|
125
|
+
yarn: ["yarn", "run", "svelte-kit", "sync"]
|
|
126
|
+
},
|
|
127
|
+
errorLabel: "svelte-kit sync"
|
|
128
|
+
}
|
|
129
|
+
];
|
|
130
|
+
async function runProjectPrepare(projectRoot, io, options = {}) {
|
|
131
|
+
const project = await ensureProjectConfig(projectRoot);
|
|
132
|
+
await ensureGeneratedSchemaPlaceholder(projectRoot, project.config);
|
|
133
|
+
await prepareProjectDiscovery(projectRoot, project.config);
|
|
134
|
+
await refreshFrameworkRunner(projectRoot);
|
|
135
|
+
const syncFramework = options.syncFramework ?? true;
|
|
136
|
+
if (syncFramework) {
|
|
137
|
+
await runFrameworkSync(projectRoot, FRAMEWORK_SYNC_DEFINITIONS[0]);
|
|
138
|
+
await runFrameworkSync(projectRoot, FRAMEWORK_SYNC_DEFINITIONS[1]);
|
|
139
|
+
}
|
|
140
|
+
const updatedDependencies = await syncManagedDriverDependencies(projectRoot);
|
|
141
|
+
if (updatedDependencies && io) {
|
|
142
|
+
await runProjectDependencyInstall(io, projectRoot);
|
|
143
|
+
await prepareProjectDiscovery(projectRoot, project.config);
|
|
144
|
+
await refreshFrameworkRunner(projectRoot);
|
|
145
|
+
if (syncFramework) {
|
|
146
|
+
await runFrameworkSync(projectRoot, FRAMEWORK_SYNC_DEFINITIONS[0]);
|
|
147
|
+
await runFrameworkSync(projectRoot, FRAMEWORK_SYNC_DEFINITIONS[1]);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
async function runProjectHotPrepare(projectRoot, io) {
|
|
152
|
+
await runProjectPrepare(projectRoot, io, { syncFramework: false });
|
|
153
|
+
}
|
|
154
|
+
async function refreshFrameworkRunner(projectRoot) {
|
|
155
|
+
const frameworkProjectPath = resolve(projectRoot, ".holo-js/framework/project.json");
|
|
156
|
+
const frameworkRunnerPath = resolve(projectRoot, ".holo-js/framework/run.mjs");
|
|
157
|
+
let framework;
|
|
158
|
+
try {
|
|
159
|
+
const content = await readFile(frameworkProjectPath, "utf8");
|
|
160
|
+
const manifest = JSON.parse(content);
|
|
161
|
+
if (manifest.framework !== "next" && manifest.framework !== "nuxt" && manifest.framework !== "sveltekit") {
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
framework = manifest.framework;
|
|
165
|
+
} catch {
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
await writeTextFile(frameworkRunnerPath, renderFrameworkRunner({ framework }));
|
|
169
|
+
}
|
|
170
|
+
async function runFrameworkSync(projectRoot, definition) {
|
|
171
|
+
const frameworkProjectPath = resolve(projectRoot, ".holo-js/framework/project.json");
|
|
172
|
+
try {
|
|
173
|
+
const content = await readFile(frameworkProjectPath, "utf8");
|
|
174
|
+
const manifest = JSON.parse(content);
|
|
175
|
+
if (manifest.framework !== definition.framework) {
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
} catch {
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
const manager = await resolveProjectPackageManager(projectRoot);
|
|
182
|
+
const invocation = definition.commands[manager];
|
|
183
|
+
const command = invocation[0];
|
|
184
|
+
const args = invocation.slice(1);
|
|
185
|
+
await new Promise((resolve2, reject) => {
|
|
186
|
+
const child = spawn(command, args, {
|
|
187
|
+
cwd: projectRoot,
|
|
188
|
+
stdio: "inherit"
|
|
189
|
+
});
|
|
190
|
+
child.on("close", (code) => {
|
|
191
|
+
if (code === 0) {
|
|
192
|
+
resolve2(void 0);
|
|
193
|
+
} else {
|
|
194
|
+
reject(new Error(`${definition.errorLabel} exited with ${code}`));
|
|
195
|
+
}
|
|
196
|
+
});
|
|
197
|
+
child.on("error", reject);
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
function toPosixSlashes(value) {
|
|
201
|
+
return value.replaceAll("\\", "/");
|
|
202
|
+
}
|
|
203
|
+
var PACKAGE_MANIFEST_DISCOVERY_PATHS = /* @__PURE__ */ new Set([
|
|
204
|
+
"package.json",
|
|
205
|
+
"bun.lock",
|
|
206
|
+
"package-lock.json",
|
|
207
|
+
"pnpm-lock.yaml",
|
|
208
|
+
"yarn.lock"
|
|
209
|
+
]);
|
|
210
|
+
function resolveConfiguredBroadcastPath(project) {
|
|
211
|
+
const configuredPaths = project.config.paths;
|
|
212
|
+
return configuredPaths.broadcast ?? "server/broadcast";
|
|
213
|
+
}
|
|
214
|
+
function resolveConfiguredChannelsPath(project) {
|
|
215
|
+
const configuredPaths = project.config.paths;
|
|
216
|
+
return configuredPaths.channels ?? "server/channels";
|
|
217
|
+
}
|
|
218
|
+
function resolveConfiguredRealtimePath(project) {
|
|
219
|
+
const configuredPaths = project.config.paths;
|
|
220
|
+
return configuredPaths.realtime ?? "server/realtime";
|
|
221
|
+
}
|
|
222
|
+
function resolveConfiguredDiscoveryRoots(project) {
|
|
223
|
+
const authorizationPoliciesPath = project.config.paths.authorizationPolicies || "server/policies";
|
|
224
|
+
const authorizationAbilitiesPath = project.config.paths.authorizationAbilities || "server/abilities";
|
|
225
|
+
return [
|
|
226
|
+
project.config.paths.models,
|
|
227
|
+
project.config.paths.migrations,
|
|
228
|
+
project.config.paths.seeders,
|
|
229
|
+
project.config.paths.commands,
|
|
230
|
+
project.config.paths.jobs,
|
|
231
|
+
project.config.paths.events,
|
|
232
|
+
project.config.paths.listeners,
|
|
233
|
+
authorizationPoliciesPath,
|
|
234
|
+
authorizationAbilitiesPath,
|
|
235
|
+
resolveConfiguredBroadcastPath(project),
|
|
236
|
+
resolveConfiguredChannelsPath(project),
|
|
237
|
+
resolveConfiguredRealtimePath(project),
|
|
238
|
+
"config"
|
|
239
|
+
];
|
|
240
|
+
}
|
|
241
|
+
function isDiscoveryRelevantPath(filePath, project) {
|
|
242
|
+
const normalized = toPosixSlashes(filePath);
|
|
243
|
+
if (PACKAGE_MANIFEST_DISCOVERY_PATHS.has(normalized)) {
|
|
244
|
+
return true;
|
|
245
|
+
}
|
|
246
|
+
const generatedSchemaPath = toPosixSlashes(project.config.paths.generatedSchema ?? ".holo-js/generated/schema.generated.ts");
|
|
247
|
+
if (normalized === generatedSchemaPath) {
|
|
248
|
+
return true;
|
|
249
|
+
}
|
|
250
|
+
if (normalized === ".holo-js/generated" || normalized.startsWith(".holo-js/generated/")) {
|
|
251
|
+
return false;
|
|
252
|
+
}
|
|
253
|
+
if (normalized === ".env" || normalized.startsWith(".env.")) {
|
|
254
|
+
return true;
|
|
255
|
+
}
|
|
256
|
+
return resolveConfiguredDiscoveryRoots(project).some((root) => normalized === root || normalized.startsWith(`${toPosixSlashes(root)}/`));
|
|
257
|
+
}
|
|
258
|
+
function isRecursiveWatchUnsupported(error) {
|
|
259
|
+
return error instanceof Error && (error.message.includes("recursive") || "code" in error && error.code === "ERR_FEATURE_UNAVAILABLE_ON_PLATFORM");
|
|
260
|
+
}
|
|
261
|
+
function isIgnorableWatchError(error) {
|
|
262
|
+
return error instanceof Error && "code" in error && (error.code === "ENOENT" || error.code === "EPERM");
|
|
263
|
+
}
|
|
264
|
+
async function collectDirectoryTree(rootPath, directories) {
|
|
265
|
+
const rootStats = await stat(rootPath).catch(() => void 0);
|
|
266
|
+
if (!rootStats?.isDirectory()) {
|
|
267
|
+
return;
|
|
268
|
+
}
|
|
269
|
+
directories.add(rootPath);
|
|
270
|
+
const entries = await readdir(rootPath, { withFileTypes: true }).catch(() => []);
|
|
271
|
+
for (const entry of entries) {
|
|
272
|
+
if (!entry.isDirectory()) {
|
|
273
|
+
continue;
|
|
274
|
+
}
|
|
275
|
+
await collectDirectoryTree(join(rootPath, entry.name), directories);
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
async function collectDiscoveryWatchRoots(projectRoot, project) {
|
|
279
|
+
const directories = /* @__PURE__ */ new Set();
|
|
280
|
+
const roots = [
|
|
281
|
+
projectRoot,
|
|
282
|
+
...resolveConfiguredDiscoveryRoots(project).map((root) => resolve(projectRoot, root)),
|
|
283
|
+
resolve(projectRoot, dirname(project.config.paths.generatedSchema ?? ".holo-js/generated/schema.generated.ts"))
|
|
284
|
+
];
|
|
285
|
+
for (const rootPath of roots) {
|
|
286
|
+
await collectDirectoryTree(rootPath, directories);
|
|
287
|
+
}
|
|
288
|
+
return [...directories];
|
|
289
|
+
}
|
|
290
|
+
function normalizeWatchedFilePath(projectRoot, watchedRoot, fileName) {
|
|
291
|
+
return toPosixSlashes(relative(projectRoot, resolve(watchedRoot, fileName)));
|
|
292
|
+
}
|
|
293
|
+
async function runProjectDevServer(io, projectRoot, spawnProcess = spawn, createWatcher = watch, prepare = runProjectPrepare) {
|
|
294
|
+
let project = await ensureProjectConfig(projectRoot);
|
|
295
|
+
let refreshNonRecursiveWatchers;
|
|
296
|
+
let requestChildRestart;
|
|
297
|
+
const hotPrepare = prepare === runProjectPrepare ? runProjectHotPrepare : prepare;
|
|
298
|
+
const prepareDiscovery = async (syncFramework = false) => {
|
|
299
|
+
await (syncFramework ? prepare : hotPrepare)(projectRoot, io);
|
|
300
|
+
project = await ensureProjectConfig(projectRoot);
|
|
301
|
+
await refreshNonRecursiveWatchers?.();
|
|
302
|
+
};
|
|
303
|
+
await prepareDiscovery(true);
|
|
304
|
+
let pendingPrepare;
|
|
305
|
+
let queued = false;
|
|
306
|
+
let shuttingDown = false;
|
|
307
|
+
const rerunPrepare = () => {
|
|
308
|
+
if (shuttingDown) {
|
|
309
|
+
return;
|
|
310
|
+
}
|
|
311
|
+
if (pendingPrepare) {
|
|
312
|
+
queued = true;
|
|
313
|
+
return;
|
|
314
|
+
}
|
|
315
|
+
pendingPrepare = prepareDiscovery().then(() => {
|
|
316
|
+
requestChildRestart?.();
|
|
317
|
+
}).catch((error) => {
|
|
318
|
+
io.stderr.write(`${error instanceof Error ? error.message : String(error)}
|
|
319
|
+
`);
|
|
320
|
+
}).finally(() => {
|
|
321
|
+
pendingPrepare = void 0;
|
|
322
|
+
if (queued) {
|
|
323
|
+
queued = false;
|
|
324
|
+
rerunPrepare();
|
|
325
|
+
}
|
|
326
|
+
});
|
|
327
|
+
};
|
|
328
|
+
const closeWatchers = (() => {
|
|
329
|
+
try {
|
|
330
|
+
const watcher = createWatcher(projectRoot, { recursive: true }, (_eventType, fileName) => {
|
|
331
|
+
if (shuttingDown || typeof fileName !== "string" || !isDiscoveryRelevantPath(fileName, project)) {
|
|
332
|
+
return;
|
|
333
|
+
}
|
|
334
|
+
rerunPrepare();
|
|
335
|
+
});
|
|
336
|
+
return () => watcher.close();
|
|
337
|
+
} catch (error) {
|
|
338
|
+
if (!isRecursiveWatchUnsupported(error)) {
|
|
339
|
+
throw error;
|
|
340
|
+
}
|
|
341
|
+
const watchers = [];
|
|
342
|
+
const closeAllWatchers = () => {
|
|
343
|
+
while (watchers.length > 0) {
|
|
344
|
+
watchers.pop()?.close();
|
|
345
|
+
}
|
|
346
|
+
};
|
|
347
|
+
refreshNonRecursiveWatchers = async () => {
|
|
348
|
+
closeAllWatchers();
|
|
349
|
+
const watchRoots = await collectDiscoveryWatchRoots(projectRoot, project);
|
|
350
|
+
for (const watchRoot of watchRoots) {
|
|
351
|
+
try {
|
|
352
|
+
watchers.push(createWatcher(watchRoot, { recursive: false }, (_eventType, fileName) => {
|
|
353
|
+
if (shuttingDown || typeof fileName !== "string") {
|
|
354
|
+
return;
|
|
355
|
+
}
|
|
356
|
+
const normalizedPath = normalizeWatchedFilePath(projectRoot, watchRoot, fileName);
|
|
357
|
+
if (!isDiscoveryRelevantPath(normalizedPath, project)) {
|
|
358
|
+
return;
|
|
359
|
+
}
|
|
360
|
+
rerunPrepare();
|
|
361
|
+
}));
|
|
362
|
+
} catch (watchError) {
|
|
363
|
+
if (!isIgnorableWatchError(watchError)) {
|
|
364
|
+
throw watchError;
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
};
|
|
369
|
+
return () => closeAllWatchers();
|
|
370
|
+
}
|
|
371
|
+
})();
|
|
372
|
+
await refreshNonRecursiveWatchers?.();
|
|
373
|
+
const invocation = await resolvePackageManagerCommand(projectRoot, "holo:dev");
|
|
374
|
+
while (!shuttingDown) {
|
|
375
|
+
const child = spawnProcess(invocation.command, [...invocation.args], {
|
|
376
|
+
cwd: projectRoot,
|
|
377
|
+
env: process.env,
|
|
378
|
+
stdio: ["pipe", "pipe", "pipe"]
|
|
379
|
+
});
|
|
380
|
+
child.stdout?.on("data", (chunk) => io.stdout.write(chunk));
|
|
381
|
+
child.stderr?.on("data", (chunk) => io.stderr.write(chunk));
|
|
382
|
+
if (child.stdin) {
|
|
383
|
+
io.stdin.pipe(child.stdin);
|
|
384
|
+
}
|
|
385
|
+
const result = await new Promise((resolvePromise) => {
|
|
386
|
+
let restartRequested = false;
|
|
387
|
+
requestChildRestart = () => {
|
|
388
|
+
if (restartRequested || shuttingDown || typeof child.kill !== "function") {
|
|
389
|
+
return;
|
|
390
|
+
}
|
|
391
|
+
restartRequested = true;
|
|
392
|
+
child.kill("SIGTERM");
|
|
393
|
+
};
|
|
394
|
+
child.on("error", (error) => {
|
|
395
|
+
if (child.stdin) {
|
|
396
|
+
io.stdin.unpipe(child.stdin);
|
|
397
|
+
}
|
|
398
|
+
requestChildRestart = void 0;
|
|
399
|
+
if (restartRequested) {
|
|
400
|
+
resolvePromise({ kind: "restart" });
|
|
401
|
+
return;
|
|
402
|
+
}
|
|
403
|
+
resolvePromise({ kind: "error", error });
|
|
404
|
+
});
|
|
405
|
+
child.on("close", (code) => {
|
|
406
|
+
if (child.stdin) {
|
|
407
|
+
io.stdin.unpipe(child.stdin);
|
|
408
|
+
}
|
|
409
|
+
requestChildRestart = void 0;
|
|
410
|
+
if (restartRequested) {
|
|
411
|
+
resolvePromise({ kind: "restart" });
|
|
412
|
+
return;
|
|
413
|
+
}
|
|
414
|
+
resolvePromise({ kind: "close", code });
|
|
415
|
+
});
|
|
416
|
+
});
|
|
417
|
+
if (result.kind === "restart") {
|
|
418
|
+
continue;
|
|
419
|
+
}
|
|
420
|
+
shuttingDown = true;
|
|
421
|
+
closeWatchers();
|
|
422
|
+
await Promise.resolve(pendingPrepare);
|
|
423
|
+
if (result.kind === "error") {
|
|
424
|
+
throw result.error;
|
|
425
|
+
}
|
|
426
|
+
if (result.code === 0) {
|
|
427
|
+
return;
|
|
428
|
+
}
|
|
429
|
+
throw new Error(`Project script "holo:dev" failed with exit code ${result.code ?? "unknown"}.`);
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
export {
|
|
434
|
+
resolveProjectPackageManager,
|
|
435
|
+
resolvePackageManagerCommand,
|
|
436
|
+
resolvePackageManagerInstallInvocation,
|
|
437
|
+
runProjectLifecycleScript,
|
|
438
|
+
runProjectDependencyInstall,
|
|
439
|
+
runProjectPrepare,
|
|
440
|
+
toPosixSlashes,
|
|
441
|
+
isDiscoveryRelevantPath,
|
|
442
|
+
isRecursiveWatchUnsupported,
|
|
443
|
+
isIgnorableWatchError,
|
|
444
|
+
collectDirectoryTree,
|
|
445
|
+
collectDiscoveryWatchRoots,
|
|
446
|
+
normalizeWatchedFilePath,
|
|
447
|
+
runProjectDevServer
|
|
448
|
+
};
|