@holo-js/cli 0.1.4 → 0.1.5

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.
Files changed (56) hide show
  1. package/dist/bin/holo.mjs +192 -35
  2. package/dist/{broadcast-CSSARTSA.mjs → broadcast-RT5KVZWP.mjs} +5 -5
  3. package/dist/{cache-4G6QGIZO.mjs → cache-NHCCHT44.mjs} +5 -5
  4. package/dist/{cache-migrations-NATT5WPQ.mjs → cache-migrations-R2RL2RVD.mjs} +15 -16
  5. package/dist/{chunk-EUIVXVJL.mjs → chunk-57SJ566R.mjs} +1 -1
  6. package/dist/chunk-5BLEC66P.mjs +284 -0
  7. package/dist/{chunk-JX2ZH6XY.mjs → chunk-5EU32E7X.mjs} +3 -3
  8. package/dist/{chunk-Q5F6C2D4.mjs → chunk-BAFQ2GOA.mjs} +1 -1
  9. package/dist/{chunk-CUL4RJTG.mjs → chunk-F4MT6GBK.mjs} +1 -1
  10. package/dist/{chunk-3OTCSFDG.mjs → chunk-MXKNQACM.mjs} +544 -82
  11. package/dist/{chunk-QYLSMF7V.mjs → chunk-OZUDZEAW.mjs} +142 -28
  12. package/dist/{chunk-66FHW725.mjs → chunk-R6BWRY3E.mjs} +28 -2
  13. package/dist/{chunk-ZLRO7HXY.mjs → chunk-SCCPDJGO.mjs} +156 -15
  14. package/dist/{chunk-VT5IDQG6.mjs → chunk-UZTDQKIY.mjs} +61 -44
  15. package/dist/{chunk-MZXN2YMI.mjs → chunk-VCEO6N5T.mjs} +3542 -2517
  16. package/dist/{config-LS5USBRB.mjs → config-5JSC6KJG.mjs} +3 -3
  17. package/dist/{dev-LZ3O2E3U.mjs → dev-OSLYSBTL.mjs} +7 -7
  18. package/dist/{discovery-GBLAUTXS.mjs → discovery-JLT2EOGH.mjs} +3 -3
  19. package/dist/{generators-DSN4GWJI.mjs → generators-ZIWACCBE.mjs} +134 -16
  20. package/dist/index.d.ts +1 -1
  21. package/dist/index.mjs +189 -32
  22. package/dist/media-migrations-UBAL2YVV.mjs +117 -0
  23. package/dist/{queue-FV35LLPR.mjs → queue-I66EISVS.mjs} +14 -14
  24. package/dist/{queue-migrations-SSIYKK5S.mjs → queue-migrations-UIAMAB6E.mjs} +24 -20
  25. package/dist/{runtime-EFZ5H5IL.mjs → runtime-MMQGO4PP.mjs} +9 -7
  26. package/dist/{runtime-OOSJ5JBY.mjs → runtime-ZKD6URAV.mjs} +1 -1
  27. package/dist/{scaffold-7OTDH4UR.mjs → scaffold-ISDVICNQ.mjs} +18 -5
  28. package/dist/{security-ATKDC26E.mjs → security-OZXTMYXF.mjs} +10 -7
  29. package/package.json +13 -12
  30. package/dist/broadcast-YSIJCL3R.mjs +0 -85
  31. package/dist/cache-OWQY4E7W.mjs +0 -67
  32. package/dist/cache-migrations-RVEA6CEU.mjs +0 -155
  33. package/dist/chunk-BWW5TDFI.mjs +0 -4
  34. package/dist/chunk-D4GG556Y.mjs +0 -23
  35. package/dist/chunk-DMH2B4UQ.mjs +0 -343
  36. package/dist/chunk-ET7UXHHQ.mjs +0 -166
  37. package/dist/chunk-G5ADO27Q.mjs +0 -463
  38. package/dist/chunk-GSQ3HTRO.mjs +0 -165
  39. package/dist/chunk-H7TJ4FB3.mjs +0 -848
  40. package/dist/chunk-ICJR7TS4.mjs +0 -66
  41. package/dist/chunk-M7J3YTHR.mjs +0 -26
  42. package/dist/chunk-QFUSWV3J.mjs +0 -3237
  43. package/dist/chunk-S7P7EBM3.mjs +0 -787
  44. package/dist/chunk-SRWJU3A5.mjs +0 -11
  45. package/dist/chunk-URK7C3VQ.mjs +0 -538
  46. package/dist/chunk-XUYKPU5Q.mjs +0 -272
  47. package/dist/config-DMWBMMGD.mjs +0 -26
  48. package/dist/dev-KQFT7RHR.mjs +0 -43
  49. package/dist/discovery-R733D2PO.mjs +0 -29
  50. package/dist/generators-WX45BI4U.mjs +0 -426
  51. package/dist/queue-6OG7VJ34.mjs +0 -626
  52. package/dist/queue-migrations-NK2EYX3J.mjs +0 -163
  53. package/dist/runtime-4BV3JODY.mjs +0 -56
  54. package/dist/runtime-ANBO7VQM.mjs +0 -33
  55. package/dist/scaffold-DRKBGS2K.mjs +0 -120
  56. package/dist/security-R7VH6W5H.mjs +0 -69
