You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit dec830b
Browse filesBrowse the repository at this point in the historyBrowse files
feat: use range from devEngines when no packageManager is set (#892)
Using Corepack without setting a `packageManager` is not recommended,
but given that no errors is thrown when no `devEngines` is set,
the behavior should be the same when one is set to a parsable range.
Disable this behavior with `COREPACK_ON_UNVERIFIED_DOWNLOAD` environment variable.
specUtils.warnOrThrow(`This project is configured to use ${devEnginesValue.name} because ${result.target} has a "devEngines.packageManager" field`,devEnginesValue.onFail);
thrownewUsageError(`Couldn't find a project in the local directory - please specify the package manager to pack, or run this command from a valid project`);
17
17
18
-
case`NoSpec`:
19
-
thrownewUsageError(`The local project doesn't feature a 'packageManager' field nor a 'devEngines.packageManager' field - please specify the package manager to pack, or update the manifest to reference it`);
thrownewUsageError(`The local project doesn't feature a 'packageManager' field ${devEnginesValue ? `` : `nor a 'devEngines.packageManager' field `}- please specify the package manager to pack, or update the manifest to reference it`);
Copy file name to clipboardExpand all lines: sources/commands/deprecated/Prepare.ts
+8-2Lines changed: 8 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -38,8 +38,14 @@ export class PrepareCommand extends Command<Context> {
38
38
case`NoProject`:
39
39
thrownewUsageError(`Couldn't find a project in the local directory - please specify the package manager to pack, or run this command from a valid project`);
40
40
41
-
case`NoSpec`:
42
-
thrownewUsageError(`The local project doesn't feature a 'packageManager' field - please specify the package manager to pack, or update the manifest to reference it`);
thrownewUsageError(`The local project doesn't feature a 'packageManager' field ${devEnginesValue ? `` : `nor a 'devEngines.packageManager' field `}- please specify the package manager to pack, or update the manifest to reference it`);
console.warn(`! Corepack only supports objects as valid value for devEngines.packageManager. The current value (${JSON.stringify(packageManager)}) will be ignored.`);
87
-
returnpm;
98
+
return{packageManagerField: pm};
88
99
}
89
100
if(Array.isArray(packageManager)){
90
101
console.warn(`! Corepack does not currently support array values for devEngines.packageManager`);
91
-
returnpm;
102
+
return{packageManagerField: pm};
92
103
}
93
104
94
105
const{name, version, onFail}=packageManager;
95
106
if(typeofname!==`string`||name.includes(`@`)){
96
107
warnOrThrow(`The value of devEngines.packageManager.name ${JSON.stringify(name)} is not a supported string value`,onFail);
warnOrThrow(`The value of devEngines.packageManager.version ${JSON.stringify(version)} is not a valid semver range`,onFail);
101
-
returnpm;
112
+
return{packageManagerField: pm};
102
113
}
103
114
104
-
debugUtils.log(`devEngines.packageManager defines that ${name}@${version} is the local package manager`);
115
+
debugUtils.log(`devEngines.packageManager defines that ${name}${version ? `@${version}` : ``} should be the local package manager`);
105
116
106
117
if(pm){
107
-
if(!pm.startsWith?.(`${name}@`))
118
+
if(!pm.startsWith?.(`${name}@`)){
108
119
warnOrThrow(`"packageManager" field is set to ${JSON.stringify(pm)} which does not match the "devEngines.packageManager" field set to ${JSON.stringify(name)}`,onFail);
warnOrThrow(`"packageManager" field is set to ${JSON.stringify(pm)} which does not match the value defined in "devEngines.packageManager" for ${JSON.stringify(name)} of ${JSON.stringify(version)}`,onFail);
warnOrThrow(`The requested version of ${info.locator.name}@${info.locator.reference} does not match the devEngines specification (${range.name}@${range.range})`,range.onFail);
warnOrThrow(`The requested version of ${info.locator.name}@${info.locator.reference} does not match the devEngines specification (${devEnginesValue.name}@${devEnginesValue.version??`*`})`,devEnginesValue.onFail);
0 commit comments