@lark-apaas/fullstack-cli 1.1.12-alpha.2 → 1.1.12-alpha.4
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 +35 -4
- 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");
|
|
@@ -1278,6 +1306,7 @@ async function run(options = {}) {
|
|
|
1278
1306
|
const outputPath = options.output || process.env.DB_SCHEMA_OUTPUT || "server/database/schema.ts";
|
|
1279
1307
|
const OUT_DIR = path2.resolve(process.cwd(), "server/database/.introspect");
|
|
1280
1308
|
const SCHEMA_FILE = path2.resolve(process.cwd(), outputPath);
|
|
1309
|
+
const GENERATED_SCHEMA_FILE = path2.join(OUT_DIR, "schema.ts");
|
|
1281
1310
|
console.log("[gen-db-schema] Starting...");
|
|
1282
1311
|
const __filename = fileURLToPath(import.meta.url);
|
|
1283
1312
|
const __dirname2 = path2.dirname(__filename);
|
|
@@ -1290,11 +1319,13 @@ async function run(options = {}) {
|
|
|
1290
1319
|
const env = {
|
|
1291
1320
|
...process.env,
|
|
1292
1321
|
__DRIZZLE_OUT_DIR__: OUT_DIR,
|
|
1293
|
-
__DRIZZLE_SCHEMA_PATH__:
|
|
1322
|
+
__DRIZZLE_SCHEMA_PATH__: GENERATED_SCHEMA_FILE
|
|
1294
1323
|
};
|
|
1295
1324
|
const args = process.argv.slice(3).filter((arg) => !arg.startsWith("--enable-nest-module-generate"));
|
|
1296
|
-
const
|
|
1297
|
-
const
|
|
1325
|
+
const drizzleKitBin = resolveDrizzleKitBin();
|
|
1326
|
+
const cliRootDir = findPackageRoot(__dirname2);
|
|
1327
|
+
const spawnArgs = [drizzleKitBin, "introspect", "--config", configPath, ...args];
|
|
1328
|
+
const result = spawnSync(process.execPath, spawnArgs, { stdio: "inherit", env, cwd: cliRootDir });
|
|
1298
1329
|
if (result.error) {
|
|
1299
1330
|
console.error("[gen-db-schema] Execution failed:", result.error);
|
|
1300
1331
|
throw result.error;
|
|
@@ -1302,7 +1333,7 @@ async function run(options = {}) {
|
|
|
1302
1333
|
if ((result.status ?? 0) !== 0) {
|
|
1303
1334
|
throw new Error(`drizzle-kit introspect failed with status ${result.status}`);
|
|
1304
1335
|
}
|
|
1305
|
-
const generatedSchema =
|
|
1336
|
+
const generatedSchema = GENERATED_SCHEMA_FILE;
|
|
1306
1337
|
if (!fs2.existsSync(generatedSchema)) {
|
|
1307
1338
|
console.error("[gen-db-schema] schema.ts not generated");
|
|
1308
1339
|
throw new Error("drizzle-kit introspect failed to generate schema.ts");
|