@lunora/cli 1.0.0-alpha.12 → 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 +1 -1
- package/dist/packem_chunks/handler.mjs +2 -2
- package/dist/packem_chunks/handler16.mjs +1 -1
- package/dist/packem_chunks/runInitCommand.mjs +42 -12
- package/dist/packem_shared/{commands-DVr4lduS.mjs → commands-DGo2VAsr.mjs} +22 -1
- package/dist/packem_shared/runAddCommand-4TpVekdC.mjs +4 -0
- package/dist/packem_shared/{storage-DL9OE4oE.mjs → storage-CaFkHfqA.mjs} +1 -1
- package/package.json +1 -1
- package/dist/packem_shared/runAddCommand-C-NOz8NJ.mjs +0 -4
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-
|
|
19
|
+
export { r as runAddCommand, a as runBuildIndexCommand, b as runRegistryViewCommand } from './packem_shared/commands-DGo2VAsr.mjs';
|
|
@@ -3,8 +3,8 @@ 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
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-
|
|
7
|
-
import { r as runAddCommand } from '../packem_shared/commands-
|
|
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-
|
|
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];
|
|
@@ -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-
|
|
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
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-
|
|
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
|
|
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
|
|
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(
|
|
@@ -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,
|
|
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 };
|
package/package.json
CHANGED