forge-sql-orm 1.0.17 → 1.0.18
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 +1 -1
- package/scripts/forgeSqlCLI.js +11 -11
package/package.json
CHANGED
package/scripts/forgeSqlCLI.js
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const fs = require("fs");
|
|
5
|
-
const os = require("os");
|
|
2
|
+
import { execSync } from "child_process";
|
|
3
|
+
import path from "node:path";
|
|
6
4
|
|
|
7
|
-
// Get CLI arguments
|
|
5
|
+
// Get CLI arguments
|
|
8
6
|
const args = process.argv.slice(2).join(" ");
|
|
9
7
|
|
|
10
|
-
// Resolve the path to cli.ts
|
|
11
|
-
const cliPath = path.resolve(
|
|
8
|
+
// Resolve the path to cli.ts
|
|
9
|
+
const cliPath = path.resolve(new URL(".", import.meta.url), "cli.ts");
|
|
10
|
+
|
|
12
11
|
|
|
13
12
|
// Function to run a command
|
|
14
13
|
const runCommand = (cmd) => {
|
|
@@ -16,6 +15,7 @@ const runCommand = (cmd) => {
|
|
|
16
15
|
execSync(cmd, { stdio: "inherit", shell: true });
|
|
17
16
|
process.exit(0);
|
|
18
17
|
} catch (e) {
|
|
18
|
+
console.error("⚠️ Command execution failed:", e.message);
|
|
19
19
|
process.exit(1);
|
|
20
20
|
}
|
|
21
21
|
};
|
|
@@ -23,7 +23,7 @@ const runCommand = (cmd) => {
|
|
|
23
23
|
// **1. Check if `ts-node` is globally installed**
|
|
24
24
|
const isGlobalTsNodeInstalled = (() => {
|
|
25
25
|
try {
|
|
26
|
-
execSync("ts-node --version", { stdio: "ignore" });
|
|
26
|
+
execSync("ts-node --version", { stdio: "ignore" });
|
|
27
27
|
return true;
|
|
28
28
|
} catch {
|
|
29
29
|
return false;
|
|
@@ -32,9 +32,9 @@ const isGlobalTsNodeInstalled = (() => {
|
|
|
32
32
|
|
|
33
33
|
if (isGlobalTsNodeInstalled) {
|
|
34
34
|
console.log("✅ Using global ts-node");
|
|
35
|
-
runCommand(`node
|
|
35
|
+
runCommand(`node --loader ts-node/esm "${cliPath}" ${args}`);
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
// **
|
|
38
|
+
// ** fallback to npx**
|
|
39
39
|
console.warn("⚠️ Neither global nor local ts-node found, using npx...");
|
|
40
|
-
runCommand(`npx node
|
|
40
|
+
runCommand(`npx node --loader ts-node/esm "${cliPath}" ${args}`);
|