@holo-js/cli 0.1.3 → 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-YZS4OFCM.mjs → broadcast-RT5KVZWP.mjs} +5 -5
  3. package/dist/{cache-V43YMG4K.mjs → cache-NHCCHT44.mjs} +5 -5
  4. package/dist/{cache-migrations-ZUOI2A7N.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-RB65DLR4.mjs → chunk-SCCPDJGO.mjs} +156 -16
  14. package/dist/{chunk-VT5IDQG6.mjs → chunk-UZTDQKIY.mjs} +61 -44
  15. package/dist/{chunk-HE6FYNVN.mjs → chunk-VCEO6N5T.mjs} +3563 -2505
  16. package/dist/{config-LS5USBRB.mjs → config-5JSC6KJG.mjs} +3 -3
  17. package/dist/{dev-KGRIGLJY.mjs → dev-OSLYSBTL.mjs} +7 -7
  18. package/dist/{discovery-GBLAUTXS.mjs → discovery-JLT2EOGH.mjs} +3 -3
  19. package/dist/{generators-WSF23UKM.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-6N7HQMRL.mjs → queue-I66EISVS.mjs} +14 -14
  24. package/dist/{queue-migrations-O6QSSDPQ.mjs → queue-migrations-UIAMAB6E.mjs} +24 -20
  25. package/dist/{runtime-RI4OWTIT.mjs → runtime-MMQGO4PP.mjs} +9 -7
  26. package/dist/{runtime-OOSJ5JBY.mjs → runtime-ZKD6URAV.mjs} +1 -1
  27. package/dist/{scaffold-IYWZKT3W.mjs → scaffold-ISDVICNQ.mjs} +18 -4
  28. package/dist/{security-AE6LGNC4.mjs → security-OZXTMYXF.mjs} +10 -7
  29. package/package.json +13 -12
  30. package/dist/broadcast-ZYFKUFM5.mjs +0 -85
  31. package/dist/cache-ODBZT6IP.mjs +0 -67
  32. package/dist/cache-migrations-KPOEH6GP.mjs +0 -155
  33. package/dist/chunk-BWW5TDFI.mjs +0 -4
  34. package/dist/chunk-D4GG556Y.mjs +0 -23
  35. package/dist/chunk-ET7UXHHQ.mjs +0 -166
  36. package/dist/chunk-G5ADO27Q.mjs +0 -463
  37. package/dist/chunk-GSQ3HTRO.mjs +0 -165
  38. package/dist/chunk-H7TJ4FB3.mjs +0 -848
  39. package/dist/chunk-ICJR7TS4.mjs +0 -66
  40. package/dist/chunk-ICKN56JY.mjs +0 -342
  41. package/dist/chunk-M7J3YTHR.mjs +0 -26
  42. package/dist/chunk-S7P7EBM3.mjs +0 -787
  43. package/dist/chunk-SRWJU3A5.mjs +0 -11
  44. package/dist/chunk-T4OVZZEE.mjs +0 -3204
  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-LVHDCPVS.mjs +0 -43
  49. package/dist/discovery-R733D2PO.mjs +0 -29
  50. package/dist/generators-32R45P6Z.mjs +0 -426
  51. package/dist/queue-QG5EXOG4.mjs +0 -626
  52. package/dist/queue-migrations-JWKU45Y3.mjs +0 -163
  53. package/dist/runtime-ANBO7VQM.mjs +0 -33
  54. package/dist/runtime-ZRPK5DIT.mjs +0 -56
  55. package/dist/scaffold-ULATB4CA.mjs +0 -121
  56. package/dist/security-OCOPEH2V.mjs +0 -69
