@lark-apaas/fullstack-cli 1.1.12-alpha.8 → 1.1.12-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.
Files changed (2) hide show
  1. package/dist/index.js +29 -12
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -141,22 +141,39 @@ async function run(options = {}) {
141
141
  console.log("[gen-db-schema] Starting...");
142
142
  const __filename = fileURLToPath(import.meta.url);
143
143
  const __dirname2 = path.dirname(__filename);
144
- const configPath = path.join(__dirname2, "config", "drizzle.config.js");
145
- console.log("[gen-db-schema] Using drizzle config from:", configPath);
146
- if (!fs.existsSync(configPath)) {
144
+ const configPathCandidates = [
145
+ path.resolve(__dirname2, "config/drizzle.config.js"),
146
+ path.resolve(__dirname2, "../../config/drizzle.config.js"),
147
+ path.resolve(__dirname2, "../../../dist/config/drizzle.config.js")
148
+ ];
149
+ const configPath = configPathCandidates.find((p) => fs.existsSync(p));
150
+ console.log("[gen-db-schema] Using drizzle config from:", configPath ?? "(not found)");
151
+ if (!configPath) {
147
152
  console.error("[gen-db-schema] Error: drizzle config not found in CLI package");
148
153
  process.exit(1);
149
154
  }
150
155
  const resolveDrizzleKitBin = () => {
151
- const pkgJsonPath = require2.resolve("drizzle-kit/package.json");
152
- const pkgJsonRaw = fs.readFileSync(pkgJsonPath, "utf8");
153
- const pkgJson = JSON.parse(pkgJsonRaw);
154
- const binField = pkgJson.bin;
155
- const binRelPath = typeof binField === "string" ? binField : binField?.["drizzle-kit"];
156
- if (!binRelPath) {
157
- throw new Error("Unable to resolve drizzle-kit binary from package.json");
158
- }
159
- return path.resolve(path.dirname(pkgJsonPath), binRelPath);
156
+ const entryPath = require2.resolve("drizzle-kit");
157
+ let currentDir = path.dirname(entryPath);
158
+ let lastDir = null;
159
+ while (currentDir !== lastDir) {
160
+ const pkgJsonPath = path.join(currentDir, "package.json");
161
+ if (fs.existsSync(pkgJsonPath)) {
162
+ const pkgJsonRaw = fs.readFileSync(pkgJsonPath, "utf8");
163
+ const pkgJson = JSON.parse(pkgJsonRaw);
164
+ if (pkgJson.name === "drizzle-kit") {
165
+ const binField = pkgJson.bin;
166
+ const binRelPath = typeof binField === "string" ? binField : binField?.["drizzle-kit"];
167
+ if (!binRelPath) {
168
+ throw new Error("Unable to resolve drizzle-kit binary from package.json");
169
+ }
170
+ return path.resolve(currentDir, binRelPath);
171
+ }
172
+ }
173
+ lastDir = currentDir;
174
+ currentDir = path.dirname(currentDir);
175
+ }
176
+ throw new Error("Unable to locate drizzle-kit package root");
160
177
  };
161
178
  try {
162
179
  const env = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lark-apaas/fullstack-cli",
3
- "version": "1.1.12-alpha.8",
3
+ "version": "1.1.12-alpha.9",
4
4
  "description": "CLI tool for fullstack template management",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",