Skip to content

Commit

Permalink
fix: packing the same file twice during publish
Browse files Browse the repository at this point in the history
close #6997
  • Loading branch information
zkochan committed Oct 27, 2023
1 parent 8abd9be commit 50a08c5
Show file tree
Hide file tree
Showing 10 changed files with 703 additions and 63 deletions.
1 change: 1 addition & 0 deletions cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@
"noproxy",
"nosystem",
"nothrow",
"npmcli",
"npmignore",
"npmjs",
"ofjergrg",
Expand Down
4 changes: 3 additions & 1 deletion fetching/directory-fetcher/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,18 @@
"@pnpm/logger": "^5.0.0"
},
"dependencies": {
"@npmcli/arborist": "7.2.0",
"@pnpm/fetcher-base": "workspace:*",
"@pnpm/read-project-manifest": "workspace:*",
"@pnpm/resolver-base": "workspace:*",
"@pnpm/types": "workspace:*",
"npm-packlist": "^5.1.3"
"npm-packlist": "^8.0.0"
},
"devDependencies": {
"@pnpm/directory-fetcher": "workspace:*",
"@pnpm/test-fixtures": "workspace:*",
"@types/npm-packlist": "^3.0.0",
"@types/npmcli__arborist": "5.6.4",
"@zkochan/rimraf": "^2.1.3"
},
"exports": {
Expand Down
5 changes: 4 additions & 1 deletion fetching/directory-fetcher/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import type { DirectoryFetcher, DirectoryFetcherOptions } from '@pnpm/fetcher-ba
import { logger } from '@pnpm/logger'
import { safeReadProjectManifestOnly } from '@pnpm/read-project-manifest'
import { type DependencyManifest } from '@pnpm/types'
import Arborist from '@npmcli/arborist'
import packlist from 'npm-packlist'

const directoryFetcherLogger = logger('directory-fetcher')
Expand Down Expand Up @@ -128,7 +129,9 @@ async function fetchPackageFilesFromDir (
dir: string,
opts: FetchFromDirOpts
) {
const files = await packlist({ path: dir })
const arborist = new Arborist(({ path: dir }))
const tree = await arborist.loadActual()
const files = await packlist(tree)
const filesIndex: Record<string, string> = Object.fromEntries(files.map((file) => [file, path.join(dir, file)]))
let manifest: DependencyManifest | undefined
if (opts.readManifest) {
Expand Down
4 changes: 3 additions & 1 deletion patching/plugin-commands-patching/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,13 @@
"@pnpm/test-fixtures": "workspace:*",
"@types/normalize-path": "^3.0.1",
"@types/npm-packlist": "^3.0.0",
"@types/npmcli__arborist": "5.6.4",
"@types/ramda": "0.28.20",
"@types/semver": "7.5.3",
"write-yaml-file": "^5.0.0"
},
"dependencies": {
"@npmcli/arborist": "7.2.0",
"@pnpm/cli-utils": "workspace:*",
"@pnpm/config": "workspace:*",
"@pnpm/constants": "workspace:*",
Expand All @@ -62,7 +64,7 @@
"escape-string-regexp": "^4.0.0",
"fast-glob": "^3.3.1",
"normalize-path": "^3.0.0",
"npm-packlist": "^5.1.3",
"npm-packlist": "^8.0.0",
"ramda": "npm:@pnpm/ramda@0.28.1",
"realpath-missing": "^1.1.0",
"render-help": "^1.0.3",
Expand Down
5 changes: 4 additions & 1 deletion patching/plugin-commands-patching/src/patchCommit.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import fs from 'fs'
import path from 'path'
import Arborist from '@npmcli/arborist'
import { docsUrl } from '@pnpm/cli-utils'
import { type Config, types as allTypes } from '@pnpm/config'
import { install } from '@pnpm/plugin-commands-installation'
Expand Down Expand Up @@ -157,7 +158,9 @@ function removeTrailingAndLeadingSlash (p: string) {
* This is required in order for the diff to not include files that are not part of the package.
*/
async function preparePkgFilesForDiff (src: string): Promise<string> {
const files = Array.from(new Set((await packlist({ path: src })).map((f) => path.join(f))))
const arborist = new Arborist(({ path: src }))
const tree = await arborist.loadActual()
const files = Array.from(new Set((await packlist(tree)).map((f) => path.join(f))))
// If there are no extra files in the source directories, then there is no reason
// to copy.
if (await areAllFilesInPkg(files, src)) {
Expand Down

0 comments on commit 50a08c5

Please sign in to comment.