@nikelyh/metamorph 2.1.1 → 2.2.0
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/README.md +27 -3
- package/dist/ProjectDetector-TPATF25O.js +16 -0
- package/dist/chunk-4G3X6IOY.js +533 -0
- package/dist/{chunk-L7B6KUCW.js → chunk-6PDOFLME.js} +276 -25
- package/dist/{chunk-VEAYUIOZ.js → chunk-7LIGC5J3.js} +257 -0
- package/dist/chunk-BWUBT277.js +181 -0
- package/dist/{chunk-GKRBTA6E.js → chunk-BWZEGLCH.js} +7 -1
- package/dist/index.js +4471 -2741
- package/dist/projectConfigAdapter-Q62XAAF6.js +14 -0
- package/dist/public/assets/index-3jZMGi8l.css +1 -0
- package/dist/public/assets/index-BiBex3Xf.js +63 -0
- package/dist/public/index.html +2 -2
- package/dist/{runtime-L7VOQROE.js → runtime-UX3643CQ.js} +2 -1
- package/dist/{src-JHOGUCRS.js → src-CWC7KTYT.js} +18 -4
- package/dist/src-YET7DW3S.js +72 -0
- package/package.json +5 -5
- package/dist/NextMigrationHints-BGO2W3K4.js +0 -32
- package/dist/TechDetector-5YP44RVR.js +0 -6
- package/dist/chunk-3QN2Q75J.js +0 -101
- package/dist/chunk-H2LZEPNI.js +0 -352
- package/dist/public/assets/index-C0AxAuiv.css +0 -1
- package/dist/public/assets/index-DtMWFmXl.js +0 -63
- package/dist/src-UC3SN46X.js +0 -40
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
// ../application/src/analysis/projectConfigAdapter.ts
|
|
2
|
+
import * as fs from "fs";
|
|
3
|
+
import * as path from "path";
|
|
4
|
+
var CANDIDATE_ENTRIES = [
|
|
5
|
+
"src/main.ts",
|
|
6
|
+
"src/app.ts",
|
|
7
|
+
"src/server.ts",
|
|
8
|
+
"src/index.ts",
|
|
9
|
+
"main.ts",
|
|
10
|
+
"app.ts",
|
|
11
|
+
"server.ts",
|
|
12
|
+
"index.ts",
|
|
13
|
+
"src/main.js",
|
|
14
|
+
"src/app.js",
|
|
15
|
+
"src/server.js",
|
|
16
|
+
"src/index.js",
|
|
17
|
+
"main.js",
|
|
18
|
+
"app.js",
|
|
19
|
+
"server.js",
|
|
20
|
+
"index.js"
|
|
21
|
+
];
|
|
22
|
+
function detectEntryPoint(shadowDir) {
|
|
23
|
+
for (const rel of CANDIDATE_ENTRIES) {
|
|
24
|
+
const full = path.join(shadowDir, rel);
|
|
25
|
+
try {
|
|
26
|
+
if (fs.existsSync(full) && fs.statSync(full).isFile()) {
|
|
27
|
+
const baseName = path.basename(rel, path.extname(rel));
|
|
28
|
+
return {
|
|
29
|
+
relativePath: rel,
|
|
30
|
+
baseName,
|
|
31
|
+
outPath: `dist/${baseName}.js`
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
} catch {
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return {
|
|
38
|
+
relativePath: "src/main.ts",
|
|
39
|
+
baseName: "main",
|
|
40
|
+
outPath: "dist/main.js"
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
function sanitizeJsonContent(raw) {
|
|
44
|
+
return raw.replace(/\/\*[\s\S]*?\*\/|([^:]|^)\/\/.*/g, "$1").replace(/,\s*([}\]])/g, "$1").trim();
|
|
45
|
+
}
|
|
46
|
+
function adaptTypeScriptConfig(shadowDir, targetFramework) {
|
|
47
|
+
const tsConfigPath = path.join(shadowDir, "tsconfig.json");
|
|
48
|
+
const target = targetFramework.toLowerCase();
|
|
49
|
+
if (!fs.existsSync(tsConfigPath)) {
|
|
50
|
+
if (target === "nestjs") {
|
|
51
|
+
const defaultNestTsConfig = {
|
|
52
|
+
compilerOptions: {
|
|
53
|
+
module: "commonjs",
|
|
54
|
+
declaration: true,
|
|
55
|
+
removeComments: true,
|
|
56
|
+
emitDecoratorMetadata: true,
|
|
57
|
+
experimentalDecorators: true,
|
|
58
|
+
allowSyntheticDefaultImports: true,
|
|
59
|
+
target: "ES2021",
|
|
60
|
+
sourceMap: true,
|
|
61
|
+
outDir: "./dist",
|
|
62
|
+
baseUrl: "./",
|
|
63
|
+
incremental: true,
|
|
64
|
+
skipLibCheck: true,
|
|
65
|
+
strictNullChecks: false,
|
|
66
|
+
noImplicitAny: false,
|
|
67
|
+
types: ["node"]
|
|
68
|
+
},
|
|
69
|
+
include: ["src/**/*"]
|
|
70
|
+
};
|
|
71
|
+
fs.writeFileSync(tsConfigPath, JSON.stringify(defaultNestTsConfig, null, 2) + "\n", "utf-8");
|
|
72
|
+
return { modified: true, created: true };
|
|
73
|
+
}
|
|
74
|
+
return { modified: false, created: false };
|
|
75
|
+
}
|
|
76
|
+
try {
|
|
77
|
+
const rawContent = fs.readFileSync(tsConfigPath, "utf-8");
|
|
78
|
+
const sanitized = sanitizeJsonContent(rawContent);
|
|
79
|
+
const tsconfig = JSON.parse(sanitized);
|
|
80
|
+
let modified = false;
|
|
81
|
+
if (!tsconfig.compilerOptions) {
|
|
82
|
+
tsconfig.compilerOptions = {};
|
|
83
|
+
modified = true;
|
|
84
|
+
}
|
|
85
|
+
if (target === "nestjs") {
|
|
86
|
+
if (tsconfig.compilerOptions.experimentalDecorators !== true) {
|
|
87
|
+
tsconfig.compilerOptions.experimentalDecorators = true;
|
|
88
|
+
modified = true;
|
|
89
|
+
}
|
|
90
|
+
if (tsconfig.compilerOptions.emitDecoratorMetadata !== true) {
|
|
91
|
+
tsconfig.compilerOptions.emitDecoratorMetadata = true;
|
|
92
|
+
modified = true;
|
|
93
|
+
}
|
|
94
|
+
if (!tsconfig.compilerOptions.types) {
|
|
95
|
+
tsconfig.compilerOptions.types = ["node"];
|
|
96
|
+
modified = true;
|
|
97
|
+
} else if (Array.isArray(tsconfig.compilerOptions.types) && !tsconfig.compilerOptions.types.includes("node")) {
|
|
98
|
+
tsconfig.compilerOptions.types.push("node");
|
|
99
|
+
modified = true;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
if (modified) {
|
|
103
|
+
fs.writeFileSync(tsConfigPath, JSON.stringify(tsconfig, null, 2) + "\n", "utf-8");
|
|
104
|
+
}
|
|
105
|
+
return { modified, created: false };
|
|
106
|
+
} catch (err) {
|
|
107
|
+
console.warn("[projectConfigAdapter] Warning: Could not parse or adapt tsconfig.json:", err);
|
|
108
|
+
return { modified: false, created: false };
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
function ensureBuildScript(pkg, targetFramework) {
|
|
112
|
+
if (!pkg.scripts) {
|
|
113
|
+
pkg.scripts = {};
|
|
114
|
+
}
|
|
115
|
+
if (pkg.scripts.build && pkg.scripts.build.trim().length > 0) {
|
|
116
|
+
return false;
|
|
117
|
+
}
|
|
118
|
+
if (pkg.scripts["build:ts"]) {
|
|
119
|
+
pkg.scripts.build = "npm run build:ts";
|
|
120
|
+
return true;
|
|
121
|
+
}
|
|
122
|
+
if (pkg.scripts.compile) {
|
|
123
|
+
pkg.scripts.build = "npm run compile";
|
|
124
|
+
return true;
|
|
125
|
+
}
|
|
126
|
+
const target = targetFramework.toLowerCase();
|
|
127
|
+
if (["nestjs", "express", "fastify"].includes(target)) {
|
|
128
|
+
pkg.scripts.build = "tsc";
|
|
129
|
+
return true;
|
|
130
|
+
}
|
|
131
|
+
return false;
|
|
132
|
+
}
|
|
133
|
+
function adaptProjectScripts(pkg, shadowDir, targetFramework) {
|
|
134
|
+
if (!pkg.scripts) {
|
|
135
|
+
pkg.scripts = {};
|
|
136
|
+
}
|
|
137
|
+
let modified = false;
|
|
138
|
+
const target = targetFramework.toLowerCase();
|
|
139
|
+
const entry = detectEntryPoint(shadowDir);
|
|
140
|
+
if (!pkg.scripts.build || pkg.scripts.build.trim().length === 0) {
|
|
141
|
+
if (pkg.scripts["build:ts"]) {
|
|
142
|
+
pkg.scripts.build = "npm run build:ts";
|
|
143
|
+
modified = true;
|
|
144
|
+
} else if (pkg.scripts.compile) {
|
|
145
|
+
pkg.scripts.build = "npm run compile";
|
|
146
|
+
modified = true;
|
|
147
|
+
} else if (["nestjs", "express", "fastify"].includes(target)) {
|
|
148
|
+
pkg.scripts.build = "tsc";
|
|
149
|
+
modified = true;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
if (["nestjs", "express", "fastify"].includes(target)) {
|
|
153
|
+
const currentStart = pkg.scripts.start || "";
|
|
154
|
+
if (!pkg.scripts.start || /fastify start|nest start|dist\/(main|app|server|index)\.js/.test(currentStart)) {
|
|
155
|
+
const targetStart = `node ${entry.outPath}`;
|
|
156
|
+
if (pkg.scripts.start !== targetStart) {
|
|
157
|
+
pkg.scripts.start = targetStart;
|
|
158
|
+
modified = true;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
if (target === "nestjs") {
|
|
163
|
+
const currentDev = pkg.scripts.dev || "";
|
|
164
|
+
if (/watch:ts|dev:start|fastify/.test(currentDev)) {
|
|
165
|
+
pkg.scripts.dev = "tsc -w";
|
|
166
|
+
modified = true;
|
|
167
|
+
} else if (!pkg.scripts.dev) {
|
|
168
|
+
pkg.scripts.dev = "tsc -w";
|
|
169
|
+
modified = true;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
return modified;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
export {
|
|
176
|
+
detectEntryPoint,
|
|
177
|
+
sanitizeJsonContent,
|
|
178
|
+
adaptTypeScriptConfig,
|
|
179
|
+
ensureBuildScript,
|
|
180
|
+
adaptProjectScripts
|
|
181
|
+
};
|
|
@@ -1,15 +1,21 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DEFAULT_METAMORPH_CONFIG
|
|
3
|
+
} from "./chunk-7LIGC5J3.js";
|
|
4
|
+
|
|
1
5
|
// ../application/src/runtime.ts
|
|
2
6
|
import { defineRuntime, RuntimeState } from "@mozaik-ai/core";
|
|
3
7
|
var MetamorphState = class extends RuntimeState {
|
|
4
|
-
constructor(repository) {
|
|
8
|
+
constructor(repository, config) {
|
|
5
9
|
super();
|
|
6
10
|
this.repository = repository;
|
|
11
|
+
this.config = config ? { ...config } : { ...DEFAULT_METAMORPH_CONFIG };
|
|
7
12
|
}
|
|
8
13
|
dispatcherId;
|
|
9
14
|
journals = /* @__PURE__ */ new Map();
|
|
10
15
|
integrationLocks = /* @__PURE__ */ new Set();
|
|
11
16
|
retryCounts = /* @__PURE__ */ new Map();
|
|
12
17
|
integrationWatchdogs = /* @__PURE__ */ new Map();
|
|
18
|
+
config;
|
|
13
19
|
journal(planId) {
|
|
14
20
|
let entry = this.journals.get(planId);
|
|
15
21
|
if (!entry) {
|