@turboops/cli 1.0.0-dev.570 → 1.0.0-dev.572

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 +92 -75
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -118,9 +118,91 @@ var logger = {
118
118
  }
119
119
  };
120
120
 
121
+ // src/utils/update-check.ts
122
+ import chalk2 from "chalk";
123
+ import { createRequire } from "module";
124
+ import { dirname, join } from "path";
125
+ import { fileURLToPath } from "url";
126
+ import { existsSync } from "fs";
127
+ function loadPackageJson() {
128
+ const require2 = createRequire(import.meta.url);
129
+ const __dirname = dirname(fileURLToPath(import.meta.url));
130
+ const paths = [
131
+ join(__dirname, "../../package.json"),
132
+ // From src/utils/
133
+ join(__dirname, "../package.json")
134
+ // From dist/
135
+ ];
136
+ for (const path of paths) {
137
+ if (existsSync(path)) {
138
+ return require2(path);
139
+ }
140
+ }
141
+ return { version: "0.0.0", name: "@turboops/cli" };
142
+ }
143
+ var pkg = loadPackageJson();
144
+ async function checkForUpdates() {
145
+ try {
146
+ const response = await fetch(
147
+ `https://registry.npmjs.org/${pkg.name}/latest`,
148
+ {
149
+ signal: AbortSignal.timeout(3e3)
150
+ // 3 second timeout
151
+ }
152
+ );
153
+ if (!response.ok) {
154
+ return;
155
+ }
156
+ const data = await response.json();
157
+ const latestVersion = data.version;
158
+ const currentVersion = pkg.version;
159
+ if (isNewerVersion(latestVersion, currentVersion)) {
160
+ showUpdateNotice(currentVersion, latestVersion);
161
+ }
162
+ } catch {
163
+ }
164
+ }
165
+ function isNewerVersion(version1, version2) {
166
+ const v1Parts = version1.split(".").map(Number);
167
+ const v2Parts = version2.split(".").map(Number);
168
+ for (let i = 0; i < Math.max(v1Parts.length, v2Parts.length); i++) {
169
+ const v1 = v1Parts[i] || 0;
170
+ const v2 = v2Parts[i] || 0;
171
+ if (v1 > v2) return true;
172
+ if (v1 < v2) return false;
173
+ }
174
+ return false;
175
+ }
176
+ function showUpdateNotice(currentVersion, latestVersion) {
177
+ console.log();
178
+ console.log(chalk2.yellow("\u2500".repeat(50)));
179
+ console.log(
180
+ chalk2.yellow(" Update available: ") + chalk2.gray(currentVersion) + chalk2.yellow(" \u2192 ") + chalk2.green(latestVersion)
181
+ );
182
+ console.log(
183
+ chalk2.yellow(" Run ") + chalk2.cyan(`npm update -g ${pkg.name}`) + chalk2.yellow(" to update")
184
+ );
185
+ console.log(chalk2.yellow("\u2500".repeat(50)));
186
+ }
187
+ function getCurrentVersion() {
188
+ return pkg.version;
189
+ }
190
+ function getPackageName() {
191
+ return pkg.name;
192
+ }
193
+
121
194
  // src/services/config.ts
