Skip to content

Commit 328ee1f

Browse files
authored
Update references of pmm to Corepack (#59)
* docs: rename pmm -> Corepack * build: use nodejs/corepack repo instead of arcanis/pmm * refactor: rename TS source pmm -> Corepack * docs: fix spelling error
1 parent 3b2961a commit 328ee1f

File tree

5 files changed

+19
-19
lines changed

5 files changed

+19
-19
lines changed

DESIGN.md

+11-11
Original file line numberDiff line numberDiff line change
@@ -16,29 +16,29 @@ Discussion thread: https://github.com/nodejs/node/issues/15244
1616

1717
2. Node would be distributed slightly differently:
1818

19-
- Pmm would be included by Node out of the box.
19+
- Corepack would be included by Node out of the box.
2020

21-
- The full npm package wouldn't be included out of the box anymore (this might be an incremental move, with first a major version shipping pmm + npm, and the next one discarding npm).
21+
- The full npm package wouldn't be included out of the box anymore (this might be an incremental move, with first a major version shipping Corepack + npm, and the next one discarding npm).
2222

23-
- **However**, the Node distribution would include jump binaries for all three main package managers (`yarn`, `npm`, and `pnpm`) that would simply delegate to `pmm <package manager name>`. Pmm would then handle the install logic by following the logic described in later sections.
23+
- **However**, the Node distribution would include jump binaries for all three main package managers (`yarn`, `npm`, and `pnpm`) that would simply delegate to `corepack <package manager name>`. Corepack would then handle the install logic by following the logic described in later sections.
2424

25-
- Pmm could potentially be distributed as a Node subcommand rather than a standalone binary. In this case, commands in this document (such as `pmm install <name@version>`) would be replaced by `node --pmm install <name@version>` (or any other variant).
25+
- Corepack could potentially be distributed as a Node subcommand rather than a standalone binary. In this case, commands in this document (such as `corepack install <name@version>`) would be replaced by `node --corepack install <name@version>` (or any other variant).
2626

2727
3. Regular users would keep using the `yarn` / `npm` / `pnpm` global binaries just like they are used to. The one difference is that the package manager implementations would be lazily downloaded, without having to be manually installed (because the global jumpers would be included in the Node distribution, cf previous point).
2828

29-
- Projects that don't list the `engines.pm` field would allow any package manager, and Pmm would install them based on predefined versions. Those versions will be frozen in time within Pmm itself to "known good values". For example, the default npm version could be 6.14.5, and the default Yarn one 1.22.4. Users that would want to upgrade to higher versions would just have to update the `engines.pm` field (cf next section).
29+
- Projects that don't list the `engines.pm` field would allow any package manager, and Corepack would install them based on predefined versions. Those versions will be frozen in time within Corepack itself to "known good values". For example, the default npm version could be 6.14.5, and the default Yarn one 1.22.4. Users that would want to upgrade to higher versions would just have to update the `engines.pm` field (cf next section).
3030

3131
4. Project authors would most of the time only have to care about the binaries as well, but they would be able to upgrade package manager versions simply by changing the versions set in the `engines.pm` field.
3232

33-
- Pmm could reasonably provide some kind of basic CLI interface to select a version to upgrade to in a few keystrokes (similar to what `emsdk` does for the [emscripten toolchain](https://github.com/emscripten-core/emsdk#how-do-i-check-for-updates-to-the-emscripten-sdk), or what [nvm](https://github.com/nvm-sh/nvm) does for Node releases).
33+
- Corepack could reasonably provide some kind of basic CLI interface to select a version to upgrade to in a few keystrokes (similar to what `emsdk` does for the [emscripten toolchain](https://github.com/emscripten-core/emsdk#how-do-i-check-for-updates-to-the-emscripten-sdk), or what [nvm](https://github.com/nvm-sh/nvm) does for Node releases).
3434

3535
5. Docker users would follow a similar workflow to other users; the default image would run network queries to install the right package manager for the project being installed.
3636

37-
- However, users with strong offline requirements would be able to run the `pmm install <name@version>` command when preparing their images. It would ensure that the requested package manager is made available for later use.
37+
- However, users with strong offline requirements would be able to run the `corepack install <name@version>` command when preparing their images. It would ensure that the requested package manager is made available for later use.
3838

39-
- Network access could be disabled entirely by setting `PMM_ENABLE_NETWORK=0` in the environmen - Pmm would then only use the package managers that got installed by prior `pmm install` calls.
39+
- Network access could be disabled entirely by setting `COREPACK_ENABLE_NETWORK=0` in the environment - Corepack would then only use the package managers that got installed by prior `corepack install` calls.
4040

41-
6. Package manager maintainers would submit a PR to the Node repository each time they wish for a new version to be made available through Pmm (can be easily automated using a GitHub Action on each of our repositories). Merging the PR would instantly make the new version available to Node users (once they upgrade).
41+
6. Package manager maintainers would submit a PR to the Node repository each time they wish for a new version to be made available through Corepack (can be easily automated using a GitHub Action on each of our repositories). Merging the PR would instantly make the new version available to Node users (once they upgrade).
4242

4343
## How does it work?
4444

@@ -70,8 +70,8 @@ Nothing would change in the context of this particular proposal. Npm would keep
7070

7171
While npm is favored by the majority of the ecosystem, a significant portion decided to use different tools. Their use cases deserve to be heard rather than be discarded simply because a slightly higher percentage of users happens not to directly benefit from it. Additionally, keeping powers balanced is important - even more so given that npm is a corporate entity with little oversight.
7272

73-
From the npm perspective, a project such as Pmm would also have its benefits: projects regularly break when upgrading from one Node version to another because of npm being upgraded as well. By pinning the package manager version, they would ensure that their users only upgrade when they are ready to, decreasing accidental frustration.
73+
From the npm perspective, a project such as Corepack would also have its benefits: projects regularly break when upgrading from one Node version to another because of npm being upgraded as well. By pinning the package manager version, they would ensure that their users only upgrade when they are ready to, decreasing accidental frustration.
7474

7575
## Known issues
7676

77-
- The `pnpx` and `npx` binaries can only be called from within pnpm and npm projects, respectively. This is because otherwise we cannot infer the package manager version from the local manifest, as it would list another package manager instead. Fixing that is possible if we include "global installs" features inside pmm (so that we would fallback to the global `npx` in those circumstances). It seemed out of scope for the initial prototype, but we certainly can discuss it in an issue.
77+
- The `pnpx` and `npx` binaries can only be called from within pnpm and npm projects, respectively. This is because otherwise we cannot infer the package manager version from the local manifest, as it would list another package manager instead. Fixing that is possible if we include "global installs" features inside corepack (so that we would fallback to the global `npx` in those circumstances). It seemed out of scope for the initial prototype, but we certainly can discuss it in an issue.

docker/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ RUN rm -rf /opt/node/lib /opt/node/bin/npm /opt/node/bin/npx
1111
ENV PATH="/opt/node/bin:$PATH"
1212
RUN which node && node --version
1313

14-
RUN wget https://github.com/arcanis/pmm/archive/master.tar.gz -O - | tar -xz --strip-components=1 -C /opt/corepack && cd /opt/corepack && node ./.yarn/releases/yarn-*.js build
14+
RUN wget https://github.com/nodejs/corepack/archive/master.tar.gz -O - | tar -xz --strip-components=1 -C /opt/corepack && cd /opt/corepack && node ./.yarn/releases/yarn-*.js build
1515

1616
ENV PATH="/opt/corepack/shims:$PATH"

sources/Engine.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import semver from 'semver';
66
import defaultConfig from '../config.json';
77

88
import * as folderUtils from './folderUtils';
9-
import * as pmmUtils from './pmmUtils';
9+
import * as corepackUtils from './corepackUtils';
1010
import * as semverUtils from './semverUtils';
1111
import {SupportedPackageManagers, SupportedPackageManagerSet} from './types';
1212
import {Config, Descriptor, Locator} from './types';
@@ -111,7 +111,7 @@ export class Engine {
111111
if (typeof range === `undefined`)
112112
throw new Error(`Assertion failed: Specified resolution (${locator.reference}) isn't supported by any of ${ranges.join(`, `)}`);
113113

114-
const installedLocation = await pmmUtils.installVersion(folderUtils.getInstallFolder(), locator, {
114+
const installedLocation = await corepackUtils.installVersion(folderUtils.getInstallFolder(), locator, {
115115
spec: definition.ranges[range],
116116
});
117117

@@ -135,7 +135,7 @@ export class Engine {
135135
const ranges = Object.keys(definition.ranges);
136136
const tagRange = ranges[ranges.length - 1];
137137

138-
const tags = await pmmUtils.fetchAvailableTags(definition.ranges[tagRange].registry);
138+
const tags = await corepackUtils.fetchAvailableTags(definition.ranges[tagRange].registry);
139139
if (!Object.prototype.hasOwnProperty.call(tags, descriptor.range))
140140
throw new UsageError(`Tag not found (${descriptor.range})`);
141141

@@ -147,7 +147,7 @@ export class Engine {
147147

148148
// If a compatible version is already installed, no need to query one
149149
// from the remote listings
150-
const cachedVersion = await pmmUtils.findInstalledVersion(folderUtils.getInstallFolder(), finalDescriptor);
150+
const cachedVersion = await corepackUtils.findInstalledVersion(folderUtils.getInstallFolder(), finalDescriptor);
151151
if (cachedVersion !== null && useCache)
152152
return {name: finalDescriptor.name, reference: cachedVersion};
153153

@@ -156,7 +156,7 @@ export class Engine {
156156
});
157157

158158
const tagResolutions = await Promise.all(candidateRangeDefinitions.map(async range => {
159-
return [range, await pmmUtils.fetchAvailableVersions(definition.ranges[range].registry)] as const;
159+
return [range, await corepackUtils.fetchAvailableVersions(definition.ranges[range].registry)] as const;
160160
}));
161161

162162
// If a version is available under multiple strategies (for example if
File renamed without changes.

sources/main.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {EnableCommand} from './command
66
import {HydrateCommand} from './commands/Hydrate';
77
import {PrepareCommand} from './commands/Prepare';
88
import * as miscUtils from './miscUtils';
9-
import * as pmmUtils from './pmmUtils';
9+
import * as corepackUtils from './corepackUtils';
1010
import * as specUtils from './specUtils';
1111
import {Locator, SupportedPackageManagers, Descriptor} from './types';
1212

@@ -82,7 +82,7 @@ async function executePackageManagerRequest({packageManager, binaryName, binaryV
8282
throw new UsageError(`Failed to successfully resolve '${descriptor.range}' to a valid ${descriptor.name} release`);
8383

8484
const installSpec = await context.engine.ensurePackageManager(resolved);
85-
const exitCode = await pmmUtils.runVersion(installSpec, resolved, binaryName, args, context);
85+
const exitCode = await corepackUtils.runVersion(installSpec, resolved, binaryName, args, context);
8686

8787
return exitCode;
8888
}

0 commit comments

Comments
 (0)