@lark-apaas/fullstack-cli 1.1.15 → 1.1.16-alpha.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/dist/index.js +121 -20
- package/package.json +2 -3
package/dist/index.js
CHANGED
|
@@ -186,7 +186,7 @@ function convertSchemaTableInvocations(source) {
|
|
|
186
186
|
// src/commands/db/gen-dbschema/helper/table-rename.ts
|
|
187
187
|
import { pinyin } from "pinyin-pro";
|
|
188
188
|
function renamePgTableConstants(source) {
|
|
189
|
-
const pgTableRegex = /export const\s+([^\s=]+)\s*=\s*(pgTable|pgView|pgMaterializedView)\(\s*["'`]([^"'`]+)["'`]/gu;
|
|
189
|
+
const pgTableRegex = /export const\s+([^\s=]+)\s*=\s*(pgTable|pgView|pgMaterializedView|pgEnum|pgSequence)\(\s*["'`]([^"'`]+)["'`]/gu;
|
|
190
190
|
const renames = [];
|
|
191
191
|
const updated = source.replace(pgTableRegex, (match, currentName, factory, tableName) => {
|
|
192
192
|
const sanitized = sanitizeIdentifier(tableName);
|
|
@@ -209,7 +209,7 @@ function updateTableReferenceIdentifiers(source, renames) {
|
|
|
209
209
|
if (!rename.from || rename.from === rename.to) {
|
|
210
210
|
return acc;
|
|
211
211
|
}
|
|
212
|
-
const pattern = new RegExp(`\\b${escapeRegExp(rename.from)}(\\s
|
|
212
|
+
const pattern = new RegExp(`\\b${escapeRegExp(rename.from)}(\\s*[.(])`, "g");
|
|
213
213
|
return acc.replace(pattern, `${rename.to}$1`);
|
|
214
214
|
}, source);
|
|
215
215
|
}
|
|
@@ -256,16 +256,18 @@ function toAsciiName(name) {
|
|
|
256
256
|
|
|
257
257
|
// src/commands/db/gen-dbschema/helper/custom-types.ts
|
|
258
258
|
var CUSTOM_TYPE_PATTERN = /\/\/ TODO: failed to parse database type '(?:\w+\.)?(user_profile|file_attachment)(\[\])?'/;
|
|
259
|
+
var UNKNOWN_TYPE_TODO_PATTERN = /\/\/ TODO: failed to parse database type '([^']+)'/;
|
|
259
260
|
function replaceUnknownColumns(source) {
|
|
260
261
|
const lines = source.split("\n");
|
|
261
262
|
const result = [];
|
|
262
263
|
let replaced = 0;
|
|
264
|
+
let fallbackToText = 0;
|
|
263
265
|
const unmatched = [];
|
|
264
266
|
for (let i = 0; i < lines.length; i += 1) {
|
|
265
267
|
const line = lines[i];
|
|
266
|
-
const
|
|
267
|
-
if (
|
|
268
|
-
const typeName =
|
|
268
|
+
const knownMatch = line.match(CUSTOM_TYPE_PATTERN);
|
|
269
|
+
if (knownMatch) {
|
|
270
|
+
const typeName = knownMatch[1];
|
|
269
271
|
const factory = typeName === "user_profile" ? "userProfile" : "fileAttachment";
|
|
270
272
|
const replacedLine = replaceFollowingUnknown(lines[i + 1], factory);
|
|
271
273
|
if (replacedLine) {
|
|
@@ -278,6 +280,19 @@ function replaceUnknownColumns(source) {
|
|
|
278
280
|
}
|
|
279
281
|
continue;
|
|
280
282
|
}
|
|
283
|
+
const unknownMatch = line.match(UNKNOWN_TYPE_TODO_PATTERN);
|
|
284
|
+
if (unknownMatch) {
|
|
285
|
+
const replacedLine = replaceFollowingUnknown(lines[i + 1], "text");
|
|
286
|
+
if (replacedLine) {
|
|
287
|
+
result.push(replacedLine);
|
|
288
|
+
fallbackToText += 1;
|
|
289
|
+
i += 1;
|
|
290
|
+
} else {
|
|
291
|
+
unmatched.push(line.trim());
|
|
292
|
+
result.push(line);
|
|
293
|
+
}
|
|
294
|
+
continue;
|
|
295
|
+
}
|
|
281
296
|
if (line.includes("unknown(")) {
|
|
282
297
|
unmatched.push(line.trim());
|
|
283
298
|
}
|
|
@@ -286,6 +301,7 @@ function replaceUnknownColumns(source) {
|
|
|
286
301
|
return {
|
|
287
302
|
text: result.join("\n"),
|
|
288
303
|
replaced,
|
|
304
|
+
fallbackToText,
|
|
289
305
|
unmatched
|
|
290
306
|
};
|
|
291
307
|
}
|
|
@@ -547,6 +563,53 @@ ${aliasLines}
|
|
|
547
563
|
`;
|
|
548
564
|
}
|
|
549
565
|
|
|
566
|
+
// src/commands/db/gen-dbschema/helper/system-objects-filter.ts
|
|
567
|
+
var SYSTEM_OBJECTS = [
|
|
568
|
+
// pg_stat_statements 扩展
|
|
569
|
+
"pg_stat_statements",
|
|
570
|
+
"pg_stat_statements_info",
|
|
571
|
+
// pg_partman 扩展
|
|
572
|
+
"part_config",
|
|
573
|
+
"part_config_sub",
|
|
574
|
+
// 系统权限视图
|
|
575
|
+
"table_privs"
|
|
576
|
+
];
|
|
577
|
+
function removeSystemObjects(source, additionalObjects = []) {
|
|
578
|
+
const objectsToFilter = [...SYSTEM_OBJECTS, ...additionalObjects];
|
|
579
|
+
const removed = [];
|
|
580
|
+
const lines = source.split("\n");
|
|
581
|
+
const result = [];
|
|
582
|
+
let skipUntilNextExport = false;
|
|
583
|
+
let currentSystemObject = null;
|
|
584
|
+
for (let i = 0; i < lines.length; i++) {
|
|
585
|
+
const line = lines[i];
|
|
586
|
+
if (!skipUntilNextExport) {
|
|
587
|
+
const exportMatch = line.match(/^export const (\w+)\s*=/);
|
|
588
|
+
if (exportMatch) {
|
|
589
|
+
const objName = exportMatch[1];
|
|
590
|
+
if (objectsToFilter.includes(objName)) {
|
|
591
|
+
skipUntilNextExport = true;
|
|
592
|
+
currentSystemObject = objName;
|
|
593
|
+
continue;
|
|
594
|
+
}
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
if (skipUntilNextExport) {
|
|
598
|
+
if (line.match(/^\}\);/) || line.match(/\.as\([^)]*\);$/)) {
|
|
599
|
+
skipUntilNextExport = false;
|
|
600
|
+
if (currentSystemObject) {
|
|
601
|
+
removed.push(currentSystemObject);
|
|
602
|
+
currentSystemObject = null;
|
|
603
|
+
}
|
|
604
|
+
continue;
|
|
605
|
+
}
|
|
606
|
+
continue;
|
|
607
|
+
}
|
|
608
|
+
result.push(line);
|
|
609
|
+
}
|
|
610
|
+
return { text: result.join("\n"), removed };
|
|
611
|
+
}
|
|
612
|
+
|
|
550
613
|
// src/commands/db/gen-dbschema/postprocess.ts
|
|
551
614
|
function postprocessDrizzleSchema(targetPath) {
|
|
552
615
|
const resolvedPath = path.resolve(targetPath);
|
|
@@ -561,6 +624,8 @@ function postprocessDrizzleSchema(targetPath) {
|
|
|
561
624
|
text = removePgSchemaDeclarations(text);
|
|
562
625
|
const tableConversion = convertSchemaTableInvocations(text);
|
|
563
626
|
text = tableConversion.text;
|
|
627
|
+
const systemObjectsResult = removeSystemObjects(text);
|
|
628
|
+
text = systemObjectsResult.text;
|
|
564
629
|
const renameResult = renamePgTableConstants(text);
|
|
565
630
|
text = renameResult.text;
|
|
566
631
|
text = updateTableReferenceIdentifiers(text, renameResult.renames);
|
|
@@ -582,10 +647,13 @@ function postprocessDrizzleSchema(targetPath) {
|
|
|
582
647
|
console.info(`[postprocess-drizzle-schema] Patched ${patchResult.fixed} drizzle-kit defects (.default(') -> .default(''))`);
|
|
583
648
|
}
|
|
584
649
|
if (replacement.replaced > 0) {
|
|
585
|
-
console.info(`[postprocess-drizzle-schema] Replaced ${replacement.replaced} unknown columns`);
|
|
650
|
+
console.info(`[postprocess-drizzle-schema] Replaced ${replacement.replaced} unknown columns with custom types`);
|
|
651
|
+
}
|
|
652
|
+
if (replacement.fallbackToText > 0) {
|
|
653
|
+
console.info(`[postprocess-drizzle-schema] Replaced ${replacement.fallbackToText} unknown columns with text (fallback)`);
|
|
586
654
|
}
|
|
587
655
|
if (replacement.unmatched.length > 0) {
|
|
588
|
-
console.warn("[postprocess-drizzle-schema] Unmatched
|
|
656
|
+
console.warn("[postprocess-drizzle-schema] Unmatched unknown columns:", replacement.unmatched.length);
|
|
589
657
|
replacement.unmatched.forEach((line) => console.warn(` ${line}`));
|
|
590
658
|
}
|
|
591
659
|
if (tableConversion.converted > 0) {
|
|
@@ -597,12 +665,17 @@ function postprocessDrizzleSchema(targetPath) {
|
|
|
597
665
|
if (defaultNowReplacement.replaced > 0) {
|
|
598
666
|
console.info(`[postprocess-drizzle-schema] Replaced ${defaultNowReplacement.replaced} .defaultNow() with .default(sql\`CURRENT_TIMESTAMP\`)`);
|
|
599
667
|
}
|
|
668
|
+
if (systemObjectsResult.removed.length > 0) {
|
|
669
|
+
console.info(`[postprocess-drizzle-schema] Removed ${systemObjectsResult.removed.length} system objects: ${systemObjectsResult.removed.join(", ")}`);
|
|
670
|
+
}
|
|
600
671
|
return {
|
|
601
672
|
replacedUnknown: replacement.replaced,
|
|
673
|
+
fallbackToText: replacement.fallbackToText,
|
|
602
674
|
unmatchedUnknown: replacement.unmatched,
|
|
603
675
|
patchedDefects: patchResult.fixed,
|
|
604
676
|
replacedTimestamps: timestampReplacement.replaced,
|
|
605
|
-
replacedDefaultNow: defaultNowReplacement.replaced
|
|
677
|
+
replacedDefaultNow: defaultNowReplacement.replaced,
|
|
678
|
+
removedSystemObjects: systemObjectsResult.removed
|
|
606
679
|
};
|
|
607
680
|
}
|
|
608
681
|
|
|
@@ -1832,10 +1905,13 @@ function getHttpClient() {
|
|
|
1832
1905
|
enabled: true
|
|
1833
1906
|
}
|
|
1834
1907
|
});
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1908
|
+
const canaryEnv = process.env.FORCE_FRAMEWORK_CLI_CANARY_ENV;
|
|
1909
|
+
if (canaryEnv) {
|
|
1910
|
+
clientInstance.interceptors.request.use((req) => {
|
|
1911
|
+
req.headers["x-tt-env"] = canaryEnv;
|
|
1912
|
+
return req;
|
|
1913
|
+
});
|
|
1914
|
+
}
|
|
1839
1915
|
}
|
|
1840
1916
|
return clientInstance;
|
|
1841
1917
|
}
|
|
@@ -2303,7 +2379,7 @@ function listCapabilityIds() {
|
|
|
2303
2379
|
return [];
|
|
2304
2380
|
}
|
|
2305
2381
|
const files = fs8.readdirSync(dir);
|
|
2306
|
-
return files.filter((f) => f.endsWith(".json")).map((f) => f.replace(/\.json$/, ""));
|
|
2382
|
+
return files.filter((f) => f.endsWith(".json") && f !== "capabilities.json").map((f) => f.replace(/\.json$/, ""));
|
|
2307
2383
|
}
|
|
2308
2384
|
function readCapability(id) {
|
|
2309
2385
|
const filePath = getCapabilityPath(id);
|
|
@@ -2322,7 +2398,19 @@ function readCapability(id) {
|
|
|
2322
2398
|
}
|
|
2323
2399
|
function readAllCapabilities() {
|
|
2324
2400
|
const ids = listCapabilityIds();
|
|
2325
|
-
|
|
2401
|
+
const capabilities = [];
|
|
2402
|
+
for (const id of ids) {
|
|
2403
|
+
try {
|
|
2404
|
+
const capability = readCapability(id);
|
|
2405
|
+
if (!capability.pluginKey) {
|
|
2406
|
+
continue;
|
|
2407
|
+
}
|
|
2408
|
+
capabilities.push(capability);
|
|
2409
|
+
} catch {
|
|
2410
|
+
continue;
|
|
2411
|
+
}
|
|
2412
|
+
}
|
|
2413
|
+
return capabilities;
|
|
2326
2414
|
}
|
|
2327
2415
|
function readPluginManifest(pluginKey) {
|
|
2328
2416
|
const manifestPath = getPluginManifestPath(pluginKey);
|
|
@@ -2557,10 +2645,21 @@ function detectJsonMigration() {
|
|
|
2557
2645
|
try {
|
|
2558
2646
|
const content = fs11.readFileSync(oldFilePath, "utf-8");
|
|
2559
2647
|
const parsed = JSON.parse(content);
|
|
2560
|
-
|
|
2648
|
+
if (!Array.isArray(parsed)) {
|
|
2649
|
+
return {
|
|
2650
|
+
needsMigration: false,
|
|
2651
|
+
reason: "capabilities.json is not a valid array"
|
|
2652
|
+
};
|
|
2653
|
+
}
|
|
2654
|
+
if (parsed.length === 0) {
|
|
2655
|
+
return {
|
|
2656
|
+
needsMigration: false,
|
|
2657
|
+
reason: "capabilities.json is an empty array"
|
|
2658
|
+
};
|
|
2659
|
+
}
|
|
2561
2660
|
return {
|
|
2562
2661
|
needsMigration: true,
|
|
2563
|
-
oldCapabilities:
|
|
2662
|
+
oldCapabilities: parsed,
|
|
2564
2663
|
oldFilePath
|
|
2565
2664
|
};
|
|
2566
2665
|
} catch (error) {
|
|
@@ -3161,13 +3260,15 @@ function analyzeClass(sourceFile) {
|
|
|
3161
3260
|
if (!name) continue;
|
|
3162
3261
|
const isInjectable = hasDecorator(classDecl, "Injectable");
|
|
3163
3262
|
const isController = hasDecorator(classDecl, "Controller");
|
|
3164
|
-
|
|
3263
|
+
const isAutomation = hasDecorator(classDecl, "Automation");
|
|
3264
|
+
if (classInfo && classInfo.isInjectable && !isInjectable && !isController && !isAutomation) {
|
|
3165
3265
|
continue;
|
|
3166
3266
|
}
|
|
3167
3267
|
const info = {
|
|
3168
3268
|
name,
|
|
3169
3269
|
isInjectable,
|
|
3170
3270
|
isController,
|
|
3271
|
+
isAutomation,
|
|
3171
3272
|
constructorParamCount: 0
|
|
3172
3273
|
};
|
|
3173
3274
|
const classBody = classDecl.getChildSyntaxListOrThrow();
|
|
@@ -3186,7 +3287,7 @@ function analyzeClass(sourceFile) {
|
|
|
3186
3287
|
info.constructorParamsEnd = ctor.getStart();
|
|
3187
3288
|
}
|
|
3188
3289
|
}
|
|
3189
|
-
if (isInjectable || isController || !classInfo) {
|
|
3290
|
+
if (isInjectable || isController || isAutomation || !classInfo) {
|
|
3190
3291
|
classInfo = info;
|
|
3191
3292
|
}
|
|
3192
3293
|
}
|
|
@@ -3199,10 +3300,10 @@ function canAutoMigrate(classInfo) {
|
|
|
3199
3300
|
reason: "No class found in file"
|
|
3200
3301
|
};
|
|
3201
3302
|
}
|
|
3202
|
-
if (!classInfo.isInjectable && !classInfo.isController) {
|
|
3303
|
+
if (!classInfo.isInjectable && !classInfo.isController && !classInfo.isAutomation) {
|
|
3203
3304
|
return {
|
|
3204
3305
|
canMigrate: false,
|
|
3205
|
-
reason: `Class "${classInfo.name}" is not @Injectable or @
|
|
3306
|
+
reason: `Class "${classInfo.name}" is not @Injectable, @Controller or @Automation`
|
|
3206
3307
|
};
|
|
3207
3308
|
}
|
|
3208
3309
|
return { canMigrate: true };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lark-apaas/fullstack-cli",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.16-alpha.0",
|
|
4
4
|
"description": "CLI tool for fullstack template management",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -52,6 +52,5 @@
|
|
|
52
52
|
"peerDependencies": {
|
|
53
53
|
"typescript": "^5.9.2"
|
|
54
54
|
},
|
|
55
|
-
"migrationVersion": 1
|
|
56
|
-
"gitHead": "01b6e36136d5e8aee0960b9b90091c8c3f66537a"
|
|
55
|
+
"migrationVersion": 1
|
|
57
56
|
}
|