gtx-cli 2.5.29-alpha.1 → 2.5.29-bin.1

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.
@@ -2,8 +2,8 @@ import { logger } from '../console/logger.js';
2
2
  import chalk from 'chalk';
3
3
  import path from 'node:path';
4
4
  import fs from 'node:fs';
5
- import { fromPackageRoot } from '../fs/getPackageResource.js';
6
5
  import { exitSync } from '../console/logging.js';
6
+ import { PACKAGE_VERSION } from '../generated/version.js';
7
7
  // search for package.json such that we can run init in non-js projects
8
8
  export async function searchForPackageJson(cwd = process.cwd()) {
9
9
  // Get the current working directory (where the CLI is being run)
@@ -33,16 +33,7 @@ export async function getPackageJson(cwd = process.cwd()) {
33
33
  }
34
34
  }
35
35
  export function getCLIVersion() {
36
- const packageJsonPath = fromPackageRoot('package.json');
37
- if (!fs.existsSync(packageJsonPath)) {
38
- return 'unknown';
39
- }
40
- try {
41
- return JSON.parse(fs.readFileSync(packageJsonPath, 'utf8')).version;
42
- }
43
- catch (error) {
44
- return 'unknown';
45
- }
36
+ return PACKAGE_VERSION;
46
37
  }
