diff --git a/.changeset/quick-starfishes-fold.md b/.changeset/quick-starfishes-fold.md new file mode 100644 index 0000000000..e9ff57edad --- /dev/null +++ b/.changeset/quick-starfishes-fold.md @@ -0,0 +1,6 @@ +--- +"@pnpm/package-requester": patch +"@pnpm/tarball-fetcher": patch +--- + +Use `fs.mkdir` instead of the `make-dir` package. diff --git a/packages/package-requester/package.json b/packages/package-requester/package.json index 3643fc16f1..25e6c7ea1c 100644 --- a/packages/package-requester/package.json +++ b/packages/package-requester/package.json @@ -44,7 +44,6 @@ "@pnpm/store-controller-types": "workspace:8.0.0-alpha.0", "@pnpm/types": "workspace:5.0.0", "load-json-file": "6.2.0", - "make-dir": "^3.1.0", "mz": "2.7.0", "p-limit": "2.3.0", "p-queue": "6.3.0", diff --git a/packages/plugin-commands-installation/package.json b/packages/plugin-commands-installation/package.json index ed697acac9..46c5f12947 100644 --- a/packages/plugin-commands-installation/package.json +++ b/packages/plugin-commands-installation/package.json @@ -46,7 +46,6 @@ "@types/sinon": "^9.0.0", "@types/table": "^5.0.0", "load-json-file": "6.2.0", - "make-dir": "^3.1.0", "proxyquire": "2.1.3", "read-yaml-file": "2.0.0", "sinon": "9.0.2", diff --git a/packages/plugin-commands-installation/test/miscRecursive.ts b/packages/plugin-commands-installation/test/miscRecursive.ts index 1cbefdbd5f..34ef68eec8 100644 --- a/packages/plugin-commands-installation/test/miscRecursive.ts +++ b/packages/plugin-commands-installation/test/miscRecursive.ts @@ -3,7 +3,6 @@ import { readProjects } from '@pnpm/filter-workspace-packages' import { Lockfile } from '@pnpm/lockfile-types' import { add, install, remove, update } from '@pnpm/plugin-commands-installation' import { preparePackages } from '@pnpm/prepare' -import makeDir = require('make-dir') import fs = require('mz/fs') import path = require('path') import readYamlFile from 'read-yaml-file' @@ -265,7 +264,7 @@ test('running `pnpm recursive` only for packages in subdirectories of cwd', asyn }, ]) - await makeDir('node_modules') + await fs.mkdir('node_modules') process.chdir('packages') await install.handler({ diff --git a/packages/plugin-commands-outdated/package.json b/packages/plugin-commands-outdated/package.json index 22fd9e806e..6f8a2650c1 100644 --- a/packages/plugin-commands-outdated/package.json +++ b/packages/plugin-commands-outdated/package.json @@ -45,7 +45,6 @@ "@types/ramda": "^0.27.4", "@types/table": "^5.0.0", "@types/wrap-ansi": "3.0.0", - "make-dir": "^3.1.0", "mz": "2.7.0", "strip-ansi": "6.0.0" }, diff --git a/packages/plugin-commands-outdated/test/index.ts b/packages/plugin-commands-outdated/test/index.ts index 707cdfb993..e7e1a70f63 100644 --- a/packages/plugin-commands-outdated/test/index.ts +++ b/packages/plugin-commands-outdated/test/index.ts @@ -5,15 +5,12 @@ import { outdated } from '@pnpm/plugin-commands-outdated' import prepare, { tempDir } from '@pnpm/prepare' import { REGISTRY_MOCK_PORT } from '@pnpm/registry-mock' import { stripIndent } from 'common-tags' -import fs = require('fs') -import makeDir = require('make-dir') +import fs = require('mz/fs') import path = require('path') import stripAnsi = require('strip-ansi') import test = require('tape') -import { promisify } from 'util' import './recursive' -const copyFile = promisify(fs.copyFile) const fixtures = path.join(__dirname, '../../../fixtures') const hasOutdatedDepsFixture = path.join(fixtures, 'has-outdated-deps') const hasOutdatedDepsFixtureAndExternalLockfile = path.join(fixtures, 'has-outdated-deps-and-external-shrinkwrap', 'pkg') @@ -43,9 +40,9 @@ const OUTDATED_OPTIONS = { test('pnpm outdated: show details', async (t) => { tempDir(t) - await makeDir(path.resolve('node_modules/.pnpm')) - await copyFile(path.join(hasOutdatedDepsFixture, 'node_modules/.pnpm/lock.yaml'), path.resolve('node_modules/.pnpm/lock.yaml')) - await copyFile(path.join(hasOutdatedDepsFixture, 'package.json'), path.resolve('package.json')) + await fs.mkdir(path.resolve('node_modules/.pnpm'), { recursive: true }) + await fs.copyFile(path.join(hasOutdatedDepsFixture, 'node_modules/.pnpm/lock.yaml'), path.resolve('node_modules/.pnpm/lock.yaml')) + await fs.copyFile(path.join(hasOutdatedDepsFixture, 'package.json'), path.resolve('package.json')) const output = await outdated.handler({ ...OUTDATED_OPTIONS, @@ -73,9 +70,9 @@ test('pnpm outdated: show details', async (t) => { test('pnpm outdated: showing only prod or dev dependencies', async (t) => { tempDir(t) - await makeDir(path.resolve('node_modules/.pnpm')) - await copyFile(path.join(hasOutdatedDepsFixture, 'node_modules/.pnpm/lock.yaml'), path.resolve('node_modules/.pnpm/lock.yaml')) - await copyFile(path.join(hasOutdatedDepsFixture, 'package.json'), path.resolve('package.json')) + await fs.mkdir(path.resolve('node_modules/.pnpm'), { recursive: true }) + await fs.copyFile(path.join(hasOutdatedDepsFixture, 'node_modules/.pnpm/lock.yaml'), path.resolve('node_modules/.pnpm/lock.yaml')) + await fs.copyFile(path.join(hasOutdatedDepsFixture, 'package.json'), path.resolve('package.json')) { const output = await outdated.handler({ @@ -117,9 +114,9 @@ test('pnpm outdated: showing only prod or dev dependencies', async (t) => { test('pnpm outdated: no table', async (t) => { tempDir(t) - await makeDir(path.resolve('node_modules/.pnpm')) - await copyFile(path.join(hasOutdatedDepsFixture, 'node_modules/.pnpm/lock.yaml'), path.resolve('node_modules/.pnpm/lock.yaml')) - await copyFile(path.join(hasOutdatedDepsFixture, 'package.json'), path.resolve('package.json')) + await fs.mkdir(path.resolve('node_modules/.pnpm'), { recursive: true }) + await fs.copyFile(path.join(hasOutdatedDepsFixture, 'node_modules/.pnpm/lock.yaml'), path.resolve('node_modules/.pnpm/lock.yaml')) + await fs.copyFile(path.join(hasOutdatedDepsFixture, 'package.json'), path.resolve('package.json')) { const output = await outdated.handler({ @@ -171,9 +168,9 @@ test('pnpm outdated: no table', async (t) => { test('pnpm outdated: only current lockfile is available', async (t) => { tempDir(t) - await makeDir(path.resolve('node_modules/.pnpm')) - await copyFile(path.join(hasOutdatedDepsFixture, 'node_modules/.pnpm/lock.yaml'), path.resolve('node_modules/.pnpm/lock.yaml')) - await copyFile(path.join(hasOutdatedDepsFixture, 'package.json'), path.resolve('package.json')) + await fs.mkdir(path.resolve('node_modules/.pnpm'), { recursive: true }) + await fs.copyFile(path.join(hasOutdatedDepsFixture, 'node_modules/.pnpm/lock.yaml'), path.resolve('node_modules/.pnpm/lock.yaml')) + await fs.copyFile(path.join(hasOutdatedDepsFixture, 'package.json'), path.resolve('package.json')) const output = await outdated.handler({ ...OUTDATED_OPTIONS, @@ -197,8 +194,8 @@ test('pnpm outdated: only current lockfile is available', async (t) => { test('pnpm outdated: only wanted lockfile is available', async (t) => { tempDir(t) - await copyFile(path.join(hasOutdatedDepsFixture, 'pnpm-lock.yaml'), path.resolve('pnpm-lock.yaml')) - await copyFile(path.join(hasOutdatedDepsFixture, 'package.json'), path.resolve('package.json')) + await fs.copyFile(path.join(hasOutdatedDepsFixture, 'pnpm-lock.yaml'), path.resolve('pnpm-lock.yaml')) + await fs.copyFile(path.join(hasOutdatedDepsFixture, 'package.json'), path.resolve('package.json')) const output = await outdated.handler({ ...OUTDATED_OPTIONS, diff --git a/packages/pnpm/package.json b/packages/pnpm/package.json index 45c42f8c6b..b98706cb63 100644 --- a/packages/pnpm/package.json +++ b/packages/pnpm/package.json @@ -94,7 +94,6 @@ "exists-link": "2.0.0", "is-windows": "1.0.2", "load-json-file": "6.2.0", - "make-dir": "^3.1.0", "mz": "2.7.0", "ncp": "2.0.0", "normalize-newline": "3.0.0", diff --git a/packages/pnpm/test/cli.ts b/packages/pnpm/test/cli.ts index 19a0fc9139..64ebf1aed1 100644 --- a/packages/pnpm/test/cli.ts +++ b/packages/pnpm/test/cli.ts @@ -1,7 +1,6 @@ import prepare from '@pnpm/prepare' import rimraf = require('@zkochan/rimraf') import execa = require('execa') -import makeDir = require('make-dir') import fs = require('mz/fs') import tape = require('tape') import promisifyTape from 'tape-promise' @@ -25,7 +24,7 @@ test('some commands pass through to npm', t => { test('installs in the folder where the package.json file is', async function (t) { const project = prepare(t) - await makeDir('subdir') + await fs.mkdir('subdir') process.chdir('subdir') await execPnpm(['install', 'rimraf@2.5.1']) diff --git a/packages/pnpm/test/install/store.ts b/packages/pnpm/test/install/store.ts index a78c15a466..c2cd5b3017 100644 --- a/packages/pnpm/test/install/store.ts +++ b/packages/pnpm/test/install/store.ts @@ -1,7 +1,7 @@ import prepare from '@pnpm/prepare' import { REGISTRY_MOCK_PORT } from '@pnpm/registry-mock' import rimraf = require('@zkochan/rimraf') -import makeDir = require('make-dir') +import fs = require('mz/fs') import ncpCB = require('ncp') import path = require('path') import tape = require('tape') @@ -18,7 +18,7 @@ test('corrupted tarball should be redownloaded to the store', async (t: tape.Tes await execPnpm(['store', 'add', 'is-positive@1.0.0', 'is-positive@2.0.0']) await rimraf(path.resolve(`../store/v3/localhost+${REGISTRY_MOCK_PORT}/is-positive/2.0.0`)) - await makeDir(path.resolve(`../store/v3/localhost+${REGISTRY_MOCK_PORT}/is-positive/2.0.0`)) + await fs.mkdir(path.resolve(`../store/v3/localhost+${REGISTRY_MOCK_PORT}/is-positive/2.0.0`), { recursive: true }) await ncp( path.resolve(`../store/v3/localhost+${REGISTRY_MOCK_PORT}/is-positive/1.0.0/packed.tgz`), path.resolve(`../store/v3/localhost+${REGISTRY_MOCK_PORT}/is-positive/2.0.0/packed.tgz`), diff --git a/packages/tarball-fetcher/package.json b/packages/tarball-fetcher/package.json index c8da8225d6..ab8f4ccdc0 100644 --- a/packages/tarball-fetcher/package.json +++ b/packages/tarball-fetcher/package.json @@ -39,7 +39,6 @@ "credentials-by-uri": "2.0.0", "fetch-from-npm-registry": "workspace:4.0.2", "graceful-fs": "4.2.1", - "make-dir": "^3.1.0", "mem": "^6.1.0", "mz": "2.7.0", "path-temp": "2.0.0", diff --git a/packages/tarball-fetcher/src/createDownloader.ts b/packages/tarball-fetcher/src/createDownloader.ts index 3b2511e659..cbc7012b4f 100644 --- a/packages/tarball-fetcher/src/createDownloader.ts +++ b/packages/tarball-fetcher/src/createDownloader.ts @@ -1,9 +1,8 @@ import PnpmError from '@pnpm/error' import { Cafs, FetchResult, FilesIndex } from '@pnpm/fetcher-base' import createFetcher from 'fetch-from-npm-registry' -import fs = require('graceful-fs') import { IncomingMessage } from 'http' -import makeDir = require('make-dir') +import fs = require('mz/fs') import path = require('path') import pathTemp = require('path-temp') import retry = require('retry') @@ -114,7 +113,7 @@ export default ( integrity?: string, }): Promise { const saveToDir = path.dirname(saveto) - await makeDir(saveToDir) + await fs.mkdir(saveToDir, { recursive: true }) // If a tarball is hosted on a different place than the manifest, only send // credentials on `alwaysAuth` @@ -185,7 +184,7 @@ export default ( if (integrityCheckResult !== true) { throw integrityCheckResult } - fs.rename(tempTarballLocation, saveto, () => { + fs.rename(tempTarballLocation, saveto).catch(() => { // ignore errors }) resolve({ filesIndex: filesIndex as FilesIndex }) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index a6479946cf..614cbe3747 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1215,7 +1215,6 @@ importers: '@pnpm/store-controller-types': 'link:../store-controller-types' '@pnpm/types': 'link:../types' load-json-file: 6.2.0 - make-dir: 3.1.0 mz: 2.7.0 p-limit: 2.3.0 p-queue: 6.3.0 @@ -1265,7 +1264,6 @@ importers: '@types/ssri': ^6.0.2 delay: 4.3.0 load-json-file: 6.2.0 - make-dir: ^3.1.0 mz: 2.7.0 ncp: 2.0.0 nock: 12.0.3 @@ -1516,7 +1514,6 @@ importers: '@types/sinon': 9.0.0 '@types/table': 5.0.0 load-json-file: 6.2.0 - make-dir: 3.1.0 proxyquire: 2.1.3 read-yaml-file: 2.0.0 sinon: 9.0.2 @@ -1564,7 +1561,6 @@ importers: is-ci: 2.0.0 is-subdir: 1.1.1 load-json-file: 6.2.0 - make-dir: ^3.1.0 mem: ^6.1.0 mz: 2.7.0 p-filter: 2.1.0 @@ -1665,7 +1661,6 @@ importers: '@types/ramda': 0.27.4 '@types/table': 5.0.0 '@types/wrap-ansi': 3.0.0 - make-dir: 3.1.0 mz: 2.7.0 strip-ansi: 6.0.0 specifiers: @@ -1697,7 +1692,6 @@ importers: chalk: 4.0.0 common-tags: 1.8.0 lru-cache: 5.1.1 - make-dir: ^3.1.0 mz: 2.7.0 ramda: 0.27.0 render-help: 1.0.0 @@ -2138,7 +2132,6 @@ importers: exists-link: 2.0.0 is-windows: 1.0.2 load-json-file: 6.2.0 - make-dir: 3.1.0 mz: 2.7.0 ncp: 2.0.0 normalize-newline: 3.0.0 @@ -2224,7 +2217,6 @@ importers: is-windows: 1.0.2 load-json-file: 6.2.0 loud-rejection: 2.2.0 - make-dir: ^3.1.0 mz: 2.7.0 ncp: 2.0.0 nopt: 4.0.3 @@ -2757,7 +2749,6 @@ importers: credentials-by-uri: 2.0.0 fetch-from-npm-registry: 'link:../fetch-from-npm-registry' graceful-fs: 4.2.1 - make-dir: 3.1.0 mem: 6.1.0 mz: 2.7.0 path-temp: 2.0.0 @@ -2793,7 +2784,6 @@ importers: credentials-by-uri: 2.0.0 fetch-from-npm-registry: 'workspace:4.0.2' graceful-fs: 4.2.1 - make-dir: ^3.1.0 mem: ^6.1.0 mz: 2.7.0 nock: 12.0.3 @@ -2877,7 +2867,6 @@ importers: '@pnpm/assert-project': 'link:../assert-project' '@pnpm/types': 'link:../../packages/types' '@types/mkdirp': 1.0.0 - make-dir: 3.1.0 tempy: 0.5.0 write-json5-file: 3.0.0 write-pkg: 4.0.0 @@ -2891,7 +2880,6 @@ importers: '@pnpm/types': 'workspace:*' '@types/mkdirp': 1.0.0 '@types/node': ^12.12.37 - make-dir: ^3.1.0 tempy: 0.5.0 tslint-config-standard: 9.0.0 tslint-eslint-rules: 5.4.0 diff --git a/privatePackages/prepare/package.json b/privatePackages/prepare/package.json index f053e479b3..619e101bc0 100644 --- a/privatePackages/prepare/package.json +++ b/privatePackages/prepare/package.json @@ -8,7 +8,6 @@ "@pnpm/assert-project": "workspace:*", "@pnpm/types": "workspace:*", "@types/mkdirp": "1.0.0", - "make-dir": "^3.1.0", "tempy": "0.5.0", "write-json5-file": "^3.0.0", "write-pkg": "4.0.0", diff --git a/privatePackages/prepare/src/index.ts b/privatePackages/prepare/src/index.ts index bae2a83dc2..b36d8bd9ab 100644 --- a/privatePackages/prepare/src/index.ts +++ b/privatePackages/prepare/src/index.ts @@ -1,6 +1,6 @@ import assertProject, { Modules, Project } from '@pnpm/assert-project' import { ProjectManifest } from '@pnpm/types' -import makeDir = require('make-dir') +import fs = require('fs') import path = require('path') import { Test } from 'tape' import tempy = require('tempy') @@ -20,7 +20,7 @@ export function tempDir (t: Test) { dirNumber++ const dirname = dirNumber.toString() const tmpDir = path.join(tmpPath, dirname) - makeDir.sync(tmpDir) + fs.mkdirSync(tmpDir, { recursive: true }) t.pass(`create testing dir ${path.join(tmpDir)}`) @@ -69,7 +69,7 @@ export default function prepare ( ) { const dir = opts?.tempDir ?? path.join(tempDir(test), 'project') - makeDir.sync(dir) + fs.mkdirSync(dir, { recursive: true }) switch (opts?.manifestFormat ?? 'JSON') { case 'JSON': writePkg.sync(dir, { name: 'project', version: '0.0.0', ...manifest } as any) // tslint:disable-line @@ -89,7 +89,7 @@ export default function prepare ( export function prepareEmpty (t: Test) { const pkgTmpPath = path.join(tempDir(t), 'project') - makeDir.sync(pkgTmpPath) + fs.mkdirSync(pkgTmpPath, { recursive: true }) process.chdir(pkgTmpPath) return assertProject(t, pkgTmpPath)