@lunora/cli 1.0.0-alpha.51 → 1.0.0-alpha.52

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
@@ -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-B-gR09Z_.mjs';
19
+ export { r as runAddCommand, a as runBuildIndexCommand, b as runRegistryViewCommand } from './packem_shared/commands-BK6Pt3Ni.mjs';
@@ -4,8 +4,8 @@ import { join, basename } from '@visulima/path';
4
4
  import { d as defineHandler } from '../packem_shared/command-D3lB_4Az.mjs';
5
5
  import { v as validateOutputFormat, i as isJsonFormat, p as printJson, l as loggerForFormat } from '../packem_shared/output-format-wUvAN6AL.mjs';
6
6
  import { t as tuiText, a as tuiSelect } from '../packem_shared/tui-prompts-BjEN8XgP.mjs';
7
- 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-BIsph-Vk.mjs';
8
- import { r as runAddCommand } from '../packem_shared/commands-B-gR09Z_.mjs';
7
+ 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-C8SAm5zu.mjs';
8
+ import { r as runAddCommand } from '../packem_shared/commands-BK6Pt3Ni.mjs';
9
9
 
10
10
  const providerToItem = (provider) => {
11
11
  const value = provider.trim().toLowerCase();
@@ -1,5 +1,5 @@
1
1
  import { d as defineHandler } from '../packem_shared/command-D3lB_4Az.mjs';
2
- import { r as runAddCommand, b as runRegistryViewCommand, a as runBuildIndexCommand } from '../packem_shared/commands-B-gR09Z_.mjs';
2
+ import { r as runAddCommand, b as runRegistryViewCommand, a as runBuildIndexCommand } from '../packem_shared/commands-BK6Pt3Ni.mjs';
3
3
 
4
4
  const execute = defineHandler(({ argument, cwd, logger, options }) => {
5
5
  const subcommand = argument[0];
@@ -26,6 +26,7 @@ const execute = defineHandler(({ argument, cwd, logger, options }) => {
26
26
  if (subcommand === "view") {
27
27
  return runRegistryViewCommand({
28
28
  allowUnsafeSource: options.allowUnsafeSource === true,
29
+ cwd,
29
30
  from: options.from,
30
31
  logger,
31
32
  names,
@@ -1,4 +1,4 @@
1
- import { existsSync, mkdirSync, writeFileSync, readFileSync, readdirSync, rmSync, mkdtempSync, cpSync, renameSync } from 'node:fs';
1
+ import { existsSync, mkdirSync, writeFileSync, readFileSync, readdirSync, rmSync, mkdtempSync, lstatSync, cpSync, renameSync } from 'node:fs';
2
2
  import { tmpdir } from 'node:os';
3
3
  import { detectFramework as detectFramework$1, isInteractive, LUNA_ART, LUNA_NAME, LUNA_SIGNOFF, paintAnswer, BADGES } from '@lunora/config';
4
4
  import { walkSync } from '@visulima/fs';
@@ -11,11 +11,11 @@ import { a as detectInstalledManagers, i as installArgsFor } from '../packem_sha
11
11
  import MagicString from 'magic-string';
12
12
  import { Project, SyntaxKind } from 'ts-morph';
13
13
  import { P as PromptCancelledError } from '../packem_shared/prompt-cancelled-APzX1Im-.mjs';
14
- import { c as resolveTagVersions, d as resolveSourceRef, e as resolveDistTag, r as runAddCommand } from '../packem_shared/commands-B-gR09Z_.mjs';
14
+ import { c as resolveTagVersions, d as resolveSourceRef, e as resolvePinnedSourceRef, f as resolveDistTag, r as runAddCommand } from '../packem_shared/commands-BK6Pt3Ni.mjs';
15
15
  import { defaultSpawner } from '../packem_shared/createRecordingSpawner-DxI3mebw.mjs';
16
16
  import { d as tuiMascot, e as tuiStep, f as tuiMoonrise, t as tuiText, g as tuiHeadline, h as tuiInfo, a as tuiSelect, b as tuiConfirm, w as withTuiSpinner, i as tuiNextSteps, j as tuiTasks, k as tuiMultiSelect, l as withTuiBadgeProgress } from '../packem_shared/tui-prompts-BjEN8XgP.mjs';
17
17
  import { logStep } from '../packem_shared/createLogger-B40gPzQo.mjs';
18
- 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-BIsph-Vk.mjs';
18
+ 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-C8SAm5zu.mjs';
19
19
  import dns from 'node:dns/promises';
20
20
 
21
21
  const GITHUB_CONTENT = `name: Deploy
@@ -1829,6 +1829,9 @@ const pnpmWorkspaceYaml = () => [
1829
1829
  const collectFiles = (directory) => {
1830
1830
  const out = [];
1831
1831
  for (const entry of walkSync(directory, { includeDirs: false, includeFiles: true })) {
1832
+ if (lstatSync(entry.path).isSymbolicLink()) {
1833
+ continue;
1834
+ }
1832
1835
  out.push(entry.path);
1833
1836
  }
1834
1837
  return out;
@@ -2028,7 +2031,8 @@ const scaffoldFromRemote = async (options) => {
2028
2031
  const stagingRoot = mkdtempSync(join$1(tmpdir(), "lunora-init-fetch-"));
2029
2032
  const stagingDirectory = join$1(stagingRoot, "template");
2030
2033
  try {
2031
- const remote = resolveTemplateSource(templateType, source, ref);
2034
+ const pinnedRef = source !== void 0 && source.length > 0 ? ref : await resolvePinnedSourceRef(ref, logger);
2035
+ const remote = resolveTemplateSource(templateType, source, pinnedRef);
2032
2036
  let downloaded;
2033
2037
  let written = [];
2034
2038
  await tuiTasks(
@@ -60,6 +60,44 @@ const resolveSourceRef = (ref) => {
60
60
  }
61
61
  return resolveVersionRef(resolveCliVersion());
62
62
  };
63
+ const SOURCE_REPO = "anolilab/lunora";
64
+ const COMMIT_SHA = /^[0-9a-f]{40}$/iu;
65
+ const SEMVER_BODY = String.raw`\d+\.\d+\.\d+(?:-[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)+)?(?:\+[0-9A-Za-z.-]+)?`;
66
+ const LEADING_VERSION_TAG = new RegExp(String.raw`^v?${SEMVER_BODY}$`, "u");
67
+ const PACKAGE_VERSION_TAG = new RegExp(String.raw`^(?:@[\w.-]+\/)?[\w.-]+@${SEMVER_BODY}$`, "u");
68
+ const isImmutableRef = (ref) => COMMIT_SHA.test(ref) || LEADING_VERSION_TAG.test(ref) || PACKAGE_VERSION_TAG.test(ref);
69
+ const githubAuthHeaders = () => {
70
+ const token = process.env["GITHUB_TOKEN"] ?? process.env["GH_TOKEN"];
71
+ return token !== void 0 && token.length > 0 ? { authorization: `Bearer ${token}` } : {};
72
+ };
73
+ const fetchBranchSha = async (branch) => {
74
+ try {
75
+ const response = await fetch(`https://api.github.com/repos/${SOURCE_REPO}/commits/${encodeURIComponent(branch)}`, {
76
+ headers: { accept: "application/vnd.github+json", "user-agent": "lunora-cli", ...githubAuthHeaders() },
77
+ signal: AbortSignal.timeout(1e4)
78
+ });
79
+ if (!response.ok) {
80
+ return void 0;
81
+ }
82
+ const body = await response.json();
83
+ return typeof body.sha === "string" && COMMIT_SHA.test(body.sha) ? body.sha : void 0;
84
+ } catch {
85
+ return void 0;
86
+ }
87
+ };
88
+ const resolvePinnedSourceRef = async (ref, logger) => {
89
+ const resolved = resolveSourceRef(ref);
90
+ if (isImmutableRef(resolved)) {
91
+ return resolved;
92
+ }
93
+ const sha = await fetchBranchSha(resolved);
94
+ if (sha === void 0) {
95
+ logger.warn(`could not pin ${SOURCE_REPO}#${resolved} to a commit — fetching the UNPINNED branch (set GITHUB_TOKEN if rate-limited).`);
96
+ return resolved;
97
+ }
98
+ logger.info(`pinned ${SOURCE_REPO}#${resolved} → ${sha}`);
99
+ return sha;
100
+ };
63
101
  const STABLE_DIST_TAG = "latest";
64
102
  const resolveDistTag = () => {
65
103
  const ref = resolveVersionRef(resolveCliVersion());
@@ -548,6 +586,16 @@ const fetchToStaging = async (remote, label, logger) => {
548
586
  throw error;
549
587
  }
550
588
  };
589
+ const remoteRefCache = /* @__PURE__ */ new WeakMap();
590
+ const resolveRemoteRef = async (options) => {
591
+ const cached = remoteRefCache.get(options);
592
+ if (cached !== void 0) {
593
+ return cached;
594
+ }
595
+ const pending = options.source !== void 0 && options.source.length > 0 ? Promise.resolve(resolveSourceRef(options.ref)) : resolvePinnedSourceRef(options.ref, options.logger);
596
+ remoteRefCache.set(options, pending);
597
+ return pending;
598
+ };
551
599
  const resolveItemDirectory = async (name, options) => {
552
600
  assertSafeItemName(name);
553
601
  if (options.from !== void 0) {
@@ -559,7 +607,7 @@ const resolveItemDirectory = async (name, options) => {
559
607
  }, directory };
560
608
  }
561
609
  const base = options.source ?? DEFAULT_SOURCE_BASE;
562
- return fetchToStaging(`${base}/${name}#${resolveSourceRef(options.ref)}`, "item", options.logger);
610
+ return fetchToStaging(`${base}/${name}#${await resolveRemoteRef(options)}`, "item", options.logger);
563
611
  };
564
612
  const resolveRegistryRoot = async (options) => {
565
613
  if (options.from !== void 0) {
@@ -570,7 +618,7 @@ const resolveRegistryRoot = async (options) => {
570
618
  }, root: options.from };
571
619
  }
572
620
  const base = options.source ?? DEFAULT_SOURCE_BASE;
573
- const { cleanup, directory } = await fetchToStaging(`${base}#${resolveSourceRef(options.ref)}`, "registry", options.logger);
621
+ const { cleanup, directory } = await fetchToStaging(`${base}#${await resolveRemoteRef(options)}`, "registry", options.logger);
574
622
  return { cleanup, root: directory };
575
623
  };
576
624
  const readManifest = (itemDirectory, name) => {
@@ -842,4 +890,4 @@ const runBuildIndexCommand = async (options) => {
842
890
  return empty;
843
891
  };
844
892
 
845
- export { runBuildIndexCommand as a, runRegistryViewCommand as b, resolveTagVersions as c, resolveSourceRef as d, resolveDistTag as e, runListCommand as f, runAddCommand as r, setBindingField as s };
893
+ export { runBuildIndexCommand as a, runRegistryViewCommand as b, resolveTagVersions as c, resolveSourceRef as d, resolvePinnedSourceRef as e, resolveDistTag as f, runListCommand as g, runAddCommand as r, setBindingField as s };
@@ -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-BK6Pt3Ni.mjs';
4
+ import './buildRegistryIndex-BcYe607_.mjs';
@@ -1,4 +1,4 @@
1
- import { s as setBindingField } from './commands-B-gR09Z_.mjs';
1
+ import { s as setBindingField } from './commands-BK6Pt3Ni.mjs';
2
2
 
3
3
  const INVALID_SLUG_CHARS = /[^a-z0-9]+/u;
4
4
  const toKebabSlug = (input, min, max) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lunora/cli",
3
- "version": "1.0.0-alpha.51",
3
+ "version": "1.0.0-alpha.52",
4
4
  "description": "The Lunora CLI: init, dev, deploy, codegen, run, reset, and migrate commands",
5
5
  "keywords": [
6
6
  "agent-skills",
@@ -52,11 +52,11 @@
52
52
  },
53
53
  "dependencies": {
54
54
  "@bomb.sh/tab": "0.0.17",
55
- "@lunora/codegen": "1.0.0-alpha.24",
56
- "@lunora/config": "1.0.0-alpha.39",
55
+ "@lunora/codegen": "1.0.0-alpha.25",
56
+ "@lunora/config": "1.0.0-alpha.40",
57
57
  "@lunora/container": "1.0.0-alpha.5",
58
- "@lunora/d1": "1.0.0-alpha.17",
59
- "@lunora/seed": "1.0.0-alpha.11",
58
+ "@lunora/d1": "1.0.0-alpha.18",
59
+ "@lunora/seed": "1.0.0-alpha.12",
60
60
  "@visulima/cerebro": "3.0.0-alpha.32",
61
61
  "@visulima/error": "6.0.0-alpha.34",
62
62
  "@visulima/fs": "5.0.0-alpha.32",
@@ -1,4 +0,0 @@
1
- import 'node:fs';
2
- import '@visulima/path';
3
- export { r as runAddCommand, a as runBuildIndexCommand, f as runListCommand, b as runRegistryViewCommand } from './commands-B-gR09Z_.mjs';
4
- import './buildRegistryIndex-BcYe607_.mjs';