lingo.dev 0.87.15 → 0.89.0
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 +248 -90
- package/build/cli.cjs.map +1 -1
- package/build/cli.mjs +246 -88
- package/build/cli.mjs.map +1 -1
- package/package.json +4 -4
package/build/cli.cjs
CHANGED
|
@@ -865,6 +865,9 @@ function getBuckets(i18nConfig) {
|
|
|
865
865
|
if (bucketEntry.lockedKeys) {
|
|
866
866
|
config.lockedKeys = bucketEntry.lockedKeys;
|
|
867
867
|
}
|
|
868
|
+
if (bucketEntry.lockedPatterns) {
|
|
869
|
+
config.lockedPatterns = bucketEntry.lockedPatterns;
|
|
870
|
+
}
|
|
868
871
|
return config;
|
|
869
872
|
});
|
|
870
873
|
return result;
|
|
@@ -3139,7 +3142,7 @@ function md5(input2) {
|
|
|
3139
3142
|
|
|
3140
3143
|
var fenceRegex = /([ \t]*)(^>\s*)?```([\s\S]*?)```/gm;
|
|
3141
3144
|
var inlineCodeRegex = /(?<!`)`([^`\r\n]+?)`(?!`)/g;
|
|
3142
|
-
var imageRegex = /([ \t]*)(^>\s*)?!\[[^\]]*?\]\([
|
|
3145
|
+
var imageRegex = /([ \t]*)(^>\s*)?!\[[^\]]*?\]\(([^()]*(\([^()]*\)[^()]*)*)\)/gm;
|
|
3143
3146
|
function ensureSurroundingImageNewlines(_content) {
|
|
3144
3147
|
let found = false;
|
|
3145
3148
|
let content = _content;
|
|
@@ -3278,8 +3281,57 @@ function createMdxSectionsSplit2Loader() {
|
|
|
3278
3281
|
});
|
|
3279
3282
|
}
|
|
3280
3283
|
|
|
3284
|
+
// src/cli/loaders/mdx2/locked-patterns.ts
|
|
3285
|
+
function extractLockedPatterns(content, patterns = []) {
|
|
3286
|
+
let finalContent = content;
|
|
3287
|
+
const lockedPlaceholders = {};
|
|
3288
|
+
if (!patterns || patterns.length === 0) {
|
|
3289
|
+
return { content: finalContent, lockedPlaceholders };
|
|
3290
|
+
}
|
|
3291
|
+
for (const patternStr of patterns) {
|
|
3292
|
+
try {
|
|
3293
|
+
const pattern = new RegExp(patternStr, "gm");
|
|
3294
|
+
const matches = Array.from(finalContent.matchAll(pattern));
|
|
3295
|
+
for (const match of matches) {
|
|
3296
|
+
const matchedText = match[0];
|
|
3297
|
+
const matchHash = md5(matchedText);
|
|
3298
|
+
const placeholder = `---LOCKED-PATTERN-${matchHash}---`;
|
|
3299
|
+
lockedPlaceholders[placeholder] = matchedText;
|
|
3300
|
+
finalContent = finalContent.replace(matchedText, placeholder);
|
|
3301
|
+
}
|
|
3302
|
+
} catch (error) {
|
|
3303
|
+
console.warn(`Invalid regex pattern: ${patternStr}`);
|
|
3304
|
+
}
|
|
3305
|
+
}
|
|
3306
|
+
return {
|
|
3307
|
+
content: finalContent,
|
|
3308
|
+
lockedPlaceholders
|
|
3309
|
+
};
|
|
3310
|
+
}
|
|
3311
|
+
function createMdxLockedPatternsLoader(defaultPatterns) {
|
|
3312
|
+
return createLoader({
|
|
3313
|
+
async pull(locale, input2, initCtx, originalLocale) {
|
|
3314
|
+
const patterns = defaultPatterns || [];
|
|
3315
|
+
const { content } = extractLockedPatterns(input2 || "", patterns);
|
|
3316
|
+
return content;
|
|
3317
|
+
},
|
|
3318
|
+
async push(locale, data, originalInput, originalLocale, pullInput, pullOutput) {
|
|
3319
|
+
const patterns = defaultPatterns || [];
|
|
3320
|
+
if (!pullInput) {
|
|
3321
|
+
return data;
|
|
3322
|
+
}
|
|
3323
|
+
const { lockedPlaceholders } = extractLockedPatterns(pullInput, patterns);
|
|
3324
|
+
let result = data;
|
|
3325
|
+
for (const [placeholder, original] of Object.entries(lockedPlaceholders)) {
|
|
3326
|
+
result = result.replaceAll(placeholder, original);
|
|
3327
|
+
}
|
|
3328
|
+
return result;
|
|
3329
|
+
}
|
|
3330
|
+
});
|
|
3331
|
+
}
|
|
3332
|
+
|
|
3281
3333
|
// src/cli/loaders/index.ts
|
|
3282
|
-
function createBucketLoader(bucketType, bucketPathPattern, options, lockedKeys) {
|
|
3334
|
+
function createBucketLoader(bucketType, bucketPathPattern, options, lockedKeys, lockedPatterns) {
|
|
3283
3335
|
switch (bucketType) {
|
|
3284
3336
|
default:
|
|
3285
3337
|
throw new Error(`Unsupported bucket type: ${bucketType}`);
|
|
@@ -3349,6 +3401,7 @@ function createBucketLoader(bucketType, bucketPathPattern, options, lockedKeys)
|
|
|
3349
3401
|
bucketPathPattern
|
|
3350
3402
|
}),
|
|
3351
3403
|
createMdxCodePlaceholderLoader(),
|
|
3404
|
+
createMdxLockedPatternsLoader(lockedPatterns),
|
|
3352
3405
|
createMdxFrontmatterSplitLoader(),
|
|
3353
3406
|
createMdxSectionsSplit2Loader(),
|
|
3354
3407
|
createLocalizableMdxDocumentLoader(),
|
|
@@ -3673,13 +3726,27 @@ function withExponentialBackoff(fn, maxAttempts = 3, baseDelay = 1e3) {
|
|
|
3673
3726
|
}
|
|
3674
3727
|
|
|
3675
3728
|
// src/cli/utils/observability.ts
|
|
3676
|
-
var _posthognode = require('posthog-node');
|
|
3729
|
+
var _posthognode = require('posthog-node'); var _posthognode2 = _interopRequireDefault(_posthognode);
|
|
3730
|
+
var { PostHog } = _posthognode2.default;
|
|
3677
3731
|
async function trackEvent(distinctId, event, properties) {
|
|
3678
3732
|
if (process.env.DO_NOT_TRACK) {
|
|
3679
3733
|
return;
|
|
3680
3734
|
}
|
|
3681
3735
|
try {
|
|
3682
|
-
const
|
|
3736
|
+
const safeProperties = properties ? JSON.parse(JSON.stringify(
|
|
3737
|
+
properties,
|
|
3738
|
+
(key, value) => {
|
|
3739
|
+
if (value instanceof Error) {
|
|
3740
|
+
return {
|
|
3741
|
+
name: value.name,
|
|
3742
|
+
message: value.message,
|
|
3743
|
+
stack: value.stack
|
|
3744
|
+
};
|
|
3745
|
+
}
|
|
3746
|
+
return value;
|
|
3747
|
+
}
|
|
3748
|
+
)) : {};
|
|
3749
|
+
const posthog = new PostHog("phc_eR0iSoQufBxNY36k0f0T15UvHJdTfHlh8rJcxsfhfXk", {
|
|
3683
3750
|
host: "https://eu.i.posthog.com",
|
|
3684
3751
|
flushAt: 1,
|
|
3685
3752
|
flushInterval: 0
|
|
@@ -3688,7 +3755,7 @@ async function trackEvent(distinctId, event, properties) {
|
|
|
3688
3755
|
distinctId,
|
|
3689
3756
|
event,
|
|
3690
3757
|
properties: {
|
|
3691
|
-
...
|
|
3758
|
+
...safeProperties,
|
|
3692
3759
|
meta: {
|
|
3693
3760
|
version: process.env.npm_package_version,
|
|
3694
3761
|
isCi: process.env.CI === "true"
|
|
@@ -3927,7 +3994,8 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
|
|
|
3927
3994
|
defaultLocale: sourceLocale,
|
|
3928
3995
|
injectLocale: bucket.injectLocale
|
|
3929
3996
|
},
|
|
3930
|
-
bucket.lockedKeys
|
|
3997
|
+
bucket.lockedKeys,
|
|
3998
|
+
bucket.lockedPatterns
|
|
3931
3999
|
);
|
|
3932
4000
|
bucketLoader.setDefaultLocale(sourceLocale);
|
|
3933
4001
|
await bucketLoader.init();
|
|
@@ -4113,7 +4181,8 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
|
|
|
4113
4181
|
defaultLocale: sourceLocale,
|
|
4114
4182
|
injectLocale: bucket.injectLocale
|
|
4115
4183
|
},
|
|
4116
|
-
bucket.lockedKeys
|
|
4184
|
+
bucket.lockedKeys,
|
|
4185
|
+
bucket.lockedPatterns
|
|
4117
4186
|
);
|
|
4118
4187
|
bucketLoader.setDefaultLocale(sourceLocale);
|
|
4119
4188
|
await bucketLoader.init();
|
|
@@ -4690,20 +4759,18 @@ var mcp_default = new (0, _interactivecommander.Command)().command("mcp").descri
|
|
|
4690
4759
|
console.log("Lingo.dev MCP Server running on stdio");
|
|
4691
4760
|
});
|
|
4692
4761
|
|
|
4693
|
-
// src/cli/cmd/ci.ts
|
|
4762
|
+
// src/cli/cmd/ci/index.ts
|
|
4694
4763
|
|
|
4695
4764
|
|
|
4696
|
-
// ../../action/src/main.ts
|
|
4697
4765
|
|
|
4698
|
-
|
|
4699
|
-
// ../../action/src/flows/pull-request.ts
|
|
4766
|
+
// src/cli/cmd/ci/flows/pull-request.ts
|
|
4700
4767
|
var _child_process = require('child_process');
|
|
4701
4768
|
|
|
4702
|
-
//
|
|
4769
|
+
// src/cli/cmd/ci/flows/in-branch.ts
|
|
4703
4770
|
|
|
4704
4771
|
|
|
4705
4772
|
|
|
4706
|
-
//
|
|
4773
|
+
// src/cli/cmd/ci/flows/_base.ts
|
|
4707
4774
|
var IntegrationFlow = class {
|
|
4708
4775
|
constructor(ora, platformKit) {
|
|
4709
4776
|
this.ora = ora;
|
|
@@ -4716,7 +4783,7 @@ var gitConfig = {
|
|
|
4716
4783
|
userEmail: "support@lingo.dev"
|
|
4717
4784
|
};
|
|
4718
4785
|
|
|
4719
|
-
//
|
|
4786
|
+
// src/cli/cmd/ci/flows/in-branch.ts
|
|
4720
4787
|
var InBranchFlow = class extends IntegrationFlow {
|
|
4721
4788
|
async preRun() {
|
|
4722
4789
|
this.ora.start("Configuring git");
|
|
@@ -4742,9 +4809,12 @@ var InBranchFlow = class extends IntegrationFlow {
|
|
|
4742
4809
|
this.ora.succeed("Changes committed");
|
|
4743
4810
|
this.ora.start("Pushing changes to remote");
|
|
4744
4811
|
const currentBranch = _nullishCoalesce(this.i18nBranchName, () => ( this.platformKit.platformConfig.baseBranchName));
|
|
4745
|
-
_child_process.execSync.call(void 0,
|
|
4746
|
-
|
|
4747
|
-
|
|
4812
|
+
_child_process.execSync.call(void 0,
|
|
4813
|
+
`git push origin ${currentBranch} ${forcePush ? "--force" : ""}`,
|
|
4814
|
+
{
|
|
4815
|
+
stdio: "inherit"
|
|
4816
|
+
}
|
|
4817
|
+
);
|
|
4748
4818
|
this.ora.succeed("Changes pushed to remote");
|
|
4749
4819
|
}
|
|
4750
4820
|
return hasChanges;
|
|
@@ -4755,7 +4825,10 @@ var InBranchFlow = class extends IntegrationFlow {
|
|
|
4755
4825
|
}).length > 0;
|
|
4756
4826
|
}
|
|
4757
4827
|
async runLingoDotDev() {
|
|
4758
|
-
_child_process.execSync.call(void 0,
|
|
4828
|
+
_child_process.execSync.call(void 0,
|
|
4829
|
+
`npx lingo.dev@latest i18n --api-key ${this.platformKit.config.replexicaApiKey}`,
|
|
4830
|
+
{ stdio: "inherit" }
|
|
4831
|
+
);
|
|
4759
4832
|
}
|
|
4760
4833
|
configureGit() {
|
|
4761
4834
|
const { processOwnCommits } = this.platformKit.config;
|
|
@@ -4771,7 +4844,9 @@ var InBranchFlow = class extends IntegrationFlow {
|
|
|
4771
4844
|
_child_process.execSync.call(void 0, `git checkout ${baseBranchName} --`, { stdio: "inherit" });
|
|
4772
4845
|
if (!processOwnCommits) {
|
|
4773
4846
|
const currentAuthor = `${gitConfig.userName} <${gitConfig.userEmail}>`;
|
|
4774
|
-
const authorOfLastCommit = _child_process.execSync.call(void 0,
|
|
4847
|
+
const authorOfLastCommit = _child_process.execSync.call(void 0,
|
|
4848
|
+
`git log -1 --pretty=format:'%an <%ae>'`
|
|
4849
|
+
).toString();
|
|
4775
4850
|
if (authorOfLastCommit === currentAuthor) {
|
|
4776
4851
|
this.ora.warn(
|
|
4777
4852
|
`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`
|
|
@@ -4779,16 +4854,21 @@ var InBranchFlow = class extends IntegrationFlow {
|
|
|
4779
4854
|
return false;
|
|
4780
4855
|
}
|
|
4781
4856
|
}
|
|
4782
|
-
const workingDir = path14.default.resolve(
|
|
4857
|
+
const workingDir = path14.default.resolve(
|
|
4858
|
+
process.cwd(),
|
|
4859
|
+
this.platformKit.config.workingDir
|
|
4860
|
+
);
|
|
4783
4861
|
if (workingDir !== process.cwd()) {
|
|
4784
|
-
this.ora.info(
|
|
4862
|
+
this.ora.info(
|
|
4863
|
+
`Changing to working directory: ${this.platformKit.config.workingDir}`
|
|
4864
|
+
);
|
|
4785
4865
|
process.chdir(workingDir);
|
|
4786
4866
|
}
|
|
4787
4867
|
return true;
|
|
4788
4868
|
}
|
|
4789
4869
|
};
|
|
4790
4870
|
|
|
4791
|
-
//
|
|
4871
|
+
// src/cli/cmd/ci/flows/pull-request.ts
|
|
4792
4872
|
var PullRequestFlow = class extends InBranchFlow {
|
|
4793
4873
|
async preRun() {
|
|
4794
4874
|
const canContinue = await _optionalChain([super.preRun.bind(this), 'optionalCall', _167 => _167()]);
|
|
@@ -4797,7 +4877,9 @@ var PullRequestFlow = class extends InBranchFlow {
|
|
|
4797
4877
|
}
|
|
4798
4878
|
this.ora.start("Calculating automated branch name");
|
|
4799
4879
|
this.i18nBranchName = this.calculatePrBranchName();
|
|
4800
|
-
this.ora.succeed(
|
|
4880
|
+
this.ora.succeed(
|
|
4881
|
+
`Automated branch name calculated: ${this.i18nBranchName}`
|
|
4882
|
+
);
|
|
4801
4883
|
this.ora.start("Checking if branch exists");
|
|
4802
4884
|
const branchExists = await this.checkBranchExistance(this.i18nBranchName);
|
|
4803
4885
|
this.ora.succeed(branchExists ? "Branch exists" : "Branch does not exist");
|
|
@@ -4805,7 +4887,9 @@ var PullRequestFlow = class extends InBranchFlow {
|
|
|
4805
4887
|
this.ora.start(`Checking out branch ${this.i18nBranchName}`);
|
|
4806
4888
|
this.checkoutI18nBranch(this.i18nBranchName);
|
|
4807
4889
|
this.ora.succeed(`Checked out branch ${this.i18nBranchName}`);
|
|
4808
|
-
this.ora.start(
|
|
4890
|
+
this.ora.start(
|
|
4891
|
+
`Syncing with ${this.platformKit.platformConfig.baseBranchName}`
|
|
4892
|
+
);
|
|
4809
4893
|
this.syncI18nBranch();
|
|
4810
4894
|
this.ora.succeed(`Checked out and synced branch ${this.i18nBranchName}`);
|
|
4811
4895
|
} else {
|
|
@@ -4820,11 +4904,15 @@ var PullRequestFlow = class extends InBranchFlow {
|
|
|
4820
4904
|
}
|
|
4821
4905
|
async postRun() {
|
|
4822
4906
|
if (!this.i18nBranchName) {
|
|
4823
|
-
throw new Error(
|
|
4907
|
+
throw new Error(
|
|
4908
|
+
"i18nBranchName is not set. Did you forget to call preRun?"
|
|
4909
|
+
);
|
|
4824
4910
|
}
|
|
4825
4911
|
this.ora.start("Checking if PR already exists");
|
|
4826
4912
|
const pullRequestNumber = await this.ensureFreshPr(this.i18nBranchName);
|
|
4827
|
-
this.ora.succeed(
|
|
4913
|
+
this.ora.succeed(
|
|
4914
|
+
`Pull request ready: ${this.platformKit.buildPullRequestUrl(pullRequestNumber)}`
|
|
4915
|
+
);
|
|
4828
4916
|
}
|
|
4829
4917
|
calculatePrBranchName() {
|
|
4830
4918
|
return `lingo.dev/${this.platformKit.platformConfig.baseBranchName}`;
|
|
@@ -4862,10 +4950,16 @@ var PullRequestFlow = class extends InBranchFlow {
|
|
|
4862
4950
|
}
|
|
4863
4951
|
createI18nBranch(i18nBranchName) {
|
|
4864
4952
|
try {
|
|
4865
|
-
_child_process.execSync.call(void 0,
|
|
4866
|
-
|
|
4867
|
-
stdio: "inherit"
|
|
4868
|
-
|
|
4953
|
+
_child_process.execSync.call(void 0,
|
|
4954
|
+
`git fetch origin ${this.platformKit.platformConfig.baseBranchName}`,
|
|
4955
|
+
{ stdio: "inherit" }
|
|
4956
|
+
);
|
|
4957
|
+
_child_process.execSync.call(void 0,
|
|
4958
|
+
`git checkout -b ${i18nBranchName} origin/${this.platformKit.platformConfig.baseBranchName}`,
|
|
4959
|
+
{
|
|
4960
|
+
stdio: "inherit"
|
|
4961
|
+
}
|
|
4962
|
+
);
|
|
4869
4963
|
} catch (error) {
|
|
4870
4964
|
const errorMessage = error instanceof Error ? error.message : "Unknown error occurred";
|
|
4871
4965
|
this.ora.fail(`Failed to create branch: ${errorMessage}`);
|
|
@@ -4882,21 +4976,38 @@ var PullRequestFlow = class extends InBranchFlow {
|
|
|
4882
4976
|
if (!this.i18nBranchName) {
|
|
4883
4977
|
throw new Error("i18nBranchName is not set");
|
|
4884
4978
|
}
|
|
4885
|
-
this.ora.start(
|
|
4886
|
-
|
|
4887
|
-
|
|
4979
|
+
this.ora.start(
|
|
4980
|
+
`Fetching latest changes from ${this.platformKit.platformConfig.baseBranchName}`
|
|
4981
|
+
);
|
|
4982
|
+
_child_process.execSync.call(void 0,
|
|
4983
|
+
`git fetch origin ${this.platformKit.platformConfig.baseBranchName}`,
|
|
4984
|
+
{ stdio: "inherit" }
|
|
4985
|
+
);
|
|
4986
|
+
this.ora.succeed(
|
|
4987
|
+
`Fetched latest changes from ${this.platformKit.platformConfig.baseBranchName}`
|
|
4988
|
+
);
|
|
4888
4989
|
try {
|
|
4889
4990
|
this.ora.start("Attempting to rebase branch");
|
|
4890
|
-
_child_process.execSync.call(void 0,
|
|
4991
|
+
_child_process.execSync.call(void 0,
|
|
4992
|
+
`git rebase origin/${this.platformKit.platformConfig.baseBranchName}`,
|
|
4993
|
+
{ stdio: "inherit" }
|
|
4994
|
+
);
|
|
4891
4995
|
this.ora.succeed("Successfully rebased branch");
|
|
4892
4996
|
} catch (error) {
|
|
4893
4997
|
this.ora.warn("Rebase failed, falling back to alternative sync method");
|
|
4894
4998
|
this.ora.start("Aborting failed rebase");
|
|
4895
4999
|
_child_process.execSync.call(void 0, "git rebase --abort", { stdio: "inherit" });
|
|
4896
5000
|
this.ora.succeed("Aborted failed rebase");
|
|
4897
|
-
this.ora.start(
|
|
4898
|
-
|
|
4899
|
-
|
|
5001
|
+
this.ora.start(
|
|
5002
|
+
`Resetting to ${this.platformKit.platformConfig.baseBranchName}`
|
|
5003
|
+
);
|
|
5004
|
+
_child_process.execSync.call(void 0,
|
|
5005
|
+
`git reset --hard origin/${this.platformKit.platformConfig.baseBranchName}`,
|
|
5006
|
+
{ stdio: "inherit" }
|
|
5007
|
+
);
|
|
5008
|
+
this.ora.succeed(
|
|
5009
|
+
`Reset to ${this.platformKit.platformConfig.baseBranchName}`
|
|
5010
|
+
);
|
|
4900
5011
|
this.ora.start("Restoring target files");
|
|
4901
5012
|
const targetFiles = ["i18n.lock"];
|
|
4902
5013
|
const targetFileNames = _child_process.execSync.call(void 0,
|
|
@@ -4919,9 +5030,12 @@ var PullRequestFlow = class extends InBranchFlow {
|
|
|
4919
5030
|
const hasChanges = this.checkCommitableChanges();
|
|
4920
5031
|
if (hasChanges) {
|
|
4921
5032
|
_child_process.execSync.call(void 0, "git add .", { stdio: "inherit" });
|
|
4922
|
-
_child_process.execSync.call(void 0,
|
|
4923
|
-
|
|
4924
|
-
|
|
5033
|
+
_child_process.execSync.call(void 0,
|
|
5034
|
+
`git commit -m "chore: sync with ${this.platformKit.platformConfig.baseBranchName}"`,
|
|
5035
|
+
{
|
|
5036
|
+
stdio: "inherit"
|
|
5037
|
+
}
|
|
5038
|
+
);
|
|
4925
5039
|
this.ora.succeed("Committed additional changes");
|
|
4926
5040
|
} else {
|
|
4927
5041
|
this.ora.succeed("No changes to commit");
|
|
@@ -4947,12 +5061,12 @@ Hey team,
|
|
|
4947
5061
|
}
|
|
4948
5062
|
};
|
|
4949
5063
|
|
|
4950
|
-
//
|
|
5064
|
+
// src/cli/cmd/ci/platforms/bitbucket.ts
|
|
4951
5065
|
|
|
4952
5066
|
var _bitbucket = require('bitbucket'); var _bitbucket2 = _interopRequireDefault(_bitbucket);
|
|
4953
5067
|
|
|
4954
5068
|
|
|
4955
|
-
//
|
|
5069
|
+
// src/cli/cmd/ci/platforms/_base.ts
|
|
4956
5070
|
|
|
4957
5071
|
|
|
4958
5072
|
var defaultMessage = "feat: update translations via @lingodotdev";
|
|
@@ -4984,7 +5098,7 @@ var PlatformKit = class {
|
|
|
4984
5098
|
}
|
|
4985
5099
|
};
|
|
4986
5100
|
|
|
4987
|
-
//
|
|
5101
|
+
// src/cli/cmd/ci/platforms/bitbucket.ts
|
|
4988
5102
|
var { Bitbucket } = _bitbucket2.default;
|
|
4989
5103
|
var BitbucketPlatformKit = class extends PlatformKit {
|
|
4990
5104
|
|
|
@@ -5021,7 +5135,11 @@ var BitbucketPlatformKit = class extends PlatformKit {
|
|
|
5021
5135
|
pull_request_id: pullRequestNumber
|
|
5022
5136
|
});
|
|
5023
5137
|
}
|
|
5024
|
-
async createPullRequest({
|
|
5138
|
+
async createPullRequest({
|
|
5139
|
+
title,
|
|
5140
|
+
body,
|
|
5141
|
+
head
|
|
5142
|
+
}) {
|
|
5025
5143
|
return await this.bb.repositories.createPullRequest({
|
|
5026
5144
|
workspace: this.platformConfig.repositoryOwner,
|
|
5027
5145
|
repo_slug: this.platformConfig.repositoryName,
|
|
@@ -5033,7 +5151,10 @@ var BitbucketPlatformKit = class extends PlatformKit {
|
|
|
5033
5151
|
}
|
|
5034
5152
|
}).then(({ data }) => _nullishCoalesce(data.id, () => ( 0)));
|
|
5035
5153
|
}
|
|
5036
|
-
async commentOnPullRequest({
|
|
5154
|
+
async commentOnPullRequest({
|
|
5155
|
+
pullRequestNumber,
|
|
5156
|
+
body
|
|
5157
|
+
}) {
|
|
5037
5158
|
await this.bb.repositories.createPullRequestComment({
|
|
5038
5159
|
workspace: this.platformConfig.repositoryOwner,
|
|
5039
5160
|
repo_slug: this.platformConfig.repositoryName,
|
|
@@ -5049,9 +5170,12 @@ var BitbucketPlatformKit = class extends PlatformKit {
|
|
|
5049
5170
|
_child_process.execSync.call(void 0, "git config --unset http.${BITBUCKET_GIT_HTTP_ORIGIN}.proxy", {
|
|
5050
5171
|
stdio: "inherit"
|
|
5051
5172
|
});
|
|
5052
|
-
_child_process.execSync.call(void 0,
|
|
5053
|
-
|
|
5054
|
-
|
|
5173
|
+
_child_process.execSync.call(void 0,
|
|
5174
|
+
"git config http.${BITBUCKET_GIT_HTTP_ORIGIN}.proxy http://host.docker.internal:29418/",
|
|
5175
|
+
{
|
|
5176
|
+
stdio: "inherit"
|
|
5177
|
+
}
|
|
5178
|
+
);
|
|
5055
5179
|
}
|
|
5056
5180
|
get platformConfig() {
|
|
5057
5181
|
const env = _zod2.default.object({
|
|
@@ -5073,7 +5197,7 @@ var BitbucketPlatformKit = class extends PlatformKit {
|
|
|
5073
5197
|
}
|
|
5074
5198
|
};
|
|
5075
5199
|
|
|
5076
|
-
//
|
|
5200
|
+
// src/cli/cmd/ci/platforms/github.ts
|
|
5077
5201
|
var _octokit2 = require('octokit');
|
|
5078
5202
|
|
|
5079
5203
|
var GitHubPlatformKit = class extends PlatformKit {
|
|
@@ -5108,7 +5232,11 @@ var GitHubPlatformKit = class extends PlatformKit {
|
|
|
5108
5232
|
state: "closed"
|
|
5109
5233
|
});
|
|
5110
5234
|
}
|
|
5111
|
-
async createPullRequest({
|
|
5235
|
+
async createPullRequest({
|
|
5236
|
+
head,
|
|
5237
|
+
title,
|
|
5238
|
+
body
|
|
5239
|
+
}) {
|
|
5112
5240
|
return await this.octokit.rest.pulls.create({
|
|
5113
5241
|
head,
|
|
5114
5242
|
title,
|
|
@@ -5118,7 +5246,10 @@ var GitHubPlatformKit = class extends PlatformKit {
|
|
|
5118
5246
|
base: this.platformConfig.baseBranchName
|
|
5119
5247
|
}).then(({ data }) => data.number);
|
|
5120
5248
|
}
|
|
5121
|
-
async commentOnPullRequest({
|
|
5249
|
+
async commentOnPullRequest({
|
|
5250
|
+
pullRequestNumber,
|
|
5251
|
+
body
|
|
5252
|
+
}) {
|
|
5122
5253
|
await this.octokit.rest.issues.createComment({
|
|
5123
5254
|
issue_number: pullRequestNumber,
|
|
5124
5255
|
body,
|
|
@@ -5130,7 +5261,9 @@ var GitHubPlatformKit = class extends PlatformKit {
|
|
|
5130
5261
|
const { ghToken, repositoryOwner, repositoryName } = this.platformConfig;
|
|
5131
5262
|
const { processOwnCommits } = this.config;
|
|
5132
5263
|
if (ghToken && processOwnCommits) {
|
|
5133
|
-
console.log(
|
|
5264
|
+
console.log(
|
|
5265
|
+
"Using provided GH_TOKEN. This will trigger your CI/CD pipeline to run again."
|
|
5266
|
+
);
|
|
5134
5267
|
const url = `https://${ghToken}@github.com/${repositoryOwner}/${repositoryName}.git`;
|
|
5135
5268
|
super.gitConfig(ghToken, url);
|
|
5136
5269
|
}
|
|
@@ -5157,7 +5290,7 @@ var GitHubPlatformKit = class extends PlatformKit {
|
|
|
5157
5290
|
}
|
|
5158
5291
|
};
|
|
5159
5292
|
|
|
5160
|
-
//
|
|
5293
|
+
// src/cli/cmd/ci/platforms/gitlab.ts
|
|
5161
5294
|
var _rest = require('@gitbeaker/rest');
|
|
5162
5295
|
|
|
5163
5296
|
var gl = new (0, _rest.Gitlab)({ token: "" });
|
|
@@ -5199,13 +5332,18 @@ var GitlabPlatformKit = class extends PlatformKit {
|
|
|
5199
5332
|
}
|
|
5200
5333
|
async branchExists({ branch }) {
|
|
5201
5334
|
try {
|
|
5202
|
-
await this.gitlab.Branches.show(
|
|
5335
|
+
await this.gitlab.Branches.show(
|
|
5336
|
+
this.platformConfig.gitlabProjectId,
|
|
5337
|
+
branch
|
|
5338
|
+
);
|
|
5203
5339
|
return true;
|
|
5204
5340
|
} catch (e2) {
|
|
5205
5341
|
return false;
|
|
5206
5342
|
}
|
|
5207
5343
|
}
|
|
5208
|
-
async getOpenPullRequestNumber({
|
|
5344
|
+
async getOpenPullRequestNumber({
|
|
5345
|
+
branch
|
|
5346
|
+
}) {
|
|
5209
5347
|
const mergeRequests = await this.gitlab.MergeRequests.all({
|
|
5210
5348
|
projectId: this.platformConfig.gitlabProjectId,
|
|
5211
5349
|
sourceBranch: branch,
|
|
@@ -5213,12 +5351,22 @@ var GitlabPlatformKit = class extends PlatformKit {
|
|
|
5213
5351
|
});
|
|
5214
5352
|
return _optionalChain([mergeRequests, 'access', _176 => _176[0], 'optionalAccess', _177 => _177.iid]);
|
|
5215
5353
|
}
|
|
5216
|
-
async closePullRequest({
|
|
5217
|
-
|
|
5218
|
-
|
|
5219
|
-
|
|
5354
|
+
async closePullRequest({
|
|
5355
|
+
pullRequestNumber
|
|
5356
|
+
}) {
|
|
5357
|
+
await this.gitlab.MergeRequests.edit(
|
|
5358
|
+
this.platformConfig.gitlabProjectId,
|
|
5359
|
+
pullRequestNumber,
|
|
5360
|
+
{
|
|
5361
|
+
stateEvent: "close"
|
|
5362
|
+
}
|
|
5363
|
+
);
|
|
5220
5364
|
}
|
|
5221
|
-
async createPullRequest({
|
|
5365
|
+
async createPullRequest({
|
|
5366
|
+
head,
|
|
5367
|
+
title,
|
|
5368
|
+
body
|
|
5369
|
+
}) {
|
|
5222
5370
|
const mr = await this.gitlab.MergeRequests.create(
|
|
5223
5371
|
this.platformConfig.gitlabProjectId,
|
|
5224
5372
|
head,
|
|
@@ -5230,8 +5378,15 @@ var GitlabPlatformKit = class extends PlatformKit {
|
|
|
5230
5378
|
);
|
|
5231
5379
|
return mr.iid;
|
|
5232
5380
|
}
|
|
5233
|
-
async commentOnPullRequest({
|
|
5234
|
-
|
|
5381
|
+
async commentOnPullRequest({
|
|
5382
|
+
pullRequestNumber,
|
|
5383
|
+
body
|
|
5384
|
+
}) {
|
|
5385
|
+
await this.gitlab.MergeRequestNotes.create(
|
|
5386
|
+
this.platformConfig.gitlabProjectId,
|
|
5387
|
+
pullRequestNumber,
|
|
5388
|
+
body
|
|
5389
|
+
);
|
|
5235
5390
|
}
|
|
5236
5391
|
gitConfig() {
|
|
5237
5392
|
const glToken = this.platformConfig.glToken;
|
|
@@ -5243,7 +5398,7 @@ var GitlabPlatformKit = class extends PlatformKit {
|
|
|
5243
5398
|
}
|
|
5244
5399
|
};
|
|
5245
5400
|
|
|
5246
|
-
//
|
|
5401
|
+
// src/cli/cmd/ci/platforms/index.ts
|
|
5247
5402
|
var getPlatformKit = () => {
|
|
5248
5403
|
if (process.env.BITBUCKET_PIPELINE_UUID) {
|
|
5249
5404
|
return new BitbucketPlatformKit();
|
|
@@ -5257,25 +5412,7 @@ var getPlatformKit = () => {
|
|
|
5257
5412
|
throw new Error("This platform is not supported");
|
|
5258
5413
|
};
|
|
5259
5414
|
|
|
5260
|
-
//
|
|
5261
|
-
async function main() {
|
|
5262
|
-
const ora = _ora2.default.call(void 0, );
|
|
5263
|
-
const platformKit = getPlatformKit();
|
|
5264
|
-
const { isPullRequestMode } = platformKit.config;
|
|
5265
|
-
ora.info(`Pull request mode: ${isPullRequestMode ? "on" : "off"}`);
|
|
5266
|
-
const flow = isPullRequestMode ? new PullRequestFlow(ora, platformKit) : new InBranchFlow(ora, platformKit);
|
|
5267
|
-
const canRun = await _optionalChain([flow, 'access', _178 => _178.preRun, 'optionalCall', _179 => _179()]);
|
|
5268
|
-
if (canRun === false) {
|
|
5269
|
-
return;
|
|
5270
|
-
}
|
|
5271
|
-
const hasChanges = await flow.run();
|
|
5272
|
-
if (!hasChanges) {
|
|
5273
|
-
return;
|
|
5274
|
-
}
|
|
5275
|
-
await _optionalChain([flow, 'access', _180 => _180.postRun, 'optionalCall', _181 => _181()]);
|
|
5276
|
-
}
|
|
5277
|
-
|
|
5278
|
-
// src/cli/cmd/ci.ts
|
|
5415
|
+
// src/cli/cmd/ci/index.ts
|
|
5279
5416
|
var ci_default = new (0, _interactivecommander.Command)().command("ci").description("Run Lingo.dev CI/CD action").helpOption("-h, --help", "Show help").option("--pull-request", "Create a pull request with the changes", false).option("--commit-message <message>", "Commit message").option("--pull-request-title <title>", "Pull request title").option("--working-directory <dir>", "Working directory").option("--process-own-commits", "Process commits made by this action", false).action(async (options, program) => {
|
|
5280
5417
|
const apiKey = program.args[0];
|
|
5281
5418
|
const settings = getSettings(apiKey);
|
|
@@ -5294,14 +5431,35 @@ var ci_default = new (0, _interactivecommander.Command)().command("ci").descript
|
|
|
5294
5431
|
}
|
|
5295
5432
|
const env = {
|
|
5296
5433
|
LINGODOTDEV_API_KEY: settings.auth.apiKey,
|
|
5297
|
-
LINGODOTDEV_PULL_REQUEST: _optionalChain([options, 'access',
|
|
5298
|
-
...options.commitMessage && {
|
|
5299
|
-
|
|
5300
|
-
|
|
5301
|
-
...options.
|
|
5434
|
+
LINGODOTDEV_PULL_REQUEST: _optionalChain([options, 'access', _178 => _178.pullRequest, 'optionalAccess', _179 => _179.toString, 'call', _180 => _180()]) || "false",
|
|
5435
|
+
...options.commitMessage && {
|
|
5436
|
+
LINGODOTDEV_COMMIT_MESSAGE: options.commitMessage
|
|
5437
|
+
},
|
|
5438
|
+
...options.pullRequestTitle && {
|
|
5439
|
+
LINGODOTDEV_PULL_REQUEST_TITLE: options.pullRequestTitle
|
|
5440
|
+
},
|
|
5441
|
+
...options.workingDirectory && {
|
|
5442
|
+
LINGODOTDEV_WORKING_DIRECTORY: options.workingDirectory
|
|
5443
|
+
},
|
|
5444
|
+
...options.processOwnCommits && {
|
|
5445
|
+
LINGODOTDEV_PROCESS_OWN_COMMITS: options.processOwnCommits.toString()
|
|
5446
|
+
}
|
|
5302
5447
|
};
|
|
5303
5448
|
process.env = { ...process.env, ...env };
|
|
5304
|
-
|
|
5449
|
+
const ora = _ora2.default.call(void 0, );
|
|
5450
|
+
const platformKit = getPlatformKit();
|
|
5451
|
+
const { isPullRequestMode } = platformKit.config;
|
|
5452
|
+
ora.info(`Pull request mode: ${isPullRequestMode ? "on" : "off"}`);
|
|
5453
|
+
const flow = isPullRequestMode ? new PullRequestFlow(ora, platformKit) : new InBranchFlow(ora, platformKit);
|
|
5454
|
+
const canRun = await _optionalChain([flow, 'access', _181 => _181.preRun, 'optionalCall', _182 => _182()]);
|
|
5455
|
+
if (canRun === false) {
|
|
5456
|
+
return;
|
|
5457
|
+
}
|
|
5458
|
+
const hasChanges = await flow.run();
|
|
5459
|
+
if (!hasChanges) {
|
|
5460
|
+
return;
|
|
5461
|
+
}
|
|
5462
|
+
await _optionalChain([flow, 'access', _183 => _183.postRun, 'optionalCall', _184 => _184()]);
|
|
5305
5463
|
});
|
|
5306
5464
|
|
|
5307
5465
|
// src/cli/cmd/status.ts
|
|
@@ -5724,7 +5882,7 @@ function validateParams2(i18nConfig, flags) {
|
|
|
5724
5882
|
// package.json
|
|
5725
5883
|
var package_default = {
|
|
5726
5884
|
name: "lingo.dev",
|
|
5727
|
-
version: "0.
|
|
5885
|
+
version: "0.89.0",
|
|
5728
5886
|
description: "Lingo.dev CLI",
|
|
5729
5887
|
private: false,
|
|
5730
5888
|
publishConfig: {
|
|
@@ -5810,7 +5968,7 @@ var package_default = {
|
|
|
5810
5968
|
"gradient-string": "^3.0.0",
|
|
5811
5969
|
"gray-matter": "^4.0.3",
|
|
5812
5970
|
ini: "^5.0.0",
|
|
5813
|
-
inquirer: "^12.
|
|
5971
|
+
inquirer: "^12.6.0",
|
|
5814
5972
|
"interactive-commander": "^0.5.194",
|
|
5815
5973
|
"is-url": "^1.2.4",
|
|
5816
5974
|
jsdom: "^25.0.1",
|