@boltic/cli 1.0.25 → 1.0.26
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/cli.js +42 -17
- package/package.json +1 -1
package/cli.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import chalk from "chalk";
|
|
2
2
|
import fs from "fs";
|
|
3
3
|
import path from "path";
|
|
4
|
+
import { fileURLToPath } from "url";
|
|
4
5
|
import EnvironmentCommands from "./commands/env.js";
|
|
5
6
|
import IntegrationCommands from "./commands/integration.js";
|
|
6
7
|
import AuthCommands from "./commands/login.js";
|
|
@@ -108,17 +109,33 @@ const createCLI = (consoleUrl, apiUrl, serviceName, env) => {
|
|
|
108
109
|
};
|
|
109
110
|
|
|
110
111
|
async function showHelp(commands) {
|
|
111
|
-
let
|
|
112
|
+
let version = "1.0.0";
|
|
112
113
|
try {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
114
|
+
let baseDir;
|
|
115
|
+
if (typeof import.meta !== "undefined" && import.meta.url) {
|
|
116
|
+
// Resolve module directory in a cross-platform (Windows-safe) way
|
|
117
|
+
const filename = fileURLToPath(import.meta.url);
|
|
118
|
+
baseDir = path.dirname(filename);
|
|
119
|
+
} else {
|
|
120
|
+
baseDir = process.cwd();
|
|
121
|
+
}
|
|
122
|
+
const packageJsonPath = path.join(baseDir, "package.json");
|
|
123
|
+
const packageJson = JSON.parse(
|
|
124
|
+
fs.readFileSync(packageJsonPath, "utf-8")
|
|
116
125
|
);
|
|
126
|
+
version = packageJson.version || version;
|
|
117
127
|
} catch {
|
|
118
|
-
//
|
|
119
|
-
|
|
128
|
+
// Best-effort secondary attempt from current working directory
|
|
129
|
+
try {
|
|
130
|
+
const fallbackPath = path.join(process.cwd(), "package.json");
|
|
131
|
+
const packageJson = JSON.parse(
|
|
132
|
+
fs.readFileSync(fallbackPath, "utf-8")
|
|
133
|
+
);
|
|
134
|
+
version = packageJson.version || version;
|
|
135
|
+
} catch {
|
|
136
|
+
// keep default version
|
|
137
|
+
}
|
|
120
138
|
}
|
|
121
|
-
const version = packageJson.version;
|
|
122
139
|
|
|
123
140
|
console.log(chalk.bold.yellow(`\nBoltic CLI Version: ${version}\n`));
|
|
124
141
|
console.log("\nUsage: boltic [command]\n");
|
|
@@ -141,24 +158,32 @@ async function handleEnvironment(args) {
|
|
|
141
158
|
}
|
|
142
159
|
|
|
143
160
|
async function showVersion() {
|
|
144
|
-
let version = "1.0.0";
|
|
161
|
+
let version = "1.0.0";
|
|
145
162
|
try {
|
|
146
|
-
let
|
|
163
|
+
let baseDir;
|
|
147
164
|
if (typeof import.meta !== "undefined" && import.meta.url) {
|
|
148
|
-
//
|
|
149
|
-
const
|
|
150
|
-
|
|
165
|
+
// Windows-safe resolution for ESM modules
|
|
166
|
+
const filename = fileURLToPath(import.meta.url);
|
|
167
|
+
baseDir = path.dirname(filename);
|
|
151
168
|
} else {
|
|
152
|
-
|
|
153
|
-
packageJsonPath = path.join(process.cwd(), "package.json");
|
|
169
|
+
baseDir = process.cwd();
|
|
154
170
|
}
|
|
155
|
-
|
|
171
|
+
const packageJsonPath = path.join(baseDir, "package.json");
|
|
156
172
|
const packageJson = JSON.parse(
|
|
157
173
|
fs.readFileSync(packageJsonPath, "utf-8")
|
|
158
174
|
);
|
|
159
|
-
version = packageJson.version;
|
|
175
|
+
version = packageJson.version || version;
|
|
160
176
|
} catch {
|
|
161
|
-
//
|
|
177
|
+
// Best-effort secondary attempt from current working directory
|
|
178
|
+
try {
|
|
179
|
+
const fallbackPath = path.join(process.cwd(), "package.json");
|
|
180
|
+
const packageJson = JSON.parse(
|
|
181
|
+
fs.readFileSync(fallbackPath, "utf-8")
|
|
182
|
+
);
|
|
183
|
+
version = packageJson.version || version;
|
|
184
|
+
} catch {
|
|
185
|
+
// fallback already defined
|
|
186
|
+
}
|
|
162
187
|
}
|
|
163
188
|
console.log(`Boltic CLI Version: ${version}`);
|
|
164
189
|
}
|
package/package.json
CHANGED