Skip to content
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

fix(deploy): inject all types of deps #5084

Merged
merged 1 commit into from
Jul 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/loud-weeks-move.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@pnpm/plugin-commands-deploy": patch
"pnpm": patch
---

`pnpm deploy` should inject local dependencies of all types (dependencies, optionalDependencies, devDependencies) [#5078](https://github.com/pnpm/pnpm/issues/5078).
1 change: 1 addition & 0 deletions packages/plugin-commands-deploy/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
"@pnpm/error": "workspace:*",
"@pnpm/fs.indexed-pkg-importer": "workspace:*",
"@pnpm/plugin-commands-installation": "workspace:*",
"@pnpm/types": "workspace:*",
"@zkochan/rimraf": "^2.1.2",
"render-help": "^1.0.2"
},
Expand Down
13 changes: 1 addition & 12 deletions packages/plugin-commands-deploy/src/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { install } from '@pnpm/plugin-commands-installation'
import PnpmError from '@pnpm/error'
import rimraf from '@zkochan/rimraf'
import renderHelp from 'render-help'
import { deployHook } from './deployHook'

export const shorthands = install.shorthands

Expand Down Expand Up @@ -99,15 +100,3 @@ async function copyProject (src: string, dest: string) {
const importPkg = createIndexedPkgImporter('clone-or-copy')
await importPkg(dest, { filesMap: filesIndex, force: true, fromStore: true })
}

function deployHook (pkg: any) { // eslint-disable-line
pkg.dependenciesMeta = pkg.dependenciesMeta || {}
for (const [depName, depVersion] of Object.entries(pkg.dependencies ?? {})) {
if ((depVersion as string).startsWith('workspace:')) {
pkg.dependenciesMeta[depName] = {
injected: true,
}
}
}
return pkg
}
15 changes: 15 additions & 0 deletions packages/plugin-commands-deploy/src/deployHook.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { DEPENDENCIES_FIELDS } from '@pnpm/types'

export function deployHook (pkg: any) { // eslint-disable-line
pkg.dependenciesMeta = pkg.dependenciesMeta || {}
for (const depField of DEPENDENCIES_FIELDS) {
for (const [depName, depVersion] of Object.entries(pkg[depField] ?? {})) {
if ((depVersion as string).startsWith('workspace:')) {
pkg.dependenciesMeta[depName] = {
injected: true,
}
}
}
}
return pkg
}
36 changes: 36 additions & 0 deletions packages/plugin-commands-deploy/test/deployHook.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { deployHook } from '../src/deployHook'

test('deployHook()', () => {
expect(deployHook({
dependencies: {
a: 'workspace:1',
},
devDependencies: {
b: 'workspace:2',
},
optionalDependencies: {
c: 'workspace:3',
},
})).toStrictEqual({
dependencies: {
a: 'workspace:1',
},
devDependencies: {
b: 'workspace:2',
},
optionalDependencies: {
c: 'workspace:3',
},
dependenciesMeta: {
a: {
injected: true,
},
b: {
injected: true,
},
c: {
injected: true,
},
},
})
})
3 changes: 3 additions & 0 deletions packages/plugin-commands-deploy/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@
},
{
"path": "../plugin-commands-installation"
},
{
"path": "../types"
}
]
}
2 changes: 2 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.