@lark-apaas/fullstack-cli 0.1.0-alpha.7 → 0.1.0-alpha.8

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.
@@ -1,6 +1,12 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- const path = require('path');
3
+ import { fileURLToPath } from 'node:url';
4
+ import path from 'node:path';
5
+ import { createRequire } from 'node:module';
6
+
7
+ const __filename = fileURLToPath(import.meta.url);
8
+ const __dirname = path.dirname(__filename);
9
+ const require = createRequire(import.meta.url);
4
10
 
5
11
  const command = process.argv[2];
6
12
  const distPath = path.join(__dirname, '..', 'dist');
@@ -9,13 +15,14 @@ async function main() {
9
15
  try {
10
16
  switch (command) {
11
17
  case 'gen-db-schema': {
12
- const { run } = await import(path.join(distPath, 'commands', 'gen-db-schema.js'));
18
+ const modulePath = path.join(distPath, 'commands', 'gen-db-schema.js');
19
+ const { run } = await import(modulePath);
13
20
  await run();
14
21
  break;
15
22
  }
16
23
  case 'sync':
17
24
  case 'postinstall': {
18
- // 调用原有的 sync-scripts.js
25
+ // 调用原有的 sync-scripts.js (CommonJS)
19
26
  require('./sync-scripts.js');
20
27
  break;
21
28
  }
@@ -40,6 +47,7 @@ async function main() {
40
47
  }
41
48
  } catch (error) {
42
49
  console.error(`Failed to execute command "${command}":`, error.message);
50
+ console.error(error.stack);
43
51
  process.exit(1);
44
52
  }
45
53
  }
@@ -4,6 +4,7 @@ import { fileURLToPath } from 'node:url';
4
4
  import { spawnSync } from 'node:child_process';
5
5
  // 加载 .env 配置
6
6
  import { config as loadEnv } from 'dotenv';
7
+ import { postprocessDrizzleSchema } from '@lark-apaas/devtool-kits';
7
8
  /**
8
9
  * 生成数据库 schema
9
10
  *
@@ -69,7 +70,6 @@ export async function run() {
69
70
  console.log(`[gen-db-schema] ✓ Copied to ${outputPath}`);
70
71
  // 后处理(如果 devtool-kits 可用)
71
72
  try {
72
- const { postprocessDrizzleSchema } = await import('@lark-apaas/devtool-kits');
73
73
  const stats = postprocessDrizzleSchema(SCHEMA_FILE);
74
74
  if (stats?.unmatchedUnknown?.length) {
75
75
  console.warn('[gen-db-schema] Unmatched custom types detected:', stats.unmatchedUnknown);
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@lark-apaas/fullstack-cli",
3
- "version": "0.1.0-alpha.7",
3
+ "version": "0.1.0-alpha.8",
4
4
  "description": "CLI tool for fullstack template management",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
- "bin": "./bin/cli.js",
7
+ "bin": "./bin/cli.mjs",
8
8
  "files": [
9
9
  "dist",
10
10
  "templates",
@@ -4,15 +4,14 @@ import { defineConfig } from 'drizzle-kit';
4
4
  // 通过环境变量传递具体参数
5
5
  const outputDir = process.env.__DRIZZLE_OUT_DIR__ || './server/database/.introspect';
6
6
  const schemaPath = process.env.__DRIZZLE_SCHEMA_PATH__ || './server/database/schema.ts';
7
- const schemaFilter = process.env.DRIZZLE_SCHEMA_FILTER?.split(',') || [];
8
- const tablesFilter = process.env.DRIZZLE_TABLES_FILTER?.split(',') || ['*'];
9
7
 
10
8
  const parsedUrl = new URL(process.env.SUDA_DATABASE_URL || '');
9
+ const schemaFilter = parsedUrl.searchParams.get('schema')?.split(',') ?? [];
11
10
 
12
- export default defineConfig({
11
+ const config = {
13
12
  schema: schemaPath,
14
13
  out: outputDir,
15
- tablesFilter,
14
+ tablesFilter: ['*'],
16
15
  schemaFilter,
17
16
  dialect: 'postgresql',
18
17
  dbCredentials: {
@@ -22,4 +21,5 @@ export default defineConfig({
22
21
  password: decodeURIComponent(parsedUrl.password),
23
22
  database: parsedUrl.pathname.split('/')[1],
24
23
  },
25
- });
24
+ }
25
+ export default defineConfig(config);