@lumerahq/cli 0.34.3 → 0.34.5
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.js
CHANGED
|
@@ -242,25 +242,25 @@ async function main() {
|
|
|
242
242
|
switch (command) {
|
|
243
243
|
// Resource commands
|
|
244
244
|
case "plan":
|
|
245
|
-
await import("./resources-
|
|
245
|
+
await import("./resources-55CTS5MT.js").then((m) => m.plan(args.slice(1)));
|
|
246
246
|
break;
|
|
247
247
|
case "apply":
|
|
248
|
-
await import("./resources-
|
|
248
|
+
await import("./resources-55CTS5MT.js").then((m) => m.apply(args.slice(1)));
|
|
249
249
|
break;
|
|
250
250
|
case "pull":
|
|
251
|
-
await import("./resources-
|
|
251
|
+
await import("./resources-55CTS5MT.js").then((m) => m.pull(args.slice(1)));
|
|
252
252
|
break;
|
|
253
253
|
case "destroy":
|
|
254
|
-
await import("./resources-
|
|
254
|
+
await import("./resources-55CTS5MT.js").then((m) => m.destroy(args.slice(1)));
|
|
255
255
|
break;
|
|
256
256
|
case "list":
|
|
257
|
-
await import("./resources-
|
|
257
|
+
await import("./resources-55CTS5MT.js").then((m) => m.list(args.slice(1)));
|
|
258
258
|
break;
|
|
259
259
|
case "show":
|
|
260
|
-
await import("./resources-
|
|
260
|
+
await import("./resources-55CTS5MT.js").then((m) => m.show(args.slice(1)));
|
|
261
261
|
break;
|
|
262
262
|
case "diff":
|
|
263
|
-
await import("./resources-
|
|
263
|
+
await import("./resources-55CTS5MT.js").then((m) => m.diff(args.slice(1)));
|
|
264
264
|
break;
|
|
265
265
|
// Development
|
|
266
266
|
case "dev":
|
|
@@ -293,7 +293,7 @@ async function main() {
|
|
|
293
293
|
await import("./status-NPNIY3QP.js").then((m) => m.status(args.slice(1)));
|
|
294
294
|
break;
|
|
295
295
|
case "migrate":
|
|
296
|
-
await import("./migrate-
|
|
296
|
+
await import("./migrate-Q2QY3YSL.js").then((m) => m.migrate(args.slice(1)));
|
|
297
297
|
break;
|
|
298
298
|
// Skills
|
|
299
299
|
case "skills":
|
|
@@ -14,7 +14,7 @@ import "./chunk-PNKVD2UK.js";
|
|
|
14
14
|
// src/commands/migrate.ts
|
|
15
15
|
import pc from "picocolors";
|
|
16
16
|
import { execFileSync } from "child_process";
|
|
17
|
-
import { existsSync, mkdirSync, renameSync, readdirSync, readFileSync, writeFileSync, rmSync, rmdirSync } from "fs";
|
|
17
|
+
import { cpSync, existsSync, mkdirSync, renameSync, readdirSync, readFileSync, writeFileSync, rmSync, rmdirSync } from "fs";
|
|
18
18
|
import { join, resolve } from "path";
|
|
19
19
|
import { stringify } from "smol-toml";
|
|
20
20
|
function showHelp() {
|
|
@@ -65,16 +65,26 @@ function rewriteAppImports(source, modules) {
|
|
|
65
65
|
for (const moduleName of modules) {
|
|
66
66
|
const escaped = moduleName.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
67
67
|
rewritten = rewritten.replace(
|
|
68
|
-
new RegExp(`^(\\s*)import\\s+${escaped}(\\s*(?:#.*)?)$`, "gm"),
|
|
69
|
-
`$1from app import ${moduleName}$2`
|
|
68
|
+
new RegExp(`^(\\s*)import\\s+${escaped}(\\s+as\\s+\\w+)?(\\s*(?:#.*)?)$`, "gm"),
|
|
69
|
+
`$1from app import ${moduleName}$2$3`
|
|
70
70
|
);
|
|
71
71
|
rewritten = rewritten.replace(
|
|
72
|
-
new RegExp(`^(\\s*)from\\s
|
|
73
|
-
|
|
72
|
+
new RegExp(`^(\\s*)from\\s+(${escaped}(?:\\.\\w+)*)\\s+import\\s+`, "gm"),
|
|
73
|
+
"$1from app.$2 import "
|
|
74
74
|
);
|
|
75
75
|
}
|
|
76
76
|
return rewritten;
|
|
77
77
|
}
|
|
78
|
+
function moveAppAPISource(source, destination, renameDirectory = renameSync, copyDirectory = cpSync) {
|
|
79
|
+
try {
|
|
80
|
+
renameDirectory(source, destination);
|
|
81
|
+
} catch (error) {
|
|
82
|
+
if (error.code !== "EXDEV") throw error;
|
|
83
|
+
mkdirSync(destination);
|
|
84
|
+
copyDirectory(source, destination, { recursive: true, force: false, errorOnExist: true });
|
|
85
|
+
rmSync(source, { recursive: true });
|
|
86
|
+
}
|
|
87
|
+
}
|
|
78
88
|
function migrateAppAPI(projectRoot, dryRun) {
|
|
79
89
|
const legacyDir = join(projectRoot, "app-api", "lambda");
|
|
80
90
|
const destination = join(projectRoot, "platform", "app");
|
|
@@ -107,19 +117,24 @@ function migrateAppAPI(projectRoot, dryRun) {
|
|
|
107
117
|
stdio: "inherit"
|
|
108
118
|
});
|
|
109
119
|
mkdirSync(join(projectRoot, "platform"), { recursive: true });
|
|
110
|
-
|
|
120
|
+
moveAppAPISource(legacyDir, destination);
|
|
111
121
|
rmSync(join(destination, "requirements.txt"), { force: true });
|
|
112
122
|
if (!existsSync(join(destination, "__init__.py"))) {
|
|
113
123
|
writeFileSync(join(destination, "__init__.py"), "", "utf8");
|
|
114
124
|
}
|
|
115
125
|
const modules = new Set(
|
|
116
|
-
readdirSync(destination, { withFileTypes: true }).filter((entry) => entry.isFile() && entry.name.endsWith(".py")).map((entry) => entry.name.slice(0, -3)).filter((name) => name !== "__init__")
|
|
126
|
+
readdirSync(destination, { withFileTypes: true }).filter((entry) => entry.isFile() && entry.name.endsWith(".py") || entry.isDirectory() && existsSync(join(destination, entry.name, "__init__.py"))).map((entry) => entry.isDirectory() ? entry.name : entry.name.slice(0, -3)).filter((name) => name !== "__init__")
|
|
117
127
|
);
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
128
|
+
const rewriteDirectory = (directory) => {
|
|
129
|
+
for (const entry of readdirSync(directory, { withFileTypes: true })) {
|
|
130
|
+
const path = join(directory, entry.name);
|
|
131
|
+
if (entry.isDirectory()) rewriteDirectory(path);
|
|
132
|
+
else if (entry.isFile() && entry.name.endsWith(".py")) {
|
|
133
|
+
writeFileSync(path, rewriteAppImports(readFileSync(path, "utf8"), modules), "utf8");
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
rewriteDirectory(destination);
|
|
123
138
|
writeFileSync(
|
|
124
139
|
pyprojectPath,
|
|
125
140
|
addReleaseAppEntrypoint(readFileSync(pyprojectPath, "utf8"), projectRoot),
|
|
@@ -296,5 +311,6 @@ async function migrate(args) {
|
|
|
296
311
|
console.log(pc.dim("Your project now uses the v1 structure."));
|
|
297
312
|
}
|
|
298
313
|
export {
|
|
299
|
-
migrate
|
|
314
|
+
migrate,
|
|
315
|
+
moveAppAPISource
|
|
300
316
|
};
|
|
@@ -762,7 +762,7 @@ function messageForIssue(issue) {
|
|
|
762
762
|
}
|
|
763
763
|
var hookVerifyRule = {
|
|
764
764
|
id: "hook-verify",
|
|
765
|
-
description: "Validates hook file structure (config export, trigger, known keys, default handler) and
|
|
765
|
+
description: "Validates hook file structure (config export, trigger, known keys, default handler) and checks on the backend that the script compiles and uses only what the hook runtime provides.",
|
|
766
766
|
appliesTo: ["hook"],
|
|
767
767
|
async check(target, ctx) {
|
|
768
768
|
if (target.filePath.endsWith(".ts")) {
|
|
@@ -835,7 +835,7 @@ var hookVerifyRule = {
|
|
|
835
835
|
const position = line ? ` at line ${line}${diagnostic.column ? `, column ${diagnostic.column}` : ""}` : "";
|
|
836
836
|
return error2(
|
|
837
837
|
target,
|
|
838
|
-
`Hook
|
|
838
|
+
`Hook script is invalid${position}: ${diagnostic.message}`,
|
|
839
839
|
line
|
|
840
840
|
);
|
|
841
841
|
})
|