gtx-cli 2.5.30-alpha.8 → 2.5.30

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,11 @@
1
1
  # gtx-cli
2
2
 
3
+ ## 2.5.30
4
+
5
+ ### Patch Changes
6
+
7
+ - [#896](https://github.com/generaltranslation/gt/pull/896) [`443ee73`](https://github.com/generaltranslation/gt/commit/443ee73395a514eec448b03810cb871062bf5b2a) Thanks [@brian-lou](https://github.com/brian-lou)! - Fix dry-run error conditions
8
+
3
9
  ## 2.5.29
4
10
 
5
11
  ### Patch Changes
@@ -4,14 +4,14 @@ import { noLocalesError, noDefaultLocaleError, noApiKeyError, noProjectIdError,
4
4
  import { collectFiles } from '../../formats/files/collectFiles.js';
5
5
  import { setupProject } from '../../workflow/setupProject.js';
6
6
  export async function handleSetupProject(options, settings, library) {
7
+ if (!settings.locales) {
8
+ return logErrorAndExit(noLocalesError);
9
+ }
10
+ if (!settings.defaultLocale) {
11
+ return logErrorAndExit(noDefaultLocaleError);
12
+ }
7
13
  // Validate required settings are present if not in dry run
8
14
  if (!options.dryRun) {
9
- if (!settings.locales) {
10
- return logErrorAndExit(noLocalesError);
11
- }
12
- if (!settings.defaultLocale) {
13
- return logErrorAndExit(noDefaultLocaleError);
14
- }
15
15
  if (!settings.apiKey) {
16
16
  return logErrorAndExit(noApiKeyError);
17
17
  }
@@ -7,14 +7,14 @@ import updateConfig from '../../fs/config/updateConfig.js';
7
7
  import { TEMPLATE_FILE_ID } from '../../utils/constants.js';
8
8
  import { collectFiles } from '../../formats/files/collectFiles.js';
9
9
  export async function handleStage(options, settings, library, stage) {
10
+ if (!settings.locales) {
11
+ return logErrorAndExit(noLocalesError);
12
+ }
13
+ if (!settings.defaultLocale) {
14
+ return logErrorAndExit(noDefaultLocaleError);
15
+ }
10
16
  // Validate required settings are present if not in dry run
11
17
  if (!options.dryRun) {
12
- if (!settings.locales) {
13
- return logErrorAndExit(noLocalesError);
14
- }
15
- if (!settings.defaultLocale) {
16
- return logErrorAndExit(noDefaultLocaleError);
17
- }
18
18
  if (!settings.apiKey) {
19
19
  return logErrorAndExit(noApiKeyError);
20
20
  }
@@ -12,9 +12,7 @@ export async function collectFiles(options, settings, library) {
12
12
  if (library === 'gt-react' || library === 'gt-next') {
13
13
  const updates = await aggregateReactTranslations(options, settings, library);
14
14
  if (updates.length > 0) {
15
- if (!options.dryRun &&
16
- !settings.publish &&
17
- !settings.files?.placeholderPaths.gt) {
15
+ if (!settings.publish && !settings.files?.placeholderPaths.gt) {
18
16
  logErrorAndExit(invalidConfigurationError);
19
17
  }
20
18
  // Convert updates to a file object
@@ -1,2 +1 @@
1
1
  export declare function fromPackageRoot(relative: string): string;
2
- export declare function fromBinariesRoot(relative: string): string;
@@ -2,10 +2,5 @@ import path from 'node:path';
2
2
  import { fileURLToPath } from 'node:url';
3
3
  const __dirname = path.dirname(fileURLToPath(import.meta.url));
4
4
  export function fromPackageRoot(relative) {
5
- console.log('fromPackageRoot __dirname' + __dirname);
6
5
  return path.resolve(__dirname, `../../`, relative);
7
6
  }
8
- export function fromBinariesRoot(relative) {
9
- console.log('fromBinariesRoot __dirname' + __dirname);
10
- return path.resolve(__dirname, `../`, relative);
11
- }
package/dist/main.d.ts CHANGED
@@ -1 +1,2 @@
1
+ #!/usr/bin/env node
1
2
  export {};
package/dist/main.js CHANGED
@@ -1,3 +1,4 @@
1
+ #!/usr/bin/env node
1
2
  import { main } from './index.js';
2
3
  import dotenv from 'dotenv';
3
4
  import { program } from 'commander';
@@ -2,7 +2,7 @@ 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 { fromBinariesRoot, fromPackageRoot } from '../fs/getPackageResource.js';
5
+ import { fromPackageRoot } from '../fs/getPackageResource.js';
6
6
  import { exitSync } from '../console/logging.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()) {
@@ -33,22 +33,14 @@ export async function getPackageJson(cwd = process.cwd()) {
33
33
  }
34
34
  }
35
35
  export function getCLIVersion() {
36
- console.log('getCLIVersion');
37
- let packageJsonPath = fromPackageRoot('package.json');
36
+ const packageJsonPath = fromPackageRoot('package.json');
38
37
  if (!fs.existsSync(packageJsonPath)) {
39
- // Try binaries behavior instead
40
- packageJsonPath = fromBinariesRoot('package.json');
41
- if (!fs.existsSync(packageJsonPath)) {
42
- return 'unknown';
43
- }
38
+ return 'unknown';
44
39
  }
45
40
  try {
46
- const result = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8')).version;
47
- console.log('CLI version: ' + result);
48
- return result;
41
+ return JSON.parse(fs.readFileSync(packageJsonPath, 'utf8')).version;
49
42
  }
50
43
  catch (error) {
51
- console.log(chalk.red('Error getting CLI version: ' + String(error)));
52
44
  return 'unknown';
53
45
  }
54
46
  }
package/package.json CHANGED
@@ -1,11 +1,10 @@
1
1
  {
2
2
  "name": "gtx-cli",
3
- "version": "2.5.30-alpha.8",
3
+ "version": "2.5.30",
4
4
  "main": "dist/index.js",
5
- "bin": "dist/router.js",
5
+ "bin": "dist/main.js",
6
6
  "files": [
7
7
  "dist",
8
- "binaries",
9
8
  "CHANGELOG.md"
10
9
  ],
11
10
  "type": "module",
@@ -130,15 +129,9 @@
130
129
  "typescript": "^5.5.4"
131
130
  },
132
131
  "scripts": {
133
- "build": "tsc && pnpm run build:exe",
134
- "build:clean": "sh ../../scripts/clean.sh && rm -rf binaries && pnpm run build",
132
+ "build": "tsc",
133
+ "build:clean": "sh ../../scripts/clean.sh && pnpm run build",
135
134
  "build:release": "pnpm run build:clean",
136
- "build:exe": "sh scripts/build-exe.sh all",
137
- "build:exe:darwin-x64": "sh scripts/build-exe.sh darwin-x64",
138
- "build:exe:darwin-arm64": "sh scripts/build-exe.sh darwin-arm64",
139
- "build:exe:linux-x64": "sh scripts/build-exe.sh linux-x64",
140
- "build:exe:linux-arm64": "sh scripts/build-exe.sh linux-arm64",
141
- "build:exe:windows-x64": "sh scripts/build-exe.sh windows-x64",
142
135
  "lint": "eslint \"src/**/*.{js,ts}\" \"./**/__tests__/**/*.{js,ts}\"",
143
136
  "lint:fix": "eslint \"src/**/*.{js,ts}\" \"./**/__tests__/**/*.{js,ts}\" --fix",
144
137
  "test": "vitest run --config=./vitest.config.ts",
@@ -146,7 +139,6 @@
146
139
  "release": "pnpm run build:clean && pnpm publish",
147
140
  "release:alpha": "pnpm run build:clean && pnpm publish --tag alpha",
148
141
  "release:beta": "pnpm run build:clean && pnpm publish --tag beta",
149
- "release:bin": "pnpm run build:clean && pnpm publish --tag bin",
150
142
  "release:latest": "pnpm run build:clean && pnpm publish --tag latest"
151
143
  }
152
144
  }
Binary file
Binary file
Binary file
Binary file
Binary file
package/dist/router.d.ts DELETED
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- export {};
package/dist/router.js DELETED
@@ -1,64 +0,0 @@
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
- return;
32
- }
33
- const binaryPath = join(__dirname, '..', 'binaries', binaryName);
34
- if (!existsSync(binaryPath)) {
35
- return;
36
- }
37
- // Check and fix execute permissions if needed (Unix-like systems only)
38
- if (process.platform !== 'win32') {
39
- try {
40
- const stats = statSync(binaryPath);
41
- const isExecutable = !!(stats.mode & parseInt('100', 8)); // Check owner execute bit
42
- if (!isExecutable) {
43
- chmodSync(binaryPath, 0o755); // Make executable
44
- }
45
- }
46
- catch (error) {
47
- // If we can't check/fix permissions, continue anyway
48
- // The spawn might still work or give a more meaningful error
49
- }
50
- }
51
- // Spawn the appropriate binary with all arguments
52
- const child = spawn(binaryPath, process.argv.slice(2), {
53
- stdio: 'inherit',
54
- });
55
- child.on('close', (code) => {
56
- process.exit(code);
57
- });
58
- child.on('error', () => {
59
- process.exit(1);
60
- });
61
- return;
62
- }
63
- // Entry point
64
- routeToBinary();