@yarnpkg/plugin-pnp 4.0.0-rc.8 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/PnpLinker.d.ts +1 -1
- package/lib/PnpLinker.js +15 -24
- package/lib/commands/unplug.d.ts +1 -1
- package/lib/commands/unplug.js +19 -13
- package/lib/index.d.ts +4 -2
- package/lib/index.js +30 -20
- package/lib/jsInstallUtils.d.ts +4 -9
- package/lib/jsInstallUtils.js +19 -32
- package/package.json +20 -17
package/lib/PnpLinker.d.ts
CHANGED
|
@@ -25,7 +25,7 @@ export declare class PnpInstaller implements Installer {
|
|
|
25
25
|
attachCustomData(customData: any): void;
|
|
26
26
|
installPackage(pkg: Package, fetchResult: FetchResult, api: InstallPackageExtraApi): Promise<{
|
|
27
27
|
packageLocation: PortablePath;
|
|
28
|
-
|
|
28
|
+
buildRequest: import("@yarnpkg/core").BuildRequest | null;
|
|
29
29
|
}>;
|
|
30
30
|
attachInternalDependencies(locator: Locator, dependencies: Array<[Descriptor, Locator]>): Promise<void>;
|
|
31
31
|
attachExternalDependents(locator: Locator, dependentPaths: Array<PortablePath>): Promise<void>;
|
package/lib/PnpLinker.js
CHANGED
|
@@ -11,13 +11,9 @@ const index_1 = require("./index");
|
|
|
11
11
|
const jsInstallUtils = tslib_1.__importStar(require("./jsInstallUtils"));
|
|
12
12
|
const pnpUtils = tslib_1.__importStar(require("./pnpUtils"));
|
|
13
13
|
const FORCED_UNPLUG_PACKAGES = new Set([
|
|
14
|
-
//
|
|
15
|
-
core_1.structUtils.makeIdent(null, `
|
|
16
|
-
core_1.structUtils.makeIdent(null, `
|
|
17
|
-
core_1.structUtils.makeIdent(null, `node-pre-gyp`).identHash,
|
|
18
|
-
core_1.structUtils.makeIdent(null, `node-addon-api`).identHash,
|
|
19
|
-
// Those ones contain native builds (*.node), and Node loads them through dlopen
|
|
20
|
-
core_1.structUtils.makeIdent(null, `fsevents`).identHash,
|
|
14
|
+
// Contains native binaries
|
|
15
|
+
core_1.structUtils.makeIdent(null, `open`).identHash,
|
|
16
|
+
core_1.structUtils.makeIdent(null, `opn`).identHash,
|
|
21
17
|
]);
|
|
22
18
|
class PnpLinker {
|
|
23
19
|
constructor() {
|
|
@@ -126,9 +122,9 @@ class PnpInstaller {
|
|
|
126
122
|
this.isESMLoaderRequired = true;
|
|
127
123
|
dependencyMeta = this.opts.project.getDependencyMeta(devirtualizedLocator, pkg.version);
|
|
128
124
|
}
|
|
129
|
-
const
|
|
130
|
-
? jsInstallUtils.
|
|
131
|
-
:
|
|
125
|
+
const buildRequest = mayNeedToBeBuilt
|
|
126
|
+
? jsInstallUtils.extractBuildRequest(pkg, customPackageData, dependencyMeta, { configuration: this.opts.project.configuration })
|
|
127
|
+
: null;
|
|
132
128
|
const packageFs = mayNeedToBeUnplugged
|
|
133
129
|
? await this.unplugPackageIfNeeded(pkg, customPackageData, fetchResult, dependencyMeta, api)
|
|
134
130
|
: fetchResult.packageFs;
|
|
@@ -164,7 +160,7 @@ class PnpInstaller {
|
|
|
164
160
|
});
|
|
165
161
|
return {
|
|
166
162
|
packageLocation: packageRawLocation,
|
|
167
|
-
|
|
163
|
+
buildRequest,
|
|
168
164
|
};
|
|
169
165
|
}
|
|
170
166
|
async attachInternalDependencies(locator, dependencies) {
|
|
@@ -186,16 +182,13 @@ class PnpInstaller {
|
|
|
186
182
|
if (this.opts.project.configuration.get(`pnpMode`) !== this.mode)
|
|
187
183
|
return undefined;
|
|
188
184
|
const pnpPath = (0, index_1.getPnpPath)(this.opts.project);
|
|
189
|
-
if (fslib_1.xfs.existsSync(pnpPath.cjsLegacy)) {
|
|
190
|
-
this.opts.report.reportWarning(core_2.MessageName.UNNAMED, `Removing the old ${core_1.formatUtils.pretty(this.opts.project.configuration, fslib_1.Filename.pnpJs, core_1.formatUtils.Type.PATH)} file. You might need to manually update existing references to reference the new ${core_1.formatUtils.pretty(this.opts.project.configuration, fslib_1.Filename.pnpCjs, core_1.formatUtils.Type.PATH)} file. If you use Editor SDKs, you'll have to rerun ${core_1.formatUtils.pretty(this.opts.project.configuration, `yarn sdks`, core_1.formatUtils.Type.CODE)}.`);
|
|
191
|
-
await fslib_1.xfs.removePromise(pnpPath.cjsLegacy);
|
|
192
|
-
}
|
|
193
185
|
if (!this.isEsmEnabled())
|
|
194
186
|
await fslib_1.xfs.removePromise(pnpPath.esmLoader);
|
|
195
187
|
if (this.opts.project.configuration.get(`nodeLinker`) !== `pnp`) {
|
|
196
188
|
await fslib_1.xfs.removePromise(pnpPath.cjs);
|
|
197
|
-
await fslib_1.xfs.removePromise(
|
|
189
|
+
await fslib_1.xfs.removePromise(pnpPath.data);
|
|
198
190
|
await fslib_1.xfs.removePromise(pnpPath.esmLoader);
|
|
191
|
+
await fslib_1.xfs.removePromise(this.opts.project.configuration.get(`pnpUnpluggedFolder`));
|
|
199
192
|
return undefined;
|
|
200
193
|
}
|
|
201
194
|
for (const { locator, location } of this.virtualTemplates.values()) {
|
|
@@ -253,7 +246,6 @@ class PnpInstaller {
|
|
|
253
246
|
}
|
|
254
247
|
async finalizeInstallWithPnp(pnpSettings) {
|
|
255
248
|
const pnpPath = (0, index_1.getPnpPath)(this.opts.project);
|
|
256
|
-
const pnpDataPath = this.opts.project.configuration.get(`pnpDataPath`);
|
|
257
249
|
const nodeModules = await this.locateNodeModules(pnpSettings.ignorePattern);
|
|
258
250
|
if (nodeModules.length > 0) {
|
|
259
251
|
this.opts.report.reportWarning(core_2.MessageName.DANGEROUS_NODE_MODULES, `One or more node_modules have been detected and will be removed. This operation may take some time.`);
|
|
@@ -268,16 +260,15 @@ class PnpInstaller {
|
|
|
268
260
|
automaticNewlines: true,
|
|
269
261
|
mode: 0o755,
|
|
270
262
|
});
|
|
271
|
-
await fslib_1.xfs.removePromise(
|
|
263
|
+
await fslib_1.xfs.removePromise(pnpPath.data);
|
|
272
264
|
}
|
|
273
265
|
else {
|
|
274
|
-
const
|
|
275
|
-
const { dataFile, loaderFile } = (0, pnp_1.generateSplitScript)({ ...pnpSettings, dataLocation });
|
|
266
|
+
const { dataFile, loaderFile } = (0, pnp_1.generateSplitScript)(pnpSettings);
|
|
276
267
|
await fslib_1.xfs.changeFilePromise(pnpPath.cjs, loaderFile, {
|
|
277
268
|
automaticNewlines: true,
|
|
278
269
|
mode: 0o755,
|
|
279
270
|
});
|
|
280
|
-
await fslib_1.xfs.changeFilePromise(
|
|
271
|
+
await fslib_1.xfs.changeFilePromise(pnpPath.data, dataFile, {
|
|
281
272
|
automaticNewlines: true,
|
|
282
273
|
mode: 0o644,
|
|
283
274
|
});
|
|
@@ -343,7 +334,8 @@ class PnpInstaller {
|
|
|
343
334
|
return true;
|
|
344
335
|
if (customPackageData.manifest.preferUnplugged !== null)
|
|
345
336
|
return customPackageData.manifest.preferUnplugged;
|
|
346
|
-
|
|
337
|
+
const buildRequest = jsInstallUtils.extractBuildRequest(pkg, customPackageData, dependencyMeta, { configuration: this.opts.project.configuration });
|
|
338
|
+
if (buildRequest?.skipped === false || customPackageData.misc.extractHint)
|
|
347
339
|
return true;
|
|
348
340
|
return false;
|
|
349
341
|
}
|
|
@@ -397,8 +389,7 @@ function normalizeDirectoryPath(root, folder) {
|
|
|
397
389
|
return relativeFolder.replace(/\/?$/, `/`);
|
|
398
390
|
}
|
|
399
391
|
async function extractCustomPackageData(fetchResult) {
|
|
400
|
-
|
|
401
|
-
const manifest = (_a = await core_2.Manifest.tryFind(fetchResult.prefixPath, { baseFs: fetchResult.packageFs })) !== null && _a !== void 0 ? _a : new core_2.Manifest();
|
|
392
|
+
const manifest = await core_2.Manifest.tryFind(fetchResult.prefixPath, { baseFs: fetchResult.packageFs }) ?? new core_2.Manifest();
|
|
402
393
|
const preservedScripts = new Set([`preinstall`, `install`, `postinstall`]);
|
|
403
394
|
for (const scriptName of manifest.scripts.keys())
|
|
404
395
|
if (!preservedScripts.has(scriptName))
|
package/lib/commands/unplug.d.ts
CHANGED
package/lib/commands/unplug.js
CHANGED
|
@@ -64,6 +64,9 @@ class UnplugCommand extends cli_1.BaseCommand {
|
|
|
64
64
|
const traverse = (pkg, depth) => {
|
|
65
65
|
if (seen.has(pkg.locatorHash))
|
|
66
66
|
return;
|
|
67
|
+
const isWorkspace = !!project.tryWorkspaceByLocator(pkg);
|
|
68
|
+
if (depth > 0 && !this.recursive && isWorkspace)
|
|
69
|
+
return;
|
|
67
70
|
seen.add(pkg.locatorHash);
|
|
68
71
|
// Note: We shouldn't skip virtual packages, as
|
|
69
72
|
// we don't iterate over the devirtualized copies.
|
|
@@ -82,12 +85,8 @@ class UnplugCommand extends cli_1.BaseCommand {
|
|
|
82
85
|
traverse(nextPkg, depth + 1);
|
|
83
86
|
}
|
|
84
87
|
};
|
|
85
|
-
for (const workspace of roots)
|
|
86
|
-
|
|
87
|
-
if (!pkg)
|
|
88
|
-
throw new Error(`Assertion failed: The package should have been registered`);
|
|
89
|
-
traverse(pkg, 0);
|
|
90
|
-
}
|
|
88
|
+
for (const workspace of roots)
|
|
89
|
+
traverse(workspace.anchoredPackage, 0);
|
|
91
90
|
return selection;
|
|
92
91
|
};
|
|
93
92
|
let selection;
|
|
@@ -113,14 +112,13 @@ class UnplugCommand extends cli_1.BaseCommand {
|
|
|
113
112
|
selection = core_1.miscUtils.sortMap(selection, pkg => {
|
|
114
113
|
return core_2.structUtils.stringifyLocator(pkg);
|
|
115
114
|
});
|
|
116
|
-
const
|
|
115
|
+
const unplugReport = await core_1.StreamReport.start({
|
|
117
116
|
configuration,
|
|
118
117
|
stdout: this.context.stdout,
|
|
119
118
|
json: this.json,
|
|
120
119
|
}, async (report) => {
|
|
121
|
-
var _a;
|
|
122
120
|
for (const pkg of selection) {
|
|
123
|
-
const version =
|
|
121
|
+
const version = pkg.version ?? `unknown`;
|
|
124
122
|
const dependencyMeta = project.topLevelWorkspace.manifest.ensureDependencyMeta(core_2.structUtils.makeDescriptor(pkg, version));
|
|
125
123
|
dependencyMeta.unplugged = true;
|
|
126
124
|
report.reportInfo(core_1.MessageName.UNNAMED, `Will unpack ${core_2.structUtils.prettyLocator(configuration, pkg)} to ${core_1.formatUtils.pretty(configuration, pnpUtils.getUnpluggedPath(pkg, { configuration }), core_1.formatUtils.Type.PATH)}`);
|
|
@@ -130,13 +128,20 @@ class UnplugCommand extends cli_1.BaseCommand {
|
|
|
130
128
|
});
|
|
131
129
|
}
|
|
132
130
|
await project.topLevelWorkspace.persistManifest();
|
|
133
|
-
|
|
134
|
-
|
|
131
|
+
if (!this.json) {
|
|
132
|
+
report.reportSeparator();
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
if (unplugReport.hasErrors())
|
|
136
|
+
return unplugReport.exitCode();
|
|
137
|
+
return await project.installWithNewReport({
|
|
138
|
+
json: this.json,
|
|
139
|
+
stdout: this.context.stdout,
|
|
140
|
+
}, {
|
|
141
|
+
cache,
|
|
135
142
|
});
|
|
136
|
-
return report.exitCode();
|
|
137
143
|
}
|
|
138
144
|
}
|
|
139
|
-
exports.default = UnplugCommand;
|
|
140
145
|
UnplugCommand.paths = [
|
|
141
146
|
[`unplug`],
|
|
142
147
|
];
|
|
@@ -176,3 +181,4 @@ UnplugCommand.usage = clipanion_1.Command.Usage({
|
|
|
176
181
|
`yarn unplug -R '*'`,
|
|
177
182
|
]],
|
|
178
183
|
});
|
|
184
|
+
exports.default = UnplugCommand;
|
package/lib/index.d.ts
CHANGED
|
@@ -1,19 +1,22 @@
|
|
|
1
1
|
import { Hooks as CoreHooks, Plugin, Project } from '@yarnpkg/core';
|
|
2
2
|
import { PortablePath } from '@yarnpkg/fslib';
|
|
3
3
|
import { Hooks as StageHooks } from '@yarnpkg/plugin-stage';
|
|
4
|
+
import UnplugCommand from './commands/unplug';
|
|
4
5
|
import * as jsInstallUtils from './jsInstallUtils';
|
|
5
6
|
import * as pnpUtils from './pnpUtils';
|
|
7
|
+
export { UnplugCommand };
|
|
6
8
|
export { jsInstallUtils };
|
|
7
9
|
export { pnpUtils };
|
|
8
10
|
export declare const getPnpPath: (project: Project) => {
|
|
9
11
|
cjs: PortablePath;
|
|
10
|
-
|
|
12
|
+
data: PortablePath;
|
|
11
13
|
esmLoader: PortablePath;
|
|
12
14
|
};
|
|
13
15
|
export declare const quotePathIfNeeded: (path: string) => string;
|
|
14
16
|
declare module '@yarnpkg/core' {
|
|
15
17
|
interface ConfigurationValueMap {
|
|
16
18
|
nodeLinker: string;
|
|
19
|
+
winLinkType: string;
|
|
17
20
|
pnpMode: string;
|
|
18
21
|
pnpShebang: string;
|
|
19
22
|
pnpIgnorePatterns: Array<string>;
|
|
@@ -21,7 +24,6 @@ declare module '@yarnpkg/core' {
|
|
|
21
24
|
pnpEnableInlining: boolean;
|
|
22
25
|
pnpFallbackMode: string;
|
|
23
26
|
pnpUnpluggedFolder: PortablePath;
|
|
24
|
-
pnpDataPath: PortablePath;
|
|
25
27
|
}
|
|
26
28
|
}
|
|
27
29
|
declare const plugin: Plugin<CoreHooks & StageHooks>;
|
package/lib/index.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PnpLinker = exports.PnpInstaller = exports.quotePathIfNeeded = exports.getPnpPath = exports.pnpUtils = exports.jsInstallUtils = void 0;
|
|
3
|
+
exports.PnpLinker = exports.PnpInstaller = exports.quotePathIfNeeded = exports.getPnpPath = exports.pnpUtils = exports.jsInstallUtils = exports.UnplugCommand = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const core_1 = require("@yarnpkg/core");
|
|
6
6
|
const fslib_1 = require("@yarnpkg/fslib");
|
|
7
|
-
const semver_1 = tslib_1.__importDefault(require("semver"));
|
|
8
7
|
const url_1 = require("url");
|
|
9
8
|
const PnpLinker_1 = require("./PnpLinker");
|
|
10
9
|
const unplug_1 = tslib_1.__importDefault(require("./commands/unplug"));
|
|
10
|
+
exports.UnplugCommand = unplug_1.default;
|
|
11
11
|
const jsInstallUtils = tslib_1.__importStar(require("./jsInstallUtils"));
|
|
12
12
|
exports.jsInstallUtils = jsInstallUtils;
|
|
13
13
|
const pnpUtils = tslib_1.__importStar(require("./pnpUtils"));
|
|
@@ -15,8 +15,8 @@ exports.pnpUtils = pnpUtils;
|
|
|
15
15
|
const getPnpPath = (project) => {
|
|
16
16
|
return {
|
|
17
17
|
cjs: fslib_1.ppath.join(project.cwd, fslib_1.Filename.pnpCjs),
|
|
18
|
-
|
|
19
|
-
esmLoader: fslib_1.ppath.join(project.cwd,
|
|
18
|
+
data: fslib_1.ppath.join(project.cwd, fslib_1.Filename.pnpData),
|
|
19
|
+
esmLoader: fslib_1.ppath.join(project.cwd, fslib_1.Filename.pnpEsmLoader),
|
|
20
20
|
};
|
|
21
21
|
};
|
|
22
22
|
exports.getPnpPath = getPnpPath;
|
|
@@ -25,28 +25,34 @@ const quotePathIfNeeded = (path) => {
|
|
|
25
25
|
};
|
|
26
26
|
exports.quotePathIfNeeded = quotePathIfNeeded;
|
|
27
27
|
async function setupScriptEnvironment(project, env, makePathWrapper) {
|
|
28
|
+
// We still support .pnp.js files to improve multi-project compatibility.
|
|
29
|
+
// TODO: Drop the question mark in the RegExp after .pnp.js files stop being used.
|
|
30
|
+
// TODO: Support `-r` as an alias for `--require` (in all packages)
|
|
31
|
+
const pnpRegularExpression = /\s*--require\s+\S*\.pnp\.c?js\s*/g;
|
|
32
|
+
const esmLoaderExpression = /\s*--experimental-loader\s+\S*\.pnp\.loader\.mjs\s*/;
|
|
33
|
+
const nodeOptions = (env.NODE_OPTIONS ?? ``)
|
|
34
|
+
.replace(pnpRegularExpression, ` `)
|
|
35
|
+
.replace(esmLoaderExpression, ` `)
|
|
36
|
+
.trim();
|
|
37
|
+
// We remove the PnP hook from NODE_OPTIONS because the process can have
|
|
38
|
+
// NODE_OPTIONS set while changing linkers, which affects build scripts.
|
|
39
|
+
if (project.configuration.get(`nodeLinker`) !== `pnp`) {
|
|
40
|
+
env.NODE_OPTIONS = nodeOptions;
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
28
43
|
const pnpPath = (0, exports.getPnpPath)(project);
|
|
29
44
|
let pnpRequire = `--require ${(0, exports.quotePathIfNeeded)(fslib_1.npath.fromPortablePath(pnpPath.cjs))}`;
|
|
30
45
|
if (fslib_1.xfs.existsSync(pnpPath.esmLoader))
|
|
31
46
|
pnpRequire = `${pnpRequire} --experimental-loader ${(0, url_1.pathToFileURL)(fslib_1.npath.fromPortablePath(pnpPath.esmLoader)).href}`;
|
|
32
|
-
if (pnpPath.cjs.includes(` `) && semver_1.default.lt(process.versions.node, `12.0.0`))
|
|
33
|
-
throw new Error(`Expected the build location to not include spaces when using Node < 12.0.0 (${process.versions.node})`);
|
|
34
47
|
if (fslib_1.xfs.existsSync(pnpPath.cjs)) {
|
|
35
|
-
|
|
36
|
-
// We still support .pnp.js files to improve multi-project compatibility.
|
|
37
|
-
// TODO: Drop the question mark in the RegExp after .pnp.js files stop being used.
|
|
38
|
-
const pnpRegularExpression = /\s*--require\s+\S*\.pnp\.c?js\s*/g;
|
|
39
|
-
const esmLoaderExpression = /\s*--experimental-loader\s+\S*\.pnp\.loader\.mjs\s*/;
|
|
40
|
-
nodeOptions = nodeOptions.replace(pnpRegularExpression, ` `).replace(esmLoaderExpression, ` `).trim();
|
|
41
|
-
nodeOptions = nodeOptions ? `${pnpRequire} ${nodeOptions}` : pnpRequire;
|
|
42
|
-
env.NODE_OPTIONS = nodeOptions;
|
|
48
|
+
env.NODE_OPTIONS = nodeOptions ? `${pnpRequire} ${nodeOptions}` : pnpRequire;
|
|
43
49
|
}
|
|
44
50
|
}
|
|
45
51
|
async function populateYarnPaths(project, definePath) {
|
|
46
52
|
const pnpPath = (0, exports.getPnpPath)(project);
|
|
47
53
|
definePath(pnpPath.cjs);
|
|
54
|
+
definePath(pnpPath.data);
|
|
48
55
|
definePath(pnpPath.esmLoader);
|
|
49
|
-
definePath(project.configuration.get(`pnpDataPath`));
|
|
50
56
|
definePath(project.configuration.get(`pnpUnpluggedFolder`));
|
|
51
57
|
}
|
|
52
58
|
const plugin = {
|
|
@@ -60,6 +66,15 @@ const plugin = {
|
|
|
60
66
|
type: core_1.SettingsType.STRING,
|
|
61
67
|
default: `pnp`,
|
|
62
68
|
},
|
|
69
|
+
winLinkType: {
|
|
70
|
+
description: `Whether Yarn should use Windows Junctions or symlinks when creating links on Windows.`,
|
|
71
|
+
type: core_1.SettingsType.STRING,
|
|
72
|
+
values: [
|
|
73
|
+
core_1.WindowsLinkType.JUNCTIONS,
|
|
74
|
+
core_1.WindowsLinkType.SYMLINKS,
|
|
75
|
+
],
|
|
76
|
+
default: core_1.WindowsLinkType.JUNCTIONS,
|
|
77
|
+
},
|
|
63
78
|
pnpMode: {
|
|
64
79
|
description: `If 'strict', generates standard PnP maps. If 'loose', merges them with the n_m resolution.`,
|
|
65
80
|
type: core_1.SettingsType.STRING,
|
|
@@ -96,11 +111,6 @@ const plugin = {
|
|
|
96
111
|
type: core_1.SettingsType.ABSOLUTE_PATH,
|
|
97
112
|
default: `./.yarn/unplugged`,
|
|
98
113
|
},
|
|
99
|
-
pnpDataPath: {
|
|
100
|
-
description: `Path of the file where the PnP data (used by the loader) must be written`,
|
|
101
|
-
type: core_1.SettingsType.ABSOLUTE_PATH,
|
|
102
|
-
default: `./.pnp.data.json`,
|
|
103
|
-
},
|
|
104
114
|
},
|
|
105
115
|
linkers: [
|
|
106
116
|
PnpLinker_1.PnpLinker,
|
package/lib/jsInstallUtils.d.ts
CHANGED
|
@@ -1,18 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Configuration, DependencyMeta, FetchResult, Manifest, Package, BuildRequest } from '@yarnpkg/core';
|
|
2
2
|
export declare function checkManifestCompatibility(pkg: Package): boolean;
|
|
3
|
-
export
|
|
4
|
-
configuration: Configuration;
|
|
5
|
-
report?: Report | null;
|
|
6
|
-
}): boolean;
|
|
7
|
-
export declare type ExtractBuildScriptDataRequirements = {
|
|
3
|
+
export type ExtractBuildScriptDataRequirements = {
|
|
8
4
|
manifest: Pick<Manifest, 'scripts'>;
|
|
9
5
|
misc: {
|
|
10
6
|
hasBindingGyp: boolean;
|
|
11
7
|
};
|
|
12
8
|
};
|
|
13
|
-
export declare function
|
|
9
|
+
export declare function extractBuildRequest(pkg: Package, requirements: ExtractBuildScriptDataRequirements, dependencyMeta: DependencyMeta, { configuration }: {
|
|
14
10
|
configuration: Configuration;
|
|
15
|
-
|
|
16
|
-
}): BuildDirective[];
|
|
11
|
+
}): BuildRequest | null;
|
|
17
12
|
export declare function getExtractHint(fetchResult: FetchResult): boolean;
|
|
18
13
|
export declare function hasBindingGyp(fetchResult: FetchResult): boolean;
|
package/lib/jsInstallUtils.js
CHANGED
|
@@ -1,51 +1,38 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.hasBindingGyp = exports.getExtractHint = exports.
|
|
3
|
+
exports.hasBindingGyp = exports.getExtractHint = exports.extractBuildRequest = exports.checkManifestCompatibility = void 0;
|
|
4
4
|
const core_1 = require("@yarnpkg/core");
|
|
5
5
|
const fslib_1 = require("@yarnpkg/fslib");
|
|
6
6
|
function checkManifestCompatibility(pkg) {
|
|
7
7
|
return core_1.structUtils.isPackageCompatible(pkg, core_1.nodeUtils.getArchitectureSet());
|
|
8
8
|
}
|
|
9
9
|
exports.checkManifestCompatibility = checkManifestCompatibility;
|
|
10
|
-
function
|
|
11
|
-
|
|
12
|
-
report === null || report === void 0 ? void 0 : report.reportWarningOnce(core_1.MessageName.INCOMPATIBLE_ARCHITECTURE, `${core_1.structUtils.prettyLocator(configuration, pkg)} The ${core_1.nodeUtils.getArchitectureName()} architecture is incompatible with this package, ${label} skipped.`);
|
|
13
|
-
return false;
|
|
14
|
-
}
|
|
15
|
-
return true;
|
|
16
|
-
}
|
|
17
|
-
exports.checkAndReportManifestCompatibility = checkAndReportManifestCompatibility;
|
|
18
|
-
function extractBuildScripts(pkg, requirements, dependencyMeta, { configuration, report }) {
|
|
19
|
-
const buildScripts = [];
|
|
10
|
+
function extractBuildRequest(pkg, requirements, dependencyMeta, { configuration }) {
|
|
11
|
+
const directives = [];
|
|
20
12
|
for (const scriptName of [`preinstall`, `install`, `postinstall`])
|
|
21
13
|
if (requirements.manifest.scripts.has(scriptName))
|
|
22
|
-
|
|
14
|
+
directives.push({ type: core_1.BuildDirectiveType.SCRIPT, script: scriptName });
|
|
23
15
|
// Detect cases where a package has a binding.gyp but no install script
|
|
24
16
|
if (!requirements.manifest.scripts.has(`install`) && requirements.misc.hasBindingGyp)
|
|
25
|
-
|
|
26
|
-
if (
|
|
27
|
-
return
|
|
28
|
-
if (pkg.linkType !== core_1.LinkType.HARD)
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
if (
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
report === null || report === void 0 ? void 0 : report.reportWarningOnce(core_1.MessageName.DISABLED_BUILD_SCRIPTS, `${core_1.structUtils.prettyLocator(configuration, pkg)} lists build scripts, but all build scripts have been disabled.`);
|
|
38
|
-
return [];
|
|
39
|
-
}
|
|
40
|
-
const isManifestCompatible = checkAndReportManifestCompatibility(pkg, `build`, { configuration, report });
|
|
41
|
-
if (!isManifestCompatible)
|
|
42
|
-
return [];
|
|
43
|
-
return buildScripts;
|
|
17
|
+
directives.push({ type: core_1.BuildDirectiveType.SHELLCODE, script: `node-gyp rebuild` });
|
|
18
|
+
if (directives.length === 0)
|
|
19
|
+
return null;
|
|
20
|
+
if (pkg.linkType !== core_1.LinkType.HARD)
|
|
21
|
+
return { skipped: true, explain: report => report.reportWarningOnce(core_1.MessageName.SOFT_LINK_BUILD, `${core_1.structUtils.prettyLocator(configuration, pkg)} lists build scripts, but is referenced through a soft link. Soft links don't support build scripts, so they'll be ignored.`) };
|
|
22
|
+
if (dependencyMeta && dependencyMeta.built === false)
|
|
23
|
+
return { skipped: true, explain: report => report.reportInfoOnce(core_1.MessageName.BUILD_DISABLED, `${core_1.structUtils.prettyLocator(configuration, pkg)} lists build scripts, but its build has been explicitly disabled through configuration.`) };
|
|
24
|
+
if (!configuration.get(`enableScripts`) && !dependencyMeta.built)
|
|
25
|
+
return { skipped: true, explain: report => report.reportWarningOnce(core_1.MessageName.DISABLED_BUILD_SCRIPTS, `${core_1.structUtils.prettyLocator(configuration, pkg)} lists build scripts, but all build scripts have been disabled.`) };
|
|
26
|
+
if (!checkManifestCompatibility(pkg))
|
|
27
|
+
return { skipped: true, explain: report => report.reportWarningOnce(core_1.MessageName.INCOMPATIBLE_ARCHITECTURE, `${core_1.structUtils.prettyLocator(configuration, pkg)} The ${core_1.nodeUtils.getArchitectureName()} architecture is incompatible with this package, build skipped.`) };
|
|
28
|
+
return { skipped: false, directives };
|
|
44
29
|
}
|
|
45
|
-
exports.
|
|
30
|
+
exports.extractBuildRequest = extractBuildRequest;
|
|
46
31
|
const FORCED_EXTRACT_FILETYPES = new Set([
|
|
47
32
|
// Windows can't execute exe files inside zip archives
|
|
48
33
|
`.exe`,
|
|
34
|
+
// May be used for some binaries on Linux; https://askubuntu.com/a/174356
|
|
35
|
+
`.bin`,
|
|
49
36
|
// The c/c++ compiler can't read files from zip archives
|
|
50
37
|
`.h`, `.hh`, `.hpp`, `.c`, `.cc`, `.cpp`,
|
|
51
38
|
// The java runtime can't read files from zip archives
|
package/package.json
CHANGED
|
@@ -1,26 +1,28 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yarnpkg/plugin-pnp",
|
|
3
|
-
"version": "4.0.0
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"license": "BSD-2-Clause",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": "./lib/index.js",
|
|
8
|
+
"./package.json": "./package.json"
|
|
9
|
+
},
|
|
6
10
|
"dependencies": {
|
|
7
|
-
"@
|
|
8
|
-
"@yarnpkg/
|
|
9
|
-
"@yarnpkg/
|
|
10
|
-
"
|
|
11
|
-
"clipanion": "^3.2.0-rc.10",
|
|
11
|
+
"@yarnpkg/fslib": "^3.0.0",
|
|
12
|
+
"@yarnpkg/plugin-stage": "^4.0.0",
|
|
13
|
+
"@yarnpkg/pnp": "^4.0.0",
|
|
14
|
+
"clipanion": "^4.0.0-rc.2",
|
|
12
15
|
"micromatch": "^4.0.2",
|
|
13
|
-
"
|
|
14
|
-
"tslib": "^1.13.0"
|
|
16
|
+
"tslib": "^2.4.0"
|
|
15
17
|
},
|
|
16
18
|
"peerDependencies": {
|
|
17
|
-
"@yarnpkg/cli": "^4.0.0
|
|
18
|
-
"@yarnpkg/core": "^4.0.0
|
|
19
|
+
"@yarnpkg/cli": "^4.0.0",
|
|
20
|
+
"@yarnpkg/core": "^4.0.0"
|
|
19
21
|
},
|
|
20
22
|
"devDependencies": {
|
|
21
23
|
"@types/micromatch": "^4.0.1",
|
|
22
|
-
"@yarnpkg/cli": "^4.0.0
|
|
23
|
-
"@yarnpkg/core": "^4.0.0
|
|
24
|
+
"@yarnpkg/cli": "^4.0.0",
|
|
25
|
+
"@yarnpkg/core": "^4.0.0"
|
|
24
26
|
},
|
|
25
27
|
"repository": {
|
|
26
28
|
"type": "git",
|
|
@@ -33,14 +35,15 @@
|
|
|
33
35
|
},
|
|
34
36
|
"publishConfig": {
|
|
35
37
|
"main": "./lib/index.js",
|
|
36
|
-
"
|
|
38
|
+
"exports": {
|
|
39
|
+
".": "./lib/index.js",
|
|
40
|
+
"./package.json": "./package.json"
|
|
41
|
+
}
|
|
37
42
|
},
|
|
38
43
|
"files": [
|
|
39
44
|
"/lib/**/*"
|
|
40
45
|
],
|
|
41
46
|
"engines": {
|
|
42
|
-
"node": ">=
|
|
43
|
-
}
|
|
44
|
-
"stableVersion": "3.2.0",
|
|
45
|
-
"typings": "./lib/index.d.ts"
|
|
47
|
+
"node": ">=18.12.0"
|
|
48
|
+
}
|
|
46
49
|
}
|