@@ -1,29 +1,30 @@
1
- #!/usr/bin/env node
2
1
  import {
3
2
  fileExists
4
- } from "./chunk-M7J3YTHR.mjs";
3
+ } from "./chunk-57SJ566R.mjs";
5
4
  import {
6
5
  prepareProjectDiscovery
7
- } from "./chunk-VT5IDQG6.mjs";
6
+ } from "./chunk-UZTDQKIY.mjs";
8
7
  import {
9
8
  loadProjectConfig,
10
9
  resolveGeneratedSchemaPath
11
- } from "./chunk-ET7UXHHQ.mjs";
10
+ } from "./chunk-5BLEC66P.mjs";
12
11
  import {
13
12
  loadGeneratedProjectRegistry
14
- } from "./chunk-3OTCSFDG.mjs";
13
+ } from "./chunk-MXKNQACM.mjs";
15
14
  import {
16
15
  CLI_RUNTIME_ROOT,
17
16
  bundleProjectModule
18
- } from "./chunk-66FHW725.mjs";
17
+ } from "./chunk-R6BWRY3E.mjs";
19
18
 
20
19
  // src/runtime.ts
21
- import { spawnSync } from "child_process";
22
- import { mkdir, rm, symlink } from "fs/promises";
20
+ import { spawn } from "child_process";
21
+ import { mkdir, readFile, rm, symlink, writeFile } from "fs/promises";
23
22
  import { dirname, join, resolve } from "path";
23
+ import { setTimeout } from "timers/promises";
24
24
  import { fileURLToPath, pathToFileURL } from "url";
25
25
  import { writeConfigCache } from "@holo-js/config";
26
26
  var runtimeImportMeta = import.meta;
