lingo.dev 0.79.2 → 0.79.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.
- package/build/cli.cjs +5 -23
- package/build/cli.cjs.map +1 -1
- package/build/cli.mjs +54 -72
- package/build/cli.mjs.map +1 -1
- package/package.json +3 -3
package/build/cli.mjs
CHANGED
|
@@ -1815,10 +1815,8 @@ function createXcodeXcstringsLoader(defaultLocale) {
|
|
|
1815
1815
|
}
|
|
1816
1816
|
|
|
1817
1817
|
// src/cli/loaders/prettier.ts
|
|
1818
|
-
import fs9 from "fs";
|
|
1819
1818
|
import path11 from "path";
|
|
1820
1819
|
import prettier from "prettier";
|
|
1821
|
-
import { execSync } from "child_process";
|
|
1822
1820
|
function createPrettierLoader(options) {
|
|
1823
1821
|
return createLoader({
|
|
1824
1822
|
async pull(locale, data) {
|
|
@@ -1847,8 +1845,9 @@ function createPrettierLoader(options) {
|
|
|
1847
1845
|
} catch (error) {
|
|
1848
1846
|
if (error instanceof Error && error.message.startsWith("Cannot find package")) {
|
|
1849
1847
|
console.log();
|
|
1850
|
-
console.log("Prettier
|
|
1851
|
-
|
|
1848
|
+
console.log("\u26A0\uFE0F Prettier plugins are not installed. Formatting without plugins.");
|
|
1849
|
+
console.log("\u26A0\uFE0F To use prettier plugins install project dependencies before running Lingo.dev.");
|
|
1850
|
+
config.plugins = [];
|
|
1852
1851
|
await prettier.clearConfigCache();
|
|
1853
1852
|
const result = await prettier.format(data, config);
|
|
1854
1853
|
return result;
|
|
@@ -1867,23 +1866,6 @@ async function loadPrettierConfig(filePath) {
|
|
|
1867
1866
|
return {};
|
|
1868
1867
|
}
|
|
1869
1868
|
}
|
|
1870
|
-
async function installDependencies() {
|
|
1871
|
-
const packageManager = await getPackageManager();
|
|
1872
|
-
console.log(`Installing dependencies using ${packageManager}`);
|
|
1873
|
-
execSync(`${packageManager} install --frozen-lockfile`, { stdio: "inherit" });
|
|
1874
|
-
console.log(`Dependencies installed`);
|
|
1875
|
-
}
|
|
1876
|
-
async function getPackageManager() {
|
|
1877
|
-
const yarnLockfile = path11.resolve(process.cwd(), "yarn.lock");
|
|
1878
|
-
const pnpmLockfile = path11.resolve(process.cwd(), "pnpm-lock.yaml");
|
|
1879
|
-
if (fs9.existsSync(yarnLockfile)) {
|
|
1880
|
-
return "yarn";
|
|
1881
|
-
}
|
|
1882
|
-
if (fs9.existsSync(pnpmLockfile)) {
|
|
1883
|
-
return "pnpm";
|
|
1884
|
-
}
|
|
1885
|
-
return "npm";
|
|
1886
|
-
}
|
|
1887
1869
|
|
|
1888
1870
|
// src/cli/loaders/unlocalizable.ts
|
|
1889
1871
|
import _10 from "lodash";
|
|
@@ -2098,7 +2080,7 @@ function createSrtLoader() {
|
|
|
2098
2080
|
}
|
|
2099
2081
|
|
|
2100
2082
|
// src/cli/loaders/dato/index.ts
|
|
2101
|
-
import
|
|
2083
|
+
import fs9 from "fs";
|
|
2102
2084
|
import JSON5 from "json5";
|
|
2103
2085
|
|
|
2104
2086
|
// src/cli/loaders/dato/_base.ts
|
|
@@ -2697,12 +2679,12 @@ function _isVideo(rawDatoValue) {
|
|
|
2697
2679
|
// src/cli/loaders/dato/index.ts
|
|
2698
2680
|
function createDatoLoader(configFilePath) {
|
|
2699
2681
|
try {
|
|
2700
|
-
const configContent =
|
|
2682
|
+
const configContent = fs9.readFileSync(configFilePath, "utf-8");
|
|
2701
2683
|
const datoConfig = datoConfigSchema.parse(JSON5.parse(configContent));
|
|
2702
2684
|
return composeLoaders(
|
|
2703
2685
|
createDatoApiLoader(
|
|
2704
2686
|
datoConfig,
|
|
2705
|
-
(updatedConfig) =>
|
|
2687
|
+
(updatedConfig) => fs9.writeFileSync(configFilePath, JSON5.stringify(updatedConfig, null, 2))
|
|
2706
2688
|
),
|
|
2707
2689
|
createDatoFilterLoader(),
|
|
2708
2690
|
createDatoExtractLoader()
|
|
@@ -3196,7 +3178,7 @@ function createBucketLoader(bucketType, bucketPathPattern, options) {
|
|
|
3196
3178
|
}
|
|
3197
3179
|
|
|
3198
3180
|
// src/cli/utils/lockfile.ts
|
|
3199
|
-
import
|
|
3181
|
+
import fs10 from "fs";
|
|
3200
3182
|
import path12 from "path";
|
|
3201
3183
|
import Z3 from "zod";
|
|
3202
3184
|
import YAML3 from "yaml";
|
|
@@ -3206,7 +3188,7 @@ function createLockfileHelper() {
|
|
|
3206
3188
|
return {
|
|
3207
3189
|
isLockfileExists: () => {
|
|
3208
3190
|
const lockfilePath = _getLockfilePath();
|
|
3209
|
-
return
|
|
3191
|
+
return fs10.existsSync(lockfilePath);
|
|
3210
3192
|
},
|
|
3211
3193
|
registerSourceData: (pathPattern, sourceData) => {
|
|
3212
3194
|
const lockfile = _loadLockfile();
|
|
@@ -3233,17 +3215,17 @@ function createLockfileHelper() {
|
|
|
3233
3215
|
};
|
|
3234
3216
|
function _loadLockfile() {
|
|
3235
3217
|
const lockfilePath = _getLockfilePath();
|
|
3236
|
-
if (!
|
|
3218
|
+
if (!fs10.existsSync(lockfilePath)) {
|
|
3237
3219
|
return LockfileSchema.parse({});
|
|
3238
3220
|
}
|
|
3239
|
-
const content =
|
|
3221
|
+
const content = fs10.readFileSync(lockfilePath, "utf-8");
|
|
3240
3222
|
const result = LockfileSchema.parse(YAML3.parse(content));
|
|
3241
3223
|
return result;
|
|
3242
3224
|
}
|
|
3243
3225
|
function _saveLockfile(lockfile) {
|
|
3244
3226
|
const lockfilePath = _getLockfilePath();
|
|
3245
3227
|
const content = YAML3.stringify(lockfile);
|
|
3246
|
-
|
|
3228
|
+
fs10.writeFileSync(lockfilePath, content);
|
|
3247
3229
|
}
|
|
3248
3230
|
function _getLockfilePath() {
|
|
3249
3231
|
return path12.join(process.cwd(), "i18n.lock");
|
|
@@ -3272,7 +3254,7 @@ import externalEditor from "external-editor";
|
|
|
3272
3254
|
|
|
3273
3255
|
// src/cli/utils/cache.ts
|
|
3274
3256
|
import path13 from "path";
|
|
3275
|
-
import
|
|
3257
|
+
import fs11 from "fs";
|
|
3276
3258
|
var cacheChunk = (targetLocale, sourceChunk, processedChunk) => {
|
|
3277
3259
|
const rows = Object.entries(sourceChunk).map(([key, source]) => ({
|
|
3278
3260
|
targetLocale,
|
|
@@ -3302,23 +3284,23 @@ function getNormalizedCache() {
|
|
|
3302
3284
|
function deleteCache() {
|
|
3303
3285
|
const cacheFilePath = _getCacheFilePath();
|
|
3304
3286
|
try {
|
|
3305
|
-
|
|
3287
|
+
fs11.unlinkSync(cacheFilePath);
|
|
3306
3288
|
} catch (e) {
|
|
3307
3289
|
}
|
|
3308
3290
|
}
|
|
3309
3291
|
function _loadCache() {
|
|
3310
3292
|
const cacheFilePath = _getCacheFilePath();
|
|
3311
|
-
if (!
|
|
3293
|
+
if (!fs11.existsSync(cacheFilePath)) {
|
|
3312
3294
|
return [];
|
|
3313
3295
|
}
|
|
3314
|
-
const content =
|
|
3296
|
+
const content = fs11.readFileSync(cacheFilePath, "utf-8");
|
|
3315
3297
|
const result = _parseJSONLines(content);
|
|
3316
3298
|
return result;
|
|
3317
3299
|
}
|
|
3318
3300
|
function _appendToCache(rows) {
|
|
3319
3301
|
const cacheFilePath = _getCacheFilePath();
|
|
3320
3302
|
const lines = _buildJSONLines(rows);
|
|
3321
|
-
|
|
3303
|
+
fs11.appendFileSync(cacheFilePath, lines);
|
|
3322
3304
|
}
|
|
3323
3305
|
function _getCacheFilePath() {
|
|
3324
3306
|
return path13.join(process.cwd(), "i18n.cache");
|
|
@@ -4028,10 +4010,10 @@ import { Command as Command10 } from "interactive-commander";
|
|
|
4028
4010
|
import createOra from "ora";
|
|
4029
4011
|
|
|
4030
4012
|
// ../../action/src/flows/pull-request.ts
|
|
4031
|
-
import { execSync as
|
|
4013
|
+
import { execSync as execSync2 } from "child_process";
|
|
4032
4014
|
|
|
4033
4015
|
// ../../action/src/flows/in-branch.ts
|
|
4034
|
-
import { execSync
|
|
4016
|
+
import { execSync } from "child_process";
|
|
4035
4017
|
import path14 from "path";
|
|
4036
4018
|
|
|
4037
4019
|
// ../../action/src/flows/_base.ts
|
|
@@ -4059,21 +4041,21 @@ var InBranchFlow = class extends IntegrationFlow {
|
|
|
4059
4041
|
this.ora.start("Running Lingo.dev");
|
|
4060
4042
|
await this.runLingoDotDev();
|
|
4061
4043
|
this.ora.succeed("Done running Lingo.dev");
|
|
4062
|
-
|
|
4044
|
+
execSync(`rm -f i18n.cache`, { stdio: "inherit" });
|
|
4063
4045
|
this.ora.start("Checking for changes");
|
|
4064
4046
|
const hasChanges = this.checkCommitableChanges();
|
|
4065
4047
|
this.ora.succeed(hasChanges ? "Changes detected" : "No changes detected");
|
|
4066
4048
|
if (hasChanges) {
|
|
4067
4049
|
this.ora.start("Committing changes");
|
|
4068
|
-
|
|
4069
|
-
|
|
4070
|
-
|
|
4050
|
+
execSync(`git add .`, { stdio: "inherit" });
|
|
4051
|
+
execSync(`git status --porcelain`, { stdio: "inherit" });
|
|
4052
|
+
execSync(`git commit -m "${this.platformKit.config.commitMessage}"`, {
|
|
4071
4053
|
stdio: "inherit"
|
|
4072
4054
|
});
|
|
4073
4055
|
this.ora.succeed("Changes committed");
|
|
4074
4056
|
this.ora.start("Pushing changes to remote");
|
|
4075
4057
|
const currentBranch = this.i18nBranchName ?? this.platformKit.platformConfig.baseBranchName;
|
|
4076
|
-
|
|
4058
|
+
execSync(`git push origin ${currentBranch} ${forcePush ? "--force" : ""}`, {
|
|
4077
4059
|
stdio: "inherit"
|
|
4078
4060
|
});
|
|
4079
4061
|
this.ora.succeed("Changes pushed to remote");
|
|
@@ -4081,28 +4063,28 @@ var InBranchFlow = class extends IntegrationFlow {
|
|
|
4081
4063
|
return hasChanges;
|
|
4082
4064
|
}
|
|
4083
4065
|
checkCommitableChanges() {
|
|
4084
|
-
return
|
|
4066
|
+
return execSync('git status --porcelain || echo "has_changes"', {
|
|
4085
4067
|
encoding: "utf8"
|
|
4086
4068
|
}).length > 0;
|
|
4087
4069
|
}
|
|
4088
4070
|
async runLingoDotDev() {
|
|
4089
|
-
|
|
4071
|
+
execSync(`npx lingo.dev@latest i18n --api-key ${this.platformKit.config.replexicaApiKey}`, { stdio: "inherit" });
|
|
4090
4072
|
}
|
|
4091
4073
|
configureGit() {
|
|
4092
4074
|
const { processOwnCommits } = this.platformKit.config;
|
|
4093
4075
|
const { baseBranchName } = this.platformKit.platformConfig;
|
|
4094
4076
|
this.ora.info(`Current working directory:`);
|
|
4095
|
-
|
|
4096
|
-
|
|
4097
|
-
|
|
4098
|
-
|
|
4099
|
-
|
|
4077
|
+
execSync(`pwd`, { stdio: "inherit" });
|
|
4078
|
+
execSync(`ls -la`, { stdio: "inherit" });
|
|
4079
|
+
execSync(`git config --global safe.directory ${process.cwd()}`);
|
|
4080
|
+
execSync(`git config user.name "${gitConfig.userName}"`);
|
|
4081
|
+
execSync(`git config user.email "${gitConfig.userEmail}"`);
|
|
4100
4082
|
this.platformKit?.gitConfig();
|
|
4101
|
-
|
|
4102
|
-
|
|
4083
|
+
execSync(`git fetch origin ${baseBranchName}`, { stdio: "inherit" });
|
|
4084
|
+
execSync(`git checkout ${baseBranchName} --`, { stdio: "inherit" });
|
|
4103
4085
|
if (!processOwnCommits) {
|
|
4104
4086
|
const currentAuthor = `${gitConfig.userName} <${gitConfig.userEmail}>`;
|
|
4105
|
-
const authorOfLastCommit =
|
|
4087
|
+
const authorOfLastCommit = execSync(`git log -1 --pretty=format:'%an <%ae>'`).toString();
|
|
4106
4088
|
if (authorOfLastCommit === currentAuthor) {
|
|
4107
4089
|
this.ora.warn(
|
|
4108
4090
|
`The last commit was already made by ${currentAuthor}, so this run will be skipped, as running again would have no effect. See docs: https://docs.lingo.dev/ci-action/overview`
|
|
@@ -4186,15 +4168,15 @@ var PullRequestFlow = class extends InBranchFlow {
|
|
|
4186
4168
|
return prNumber;
|
|
4187
4169
|
}
|
|
4188
4170
|
checkoutI18nBranch(i18nBranchName) {
|
|
4189
|
-
|
|
4190
|
-
|
|
4171
|
+
execSync2(`git fetch origin ${i18nBranchName}`, { stdio: "inherit" });
|
|
4172
|
+
execSync2(`git checkout -b ${i18nBranchName}`, {
|
|
4191
4173
|
stdio: "inherit"
|
|
4192
4174
|
});
|
|
4193
4175
|
}
|
|
4194
4176
|
createI18nBranch(i18nBranchName) {
|
|
4195
4177
|
try {
|
|
4196
|
-
|
|
4197
|
-
|
|
4178
|
+
execSync2(`git fetch origin ${this.platformKit.platformConfig.baseBranchName}`, { stdio: "inherit" });
|
|
4179
|
+
execSync2(`git checkout -b ${i18nBranchName} origin/${this.platformKit.platformConfig.baseBranchName}`, {
|
|
4198
4180
|
stdio: "inherit"
|
|
4199
4181
|
});
|
|
4200
4182
|
} catch (error) {
|
|
@@ -4214,31 +4196,31 @@ var PullRequestFlow = class extends InBranchFlow {
|
|
|
4214
4196
|
throw new Error("i18nBranchName is not set");
|
|
4215
4197
|
}
|
|
4216
4198
|
this.ora.start(`Fetching latest changes from ${this.platformKit.platformConfig.baseBranchName}`);
|
|
4217
|
-
|
|
4199
|
+
execSync2(`git fetch origin ${this.platformKit.platformConfig.baseBranchName}`, { stdio: "inherit" });
|
|
4218
4200
|
this.ora.succeed(`Fetched latest changes from ${this.platformKit.platformConfig.baseBranchName}`);
|
|
4219
4201
|
try {
|
|
4220
4202
|
this.ora.start("Attempting to rebase branch");
|
|
4221
|
-
|
|
4203
|
+
execSync2(`git rebase origin/${this.platformKit.platformConfig.baseBranchName}`, { stdio: "inherit" });
|
|
4222
4204
|
this.ora.succeed("Successfully rebased branch");
|
|
4223
4205
|
} catch (error) {
|
|
4224
4206
|
this.ora.warn("Rebase failed, falling back to alternative sync method");
|
|
4225
4207
|
this.ora.start("Aborting failed rebase");
|
|
4226
|
-
|
|
4208
|
+
execSync2("git rebase --abort", { stdio: "inherit" });
|
|
4227
4209
|
this.ora.succeed("Aborted failed rebase");
|
|
4228
4210
|
this.ora.start(`Resetting to ${this.platformKit.platformConfig.baseBranchName}`);
|
|
4229
|
-
|
|
4211
|
+
execSync2(`git reset --hard origin/${this.platformKit.platformConfig.baseBranchName}`, { stdio: "inherit" });
|
|
4230
4212
|
this.ora.succeed(`Reset to ${this.platformKit.platformConfig.baseBranchName}`);
|
|
4231
4213
|
this.ora.start("Restoring target files");
|
|
4232
4214
|
const targetFiles = ["i18n.lock"];
|
|
4233
|
-
const targetFileNames =
|
|
4215
|
+
const targetFileNames = execSync2(
|
|
4234
4216
|
`npx lingo.dev@latest show files --target ${this.platformKit.platformConfig.baseBranchName}`,
|
|
4235
4217
|
{ encoding: "utf8" }
|
|
4236
4218
|
).split("\n").filter(Boolean);
|
|
4237
4219
|
targetFiles.push(...targetFileNames);
|
|
4238
|
-
|
|
4220
|
+
execSync2(`git fetch origin ${this.i18nBranchName}`, { stdio: "inherit" });
|
|
4239
4221
|
for (const file of targetFiles) {
|
|
4240
4222
|
try {
|
|
4241
|
-
|
|
4223
|
+
execSync2(`git checkout FETCH_HEAD -- ${file}`, { stdio: "inherit" });
|
|
4242
4224
|
} catch (error2) {
|
|
4243
4225
|
this.ora.warn(`Skipping non-existent file: ${file}`);
|
|
4244
4226
|
continue;
|
|
@@ -4249,8 +4231,8 @@ var PullRequestFlow = class extends InBranchFlow {
|
|
|
4249
4231
|
this.ora.start("Checking for changes to commit");
|
|
4250
4232
|
const hasChanges = this.checkCommitableChanges();
|
|
4251
4233
|
if (hasChanges) {
|
|
4252
|
-
|
|
4253
|
-
|
|
4234
|
+
execSync2("git add .", { stdio: "inherit" });
|
|
4235
|
+
execSync2(`git commit -m "chore: sync with ${this.platformKit.platformConfig.baseBranchName}"`, {
|
|
4254
4236
|
stdio: "inherit"
|
|
4255
4237
|
});
|
|
4256
4238
|
this.ora.succeed("Committed additional changes");
|
|
@@ -4279,7 +4261,7 @@ Hey team,
|
|
|
4279
4261
|
};
|
|
4280
4262
|
|
|
4281
4263
|
// ../../action/src/platforms/bitbucket.ts
|
|
4282
|
-
import { execSync as
|
|
4264
|
+
import { execSync as execSync3 } from "child_process";
|
|
4283
4265
|
import bbLib from "bitbucket";
|
|
4284
4266
|
import Z8 from "zod";
|
|
4285
4267
|
|
|
@@ -4371,10 +4353,10 @@ var BitbucketPlatformKit = class extends PlatformKit {
|
|
|
4371
4353
|
});
|
|
4372
4354
|
}
|
|
4373
4355
|
async gitConfig() {
|
|
4374
|
-
|
|
4356
|
+
execSync3("git config --unset http.${BITBUCKET_GIT_HTTP_ORIGIN}.proxy", {
|
|
4375
4357
|
stdio: "inherit"
|
|
4376
4358
|
});
|
|
4377
|
-
|
|
4359
|
+
execSync3("git config http.${BITBUCKET_GIT_HTTP_ORIGIN}.proxy http://host.docker.internal:29418/", {
|
|
4378
4360
|
stdio: "inherit"
|
|
4379
4361
|
});
|
|
4380
4362
|
}
|
|
@@ -4401,7 +4383,7 @@ var BitbucketPlatformKit = class extends PlatformKit {
|
|
|
4401
4383
|
// ../../action/src/platforms/github.ts
|
|
4402
4384
|
import { Octokit } from "octokit";
|
|
4403
4385
|
import Z9 from "zod";
|
|
4404
|
-
import { execSync as
|
|
4386
|
+
import { execSync as execSync4 } from "child_process";
|
|
4405
4387
|
var GitHubPlatformKit = class extends PlatformKit {
|
|
4406
4388
|
_octokit;
|
|
4407
4389
|
get octokit() {
|
|
@@ -4458,7 +4440,7 @@ var GitHubPlatformKit = class extends PlatformKit {
|
|
|
4458
4440
|
if (ghToken && processOwnCommits) {
|
|
4459
4441
|
console.log("Using provided GH_TOKEN. This will trigger your CI/CD pipeline to run again.");
|
|
4460
4442
|
const url = `https://${ghToken}@github.com/${repositoryOwner}/${repositoryName}.git`;
|
|
4461
|
-
|
|
4443
|
+
execSync4(`git remote set-url origin ${url}`, {
|
|
4462
4444
|
stdio: "inherit"
|
|
4463
4445
|
});
|
|
4464
4446
|
}
|
|
@@ -4488,7 +4470,7 @@ var GitHubPlatformKit = class extends PlatformKit {
|
|
|
4488
4470
|
// ../../action/src/platforms/gitlab.ts
|
|
4489
4471
|
import { Gitlab } from "@gitbeaker/rest";
|
|
4490
4472
|
import Z10 from "zod";
|
|
4491
|
-
import { execSync as
|
|
4473
|
+
import { execSync as execSync5 } from "child_process";
|
|
4492
4474
|
var gl = new Gitlab({ token: "" });
|
|
4493
4475
|
var GitlabPlatformKit = class extends PlatformKit {
|
|
4494
4476
|
_gitlab;
|
|
@@ -4564,7 +4546,7 @@ var GitlabPlatformKit = class extends PlatformKit {
|
|
|
4564
4546
|
}
|
|
4565
4547
|
gitConfig() {
|
|
4566
4548
|
const url = `https://oauth2:${this.platformConfig.glToken}@gitlab.com/${this.platformConfig.repositoryOwner}/${this.platformConfig.repositoryName}.git`;
|
|
4567
|
-
|
|
4549
|
+
execSync5(`git remote set-url origin ${url}`, {
|
|
4568
4550
|
stdio: "inherit"
|
|
4569
4551
|
});
|
|
4570
4552
|
}
|
|
@@ -4637,7 +4619,7 @@ var ci_default = new Command10().command("ci").description("Run Lingo.dev CI/CD
|
|
|
4637
4619
|
// package.json
|
|
4638
4620
|
var package_default = {
|
|
4639
4621
|
name: "lingo.dev",
|
|
4640
|
-
version: "0.79.
|
|
4622
|
+
version: "0.79.4",
|
|
4641
4623
|
description: "Lingo.dev CLI",
|
|
4642
4624
|
private: false,
|
|
4643
4625
|
publishConfig: {
|