@backstage/cli-module-package-manager-yarn 0.1.3-next.1 → 0.1.3-next.2
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 +11 -0
- package/README.md +36 -7
- package/dist/commands/pm/verifyPatches.cjs.js +32 -1
- package/dist/commands/pm/verifyPatches.cjs.js.map +1 -1
- package/dist/lib/fixYarnPatches.cjs.js +235 -0
- package/dist/lib/fixYarnPatches.cjs.js.map +1 -0
- package/dist/lib/verifyYarnPatches.cjs.js +12 -3
- package/dist/lib/verifyYarnPatches.cjs.js.map +1 -1
- package/dist/package.json.cjs.js +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# @backstage/cli-module-package-manager-yarn
|
|
2
2
|
|
|
3
|
+
## 0.1.3-next.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 84cfb88: Added a conservative `--fix` mode to `backstage-cli pm verify-patches` that can
|
|
8
|
+
update project-owned Backstage package patches when an automated release
|
|
9
|
+
upgrade leaves them pinned to older versions. The repair requires Yarn 3 or
|
|
10
|
+
later.
|
|
11
|
+
- Updated dependencies
|
|
12
|
+
- @backstage/cli-node@0.3.5-next.1
|
|
13
|
+
|
|
3
14
|
## 0.1.3-next.1
|
|
4
15
|
|
|
5
16
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# @backstage/cli-module-package-manager-yarn
|
|
2
2
|
|
|
3
|
-
Adds `backstage-cli pm verify-patches`, a
|
|
4
|
-
|
|
3
|
+
Adds `backstage-cli pm verify-patches`, a check for Yarn patch references,
|
|
4
|
+
root resolutions, and patched Backstage package versions.
|
|
5
5
|
|
|
6
6
|
The command verifies Yarn's native `patch:` protocol, available in Yarn 2 and
|
|
7
7
|
later. It does not inspect patches managed by tools such as `patch-package` in
|
|
@@ -30,11 +30,40 @@ are printed together and the command exits unsuccessfully if any are found.
|
|
|
30
30
|
Repositories without `backstage.json` still receive generic patch validation;
|
|
31
31
|
the Backstage release check is reported as skipped.
|
|
32
32
|
|
|
33
|
-
|
|
34
|
-
Use it alongside `yarn install --immutable`: immutable installs
|
|
35
|
-
resolved dependency state, while this command verifies that patch
|
|
36
|
-
patch files, resolutions, the lockfile, and the selected
|
|
37
|
-
remain aligned.
|
|
33
|
+
By default, the command does not run Yarn, install dependencies, or write
|
|
34
|
+
project files. Use it alongside `yarn install --immutable`: immutable installs
|
|
35
|
+
protect the resolved dependency state, while this command verifies that patch
|
|
36
|
+
declarations, patch files, resolutions, the lockfile, and the selected
|
|
37
|
+
Backstage release remain aligned.
|
|
38
|
+
|
|
39
|
+
### Repairing an outdated Backstage patch
|
|
40
|
+
|
|
41
|
+
When a Backstage release upgrade leaves a patched package pinned to its old
|
|
42
|
+
version, the command can attempt a conservative repair:
|
|
43
|
+
|
|
44
|
+
```shell
|
|
45
|
+
yarn backstage-cli pm verify-patches --fix
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
The fixer handles exact-version `@backstage/*` patches declared in the root
|
|
49
|
+
`resolutions`. It updates all eligible outdated patches to the versions in the
|
|
50
|
+
selected Backstage release, runs one lockfile-only Yarn install, and then runs
|
|
51
|
+
the full verification again. It never updates a patch to an older version and
|
|
52
|
+
restores `package.json` and `yarn.lock` if the install or verification fails.
|
|
53
|
+
Unsupported or ambiguous cases remain verification failures for manual repair.
|
|
54
|
+
The `--fix` mode requires Yarn 3 or later.
|
|
55
|
+
|
|
56
|
+
The repair runs in the working checkout using the repository's configured Yarn
|
|
57
|
+
binary, plugins, and registry settings, with dependency build scripts disabled.
|
|
58
|
+
Run it in a clean, exclusive checkout. An abrupt interruption can leave a
|
|
59
|
+
partial change behind.
|
|
60
|
+
|
|
61
|
+
For an automated Backstage version bump, run the commands in this order:
|
|
62
|
+
|
|
63
|
+
```shell
|
|
64
|
+
yarn backstage-cli versions:bump
|
|
65
|
+
yarn backstage-cli pm verify-patches --fix
|
|
66
|
+
```
|
|
38
67
|
|
|
39
68
|
## Release manifest environment
|
|
40
69
|
|
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var cliCommon = require('@backstage/cli-common');
|
|
6
6
|
var cleye = require('cleye');
|
|
7
|
+
var fixYarnPatches = require('../../lib/fixYarnPatches.cjs.js');
|
|
7
8
|
var verifyYarnPatches = require('../../lib/verifyYarnPatches.cjs.js');
|
|
8
9
|
|
|
9
10
|
function formatPatchReferenceCount(patchCount) {
|
|
@@ -15,12 +16,42 @@ function formatError(error) {
|
|
|
15
16
|
`;
|
|
16
17
|
}
|
|
17
18
|
var verifyPatches = async ({ args, info }) => {
|
|
18
|
-
|
|
19
|
+
const { flags } = cleye.cli(
|
|
20
|
+
{
|
|
21
|
+
name: info.usage,
|
|
22
|
+
flags: {
|
|
23
|
+
fix: {
|
|
24
|
+
type: Boolean,
|
|
25
|
+
description: "Safely retarget outdated Backstage package patches"
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
void 0,
|
|
30
|
+
args
|
|
31
|
+
);
|
|
19
32
|
const result = await verifyYarnPatches.verifyYarnPatches({
|
|
20
33
|
rootDir: cliCommon.targetPaths.dir,
|
|
21
34
|
env: process.env
|
|
22
35
|
});
|
|
36
|
+
let fixFailureMessage;
|
|
37
|
+
if (flags.fix && result.errors.length > 0 && result.errors.every((error) => error.kind === "backstage-patch-holdback")) {
|
|
38
|
+
const fixResult = await fixYarnPatches.fixYarnPatches({
|
|
39
|
+
rootDir: cliCommon.targetPaths.dir,
|
|
40
|
+
env: process.env,
|
|
41
|
+
verificationResult: result
|
|
42
|
+
});
|
|
43
|
+
if (fixResult.status === "fixed") {
|
|
44
|
+
process.stdout.write(`${fixResult.message}.
|
|
45
|
+
`);
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
fixFailureMessage = fixResult.message;
|
|
49
|
+
}
|
|
23
50
|
if (result.errors.length > 0) {
|
|
51
|
+
if (fixFailureMessage) {
|
|
52
|
+
process.stderr.write(`${fixFailureMessage}.
|
|
53
|
+
`);
|
|
54
|
+
}
|
|
24
55
|
process.stderr.write("Yarn patch verification failed:\n");
|
|
25
56
|
for (const error of result.errors) {
|
|
26
57
|
process.stderr.write(formatError(error));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"verifyPatches.cjs.js","sources":["../../../src/commands/pm/verifyPatches.ts"],"sourcesContent":["/*\n * Copyright 2026 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { targetPaths } from '@backstage/cli-common';\nimport type { CliCommandContext } from '@backstage/cli-node';\nimport { cli } from 'cleye';\nimport {\n verifyYarnPatches,\n type PatchVerificationError,\n} from '../../lib/verifyYarnPatches';\n\nfunction formatPatchReferenceCount(patchCount: number): string {\n return `${patchCount} patch reference${patchCount === 1 ? '' : 's'}`;\n}\n\nfunction formatError(error: PatchVerificationError): string {\n const location = error.location ? `${error.location} ` : '';\n return ` ${location}[${error.kind}]: ${error.message}\\n`;\n}\n\nexport default async ({ args, info }: CliCommandContext) => {\n cli({
|
|
1
|
+
{"version":3,"file":"verifyPatches.cjs.js","sources":["../../../src/commands/pm/verifyPatches.ts"],"sourcesContent":["/*\n * Copyright 2026 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { targetPaths } from '@backstage/cli-common';\nimport type { CliCommandContext } from '@backstage/cli-node';\nimport { cli } from 'cleye';\nimport { fixYarnPatches } from '../../lib/fixYarnPatches';\nimport {\n verifyYarnPatches,\n type PatchVerificationError,\n} from '../../lib/verifyYarnPatches';\n\nfunction formatPatchReferenceCount(patchCount: number): string {\n return `${patchCount} patch reference${patchCount === 1 ? '' : 's'}`;\n}\n\nfunction formatError(error: PatchVerificationError): string {\n const location = error.location ? `${error.location} ` : '';\n return ` ${location}[${error.kind}]: ${error.message}\\n`;\n}\n\nexport default async ({ args, info }: CliCommandContext) => {\n const { flags } = cli(\n {\n name: info.usage,\n flags: {\n fix: {\n type: Boolean,\n description: 'Safely retarget outdated Backstage package patches',\n },\n },\n },\n undefined,\n args,\n );\n\n const result = await verifyYarnPatches({\n rootDir: targetPaths.dir,\n env: process.env,\n });\n\n let fixFailureMessage: string | undefined;\n if (\n flags.fix &&\n result.errors.length > 0 &&\n result.errors.every(error => error.kind === 'backstage-patch-holdback')\n ) {\n const fixResult = await fixYarnPatches({\n rootDir: targetPaths.dir,\n env: process.env,\n verificationResult: result,\n });\n if (fixResult.status === 'fixed') {\n process.stdout.write(`${fixResult.message}.\\n`);\n return;\n }\n fixFailureMessage = fixResult.message;\n }\n\n if (result.errors.length > 0) {\n if (fixFailureMessage) {\n process.stderr.write(`${fixFailureMessage}.\\n`);\n }\n process.stderr.write('Yarn patch verification failed:\\n');\n for (const error of result.errors) {\n process.stderr.write(formatError(error));\n }\n throw new Error('Yarn patch verification failed');\n }\n\n const patchSummary =\n result.patchCount === 0\n ? 'no patch references found'\n : `${formatPatchReferenceCount(result.patchCount)} verified`;\n const backstageSummary =\n result.backstageCheck === 'verified'\n ? 'Backstage release validation passed'\n : 'Backstage release validation was skipped';\n process.stdout.write(\n `Yarn patch verification passed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');
|
|
4
|
+
var core = require('@yarnpkg/core');
|
|
5
|
+
var patchPlugin = require('@yarnpkg/plugin-patch');
|
|
6
|
+
var fs = require('node:fs/promises');
|
|
7
|
+
var path = require('node:path');
|
|
8
|
+
var verifyYarnPatches = require('./verifyYarnPatches.cjs.js');
|
|
9
|
+
|
|
10
|
+
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
11
|
+
|
|
12
|
+
var fs__default = /*#__PURE__*/_interopDefaultCompat(fs);
|
|
13
|
+
var path__default = /*#__PURE__*/_interopDefaultCompat(path);
|
|
14
|
+
|
|
15
|
+
function hasExactPatchSource(declaration, packageName, version) {
|
|
16
|
+
try {
|
|
17
|
+
const source = core.structUtils.parseDescriptor(declaration.source, true);
|
|
18
|
+
const range = core.structUtils.parseRange(source.range);
|
|
19
|
+
return core.structUtils.stringifyIdent(source) === packageName && range.protocol === "npm:" && range.selector === version && core.semverUtils.clean(range.selector) === version;
|
|
20
|
+
} catch {
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
function getRepairableHoldbacks(result) {
|
|
25
|
+
if (result.errors.length === 0) {
|
|
26
|
+
return void 0;
|
|
27
|
+
}
|
|
28
|
+
const holdbacks = [];
|
|
29
|
+
for (const error of result.errors) {
|
|
30
|
+
const holdback = error.repairHint;
|
|
31
|
+
if (error.kind !== "backstage-patch-holdback" || !holdback || !core.semverUtils.satisfiesWithPrereleases(
|
|
32
|
+
holdback.targetVersion,
|
|
33
|
+
`>${holdback.currentVersion}`
|
|
34
|
+
)) {
|
|
35
|
+
return void 0;
|
|
36
|
+
}
|
|
37
|
+
holdbacks.push(holdback);
|
|
38
|
+
}
|
|
39
|
+
return holdbacks;
|
|
40
|
+
}
|
|
41
|
+
function createRetargetedPatchReference(options) {
|
|
42
|
+
const ident = core.structUtils.parseIdent(options.packageName);
|
|
43
|
+
const descriptor = core.structUtils.makeDescriptor(ident, options.reference);
|
|
44
|
+
const parsed = patchPlugin.patchUtils.parseDescriptor(descriptor);
|
|
45
|
+
return patchPlugin.patchUtils.makeDescriptor(ident, {
|
|
46
|
+
...parsed,
|
|
47
|
+
sourceDescriptor: core.structUtils.makeDescriptor(
|
|
48
|
+
ident,
|
|
49
|
+
`npm:${options.targetVersion}`
|
|
50
|
+
)
|
|
51
|
+
}).range;
|
|
52
|
+
}
|
|
53
|
+
function isRecord(value) {
|
|
54
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
55
|
+
}
|
|
56
|
+
function createTargetManifest(options) {
|
|
57
|
+
let manifest;
|
|
58
|
+
try {
|
|
59
|
+
manifest = JSON.parse(options.originalManifest);
|
|
60
|
+
} catch {
|
|
61
|
+
return void 0;
|
|
62
|
+
}
|
|
63
|
+
if (!isRecord(manifest) || !isRecord(manifest.resolutions)) {
|
|
64
|
+
return void 0;
|
|
65
|
+
}
|
|
66
|
+
let content = options.originalManifest;
|
|
67
|
+
const transitions = [];
|
|
68
|
+
for (const holdback of options.holdbacks) {
|
|
69
|
+
const declaration = holdback.declaration;
|
|
70
|
+
if (declaration.location !== `package.json#resolutions.${holdback.packageName}` || declaration.patchedIdent !== holdback.packageName || manifest.resolutions[holdback.packageName] !== declaration.reference || !hasExactPatchSource(
|
|
71
|
+
declaration,
|
|
72
|
+
holdback.packageName,
|
|
73
|
+
holdback.currentVersion
|
|
74
|
+
) || declaration.paths.length !== 1 || declaration.components.length !== 1 || declaration.components[0] !== `local<${declaration.paths[0].absolute}>` || !declaration.projectOwned) {
|
|
75
|
+
return void 0;
|
|
76
|
+
}
|
|
77
|
+
const currentLiteral = JSON.stringify(declaration.reference);
|
|
78
|
+
const firstReference = content.indexOf(currentLiteral);
|
|
79
|
+
if (firstReference === -1 || content.indexOf(
|
|
80
|
+
currentLiteral,
|
|
81
|
+
firstReference + currentLiteral.length
|
|
82
|
+
) !== -1) {
|
|
83
|
+
return void 0;
|
|
84
|
+
}
|
|
85
|
+
let targetReference;
|
|
86
|
+
try {
|
|
87
|
+
targetReference = createRetargetedPatchReference({
|
|
88
|
+
packageName: holdback.packageName,
|
|
89
|
+
targetVersion: holdback.targetVersion,
|
|
90
|
+
reference: declaration.reference
|
|
91
|
+
});
|
|
92
|
+
} catch {
|
|
93
|
+
return void 0;
|
|
94
|
+
}
|
|
95
|
+
content = `${content.slice(0, firstReference)}${JSON.stringify(
|
|
96
|
+
targetReference
|
|
97
|
+
)}${content.slice(firstReference + currentLiteral.length)}`;
|
|
98
|
+
transitions.push(
|
|
99
|
+
`Retargeted patch for '${holdback.packageName}' from '${holdback.currentVersion}' to '${holdback.targetVersion}'`
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
return { content, transitions };
|
|
103
|
+
}
|
|
104
|
+
async function defaultInstall(rootDir, env) {
|
|
105
|
+
const child = cliCommon.run(["yarn", "install", "--mode=update-lockfile"], {
|
|
106
|
+
cwd: rootDir,
|
|
107
|
+
env: createYarnEnvironment(env)
|
|
108
|
+
});
|
|
109
|
+
await child.waitForExit();
|
|
110
|
+
if (child.signalCode) {
|
|
111
|
+
throw new Error(`Yarn install was terminated by ${child.signalCode}`);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
function createYarnEnvironment(env) {
|
|
115
|
+
return {
|
|
116
|
+
...Object.fromEntries(
|
|
117
|
+
Object.entries(env ?? process.env).map(
|
|
118
|
+
([name, value]) => name.startsWith("npm_") ? [name, void 0] : [name, value]
|
|
119
|
+
)
|
|
120
|
+
),
|
|
121
|
+
YARN_ENABLE_IMMUTABLE_INSTALLS: "false",
|
|
122
|
+
YARN_ENABLE_SCRIPTS: "false"
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
async function getYarnVersion(rootDir, env) {
|
|
126
|
+
const stdoutChunks = [];
|
|
127
|
+
const child = cliCommon.run(["yarn", "--version"], {
|
|
128
|
+
cwd: rootDir,
|
|
129
|
+
env: createYarnEnvironment(env),
|
|
130
|
+
onStdout: (data) => stdoutChunks.push(data)
|
|
131
|
+
});
|
|
132
|
+
await child.waitForExit();
|
|
133
|
+
if (child.signalCode) {
|
|
134
|
+
throw new Error(`Yarn version check was terminated by ${child.signalCode}`);
|
|
135
|
+
}
|
|
136
|
+
return Buffer.concat(stdoutChunks).toString().trim();
|
|
137
|
+
}
|
|
138
|
+
async function restoreOriginals(options) {
|
|
139
|
+
let restored = true;
|
|
140
|
+
for (const [filePath, content] of [
|
|
141
|
+
[options.manifestPath, options.originalManifest],
|
|
142
|
+
[options.lockfilePath, options.originalLockfile]
|
|
143
|
+
]) {
|
|
144
|
+
try {
|
|
145
|
+
await options.writeFile(filePath, content);
|
|
146
|
+
} catch {
|
|
147
|
+
restored = false;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
return restored;
|
|
151
|
+
}
|
|
152
|
+
async function fixYarnPatches(options) {
|
|
153
|
+
const rootDir = path__default.default.resolve(options.rootDir);
|
|
154
|
+
const initialResult = options.verificationResult ?? await verifyYarnPatches.verifyYarnPatches(options);
|
|
155
|
+
const holdbacks = getRepairableHoldbacks(initialResult);
|
|
156
|
+
if (!holdbacks) {
|
|
157
|
+
return {
|
|
158
|
+
status: "not-fixable",
|
|
159
|
+
message: "No patch holdback could be repaired safely"
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
const manifestPath = path__default.default.join(rootDir, "package.json");
|
|
163
|
+
const lockfilePath = path__default.default.join(rootDir, "yarn.lock");
|
|
164
|
+
const originalManifest = await fs__default.default.readFile(manifestPath, "utf8");
|
|
165
|
+
const originalLockfile = await fs__default.default.readFile(lockfilePath, "utf8");
|
|
166
|
+
const target = createTargetManifest({ originalManifest, holdbacks });
|
|
167
|
+
if (!target) {
|
|
168
|
+
return {
|
|
169
|
+
status: "not-fixable",
|
|
170
|
+
message: "The patch resolutions changed or could not be retargeted safely"
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
if (!options.install) {
|
|
174
|
+
let reportedVersion;
|
|
175
|
+
try {
|
|
176
|
+
reportedVersion = await getYarnVersion(rootDir, options.env);
|
|
177
|
+
} catch (error) {
|
|
178
|
+
return {
|
|
179
|
+
status: "not-fixable",
|
|
180
|
+
message: `Could not determine the repository Yarn version: ${String(
|
|
181
|
+
error
|
|
182
|
+
)}`
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
const yarnVersion = core.semverUtils.clean(reportedVersion);
|
|
186
|
+
if (!yarnVersion || !core.semverUtils.satisfiesWithPrereleases(yarnVersion, ">=3.0.0")) {
|
|
187
|
+
return {
|
|
188
|
+
status: "not-fixable",
|
|
189
|
+
message: `Automatic patch repair requires Yarn 3 or later, but the repository uses Yarn '${reportedVersion}'`
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
const writeFile = options.writeFile ?? ((filePath, content) => fs__default.default.writeFile(filePath, content));
|
|
194
|
+
const restoreFailure = async (reason) => {
|
|
195
|
+
const restored = await restoreOriginals({
|
|
196
|
+
manifestPath,
|
|
197
|
+
lockfilePath,
|
|
198
|
+
originalManifest,
|
|
199
|
+
originalLockfile,
|
|
200
|
+
writeFile
|
|
201
|
+
});
|
|
202
|
+
return {
|
|
203
|
+
status: "not-fixable",
|
|
204
|
+
message: restored ? `${reason}; the original project files were restored` : `${reason}; project files may contain a partial repair`
|
|
205
|
+
};
|
|
206
|
+
};
|
|
207
|
+
try {
|
|
208
|
+
await writeFile(manifestPath, target.content);
|
|
209
|
+
await (options.install ?? ((dir) => defaultInstall(dir, options.env)))(
|
|
210
|
+
rootDir
|
|
211
|
+
);
|
|
212
|
+
const finalManifest = await fs__default.default.readFile(manifestPath, "utf8");
|
|
213
|
+
if (finalManifest !== target.content) {
|
|
214
|
+
return restoreFailure("Yarn changed package.json unexpectedly");
|
|
215
|
+
}
|
|
216
|
+
const verified = await verifyYarnPatches.verifyYarnPatches({
|
|
217
|
+
rootDir,
|
|
218
|
+
env: options.env,
|
|
219
|
+
fetch: options.fetch
|
|
220
|
+
});
|
|
221
|
+
if (verified.errors.length > 0) {
|
|
222
|
+
return restoreFailure(
|
|
223
|
+
`The repaired project did not pass patch verification: ${verified.errors.map((error) => error.message).join("; ")}`
|
|
224
|
+
);
|
|
225
|
+
}
|
|
226
|
+
return { status: "fixed", message: target.transitions.join("; ") };
|
|
227
|
+
} catch (error) {
|
|
228
|
+
return restoreFailure(
|
|
229
|
+
`Yarn could not repair the patches: ${String(error)}`
|
|
230
|
+
);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
exports.fixYarnPatches = fixYarnPatches;
|
|
235
|
+
//# sourceMappingURL=fixYarnPatches.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fixYarnPatches.cjs.js","sources":["../../src/lib/fixYarnPatches.ts"],"sourcesContent":["/*\n * Copyright 2026 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { run } from '@backstage/cli-common';\nimport { semverUtils, structUtils } from '@yarnpkg/core';\nimport { patchUtils } from '@yarnpkg/plugin-patch';\nimport fs from 'node:fs/promises';\nimport path from 'node:path';\nimport {\n verifyYarnPatches,\n type PatchDeclaration,\n type PatchHoldbackFix,\n type VerifyYarnPatchesOptions,\n type VerifyYarnPatchesResult,\n} from './verifyYarnPatches';\n\nexport type FixYarnPatchesOptions = VerifyYarnPatchesOptions & {\n install?: (rootDir: string) => Promise<void>;\n verificationResult?: VerifyYarnPatchesResult;\n writeFile?: (filePath: string, content: string) => Promise<void>;\n};\n\nexport type FixYarnPatchesResult = {\n status: 'fixed' | 'not-fixable';\n message: string;\n};\n\nfunction hasExactPatchSource(\n declaration: PatchDeclaration,\n packageName: string,\n version: string,\n): boolean {\n try {\n const source = structUtils.parseDescriptor(declaration.source, true);\n const range = structUtils.parseRange(source.range);\n return (\n structUtils.stringifyIdent(source) === packageName &&\n range.protocol === 'npm:' &&\n range.selector === version &&\n semverUtils.clean(range.selector) === version\n );\n } catch {\n return false;\n }\n}\n\nfunction getRepairableHoldbacks(\n result: VerifyYarnPatchesResult,\n): PatchHoldbackFix[] | undefined {\n if (result.errors.length === 0) {\n return undefined;\n }\n const holdbacks: PatchHoldbackFix[] = [];\n for (const error of result.errors) {\n const holdback = error.repairHint;\n if (\n error.kind !== 'backstage-patch-holdback' ||\n !holdback ||\n !semverUtils.satisfiesWithPrereleases(\n holdback.targetVersion,\n `>${holdback.currentVersion}`,\n )\n ) {\n return undefined;\n }\n holdbacks.push(holdback);\n }\n return holdbacks;\n}\n\nfunction createRetargetedPatchReference(options: {\n packageName: string;\n targetVersion: string;\n reference: string;\n}): string {\n const ident = structUtils.parseIdent(options.packageName);\n const descriptor = structUtils.makeDescriptor(ident, options.reference);\n const parsed = patchUtils.parseDescriptor(descriptor);\n return patchUtils.makeDescriptor(ident, {\n ...parsed,\n sourceDescriptor: structUtils.makeDescriptor(\n ident,\n `npm:${options.targetVersion}`,\n ),\n }).range;\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\nfunction createTargetManifest(options: {\n originalManifest: string;\n holdbacks: PatchHoldbackFix[];\n}): { content: string; transitions: string[] } | undefined {\n let manifest: unknown;\n try {\n manifest = JSON.parse(options.originalManifest);\n } catch {\n return undefined;\n }\n if (!isRecord(manifest) || !isRecord(manifest.resolutions)) {\n return undefined;\n }\n\n let content = options.originalManifest;\n const transitions: string[] = [];\n for (const holdback of options.holdbacks) {\n const declaration = holdback.declaration;\n if (\n declaration.location !==\n `package.json#resolutions.${holdback.packageName}` ||\n declaration.patchedIdent !== holdback.packageName ||\n manifest.resolutions[holdback.packageName] !== declaration.reference ||\n !hasExactPatchSource(\n declaration,\n holdback.packageName,\n holdback.currentVersion,\n ) ||\n declaration.paths.length !== 1 ||\n declaration.components.length !== 1 ||\n declaration.components[0] !== `local<${declaration.paths[0].absolute}>` ||\n !declaration.projectOwned\n ) {\n return undefined;\n }\n\n const currentLiteral = JSON.stringify(declaration.reference);\n const firstReference = content.indexOf(currentLiteral);\n if (\n firstReference === -1 ||\n content.indexOf(\n currentLiteral,\n firstReference + currentLiteral.length,\n ) !== -1\n ) {\n return undefined;\n }\n let targetReference: string;\n try {\n targetReference = createRetargetedPatchReference({\n packageName: holdback.packageName,\n targetVersion: holdback.targetVersion,\n reference: declaration.reference,\n });\n } catch {\n return undefined;\n }\n content = `${content.slice(0, firstReference)}${JSON.stringify(\n targetReference,\n )}${content.slice(firstReference + currentLiteral.length)}`;\n transitions.push(\n `Retargeted patch for '${holdback.packageName}' from '${holdback.currentVersion}' to '${holdback.targetVersion}'`,\n );\n }\n return { content, transitions };\n}\n\nasync function defaultInstall(\n rootDir: string,\n env: NodeJS.ProcessEnv | undefined,\n): Promise<void> {\n const child = run(['yarn', 'install', '--mode=update-lockfile'], {\n cwd: rootDir,\n env: createYarnEnvironment(env),\n });\n await child.waitForExit();\n // A signal-terminated process has no exit code, so waitForExit resolves.\n if (child.signalCode) {\n throw new Error(`Yarn install was terminated by ${child.signalCode}`);\n }\n}\n\nfunction createYarnEnvironment(\n env: NodeJS.ProcessEnv | undefined,\n): Partial<NodeJS.ProcessEnv> {\n return {\n ...Object.fromEntries(\n Object.entries(env ?? process.env).map(([name, value]) =>\n name.startsWith('npm_') ? [name, undefined] : [name, value],\n ),\n ),\n YARN_ENABLE_IMMUTABLE_INSTALLS: 'false',\n YARN_ENABLE_SCRIPTS: 'false',\n };\n}\n\nasync function getYarnVersion(\n rootDir: string,\n env: NodeJS.ProcessEnv | undefined,\n): Promise<string> {\n const stdoutChunks: Buffer[] = [];\n const child = run(['yarn', '--version'], {\n cwd: rootDir,\n env: createYarnEnvironment(env),\n onStdout: data => stdoutChunks.push(data),\n });\n await child.waitForExit();\n if (child.signalCode) {\n throw new Error(`Yarn version check was terminated by ${child.signalCode}`);\n }\n return Buffer.concat(stdoutChunks).toString().trim();\n}\n\nasync function restoreOriginals(options: {\n manifestPath: string;\n lockfilePath: string;\n originalManifest: string;\n originalLockfile: string;\n writeFile: (filePath: string, content: string) => Promise<void>;\n}): Promise<boolean> {\n let restored = true;\n for (const [filePath, content] of [\n [options.manifestPath, options.originalManifest],\n [options.lockfilePath, options.originalLockfile],\n ] as const) {\n try {\n await options.writeFile(filePath, content);\n } catch {\n restored = false;\n }\n }\n return restored;\n}\n\n/**\n * Attempts to repair forward-only Backstage patch holdbacks.\n *\n * @internal\n */\nexport async function fixYarnPatches(\n options: FixYarnPatchesOptions,\n): Promise<FixYarnPatchesResult> {\n const rootDir = path.resolve(options.rootDir);\n const initialResult =\n options.verificationResult ?? (await verifyYarnPatches(options));\n const holdbacks = getRepairableHoldbacks(initialResult);\n if (!holdbacks) {\n return {\n status: 'not-fixable',\n message: 'No patch holdback could be repaired safely',\n };\n }\n\n const manifestPath = path.join(rootDir, 'package.json');\n const lockfilePath = path.join(rootDir, 'yarn.lock');\n const originalManifest = await fs.readFile(manifestPath, 'utf8');\n const originalLockfile = await fs.readFile(lockfilePath, 'utf8');\n const target = createTargetManifest({ originalManifest, holdbacks });\n if (!target) {\n return {\n status: 'not-fixable',\n message:\n 'The patch resolutions changed or could not be retargeted safely',\n };\n }\n\n if (!options.install) {\n let reportedVersion: string;\n try {\n reportedVersion = await getYarnVersion(rootDir, options.env);\n } catch (error) {\n return {\n status: 'not-fixable',\n message: `Could not determine the repository Yarn version: ${String(\n error,\n )}`,\n };\n }\n const yarnVersion = semverUtils.clean(reportedVersion);\n if (\n !yarnVersion ||\n !semverUtils.satisfiesWithPrereleases(yarnVersion, '>=3.0.0')\n ) {\n return {\n status: 'not-fixable',\n message: `Automatic patch repair requires Yarn 3 or later, but the repository uses Yarn '${reportedVersion}'`,\n };\n }\n }\n\n const writeFile =\n options.writeFile ??\n ((filePath: string, content: string) => fs.writeFile(filePath, content));\n const restoreFailure = async (\n reason: string,\n ): Promise<FixYarnPatchesResult> => {\n const restored = await restoreOriginals({\n manifestPath,\n lockfilePath,\n originalManifest,\n originalLockfile,\n writeFile,\n });\n return {\n status: 'not-fixable',\n message: restored\n ? `${reason}; the original project files were restored`\n : `${reason}; project files may contain a partial repair`,\n };\n };\n\n try {\n await writeFile(manifestPath, target.content);\n await (options.install ?? (dir => defaultInstall(dir, options.env)))(\n rootDir,\n );\n const finalManifest = await fs.readFile(manifestPath, 'utf8');\n if (finalManifest !== target.content) {\n return restoreFailure('Yarn changed package.json unexpectedly');\n }\n const verified = await verifyYarnPatches({\n rootDir,\n env: options.env,\n fetch: options.fetch,\n });\n if (verified.errors.length > 0) {\n return restoreFailure(\n `The repaired project did not pass patch verification: ${verified.errors\n .map(error => error.message)\n .join('; ')}`,\n );\n }\n return { status: 'fixed', message: target.transitions.join('; ') };\n } catch (error) {\n return restoreFailure(\n `Yarn could not repair the patches: ${String(error)}`,\n );\n }\n}\n"],"names":["structUtils","semverUtils","patchUtils","run","path","verifyYarnPatches","fs"],"mappings":";;;;;;;;;;;;;;AAwCA,SAAS,mBAAA,CACP,WAAA,EACA,WAAA,EACA,OAAA,EACS;AACT,EAAA,IAAI;AACF,IAAA,MAAM,MAAA,GAASA,gBAAA,CAAY,eAAA,CAAgB,WAAA,CAAY,QAAQ,IAAI,CAAA;AACnE,IAAA,MAAM,KAAA,GAAQA,gBAAA,CAAY,UAAA,CAAW,MAAA,CAAO,KAAK,CAAA;AACjD,IAAA,OACEA,gBAAA,CAAY,cAAA,CAAe,MAAM,CAAA,KAAM,eACvC,KAAA,CAAM,QAAA,KAAa,MAAA,IACnB,KAAA,CAAM,aAAa,OAAA,IACnBC,gBAAA,CAAY,KAAA,CAAM,KAAA,CAAM,QAAQ,CAAA,KAAM,OAAA;AAAA,EAE1C,CAAA,CAAA,MAAQ;AACN,IAAA,OAA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MAC/D;AAAA,KACF;AACA,IAAA,MAAM,aAAA,GAAgB,MAAMA,mBAAA,CAAG,QAAA,CAAS,cAAc,MAAM,CAAA;AAC5D,IAAA,IAAI,aAAA,KAAkB,OAAO,OAAA,EAAS;AACpC,MAAA,OAAO,eAAe,wCAAwC,CAAA;AAAA,IAChE;AACA,IAAA,MAAM,QAAA,GAAW,MAAMD,mCAAA,CAAkB;AAAA,MACvC,OAAA;AAAA,MACA,KAAK,OAAA,CAAQ,GAAA;AAAA,MACb,OAAO,OAAA,CAAQ;AAAA,KAChB,CAAA;AACD,IAAA,IAAI,QAAA,CAAS,MAAA,CAAO,MAAA,GAAS,CAAA,EAAG;AAC9B,MAAA,OAAO,cAAA;AAAA,QACL,CAAA,sDAAA,EAAyD,QAAA,CAAS,MAAA,CAC/D,GAAA,CAAI,CAAA,KAAA,KAAS,MAAM,OAAO,CAAA,CAC1B,IAAA,CAAK,IAAI,CAAC,CAAA;AAAA,OACf;AAAA,IACF;AACA,IAAA,OAAO,EAAE,QAAQ,OAAA,EAAS,OAAA,EAAS,OAAO,WAAA,CAAY,IAAA,CAAK,IAAI,CAAA,EAAE;AAAA,EACnE,SAAS,KAAA,EAAO;AACd,IAAA,OAAO,cAAA;AAAA,MACL,CAAA,mCAAA,EAAsC,MAAA,CAAO,KAAK,CAAC,CAAA;AAAA,KACrD;AAAA,EACF;AACF;;"}
|
|
@@ -140,6 +140,7 @@ function parsePatchDeclaration(options) {
|
|
|
140
140
|
}
|
|
141
141
|
return {
|
|
142
142
|
patchedIdent: options.patchedIdent,
|
|
143
|
+
reference: options.range,
|
|
143
144
|
source,
|
|
144
145
|
components,
|
|
145
146
|
parentLocator: parent.locator ?? (hasProjectRelativePath ? options.parentLocator : void 0),
|
|
@@ -684,7 +685,8 @@ function getPatchedBackstagePackages(declarations) {
|
|
|
684
685
|
packages.push({
|
|
685
686
|
name: core.structUtils.stringifyIdent(source),
|
|
686
687
|
version: range.selector,
|
|
687
|
-
location: declaration.location
|
|
688
|
+
location: declaration.location,
|
|
689
|
+
declaration
|
|
688
690
|
});
|
|
689
691
|
}
|
|
690
692
|
return packages;
|
|
@@ -801,11 +803,18 @@ async function validateBackstagePatches(options) {
|
|
|
801
803
|
location: patchedPackage.location
|
|
802
804
|
});
|
|
803
805
|
} else if (releaseVersion !== patchedPackage.version) {
|
|
804
|
-
|
|
806
|
+
const error = {
|
|
805
807
|
kind: "backstage-patch-holdback",
|
|
806
808
|
message: `Patched package '${patchedPackage.name}' is at version '${patchedPackage.version}', but Backstage release '${backstageVersion}' requires version '${releaseVersion}'`,
|
|
807
809
|
location: patchedPackage.location
|
|
808
|
-
}
|
|
810
|
+
};
|
|
811
|
+
error.repairHint = {
|
|
812
|
+
packageName: patchedPackage.name,
|
|
813
|
+
currentVersion: patchedPackage.version,
|
|
814
|
+
targetVersion: releaseVersion,
|
|
815
|
+
declaration: patchedPackage.declaration
|
|
816
|
+
};
|
|
817
|
+
errors.push(error);
|
|
809
818
|
}
|
|
810
819
|
}
|
|
811
820
|
return { backstageCheck: "verified", errors };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"verifyYarnPatches.cjs.js","sources":["../../src/lib/verifyYarnPatches.ts"],"sourcesContent":["/*\n * Copyright 2026 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n getManifestByVersion,\n type ReleaseManifest,\n} from '@backstage/release-manifests';\nimport {\n Configuration,\n httpUtils,\n semverUtils,\n structUtils,\n} from '@yarnpkg/core';\nimport { Project, TAG_REGEXP, Workspace } from '@yarnpkg/core';\nimport type { Descriptor, PluginConfiguration } from '@yarnpkg/core';\nimport { npath, ppath } from '@yarnpkg/fslib';\nimport { parseResolution, parseSyml } from '@yarnpkg/parsers';\nimport patchPlugin from '@yarnpkg/plugin-patch';\nimport fs from 'node:fs/promises';\nimport path from 'node:path';\n\nexport type PatchVerificationErrorKind =\n | 'backstage-manifest-load-failure'\n | 'backstage-package-missing'\n | 'backstage-patch-holdback'\n | 'incompatible-patch-declarations'\n | 'lockfile-mismatch'\n | 'malformed-lockfile'\n | 'malformed-patch-reference'\n | 'missing-lockfile'\n | 'missing-patch-file'\n | 'orphaned-patch-file'\n | 'unused-resolution';\n\nexport type PatchVerificationError = {\n kind: PatchVerificationErrorKind;\n message: string;\n location?: string;\n};\n\nexport type VerifyYarnPatchesOptions = {\n rootDir: string;\n env?: NodeJS.ProcessEnv;\n fetch?: typeof globalThis.fetch;\n};\n\nexport type VerifyYarnPatchesResult = {\n patchCount: number;\n backstageCheck: 'verified' | 'skipped';\n errors: PatchVerificationError[];\n};\n\ntype PatchDeclaration = {\n patchedIdent: string;\n source: string;\n resolvedSource?: string;\n components: string[];\n parentLocator?: string;\n canMatchManifest: boolean;\n projectOwned: boolean;\n paths: LocalPatchPath[];\n location: string;\n};\n\ntype LocalPatchPath = {\n absolute: string;\n relative: string;\n};\n\ntype PatchedBackstagePackage = {\n name: string;\n version: string;\n location: string;\n};\n\ntype ResolutionDeclaration = {\n pattern: string;\n location: string;\n};\n\nconst MANIFEST_FIELDS = [\n 'resolutions',\n 'dependencies',\n 'devDependencies',\n 'peerDependencies',\n 'optionalDependencies',\n] as const;\n\nconst PATCH_PLUGIN_CONFIGURATION: PluginConfiguration = {\n modules: new Map([['@yarnpkg/plugin-patch', patchPlugin]]),\n plugins: new Set(['@yarnpkg/plugin-patch']),\n};\n\n// Yarn Configuration.find has no environment parameter and reads process.env.\n// Serialize the narrow overlay so concurrent verifications cannot interleave.\nlet configurationEnvironmentQueue = Promise.resolve();\n\nfunction relativePath(rootDir: string, targetPath: string): string {\n return path.relative(rootDir, targetPath).split(path.sep).join('/');\n}\n\nfunction compareStrings(left: string, right: string): number {\n if (left < right) {\n return -1;\n }\n if (left > right) {\n return 1;\n }\n return 0;\n}\n\nfunction sortErrors(\n errors: PatchVerificationError[],\n): PatchVerificationError[] {\n return errors.sort((left, right) => {\n return (\n compareStrings(left.location ?? '', right.location ?? '') ||\n compareStrings(left.kind, right.kind) ||\n compareStrings(left.message, right.message)\n );\n });\n}\n\nfunction isErrorWithCode(error: unknown, code: string): boolean {\n return (\n typeof error === 'object' &&\n error !== null &&\n 'code' in error &&\n error.code === code\n );\n}\n\nfunction getPatchPathWithoutFlags(patchPath: string): string {\n if (patchPath.startsWith('~builtin<')) {\n return patchPath.slice(1);\n }\n const flagIndex = patchPath.lastIndexOf('!');\n return flagIndex === -1 ? patchPath : patchPath.slice(flagIndex + 1);\n}\n\nfunction isBuiltinPatchPath(patchPath: string): boolean {\n const pathWithoutFlags = getPatchPathWithoutFlags(patchPath);\n return (\n pathWithoutFlags.startsWith('builtin<') && pathWithoutFlags.endsWith('>')\n );\n}\n\ntype PatchParent = {\n directory?: string;\n locator?: string;\n};\n\nfunction getPatchParent(\n rootDir: string,\n fallbackDir: string,\n locatorValue: unknown,\n): PatchParent {\n if (typeof locatorValue !== 'string') {\n return { directory: fallbackDir };\n }\n\n const parentLocator = structUtils.parseLocator(locatorValue, true);\n const locator = structUtils.stringifyLocator(parentLocator);\n const parentRange = structUtils.parseRange(parentLocator.reference);\n if (parentRange.protocol !== 'workspace:') {\n return { locator };\n }\n\n return {\n directory: path.resolve(rootDir, parentRange.selector),\n locator,\n };\n}\n\nfunction resolvePatchPath(\n rootDir: string,\n parentDir: string | undefined,\n patchPath: string,\n): LocalPatchPath | undefined {\n const pathWithoutFlags = getPatchPathWithoutFlags(patchPath);\n if (isBuiltinPatchPath(pathWithoutFlags)) {\n return undefined;\n }\n\n const portablePatchPath = npath.toPortablePath(pathWithoutFlags);\n let absolute: string | undefined;\n if (pathWithoutFlags.startsWith('~/')) {\n absolute = path.resolve(rootDir, pathWithoutFlags.slice(2));\n } else if (ppath.isAbsolute(portablePatchPath)) {\n absolute = npath.fromPortablePath(portablePatchPath);\n } else if (parentDir !== undefined) {\n absolute = path.resolve(parentDir, pathWithoutFlags);\n }\n if (absolute === undefined) {\n return undefined;\n }\n return {\n absolute,\n relative: relativePath(rootDir, absolute),\n };\n}\n\nfunction parsePatchDeclaration(options: {\n rootDir: string;\n parentDir: string;\n parentLocator?: string;\n patchedIdent: string;\n range: string;\n location: string;\n origin: 'manifest' | 'lockfile';\n}): PatchDeclaration | undefined {\n const parsedRange = structUtils.parseRange(options.range, {\n requireProtocol: 'patch:',\n requireSource: true,\n });\n const sourceDescriptor = structUtils.parseDescriptor(\n parsedRange.source,\n true,\n );\n const source = structUtils.stringifyDescriptor(sourceDescriptor);\n const parent = getPatchParent(\n options.rootDir,\n options.parentDir,\n parsedRange.params?.locator,\n );\n const paths: LocalPatchPath[] = [];\n let hasDependencyOwnedPath = false;\n let hasProjectRelativePath = false;\n const patchPaths =\n parsedRange.selector === '' ? [] : parsedRange.selector.split('&');\n const components = patchPaths.map(patchPath => {\n const flagIndex = patchPath.lastIndexOf('!');\n const flags = flagIndex === -1 ? '' : patchPath.slice(0, flagIndex + 1);\n const pathWithoutFlags = getPatchPathWithoutFlags(patchPath);\n if (isBuiltinPatchPath(patchPath)) {\n return patchPath;\n }\n\n const localPath = resolvePatchPath(\n options.rootDir,\n parent.directory,\n patchPath,\n );\n if (localPath) {\n paths.push(localPath);\n if (\n !pathWithoutFlags.startsWith('~/') &&\n !ppath.isAbsolute(npath.toPortablePath(pathWithoutFlags))\n ) {\n hasProjectRelativePath = true;\n }\n return `${flags}local<${localPath.absolute}>`;\n }\n hasDependencyOwnedPath = true;\n return `${flags}relative<${pathWithoutFlags}>`;\n });\n\n if (components.length === 0) {\n return undefined;\n }\n\n return {\n patchedIdent: options.patchedIdent,\n source,\n components,\n parentLocator:\n parent.locator ??\n (hasProjectRelativePath ? options.parentLocator : undefined),\n canMatchManifest: !hasDependencyOwnedPath,\n projectOwned:\n paths.length > 0 ||\n (options.origin === 'manifest' && !hasDependencyOwnedPath),\n paths,\n location: options.location,\n };\n}\n\nfunction declarationKey(declaration: PatchDeclaration): string {\n return `${declaration.parentLocator ?? ''}\\0${declaration.patchedIdent}\\0${\n declaration.source\n }\\0${declaration.components.join('\\0')}`;\n}\n\nfunction declarationDescription(declaration: PatchDeclaration): string {\n return declaration.paths.map(patchPath => patchPath.relative).join(', ');\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null;\n}\n\nfunction isYarnPluginsKey(key: string): boolean {\n return key.toLowerCase() === 'yarn_plugins';\n}\n\nfunction setEnvironmentValue(key: string, value: string | undefined): void {\n if (value === undefined) {\n delete process.env[key];\n } else {\n process.env[key] = value;\n }\n}\n\nasync function withConfigurationEnvironment<T>(\n env: NodeJS.ProcessEnv | undefined,\n action: () => Promise<T>,\n): Promise<T> {\n const waitForTurn = configurationEnvironmentQueue;\n let releaseTurn = () => {};\n const turnComplete = new Promise<void>(resolve => {\n releaseTurn = resolve;\n });\n configurationEnvironmentQueue = waitForTurn.then(() => turnComplete);\n await waitForTurn;\n\n const environmentState = new Map<\n string,\n { previous: string | undefined; applied: string | undefined }\n >();\n\n try {\n const targetEnvironment = env ? { ...env } : undefined;\n if (targetEnvironment) {\n for (const key of Object.keys(targetEnvironment)) {\n if (isYarnPluginsKey(key)) {\n delete targetEnvironment[key];\n }\n }\n }\n\n const keysToScope = new Set(\n targetEnvironment\n ? [...Object.keys(process.env), ...Object.keys(env ?? {})]\n : Object.keys(process.env).filter(isYarnPluginsKey),\n );\n for (const key of keysToScope) {\n const previous = process.env[key];\n const applied = isYarnPluginsKey(key)\n ? undefined\n : targetEnvironment?.[key];\n environmentState.set(key, { previous, applied });\n setEnvironmentValue(key, applied);\n }\n\n return await action();\n } finally {\n for (const [key, { previous, applied }] of environmentState) {\n // Keep values changed by unrelated async work while Yarn was loading.\n if (process.env[key] === applied) {\n setEnvironmentValue(key, previous);\n }\n }\n releaseTurn();\n }\n}\n\nfunction arraysEqual(left: string[], right: string[]): boolean {\n return (\n left.length === right.length &&\n left.every((value, index) => value === right[index])\n );\n}\n\nfunction getNpmResolutionRange(\n range: ReturnType<typeof structUtils.parseRange>,\n): string | undefined {\n if (\n range.protocol === 'npm:' &&\n semverUtils.validRange(range.selector) !== null\n ) {\n return range.selector;\n }\n\n const npmVersion = range.params?.npm;\n if (\n range.protocol === 'backstage:' &&\n range.selector === '^' &&\n typeof npmVersion === 'string' &&\n semverUtils.clean(npmVersion) !== null\n ) {\n return `^${npmVersion}`;\n }\n\n return undefined;\n}\n\nfunction normalizeNpmAliasSource(descriptor: Descriptor): Descriptor {\n const range = structUtils.parseRange(descriptor.range);\n if (range.protocol !== 'npm:') {\n return descriptor;\n }\n\n const aliasTarget = structUtils.tryParseDescriptor(range.selector, true);\n if (!aliasTarget) {\n return descriptor;\n }\n\n const aliasTargetRange = structUtils.parseRange(aliasTarget.range);\n return aliasTargetRange.protocol === null\n ? structUtils.makeDescriptor(aliasTarget, `npm:${aliasTarget.range}`)\n : aliasTarget;\n}\n\nfunction npmSourceAgrees(\n descriptorRange: ReturnType<typeof structUtils.parseRange>,\n locatorRange: ReturnType<typeof structUtils.parseRange>,\n): boolean | undefined {\n if (locatorRange.protocol !== 'npm:') {\n return undefined;\n }\n\n const resolvedVersion = semverUtils.clean(locatorRange.selector);\n if (resolvedVersion === null) {\n return false;\n }\n\n const resolutionRange = getNpmResolutionRange(descriptorRange);\n if (resolutionRange !== undefined) {\n return semverUtils.satisfiesWithPrereleases(\n resolvedVersion,\n resolutionRange,\n );\n }\n\n return descriptorRange.protocol === 'npm:'\n ? TAG_REGEXP.test(descriptorRange.selector)\n : undefined;\n}\n\nfunction nonNpmSourceAgrees(\n descriptorRange: ReturnType<typeof structUtils.parseRange>,\n locatorRange: ReturnType<typeof structUtils.parseRange>,\n): boolean {\n if (descriptorRange.protocol !== locatorRange.protocol) {\n return false;\n }\n\n if (descriptorRange.protocol === 'workspace:') {\n const selector = descriptorRange.selector;\n if (\n selector === '*' ||\n selector === '^' ||\n selector === '~' ||\n semverUtils.validRange(selector) !== null\n ) {\n return true;\n }\n }\n\n const descriptorIdentity = descriptorRange.source ?? descriptorRange.selector;\n const locatorIdentity = locatorRange.source ?? locatorRange.selector;\n if (descriptorIdentity !== locatorIdentity) {\n return false;\n }\n\n const descriptorParent = descriptorRange.params?.locator;\n if (\n typeof descriptorParent === 'string' &&\n descriptorParent !== locatorRange.params?.locator\n ) {\n return false;\n }\n\n if (\n descriptorRange.source !== null &&\n descriptorRange.selector.startsWith('commit=')\n ) {\n return descriptorRange.selector === locatorRange.selector;\n }\n\n return true;\n}\n\nfunction patchDescriptorAgreesWithLocator(options: {\n configuration: Configuration;\n descriptor: ReturnType<typeof structUtils.parseDescriptor>;\n descriptorDeclaration: PatchDeclaration | undefined;\n locator: ReturnType<typeof structUtils.parseLocator>;\n locatorDeclaration: PatchDeclaration | undefined;\n}): boolean {\n if (!structUtils.areIdentsEqual(options.descriptor, options.locator)) {\n return false;\n }\n\n const descriptorRange = structUtils.parseRange(options.descriptor.range, {\n requireProtocol: 'patch:',\n requireSource: true,\n });\n const locatorRange = structUtils.parseRange(options.locator.reference, {\n requireProtocol: 'patch:',\n requireSource: true,\n });\n const sourceDescriptor = normalizeNpmAliasSource(\n options.configuration.normalizeDependency(\n structUtils.parseDescriptor(descriptorRange.source, true),\n ),\n );\n const sourceLocator = structUtils.parseLocator(locatorRange.source, true);\n if (!structUtils.areIdentsEqual(sourceDescriptor, sourceLocator)) {\n return false;\n }\n\n const descriptorSourceRange = structUtils.parseRange(sourceDescriptor.range);\n const locatorSourceRange = structUtils.parseRange(sourceLocator.reference);\n const npmAgreement = npmSourceAgrees(\n descriptorSourceRange,\n locatorSourceRange,\n );\n if (\n npmAgreement === false ||\n (npmAgreement === undefined &&\n !nonNpmSourceAgrees(descriptorSourceRange, locatorSourceRange))\n ) {\n return false;\n }\n\n return (\n options.descriptorDeclaration?.parentLocator ===\n options.locatorDeclaration?.parentLocator &&\n arraysEqual(\n options.descriptorDeclaration?.components ?? [],\n options.locatorDeclaration?.components ?? [],\n )\n );\n}\n\nasync function discoverManifestDeclarations(\n rootDir: string,\n configuration: Configuration,\n errors: PatchVerificationError[],\n): Promise<{\n patchDeclarations: PatchDeclaration[];\n resolutionDeclarations: ResolutionDeclaration[];\n}> {\n const project = new Project(npath.toPortablePath(rootDir), { configuration });\n const pendingWorkspaces = [npath.toPortablePath(rootDir)];\n const visitedWorkspaces = new Set<string>();\n const patchDeclarations: PatchDeclaration[] = [];\n const resolutionDeclarations: ResolutionDeclaration[] = [];\n\n while (pendingWorkspaces.length > 0) {\n const workspaceCwd = pendingWorkspaces.shift();\n if (workspaceCwd === undefined || visitedWorkspaces.has(workspaceCwd)) {\n continue;\n }\n visitedWorkspaces.add(workspaceCwd);\n\n const workspace = new Workspace(workspaceCwd, { project });\n await workspace.setup();\n pendingWorkspaces.push(...workspace.workspacesCwds);\n\n const manifestDir = npath.fromPortablePath(workspace.cwd);\n const manifestPath = relativePath(\n rootDir,\n path.join(manifestDir, 'package.json'),\n );\n const manifestJson: Record<string, unknown> = workspace.manifest.raw;\n const parentLocator = structUtils.stringifyLocator(\n workspace.anchoredLocator,\n );\n\n for (const field of MANIFEST_FIELDS) {\n const entries = manifestJson[field];\n if (typeof entries !== 'object' || entries === null) {\n continue;\n }\n\n for (const [name, range] of Object.entries(entries)) {\n if (\n field === 'resolutions' &&\n workspace.cwd === project.cwd &&\n typeof range === 'string'\n ) {\n resolutionDeclarations.push({\n pattern: name,\n location: `${manifestPath}#${field}.${name}`,\n });\n }\n if (typeof range !== 'string' || !range.startsWith('patch:')) {\n continue;\n }\n\n const location = `${manifestPath}#${field}.${name}`;\n try {\n const declaration = parsePatchDeclaration({\n rootDir,\n parentDir: manifestDir,\n parentLocator,\n patchedIdent:\n field === 'resolutions'\n ? parseResolution(name).descriptor.fullName\n : structUtils.stringifyIdent(structUtils.parseIdent(name)),\n range,\n location,\n origin: 'manifest',\n });\n if (declaration) {\n patchDeclarations.push(declaration);\n }\n } catch (error) {\n errors.push({\n kind: 'malformed-patch-reference',\n message: `Invalid patch reference for '${name}' in ${field}: ${String(\n error,\n )}`,\n location,\n });\n }\n }\n }\n }\n\n return { patchDeclarations, resolutionDeclarations };\n}\n\nfunction parseLockfile(\n lockfileContent: string,\n errors: PatchVerificationError[],\n): Record<string, unknown> | undefined {\n try {\n return parseSyml(lockfileContent);\n } catch (error) {\n errors.push({\n kind: 'malformed-lockfile',\n message: `Failed to parse yarn.lock: ${String(error)}`,\n location: 'yarn.lock',\n });\n return undefined;\n }\n}\n\nfunction discoverLockfileDeclarations(\n rootDir: string,\n configuration: Configuration,\n lockfileData: Record<string, unknown>,\n errors: PatchVerificationError[],\n): PatchDeclaration[] {\n const declarations: PatchDeclaration[] = [];\n for (const [key, lockfileEntry] of Object.entries(lockfileData)) {\n if (key === '__metadata') {\n continue;\n }\n\n const patchDescriptors: Array<{\n descriptor: ReturnType<typeof structUtils.parseDescriptor>;\n declaration: PatchDeclaration | undefined;\n }> = [];\n for (const entry of key.split(', ')) {\n try {\n const descriptor = structUtils.parseDescriptor(entry, true);\n if (!descriptor.range.startsWith('patch:')) {\n continue;\n }\n const declaration = parsePatchDeclaration({\n rootDir,\n parentDir: rootDir,\n patchedIdent: structUtils.stringifyIdent(descriptor),\n range: descriptor.range,\n location: 'yarn.lock',\n origin: 'lockfile',\n });\n if (declaration?.canMatchManifest) {\n declarations.push(declaration);\n }\n patchDescriptors.push({ descriptor, declaration });\n } catch (error) {\n errors.push({\n kind: 'malformed-lockfile',\n message: `Invalid patch entry '${entry}' in yarn.lock: ${String(\n error,\n )}`,\n location: 'yarn.lock',\n });\n }\n }\n\n if (patchDescriptors.length === 0) {\n continue;\n }\n\n const resolution = isRecord(lockfileEntry)\n ? lockfileEntry.resolution\n : undefined;\n if (typeof resolution !== 'string') {\n errors.push({\n kind: 'malformed-lockfile',\n message: `Patch entry '${key}' is missing its resolution locator`,\n location: 'yarn.lock',\n });\n continue;\n }\n\n try {\n const locator = structUtils.parseLocator(resolution, true);\n if (!locator.reference.startsWith('patch:')) {\n errors.push({\n kind: 'lockfile-mismatch',\n message: `Patch entry '${key}' disagrees with its resolution locator '${resolution}'`,\n location: 'yarn.lock',\n });\n continue;\n }\n const locatorDeclaration = parsePatchDeclaration({\n rootDir,\n parentDir: rootDir,\n patchedIdent: structUtils.stringifyIdent(locator),\n range: locator.reference,\n location: 'yarn.lock',\n origin: 'lockfile',\n });\n const locatorRange = structUtils.parseRange(locator.reference, {\n requireProtocol: 'patch:',\n requireSource: true,\n });\n const resolvedSource = structUtils.stringifyLocator(\n structUtils.parseLocator(locatorRange.source, true),\n );\n for (const { declaration } of patchDescriptors) {\n if (declaration) {\n declaration.resolvedSource = resolvedSource;\n }\n }\n if (\n patchDescriptors.some(\n ({ descriptor, declaration }) =>\n !patchDescriptorAgreesWithLocator({\n configuration,\n descriptor,\n descriptorDeclaration: declaration,\n locator,\n locatorDeclaration,\n }),\n )\n ) {\n errors.push({\n kind: 'lockfile-mismatch',\n message: `Patch entry '${key}' disagrees with its resolution locator '${resolution}'`,\n location: 'yarn.lock',\n });\n }\n } catch (error) {\n errors.push({\n kind: 'malformed-lockfile',\n message: `Patch entry '${key}' has an invalid resolution locator '${resolution}': ${String(\n error,\n )}`,\n location: 'yarn.lock',\n });\n }\n }\n\n return declarations;\n}\n\nfunction getLockfileLocator(\n lockfileEntry: Record<string, unknown>,\n configuration: Configuration,\n): ReturnType<typeof structUtils.parseLocator> | undefined {\n if (typeof lockfileEntry.resolution !== 'string') {\n return undefined;\n }\n try {\n return configuration.normalizeLocator(\n structUtils.parseLocator(lockfileEntry.resolution, true),\n );\n } catch {\n return undefined;\n }\n}\n\nfunction resolutionMatchesDependency(options: {\n resolution: ReturnType<typeof parseResolution>;\n dependencyName: string;\n dependencyRange: string;\n parentLocator: ReturnType<typeof structUtils.parseLocator> | undefined;\n configuration: Configuration;\n}): boolean {\n const { resolution, configuration, parentLocator } = options;\n if (resolution.from) {\n if (\n parentLocator === undefined ||\n resolution.from.fullName !== structUtils.stringifyIdent(parentLocator)\n ) {\n return false;\n }\n const normalizedFrom = configuration.normalizeLocator(\n structUtils.makeLocator(\n structUtils.parseIdent(resolution.from.fullName),\n resolution.from.description ?? parentLocator.reference,\n ),\n );\n if (normalizedFrom.locatorHash !== parentLocator.locatorHash) {\n return false;\n }\n }\n\n const dependency = configuration.normalizeDependency(\n structUtils.makeDescriptor(\n structUtils.parseIdent(options.dependencyName),\n options.dependencyRange,\n ),\n );\n if (\n resolution.descriptor.fullName !== structUtils.stringifyIdent(dependency)\n ) {\n return false;\n }\n const normalizedDescriptor = configuration.normalizeDependency(\n structUtils.makeDescriptor(\n structUtils.parseIdent(resolution.descriptor.fullName),\n resolution.descriptor.description ?? dependency.range,\n ),\n );\n return normalizedDescriptor.descriptorHash === dependency.descriptorHash;\n}\n\nfunction validateResolutions(options: {\n declarations: ResolutionDeclaration[];\n lockfileData: Record<string, unknown>;\n configuration: Configuration;\n}): {\n errors: PatchVerificationError[];\n unusedLocations: Set<string>;\n} {\n const lockfileEntries = Object.entries(options.lockfileData)\n .filter(([key, value]) => key !== '__metadata' && isRecord(value))\n .map(([, value]) => ({\n entry: value as Record<string, unknown>,\n parentLocator: getLockfileLocator(\n value as Record<string, unknown>,\n options.configuration,\n ),\n }));\n const hasRootWorkspace = lockfileEntries.some(\n ({ parentLocator }) => parentLocator?.reference === 'workspace:.',\n );\n // Without the root workspace entry, the lockfile does not contain the\n // complete project dependency graph, so absence cannot prove that a\n // resolution is unused.\n if (!hasRootWorkspace) {\n return { errors: [], unusedLocations: new Set() };\n }\n\n const errors: PatchVerificationError[] = [];\n const unusedLocations = new Set<string>();\n for (const declaration of options.declarations) {\n let resolution;\n try {\n resolution = parseResolution(declaration.pattern);\n } catch {\n continue;\n }\n\n const matches = lockfileEntries.some(({ entry, parentLocator }) => {\n return ['dependencies', 'optionalDependencies'].some(field => {\n const dependencies = entry[field];\n if (!isRecord(dependencies)) {\n return false;\n }\n return Object.entries(dependencies).some(\n ([dependencyName, dependencyRange]) => {\n if (typeof dependencyRange !== 'string') {\n return false;\n }\n try {\n return resolutionMatchesDependency({\n resolution,\n dependencyName,\n dependencyRange,\n parentLocator,\n configuration: options.configuration,\n });\n } catch {\n return false;\n }\n },\n );\n });\n });\n if (!matches) {\n unusedLocations.add(declaration.location);\n errors.push({\n kind: 'unused-resolution',\n message: `Resolution '${declaration.pattern}' does not match any dependency request in yarn.lock`,\n location: declaration.location,\n });\n }\n }\n return { errors, unusedLocations };\n}\n\nasync function readYarnConfiguration(\n rootDir: string,\n env: NodeJS.ProcessEnv | undefined,\n): Promise<Configuration> {\n return withConfigurationEnvironment(env, async () => {\n // Yarn still applies inherited rc files when useRc is false; this only\n // prevents project rc files from loading arbitrary third-party plugins.\n return Configuration.find(\n npath.toPortablePath(rootDir),\n PATCH_PLUGIN_CONFIGURATION,\n {\n strict: false,\n useRc: false,\n },\n );\n });\n}\n\nasync function findPatchFiles(\n directory: string,\n realpathAncestry: ReadonlySet<string> = new Set(),\n): Promise<string[]> {\n let realDirectory;\n try {\n realDirectory = await fs.realpath(directory);\n } catch (error) {\n if (isErrorWithCode(error, 'ENOENT')) {\n return [];\n }\n throw error;\n }\n if (realpathAncestry.has(realDirectory)) {\n return [];\n }\n const nextAncestry = new Set(realpathAncestry).add(realDirectory);\n\n let entries;\n try {\n entries = await fs.readdir(directory, { withFileTypes: true });\n } catch (error) {\n if (isErrorWithCode(error, 'ENOENT')) {\n return [];\n }\n throw error;\n }\n\n const files = await Promise.all(\n entries.map(async entry => {\n const entryPath = path.join(directory, entry.name);\n if (entry.isDirectory()) {\n return findPatchFiles(entryPath, nextAncestry);\n }\n if (entry.isSymbolicLink()) {\n try {\n const targetStats = await fs.stat(entryPath);\n if (targetStats.isDirectory()) {\n return findPatchFiles(entryPath, nextAncestry);\n }\n } catch (error) {\n if (!isErrorWithCode(error, 'ENOENT')) {\n throw error;\n }\n }\n return [entryPath];\n }\n return entry.isFile() ? [entryPath] : [];\n }),\n );\n return files.flat().sort();\n}\n\nfunction uniqueDeclarations(\n declarations: PatchDeclaration[],\n): Map<string, PatchDeclaration> {\n const unique = new Map<string, PatchDeclaration>();\n for (const declaration of declarations) {\n const key = declarationKey(declaration);\n if (!unique.has(key)) {\n unique.set(key, declaration);\n }\n }\n return unique;\n}\n\nfunction getPatchedBackstagePackages(\n declarations: Iterable<PatchDeclaration>,\n): PatchedBackstagePackage[] {\n const packages: PatchedBackstagePackage[] = [];\n for (const declaration of declarations) {\n const declaredSource = normalizeNpmAliasSource(\n structUtils.parseDescriptor(declaration.source, true),\n );\n const resolvedSource = declaration.resolvedSource;\n const source = resolvedSource\n ? structUtils.parseLocator(resolvedSource, true)\n : declaredSource;\n if (source.scope !== 'backstage') {\n continue;\n }\n const range = structUtils.parseRange(\n 'reference' in source ? source.reference : source.range,\n );\n if (\n range.protocol !== 'npm:' ||\n semverUtils.clean(range.selector) === null\n ) {\n continue;\n }\n packages.push({\n name: structUtils.stringifyIdent(source),\n version: range.selector,\n location: declaration.location,\n });\n }\n return packages;\n}\n\nfunction isReleaseManifest(value: unknown): value is ReleaseManifest {\n return (\n isRecord(value) &&\n typeof value.releaseVersion === 'string' &&\n Array.isArray(value.packages) &&\n value.packages.every(\n packageEntry =>\n isRecord(packageEntry) &&\n typeof packageEntry.name === 'string' &&\n typeof packageEntry.version === 'string',\n )\n );\n}\n\nasync function readBackstageVersion(\n rootDir: string,\n): Promise<string | undefined> {\n try {\n const backstageJson: unknown = JSON.parse(\n await fs.readFile(path.join(rootDir, 'backstage.json'), 'utf8'),\n );\n if (!isRecord(backstageJson) || typeof backstageJson.version !== 'string') {\n throw new Error(\n \"backstage.json must contain a string 'version' property\",\n );\n }\n return backstageJson.version;\n } catch (error) {\n if (isErrorWithCode(error, 'ENOENT')) {\n return undefined;\n }\n throw error;\n }\n}\n\nasync function loadReleaseManifest(options: {\n backstageVersion: string;\n configuration: Configuration;\n env: NodeJS.ProcessEnv | undefined;\n fetch: typeof globalThis.fetch | undefined;\n}): Promise<ReleaseManifest> {\n const manifestFile = options.env?.BACKSTAGE_MANIFEST_FILE;\n const fetch =\n options.fetch ??\n (async (url: string) => {\n const manifest = await httpUtils.get(url, {\n configuration: options.configuration,\n jsonResponse: true,\n });\n return {\n status: 200,\n url,\n json: async () => manifest,\n };\n });\n const manifest: unknown = manifestFile\n ? JSON.parse(await fs.readFile(manifestFile, 'utf8'))\n : await getManifestByVersion({\n version: options.backstageVersion,\n versionsBaseUrl: options.env?.BACKSTAGE_VERSIONS_BASE_URL,\n fetch,\n });\n if (!isReleaseManifest(manifest)) {\n throw new Error('Backstage release manifest has an invalid format');\n }\n if (manifest.releaseVersion !== options.backstageVersion) {\n throw new Error(\n `Backstage release manifest version '${manifest.releaseVersion}' does not match selected version '${options.backstageVersion}'`,\n );\n }\n return manifest;\n}\n\nasync function validateBackstagePatches(options: {\n rootDir: string;\n declarations: Iterable<PatchDeclaration>;\n configuration: Configuration;\n env: NodeJS.ProcessEnv | undefined;\n fetch: typeof globalThis.fetch | undefined;\n}): Promise<{\n backstageCheck: VerifyYarnPatchesResult['backstageCheck'];\n errors: PatchVerificationError[];\n}> {\n const patchedPackages = getPatchedBackstagePackages(options.declarations);\n if (patchedPackages.length === 0) {\n return { backstageCheck: 'skipped', errors: [] };\n }\n\n let backstageVersion: string | undefined;\n try {\n backstageVersion = await readBackstageVersion(options.rootDir);\n } catch (error) {\n return {\n backstageCheck: 'verified',\n errors: [\n {\n kind: 'backstage-manifest-load-failure',\n message: `Failed to read Backstage release version: ${String(error)}`,\n location: 'backstage.json',\n },\n ],\n };\n }\n if (backstageVersion === undefined) {\n return { backstageCheck: 'skipped', errors: [] };\n }\n\n let releaseManifest: ReleaseManifest;\n try {\n releaseManifest = await loadReleaseManifest({\n backstageVersion,\n configuration: options.configuration,\n env: options.env,\n fetch: options.fetch,\n });\n } catch (error) {\n return {\n backstageCheck: 'verified',\n errors: [\n {\n kind: 'backstage-manifest-load-failure',\n message: `Failed to load Backstage release manifest for '${backstageVersion}': ${String(\n error,\n )}`,\n location: 'backstage.json',\n },\n ],\n };\n }\n\n const packageVersions = new Map(\n releaseManifest.packages.map(packageEntry => [\n packageEntry.name,\n packageEntry.version,\n ]),\n );\n const errors: PatchVerificationError[] = [];\n for (const patchedPackage of patchedPackages) {\n const releaseVersion = packageVersions.get(patchedPackage.name);\n if (releaseVersion === undefined) {\n errors.push({\n kind: 'backstage-package-missing',\n message: `Patched package '${patchedPackage.name}' is absent from Backstage release '${backstageVersion}'`,\n location: patchedPackage.location,\n });\n } else if (releaseVersion !== patchedPackage.version) {\n errors.push({\n kind: 'backstage-patch-holdback',\n message: `Patched package '${patchedPackage.name}' is at version '${patchedPackage.version}', but Backstage release '${backstageVersion}' requires version '${releaseVersion}'`,\n location: patchedPackage.location,\n });\n }\n }\n\n return { backstageCheck: 'verified', errors };\n}\n\nexport async function verifyYarnPatches(\n options: VerifyYarnPatchesOptions,\n): Promise<VerifyYarnPatchesResult> {\n const rootDir = path.resolve(options.rootDir);\n const errors: PatchVerificationError[] = [];\n const configuration = await readYarnConfiguration(rootDir, options.env);\n const { patchDeclarations, resolutionDeclarations } =\n await discoverManifestDeclarations(rootDir, configuration, errors);\n\n let lockfileData: Record<string, unknown> | undefined;\n try {\n const lockfileContent = await fs.readFile(\n path.join(rootDir, 'yarn.lock'),\n 'utf8',\n );\n lockfileData = parseLockfile(lockfileContent, errors);\n } catch (error) {\n if (!isErrorWithCode(error, 'ENOENT')) {\n throw error;\n }\n errors.push({\n kind: 'missing-lockfile',\n message: 'No yarn.lock found',\n location: 'yarn.lock',\n });\n }\n\n let unusedResolutionLocations = new Set<string>();\n if (lockfileData !== undefined) {\n const resolutionValidation = validateResolutions({\n declarations: resolutionDeclarations,\n lockfileData,\n configuration,\n });\n errors.push(...resolutionValidation.errors);\n unusedResolutionLocations = resolutionValidation.unusedLocations;\n }\n\n const manifestDeclaredPatchFiles = new Set(\n patchDeclarations.flatMap(declaration =>\n declaration.paths.map(patchPath => patchPath.absolute),\n ),\n );\n const uniqueManifestDeclarations = uniqueDeclarations(\n patchDeclarations.filter(\n declaration => !unusedResolutionLocations.has(declaration.location),\n ),\n );\n const referencedPatchFiles = new Map<string, LocalPatchPath>();\n\n for (const declaration of uniqueManifestDeclarations.values()) {\n for (const patchPath of declaration.paths) {\n referencedPatchFiles.set(patchPath.absolute, patchPath);\n }\n }\n\n for (const [absolute, patchPath] of referencedPatchFiles) {\n try {\n const stats = await fs.stat(absolute);\n if (!stats.isFile()) {\n errors.push({\n kind: 'missing-patch-file',\n message: `Patch path '${patchPath.relative}' is not a regular file`,\n location: patchPath.relative,\n });\n }\n } catch (error) {\n if (!isErrorWithCode(error, 'ENOENT')) {\n throw error;\n }\n errors.push({\n kind: 'missing-patch-file',\n message: `Patch file '${patchPath.relative}' does not exist`,\n location: patchPath.relative,\n });\n }\n }\n\n const patchFolder = npath.fromPortablePath(configuration.get('patchFolder'));\n const patchFiles = await findPatchFiles(patchFolder);\n for (const patchFile of patchFiles) {\n if (!manifestDeclaredPatchFiles.has(patchFile)) {\n const relative = relativePath(rootDir, patchFile);\n errors.push({\n kind: 'orphaned-patch-file',\n message: `Patch file '${relative}' is not referenced by any manifest`,\n location: relative,\n });\n }\n }\n\n if (lockfileData !== undefined) {\n const lockfileDeclarations = uniqueDeclarations(\n discoverLockfileDeclarations(\n rootDir,\n configuration,\n lockfileData,\n errors,\n ),\n );\n\n for (const [key, declaration] of uniqueManifestDeclarations) {\n const lockfileDeclaration = lockfileDeclarations.get(key);\n if (!lockfileDeclaration) {\n errors.push({\n kind: 'lockfile-mismatch',\n message: `Patch declaration for '${\n declaration.source\n }' using '${declarationDescription(\n declaration,\n )}' is missing from yarn.lock`,\n location: declaration.location,\n });\n } else {\n declaration.resolvedSource = lockfileDeclaration.resolvedSource;\n }\n }\n\n for (const [key, declaration] of lockfileDeclarations) {\n if (declaration.projectOwned && !uniqueManifestDeclarations.has(key)) {\n errors.push({\n kind: 'lockfile-mismatch',\n message: `yarn.lock contains patch declaration for '${\n declaration.source\n }' using '${declarationDescription(\n declaration,\n )}' that is absent from manifests`,\n location: 'yarn.lock',\n });\n }\n }\n }\n\n const sourcesByPatchFile = new Map<string, Set<string>>();\n for (const declaration of uniqueManifestDeclarations.values()) {\n for (const patchPath of declaration.paths) {\n let sources = sourcesByPatchFile.get(patchPath.absolute);\n if (!sources) {\n sources = new Set();\n sourcesByPatchFile.set(patchPath.absolute, sources);\n }\n sources.add(declaration.resolvedSource ?? declaration.source);\n }\n }\n\n for (const [absolute, sources] of sourcesByPatchFile) {\n if (sources.size <= 1) {\n continue;\n }\n const patchPath = referencedPatchFiles.get(absolute);\n if (!patchPath) {\n continue;\n }\n const sortedSources = [...sources].sort();\n errors.push({\n kind: 'incompatible-patch-declarations',\n message: `Patch file '${\n patchPath.relative\n }' is used for incompatible sources: ${sortedSources\n .map(source => `'${source}'`)\n .join(', ')}`,\n location: patchPath.relative,\n });\n }\n\n const backstageValidation = await validateBackstagePatches({\n rootDir,\n declarations: uniqueManifestDeclarations.values(),\n configuration,\n env: options.env,\n fetch: options.fetch,\n });\n errors.push(...backstageValidation.errors);\n\n return {\n patchCount: referencedPatchFiles.size,\n backstageCheck: backstageValidation.backstageCheck,\n errors: sortErrors(errors),\n };\n}\n"],"names":["patchPlugin","path","structUtils","npath","ppath","semverUtils","TAG_REGEXP","Project","Workspace","parseResolution","parseSyml","Configuration","fs","manifest","httpUtils","getManifestByVersion"],"mappings":";;;;;;;;;;;;;;;;AA6FA,MAAM,eAAA,GAAkB;AAAA,EACtB,aAAA;AAAA,EACA,cAAA;AAAA,EACA,iBAAA;AAAA,EACA,kBAAA;AAAA,EACA;AACF,CAAA;AAEA,MAAM,0BAAA,GAAkD;AAAA,EACtD,OAAA,sBAAa,GAAA,CAAI,CAAC,CAAC,uBAAA,EAAyBA,4BAAW,CAAC,CAAC,CAAA;AAAA,EACz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
1
|
+
{"version":3,"file":"verifyYarnPatches.cjs.js","sources":["../../src/lib/verifyYarnPatches.ts"],"sourcesContent":["/*\n * Copyright 2026 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n getManifestByVersion,\n type ReleaseManifest,\n} from '@backstage/release-manifests';\nimport {\n Configuration,\n httpUtils,\n semverUtils,\n structUtils,\n} from '@yarnpkg/core';\nimport { Project, TAG_REGEXP, Workspace } from '@yarnpkg/core';\nimport type { Descriptor, PluginConfiguration } from '@yarnpkg/core';\nimport { npath, ppath } from '@yarnpkg/fslib';\nimport { parseResolution, parseSyml } from '@yarnpkg/parsers';\nimport patchPlugin from '@yarnpkg/plugin-patch';\nimport fs from 'node:fs/promises';\nimport path from 'node:path';\n\nexport type PatchVerificationErrorKind =\n | 'backstage-manifest-load-failure'\n | 'backstage-package-missing'\n | 'backstage-patch-holdback'\n | 'incompatible-patch-declarations'\n | 'lockfile-mismatch'\n | 'malformed-lockfile'\n | 'malformed-patch-reference'\n | 'missing-lockfile'\n | 'missing-patch-file'\n | 'orphaned-patch-file'\n | 'unused-resolution';\n\nexport type PatchVerificationError = {\n kind: PatchVerificationErrorKind;\n message: string;\n location?: string;\n repairHint?: PatchHoldbackFix;\n};\n\nexport type VerifyYarnPatchesOptions = {\n rootDir: string;\n env?: NodeJS.ProcessEnv;\n fetch?: typeof globalThis.fetch;\n};\n\nexport type VerifyYarnPatchesResult = {\n patchCount: number;\n backstageCheck: 'verified' | 'skipped';\n errors: PatchVerificationError[];\n};\n\nexport type PatchDeclaration = {\n patchedIdent: string;\n reference: string;\n source: string;\n resolvedSource?: string;\n components: string[];\n parentLocator?: string;\n canMatchManifest: boolean;\n projectOwned: boolean;\n paths: LocalPatchPath[];\n location: string;\n};\n\nexport type LocalPatchPath = {\n absolute: string;\n relative: string;\n};\n\ntype PatchedBackstagePackage = {\n name: string;\n version: string;\n location: string;\n declaration: PatchDeclaration;\n};\n\nexport type PatchHoldbackFix = {\n packageName: string;\n currentVersion: string;\n targetVersion: string;\n declaration: PatchDeclaration;\n};\n\ntype ResolutionDeclaration = {\n pattern: string;\n location: string;\n};\n\nconst MANIFEST_FIELDS = [\n 'resolutions',\n 'dependencies',\n 'devDependencies',\n 'peerDependencies',\n 'optionalDependencies',\n] as const;\n\nconst PATCH_PLUGIN_CONFIGURATION: PluginConfiguration = {\n modules: new Map([['@yarnpkg/plugin-patch', patchPlugin]]),\n plugins: new Set(['@yarnpkg/plugin-patch']),\n};\n\n// Yarn Configuration.find has no environment parameter and reads process.env.\n// Serialize the narrow overlay so concurrent verifications cannot interleave.\nlet configurationEnvironmentQueue = Promise.resolve();\n\nfunction relativePath(rootDir: string, targetPath: string): string {\n return path.relative(rootDir, targetPath).split(path.sep).join('/');\n}\n\nfunction compareStrings(left: string, right: string): number {\n if (left < right) {\n return -1;\n }\n if (left > right) {\n return 1;\n }\n return 0;\n}\n\nfunction sortErrors(\n errors: PatchVerificationError[],\n): PatchVerificationError[] {\n return errors.sort((left, right) => {\n return (\n compareStrings(left.location ?? '', right.location ?? '') ||\n compareStrings(left.kind, right.kind) ||\n compareStrings(left.message, right.message)\n );\n });\n}\n\nfunction isErrorWithCode(error: unknown, code: string): boolean {\n return (\n typeof error === 'object' &&\n error !== null &&\n 'code' in error &&\n error.code === code\n );\n}\n\nfunction getPatchPathWithoutFlags(patchPath: string): string {\n if (patchPath.startsWith('~builtin<')) {\n return patchPath.slice(1);\n }\n const flagIndex = patchPath.lastIndexOf('!');\n return flagIndex === -1 ? patchPath : patchPath.slice(flagIndex + 1);\n}\n\nfunction isBuiltinPatchPath(patchPath: string): boolean {\n const pathWithoutFlags = getPatchPathWithoutFlags(patchPath);\n return (\n pathWithoutFlags.startsWith('builtin<') && pathWithoutFlags.endsWith('>')\n );\n}\n\ntype PatchParent = {\n directory?: string;\n locator?: string;\n};\n\nfunction getPatchParent(\n rootDir: string,\n fallbackDir: string,\n locatorValue: unknown,\n): PatchParent {\n if (typeof locatorValue !== 'string') {\n return { directory: fallbackDir };\n }\n\n const parentLocator = structUtils.parseLocator(locatorValue, true);\n const locator = structUtils.stringifyLocator(parentLocator);\n const parentRange = structUtils.parseRange(parentLocator.reference);\n if (parentRange.protocol !== 'workspace:') {\n return { locator };\n }\n\n return {\n directory: path.resolve(rootDir, parentRange.selector),\n locator,\n };\n}\n\nfunction resolvePatchPath(\n rootDir: string,\n parentDir: string | undefined,\n patchPath: string,\n): LocalPatchPath | undefined {\n const pathWithoutFlags = getPatchPathWithoutFlags(patchPath);\n if (isBuiltinPatchPath(pathWithoutFlags)) {\n return undefined;\n }\n\n const portablePatchPath = npath.toPortablePath(pathWithoutFlags);\n let absolute: string | undefined;\n if (pathWithoutFlags.startsWith('~/')) {\n absolute = path.resolve(rootDir, pathWithoutFlags.slice(2));\n } else if (ppath.isAbsolute(portablePatchPath)) {\n absolute = npath.fromPortablePath(portablePatchPath);\n } else if (parentDir !== undefined) {\n absolute = path.resolve(parentDir, pathWithoutFlags);\n }\n if (absolute === undefined) {\n return undefined;\n }\n return {\n absolute,\n relative: relativePath(rootDir, absolute),\n };\n}\n\nfunction parsePatchDeclaration(options: {\n rootDir: string;\n parentDir: string;\n parentLocator?: string;\n patchedIdent: string;\n range: string;\n location: string;\n origin: 'manifest' | 'lockfile';\n}): PatchDeclaration | undefined {\n const parsedRange = structUtils.parseRange(options.range, {\n requireProtocol: 'patch:',\n requireSource: true,\n });\n const sourceDescriptor = structUtils.parseDescriptor(\n parsedRange.source,\n true,\n );\n const source = structUtils.stringifyDescriptor(sourceDescriptor);\n const parent = getPatchParent(\n options.rootDir,\n options.parentDir,\n parsedRange.params?.locator,\n );\n const paths: LocalPatchPath[] = [];\n let hasDependencyOwnedPath = false;\n let hasProjectRelativePath = false;\n const patchPaths =\n parsedRange.selector === '' ? [] : parsedRange.selector.split('&');\n const components = patchPaths.map(patchPath => {\n const flagIndex = patchPath.lastIndexOf('!');\n const flags = flagIndex === -1 ? '' : patchPath.slice(0, flagIndex + 1);\n const pathWithoutFlags = getPatchPathWithoutFlags(patchPath);\n if (isBuiltinPatchPath(patchPath)) {\n return patchPath;\n }\n\n const localPath = resolvePatchPath(\n options.rootDir,\n parent.directory,\n patchPath,\n );\n if (localPath) {\n paths.push(localPath);\n if (\n !pathWithoutFlags.startsWith('~/') &&\n !ppath.isAbsolute(npath.toPortablePath(pathWithoutFlags))\n ) {\n hasProjectRelativePath = true;\n }\n return `${flags}local<${localPath.absolute}>`;\n }\n hasDependencyOwnedPath = true;\n return `${flags}relative<${pathWithoutFlags}>`;\n });\n\n if (components.length === 0) {\n return undefined;\n }\n\n return {\n patchedIdent: options.patchedIdent,\n reference: options.range,\n source,\n components,\n parentLocator:\n parent.locator ??\n (hasProjectRelativePath ? options.parentLocator : undefined),\n canMatchManifest: !hasDependencyOwnedPath,\n projectOwned:\n paths.length > 0 ||\n (options.origin === 'manifest' && !hasDependencyOwnedPath),\n paths,\n location: options.location,\n };\n}\n\nfunction declarationKey(declaration: PatchDeclaration): string {\n return `${declaration.parentLocator ?? ''}\\0${declaration.patchedIdent}\\0${\n declaration.source\n }\\0${declaration.components.join('\\0')}`;\n}\n\nfunction declarationDescription(declaration: PatchDeclaration): string {\n return declaration.paths.map(patchPath => patchPath.relative).join(', ');\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null;\n}\n\nfunction isYarnPluginsKey(key: string): boolean {\n return key.toLowerCase() === 'yarn_plugins';\n}\n\nfunction setEnvironmentValue(key: string, value: string | undefined): void {\n if (value === undefined) {\n delete process.env[key];\n } else {\n process.env[key] = value;\n }\n}\n\nasync function withConfigurationEnvironment<T>(\n env: NodeJS.ProcessEnv | undefined,\n action: () => Promise<T>,\n): Promise<T> {\n const waitForTurn = configurationEnvironmentQueue;\n let releaseTurn = () => {};\n const turnComplete = new Promise<void>(resolve => {\n releaseTurn = resolve;\n });\n configurationEnvironmentQueue = waitForTurn.then(() => turnComplete);\n await waitForTurn;\n\n const environmentState = new Map<\n string,\n { previous: string | undefined; applied: string | undefined }\n >();\n\n try {\n const targetEnvironment = env ? { ...env } : undefined;\n if (targetEnvironment) {\n for (const key of Object.keys(targetEnvironment)) {\n if (isYarnPluginsKey(key)) {\n delete targetEnvironment[key];\n }\n }\n }\n\n const keysToScope = new Set(\n targetEnvironment\n ? [...Object.keys(process.env), ...Object.keys(env ?? {})]\n : Object.keys(process.env).filter(isYarnPluginsKey),\n );\n for (const key of keysToScope) {\n const previous = process.env[key];\n const applied = isYarnPluginsKey(key)\n ? undefined\n : targetEnvironment?.[key];\n environmentState.set(key, { previous, applied });\n setEnvironmentValue(key, applied);\n }\n\n return await action();\n } finally {\n for (const [key, { previous, applied }] of environmentState) {\n // Keep values changed by unrelated async work while Yarn was loading.\n if (process.env[key] === applied) {\n setEnvironmentValue(key, previous);\n }\n }\n releaseTurn();\n }\n}\n\nfunction arraysEqual(left: string[], right: string[]): boolean {\n return (\n left.length === right.length &&\n left.every((value, index) => value === right[index])\n );\n}\n\nfunction getNpmResolutionRange(\n range: ReturnType<typeof structUtils.parseRange>,\n): string | undefined {\n if (\n range.protocol === 'npm:' &&\n semverUtils.validRange(range.selector) !== null\n ) {\n return range.selector;\n }\n\n const npmVersion = range.params?.npm;\n if (\n range.protocol === 'backstage:' &&\n range.selector === '^' &&\n typeof npmVersion === 'string' &&\n semverUtils.clean(npmVersion) !== null\n ) {\n return `^${npmVersion}`;\n }\n\n return undefined;\n}\n\nfunction normalizeNpmAliasSource(descriptor: Descriptor): Descriptor {\n const range = structUtils.parseRange(descriptor.range);\n if (range.protocol !== 'npm:') {\n return descriptor;\n }\n\n const aliasTarget = structUtils.tryParseDescriptor(range.selector, true);\n if (!aliasTarget) {\n return descriptor;\n }\n\n const aliasTargetRange = structUtils.parseRange(aliasTarget.range);\n return aliasTargetRange.protocol === null\n ? structUtils.makeDescriptor(aliasTarget, `npm:${aliasTarget.range}`)\n : aliasTarget;\n}\n\nfunction npmSourceAgrees(\n descriptorRange: ReturnType<typeof structUtils.parseRange>,\n locatorRange: ReturnType<typeof structUtils.parseRange>,\n): boolean | undefined {\n if (locatorRange.protocol !== 'npm:') {\n return undefined;\n }\n\n const resolvedVersion = semverUtils.clean(locatorRange.selector);\n if (resolvedVersion === null) {\n return false;\n }\n\n const resolutionRange = getNpmResolutionRange(descriptorRange);\n if (resolutionRange !== undefined) {\n return semverUtils.satisfiesWithPrereleases(\n resolvedVersion,\n resolutionRange,\n );\n }\n\n return descriptorRange.protocol === 'npm:'\n ? TAG_REGEXP.test(descriptorRange.selector)\n : undefined;\n}\n\nfunction nonNpmSourceAgrees(\n descriptorRange: ReturnType<typeof structUtils.parseRange>,\n locatorRange: ReturnType<typeof structUtils.parseRange>,\n): boolean {\n if (descriptorRange.protocol !== locatorRange.protocol) {\n return false;\n }\n\n if (descriptorRange.protocol === 'workspace:') {\n const selector = descriptorRange.selector;\n if (\n selector === '*' ||\n selector === '^' ||\n selector === '~' ||\n semverUtils.validRange(selector) !== null\n ) {\n return true;\n }\n }\n\n const descriptorIdentity = descriptorRange.source ?? descriptorRange.selector;\n const locatorIdentity = locatorRange.source ?? locatorRange.selector;\n if (descriptorIdentity !== locatorIdentity) {\n return false;\n }\n\n const descriptorParent = descriptorRange.params?.locator;\n if (\n typeof descriptorParent === 'string' &&\n descriptorParent !== locatorRange.params?.locator\n ) {\n return false;\n }\n\n if (\n descriptorRange.source !== null &&\n descriptorRange.selector.startsWith('commit=')\n ) {\n return descriptorRange.selector === locatorRange.selector;\n }\n\n return true;\n}\n\nfunction patchDescriptorAgreesWithLocator(options: {\n configuration: Configuration;\n descriptor: ReturnType<typeof structUtils.parseDescriptor>;\n descriptorDeclaration: PatchDeclaration | undefined;\n locator: ReturnType<typeof structUtils.parseLocator>;\n locatorDeclaration: PatchDeclaration | undefined;\n}): boolean {\n if (!structUtils.areIdentsEqual(options.descriptor, options.locator)) {\n return false;\n }\n\n const descriptorRange = structUtils.parseRange(options.descriptor.range, {\n requireProtocol: 'patch:',\n requireSource: true,\n });\n const locatorRange = structUtils.parseRange(options.locator.reference, {\n requireProtocol: 'patch:',\n requireSource: true,\n });\n const sourceDescriptor = normalizeNpmAliasSource(\n options.configuration.normalizeDependency(\n structUtils.parseDescriptor(descriptorRange.source, true),\n ),\n );\n const sourceLocator = structUtils.parseLocator(locatorRange.source, true);\n if (!structUtils.areIdentsEqual(sourceDescriptor, sourceLocator)) {\n return false;\n }\n\n const descriptorSourceRange = structUtils.parseRange(sourceDescriptor.range);\n const locatorSourceRange = structUtils.parseRange(sourceLocator.reference);\n const npmAgreement = npmSourceAgrees(\n descriptorSourceRange,\n locatorSourceRange,\n );\n if (\n npmAgreement === false ||\n (npmAgreement === undefined &&\n !nonNpmSourceAgrees(descriptorSourceRange, locatorSourceRange))\n ) {\n return false;\n }\n\n return (\n options.descriptorDeclaration?.parentLocator ===\n options.locatorDeclaration?.parentLocator &&\n arraysEqual(\n options.descriptorDeclaration?.components ?? [],\n options.locatorDeclaration?.components ?? [],\n )\n );\n}\n\nasync function discoverManifestDeclarations(\n rootDir: string,\n configuration: Configuration,\n errors: PatchVerificationError[],\n): Promise<{\n patchDeclarations: PatchDeclaration[];\n resolutionDeclarations: ResolutionDeclaration[];\n}> {\n const project = new Project(npath.toPortablePath(rootDir), { configuration });\n const pendingWorkspaces = [npath.toPortablePath(rootDir)];\n const visitedWorkspaces = new Set<string>();\n const patchDeclarations: PatchDeclaration[] = [];\n const resolutionDeclarations: ResolutionDeclaration[] = [];\n\n while (pendingWorkspaces.length > 0) {\n const workspaceCwd = pendingWorkspaces.shift();\n if (workspaceCwd === undefined || visitedWorkspaces.has(workspaceCwd)) {\n continue;\n }\n visitedWorkspaces.add(workspaceCwd);\n\n const workspace = new Workspace(workspaceCwd, { project });\n await workspace.setup();\n pendingWorkspaces.push(...workspace.workspacesCwds);\n\n const manifestDir = npath.fromPortablePath(workspace.cwd);\n const manifestPath = relativePath(\n rootDir,\n path.join(manifestDir, 'package.json'),\n );\n const manifestJson: Record<string, unknown> = workspace.manifest.raw;\n const parentLocator = structUtils.stringifyLocator(\n workspace.anchoredLocator,\n );\n\n for (const field of MANIFEST_FIELDS) {\n const entries = manifestJson[field];\n if (typeof entries !== 'object' || entries === null) {\n continue;\n }\n\n for (const [name, range] of Object.entries(entries)) {\n if (\n field === 'resolutions' &&\n workspace.cwd === project.cwd &&\n typeof range === 'string'\n ) {\n resolutionDeclarations.push({\n pattern: name,\n location: `${manifestPath}#${field}.${name}`,\n });\n }\n if (typeof range !== 'string' || !range.startsWith('patch:')) {\n continue;\n }\n\n const location = `${manifestPath}#${field}.${name}`;\n try {\n const declaration = parsePatchDeclaration({\n rootDir,\n parentDir: manifestDir,\n parentLocator,\n patchedIdent:\n field === 'resolutions'\n ? parseResolution(name).descriptor.fullName\n : structUtils.stringifyIdent(structUtils.parseIdent(name)),\n range,\n location,\n origin: 'manifest',\n });\n if (declaration) {\n patchDeclarations.push(declaration);\n }\n } catch (error) {\n errors.push({\n kind: 'malformed-patch-reference',\n message: `Invalid patch reference for '${name}' in ${field}: ${String(\n error,\n )}`,\n location,\n });\n }\n }\n }\n }\n\n return { patchDeclarations, resolutionDeclarations };\n}\n\nfunction parseLockfile(\n lockfileContent: string,\n errors: PatchVerificationError[],\n): Record<string, unknown> | undefined {\n try {\n return parseSyml(lockfileContent);\n } catch (error) {\n errors.push({\n kind: 'malformed-lockfile',\n message: `Failed to parse yarn.lock: ${String(error)}`,\n location: 'yarn.lock',\n });\n return undefined;\n }\n}\n\nfunction discoverLockfileDeclarations(\n rootDir: string,\n configuration: Configuration,\n lockfileData: Record<string, unknown>,\n errors: PatchVerificationError[],\n): PatchDeclaration[] {\n const declarations: PatchDeclaration[] = [];\n for (const [key, lockfileEntry] of Object.entries(lockfileData)) {\n if (key === '__metadata') {\n continue;\n }\n\n const patchDescriptors: Array<{\n descriptor: ReturnType<typeof structUtils.parseDescriptor>;\n declaration: PatchDeclaration | undefined;\n }> = [];\n for (const entry of key.split(', ')) {\n try {\n const descriptor = structUtils.parseDescriptor(entry, true);\n if (!descriptor.range.startsWith('patch:')) {\n continue;\n }\n const declaration = parsePatchDeclaration({\n rootDir,\n parentDir: rootDir,\n patchedIdent: structUtils.stringifyIdent(descriptor),\n range: descriptor.range,\n location: 'yarn.lock',\n origin: 'lockfile',\n });\n if (declaration?.canMatchManifest) {\n declarations.push(declaration);\n }\n patchDescriptors.push({ descriptor, declaration });\n } catch (error) {\n errors.push({\n kind: 'malformed-lockfile',\n message: `Invalid patch entry '${entry}' in yarn.lock: ${String(\n error,\n )}`,\n location: 'yarn.lock',\n });\n }\n }\n\n if (patchDescriptors.length === 0) {\n continue;\n }\n\n const resolution = isRecord(lockfileEntry)\n ? lockfileEntry.resolution\n : undefined;\n if (typeof resolution !== 'string') {\n errors.push({\n kind: 'malformed-lockfile',\n message: `Patch entry '${key}' is missing its resolution locator`,\n location: 'yarn.lock',\n });\n continue;\n }\n\n try {\n const locator = structUtils.parseLocator(resolution, true);\n if (!locator.reference.startsWith('patch:')) {\n errors.push({\n kind: 'lockfile-mismatch',\n message: `Patch entry '${key}' disagrees with its resolution locator '${resolution}'`,\n location: 'yarn.lock',\n });\n continue;\n }\n const locatorDeclaration = parsePatchDeclaration({\n rootDir,\n parentDir: rootDir,\n patchedIdent: structUtils.stringifyIdent(locator),\n range: locator.reference,\n location: 'yarn.lock',\n origin: 'lockfile',\n });\n const locatorRange = structUtils.parseRange(locator.reference, {\n requireProtocol: 'patch:',\n requireSource: true,\n });\n const resolvedSource = structUtils.stringifyLocator(\n structUtils.parseLocator(locatorRange.source, true),\n );\n for (const { declaration } of patchDescriptors) {\n if (declaration) {\n declaration.resolvedSource = resolvedSource;\n }\n }\n if (\n patchDescriptors.some(\n ({ descriptor, declaration }) =>\n !patchDescriptorAgreesWithLocator({\n configuration,\n descriptor,\n descriptorDeclaration: declaration,\n locator,\n locatorDeclaration,\n }),\n )\n ) {\n errors.push({\n kind: 'lockfile-mismatch',\n message: `Patch entry '${key}' disagrees with its resolution locator '${resolution}'`,\n location: 'yarn.lock',\n });\n }\n } catch (error) {\n errors.push({\n kind: 'malformed-lockfile',\n message: `Patch entry '${key}' has an invalid resolution locator '${resolution}': ${String(\n error,\n )}`,\n location: 'yarn.lock',\n });\n }\n }\n\n return declarations;\n}\n\nfunction getLockfileLocator(\n lockfileEntry: Record<string, unknown>,\n configuration: Configuration,\n): ReturnType<typeof structUtils.parseLocator> | undefined {\n if (typeof lockfileEntry.resolution !== 'string') {\n return undefined;\n }\n try {\n return configuration.normalizeLocator(\n structUtils.parseLocator(lockfileEntry.resolution, true),\n );\n } catch {\n return undefined;\n }\n}\n\nfunction resolutionMatchesDependency(options: {\n resolution: ReturnType<typeof parseResolution>;\n dependencyName: string;\n dependencyRange: string;\n parentLocator: ReturnType<typeof structUtils.parseLocator> | undefined;\n configuration: Configuration;\n}): boolean {\n const { resolution, configuration, parentLocator } = options;\n if (resolution.from) {\n if (\n parentLocator === undefined ||\n resolution.from.fullName !== structUtils.stringifyIdent(parentLocator)\n ) {\n return false;\n }\n const normalizedFrom = configuration.normalizeLocator(\n structUtils.makeLocator(\n structUtils.parseIdent(resolution.from.fullName),\n resolution.from.description ?? parentLocator.reference,\n ),\n );\n if (normalizedFrom.locatorHash !== parentLocator.locatorHash) {\n return false;\n }\n }\n\n const dependency = configuration.normalizeDependency(\n structUtils.makeDescriptor(\n structUtils.parseIdent(options.dependencyName),\n options.dependencyRange,\n ),\n );\n if (\n resolution.descriptor.fullName !== structUtils.stringifyIdent(dependency)\n ) {\n return false;\n }\n const normalizedDescriptor = configuration.normalizeDependency(\n structUtils.makeDescriptor(\n structUtils.parseIdent(resolution.descriptor.fullName),\n resolution.descriptor.description ?? dependency.range,\n ),\n );\n return normalizedDescriptor.descriptorHash === dependency.descriptorHash;\n}\n\nfunction validateResolutions(options: {\n declarations: ResolutionDeclaration[];\n lockfileData: Record<string, unknown>;\n configuration: Configuration;\n}): {\n errors: PatchVerificationError[];\n unusedLocations: Set<string>;\n} {\n const lockfileEntries = Object.entries(options.lockfileData)\n .filter(([key, value]) => key !== '__metadata' && isRecord(value))\n .map(([, value]) => ({\n entry: value as Record<string, unknown>,\n parentLocator: getLockfileLocator(\n value as Record<string, unknown>,\n options.configuration,\n ),\n }));\n const hasRootWorkspace = lockfileEntries.some(\n ({ parentLocator }) => parentLocator?.reference === 'workspace:.',\n );\n // Without the root workspace entry, the lockfile does not contain the\n // complete project dependency graph, so absence cannot prove that a\n // resolution is unused.\n if (!hasRootWorkspace) {\n return { errors: [], unusedLocations: new Set() };\n }\n\n const errors: PatchVerificationError[] = [];\n const unusedLocations = new Set<string>();\n for (const declaration of options.declarations) {\n let resolution;\n try {\n resolution = parseResolution(declaration.pattern);\n } catch {\n continue;\n }\n\n const matches = lockfileEntries.some(({ entry, parentLocator }) => {\n return ['dependencies', 'optionalDependencies'].some(field => {\n const dependencies = entry[field];\n if (!isRecord(dependencies)) {\n return false;\n }\n return Object.entries(dependencies).some(\n ([dependencyName, dependencyRange]) => {\n if (typeof dependencyRange !== 'string') {\n return false;\n }\n try {\n return resolutionMatchesDependency({\n resolution,\n dependencyName,\n dependencyRange,\n parentLocator,\n configuration: options.configuration,\n });\n } catch {\n return false;\n }\n },\n );\n });\n });\n if (!matches) {\n unusedLocations.add(declaration.location);\n errors.push({\n kind: 'unused-resolution',\n message: `Resolution '${declaration.pattern}' does not match any dependency request in yarn.lock`,\n location: declaration.location,\n });\n }\n }\n return { errors, unusedLocations };\n}\n\nasync function readYarnConfiguration(\n rootDir: string,\n env: NodeJS.ProcessEnv | undefined,\n): Promise<Configuration> {\n return withConfigurationEnvironment(env, async () => {\n // Yarn still applies inherited rc files when useRc is false; this only\n // prevents project rc files from loading arbitrary third-party plugins.\n return Configuration.find(\n npath.toPortablePath(rootDir),\n PATCH_PLUGIN_CONFIGURATION,\n {\n strict: false,\n useRc: false,\n },\n );\n });\n}\n\nasync function findPatchFiles(\n directory: string,\n realpathAncestry: ReadonlySet<string> = new Set(),\n): Promise<string[]> {\n let realDirectory;\n try {\n realDirectory = await fs.realpath(directory);\n } catch (error) {\n if (isErrorWithCode(error, 'ENOENT')) {\n return [];\n }\n throw error;\n }\n if (realpathAncestry.has(realDirectory)) {\n return [];\n }\n const nextAncestry = new Set(realpathAncestry).add(realDirectory);\n\n let entries;\n try {\n entries = await fs.readdir(directory, { withFileTypes: true });\n } catch (error) {\n if (isErrorWithCode(error, 'ENOENT')) {\n return [];\n }\n throw error;\n }\n\n const files = await Promise.all(\n entries.map(async entry => {\n const entryPath = path.join(directory, entry.name);\n if (entry.isDirectory()) {\n return findPatchFiles(entryPath, nextAncestry);\n }\n if (entry.isSymbolicLink()) {\n try {\n const targetStats = await fs.stat(entryPath);\n if (targetStats.isDirectory()) {\n return findPatchFiles(entryPath, nextAncestry);\n }\n } catch (error) {\n if (!isErrorWithCode(error, 'ENOENT')) {\n throw error;\n }\n }\n return [entryPath];\n }\n return entry.isFile() ? [entryPath] : [];\n }),\n );\n return files.flat().sort();\n}\n\nfunction uniqueDeclarations(\n declarations: PatchDeclaration[],\n): Map<string, PatchDeclaration> {\n const unique = new Map<string, PatchDeclaration>();\n for (const declaration of declarations) {\n const key = declarationKey(declaration);\n if (!unique.has(key)) {\n unique.set(key, declaration);\n }\n }\n return unique;\n}\n\nfunction getPatchedBackstagePackages(\n declarations: Iterable<PatchDeclaration>,\n): PatchedBackstagePackage[] {\n const packages: PatchedBackstagePackage[] = [];\n for (const declaration of declarations) {\n const declaredSource = normalizeNpmAliasSource(\n structUtils.parseDescriptor(declaration.source, true),\n );\n const resolvedSource = declaration.resolvedSource;\n const source = resolvedSource\n ? structUtils.parseLocator(resolvedSource, true)\n : declaredSource;\n if (source.scope !== 'backstage') {\n continue;\n }\n const range = structUtils.parseRange(\n 'reference' in source ? source.reference : source.range,\n );\n if (\n range.protocol !== 'npm:' ||\n semverUtils.clean(range.selector) === null\n ) {\n continue;\n }\n packages.push({\n name: structUtils.stringifyIdent(source),\n version: range.selector,\n location: declaration.location,\n declaration,\n });\n }\n return packages;\n}\n\nfunction isReleaseManifest(value: unknown): value is ReleaseManifest {\n return (\n isRecord(value) &&\n typeof value.releaseVersion === 'string' &&\n Array.isArray(value.packages) &&\n value.packages.every(\n packageEntry =>\n isRecord(packageEntry) &&\n typeof packageEntry.name === 'string' &&\n typeof packageEntry.version === 'string',\n )\n );\n}\n\nasync function readBackstageVersion(\n rootDir: string,\n): Promise<string | undefined> {\n try {\n const backstageJson: unknown = JSON.parse(\n await fs.readFile(path.join(rootDir, 'backstage.json'), 'utf8'),\n );\n if (!isRecord(backstageJson) || typeof backstageJson.version !== 'string') {\n throw new Error(\n \"backstage.json must contain a string 'version' property\",\n );\n }\n return backstageJson.version;\n } catch (error) {\n if (isErrorWithCode(error, 'ENOENT')) {\n return undefined;\n }\n throw error;\n }\n}\n\nasync function loadReleaseManifest(options: {\n backstageVersion: string;\n configuration: Configuration;\n env: NodeJS.ProcessEnv | undefined;\n fetch: typeof globalThis.fetch | undefined;\n}): Promise<ReleaseManifest> {\n const manifestFile = options.env?.BACKSTAGE_MANIFEST_FILE;\n const fetch =\n options.fetch ??\n (async (url: string) => {\n const manifest = await httpUtils.get(url, {\n configuration: options.configuration,\n jsonResponse: true,\n });\n return {\n status: 200,\n url,\n json: async () => manifest,\n };\n });\n const manifest: unknown = manifestFile\n ? JSON.parse(await fs.readFile(manifestFile, 'utf8'))\n : await getManifestByVersion({\n version: options.backstageVersion,\n versionsBaseUrl: options.env?.BACKSTAGE_VERSIONS_BASE_URL,\n fetch,\n });\n if (!isReleaseManifest(manifest)) {\n throw new Error('Backstage release manifest has an invalid format');\n }\n if (manifest.releaseVersion !== options.backstageVersion) {\n throw new Error(\n `Backstage release manifest version '${manifest.releaseVersion}' does not match selected version '${options.backstageVersion}'`,\n );\n }\n return manifest;\n}\n\nasync function validateBackstagePatches(options: {\n rootDir: string;\n declarations: Iterable<PatchDeclaration>;\n configuration: Configuration;\n env: NodeJS.ProcessEnv | undefined;\n fetch: typeof globalThis.fetch | undefined;\n}): Promise<{\n backstageCheck: VerifyYarnPatchesResult['backstageCheck'];\n errors: PatchVerificationError[];\n}> {\n const patchedPackages = getPatchedBackstagePackages(options.declarations);\n if (patchedPackages.length === 0) {\n return { backstageCheck: 'skipped', errors: [] };\n }\n\n let backstageVersion: string | undefined;\n try {\n backstageVersion = await readBackstageVersion(options.rootDir);\n } catch (error) {\n return {\n backstageCheck: 'verified',\n errors: [\n {\n kind: 'backstage-manifest-load-failure',\n message: `Failed to read Backstage release version: ${String(error)}`,\n location: 'backstage.json',\n },\n ],\n };\n }\n if (backstageVersion === undefined) {\n return { backstageCheck: 'skipped', errors: [] };\n }\n\n let releaseManifest: ReleaseManifest;\n try {\n releaseManifest = await loadReleaseManifest({\n backstageVersion,\n configuration: options.configuration,\n env: options.env,\n fetch: options.fetch,\n });\n } catch (error) {\n return {\n backstageCheck: 'verified',\n errors: [\n {\n kind: 'backstage-manifest-load-failure',\n message: `Failed to load Backstage release manifest for '${backstageVersion}': ${String(\n error,\n )}`,\n location: 'backstage.json',\n },\n ],\n };\n }\n\n const packageVersions = new Map(\n releaseManifest.packages.map(packageEntry => [\n packageEntry.name,\n packageEntry.version,\n ]),\n );\n const errors: PatchVerificationError[] = [];\n for (const patchedPackage of patchedPackages) {\n const releaseVersion = packageVersions.get(patchedPackage.name);\n if (releaseVersion === undefined) {\n errors.push({\n kind: 'backstage-package-missing',\n message: `Patched package '${patchedPackage.name}' is absent from Backstage release '${backstageVersion}'`,\n location: patchedPackage.location,\n });\n } else if (releaseVersion !== patchedPackage.version) {\n const error: PatchVerificationError = {\n kind: 'backstage-patch-holdback',\n message: `Patched package '${patchedPackage.name}' is at version '${patchedPackage.version}', but Backstage release '${backstageVersion}' requires version '${releaseVersion}'`,\n location: patchedPackage.location,\n };\n error.repairHint = {\n packageName: patchedPackage.name,\n currentVersion: patchedPackage.version,\n targetVersion: releaseVersion,\n declaration: patchedPackage.declaration,\n };\n errors.push(error);\n }\n }\n\n return { backstageCheck: 'verified', errors };\n}\n\nexport async function verifyYarnPatches(\n options: VerifyYarnPatchesOptions,\n): Promise<VerifyYarnPatchesResult> {\n const rootDir = path.resolve(options.rootDir);\n const errors: PatchVerificationError[] = [];\n const configuration = await readYarnConfiguration(rootDir, options.env);\n const { patchDeclarations, resolutionDeclarations } =\n await discoverManifestDeclarations(rootDir, configuration, errors);\n\n let lockfileData: Record<string, unknown> | undefined;\n try {\n const lockfileContent = await fs.readFile(\n path.join(rootDir, 'yarn.lock'),\n 'utf8',\n );\n lockfileData = parseLockfile(lockfileContent, errors);\n } catch (error) {\n if (!isErrorWithCode(error, 'ENOENT')) {\n throw error;\n }\n errors.push({\n kind: 'missing-lockfile',\n message: 'No yarn.lock found',\n location: 'yarn.lock',\n });\n }\n\n let unusedResolutionLocations = new Set<string>();\n if (lockfileData !== undefined) {\n const resolutionValidation = validateResolutions({\n declarations: resolutionDeclarations,\n lockfileData,\n configuration,\n });\n errors.push(...resolutionValidation.errors);\n unusedResolutionLocations = resolutionValidation.unusedLocations;\n }\n\n const manifestDeclaredPatchFiles = new Set(\n patchDeclarations.flatMap(declaration =>\n declaration.paths.map(patchPath => patchPath.absolute),\n ),\n );\n const uniqueManifestDeclarations = uniqueDeclarations(\n patchDeclarations.filter(\n declaration => !unusedResolutionLocations.has(declaration.location),\n ),\n );\n const referencedPatchFiles = new Map<string, LocalPatchPath>();\n\n for (const declaration of uniqueManifestDeclarations.values()) {\n for (const patchPath of declaration.paths) {\n referencedPatchFiles.set(patchPath.absolute, patchPath);\n }\n }\n\n for (const [absolute, patchPath] of referencedPatchFiles) {\n try {\n const stats = await fs.stat(absolute);\n if (!stats.isFile()) {\n errors.push({\n kind: 'missing-patch-file',\n message: `Patch path '${patchPath.relative}' is not a regular file`,\n location: patchPath.relative,\n });\n }\n } catch (error) {\n if (!isErrorWithCode(error, 'ENOENT')) {\n throw error;\n }\n errors.push({\n kind: 'missing-patch-file',\n message: `Patch file '${patchPath.relative}' does not exist`,\n location: patchPath.relative,\n });\n }\n }\n\n const patchFolder = npath.fromPortablePath(configuration.get('patchFolder'));\n const patchFiles = await findPatchFiles(patchFolder);\n for (const patchFile of patchFiles) {\n if (!manifestDeclaredPatchFiles.has(patchFile)) {\n const relative = relativePath(rootDir, patchFile);\n errors.push({\n kind: 'orphaned-patch-file',\n message: `Patch file '${relative}' is not referenced by any manifest`,\n location: relative,\n });\n }\n }\n\n if (lockfileData !== undefined) {\n const lockfileDeclarations = uniqueDeclarations(\n discoverLockfileDeclarations(\n rootDir,\n configuration,\n lockfileData,\n errors,\n ),\n );\n\n for (const [key, declaration] of uniqueManifestDeclarations) {\n const lockfileDeclaration = lockfileDeclarations.get(key);\n if (!lockfileDeclaration) {\n errors.push({\n kind: 'lockfile-mismatch',\n message: `Patch declaration for '${\n declaration.source\n }' using '${declarationDescription(\n declaration,\n )}' is missing from yarn.lock`,\n location: declaration.location,\n });\n } else {\n declaration.resolvedSource = lockfileDeclaration.resolvedSource;\n }\n }\n\n for (const [key, declaration] of lockfileDeclarations) {\n if (declaration.projectOwned && !uniqueManifestDeclarations.has(key)) {\n errors.push({\n kind: 'lockfile-mismatch',\n message: `yarn.lock contains patch declaration for '${\n declaration.source\n }' using '${declarationDescription(\n declaration,\n )}' that is absent from manifests`,\n location: 'yarn.lock',\n });\n }\n }\n }\n\n const sourcesByPatchFile = new Map<string, Set<string>>();\n for (const declaration of uniqueManifestDeclarations.values()) {\n for (const patchPath of declaration.paths) {\n let sources = sourcesByPatchFile.get(patchPath.absolute);\n if (!sources) {\n sources = new Set();\n sourcesByPatchFile.set(patchPath.absolute, sources);\n }\n sources.add(declaration.resolvedSource ?? declaration.source);\n }\n }\n\n for (const [absolute, sources] of sourcesByPatchFile) {\n if (sources.size <= 1) {\n continue;\n }\n const patchPath = referencedPatchFiles.get(absolute);\n if (!patchPath) {\n continue;\n }\n const sortedSources = [...sources].sort();\n errors.push({\n kind: 'incompatible-patch-declarations',\n message: `Patch file '${\n patchPath.relative\n }' is used for incompatible sources: ${sortedSources\n .map(source => `'${source}'`)\n .join(', ')}`,\n location: patchPath.relative,\n });\n }\n\n const backstageValidation = await validateBackstagePatches({\n rootDir,\n declarations: uniqueManifestDeclarations.values(),\n configuration,\n env: options.env,\n fetch: options.fetch,\n });\n errors.push(...backstageValidation.errors);\n\n return {\n patchCount: referencedPatchFiles.size,\n backstageCheck: backstageValidation.backstageCheck,\n errors: sortErrors(errors),\n };\n}\n"],"names":["patchPlugin","path","structUtils","npath","ppath","semverUtils","TAG_REGEXP","Project","Workspace","parseResolution","parseSyml","Configuration","fs","manifest","httpUtils","getManifestByVersion"],"mappings":";;;;;;;;;;;;;;;;AAuGA,MAAM,eAAA,GAAkB;AAAA,EACtB,aAAA;AAAA,EACA,cAAA;AAAA,EACA,iBAAA;AAAA,EACA,kBAAA;AAAA,EACA;AACF,CAAA;AAEA,MAAM,0BAAA,GAAkD;AAAA,EACtD,OAAA,sBAAa,GAAA,CAAI,CAAC,CAAC,uBAAA,EAAyBA,4BAAW,CAAC,CAAC,CAAA;AAAA,EACzD,OAAA,kBAAS,IAAI,GAAA,CAAI,CAAC,uBAAuB,CAAC;AAC5C,CAAA;AAIA,IAAI,6BAAA,GAAgC,QAAQ,OAAA,EAAQ;AAEpD,SAAS,YAAA,CAAa,SAAiB,UAAA,EAA4B;AACjE,EAAA,OAAOC,qBAAA,CAAK,QAAA,CAAS,OAAA,EAAS,UAAU,CAAA,CAAE,MAAMA,qBAAA,CAAK,GAAG,CAAA,CAAE,IAAA,CAAK,GAAG,CAAA;AACpE;AAEA,SAAS,cAAA,CAAe,MAAc,KAAA,EAAuB;AAC3D,EAAA,IAAI,OAAO,KAAA,EAAO;AAChB,IAAA,OAAO,EAAA;AAAA,EAC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,CAAC,QAAA,EAAU,OAAO,CAAA,IAAK,kBAAA,EAAoB;AACpD,IAAA,IAAI,OAAA,CAAQ,QAAQ,CAAA,EAAG;AACrB,MAAA;AAAA,IACF;AACA,IAAA,MAAM,SAAA,GAAY,oBAAA,CAAqB,GAAA,CAAI,QAAQ,CAAA;AACnD,IAAA,IAAI,CAAC,SAAA,EAAW;AACd,MAAA;AAAA,IACF;AACA,IAAA,MAAM,aAAA,GAAgB,CAAC,GAAG,OAAO,EAAE,IAAA,EAAK;AACxC,IAAA,MAAA,CAAO,IAAA,CAAK;AAAA,MACV,IAAA,EAAM,iCAAA;AAAA,MACN,OAAA,EAAS,CAAA,YAAA,EACP,SAAA,CAAU,QACZ,uCAAuC,aAAA,CACpC,GAAA,CAAI,CAAA,MAAA,KAAU,CAAA,CAAA,EAAI,MAAM,CAAA,CAAA,CAAG,CAAA,CAC3B,IAAA,CAAK,IAAI,CAAC,CAAA,CAAA;AAAA,MACb,UAAU,SAAA,CAAU;AAAA,KACrB,CAAA;AAAA,EACH;AAEA,EAAA,MAAM,mBAAA,GAAsB,MAAM,wBAAA,CAAyB;AAAA,IACzD,OAAA;AAAA,IACA,YAAA,EAAc,2BAA2B,MAAA,EAAO;AAAA,IAChD,aAAA;AAAA,IACA,KAAK,OAAA,CAAQ,GAAA;AAAA,IACb,OAAO,OAAA,CAAQ;AAAA,GAChB,CAAA;AACD,EAAA,MAAA,CAAO,IAAA,CAAK,GAAG,mBAAA,CAAoB,MAAM,CAAA;AAEzC,EAAA,OAAO;AAAA,IACL,YAAY,oBAAA,CAAqB,IAAA;AAAA,IACjC,gBAAgB,mBAAA,CAAoB,cAAA;AAAA,IACpC,MAAA,EAAQ,WAAW,MAAM;AAAA,GAC3B;AACF;;"}
|
package/dist/package.json.cjs.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var name = "@backstage/cli-module-package-manager-yarn";
|
|
6
|
-
var version = "0.1.3-next.
|
|
6
|
+
var version = "0.1.3-next.2";
|
|
7
7
|
var description = "CLI module for Yarn package manager commands";
|
|
8
8
|
var backstage = {
|
|
9
9
|
role: "cli-module"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backstage/cli-module-package-manager-yarn",
|
|
3
|
-
"version": "0.1.3-next.
|
|
3
|
+
"version": "0.1.3-next.2",
|
|
4
4
|
"description": "CLI module for Yarn package manager commands",
|
|
5
5
|
"backstage": {
|
|
6
6
|
"role": "cli-module"
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@backstage/cli-common": "0.3.2-next.0",
|
|
37
|
-
"@backstage/cli-node": "0.3.5-next.
|
|
37
|
+
"@backstage/cli-node": "0.3.5-next.1",
|
|
38
38
|
"@backstage/release-manifests": "0.0.15-next.0",
|
|
39
39
|
"@yarnpkg/cli": "^4.7.0",
|
|
40
40
|
"@yarnpkg/core": "^4.9.1",
|