-
Notifications
You must be signed in to change notification settings - Fork 173
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add cnpm to corepack #333
Open
elrrrrrrr
wants to merge
12
commits into
nodejs:main
Choose a base branch
from
elrrrrrrr:cnpm
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 11 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
faaac09
feat: add cnpm
elrrrrrrr f281d19
chore: bump version
elrrrrrrr de5f2a6
chore: ci
elrrrrrrr b1a8d92
update Nock files
actions-user e3bc1c5
Update .github/workflows/sync.yml
elrrrrrrr 4af1855
Update sources/nodeUtils.ts
elrrrrrrr b994028
Update tests/main.test.ts
elrrrrrrr 160dcd3
update Nock files
actions-user 2162567
Update tests/main.test.ts
elrrrrrrr dd8f8a4
revert Update tests/main.test.ts
aduh95 8ac771a
Update config.json
elrrrrrrr f3de099
Merge branch 'main' of https://github.com/nodejs/corepack
aduh95 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -5,6 +5,7 @@ export enum SupportedPackageManagers { | |||||||||||||||||
Npm = `npm`, | ||||||||||||||||||
Pnpm = `pnpm`, | ||||||||||||||||||
Yarn = `yarn`, | ||||||||||||||||||
Cnpm = `cnpm`, | ||||||||||||||||||
Comment on lines
5
to
+8
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: ASCII/alphabetical order
Suggested change
|
||||||||||||||||||
} | ||||||||||||||||||
|
||||||||||||||||||
export const SupportedPackageManagerSet = new Set<SupportedPackageManagers>( | ||||||||||||||||||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -79,6 +79,9 @@ const testedPackageManagers: Array<[string, string]> = [ | |
[`pnpm`, `6.6.2`], | ||
[`pnpm`, `6.6.2+sha1.7b4d6b176c1b93b5670ed94c24babb7d80c13854`], | ||
[`pnpm`, `6.6.2+sha224.eb5c0acad3b0f40ecdaa2db9aa5a73134ad256e17e22d1419a2ab073`], | ||
[`cnpm`, `9.3.2`], | ||
elrrrrrrr marked this conversation as resolved.
Show resolved
Hide resolved
|
||
[`cnpm`, `9.3.2+sha1.05a307b7c1d34a368b8d30ff159dfd0533c8c328`], | ||
[`cnpm`, `9.3.2+sha224.6d124ff3ac4ea4ba18833993e063fd8091156d6400ed7a2e5ad47ce3`], | ||
[`npm`, `6.14.2`], | ||
[`npm`, `6.14.2+sha1.f057d35cd4792c4c511bb1fa332edb43143d07b0`], | ||
[`npm`, `6.14.2+sha224.50512c1eb404900ee78586faa6d756b8d867ff46a328e6fb4cdf3a87`], | ||
|
@@ -94,7 +97,7 @@ for (const [name, version] of testedPackageManagers) { | |
await expect(runCli(cwd, [name, `--version`])).resolves.toMatchObject({ | ||
exitCode: 0, | ||
stderr: ``, | ||
stdout: `${version.split(`+`, 1)[0]}\n`, | ||
stdout: expect.stringContaining(version.split(`+`, 1)[0]), | ||
}); | ||
}); | ||
}); | ||
|
@@ -221,6 +224,12 @@ it(`should use the pinned version when local projects don't list any spec`, asyn | |
exitCode: 0, | ||
}); | ||
|
||
await expect(runCli(cwd, [`cnpm`, `--version`])).resolves.toMatchObject({ | ||
stdout: expect.stringContaining(`cnpm@${config.definitions.cnpm.default.split(`+`, 1)[0]}`), | ||
stderr: ``, | ||
exitCode: 0, | ||
}); | ||
|
||
await expect(runCli(cwd, [`npm`, `--version`])).resolves.toMatchObject({ | ||
stdout: `${config.definitions.npm.default.split(`+`, 1)[0]}\n`, | ||
stderr: ``, | ||
|
@@ -306,6 +315,11 @@ it(`should refuse to run a different package manager within a configured project | |
exitCode: 1, | ||
}); | ||
|
||
await expect(runCli(cwd, [`cnpm`, `--version`])).resolves.toMatchObject({ | ||
stdout: `Usage Error: This project is configured to use yarn\n\n$ cnpm ...\n`, | ||
exitCode: 1, | ||
}); | ||
|
||
// Disable strict checking to workaround the UsageError. | ||
process.env.COREPACK_ENABLE_STRICT = `0`; | ||
|
||
|
@@ -320,6 +334,11 @@ it(`should refuse to run a different package manager within a configured project | |
stderr: ``, | ||
exitCode: 0, | ||
}); | ||
await expect(runCli(cwd, [`cnpm`, `--version`])).resolves.toMatchObject({ | ||
stdout: expect.stringContaining(`cnpm@${config.definitions.cnpm.default.split(`+`, 1)[0]}`), | ||
stderr: ``, | ||
exitCode: 0, | ||
}); | ||
} finally { | ||
delete process.env.COREPACK_ENABLE_STRICT; | ||
delete process.env.FORCE_COLOR; | ||
|
@@ -346,6 +365,11 @@ it(`should always use fallback version when project spec env is disabled`, async | |
stderr: ``, | ||
exitCode: 0, | ||
}); | ||
await expect(runCli(cwd, [`cnpm`, `--version`])).resolves.toMatchObject({ | ||
stdout: expect.stringContaining(`cnpm@${config.definitions.cnpm.default.split(`+`, 1)[0]}`), | ||
stderr: ``, | ||
exitCode: 0, | ||
}); | ||
} finally { | ||
delete process.env.COREPACK_ENABLE_PROJECT_SPEC; | ||
} | ||
|
@@ -378,6 +402,12 @@ it(`should allow to call "corepack install -g --all" to prepare all package mana | |
exitCode: 0, | ||
}); | ||
|
||
await expect(runCli(cwd, [`cnpm`, `--version`])).resolves.toMatchObject({ | ||
stdout: expect.stringContaining(`cnpm@${config.definitions.cnpm.default.split(`+`, 1)[0]}`), | ||
stderr: ``, | ||
exitCode: 0, | ||
}); | ||
|
||
await expect(runCli(cwd, [`npm`, `--version`])).resolves.toMatchObject({ | ||
stdout: `${config.definitions.npm.default.split(`+`, 1)[0]}\n`, | ||
stderr: ``, | ||
|
@@ -482,7 +512,7 @@ it(`should support hydrating package managers if cache folder was removed`, asyn | |
|
||
it(`should support hydrating multiple package managers from cached archives`, async () => { | ||
await xfs.mktempPromise(async cwd => { | ||
await expect(runCli(cwd, [`pack`, `[email protected]`, `[email protected]`])).resolves.toMatchObject({ | ||
await expect(runCli(cwd, [`pack`, `[email protected]`, `[email protected]`, `[email protected]`])).resolves.toMatchObject({ | ||
exitCode: 0, | ||
stderr: ``, | ||
}); | ||
|
@@ -518,6 +548,16 @@ it(`should support hydrating multiple package managers from cached archives`, as | |
stderr: ``, | ||
exitCode: 0, | ||
}); | ||
|
||
await xfs.writeJsonPromise(ppath.join(cwd, `package.json` as Filename), { | ||
packageManager: `[email protected]`, | ||
}); | ||
|
||
await expect(runCli(cwd, [`cnpm`, `--version`])).resolves.toMatchObject({ | ||
stdout: expect.stringContaining(`[email protected]`), | ||
stderr: ``, | ||
exitCode: 0, | ||
}); | ||
} finally { | ||
delete process.env.COREPACK_ENABLE_NETWORK; | ||
} | ||
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably provide mentioned for the npm package, see #339