release-please 13.16.1 → 13.16.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/CHANGELOG.md +39 -0
- package/build/src/factories/plugin-factory.d.ts +1 -0
- package/build/src/manifest.js +70 -19
- package/build/src/plugins/cargo-workspace.d.ts +1 -0
- package/build/src/plugins/cargo-workspace.js +3 -0
- package/build/src/plugins/node-workspace.d.ts +1 -0
- package/build/src/plugins/node-workspace.js +3 -0
- package/build/src/plugins/workspace.d.ts +8 -0
- package/build/src/plugins/workspace.js +21 -2
- package/build/src/strategies/base.d.ts +1 -1
- package/build/src/strategy.d.ts +6 -0
- package/build/src/util/commit-split.d.ts +15 -0
- package/build/src/util/commit-split.js +25 -3
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,45 @@
|
|
|
4
4
|
|
|
5
5
|
[1]: https://www.npmjs.com/package/release-please?activeTab=versions
|
|
6
6
|
|
|
7
|
+
### [13.16.4](https://github.com/googleapis/release-please/compare/v13.16.3...v13.16.4) (2022-05-17)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### Bug Fixes
|
|
11
|
+
|
|
12
|
+
* add release labels if release PR was completed ([#1433](https://github.com/googleapis/release-please/issues/1433)) ([072498c](https://github.com/googleapis/release-please/commit/072498c8ce2f89bc86eb33445d87491e3ab31fbd))
|
|
13
|
+
* CommitSplit with includeEmpty should add commit to all packages ([#1432](https://github.com/googleapis/release-please/issues/1432)) ([19629cb](https://github.com/googleapis/release-please/commit/19629cb42da625d6c62e67f1e9edf7f3cf14d6ee)), closes [#1360](https://github.com/googleapis/release-please/issues/1360)
|
|
14
|
+
* Manifest.fromConfig should find branch component ([#1436](https://github.com/googleapis/release-please/issues/1436)) ([628a562](https://github.com/googleapis/release-please/commit/628a562a21245ed02546aa0c40c97a0e3d50a0c7))
|
|
15
|
+
|
|
16
|
+
### [13.16.3](https://github.com/googleapis/release-please/compare/v13.16.2...v13.16.3) (2022-05-17)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
### Bug Fixes
|
|
20
|
+
|
|
21
|
+
* add release labels if release PR was completed ([#1433](https://github.com/googleapis/release-please/issues/1433)) ([072498c](https://github.com/googleapis/release-please/commit/072498c8ce2f89bc86eb33445d87491e3ab31fbd))
|
|
22
|
+
* CommitSplit with includeEmpty should add commit to all packages ([#1432](https://github.com/googleapis/release-please/issues/1432)) ([19629cb](https://github.com/googleapis/release-please/commit/19629cb42da625d6c62e67f1e9edf7f3cf14d6ee)), closes [#1360](https://github.com/googleapis/release-please/issues/1360)
|
|
23
|
+
* workspace plugins should update manifest versions ([#1429](https://github.com/googleapis/release-please/issues/1429)) ([ab802a9](https://github.com/googleapis/release-please/commit/ab802a924704044b26017b40a2da48657022faad))
|
|
24
|
+
|
|
25
|
+
### [13.16.3](https://github.com/googleapis/release-please/compare/v13.16.2...v13.16.3) (2022-05-13)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
### Bug Fixes
|
|
29
|
+
|
|
30
|
+
* workspace plugins should update manifest versions ([#1429](https://github.com/googleapis/release-please/issues/1429)) ([ab802a9](https://github.com/googleapis/release-please/commit/ab802a924704044b26017b40a2da48657022faad))
|
|
31
|
+
|
|
32
|
+
### [13.16.3](https://github.com/googleapis/release-please/compare/v13.16.2...v13.16.3) (2022-05-13)
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
### Bug Fixes
|
|
36
|
+
|
|
37
|
+
* workspace plugins should update manifest versions ([#1429](https://github.com/googleapis/release-please/issues/1429)) ([ab802a9](https://github.com/googleapis/release-please/commit/ab802a924704044b26017b40a2da48657022faad))
|
|
38
|
+
|
|
39
|
+
### [13.16.2](https://github.com/googleapis/release-please/compare/v13.16.1...v13.16.2) (2022-05-12)
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
### Bug Fixes
|
|
43
|
+
|
|
44
|
+
* throw ConfigurationError when required manifest config file is missing ([#1422](https://github.com/googleapis/release-please/issues/1422)) ([83e461e](https://github.com/googleapis/release-please/commit/83e461e8947d16fbd92d57a0d9c64d37ab0dfa42))
|
|
45
|
+
|
|
7
46
|
### [13.16.1](https://github.com/googleapis/release-please/compare/v13.16.0...v13.16.1) (2022-05-10)
|
|
8
47
|
|
|
9
48
|
|
package/build/src/manifest.js
CHANGED
|
@@ -145,9 +145,9 @@ class Manifest {
|
|
|
145
145
|
github,
|
|
146
146
|
...config,
|
|
147
147
|
});
|
|
148
|
-
const component = await strategy.
|
|
148
|
+
const component = await strategy.getBranchComponent();
|
|
149
149
|
const releasedVersions = {};
|
|
150
|
-
const latestVersion = await latestReleaseVersion(github, targetBranch, version => isPublishedVersion(strategy, version),
|
|
150
|
+
const latestVersion = await latestReleaseVersion(github, targetBranch, version => isPublishedVersion(strategy, version), component, config.pullRequestTitlePattern);
|
|
151
151
|
if (latestVersion) {
|
|
152
152
|
releasedVersions[path] = latestVersion;
|
|
153
153
|
}
|
|
@@ -314,6 +314,7 @@ class Manifest {
|
|
|
314
314
|
github: this.github,
|
|
315
315
|
targetBranch: this.targetBranch,
|
|
316
316
|
repositoryConfig: this.repositoryConfig,
|
|
317
|
+
manifestPath: this.manifestPath,
|
|
317
318
|
}));
|
|
318
319
|
let strategies = strategiesByPath;
|
|
319
320
|
for (const plugin of plugins) {
|
|
@@ -603,20 +604,16 @@ class Manifest {
|
|
|
603
604
|
}
|
|
604
605
|
}
|
|
605
606
|
async createReleasesForPullRequest(releases, pullRequest) {
|
|
606
|
-
|
|
607
|
-
const promises = [];
|
|
608
|
-
for (const release of releases) {
|
|
609
|
-
promises.push(this.createRelease(release));
|
|
610
|
-
}
|
|
607
|
+
logger_1.logger.info(`Creating ${releases.length} releases for pull #${pullRequest.number}`);
|
|
611
608
|
const duplicateReleases = [];
|
|
612
609
|
const githubReleases = [];
|
|
613
|
-
for (const
|
|
610
|
+
for (const release of releases) {
|
|
614
611
|
try {
|
|
615
|
-
githubReleases.push(await
|
|
612
|
+
githubReleases.push(await this.createRelease(release));
|
|
616
613
|
}
|
|
617
614
|
catch (err) {
|
|
618
615
|
if (err instanceof errors_1.DuplicateReleaseError) {
|
|
619
|
-
logger_1.logger.warn(`Duplicate release tag: ${
|
|
616
|
+
logger_1.logger.warn(`Duplicate release tag: ${release.tag.toString()}`);
|
|
620
617
|
duplicateReleases.push(err);
|
|
621
618
|
}
|
|
622
619
|
else {
|
|
@@ -624,14 +621,28 @@ class Manifest {
|
|
|
624
621
|
}
|
|
625
622
|
}
|
|
626
623
|
}
|
|
627
|
-
if (duplicateReleases.length > 0
|
|
628
|
-
|
|
624
|
+
if (duplicateReleases.length > 0) {
|
|
625
|
+
if (duplicateReleases.length + githubReleases.length ===
|
|
626
|
+
releases.length) {
|
|
627
|
+
// we've either tagged all releases or they were duplicates:
|
|
628
|
+
// adjust tags on pullRequest
|
|
629
|
+
await Promise.all([
|
|
630
|
+
this.github.removeIssueLabels(this.labels, pullRequest.number),
|
|
631
|
+
this.github.addIssueLabels(this.releaseLabels, pullRequest.number),
|
|
632
|
+
]);
|
|
633
|
+
}
|
|
634
|
+
if (githubReleases.length === 0) {
|
|
635
|
+
// If all releases were duplicate, throw a duplicate error
|
|
636
|
+
throw duplicateReleases[0];
|
|
637
|
+
}
|
|
638
|
+
}
|
|
639
|
+
else {
|
|
640
|
+
// adjust tags on pullRequest
|
|
641
|
+
await Promise.all([
|
|
642
|
+
this.github.removeIssueLabels(this.labels, pullRequest.number),
|
|
643
|
+
this.github.addIssueLabels(this.releaseLabels, pullRequest.number),
|
|
644
|
+
]);
|
|
629
645
|
}
|
|
630
|
-
// adjust tags on pullRequest
|
|
631
|
-
await Promise.all([
|
|
632
|
-
this.github.removeIssueLabels(this.labels, pullRequest.number),
|
|
633
|
-
this.github.addIssueLabels(this.releaseLabels, pullRequest.number),
|
|
634
|
-
]);
|
|
635
646
|
return githubReleases;
|
|
636
647
|
}
|
|
637
648
|
async createRelease(release) {
|
|
@@ -729,7 +740,7 @@ function extractReleaserConfig(config) {
|
|
|
729
740
|
* @param {string} releaseAs Optional. Override release-as and use the given version
|
|
730
741
|
*/
|
|
731
742
|
async function parseConfig(github, configFile, branch, onlyPath, releaseAs) {
|
|
732
|
-
const config = await github
|
|
743
|
+
const config = await fetchManifestConfig(github, configFile, branch);
|
|
733
744
|
const defaultConfig = extractReleaserConfig(config);
|
|
734
745
|
const repositoryConfig = {};
|
|
735
746
|
for (const path in config.packages) {
|
|
@@ -759,21 +770,61 @@ async function parseConfig(github, configFile, branch, onlyPath, releaseAs) {
|
|
|
759
770
|
};
|
|
760
771
|
return { config: repositoryConfig, options: manifestOptions };
|
|
761
772
|
}
|
|
773
|
+
/**
|
|
774
|
+
* Helper to fetch manifest config
|
|
775
|
+
*
|
|
776
|
+
* @param {GitHub} github
|
|
777
|
+
* @param {string} configFile
|
|
778
|
+
* @param {string} branch
|
|
779
|
+
* @returns {ManifestConfig}
|
|
780
|
+
* @throws {ConfigurationError} if missing the manifest config file
|
|
781
|
+
*/
|
|
782
|
+
async function fetchManifestConfig(github, configFile, branch) {
|
|
783
|
+
try {
|
|
784
|
+
return await github.getFileJson(configFile, branch);
|
|
785
|
+
}
|
|
786
|
+
catch (e) {
|
|
787
|
+
if (e instanceof errors_1.FileNotFoundError) {
|
|
788
|
+
throw new errors_1.ConfigurationError(`Missing required manifest config: ${configFile}`, 'base', `${github.repository.owner}/${github.repository.repo}`);
|
|
789
|
+
}
|
|
790
|
+
throw e;
|
|
791
|
+
}
|
|
792
|
+
}
|
|
762
793
|
/**
|
|
763
794
|
* Helper to parse the manifest versions file.
|
|
764
795
|
*
|
|
765
796
|
* @param {GitHub} github GitHub client
|
|
766
797
|
* @param {string} manifestFile Path in the repository to the versions file
|
|
767
798
|
* @param {string} branch Branch to fetch the versions file from
|
|
799
|
+
* @returns {Record<string, string>}
|
|
768
800
|
*/
|
|
769
801
|
async function parseReleasedVersions(github, manifestFile, branch) {
|
|
770
|
-
const manifestJson = await github
|
|
802
|
+
const manifestJson = await fetchReleasedVersions(github, manifestFile, branch);
|
|
771
803
|
const releasedVersions = {};
|
|
772
804
|
for (const path in manifestJson) {
|
|
773
805
|
releasedVersions[path] = version_1.Version.parse(manifestJson[path]);
|
|
774
806
|
}
|
|
775
807
|
return releasedVersions;
|
|
776
808
|
}
|
|
809
|
+
/**
|
|
810
|
+
* Helper to fetch manifest config
|
|
811
|
+
*
|
|
812
|
+
* @param {GitHub} github
|
|
813
|
+
* @param {string} manifestFile
|
|
814
|
+
* @param {string} branch
|
|
815
|
+
* @throws {ConfigurationError} if missing the manifest config file
|
|
816
|
+
*/
|
|
817
|
+
async function fetchReleasedVersions(github, manifestFile, branch) {
|
|
818
|
+
try {
|
|
819
|
+
return await github.getFileJson(manifestFile, branch);
|
|
820
|
+
}
|
|
821
|
+
catch (e) {
|
|
822
|
+
if (e instanceof errors_1.FileNotFoundError) {
|
|
823
|
+
throw new errors_1.ConfigurationError(`Missing required manifest versions: ${manifestFile}`, 'base', `${github.repository.owner}/${github.repository.repo}`);
|
|
824
|
+
}
|
|
825
|
+
throw e;
|
|
826
|
+
}
|
|
827
|
+
}
|
|
777
828
|
function isPublishedVersion(strategy, version) {
|
|
778
829
|
return strategy.isPublishedVersion
|
|
779
830
|
? strategy.isPublishedVersion(version)
|
|
@@ -47,5 +47,6 @@ export declare class CargoWorkspace extends WorkspacePlugin<CrateInfo> {
|
|
|
47
47
|
protected buildGraph(allPackages: CrateInfo[]): Promise<DependencyGraph<CrateInfo>>;
|
|
48
48
|
protected inScope(candidate: CandidateReleasePullRequest): boolean;
|
|
49
49
|
protected packageNameFromPackage(pkg: CrateInfo): string;
|
|
50
|
+
protected pathFromPackage(pkg: CrateInfo): string;
|
|
50
51
|
}
|
|
51
52
|
export {};
|
|
@@ -213,6 +213,9 @@ class CargoWorkspace extends workspace_1.WorkspacePlugin {
|
|
|
213
213
|
packageNameFromPackage(pkg) {
|
|
214
214
|
return pkg.name;
|
|
215
215
|
}
|
|
216
|
+
pathFromPackage(pkg) {
|
|
217
|
+
return pkg.path;
|
|
218
|
+
}
|
|
216
219
|
}
|
|
217
220
|
exports.CargoWorkspace = CargoWorkspace;
|
|
218
221
|
function getChangelogDepsNotes(originalManifest, updatedManifest) {
|
|
@@ -33,5 +33,6 @@ export declare class NodeWorkspace extends WorkspacePlugin<Package> {
|
|
|
33
33
|
protected buildGraph(allPackages: Package[]): Promise<DependencyGraph<Package>>;
|
|
34
34
|
protected inScope(candidate: CandidateReleasePullRequest): boolean;
|
|
35
35
|
protected packageNameFromPackage(pkg: Package): string;
|
|
36
|
+
protected pathFromPackage(pkg: Package): string;
|
|
36
37
|
}
|
|
37
38
|
export {};
|
|
@@ -235,6 +235,9 @@ class NodeWorkspace extends workspace_1.WorkspacePlugin {
|
|
|
235
235
|
packageNameFromPackage(pkg) {
|
|
236
236
|
return pkg.name;
|
|
237
237
|
}
|
|
238
|
+
pathFromPackage(pkg) {
|
|
239
|
+
return pkg.location;
|
|
240
|
+
}
|
|
238
241
|
}
|
|
239
242
|
exports.NodeWorkspace = NodeWorkspace;
|
|
240
243
|
function getChangelogDepsNotes(original, updated) {
|
|
@@ -8,6 +8,7 @@ export interface DependencyNode<T> {
|
|
|
8
8
|
value: T;
|
|
9
9
|
}
|
|
10
10
|
export interface WorkspacePluginOptions {
|
|
11
|
+
manifestPath?: string;
|
|
11
12
|
updateAllPackages?: boolean;
|
|
12
13
|
}
|
|
13
14
|
interface AllPackages<T> {
|
|
@@ -27,6 +28,7 @@ interface AllPackages<T> {
|
|
|
27
28
|
*/
|
|
28
29
|
export declare abstract class WorkspacePlugin<T> extends ManifestPlugin {
|
|
29
30
|
private updateAllPackages;
|
|
31
|
+
private manifestPath;
|
|
30
32
|
constructor(github: GitHub, targetBranch: string, repositoryConfig: RepositoryConfig, options?: WorkspacePluginOptions);
|
|
31
33
|
run(candidates: CandidateReleasePullRequest[]): Promise<CandidateReleasePullRequest[]>;
|
|
32
34
|
/**
|
|
@@ -83,6 +85,12 @@ export declare abstract class WorkspacePlugin<T> extends ManifestPlugin {
|
|
|
83
85
|
* @returns {string} The package name.
|
|
84
86
|
*/
|
|
85
87
|
protected abstract packageNameFromPackage(pkg: T): string;
|
|
88
|
+
/**
|
|
89
|
+
* Given a package, return the path in the repo to the package.
|
|
90
|
+
* @param {T} pkg The package definition.
|
|
91
|
+
* @returns {string} The package path.
|
|
92
|
+
*/
|
|
93
|
+
protected abstract pathFromPackage(pkg: T): string;
|
|
86
94
|
/**
|
|
87
95
|
* Amend any or all in-scope candidates once all other processing has occured.
|
|
88
96
|
*
|
|
@@ -15,8 +15,10 @@
|
|
|
15
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
16
|
exports.WorkspacePlugin = void 0;
|
|
17
17
|
const plugin_1 = require("../plugin");
|
|
18
|
+
const manifest_1 = require("../manifest");
|
|
18
19
|
const logger_1 = require("../util/logger");
|
|
19
20
|
const merge_1 = require("./merge");
|
|
21
|
+
const release_please_manifest_1 = require("../updaters/release-please-manifest");
|
|
20
22
|
/**
|
|
21
23
|
* The plugin generalizes the logic for handling a workspace and
|
|
22
24
|
* will bump dependencies of managed packages if those dependencies
|
|
@@ -30,9 +32,10 @@ const merge_1 = require("./merge");
|
|
|
30
32
|
*/
|
|
31
33
|
class WorkspacePlugin extends plugin_1.ManifestPlugin {
|
|
32
34
|
constructor(github, targetBranch, repositoryConfig, options = {}) {
|
|
33
|
-
var _a;
|
|
35
|
+
var _a, _b;
|
|
34
36
|
super(github, targetBranch, repositoryConfig);
|
|
35
|
-
this.
|
|
37
|
+
this.manifestPath = (_a = options.manifestPath) !== null && _a !== void 0 ? _a : manifest_1.DEFAULT_RELEASE_PLEASE_MANIFEST;
|
|
38
|
+
this.updateAllPackages = (_b = options.updateAllPackages) !== null && _b !== void 0 ? _b : false;
|
|
36
39
|
}
|
|
37
40
|
async run(candidates) {
|
|
38
41
|
logger_1.logger.info('Running workspace plugin');
|
|
@@ -63,6 +66,7 @@ class WorkspacePlugin extends plugin_1.ManifestPlugin {
|
|
|
63
66
|
const orderedPackages = this.buildGraphOrder(graph, packageNamesToUpdate);
|
|
64
67
|
logger_1.logger.info(`Updating ${orderedPackages.length} packages`);
|
|
65
68
|
const updatedVersions = new Map();
|
|
69
|
+
const updatedPathVersions = new Map();
|
|
66
70
|
for (const pkg of orderedPackages) {
|
|
67
71
|
const packageName = this.packageNameFromPackage(pkg);
|
|
68
72
|
logger_1.logger.debug(`package: ${packageName}`);
|
|
@@ -76,6 +80,7 @@ class WorkspacePlugin extends plugin_1.ManifestPlugin {
|
|
|
76
80
|
const version = this.bumpVersion(pkg);
|
|
77
81
|
logger_1.logger.debug(`version: ${version} forced bump`);
|
|
78
82
|
updatedVersions.set(packageName, version);
|
|
83
|
+
updatedPathVersions.set(this.pathFromPackage(pkg), version);
|
|
79
84
|
}
|
|
80
85
|
}
|
|
81
86
|
let newCandidates = [];
|
|
@@ -98,6 +103,20 @@ class WorkspacePlugin extends plugin_1.ManifestPlugin {
|
|
|
98
103
|
logger_1.logger.info(`Merging ${newCandidates.length} in-scope candidates`);
|
|
99
104
|
const mergePlugin = new merge_1.Merge(this.github, this.targetBranch, this.repositoryConfig);
|
|
100
105
|
newCandidates = await mergePlugin.run(newCandidates);
|
|
106
|
+
if (newCandidates.length === 1) {
|
|
107
|
+
const newUpdates = newCandidates[0].pullRequest.updates;
|
|
108
|
+
newUpdates.push({
|
|
109
|
+
path: this.manifestPath,
|
|
110
|
+
createIfMissing: false,
|
|
111
|
+
updater: new release_please_manifest_1.ReleasePleaseManifest({
|
|
112
|
+
version: newCandidates[0].pullRequest.version,
|
|
113
|
+
versionsMap: updatedPathVersions,
|
|
114
|
+
}),
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
logger_1.logger.warn(`Expected 1 merged candidate, got ${newCandidates.length}`);
|
|
119
|
+
}
|
|
101
120
|
logger_1.logger.info(`Post-processing ${newCandidates.length} in-scope candidates`);
|
|
102
121
|
newCandidates = this.postProcessCandidates(newCandidates, updatedVersions);
|
|
103
122
|
return [...outOfScopeCandidates, ...newCandidates];
|
|
@@ -79,7 +79,7 @@ export declare abstract class BaseStrategy implements Strategy {
|
|
|
79
79
|
*/
|
|
80
80
|
getComponent(): Promise<string | undefined>;
|
|
81
81
|
getDefaultComponent(): Promise<string | undefined>;
|
|
82
|
-
|
|
82
|
+
getBranchComponent(): Promise<string | undefined>;
|
|
83
83
|
getPackageName(): Promise<string | undefined>;
|
|
84
84
|
getDefaultPackageName(): Promise<string | undefined>;
|
|
85
85
|
protected normalizeComponent(component: string | undefined): string;
|
package/build/src/strategy.d.ts
CHANGED
|
@@ -36,6 +36,12 @@ export interface Strategy {
|
|
|
36
36
|
* @returns {string}
|
|
37
37
|
*/
|
|
38
38
|
getComponent(): Promise<string | undefined>;
|
|
39
|
+
/**
|
|
40
|
+
* Return the component for this strategy used in the branch name.
|
|
41
|
+
* This may be a computed field.
|
|
42
|
+
* @returns {string}
|
|
43
|
+
*/
|
|
44
|
+
getBranchComponent(): Promise<string | undefined>;
|
|
39
45
|
/**
|
|
40
46
|
* Validate whether version is a valid release.
|
|
41
47
|
* @param version Released version.
|
|
@@ -3,9 +3,24 @@ export interface CommitSplitOptions {
|
|
|
3
3
|
includeEmpty?: boolean;
|
|
4
4
|
packagePaths?: string[];
|
|
5
5
|
}
|
|
6
|
+
/**
|
|
7
|
+
* Helper class for splitting commits by component path. If `packagePaths`
|
|
8
|
+
* is configured, then only consider the provided paths. If `includeEmpty`
|
|
9
|
+
* is configured, then commits without any touched files apply to all
|
|
10
|
+
* configured component paths.
|
|
11
|
+
*/
|
|
6
12
|
export declare class CommitSplit {
|
|
7
13
|
includeEmpty: boolean;
|
|
8
14
|
packagePaths?: string[];
|
|
9
15
|
constructor(opts?: CommitSplitOptions);
|
|
16
|
+
/**
|
|
17
|
+
* Split commits by component path. If the commit splitter is configured
|
|
18
|
+
* with a set of tracked package paths, then only consider paths for
|
|
19
|
+
* configured components. If `includeEmpty` is configured, then a commit
|
|
20
|
+
* that does not touch any files will be applied to all components'
|
|
21
|
+
* commits.
|
|
22
|
+
* @param {Commit[]} commits The commits to split
|
|
23
|
+
* @returns {Record<string, Commit[]>} Commits indexed by component path
|
|
24
|
+
*/
|
|
10
25
|
split<T extends Commit>(commits: T[]): Record<string, T[]>;
|
|
11
26
|
}
|
|
@@ -15,6 +15,12 @@
|
|
|
15
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
16
|
exports.CommitSplit = void 0;
|
|
17
17
|
const manifest_1 = require("../manifest");
|
|
18
|
+
/**
|
|
19
|
+
* Helper class for splitting commits by component path. If `packagePaths`
|
|
20
|
+
* is configured, then only consider the provided paths. If `includeEmpty`
|
|
21
|
+
* is configured, then commits without any touched files apply to all
|
|
22
|
+
* configured component paths.
|
|
23
|
+
*/
|
|
18
24
|
class CommitSplit {
|
|
19
25
|
constructor(opts) {
|
|
20
26
|
opts = opts || {};
|
|
@@ -50,7 +56,15 @@ class CommitSplit {
|
|
|
50
56
|
this.packagePaths = paths;
|
|
51
57
|
}
|
|
52
58
|
}
|
|
53
|
-
|
|
59
|
+
/**
|
|
60
|
+
* Split commits by component path. If the commit splitter is configured
|
|
61
|
+
* with a set of tracked package paths, then only consider paths for
|
|
62
|
+
* configured components. If `includeEmpty` is configured, then a commit
|
|
63
|
+
* that does not touch any files will be applied to all components'
|
|
64
|
+
* commits.
|
|
65
|
+
* @param {Commit[]} commits The commits to split
|
|
66
|
+
* @returns {Record<string, Commit[]>} Commits indexed by component path
|
|
67
|
+
*/
|
|
54
68
|
split(commits) {
|
|
55
69
|
const splitCommits = {};
|
|
56
70
|
commits.forEach(commit => {
|
|
@@ -85,8 +99,16 @@ class CommitSplit {
|
|
|
85
99
|
splitCommits[pkgName].push(commit);
|
|
86
100
|
}
|
|
87
101
|
if (commit.files.length === 0 && this.includeEmpty) {
|
|
88
|
-
|
|
89
|
-
|
|
102
|
+
if (this.packagePaths) {
|
|
103
|
+
for (const pkgName of this.packagePaths) {
|
|
104
|
+
splitCommits[pkgName] = splitCommits[pkgName] || [];
|
|
105
|
+
splitCommits[pkgName].push(commit);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
for (const pkgName in splitCommits) {
|
|
110
|
+
splitCommits[pkgName].push(commit);
|
|
111
|
+
}
|
|
90
112
|
}
|
|
91
113
|
}
|
|
92
114
|
});
|
package/package.json
CHANGED