beachball 2.65.3 → 2.65.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/lib/commands/publish.d.ts.map +1 -1
- package/lib/commands/publish.js +5 -0
- package/lib/commands/publish.js.map +1 -1
- package/lib/git/ensureSharedHistory.js +15 -2
- package/lib/git/ensureSharedHistory.js.map +1 -1
- package/lib/git/fetch.d.ts +6 -3
- package/lib/git/fetch.d.ts.map +1 -1
- package/lib/git/fetch.js +8 -6
- package/lib/git/fetch.js.map +1 -1
- package/lib/packageManager/npmAuthEnvPassthrough.d.ts +32 -0
- package/lib/packageManager/npmAuthEnvPassthrough.d.ts.map +1 -0
- package/lib/packageManager/npmAuthEnvPassthrough.js +90 -0
- package/lib/packageManager/npmAuthEnvPassthrough.js.map +1 -0
- package/lib/packageManager/packageManager.d.ts.map +1 -1
- package/lib/packageManager/packageManager.js +2 -19
- package/lib/packageManager/packageManager.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"publish.d.ts","sourceRoot":"","sources":["../../src/commands/publish.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAElE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"publish.d.ts","sourceRoot":"","sources":["../../src/commands/publish.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAElE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAG9D;;;GAGG;AACH,wBAAsB,OAAO,CAAC,OAAO,EAAE,gBAAgB,EAAE,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AACjG,sCAAsC;AACtC,wBAAsB,OAAO,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC"}
|
package/lib/commands/publish.js
CHANGED
|
@@ -11,6 +11,7 @@ const createCommandContext_1 = require("../monorepo/createCommandContext");
|
|
|
11
11
|
const bumpAndPush_1 = require("../publish/bumpAndPush");
|
|
12
12
|
const getNewPackages_1 = require("../publish/getNewPackages");
|
|
13
13
|
const publishToRegistry_1 = require("../publish/publishToRegistry");
|
|
14
|
+
const npmAuthEnvPassthrough_1 = require("../packageManager/npmAuthEnvPassthrough");
|
|
14
15
|
async function publish(options, context) {
|
|
15
16
|
console.log('Preparing to publish\n');
|
|
16
17
|
const { path: cwd, branch, registry, tag, packToPath } = options;
|
|
@@ -52,6 +53,10 @@ async function publish(options, context) {
|
|
|
52
53
|
}
|
|
53
54
|
console.log();
|
|
54
55
|
}
|
|
56
|
+
if (options.token) {
|
|
57
|
+
// Verify that passing the npm auth token via env vars works (see function comment...)
|
|
58
|
+
await (0, npmAuthEnvPassthrough_1.checkNpmAuthEnvPassthrough)(options);
|
|
59
|
+
}
|
|
55
60
|
// checkout publish branch
|
|
56
61
|
const publishBranch = `publish_${Date.now()}`;
|
|
57
62
|
console.log(`Creating temporary publish branch ${publishBranch}\n`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"publish.js","sourceRoot":"","sources":["../../src/commands/publish.ts"],"names":[],"mappings":";;;;;;AAAA,sDAA8B;AAC9B,qDAAkF;AAClF,uDAAoD;AACpD,2EAAwE;AACxE,wDAAqD;AACrD,8DAA2D;AAC3D,oEAAiE;
|
|
1
|
+
{"version":3,"file":"publish.js","sourceRoot":"","sources":["../../src/commands/publish.ts"],"names":[],"mappings":";;;;;;AAAA,sDAA8B;AAC9B,qDAAkF;AAClF,uDAAoD;AACpD,2EAAwE;AACxE,wDAAqD;AACrD,8DAA2D;AAC3D,oEAAiE;AAIjE,mFAAqF;AAS9E,KAAK,UAAU,OAAO,CAAC,OAAyB,EAAE,OAAwB;IAC/E,OAAO,CAAC,GAAG,CAAC,wBAAwB,CAAC,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AC,CAAC,UAAU,EAAE,WAAW,CAAC,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC;KACjD;IAED,IAAI,aAAa,IAAI,WAAW,EAAE;QAChC,OAAO,CAAC,GAAG,CAAC,qCAAqC,aAAa,EAAE,CAAC,CAAC;QAClE,MAAM,cAAc,GAAG,IAAA,qBAAG,EAAC,CAAC,QAAQ,EAAE,IAAI,EAAE,aAAa,CAAC,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC;QACrE,IAAI,CAAC,cAAc,CAAC,OAAO,EAAE;YAC3B,OAAO,CAAC,IAAI,CAAC,sCAAsC,aAAa,iBAAiB,cAAc,CAAC,MAAM,EAAE,CAAC,CAAC;SAC3G;KACF;AACH,CAAC;AAjID,0BAiIC"}
|
|
@@ -91,11 +91,18 @@ function deepenHistory(params) {
|
|
|
91
91
|
const { remote, remoteBranch, branch, cwd, verbose } = params;
|
|
92
92
|
const depth = params.depth || 100;
|
|
93
93
|
console.log(`This is a shallow clone. Deepening to check for changes...`);
|
|
94
|
+
// git fetch --deepen only deepens the histories of the refs explicitly listed in the
|
|
95
|
+
// refspec args, not other local refs. To find the common ancestor, both the target branch
|
|
96
|
+
// and HEAD (when on a different branch) need enough history to reach it. We pass both
|
|
97
|
+
// refspecs to a single git invocation so one --deepen / --unshallow covers both refs in one
|
|
98
|
+
// network round-trip.
|
|
99
|
+
const headBranch = getHeadBranch(cwd);
|
|
100
|
+
const branchesToFetch = headBranch && headBranch !== remoteBranch ? [remoteBranch, headBranch] : [remoteBranch];
|
|
94
101
|
// Iteratively deepen the history
|
|
95
102
|
const maxAttempts = 3;
|
|
96
103
|
for (let attempt = 1; attempt <= maxAttempts; attempt++) {
|
|
97
104
|
console.log(`Deepening by ${depth} more commits (attempt ${attempt}/${maxAttempts})...`);
|
|
98
|
-
const result = (0, fetch_1.gitFetch)({ remote, branch:
|
|
105
|
+
const result = (0, fetch_1.gitFetch)({ remote, branch: branchesToFetch, deepen: depth, cwd, verbose });
|
|
99
106
|
if (!result.success) {
|
|
100
107
|
throw new BeachballError_1.BeachballError(`Failed to fetch more history (see above for details)`);
|
|
101
108
|
}
|
|
@@ -110,7 +117,7 @@ function deepenHistory(params) {
|
|
|
110
117
|
}
|
|
111
118
|
// No common commit was found and the repo is still shallow, so fully unshallow it
|
|
112
119
|
console.log(`Still didn't find a common commit after deepening by ${depth * maxAttempts}. Unshallowing...`);
|
|
113
|
-
const result = (0, fetch_1.gitFetch)({ remote, branch:
|
|
120
|
+
const result = (0, fetch_1.gitFetch)({ remote, branch: branchesToFetch, unshallow: true, cwd, verbose });
|
|
114
121
|
if (!result.success) {
|
|
115
122
|
throw new BeachballError_1.BeachballError(`Failed to unshallow repo (see above for details)`);
|
|
116
123
|
}
|
|
@@ -150,6 +157,12 @@ ${(0, bulletedList_1.bulletedList)(mitigationSteps)}
|
|
|
150
157
|
function hasBranchRef(branch, cwd) {
|
|
151
158
|
return (0, workspace_tools_1.git)(['rev-parse', '--verify', branch], { cwd }).success;
|
|
152
159
|
}
|
|
160
|
+
/** Returns the current branch name, or undefined if in detached HEAD state */
|
|
161
|
+
function getHeadBranch(cwd) {
|
|
162
|
+
const result = (0, workspace_tools_1.git)(['rev-parse', '--abbrev-ref', 'HEAD'], { cwd });
|
|
163
|
+
const branch = result.stdout.trim();
|
|
164
|
+
return result.success && branch !== 'HEAD' ? branch : undefined;
|
|
165
|
+
}
|
|
153
166
|
function isShallowRepository(cwd) {
|
|
154
167
|
return (0, workspace_tools_1.git)(['rev-parse', '--is-shallow-repository'], { cwd }).stdout.trim() === 'true';
|
|
155
168
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ensureSharedHistory.js","sourceRoot":"","sources":["../../src/git/ensureSharedHistory.ts"],"names":[],"mappings":";;;AAAA,qDAAyD;AAEzD,mCAAmC;AACnC,0DAAwE;AACxE,4DAAyD;AAEzD;;;;;;;;;;;;GAYG;AACH,SAAgB,mBAAmB,CACjC,OAAkF;IAElF,MAAM,EAAE,K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SAAS,CAAC;AAClE,CAAC;AAED,SAAS,mBAAmB,CAAC,GAAW;IACtC,OAAO,IAAA,qBAAG,EAAC,CAAC,WAAW,EAAE,yBAAyB,CAAC,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,MAAM,CAAC;AACzF,CAAC;AAED,uFAAuF;AACvF,SAAS,eAAe,CAAC,MAAc,EAAE,GAAW;IAClD,OAAO,IAAA,qBAAG,EAAC,CAAC,YAAY,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC,OAAO,CAAC;AAC9D,CAAC"}
|
package/lib/git/fetch.d.ts
CHANGED
|
@@ -7,10 +7,13 @@ type GitFetchParams = {
|
|
|
7
7
|
*/
|
|
8
8
|
remote: string;
|
|
9
9
|
/**
|
|
10
|
-
* Branch to fetch.
|
|
11
|
-
* e.g. `branch: 'main', remote: 'origin'` will be converted to `+main:refs/remotes/origin/main`.
|
|
10
|
+
* Branch(es) to fetch. Each will be converted to a full refspec for fetching:
|
|
11
|
+
* e.g. `branch: 'main', remote: 'origin'` will be converted to `+refs/heads/main:refs/remotes/origin/main`.
|
|
12
|
+
* Pass an array to fetch multiple branches in a single git invocation, which lets a single
|
|
13
|
+
* `--deepen` or `--unshallow` apply to all of them (saves network round-trips when both HEAD
|
|
14
|
+
* and the target branch need deepening).
|
|
12
15
|
*/
|
|
13
|
-
branch: string;
|
|
16
|
+
branch: string | string[];
|
|
14
17
|
/** Set depth to this number of commits (mutually exclusive with `deepen` and `unshallow`) */
|
|
15
18
|
depth?: number;
|
|
16
19
|
/** Deepen a shallow clone by this number of commits (mutually exclusive with `depth` and `unshallow`) */
|
package/lib/git/fetch.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../../src/git/fetch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAO,KAAK,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAG7D,KAAK,cAAc,GAAG;IACpB,GAAG,EAAE,MAAM,CAAC;IACZ;;;OAGG;IACH,MAAM,EAAE,MAAM,CAAC;IACf
|
|
1
|
+
{"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../../src/git/fetch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAO,KAAK,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAG7D,KAAK,cAAc,GAAG;IACpB,GAAG,EAAE,MAAM,CAAC;IACZ;;;OAGG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;;;;;OAMG;IACH,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAC1B,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;;;;;;;GAOG;AACH,wBAAgB,QAAQ,CAAC,MAAM,EAAE,cAAc,GAAG,gBAAgB,GAAG;IAAE,YAAY,CAAC,EAAE,MAAM,CAAA;CAAE,CAiE7F"}
|
package/lib/git/fetch.js
CHANGED
|
@@ -12,13 +12,14 @@ const gitAsync_1 = require("./gitAsync");
|
|
|
12
12
|
* the remote branch is tracked or not in the local repository.
|
|
13
13
|
*/
|
|
14
14
|
function gitFetch(params) {
|
|
15
|
-
const { remote,
|
|
15
|
+
const { remote, depth, deepen, unshallow, cwd, verbose } = params;
|
|
16
|
+
const branches = Array.isArray(params.branch) ? params.branch : [params.branch];
|
|
16
17
|
const { shouldLog } = (0, gitAsync_1.getGitEnv)(verbose);
|
|
17
18
|
if ([depth, deepen, unshallow].filter(v => v !== undefined).length > 1) {
|
|
18
19
|
throw new Error('"depth", "deepen", and "unshallow" are mutually exclusive');
|
|
19
20
|
}
|
|
20
21
|
const extraArgs = depth ? [`--depth=${depth}`] : deepen ? [`--deepen=${deepen}`] : unshallow ? ['--unshallow'] : [];
|
|
21
|
-
// Be specific with
|
|
22
|
+
// Be specific with each ref being fetched, so we don't have to worry about tracking configs.
|
|
22
23
|
// In git fetch <remote> +<src>:<dst>...
|
|
23
24
|
// - The + means allow non-fast-forward updates (in case the remote was force pushed).
|
|
24
25
|
// - <src> refs/heads/${branch} is resolved against the remote's advertised refs. The fully
|
|
@@ -26,17 +27,18 @@ function gitFetch(params) {
|
|
|
26
27
|
// causing git to treat the ref as absent and delete the local tracking ref.
|
|
27
28
|
// - <dst> refs/remotes/${remote}/${branch} is resolved locally and only moves the tracking ref
|
|
28
29
|
// for the remote branch, not the local refs/heads/${branch} or its tracking config.
|
|
29
|
-
const
|
|
30
|
-
const
|
|
30
|
+
const resolvedRefspecs = remote ? branches.map(b => `+refs/heads/${b}:refs/remotes/${remote}/${b}`) : [];
|
|
31
|
+
const branchLabel = branches.length > 1 ? `branches ${branches.map(b => `"${b}"`).join(', ')}` : `branch "${branches[0]}"`;
|
|
32
|
+
const shortDescription = `Fetching ${resolvedRefspecs.length ? `${branchLabel} from remote "${remote}"` : 'all remotes'}`;
|
|
31
33
|
let description = shortDescription;
|
|
32
|
-
|
|
34
|
+
resolvedRefspecs.length && (description += ` (${resolvedRefspecs.join(' ')})`);
|
|
33
35
|
extraArgs.length && (description += ` (with ${extraArgs.join(' ')})`);
|
|
34
36
|
shouldLog && console.log(description + '...');
|
|
35
37
|
const result = (0, workspace_tools_1.git)([
|
|
36
38
|
'fetch',
|
|
37
39
|
...extraArgs,
|
|
38
40
|
// If the remote is unknown, don't specify the branch (fetching a branch without a remote is invalid)
|
|
39
|
-
...(
|
|
41
|
+
...(resolvedRefspecs.length ? [remote, ...resolvedRefspecs] : []),
|
|
40
42
|
], { cwd, stdio: shouldLog === 'live' ? 'inherit' : 'pipe' });
|
|
41
43
|
const log = result.success ? console.log : console.warn;
|
|
42
44
|
// do the jest logging all at once in a way that can be captured by mocks (jest can't mock process.stdout/err)
|
package/lib/git/fetch.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetch.js","sourceRoot":"","sources":["../../src/git/fetch.ts"],"names":[],"mappings":";;;AAAA,qDAA6D;AAC7D,yCAAuC;
|
|
1
|
+
{"version":3,"file":"fetch.js","sourceRoot":"","sources":["../../src/git/fetch.ts"],"names":[],"mappings":";;;AAAA,qDAA6D;AAC7D,yCAAuC;AA0BvC;;;;;;;GAOG;AACH,SAAgB,QAAQ,CAAC,MAAsB;IAC7C,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,MAAM,CAAC;IAClE,MAAM,QAAQ,GAAG,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAChF,MAAM,EAAE,SAAS,EAAE,GAAG,IAAA,oBAAS,EAAC,OAAO,CAAC,CAAC;IAEzC,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,SAAS,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE;QACtE,MAAM,IAAI,KAAK,CAAC,2DAA2D,CAAC,CAAC;KAC9E;IAED,MAAM,SAAS,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,WAAW,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,YAAY,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IAEpH,6FAA6F;IAC7F,wCAAwC;IACxC,sFAAsF;IACtF,2FAA2F;IAC3F,yFAAyF;IACzF,8EAA8E;IAC9E,+FAA+F;IAC/F,sF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AAE,CAC1D,CAAC;IAEF,MAAM,GAAG,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC;IAExD,8GAA8G;IAC9G,IAAI,SAAS,KAAK,KAAK,EAAE;QACvB,MAAM,CAAC,MAAM,IAAI,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QAC5C,MAAM,CAAC,MAAM,IAAI,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;KACrC;IAED,IAAI,OAAO,GAAG,GAAG,gBAAgB,IAAI,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,wBAAwB,CAAC,CAAC,CAAC,gBAAgB,MAAM,CAAC,MAAM,GAAG,EAAE,CAAC;IACpH,IAAI,SAAS,EAAE;QACb,GAAG,CAAC,OAAO,CAAC,CAAC;QACb,OAAO,IAAI,0BAA0B,CAAC;KACvC;SAAM,IAAI,MAAM,CAAC,MAAM,IAAI,MAAM,CAAC,MAAM,EAAE;QACzC,OAAO,IAAI,cAAc,MAAM,CAAC,MAAM,cAAc,MAAM,CAAC,MAAM,EAAE,CAAC;KACrE;SAAM,IAAI,MAAM,CAAC,MAAM,IAAI,MAAM,CAAC,MAAM,EAAE;QACzC,OAAO,IAAI,eAAe,MAAM,CAAC,MAAM,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;KAC5D;IAED,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE;QACnB,MAAM,CAAC,YAAY,GAAG,OAAO,CAAC;KAC/B;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAjED,4BAiEC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { BeachballOptions } from '../types/BeachballOptions';
|
|
2
|
+
/**
|
|
3
|
+
* Filter PATH for running npm commands, removing entries that contain shell-script node wrappers.
|
|
4
|
+
*
|
|
5
|
+
* Package managers inject temp directories into PATH with shims for `node` — yarn classic uses
|
|
6
|
+
* `yarn--*` dirs, yarn berry uses `xfs-*` dirs. (Context: https://github.com/yarnpkg/yarn/issues/6685 -
|
|
7
|
+
* yarn berry does similar but cleans up afterwards.)
|
|
8
|
+
*
|
|
9
|
+
* These shims are POSIX shell scripts, e.g. this `node` shim:
|
|
10
|
+
* ```sh
|
|
11
|
+
* #!/bin/sh
|
|
12
|
+
* exec "/path/to/node" "$@"
|
|
13
|
+
* ```
|
|
14
|
+
*
|
|
15
|
+
* Problem is POSIX `sh` drops env var names with invalid characters like `/` and `:`, which are
|
|
16
|
+
* needed for npm auth token env vars (e.g. `npm_config_//someRegistry/:_authToken`).
|
|
17
|
+
*
|
|
18
|
+
* Removing those path entries fixes the issue and is unlikely to cause other problems in this context.
|
|
19
|
+
* Use `checkNpmAuthEnvPassthrough` after this filter to detect unknown variants of this issue.
|
|
20
|
+
*/
|
|
21
|
+
export declare function filterPathForNpm(pathEnv: string): string;
|
|
22
|
+
/**
|
|
23
|
+
* Check whether env vars with special characters in their names (like npm auth token env vars,
|
|
24
|
+
* which contain `//` and `:`) will be passed through to npm subprocesses. Runs a test using the same
|
|
25
|
+
* PATH filtering applied to actual npm commands, so a failure here means the fix in
|
|
26
|
+
* `filterPathForNpm` doesn't cover this platform/environment variant.
|
|
27
|
+
*/
|
|
28
|
+
export declare function checkNpmAuthEnvPassthrough(options: Pick<BeachballOptions, 'registry' | 'path'> & {
|
|
29
|
+
/** PATH override only for testing */
|
|
30
|
+
pathEnv?: string;
|
|
31
|
+
}): Promise<void>;
|
|
32
|
+
//# sourceMappingURL=npmAuthEnvPassthrough.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"npmAuthEnvPassthrough.d.ts","sourceRoot":"","sources":["../../src/packageManager/npmAuthEnvPassthrough.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAKlE;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAQxD;AAED;;;;;GAKG;AACH,wBAAsB,0BAA0B,CAC9C,OAAO,EAAE,IAAI,CAAC,gBAAgB,EAAE,UAAU,GAAG,MAAM,CAAC,GAAG;IACrD,qCAAqC;IACrC,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,GACA,OAAO,CAAC,IAAI,CAAC,CA+Cf"}
|
|
@@ -0,0 +1,90 @@
|
|
|
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.checkNpmAuthEnvPassthrough = exports.filterPathForNpm = void 0;
|
|
7
|
+
const execa_1 = __importDefault(require("execa"));
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
const npmArgs_1 = require("./npmArgs");
|
|
10
|
+
const BeachballError_1 = require("../types/BeachballError");
|
|
11
|
+
const workspace_tools_1 = require("workspace-tools");
|
|
12
|
+
/**
|
|
13
|
+
* Filter PATH for running npm commands, removing entries that contain shell-script node wrappers.
|
|
14
|
+
*
|
|
15
|
+
* Package managers inject temp directories into PATH with shims for `node` — yarn classic uses
|
|
16
|
+
* `yarn--*` dirs, yarn berry uses `xfs-*` dirs. (Context: https://github.com/yarnpkg/yarn/issues/6685 -
|
|
17
|
+
* yarn berry does similar but cleans up afterwards.)
|
|
18
|
+
*
|
|
19
|
+
* These shims are POSIX shell scripts, e.g. this `node` shim:
|
|
20
|
+
* ```sh
|
|
21
|
+
* #!/bin/sh
|
|
22
|
+
* exec "/path/to/node" "$@"
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
25
|
+
* Problem is POSIX `sh` drops env var names with invalid characters like `/` and `:`, which are
|
|
26
|
+
* needed for npm auth token env vars (e.g. `npm_config_//someRegistry/:_authToken`).
|
|
27
|
+
*
|
|
28
|
+
* Removing those path entries fixes the issue and is unlikely to cause other problems in this context.
|
|
29
|
+
* Use `checkNpmAuthEnvPassthrough` after this filter to detect unknown variants of this issue.
|
|
30
|
+
*/
|
|
31
|
+
function filterPathForNpm(pathEnv) {
|
|
32
|
+
return pathEnv
|
|
33
|
+
.split(path_1.default.delimiter)
|
|
34
|
+
.filter(p => {
|
|
35
|
+
const base = path_1.default.basename(p);
|
|
36
|
+
return !base.startsWith('yarn--') && !base.startsWith('xfs-');
|
|
37
|
+
})
|
|
38
|
+
.join(path_1.default.delimiter);
|
|
39
|
+
}
|
|
40
|
+
exports.filterPathForNpm = filterPathForNpm;
|
|
41
|
+
/**
|
|
42
|
+
* Check whether env vars with special characters in their names (like npm auth token env vars,
|
|
43
|
+
* which contain `//` and `:`) will be passed through to npm subprocesses. Runs a test using the same
|
|
44
|
+
* PATH filtering applied to actual npm commands, so a failure here means the fix in
|
|
45
|
+
* `filterPathForNpm` doesn't cover this platform/environment variant.
|
|
46
|
+
*/
|
|
47
|
+
async function checkNpmAuthEnvPassthrough(options) {
|
|
48
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
49
|
+
const pathEnv = options.pathEnv ?? process.env.PATH;
|
|
50
|
+
const fakeToken = 'fake-token';
|
|
51
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- always defined if token is passed
|
|
52
|
+
const tokenEnv = (0, npmArgs_1.getNpmAuthEnv)({ registry: options.registry, token: fakeToken });
|
|
53
|
+
const envName = Object.keys(tokenEnv)[0];
|
|
54
|
+
const filteredPath = filterPathForNpm(pathEnv);
|
|
55
|
+
try {
|
|
56
|
+
const result = await (0, execa_1.default)('node', ['-e', `process.stdout.write(process.env[${JSON.stringify(envName)}] || '')`], {
|
|
57
|
+
env: { ...tokenEnv, PATH: filteredPath },
|
|
58
|
+
extendEnv: true,
|
|
59
|
+
});
|
|
60
|
+
if (result.stdout === fakeToken) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
catch {
|
|
65
|
+
// ignore
|
|
66
|
+
}
|
|
67
|
+
let relBeachballBin;
|
|
68
|
+
const beachballRoot = (0, workspace_tools_1.findPackageRoot)(__dirname);
|
|
69
|
+
const beachballPkg = beachballRoot ? (0, workspace_tools_1.getPackageInfo)(beachballRoot) : undefined;
|
|
70
|
+
// This should usually be found unless the code was bundled or something
|
|
71
|
+
if (beachballRoot && beachballPkg?.name === 'beachball' && beachballPkg.bin) {
|
|
72
|
+
const binValue = typeof beachballPkg.bin === 'string' ? beachballPkg.bin : beachballPkg.bin.beachball;
|
|
73
|
+
const beachballBinPath = path_1.default.join(beachballRoot, binValue);
|
|
74
|
+
relBeachballBin = path_1.default.relative(options.path, beachballBinPath);
|
|
75
|
+
}
|
|
76
|
+
console.error([
|
|
77
|
+
`The environment variable used to pass the npm auth token to "npm publish" is not being ` +
|
|
78
|
+
`passed to npm subprocesses. This is typically caused by a shell script node wrapper in ` +
|
|
79
|
+
`your PATH (e.g. injected by a package manager).`,
|
|
80
|
+
'',
|
|
81
|
+
`Please file an issue with beachball so this can be investigated. Your PATH:`,
|
|
82
|
+
pathEnv,
|
|
83
|
+
...(relBeachballBin
|
|
84
|
+
? ['', `In the meantime, you can try running the CLI directly via Node:`, ` node ${relBeachballBin} <args>`]
|
|
85
|
+
: []),
|
|
86
|
+
].join('\n'));
|
|
87
|
+
throw new BeachballError_1.BeachballError('Error passing npm auth token', { alreadyLogged: true });
|
|
88
|
+
}
|
|
89
|
+
exports.checkNpmAuthEnvPassthrough = checkNpmAuthEnvPassthrough;
|
|
90
|
+
//# sourceMappingURL=npmAuthEnvPassthrough.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"npmAuthEnvPassthrough.js","sourceRoot":"","sources":["../../src/packageManager/npmAuthEnvPassthrough.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC1B,gDAAwB;AAExB,uCAA0C;AAC1C,4DAAyD;AACzD,qDAAkE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G,KAAK,CAAC,gBAAgB,GAAG;IAAE,OAAO,EAAE,OAAO,CAAA;CAAE,CAAC;AACjF,MAAM,MAAM,qBAAqB,GAAG,KAAK,CAAC,OAAO,GAAG;IAAE,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC;AAEpE;;;;;;GAMG;AACH,wBAAsB,cAAc,CAClC,OAAO,EAAE,KAAK,GAAG,MAAM,GAAG,MAAM,EAChC,IAAI,EAAE,MAAM,EAAE,EACd,OAAO,EAAE,qBAAqB,GAC7B,OAAO,CAAC,oBAAoB,CAAC,
|
|
1
|
+
{"version":3,"file":"packageManager.d.ts","sourceRoot":"","sources":["../../src/packageManager/packageManager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,MAAM,MAAM,oBAAoB,GAAG,KAAK,CAAC,gBAAgB,GAAG;IAAE,OAAO,EAAE,OAAO,CAAA;CAAE,CAAC;AACjF,MAAM,MAAM,qBAAqB,GAAG,KAAK,CAAC,OAAO,GAAG;IAAE,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC;AAEpE;;;;;;GAMG;AACH,wBAAsB,cAAc,CAClC,OAAO,EAAE,KAAK,GAAG,MAAM,GAAG,MAAM,EAChC,IAAI,EAAE,MAAM,EAAE,EACd,OAAO,EAAE,qBAAqB,GAC7B,OAAO,CAAC,oBAAoB,CAAC,CAwB/B"}
|
|
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.packageManager = void 0;
|
|
7
7
|
const execa_1 = __importDefault(require("execa"));
|
|
8
|
-
const
|
|
8
|
+
const npmAuthEnvPassthrough_1 = require("./npmAuthEnvPassthrough");
|
|
9
9
|
/**
|
|
10
10
|
* Run a package manager command. Returns the error result instead of throwing on failure.
|
|
11
11
|
* @param manager The package manager to use
|
|
@@ -16,24 +16,7 @@ const path_1 = __importDefault(require("path"));
|
|
|
16
16
|
async function packageManager(manager, args, options) {
|
|
17
17
|
let pathEnv = options.env?.PATH || process.env.PATH;
|
|
18
18
|
if (manager === 'npm' && pathEnv) {
|
|
19
|
-
|
|
20
|
-
// The auth environment variable (e.g. `npm_config_//someRegistry/:_authToken`) was not being
|
|
21
|
-
// passed through to the child process. This might be because:
|
|
22
|
-
// - Special characters such as / and : aren't valid in env var names for certain shells/platforms
|
|
23
|
-
// - On every `yarn run ...` command, yarn makes temp directories like /<temp>/yarn--1776822418161-0.7992675923334178
|
|
24
|
-
// with aliases for `node` and `yarn`. On Linux (and Mac), the `node` alias looks something like:
|
|
25
|
-
// #!/bin/sh
|
|
26
|
-
// exec "/path/to/node" "$@"
|
|
27
|
-
// (see https://github.com/yarnpkg/yarn/issues/6685 for context)
|
|
28
|
-
// - Best guess: invalid environment variable names are dropped by this extra `exec` step??
|
|
29
|
-
// (This consistently reproed on Ubuntu+bash, but not Mac+zsh or bash. The clue was that the
|
|
30
|
-
// tests passed even on Linux when run via debugTests.js, but failed when run via yarn test.)
|
|
31
|
-
//
|
|
32
|
-
// Removing the yarn-- segment from the PATH seems to consistently fix this issue.
|
|
33
|
-
pathEnv = pathEnv
|
|
34
|
-
.split(path_1.default.delimiter)
|
|
35
|
-
.filter(p => !path_1.default.basename(p).startsWith('yarn--'))
|
|
36
|
-
.join(path_1.default.delimiter);
|
|
19
|
+
pathEnv = (0, npmAuthEnvPassthrough_1.filterPathForNpm)(pathEnv);
|
|
37
20
|
}
|
|
38
21
|
try {
|
|
39
22
|
const result = await (0, execa_1.default)(manager, args, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"packageManager.js","sourceRoot":"","sources":["../../src/packageManager/packageManager.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC1B,
|
|
1
|
+
{"version":3,"file":"packageManager.js","sourceRoot":"","sources":["../../src/packageManager/packageManager.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC1B,mEAA2D;AAK3D;;;;;;GAMG;AACI,KAAK,UAAU,cAAc,CAClC,OAAgC,EAChC,IAAc,EACd,OAA8B;IAE9B,IAAI,OAAO,GAAG,OAAO,CAAC,GAAG,EAAE,IAAI,IAAI,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC;IACpD,IAAI,OAAO,KAAK,KAAK,IAAI,OAAO,EAAE;QAChC,OAAO,GAAG,IAAA,wCAAgB,EAAC,OAAO,CAAC,CAAC;KACrC;IAED,IAAI;QACF,MAAM,MAAM,GAAG,MAAM,IAAA,eAAK,EAAC,OAAO,EAAE,IAAI,EAAE;YACxC,GAAG,OAAO;YACV,GAAG,EAAE,EAAE,GAAG,OAAO,CAAC,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE;YACtC,8GAA8G;YAC9G,gFAAgF;YAChF,GAAG,CAAC,OAAO,CAAC,QAAQ,KAAK,OAAO,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;SACrD,CAAC,CAAC;QACH,OAAO;YACL,GAAG,MAAM;YACT,OAAO,EAAE,CAAC,MAAM,CAAC,MAAM;SACxB,CAAC;KACH;IAAC,OAAO,CAAC,EAAE;QACV,OAAO;YACL,GAAI,CAAsB;YAC1B,OAAO,EAAE,KAAK;SACf,CAAC;KACH;AACH,CAAC;AA5BD,wCA4BC"}
|