gtx-cli 2.5.30 → 2.5.32

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/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # gtx-cli
2
2
 
3
+ ## 2.5.32
4
+
5
+ ### Patch Changes
6
+
7
+ - [#899](https://github.com/generaltranslation/gt/pull/899) [`94edf07`](https://github.com/generaltranslation/gt/commit/94edf07fb5a05130da967ffb1e76577667e9dff0) Thanks [@ErnestM1234](https://github.com/ErnestM1234)! - fix: bin release
8
+
9
+ ## 2.5.31
10
+
11
+ ### Patch Changes
12
+
13
+ - [#895](https://github.com/generaltranslation/gt/pull/895) [`a64277c`](https://github.com/generaltranslation/gt/commit/a64277cd1d633899f4ac0977b389ccfa00660512) Thanks [@ErnestM1234](https://github.com/ErnestM1234)! - fix: support for cli execution independent of package resolution
14
+
3
15
  ## 2.5.30
4
16
 
5
17
  ### Patch Changes
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,9 @@
1
+ // Entry point for binaries
2
+ import { main } from '../index.js';
3
+ import dotenv from 'dotenv';
4
+ import { program } from 'commander';
5
+ dotenv.config({ path: '.env' });
6
+ dotenv.config({ path: '.env.local', override: true });
7
+ dotenv.config({ path: '.env.production', override: true });
8
+ main(program);
9
+ program.parse();
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
@@ -0,0 +1,67 @@
1
+ #!/usr/bin/env node
2
+ // Routes to proper binary based on platform
3
+ import { spawn } from 'child_process';
4
+ import { fileURLToPath } from 'url';
5
+ import { dirname, join } from 'path';
6
+ import { existsSync, chmodSync, statSync } from 'fs';
7
+ const __filename = fileURLToPath(import.meta.url);
8
+ const __dirname = dirname(__filename);
9
+ function detectPlatform() {
10
+ const platform = process.platform;
11
+ const arch = process.arch;
12
+ // Map Node.js platform/arch to our binary names
13
+ const platformMap = {
14
+ darwin: {
15
+ x64: 'gtx-cli-darwin-x64',
16
+ arm64: 'gtx-cli-darwin-arm64',
17
+ },
18
+ linux: {
19
+ x64: 'gtx-cli-linux-x64',
20
+ arm64: 'gtx-cli-linux-arm64',
21
+ },
22
+ win32: {
23
+ x64: 'gtx-cli-win32-x64.exe',
24
+ },
25
+ };
26
+ return platformMap[platform]?.[arch] || null;
27
+ }
28
+ function routeToBinary() {
29
+ const binaryName = detectPlatform();
30
+ if (!binaryName) {
31
+ console.error(`Unsupported platform: ${process.platform}-${process.arch}`);
32
+ process.exit(1);
33
+ }
34
+ const binaryPath = join(__dirname, '..', '..', 'binaries', binaryName);
35
+ if (!existsSync(binaryPath)) {
36
+ console.error(`Binary not found at: ${binaryPath}`);
37
+ process.exit(1);
38
+ }
39
+ // Check and fix execute permissions if needed (Unix-like systems only)
40
+ if (process.platform !== 'win32') {
41
+ try {
42
+ const stats = statSync(binaryPath);
43
+ const isExecutable = !!(stats.mode & parseInt('100', 8)); // Check owner execute bit
44
+ if (!isExecutable) {
45
+ chmodSync(binaryPath, 0o755); // Make executable
46
+ }
47
+ }
48
+ catch (error) {
49
+ // If we can't check/fix permissions, continue anyway
50
+ // The spawn might still work or give a more meaningful error
51
+ }
52
+ }
53
+ // Spawn the appropriate binary with all arguments
54
+ const child = spawn(binaryPath, process.argv.slice(2), {
55
+ stdio: 'inherit',
56
+ });
57
+ child.on('close', (code) => {
58
+ // code might be null
59
+ process.exit(code ?? 1);
60
+ });
61
+ child.on('error', () => {
62
+ process.exit(1);
63
+ });
64
+ return;
65
+ }
66
+ // Entry point
67
+ routeToBinary();
@@ -0,0 +1 @@
1
+ export declare const PACKAGE_VERSION = "2.5.32";
@@ -0,0 +1,2 @@
1
+ // This file is auto-generated. Do not edit manually.
2
+ export const PACKAGE_VERSION = '2.5.32';
package/dist/index.js CHANGED
@@ -3,6 +3,7 @@ import { NextCLI } from './cli/next.js';
3
3
  import { ReactCLI } from './cli/react.js';
4
4
  import { determineLibrary } from './fs/determineFramework.js';
5
5
  export function main(program) {
6
+ program.name('gtx-cli');
6
7
  const { library, additionalModules } = determineLibrary();
7
8
  let cli;
8
9
  if (library === 'gt-next') {
package/dist/main.js CHANGED
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env node
2
+ // Non-binary router - directly runs main.ts
2
3
  import { main } from './index.js';
3
4
  import dotenv from 'dotenv';
4
5
  import { program } from 'commander';
@@ -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 {
package/package.json CHANGED
@@ -1,10 +1,11 @@
1
1
  {
2
2
  "name": "gtx-cli",
3
- "version": "2.5.30",
3
+ "version": "2.5.32",
4
4
  "main": "dist/index.js",
5
5
  "bin": "dist/main.js",
6
6
  "files": [
7
7
  "dist",
8
+ "binaries",
8
9
  "CHANGELOG.md"
9
10
  ],
10
11
  "type": "module",
@@ -129,16 +130,28 @@
129
130
  "typescript": "^5.5.4"
130
131
  },
131
132
  "scripts": {
132
- "build": "tsc",
133
- "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 bin:restore && rm -rf binaries && pnpm run build",
134
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",
135
144
  "lint": "eslint \"src/**/*.{js,ts}\" \"./**/__tests__/**/*.{js,ts}\"",
136
145
  "lint:fix": "eslint \"src/**/*.{js,ts}\" \"./**/__tests__/**/*.{js,ts}\" --fix",
137
146
  "test": "vitest run --config=./vitest.config.ts",
138
147
  "test:watch": "vitest --config=./vitest.config.ts",
139
- "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 bin:prep && pnpm run build:bin:clean && pnpm publish --tag bin --no-git-checks && pnpm run bin:restore && pnpm run build:clean",
140
151
  "release:alpha": "pnpm run build:clean && pnpm publish --tag alpha",
141
152
  "release:beta": "pnpm run build:clean && pnpm publish --tag beta",
142
- "release:latest": "pnpm run build:clean && pnpm publish --tag latest"
153
+ "release:latest": "pnpm run build:clean && pnpm publish --tag latest",
154
+ "bin:restore": "node scripts/restore-package-json.js",
155
+ "bin:prep": "node scripts/prepare-binary-release.js"
143
156
  }
144
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
- }