195
+ var API_URLS = {
196
+ production: "https://api.turbo-ops.de",
197
+ dev: "https://api.dev.turbo-ops.de"
198
+ };
199
+ function getDefaultApiUrl() {
200
+ const version = getCurrentVersion();
201
+ const isDevVersion = version.includes("-dev");
202
+ return isDevVersion ? API_URLS.dev : API_URLS.production;
203
+ }
122
204
  var defaults = {
123
- apiUrl: "https://api.turboops.io",
205
+ apiUrl: API_URLS.production,
124
206
  token: null,
125
207
  project: null,
126
208
  userId: null
@@ -132,9 +214,17 @@ var config = new Conf({
132
214
  var configService = {
133
215
  /**
134
216
  * Get API URL
217
+ * Priority: ENV variable > stored config > version-based default
135
218
  */
136
219
  getApiUrl() {
137
- return process.env.TURBOOPS_API_URL || config.get("apiUrl");
220
+ if (process.env.TURBOOPS_API_URL) {
221
+ return process.env.TURBOOPS_API_URL;
222
+ }
223
+ const storedUrl = config.get("apiUrl");
224
+ if (storedUrl === "https://api.turboops.io" || storedUrl === API_URLS.production) {
225
+ return getDefaultApiUrl();
226
+ }
227
+ return storedUrl;
138
228
  },
139
229
  /**
140
230
  * Set API URL
@@ -244,79 +334,6 @@ var configService = {
244
334
  }
245
335
  };
246
336
 
247
- // src/utils/update-check.ts
248
- import chalk2 from "chalk";
249
- import { createRequire } from "module";
250
- import { dirname, join } from "path";
251
- import { fileURLToPath } from "url";
252
- import { existsSync } from "fs";
253
- function loadPackageJson() {
254
- const require2 = createRequire(import.meta.url);
255
- const __dirname = dirname(fileURLToPath(import.meta.url));
256
- const paths = [
257
- join(__dirname, "../../package.json"),
258
- // From src/utils/
259
- join(__dirname, "../package.json")
260
- // From dist/
261
- ];
262
- for (const path of paths) {
263
- if (existsSync(path)) {
264
- return require2(path);
265
- }
266
- }
267
- return { version: "0.0.0", name: "@turboops/cli" };
268
- }
269
- var pkg = loadPackageJson();
270
- async function checkForUpdates() {
271
- try {
272
- const response = await fetch(
273
- `https://registry.npmjs.org/${pkg.name}/latest`,
274
- {
275
- signal: AbortSignal.timeout(3e3)
276
- // 3 second timeout
277
- }
278
- );
279
- if (!response.ok) {
280
- return;
281
- }
282
- const data = await response.json();
283
- const latestVersion = data.version;
284
- const currentVersion = pkg.version;
285
- if (isNewerVersion(latestVersion, currentVersion)) {
286
- showUpdateNotice(currentVersion, latestVersion);
287
- }
288
- } catch {
289
- }
290
- }
291
- function isNewerVersion(version1, version2) {
292
- const v1Parts = version1.split(".").map(Number);
293
- const v2Parts = version2.split(".").map(Number);
294
- for (let i = 0; i < Math.max(v1Parts.length, v2Parts.length); i++) {
295
- const v1 = v1Parts[i] || 0;
296
- const v2 = v2Parts[i] || 0;
297
- if (v1 > v2) return true;
298
- if (v1 < v2) return false;
299
- }
300
- return false;
301
- }
302
- function showUpdateNotice(currentVersion, latestVersion) {
303
- console.log();
304
- console.log(chalk2.yellow("\u2500".repeat(50)));
305
- console.log(
306
- chalk2.yellow(" Update available: ") + chalk2.gray(currentVersion) + chalk2.yellow(" \u2192 ") + chalk2.green(latestVersion)
307
- );
308
- console.log(
309
- chalk2.yellow(" Run ") + chalk2.cyan(`npm update -g ${pkg.name}`) + chalk2.yellow(" to update")
310
- );
311
- console.log(chalk2.yellow("\u2500".repeat(50)));
312
- }
313
- function getCurrentVersion() {
314
- return pkg.version;
315
- }
316
- function getPackageName() {
317
- return pkg.name;
318
- }
319
-
320
337
  // src/commands/login.ts
321
338
  import { Command } from "commander";
322
339
  import prompts from "prompts";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@turboops/cli",
3
- "version": "1.0.0-dev.570",
3
+ "version": "1.0.0-dev.572",
4
4
  "description": "TurboCLI - Command line interface for TurboOps deployments",
5
5
  "author": "lenne.tech GmbH",
6
6
  "license": "MIT",