@lunora/cli 1.0.0-alpha.8 → 1.0.0-alpha.80

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 (59) hide show
  1. package/LICENSE.md +6 -0
  2. package/__assets__/package-og.svg +1 -1
  3. package/dist/bin.mjs +1 -1
  4. package/dist/index.d.mts +290 -117
  5. package/dist/index.d.ts +290 -117
  6. package/dist/index.mjs +8 -8
  7. package/dist/packem_chunks/handler.mjs +87 -6
  8. package/dist/packem_chunks/handler10.mjs +8 -14
  9. package/dist/packem_chunks/handler11.mjs +19 -189
  10. package/dist/packem_chunks/handler12.mjs +176 -115
  11. package/dist/packem_chunks/handler13.mjs +118 -52
  12. package/dist/packem_chunks/handler14.mjs +50 -43
  13. package/dist/packem_chunks/handler15.mjs +48 -67
  14. package/dist/packem_chunks/handler16.mjs +85 -37
  15. package/dist/packem_chunks/handler17.mjs +39 -100
  16. package/dist/packem_chunks/handler18.mjs +87 -152
  17. package/dist/packem_chunks/handler19.mjs +148 -67
  18. package/dist/packem_chunks/handler2.mjs +6 -4
  19. package/dist/packem_chunks/handler20.mjs +77 -75
  20. package/dist/packem_chunks/handler21.mjs +71 -288
  21. package/dist/packem_chunks/handler3.mjs +6 -3
  22. package/dist/packem_chunks/handler4.mjs +2 -2
  23. package/dist/packem_chunks/handler5.mjs +7 -4
  24. package/dist/packem_chunks/handler6.mjs +10 -7
  25. package/dist/packem_chunks/handler7.mjs +2 -2
  26. package/dist/packem_chunks/handler8.mjs +1 -1
  27. package/dist/packem_chunks/handler9.mjs +315 -12
  28. package/dist/packem_chunks/planDevCommand.mjs +758 -81
  29. package/dist/packem_chunks/runCodegenCommand.mjs +5 -4
  30. package/dist/packem_chunks/runDeployCommand.mjs +126 -20
  31. package/dist/packem_chunks/runInitCommand.mjs +1661 -179
  32. package/dist/packem_chunks/runMigrateGenerateCommand.mjs +5 -4
  33. package/dist/packem_chunks/runResetCommand.mjs +2 -2
  34. package/dist/packem_chunks/runRpcCommand.mjs +3 -2
  35. package/dist/packem_shared/{COMMANDS-Bn8luojF.mjs → COMMANDS-DW8lQmuW.mjs} +85 -23
  36. package/dist/packem_shared/{DEFAULT_IMPORT_BATCH_SIZE-Ck-2bU08.mjs → DEFAULT_IMPORT_BATCH_SIZE-CRQmmBZM.mjs} +3 -2
  37. package/dist/packem_shared/{api-spec-CtA6ilu4.mjs → api-spec-Bx0iKbxA.mjs} +3 -1
  38. package/dist/packem_shared/{buildRegistryIndex-BcYe607_.mjs → buildRegistryIndex-BS5ig822.mjs} +1 -1
  39. package/dist/packem_shared/codegen-error-DJG-ghs_.mjs +31 -0
  40. package/dist/packem_shared/{command-BDXcJCCJ.mjs → command-lYnl4QyF.mjs} +6 -1
  41. package/dist/packem_shared/{commands-DqsEzojt.mjs → commands-ClEvcz3V.mjs} +224 -18
  42. package/dist/packem_shared/{createLogger-CHPNjFw2.mjs → createLogger-CIWSHrTL.mjs} +40 -8
  43. package/dist/packem_shared/{createRecordingSpawner-DxI3mebw.mjs → createRecordingSpawner-Cw5Iu73G.mjs} +12 -2
  44. package/dist/packem_shared/{detect-package-manager-DYp7n3mJ.mjs → detect-package-manager-DvEthdCw.mjs} +26 -30
  45. package/dist/packem_shared/{insertSchemaExtension-BuzF6-t2.mjs → insertSchemaExtension-DAqbfr9Z.mjs} +15 -10
  46. package/dist/packem_shared/{open-url-Dfq6fAyT.mjs → open-url-4PBLY9X0.mjs} +3 -2
  47. package/dist/packem_shared/{output-format-7gyGR3h8.mjs → output-format-B4642rjE.mjs} +1 -1
  48. package/dist/packem_shared/{parseManifest--vZf2FY1.mjs → parseManifest-Dbp-Q2q3.mjs} +36 -9
  49. package/dist/packem_shared/prompt-cancelled-APzX1Im-.mjs +9 -0
  50. package/dist/packem_shared/runAddCommand-DGjFXGqa.mjs +4 -0
  51. package/dist/packem_shared/storage-DEXpJkXh.mjs +84 -0
  52. package/dist/packem_shared/tui-prompts-BjEN8XgP.mjs +658 -0
  53. package/dist/packem_shared/wrangler-secrets-Dq_Fkbm-.mjs +49 -0
  54. package/package.json +16 -13
  55. package/skills/lunora-quickstart/SKILL.md +25 -5
  56. package/skills/lunora-setup-storage/SKILL.md +7 -3
  57. package/dist/packem_shared/features-ocSSpZtS.mjs +0 -24
  58. package/dist/packem_shared/runAddCommand-G544_v6e.mjs +0 -4
  59. package/dist/packem_shared/tui-prompts-XHFxlOg5.mjs +0 -269
