@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
@@ -1,20 +1,20 @@
1
1
  import {
2
2
  prepareProjectDiscovery
3
- } from "./chunk-7JR73TOH.mjs";
3
+ } from "./chunk-VP2E62DF.mjs";
4
4
  import {
5
5
  syncManagedDriverDependencies
6
- } from "./chunk-WRZFATUT.mjs";
6
+ } from "./chunk-4OHJC3GL.mjs";
7
7
  import {
8
8
  ensureGeneratedSchemaPlaceholder,
9
9
  ensureProjectConfig
10
- } from "./chunk-SRPGIWCF.mjs";
10
+ } from "./chunk-YEFJBN56.mjs";
11
11
  import {
12
12
  renderFrameworkRunner
13
- } from "./chunk-IMOGEKB4.mjs";
13
+ } from "./chunk-J76GH2DR.mjs";
14
14
  import {
15
15
  readTextFile,
16
16
  writeTextFile
17
- } from "./chunk-R6BWRY3E.mjs";
17
+ } from "./chunk-ILU426CF.mjs";
18
18
 
19
19
  // src/dev.ts
20
20
  import { spawnSync, spawn } from "child_process";
@@ -88,6 +88,29 @@ async function runProjectLifecycleScript(io, projectRoot, scriptName, spawn2 = s
88
88
  throw new Error(result.stderr?.trim() || result.stdout?.trim() || `Project script "${scriptName}" failed.`);
89
89
  }
90
90
  }
