@lunora/cli 1.0.0-alpha.11 → 1.0.0-alpha.13

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.
package/dist/index.mjs CHANGED
@@ -8,7 +8,7 @@ export { runMigrateGenerateCommand } from './packem_chunks/runMigrateGenerateCom
8
8
  export { runResetCommand } from './packem_chunks/runResetCommand.mjs';
9
9
  export { runRpcCommand } from './packem_chunks/runRpcCommand.mjs';
10
10
  export { default as parseArgs } from './packem_shared/parseArgs-YXFuKdEk.mjs';
11
- export { insertSchemaExtension } from './packem_shared/insertSchemaExtension-BuzF6-t2.mjs';
11
+ export { insertSchemaExtension } from './packem_shared/insertSchemaExtension-DAqbfr9Z.mjs';
12
12
  export { createLogger, pail } from './packem_shared/createLogger-B40gPzQo.mjs';
13
13
  export { diffSnapshots, renderAddColumn, renderCreateIndex, renderCreateTable, renderDropIndex, renderDropTable, renderMigrationFile, validatorKindToSqlType } from './packem_shared/diffSnapshots-BeDvvNiF.mjs';
14
14
  export { default as schemaIrToSnapshot } from './packem_shared/schemaIrToSnapshot-DdsljJT-.mjs';
@@ -16,4 +16,4 @@ export { createRecordingSpawner, defaultSpawner } from './packem_shared/createRe
16
16
  export { default as parseManifest } from './packem_shared/parseManifest--vZf2FY1.mjs';
17
17
  export { REQUIRED_COMPATIBILITY_DATE, REQUIRED_FLAG, validateWranglerProject as validateWrangler, validateWranglerConfig } from '@lunora/config';
18
18
  export { buildRegistryIndex } from './packem_shared/buildRegistryIndex-BcYe607_.mjs';
19
- export { r as runAddCommand, a as runBuildIndexCommand, b as runRegistryViewCommand } from './packem_shared/commands-zs-0Es9F.mjs';
19
+ export { r as runAddCommand, a as runBuildIndexCommand, b as runRegistryViewCommand } from './packem_shared/commands-DGo2VAsr.mjs';
@@ -2,9 +2,9 @@ import { existsSync } from 'node:fs';
2
2
  import { findWranglerFile } from '@lunora/config';
3
3
  import { join, basename } from '@visulima/path';
4
4
  import { d as defineHandler } from '../packem_shared/command-BC30oSBW.mjs';
5
- import { t as tuiText, a as tuiSelect } from '../packem_shared/tui-prompts-Dvlh5xWt.mjs';
6
- import { n as normalizeFeature, E as EMAIL_ITEM, s as sanitizeBucketName, d as deriveBucketName, p as promptBucketName, r as resolveTypedDestination, M as MAIL_DESTINATION_PROMPT, a as sanitizeDatabaseName, b as deriveDatabaseName, c as promptDatabaseName, D as DEFAULT_AUTH_ITEM, e as promptAuthProvider, A as AUTH_PROVIDER_OPTIONS, w as withStorageBucketName, f as withMailDestination, g as withAuthDatabaseName } from '../packem_shared/storage-7faZve2Z.mjs';
7
- import { r as runAddCommand } from '../packem_shared/commands-zs-0Es9F.mjs';
5
+ import { t as tuiText, a as tuiSelect } from '../packem_shared/tui-prompts-M6OWsuyw.mjs';
6
+ import { n as normalizeFeature, E as EMAIL_ITEM, s as sanitizeBucketName, d as deriveBucketName, p as promptBucketName, r as resolveTypedDestination, M as MAIL_DESTINATION_PROMPT, a as sanitizeDatabaseName, b as deriveDatabaseName, c as promptDatabaseName, D as DEFAULT_AUTH_ITEM, e as promptAuthProvider, A as AUTH_PROVIDER_OPTIONS, w as withStorageBucketName, f as withMailDestination, g as withAuthDatabaseName } from '../packem_shared/storage-CaFkHfqA.mjs';
7
+ import { r as runAddCommand } from '../packem_shared/commands-DGo2VAsr.mjs';
8
8
 
