@lark-apaas/fullstack-cli 0.1.0-alpha.4 → 0.1.0-alpha.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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lark-apaas/fullstack-cli",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.5",
|
|
4
4
|
"description": "CLI tool for fullstack template management",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -35,7 +35,6 @@
|
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
37
37
|
"@nestjs/core": "^10.0.0",
|
|
38
|
-
"@lark-apaas/fullstack-nestjs-core": "^1.0.0",
|
|
39
38
|
"drizzle-kit": "^0.20.0"
|
|
40
39
|
},
|
|
41
40
|
"peerDependenciesMeta": {
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import fs from 'node:fs';
|
|
2
|
-
import path from 'node:path';
|
|
3
|
-
import { spawnSync } from 'node:child_process';
|
|
4
|
-
import { postprocessDrizzleSchema } from '@lark-apaas/devtool-kits';
|
|
5
|
-
|
|
6
|
-
const OUT_DIR = path.resolve(process.cwd(), 'server/database/.introspect');
|
|
7
|
-
const SCHEMA_FILE = path.resolve(process.cwd(), 'server/database/schema.ts');
|
|
8
|
-
|
|
9
|
-
function run(): void {
|
|
10
|
-
const args = process.argv.slice(2);
|
|
11
|
-
const spawnArgs = ['--yes', 'drizzle-kit', 'introspect', '--config', 'drizzle.config.ts', ...args];
|
|
12
|
-
|
|
13
|
-
const result = spawnSync('npx', spawnArgs, { stdio: 'inherit' });
|
|
14
|
-
if (result.error) {
|
|
15
|
-
console.error('[gen-db-schema] Execution failed:', result.error);
|
|
16
|
-
process.exit(result.status ?? 1);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
if ((result.status ?? 0) !== 0) {
|
|
20
|
-
process.exit(result.status ?? 1);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
const generatedSchema = path.join(OUT_DIR, 'schema.ts');
|
|
24
|
-
if (!fs.existsSync(generatedSchema)) {
|
|
25
|
-
console.warn('[gen-db-schema] schema.ts not generated');
|
|
26
|
-
process.exit(1);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
fs.mkdirSync(path.dirname(SCHEMA_FILE), { recursive: true });
|
|
30
|
-
fs.copyFileSync(generatedSchema, SCHEMA_FILE);
|
|
31
|
-
|
|
32
|
-
try {
|
|
33
|
-
const stats = postprocessDrizzleSchema(SCHEMA_FILE);
|
|
34
|
-
if (stats?.unmatchedUnknown?.length) {
|
|
35
|
-
console.warn('[gen-db-schema] Unmatched custom types detected');
|
|
36
|
-
}
|
|
37
|
-
} catch (error) {
|
|
38
|
-
console.warn('[gen-db-schema] postprocess failed:', error);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
if (fs.existsSync(OUT_DIR)) {
|
|
42
|
-
fs.rmSync(OUT_DIR, { recursive: true, force: true });
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
if (require.main === module) {
|
|
47
|
-
run();
|
|
48
|
-
}
|