@holo-js/cli 0.1.9 → 0.2.1

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 (46) hide show
  1. package/dist/bin/holo.mjs +179 -81
  2. package/dist/broadcast-III5MB3R.mjs +203 -0
  3. package/dist/broadcast-ZIFYFOUQ.mjs +203 -0
  4. package/dist/{cache-ETOIQ5IG.mjs → cache-634WUR3T.mjs} +6 -6
  5. package/dist/cache-7J7DIOP6.mjs +66 -0
  6. package/dist/{cache-migrations-2GGI4TJK.mjs → cache-migrations-2NBEUF2T.mjs} +50 -30
  7. package/dist/cache-migrations-S2LJMDOQ.mjs +173 -0
  8. package/dist/{chunk-WRZFATUT.mjs → chunk-4OHJC3GL.mjs} +232 -143
  9. package/dist/{chunk-ASTSSSL2.mjs → chunk-5TEH2QPK.mjs} +99 -122
  10. package/dist/{chunk-F4MT6GBK.mjs → chunk-FGQ2I2YH.mjs} +1 -1
  11. package/dist/chunk-I7QBCEV7.mjs +33 -0
  12. package/dist/{chunk-R6BWRY3E.mjs → chunk-ILU426CF.mjs} +3 -1
  13. package/dist/{chunk-IMOGEKB4.mjs → chunk-J76GH2DR.mjs} +229 -119
  14. package/dist/{chunk-HB4Q7VYK.mjs → chunk-KS5TWO75.mjs} +30 -273
  15. package/dist/{chunk-57SJ566R.mjs → chunk-LBJAJLKU.mjs} +1 -1
  16. package/dist/{chunk-BAFQ2GOA.mjs → chunk-LXGQCG56.mjs} +1 -1
  17. package/dist/chunk-MCVRN7KX.mjs +3308 -0
  18. package/dist/chunk-SFRAGRHY.mjs +472 -0
  19. package/dist/{chunk-7JR73TOH.mjs → chunk-VP2E62DF.mjs} +36 -25
  20. package/dist/{chunk-5EU32E7X.mjs → chunk-VRGB6DIS.mjs} +116 -12
  21. package/dist/{chunk-SRPGIWCF.mjs → chunk-YEFJBN56.mjs} +2 -2
  22. package/dist/{config-ARLE6PKR.mjs → config-MD27U4FM.mjs} +3 -3
  23. package/dist/{dev-6RG5SSZ7.mjs → dev-M2GGURAX.mjs} +9 -7
  24. package/dist/dev-PBNFQK6Y.mjs +44 -0
  25. package/dist/{discovery-FCVGQQVD.mjs → discovery-GWTBF5RZ.mjs} +3 -3
  26. package/dist/{generators-UI2LJK3O.mjs → generators-BZJ53PUU.mjs} +13 -36
  27. package/dist/generators-DEPLONDJ.mjs +520 -0
  28. package/dist/index.mjs +181 -83
  29. package/dist/{media-migrations-JQSDCC7S.mjs → media-migrations-5EISZBSD.mjs} +9 -20
  30. package/dist/media-migrations-NMUWBEKE.mjs +106 -0
  31. package/dist/{queue-BY3PLH4I.mjs → queue-FRAVPNFJ.mjs} +12 -12
  32. package/dist/queue-GY7BWGTX.mjs +625 -0
  33. package/dist/{queue-migrations-YZUKEZK7.mjs → queue-migrations-J7YPIKRB.mjs} +13 -12
  34. package/dist/queue-migrations-O24ERNFF.mjs +167 -0
  35. package/dist/{runtime-BI343WHS.mjs → runtime-2AA7ZLJ6.mjs} +9 -9
  36. package/dist/{runtime-ZKD6URAV.mjs → runtime-GSXF4NB3.mjs} +1 -1
  37. package/dist/runtime-HGK2MWSC.mjs +57 -0
  38. package/dist/runtime-worker.d.ts +2 -0
  39. package/dist/runtime-worker.mjs +276 -0
  40. package/dist/{scaffold-UBOS2NZR.mjs → scaffold-DEOTRALR.mjs} +9 -5
  41. package/dist/scaffold-Y232IGYS.mjs +139 -0
  42. package/dist/{security-TYPVOYGF.mjs → security-MZW2CJKS.mjs} +6 -6
  43. package/dist/security-XVG673UR.mjs +71 -0
  44. package/package.json +9 -7
  45. package/dist/broadcast-VR46UZEL.mjs +0 -84
  46. package/dist/chunk-ZXDU7RHU.mjs +0 -9
