fork-version 4.1.7 → 4.1.8
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/CHANGELOG.md +16 -0
- package/README.md +31 -0
- package/dist/{chunk-JYQTKLHN.cjs → chunk-KRGBUNRK.cjs} +197 -42
- package/dist/chunk-KRGBUNRK.cjs.map +1 -0
- package/dist/{chunk-5CZU5EA7.js → chunk-X4NB24VR.js} +197 -42
- package/dist/chunk-X4NB24VR.js.map +1 -0
- package/dist/cli.cjs +8 -8
- package/dist/cli.js +1 -1
- package/dist/index.cjs +18 -18
- package/dist/index.d.cts +71 -109
- package/dist/index.d.ts +71 -109
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-5CZU5EA7.js.map +0 -1
- package/dist/chunk-JYQTKLHN.cjs.map +0 -1
|
@@ -250,10 +250,10 @@ var ForkConfigSchema = z.object({
|
|
|
250
250
|
*/
|
|
251
251
|
verify: z.boolean().describe("If true, git will run user defined git hooks before committing."),
|
|
252
252
|
/**
|
|
253
|
-
*
|
|
253
|
+
* Print inspected output as a parsable json string.
|
|
254
254
|
* @default false
|
|
255
255
|
*/
|
|
256
|
-
asJson: z.boolean().describe("
|
|
256
|
+
asJson: z.boolean().describe("Print inspected output as a parsable json string."),
|
|
257
257
|
// Skip Steps
|
|
258
258
|
//
|
|
259
259
|
/**
|
|
@@ -276,17 +276,34 @@ var ForkConfigSchema = z.object({
|
|
|
276
276
|
* @default false
|
|
277
277
|
*/
|
|
278
278
|
skipTag: z.boolean().describe("Skip the tag step."),
|
|
279
|
+
// Parser Options
|
|
280
|
+
//
|
|
281
|
+
/**
|
|
282
|
+
* The detected git host:
|
|
283
|
+
* - `GitHub`
|
|
284
|
+
* - `GitLab`
|
|
285
|
+
* - `Bitbucket`
|
|
286
|
+
* - `Azure Devops`
|
|
287
|
+
* - Or undefined if unknown or not detected.
|
|
288
|
+
*/
|
|
289
|
+
detectedGitHost: z.string().optional().describe(
|
|
290
|
+
"The detected git host, such as GitHub, GitLab, Bitbucket, Azure Devops, or undefined if unknown or not detected."
|
|
291
|
+
),
|
|
279
292
|
/**
|
|
280
293
|
* Override the default "conventional-changelog-conventionalcommits" preset configuration.
|
|
281
294
|
*/
|
|
282
|
-
changelogPresetConfig: ChangelogPresetConfigSchema.partial().describe(
|
|
295
|
+
changelogPresetConfig: ChangelogPresetConfigSchema.partial().optional().describe(
|
|
283
296
|
'Override the default "conventional-changelog-conventionalcommits" preset configuration.'
|
|
284
297
|
),
|
|
285
298
|
/**
|
|
286
299
|
* Add a suffix to the release commit message.
|
|
287
300
|
* @example "[skip ci]"
|
|
288
301
|
*/
|
|
289
|
-
releaseMessageSuffix: z.string().optional().describe("Add a suffix to the release commit message.")
|
|
302
|
+
releaseMessageSuffix: z.string().optional().describe("Add a suffix to the release commit message."),
|
|
303
|
+
/**
|
|
304
|
+
* Options to pass to commits parser.
|
|
305
|
+
*/
|
|
306
|
+
commitParserOptions: z.looseObject().optional().describe("Options to pass to commits parser.")
|
|
290
307
|
});
|
|
291
308
|
|
|
292
309
|
// src/utils/escape-regex.ts
|
|
@@ -563,7 +580,7 @@ ${SCISSOR}
|
|
|
563
580
|
return splitCommits;
|
|
564
581
|
}
|
|
565
582
|
};
|
|
566
|
-
function getChangelogPresetConfig(mergedConfig, cliArguments,
|
|
583
|
+
function getChangelogPresetConfig(mergedConfig, cliArguments, detectedChangelogOptions) {
|
|
567
584
|
const preset = {
|
|
568
585
|
name: "conventionalcommits"
|
|
569
586
|
};
|
|
@@ -587,8 +604,8 @@ function getChangelogPresetConfig(mergedConfig, cliArguments, detectedGitHost) {
|
|
|
587
604
|
}
|
|
588
605
|
});
|
|
589
606
|
}
|
|
590
|
-
if (
|
|
591
|
-
Object.entries(
|
|
607
|
+
if (detectedChangelogOptions) {
|
|
608
|
+
Object.entries(detectedChangelogOptions).forEach(([key, value]) => {
|
|
592
609
|
if (value !== void 0) {
|
|
593
610
|
preset[key] = value;
|
|
594
611
|
}
|
|
@@ -664,41 +681,175 @@ All notable changes to this project will be documented in this file. See [fork-v
|
|
|
664
681
|
skipBump: false,
|
|
665
682
|
skipChangelog: false,
|
|
666
683
|
skipCommit: false,
|
|
667
|
-
skipTag: false
|
|
668
|
-
changelogPresetConfig: {}
|
|
684
|
+
skipTag: false
|
|
669
685
|
};
|
|
670
686
|
|
|
671
|
-
// src/
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
if (
|
|
675
|
-
|
|
687
|
+
// src/detect-git-host/host-github.ts
|
|
688
|
+
function detectGitHubOptions(remoteUrl) {
|
|
689
|
+
let matches = null;
|
|
690
|
+
if (/^https:\/\/(.*)?github\.com/.test(remoteUrl)) {
|
|
691
|
+
matches = /^https:\/\/(.*)?github\.com\/(?<organisation>.*?)\/(?<repository>.*?)(?:\.git)?$/.exec(
|
|
692
|
+
remoteUrl
|
|
693
|
+
);
|
|
694
|
+
} else if (remoteUrl.startsWith("git@github.com:")) {
|
|
695
|
+
matches = /^git@github\.com:(?<organisation>.*?)\/(?<repository>.*?)(?:\.git)?$/.exec(
|
|
696
|
+
remoteUrl
|
|
697
|
+
);
|
|
698
|
+
}
|
|
699
|
+
if (matches?.groups) {
|
|
700
|
+
const { organisation = "", repository = "" } = matches.groups;
|
|
701
|
+
return {
|
|
702
|
+
hostName: "GitHub",
|
|
703
|
+
changelogOptions: {
|
|
704
|
+
commitUrlFormat: `https://github.com/${organisation}/${repository}/commit/{{hash}}`,
|
|
705
|
+
compareUrlFormat: `https://github.com/${organisation}/${repository}/compare/{{previousTag}}...{{currentTag}}`,
|
|
706
|
+
issueUrlFormat: `https://github.com/${organisation}/${repository}/issues/{{id}}`,
|
|
707
|
+
issuePrefixes: ["#", "gh-"]
|
|
708
|
+
},
|
|
709
|
+
commitParserOptions: {
|
|
710
|
+
mergePattern: /^Merge pull request #(?<id>\d*) from (?<source>.*)/i,
|
|
711
|
+
issuePrefixes: ["#", "gh-"]
|
|
712
|
+
}
|
|
713
|
+
};
|
|
714
|
+
}
|
|
715
|
+
return void 0;
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
// src/detect-git-host/host-gitlab.ts
|
|
719
|
+
function detectGitlabOptions(remoteUrl) {
|
|
720
|
+
let matches = null;
|
|
721
|
+
if (/^https:\/\/(.*)?gitlab\.com/.test(remoteUrl)) {
|
|
722
|
+
matches = /^https:\/\/(.*)?gitlab\.com\/(?<organisation>.*?)\/(?<repository>.*?)(?:\.git)?$/.exec(
|
|
723
|
+
remoteUrl
|
|
724
|
+
);
|
|
725
|
+
} else if (remoteUrl.startsWith("git@gitlab.com:")) {
|
|
726
|
+
matches = /^git@gitlab\.com:(?<organisation>.*?)\/(?<repository>.*?)(?:\.git)?$/.exec(
|
|
727
|
+
remoteUrl
|
|
728
|
+
);
|
|
729
|
+
}
|
|
730
|
+
if (matches?.groups) {
|
|
731
|
+
const { organisation = "", repository = "" } = matches.groups;
|
|
732
|
+
return {
|
|
733
|
+
hostName: "GitLab",
|
|
734
|
+
changelogOptions: {
|
|
735
|
+
commitUrlFormat: `https://gitlab.com/${organisation}/${repository}/-/commit/{{hash}}`,
|
|
736
|
+
compareUrlFormat: `https://gitlab.com/${organisation}/${repository}/-/compare/{{previousTag}}...{{currentTag}}`,
|
|
737
|
+
issueUrlFormat: `https://gitlab.com/${organisation}/${repository}/-/issues/{{id}}`
|
|
738
|
+
},
|
|
739
|
+
commitParserOptions: {
|
|
740
|
+
mergePattern: /^Merge branch '(?<source>.*)' into '(.*)'/i,
|
|
741
|
+
// https://docs.gitlab.com/user/project/issues/managing_issues/#default-closing-pattern
|
|
742
|
+
referenceActions: [
|
|
743
|
+
"close",
|
|
744
|
+
"closes",
|
|
745
|
+
"closed",
|
|
746
|
+
"closing",
|
|
747
|
+
"fix",
|
|
748
|
+
"fixes",
|
|
749
|
+
"fixed",
|
|
750
|
+
"fixing",
|
|
751
|
+
"resolve",
|
|
752
|
+
"resolves",
|
|
753
|
+
"resolved",
|
|
754
|
+
"resolving",
|
|
755
|
+
"implement",
|
|
756
|
+
"implements",
|
|
757
|
+
"implemented",
|
|
758
|
+
"implementing"
|
|
759
|
+
]
|
|
760
|
+
}
|
|
761
|
+
};
|
|
762
|
+
}
|
|
763
|
+
return void 0;
|
|
764
|
+
}
|
|
765
|
+
|
|
766
|
+
// src/detect-git-host/host-bitbucket.ts
|
|
767
|
+
function detectBitbucketOptions(remoteUrl) {
|
|
768
|
+
let matches = null;
|
|
769
|
+
if (/^https:\/\/(.*)?bitbucket\.(org|com)/.test(remoteUrl)) {
|
|
770
|
+
matches = /^https:\/\/(.*)?bitbucket\.(?<domain>org|com)\/(?<organisation>.*?)\/(?<repository>.*?)(?:\.git)?$/.exec(
|
|
771
|
+
remoteUrl
|
|
772
|
+
);
|
|
773
|
+
} else if (remoteUrl.startsWith("git@bitbucket.org:")) {
|
|
774
|
+
matches = /^git@bitbucket\.(?<domain>org|com):(?<organisation>.*?)\/(?<repository>.*?)(?:\.git)?$/.exec(
|
|
775
|
+
remoteUrl
|
|
776
|
+
);
|
|
777
|
+
}
|
|
778
|
+
if (matches?.groups) {
|
|
779
|
+
const { domain = "", organisation = "", repository = "" } = matches.groups;
|
|
780
|
+
return {
|
|
781
|
+
hostName: "Bitbucket",
|
|
782
|
+
changelogOptions: {
|
|
783
|
+
commitUrlFormat: `https://bitbucket.${domain}/${organisation}/${repository}/commits/{{hash}}`,
|
|
784
|
+
compareUrlFormat: `https://bitbucket.${domain}/${organisation}/${repository}/branches/compare/{{currentTag}}..{{previousTag}}`,
|
|
785
|
+
// Bitbucket doesn't have a builtin issue tracker like GitHub or GitLab, this should be overridden by the user if they want to link to issues in their changelog.
|
|
786
|
+
issueUrlFormat: `https://bitbucket.${domain}/${organisation}/${repository}/issues/{{id}}`
|
|
787
|
+
},
|
|
788
|
+
commitParserOptions: {
|
|
789
|
+
mergePattern: /^Merged in (?<source>.*) \(pull request #(?<id>\d*)\)/i
|
|
790
|
+
}
|
|
791
|
+
};
|
|
792
|
+
}
|
|
793
|
+
return void 0;
|
|
794
|
+
}
|
|
795
|
+
|
|
796
|
+
// src/detect-git-host/host-azure-devops.ts
|
|
797
|
+
function detectAzureDevopsOptions(remoteUrl) {
|
|
798
|
+
let matches = null;
|
|
799
|
+
if (/^https:\/\/(.*)?dev\.azure\.com/.test(remoteUrl)) {
|
|
800
|
+
matches = /^https:\/\/(.*)?dev\.azure\.com\/(?<organisation>.*?)\/(?<project>.*?)\/_git\/(?<repository>.*?)(?:\.git)?$/.exec(
|
|
676
801
|
remoteUrl
|
|
677
802
|
);
|
|
678
|
-
if (match?.groups) {
|
|
679
|
-
const { organisation = "", project = "", repository = "" } = match.groups;
|
|
680
|
-
return {
|
|
681
|
-
detectedGitHost: "Azure",
|
|
682
|
-
commitUrlFormat: `{{host}}/${organisation}/${project}/_git/${repository}/commit/{{hash}}`,
|
|
683
|
-
compareUrlFormat: `{{host}}/${organisation}/${project}/_git/${repository}/branchCompare?baseVersion=GT{{previousTag}}&targetVersion=GT{{currentTag}}`,
|
|
684
|
-
issueUrlFormat: `{{host}}/${organisation}/${project}/_workitems/edit/{{id}}`
|
|
685
|
-
};
|
|
686
|
-
}
|
|
687
803
|
} else if (remoteUrl.startsWith("git@ssh.dev.azure.com:")) {
|
|
688
|
-
|
|
804
|
+
matches = /^git@ssh\.dev\.azure\.com:v\d\/(?<organisation>.*?)\/(?<project>.*?)\/(?<repository>.*?)(?:\.git)?$/.exec(
|
|
689
805
|
remoteUrl
|
|
690
806
|
);
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
807
|
+
}
|
|
808
|
+
if (matches?.groups) {
|
|
809
|
+
const { organisation = "", project = "", repository = "" } = matches.groups;
|
|
810
|
+
return {
|
|
811
|
+
hostName: "Azure Devops",
|
|
812
|
+
changelogOptions: {
|
|
813
|
+
commitUrlFormat: `https://dev.azure.com/${organisation}/${project}/_git/${repository}/commit/{{hash}}`,
|
|
814
|
+
compareUrlFormat: `https://dev.azure.com/${organisation}/${project}/_git/${repository}/branchCompare?baseVersion=GT{{previousTag}}&targetVersion=GT{{currentTag}}`,
|
|
815
|
+
issueUrlFormat: `https://dev.azure.com/${organisation}/${project}/_workitems/edit/{{id}}`
|
|
816
|
+
},
|
|
817
|
+
commitParserOptions: {
|
|
818
|
+
mergePattern: /^Merged PR (?<id>\d*): (?<source>.*)/i
|
|
819
|
+
}
|
|
820
|
+
};
|
|
821
|
+
}
|
|
822
|
+
return void 0;
|
|
823
|
+
}
|
|
824
|
+
|
|
825
|
+
// src/detect-git-host/detect-git-host.ts
|
|
826
|
+
async function detectGitHost(path) {
|
|
827
|
+
const remoteUrl = await new Git({ path }).getRemoteUrl();
|
|
828
|
+
if (remoteUrl.includes("github.com")) {
|
|
829
|
+
const githubOptions = detectGitHubOptions(remoteUrl);
|
|
830
|
+
if (githubOptions) {
|
|
831
|
+
return githubOptions;
|
|
832
|
+
}
|
|
833
|
+
}
|
|
834
|
+
if (remoteUrl.includes("gitlab.com")) {
|
|
835
|
+
const gitlabOptions = detectGitlabOptions(remoteUrl);
|
|
836
|
+
if (gitlabOptions) {
|
|
837
|
+
return gitlabOptions;
|
|
838
|
+
}
|
|
839
|
+
}
|
|
840
|
+
if (/bitbucket\.(org|com)/.test(remoteUrl)) {
|
|
841
|
+
const bitbucketOptions = detectBitbucketOptions(remoteUrl);
|
|
842
|
+
if (bitbucketOptions) {
|
|
843
|
+
return bitbucketOptions;
|
|
844
|
+
}
|
|
845
|
+
}
|
|
846
|
+
if (remoteUrl.includes("dev.azure.com")) {
|
|
847
|
+
const azureDevopsOptions = detectAzureDevopsOptions(remoteUrl);
|
|
848
|
+
if (azureDevopsOptions) {
|
|
849
|
+
return azureDevopsOptions;
|
|
699
850
|
}
|
|
700
851
|
}
|
|
701
|
-
return
|
|
852
|
+
return void 0;
|
|
702
853
|
}
|
|
703
854
|
var PACKAGE_JSON_CONFIG_KEY = "fork-version";
|
|
704
855
|
async function loadConfigFile(cwd) {
|
|
@@ -785,11 +936,6 @@ async function getUserConfig(cliArguments) {
|
|
|
785
936
|
}
|
|
786
937
|
const files = mergeFiles(configFile?.files, cliArguments.flags.files, globResults);
|
|
787
938
|
const detectedGitHost = await detectGitHost(cwd);
|
|
788
|
-
const changelogPresetConfig = getChangelogPresetConfig(
|
|
789
|
-
mergedConfig,
|
|
790
|
-
cliArguments.flags,
|
|
791
|
-
detectedGitHost
|
|
792
|
-
);
|
|
793
939
|
let command = DEFAULT_CONFIG.command;
|
|
794
940
|
if (cliArguments.input.length > 0 && cliArguments.input[0].trim()) {
|
|
795
941
|
command = cliArguments.input[0].trim().toLowerCase();
|
|
@@ -810,7 +956,16 @@ async function getUserConfig(cliArguments) {
|
|
|
810
956
|
cliArguments.flags.preReleaseTag ?? cliArguments.flags.preRelease ?? configFile.preRelease
|
|
811
957
|
),
|
|
812
958
|
silent: shouldBeSilent || mergedConfig.silent,
|
|
813
|
-
|
|
959
|
+
detectedGitHost: detectedGitHost?.hostName,
|
|
960
|
+
changelogPresetConfig: getChangelogPresetConfig(
|
|
961
|
+
mergedConfig,
|
|
962
|
+
cliArguments.flags,
|
|
963
|
+
detectedGitHost?.changelogOptions
|
|
964
|
+
),
|
|
965
|
+
commitParserOptions: {
|
|
966
|
+
...detectedGitHost?.commitParserOptions,
|
|
967
|
+
...mergedConfig.commitParserOptions
|
|
968
|
+
}
|
|
814
969
|
};
|
|
815
970
|
}
|
|
816
971
|
var Logger = class {
|
|
@@ -1649,7 +1804,7 @@ function cleanTag(tag, tagPrefix) {
|
|
|
1649
1804
|
|
|
1650
1805
|
// src/process/get-commits.ts
|
|
1651
1806
|
async function getCommitsSinceTag(config, logger, git) {
|
|
1652
|
-
const commitParser = new CommitParser();
|
|
1807
|
+
const commitParser = new CommitParser(config.commitParserOptions);
|
|
1653
1808
|
if (config.debug) commitParser.setLogger(logger);
|
|
1654
1809
|
const latestTag = await git.getMostRecentTag(config.tagPrefix);
|
|
1655
1810
|
if (!latestTag) {
|
|
@@ -2061,5 +2216,5 @@ async function main(config, logger, fileManager, git) {
|
|
|
2061
2216
|
}
|
|
2062
2217
|
|
|
2063
2218
|
export { CommitParser, FileManager, ForkConfigSchema, Git, Logger, commitChanges, createParserOptions, filterRevertedCommits, getCommitsSinceTag, getCurrentVersion, getNextVersion, getUserConfig, inspect, main, tagChanges, updateChangelog, validateConfig };
|
|
2064
|
-
//# sourceMappingURL=chunk-
|
|
2065
|
-
//# sourceMappingURL=chunk-
|
|
2219
|
+
//# sourceMappingURL=chunk-X4NB24VR.js.map
|
|
2220
|
+
//# sourceMappingURL=chunk-X4NB24VR.js.map
|