lingo.dev 0.70.3 → 0.70.4
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.
|
@@ -7,7 +7,7 @@ import Z from "zod";
|
|
|
7
7
|
import { createId } from "@paralleldrive/cuid2";
|
|
8
8
|
var engineParamsSchema = Z.object({
|
|
9
9
|
apiKey: Z.string(),
|
|
10
|
-
apiUrl: Z.string().url().default("https://engine.
|
|
10
|
+
apiUrl: Z.string().url().default("https://engine.lingo.dev"),
|
|
11
11
|
batchSize: Z.number().int().gt(0).lte(250).default(25),
|
|
12
12
|
idealBatchItemSize: Z.number().int().gt(0).lte(2500).default(250)
|
|
13
13
|
}).passthrough();
|
|
@@ -28,7 +28,7 @@ var ReplexicaEngine = class {
|
|
|
28
28
|
this.config = engineParamsSchema.parse(config);
|
|
29
29
|
}
|
|
30
30
|
/**
|
|
31
|
-
* Localize content using the
|
|
31
|
+
* Localize content using the Lingo.dev API
|
|
32
32
|
* @param payload - The content to be localized
|
|
33
33
|
* @param params - Localization parameters including source/target locales and fast mode option
|
|
34
34
|
* @param reference - Optional reference translations to maintain consistency
|
|
@@ -7,7 +7,7 @@ var _zod = require('zod'); var _zod2 = _interopRequireDefault(_zod);
|
|
|
7
7
|
var _cuid2 = require('@paralleldrive/cuid2');
|
|
8
8
|
var engineParamsSchema = _zod2.default.object({
|
|
9
9
|
apiKey: _zod2.default.string(),
|
|
10
|
-
apiUrl: _zod2.default.string().url().default("https://engine.
|
|
10
|
+
apiUrl: _zod2.default.string().url().default("https://engine.lingo.dev"),
|
|
11
11
|
batchSize: _zod2.default.number().int().gt(0).lte(250).default(25),
|
|
12
12
|
idealBatchItemSize: _zod2.default.number().int().gt(0).lte(2500).default(250)
|
|
13
13
|
}).passthrough();
|
|
@@ -28,7 +28,7 @@ var ReplexicaEngine = class {
|
|
|
28
28
|
this.config = engineParamsSchema.parse(config);
|
|
29
29
|
}
|
|
30
30
|
/**
|
|
31
|
-
* Localize content using the
|
|
31
|
+
* Localize content using the Lingo.dev API
|
|
32
32
|
* @param payload - The content to be localized
|
|
33
33
|
* @param params - Localization parameters including source/target locales and fast mode option
|
|
34
34
|
* @param reference - Optional reference translations to maintain consistency
|
package/build/cli.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkMNP3B6L4cjs = require('./chunk-MNP3B6L4.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
@@ -56,8 +56,8 @@ function _loadDefaults() {
|
|
|
56
56
|
return {
|
|
57
57
|
auth: {
|
|
58
58
|
apiKey: "",
|
|
59
|
-
apiUrl: "https://engine.
|
|
60
|
-
webUrl: "https://
|
|
59
|
+
apiUrl: "https://engine.lingo.dev",
|
|
60
|
+
webUrl: "https://lingo.dev"
|
|
61
61
|
}
|
|
62
62
|
};
|
|
63
63
|
}
|
|
@@ -86,7 +86,7 @@ function _saveSystemFile(settings) {
|
|
|
86
86
|
_fs2.default.writeFileSync(settingsFilePath, content);
|
|
87
87
|
}
|
|
88
88
|
function _getSettingsFilePath() {
|
|
89
|
-
const settingsFile = ".
|
|
89
|
+
const settingsFile = ".lingodotdevrc";
|
|
90
90
|
const homedir = _os2.default.homedir();
|
|
91
91
|
const settingsFilePath = _path2.default.join(homedir, settingsFile);
|
|
92
92
|
return settingsFilePath;
|
|
@@ -94,22 +94,22 @@ function _getSettingsFilePath() {
|
|
|
94
94
|
|
|
95
95
|
// src/cli/utils/errors.ts
|
|
96
96
|
var docLinks = {
|
|
97
|
-
i18nNotFound: "https://docs.
|
|
98
|
-
bucketNotFound: "https://docs.
|
|
99
|
-
authError: "https://docs.
|
|
100
|
-
localeTargetNotFound: "https://docs.
|
|
101
|
-
lockFiletNotFound: "https://docs.
|
|
102
|
-
failedReplexicaEngine: "https://docs.
|
|
103
|
-
placeHolderFailed: "https://docs.
|
|
104
|
-
translationFailed: "https://docs.
|
|
105
|
-
connectionFailed: "https://docs.
|
|
106
|
-
invalidType: "https://docs.
|
|
107
|
-
invalidPathPattern: "https://docs.
|
|
108
|
-
androidResouceError: "https://docs.
|
|
109
|
-
invalidBucketType: "https://docs.
|
|
110
|
-
invalidStringDict: "https://docs.
|
|
97
|
+
i18nNotFound: "https://docs.lingo.dev/quickstart#initialization",
|
|
98
|
+
bucketNotFound: "https://docs.lingo.dev/config#buckets",
|
|
99
|
+
authError: "https://docs.lingo.dev/auth",
|
|
100
|
+
localeTargetNotFound: "https://docs.lingo.dev/config#locale",
|
|
101
|
+
lockFiletNotFound: "https://docs.lingo.dev/config#i18n-lock",
|
|
102
|
+
failedReplexicaEngine: "https://docs.lingo.dev/",
|
|
103
|
+
placeHolderFailed: "https://docs.lingo.dev/formats/json",
|
|
104
|
+
translationFailed: "https://docs.lingo.dev/setup/cli#core-command-i18n",
|
|
105
|
+
connectionFailed: "https://docs.lingo.dev/",
|
|
106
|
+
invalidType: "https://docs.lingo.dev/setup/cli#configuration-commands",
|
|
107
|
+
invalidPathPattern: "https://docs.lingo.dev/config#buckets",
|
|
108
|
+
androidResouceError: "https://docs.lingo.dev/formats/android",
|
|
109
|
+
invalidBucketType: "https://docs.lingo.dev/config#buckets",
|
|
110
|
+
invalidStringDict: "https://docs.lingo.dev/formats/xcode-stringsdict"
|
|
111
111
|
};
|
|
112
|
-
var
|
|
112
|
+
var CLIError = class extends Error {
|
|
113
113
|
|
|
114
114
|
constructor({ message, docUrl }) {
|
|
115
115
|
super(message);
|
|
@@ -144,7 +144,7 @@ function createAuthenticator(params) {
|
|
|
144
144
|
} catch (error) {
|
|
145
145
|
const isNetworkError = error instanceof TypeError && error.message === "fetch failed";
|
|
146
146
|
if (isNetworkError) {
|
|
147
|
-
throw new
|
|
147
|
+
throw new CLIError({
|
|
148
148
|
message: `Failed to connect to the API at ${params.apiUrl}. Please check your connection and try again.`,
|
|
149
149
|
docUrl: "connectionFailed"
|
|
150
150
|
});
|
|
@@ -157,7 +157,7 @@ function createAuthenticator(params) {
|
|
|
157
157
|
}
|
|
158
158
|
|
|
159
159
|
// src/cli/cli/auth.ts
|
|
160
|
-
var auth_default = new (0, _interactivecommander.Command)().command("auth").description("Authenticate with
|
|
160
|
+
var auth_default = new (0, _interactivecommander.Command)().command("auth").description("Authenticate with Lingo.dev API").helpOption("-h, --help", "Show help").option("--logout", "Delete existing authentication").option("--login", "Authenticate with Lingo.dev API").action(async (options) => {
|
|
161
161
|
try {
|
|
162
162
|
let settings = await getSettings(void 0);
|
|
163
163
|
if (options.logout) {
|
|
@@ -276,7 +276,7 @@ var throwHelpError = (option, value) => {
|
|
|
276
276
|
Do you need support for ${value} ${option}? Type "help" and we will.`
|
|
277
277
|
);
|
|
278
278
|
};
|
|
279
|
-
var init_default = new (0, _interactivecommander.InteractiveCommand)().command("init").description("Initialize
|
|
279
|
+
var init_default = new (0, _interactivecommander.InteractiveCommand)().command("init").description("Initialize Lingo.dev project").helpOption("-h, --help", "Show help").addOption(new (0, _interactivecommander.InteractiveOption)("-f --force", "Overwrite existing config").prompt(void 0).default(false)).addOption(
|
|
280
280
|
new (0, _interactivecommander.InteractiveOption)("-s --source <locale>", "Source locale").argParser((value) => {
|
|
281
281
|
try {
|
|
282
282
|
_chunkDTGLPBE5cjs.resolveLocaleCode.call(void 0, value);
|
|
@@ -321,10 +321,10 @@ var init_default = new (0, _interactivecommander.InteractiveCommand)().command("
|
|
|
321
321
|
}).default(".")
|
|
322
322
|
).action(async (options) => {
|
|
323
323
|
const settings = getSettings(void 0);
|
|
324
|
-
const spinner = _ora2.default.call(void 0, ).start("Initializing
|
|
324
|
+
const spinner = _ora2.default.call(void 0, ).start("Initializing Lingo.dev project");
|
|
325
325
|
let existingConfig = await getConfig(false);
|
|
326
326
|
if (existingConfig && !options.force) {
|
|
327
|
-
spinner.fail("
|
|
327
|
+
spinner.fail("Lingo.dev project already initialized");
|
|
328
328
|
return process.exit(1);
|
|
329
329
|
}
|
|
330
330
|
const newConfig = _lodash2.default.cloneDeep(_chunkDTGLPBE5cjs.defaultConfig);
|
|
@@ -334,7 +334,7 @@ var init_default = new (0, _interactivecommander.InteractiveCommand)().command("
|
|
|
334
334
|
[options.bucket]: options.paths
|
|
335
335
|
};
|
|
336
336
|
await saveConfig(newConfig);
|
|
337
|
-
spinner.succeed("
|
|
337
|
+
spinner.succeed("Lingo.dev project initialized");
|
|
338
338
|
const isInteractive = !process.argv.includes("-y") && !process.argv.includes("--no-interactive");
|
|
339
339
|
if (isInteractive) {
|
|
340
340
|
const openDocs = await _prompts.confirm.call(void 0, { message: "Would you like to see our docs?" });
|
|
@@ -368,13 +368,13 @@ var init_default = new (0, _interactivecommander.InteractiveCommand)().command("
|
|
|
368
368
|
}
|
|
369
369
|
}
|
|
370
370
|
} else {
|
|
371
|
-
_ora2.default.call(void 0, ).warn("You are not logged in. Run `npx
|
|
371
|
+
_ora2.default.call(void 0, ).warn("You are not logged in. Run `npx lingo.dev@latest auth --login` to login.");
|
|
372
372
|
}
|
|
373
373
|
} else {
|
|
374
374
|
_ora2.default.call(void 0, ).succeed(`Authenticated as ${auth.email}`);
|
|
375
375
|
}
|
|
376
376
|
if (!isInteractive) {
|
|
377
|
-
_ora2.default.call(void 0, ).info("Please see https://docs.
|
|
377
|
+
_ora2.default.call(void 0, ).info("Please see https://docs.lingo.dev/");
|
|
378
378
|
}
|
|
379
379
|
});
|
|
380
380
|
|
|
@@ -410,7 +410,7 @@ var locale_default = new (0, _interactivecommander.Command)().command("locale").
|
|
|
410
410
|
try {
|
|
411
411
|
switch (type) {
|
|
412
412
|
default:
|
|
413
|
-
throw new
|
|
413
|
+
throw new CLIError({
|
|
414
414
|
message: `Invalid type: ${type}`,
|
|
415
415
|
docUrl: "invalidType"
|
|
416
416
|
});
|
|
@@ -470,19 +470,19 @@ function expandPlaceholderedGlob(_pathPattern, sourceLocale) {
|
|
|
470
470
|
const absolutePathPattern = _path2.default.resolve(_pathPattern);
|
|
471
471
|
const pathPattern = _path2.default.relative(process.cwd(), absolutePathPattern);
|
|
472
472
|
if (_path2.default.relative(process.cwd(), pathPattern).startsWith("..")) {
|
|
473
|
-
throw new
|
|
473
|
+
throw new CLIError({
|
|
474
474
|
message: `Invalid path pattern: ${pathPattern}. Path pattern must be within the current working directory.`,
|
|
475
475
|
docUrl: "invalidPathPattern"
|
|
476
476
|
});
|
|
477
477
|
}
|
|
478
478
|
if (pathPattern.includes("**")) {
|
|
479
|
-
throw new
|
|
479
|
+
throw new CLIError({
|
|
480
480
|
message: `Invalid path pattern: ${pathPattern}. Recursive path patterns are not supported.`,
|
|
481
481
|
docUrl: "invalidPathPattern"
|
|
482
482
|
});
|
|
483
483
|
}
|
|
484
484
|
if (pathPattern.split("[locale]").length > 2) {
|
|
485
|
-
throw new
|
|
485
|
+
throw new CLIError({
|
|
486
486
|
message: `Invalid path pattern: ${pathPattern}. Path pattern must contain at most one "[locale]" placeholder.`,
|
|
487
487
|
docUrl: "invalidPathPattern"
|
|
488
488
|
});
|
|
@@ -512,14 +512,14 @@ function resolveBucketItem(bucketItem) {
|
|
|
512
512
|
}
|
|
513
513
|
|
|
514
514
|
// src/cli/cli/show/files.ts
|
|
515
|
-
var files_default = new (0, _interactivecommander.Command)().command("files").description("Print out the list of files managed by
|
|
515
|
+
var files_default = new (0, _interactivecommander.Command)().command("files").description("Print out the list of files managed by Lingo.dev").option("--source", "Only show source files").option("--target", "Only show target files").helpOption("-h, --help", "Show help").action(async (type) => {
|
|
516
516
|
const ora = _ora2.default.call(void 0, );
|
|
517
517
|
try {
|
|
518
518
|
try {
|
|
519
519
|
const i18nConfig = await getConfig();
|
|
520
520
|
if (!i18nConfig) {
|
|
521
|
-
throw new
|
|
522
|
-
message: "i18n.json not found. Please run `
|
|
521
|
+
throw new CLIError({
|
|
522
|
+
message: "i18n.json not found. Please run `lingo.dev init` to initialize the project.",
|
|
523
523
|
docUrl: "i18nNotFound"
|
|
524
524
|
});
|
|
525
525
|
}
|
|
@@ -546,7 +546,7 @@ var files_default = new (0, _interactivecommander.Command)().command("files").de
|
|
|
546
546
|
}
|
|
547
547
|
}
|
|
548
548
|
} catch (error) {
|
|
549
|
-
throw new
|
|
549
|
+
throw new CLIError({
|
|
550
550
|
message: `Failed to expand placeholdered globs: ${error.message}`,
|
|
551
551
|
docUrl: "placeHolderFailed"
|
|
552
552
|
});
|
|
@@ -807,7 +807,7 @@ function createAndroidLoader() {
|
|
|
807
807
|
return result;
|
|
808
808
|
} catch (error) {
|
|
809
809
|
console.error("Error parsing Android resource file:", error);
|
|
810
|
-
throw new
|
|
810
|
+
throw new CLIError({
|
|
811
811
|
message: "Failed to parse Android resource file",
|
|
812
812
|
docUrl: "androidResouceError"
|
|
813
813
|
});
|
|
@@ -1149,14 +1149,14 @@ function createXcodeStringsdictLoader() {
|
|
|
1149
1149
|
try {
|
|
1150
1150
|
const parsed = _plist2.default.parse(input || emptyData);
|
|
1151
1151
|
if (typeof parsed !== "object" || parsed === null) {
|
|
1152
|
-
throw new
|
|
1152
|
+
throw new CLIError({
|
|
1153
1153
|
message: "Invalid .stringsdict format",
|
|
1154
1154
|
docUrl: "invalidStringDict"
|
|
1155
1155
|
});
|
|
1156
1156
|
}
|
|
1157
1157
|
return parsed;
|
|
1158
1158
|
} catch (error) {
|
|
1159
|
-
throw new
|
|
1159
|
+
throw new CLIError({
|
|
1160
1160
|
message: `Invalid .stringsdict format: ${error.message}`,
|
|
1161
1161
|
docUrl: "invalidStringDict"
|
|
1162
1162
|
});
|
|
@@ -2639,7 +2639,7 @@ async function retryWithExponentialBackoff(operation, maxAttempts, baseDelay = 1
|
|
|
2639
2639
|
throw new Error("Unreachable code");
|
|
2640
2640
|
}
|
|
2641
2641
|
function createLocalizationEngineConnection(params) {
|
|
2642
|
-
const replexicaEngine = new (0,
|
|
2642
|
+
const replexicaEngine = new (0, _chunkMNP3B6L4cjs.ReplexicaEngine)({
|
|
2643
2643
|
apiKey: params.apiKey,
|
|
2644
2644
|
apiUrl: params.apiUrl
|
|
2645
2645
|
});
|
|
@@ -2675,8 +2675,8 @@ function parseFlags(options) {
|
|
|
2675
2675
|
}
|
|
2676
2676
|
async function validateAuth(settings) {
|
|
2677
2677
|
if (!settings.auth.apiKey) {
|
|
2678
|
-
throw new
|
|
2679
|
-
message: "Not authenticated. Please run `
|
|
2678
|
+
throw new CLIError({
|
|
2679
|
+
message: "Not authenticated. Please run `lingo.dev auth --login` to authenticate.",
|
|
2680
2680
|
docUrl: "authError"
|
|
2681
2681
|
});
|
|
2682
2682
|
}
|
|
@@ -2686,8 +2686,8 @@ async function validateAuth(settings) {
|
|
|
2686
2686
|
});
|
|
2687
2687
|
const user = await authenticator.whoami();
|
|
2688
2688
|
if (!user) {
|
|
2689
|
-
throw new
|
|
2690
|
-
message: "Invalid API key. Please run `
|
|
2689
|
+
throw new CLIError({
|
|
2690
|
+
message: "Invalid API key. Please run `lingo.dev auth --login` to authenticate.",
|
|
2691
2691
|
docUrl: "authError"
|
|
2692
2692
|
});
|
|
2693
2693
|
}
|
|
@@ -2695,22 +2695,22 @@ async function validateAuth(settings) {
|
|
|
2695
2695
|
}
|
|
2696
2696
|
function validateParams(i18nConfig, flags) {
|
|
2697
2697
|
if (!i18nConfig) {
|
|
2698
|
-
throw new
|
|
2699
|
-
message: "i18n.json not found. Please run `
|
|
2698
|
+
throw new CLIError({
|
|
2699
|
+
message: "i18n.json not found. Please run `lingo.dev init` to initialize the project.",
|
|
2700
2700
|
docUrl: "i18nNotFound"
|
|
2701
2701
|
});
|
|
2702
2702
|
} else if (!i18nConfig.buckets || !Object.keys(i18nConfig.buckets).length) {
|
|
2703
|
-
throw new
|
|
2703
|
+
throw new CLIError({
|
|
2704
2704
|
message: "No buckets found in i18n.json. Please add at least one bucket containing i18n content.",
|
|
2705
2705
|
docUrl: "bucketNotFound"
|
|
2706
2706
|
});
|
|
2707
2707
|
} else if (_optionalChain([flags, 'access', _123 => _123.locale, 'optionalAccess', _124 => _124.some, 'call', _125 => _125((locale) => !i18nConfig.locale.targets.includes(locale))])) {
|
|
2708
|
-
throw new
|
|
2708
|
+
throw new CLIError({
|
|
2709
2709
|
message: `One or more specified locales do not exist in i18n.json locale.targets. Please add them to the list and try again.`,
|
|
2710
2710
|
docUrl: "localeTargetNotFound"
|
|
2711
2711
|
});
|
|
2712
2712
|
} else if (_optionalChain([flags, 'access', _126 => _126.bucket, 'optionalAccess', _127 => _127.some, 'call', _128 => _128((bucket) => !i18nConfig.buckets[bucket])])) {
|
|
2713
|
-
throw new
|
|
2713
|
+
throw new CLIError({
|
|
2714
2714
|
message: `One or more specified buckets do not exist in i18n.json. Please add them to the list and try again.`,
|
|
2715
2715
|
docUrl: "bucketNotFound"
|
|
2716
2716
|
});
|
|
@@ -2910,13 +2910,13 @@ var cleanup_default = new (0, _interactivecommander.Command)().command("cleanup"
|
|
|
2910
2910
|
});
|
|
2911
2911
|
function validateConfig(i18nConfig) {
|
|
2912
2912
|
if (!i18nConfig) {
|
|
2913
|
-
throw new
|
|
2914
|
-
message: "i18n.json not found. Please run `
|
|
2913
|
+
throw new CLIError({
|
|
2914
|
+
message: "i18n.json not found. Please run `lingo.dev init` to initialize the project.",
|
|
2915
2915
|
docUrl: "i18nNotFound"
|
|
2916
2916
|
});
|
|
2917
2917
|
}
|
|
2918
2918
|
if (!i18nConfig.buckets || !Object.keys(i18nConfig.buckets).length) {
|
|
2919
|
-
throw new
|
|
2919
|
+
throw new CLIError({
|
|
2920
2920
|
message: "No buckets found in i18n.json. Please add at least one bucket containing i18n content.",
|
|
2921
2921
|
docUrl: "bucketNotFound"
|
|
2922
2922
|
});
|
|
@@ -2934,7 +2934,7 @@ function displaySummary(results) {
|
|
|
2934
2934
|
// package.json
|
|
2935
2935
|
var package_default = {
|
|
2936
2936
|
name: "lingo.dev",
|
|
2937
|
-
version: "0.70.
|
|
2937
|
+
version: "0.70.4",
|
|
2938
2938
|
description: "Lingo.dev CLI",
|
|
2939
2939
|
private: false,
|
|
2940
2940
|
type: "module",
|
|
@@ -3049,7 +3049,7 @@ var package_default = {
|
|
|
3049
3049
|
|
|
3050
3050
|
// src/cli/index.ts
|
|
3051
3051
|
_dotenv2.default.config();
|
|
3052
|
-
var cli_default = new (0, _interactivecommander.InteractiveCommand)().name("
|
|
3052
|
+
var cli_default = new (0, _interactivecommander.InteractiveCommand)().name("lingo.dev").description("Lingo.dev CLI").helpOption("-h, --help", "Show help").addHelpText(
|
|
3053
3053
|
"beforeAll",
|
|
3054
3054
|
`
|
|
3055
3055
|
Lingo.dev CLI
|
package/build/cli.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ReplexicaEngine
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-FAB4HZX7.mjs";
|
|
4
4
|
import {
|
|
5
5
|
bucketTypeSchema,
|
|
6
6
|
bucketTypes,
|
|
@@ -56,8 +56,8 @@ function _loadDefaults() {
|
|
|
56
56
|
return {
|
|
57
57
|
auth: {
|
|
58
58
|
apiKey: "",
|
|
59
|
-
apiUrl: "https://engine.
|
|
60
|
-
webUrl: "https://
|
|
59
|
+
apiUrl: "https://engine.lingo.dev",
|
|
60
|
+
webUrl: "https://lingo.dev"
|
|
61
61
|
}
|
|
62
62
|
};
|
|
63
63
|
}
|
|
@@ -86,7 +86,7 @@ function _saveSystemFile(settings) {
|
|
|
86
86
|
fs.writeFileSync(settingsFilePath, content);
|
|
87
87
|
}
|
|
88
88
|
function _getSettingsFilePath() {
|
|
89
|
-
const settingsFile = ".
|
|
89
|
+
const settingsFile = ".lingodotdevrc";
|
|
90
90
|
const homedir = os.homedir();
|
|
91
91
|
const settingsFilePath = path.join(homedir, settingsFile);
|
|
92
92
|
return settingsFilePath;
|
|
@@ -94,22 +94,22 @@ function _getSettingsFilePath() {
|
|
|
94
94
|
|
|
95
95
|
// src/cli/utils/errors.ts
|
|
96
96
|
var docLinks = {
|
|
97
|
-
i18nNotFound: "https://docs.
|
|
98
|
-
bucketNotFound: "https://docs.
|
|
99
|
-
authError: "https://docs.
|
|
100
|
-
localeTargetNotFound: "https://docs.
|
|
101
|
-
lockFiletNotFound: "https://docs.
|
|
102
|
-
failedReplexicaEngine: "https://docs.
|
|
103
|
-
placeHolderFailed: "https://docs.
|
|
104
|
-
translationFailed: "https://docs.
|
|
105
|
-
connectionFailed: "https://docs.
|
|
106
|
-
invalidType: "https://docs.
|
|
107
|
-
invalidPathPattern: "https://docs.
|
|
108
|
-
androidResouceError: "https://docs.
|
|
109
|
-
invalidBucketType: "https://docs.
|
|
110
|
-
invalidStringDict: "https://docs.
|
|
97
|
+
i18nNotFound: "https://docs.lingo.dev/quickstart#initialization",
|
|
98
|
+
bucketNotFound: "https://docs.lingo.dev/config#buckets",
|
|
99
|
+
authError: "https://docs.lingo.dev/auth",
|
|
100
|
+
localeTargetNotFound: "https://docs.lingo.dev/config#locale",
|
|
101
|
+
lockFiletNotFound: "https://docs.lingo.dev/config#i18n-lock",
|
|
102
|
+
failedReplexicaEngine: "https://docs.lingo.dev/",
|
|
103
|
+
placeHolderFailed: "https://docs.lingo.dev/formats/json",
|
|
104
|
+
translationFailed: "https://docs.lingo.dev/setup/cli#core-command-i18n",
|
|
105
|
+
connectionFailed: "https://docs.lingo.dev/",
|
|
106
|
+
invalidType: "https://docs.lingo.dev/setup/cli#configuration-commands",
|
|
107
|
+
invalidPathPattern: "https://docs.lingo.dev/config#buckets",
|
|
108
|
+
androidResouceError: "https://docs.lingo.dev/formats/android",
|
|
109
|
+
invalidBucketType: "https://docs.lingo.dev/config#buckets",
|
|
110
|
+
invalidStringDict: "https://docs.lingo.dev/formats/xcode-stringsdict"
|
|
111
111
|
};
|
|
112
|
-
var
|
|
112
|
+
var CLIError = class extends Error {
|
|
113
113
|
docUrl;
|
|
114
114
|
constructor({ message, docUrl }) {
|
|
115
115
|
super(message);
|
|
@@ -144,7 +144,7 @@ function createAuthenticator(params) {
|
|
|
144
144
|
} catch (error) {
|
|
145
145
|
const isNetworkError = error instanceof TypeError && error.message === "fetch failed";
|
|
146
146
|
if (isNetworkError) {
|
|
147
|
-
throw new
|
|
147
|
+
throw new CLIError({
|
|
148
148
|
message: `Failed to connect to the API at ${params.apiUrl}. Please check your connection and try again.`,
|
|
149
149
|
docUrl: "connectionFailed"
|
|
150
150
|
});
|
|
@@ -157,7 +157,7 @@ function createAuthenticator(params) {
|
|
|
157
157
|
}
|
|
158
158
|
|
|
159
159
|
// src/cli/cli/auth.ts
|
|
160
|
-
var auth_default = new Command().command("auth").description("Authenticate with
|
|
160
|
+
var auth_default = new Command().command("auth").description("Authenticate with Lingo.dev API").helpOption("-h, --help", "Show help").option("--logout", "Delete existing authentication").option("--login", "Authenticate with Lingo.dev API").action(async (options) => {
|
|
161
161
|
try {
|
|
162
162
|
let settings = await getSettings(void 0);
|
|
163
163
|
if (options.logout) {
|
|
@@ -276,7 +276,7 @@ var throwHelpError = (option, value) => {
|
|
|
276
276
|
Do you need support for ${value} ${option}? Type "help" and we will.`
|
|
277
277
|
);
|
|
278
278
|
};
|
|
279
|
-
var init_default = new InteractiveCommand().command("init").description("Initialize
|
|
279
|
+
var init_default = new InteractiveCommand().command("init").description("Initialize Lingo.dev project").helpOption("-h, --help", "Show help").addOption(new InteractiveOption("-f --force", "Overwrite existing config").prompt(void 0).default(false)).addOption(
|
|
280
280
|
new InteractiveOption("-s --source <locale>", "Source locale").argParser((value) => {
|
|
281
281
|
try {
|
|
282
282
|
resolveLocaleCode(value);
|
|
@@ -321,10 +321,10 @@ var init_default = new InteractiveCommand().command("init").description("Initial
|
|
|
321
321
|
}).default(".")
|
|
322
322
|
).action(async (options) => {
|
|
323
323
|
const settings = getSettings(void 0);
|
|
324
|
-
const spinner = Ora2().start("Initializing
|
|
324
|
+
const spinner = Ora2().start("Initializing Lingo.dev project");
|
|
325
325
|
let existingConfig = await getConfig(false);
|
|
326
326
|
if (existingConfig && !options.force) {
|
|
327
|
-
spinner.fail("
|
|
327
|
+
spinner.fail("Lingo.dev project already initialized");
|
|
328
328
|
return process.exit(1);
|
|
329
329
|
}
|
|
330
330
|
const newConfig = _2.cloneDeep(defaultConfig);
|
|
@@ -334,7 +334,7 @@ var init_default = new InteractiveCommand().command("init").description("Initial
|
|
|
334
334
|
[options.bucket]: options.paths
|
|
335
335
|
};
|
|
336
336
|
await saveConfig(newConfig);
|
|
337
|
-
spinner.succeed("
|
|
337
|
+
spinner.succeed("Lingo.dev project initialized");
|
|
338
338
|
const isInteractive = !process.argv.includes("-y") && !process.argv.includes("--no-interactive");
|
|
339
339
|
if (isInteractive) {
|
|
340
340
|
const openDocs = await confirm({ message: "Would you like to see our docs?" });
|
|
@@ -368,13 +368,13 @@ var init_default = new InteractiveCommand().command("init").description("Initial
|
|
|
368
368
|
}
|
|
369
369
|
}
|
|
370
370
|
} else {
|
|
371
|
-
Ora2().warn("You are not logged in. Run `npx
|
|
371
|
+
Ora2().warn("You are not logged in. Run `npx lingo.dev@latest auth --login` to login.");
|
|
372
372
|
}
|
|
373
373
|
} else {
|
|
374
374
|
Ora2().succeed(`Authenticated as ${auth.email}`);
|
|
375
375
|
}
|
|
376
376
|
if (!isInteractive) {
|
|
377
|
-
Ora2().info("Please see https://docs.
|
|
377
|
+
Ora2().info("Please see https://docs.lingo.dev/");
|
|
378
378
|
}
|
|
379
379
|
});
|
|
380
380
|
|
|
@@ -410,7 +410,7 @@ var locale_default = new Command3().command("locale").description("Print out the
|
|
|
410
410
|
try {
|
|
411
411
|
switch (type) {
|
|
412
412
|
default:
|
|
413
|
-
throw new
|
|
413
|
+
throw new CLIError({
|
|
414
414
|
message: `Invalid type: ${type}`,
|
|
415
415
|
docUrl: "invalidType"
|
|
416
416
|
});
|
|
@@ -470,19 +470,19 @@ function expandPlaceholderedGlob(_pathPattern, sourceLocale) {
|
|
|
470
470
|
const absolutePathPattern = path4.resolve(_pathPattern);
|
|
471
471
|
const pathPattern = path4.relative(process.cwd(), absolutePathPattern);
|
|
472
472
|
if (path4.relative(process.cwd(), pathPattern).startsWith("..")) {
|
|
473
|
-
throw new
|
|
473
|
+
throw new CLIError({
|
|
474
474
|
message: `Invalid path pattern: ${pathPattern}. Path pattern must be within the current working directory.`,
|
|
475
475
|
docUrl: "invalidPathPattern"
|
|
476
476
|
});
|
|
477
477
|
}
|
|
478
478
|
if (pathPattern.includes("**")) {
|
|
479
|
-
throw new
|
|
479
|
+
throw new CLIError({
|
|
480
480
|
message: `Invalid path pattern: ${pathPattern}. Recursive path patterns are not supported.`,
|
|
481
481
|
docUrl: "invalidPathPattern"
|
|
482
482
|
});
|
|
483
483
|
}
|
|
484
484
|
if (pathPattern.split("[locale]").length > 2) {
|
|
485
|
-
throw new
|
|
485
|
+
throw new CLIError({
|
|
486
486
|
message: `Invalid path pattern: ${pathPattern}. Path pattern must contain at most one "[locale]" placeholder.`,
|
|
487
487
|
docUrl: "invalidPathPattern"
|
|
488
488
|
});
|
|
@@ -512,14 +512,14 @@ function resolveBucketItem(bucketItem) {
|
|
|
512
512
|
}
|
|
513
513
|
|
|
514
514
|
// src/cli/cli/show/files.ts
|
|
515
|
-
var files_default = new Command4().command("files").description("Print out the list of files managed by
|
|
515
|
+
var files_default = new Command4().command("files").description("Print out the list of files managed by Lingo.dev").option("--source", "Only show source files").option("--target", "Only show target files").helpOption("-h, --help", "Show help").action(async (type) => {
|
|
516
516
|
const ora = Ora4();
|
|
517
517
|
try {
|
|
518
518
|
try {
|
|
519
519
|
const i18nConfig = await getConfig();
|
|
520
520
|
if (!i18nConfig) {
|
|
521
|
-
throw new
|
|
522
|
-
message: "i18n.json not found. Please run `
|
|
521
|
+
throw new CLIError({
|
|
522
|
+
message: "i18n.json not found. Please run `lingo.dev init` to initialize the project.",
|
|
523
523
|
docUrl: "i18nNotFound"
|
|
524
524
|
});
|
|
525
525
|
}
|
|
@@ -546,7 +546,7 @@ var files_default = new Command4().command("files").description("Print out the l
|
|
|
546
546
|
}
|
|
547
547
|
}
|
|
548
548
|
} catch (error) {
|
|
549
|
-
throw new
|
|
549
|
+
throw new CLIError({
|
|
550
550
|
message: `Failed to expand placeholdered globs: ${error.message}`,
|
|
551
551
|
docUrl: "placeHolderFailed"
|
|
552
552
|
});
|
|
@@ -807,7 +807,7 @@ function createAndroidLoader() {
|
|
|
807
807
|
return result;
|
|
808
808
|
} catch (error) {
|
|
809
809
|
console.error("Error parsing Android resource file:", error);
|
|
810
|
-
throw new
|
|
810
|
+
throw new CLIError({
|
|
811
811
|
message: "Failed to parse Android resource file",
|
|
812
812
|
docUrl: "androidResouceError"
|
|
813
813
|
});
|
|
@@ -1149,14 +1149,14 @@ function createXcodeStringsdictLoader() {
|
|
|
1149
1149
|
try {
|
|
1150
1150
|
const parsed = plist.parse(input || emptyData);
|
|
1151
1151
|
if (typeof parsed !== "object" || parsed === null) {
|
|
1152
|
-
throw new
|
|
1152
|
+
throw new CLIError({
|
|
1153
1153
|
message: "Invalid .stringsdict format",
|
|
1154
1154
|
docUrl: "invalidStringDict"
|
|
1155
1155
|
});
|
|
1156
1156
|
}
|
|
1157
1157
|
return parsed;
|
|
1158
1158
|
} catch (error) {
|
|
1159
|
-
throw new
|
|
1159
|
+
throw new CLIError({
|
|
1160
1160
|
message: `Invalid .stringsdict format: ${error.message}`,
|
|
1161
1161
|
docUrl: "invalidStringDict"
|
|
1162
1162
|
});
|
|
@@ -2675,8 +2675,8 @@ function parseFlags(options) {
|
|
|
2675
2675
|
}
|
|
2676
2676
|
async function validateAuth(settings) {
|
|
2677
2677
|
if (!settings.auth.apiKey) {
|
|
2678
|
-
throw new
|
|
2679
|
-
message: "Not authenticated. Please run `
|
|
2678
|
+
throw new CLIError({
|
|
2679
|
+
message: "Not authenticated. Please run `lingo.dev auth --login` to authenticate.",
|
|
2680
2680
|
docUrl: "authError"
|
|
2681
2681
|
});
|
|
2682
2682
|
}
|
|
@@ -2686,8 +2686,8 @@ async function validateAuth(settings) {
|
|
|
2686
2686
|
});
|
|
2687
2687
|
const user = await authenticator.whoami();
|
|
2688
2688
|
if (!user) {
|
|
2689
|
-
throw new
|
|
2690
|
-
message: "Invalid API key. Please run `
|
|
2689
|
+
throw new CLIError({
|
|
2690
|
+
message: "Invalid API key. Please run `lingo.dev auth --login` to authenticate.",
|
|
2691
2691
|
docUrl: "authError"
|
|
2692
2692
|
});
|
|
2693
2693
|
}
|
|
@@ -2695,22 +2695,22 @@ async function validateAuth(settings) {
|
|
|
2695
2695
|
}
|
|
2696
2696
|
function validateParams(i18nConfig, flags) {
|
|
2697
2697
|
if (!i18nConfig) {
|
|
2698
|
-
throw new
|
|
2699
|
-
message: "i18n.json not found. Please run `
|
|
2698
|
+
throw new CLIError({
|
|
2699
|
+
message: "i18n.json not found. Please run `lingo.dev init` to initialize the project.",
|
|
2700
2700
|
docUrl: "i18nNotFound"
|
|
2701
2701
|
});
|
|
2702
2702
|
} else if (!i18nConfig.buckets || !Object.keys(i18nConfig.buckets).length) {
|
|
2703
|
-
throw new
|
|
2703
|
+
throw new CLIError({
|
|
2704
2704
|
message: "No buckets found in i18n.json. Please add at least one bucket containing i18n content.",
|
|
2705
2705
|
docUrl: "bucketNotFound"
|
|
2706
2706
|
});
|
|
2707
2707
|
} else if (flags.locale?.some((locale) => !i18nConfig.locale.targets.includes(locale))) {
|
|
2708
|
-
throw new
|
|
2708
|
+
throw new CLIError({
|
|
2709
2709
|
message: `One or more specified locales do not exist in i18n.json locale.targets. Please add them to the list and try again.`,
|
|
2710
2710
|
docUrl: "localeTargetNotFound"
|
|
2711
2711
|
});
|
|
2712
2712
|
} else if (flags.bucket?.some((bucket) => !i18nConfig.buckets[bucket])) {
|
|
2713
|
-
throw new
|
|
2713
|
+
throw new CLIError({
|
|
2714
2714
|
message: `One or more specified buckets do not exist in i18n.json. Please add them to the list and try again.`,
|
|
2715
2715
|
docUrl: "bucketNotFound"
|
|
2716
2716
|
});
|
|
@@ -2910,13 +2910,13 @@ var cleanup_default = new Command8().command("cleanup").description("Remove keys
|
|
|
2910
2910
|
});
|
|
2911
2911
|
function validateConfig(i18nConfig) {
|
|
2912
2912
|
if (!i18nConfig) {
|
|
2913
|
-
throw new
|
|
2914
|
-
message: "i18n.json not found. Please run `
|
|
2913
|
+
throw new CLIError({
|
|
2914
|
+
message: "i18n.json not found. Please run `lingo.dev init` to initialize the project.",
|
|
2915
2915
|
docUrl: "i18nNotFound"
|
|
2916
2916
|
});
|
|
2917
2917
|
}
|
|
2918
2918
|
if (!i18nConfig.buckets || !Object.keys(i18nConfig.buckets).length) {
|
|
2919
|
-
throw new
|
|
2919
|
+
throw new CLIError({
|
|
2920
2920
|
message: "No buckets found in i18n.json. Please add at least one bucket containing i18n content.",
|
|
2921
2921
|
docUrl: "bucketNotFound"
|
|
2922
2922
|
});
|
|
@@ -2934,7 +2934,7 @@ function displaySummary(results) {
|
|
|
2934
2934
|
// package.json
|
|
2935
2935
|
var package_default = {
|
|
2936
2936
|
name: "lingo.dev",
|
|
2937
|
-
version: "0.70.
|
|
2937
|
+
version: "0.70.4",
|
|
2938
2938
|
description: "Lingo.dev CLI",
|
|
2939
2939
|
private: false,
|
|
2940
2940
|
type: "module",
|
|
@@ -3049,7 +3049,7 @@ var package_default = {
|
|
|
3049
3049
|
|
|
3050
3050
|
// src/cli/index.ts
|
|
3051
3051
|
dotenv.config();
|
|
3052
|
-
var cli_default = new InteractiveCommand2().name("
|
|
3052
|
+
var cli_default = new InteractiveCommand2().name("lingo.dev").description("Lingo.dev CLI").helpOption("-h, --help", "Show help").addHelpText(
|
|
3053
3053
|
"beforeAll",
|
|
3054
3054
|
`
|
|
3055
3055
|
Lingo.dev CLI
|
package/build/sdk.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkMNP3B6L4cjs = require('./chunk-MNP3B6L4.cjs');
|
|
4
4
|
require('./chunk-DTGLPBE5.cjs');
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
exports.ReplexicaEngine =
|
|
7
|
+
exports.ReplexicaEngine = _chunkMNP3B6L4cjs.ReplexicaEngine;
|
package/build/sdk.mjs
CHANGED