47
38
  export async function updatePackageJson(packageJson, cwd = process.cwd()) {
48
39
  try {
@@ -251,7 +251,14 @@ function parseOpenApiValue(value) {
251
251
  return null;
252
252
  let cursor = 0;
253
253
  let specPath;
254
- if (tokens[0].toLowerCase().endsWith('.json')) {
254
+ const first = tokens[0];
255
+ const second = tokens[1];
256
+ const methodCandidate = second?.toUpperCase();
257
+ const firstLooksLikeSpec = first.toLowerCase().endsWith('.json') ||
258
+ (second &&
259
+ (second.toLowerCase() === 'webhook' ||
260
+ (methodCandidate && HTTP_METHODS.has(methodCandidate))));
261
+ if (firstLooksLikeSpec) {
255
262
  specPath = tokens[0];
256
263
  cursor = 1;
257
264
  }
@@ -260,9 +267,13 @@ function parseOpenApiValue(value) {
260
267
  const keyword = tokens[cursor];
261
268
  if (keyword.toLowerCase() === 'webhook') {
262
269
  const name = tokens.slice(cursor + 1).join(' ');
270
+ if (!name)
271
+ return null;
263
272
  return { kind: 'webhook', specPath, name };
264
273
  }
265
274
  const method = keyword.toUpperCase();
275
+ if (!HTTP_METHODS.has(method))
276
+ return null;
266
277
  const operationPath = tokens.slice(cursor + 1).join(' ');
267
278
  if (!operationPath)
268
279
  return null;
@@ -300,14 +311,38 @@ function resolveSpec(explicitPath, specs, filePath, configDir, warnings, refDesc
300
311
  if (!specs.length)
301
312
  return null;
302
313
  if (explicitPath) {
303
- const normalizedExplicit = explicitPath.replace(/^\.?\/+/, '');
314
+ const normalizedExplicit = normalizeSlashes(explicitPath.replace(/^\.?\/+/, ''));
304
315
  const candidates = [
305
316
  path.resolve(configDir, normalizedExplicit),
306
317
  path.resolve(path.dirname(filePath), normalizedExplicit),
307
318
  ];
308
- const foundSpec = specs.find((spec) => candidates.some((candidate) => samePath(candidate, spec.absPath)));
319
+ const foundSpec = specs.find((spec) => {
320
+ const normalizedSpecPath = normalizeSlashes(spec.absPath);
321
+ return candidates.some((candidate) => samePath(candidate, normalizedSpecPath));
322
+ });
309
323
  if (foundSpec)
310
324
  return foundSpec;
325
+ const explicitWithoutExt = stripExtension(normalizedExplicit);
326
+ const explicitBase = path.basename(normalizedExplicit);
327
+ const explicitBaseWithoutExt = stripExtension(explicitBase);
328
+ const matches = specs.filter((spec) => {
329
+ const configPath = normalizeSlashes(spec.configPath).replace(/^\.?\/+/, '');
330
+ const configBase = path.basename(configPath);
331
+ const configPathNoExt = stripExtension(configPath);
332
+ const configBaseNoExt = stripExtension(configBase);
333
+ return (configPath === normalizedExplicit ||
334
+ configPathNoExt === explicitWithoutExt ||
335
+ configBase === explicitBase ||
336
+ configBaseNoExt === explicitBaseWithoutExt);
337
+ });
338
+ if (matches.length === 1)
339
+ return matches[0];
340
+ if (matches.length > 1) {
341
+ warnings.add(`OpenAPI reference ${refDescription} in ${filePath} matches multiple specs (${matches
342
+ .map((m) => m.configPath)
343
+ .join(', ')}). Using the first configured match (${matches[0].configPath}).`);
344
+ return matches[0];
345
+ }
311
346
  warnings.add(`OpenAPI reference ${refDescription} in ${filePath} points to an unconfigured spec (${explicitPath}). Skipping localization for this reference.`);
312
347
  return null;
313
348
  }
@@ -325,12 +360,11 @@ function resolveSpec(explicitPath, specs, filePath, configDir, warnings, refDesc
325
360
  if (matches.length === 1)
326
361
  return matches[0];
327
362
  if (matches.length > 1) {
328
- warnings.add(`OpenAPI reference ${refDescription} in ${filePath} is available in multiple specs. Using the first configured file (${matches[0].configPath}).`);
329
- return matches[0];
363
+ warnings.add(`OpenAPI reference ${refDescription} in ${filePath} is available in multiple specs. Skipping localization for this reference.`);
364
+ return null;
330
365
  }
331
- // Not found anywhere, fall back to first configured spec
332
- warnings.add(`OpenAPI reference ${refDescription} in ${filePath} was not found in any configured spec. Using ${specs[0].configPath}.`);
333
- return specs[0];
366
+ warnings.add(`OpenAPI reference ${refDescription} in ${filePath} was not found in any configured spec. Skipping localization for this reference.`);
367
+ return null;
334
368
  }
335
369
  /**
336
370
  * Map a spec to the locale-specific file path when available and normalize it
@@ -377,6 +411,11 @@ function describeOpenApiRef(value) {
377
411
  return `webhook ${value.name}`;
378
412
  return `${value.method.toUpperCase()} ${value.operationPath}`;
379
413
  }
414
+ /** Remove a single trailing file extension while preserving directory segments. */
415
+ function stripExtension(p) {
416
+ const parsed = path.parse(p);
417
+ return normalizeSlashes(path.join(parsed.dir, parsed.name));
418
+ }
380
419
  /** Normalize separators for stable comparisons and output. */
381
420
  function normalizeSlashes(p) {
382
421
  return p.replace(/\\/g, '/');
package/package.json CHANGED
@@ -1,10 +1,11 @@
1
1
  {
2
2
  "name": "gtx-cli",
3
- "version": "2.5.29-alpha.1",
3
+ "version": "2.5.29-bin.1",
4
4
  "main": "dist/index.js",
5
- "bin": "dist/main.js",
5
+ "bin": "dist/bin/bin-main.js",
6
6
  "files": [
7
7
  "dist",
8
+ "binaries",
8
9
  "CHANGELOG.md"
9
10
  ],
10
11
  "type": "module",
@@ -110,11 +111,6 @@
110
111
  "devDependencies": {
111
112
  "@babel/types": "^7.28.4",
112
113
  "@biomejs/biome": "^1.9.4",
113
- "@rollup/plugin-commonjs": "^29.0.0",
114
- "@rollup/plugin-json": "^6.1.0",
115
- "@rollup/plugin-node-resolve": "^16.0.3",
116
- "@rollup/plugin-terser": "^0.4.4",
117
- "@rollup/plugin-typescript": "^12.3.0",
118
114
  "@types/babel__generator": "^7.27.0",
119
115
  "@types/babel__traverse": "^7.20.6",
120
116
  "@types/figlet": "^1.7.0",
@@ -129,22 +125,33 @@
129
125
  "mdast-util-mdx-jsx": "^3.2.0",
130
126
  "mdast-util-mdxjs-esm": "^2.0.1",
131
127
  "prettier": "^3.4.2",
132
- "rollup": "^4.53.3",
133
128
  "ts-node": "^10.9.2",
134
129
  "tslib": "^2.8.1",
135
130
  "typescript": "^5.5.4"
136
131
  },
137
132
  "scripts": {
138
- "build": "tsc && rollup -c",
139
- "build:clean": "sh ../../scripts/clean.sh && pnpm run build",
133
+ "build": "node scripts/generate-version.js && tsc",
134
+ "build:clean": "sh ../../scripts/clean.sh && pnpm restore-bin-release && rm -rf binaries && pnpm run build",
140
135
  "build:release": "pnpm run build:clean",
136
+ "build:bin": "node scripts/generate-version.js && tsc && sh scripts/build-exe.sh all",
137
+ "build:bin:clean": "sh ../../scripts/clean.sh && rm -rf binaries && pnpm run build:bin",
138
+ "build:bin:release": "pnpm run build:bin:clean && pnpm run build:bin",
139
+ "build:bin:darwin-x64": "sh scripts/build-exe.sh darwin-x64",
140
+ "build:bin:darwin-arm64": "sh scripts/build-exe.sh darwin-arm64",
141
+ "build:bin:linux-x64": "sh scripts/build-exe.sh linux-x64",
142
+ "build:bin:linux-arm64": "sh scripts/build-exe.sh linux-arm64",
143
+ "build:bin:windows-x64": "sh scripts/build-exe.sh windows-x64",
141
144
  "lint": "eslint \"src/**/*.{js,ts}\" \"./**/__tests__/**/*.{js,ts}\"",
142
145
  "lint:fix": "eslint \"src/**/*.{js,ts}\" \"./**/__tests__/**/*.{js,ts}\" --fix",
143
146
  "test": "vitest run --config=./vitest.config.ts",
144
147
  "test:watch": "vitest --config=./vitest.config.ts",
145
- "release": "pnpm run build:clean && pnpm publish",
148
+ "release": "pnpm run release:normal && pnpm run release:bin",
149
+ "release:normal": "pnpm run build:clean && pnpm publish",
150
+ "release:bin": "pnpm run prep-bin-release && pnpm run build:bin:clean && pnpm publish --tag bin --no-git-checks && pnpm run restore-bin-release && pnpm run build:clean",
146
151
  "release:alpha": "pnpm run build:clean && pnpm publish --tag alpha",
147
152
  "release:beta": "pnpm run build:clean && pnpm publish --tag beta",
148
- "release:latest": "pnpm run build:clean && pnpm publish --tag latest"
153
+ "release:latest": "pnpm run build:clean && pnpm publish --tag latest",
154
+ "prep-bin-release": "node scripts/prepare-binary-release.js",
155
+ "restore-bin-release": "node scripts/restore-package-json.js"
149
156
  }
150
157
  }
@@ -1 +0,0 @@
1
- export declare function fromPackageRoot(relative: string): string;
@@ -1,6 +0,0 @@
1
- import path from 'node:path';
2
- import { fileURLToPath } from 'node:url';
3
- const __dirname = path.dirname(fileURLToPath(import.meta.url));
4
- export function fromPackageRoot(relative) {
5
- return path.resolve(__dirname, `../../`, relative);
6
- }