@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.
Files changed (2) hide show
  1. package/cli.js +42 -17
  2. 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 packageJson;
112
+ let version = "1.0.0";
112
113
  try {
113
- // Try to read package.json from current directory
114
- packageJson = JSON.parse(
115
- fs.readFileSync(path.join(process.cwd(), "package.json"))
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
- // Fallback version if package.json not found
119
- packageJson = { version: "1.0.0" };
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"; // default fallback
161
+ let version = "1.0.0";
145
162
  try {
146
- let packageJsonPath;
163
+ let baseDir;
147
164
  if (typeof import.meta !== "undefined" && import.meta.url) {
148
- // ES modules in Node.js
149
- const currentDir = path.dirname(new URL(import.meta.url).pathname);
150
- packageJsonPath = path.join(currentDir, "package.json");
165
+ // Windows-safe resolution for ESM modules
166
+ const filename = fileURLToPath(import.meta.url);
167
+ baseDir = path.dirname(filename);
151
168
  } else {
152
- // Jest or other environments
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
- // fallback already defined
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@boltic/cli",
3
- "version": "1.0.25",
3
+ "version": "1.0.26",
4
4
  "description": "A powerful CLI tool for managing Boltic Workflow integrations - create, sync, test, and publish integrations with ease",
5
5
  "main": "index.js",
6
6
  "bin": {