gtx-cli 1.2.23 → 1.2.24-alpha.0

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.
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.checkFileTranslations = checkFileTranslations;
7
7
  const chalk_1 = __importDefault(require("chalk"));
8
8
  const console_1 = require("../console");
9
- const generaltranslation_1 = require("generaltranslation");
9
+ const generaltranslation_1 = __importDefault(require("generaltranslation"));
10
10
  const downloadFile_1 = require("./downloadFile");
11
11
  const downloadFileBatch_1 = require("./downloadFileBatch");
12
12
  /**
@@ -132,21 +132,21 @@ function generateStatusSuffixText(downloadStatus, fileQueryData) {
132
132
  // Add completed locales
133
133
  if (status.completed.size > 0) {
134
134
  const completedCodes = Array.from(status.completed)
135
- .map((locale) => (0, generaltranslation_1.getLocaleProperties)(locale).code)
135
+ .map((locale) => generaltranslation_1.default.getLocaleProperties(locale).code)
136
136
  .join(', ');
137
137
  localeStatuses.push(chalk_1.default.green(`${completedCodes}`));
138
138
  }
139
139
  // Add failed locales
140
140
  if (status.failed.size > 0) {
141
141
  const failedCodes = Array.from(status.failed)
142
- .map((locale) => (0, generaltranslation_1.getLocaleProperties)(locale).code)
142
+ .map((locale) => generaltranslation_1.default.getLocaleProperties(locale).code)
143
143
  .join(', ');
144
144
  localeStatuses.push(chalk_1.default.red(`${failedCodes}`));
145
145
  }
146
146
  // Add pending locales
147
147
  if (status.pending.size > 0) {
148
148
  const pendingCodes = Array.from(status.pending)
149
- .map((locale) => (0, generaltranslation_1.getLocaleProperties)(locale).code)
149
+ .map((locale) => generaltranslation_1.default.getLocaleProperties(locale).code)
150
150
  .join(', ');
151
151
  localeStatuses.push(chalk_1.default.yellow(`${pendingCodes}`));
152
152
  }
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.waitForUpdates = void 0;
7
7
  const chalk_1 = __importDefault(require("chalk"));
8
8
  const console_1 = require("../console");
9
- const generaltranslation_1 = require("generaltranslation");
9
+ const generaltranslation_1 = __importDefault(require("generaltranslation"));
10
10
  /**
11
11
  * Waits for translations to be deployed to the General Translation API
12
12
  * @param apiKey - The API key for the General Translation API
@@ -47,7 +47,7 @@ const waitForUpdates = async (apiKey, baseUrl, versionId, startTime, timeoutDura
47
47
  chalk_1.default.green(`[${availableLocales.length}/${locales.length}]`) +
48
48
  ` translations completed`,
49
49
  ...availableLocales.map((locale) => {
50
- const localeProperties = (0, generaltranslation_1.getLocaleProperties)(locale);
50
+ const localeProperties = generaltranslation_1.default.getLocaleProperties(locale);
51
51
  return `Translation completed for ${chalk_1.default.green(localeProperties.name)} (${chalk_1.default.green(localeProperties.code)})`;
52
52
  }),
53
53
  ];
@@ -1,23 +1,26 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.validateSettings = validateSettings;
4
- const generaltranslation_1 = require("generaltranslation");
7
+ const generaltranslation_1 = __importDefault(require("generaltranslation"));
5
8
  const console_1 = require("../console");
6
9
  function validateSettings(settings) {
7
10
  // Validate locales
8
11
  for (const locale of settings.locales) {
9
- if (!(0, generaltranslation_1.isValidLocale)(locale)) {
12
+ if (!generaltranslation_1.default.isValidLocale(locale)) {
10
13
  (0, console_1.logErrorAndExit)(`Provided locales: "${settings?.locales?.join()}", ${locale} is not a valid locale!`);
11
14
  }
12
15
  }
13
- if (settings.defaultLocale && !(0, generaltranslation_1.isValidLocale)(settings.defaultLocale)) {
16
+ if (settings.defaultLocale && !generaltranslation_1.default.isValidLocale(settings.defaultLocale)) {
14
17
  (0, console_1.logErrorAndExit)(`defaultLocale: ${settings.defaultLocale} is not a valid locale!`);
15
18
  }
16
19
  // defaultLocale cannot be a superset of any other locale
17
20
  if (settings.defaultLocale &&
18
- settings.locales.some((locale) => (0, generaltranslation_1.isSupersetLocale)(settings.defaultLocale, locale) &&
19
- !(0, generaltranslation_1.isSupersetLocale)(locale, settings.defaultLocale))) {
20
- const locale = settings.locales.find((locale) => (0, generaltranslation_1.isSupersetLocale)(settings.defaultLocale, locale));
21
+ settings.locales.some((locale) => generaltranslation_1.default.isSupersetLocale(settings.defaultLocale, locale) &&
22
+ !generaltranslation_1.default.isSupersetLocale(locale, settings.defaultLocale))) {
23
+ const locale = settings.locales.find((locale) => generaltranslation_1.default.isSupersetLocale(settings.defaultLocale, locale));
21
24
  (0, console_1.logErrorAndExit)(`defaultLocale: ${settings.defaultLocale} is a superset of another locale (${locale})! Please change the defaultLocale to a more specific locale.`);
22
25
  }
23
26
  }
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.parseNextConfig = parseNextConfig;
7
7
  const node_fs_1 = __importDefault(require("node:fs"));
8
- const generaltranslation_1 = require("generaltranslation");
8
+ const generaltranslation_1 = __importDefault(require("generaltranslation"));
9
9
  const node_path_1 = __importDefault(require("node:path"));
10
10
  /**
11
11
  * Extracts projectId, defaultLocale, and locales from a next.config.js file.
@@ -42,7 +42,7 @@ async function parseNextConfig(filePath) {
42
42
  .filter((locale) => typeof locale === 'string')
43
43
  : undefined;
44
44
  // Ensure approvedLocales is an array of strings
45
- const validLocales = locales && locales.every((locale) => (0, generaltranslation_1.isValidLocale)(locale))
45
+ const validLocales = locales && locales.every((locale) => generaltranslation_1.default.isValidLocale(locale))
46
46
  ? locales
47
47
  : undefined;
48
48
  // Return the extracted values if they pass type checks or return null
@@ -38,7 +38,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
39
  exports.attributes = void 0;
40
40
  exports.parseStrings = parseStrings;
41
- const generaltranslation_1 = require("generaltranslation");
42
41
  const t = __importStar(require("@babel/types"));
43
42
  const evaluateJsx_1 = require("../evaluateJsx");
44
43
  const console_1 = require("../../../console");
@@ -77,8 +76,6 @@ function parseStrings(importName, path, updates, errors, file) {
77
76
  const source = arg.type === 'StringLiteral'
78
77
  ? arg.value
79
78
  : arg.quasis[0].value.raw;
80
- // split the string into content (same as runtime behavior)
81
- const content = (0, generaltranslation_1.splitStringToContent)(source);
82
79
  // get metadata and id from options
83
80
  const options = tPath.parent.arguments[1];
84
81
  const metadata = {};
@@ -102,7 +99,7 @@ function parseStrings(importName, path, updates, errors, file) {
102
99
  }
103
100
  updates.push({
104
101
  dataFormat: 'JSX',
105
- source: content,
102
+ source,
106
103
  metadata,
107
104
  });
108
105
  }
@@ -38,7 +38,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
39
  exports.attributes = void 0;
40
40
  exports.parseStrings = parseStrings;
41
- const generaltranslation_1 = require("generaltranslation");
42
41
  const t = __importStar(require("@babel/types"));
43
42
  const evaluateJsx_1 = require("../evaluateJsx");
44
43
  const console_1 = require("../../../console");
@@ -67,8 +66,6 @@ function processTranslationCall(tPath, updates, errors, file) {
67
66
  if (arg.type === 'StringLiteral' ||
68
67
  (t.isTemplateLiteral(arg) && arg.expressions.length === 0)) {
69
68
  const source = arg.type === 'StringLiteral' ? arg.value : arg.quasis[0].value.raw;
70
- // split the string into content (same as runtime behavior)
71
- const content = (0, generaltranslation_1.splitStringToContent)(source);
72
69
  // get metadata and id from options
73
70
  const options = tPath.parent.arguments[1];
74
71
  const metadata = {};
@@ -91,7 +88,7 @@ function processTranslationCall(tPath, updates, errors, file) {
91
88
  }
92
89
  updates.push({
93
90
  dataFormat: 'JSX',
94
- source: content,
91
+ source,
95
92
  metadata,
96
93
  });
97
94
  }
@@ -9,7 +9,6 @@ const node_path_1 = __importDefault(require("node:path"));
9
9
  const os_1 = __importDefault(require("os"));
10
10
  const esbuild_1 = require("esbuild");
11
11
  const flattenDictionary_1 = __importDefault(require("../utils/flattenDictionary"));
12
- const generaltranslation_1 = require("generaltranslation");
13
12
  const loadJSON_1 = __importDefault(require("../../fs/loadJSON"));
14
13
  const id_1 = require("generaltranslation/id");
15
14
  const getEntryAndMetadata_1 = __importDefault(require("../utils/getEntryAndMetadata"));
@@ -55,14 +54,13 @@ async function createDictionaryUpdates(options, dictionaryPath, esbuildConfig) {
55
54
  for (const id of Object.keys(dictionary)) {
56
55
  const { entry, metadata: props, // context, etc.
57
56
  } = (0, getEntryAndMetadata_1.default)(dictionary[id]);
58
- const source = (0, generaltranslation_1.splitStringToContent)(entry);
59
57
  const context = props?.context;
60
58
  const metadata = {
61
59
  id,
62
60
  ...(context && { context }),
63
61
  // This hash isn't actually used by the GT API, just for consistency sake
64
62
  hash: (0, id_1.hashJsxChildren)({
65
- source,
63
+ source: entry,
66
64
  ...(context && { context }),
67
65
  ...(id && { id }),
68
66
  dataFormat: 'JSX',
@@ -70,7 +68,7 @@ async function createDictionaryUpdates(options, dictionaryPath, esbuildConfig) {
70
68
  };
71
69
  updates.push({
72
70
  dataFormat: 'JSX',
73
- source,
71
+ source: entry,
74
72
  metadata,
75
73
  });
76
74
  }
@@ -7,7 +7,7 @@ exports.getDesiredLocales = getDesiredLocales;
7
7
  const internal_1 = require("generaltranslation/internal");
8
8
  const console_1 = require("../console");
9
9
  const chalk_1 = __importDefault(require("chalk"));
10
- const generaltranslation_1 = require("generaltranslation");
10
+ const generaltranslation_1 = __importDefault(require("generaltranslation"));
11
11
  async function getDesiredLocales() {
12
12
  // Ask for the default locale
13
13
  const defaultLocale = await (0, console_1.promptText)({
@@ -24,7 +24,7 @@ async function getDesiredLocales() {
24
24
  return 'Please enter at least one locale';
25
25
  }
26
26
  for (const locale of localeList) {
27
- if (!(0, generaltranslation_1.isValidLocale)(locale)) {
27
+ if (!generaltranslation_1.default.isValidLocale(locale)) {
28
28
  return 'Please enter a valid locale (e.g., en, fr, es)';
29
29
  }
30
30
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gtx-cli",
3
- "version": "1.2.23",
3
+ "version": "1.2.24-alpha.0",
4
4
  "main": "dist/index.js",
5
5
  "bin": "dist/main.js",
6
6
  "files": [
@@ -79,7 +79,7 @@
79
79
  "esbuild": "^0.25.4",
80
80
  "fast-glob": "^3.3.3",
81
81
  "form-data": "^4.0.2",
82
- "generaltranslation": "^6.2.10",
82
+ "generaltranslation": "^7.0.0-alpha.0",
83
83
  "open": "^10.1.1",
84
84
  "ora": "^8.2.0",
85
85
  "resolve": "^1.22.10",