package/dist/bin/holo.mjs CHANGED
@@ -4,35 +4,38 @@ import {
4
4
  SUPPORTED_INSTALL_TARGETS,
5
5
  SUPPORTED_QUEUE_INSTALL_DRIVERS,
6
6
  collectMultiStringFlag,
7
- confirm,
8
7
  ensureRequiredArg,
9
8
  isInteractive,
10
9
  normalizeChoice,
11
10
  normalizeOptionalPackages,
12
11
  parseNumberFlag,
13
12
  parseTokens,
13
+ promptChoice,
14
+ promptMultiChoice,
14
15
  resolveBooleanFlag,
15
16
  resolveNewProjectInput,
16
17
  resolveStringFlag,
17
18
  splitCsv
18
- } from "../chunk-5EU32E7X.mjs";
19
+ } from "../chunk-VRGB6DIS.mjs";
19
20
  import {
20
21
  hasProjectDependency
21
- } from "../chunk-F4MT6GBK.mjs";
22
+ } from "../chunk-FGQ2I2YH.mjs";
22
23
  import {
24
+ runWithSpinner,
25
+ supportsSpinner,
23
26
  writeLine
24
- } from "../chunk-ZXDU7RHU.mjs";
27
+ } from "../chunk-I7QBCEV7.mjs";
25
28
  import {
26
29
  fileExists
27
- } from "../chunk-57SJ566R.mjs";
30
+ } from "../chunk-LBJAJLKU.mjs";
28
31
  import "../chunk-D7O4SU6N.mjs";
29
- import "../chunk-7JR73TOH.mjs";
30
- import "../chunk-WRZFATUT.mjs";
31
- import "../chunk-SRPGIWCF.mjs";
32
- import "../chunk-IMOGEKB4.mjs";
32
+ import "../chunk-VP2E62DF.mjs";
33
+ import "../chunk-4OHJC3GL.mjs";
34
+ import "../chunk-YEFJBN56.mjs";
35
+ import "../chunk-J76GH2DR.mjs";
33
36
  import {
34
37
  SUPPORTED_AUTH_SOCIAL_PROVIDERS
35
- } from "../chunk-R6BWRY3E.mjs";
38
+ } from "../chunk-ILU426CF.mjs";
36
39
 
37
40
  // src/cli.ts
38
41
  import { resolve as resolve2 } from "path";
@@ -105,6 +108,10 @@ async function generateProjectAppKey(projectRoot) {
105
108
  }
106
109
 
107
110
  // src/cli.ts
111
+ var AUTH_INSTALL_FEATURES = ["social", "workos", "clerk"];
112
+ var AUTH_SOCIAL_PROVIDER_MODES = ["default", "specific"];
113
+ var EVENTS_QUEUE_ACTIONS = ["skip", "enable"];
114
+ var MODEL_GENERATOR_OPTIONS = ["migration", "observer", "seeder", "factory"];
108
115
  var runtimeModulePromise;
109
116
  var queueModulePromise;
110
117
  var cacheModulePromise;
@@ -120,59 +127,59 @@ var projectDiscoveryModulePromise;
120
127
  var projectRuntimeModulePromise;
121
128
  var projectScaffoldModulePromise;
122
129
  function loadRuntimeModule() {
123
- runtimeModulePromise ??= import("../runtime-BI343WHS.mjs");
130
+ runtimeModulePromise ??= import("../runtime-HGK2MWSC.mjs");
124
131
  return runtimeModulePromise;
125
132
  }
126
133
  function loadQueueModule() {
127
- queueModulePromise ??= import("../queue-BY3PLH4I.mjs");
134
+ queueModulePromise ??= import("../queue-GY7BWGTX.mjs");
128
135
  return queueModulePromise;
129
136
  }
130
137
  function loadCacheModule() {
131
- cacheModulePromise ??= import("../cache-ETOIQ5IG.mjs");
138
+ cacheModulePromise ??= import("../cache-634WUR3T.mjs");
132
139
  return cacheModulePromise;
133
140
  }
134
141
  function loadQueueMigrationsModule() {
135
- queueMigrationsModulePromise ??= import("../queue-migrations-YZUKEZK7.mjs");
142
+ queueMigrationsModulePromise ??= import("../queue-migrations-J7YPIKRB.mjs");
136
143
  return queueMigrationsModulePromise;
137
144
  }
138
145
  function loadCacheMigrationsModule() {
139
- cacheMigrationsModulePromise ??= import("../cache-migrations-2GGI4TJK.mjs");
146
+ cacheMigrationsModulePromise ??= import("../cache-migrations-2NBEUF2T.mjs");
140
147
  return cacheMigrationsModulePromise;
141
148
  }
142
149
  function loadMediaMigrationsModule() {
143
- mediaMigrationsModulePromise ??= import("../media-migrations-JQSDCC7S.mjs");
150
+ mediaMigrationsModulePromise ??= import("../media-migrations-5EISZBSD.mjs");
144
151
  return mediaMigrationsModulePromise;
145
152
  }
