@lark-apaas/fullstack-cli 1.1.12-alpha.2 → 1.1.12-alpha.3

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.
Files changed (2) hide show
  1. package/dist/index.js +32 -2
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -120,6 +120,7 @@ import path2 from "path";
120
120
  import fs2 from "fs";
121
121
  import { fileURLToPath } from "url";
122
122
  import { spawnSync } from "child_process";
123
+ import { createRequire } from "module";
123
124
  import { config as loadEnv } from "dotenv";
124
125
 
125
126
  // src/internal/postprocess-drizzle-schema.ts
@@ -1263,6 +1264,33 @@ async function parseAndGenerateNestResourceTemplate(options) {
1263
1264
  }
1264
1265
 
1265
1266
  // src/commands/db/schema.handler.ts
1267
+ var require2 = createRequire(import.meta.url);
1268
+ function findPackageRoot(startDir) {
1269
+ let current = startDir;
1270
+ let parent = path2.dirname(current);
1271
+ while (parent !== current) {
1272
+ if (fs2.existsSync(path2.join(current, "package.json"))) {
1273
+ return current;
1274
+ }
1275
+ current = parent;
1276
+ parent = path2.dirname(current);
1277
+ }
1278
+ if (fs2.existsSync(path2.join(current, "package.json"))) {
1279
+ return current;
1280
+ }
1281
+ return startDir;
1282
+ }
1283
+ function resolveDrizzleKitBin() {
1284
+ const candidates = ["drizzle-kit/bin.cjs", "drizzle-kit/bin.js", "drizzle-kit/bin"];
1285
+ for (const id of candidates) {
1286
+ try {
1287
+ return require2.resolve(id);
1288
+ } catch {
1289
+ continue;
1290
+ }
1291
+ }
1292
+ return require2.resolve("drizzle-kit");
1293
+ }
1266
1294
  async function run(options = {}) {
1267
1295
  let exitCode = 0;
1268
1296
  const envPath2 = path2.resolve(process.cwd(), ".env");
@@ -1293,8 +1321,10 @@ async function run(options = {}) {
1293
1321
  __DRIZZLE_SCHEMA_PATH__: SCHEMA_FILE
1294
1322
  };
1295
1323
  const args = process.argv.slice(3).filter((arg) => !arg.startsWith("--enable-nest-module-generate"));
1296
- const spawnArgs = ["--yes", "drizzle-kit", "introspect", "--config", configPath, ...args];
1297
- const result = spawnSync("npx", spawnArgs, { stdio: "inherit", env });
1324
+ const drizzleKitBin = resolveDrizzleKitBin();
1325
+ const cliRootDir = findPackageRoot(__dirname2);
1326
+ const spawnArgs = [drizzleKitBin, "introspect", "--config", configPath, ...args];
1327
+ const result = spawnSync(process.execPath, spawnArgs, { stdio: "inherit", env, cwd: cliRootDir });
1298
1328
  if (result.error) {
1299
1329
  console.error("[gen-db-schema] Execution failed:", result.error);
1300
1330
  throw result.error;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lark-apaas/fullstack-cli",
3
- "version": "1.1.12-alpha.2",
3
+ "version": "1.1.12-alpha.3",
4
4
  "description": "CLI tool for fullstack template management",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",