gtx-cli 1.1.16 → 1.1.17

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.
@@ -4,7 +4,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.generateSettings = generateSettings;
7
- const generaltranslation_1 = require("generaltranslation");
8
7
  const console_1 = require("../console/console");
9
8
  const warnings_1 = require("../console/warnings");
10
9
  const loadConfig_1 = __importDefault(require("../fs/config/loadConfig"));
@@ -13,13 +12,14 @@ const fs_1 = __importDefault(require("fs"));
13
12
  const setupConfig_1 = __importDefault(require("../fs/config/setupConfig"));
14
13
  const parseFilesConfig_1 = require("../fs/config/parseFilesConfig");
15
14
  const findFilepath_1 = require("../fs/findFilepath");
15
+ const validateSettings_1 = require("./validateSettings");
16
16
  /**
17
17
  * Generates settings from any
18
18
  * @param options - The options to generate settings from
19
19
  * @returns The generated settings
20
20
  */
21
21
  function generateSettings(options) {
22
- var _a, _b;
22
+ var _a;
23
23
  // Load config file
24
24
  let gtConfig = {};
25
25
  if (options.config && !options.config.endsWith('.json')) {
@@ -70,18 +70,6 @@ function generateSettings(options) {
70
70
  mergedOptions.src =
71
71
  mergedOptions.src ||
72
72
  (0, findFilepath_1.findFilepaths)(['./src', './app', './pages', './components']);
73
- // Check locales
74
- if (mergedOptions.defaultLocale &&
75
- !(0, generaltranslation_1.isValidLocale)(mergedOptions.defaultLocale)) {
76
- console.error(`defaultLocale: ${mergedOptions.defaultLocale} is not a valid locale!`);
77
- process.exit(1);
78
- }
79
- for (const locale of mergedOptions.locales) {
80
- if (!(0, generaltranslation_1.isValidLocale)(locale)) {
81
- console.error(`Provided locales: "${(_a = mergedOptions === null || mergedOptions === void 0 ? void 0 : mergedOptions.locales) === null || _a === void 0 ? void 0 : _a.join()}", ${locale} is not a valid locale!`);
82
- process.exit(1);
83
- }
84
- }
85
73
  // Resolve all glob patterns in the files object
86
74
  mergedOptions.files = (0, parseFilesConfig_1.resolveFiles)(mergedOptions.files || {}, mergedOptions.defaultLocale);
87
75
  // if there's no existing config file, creates one
@@ -90,8 +78,9 @@ function generateSettings(options) {
90
78
  (0, setupConfig_1.default)(mergedOptions.config, {
91
79
  projectId: mergedOptions.projectId,
92
80
  defaultLocale: mergedOptions.defaultLocale,
93
- locales: ((_b = mergedOptions.locales) === null || _b === void 0 ? void 0 : _b.length) > 0 ? mergedOptions.locales : undefined,
81
+ locales: ((_a = mergedOptions.locales) === null || _a === void 0 ? void 0 : _a.length) > 0 ? mergedOptions.locales : undefined,
94
82
  });
95
83
  }
84
+ (0, validateSettings_1.validateSettings)(mergedOptions);
96
85
  return mergedOptions;
97
86
  }
@@ -0,0 +1,2 @@
1
+ import { Settings } from '../types';
2
+ export declare function validateSettings(settings: Settings): void;
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.validateSettings = validateSettings;
4
+ const generaltranslation_1 = require("generaltranslation");
5
+ function validateSettings(settings) {
6
+ var _a;
7
+ // Validate locales
8
+ for (const locale of settings.locales) {
9
+ if (!(0, generaltranslation_1.isValidLocale)(locale)) {
10
+ console.error(`Provided locales: "${(_a = settings === null || settings === void 0 ? void 0 : settings.locales) === null || _a === void 0 ? void 0 : _a.join()}", ${locale} is not a valid locale!`);
11
+ process.exit(1);
12
+ }
13
+ }
14
+ if (settings.defaultLocale && !(0, generaltranslation_1.isValidLocale)(settings.defaultLocale)) {
15
+ console.error(`defaultLocale: ${settings.defaultLocale} is not a valid locale!`);
16
+ process.exit(1);
17
+ }
18
+ // defaultLocale cannot be a superset of any other locale
19
+ if (settings.defaultLocale &&
20
+ settings.locales.some((locale) => (0, generaltranslation_1.isSupersetLocale)(settings.defaultLocale, locale))) {
21
+ const locale = settings.locales.find((locale) => (0, generaltranslation_1.isSupersetLocale)(settings.defaultLocale, locale));
22
+ console.error(`defaultLocale: ${settings.defaultLocale} is a superset of another locale (${locale})! Please change the defaultLocale to a more specific locale.`);
23
+ process.exit(1);
24
+ }
25
+ }
@@ -12,7 +12,7 @@ const console_1 = require("../../console/console");
12
12
  */
13
13
  function updateConfig({ configFilepath, projectId, _versionId, locales, }) {
14
14
  // Filter out empty string values from the config object
15
- const newContent = Object.assign(Object.assign(Object.assign({}, (projectId && { projectId })), (_versionId && { _versionId })), (locales && { locales }));
15
+ const newContent = Object.assign(Object.assign({}, (projectId && { projectId })), (_versionId && { _versionId }));
16
16
  try {
17
17
  // if file exists
18
18
  let oldContent = {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gtx-cli",
3
- "version": "1.1.16",
3
+ "version": "1.1.17",
4
4
  "main": "dist/index.js",
5
5
  "bin": "dist/main.js",
6
6
  "scripts": {
@@ -54,7 +54,7 @@
54
54
  "esbuild": "^0.23.1",
55
55
  "fast-glob": "^3.3.3",
56
56
  "form-data": "^4.0.2",
57
- "generaltranslation": "^6.2.3",
57
+ "generaltranslation": "^6.2.4",
58
58
  "ora": "^8.2.0"
59
59
  },
60
60
  "devDependencies": {