Skip to content

Commit

Permalink
Add pnpm commands for migration guide
Browse files Browse the repository at this point in the history
  • Loading branch information
ai committed Dec 25, 2021
1 parent 9474740 commit 2d931b8
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 0 deletions.
6 changes: 6 additions & 0 deletions fixtures/legacy-pnpm/package.json
@@ -0,0 +1,6 @@
{
"private": true,
"devDependencies": {
"size-limit": ">= 0.0.0"
}
}
Empty file.
3 changes: 3 additions & 0 deletions packages/size-limit/create-help.js
Expand Up @@ -10,6 +10,9 @@ function npmCommands(pkg) {
if (existsSync(join(pkg.path, '..', 'yarn.lock'))) {
add = 'yarn add --dev '
rm = 'yarn remove '
} else if (existsSync(join(pkg.path, '..', 'pnpm-lock.yaml'))) {
add = 'pnpm add --save-dev '
rm = 'pnpm remove '
}
return { add, rm }
}
Expand Down
17 changes: 17 additions & 0 deletions packages/size-limit/test/__snapshots__/run.test.js.snap
Expand Up @@ -275,6 +275,23 @@ You need to add size-limit dependency: npm install --save-dev size-limit[3
"
`;

exports[`run shows migration guide for pnpm users 1`] = `
"Install Size Limit preset depends on type of the project
For application, where you send JS bundle directly to users
pnpm add --save-dev @size-limit/preset-app
For frameworks, components and big libraries
pnpm add --save-dev @size-limit/preset-big-lib
For small (< 10 kB) libraries
pnpm add --save-dev @size-limit/preset-small-lib
Check out docs for more complicated cases
https://github.com/ai/size-limit/
"
`;

exports[`run shows migration guide for yarn users 1`] = `
"Install Size Limit preset depends on type of the project
Expand Down
4 changes: 4 additions & 0 deletions packages/size-limit/test/run.test.js
Expand Up @@ -140,6 +140,10 @@ describe(`run`, () => {
expect(await error('legacy-yarn')).toMatchSnapshot()
})

it('shows migration guide for pnpm users', async () => {
expect(await error('legacy-pnpm')).toMatchSnapshot()
})

it('shows migration guide for npm users: config 1, dep 0', async () => {
let [process, history] = createProcess('npm-with-config-without-dev')
await run(process)
Expand Down

0 comments on commit 2d931b8

Please sign in to comment.