lingo.dev 0.79.3 → 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 -27
- package/build/cli.cjs.map +1 -1
- package/build/cli.mjs +54 -76
- 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,27 +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
|
-
if (fs9.existsSync(yarnLockfile)) {
|
|
1879
|
-
return "yarn";
|
|
1880
|
-
}
|
|
1881
|
-
const pnpmLockfile = path11.resolve(process.cwd(), "pnpm-lock.yaml");
|
|
1882
|
-
if (fs9.existsSync(pnpmLockfile)) {
|
|
1883
|
-
return "pnpm";
|
|
1884
|
-
}
|
|
1885
|
-
const bunLockfile = path11.resolve(process.cwd(), "bun.lock");
|
|
1886
|
-
if (fs9.existsSync(bunLockfile)) {
|
|
1887
|
-
return "bun";
|
|
1888
|
-
}
|
|
1889
|
-
return "npm";
|
|
1890
|
-
}
|
|
1891
1869
|
|
|
1892
1870
|
// src/cli/loaders/unlocalizable.ts
|
|
1893
1871
|
import _10 from "lodash";
|
|
@@ -2102,7 +2080,7 @@ function createSrtLoader() {
|
|
|
2102
2080
|
}
|
|
2103
2081
|
|
|
2104
2082
|
// src/cli/loaders/dato/index.ts
|
|
2105
|
-
import
|
|
2083
|
+
import fs9 from "fs";
|
|
2106
2084
|
import JSON5 from "json5";
|
|
2107
2085
|
|
|
2108
2086
|
// src/cli/loaders/dato/_base.ts
|
|
@@ -2701,12 +2679,12 @@ function _isVideo(rawDatoValue) {
|
|
|
2701
2679
|
// src/cli/loaders/dato/index.ts
|
|
2702
2680
|
function createDatoLoader(configFilePath) {
|
|
2703
2681
|
try {
|
|
2704
|
-
const configContent =
|
|
2682
|
+
const configContent = fs9.readFileSync(configFilePath, "utf-8");
|
|
2705
2683
|
const datoConfig = datoConfigSchema.parse(JSON5.parse(configContent));
|
|
2706
2684
|
return composeLoaders(
|
|
2707
2685
|
createDatoApiLoader(
|
|
2708
2686
|
datoConfig,
|
|
2709
|
-
(updatedConfig) =>
|
|
2687
|
+
(updatedConfig) => fs9.writeFileSync(configFilePath, JSON5.stringify(updatedConfig, null, 2))
|
|
2710
2688
|
),
|
|
2711
2689
|
createDatoFilterLoader(),
|
|
2712
2690
|
createDatoExtractLoader()
|
|
@@ -3200,7 +3178,7 @@ function createBucketLoader(bucketType, bucketPathPattern, options) {
|
|
|
3200
3178
|
}
|
|
3201
3179
|
|
|
3202
3180
|
// src/cli/utils/lockfile.ts
|
|
3203
|
-
import
|
|
3181
|
+
import fs10 from "fs";
|
|
3204
3182
|
import path12 from "path";
|
|
3205
3183
|
import Z3 from "zod";
|
|
3206
3184
|
import YAML3 from "yaml";
|
|
@@ -3210,7 +3188,7 @@ function createLockfileHelper() {
|
|
|
3210
3188
|
return {
|
|
3211
3189
|
isLockfileExists: () => {
|
|
3212
3190
|
const lockfilePath = _getLockfilePath();
|
|
3213
|
-
return
|
|
3191
|
+
return fs10.existsSync(lockfilePath);
|
|
3214
3192
|
},
|
|
3215
3193
|
registerSourceData: (pathPattern, sourceData) => {
|
|
3216
3194
|
const lockfile = _loadLockfile();
|
|
@@ -3237,17 +3215,17 @@ function createLockfileHelper() {
|
|
|
3237
3215
|
};
|
|
3238
3216
|
function _loadLockfile() {
|
|
3239
3217
|
const lockfilePath = _getLockfilePath();
|
|
3240
|
-
if (!
|
|
3218
|
+
if (!fs10.existsSync(lockfilePath)) {
|
|
3241
3219
|
return LockfileSchema.parse({});
|
|
3242
3220
|
}
|
|
3243
|
-
const content =
|
|
3221
|
+
const content = fs10.readFileSync(lockfilePath, "utf-8");
|
|
3244
3222
|
const result = LockfileSchema.parse(YAML3.parse(content));
|
|
3245
3223
|
return result;
|
|
3246
3224
|
}
|
|
3247
3225
|
function _saveLockfile(lockfile) {
|
|
3248
3226
|
const lockfilePath = _getLockfilePath();
|
|
3249
3227
|
const content = YAML3.stringify(lockfile);
|
|
3250
|
-
|
|
3228
|
+
fs10.writeFileSync(lockfilePath, content);
|
|
3251
3229
|
}
|
|
3252
3230
|
function _getLockfilePath() {
|
|
3253
3231
|
return path12.join(process.cwd(), "i18n.lock");
|
|
@@ -3276,7 +3254,7 @@ import externalEditor from "external-editor";
|
|
|
3276
3254
|
|
|
3277
3255
|
// src/cli/utils/cache.ts
|
|
3278
3256
|
import path13 from "path";
|
|
3279
|
-
import
|
|
3257
|
+
import fs11 from "fs";
|
|
3280
3258
|
var cacheChunk = (targetLocale, sourceChunk, processedChunk) => {
|
|
3281
3259
|
const rows = Object.entries(sourceChunk).map(([key, source]) => ({
|
|
3282
3260
|
targetLocale,
|
|
@@ -3306,23 +3284,23 @@ function getNormalizedCache() {
|
|
|
3306
3284
|
function deleteCache() {
|
|
3307
3285
|
const cacheFilePath = _getCacheFilePath();
|
|
3308
3286
|
try {
|
|
3309
|
-
|
|
3287
|
+
fs11.unlinkSync(cacheFilePath);
|
|
3310
3288
|
} catch (e) {
|
|
3311
3289
|
}
|
|
3312
3290
|
}
|
|
3313
3291
|
function _loadCache() {
|
|
3314
3292
|
const cacheFilePath = _getCacheFilePath();
|
|
3315
|
-
if (!
|
|
3293
|
+
if (!fs11.existsSync(cacheFilePath)) {
|
|
3316
3294
|
return [];
|
|
3317
3295
|
}
|
|
3318
|
-
const content =
|
|
3296
|
+
const content = fs11.readFileSync(cacheFilePath, "utf-8");
|
|
3319
3297
|
const result = _parseJSONLines(content);
|
|
3320
3298
|
return result;
|
|
3321
3299
|
}
|
|
3322
3300
|
function _appendToCache(rows) {
|
|
3323
3301
|
const cacheFilePath = _getCacheFilePath();
|
|
3324
3302
|
const lines = _buildJSONLines(rows);
|
|
3325
|
-
|
|
3303
|
+
fs11.appendFileSync(cacheFilePath, lines);
|
|
3326
3304
|
}
|
|
3327
3305
|
function _getCacheFilePath() {
|
|
3328
3306
|
return path13.join(process.cwd(), "i18n.cache");
|
|
@@ -4032,10 +4010,10 @@ import { Command as Command10 } from "interactive-commander";
|
|
|
4032
4010
|
import createOra from "ora";
|
|
4033
4011
|
|
|
4034
4012
|
// ../../action/src/flows/pull-request.ts
|
|
4035
|
-
import { execSync as
|
|
4013
|
+
import { execSync as execSync2 } from "child_process";
|
|
4036
4014
|
|
|
4037
4015
|
// ../../action/src/flows/in-branch.ts
|
|
4038
|
-
import { execSync
|
|
4016
|
+
import { execSync } from "child_process";
|
|
4039
4017
|
import path14 from "path";
|
|
4040
4018
|
|
|
4041
4019
|
// ../../action/src/flows/_base.ts
|
|
@@ -4063,21 +4041,21 @@ var InBranchFlow = class extends IntegrationFlow {
|
|
|
4063
4041
|
this.ora.start("Running Lingo.dev");
|
|
4064
4042
|
await this.runLingoDotDev();
|
|
4065
4043
|
this.ora.succeed("Done running Lingo.dev");
|
|
4066
|
-
|
|
4044
|
+
execSync(`rm -f i18n.cache`, { stdio: "inherit" });
|
|
4067
4045
|
this.ora.start("Checking for changes");
|
|
4068
4046
|
const hasChanges = this.checkCommitableChanges();
|
|
4069
4047
|
this.ora.succeed(hasChanges ? "Changes detected" : "No changes detected");
|
|
4070
4048
|
if (hasChanges) {
|
|
4071
4049
|
this.ora.start("Committing changes");
|
|
4072
|
-
|
|
4073
|
-
|
|
4074
|
-
|
|
4050
|
+
execSync(`git add .`, { stdio: "inherit" });
|
|
4051
|
+
execSync(`git status --porcelain`, { stdio: "inherit" });
|
|
4052
|
+
execSync(`git commit -m "${this.platformKit.config.commitMessage}"`, {
|
|
4075
4053
|
stdio: "inherit"
|
|
4076
4054
|
});
|
|
4077
4055
|
this.ora.succeed("Changes committed");
|
|
4078
4056
|
this.ora.start("Pushing changes to remote");
|
|
4079
4057
|
const currentBranch = this.i18nBranchName ?? this.platformKit.platformConfig.baseBranchName;
|
|
4080
|
-
|
|
4058
|
+
execSync(`git push origin ${currentBranch} ${forcePush ? "--force" : ""}`, {
|
|
4081
4059
|
stdio: "inherit"
|
|
4082
4060
|
});
|
|
4083
4061
|
this.ora.succeed("Changes pushed to remote");
|
|
@@ -4085,28 +4063,28 @@ var InBranchFlow = class extends IntegrationFlow {
|
|
|
4085
4063
|
return hasChanges;
|
|
4086
4064
|
}
|
|
4087
4065
|
checkCommitableChanges() {
|
|
4088
|
-
return
|
|
4066
|
+
return execSync('git status --porcelain || echo "has_changes"', {
|
|
4089
4067
|
encoding: "utf8"
|
|
4090
4068
|
}).length > 0;
|
|
4091
4069
|
}
|
|
4092
4070
|
async runLingoDotDev() {
|
|
4093
|
-
|
|
4071
|
+
execSync(`npx lingo.dev@latest i18n --api-key ${this.platformKit.config.replexicaApiKey}`, { stdio: "inherit" });
|
|
4094
4072
|
}
|
|
4095
4073
|
configureGit() {
|
|
4096
4074
|
const { processOwnCommits } = this.platformKit.config;
|
|
4097
4075
|
const { baseBranchName } = this.platformKit.platformConfig;
|
|
4098
4076
|
this.ora.info(`Current working directory:`);
|
|
4099
|
-
|
|
4100
|
-
|
|
4101
|
-
|
|
4102
|
-
|
|
4103
|
-
|
|
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}"`);
|
|
4104
4082
|
this.platformKit?.gitConfig();
|
|
4105
|
-
|
|
4106
|
-
|
|
4083
|
+
execSync(`git fetch origin ${baseBranchName}`, { stdio: "inherit" });
|
|
4084
|
+
execSync(`git checkout ${baseBranchName} --`, { stdio: "inherit" });
|
|
4107
4085
|
if (!processOwnCommits) {
|
|
4108
4086
|
const currentAuthor = `${gitConfig.userName} <${gitConfig.userEmail}>`;
|
|
4109
|
-
const authorOfLastCommit =
|
|
4087
|
+
const authorOfLastCommit = execSync(`git log -1 --pretty=format:'%an <%ae>'`).toString();
|
|
4110
4088
|
if (authorOfLastCommit === currentAuthor) {
|
|
4111
4089
|
this.ora.warn(
|
|
4112
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`
|
|
@@ -4190,15 +4168,15 @@ var PullRequestFlow = class extends InBranchFlow {
|
|
|
4190
4168
|
return prNumber;
|
|
4191
4169
|
}
|
|
4192
4170
|
checkoutI18nBranch(i18nBranchName) {
|
|
4193
|
-
|
|
4194
|
-
|
|
4171
|
+
execSync2(`git fetch origin ${i18nBranchName}`, { stdio: "inherit" });
|
|
4172
|
+
execSync2(`git checkout -b ${i18nBranchName}`, {
|
|
4195
4173
|
stdio: "inherit"
|
|
4196
4174
|
});
|
|
4197
4175
|
}
|
|
4198
4176
|
createI18nBranch(i18nBranchName) {
|
|
4199
4177
|
try {
|
|
4200
|
-
|
|
4201
|
-
|
|
4178
|
+
execSync2(`git fetch origin ${this.platformKit.platformConfig.baseBranchName}`, { stdio: "inherit" });
|
|
4179
|
+
execSync2(`git checkout -b ${i18nBranchName} origin/${this.platformKit.platformConfig.baseBranchName}`, {
|
|
4202
4180
|
stdio: "inherit"
|
|
4203
4181
|
});
|
|
4204
4182
|
} catch (error) {
|
|
@@ -4218,31 +4196,31 @@ var PullRequestFlow = class extends InBranchFlow {
|
|
|
4218
4196
|
throw new Error("i18nBranchName is not set");
|
|
4219
4197
|
}
|
|
4220
4198
|
this.ora.start(`Fetching latest changes from ${this.platformKit.platformConfig.baseBranchName}`);
|
|
4221
|
-
|
|
4199
|
+
execSync2(`git fetch origin ${this.platformKit.platformConfig.baseBranchName}`, { stdio: "inherit" });
|
|
4222
4200
|
this.ora.succeed(`Fetched latest changes from ${this.platformKit.platformConfig.baseBranchName}`);
|
|
4223
4201
|
try {
|
|
4224
4202
|
this.ora.start("Attempting to rebase branch");
|
|
4225
|
-
|
|
4203
|
+
execSync2(`git rebase origin/${this.platformKit.platformConfig.baseBranchName}`, { stdio: "inherit" });
|
|
4226
4204
|
this.ora.succeed("Successfully rebased branch");
|
|
4227
4205
|
} catch (error) {
|
|
4228
4206
|
this.ora.warn("Rebase failed, falling back to alternative sync method");
|
|
4229
4207
|
this.ora.start("Aborting failed rebase");
|
|
4230
|
-
|
|
4208
|
+
execSync2("git rebase --abort", { stdio: "inherit" });
|
|
4231
4209
|
this.ora.succeed("Aborted failed rebase");
|
|
4232
4210
|
this.ora.start(`Resetting to ${this.platformKit.platformConfig.baseBranchName}`);
|
|
4233
|
-
|
|
4211
|
+
execSync2(`git reset --hard origin/${this.platformKit.platformConfig.baseBranchName}`, { stdio: "inherit" });
|
|
4234
4212
|
this.ora.succeed(`Reset to ${this.platformKit.platformConfig.baseBranchName}`);
|
|
4235
4213
|
this.ora.start("Restoring target files");
|
|
4236
4214
|
const targetFiles = ["i18n.lock"];
|
|
4237
|
-
const targetFileNames =
|
|
4215
|
+
const targetFileNames = execSync2(
|
|
4238
4216
|
`npx lingo.dev@latest show files --target ${this.platformKit.platformConfig.baseBranchName}`,
|
|
4239
4217
|
{ encoding: "utf8" }
|
|
4240
4218
|
).split("\n").filter(Boolean);
|
|
4241
4219
|
targetFiles.push(...targetFileNames);
|
|
4242
|
-
|
|
4220
|
+
execSync2(`git fetch origin ${this.i18nBranchName}`, { stdio: "inherit" });
|
|
4243
4221
|
for (const file of targetFiles) {
|
|
4244
4222
|
try {
|
|
4245
|
-
|
|
4223
|
+
execSync2(`git checkout FETCH_HEAD -- ${file}`, { stdio: "inherit" });
|
|
4246
4224
|
} catch (error2) {
|
|
4247
4225
|
this.ora.warn(`Skipping non-existent file: ${file}`);
|
|
4248
4226
|
continue;
|
|
@@ -4253,8 +4231,8 @@ var PullRequestFlow = class extends InBranchFlow {
|
|
|
4253
4231
|
this.ora.start("Checking for changes to commit");
|
|
4254
4232
|
const hasChanges = this.checkCommitableChanges();
|
|
4255
4233
|
if (hasChanges) {
|
|
4256
|
-
|
|
4257
|
-
|
|
4234
|
+
execSync2("git add .", { stdio: "inherit" });
|
|
4235
|
+
execSync2(`git commit -m "chore: sync with ${this.platformKit.platformConfig.baseBranchName}"`, {
|
|
4258
4236
|
stdio: "inherit"
|
|
4259
4237
|
});
|
|
4260
4238
|
this.ora.succeed("Committed additional changes");
|
|
@@ -4283,7 +4261,7 @@ Hey team,
|
|
|
4283
4261
|
};
|
|
4284
4262
|
|
|
4285
4263
|
// ../../action/src/platforms/bitbucket.ts
|
|
4286
|
-
import { execSync as
|
|
4264
|
+
import { execSync as execSync3 } from "child_process";
|
|
4287
4265
|
import bbLib from "bitbucket";
|
|
4288
4266
|
import Z8 from "zod";
|
|
4289
4267
|
|
|
@@ -4375,10 +4353,10 @@ var BitbucketPlatformKit = class extends PlatformKit {
|
|
|
4375
4353
|
});
|
|
4376
4354
|
}
|
|
4377
4355
|
async gitConfig() {
|
|
4378
|
-
|
|
4356
|
+
execSync3("git config --unset http.${BITBUCKET_GIT_HTTP_ORIGIN}.proxy", {
|
|
4379
4357
|
stdio: "inherit"
|
|
4380
4358
|
});
|
|
4381
|
-
|
|
4359
|
+
execSync3("git config http.${BITBUCKET_GIT_HTTP_ORIGIN}.proxy http://host.docker.internal:29418/", {
|
|
4382
4360
|
stdio: "inherit"
|
|
4383
4361
|
});
|
|
4384
4362
|
}
|
|
@@ -4405,7 +4383,7 @@ var BitbucketPlatformKit = class extends PlatformKit {
|
|
|
4405
4383
|
// ../../action/src/platforms/github.ts
|
|
4406
4384
|
import { Octokit } from "octokit";
|
|
4407
4385
|
import Z9 from "zod";
|
|
4408
|
-
import { execSync as
|
|
4386
|
+
import { execSync as execSync4 } from "child_process";
|
|
4409
4387
|
var GitHubPlatformKit = class extends PlatformKit {
|
|
4410
4388
|
_octokit;
|
|
4411
4389
|
get octokit() {
|
|
@@ -4462,7 +4440,7 @@ var GitHubPlatformKit = class extends PlatformKit {
|
|
|
4462
4440
|
if (ghToken && processOwnCommits) {
|
|
4463
4441
|
console.log("Using provided GH_TOKEN. This will trigger your CI/CD pipeline to run again.");
|
|
4464
4442
|
const url = `https://${ghToken}@github.com/${repositoryOwner}/${repositoryName}.git`;
|
|
4465
|
-
|
|
4443
|
+
execSync4(`git remote set-url origin ${url}`, {
|
|
4466
4444
|
stdio: "inherit"
|
|
4467
4445
|
});
|
|
4468
4446
|
}
|
|
@@ -4492,7 +4470,7 @@ var GitHubPlatformKit = class extends PlatformKit {
|
|
|
4492
4470
|
// ../../action/src/platforms/gitlab.ts
|
|
4493
4471
|
import { Gitlab } from "@gitbeaker/rest";
|
|
4494
4472
|
import Z10 from "zod";
|
|
4495
|
-
import { execSync as
|
|
4473
|
+
import { execSync as execSync5 } from "child_process";
|
|
4496
4474
|
var gl = new Gitlab({ token: "" });
|
|
4497
4475
|
var GitlabPlatformKit = class extends PlatformKit {
|
|
4498
4476
|
_gitlab;
|
|
@@ -4568,7 +4546,7 @@ var GitlabPlatformKit = class extends PlatformKit {
|
|
|
4568
4546
|
}
|
|
4569
4547
|
gitConfig() {
|
|
4570
4548
|
const url = `https://oauth2:${this.platformConfig.glToken}@gitlab.com/${this.platformConfig.repositoryOwner}/${this.platformConfig.repositoryName}.git`;
|
|
4571
|
-
|
|
4549
|
+
execSync5(`git remote set-url origin ${url}`, {
|
|
4572
4550
|
stdio: "inherit"
|
|
4573
4551
|
});
|
|
4574
4552
|
}
|
|
@@ -4641,7 +4619,7 @@ var ci_default = new Command10().command("ci").description("Run Lingo.dev CI/CD
|
|
|
4641
4619
|
// package.json
|
|
4642
4620
|
var package_default = {
|
|
4643
4621
|
name: "lingo.dev",
|
|
4644
|
-
version: "0.79.
|
|
4622
|
+
version: "0.79.4",
|
|
4645
4623
|
description: "Lingo.dev CLI",
|
|
4646
4624
|
private: false,
|
|
4647
4625
|
publishConfig: {
|