gtx-cli 2.5.30-alpha.9 → 2.5.31

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.31
4
+
5
+ ### Patch Changes
6
+
7
+ - [#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
8
+
9
+ ## 2.5.30
10
+
11
+ ### Patch Changes
12
+
13
+ - [#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
14
+
3
15
  ## 2.5.29
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();
@@ -28,11 +28,13 @@ function detectPlatform() {
28
28
  function routeToBinary() {
29
29
  const binaryName = detectPlatform();
30
30
  if (!binaryName) {
31
- return;
31
+ console.error(`Unsupported platform: ${process.platform}-${process.arch}`);
32
+ process.exit(1);
32
33
  }
33
- const binaryPath = join(__dirname, '..', 'binaries', binaryName);
34
+ const binaryPath = join(__dirname, '..', '..', 'binaries', binaryName);
34
35
  if (!existsSync(binaryPath)) {
35
- return;
36
+ console.error(`Binary not found at: ${binaryPath}`);
37
+ process.exit(1);
36
38
  }
37
39
  // Check and fix execute permissions if needed (Unix-like systems only)
38
40
  if (process.platform !== 'win32') {
@@ -53,7 +55,8 @@ function routeToBinary() {
53
55
  stdio: 'inherit',
54
56
  });
55
57
  child.on('close', (code) => {
56
- process.exit(code);
58
+ // code might be null
59
+ process.exit(code ?? 1);
57
60
  });
58
61
  child.on('error', () => {
59
62
  process.exit(1);
@@ -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
@@ -0,0 +1 @@
1
+ export declare const PACKAGE_VERSION = "2.5.31";
@@ -0,0 +1,2 @@
1
+ // This file is auto-generated. Do not edit manually.
2
+ export const PACKAGE_VERSION = '2.5.31';
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.d.ts CHANGED
@@ -1 +1,2 @@
1
+ #!/usr/bin/env node
1
2
  export {};
package/dist/main.js CHANGED
@@ -1,3 +1,5 @@
1
+ #!/usr/bin/env node
2
+ // Non-binary router - directly runs main.ts
1
3
  import { main } from './index.js';
2
4
  import dotenv from 'dotenv';
3
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 { fromBinariesRoot, 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,25 +33,7 @@ export async function getPackageJson(cwd = process.cwd()) {
33
33
  }
34
34
  }
35
35
  export function getCLIVersion() {
36
- console.log('getCLIVersion');
37
- logger.error('getCLIVersion -- logger');
38
- let packageJsonPath = fromPackageRoot('package.json');
39
- if (!fs.existsSync(packageJsonPath)) {
40
- // Try binaries behavior instead
41
- packageJsonPath = fromBinariesRoot('package.json');
42
- if (!fs.existsSync(packageJsonPath)) {
43
- return 'unknown';
44
- }
45
- }
46
- try {
47
- const result = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8')).version;
48
- console.log('CLI version: ' + result);
49
- return result;
50
- }
51
- catch (error) {
52
- console.log(chalk.red('Error getting CLI version: ' + String(error)));
53
- return 'unknown';
54
- }
36
+ return PACKAGE_VERSION;
55
37
  }
56
38
  export async function updatePackageJson(packageJson, cwd = process.cwd()) {
57
39
  try {
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "gtx-cli",
3
- "version": "2.5.30-alpha.9",
3
+ "version": "2.5.31",
4
4
  "main": "dist/index.js",
5
- "bin": "dist/router.js",
5
+ "bin": "dist/main.js",
6
6
  "files": [
7
7
  "dist",
8
8
  "binaries",
@@ -130,23 +130,28 @@
130
130
  "typescript": "^5.5.4"
131
131
  },
132
132
  "scripts": {
133
- "build": "tsc && pnpm run build:exe",
134
- "build:clean": "sh ../../scripts/clean.sh && rm -rf binaries && 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",
135
135
  "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",
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",
142
144
  "lint": "eslint \"src/**/*.{js,ts}\" \"./**/__tests__/**/*.{js,ts}\"",
143
145
  "lint:fix": "eslint \"src/**/*.{js,ts}\" \"./**/__tests__/**/*.{js,ts}\" --fix",
144
146
  "test": "vitest run --config=./vitest.config.ts",
145
147
  "test:watch": "vitest --config=./vitest.config.ts",
146
- "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",
147
151
  "release:alpha": "pnpm run build:clean && pnpm publish --tag alpha",
148
152
  "release:beta": "pnpm run build:clean && pnpm publish --tag beta",
149
- "release:bin": "pnpm run build:clean && pnpm publish --tag bin",
150
- "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"
151
156
  }
152
157
  }
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -1,2 +0,0 @@
1
- export declare function fromPackageRoot(relative: string): string;
2
- export declare function fromBinariesRoot(relative: string): string;
@@ -1,11 +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
- console.log('fromPackageRoot __dirname' + __dirname);
6
- return path.resolve(__dirname, `../../`, relative);
7
- }
8
- export function fromBinariesRoot(relative) {
9
- console.log('fromBinariesRoot __dirname' + __dirname);
10
- return path.resolve(__dirname, `../`, relative);
11
- }
File without changes