@lunora/cli 1.0.0-alpha.7 → 1.0.0-alpha.70
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/LICENSE.md +6 -0
- package/__assets__/package-og.svg +1 -1
- package/dist/bin.mjs +1 -1
- package/dist/index.d.mts +248 -115
- package/dist/index.d.ts +248 -115
- package/dist/index.mjs +8 -8
- package/dist/packem_chunks/handler.mjs +87 -6
- package/dist/packem_chunks/handler10.mjs +8 -14
- package/dist/packem_chunks/handler11.mjs +19 -189
- package/dist/packem_chunks/handler12.mjs +176 -115
- package/dist/packem_chunks/handler13.mjs +118 -52
- package/dist/packem_chunks/handler14.mjs +50 -43
- package/dist/packem_chunks/handler15.mjs +48 -67
- package/dist/packem_chunks/handler16.mjs +74 -37
- package/dist/packem_chunks/handler17.mjs +39 -100
- package/dist/packem_chunks/handler18.mjs +87 -152
- package/dist/packem_chunks/handler19.mjs +148 -67
- package/dist/packem_chunks/handler2.mjs +6 -4
- package/dist/packem_chunks/handler20.mjs +77 -75
- package/dist/packem_chunks/handler21.mjs +71 -288
- package/dist/packem_chunks/handler3.mjs +6 -3
- package/dist/packem_chunks/handler4.mjs +2 -2
- package/dist/packem_chunks/handler5.mjs +7 -4
- package/dist/packem_chunks/handler6.mjs +10 -7
- package/dist/packem_chunks/handler7.mjs +2 -2
- package/dist/packem_chunks/handler8.mjs +1 -1
- package/dist/packem_chunks/handler9.mjs +315 -12
- package/dist/packem_chunks/planDevCommand.mjs +653 -37
- package/dist/packem_chunks/runCodegenCommand.mjs +5 -4
- package/dist/packem_chunks/runDeployCommand.mjs +115 -20
- package/dist/packem_chunks/runInitCommand.mjs +1602 -172
- package/dist/packem_chunks/runMigrateGenerateCommand.mjs +5 -4
- package/dist/packem_chunks/runResetCommand.mjs +2 -2
- package/dist/packem_chunks/runRpcCommand.mjs +3 -2
- package/dist/packem_shared/{COMMANDS-Bn8luojF.mjs → COMMANDS-0BD3K1pb.mjs} +79 -21
- package/dist/packem_shared/{DEFAULT_IMPORT_BATCH_SIZE-Ck-2bU08.mjs → DEFAULT_IMPORT_BATCH_SIZE-CRQmmBZM.mjs} +3 -2
- package/dist/packem_shared/{api-spec-CtA6ilu4.mjs → api-spec-Bx0iKbxA.mjs} +3 -1
- package/dist/packem_shared/{buildRegistryIndex-BcYe607_.mjs → buildRegistryIndex-CqM5FwGI.mjs} +1 -1
- package/dist/packem_shared/codegen-error-DJG-ghs_.mjs +31 -0
- package/dist/packem_shared/{command-BDXcJCCJ.mjs → command-lYnl4QyF.mjs} +6 -1
- package/dist/packem_shared/{commands-DqsEzojt.mjs → commands-vnRRkhNE.mjs} +123 -15
- package/dist/packem_shared/{createLogger-CHPNjFw2.mjs → createLogger-CIWSHrTL.mjs} +40 -8
- package/dist/packem_shared/{createRecordingSpawner-DxI3mebw.mjs → createRecordingSpawner-Cw5Iu73G.mjs} +12 -2
- package/dist/packem_shared/{detect-package-manager-DYp7n3mJ.mjs → detect-package-manager-DvEthdCw.mjs} +26 -30
- package/dist/packem_shared/{insertSchemaExtension-BuzF6-t2.mjs → insertSchemaExtension-DAqbfr9Z.mjs} +15 -10
- package/dist/packem_shared/{open-url-Dfq6fAyT.mjs → open-url-4PBLY9X0.mjs} +3 -2
- package/dist/packem_shared/{output-format-7gyGR3h8.mjs → output-format-B4642rjE.mjs} +1 -1
- package/dist/packem_shared/{parseManifest--vZf2FY1.mjs → parseManifest-BBrXCg9V.mjs} +16 -9
- package/dist/packem_shared/prompt-cancelled-APzX1Im-.mjs +9 -0
- package/dist/packem_shared/runAddCommand-BCcJzs_k.mjs +4 -0
- package/dist/packem_shared/storage-bGfgwOgF.mjs +84 -0
- package/dist/packem_shared/tui-prompts-BjEN8XgP.mjs +658 -0
- package/dist/packem_shared/wrangler-secrets-Dq_Fkbm-.mjs +49 -0
- package/package.json +10 -7
- package/skills/lunora-quickstart/SKILL.md +25 -5
- package/skills/lunora-setup-storage/SKILL.md +7 -3
- package/dist/packem_shared/features-ocSSpZtS.mjs +0 -24
- package/dist/packem_shared/runAddCommand-G544_v6e.mjs +0 -4
- package/dist/packem_shared/tui-prompts-XHFxlOg5.mjs +0 -269
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { runCodegen } from '@lunora/codegen';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
2
|
+
import { collectWranglerSecretVariables } from '@lunora/config';
|
|
3
|
+
import { p as parseApiSpec } from '../packem_shared/api-spec-Bx0iKbxA.mjs';
|
|
4
|
+
import { d as defineHandler } from '../packem_shared/command-lYnl4QyF.mjs';
|
|
5
|
+
import { v as validateOutputFormat, p as printJson, l as loggerForFormat, i as isJsonFormat } from '../packem_shared/output-format-B4642rjE.mjs';
|
|
5
6
|
|
|
6
7
|
const CRON_TRIGGER_LIMIT = 3;
|
|
7
8
|
const runCodegenCommand = (options) => {
|
|
@@ -13,7 +14,7 @@ const runCodegenCommand = (options) => {
|
|
|
13
14
|
options.logger.error(formatError);
|
|
14
15
|
return { advisories: [], cronTriggers: [], error: formatError, outputDirectory: "" };
|
|
15
16
|
}
|
|
16
|
-
const result = runCodegen({ apiSpec: options.apiSpec, projectRoot });
|
|
17
|
+
const result = runCodegen({ apiSpec: options.apiSpec, projectRoot, wranglerVariables: collectWranglerSecretVariables(projectRoot) });
|
|
17
18
|
const commandResult = {
|
|
18
19
|
advisories: result.advisories.map((advisory) => {
|
|
19
20
|
return {
|
|
@@ -1,18 +1,21 @@
|
|
|
1
1
|
import { existsSync, readFileSync } from 'node:fs';
|
|
2
2
|
import { runCodegen, discoverMigrations } from '@lunora/codegen';
|
|
3
|
-
import { readLinkedProject, writeLinkedProject, validateWranglerProject, inferLunoraBindings, reconcileWranglerBindings, DEV_VARS_FILE, parseDevVariableEntries, findWranglerFile, readWranglerJsonc, discoverContainerInfo } from '@lunora/config';
|
|
3
|
+
import { readLinkedProject, writeLinkedProject, validateWranglerProject, inferLunoraBindings, reconcileWranglerBindings, DEV_VARS_FILE, parseDevVariableEntries, isMintableSecretKey, findWranglerFile, readWranglerJsonc, discoverContainerInfo, packageNamesFromBindings, requiredSecrets, generateSecretValue } from '@lunora/config';
|
|
4
4
|
import { join } from '@visulima/path';
|
|
5
5
|
import { Spinner } from '@visulima/spinner';
|
|
6
6
|
import { Project } from 'ts-morph';
|
|
7
|
-
import { p as parseApiSpec } from '../packem_shared/api-spec-
|
|
7
|
+
import { p as parseApiSpec } from '../packem_shared/api-spec-Bx0iKbxA.mjs';
|
|
8
8
|
import { r as readWranglerName } from '../packem_shared/wrangler-name-cy4yhm9j.mjs';
|
|
9
|
-
import { d as defineHandler } from '../packem_shared/command-
|
|
9
|
+
import { d as defineHandler } from '../packem_shared/command-lYnl4QyF.mjs';
|
|
10
|
+
import { e as execArgsFor, d as detectPackageManager } from '../packem_shared/detect-package-manager-DvEthdCw.mjs';
|
|
10
11
|
import { a as isRailpackAvailable, i as isDockerAvailable } from '../packem_shared/docker-hMQ97KSQ.mjs';
|
|
11
|
-
import { v as validateOutputFormat, i as isJsonFormat, p as printJson, l as loggerForFormat } from '../packem_shared/output-format-
|
|
12
|
+
import { v as validateOutputFormat, i as isJsonFormat, p as printJson, l as loggerForFormat } from '../packem_shared/output-format-B4642rjE.mjs';
|
|
12
13
|
import { containerBuildTag } from '@lunora/container';
|
|
13
|
-
import { defaultSpawner } from '../packem_shared/createRecordingSpawner-
|
|
14
|
+
import { defaultSpawner } from '../packem_shared/createRecordingSpawner-Cw5Iu73G.mjs';
|
|
14
15
|
import { r as resolveWorkerUrl } from '../packem_shared/resolve-target-qbsJ_5sF.mjs';
|
|
15
16
|
import { r as runSchemaDriftGate } from '../packem_shared/schema-drift-gate-BtBt0as0.mjs';
|
|
17
|
+
import { c as createTuiConfirm } from '../packem_shared/tui-prompts-BjEN8XgP.mjs';
|
|
18
|
+
import { l as listRemoteSecrets } from '../packem_shared/wrangler-secrets-Dq_Fkbm-.mjs';
|
|
16
19
|
import { runMigrateDataCommand } from './runMigrateGenerateCommand.mjs';
|
|
17
20
|
|
|
18
21
|
const WORKERS_DEV_URL = /https?:\/\/[^\s"'<>]+\.workers\.dev[^\s"'<>]*/u;
|
|
@@ -78,7 +81,8 @@ const buildRailpackImages = async (options) => {
|
|
|
78
81
|
for (const target of options.targets) {
|
|
79
82
|
const tag = containerBuildTag(target.exportName);
|
|
80
83
|
const build = { args: ["build", target.buildDir, "--name", tag], command: "railpack", cwd: options.cwd };
|
|
81
|
-
const
|
|
84
|
+
const pushExec = execArgsFor(detectPackageManager(options.cwd), "wrangler", ["containers", "push", tag]);
|
|
85
|
+
const push = { args: pushExec.args, command: pushExec.command, cwd: options.cwd };
|
|
82
86
|
options.logger.info(`railpack: building "${target.exportName}" → ${tag} from ${target.buildDir}`);
|
|
83
87
|
const buildResult = await spawner(build);
|
|
84
88
|
if (buildResult.code !== 0) {
|
|
@@ -210,6 +214,90 @@ const warnDevVariablesNotPushed = (cwd, logger) => {
|
|
|
210
214
|
`Note: \`lunora deploy\` does not push secrets. ${DEV_VARS_FILE} has ${String(keyCount)} key(s); if you changed them, run \`lunora env push --yes\` to update the deployed secrets.`
|
|
211
215
|
);
|
|
212
216
|
};
|
|
217
|
+
const SECRET_LIKE_KEY = /(?:KEY|PASSWORD|SECRET|TOKEN)$/u;
|
|
218
|
+
const resolveRequiredSecretKeys = async (cwd) => {
|
|
219
|
+
let packages = [];
|
|
220
|
+
try {
|
|
221
|
+
packages = packageNamesFromBindings(await inferLunoraBindings({ projectRoot: cwd }));
|
|
222
|
+
} catch {
|
|
223
|
+
}
|
|
224
|
+
const fromPackages = requiredSecrets(packages).map((entry) => entry.key);
|
|
225
|
+
let fromLocal = [];
|
|
226
|
+
try {
|
|
227
|
+
const devVariablesPath = join(cwd, DEV_VARS_FILE);
|
|
228
|
+
if (existsSync(devVariablesPath)) {
|
|
229
|
+
fromLocal = parseDevVariableEntries(readFileSync(devVariablesPath, "utf8")).map((entry) => entry.key).filter((key) => SECRET_LIKE_KEY.test(key));
|
|
230
|
+
}
|
|
231
|
+
} catch {
|
|
232
|
+
}
|
|
233
|
+
return [.../* @__PURE__ */ new Set([...fromPackages, ...fromLocal])];
|
|
234
|
+
};
|
|
235
|
+
const pushMintableSecrets = async (cwd, options, keys) => {
|
|
236
|
+
const { logger } = options;
|
|
237
|
+
const spawner = options.spawner ?? defaultSpawner;
|
|
238
|
+
const manager = detectPackageManager(cwd);
|
|
239
|
+
const environmentFlag = options.env === void 0 ? "" : ` --env ${options.env}`;
|
|
240
|
+
for (const key of keys) {
|
|
241
|
+
const args = ["secret", "put", key];
|
|
242
|
+
if (options.env !== void 0) {
|
|
243
|
+
args.push("--env", options.env);
|
|
244
|
+
}
|
|
245
|
+
if (options.temporary === true) {
|
|
246
|
+
args.push("--temporary");
|
|
247
|
+
}
|
|
248
|
+
const exec = execArgsFor(manager, "wrangler", args);
|
|
249
|
+
const pushResult = await spawner({ args: exec.args, command: exec.command, cwd, input: generateSecretValue() });
|
|
250
|
+
if (pushResult.code !== 0) {
|
|
251
|
+
logger.error(
|
|
252
|
+
`failed to push secret ${key} (exit ${String(pushResult.code)}); set it manually with \`wrangler secret put ${key}${environmentFlag}\`.`
|
|
253
|
+
);
|
|
254
|
+
return false;
|
|
255
|
+
}
|
|
256
|
+
logger.success(`generated + pushed ${key}`);
|
|
257
|
+
}
|
|
258
|
+
return true;
|
|
259
|
+
};
|
|
260
|
+
const offerMissingSecrets = async (cwd, options, interactive) => {
|
|
261
|
+
if (options.dryRun === true || options.preview === true) {
|
|
262
|
+
return void 0;
|
|
263
|
+
}
|
|
264
|
+
const { logger } = options;
|
|
265
|
+
const environmentFlag = options.env === void 0 ? "" : ` --env ${options.env}`;
|
|
266
|
+
let remote;
|
|
267
|
+
try {
|
|
268
|
+
remote = await (options.secretLister ?? listRemoteSecrets)({ cwd, env: options.env, temporary: options.temporary });
|
|
269
|
+
} catch {
|
|
270
|
+
return void 0;
|
|
271
|
+
}
|
|
272
|
+
if (!remote.ok) {
|
|
273
|
+
return void 0;
|
|
274
|
+
}
|
|
275
|
+
const remoteNames = new Set(remote.names);
|
|
276
|
+
const required = await resolveRequiredSecretKeys(cwd);
|
|
277
|
+
const missing = required.filter((key) => !remoteNames.has(key));
|
|
278
|
+
if (missing.length === 0) {
|
|
279
|
+
return void 0;
|
|
280
|
+
}
|
|
281
|
+
if (!interactive) {
|
|
282
|
+
return `missing required secret(s) on the deploy target: ${missing.join(", ")}. Set them with \`wrangler secret put <KEY>${environmentFlag}\` (or \`lunora env generate --set\` then \`lunora env push --yes${options.env === void 0 ? "" : " --prod"}\`), then re-deploy.`;
|
|
283
|
+
}
|
|
284
|
+
for (const key of missing.filter((name) => !isMintableSecretKey(name))) {
|
|
285
|
+
logger.warn(`required secret ${key} is not set on the target — set it with: wrangler secret put ${key}${environmentFlag}`);
|
|
286
|
+
}
|
|
287
|
+
const mintable = missing.filter((key) => isMintableSecretKey(key));
|
|
288
|
+
if (mintable.length === 0) {
|
|
289
|
+
return void 0;
|
|
290
|
+
}
|
|
291
|
+
const confirm = options.secretConfirm ?? createTuiConfirm();
|
|
292
|
+
if (await confirm(`${String(mintable.length)} required secret(s) not set on the target (${mintable.join(", ")}). Generate strong values and push them now?`)) {
|
|
293
|
+
await pushMintableSecrets(cwd, options, mintable);
|
|
294
|
+
return void 0;
|
|
295
|
+
}
|
|
296
|
+
logger.warn(
|
|
297
|
+
`${String(mintable.length)} required secret(s) not set on the target: ${mintable.join(", ")}. Generate + push with \`lunora env generate --set\` then \`lunora env push --yes${options.env === void 0 ? "" : " --prod"}\`.`
|
|
298
|
+
);
|
|
299
|
+
return void 0;
|
|
300
|
+
};
|
|
213
301
|
const runPostDeployMigrations = async (options, cwd) => {
|
|
214
302
|
const project = new Project({ skipAddingFilesFromTsConfig: true });
|
|
215
303
|
const lunoraDirectory = join(cwd, "lunora");
|
|
@@ -352,7 +440,7 @@ const runPreDeployGates = async (cwd, options) => {
|
|
|
352
440
|
return buildContainerImages(cwd, options);
|
|
353
441
|
};
|
|
354
442
|
const buildWranglerDeployArgs = (cwd, options) => {
|
|
355
|
-
const args = options.preview ? ["
|
|
443
|
+
const args = options.preview ? ["versions", "upload"] : ["deploy"];
|
|
356
444
|
const composedEntry = resolveComposedWorkerEntry(cwd);
|
|
357
445
|
if (composedEntry !== void 0) {
|
|
358
446
|
args.push(composedEntry);
|
|
@@ -375,6 +463,16 @@ const buildWranglerDeployArgs = (cwd, options) => {
|
|
|
375
463
|
}
|
|
376
464
|
return args;
|
|
377
465
|
};
|
|
466
|
+
const reportWranglerProblems = (validation, logger) => {
|
|
467
|
+
if (validation.problems.length === 0) {
|
|
468
|
+
return false;
|
|
469
|
+
}
|
|
470
|
+
logger.error("wrangler.jsonc validation failed:");
|
|
471
|
+
for (const problem of validation.problems) {
|
|
472
|
+
logger.error(` - ${problem}`);
|
|
473
|
+
}
|
|
474
|
+
return true;
|
|
475
|
+
};
|
|
378
476
|
const executeDeploy = async (options) => {
|
|
379
477
|
const cwd = options.cwd ?? process.cwd();
|
|
380
478
|
const interactive = isInteractive(options);
|
|
@@ -420,24 +518,21 @@ const executeDeploy = async (options) => {
|
|
|
420
518
|
return { code: 1, descriptor: void 0, error: preflightError, validation: { problems: [], wranglerPath: void 0 } };
|
|
421
519
|
}
|
|
422
520
|
const validation = validateWranglerProject({ projectRoot: cwd });
|
|
423
|
-
if (validation.
|
|
424
|
-
|
|
425
|
-
for (const problem of validation.problems) {
|
|
426
|
-
options.logger.error(` - ${problem}`);
|
|
427
|
-
}
|
|
428
|
-
return {
|
|
429
|
-
code: 1,
|
|
430
|
-
descriptor: void 0,
|
|
431
|
-
error: "wrangler validation failed",
|
|
432
|
-
validation
|
|
433
|
-
};
|
|
521
|
+
if (reportWranglerProblems(validation, options.logger)) {
|
|
522
|
+
return { code: 1, descriptor: void 0, error: "wrangler validation failed", validation };
|
|
434
523
|
}
|
|
435
524
|
warnDevVariablesNotPushed(cwd, options.logger);
|
|
525
|
+
const secretAbort = await offerMissingSecrets(cwd, options, interactive);
|
|
526
|
+
if (secretAbort !== void 0) {
|
|
527
|
+
options.logger.error(secretAbort);
|
|
528
|
+
return { code: 1, descriptor: void 0, error: secretAbort, validation };
|
|
529
|
+
}
|
|
436
530
|
const shouldAutoLink = !isJsonFormat(options.format) && options.dryRun !== true && options.preview !== true && readLinkedProject(cwd) === void 0;
|
|
531
|
+
const exec = execArgsFor(detectPackageManager(cwd), "wrangler", buildWranglerDeployArgs(cwd, options));
|
|
437
532
|
const descriptor = {
|
|
438
|
-
args:
|
|
533
|
+
args: exec.args,
|
|
439
534
|
captureStdout: shouldAutoLink,
|
|
440
|
-
command:
|
|
535
|
+
command: exec.command,
|
|
441
536
|
cwd,
|
|
442
537
|
// In `--format json` mode stdout is reserved for the single JSON document,
|
|
443
538
|
// so route wrangler's progress + deployed-URL output to stderr instead.
|