27
+ var RUNTIME_DEPENDENCY_LOCK_RETRY_MS = 10;
27
28
  function resolveConfigModuleUrl(runtimeResolve = runtimeImportMeta.resolve?.bind(runtimeImportMeta)) {
28
29
  if (typeof runtimeResolve === "function") {
29
30
  const resolved = runtimeResolve("@holo-js/config");
@@ -196,6 +197,7 @@ import {
196
197
  createSchemaService,
197
198
  createMigrationService,
198
199
  createSeederService,
200
+ registerGeneratedTables,
199
201
  renderGeneratedSchemaModule,
200
202
  resetDB,
201
203
  resolveRuntimeConnectionManagerOptions,
@@ -275,6 +277,12 @@ async function writeGeneratedSchemaArtifact(manager, outputPath) {
275
277
  await writeFile(outputPath, source, 'utf8')
276
278
  }
277
279
 
280
+ function syncGeneratedSchemaFromManager(manager) {
281
+ registerGeneratedTables(Object.fromEntries(
282
+ manager.connection().getSchemaRegistry().list().map(table => [table.tableName, table]),
283
+ ))
284
+ }
285
+
278
286
  const manager = resolveRuntimeConnectionManagerOptions(payload.runtimeConfig)
279
287
  configureDB(manager)
280
288
 
@@ -297,7 +305,10 @@ try {
297
305
  if (executed.length === 0) {
298
306
  console.log('No migrations were executed.')
299
307
  } else {
300
- console.log(\`Migrations executed: \${executed.map(item => item.name).join(', ')}\`)
308
+ console.log('Migrations executed:')
309
+ for (const item of executed) {
310
+ console.log(\` \${item.name}\`)
311
+ }
301
312
  }
302
313
  } else if (payload.kind === 'fresh') {
303
314
  const migrations = []
@@ -315,10 +326,14 @@ try {
315
326
 
316
327
  const executed = await createMigrationService(manager.connection(), migrations).migrate({})
317
328
  await writeGeneratedSchemaArtifact(manager, payload.generatedSchemaOutputPath)
329
+ syncGeneratedSchemaFromManager(manager)
318
330
  if (executed.length === 0) {
319
331
  console.log('No migrations were executed.')
320
332
  } else {
321
- console.log(\`Migrations executed: \${executed.map(item => item.name).join(', ')}\`)
333
+ console.log('Migrations executed:')
334
+ for (const item of executed) {
335
+ console.log(\` \${item.name}\`)
336
+ }
322
337
  }
323
338
 
324
339
  if (payload.options?.seed) {
@@ -340,7 +355,10 @@ try {
340
355
  if (seeded.length === 0) {
341
356
  console.log('No seeders were executed.')
342
357
  } else {
343
- console.log(\`Seeders executed: \${seeded.map(item => item.name).join(', ')}\`)
358
+ console.log('Seeders executed:')
359
+ for (const item of seeded) {
360
+ console.log(\` \${item.name}\`)
361
+ }
344
362
  }
345
363
  }
346
364
  } else if (payload.kind === 'rollback') {
@@ -357,11 +375,18 @@ try {
357
375
  const rolledBack = await createMigrationService(manager.connection(), migrations).rollback(payload.options ?? {})
358
376
  await writeGeneratedSchemaArtifact(manager, payload.generatedSchemaOutputPath)
359
377
  if (rolledBack.length === 0) {
360
- console.log('No migrations were executed.')
378
+ console.log('No migrations were rolled back.')
361
379
  } else {
362
- console.log(\`Migrations executed: \${rolledBack.map(item => item.name).join(', ')}\`)
380
+ console.log('Migrations rolled back:')
381
+ for (const item of rolledBack) {
382
+ console.log(\` \${item.name}\`)
383
+ }
363
384
  }
364
385
  } else if (payload.kind === 'seed') {
386
+ if (payload.generatedSchema) {
387
+ await preloadGeneratedSchema(manager, payload.generatedSchema)
388
+ }
389
+
365
390
  const seeders = []
366
391
  for (const entry of payload.seeders) {
367
392
  const seeder = resolveExport(await loadModule(entry), isSeeder)
@@ -375,7 +400,10 @@ try {
375
400
  if (executed.length === 0) {
376
401
  console.log('No seeders were executed.')
377
402
  } else {
378
- console.log(\`Seeders executed: \${executed.map(item => item.name).join(', ')}\`)
403
+ console.log('Seeders executed:')
404
+ for (const item of executed) {
405
+ console.log(\` \${item.name}\`)
406
+ }
379
407
  }
380
408
  } else if (payload.kind === 'prune') {
381
409
  const models = []
@@ -438,18 +466,65 @@ async function resolvePackageRootFromSpecifier(specifier) {
438
466
  current = parent;
439
467
  }
440
468
  }
441
- async function ensureRuntimeDependencyLink(projectRoot) {
469
+ function isFileExistsError(error) {
470
+ return error instanceof Error && "code" in error && error.code === "EEXIST";
471
+ }
472
+ async function withRuntimeDependencyLock(projectRoot, callback) {
442
473
  const runtimeRoot = join(projectRoot, CLI_RUNTIME_ROOT);
443
- const packageRoot = await resolvePackageRootFromSpecifier("@holo-js/db");
444
- const namespaceDir = join(runtimeRoot, "node_modules", "@holo-js");
445
- const targetPath = join(namespaceDir, "db");
446
- await mkdir(namespaceDir, { recursive: true });
447
- await rm(targetPath, { recursive: true, force: true });
448
- await symlink(packageRoot, targetPath, "junction");
449
- return runtimeRoot;
474
+ const lockDir = join(runtimeRoot, "node_modules.lock");
475
+ await mkdir(runtimeRoot, { recursive: true });
476
+ while (true) {
477
+ try {
478
+ await mkdir(lockDir);
479
+ break;
480
+ } catch (error) {
481
+ if (!isFileExistsError(error)) {
482
+ throw error;
483
+ }
484
+ await setTimeout(RUNTIME_DEPENDENCY_LOCK_RETRY_MS);
485
+ }
486
+ }
487
+ try {
488
+ return await callback();
489
+ } finally {
490
+ await rm(lockDir, { recursive: true, force: true });
491
+ }
492
+ }
493
+ async function readRuntimeDependencyReferenceCount(refPath) {
494
+ const raw = await readFile(refPath, "utf8").catch(() => void 0);
495
+ const count = raw === void 0 ? 0 : Number.parseInt(raw, 10);
496
+ return Number.isFinite(count) && count > 0 ? count : 0;
497
+ }
498
+ async function ensureRuntimeDependencyLink(projectRoot) {
499
+ return await withRuntimeDependencyLock(projectRoot, async () => {
500
+ const runtimeRoot = join(projectRoot, CLI_RUNTIME_ROOT);
501
+ const packageRoot = await resolvePackageRootFromSpecifier("@holo-js/db");
502
+ const nodeModulesDir = join(runtimeRoot, "node_modules");
503
+ const namespaceDir = join(nodeModulesDir, "@holo-js");
504
+ const targetPath = join(namespaceDir, "db");
505
+ const refPath = join(nodeModulesDir, ".holo-js-runtime-refs");
506
+ const references = await readRuntimeDependencyReferenceCount(refPath);
507
+ await mkdir(namespaceDir, { recursive: true });
508
+ if (references === 0) {
509
+ await rm(targetPath, { recursive: true, force: true });
510
+ await symlink(packageRoot, targetPath, "junction");
511
+ }
512
+ await writeFile(refPath, String(references + 1), "utf8");
513
+ return runtimeRoot;
514
+ });
450
515
  }
451
516
  async function cleanupRuntimeDependencyLink(projectRoot) {
452
- await rm(join(projectRoot, CLI_RUNTIME_ROOT, "node_modules"), { recursive: true, force: true });
517
+ await withRuntimeDependencyLock(projectRoot, async () => {
518
+ const nodeModulesDir = join(projectRoot, CLI_RUNTIME_ROOT, "node_modules");
519
+ const refPath = join(nodeModulesDir, ".holo-js-runtime-refs");
520
+ const references = await readRuntimeDependencyReferenceCount(refPath);
521
+ const nextReferences = references - 1;
522
+ if (nextReferences <= 0) {
523
+ await rm(nodeModulesDir, { recursive: true, force: true });
524
+ return;
525
+ }
526
+ await writeFile(refPath, String(nextReferences), "utf8");
527
+ });
453
528
  }
454
529
  function createRuntimeInvocation(script) {
455
530
  return {
@@ -457,6 +532,37 @@ function createRuntimeInvocation(script) {
457
532
  args: ["--input-type=module", "--eval", script]
458
533
  };
459
534
  }
535
+ function runRuntimeInvocation(command, args, options) {
536
+ return new Promise((resolveInvocation) => {
537
+ const child = spawn(command, args, {
538
+ cwd: options.cwd,
539
+ env: options.env,
540
+ stdio: ["ignore", "pipe", "pipe"]
541
+ });
542
+ let stdout = "";
543
+ let stderr = "";
544
+ let error = null;
545
+ child.stdout.setEncoding("utf8");
546
+ child.stdout.on("data", (chunk) => {
547
+ stdout += chunk;
548
+ });
549
+ child.stderr.setEncoding("utf8");
550
+ child.stderr.on("data", (chunk) => {
551
+ stderr += chunk;
552
+ });
553
+ child.on("error", (spawnError) => {
554
+ error = spawnError;
555
+ });
556
+ child.on("close", (status) => {
557
+ resolveInvocation({
558
+ status,
559
+ error,
560
+ stdout,
561
+ stderr
562
+ });
563
+ });
564
+ });
565
+ }
460
566
  function getRuntimeFailureMessage(kind, result) {
461
567
  const stderr = result.stderr?.trim();
462
568
  if (stderr) {
@@ -473,7 +579,12 @@ function getRuntimeFailureMessage(kind, result) {
473
579
  return `Runtime command "${kind}" failed.`;
474
580
  }
475
581
  async function withRuntimeEnvironment(projectRoot, kind, options, callback) {
582
+ if (kind === "seed") {
583
+ const project = await loadProjectConfig(projectRoot, { required: true });
584
+ await prepareProjectDiscovery(projectRoot, project.config);
585
+ }
476
586
  const environment = await getRuntimeEnvironment(projectRoot);
587
+ let dependencyLinkEnsured = false;
477
588
  try {
478
589
  const envRuntimeConfig = createEnvRuntimeConfig();
479
590
  const runtimeDatabaseConfig = mergeRuntimeDatabaseConfig(
@@ -481,6 +592,7 @@ async function withRuntimeEnvironment(projectRoot, kind, options, callback) {
481
592
  envRuntimeConfig
482
593
  );
483
594
  const runtimeRoot = await ensureRuntimeDependencyLink(projectRoot);
595
+ dependencyLinkEnsured = true;
484
596
  const runtimePayload = JSON.stringify({
485
597
  kind,
486
598
  projectRoot,
@@ -495,20 +607,21 @@ async function withRuntimeEnvironment(projectRoot, kind, options, callback) {
495
607
  options
496
608
  });
497
609
  const runtime = createRuntimeInvocation(nodeRuntimeScript);
498
- const result = spawnSync(runtime.command, runtime.args, {
610
+ const result = await runRuntimeInvocation(runtime.command, runtime.args, {
499
611
  cwd: runtimeRoot,
500
612
  env: {
501
613
  ...process.env,
502
614
  HOLO_RUNTIME_PAYLOAD: runtimePayload
503
- },
504
- encoding: "utf8"
615
+ }
505
616
  });
506
617
  if (result.status !== 0) {
507
618
  throw new Error(getRuntimeFailureMessage(kind, result));
508
619
  }
509
- return await callback(result.stdout.trim());
620
+ return await callback((result.stdout ?? "").trim());
510
621
  } finally {
511
- await cleanupRuntimeDependencyLink(projectRoot);
622
+ if (dependencyLinkEnsured) {
623
+ await cleanupRuntimeDependencyLink(projectRoot);
624
+ }
512
625
  await environment.cleanup();
513
626
  }
514
627
  }
@@ -534,6 +647,7 @@ export {
534
647
  ensureRuntimeDependencyLink,
535
648
  cleanupRuntimeDependencyLink,
536
649
  createRuntimeInvocation,
650
+ runRuntimeInvocation,
537
651
  getRuntimeFailureMessage,
538
652
  withRuntimeEnvironment
539
653
  };
@@ -1,5 +1,3 @@
1
- #!/usr/bin/env node
2
-
3
1
  // src/project/runtime.ts
4
2
  import { mkdtemp, mkdir, readFile, rm, writeFile } from "fs/promises";
5
3
  import { existsSync } from "fs";
@@ -93,6 +91,14 @@ var MAIL_CONFIG_FILE_NAMES = [
93
91
  "config/mail.cts",
94
92
  "config/mail.cjs"
95
93
  ];
94
+ var MEDIA_CONFIG_FILE_NAMES = [
95
+ "config/media.ts",
96
+ "config/media.mts",
97
+ "config/media.js",
98
+ "config/media.mjs",
99
+ "config/media.cts",
100
+ "config/media.cjs"
101
+ ];
96
102
  var SECURITY_CONFIG_FILE_NAMES = [
97
103
  "config/security.ts",
98
104
  "config/security.mts",
@@ -101,6 +107,14 @@ var SECURITY_CONFIG_FILE_NAMES = [
101
107
  "config/security.cts",
102
108
  "config/security.cjs"
103
109
  ];
110
+ var CORS_CONFIG_FILE_NAMES = [
111
+ "config/cors.ts",
112
+ "config/cors.mts",
113
+ "config/cors.js",
114
+ "config/cors.mjs",
115
+ "config/cors.cts",
116
+ "config/cors.cjs"
117
+ ];
104
118
  var BROADCAST_CONFIG_FILE_NAMES = [
105
119
  "config/broadcast.ts",
106
120
  "config/broadcast.mts",
@@ -122,6 +136,7 @@ var GENERATED_ROOT = join(".holo-js", "generated");
122
136
  var GENERATED_INDEX_PATH = join(GENERATED_ROOT, "index.ts");
123
137
  var GENERATED_METADATA_PATH = join(GENERATED_ROOT, "metadata.ts");
124
138
  var GENERATED_MODELS_PATH = join(GENERATED_ROOT, "models.ts");
139
+ var GENERATED_MODEL_TYPES_PATH = join(GENERATED_ROOT, "model-registry.d.ts");
125
140
  var GENERATED_MIGRATIONS_PATH = join(GENERATED_ROOT, "migrations.ts");
126
141
  var GENERATED_SEEDERS_PATH = join(GENERATED_ROOT, "seeders.ts");
127
142
  var GENERATED_COMMANDS_PATH = join(GENERATED_ROOT, "commands.ts");
@@ -134,13 +149,17 @@ var GENERATED_BROADCAST_MANIFEST_PATH = join(GENERATED_ROOT, "broadcast-manifest
134
149
  var GENERATED_AUTHORIZATION_ROOT = join(GENERATED_ROOT, "authorization");
135
150
  var GENERATED_AUTHORIZATION_REGISTRY_PATH = join(GENERATED_AUTHORIZATION_ROOT, "registry.ts");
136
151
  var GENERATED_AUTHORIZATION_TYPES_PATH = join(GENERATED_AUTHORIZATION_ROOT, "types.d.ts");
152
+ var GENERATED_AUTH_TYPES_PATH = join(GENERATED_ROOT, "auth.d.ts");
137
153
  var GENERATED_CONFIG_TYPES_PATH = join(GENERATED_ROOT, "config.d.ts");
138
154
  var GENERATED_QUEUE_TYPES_PATH = join(GENERATED_ROOT, "queue.d.ts");
139
155
  var GENERATED_EVENT_TYPES_PATH = join(GENERATED_ROOT, "events.d.ts");
140
156
  var GENERATED_BROADCAST_TYPES_PATH = join(GENERATED_ROOT, "broadcast.d.ts");
141
157
  var GENERATED_REGISTRY_JSON_PATH = join(GENERATED_ROOT, "registry.json");
158
+ var GENERATED_SCHEMA_RUNTIME_PATH = join(GENERATED_ROOT, "schema.mjs");
142
159
  var GENERATED_TSCONFIG_PATH = join(GENERATED_ROOT, "tsconfig.json");
143
160
  var GENERATED_GITIGNORE_PATH = join(GENERATED_ROOT, ".gitignore");
161
+ var GENERATED_SVELTE_HOOKS_PATH = join(GENERATED_ROOT, "hooks.ts");
162
+ var GENERATED_SVELTE_SERVER_HOOKS_PATH = join(GENERATED_ROOT, "hooks.server.ts");
144
163
  var CONFIG_EXTENSION_PRIORITY = [".ts", ".mts", ".js", ".mjs", ".cts", ".cjs"];
145
164
  var SUPPORTED_CONFIG_EXTENSIONS = new Set(CONFIG_EXTENSION_PRIORITY);
146
165
  var SUPPORTED_SCAFFOLD_OPTIONAL_PACKAGES = ["storage", "events", "queue", "validation", "forms", "auth", "authorization", "notifications", "mail", "broadcast", "security", "cache"];
@@ -406,7 +425,9 @@ export {
406
425
  CACHE_CONFIG_FILE_NAMES,
407
426
  NOTIFICATIONS_CONFIG_FILE_NAMES,
408
427
  MAIL_CONFIG_FILE_NAMES,
428
+ MEDIA_CONFIG_FILE_NAMES,
409
429
  SECURITY_CONFIG_FILE_NAMES,
430
+ CORS_CONFIG_FILE_NAMES,
410
431
  BROADCAST_CONFIG_FILE_NAMES,
411
432
  DB_DRIVER_PACKAGE_NAMES,
412
433
  COMMAND_FILE_PATTERN,
@@ -417,6 +438,7 @@ export {
417
438
  GENERATED_INDEX_PATH,
418
439
  GENERATED_METADATA_PATH,
419
440
  GENERATED_MODELS_PATH,
441
+ GENERATED_MODEL_TYPES_PATH,
420
442
  GENERATED_MIGRATIONS_PATH,
421
443
  GENERATED_SEEDERS_PATH,
422
444
  GENERATED_COMMANDS_PATH,
@@ -428,13 +450,17 @@ export {
428
450
  GENERATED_BROADCAST_MANIFEST_PATH,
429
451
  GENERATED_AUTHORIZATION_REGISTRY_PATH,
430
452
  GENERATED_AUTHORIZATION_TYPES_PATH,
453
+ GENERATED_AUTH_TYPES_PATH,
431
454
  GENERATED_CONFIG_TYPES_PATH,
432
455
  GENERATED_QUEUE_TYPES_PATH,
433
456
  GENERATED_EVENT_TYPES_PATH,
434
457
  GENERATED_BROADCAST_TYPES_PATH,
435
458
  GENERATED_REGISTRY_JSON_PATH,
459
+ GENERATED_SCHEMA_RUNTIME_PATH,
436
460
  GENERATED_TSCONFIG_PATH,
437
461
  GENERATED_GITIGNORE_PATH,
462
+ GENERATED_SVELTE_HOOKS_PATH,
463
+ GENERATED_SVELTE_SERVER_HOOKS_PATH,
438
464
  CONFIG_EXTENSION_PRIORITY,
439
465
  SUPPORTED_CONFIG_EXTENSIONS,
440
466
  toPosixPath,
@@ -1,21 +1,25 @@
1
1
  import {
2
2
  prepareProjectDiscovery
3
- } from "./chunk-S7P7EBM3.mjs";
3
+ } from "./chunk-UZTDQKIY.mjs";
4
4
  import {
5
+ renderFrameworkRunner,
5
6
  syncManagedDriverDependencies
6
- } from "./chunk-MZXN2YMI.mjs";
7
+ } from "./chunk-VCEO6N5T.mjs";
7
8
  import {
9
+ ensureGeneratedSchemaPlaceholder,
8
10
  ensureProjectConfig
9
- } from "./chunk-GSQ3HTRO.mjs";
11
+ } from "./chunk-5BLEC66P.mjs";
10
12
  import {
11
- readTextFile
12
- } from "./chunk-G5ADO27Q.mjs";
13
+ readTextFile,
14
+ writeTextFile
15
+ } from "./chunk-R6BWRY3E.mjs";
13
16
 
14
17
  // src/dev.ts
15
18
  import { spawnSync, spawn } from "child_process";
16
19
  import { watch } from "fs";
17
20
  import { readdir, stat } from "fs/promises";
18
- import { dirname, join, relative, resolve } from "path";
21
+ import { join, dirname, relative, resolve } from "path";
22
+ import { readFile } from "fs/promises";
19
23
  async function fileExists(path) {
20
24
  try {
21
25
  await stat(path);
@@ -101,20 +105,158 @@ async function runProjectDependencyInstall(io, projectRoot, spawn2 = spawnSync)
101
105
  }
102
106
  async function runProjectPrepare(projectRoot, io) {
103
107
  const project = await ensureProjectConfig(projectRoot);
108
+ await ensureGeneratedSchemaPlaceholder(projectRoot, project.config);
104
109
  await prepareProjectDiscovery(projectRoot, project.config);
110
+ await refreshFrameworkRunner(projectRoot);
111
+ await runNuxtPrepare(projectRoot);
112
+ await runSvelteKitSync(projectRoot);
105
113
  const updatedDependencies = await syncManagedDriverDependencies(projectRoot);
106
114
  if (updatedDependencies && io) {
107
115
  await runProjectDependencyInstall(io, projectRoot);
108
116
  await prepareProjectDiscovery(projectRoot, project.config);
117
+ await refreshFrameworkRunner(projectRoot);
118
+ await runNuxtPrepare(projectRoot);
119
+ await runSvelteKitSync(projectRoot);
109
120
  }
110
121
  }
122
+ async function refreshFrameworkRunner(projectRoot) {
123
+ const frameworkProjectPath = resolve(projectRoot, ".holo-js/framework/project.json");
124
+ const frameworkRunnerPath = resolve(projectRoot, ".holo-js/framework/run.mjs");
125
+ let framework;
126
+ try {
127
+ const content = await readFile(frameworkProjectPath, "utf8");
128
+ const manifest = JSON.parse(content);
129
+ if (manifest.framework !== "next" && manifest.framework !== "nuxt" && manifest.framework !== "sveltekit") {
130
+ return;
131
+ }
132
+ framework = manifest.framework;
133
+ } catch {
134
+ return;
135
+ }
136
+ await writeTextFile(frameworkRunnerPath, renderFrameworkRunner({ framework }));
137
+ }
138
+ async function runNuxtPrepare(projectRoot) {
139
+ const frameworkProjectPath = resolve(projectRoot, ".holo-js/framework/project.json");
140
+ try {
141
+ const content = await readFile(frameworkProjectPath, "utf8");
142
+ const manifest = JSON.parse(content);
143
+ if (manifest.framework !== "nuxt") {
144
+ return;
145
+ }
146
+ } catch {
147
+ return;
148
+ }
149
+ const manager = await resolveProjectPackageManager(projectRoot);
150
+ let command;
151
+ let args;
152
+ switch (manager) {
153
+ case "npm":
154
+ command = "npm";
155
+ args = ["exec", "--", "nuxt", "prepare"];
156
+ break;
157
+ case "pnpm":
158
+ command = "pnpm";
159
+ args = ["exec", "nuxt", "prepare"];
160
+ break;
161
+ case "yarn":
162
+ command = "yarn";
163
+ args = ["run", "nuxt", "prepare"];
164
+ break;
165
+ case "bun":
166
+ default:
167
+ command = "bun";
168
+ args = ["x", "nuxt", "prepare"];
169
+ break;
170
+ }
171
+ const { spawn: spawn2 } = await import("child_process");
172
+ await new Promise((resolve2, reject) => {
173
+ const child = spawn2(command, args, {
174
+ cwd: projectRoot,
175
+ stdio: "inherit"
176
+ });
177
+ child.on("close", (code) => {
178
+ if (code === 0) {
179
+ resolve2(void 0);
180
+ } else {
181
+ reject(new Error(`nuxt prepare exited with ${code}`));
182
+ }
183
+ });
184
+ child.on("error", reject);
185
+ });
186
+ }
187
+ async function runSvelteKitSync(projectRoot) {
188
+ const frameworkProjectPath = resolve(projectRoot, ".holo-js/framework/project.json");
189
+ try {
190
+ const content = await readFile(frameworkProjectPath, "utf8");
191
+ const manifest = JSON.parse(content);
192
+ if (manifest.framework !== "sveltekit") {
193
+ return;
194
+ }
195
+ } catch {
196
+ return;
197
+ }
198
+ const manager = await resolveProjectPackageManager(projectRoot);
199
+ let command;
200
+ let args;
201
+ switch (manager) {
202
+ case "npm":
203
+ command = "npm";
204
+ args = ["exec", "--", "svelte-kit", "sync"];
205
+ break;
206
+ case "pnpm":
207
+ command = "pnpm";
208
+ args = ["exec", "svelte-kit", "sync"];
209
+ break;
210
+ case "yarn":
211
+ command = "yarn";
212
+ args = ["run", "svelte-kit", "sync"];
213
+ break;
214
+ case "bun":
215
+ default:
216
+ command = "bun";
217
+ args = ["x", "svelte-kit", "sync"];
218
+ break;
219
+ }
220
+ const { spawn: spawn2 } = await import("child_process");
221
+ await new Promise((resolve2, reject) => {
222
+ const child = spawn2(command, args, {
223
+ cwd: projectRoot,
224
+ stdio: "inherit"
225
+ });
226
+ child.on("close", (code) => {
227
+ if (code === 0) {
228
+ resolve2(void 0);
229
+ } else {
230
+ reject(new Error(`svelte-kit sync exited with ${code}`));
231
+ }
232
+ });
233
+ child.on("error", reject);
234
+ });
235
+ }
111
236
  function toPosixSlashes(value) {
112
237
  return value.replaceAll("\\", "/");
113
238
  }
239
+ function resolveConfiguredBroadcastPath(project) {
240
+ const configuredPaths = project.config.paths;
241
+ return configuredPaths.broadcast ?? "server/broadcast";
242
+ }
243
+ function resolveConfiguredChannelsPath(project) {
244
+ const configuredPaths = project.config.paths;
245
+ return configuredPaths.channels ?? "server/channels";
246
+ }
114
247
  function isDiscoveryRelevantPath(filePath, project) {
115
248
  const normalized = toPosixSlashes(filePath);
249
+ const generatedSchemaPath = toPosixSlashes(project.config.paths.generatedSchema ?? ".holo-js/generated/schema.generated.ts");
250
+ if (normalized === generatedSchemaPath) {
251
+ return true;
252
+ }
253
+ if (normalized === ".holo-js/generated" || normalized.startsWith(".holo-js/generated/")) {
254
+ return false;
255
+ }
116
256
  const authorizationPoliciesPath = project.config.paths.authorizationPolicies || "server/policies";
117
257
  const authorizationAbilitiesPath = project.config.paths.authorizationAbilities || "server/abilities";
258
+ const broadcastPath = resolveConfiguredBroadcastPath(project);
259
+ const channelsPath = resolveConfiguredChannelsPath(project);
118
260
  const roots = [
119
261
  project.config.paths.models,
120
262
  project.config.paths.migrations,
@@ -125,11 +267,9 @@ function isDiscoveryRelevantPath(filePath, project) {
125
267
  project.config.paths.listeners,
126
268
  authorizationPoliciesPath,
127
269
  authorizationAbilitiesPath,
128
- "server/broadcast",
129
- "server/channels",
130
- project.config.paths.generatedSchema,
131
- "config",
132
- ".holo-js/generated"
270
+ broadcastPath,
271
+ channelsPath,
272
+ "config"
133
273
  ];
134
274
  if (normalized === ".env" || normalized.startsWith(".env.")) {
135
275
  return true;
@@ -160,10 +300,11 @@ async function collectDiscoveryWatchRoots(projectRoot, project) {
160
300
  const directories = /* @__PURE__ */ new Set();
161
301
  const authorizationPoliciesPath = project.config.paths.authorizationPolicies || "server/policies";
162
302
  const authorizationAbilitiesPath = project.config.paths.authorizationAbilities || "server/abilities";
303
+ const broadcastPath = resolveConfiguredBroadcastPath(project);
304
+ const channelsPath = resolveConfiguredChannelsPath(project);
163
305
  const roots = [
164
306
  projectRoot,
165
307
  resolve(projectRoot, "config"),
166
- resolve(projectRoot, ".holo-js/generated"),
167
308
  resolve(projectRoot, project.config.paths.models),
168
309
  resolve(projectRoot, project.config.paths.migrations),
169
310
  resolve(projectRoot, project.config.paths.seeders),
@@ -173,9 +314,9 @@ async function collectDiscoveryWatchRoots(projectRoot, project) {
173
314
  resolve(projectRoot, project.config.paths.listeners),
174
315
  resolve(projectRoot, authorizationPoliciesPath),
175
316
  resolve(projectRoot, authorizationAbilitiesPath),
176
- resolve(projectRoot, "server/broadcast"),
177
- resolve(projectRoot, "server/channels"),
178
- dirname(resolve(projectRoot, project.config.paths.generatedSchema))
317
+ resolve(projectRoot, broadcastPath),
318
+ resolve(projectRoot, channelsPath),
319
+ resolve(projectRoot, dirname(project.config.paths.generatedSchema ?? ".holo-js/generated/schema.generated.ts"))
179
320
  ];
180
321
  for (const rootPath of roots) {
181
322
  await collectDirectoryTree(rootPath, directories);