146
153
  function loadGeneratorsModule() {
147
- generatorsModulePromise ??= import("../generators-UI2LJK3O.mjs");
154
+ generatorsModulePromise ??= import("../generators-DEPLONDJ.mjs");
148
155
  return generatorsModulePromise;
149
156
  }
150
157
  function loadBroadcastModule() {
151
- broadcastModulePromise ??= import("../broadcast-VR46UZEL.mjs");
158
+ broadcastModulePromise ??= import("../broadcast-ZIFYFOUQ.mjs");
152
159
  return broadcastModulePromise;
153
160
  }
154
161
  function loadSecurityModule() {
155
- securityModulePromise ??= import("../security-TYPVOYGF.mjs");
162
+ securityModulePromise ??= import("../security-XVG673UR.mjs");
156
163
  return securityModulePromise;
157
164
  }
158
165
  function loadDevModule() {
159
- devModulePromise ??= import("../dev-6RG5SSZ7.mjs");
166
+ devModulePromise ??= import("../dev-M2GGURAX.mjs");
160
167
  return devModulePromise;
161
168
  }
162
169
  function loadProjectConfigModule() {
163
- projectConfigModulePromise ??= import("../config-ARLE6PKR.mjs");
170
+ projectConfigModulePromise ??= import("../config-MD27U4FM.mjs");
164
171
  return projectConfigModulePromise;
165
172
  }
166
173
  function loadProjectDiscoveryModule() {
167
- projectDiscoveryModulePromise ??= import("../discovery-FCVGQQVD.mjs");
174
+ projectDiscoveryModulePromise ??= import("../discovery-GWTBF5RZ.mjs");
168
175
  return projectDiscoveryModulePromise;
169
176
  }
170
177
  function loadProjectRuntimeModule() {
171
- projectRuntimeModulePromise ??= import("../runtime-ZKD6URAV.mjs");
178
+ projectRuntimeModulePromise ??= import("../runtime-GSXF4NB3.mjs");
172
179
  return projectRuntimeModulePromise;
173
180
  }
174
181
  function loadProjectScaffoldModule() {
175
- projectScaffoldModulePromise ??= import("../scaffold-UBOS2NZR.mjs");
182
+ projectScaffoldModulePromise ??= import("../scaffold-Y232IGYS.mjs");
176
183
  return projectScaffoldModulePromise;
177
184
  }