@@ -1,66 +0,0 @@
1
- #!/usr/bin/env node
2
- import {
3
- fileExists
4
- } from "./chunk-M7J3YTHR.mjs";
5
-
6
- // src/migrations.ts
7
- import { join } from "path";
8
- import {
9
- generateMigrationTemplate,
10
- inferMigrationTableName,
11
- inferMigrationTemplateKind,
12
- normalizeMigrationSlug
13
- } from "@holo-js/db";
14
- var MIGRATION_NAME_PREFIX_PATTERN = /^\d{4}_\d{2}_\d{2}_\d{6}_/;
15
- function stripMigrationNamePrefix(name) {
16
- return name.replace(MIGRATION_NAME_PREFIX_PATTERN, "");
17
- }
18
- function getRegistryMigrationSlug(name) {
19
- return normalizeMigrationSlug(stripMigrationNamePrefix(name));
20
- }
21
- function hasRegisteredMigrationSlug(registry, migrationSlug) {
22
- return Boolean(registry?.migrations.some((entry) => {
23
- try {
24
- return getRegistryMigrationSlug(entry.name) === migrationSlug;
25
- } catch {
26
- return false;
27
- }
28
- }));
29
- }
30
- function hasRegisteredCreateTableMigration(registry, tableName) {
31
- const expectedSlug = `create_${tableName}_table`;
32
- return Boolean(registry?.migrations.some((entry) => {
33
- try {
34
- const slug = getRegistryMigrationSlug(entry.name);
35
- if (slug === expectedSlug) {
36
- return true;
37
- }
38
- if (inferMigrationTemplateKind(slug) !== "create_table") {
39
- return false;
40
- }
41
- return inferMigrationTableName(slug, "create_table") === tableName;
42
- } catch {
43
- return false;
44
- }
45
- }));
46
- }
47
- async function nextMigrationTemplate(name, migrationsDir, options = {}) {
48
- let offsetSeconds = 0;
49
- while (true) {
50
- const candidate = generateMigrationTemplate(name, {
51
- date: new Date(Date.now() + offsetSeconds * 1e3),
52
- ...options
53
- });
54
- if (!await fileExists(join(migrationsDir, candidate.fileName))) {
55
- return candidate;
56
- }
57
- offsetSeconds += 1;
58
- }
59
- }
60
-
61
- export {
62
- getRegistryMigrationSlug,
63
- hasRegisteredMigrationSlug,
64
- hasRegisteredCreateTableMigration,
65
- nextMigrationTemplate
66
- };
@@ -1,342 +0,0 @@
1
- import {
2
- prepareProjectDiscovery
3
- } from "./chunk-S7P7EBM3.mjs";
4
- import {
5
- syncManagedDriverDependencies
6
- } from "./chunk-HE6FYNVN.mjs";
7
- import {
8
- ensureProjectConfig
9
- } from "./chunk-GSQ3HTRO.mjs";
10
- import {
11
- readTextFile
12
- } from "./chunk-G5ADO27Q.mjs";
13
-
14
- // src/dev.ts
15
- import { spawnSync, spawn } from "child_process";
16
- import { watch } from "fs";
17
- import { readdir, stat } from "fs/promises";
18
- import { dirname, join, relative, resolve } from "path";
19
- async function fileExists(path) {
20
- try {
21
- await stat(path);
22
- return true;
23
- } catch {
24
- return false;
25
- }
26
- }
27
- async function resolveProjectPackageManager(projectRoot) {
28
- const packageJsonPath = join(projectRoot, "package.json");
29
- const packageJson = await readTextFile(packageJsonPath);
30
- if (packageJson) {
31
- try {
32
- const parsed = JSON.parse(packageJson);
33
- const packageManager = typeof parsed.packageManager === "string" ? parsed.packageManager.split("@")[0] : void 0;
34
- if (packageManager === "bun" || packageManager === "npm" || packageManager === "pnpm" || packageManager === "yarn") {
35
- return packageManager;
36
- }
37
- } catch {
38
- }
39
- }
40
- if (await fileExists(join(projectRoot, "bun.lock"))) {
41
- return "bun";
42
- }
43
- if (await fileExists(join(projectRoot, "pnpm-lock.yaml"))) {
44
- return "pnpm";
45
- }
46
- if (await fileExists(join(projectRoot, "yarn.lock"))) {
47
- return "yarn";
48
- }
49
- if (await fileExists(join(projectRoot, "package-lock.json"))) {
50
- return "npm";
51
- }
52
- return "bun";
53
- }
54
- async function resolvePackageManagerCommand(projectRoot, scriptName) {
55
- const packageManager = await resolveProjectPackageManager(projectRoot);
56
- return {
57
- command: packageManager,
58
- args: ["run", scriptName]
59
- };
60
- }
61
- async function resolvePackageManagerInstallInvocation(projectRoot) {
62
- const packageManager = await resolveProjectPackageManager(projectRoot);
63
- return {
64
- command: packageManager,
65
- args: ["install"]
66
- };
67
- }
68
- async function runProjectLifecycleScript(io, projectRoot, scriptName, spawn2 = spawnSync) {
69
- const invocation = await resolvePackageManagerCommand(projectRoot, scriptName);
70
- const result = spawn2(invocation.command, [...invocation.args], {
71
- cwd: projectRoot,
72
- encoding: "utf8",
73
- env: process.env
74
- });
75
- if (result.stdout) {
76
- io.stdout.write(result.stdout);
77
- }
78
- if (result.stderr) {
79
- io.stderr.write(result.stderr);
80
- }
81
- if (result.status !== 0) {
82
- throw new Error(result.stderr?.trim() || result.stdout?.trim() || `Project script "${scriptName}" failed.`);
83
- }
84
- }
85
- async function runProjectDependencyInstall(io, projectRoot, spawn2 = spawnSync) {
86
- const invocation = await resolvePackageManagerInstallInvocation(projectRoot);
87
- const result = spawn2(invocation.command, [...invocation.args], {
88
- cwd: projectRoot,
89
- encoding: "utf8",
90
- env: process.env
91
- });
92
- if (result.stdout) {
93
- io.stdout.write(result.stdout);
94
- }
95
- if (result.stderr) {
96
- io.stderr.write(result.stderr);
97
- }
98
- if (result.status !== 0) {
99
- throw new Error(result.stderr?.trim() || result.stdout?.trim() || "Project dependency installation failed.");
100
- }
101
- }
102
- async function runProjectPrepare(projectRoot, io) {
103
- const project = await ensureProjectConfig(projectRoot);
104
- await prepareProjectDiscovery(projectRoot, project.config);
105
- const updatedDependencies = await syncManagedDriverDependencies(projectRoot);
106
- if (updatedDependencies && io) {
107
- await runProjectDependencyInstall(io, projectRoot);
108
- await prepareProjectDiscovery(projectRoot, project.config);
109
- }
110
- }
111
- function toPosixSlashes(value) {
112
- return value.replaceAll("\\", "/");
113
- }
114
- function isDiscoveryRelevantPath(filePath, project) {
115
- const normalized = toPosixSlashes(filePath);
116
- const authorizationPoliciesPath = project.config.paths.authorizationPolicies || "server/policies";
117
- const authorizationAbilitiesPath = project.config.paths.authorizationAbilities || "server/abilities";
118
- const roots = [
119
- project.config.paths.models,
120
- project.config.paths.migrations,
121
- project.config.paths.seeders,
122
- project.config.paths.commands,
123
- project.config.paths.jobs,
124
- project.config.paths.events,
125
- project.config.paths.listeners,
126
- authorizationPoliciesPath,
127
- authorizationAbilitiesPath,
128
- "server/broadcast",
129
- "server/channels",
130
- project.config.paths.generatedSchema,
131
- "config",
132
- ".holo-js/generated"
133
- ];
134
- if (normalized === ".env" || normalized.startsWith(".env.")) {
135
- return true;
136
- }
137
- return roots.some((root) => normalized === root || normalized.startsWith(`${toPosixSlashes(root)}/`));
138
- }
139
- function isRecursiveWatchUnsupported(error) {
140
- return error instanceof Error && (error.message.includes("recursive") || "code" in error && error.code === "ERR_FEATURE_UNAVAILABLE_ON_PLATFORM");
141
- }
142
- function isIgnorableWatchError(error) {
143
- return error instanceof Error && "code" in error && (error.code === "ENOENT" || error.code === "EPERM");
144
- }
145
- async function collectDirectoryTree(rootPath, directories) {
146
- const rootStats = await stat(rootPath).catch(() => void 0);
147
- if (!rootStats?.isDirectory()) {
148
- return;
149
- }
150
- directories.add(rootPath);
151
- const entries = await readdir(rootPath, { withFileTypes: true }).catch(() => []);
152
- for (const entry of entries) {
153
- if (!entry.isDirectory()) {
154
- continue;
155
- }
156
- await collectDirectoryTree(join(rootPath, entry.name), directories);
157
- }
158
- }
159
- async function collectDiscoveryWatchRoots(projectRoot, project) {
160
- const directories = /* @__PURE__ */ new Set();
161
- const authorizationPoliciesPath = project.config.paths.authorizationPolicies || "server/policies";
162
- const authorizationAbilitiesPath = project.config.paths.authorizationAbilities || "server/abilities";
163
- const roots = [
164
- projectRoot,
165
- resolve(projectRoot, "config"),
166
- resolve(projectRoot, ".holo-js/generated"),
167
- resolve(projectRoot, project.config.paths.models),
168
- resolve(projectRoot, project.config.paths.migrations),
169
- resolve(projectRoot, project.config.paths.seeders),
170
- resolve(projectRoot, project.config.paths.commands),
171
- resolve(projectRoot, project.config.paths.jobs),
172
- resolve(projectRoot, project.config.paths.events),
173
- resolve(projectRoot, project.config.paths.listeners),
174
- resolve(projectRoot, authorizationPoliciesPath),
175
- resolve(projectRoot, authorizationAbilitiesPath),
176
- resolve(projectRoot, "server/broadcast"),
177
- resolve(projectRoot, "server/channels"),
178
- dirname(resolve(projectRoot, project.config.paths.generatedSchema))
179
- ];
180
- for (const rootPath of roots) {
181
- await collectDirectoryTree(rootPath, directories);
182
- }
183
- return [...directories];
184
- }
185
- function normalizeWatchedFilePath(projectRoot, watchedRoot, fileName) {
186
- return toPosixSlashes(relative(projectRoot, resolve(watchedRoot, fileName)));
187
- }
188
- async function runProjectDevServer(io, projectRoot, spawnProcess = spawn, createWatcher = watch, prepare = runProjectPrepare) {
189
- let project = await ensureProjectConfig(projectRoot);
190
- let refreshNonRecursiveWatchers;
191
- let requestChildRestart;
192
- const prepareDiscovery = async () => {
193
- await prepare(projectRoot, io);
194
- project = await ensureProjectConfig(projectRoot);
195
- await refreshNonRecursiveWatchers?.();
196
- };
197
- await prepareDiscovery();
198
- let pendingPrepare;
199
- let queued = false;
200
- let shuttingDown = false;
201
- const rerunPrepare = () => {
202
- if (shuttingDown) {
203
- return;
204
- }
205
- if (pendingPrepare) {
206
- queued = true;
207
- return;
208
- }
209
- pendingPrepare = prepareDiscovery().then(() => {
210
- requestChildRestart?.();
211
- }).catch((error) => {
212
- io.stderr.write(`${error instanceof Error ? error.message : String(error)}
213
- `);
214
- }).finally(() => {
215
- pendingPrepare = void 0;
216
- if (queued) {
217
- queued = false;
218
- rerunPrepare();
219
- }
220
- });
221
- };
222
- const closeWatchers = (() => {
223
- try {
224
- const watcher = createWatcher(projectRoot, { recursive: true }, (_eventType, fileName) => {
225
- if (shuttingDown || typeof fileName !== "string" || !isDiscoveryRelevantPath(fileName, project)) {
226
- return;
227
- }
228
- rerunPrepare();
229
- });
230
- return () => watcher.close();
231
- } catch (error) {
232
- if (!isRecursiveWatchUnsupported(error)) {
233
- throw error;
234
- }
235
- const watchers = [];
236
- const closeAllWatchers = () => {
237
- while (watchers.length > 0) {
238
- watchers.pop()?.close();
239
- }
240
- };
241
- refreshNonRecursiveWatchers = async () => {
242
- closeAllWatchers();
243
- const watchRoots = await collectDiscoveryWatchRoots(projectRoot, project);
244
- for (const watchRoot of watchRoots) {
245
- try {
246
- watchers.push(createWatcher(watchRoot, { recursive: false }, (_eventType, fileName) => {
247
- if (shuttingDown || typeof fileName !== "string") {
248
- return;
249
- }
250
- const normalizedPath = normalizeWatchedFilePath(projectRoot, watchRoot, fileName);
251
- if (!isDiscoveryRelevantPath(normalizedPath, project)) {
252
- return;
253
- }
254
- rerunPrepare();
255
- }));
256
- } catch (watchError) {
257
- if (!isIgnorableWatchError(watchError)) {
258
- throw watchError;
259
- }
260
- }
261
- }
262
- };
263
- return () => closeAllWatchers();
264
- }
265
- })();
266
- await refreshNonRecursiveWatchers?.();
267
- const invocation = await resolvePackageManagerCommand(projectRoot, "holo:dev");
268
- while (!shuttingDown) {
269
- const child = spawnProcess(invocation.command, [...invocation.args], {
270
- cwd: projectRoot,
271
- env: process.env,
272
- stdio: ["pipe", "pipe", "pipe"]
273
- });
274
- child.stdout?.on("data", (chunk) => io.stdout.write(chunk));
275
- child.stderr?.on("data", (chunk) => io.stderr.write(chunk));
276
- if (child.stdin) {
277
- io.stdin.pipe(child.stdin);
278
- }
279
- const result = await new Promise((resolvePromise) => {
280
- let restartRequested = false;
281
- requestChildRestart = () => {
282
- if (restartRequested || shuttingDown || typeof child.kill !== "function") {
283
- return;
284
- }
285
- restartRequested = true;
286
- child.kill("SIGTERM");
287
- };
288
- child.on("error", (error) => {
289
- if (child.stdin) {
290
- io.stdin.unpipe(child.stdin);
291
- }
292
- requestChildRestart = void 0;
293
- if (restartRequested) {
294
- resolvePromise({ kind: "restart" });
295
- return;
296
- }
297
- resolvePromise({ kind: "error", error });
298
- });
299
- child.on("close", (code) => {
300
- if (child.stdin) {
301
- io.stdin.unpipe(child.stdin);
302
- }
303
- requestChildRestart = void 0;
304
- if (restartRequested) {
305
- resolvePromise({ kind: "restart" });
306
- return;
307
- }
308
- resolvePromise({ kind: "close", code });
309
- });
310
- });
311
- if (result.kind === "restart") {
312
- continue;
313
- }
314
- shuttingDown = true;
315
- closeWatchers();
316
- await Promise.resolve(pendingPrepare);
317
- if (result.kind === "error") {
318
- throw result.error;
319
- }
320
- if (result.code === 0) {
321
- return;
322
- }
323
- throw new Error(`Project script "holo:dev" failed with exit code ${result.code ?? "unknown"}.`);
324
- }
325
- }
326
-
327
- export {
328
- resolveProjectPackageManager,
329
- resolvePackageManagerCommand,
330
- resolvePackageManagerInstallInvocation,
331
- runProjectLifecycleScript,
332
- runProjectDependencyInstall,
333
- runProjectPrepare,
334
- toPosixSlashes,
335
- isDiscoveryRelevantPath,
336
- isRecursiveWatchUnsupported,
337
- isIgnorableWatchError,
338
- collectDirectoryTree,
339
- collectDiscoveryWatchRoots,
340
- normalizeWatchedFilePath,
341
- runProjectDevServer
342
- };
@@ -1,26 +0,0 @@
1
- #!/usr/bin/env node
2
- import {
3
- readTextFile
4
- } from "./chunk-66FHW725.mjs";
5
-
6
- // src/fs-utils.ts
7
- import { stat } from "fs/promises";
8
- async function fileExists(path) {
9
- try {
10
- await stat(path);
11
- return true;
12
- } catch {
13
- return false;
14
- }
15
- }
16
- async function ensureAbsent(path) {
17
- const existing = await readTextFile(path);
18
- if (typeof existing !== "undefined") {
19
- throw new TypeError(`Refusing to overwrite existing file: ${path}`);
20
- }
21
- }
22
-
23
- export {
24
- fileExists,
25
- ensureAbsent
26
- };