@lark-apaas/fullstack-cli 0.1.0-alpha.8 → 0.1.0-alpha.9
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.
|
@@ -2,9 +2,11 @@ import path from 'node:path';
|
|
|
2
2
|
import fs from 'node:fs';
|
|
3
3
|
import { fileURLToPath } from 'node:url';
|
|
4
4
|
import { spawnSync } from 'node:child_process';
|
|
5
|
+
import { createRequire } from 'node:module';
|
|
5
6
|
// 加载 .env 配置
|
|
6
7
|
import { config as loadEnv } from 'dotenv';
|
|
7
|
-
|
|
8
|
+
// 创建 require 函数来加载 CommonJS 模块
|
|
9
|
+
const require = createRequire(import.meta.url);
|
|
8
10
|
/**
|
|
9
11
|
* 生成数据库 schema
|
|
10
12
|
*
|
|
@@ -68,8 +70,9 @@ export async function run() {
|
|
|
68
70
|
fs.mkdirSync(path.dirname(SCHEMA_FILE), { recursive: true });
|
|
69
71
|
fs.copyFileSync(generatedSchema, SCHEMA_FILE);
|
|
70
72
|
console.log(`[gen-db-schema] ✓ Copied to ${outputPath}`);
|
|
71
|
-
//
|
|
73
|
+
// 后处理 schema(使用 CommonJS require 方式加载)
|
|
72
74
|
try {
|
|
75
|
+
const { postprocessDrizzleSchema } = require('@lark-apaas/devtool-kits');
|
|
73
76
|
const stats = postprocessDrizzleSchema(SCHEMA_FILE);
|
|
74
77
|
if (stats?.unmatchedUnknown?.length) {
|
|
75
78
|
console.warn('[gen-db-schema] Unmatched custom types detected:', stats.unmatchedUnknown);
|
|
@@ -77,7 +80,7 @@ export async function run() {
|
|
|
77
80
|
console.log('[gen-db-schema] ✓ Postprocessed schema');
|
|
78
81
|
}
|
|
79
82
|
catch (error) {
|
|
80
|
-
console.warn('[gen-db-schema] Postprocess
|
|
83
|
+
console.warn('[gen-db-schema] Postprocess failed:', error instanceof Error ? error.message : String(error));
|
|
81
84
|
}
|
|
82
85
|
// 清理临时文件
|
|
83
86
|
if (fs.existsSync(OUT_DIR)) {
|