91
+ async function runProjectStartServer(io, projectRoot, spawnProcess = spawn) {
92
+ const runnerPath = join(projectRoot, ".holo-js/framework/run.mjs");
93
+ const child = spawnProcess(process.execPath, [runnerPath, "start"], {
94
+ cwd: projectRoot,
95
+ env: process.env,
96
+ stdio: ["pipe", "pipe", "pipe"]
97
+ });
98
+ child.stdout?.on("data", (chunk) => io.stdout.write(chunk));
99
+ child.stderr?.on("data", (chunk) => io.stderr.write(chunk));
100
+ if (child.stdin) {
101
+ io.stdin.pipe(child.stdin);
102
+ }
103
+ const result = await new Promise((resolvePromise) => {
104
+ child.on("error", (error) => resolvePromise({ kind: "error", error }));
105
+ child.on("close", (code) => resolvePromise({ kind: "close", code }));
106
+ });
107
+ if (result.kind === "error") {
108
+ throw result.error;
109
+ }
110
+ if (result.code !== 0) {
111
+ throw new Error(`Project production server failed with exit code ${result.code ?? "unknown"}.`);
112
+ }
113
+ }
91
114
  async function runProjectDependencyInstall(io, projectRoot, spawn2 = spawnSync) {
92
115
  const invocation = await resolvePackageManagerInstallInvocation(projectRoot);
93
116
  const result = spawn2(invocation.command, [...invocation.args], {
@@ -105,22 +128,52 @@ async function runProjectDependencyInstall(io, projectRoot, spawn2 = spawnSync)
105
128
  throw new Error(result.stderr?.trim() || result.stdout?.trim() || "Project dependency installation failed.");
106
129
  }
107
130
  }
108
- async function runProjectPrepare(projectRoot, io) {
131
+ var FRAMEWORK_SYNC_DEFINITIONS = [
132
+ {
133
+ framework: "nuxt",
134
+ commands: {
135
+ bun: ["bun", "x", "nuxt", "prepare"],
136
+ npm: ["npm", "exec", "--", "nuxt", "prepare"],
137
+ pnpm: ["pnpm", "exec", "nuxt", "prepare"],
138
+ yarn: ["yarn", "run", "nuxt", "prepare"]
139
+ },
140
+ errorLabel: "nuxt prepare"
141
+ },
142
+ {
143
+ framework: "sveltekit",
144
+ commands: {
145
+ bun: ["bun", "x", "svelte-kit", "sync"],
146
+ npm: ["npm", "exec", "--", "svelte-kit", "sync"],
147
+ pnpm: ["pnpm", "exec", "svelte-kit", "sync"],
148
+ yarn: ["yarn", "run", "svelte-kit", "sync"]
149
+ },
150
+ errorLabel: "svelte-kit sync"
151
+ }
152
+ ];
153
+ async function runProjectPrepare(projectRoot, io, options = {}) {
109
154
  const project = await ensureProjectConfig(projectRoot);
110
155
  await ensureGeneratedSchemaPlaceholder(projectRoot, project.config);
111
156
  await prepareProjectDiscovery(projectRoot, project.config);
112
157
  await refreshFrameworkRunner(projectRoot);
113
- await runNuxtPrepare(projectRoot);
114
- await runSvelteKitSync(projectRoot);
158
+ const syncFramework = options.syncFramework ?? true;
159
+ if (syncFramework) {
160
+ await runFrameworkSync(projectRoot, FRAMEWORK_SYNC_DEFINITIONS[0]);
161
+ await runFrameworkSync(projectRoot, FRAMEWORK_SYNC_DEFINITIONS[1]);
162
+ }
115
163
  const updatedDependencies = await syncManagedDriverDependencies(projectRoot);
116
164
  if (updatedDependencies && io) {
117
165
  await runProjectDependencyInstall(io, projectRoot);
118
166
  await prepareProjectDiscovery(projectRoot, project.config);
119
167
  await refreshFrameworkRunner(projectRoot);
120
- await runNuxtPrepare(projectRoot);
121
- await runSvelteKitSync(projectRoot);
168
+ if (syncFramework) {
169
+ await runFrameworkSync(projectRoot, FRAMEWORK_SYNC_DEFINITIONS[0]);
170
+ await runFrameworkSync(projectRoot, FRAMEWORK_SYNC_DEFINITIONS[1]);
171
+ }
122
172
  }
123
173
  }
174
+ async function runProjectHotPrepare(projectRoot, io) {
175
+ await runProjectPrepare(projectRoot, io, { syncFramework: false });
176
+ }
124
177
  async function refreshFrameworkRunner(projectRoot) {
125
178
  const frameworkProjectPath = resolve(projectRoot, ".holo-js/framework/project.json");
126
179
  const frameworkRunnerPath = resolve(projectRoot, ".holo-js/framework/run.mjs");
@@ -137,91 +190,23 @@ async function refreshFrameworkRunner(projectRoot) {
137
190
  }
138
191
  await writeTextFile(frameworkRunnerPath, renderFrameworkRunner({ framework }));
139
192
  }
140
- async function runNuxtPrepare(projectRoot) {
141
- const frameworkProjectPath = resolve(projectRoot, ".holo-js/framework/project.json");
142
- try {
143
- const content = await readFile(frameworkProjectPath, "utf8");
144
- const manifest = JSON.parse(content);
145
- if (manifest.framework !== "nuxt") {
146
- return;
147
- }
148
- } catch {
149
- return;
150
- }
151
- const manager = await resolveProjectPackageManager(projectRoot);
152
- let command;
153
- let args;
154
- switch (manager) {
155
- case "npm":
156
- command = "npm";
157
- args = ["exec", "--", "nuxt", "prepare"];
158
- break;
159
- case "pnpm":
160
- command = "pnpm";
161
- args = ["exec", "nuxt", "prepare"];
162
- break;
163
- case "yarn":
164
- command = "yarn";
165
- args = ["run", "nuxt", "prepare"];
166
- break;
167
- case "bun":
168
- default:
169
- command = "bun";
170
- args = ["x", "nuxt", "prepare"];
171
- break;
172
- }
173
- const { spawn: spawn2 } = await import("child_process");
174
- await new Promise((resolve2, reject) => {
175
- const child = spawn2(command, args, {
176
- cwd: projectRoot,
177
- stdio: "inherit"
178
- });
179
- child.on("close", (code) => {
180
- if (code === 0) {
181
- resolve2(void 0);
182
- } else {
183
- reject(new Error(`nuxt prepare exited with ${code}`));
184
- }
185
- });
186
- child.on("error", reject);
187
- });
188
- }
189
- async function runSvelteKitSync(projectRoot) {
193
+ async function runFrameworkSync(projectRoot, definition) {
190
194
  const frameworkProjectPath = resolve(projectRoot, ".holo-js/framework/project.json");
191
195
  try {
192
196
  const content = await readFile(frameworkProjectPath, "utf8");
193
197
  const manifest = JSON.parse(content);
194
- if (manifest.framework !== "sveltekit") {
198
+ if (manifest.framework !== definition.framework) {
195
199
  return;
196
200
  }
197
201
  } catch {
198
202
  return;
199
203
  }
200
204
  const manager = await resolveProjectPackageManager(projectRoot);
201
- let command;
202
- let args;
203
- switch (manager) {
204
- case "npm":
205
- command = "npm";
206
- args = ["exec", "--", "svelte-kit", "sync"];
207
- break;
208
- case "pnpm":
209
- command = "pnpm";
210
- args = ["exec", "svelte-kit", "sync"];
211
- break;
212
- case "yarn":
213
- command = "yarn";
214
- args = ["run", "svelte-kit", "sync"];
215
- break;
216
- case "bun":
217
- default:
218
- command = "bun";
219
- args = ["x", "svelte-kit", "sync"];
220
- break;
221
- }
222
- const { spawn: spawn2 } = await import("child_process");
205
+ const invocation = definition.commands[manager];
206
+ const command = invocation[0];
207
+ const args = invocation.slice(1);
223
208
  await new Promise((resolve2, reject) => {
224
- const child = spawn2(command, args, {
209
+ const child = spawn(command, args, {
225
210
  cwd: projectRoot,
226
211
  stdio: "inherit"
227
212
  });
@@ -229,7 +214,7 @@ async function runSvelteKitSync(projectRoot) {
229
214
  if (code === 0) {
230
215
  resolve2(void 0);
231
216
  } else {
232
- reject(new Error(`svelte-kit sync exited with ${code}`));
217
+ reject(new Error(`${definition.errorLabel} exited with ${code}`));
233
218
  }
234
219
  });
235
220
  child.on("error", reject);
@@ -253,23 +238,14 @@ function resolveConfiguredChannelsPath(project) {
253
238
  const configuredPaths = project.config.paths;
254
239
  return configuredPaths.channels ?? "server/channels";
255
240
  }
256
- function isDiscoveryRelevantPath(filePath, project) {
257
- const normalized = toPosixSlashes(filePath);
258
- if (PACKAGE_MANIFEST_DISCOVERY_PATHS.has(normalized)) {
259
- return true;
260
- }
261
- const generatedSchemaPath = toPosixSlashes(project.config.paths.generatedSchema ?? ".holo-js/generated/schema.generated.ts");
262
- if (normalized === generatedSchemaPath) {
263
- return true;
264
- }
265
- if (normalized === ".holo-js/generated" || normalized.startsWith(".holo-js/generated/")) {
266
- return false;
267
- }
241
+ function resolveConfiguredRealtimePath(project) {
242
+ const configuredPaths = project.config.paths;
243
+ return configuredPaths.realtime ?? "server/realtime";
244
+ }
245
+ function resolveConfiguredDiscoveryRoots(project) {
268
246
  const authorizationPoliciesPath = project.config.paths.authorizationPolicies || "server/policies";
269
247
  const authorizationAbilitiesPath = project.config.paths.authorizationAbilities || "server/abilities";
270
- const broadcastPath = resolveConfiguredBroadcastPath(project);
271
- const channelsPath = resolveConfiguredChannelsPath(project);
272
- const roots = [
248
+ return [
273
249
  project.config.paths.models,
274
250
  project.config.paths.migrations,
275
251
  project.config.paths.seeders,
@@ -279,14 +255,28 @@ function isDiscoveryRelevantPath(filePath, project) {
279
255
  project.config.paths.listeners,
280
256
  authorizationPoliciesPath,
281
257
  authorizationAbilitiesPath,
282
- broadcastPath,
283
- channelsPath,
258
+ resolveConfiguredBroadcastPath(project),
259
+ resolveConfiguredChannelsPath(project),
260
+ resolveConfiguredRealtimePath(project),
284
261
  "config"
285
262
  ];
263
+ }
264
+ function isDiscoveryRelevantPath(filePath, project) {
265
+ const normalized = toPosixSlashes(filePath);
266
+ if (PACKAGE_MANIFEST_DISCOVERY_PATHS.has(normalized)) {
267
+ return true;
268
+ }
269
+ const generatedSchemaPath = toPosixSlashes(project.config.paths.generatedSchema ?? ".holo-js/generated/schema.generated.ts");
270
+ if (normalized === generatedSchemaPath) {
271
+ return true;
272
+ }
273
+ if (normalized === ".holo-js/generated" || normalized.startsWith(".holo-js/generated/")) {
274
+ return false;
275
+ }
286
276
  if (normalized === ".env" || normalized.startsWith(".env.")) {
287
277
  return true;
288
278
  }
289
- return roots.some((root) => normalized === root || normalized.startsWith(`${toPosixSlashes(root)}/`));
279
+ return resolveConfiguredDiscoveryRoots(project).some((root) => normalized === root || normalized.startsWith(`${toPosixSlashes(root)}/`));
290
280
  }
291
281
  function isRecursiveWatchUnsupported(error) {
292
282
  return error instanceof Error && (error.message.includes("recursive") || "code" in error && error.code === "ERR_FEATURE_UNAVAILABLE_ON_PLATFORM");
@@ -310,24 +300,9 @@ async function collectDirectoryTree(rootPath, directories) {
310
300
  }
311
301
  async function collectDiscoveryWatchRoots(projectRoot, project) {
312
302
  const directories = /* @__PURE__ */ new Set();
313
- const authorizationPoliciesPath = project.config.paths.authorizationPolicies || "server/policies";
314
- const authorizationAbilitiesPath = project.config.paths.authorizationAbilities || "server/abilities";
315
- const broadcastPath = resolveConfiguredBroadcastPath(project);
316
- const channelsPath = resolveConfiguredChannelsPath(project);
317
303
  const roots = [
318
304
  projectRoot,
319
- resolve(projectRoot, "config"),
320
- resolve(projectRoot, project.config.paths.models),
321
- resolve(projectRoot, project.config.paths.migrations),
322
- resolve(projectRoot, project.config.paths.seeders),
323
- resolve(projectRoot, project.config.paths.commands),
324
- resolve(projectRoot, project.config.paths.jobs),
325
- resolve(projectRoot, project.config.paths.events),
326
- resolve(projectRoot, project.config.paths.listeners),
327
- resolve(projectRoot, authorizationPoliciesPath),
328
- resolve(projectRoot, authorizationAbilitiesPath),
329
- resolve(projectRoot, broadcastPath),
330
- resolve(projectRoot, channelsPath),
305
+ ...resolveConfiguredDiscoveryRoots(project).map((root) => resolve(projectRoot, root)),
331
306
  resolve(projectRoot, dirname(project.config.paths.generatedSchema ?? ".holo-js/generated/schema.generated.ts"))
332
307
  ];
333
308
  for (const rootPath of roots) {
@@ -342,12 +317,13 @@ async function runProjectDevServer(io, projectRoot, spawnProcess = spawn, create
342
317
  let project = await ensureProjectConfig(projectRoot);
343
318
  let refreshNonRecursiveWatchers;
344
319
  let requestChildRestart;
345
- const prepareDiscovery = async () => {
346
- await prepare(projectRoot, io);
320
+ const hotPrepare = prepare === runProjectPrepare ? runProjectHotPrepare : prepare;
321
+ const prepareDiscovery = async (syncFramework = false) => {
322
+ await (syncFramework ? prepare : hotPrepare)(projectRoot, io);
347
323
  project = await ensureProjectConfig(projectRoot);
348
324
  await refreshNonRecursiveWatchers?.();
349
325
  };
350
- await prepareDiscovery();
326
+ await prepareDiscovery(true);
351
327
  let pendingPrepare;
352
328
  let queued = false;
353
329
  let shuttingDown = false;
@@ -482,6 +458,7 @@ export {
482
458
  resolvePackageManagerCommand,
483
459
  resolvePackageManagerInstallInvocation,
484
460
  runProjectLifecycleScript,
461
+ runProjectStartServer,
485
462
  runProjectDependencyInstall,
486
463
  runProjectPrepare,
487
464
  toPosixSlashes,
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  readTextFile
3
- } from "./chunk-R6BWRY3E.mjs";
3
+ } from "./chunk-ILU426CF.mjs";
4
4
 
5
5
  // src/package-json.ts
6
6
  import { join } from "path";
@@ -0,0 +1,33 @@
1
+ // src/io.ts
2
+ import { spinner } from "@clack/prompts";
3
+ function writeLine(stream, message = "") {
4
+ stream.write(`${message}
5
+ `);
6
+ }
7
+ async function runWithSpinner(io, message, task, successMessage = message) {
8
+ if (!supportsSpinner(io)) {
9
+ return task();
10
+ }
11
+ const loading = spinner({
12
+ input: io.stdin,
13
+ output: io.stdout
14
+ });
15
+ loading.start(message);
16
+ try {
17
+ const result = await task();
18
+ loading.stop(successMessage);
19
+ return result;
20
+ } catch (error) {
21
+ loading.error("Command failed.");
22
+ throw error;
23
+ }
24
+ }
25
+ function supportsSpinner(io) {
26
+ return io.stdin.isTTY === true && io.stdout.isTTY === true && typeof io.stdin.setRawMode === "function";
27
+ }
28
+
29
+ export {
30
+ writeLine,
31
+ runWithSpinner,
32
+ supportsSpinner
33
+ };
@@ -145,6 +145,7 @@ var GENERATED_EVENTS_PATH = join(GENERATED_ROOT, "events.ts");
145
145
  var GENERATED_LISTENERS_PATH = join(GENERATED_ROOT, "listeners.ts");
146
146
  var GENERATED_BROADCAST_PATH = join(GENERATED_ROOT, "broadcast.ts");
147
147
  var GENERATED_CHANNELS_PATH = join(GENERATED_ROOT, "channels.ts");
148
+ var GENERATED_CHANNEL_IMPORTER_PATH = join(GENERATED_ROOT, "channel-importer.ts");
148
149
  var GENERATED_BROADCAST_MANIFEST_PATH = join(GENERATED_ROOT, "broadcast-manifest.ts");
149
150
  var GENERATED_AUTHORIZATION_ROOT = join(GENERATED_ROOT, "authorization");
150
151
  var GENERATED_AUTHORIZATION_REGISTRY_PATH = join(GENERATED_AUTHORIZATION_ROOT, "registry.ts");
@@ -162,7 +163,7 @@ var GENERATED_SVELTE_HOOKS_PATH = join(GENERATED_ROOT, "hooks.ts");
162
163
  var GENERATED_SVELTE_SERVER_HOOKS_PATH = join(GENERATED_ROOT, "hooks.server.ts");
163
164
  var CONFIG_EXTENSION_PRIORITY = [".ts", ".mts", ".js", ".mjs", ".cts", ".cjs"];
164
165
  var SUPPORTED_CONFIG_EXTENSIONS = new Set(CONFIG_EXTENSION_PRIORITY);
165
- var SUPPORTED_SCAFFOLD_OPTIONAL_PACKAGES = ["storage", "events", "queue", "validation", "forms", "auth", "authorization", "notifications", "mail", "broadcast", "security", "cache"];
166
+ var SUPPORTED_SCAFFOLD_OPTIONAL_PACKAGES = ["storage", "events", "queue", "validation", "forms", "auth", "authorization", "notifications", "mail", "broadcast", "realtime", "security", "cache"];
166
167
  var SUPPORTED_QUEUE_INSTALLER_DRIVERS = ["sync", "redis", "database"];
167
168
  var SUPPORTED_CACHE_INSTALLER_DRIVERS = ["file", "redis", "database"];
168
169
  var HOLO_EVENT_DEFINITION_MARKER = /* @__PURE__ */ Symbol.for("holo-js.events.definition");
@@ -447,6 +448,7 @@ export {
447
448
  GENERATED_LISTENERS_PATH,
448
449
  GENERATED_BROADCAST_PATH,
449
450
  GENERATED_CHANNELS_PATH,
451
+ GENERATED_CHANNEL_IMPORTER_PATH,
450
452
  GENERATED_BROADCAST_MANIFEST_PATH,
451
453
  GENERATED_AUTHORIZATION_REGISTRY_PATH,
452
454
  GENERATED_AUTHORIZATION_TYPES_PATH,