mirror of
https://github.com/pnpm/pnpm.git
synced 2025-12-24 07:38:12 -05:00
This reverts commit d57e4de6dc.
This reverts #6943
This will solve:
- https://github.com/pnpm/pnpm/issues/7040
- https://github.com/pnpm/pnpm/issues/6994
This commit is contained in:
8
.changeset/quick-pots-promise.md
Normal file
8
.changeset/quick-pots-promise.md
Normal file
@@ -0,0 +1,8 @@
|
||||
---
|
||||
"@pnpm/plugin-commands-deploy": patch
|
||||
"@pnpm/directory-fetcher": patch
|
||||
"pnpm": patch
|
||||
---
|
||||
|
||||
Reverting a change shipped in v8.7 that caused issues with the `pnpm deploy` command and "injected dependencies" [#6943](https://github.com/pnpm/pnpm/pull/6943).
|
||||
|
||||
@@ -34,13 +34,10 @@
|
||||
"@pnpm/logger": "^5.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@pnpm/exportable-manifest": "workspace:*",
|
||||
"@pnpm/fetcher-base": "workspace:*",
|
||||
"@pnpm/read-project-manifest": "workspace:*",
|
||||
"@pnpm/resolver-base": "workspace:*",
|
||||
"@pnpm/types": "workspace:*",
|
||||
"@pnpm/write-project-manifest": "workspace:*",
|
||||
"fast-deep-equal": "^3.1.3",
|
||||
"npm-packlist": "^5.1.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
@@ -1,12 +1,9 @@
|
||||
import { promises as fs, type Stats } from 'fs'
|
||||
import path from 'path'
|
||||
import { createExportableManifest } from '@pnpm/exportable-manifest'
|
||||
import type { DirectoryFetcher, DirectoryFetcherOptions } from '@pnpm/fetcher-base'
|
||||
import { logger } from '@pnpm/logger'
|
||||
import { safeReadProjectManifestOnly } from '@pnpm/read-project-manifest'
|
||||
import { type DependencyManifest } from '@pnpm/types'
|
||||
import { writeProjectManifest } from '@pnpm/write-project-manifest'
|
||||
import equal from 'fast-deep-equal'
|
||||
import packlist from 'npm-packlist'
|
||||
|
||||
const directoryFetcherLogger = logger('directory-fetcher')
|
||||
@@ -51,7 +48,13 @@ async function fetchAllFilesFromDir (
|
||||
opts: FetchFromDirOpts
|
||||
) {
|
||||
const filesIndex = await _fetchAllFilesFromDir(readFileStat, dir)
|
||||
const manifest = await safeReadProjectManifestAndMakeExportable(dir, filesIndex)
|
||||
let manifest: DependencyManifest | undefined
|
||||
if (opts.readManifest) {
|
||||
// In a regular pnpm workspace it will probably never happen that a dependency has no package.json file.
|
||||
// Safe read was added to support the Bit workspace in which the components have no package.json files.
|
||||
// Related PR in Bit: https://github.com/teambit/bit/pull/5251
|
||||
manifest = await safeReadProjectManifestOnly(dir) as DependencyManifest ?? undefined
|
||||
}
|
||||
return {
|
||||
local: true as const,
|
||||
filesIndex,
|
||||
@@ -127,7 +130,13 @@ async function fetchPackageFilesFromDir (
|
||||
) {
|
||||
const files = await packlist({ path: dir })
|
||||
const filesIndex: Record<string, string> = Object.fromEntries(files.map((file) => [file, path.join(dir, file)]))
|
||||
const manifest = await safeReadProjectManifestAndMakeExportable(dir, filesIndex)
|
||||
let manifest: DependencyManifest | undefined
|
||||
if (opts.readManifest) {
|
||||
// In a regular pnpm workspace it will probably never happen that a dependency has no package.json file.
|
||||
// Safe read was added to support the Bit workspace in which the components have no package.json files.
|
||||
// Related PR in Bit: https://github.com/teambit/bit/pull/5251
|
||||
manifest = await safeReadProjectManifestOnly(dir) as DependencyManifest ?? undefined
|
||||
}
|
||||
return {
|
||||
local: true as const,
|
||||
filesIndex,
|
||||
@@ -135,20 +144,3 @@ async function fetchPackageFilesFromDir (
|
||||
manifest,
|
||||
}
|
||||
}
|
||||
|
||||
async function safeReadProjectManifestAndMakeExportable (
|
||||
dir: string,
|
||||
filesIndex: Record<string, string>
|
||||
): Promise<DependencyManifest | undefined> {
|
||||
const manifest = await safeReadProjectManifestOnly(dir) as DependencyManifest
|
||||
// In a regular pnpm workspace it will probably never happen that a dependency has no package.json file.
|
||||
// Safe read was added to support the Bit workspace in which the components have no package.json files.
|
||||
// Related PR in Bit: https://github.com/teambit/bit/pull/5251
|
||||
if (!manifest) return undefined
|
||||
const exportableManifest = await createExportableManifest(dir, manifest)
|
||||
if (equal(manifest, exportableManifest)) return manifest
|
||||
const manifestPathOverride = path.join(dir, 'node_modules/.pnpm/package.json')
|
||||
await writeProjectManifest(manifestPathOverride, exportableManifest)
|
||||
filesIndex['package.json'] = manifestPathOverride
|
||||
return manifest
|
||||
}
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
{
|
||||
"name": "exportable",
|
||||
"version": "1.0.0",
|
||||
"main": "src/index.ts",
|
||||
"publishConfig": {
|
||||
"main": "dist/index.js"
|
||||
}
|
||||
}
|
||||
@@ -153,24 +153,3 @@ describe('fetch resolves symlinked files to their real locations', () => {
|
||||
expect(fetchResult.filesIndex['src/index.js']).toBe(path.resolve('src/index.js'))
|
||||
})
|
||||
})
|
||||
|
||||
test('fetch should return exportable manifest', async () => {
|
||||
process.chdir(f.find('exportable-manifest'))
|
||||
const fetcher = createDirectoryFetcher()
|
||||
|
||||
// eslint-disable-next-line
|
||||
const fetchResult = await fetcher.directory({} as any, {
|
||||
directory: '.',
|
||||
type: 'directory',
|
||||
}, {
|
||||
lockfileDir: process.cwd(),
|
||||
})
|
||||
|
||||
expect(fetchResult.filesIndex['package.json']).not.toBe(path.resolve('package.json'))
|
||||
|
||||
expect(JSON.parse(fs.readFileSync(fetchResult.filesIndex['package.json'], 'utf8'))).toStrictEqual({
|
||||
name: 'exportable',
|
||||
version: '1.0.0',
|
||||
main: 'dist/index.js',
|
||||
})
|
||||
})
|
||||
|
||||
@@ -15,15 +15,9 @@
|
||||
{
|
||||
"path": "../../packages/types"
|
||||
},
|
||||
{
|
||||
"path": "../../pkg-manifest/exportable-manifest"
|
||||
},
|
||||
{
|
||||
"path": "../../pkg-manifest/read-project-manifest"
|
||||
},
|
||||
{
|
||||
"path": "../../pkg-manifest/write-project-manifest"
|
||||
},
|
||||
{
|
||||
"path": "../../resolving/resolver-base"
|
||||
},
|
||||
|
||||
23
pnpm-lock.yaml
generated
23
pnpm-lock.yaml
generated
@@ -1462,9 +1462,6 @@ importers:
|
||||
|
||||
fetching/directory-fetcher:
|
||||
dependencies:
|
||||
'@pnpm/exportable-manifest':
|
||||
specifier: workspace:*
|
||||
version: link:../../pkg-manifest/exportable-manifest
|
||||
'@pnpm/fetcher-base':
|
||||
specifier: workspace:*
|
||||
version: link:../fetcher-base
|
||||
@@ -1480,12 +1477,6 @@ importers:
|
||||
'@pnpm/types':
|
||||
specifier: workspace:*
|
||||
version: link:../../packages/types
|
||||
'@pnpm/write-project-manifest':
|
||||
specifier: workspace:*
|
||||
version: link:../../pkg-manifest/write-project-manifest
|
||||
fast-deep-equal:
|
||||
specifier: ^3.1.3
|
||||
version: 3.1.3
|
||||
npm-packlist:
|
||||
specifier: ^5.1.3
|
||||
version: 5.1.3
|
||||
@@ -4676,18 +4667,6 @@ importers:
|
||||
'@pnpm/registry-mock':
|
||||
specifier: 3.11.0
|
||||
version: 3.11.0(typanion@3.14.0)
|
||||
'@types/cross-spawn':
|
||||
specifier: ^6.0.2
|
||||
version: 6.0.2
|
||||
cross-spawn:
|
||||
specifier: ^7.0.3
|
||||
version: 7.0.3
|
||||
load-json-file:
|
||||
specifier: ^6.2.0
|
||||
version: 6.2.0
|
||||
write-yaml-file:
|
||||
specifier: ^5.0.0
|
||||
version: 5.0.0
|
||||
|
||||
releasing/plugin-commands-publishing:
|
||||
dependencies:
|
||||
@@ -9007,7 +8986,7 @@ packages:
|
||||
resolution: {integrity: sha512-YmG+oTBCyrAoMIx5g2I9CfyurSpHyoan+9SCj7laaFKseOe3lFEyIVKvwRBQMmSt8uzh+eY5RWeQnoyyOs6AbA==}
|
||||
engines: {node: '>=14.15.0'}
|
||||
peerDependencies:
|
||||
'@yarnpkg/fslib': 3.0.0-rc.45
|
||||
'@yarnpkg/fslib': 3.0.0-rc.25
|
||||
dependencies:
|
||||
'@types/emscripten': 1.39.7
|
||||
'@yarnpkg/fslib': 3.0.0-rc.25
|
||||
|
||||
@@ -39,11 +39,7 @@
|
||||
"@pnpm/lockfile-types": "workspace:*",
|
||||
"@pnpm/plugin-commands-deploy": "workspace:*",
|
||||
"@pnpm/prepare": "workspace:*",
|
||||
"@pnpm/registry-mock": "3.11.0",
|
||||
"@types/cross-spawn": "^6.0.2",
|
||||
"cross-spawn": "^7.0.3",
|
||||
"load-json-file": "^6.2.0",
|
||||
"write-yaml-file": "^5.0.0"
|
||||
"@pnpm/registry-mock": "3.11.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@pnpm/cli-utils": "workspace:*",
|
||||
|
||||
@@ -3,15 +3,9 @@ import path from 'path'
|
||||
import { deploy } from '@pnpm/plugin-commands-deploy'
|
||||
import { assertProject } from '@pnpm/assert-project'
|
||||
import { preparePackages } from '@pnpm/prepare'
|
||||
import { REGISTRY_MOCK_PORT } from '@pnpm/registry-mock'
|
||||
import { readProjects } from '@pnpm/filter-workspace-packages'
|
||||
import crossSpawn from 'cross-spawn'
|
||||
import { sync as loadJsonFile } from 'load-json-file'
|
||||
import writeYamlFile from 'write-yaml-file'
|
||||
import { DEFAULT_OPTS } from './utils'
|
||||
|
||||
const pnpmBin = path.join(__dirname, '../../../pnpm/bin/pnpm.cjs')
|
||||
|
||||
test('deploy', async () => {
|
||||
preparePackages([
|
||||
{
|
||||
@@ -26,10 +20,6 @@ test('deploy', async () => {
|
||||
'project-3': 'workspace:*',
|
||||
'is-negative': '1.0.0',
|
||||
},
|
||||
main: 'local-file-1.js',
|
||||
publishConfig: {
|
||||
main: 'publish-file-1.js',
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'project-2',
|
||||
@@ -39,10 +29,6 @@ test('deploy', async () => {
|
||||
'project-3': 'workspace:*',
|
||||
'is-odd': '1.0.0',
|
||||
},
|
||||
main: 'local-file-2.js',
|
||||
publishConfig: {
|
||||
main: 'publish-file-2.js',
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'project-3',
|
||||
@@ -60,10 +46,6 @@ test('deploy', async () => {
|
||||
fs.writeFileSync(`${name}/index.js`, '', 'utf8')
|
||||
})
|
||||
|
||||
await writeYamlFile('pnpm-workspace.yaml', { packages: ['*'] })
|
||||
crossSpawn.sync(pnpmBin, ['install', '--ignore-scripts', '--store-dir=../store', `--registry=http://localhost:${REGISTRY_MOCK_PORT}`])
|
||||
fs.rmSync('pnpm-lock.yaml')
|
||||
|
||||
const { allProjects, selectedProjectsGraph } = await readProjects(process.cwd(), [{ namePattern: 'project-1' }])
|
||||
|
||||
await deploy.handler({
|
||||
@@ -91,26 +73,6 @@ test('deploy', async () => {
|
||||
expect(fs.existsSync('deploy/node_modules/.pnpm/file+project-3/node_modules/project-3/index.js')).toBeTruthy()
|
||||
expect(fs.existsSync('deploy/node_modules/.pnpm/file+project-3/node_modules/project-3/test.js')).toBeFalsy()
|
||||
expect(fs.existsSync('pnpm-lock.yaml')).toBeFalsy() // no changes to the lockfile are written
|
||||
const project1Manifest = loadJsonFile('deploy/package.json')
|
||||
expect(project1Manifest).toMatchObject({
|
||||
name: 'project-1',
|
||||
main: 'publish-file-1.js',
|
||||
dependencies: {
|
||||
'is-positive': '1.0.0',
|
||||
'project-2': '2.0.0',
|
||||
},
|
||||
})
|
||||
expect(project1Manifest).not.toHaveProperty('publishConfig')
|
||||
const project2Manifest = loadJsonFile('deploy/node_modules/.pnpm/file+project-2/node_modules/project-2/package.json')
|
||||
expect(project2Manifest).toMatchObject({
|
||||
name: 'project-2',
|
||||
main: 'publish-file-2.js',
|
||||
dependencies: {
|
||||
'project-3': '2.0.0',
|
||||
'is-odd': '1.0.0',
|
||||
},
|
||||
})
|
||||
expect(project2Manifest).not.toHaveProperty('publishConfig')
|
||||
})
|
||||
|
||||
test('deploy with dedupePeerDependents=true ignores the value of dedupePeerDependents', async () => {
|
||||
|
||||
Reference in New Issue
Block a user