@@ -1,17 +1,21 @@
1
+ import { LunoraError } from '@lunora/errors';
2
+
1
3
  const NEWLINE_PRESENT = /[\r\n]/u;
2
4
  const VALID_ENV_NAME = /^[A-Za-z_]\w*$/u;
3
5
  const VALID_ITEM_NAME = /^[A-Za-z0-9][\w-]*$/u;
6
+ const VALID_MODULE_PATH = /^[\w.-]+(?:\/[\w.-]+)*$/u;
4
7
  const parseManifest = (raw, itemName) => {
5
8
  if (typeof raw !== "object" || raw === null) {
6
- throw new Error(`registry.json for "${itemName}" is not an object`);
9
+ throw new LunoraError("INTERNAL", `registry.json for "${itemName}" is not an object`);
7
10
  }
8
11
  const record = raw;
9
12
  const { name } = record;
10
13
  if (typeof name !== "string" || name.length === 0) {
11
- throw new Error(`registry.json for "${itemName}" is missing a string "name"`);
14
+ throw new LunoraError("INTERNAL", `registry.json for "${itemName}" is missing a string "name"`);
12
15
  }
13
16
  if (!VALID_ITEM_NAME.test(name)) {
14
- throw new Error(
17
+ throw new LunoraError(
18
+ "INTERNAL",
15
19
  `registry.json for "${itemName}": name "${name}" must match ${VALID_ITEM_NAME.source} (letters, digits, "-", "_"; no path separators, "..", or code)`
16
20
  );
17
21
  }
@@ -21,7 +25,7 @@ const parseManifest = (raw, itemName) => {
21
25
  }
22
26
  const files = filesRaw.map((entry, index) => {
23
27
  if (typeof entry !== "object" || entry === null) {
24
- throw new Error(`registry.json "${itemName}": files[${String(index)}] is not an object`);
28
+ throw new LunoraError("INTERNAL", `registry.json "${itemName}": files[${String(index)}] is not an object`);
25
29
  }
26
30
  const fileRecord = entry;
27
31
  const { from } = fileRecord;
@@ -31,14 +35,17 @@ const parseManifest = (raw, itemName) => {
31
35
  throw new TypeError(`registry.json "${itemName}": files[${String(index)}] needs string "from" and "to"`);
32
36
  }
33
37
  if (merge !== "create-or-skip" && merge !== "schema-extension") {
34
- throw new Error(`registry.json "${itemName}": files[${String(index)}].merge must be "create-or-skip" or "schema-extension"`);
38
+ throw new LunoraError("INTERNAL", `registry.json "${itemName}": files[${String(index)}].merge must be "create-or-skip" or "schema-extension"`);
35
39
  }
36
40
  for (const [field, value] of [
37
41
  ["from", from],
38
42
  ["to", to]
39
43
  ]) {
40
44
  if (value.includes("..") || value.startsWith("/")) {
41
- throw new Error(`registry.json "${itemName}": files[${String(index)}].${field} "${value}" must be a relative path without ".."`);
45
+ throw new LunoraError(
46
+ "INTERNAL",
47
+ `registry.json "${itemName}": files[${String(index)}].${field} "${value}" must be a relative path without ".."`
48
+ );
42
49
  }
43
50
  }
44
51
  return { from, merge, to };
@@ -54,20 +61,39 @@ const parseManifest = (raw, itemName) => {
54
61
  const bindingRecord = value;
55
62
  return Array.isArray(bindingRecord.path) && bindingRecord.path.every((segment) => typeof segment === "string");
56
63
  }) : void 0;
64
+ const entrypointReexports = Array.isArray(record.entrypointReexports) ? record.entrypointReexports.filter(
65
+ (value) => typeof value === "object" && value !== null && typeof value.module === "string"
66
+ ).map((entry) => {
67
+ if (entry.module.includes("..") || entry.module.startsWith("/") || !VALID_MODULE_PATH.test(entry.module)) {
68
+ throw new LunoraError(
69
+ "INTERNAL",
70
+ `registry.json "${itemName}": entrypointReexports[].module "${entry.module}" must be a safe relative module path without path traversal or unsafe characters`
71
+ );
72
+ }
73
+ const reexport = { module: entry.module };
74
+ if (typeof entry.comment === "string") {
75
+ if (NEWLINE_PRESENT.test(entry.comment)) {
76
+ throw new LunoraError("INTERNAL", `registry.json "${itemName}": entrypointReexports[].comment must not contain a newline`);
77
+ }
78
+ reexport.comment = entry.comment;
79
+ }
80
+ return reexport;
81
+ }) : void 0;
57
82
  const envVariables = Array.isArray(record.envVars) ? record.envVars.filter(
58
83
  (value) => typeof value === "object" && value !== null && typeof value.name === "string"
59
84
  ).map((entry) => {
60
85
  const hasValue = typeof entry.value === "string";
61
86
  if (!VALID_ENV_NAME.test(entry.name)) {
62
- throw new Error(
87
+ throw new LunoraError(
88
+ "INTERNAL",
63
89
  `registry.json "${itemName}": envVars["${entry.name}"].name must match ${VALID_ENV_NAME.source} (letters, digits, underscore; no "=" or newline)`
64
90
  );
65
91
  }
66
92
  if (hasValue && NEWLINE_PRESENT.test(entry.value)) {
67
- throw new Error(`registry.json "${itemName}": envVars["${entry.name}"].value must not contain a newline`);
93
+ throw new LunoraError("INTERNAL", `registry.json "${itemName}": envVars["${entry.name}"].value must not contain a newline`);
68
94
  }
69
95
  if (typeof entry.description === "string" && NEWLINE_PRESENT.test(entry.description)) {
70
- throw new Error(`registry.json "${itemName}": envVars["${entry.name}"].description must not contain a newline`);
96
+ throw new LunoraError("INTERNAL", `registry.json "${itemName}": envVars["${entry.name}"].description must not contain a newline`);
71
97
  }
72
98
  return {
73
99
  ...typeof entry.description === "string" ? { description: entry.description } : {},
@@ -83,6 +109,7 @@ const parseManifest = (raw, itemName) => {
83
109
  description: typeof record.description === "string" ? record.description : void 0,
84
110
  devDependencies,
85
111
  docs: typeof record.docs === "string" ? record.docs : void 0,
112
+ entrypointReexports,
86
113
  envVars: envVariables,
87
114
  files,
88
115
  name,
@@ -0,0 +1,9 @@
1
+ class PromptCancelledError extends Error {
2
+ constructor() {
3
+ super("cancelled");
4
+ this.name = "PromptCancelledError";
5
+ }
6
+ }
7
+ const PROMPT_CANCEL_EXIT_CODE = 130;
8
+
9
+ export { PromptCancelledError as P, PROMPT_CANCEL_EXIT_CODE as a };
@@ -0,0 +1,4 @@
1
+ import 'node:fs';
2
+ import '@visulima/path';
3
+ export { r as runAddCommand, a as runBuildIndexCommand, g as runListCommand, b as runRegistryViewCommand } from './commands-ClEvcz3V.mjs';
4
+ import './buildRegistryIndex-BS5ig822.mjs';
@@ -0,0 +1,84 @@
1
+ import { s as setBindingField } from './commands-ClEvcz3V.mjs';
2
+
3
+ const INVALID_SLUG_CHARS = /[^a-z0-9]+/u;
4
+ const toKebabSlug = (input, min, max) => {
5
+ let slug = input.toLowerCase().split(INVALID_SLUG_CHARS).filter(Boolean).join("-").slice(0, max);
6
+ if (slug.endsWith("-")) {
7
+ slug = slug.slice(0, -1);
8
+ }
9
+ return slug.length >= min ? slug : void 0;
10
+ };
11
+
12
+ const DB_BINDING = "DB";
13
+ const AUTH_DB_PROMPT = "Name your D1 database (run `wrangler d1 create` to get its id, then put it in wrangler.jsonc)";
14
+ const sanitizeDatabaseName = (input) => toKebabSlug(input, 1, 64);
15
+ const FALLBACK_DATABASE_NAME = "lunora-db";
16
+ const deriveDatabaseName = (projectName) => sanitizeDatabaseName(`${projectName}-db`) ?? FALLBACK_DATABASE_NAME;
17
+ const promptDatabaseName = async (text, projectName) => {
18
+ const fallback = deriveDatabaseName(projectName);
19
+ return sanitizeDatabaseName(await text(AUTH_DB_PROMPT, { default: fallback, placeholder: fallback })) ?? fallback;
20
+ };
21
+ const withAuthDatabaseName = (manifest, name) => setBindingField(manifest, "d1_databases", { key: "binding", value: DB_BINDING }, "database_name", name);
22
+
23
+ const AUTH_PROVIDER_OPTIONS = [
24
+ { description: "Email + password on better-auth (default)", label: "Email & password", value: "auth" },
25
+ { description: "Clerk-hosted auth", label: "Clerk", value: "auth-clerk" },
26
+ { description: "Auth0 (OIDC)", label: "Auth0", value: "auth-auth0" }
27
+ ];
28
+ const DEFAULT_AUTH_ITEM = "auth";
29
+ const promptAuthProvider = async (select) => await select("Which auth provider?", AUTH_PROVIDER_OPTIONS, { default: DEFAULT_AUTH_ITEM }) ?? DEFAULT_AUTH_ITEM;
30
+ const EMAIL_ITEM = "mail";
31
+ const normalizeFeature = (raw) => {
32
+ const value = raw.trim();
33
+ if (value === "") {
34
+ return void 0;
35
+ }
36
+ const lower = value.toLowerCase();
37
+ if (lower === "auth") {
38
+ return { kind: "auth" };
39
+ }
40
+ if (lower === "email" || lower === "mail") {
41
+ return { kind: "email" };
42
+ }
43
+ return { item: lower, kind: "item" };
44
+ };
45
+
46
+ const SEND_EMAIL_BINDING = "SEND_EMAIL";
47
+ const MAIL_DESTINATION_PROMPT = "Verified destination email for production delivery (blank = set it later in wrangler.jsonc)";
48
+ const isValidEmail = (value) => {
49
+ const trimmed = value.trim();
50
+ if (trimmed.length === 0 || trimmed.includes(" ")) {
51
+ return false;
52
+ }
53
+ const at = trimmed.indexOf("@");
54
+ if (at <= 0 || at !== trimmed.lastIndexOf("@")) {
55
+ return false;
56
+ }
57
+ const domain = trimmed.slice(at + 1);
58
+ return domain.length >= 3 && domain.includes(".") && !domain.startsWith(".") && !domain.endsWith(".");
59
+ };
60
+ const resolveTypedDestination = (entered, warn) => {
61
+ const trimmed = entered.trim();
62
+ if (trimmed === "") {
63
+ return void 0;
64
+ }
65
+ if (!isValidEmail(trimmed)) {
66
+ warn(`"${trimmed}" doesn't look like an email — leaving the placeholder; set destination_address in wrangler.jsonc.`);
67
+ return void 0;
68
+ }
69
+ return trimmed;
70
+ };
71
+ const withMailDestination = (manifest, address) => setBindingField(manifest, "send_email", { key: "name", value: SEND_EMAIL_BINDING }, "destination_address", address);
72
+
73
+ const UPLOADS_BINDING = "UPLOADS";
74
+ const STORAGE_BUCKET_PROMPT = "Name your R2 bucket (you can rename it in wrangler.jsonc later)";
75
+ const sanitizeBucketName = (input) => toKebabSlug(input, 3, 63);
76
+ const FALLBACK_BUCKET_NAME = "lunora-uploads";
77
+ const deriveBucketName = (projectName) => sanitizeBucketName(`${projectName}-uploads`) ?? FALLBACK_BUCKET_NAME;
78
+ const promptBucketName = async (text, projectName) => {
79
+ const fallback = deriveBucketName(projectName);
80
+ return sanitizeBucketName(await text(STORAGE_BUCKET_PROMPT, { default: fallback, placeholder: fallback })) ?? fallback;
81
+ };
82
+ const withStorageBucketName = (manifest, bucketName) => setBindingField(manifest, "r2_buckets", { key: "binding", value: UPLOADS_BINDING }, "bucket_name", bucketName);
83
+
84
+ export { AUTH_PROVIDER_OPTIONS as A, DEFAULT_AUTH_ITEM as D, EMAIL_ITEM as E, MAIL_DESTINATION_PROMPT as M, sanitizeDatabaseName as a, deriveDatabaseName as b, promptDatabaseName as c, deriveBucketName as d, promptAuthProvider as e, withMailDestination as f, withAuthDatabaseName as g, normalizeFeature as n, promptBucketName as p, resolveTypedDestination as r, sanitizeBucketName as s, withStorageBucketName as w };