178
185
  async function resolveRuntimeExecutor(runtimeExecutor) {
@@ -182,14 +189,18 @@ var projectExecutorLoaders = {
182
189
  runProjectPrepare: async () => (await loadDevModule()).runProjectPrepare,
183
190
  runProjectDevServer: async () => (await loadDevModule()).runProjectDevServer,
184
191
  runProjectLifecycleScript: async () => (await loadDevModule()).runProjectLifecycleScript,
192
+ runProjectStartServer: async () => (await loadDevModule()).runProjectStartServer,
185
193
  runProjectDependencyInstall: async () => (await loadDevModule()).runProjectDependencyInstall
186
194
  };
187
- async function resolveProjectExecutor(projectExecutors, key) {
188
- const existing = projectExecutors[key];
195
+ async function resolveExecutor(executors, loaders, key) {
196
+ const existing = executors[key];
189
197
  if (existing) {
190
198
  return existing;
191
199
  }
192
- return projectExecutorLoaders[key]();
200
+ return await loaders[key]();
201
+ }
202
+ async function resolveProjectExecutor(projectExecutors, key) {
203
+ return await resolveExecutor(projectExecutors, projectExecutorLoaders, key);
193
204
  }
194
205
  var queueExecutorLoaders = {
195
206
  runQueueFailedTableCommand: async () => (await loadQueueMigrationsModule()).runQueueFailedTableCommand,
@@ -215,32 +226,16 @@ var broadcastExecutorLoaders = {
215
226
  runBroadcastWorkCommand: async () => (await loadBroadcastModule()).runBroadcastWorkCommand
216
227
  };
217
228
  async function resolveQueueExecutor(queueExecutors, key) {
218
- const existing = queueExecutors[key];
219
- if (existing) {
220
- return existing;
221
- }
222
- return queueExecutorLoaders[key]();
229
+ return await resolveExecutor(queueExecutors, queueExecutorLoaders, key);
223
230
  }
224
231
  async function resolveCacheExecutor(cacheExecutors, key) {
225
- const existing = cacheExecutors[key];
226
- if (existing) {
227
- return existing;
228
- }
229
- return cacheExecutorLoaders[key]();
232
+ return await resolveExecutor(cacheExecutors, cacheExecutorLoaders, key);
230
233
  }
231
234
  async function resolveMediaExecutor(mediaExecutors, key) {
232
- const existing = mediaExecutors[key];
233
- if (existing) {
234
- return existing;
235
- }
236
- return mediaExecutorLoaders[key]();
235
+ return await resolveExecutor(mediaExecutors, mediaExecutorLoaders, key);
237
236
  }
238
237
  async function resolveBroadcastExecutor(broadcastExecutors, key) {
239
- const existing = broadcastExecutors[key];
240
- if (existing) {
241
- return existing;
242
- }
243
- return broadcastExecutorLoaders[key]();
238
+ return await resolveExecutor(broadcastExecutors, broadcastExecutorLoaders, key);
244
239
  }
245
240
  async function resolveGeneratorCommand(key) {
246
241
  return (await loadGeneratorsModule())[key];
@@ -295,10 +290,12 @@ async function runProjectDependencyInstallAfterPackageJsonUpdate(context, projec
295
290
  const runProjectPrepare = await resolveProjectExecutor(projectExecutors, "runProjectPrepare");
296
291
  await runProjectPrepare(context.projectRoot, context);
297
292
  }
298
- async function runProjectDependencyInstallForProject(context, projectExecutors, projectRoot) {
293
+ async function runProjectDependencyInstallForProject(context, projectExecutors, projectRoot, options = {}) {
299
294
  const runProjectDependencyInstall = await resolveProjectExecutor(projectExecutors, "runProjectDependencyInstall");
300
295
  await runProjectDependencyInstall(context, projectRoot);
301
- writeLine(context.stdout, " - installed dependencies");
296
+ if (options.writeStatus ?? true) {
297
+ writeLine(context.stdout, " - installed dependencies");
298
+ }
302
299
  }
303
300
  function createInternalCommands(context, runtimeExecutor, queueExecutors = {}, projectExecutors = {}, broadcastExecutors = {}, securityExecutors = {}, cacheExecutors = {}, mediaExecutors = {}) {
304
301
  return [
@@ -317,7 +314,7 @@ function createInternalCommands(context, runtimeExecutor, queueExecutors = {}, p
317
314
  {
318
315
  name: "new",
319
316
  description: "Scaffold a new Holo project",
320
- usage: "holo new <name> [--framework <nuxt|next|sveltekit>] [--database <sqlite|mysql|postgres>] [--package-manager <bun|npm|pnpm|yarn>] [--package <storage|events|queue|validation|forms|auth|authorization|notifications|mail|broadcast|security|cache>] [--storage-default-disk <local|public>]",
317
+ usage: "holo new <name> [--framework <nuxt|next|sveltekit>] [--database <sqlite|mysql|postgres>] [--package-manager <bun|npm|pnpm|yarn>] [--package <storage|events|queue|validation|forms|auth|authorization|notifications|mail|broadcast|realtime|security|cache>] [--storage-default-disk <local|public>]",
321
318
  source: "internal",
322
319
  async prepare(input) {
323
320
  const resolved = await resolveNewProjectInput(context, input);
@@ -343,16 +340,28 @@ function createInternalCommands(context, runtimeExecutor, queueExecutors = {}, p
343
340
  );
344
341
  const targetDir = resolve2(commandContext.cwd, projectName);
345
342
  const { scaffoldProject } = await loadProjectScaffoldModule();
346
- await scaffoldProject(targetDir, {
347
- projectName,
348
- framework,
349
- databaseDriver,
350
- packageManager,
351
- storageDefaultDisk,
352
- optionalPackages
353
- });
343
+ await runWithSpinner(
344
+ context,
345
+ "Creating project files...",
346
+ () => scaffoldProject(targetDir, {
347
+ projectName,
348
+ framework,
349
+ databaseDriver,
350
+ packageManager,
351
+ storageDefaultDisk,
352
+ optionalPackages
353
+ }),
354
+ "Project files created."
355
+ );
354
356
  writeLine(context.stdout, `Created Holo project: ${targetDir}`);
355
- await runProjectDependencyInstallForProject(context, projectExecutors, targetDir);
357
+ await runWithSpinner(
358
+ context,
359
+ "Installing dependencies...",
360
+ () => runProjectDependencyInstallForProject(context, projectExecutors, targetDir, {
361
+ writeStatus: !supportsSpinner(context)
362
+ }),
363
+ "Dependencies installed."
364
+ );
356
365
  writeLine(context.stdout);
357
366
  writeLine(context.stdout, "Next steps");
358
367
  writeLine(context.stdout, ` cd ${projectName}`);
@@ -378,11 +387,13 @@ function createInternalCommands(context, runtimeExecutor, queueExecutors = {}, p
378
387
  {
379
388
  name: "install",
380
389
  description: "Install first-party Holo support into an existing project.",
381
- usage: "holo install <queue|events|auth|authorization|notifications|mail|broadcast|security|cache|media> [--driver <queue: sync|file|redis|database; cache: file|redis|database>] [--social] [--provider <google|github|discord|facebook|apple|linkedin>] [--workos] [--clerk]",
390
+ usage: "holo install <queue|events|auth|authorization|notifications|mail|broadcast|realtime|security|cache|media> [--driver <queue: sync|file|redis|database; cache: file|redis|database>] [--social] [--provider <google|github|discord|facebook|apple|linkedin>] [--workos] [--clerk]",
382
391
  source: "internal",
383
392
  async prepare(input) {
393
+ const interactive = isInteractive(context, input.flags);
394
+ const requestedTarget = input.args[0]?.trim();
384
395
  const target = normalizeChoice(
385
- await ensureRequiredArg(context, input, 0, "Install target"),
396
+ requestedTarget || (interactive ? await promptChoice(context, "Install target", SUPPORTED_INSTALL_TARGETS, "queue") : await ensureRequiredArg(context, input, 0, "Install target")),
386
397
  SUPPORTED_INSTALL_TARGETS,
387
398
  "install target"
388
399
  );
@@ -405,17 +416,65 @@ function createInternalCommands(context, runtimeExecutor, queueExecutors = {}, p
405
416
  if (target === "broadcast" && requestedDriver) {
406
417
  throw new Error("The broadcast installer does not support --driver.");
407
418
  }
419
+ if (target === "realtime" && requestedDriver) {
420
+ throw new Error("The realtime installer does not support --driver.");
421
+ }
408
422
  if (target === "security" && requestedDriver) {
409
423
  throw new Error("The security installer does not support --driver.");
410
424
  }
411
425
  if (target === "media" && requestedDriver) {
412
426
  throw new Error("The media installer does not support --driver.");
413
427
  }
414
- const driver = target === "queue" ? requestedDriver ? normalizeChoice(requestedDriver, SUPPORTED_QUEUE_INSTALL_DRIVERS, "queue driver") : "sync" : target === "cache" ? requestedDriver ? normalizeChoice(requestedDriver, SUPPORTED_CACHE_INSTALL_DRIVERS, "cache driver") : "file" : void 0;
415
- const socialProviders = target === "auth" ? (collectMultiStringFlag(input.flags, "provider") ?? []).flatMap((entry) => splitCsv(entry) ?? []).map((provider) => normalizeChoice(provider, SUPPORTED_AUTH_SOCIAL_PROVIDERS, "auth social provider")) : [];
416
- const social = target === "auth" ? resolveBooleanFlag(input.flags, "social") === true || socialProviders.length > 0 : false;
417
- const workos = target === "auth" ? resolveBooleanFlag(input.flags, "workos") === true : false;
418
- const clerk = target === "auth" ? resolveBooleanFlag(input.flags, "clerk") === true : false;
428
+ const driver = target === "queue" ? requestedDriver ? normalizeChoice(requestedDriver, SUPPORTED_QUEUE_INSTALL_DRIVERS, "queue driver") : interactive ? await promptChoice(context, "Queue driver", SUPPORTED_QUEUE_INSTALL_DRIVERS, "sync") : "sync" : target === "cache" ? requestedDriver ? normalizeChoice(requestedDriver, SUPPORTED_CACHE_INSTALL_DRIVERS, "cache driver") : interactive ? await promptChoice(context, "Cache driver", SUPPORTED_CACHE_INSTALL_DRIVERS, "file") : "file" : void 0;
429
+ let socialProviders = target === "auth" ? (collectMultiStringFlag(input.flags, "provider") ?? []).flatMap((entry) => splitCsv(entry) ?? []).map((provider) => normalizeChoice(provider, SUPPORTED_AUTH_SOCIAL_PROVIDERS, "auth social provider")) : [];
430
+ let social = target === "auth" ? resolveBooleanFlag(input.flags, "social") === true || socialProviders.length > 0 : false;
431
+ let workos = target === "auth" ? resolveBooleanFlag(input.flags, "workos") === true : false;
432
+ let clerk = target === "auth" ? resolveBooleanFlag(input.flags, "clerk") === true : false;
433
+ const authFlagsProvided = "social" in input.flags || "provider" in input.flags || "workos" in input.flags || "clerk" in input.flags;
434
+ if (target === "auth" && interactive && !authFlagsProvided) {
435
+ const features = await promptMultiChoice(
436
+ context,
437
+ "Auth providers",
438
+ AUTH_INSTALL_FEATURES,
439
+ {
440
+ labels: {
441
+ social: "Social OAuth",
442
+ workos: "WorkOS",
443
+ clerk: "Clerk"
444
+ },
445
+ hints: {
446
+ social: "Google, GitHub, Discord, Facebook, Apple, or LinkedIn"
447
+ }
448
+ }
449
+ );
450
+ social = features.includes("social");
451
+ workos = features.includes("workos");
452
+ clerk = features.includes("clerk");
453
+ if (social) {
454
+ const providerMode = await promptChoice(
455
+ context,
456
+ "Social provider setup",
457
+ AUTH_SOCIAL_PROVIDER_MODES,
458
+ "default",
459
+ {
460
+ labels: {
461
+ default: "Default social setup",
462
+ specific: "Choose specific providers"
463
+ }
464
+ }
465
+ );
466
+ if (providerMode === "specific") {
467
+ socialProviders = [
468
+ ...await promptMultiChoice(
469
+ context,
470
+ "Social providers",
471
+ SUPPORTED_AUTH_SOCIAL_PROVIDERS,
472
+ { required: true }
473
+ )
474
+ ];
475
+ }
476
+ }
477
+ }
419
478
  return {
420
479
  args: [target],
421
480
  flags: {
@@ -439,12 +498,19 @@ function createInternalCommands(context, runtimeExecutor, queueExecutors = {}, p
439
498
  const eventsResult = await installEventsIntoProject(context.projectRoot);
440
499
  let queueResult;
441
500
  if (!queueConfigured && isInteractive(context, commandContext.flags)) {
442
- const enableQueuedListeners = await confirm(
501
+ const queueAction = await promptChoice(
443
502
  context,
444
- "Enable queued listeners too?",
445
- false
503
+ "Queued listeners",
504
+ EVENTS_QUEUE_ACTIONS,
505
+ "skip",
506
+ {
507
+ labels: {
508
+ skip: "Skip queued listeners",
509
+ enable: "Enable queued listeners"
510
+ }
511
+ }
446
512
  );
447
- if (enableQueuedListeners) {
513
+ if (queueAction === "enable") {
448
514
  queueResult = await installQueueIntoProject2(context.projectRoot, { driver: "sync" });
449
515
  }
450
516
  }
@@ -545,6 +611,17 @@ function createInternalCommands(context, runtimeExecutor, queueExecutors = {}, p
545
611
  await runProjectDependencyInstallAfterPackageJsonUpdate(context, projectExecutors, result2.updatedPackageJson);
546
612
  return;
547
613
  }
614
+ if (target === "realtime") {
615
+ const { installRealtimeIntoProject } = await loadProjectScaffoldModule();
616
+ const result2 = await installRealtimeIntoProject(context.projectRoot);
617
+ const changed2 = result2.updatedPackageJson || result2.createdRealtimeDirectory || result2.createdFrameworkSetup;
618
+ writeLine(context.stdout, changed2 ? "Installed realtime support." : "Realtime support is already installed.");
619
+ if (result2.updatedPackageJson) writeLine(context.stdout, " - updated package.json");
620
+ if (result2.createdRealtimeDirectory) writeLine(context.stdout, " - created server/realtime");
621
+ if (result2.createdFrameworkSetup) writeLine(context.stdout, " - created realtime framework setup");
622
+ await runProjectDependencyInstallAfterPackageJsonUpdate(context, projectExecutors, result2.updatedPackageJson);
623
+ return;
624
+ }
548
625
  if (target === "security") {
549
626
  const { installSecurityIntoProject } = await loadProjectScaffoldModule();
550
627
  const result2 = await installSecurityIntoProject(context.projectRoot);
@@ -669,6 +746,19 @@ function createInternalCommands(context, runtimeExecutor, queueExecutors = {}, p
669
746
  await runProjectLifecycleScript(context, context.projectRoot, "holo:build");
670
747
  }
671
748
  },
749
+ {
750
+ name: "start",
751
+ description: "Run the production framework server with Holo runtime preloads.",
752
+ usage: "holo start",
753
+ source: "internal",
754
+ async prepare() {
755
+ return { args: [], flags: {} };
756
+ },
757
+ async run() {
758
+ const runProjectStartServer = await resolveProjectExecutor(projectExecutors, "runProjectStartServer");
759
+ await runProjectStartServer(context, context.projectRoot);
760
+ }
761
+ },
672
762
  {
673
763
  name: "broadcast:work",
674
764
  description: "Run the self-hosted broadcast worker.",
@@ -1041,17 +1131,25 @@ function createInternalCommands(context, runtimeExecutor, queueExecutors = {}, p
1041
1131
  };
1042
1132
  if (isInteractive(context, input.flags)) {
1043
1133
  const noneSelected = [flags.migration, flags.observer, flags.seeder, flags.factory].every((value) => value !== true);
1044
- if (noneSelected && await confirm(context, "Generate a migration?", true)) {
1045
- flags.migration = true;
1046
- }
1047
- if (!flags.observer && await confirm(context, "Generate an observer?")) {
1048
- flags.observer = true;
1049
- }
1050
- if (!flags.seeder && await confirm(context, "Generate a seeder?")) {
1051
- flags.seeder = true;
1052
- }
1053
- if (!flags.factory && await confirm(context, "Generate a factory?")) {
1054
- flags.factory = true;
1134
+ if (noneSelected) {
1135
+ const selectedArtifacts = await promptMultiChoice(
1136
+ context,
1137
+ "Model artifacts",
1138
+ MODEL_GENERATOR_OPTIONS,
1139
+ {
1140
+ initialValues: ["migration"],
1141
+ labels: {
1142
+ migration: "Migration",
1143
+ observer: "Observer",
1144
+ seeder: "Seeder",
1145
+ factory: "Factory"
1146
+ }
1147
+ }
1148
+ );
1149
+ flags.migration = selectedArtifacts.includes("migration");
1150
+ flags.observer = selectedArtifacts.includes("observer");
1151
+ flags.seeder = selectedArtifacts.includes("seeder");
1152
+ flags.factory = selectedArtifacts.includes("factory");
1055
1153
  }
1056
1154
  }
1057
1155
  return {
@@ -0,0 +1,203 @@
1
+ import {
2
+ initializeProjectRuntime
3
+ } from "./chunk-KS5TWO75.mjs";
4
+ import "./chunk-LBJAJLKU.mjs";
5
+ import {
6
+ writeLine
7
+ } from "./chunk-I7QBCEV7.mjs";
8
+ import "./chunk-D7O4SU6N.mjs";
9
+ import {
10
+ prepareProjectDiscovery
11
+ } from "./chunk-VP2E62DF.mjs";
12
+ import "./chunk-MCVRN7KX.mjs";
13
+ import {
14
+ loadProjectConfig
15
+ } from "./chunk-YEFJBN56.mjs";
16
+ import {
17
+ loadGeneratedProjectRegistry
18
+ } from "./chunk-J76GH2DR.mjs";
19
+ import {
20
+ importProjectModule,
21
+ resolveProjectPackageImportSpecifier
22
+ } from "./chunk-ILU426CF.mjs";
23
+
24
+ // src/broadcast.ts
25
+ import { basename, extname, resolve } from "path";
26
+ import { readFile } from "fs/promises";
27
+ import { loadConfigDirectory } from "@holo-js/config";
28
+ function hasLoadedRedisConfigSection(loadedFiles) {
29
+ return Array.isArray(loadedFiles) && loadedFiles.some((filePath) => {
30
+ return basename(filePath, extname(filePath)) === "redis";
31
+ });
32
+ }
33
+ async function hasProjectPackageDependency(projectRoot, packageName) {
34
+ try {
35
+ const manifest = JSON.parse(await readFile(resolve(projectRoot, "package.json"), "utf8"));
36
+ return Boolean(
37
+ manifest.dependencies?.[packageName] || manifest.devDependencies?.[packageName] || manifest.optionalDependencies?.[packageName] || manifest.peerDependencies?.[packageName]
38
+ );
39
+ } catch {
40
+ return false;
41
+ }
42
+ }
43
+ async function loadBroadcastCliModule(projectRoot) {
44
+ try {
45
+ return await import(resolveProjectPackageImportSpecifier(projectRoot, "@holo-js/broadcast"));
46
+ } catch (error) {
47
+ const details = error instanceof Error ? error.message : String(error);
48
+ throw new Error(
49
+ `Unable to load @holo-js/broadcast from ${projectRoot}. Install it with "holo install broadcast". ${details}`
50
+ );
51
+ }
52
+ }
53
+ async function loadRealtimeServerModule(projectRoot) {
54
+ const specifier = resolveProjectPackageImportSpecifier(projectRoot, "@holo-js/realtime/server");
55
+ try {
56
+ return await import(specifier);
57
+ } catch (error) {
58
+ const details = error instanceof Error ? error.message : String(error);
59
+ if (/Cannot find module|ERR_MODULE_NOT_FOUND|MODULE_NOT_FOUND/i.test(details) && details.includes(specifier)) {
60
+ return null;
61
+ }
62
+ throw error;
63
+ }
64
+ }
65
+ function safeDecodeCookieSegment(value) {
66
+ try {
67
+ return decodeURIComponent(value);
68
+ } catch {
69
+ return value;
70
+ }
71
+ }
72
+ function readCookieFromHeader(header, name) {
73
+ for (const segment of header?.split(";") ?? []) {
74
+ const separator = segment.indexOf("=");
75
+ if (separator <= 0) {
76
+ continue;
77
+ }
78
+ const cookieName = safeDecodeCookieSegment(segment.slice(0, separator).trim());
79
+ if (cookieName === name) {
80
+ return safeDecodeCookieSegment(segment.slice(separator + 1).trim());
81
+ }
82
+ }
83
+ return void 0;
84
+ }
85
+ function createRealtimeAuthRequestAccessors(headers) {
86
+ return {
87
+ async getCookie(name) {
88
+ return readCookieFromHeader(headers.get("cookie"), name);
89
+ },
90
+ async getHeader(name) {
91
+ return headers.get(name) ?? void 0;
92
+ },
93
+ async appendResponseCookie(_cookie) {
94
+ },
95
+ async redirectResponse(url) {
96
+ throw new Error(`Realtime auth attempted to redirect to "${url}". Realtime requests cannot redirect.`);
97
+ }
98
+ };
99
+ }
100
+ async function createRealtimeWorkerBindings(projectRoot) {
101
+ if (!await hasProjectPackageDependency(projectRoot, "@holo-js/realtime")) {
102
+ return void 0;
103
+ }
104
+ const realtime = await loadRealtimeServerModule(projectRoot);
105
+ if (!realtime) {
106
+ return void 0;
107
+ }
108
+ const runtime = await initializeProjectRuntime(projectRoot);
109
+ realtime.configureRealtimeRuntime?.({
110
+ async runWithAuthRequestAccessors(accessors, callback) {
111
+ const runner = runtime.runWithAuthRequestAccessors;
112
+ return runner ? await runner(accessors, callback) : await callback();
113
+ }
114
+ });
115
+ const definitions = /* @__PURE__ */ new Map();
116
+ const resolveDefinition = async (name) => {
117
+ const cached = definitions.get(name);
118
+ if (cached) {
119
+ return await cached;
120
+ }
121
+ const resolved = realtime.resolveRealtimeDefinition(name, {
122
+ projectRoot,
123
+ importModule: async (absolutePath) => await importProjectModule(projectRoot, absolutePath)
124
+ }).catch((error) => {
125
+ definitions.delete(name);
126
+ throw error;
127
+ });
128
+ definitions.set(name, resolved);
129
+ return await resolved;
130
+ };
131
+ const withRealtimeRequest = async (context, callback) => {
132
+ return await callback(createRealtimeAuthRequestAccessors(context.headers));
133
+ };
134
+ return {
135
+ async query(name, args, context) {
136
+ return await withRealtimeRequest(context, async (authRequest) => {
137
+ return await realtime.executeRealtimeQuery(await resolveDefinition(name), args, { authRequest });
138
+ });
139
+ },
140
+ async mutate(name, args, context) {
141
+ return await withRealtimeRequest(context, async (authRequest) => {
142
+ return await realtime.executeRealtimeMutation(await resolveDefinition(name), args, { authRequest });
143
+ });
144
+ },
145
+ async subscribe(name, args, options) {
146
+ return await withRealtimeRequest(options.context, async (authRequest) => {
147
+ return await realtime.subscribeRealtimeQuery(await resolveDefinition(name), args, {
148
+ onData: options.onData,
149
+ onError: options.onError
150
+ }, { authRequest });
151
+ });
152
+ }
153
+ };
154
+ }
155
+ async function runBroadcastWorkCommand(io, projectRoot, dependencies = {}) {
156
+ const loadConfig = dependencies.loadConfig ?? loadConfigDirectory;
157
+ const loadModule = dependencies.loadModule ?? loadBroadcastCliModule;
158
+ const config = await loadConfig(projectRoot);
159
+ const project = await loadProjectConfig(projectRoot);
160
+ const loadRegistry = dependencies.loadRegistry ?? loadGeneratedProjectRegistry;
161
+ await loadRegistry(projectRoot).catch(() => void 0);
162
+ const registry = await prepareProjectDiscovery(projectRoot, project.config);
163
+ const broadcastModule = await loadModule(projectRoot);
164
+ const realtime = await createRealtimeWorkerBindings(projectRoot);
165
+ const worker = await broadcastModule.startBroadcastWorker({
166
+ config: config.broadcast,
167
+ queue: config.queue,
168
+ ...hasLoadedRedisConfigSection(config.loadedFiles) ? { redis: config.redis } : {},
169
+ ...registry ? {
170
+ channelAuth: {
171
+ registry: {
172
+ projectRoot,
173
+ channels: registry.channels
174
+ },
175
+ importModule: async (absolutePath) => await importProjectModule(projectRoot, absolutePath)
176
+ }
177
+ } : {},
178
+ ...realtime ? { realtime } : {}
179
+ });
180
+ writeLine(io.stdout, `[broadcast] Worker listening on ${worker.host}:${worker.port}`);
181
+ await new Promise((resolvePromise) => {
182
+ let stopped = false;
183
+ const stop = async () => {
184
+ if (stopped) {
185
+ return;
186
+ }
187
+ stopped = true;
188
+ process.off("SIGINT", onSignal);
189
+ process.off("SIGTERM", onSignal);
190
+ await worker.stop();
191
+ resolvePromise();
192
+ };
193
+ const onSignal = () => {
194
+ void stop();
195
+ };
196
+ process.on("SIGINT", onSignal);
197
+ process.on("SIGTERM", onSignal);
198
+ });
199
+ }
200
+ export {
201
+ loadBroadcastCliModule,
202
+ runBroadcastWorkCommand
203
+ };