9
9
  const providerToItem = (provider) => {
10
10
  const value = provider.trim().toLowerCase();
@@ -1,5 +1,5 @@
1
1
  import { d as defineHandler } from '../packem_shared/command-BC30oSBW.mjs';
2
- import { r as runAddCommand, b as runRegistryViewCommand, a as runBuildIndexCommand } from '../packem_shared/commands-zs-0Es9F.mjs';
2
+ import { r as runAddCommand, b as runRegistryViewCommand, a as runBuildIndexCommand } from '../packem_shared/commands-DGo2VAsr.mjs';
3
3
 
4
4
  const execute = defineHandler(({ argument, cwd, logger, options }) => {
5
5
  const subcommand = argument[0];
@@ -7,7 +7,7 @@ import { join } from '@visulima/path';
7
7
  import { Project } from 'ts-morph';
8
8
  import { d as defineHandler } from '../packem_shared/command-BC30oSBW.mjs';
9
9
  import { a as resolveProductionWorkerUrl } from '../packem_shared/resolve-target-qbsJ_5sF.mjs';
10
- import { b as tuiConfirm } from '../packem_shared/tui-prompts-Dvlh5xWt.mjs';
10
+ import { b as tuiConfirm } from '../packem_shared/tui-prompts-M6OWsuyw.mjs';
11
11
  import { runImportCommand } from '../packem_shared/DEFAULT_IMPORT_BATCH_SIZE-Ck-2bU08.mjs';
12
12
  import { runResetCommand } from './runResetCommand.mjs';
13
13
 
@@ -9,7 +9,7 @@ import { d as detectPackageManager, e as execArgsFor } from '../packem_shared/de
9
9
  import { createServer, request } from 'node:http';
10
10
  import { connect } from 'node:net';
11
11
  import { loadStudioAssets, studioAssetsStamp, renderStudioHtml, resolveAdminToken, SCHEMA_EDIT_ENDPOINT, POLICY_SCAFFOLD_ENDPOINT, SEED_ENDPOINT, serveJsonHandler, handleSchemaEditRequest, handlePolicyScaffoldRequest, handleSeedRequest } from '@lunora/config/studio-host';
12
- import { c as createTuiConfirm } from '../packem_shared/tui-prompts-Dvlh5xWt.mjs';
12
+ import { c as createTuiConfirm } from '../packem_shared/tui-prompts-M6OWsuyw.mjs';
13
13
 
14
14
  const DEFAULT_DEBOUNCE_MS = 100;
15
15
  const PATH_SEGMENT_SEPARATOR = /[/\\]/u;
@@ -10,11 +10,11 @@ import { d as defineHandler } from '../packem_shared/command-BC30oSBW.mjs';
10
10
  import { a as detectInstalledManagers, i as installArgsFor } from '../packem_shared/detect-package-manager-DYp7n3mJ.mjs';
11
11
  import MagicString from 'magic-string';
12
12
  import { Project, SyntaxKind } from 'ts-morph';
13
- import { c as resolveSourceRef, d as resolveDistTag, r as runAddCommand } from '../packem_shared/commands-zs-0Es9F.mjs';
13
+ import { c as resolveSourceRef, d as resolveDistTag, e as resolveTagVersion, r as runAddCommand } from '../packem_shared/commands-DGo2VAsr.mjs';
14
14
  import { defaultSpawner } from '../packem_shared/createRecordingSpawner-DxI3mebw.mjs';
15
- import { d as tuiMascot, e as tuiStep, P as PromptCancelledError, f as tuiMoonrise, t as tuiText, g as tuiHeadline, h as tuiInfo, a as tuiSelect, w as withTuiSpinner, b as tuiConfirm, i as tuiNextSteps, j as tuiTasks, k as tuiMultiSelect, l as withTuiBadgeProgress } from '../packem_shared/tui-prompts-Dvlh5xWt.mjs';
15
+ import { d as tuiMascot, e as tuiStep, P as PromptCancelledError, f as tuiMoonrise, t as tuiText, g as tuiHeadline, h as tuiInfo, a as tuiSelect, w as withTuiSpinner, b as tuiConfirm, i as tuiNextSteps, j as tuiTasks, k as tuiMultiSelect, l as withTuiBadgeProgress } from '../packem_shared/tui-prompts-M6OWsuyw.mjs';
16
16
  import { logStep } from '../packem_shared/createLogger-B40gPzQo.mjs';
17
- import { E as EMAIL_ITEM, p as promptBucketName, w as withStorageBucketName, M as MAIL_DESTINATION_PROMPT, r as resolveTypedDestination, f as withMailDestination, e as promptAuthProvider, c as promptDatabaseName, g as withAuthDatabaseName } from '../packem_shared/storage-7faZve2Z.mjs';
17
+ import { E as EMAIL_ITEM, p as promptBucketName, w as withStorageBucketName, M as MAIL_DESTINATION_PROMPT, r as resolveTypedDestination, f as withMailDestination, e as promptAuthProvider, c as promptDatabaseName, g as withAuthDatabaseName } from '../packem_shared/storage-CaFkHfqA.mjs';
18
18
  import dns from 'node:dns/promises';
19
19
 
20
20
  const GITHUB_CONTENT = `name: Deploy
@@ -791,7 +791,36 @@ const isTextFile = (filePath) => {
791
791
  };
792
792
  const substitute = (content, name) => content.replaceAll("{{name}}", name);
793
793
  const isLunoraDep = (name) => name === "lunorash" || name.startsWith("@lunora/");
794
- const stampLunoraDeps = (packageJsonText, distTag) => {
794
+ const resolveLunoraVersions = async (files, distTag) => {
795
+ const names = /* @__PURE__ */ new Set();
796
+ for (const file of files) {
797
+ if (basename(file) !== "package.json") {
798
+ continue;
799
+ }
800
+ try {
801
+ const parsed = JSON.parse(readFileSync(file, "utf8"));
802
+ for (const section of ["dependencies", "devDependencies"]) {
803
+ for (const name of Object.keys(parsed[section] ?? {})) {
804
+ if (isLunoraDep(name)) {
805
+ names.add(name);
806
+ }
807
+ }
808
+ }
809
+ } catch {
810
+ }
811
+ }
812
+ const resolved = /* @__PURE__ */ new Map();
813
+ await Promise.all(
814
+ [...names].map(async (name) => {
815
+ const version = await resolveTagVersion(name, distTag);
816
+ if (version !== void 0) {
817
+ resolved.set(name, version);
818
+ }
819
+ })
820
+ );
821
+ return resolved;
822
+ };
823
+ const stampLunoraDeps = (packageJsonText, distTag, versions) => {
795
824
  let parsed;
796
825
  try {
797
826
  parsed = JSON.parse(packageJsonText);
@@ -804,7 +833,8 @@ const stampLunoraDeps = (packageJsonText, distTag) => {
804
833
  if (!isLunoraDep(name)) {
805
834
  continue;
806
835
  }
807
- const edits = modify(text, [section, name], distTag, { formattingOptions: { insertSpaces: true, tabSize: 4 } });
836
+ const pin = versions.get(name) ?? distTag;
837
+ const edits = modify(text, [section, name], pin, { formattingOptions: { insertSpaces: true, tabSize: 4 } });
808
838
  text = applyEdits(text, edits);
809
839
  }
810
840
  }
@@ -817,10 +847,11 @@ const collectFiles = (directory) => {
817
847
  }
818
848
  return out;
819
849
  };
820
- const copyTemplate = (sourceDirectory, target, name) => {
850
+ const copyTemplate = async (sourceDirectory, target, name) => {
821
851
  const files = collectFiles(sourceDirectory);
822
852
  const written = [];
823
853
  const distTag = resolveDistTag();
854
+ const versions = await resolveLunoraVersions(files, distTag);
824
855
  for (const source of files) {
825
856
  const relativePath = relative(sourceDirectory, source);
826
857
  const destination = join$1(target, relativePath);
@@ -828,7 +859,7 @@ const copyTemplate = (sourceDirectory, target, name) => {
828
859
  const raw = readFileSync(source);
829
860
  let text = isTextFile(source) ? substitute(raw.toString("utf8"), name) : void 0;
830
861
  if (text !== void 0 && basename(source) === "package.json") {
831
- text = stampLunoraDeps(text, distTag);
862
+ text = stampLunoraDeps(text, distTag, versions);
832
863
  }
833
864
  if (text === void 0) {
834
865
  writeFileSync(destination, raw);
@@ -989,13 +1020,13 @@ const maybeOfferInstall = async (options, target) => {
989
1020
  await emitStep("deps", `Dependencies installed with ${manager}.`);
990
1021
  return manager;
991
1022
  };
992
- const scaffoldFromLocal = (fromRoot, templateType, target, name, logger) => {
1023
+ const scaffoldFromLocal = async (fromRoot, templateType, target, name, logger) => {
993
1024
  const templateDirectory = join$1(fromRoot, templateType);
994
1025
  if (!existsSync(templateDirectory)) {
995
1026
  logger.error(`template not found in local source: ${templateDirectory}`);
996
1027
  return { code: 1, files: [], target };
997
1028
  }
998
- const written = copyTemplate(templateDirectory, target, name);
1029
+ const written = await copyTemplate(templateDirectory, target, name);
999
1030
  logScaffoldSuccess(logger, written, target);
1000
1031
  return { code: 0, files: written, target };
1001
1032
  };
@@ -1023,9 +1054,8 @@ const scaffoldFromRemote = async (options) => {
1023
1054
  },
1024
1055
  {
1025
1056
  label: `files copied into ${name}/`,
1026
- run: () => {
1027
- written = copyTemplate(stagingDirectory, target, name);
1028
- return Promise.resolve();
1057
+ run: async () => {
1058
+ written = await copyTemplate(stagingDirectory, target, name);
1029
1059
  }
1030
1060
  }
1031
1061
  ],
@@ -1356,7 +1386,7 @@ const scaffoldTemplatePath = async (options, templateType, name, target) => {
1356
1386
  return { code: 1, files: [], target };
1357
1387
  }
1358
1388
  if (options.from !== void 0) {
1359
- return scaffoldFromLocal(options.from, templateType, target, name, options.logger);
1389
+ return await scaffoldFromLocal(options.from, templateType, target, name, options.logger);
1360
1390
  }
1361
1391
  if (options.source !== void 0 && options.source.length > 0 && !options.allowUnsafeSource && !isSafeSource(options.source)) {
1362
1392
  options.logger.error(
@@ -1,7 +1,7 @@
1
1
  import { existsSync, rmSync } from 'node:fs';
2
2
  import { join } from '@visulima/path';
3
3
  import { d as defineHandler } from '../packem_shared/command-BC30oSBW.mjs';
4
- import { b as tuiConfirm } from '../packem_shared/tui-prompts-Dvlh5xWt.mjs';
4
+ import { b as tuiConfirm } from '../packem_shared/tui-prompts-M6OWsuyw.mjs';
5
5
 
6
6
  const runResetCommand = async (options) => {
7
7
  const cwd = options.cwd ?? process.cwd();
@@ -3,9 +3,9 @@ import { dirname, join } from '@visulima/path';
3
3
  import { DEV_VARS_FILE, parseDevVariableEntries } from '@lunora/config';
4
4
  import { modify, applyEdits, parse } from 'jsonc-parser';
5
5
  import { fileURLToPath } from 'node:url';
6
- import { b as tuiConfirm } from './tui-prompts-Dvlh5xWt.mjs';
6
+ import { b as tuiConfirm } from './tui-prompts-M6OWsuyw.mjs';
7
7
  import { collectCatalog, buildRegistryIndex } from './buildRegistryIndex-BcYe607_.mjs';
8
- import { insertSchemaExtension } from './insertSchemaExtension-BuzF6-t2.mjs';
8
+ import { insertSchemaExtension } from './insertSchemaExtension-DAqbfr9Z.mjs';
9
9
  import { createHash } from 'node:crypto';
10
10
  import { tmpdir } from 'node:os';
11
11
  import { downloadTemplate } from 'giget';
@@ -65,6 +65,27 @@ const resolveDistTag = () => {
65
65
  const ref = resolveVersionRef(resolveCliVersion());
66
66
  return ref === STABLE_BRANCH ? STABLE_DIST_TAG : ref;
67
67
  };
68
+ const DEFAULT_REGISTRY = "https://registry.npmjs.org";
69
+ const registryBase = () => {
70
+ const configured = process.env["npm_config_registry"];
71
+ const base = configured !== void 0 && configured.length > 0 ? configured : DEFAULT_REGISTRY;
72
+ return base.endsWith("/") ? base.slice(0, -1) : base;
73
+ };
74
+ const resolveTagVersion = async (packageName, tag) => {
75
+ try {
76
+ const response = await fetch(`${registryBase()}/${packageName.replace("/", "%2F")}`, {
77
+ headers: { accept: "application/vnd.npm.install-v1+json" },
78
+ signal: AbortSignal.timeout(1e4)
79
+ });
80
+ if (!response.ok) {
81
+ return void 0;
82
+ }
83
+ const packument = await response.json();
84
+ return packument["dist-tags"]?.[tag];
85
+ } catch {
86
+ return void 0;
87
+ }
88
+ };
68
89
 
69
90
  const resolveDepRange = (range) => {
70
91
  if (!range.startsWith("workspace:")) {
@@ -809,4 +830,4 @@ const runBuildIndexCommand = async (options) => {
809
830
  return empty;
810
831
  };
811
832
 
812
- export { runBuildIndexCommand as a, runRegistryViewCommand as b, resolveSourceRef as c, resolveDistTag as d, runListCommand as e, runAddCommand as r, setBindingField as s };
833
+ export { runBuildIndexCommand as a, runRegistryViewCommand as b, resolveSourceRef as c, resolveDistTag as d, resolveTagVersion as e, runListCommand as f, runAddCommand as r, setBindingField as s };
@@ -1,4 +1,4 @@
1
- import { Project, SyntaxKind } from 'ts-morph';
1
+ import { Project, SyntaxKind, Node } from 'ts-morph';
2
2
 
3
3
  const VALID_JS_IDENTIFIER = /^[A-Za-z_$][\w$]*$/u;
4
4
  const startMarker = (key) => `// lunora:add:${key}:start`;
@@ -12,6 +12,19 @@ const findDefineSchemaCall = (callExpressions) => {
12
12
  }
13
13
  return void 0;
14
14
  };
15
+ const outermostChainExpression = (defineSchemaCall) => {
16
+ let node = defineSchemaCall;
17
+ for (let parent = node.getParent(); parent !== void 0; parent = node.getParent()) {
18
+ if (Node.isPropertyAccessExpression(parent) && parent.getExpression() === node) {
19
+ node = parent;
20
+ } else if (Node.isCallExpression(parent) && parent.getExpression() === node) {
21
+ node = parent;
22
+ } else {
23
+ break;
24
+ }
25
+ }
26
+ return node;
27
+ };
15
28
  const insertSchemaExtension = (source, key) => {
16
29
  if (!VALID_JS_IDENTIFIER.test(key)) {
17
30
  return { ok: false, reason: "invalid-identifier" };
@@ -33,15 +46,7 @@ const insertSchemaExtension = (source, key) => {
33
46
  if (tablesArgument?.getKind() !== SyntaxKind.ObjectLiteralExpression) {
34
47
  return { ok: false, reason: "non-object-argument" };
35
48
  }
36
- const variableDeclaration = defineSchemaCall.getFirstAncestorByKind(SyntaxKind.VariableDeclaration);
37
- if (!variableDeclaration) {
38
- return { ok: false, reason: "no-define-schema" };
39
- }
40
- const initializer = variableDeclaration.getInitializer();
41
- if (!initializer) {
42
- return { ok: false, reason: "no-define-schema" };
43
- }
44
- const insertAt = initializer.getEnd();
49
+ const insertAt = outermostChainExpression(defineSchemaCall).getEnd();
45
50
  const chainText = `
46
51
  ${startMarker(key)}
47
52
  .extend(${key}.extension)
@@ -0,0 +1,4 @@
1
+ import 'node:fs';
2
+ import '@visulima/path';
3
+ export { r as runAddCommand, a as runBuildIndexCommand, f as runListCommand, b as runRegistryViewCommand } from './commands-DGo2VAsr.mjs';
4
+ import './buildRegistryIndex-BcYe607_.mjs';
@@ -1,4 +1,4 @@
1
- import { s as setBindingField } from './commands-zs-0Es9F.mjs';
1
+ import { s as setBindingField } from './commands-DGo2VAsr.mjs';
2
2
 
3
3
  const INVALID_SLUG_CHARS = /[^a-z0-9]+/u;
4
4
  const toKebabSlug = (input, min, max) => {
@@ -449,7 +449,7 @@ const tuiNextSteps = async (badge, header, steps, help) => {
449
449
  ] })
450
450
  );
451
451
  };
452
- const TASK_INDENT = " ".repeat(9);
452
+ const TASK_INDENT = " ".repeat(BADGE_COLUMN_WIDTH - 1);
453
453
  const SPINNER_FIRST = "#a855f7";
454
454
  const SPINNER_LAST = "#06b6d4";
455
455
  const SPINNER_COLORS = [SPINNER_FIRST, "#9b51f6", "#8a5cf6", "#6f86f6", "#4aa6ef", "#2bb6dd", "#12bcd0", SPINNER_LAST];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lunora/cli",
3
- "version": "1.0.0-alpha.11",
3
+ "version": "1.0.0-alpha.13",
4
4
  "description": "The Lunora CLI: init, dev, deploy, codegen, run, reset, and migrate commands",
5
5
  "keywords": [
6
6
  "agent-skills",
@@ -1,4 +0,0 @@
1
- import 'node:fs';
2
- import '@visulima/path';
3
- export { r as runAddCommand, a as runBuildIndexCommand, e as runListCommand, b as runRegistryViewCommand } from './commands-zs-0Es9F.mjs';
4
- import './buildRegistryIndex-BcYe607_.mjs';