beachball 2.32.3 → 2.33.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/lib/bump/gatherBumpInfo.d.ts.map +1 -1
- package/lib/bump/gatherBumpInfo.js +5 -10
- package/lib/bump/gatherBumpInfo.js.map +1 -1
- package/lib/bump/performBump.js +1 -4
- package/lib/bump/performBump.js.map +1 -1
- package/lib/bump/updateRelatedChangeType.js +4 -4
- package/lib/bump/updateRelatedChangeType.js.map +1 -1
- package/lib/changefile/changeTypes.d.ts +23 -0
- package/lib/changefile/changeTypes.d.ts.map +1 -0
- package/lib/changefile/changeTypes.js +53 -0
- package/lib/changefile/changeTypes.js.map +1 -0
- package/lib/changefile/getChangedPackages.d.ts.map +1 -1
- package/lib/changefile/getChangedPackages.js +5 -77
- package/lib/changefile/getChangedPackages.js.map +1 -1
- package/lib/changelog/getPackageChangelogs.js +2 -2
- package/lib/changelog/getPackageChangelogs.js.map +1 -1
- package/lib/changelog/mergeChangelogs.js +2 -2
- package/lib/changelog/mergeChangelogs.js.map +1 -1
- package/lib/changelog/renderJsonChangelog.js +2 -2
- package/lib/changelog/renderJsonChangelog.js.map +1 -1
- package/lib/commands/publish.d.ts.map +1 -1
- package/lib/commands/publish.js +1 -3
- package/lib/commands/publish.js.map +1 -1
- package/lib/git/ensureSharedHistory.d.ts +10 -0
- package/lib/git/ensureSharedHistory.d.ts.map +1 -0
- package/lib/git/ensureSharedHistory.js +156 -0
- package/lib/git/ensureSharedHistory.js.map +1 -0
- package/lib/git/fetch.d.ts +25 -0
- package/lib/git/fetch.d.ts.map +1 -0
- package/lib/git/fetch.js +54 -0
- package/lib/git/fetch.js.map +1 -0
- package/lib/git/generateTag.d.ts +3 -0
- package/lib/git/generateTag.d.ts.map +1 -0
- package/lib/{tag.js → git/generateTag.js} +2 -1
- package/lib/git/generateTag.js.map +1 -0
- package/lib/git/gitAsync.d.ts +33 -0
- package/lib/git/gitAsync.d.ts.map +1 -0
- package/lib/git/gitAsync.js +63 -0
- package/lib/git/gitAsync.js.map +1 -0
- package/lib/monorepo/getPackageGroups.d.ts.map +1 -1
- package/lib/monorepo/getPackageGroups.js +27 -22
- package/lib/monorepo/getPackageGroups.js.map +1 -1
- package/lib/monorepo/getPackageInfos.d.ts.map +1 -1
- package/lib/monorepo/getPackageInfos.js +41 -34
- package/lib/monorepo/getPackageInfos.js.map +1 -1
- package/lib/publish/bumpAndPush.d.ts.map +1 -1
- package/lib/publish/bumpAndPush.js +46 -39
- package/lib/publish/bumpAndPush.js.map +1 -1
- package/lib/publish/publishToRegistry.d.ts.map +1 -1
- package/lib/publish/publishToRegistry.js +1 -4
- package/lib/publish/publishToRegistry.js.map +1 -1
- package/lib/publish/tagPackages.d.ts +7 -2
- package/lib/publish/tagPackages.d.ts.map +1 -1
- package/lib/publish/tagPackages.js +16 -12
- package/lib/publish/tagPackages.js.map +1 -1
- package/lib/types/BeachballOptions.d.ts +8 -2
- package/lib/types/BeachballOptions.d.ts.map +1 -1
- package/package.json +1 -1
- package/lib/changefile/getPackageChangeTypes.d.ts +0 -17
- package/lib/changefile/getPackageChangeTypes.d.ts.map +0 -1
- package/lib/changefile/getPackageChangeTypes.js +0 -81
- package/lib/changefile/getPackageChangeTypes.js.map +0 -1
- package/lib/publish/mergePublishBranch.d.ts +0 -4
- package/lib/publish/mergePublishBranch.d.ts.map +0 -1
- package/lib/publish/mergePublishBranch.js +0 -35
- package/lib/publish/mergePublishBranch.js.map +0 -1
- package/lib/tag.d.ts +0 -2
- package/lib/tag.d.ts.map +0 -1
- package/lib/tag.js.map +0 -1
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ensureSharedHistory = void 0;
|
|
4
|
+
const workspace_tools_1 = require("workspace-tools");
|
|
5
|
+
const fetch_1 = require("./fetch");
|
|
6
|
+
/**
|
|
7
|
+
* Ensure that adequate history is available to check for changes between HEAD and `options.branch`.
|
|
8
|
+
* Otherwise attempting to get changes will fail with an error "no merge base".
|
|
9
|
+
* (This is mostly an issue with CI builds that use shallow clones.)
|
|
10
|
+
*
|
|
11
|
+
* Throws an error if history is inadequate and cannot be fixed.
|
|
12
|
+
*/
|
|
13
|
+
function ensureSharedHistory(options) {
|
|
14
|
+
const { fetch, path: cwd, branch, depth, verbose } = options;
|
|
15
|
+
// `branch` should *usually* include a remote, but it's not guaranteed (see doc comment).
|
|
16
|
+
// `remote` is the remote name (e.g. "origin") or "" if `branch` was missing a remote.
|
|
17
|
+
// `remoteBranch` is the comparison branch name (e.g. "main").
|
|
18
|
+
const { remote, remoteBranch } = workspace_tools_1.parseRemoteBranch(branch);
|
|
19
|
+
// Ensure the comparison branch ref exists
|
|
20
|
+
if (!hasBranchRef(branch, cwd)) {
|
|
21
|
+
if (!fetch) {
|
|
22
|
+
// If fetching is disabled, the target branch must be available for comparison locally.
|
|
23
|
+
// This is most likely to be an issue in a CI build which does a shallow checkout (github
|
|
24
|
+
// actions/checkout does this by default) and also disables beachball fetching.
|
|
25
|
+
logError('missing-branch', branch, remote, remoteBranch);
|
|
26
|
+
throw new Error(`Target branch "${branch}" does not exist locally, and fetching is disabled`);
|
|
27
|
+
}
|
|
28
|
+
if (!remote) {
|
|
29
|
+
// If the remote isn't specified, even if fetching is allowed it will be unclear what to
|
|
30
|
+
// compare against
|
|
31
|
+
throw new Error(`Target branch "${branch}" doesn't exist locally, and a remote name wasn't specified and couldn't be inferred. ` +
|
|
32
|
+
'Please set "repository" in your root package.json or include a remote in the beachball "branch" setting.');
|
|
33
|
+
}
|
|
34
|
+
// If fetching the requested branch isn't already (probably) configured, add it to the list so
|
|
35
|
+
// it can be fetched in the next step. Otherwise the ref <remote>/<remoteBranch> won't exist locally.
|
|
36
|
+
const fetchConfig = workspace_tools_1.git(['config', '--get-all', `remote.${remote}.fetch`], { cwd }).stdout.trim();
|
|
37
|
+
if (!fetchConfig.includes(`${remote}/*`) && !fetchConfig.includes(branch)) {
|
|
38
|
+
console.log(`Adding branch "${remoteBranch}" to fetch config for remote "${remote}"`);
|
|
39
|
+
const result = workspace_tools_1.git(['remote', 'set-branches', '--add', remote, remoteBranch], { cwd });
|
|
40
|
+
if (!result.success) {
|
|
41
|
+
throw new Error(`Failed to add branch "${remoteBranch}" to fetch config for remote "${remote}":\n${result.stderr}`);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
if (fetch) {
|
|
46
|
+
// Fetch the latest from the remote branch for comparison. If the specified remoteBranch doesn't
|
|
47
|
+
// exist (or there's a network error or something), this will return an error.
|
|
48
|
+
const result = fetch_1.gitFetch({
|
|
49
|
+
remote,
|
|
50
|
+
branch: remoteBranch,
|
|
51
|
+
cwd,
|
|
52
|
+
verbose,
|
|
53
|
+
// Only use "depth" if the repo is already shallow, since fetching a normal repo with --depth
|
|
54
|
+
// will convert it to shallow (which is likely not desired and could be confusing)
|
|
55
|
+
depth: depth && isShallowRepository(cwd) ? depth : undefined,
|
|
56
|
+
});
|
|
57
|
+
if (!result.success) {
|
|
58
|
+
throw new Error(result.errorMessage);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
// Verify that HEAD and the target branch share history
|
|
62
|
+
let isConnected = hasCommonCommit(branch, cwd);
|
|
63
|
+
if (!isConnected) {
|
|
64
|
+
// If this is a shallow repo, history may not go back far enough to connect the branches
|
|
65
|
+
if (isShallowRepository(cwd)) {
|
|
66
|
+
if (!fetch) {
|
|
67
|
+
// Fetching is disabled, so the lack of history can't be fixed
|
|
68
|
+
logError('shallow-clone', branch, remote, remoteBranch);
|
|
69
|
+
throw new Error(`Inadequate history available to connect HEAD to target branch "${branch}"`);
|
|
70
|
+
}
|
|
71
|
+
// Try fetching more history
|
|
72
|
+
isConnected = deepenHistory({ remote, remoteBranch, branch, depth, cwd, verbose });
|
|
73
|
+
}
|
|
74
|
+
if (!isConnected) {
|
|
75
|
+
throw new Error(`HEAD does not appear to share history with target branch "${branch}"`);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
exports.ensureSharedHistory = ensureSharedHistory;
|
|
80
|
+
/**
|
|
81
|
+
* Try to deepen history of a shallow clone to find a common commit with the target branch.
|
|
82
|
+
* Returns true if a common commit can be found after fetching more history.
|
|
83
|
+
* Throws if there's any issue
|
|
84
|
+
*/
|
|
85
|
+
function deepenHistory(params) {
|
|
86
|
+
const { remote, remoteBranch, branch, cwd, verbose } = params;
|
|
87
|
+
const depth = params.depth || 100;
|
|
88
|
+
console.log(`This is a shallow clone. Deepening to check for changes...`);
|
|
89
|
+
// Iteratively deepen the history
|
|
90
|
+
const maxAttempts = 3;
|
|
91
|
+
for (let attempt = 1; attempt <= maxAttempts; attempt++) {
|
|
92
|
+
console.log(`Deepening by ${depth} more commits (attempt ${attempt}/${maxAttempts})...`);
|
|
93
|
+
const result = fetch_1.gitFetch({ remote, branch: remoteBranch, deepen: depth, cwd, verbose });
|
|
94
|
+
if (!result.success) {
|
|
95
|
+
throw new Error(`Failed to fetch more history (see above for details)`);
|
|
96
|
+
}
|
|
97
|
+
if (hasCommonCommit(branch, cwd)) {
|
|
98
|
+
// Fetched enough history to find a common commit
|
|
99
|
+
return true;
|
|
100
|
+
}
|
|
101
|
+
if (!isShallowRepository(cwd)) {
|
|
102
|
+
// Fetched all history and still no common commit
|
|
103
|
+
return false;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
// No common commit was found and the repo is still shallow, so fully unshallow it
|
|
107
|
+
console.log(`Still didn't find a common commit after deepening by ${depth * maxAttempts}. Unshallowing...`);
|
|
108
|
+
const result = fetch_1.gitFetch({ remote, branch: remoteBranch, unshallow: true, cwd, verbose });
|
|
109
|
+
if (!result.success) {
|
|
110
|
+
throw new Error(`Failed to unshallow repo (see above for details)`);
|
|
111
|
+
}
|
|
112
|
+
return hasCommonCommit(branch, cwd);
|
|
113
|
+
}
|
|
114
|
+
function logError(error, branch, remote, remoteBranch) {
|
|
115
|
+
let mainError;
|
|
116
|
+
let mitigationSteps;
|
|
117
|
+
switch (error) {
|
|
118
|
+
case 'missing-branch':
|
|
119
|
+
// Due to checks in the calling method, "remote" should be non-empty here
|
|
120
|
+
mainError = `Target branch "${branch}" does not exist locally, and fetching is disabled.`;
|
|
121
|
+
mitigationSteps = `- Fetch the branch manually:\n git remote set-branches --add ${remote} ${remoteBranch} && git fetch ${remote}`;
|
|
122
|
+
break;
|
|
123
|
+
case 'shallow-clone':
|
|
124
|
+
mainError =
|
|
125
|
+
'This repo is a shallow clone, fetching is disabled, and not enough history is ' +
|
|
126
|
+
`available to connect HEAD to "${branch}".`;
|
|
127
|
+
mitigationSteps = [
|
|
128
|
+
"- Verify that you're using the correct target branch",
|
|
129
|
+
'- Unshallow or deepen the clone manually',
|
|
130
|
+
].join('\n');
|
|
131
|
+
break;
|
|
132
|
+
}
|
|
133
|
+
console.error(`
|
|
134
|
+
|
|
135
|
+
${mainError}
|
|
136
|
+
|
|
137
|
+
Some possible fixes:
|
|
138
|
+
${mitigationSteps}
|
|
139
|
+
- Omit the "--no-fetch" / "--fetch=false" option from the command line
|
|
140
|
+
- Remove "fetch: false" from the beachball config
|
|
141
|
+
- If this is a CI build, ensure that adequate history is being fetched
|
|
142
|
+
- For GitHub Actions (actions/checkout), add the option "fetch-depth: 0" in the checkout step
|
|
143
|
+
|
|
144
|
+
`);
|
|
145
|
+
}
|
|
146
|
+
function hasBranchRef(branch, cwd) {
|
|
147
|
+
return workspace_tools_1.git(['rev-parse', '--verify', branch], { cwd }).success;
|
|
148
|
+
}
|
|
149
|
+
function isShallowRepository(cwd) {
|
|
150
|
+
return workspace_tools_1.git(['rev-parse', '--is-shallow-repository'], { cwd }).stdout.trim() === 'true';
|
|
151
|
+
}
|
|
152
|
+
/** Returns whether `branch` and HEAD have a common commit anywhere in their history */
|
|
153
|
+
function hasCommonCommit(branch, cwd) {
|
|
154
|
+
return workspace_tools_1.git(['merge-base', branch, 'HEAD'], { cwd }).success;
|
|
155
|
+
}
|
|
156
|
+
//# sourceMappingURL=ensureSharedHistory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ensureSharedHistory.js","sourceRoot":"","sources":["../../src/git/ensureSharedHistory.ts"],"names":[],"mappings":";;;AAAA,qDAAyD;AAEzD,mCAAmC;AAEnC;;;;;;GAMG;AACH,SAAgB,mBAAmB,CACjC,OAAkF;IAElF,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;IAC7D,yFAAyF;IACzF,sFAAsF;IACtF,8DAA8D;IAC9D,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,GAAG,mCAAiB,CAAC,MAAM,CAAC,CAAC;IAE3D,0CAA0C;IAC1C,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE;QAC9B,IAAI,CAAC,KAAK,EAAE;YACV,uFAAuF;YACvF,yFAAyF;YACzF,+EAA+E;YAC/E,QAAQ,CAAC,gBAAgB,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY,CAAC,CAAC;YACzD,MAAM,IAAI,KAAK,CAAC,kBAAkB,MAAM,oDAAoD,CAAC,CAAC;SAC/F;QAED,IAAI,CAAC,MAAM,EAAE;YACX,wFAAwF;YACxF,kBAAkB;YAClB,MAAM,IAAI,KAAK,CACb,kBAAkB,MAAM,wFAAwF;gBAC9G,0GAA0G,CAC7G,CAAC;SACH;QAED,8FAA8F;QAC9F,qGAAqG;QACrG,MAAM,WAAW,GAAG,qBAAG,CAAC,CAAC,QAAQ,EAAE,WAAW,EAAE,UAAU,MAAM,QAAQ,CAAC,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;QAClG,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC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F;AACvF,SAAS,eAAe,CAAC,MAAc,EAAE,GAAW;IAClD,OAAO,qBAAG,CAAC,CAAC,YAAY,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC,OAAO,CAAC;AAC9D,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { GitProcessOutput } from 'workspace-tools';
|
|
2
|
+
declare type GitFetchParams = {
|
|
3
|
+
cwd: string;
|
|
4
|
+
/** Remote to fetch from. If not specified, fetches all remotes. */
|
|
5
|
+
remote?: string;
|
|
6
|
+
/** Branch to fetch. This will be ignored if `remote` is not also specified. */
|
|
7
|
+
branch?: string;
|
|
8
|
+
/** Set depth to this number of commits (mutually exclusive with `deepen` and `unshallow`) */
|
|
9
|
+
depth?: number;
|
|
10
|
+
/** Deepen a shallow clone by this number of commits (mutually exclusive with `depth` and `unshallow`) */
|
|
11
|
+
deepen?: number;
|
|
12
|
+
/** Convert this from a shallow clone to a full clone (mutually exclusive with `depth` and `deepen`) */
|
|
13
|
+
unshallow?: true;
|
|
14
|
+
verbose?: boolean;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Wrapper for `git fetch`. If `verbose` is true, log the command before starting, and display output
|
|
18
|
+
* on stdout (except in tests). In tests with `verbose`, the output will be logged all together to
|
|
19
|
+
* `console.log` when the command finishes (for easier mocking/capturing).
|
|
20
|
+
*/
|
|
21
|
+
export declare function gitFetch(params: GitFetchParams): GitProcessOutput & {
|
|
22
|
+
errorMessage?: string;
|
|
23
|
+
};
|
|
24
|
+
export {};
|
|
25
|
+
//# sourceMappingURL=fetch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../../src/git/fetch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAO,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAGxD,aAAK,cAAc,GAAG;IACpB,GAAG,EAAE,MAAM,CAAC;IACZ,mEAAmE;IACnE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,+EAA+E;IAC/E,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,6FAA6F;IAC7F,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,yGAAyG;IACzG,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,uGAAuG;IACvG,SAAS,CAAC,EAAE,IAAI,CAAC;IACjB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,MAAM,EAAE,cAAc,GAAG,gBAAgB,GAAG;IAAE,YAAY,CAAC,EAAE,MAAM,CAAA;CAAE,CAqD7F"}
|
package/lib/git/fetch.js
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.gitFetch = void 0;
|
|
4
|
+
const workspace_tools_1 = require("workspace-tools");
|
|
5
|
+
const gitAsync_1 = require("./gitAsync");
|
|
6
|
+
/**
|
|
7
|
+
* Wrapper for `git fetch`. If `verbose` is true, log the command before starting, and display output
|
|
8
|
+
* on stdout (except in tests). In tests with `verbose`, the output will be logged all together to
|
|
9
|
+
* `console.log` when the command finishes (for easier mocking/capturing).
|
|
10
|
+
*/
|
|
11
|
+
function gitFetch(params) {
|
|
12
|
+
const { remote, branch, depth, deepen, unshallow, cwd, verbose } = params;
|
|
13
|
+
const { shouldLog } = gitAsync_1.getGitEnv(verbose);
|
|
14
|
+
if ([depth, deepen, unshallow].filter(v => v !== undefined).length > 1) {
|
|
15
|
+
throw new Error('"depth", "deepen", and "unshallow" are mutually exclusive');
|
|
16
|
+
}
|
|
17
|
+
const extraArgs = depth ? [`--depth=${depth}`] : deepen ? [`--deepen=${deepen}`] : unshallow ? ['--unshallow'] : [];
|
|
18
|
+
let description = remote
|
|
19
|
+
? `Fetching ${branch ? `branch "${branch}" from ` : ''}remote "${remote}"`
|
|
20
|
+
: 'Fetching all remotes';
|
|
21
|
+
if (extraArgs.length) {
|
|
22
|
+
description += ` (with ${extraArgs.join(' ')})`;
|
|
23
|
+
}
|
|
24
|
+
shouldLog && console.log(description + '...');
|
|
25
|
+
const result = workspace_tools_1.git([
|
|
26
|
+
'fetch',
|
|
27
|
+
...extraArgs,
|
|
28
|
+
// If the remote is unknown, don't specify the branch (fetching a branch without a remote is invalid)
|
|
29
|
+
...(remote && branch ? [remote, branch] : remote ? [remote] : []),
|
|
30
|
+
], { cwd, stdio: shouldLog === 'live' ? 'inherit' : 'pipe' });
|
|
31
|
+
const log = result.success ? console.log : console.warn;
|
|
32
|
+
// do the jest logging all at once in a way that can be captured by mocks (jest can't mock process.stdout/err)
|
|
33
|
+
if (shouldLog === 'end') {
|
|
34
|
+
result.stdout && console.log(result.stdout);
|
|
35
|
+
result.stderr && log(result.stderr);
|
|
36
|
+
}
|
|
37
|
+
let message = `${description} ${result.success ? 'completed successfully' : `failed (code ${result.status})`}`;
|
|
38
|
+
if (shouldLog) {
|
|
39
|
+
log(message);
|
|
40
|
+
message += ' - see above for details';
|
|
41
|
+
}
|
|
42
|
+
else if (result.stdout && result.stderr) {
|
|
43
|
+
message += `\nstdout:\n${result.stdout}\nstderr:\n${result.stderr}`;
|
|
44
|
+
}
|
|
45
|
+
else if (result.stdout || result.stderr) {
|
|
46
|
+
message += ` - output:\n${result.stdout || result.stderr}`;
|
|
47
|
+
}
|
|
48
|
+
if (!result.success) {
|
|
49
|
+
result.errorMessage = message;
|
|
50
|
+
}
|
|
51
|
+
return result;
|
|
52
|
+
}
|
|
53
|
+
exports.gitFetch = gitFetch;
|
|
54
|
+
//# sourceMappingURL=fetch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fetch.js","sourceRoot":"","sources":["../../src/git/fetch.ts"],"names":[],"mappings":";;;AAAA,qDAAwD;AACxD,yCAAuC;AAiBvC;;;;GAIG;AACH,SAAgB,QAAQ,CAAC,MAAs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ot":"","sources":["../../src/git/generateTag.ts"],"names":[],"mappings":"AAAA,wEAAwE;AACxE,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,UAExD"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.generateTag = void 0;
|
|
4
|
+
/** Get a standardized package version git tag: `${name}_v${version}` */
|
|
4
5
|
function generateTag(name, version) {
|
|
5
6
|
return `${name}_v${version}`;
|
|
6
7
|
}
|
|
7
8
|
exports.generateTag = generateTag;
|
|
8
|
-
//# sourceMappingURL=
|
|
9
|
+
//# sourceMappingURL=generateTag.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generateTag.js","sourceRoot":"","sources":["../../src/git/generateTag.ts"],"names":[],"mappings":";;;AAAA,wEAAwE;AACxE,SAAgB,WAAW,CAAC,IAAY,EAAE,OAAe;IACvD,OAAO,GAAG,IAAI,KAAK,OAAO,EAAE,CAAC;AAC/B,CAAC;AAFD,kCAEC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import execa from 'execa';
|
|
2
|
+
export declare type GitAsyncOptions = Omit<execa.Options, 'cwd' | 'all' | 'stdio' | 'stdout' | 'stderr' | 'stdin' | 'reject'> & {
|
|
3
|
+
cwd: string;
|
|
4
|
+
verbose?: boolean;
|
|
5
|
+
};
|
|
6
|
+
export declare type GitAsyncResult = ((Omit<execa.ExecaReturnValue<string>, 'failed'> & {
|
|
7
|
+
success: true;
|
|
8
|
+
}) | (Omit<execa.ExecaError<string>, 'failed'> & {
|
|
9
|
+
success: false;
|
|
10
|
+
})) & {
|
|
11
|
+
errorMessage?: string;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Run a git command asynchronously. If `verbose` is true, log the command before starting, and display
|
|
15
|
+
* output on stdout (except in tests) *and* return it in the result. For tests with `verbose`, the output
|
|
16
|
+
* will be logged all together to `console.log` when the command finishes (for easier mocking/capturing).
|
|
17
|
+
*
|
|
18
|
+
* (This utility should potentially be moved to `workspace-tools`, but it uses `execa` to capture
|
|
19
|
+
* interleaved stdout/stderr, and `execa` is a large-ish dep not currently used there.)
|
|
20
|
+
*/
|
|
21
|
+
export declare function gitAsync(args: string[], options: GitAsyncOptions): Promise<GitAsyncResult>;
|
|
22
|
+
export declare function getGitEnv(verbose: boolean | undefined): {
|
|
23
|
+
/**
|
|
24
|
+
* If/when to log git commands and output:
|
|
25
|
+
* - false: never (but return output in result)
|
|
26
|
+
* - 'live': log command, and pipe output to stdout/stderr (if `verbose` or `process.env.GIT_DEBUG`, except in tests)
|
|
27
|
+
* - 'end': log command, and log output at the end (for tests, if `verbose` or `process.env.GIT_DEBUG`)
|
|
28
|
+
*/
|
|
29
|
+
shouldLog: false | 'live' | 'end';
|
|
30
|
+
/** Max buffer for git operations, copied from workspace-tools implementation */
|
|
31
|
+
maxBuffer: number;
|
|
32
|
+
};
|
|
33
|
+
//# sourceMappingURL=gitAsync.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gitAsync.d.ts","sourceRoot":"","sources":["../../src/git/gitAsync.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAK1B,oBAAY,eAAe,GAAG,IAAI,CAChC,KAAK,CAAC,OAAO,EACb,KAAK,GAAG,KAAK,GAAG,OAAO,GAAG,QAAQ,GAAG,QAAQ,GAAG,OAAO,GAAG,QAAQ,CACnE,GAAG;IACF,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC;AAEF,oBAAY,cAAc,GAAG,CACzB,CAAC,IAAI,CAAC,KAAK,CAAC,gBAAgB,CAAC,MAAM,CAAC,EAAE,QAAQ,CAAC,GAAG;IAAE,OAAO,EAAE,IAAI,CAAA;CAAE,CAAC,GACpE,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,QAAQ,CAAC,GAAG;IAAE,OAAO,EAAE,KAAK,CAAA;CAAE,CAAC,CAClE,GAAG;IAAE,YAAY,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAE9B;;;;;;;GAOG;AACH,wBAAsB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,cAAc,CAAC,CA2ChG;AAED,wBAAgB,SAAS,CAAC,OAAO,EAAE,OAAO,GAAG,SAAS,GAAG;IACvD;;;;;OAKG;IACH,SAAS,EAAE,KAAK,GAAG,MAAM,GAAG,KAAK,CAAC;IAClC,gFAAgF;IAChF,SAAS,EAAE,MAAM,CAAC;CACnB,CASA"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getGitEnv = exports.gitAsync = void 0;
|
|
7
|
+
const execa_1 = __importDefault(require("execa"));
|
|
8
|
+
/**
|
|
9
|
+
* Run a git command asynchronously. If `verbose` is true, log the command before starting, and display
|
|
10
|
+
* output on stdout (except in tests) *and* return it in the result. For tests with `verbose`, the output
|
|
11
|
+
* will be logged all together to `console.log` when the command finishes (for easier mocking/capturing).
|
|
12
|
+
*
|
|
13
|
+
* (This utility should potentially be moved to `workspace-tools`, but it uses `execa` to capture
|
|
14
|
+
* interleaved stdout/stderr, and `execa` is a large-ish dep not currently used there.)
|
|
15
|
+
*/
|
|
16
|
+
async function gitAsync(args, options) {
|
|
17
|
+
const { verbose, ...execaOpts } = options;
|
|
18
|
+
const { shouldLog, maxBuffer } = getGitEnv(verbose);
|
|
19
|
+
const gitCmd = `git ${args.join(' ')}`;
|
|
20
|
+
shouldLog && console.log(`Running: ${gitCmd}`);
|
|
21
|
+
const child = execa_1.default('git', args, {
|
|
22
|
+
maxBuffer,
|
|
23
|
+
...execaOpts,
|
|
24
|
+
stdio: 'pipe',
|
|
25
|
+
all: true,
|
|
26
|
+
reject: false,
|
|
27
|
+
});
|
|
28
|
+
if (shouldLog === 'live') {
|
|
29
|
+
child.stdout.pipe(process.stdout);
|
|
30
|
+
child.stderr.pipe(process.stderr);
|
|
31
|
+
}
|
|
32
|
+
const execaResult = await child;
|
|
33
|
+
const result = { ...execaResult, success: !execaResult.failed };
|
|
34
|
+
const log = result.success ? console.log : console.warn;
|
|
35
|
+
if (shouldLog === 'end') {
|
|
36
|
+
// do the jest logging all at once in a way that can be captured by mocks
|
|
37
|
+
log(result.all);
|
|
38
|
+
}
|
|
39
|
+
let message = `${gitCmd} ${result.success ? 'completed successfully' : `failed (code ${result.exitCode})`}`;
|
|
40
|
+
if (shouldLog) {
|
|
41
|
+
log(message);
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
message += ` - output:\n${result.all}`;
|
|
45
|
+
}
|
|
46
|
+
if (!result.success) {
|
|
47
|
+
result.errorMessage = message;
|
|
48
|
+
}
|
|
49
|
+
return result;
|
|
50
|
+
}
|
|
51
|
+
exports.gitAsync = gitAsync;
|
|
52
|
+
function getGitEnv(verbose) {
|
|
53
|
+
verbose = verbose || !!process.env.GIT_DEBUG;
|
|
54
|
+
const isJest = !!process.env.JEST_WORKER_ID;
|
|
55
|
+
const maxBuffer = process.env.GIT_MAX_BUFFER && parseInt(process.env.GIT_MAX_BUFFER, 10);
|
|
56
|
+
return {
|
|
57
|
+
shouldLog: verbose ? (isJest ? 'end' : 'live') : false,
|
|
58
|
+
// isVerbose: verbose || !!process.env.GIT_DEBUG,
|
|
59
|
+
maxBuffer: maxBuffer || 500 * 1024 * 1024,
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
exports.getGitEnv = getGitEnv;
|
|
63
|
+
//# sourceMappingURL=gitAsync.js.map
|
|
@@ -0,0 +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YAAY,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,mBAAmB,EAAE,GAAG,SAAS,
|
|
1
|
+
{"version":3,"file":"getPackageGroups.d.ts","sourceRoot":"","sources":["../../src/monorepo/getPackageGroups.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAEhE,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAGnE,wBAAgB,gBAAgB,CAAC,YAAY,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,mBAAmB,EAAE,GAAG,SAAS,iBAyCnH"}
|
|
@@ -7,32 +7,37 @@ exports.getPackageGroups = void 0;
|
|
|
7
7
|
const path_1 = __importDefault(require("path"));
|
|
8
8
|
const isPathIncluded_1 = require("./isPathIncluded");
|
|
9
9
|
function getPackageGroups(packageInfos, root, groups) {
|
|
10
|
+
var _a;
|
|
11
|
+
if (!groups?.length) {
|
|
12
|
+
return {};
|
|
13
|
+
}
|
|
10
14
|
const packageGroups = {};
|
|
11
15
|
const packageNameToGroup = {};
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
packageGroups[groupName].packageNames.push(pkgName);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
16
|
+
let hasError = false;
|
|
17
|
+
// Check every package to see which group it belongs to
|
|
18
|
+
for (const [pkgName, info] of Object.entries(packageInfos)) {
|
|
19
|
+
const packagePath = path_1.default.dirname(info.packageJsonPath);
|
|
20
|
+
const relativePath = path_1.default.relative(root, packagePath);
|
|
21
|
+
const groupsForPkg = groups.filter(group => isPathIncluded_1.isPathIncluded(relativePath, group.include, group.exclude));
|
|
22
|
+
if (groupsForPkg.length > 1) {
|
|
23
|
+
// Keep going after this error to ensure we report all errors
|
|
24
|
+
console.error(`ERROR: "${pkgName}" cannot belong to multiple groups: [${groupsForPkg.map(g => g.name).join(', ')}]`);
|
|
25
|
+
hasError = true;
|
|
26
|
+
}
|
|
27
|
+
else if (groupsForPkg.length === 1) {
|
|
28
|
+
const group = groupsForPkg[0];
|
|
29
|
+
packageNameToGroup[pkgName] = group.name;
|
|
30
|
+
packageGroups[_a = group.name] ?? (packageGroups[_a] = {
|
|
31
|
+
packageNames: [],
|
|
32
|
+
disallowedChangeTypes: group.disallowedChangeTypes,
|
|
33
|
+
});
|
|
34
|
+
packageGroups[group.name].packageNames.push(pkgName);
|
|
34
35
|
}
|
|
35
36
|
}
|
|
37
|
+
if (hasError) {
|
|
38
|
+
// TODO: probably more appropriate to throw here and let the caller handle it?
|
|
39
|
+
process.exit(1);
|
|
40
|
+
}
|
|
36
41
|
return packageGroups;
|
|
37
42
|
}
|
|
38
43
|
exports.getPackageGroups = getPackageGroups;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getPackageGroups.js","sourceRoot":"","sources":["../../src/monorepo/getPackageGroups.ts"],"names":[],"mappings":";;;;;;AACA,gDAAwB;AAExB,qDAAkD;AAElD,SAAgB,gBAAgB,CAAC,YAA0B,EAAE,IAAY,EAAE,MAAyC
|
|
1
|
+
{"version":3,"file":"getPackageGroups.js","sourceRoot":"","sources":["../../src/monorepo/getPackageGroups.ts"],"names":[],"mappings":";;;;;;AACA,gDAAwB;AAExB,qDAAkD;AAElD,SAAgB,gBAAgB,CAAC,YAA0B,EAAE,IAAY,EAAE,MAAyC;;IAClH,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE;QACnB,OAAO,EAAE,CAAC;KACX;IAED,MAAM,aAAa,GAAkB,EAAE,CAAC;IAExC,MAAM,kBAAkB,GAAsC,EAAE,CAAC;IAEjE,IAAI,Q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aAAa,CAAC;AACvB,CAAC;AAzCD,4CAyCC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getPackageInfos.d.ts","sourceRoot":"","sources":["../../src/monorepo/getPackageInfos.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"getPackageInfos.d.ts","sourceRoot":"","sources":["../../src/monorepo/getPackageInfos.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAGpD;;;GAGG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,YAAY,CAUzD"}
|
|
@@ -22,54 +22,61 @@ function getPackageInfos(cwd) {
|
|
|
22
22
|
}
|
|
23
23
|
exports.getPackageInfos = getPackageInfos;
|
|
24
24
|
function getPackageInfosFromWorkspace(projectRoot) {
|
|
25
|
+
let workspacePackages;
|
|
25
26
|
try {
|
|
26
|
-
const packageInfos = {};
|
|
27
27
|
// first try using the workspace provided packages (if available)
|
|
28
|
-
|
|
29
|
-
if (workspaceInfo && workspaceInfo.length > 0) {
|
|
30
|
-
workspaceInfo.forEach(info => {
|
|
31
|
-
const { path: packagePath, packageJson } = info;
|
|
32
|
-
const packageJsonPath = path_1.default.join(packagePath, 'package.json');
|
|
33
|
-
try {
|
|
34
|
-
packageInfos[packageJson.name] = infoFromPackageJson_1.infoFromPackageJson(packageJson, packageJsonPath);
|
|
35
|
-
}
|
|
36
|
-
catch (e) {
|
|
37
|
-
// Pass, the package.json is invalid
|
|
38
|
-
console.warn(`Invalid package.json file detected ${packageJsonPath}: `, e);
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
return packageInfos;
|
|
42
|
-
}
|
|
28
|
+
workspacePackages = workspace_tools_1.getWorkspaces(projectRoot);
|
|
43
29
|
}
|
|
44
30
|
catch (e) {
|
|
45
31
|
// not a recognized workspace from workspace-tools
|
|
46
32
|
}
|
|
33
|
+
if (!workspacePackages?.length) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
const packageInfos = {};
|
|
37
|
+
for (const { path: packagePath, packageJson } of workspacePackages) {
|
|
38
|
+
const packageJsonPath = path_1.default.join(packagePath, 'package.json');
|
|
39
|
+
try {
|
|
40
|
+
packageInfos[packageJson.name] = infoFromPackageJson_1.infoFromPackageJson(packageJson, packageJsonPath);
|
|
41
|
+
}
|
|
42
|
+
catch (e) {
|
|
43
|
+
// Pass, the package.json is invalid
|
|
44
|
+
console.warn(`Problem processing ${packageJsonPath}: ${e}`);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return packageInfos;
|
|
47
48
|
}
|
|
48
49
|
function getPackageInfosFromNonWorkspaceMonorepo(projectRoot) {
|
|
49
50
|
const packageJsonFiles = workspace_tools_1.listAllTrackedFiles(['**/package.json', 'package.json'], projectRoot);
|
|
51
|
+
if (!packageJsonFiles.length) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
50
54
|
const packageInfos = {};
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
if (packageInfos[packageJson.name]) {
|
|
58
|
-
hasDuplicatePackage = true;
|
|
59
|
-
throw new Error(`Two packages in different workspaces have the same name. Please rename one of these packages:\n- ${packageInfos[packageJson.name].packageJsonPath}\n- ${packageJsonPath}`);
|
|
60
|
-
}
|
|
55
|
+
let hasError = false;
|
|
56
|
+
for (const packageJsonPath of packageJsonFiles) {
|
|
57
|
+
try {
|
|
58
|
+
const packageJsonFullPath = path_1.default.join(projectRoot, packageJsonPath);
|
|
59
|
+
const packageJson = fs_extra_1.default.readJSONSync(packageJsonFullPath);
|
|
60
|
+
if (!packageInfos[packageJson.name]) {
|
|
61
61
|
packageInfos[packageJson.name] = infoFromPackageJson_1.infoFromPackageJson(packageJson, packageJsonFullPath);
|
|
62
62
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
//
|
|
68
|
-
|
|
63
|
+
else {
|
|
64
|
+
console.error(`ERROR: Two packages have the same name "${packageJson.name}". Please rename one of these packages:\n` +
|
|
65
|
+
`- ${path_1.default.relative(projectRoot, packageInfos[packageJson.name].packageJsonPath)}\n` +
|
|
66
|
+
`- ${packageJsonPath}`);
|
|
67
|
+
// Keep going so we can log all the errors
|
|
68
|
+
hasError = true;
|
|
69
69
|
}
|
|
70
|
-
}
|
|
71
|
-
|
|
70
|
+
}
|
|
71
|
+
catch (e) {
|
|
72
|
+
// Pass, the package.json is invalid
|
|
73
|
+
console.warn(`Problem processing ${packageJsonPath}: ${e}`);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
if (hasError) {
|
|
77
|
+
throw new Error('Duplicate package names found (see above for details)');
|
|
72
78
|
}
|
|
79
|
+
return packageInfos;
|
|
73
80
|
}
|
|
74
81
|
function getPackageInfosFromSingleRepo(packageRoot) {
|
|
75
82
|
const packageInfos = {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getPackageInfos.js","sourceRoot":"","sources":["../../src/monorepo/getPackageInfos.ts"],"names":[],"mappings":";;;;;;AAAA,wDAA0B;AAC1B,gDAAwB;AACxB,
|
|
1
|
+
{"version":3,"file":"getPackageInfos.js","sourceRoot":"","sources":["../../src/monorepo/getPackageInfos.ts"],"names":[],"mappings":";;;;;;AAAA,wDAA0B;AAC1B,gDAAwB;AACxB,qDAMyB;AAEzB,+DAA4D;AAE5D;;;GAGG;AACH,SAAgB,eAAe,CAAC,GAAW;IACzC,MAAM,WAAW,GAAG,iCAAe,CAAC,GAAG,CAAC,CAAC;IACzC,MAAM,WAAW,GAAG,iCAAe,CAAC,GAAG,CAAC,CAAC;IAEzC,OAAO,CACL,CAAC,WAAW,IAAI,4BAA4B,CAAC,WAAW,CAAC,CAAC;QAC1D,CAAC,WAAW,IAAI,uCAAuC,CAAC,WAAW,CAAC,CAAC;QACrE,CAAC,WAAW,IAAI,6BAA6B,CAAC,WAAW,CAAC,CAAC;QAC3D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MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"bumpAndPush.d.ts","sourceRoot":"","sources":["../../src/publish/bumpAndPush.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAW7D,wBAAsB,WAAW,CAAC,QAAQ,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,EAAE,OAAO,EAAE,gBAAgB,iBAqErG"}
|