gtx-cli 1.1.0 → 1.1.2

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/README.md CHANGED
@@ -18,6 +18,42 @@ npm install gtx-cli
18
18
 
19
19
  ## Usage
20
20
 
21
+ ### Set up
22
+
23
+ For more details, check out the [setup command documentation](https://generaltranslation.com/docs/cli/setup).
24
+
25
+ If you are using gt-react or gt-next, run this command to automatically insert `<T>` components into your project.
26
+
27
+ ```bash
28
+ npx gtx-cli setup
29
+ ```
30
+
31
+ ### Init
32
+
33
+ For more details, check out the [init command documentation](https://generaltranslation.com/docs/cli/init).
34
+
35
+ This command sets up your `gt.config.json` file.
36
+ You will need to run this command in order to run the translate command.
37
+
38
+ ```bash
39
+ npx gtx-cli init
40
+ ```
41
+
42
+ ### Translation
43
+
44
+ For more details, check out the [translate command documentation](https://generaltranslation.com/docs/cli/translate).
45
+
46
+ Before deploying to production, you need to generate translations.
47
+ First, add your [production api keys](https://generaltranslation.com/dashboard):
48
+
49
+ ```bash
50
+ GT_API_KEY=your-production-api-key
51
+ GT_PROJECT_ID=your-project-id
52
+ ```
53
+
54
+ Next run the translate command.
55
+ This will generate translations and either publish them to the CDN or save them in your project depending on your configuration.
56
+
21
57
  ```bash
22
58
  npx gtx-cli translate
23
59
  ```
@@ -11,6 +11,6 @@
11
11
  export declare function checkFileTranslations(apiKey: string, baseUrl: string, data: {
12
12
  [key: string]: {
13
13
  versionId: string;
14
- canonicalName: string;
14
+ fileName: string;
15
15
  };
16
16
  }, locales: string[], timeoutDuration: number, resolveOutputPath: (sourcePath: string, locale: string) => string): Promise<boolean>;
@@ -38,7 +38,7 @@ function checkFileTranslations(apiKey, baseUrl, data, locales, timeoutDuration,
38
38
  for (const locale of locales) {
39
39
  fileQueryData.push({
40
40
  versionId: data[file].versionId,
41
- fileName: data[file].canonicalName,
41
+ fileName: data[file].fileName,
42
42
  locale,
43
43
  });
44
44
  }
@@ -62,13 +62,14 @@ function checkFileTranslations(apiKey, baseUrl, data, locales, timeoutDuration,
62
62
  // Process available translations
63
63
  for (const translation of translations) {
64
64
  const locale = translation.locale;
65
- const fileName = data[translation.fileName].canonicalName;
65
+ const fileName = translation.fileName;
66
+ const translationId = translation.id;
66
67
  if (translation.isReady && fileName) {
67
68
  // Mark this file+locale as downloaded
68
69
  downloadedFiles.add(`${fileName}:${locale}`);
69
70
  // Download the file
70
71
  const outputPath = resolveOutputPath(fileName, locale);
71
- yield (0, downloadFile_1.downloadFile)(baseUrl, apiKey, translation.fileId, outputPath);
72
+ yield (0, downloadFile_1.downloadFile)(baseUrl, apiKey, translationId, outputPath);
72
73
  }
73
74
  }
74
75
  // Update the spinner text
@@ -1 +1 @@
1
- export declare function downloadFile(baseUrl: string, apiKey: string, fileId: string, outputPath: string): Promise<boolean>;
1
+ export declare function downloadFile(baseUrl: string, apiKey: string, translationId: string, outputPath: string): Promise<boolean>;
@@ -46,10 +46,10 @@ exports.downloadFile = downloadFile;
46
46
  const fs = __importStar(require("fs"));
47
47
  const path = __importStar(require("path"));
48
48
  // Helper function to download a file
49
- function downloadFile(baseUrl, apiKey, fileId, outputPath) {
49
+ function downloadFile(baseUrl, apiKey, translationId, outputPath) {
50
50
  return __awaiter(this, void 0, void 0, function* () {
51
51
  try {
52
- const downloadResponse = yield fetch(`${baseUrl}/v1/project/translations/files/${fileId}/download`, {
52
+ const downloadResponse = yield fetch(`${baseUrl}/v1/project/translations/files/${translationId}/download`, {
53
53
  method: 'GET',
54
54
  headers: Object.assign({}, (apiKey && { 'x-gt-api-key': apiKey })),
55
55
  });
package/dist/cli/base.js CHANGED
@@ -257,7 +257,7 @@ class BaseCLI {
257
257
  else {
258
258
  const translationsDirWithFormat = path_1.default.join(translationsDir, `[locale].json`);
259
259
  // Create gt.config.json
260
- (0, setupConfig_1.default)(configFilepath, {
260
+ (0, setupConfig_1.default)('gt.config.json', {
261
261
  defaultLocale,
262
262
  locales: locales.split(' '),
263
263
  files: {
package/dist/cli/react.js CHANGED
@@ -376,15 +376,16 @@ class ReactCLI extends base_1.BaseCLI {
376
376
  (0, console_1.displayInitializingText)();
377
377
  const settings = (0, generateSettings_1.generateSettings)(initOptions);
378
378
  // First run the base class's handleTranslate method
379
- try {
380
- yield _super.handleGenericTranslate.call(this, settings);
381
- // If the base class's handleTranslate completes successfully, continue with ReactCLI-specific code
382
- }
383
- catch (error) {
384
- // Continue with ReactCLI-specific code even if base handleTranslate failed
385
- }
386
- // only for typing purposes
387
379
  const options = Object.assign(Object.assign({}, initOptions), settings);
380
+ if (!options.dryRun) {
381
+ try {
382
+ yield _super.handleGenericTranslate.call(this, settings);
383
+ // If the base class's handleTranslate completes successfully, continue with ReactCLI-specific code
384
+ }
385
+ catch (error) {
386
+ // Continue with ReactCLI-specific code even if base handleTranslate failed
387
+ }
388
+ }
388
389
  if (!options.dictionary) {
389
390
  options.dictionary = (0, findFilepath_1.default)([
390
391
  './dictionary.js',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gtx-cli",
3
- "version": "1.1.0",
3
+ "version": "1.1.2",
4
4
  "main": "dist/index.js",
5
5
  "bin": "dist/main.js",
6
6
  "scripts": {