lingo.dev 0.78.11 → 0.78.13
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/build/cli.cjs +99 -49
- package/build/cli.cjs.map +1 -1
- package/build/cli.mjs +67 -17
- package/build/cli.mjs.map +1 -1
- package/package.json +1 -1
package/build/cli.mjs
CHANGED
|
@@ -23,6 +23,7 @@ function getSettings(explicitApiKey) {
|
|
|
23
23
|
const systemFile = _loadSystemFile();
|
|
24
24
|
const defaults = _loadDefaults();
|
|
25
25
|
_legacyEnvVarWarning();
|
|
26
|
+
_envVarsInfo();
|
|
26
27
|
return {
|
|
27
28
|
auth: {
|
|
28
29
|
apiKey: explicitApiKey || env.LINGODOTDEV_API_KEY || systemFile.auth?.apiKey || defaults.auth.apiKey,
|
|
@@ -95,6 +96,22 @@ Please use LINGODOTDEV_API_KEY instead.
|
|
|
95
96
|
);
|
|
96
97
|
}
|
|
97
98
|
}
|
|
99
|
+
function _envVarsInfo() {
|
|
100
|
+
const env = _loadEnv();
|
|
101
|
+
const systemFile = _loadSystemFile();
|
|
102
|
+
if (env.LINGODOTDEV_API_KEY && systemFile.auth?.apiKey) {
|
|
103
|
+
console.info(
|
|
104
|
+
"\x1B[36m%s\x1B[0m",
|
|
105
|
+
`\u2139\uFE0F Using LINGODOTDEV_API_KEY env var instead of credentials from login flow (saved in .lingodotdevrc)`
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
if (env.LINGODOTDEV_API_URL) {
|
|
109
|
+
console.info("\x1B[36m%s\x1B[0m", `\u2139\uFE0F Using LINGODOTDEV_API_URL: ${env.LINGODOTDEV_API_URL}`);
|
|
110
|
+
}
|
|
111
|
+
if (env.LINGODOTDEV_WEB_URL) {
|
|
112
|
+
console.info("\x1B[36m%s\x1B[0m", `\u2139\uFE0F Using LINGODOTDEV_WEB_URL: ${env.LINGODOTDEV_WEB_URL}`);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
98
115
|
|
|
99
116
|
// src/cli/utils/errors.ts
|
|
100
117
|
var docLinks = {
|
|
@@ -1793,8 +1810,10 @@ function createXcodeXcstringsLoader(defaultLocale) {
|
|
|
1793
1810
|
}
|
|
1794
1811
|
|
|
1795
1812
|
// src/cli/loaders/prettier.ts
|
|
1813
|
+
import fs9 from "fs";
|
|
1796
1814
|
import path11 from "path";
|
|
1797
1815
|
import prettier from "prettier";
|
|
1816
|
+
import { execSync } from "child_process";
|
|
1798
1817
|
function createPrettierLoader(options) {
|
|
1799
1818
|
return createLoader({
|
|
1800
1819
|
async pull(locale, data) {
|
|
@@ -1807,7 +1826,7 @@ function createPrettierLoader(options) {
|
|
|
1807
1826
|
if (!prettierConfig) {
|
|
1808
1827
|
return data;
|
|
1809
1828
|
}
|
|
1810
|
-
const
|
|
1829
|
+
const config = {
|
|
1811
1830
|
...prettierConfig || { printWidth: 2500, bracketSameLine: false },
|
|
1812
1831
|
parser: options.parser,
|
|
1813
1832
|
// For HTML parser, preserve comments and quotes
|
|
@@ -1816,8 +1835,22 @@ function createPrettierLoader(options) {
|
|
|
1816
1835
|
singleQuote: false,
|
|
1817
1836
|
embeddedLanguageFormatting: "off"
|
|
1818
1837
|
} : {}
|
|
1819
|
-
}
|
|
1820
|
-
|
|
1838
|
+
};
|
|
1839
|
+
try {
|
|
1840
|
+
const result = await prettier.format(data, config);
|
|
1841
|
+
return result;
|
|
1842
|
+
} catch (error) {
|
|
1843
|
+
if (error instanceof Error && error.message.startsWith("Cannot find package")) {
|
|
1844
|
+
console.log();
|
|
1845
|
+
console.log("Prettier is missing some dependecies - installing all project dependencies");
|
|
1846
|
+
installDependencies();
|
|
1847
|
+
await prettier.clearConfigCache();
|
|
1848
|
+
const result = await prettier.format(data, config);
|
|
1849
|
+
return result;
|
|
1850
|
+
} else {
|
|
1851
|
+
throw error;
|
|
1852
|
+
}
|
|
1853
|
+
}
|
|
1821
1854
|
}
|
|
1822
1855
|
});
|
|
1823
1856
|
}
|
|
@@ -1829,6 +1862,23 @@ async function loadPrettierConfig(filePath) {
|
|
|
1829
1862
|
return {};
|
|
1830
1863
|
}
|
|
1831
1864
|
}
|
|
1865
|
+
async function installDependencies() {
|
|
1866
|
+
const packageManager = await getPackageManager();
|
|
1867
|
+
console.log(`Installing dependencies using ${packageManager}`);
|
|
1868
|
+
execSync(`${packageManager} install --frozen-lockfile`, { stdio: "inherit" });
|
|
1869
|
+
console.log(`Dependencies installed`);
|
|
1870
|
+
}
|
|
1871
|
+
async function getPackageManager() {
|
|
1872
|
+
const yarnLockfile = path11.resolve(process.cwd(), "yarn.lock");
|
|
1873
|
+
const pnpmLockfile = path11.resolve(process.cwd(), "pnpm-lock.yaml");
|
|
1874
|
+
if (fs9.existsSync(yarnLockfile)) {
|
|
1875
|
+
return "yarn";
|
|
1876
|
+
}
|
|
1877
|
+
if (fs9.existsSync(pnpmLockfile)) {
|
|
1878
|
+
return "pnpm";
|
|
1879
|
+
}
|
|
1880
|
+
return "npm";
|
|
1881
|
+
}
|
|
1832
1882
|
|
|
1833
1883
|
// src/cli/loaders/unlocalizable.ts
|
|
1834
1884
|
import _10 from "lodash";
|
|
@@ -2043,7 +2093,7 @@ function createSrtLoader() {
|
|
|
2043
2093
|
}
|
|
2044
2094
|
|
|
2045
2095
|
// src/cli/loaders/dato/index.ts
|
|
2046
|
-
import
|
|
2096
|
+
import fs10 from "fs";
|
|
2047
2097
|
import JSON5 from "json5";
|
|
2048
2098
|
|
|
2049
2099
|
// src/cli/loaders/dato/_base.ts
|
|
@@ -2642,12 +2692,12 @@ function _isVideo(rawDatoValue) {
|
|
|
2642
2692
|
// src/cli/loaders/dato/index.ts
|
|
2643
2693
|
function createDatoLoader(configFilePath) {
|
|
2644
2694
|
try {
|
|
2645
|
-
const configContent =
|
|
2695
|
+
const configContent = fs10.readFileSync(configFilePath, "utf-8");
|
|
2646
2696
|
const datoConfig = datoConfigSchema.parse(JSON5.parse(configContent));
|
|
2647
2697
|
return composeLoaders(
|
|
2648
2698
|
createDatoApiLoader(
|
|
2649
2699
|
datoConfig,
|
|
2650
|
-
(updatedConfig) =>
|
|
2700
|
+
(updatedConfig) => fs10.writeFileSync(configFilePath, JSON5.stringify(updatedConfig, null, 2))
|
|
2651
2701
|
),
|
|
2652
2702
|
createDatoFilterLoader(),
|
|
2653
2703
|
createDatoExtractLoader()
|
|
@@ -3112,7 +3162,7 @@ function createBucketLoader(bucketType, bucketPathPattern, options) {
|
|
|
3112
3162
|
}
|
|
3113
3163
|
|
|
3114
3164
|
// src/cli/utils/lockfile.ts
|
|
3115
|
-
import
|
|
3165
|
+
import fs11 from "fs";
|
|
3116
3166
|
import path12 from "path";
|
|
3117
3167
|
import Z3 from "zod";
|
|
3118
3168
|
import YAML3 from "yaml";
|
|
@@ -3122,7 +3172,7 @@ function createLockfileHelper() {
|
|
|
3122
3172
|
return {
|
|
3123
3173
|
isLockfileExists: () => {
|
|
3124
3174
|
const lockfilePath = _getLockfilePath();
|
|
3125
|
-
return
|
|
3175
|
+
return fs11.existsSync(lockfilePath);
|
|
3126
3176
|
},
|
|
3127
3177
|
registerSourceData: (pathPattern, sourceData) => {
|
|
3128
3178
|
const lockfile = _loadLockfile();
|
|
@@ -3149,17 +3199,17 @@ function createLockfileHelper() {
|
|
|
3149
3199
|
};
|
|
3150
3200
|
function _loadLockfile() {
|
|
3151
3201
|
const lockfilePath = _getLockfilePath();
|
|
3152
|
-
if (!
|
|
3202
|
+
if (!fs11.existsSync(lockfilePath)) {
|
|
3153
3203
|
return LockfileSchema.parse({});
|
|
3154
3204
|
}
|
|
3155
|
-
const content =
|
|
3205
|
+
const content = fs11.readFileSync(lockfilePath, "utf-8");
|
|
3156
3206
|
const result = LockfileSchema.parse(YAML3.parse(content));
|
|
3157
3207
|
return result;
|
|
3158
3208
|
}
|
|
3159
3209
|
function _saveLockfile(lockfile) {
|
|
3160
3210
|
const lockfilePath = _getLockfilePath();
|
|
3161
3211
|
const content = YAML3.stringify(lockfile);
|
|
3162
|
-
|
|
3212
|
+
fs11.writeFileSync(lockfilePath, content);
|
|
3163
3213
|
}
|
|
3164
3214
|
function _getLockfilePath() {
|
|
3165
3215
|
return path12.join(process.cwd(), "i18n.lock");
|
|
@@ -3188,7 +3238,7 @@ import externalEditor from "external-editor";
|
|
|
3188
3238
|
|
|
3189
3239
|
// src/cli/utils/cache.ts
|
|
3190
3240
|
import path13 from "path";
|
|
3191
|
-
import
|
|
3241
|
+
import fs12 from "fs";
|
|
3192
3242
|
var cacheChunk = (targetLocale, sourceChunk, processedChunk) => {
|
|
3193
3243
|
const rows = Object.entries(sourceChunk).map(([key, source]) => ({
|
|
3194
3244
|
targetLocale,
|
|
@@ -3218,23 +3268,23 @@ function getNormalizedCache() {
|
|
|
3218
3268
|
function deleteCache() {
|
|
3219
3269
|
const cacheFilePath = _getCacheFilePath();
|
|
3220
3270
|
try {
|
|
3221
|
-
|
|
3271
|
+
fs12.unlinkSync(cacheFilePath);
|
|
3222
3272
|
} catch (e) {
|
|
3223
3273
|
}
|
|
3224
3274
|
}
|
|
3225
3275
|
function _loadCache() {
|
|
3226
3276
|
const cacheFilePath = _getCacheFilePath();
|
|
3227
|
-
if (!
|
|
3277
|
+
if (!fs12.existsSync(cacheFilePath)) {
|
|
3228
3278
|
return [];
|
|
3229
3279
|
}
|
|
3230
|
-
const content =
|
|
3280
|
+
const content = fs12.readFileSync(cacheFilePath, "utf-8");
|
|
3231
3281
|
const result = _parseJSONLines(content);
|
|
3232
3282
|
return result;
|
|
3233
3283
|
}
|
|
3234
3284
|
function _appendToCache(rows) {
|
|
3235
3285
|
const cacheFilePath = _getCacheFilePath();
|
|
3236
3286
|
const lines = _buildJSONLines(rows);
|
|
3237
|
-
|
|
3287
|
+
fs12.appendFileSync(cacheFilePath, lines);
|
|
3238
3288
|
}
|
|
3239
3289
|
function _getCacheFilePath() {
|
|
3240
3290
|
return path13.join(process.cwd(), "i18n.cache");
|
|
@@ -3899,7 +3949,7 @@ var mcp_default = new Command9().command("mcp").description("Use Lingo.dev model
|
|
|
3899
3949
|
// package.json
|
|
3900
3950
|
var package_default = {
|
|
3901
3951
|
name: "lingo.dev",
|
|
3902
|
-
version: "0.78.
|
|
3952
|
+
version: "0.78.13",
|
|
3903
3953
|
description: "Lingo.dev CLI",
|
|
3904
3954
|
private: false,
|
|
3905
3955
|
publishConfig: {
|