@lunora/cli 0.0.0 → 1.0.0-alpha.2
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 +105 -0
- package/README.md +109 -9
- package/__assets__/package-og.svg +14 -0
- package/dist/bin.mjs +11 -0
- package/dist/index.d.mts +852 -0
- package/dist/index.d.ts +852 -0
- package/dist/index.mjs +19 -0
- package/dist/packem_chunks/handler.mjs +76 -0
- package/dist/packem_chunks/handler10.mjs +22 -0
- package/dist/packem_chunks/handler11.mjs +192 -0
- package/dist/packem_chunks/handler12.mjs +131 -0
- package/dist/packem_chunks/handler13.mjs +65 -0
- package/dist/packem_chunks/handler14.mjs +58 -0
- package/dist/packem_chunks/handler15.mjs +79 -0
- package/dist/packem_chunks/handler16.mjs +41 -0
- package/dist/packem_chunks/handler17.mjs +105 -0
- package/dist/packem_chunks/handler18.mjs +172 -0
- package/dist/packem_chunks/handler19.mjs +89 -0
- package/dist/packem_chunks/handler2.mjs +114 -0
- package/dist/packem_chunks/handler20.mjs +94 -0
- package/dist/packem_chunks/handler21.mjs +311 -0
- package/dist/packem_chunks/handler3.mjs +204 -0
- package/dist/packem_chunks/handler4.mjs +33 -0
- package/dist/packem_chunks/handler5.mjs +49 -0
- package/dist/packem_chunks/handler6.mjs +91 -0
- package/dist/packem_chunks/handler7.mjs +42 -0
- package/dist/packem_chunks/handler8.mjs +174 -0
- package/dist/packem_chunks/handler9.mjs +16 -0
- package/dist/packem_chunks/planDevCommand.mjs +543 -0
- package/dist/packem_chunks/runCodegenCommand.mjs +52 -0
- package/dist/packem_chunks/runDeployCommand.mjs +504 -0
- package/dist/packem_chunks/runInitCommand.mjs +652 -0
- package/dist/packem_chunks/runMigrateGenerateCommand.mjs +397 -0
- package/dist/packem_chunks/runResetCommand.mjs +41 -0
- package/dist/packem_chunks/runRpcCommand.mjs +68 -0
- package/dist/packem_shared/COMMANDS-1V_KEx35.mjs +905 -0
- package/dist/packem_shared/DEFAULT_IMPORT_BATCH_SIZE-Ck-2bU08.mjs +244 -0
- package/dist/packem_shared/admin-url-4UzT-CI4.mjs +19 -0
- package/dist/packem_shared/api-spec-CtA6ilu4.mjs +13 -0
- package/dist/packem_shared/buildRegistryIndex-BcYe607_.mjs +38 -0
- package/dist/packem_shared/command-BDXcJCCJ.mjs +14 -0
- package/dist/packem_shared/createLogger-CHPNjFw2.mjs +73 -0
- package/dist/packem_shared/defaultSpawner-DxI3mebw.mjs +43 -0
- package/dist/packem_shared/diffSnapshots-RR2ZE8Ya.mjs +161 -0
- package/dist/packem_shared/docker-hMQ97KSQ.mjs +21 -0
- package/dist/packem_shared/features-ocSSpZtS.mjs +24 -0
- package/dist/packem_shared/insertSchemaExtension-BuzF6-t2.mjs +59 -0
- package/dist/packem_shared/open-url-Dfq6fAyT.mjs +41 -0
- package/dist/packem_shared/output-format-7gyGR3h8.mjs +17 -0
- package/dist/packem_shared/parseArgs-YXFuKdEk.mjs +56 -0
- package/dist/packem_shared/parseManifest--vZf2FY1.mjs +94 -0
- package/dist/packem_shared/resolve-target-qbsJ_5sF.mjs +16 -0
- package/dist/packem_shared/runAddCommand-BZGkRnBs.mjs +693 -0
- package/dist/packem_shared/schema-drift-gate-BtBt0as0.mjs +79 -0
- package/dist/packem_shared/schemaIrToSnapshot-aBTo7TM5.mjs +43 -0
- package/dist/packem_shared/wrangler-name-cy4yhm9j.mjs +12 -0
- package/package.json +61 -18
- package/skills/README.md +29 -0
- package/skills/lunora/SKILL.md +83 -0
- package/skills/lunora-create-package/SKILL.md +129 -0
- package/skills/lunora-deploy/SKILL.md +150 -0
- package/skills/lunora-functions/SKILL.md +182 -0
- package/skills/lunora-migration-helper/SKILL.md +194 -0
- package/skills/lunora-performance-audit/SKILL.md +143 -0
- package/skills/lunora-quickstart/SKILL.md +240 -0
- package/skills/lunora-realtime/SKILL.md +177 -0
- package/skills/lunora-setup-auth/SKILL.md +170 -0
- package/skills/lunora-setup-hyperdrive/SKILL.md +154 -0
- package/skills/lunora-setup-hyperdrive-global/SKILL.md +171 -0
- package/skills/lunora-setup-mail/SKILL.md +151 -0
- package/skills/lunora-setup-scheduler/SKILL.md +157 -0
- package/skills/lunora-setup-storage/SKILL.md +154 -0
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { d as defineHandler } from '../packem_shared/command-BDXcJCCJ.mjs';
|
|
2
|
+
import { o as openUrl } from '../packem_shared/open-url-Dfq6fAyT.mjs';
|
|
3
|
+
|
|
4
|
+
const DEFAULT_DOCS_URL = "https://lunora.anolilab.dev/docs";
|
|
5
|
+
const trimSlashes = (value) => {
|
|
6
|
+
let start = 0;
|
|
7
|
+
let end = value.length;
|
|
8
|
+
while (start < end && value[start] === "/") {
|
|
9
|
+
start += 1;
|
|
10
|
+
}
|
|
11
|
+
while (end > start && value[end - 1] === "/") {
|
|
12
|
+
end -= 1;
|
|
13
|
+
}
|
|
14
|
+
return value.slice(start, end);
|
|
15
|
+
};
|
|
16
|
+
const buildUrl = (section) => {
|
|
17
|
+
if (!section || section.length === 0) {
|
|
18
|
+
return DEFAULT_DOCS_URL;
|
|
19
|
+
}
|
|
20
|
+
const trimmed = trimSlashes(section);
|
|
21
|
+
if (trimmed.length === 0) {
|
|
22
|
+
return DEFAULT_DOCS_URL;
|
|
23
|
+
}
|
|
24
|
+
return `${DEFAULT_DOCS_URL}/${trimmed}`;
|
|
25
|
+
};
|
|
26
|
+
const runDocsCommand = async (options) => {
|
|
27
|
+
const url = buildUrl(options.section);
|
|
28
|
+
options.logger.info(`opening ${url}`);
|
|
29
|
+
try {
|
|
30
|
+
await openUrl(url, { opener: options.opener });
|
|
31
|
+
} catch (error) {
|
|
32
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
33
|
+
options.logger.error(`docs: failed to open URL: ${message}`);
|
|
34
|
+
return { code: 1, url };
|
|
35
|
+
}
|
|
36
|
+
return { code: 0, url };
|
|
37
|
+
};
|
|
38
|
+
const execute = defineHandler(
|
|
39
|
+
({ argument, logger }) => runDocsCommand({ logger, section: argument[0] })
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
export { execute, runDocsCommand };
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import { findWranglerFile, readWranglerJsonc, validateWranglerConfig, isPlaceholderValue, DEV_VARS_FILE, parseDevVariableEntries, inferLunoraBindings } from '@lunora/config';
|
|
4
|
+
import { d as defineHandler } from '../packem_shared/command-BDXcJCCJ.mjs';
|
|
5
|
+
|
|
6
|
+
const SECRET_KEY_PATTERN = /(?:KEY|PASSWORD|SECRET|TOKEN)$/u;
|
|
7
|
+
const isD1PlaceholderId = (databaseId) => {
|
|
8
|
+
const value = databaseId.trim();
|
|
9
|
+
if (value === "") {
|
|
10
|
+
return true;
|
|
11
|
+
}
|
|
12
|
+
const lower = value.toLowerCase();
|
|
13
|
+
return lower.includes("replace") || lower.startsWith("<") && lower.endsWith(">");
|
|
14
|
+
};
|
|
15
|
+
const readWrangler = (cwd) => {
|
|
16
|
+
const path = findWranglerFile(cwd);
|
|
17
|
+
if (path === void 0) {
|
|
18
|
+
return { parsed: void 0, path: void 0 };
|
|
19
|
+
}
|
|
20
|
+
const { parsed } = readWranglerJsonc(path);
|
|
21
|
+
return { parsed, path };
|
|
22
|
+
};
|
|
23
|
+
const checkWrangler = (parsed, path, findings) => {
|
|
24
|
+
if (path === void 0) {
|
|
25
|
+
findings.push({
|
|
26
|
+
fix: "Run `lunora init` (or `lunora dev`) to scaffold and reconcile wrangler.jsonc.",
|
|
27
|
+
level: "fail",
|
|
28
|
+
message: "wrangler.jsonc not found."
|
|
29
|
+
});
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
if (parsed === void 0) {
|
|
33
|
+
findings.push({ fix: `Check ${path} is valid JSONC.`, level: "fail", message: `Could not parse ${path}.` });
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
const report = validateWranglerConfig(parsed);
|
|
37
|
+
const shardError = report.errors.find((error) => error.includes("SHARD"));
|
|
38
|
+
if (shardError === void 0) {
|
|
39
|
+
findings.push({ level: "pass", message: "wrangler.jsonc present with a SHARD durable-object binding." });
|
|
40
|
+
} else {
|
|
41
|
+
findings.push({ fix: "Run `lunora dev` to auto-reconcile, or add the binding manually.", level: "fail", message: shardError });
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
const checkD1Placeholders = (parsed, findings) => {
|
|
45
|
+
if (parsed === void 0) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
const databases = (parsed.d1_databases ?? []).filter(Boolean);
|
|
49
|
+
for (const database of databases) {
|
|
50
|
+
const databaseId = typeof database.database_id === "string" ? database.database_id : "";
|
|
51
|
+
if (isD1PlaceholderId(databaseId)) {
|
|
52
|
+
const label = typeof database.binding === "string" && database.binding.length > 0 ? database.binding : "<unnamed>";
|
|
53
|
+
findings.push({
|
|
54
|
+
fix: "Run `wrangler d1 create <name>` and paste the returned database_id into wrangler.jsonc.",
|
|
55
|
+
level: "fail",
|
|
56
|
+
message: `D1 binding "${label}" has a placeholder database_id ("${databaseId || "<empty>"}").`
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
const checkEmailDestination = (parsed, findings) => {
|
|
62
|
+
if (parsed === void 0) {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
const bindings = (parsed.send_email ?? []).filter(Boolean);
|
|
66
|
+
for (const binding of bindings) {
|
|
67
|
+
const destination = typeof binding.destination_address === "string" ? binding.destination_address : "";
|
|
68
|
+
if (destination !== "" && isPlaceholderValue(destination)) {
|
|
69
|
+
const label = typeof binding.name === "string" && binding.name.length > 0 ? binding.name : "send_email";
|
|
70
|
+
findings.push({
|
|
71
|
+
fix: "Set destination_address to a verified Cloudflare Email Routing address.",
|
|
72
|
+
level: "warn",
|
|
73
|
+
message: `send_email binding "${label}" has a placeholder destination_address ("${destination}").`
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
const checkDevVariables = (cwd, findings) => {
|
|
79
|
+
const devVariablesPath = join(cwd, DEV_VARS_FILE);
|
|
80
|
+
if (!existsSync(devVariablesPath)) {
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
let content;
|
|
84
|
+
try {
|
|
85
|
+
content = readFileSync(devVariablesPath, "utf8");
|
|
86
|
+
} catch {
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
const unfilled = parseDevVariableEntries(content).filter((entry) => SECRET_KEY_PATTERN.test(entry.key) && isPlaceholderValue(entry.value)).map((entry) => entry.key);
|
|
90
|
+
if (unfilled.length > 0) {
|
|
91
|
+
findings.push({
|
|
92
|
+
fix: "Run `lunora dev` to auto-generate secrets, or fill them in by hand.",
|
|
93
|
+
level: "warn",
|
|
94
|
+
message: `${DEV_VARS_FILE} has unfilled secret value(s): ${unfilled.join(", ")}.`
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
const checkAdminToken = (findings) => {
|
|
99
|
+
const token = process.env.LUNORA_ADMIN_TOKEN;
|
|
100
|
+
if (token === void 0 || token.trim() === "") {
|
|
101
|
+
findings.push({
|
|
102
|
+
fix: "Set LUNORA_ADMIN_TOKEN (env or `.dev.vars`) to enable admin RPCs / studio.",
|
|
103
|
+
level: "info",
|
|
104
|
+
message: "LUNORA_ADMIN_TOKEN is not set."
|
|
105
|
+
});
|
|
106
|
+
} else {
|
|
107
|
+
findings.push({ level: "pass", message: "LUNORA_ADMIN_TOKEN is set." });
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
const checkContainers = async (cwd, findings) => {
|
|
111
|
+
let containers;
|
|
112
|
+
try {
|
|
113
|
+
({ containers } = await inferLunoraBindings({ projectRoot: cwd }));
|
|
114
|
+
} catch {
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
for (const container of containers) {
|
|
118
|
+
if (container.exported) {
|
|
119
|
+
findings.push({ level: "pass", message: `container "${container.exportName}" is exported by the worker entry.` });
|
|
120
|
+
} else {
|
|
121
|
+
findings.push({
|
|
122
|
+
fix: 'Add `export * from "./lunora/_generated/containers"` to your worker entry (or re-run `vis generate lunora-container`).',
|
|
123
|
+
level: "fail",
|
|
124
|
+
message: `container "${container.exportName}" is declared but ${container.className} is not exported by the worker entry.`
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
const runDoctor = async (options) => {
|
|
130
|
+
const cwd = options.cwd ?? process.cwd();
|
|
131
|
+
const findings = [];
|
|
132
|
+
const { parsed, path } = readWrangler(cwd);
|
|
133
|
+
checkWrangler(parsed, path, findings);
|
|
134
|
+
checkD1Placeholders(parsed, findings);
|
|
135
|
+
checkEmailDestination(parsed, findings);
|
|
136
|
+
checkDevVariables(cwd, findings);
|
|
137
|
+
checkAdminToken(findings);
|
|
138
|
+
await checkContainers(cwd, findings);
|
|
139
|
+
const code = findings.some((finding) => finding.level === "fail") ? 1 : 0;
|
|
140
|
+
return { code, findings };
|
|
141
|
+
};
|
|
142
|
+
const LEVEL_LABEL = { fail: "FAIL", info: "INFO", pass: "PASS", warn: "WARN" };
|
|
143
|
+
const renderReport = (result, logger) => {
|
|
144
|
+
logger.info("lunora doctor — project preflight");
|
|
145
|
+
for (const finding of result.findings) {
|
|
146
|
+
const line = `[${LEVEL_LABEL[finding.level]}] ${finding.message}`;
|
|
147
|
+
if (finding.level === "fail") {
|
|
148
|
+
logger.error(line);
|
|
149
|
+
} else if (finding.level === "warn") {
|
|
150
|
+
logger.warn(line);
|
|
151
|
+
} else {
|
|
152
|
+
logger.info(line);
|
|
153
|
+
}
|
|
154
|
+
if (finding.fix !== void 0 && finding.level !== "pass") {
|
|
155
|
+
logger.info(` fix: ${finding.fix}`);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
const fails = result.findings.filter((finding) => finding.level === "fail").length;
|
|
159
|
+
const warns = result.findings.filter((finding) => finding.level === "warn").length;
|
|
160
|
+
if (fails > 0) {
|
|
161
|
+
logger.error(`${String(fails)} failure(s), ${String(warns)} warning(s).`);
|
|
162
|
+
} else if (warns > 0) {
|
|
163
|
+
logger.warn(`0 failures, ${String(warns)} warning(s).`);
|
|
164
|
+
} else {
|
|
165
|
+
logger.success("all checks passed.");
|
|
166
|
+
}
|
|
167
|
+
};
|
|
168
|
+
const execute = defineHandler(async ({ cwd, logger }) => {
|
|
169
|
+
const result = await runDoctor({ cwd});
|
|
170
|
+
renderReport(result, logger);
|
|
171
|
+
return { code: result.code };
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
export { execute, runDoctor };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { d as defineHandler } from '../packem_shared/command-BDXcJCCJ.mjs';
|
|
2
|
+
import { a as resolveProductionWorkerUrl } from '../packem_shared/resolve-target-qbsJ_5sF.mjs';
|
|
3
|
+
import { runExportCommand } from '../packem_shared/DEFAULT_IMPORT_BATCH_SIZE-Ck-2bU08.mjs';
|
|
4
|
+
|
|
5
|
+
const execute = defineHandler(
|
|
6
|
+
({ argument, cwd, logger, options }) => runExportCommand({
|
|
7
|
+
logger,
|
|
8
|
+
out: argument[0] ?? options.out,
|
|
9
|
+
prod: options.prod === true,
|
|
10
|
+
tables: options.tables,
|
|
11
|
+
token: options.token,
|
|
12
|
+
url: resolveProductionWorkerUrl({ cwd, prod: options.prod === true, url: options.url })
|
|
13
|
+
})
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
export { execute };
|