From 878ddfb5b68c03bdcd7d7da8dae92c4947942801 Mon Sep 17 00:00:00 2001 From: Luke Karrys Date: Thu, 3 Nov 2022 14:32:25 -0700 Subject: [PATCH] deps: @npmcli/fs@3.1.0 This also removes `readdir-scoped-modules` and `@npmcli/fs` since those are now a part of `@npmcli/fs` --- DEPENDENCIES.md | 22 +- lib/utils/completion/installed-shallow.js | 8 +- node_modules/.gitignore | 4 - node_modules/@npmcli/fs/lib/index.js | 4 + node_modules/@npmcli/fs/lib/move-file.js | 78 ++++++ node_modules/@npmcli/fs/lib/readdir-scoped.js | 20 ++ node_modules/@npmcli/fs/package.json | 8 +- node_modules/asap/CHANGES.md | 70 ------ node_modules/asap/LICENSE.md | 21 -- node_modules/asap/asap.js | 65 ----- node_modules/asap/browser-asap.js | 66 ------ node_modules/asap/browser-raw.js | 223 ------------------ node_modules/asap/package.json | 58 ----- node_modules/asap/raw.js | 101 -------- node_modules/debuglog/LICENSE | 19 -- node_modules/debuglog/debuglog.js | 22 -- node_modules/debuglog/package.json | 21 -- node_modules/dezalgo/LICENSE | 15 -- node_modules/dezalgo/dezalgo.js | 22 -- node_modules/dezalgo/package.json | 46 ---- node_modules/readdir-scoped-modules/LICENSE | 15 -- .../readdir-scoped-modules/package.json | 34 --- .../readdir-scoped-modules/readdir.js | 121 ---------- package-lock.json | 20 +- package.json | 4 +- .../arborist/lib/arborist/build-ideal-tree.js | 6 +- .../arborist/lib/arborist/load-actual.js | 9 +- workspaces/arborist/lib/arborist/reify.js | 2 +- workspaces/arborist/package.json | 3 +- workspaces/arborist/test/arborist/reify.js | 54 +++-- 30 files changed, 168 insertions(+), 993 deletions(-) create mode 100644 node_modules/@npmcli/fs/lib/move-file.js create mode 100644 node_modules/@npmcli/fs/lib/readdir-scoped.js delete mode 100644 node_modules/asap/CHANGES.md delete mode 100644 node_modules/asap/LICENSE.md delete mode 100644 node_modules/asap/asap.js delete mode 100644 node_modules/asap/browser-asap.js delete mode 100644 node_modules/asap/browser-raw.js delete mode 100644 node_modules/asap/package.json delete mode 100644 node_modules/asap/raw.js delete mode 100644 node_modules/debuglog/LICENSE delete mode 100644 node_modules/debuglog/debuglog.js delete mode 100644 node_modules/debuglog/package.json delete mode 100644 node_modules/dezalgo/LICENSE delete mode 100644 node_modules/dezalgo/dezalgo.js delete mode 100644 node_modules/dezalgo/package.json delete mode 100644 node_modules/readdir-scoped-modules/LICENSE delete mode 100644 node_modules/readdir-scoped-modules/package.json delete mode 100644 node_modules/readdir-scoped-modules/readdir.js diff --git a/DEPENDENCIES.md b/DEPENDENCIES.md index 1933339759f0a..d4a82a0af1b43 100644 --- a/DEPENDENCIES.md +++ b/DEPENDENCIES.md @@ -12,7 +12,6 @@ graph LR; cacache-->npmcli-move-file["@npmcli/move-file"]; cacache-->ssri; cacache-->unique-filename; - dezalgo-->wrappy; init-package-json-->npm-package-arg; init-package-json-->promzard; init-package-json-->read-package-json; @@ -133,7 +132,6 @@ graph LR; npm-->read-package-json-fast; npm-->read-package-json; npm-->read; - npm-->readdir-scoped-modules; npm-->semver; npm-->ssri; npm-->treeverse; @@ -167,10 +165,10 @@ graph LR; npmcli-arborist-->npm-pick-manifest; npmcli-arborist-->npm-registry-fetch; npmcli-arborist-->npmcli-eslint-config["@npmcli/eslint-config"]; + npmcli-arborist-->npmcli-fs["@npmcli/fs"]; npmcli-arborist-->npmcli-installed-package-contents["@npmcli/installed-package-contents"]; npmcli-arborist-->npmcli-map-workspaces["@npmcli/map-workspaces"]; npmcli-arborist-->npmcli-metavuln-calculator["@npmcli/metavuln-calculator"]; - npmcli-arborist-->npmcli-move-file["@npmcli/move-file"]; npmcli-arborist-->npmcli-name-from-folder["@npmcli/name-from-folder"]; npmcli-arborist-->npmcli-node-gyp["@npmcli/node-gyp"]; npmcli-arborist-->npmcli-package-json["@npmcli/package-json"]; @@ -182,7 +180,6 @@ graph LR; npmcli-arborist-->parse-conflict-json; npmcli-arborist-->proc-log; npmcli-arborist-->read-package-json-fast; - npmcli-arborist-->readdir-scoped-modules; npmcli-arborist-->semver; npmcli-arborist-->ssri; npmcli-arborist-->treeverse; @@ -238,7 +235,6 @@ graph LR; read-package-json-->npm-normalize-package-bin; read-package-json-fast-->json-parse-even-better-errors; read-package-json-fast-->npm-normalize-package-bin; - readdir-scoped-modules-->dezalgo; unique-filename-->unique-slug; ``` @@ -290,8 +286,6 @@ graph LR; columnify-->wcwidth; debug-->ms; defaults-->clone; - dezalgo-->asap; - dezalgo-->wrappy; encoding-->iconv-lite; fs-minipass-->minipass; gauge-->aproba; @@ -535,7 +529,6 @@ graph LR; npm-->read-package-json-fast; npm-->read-package-json; npm-->read; - npm-->readdir-scoped-modules; npm-->remark-gfm; npm-->remark-github; npm-->remark; @@ -591,10 +584,10 @@ graph LR; npmcli-arborist-->npm-pick-manifest; npmcli-arborist-->npm-registry-fetch; npmcli-arborist-->npmcli-eslint-config["@npmcli/eslint-config"]; + npmcli-arborist-->npmcli-fs["@npmcli/fs"]; npmcli-arborist-->npmcli-installed-package-contents["@npmcli/installed-package-contents"]; npmcli-arborist-->npmcli-map-workspaces["@npmcli/map-workspaces"]; npmcli-arborist-->npmcli-metavuln-calculator["@npmcli/metavuln-calculator"]; - npmcli-arborist-->npmcli-move-file["@npmcli/move-file"]; npmcli-arborist-->npmcli-name-from-folder["@npmcli/name-from-folder"]; npmcli-arborist-->npmcli-node-gyp["@npmcli/node-gyp"]; npmcli-arborist-->npmcli-package-json["@npmcli/package-json"]; @@ -608,7 +601,6 @@ graph LR; npmcli-arborist-->promise-all-reject-late; npmcli-arborist-->promise-call-limit; npmcli-arborist-->read-package-json-fast; - npmcli-arborist-->readdir-scoped-modules; npmcli-arborist-->semver; npmcli-arborist-->ssri; npmcli-arborist-->tap; @@ -708,10 +700,6 @@ graph LR; readable-stream-->inherits; readable-stream-->string_decoder; readable-stream-->util-deprecate; - readdir-scoped-modules-->debuglog; - readdir-scoped-modules-->dezalgo; - readdir-scoped-modules-->graceful-fs; - readdir-scoped-modules-->once; rimraf-->glob; semver-->lru-cache; smoke-tests-->minify-registry-metadata; @@ -769,6 +757,6 @@ packages higher up the chain. - pacote, libnpmaccess, libnpmhook, libnpmorg, libnpmsearch, libnpmteam, npm-profile - npm-registry-fetch, libnpmversion - @npmcli/git, make-fetch-happen, @npmcli/config, init-package-json - - @npmcli/installed-package-contents, @npmcli/map-workspaces, cacache, npm-pick-manifest, @npmcli/run-script, read-package-json, readdir-scoped-modules, promzard - - @npmcli/docs, npm-bundled, read-package-json-fast, @npmcli/fs, unique-filename, npm-install-checks, npm-package-arg, npm-packlist, normalize-package-data, @npmcli/package-json, bin-links, nopt, npmlog, parse-conflict-json, dezalgo, read - - @npmcli/eslint-config, @npmcli/template-oss, ignore-walk, npm-normalize-package-bin, @npmcli/name-from-folder, json-parse-even-better-errors, semver, @npmcli/move-file, fs-minipass, ssri, unique-slug, @npmcli/promise-spawn, hosted-git-info, proc-log, validate-npm-package-name, @npmcli/node-gyp, minipass-fetch, @npmcli/query, cmd-shim, read-cmd-shim, write-file-atomic, abbrev, are-we-there-yet, gauge, wrappy, treeverse, minify-registry-metadata, ini, @npmcli/disparity-colors, @npmcli/ci-detect, mute-stream, npm-audit-report, npm-user-validate + - @npmcli/installed-package-contents, @npmcli/map-workspaces, cacache, npm-pick-manifest, @npmcli/run-script, read-package-json, promzard + - @npmcli/docs, @npmcli/fs, npm-bundled, read-package-json-fast, unique-filename, npm-install-checks, npm-package-arg, npm-packlist, normalize-package-data, @npmcli/package-json, bin-links, nopt, npmlog, parse-conflict-json, read + - @npmcli/eslint-config, @npmcli/template-oss, ignore-walk, semver, npm-normalize-package-bin, @npmcli/name-from-folder, json-parse-even-better-errors, @npmcli/move-file, fs-minipass, ssri, unique-slug, @npmcli/promise-spawn, hosted-git-info, proc-log, validate-npm-package-name, @npmcli/node-gyp, minipass-fetch, @npmcli/query, cmd-shim, read-cmd-shim, write-file-atomic, abbrev, are-we-there-yet, gauge, treeverse, minify-registry-metadata, ini, @npmcli/disparity-colors, @npmcli/ci-detect, mute-stream, npm-audit-report, npm-user-validate diff --git a/lib/utils/completion/installed-shallow.js b/lib/utils/completion/installed-shallow.js index 686c95e63245e..d59318fe78541 100644 --- a/lib/utils/completion/installed-shallow.js +++ b/lib/utils/completion/installed-shallow.js @@ -1,8 +1,10 @@ -const { promisify } = require('util') -const readdir = promisify(require('readdir-scoped-modules')) +const { readdirScoped } = require('@npmcli/fs') const installedShallow = async (npm, opts) => { - const names = global => readdir(global ? npm.globalDir : npm.localDir) + const names = async global => { + const paths = await readdirScoped(global ? npm.globalDir : npm.localDir) + return paths.map(p => p.replace(/\\/g, '/')) + } const { conf: { argv: { remain } } } = opts if (remain.length > 3) { return null diff --git a/node_modules/.gitignore b/node_modules/.gitignore index b1752b46d3b5e..292e3d4dd1bf8 100644 --- a/node_modules/.gitignore +++ b/node_modules/.gitignore @@ -47,7 +47,6 @@ /are-we-there-yet/node_modules/* !/are-we-there-yet/node_modules/buffer !/are-we-there-yet/node_modules/readable-stream -!/asap !/balanced-match !/base64-js !/bin-links @@ -75,11 +74,9 @@ !/debug/node_modules/ /debug/node_modules/* !/debug/node_modules/ms -!/debuglog !/defaults !/delegates !/depd -!/dezalgo !/diff !/emoji-regex !/encoding @@ -209,7 +206,6 @@ !/read-package-json !/read !/readable-stream -!/readdir-scoped-modules !/retry !/rimraf !/rimraf/node_modules/ diff --git a/node_modules/@npmcli/fs/lib/index.js b/node_modules/@npmcli/fs/lib/index.js index 0dc02f8a3da44..81c746304cc42 100644 --- a/node_modules/@npmcli/fs/lib/index.js +++ b/node_modules/@npmcli/fs/lib/index.js @@ -2,8 +2,12 @@ const cp = require('./cp/index.js') const withTempDir = require('./with-temp-dir.js') +const readdirScoped = require('./readdir-scoped.js') +const moveFile = require('./move-file.js') module.exports = { cp, withTempDir, + readdirScoped, + moveFile, } diff --git a/node_modules/@npmcli/fs/lib/move-file.js b/node_modules/@npmcli/fs/lib/move-file.js new file mode 100644 index 0000000000000..d56e06d384659 --- /dev/null +++ b/node_modules/@npmcli/fs/lib/move-file.js @@ -0,0 +1,78 @@ +const { dirname, join, resolve, relative, isAbsolute } = require('path') +const fs = require('fs/promises') + +const pathExists = async path => { + try { + await fs.access(path) + return true + } catch (er) { + return er.code !== 'ENOENT' + } +} + +const moveFile = async (source, destination, options = {}, root = true, symlinks = []) => { + if (!source || !destination) { + throw new TypeError('`source` and `destination` file required') + } + + options = { + overwrite: true, + ...options, + } + + if (!options.overwrite && await pathExists(destination)) { + throw new Error(`The destination file exists: ${destination}`) + } + + await fs.mkdir(dirname(destination), { recursive: true }) + + try { + await fs.rename(source, destination) + } catch (error) { + if (error.code === 'EXDEV' || error.code === 'EPERM') { + const sourceStat = await fs.lstat(source) + if (sourceStat.isDirectory()) { + const files = await fs.readdir(source) + await Promise.all(files.map((file) => + moveFile(join(source, file), join(destination, file), options, false, symlinks) + )) + } else if (sourceStat.isSymbolicLink()) { + symlinks.push({ source, destination }) + } else { + await fs.copyFile(source, destination) + } + } else { + throw error + } + } + + if (root) { + await Promise.all(symlinks.map(async ({ source: symSource, destination: symDestination }) => { + let target = await fs.readlink(symSource) + // junction symlinks in windows will be absolute paths, so we need to + // make sure they point to the symlink destination + if (isAbsolute(target)) { + target = resolve(symDestination, relative(symSource, target)) + } + // try to determine what the actual file is so we can create the correct + // type of symlink in windows + let targetStat = 'file' + try { + targetStat = await fs.stat(resolve(dirname(symSource), target)) + if (targetStat.isDirectory()) { + targetStat = 'junction' + } + } catch { + // targetStat remains 'file' + } + await fs.symlink( + target, + symDestination, + targetStat + ) + })) + await fs.rm(source, { recursive: true, force: true }) + } +} + +module.exports = moveFile diff --git a/node_modules/@npmcli/fs/lib/readdir-scoped.js b/node_modules/@npmcli/fs/lib/readdir-scoped.js new file mode 100644 index 0000000000000..cd601dfbe7486 --- /dev/null +++ b/node_modules/@npmcli/fs/lib/readdir-scoped.js @@ -0,0 +1,20 @@ +const { readdir } = require('fs/promises') +const { join } = require('path') + +const readdirScoped = async (dir) => { + const results = [] + + for (const item of await readdir(dir)) { + if (item.startsWith('@')) { + for (const scopedItem of await readdir(join(dir, item))) { + results.push(join(item, scopedItem)) + } + } else { + results.push(item) + } + } + + return results +} + +module.exports = readdirScoped diff --git a/node_modules/@npmcli/fs/package.json b/node_modules/@npmcli/fs/package.json index 2eabc35dab33b..28eb613388418 100644 --- a/node_modules/@npmcli/fs/package.json +++ b/node_modules/@npmcli/fs/package.json @@ -1,6 +1,6 @@ { "name": "@npmcli/fs", - "version": "3.0.0", + "version": "3.1.0", "description": "filesystem utilities for the npm cli", "main": "lib/index.js", "files": [ @@ -29,8 +29,8 @@ "author": "GitHub Inc.", "license": "ISC", "devDependencies": { - "@npmcli/eslint-config": "^3.0.1", - "@npmcli/template-oss": "4.5.1", + "@npmcli/eslint-config": "^4.0.0", + "@npmcli/template-oss": "4.8.0", "tap": "^16.0.1" }, "dependencies": { @@ -41,7 +41,7 @@ }, "templateOSS": { "//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.", - "version": "4.5.1" + "version": "4.8.0" }, "tap": { "nyc-arg": [ diff --git a/node_modules/asap/CHANGES.md b/node_modules/asap/CHANGES.md deleted file mode 100644 index f105b91956d15..0000000000000 --- a/node_modules/asap/CHANGES.md +++ /dev/null @@ -1,70 +0,0 @@ - -## 2.0.6 - -Version 2.0.4 adds support for React Native by clarifying in package.json that -the browser environment does not support Node.js domains. -Why this is necessary, we leave as an exercise for the user. - -## 2.0.3 - -Version 2.0.3 fixes a bug when adjusting the capacity of the task queue. - -## 2.0.1-2.02 - -Version 2.0.1 fixes a bug in the way redirects were expressed that affected the -function of Browserify, but which Mr would tolerate. - -## 2.0.0 - -Version 2 of ASAP is a full rewrite with a few salient changes. -First, the ASAP source is CommonJS only and designed with [Browserify][] and -[Browserify-compatible][Mr] module loaders in mind. - -[Browserify]: https://github.com/substack/node-browserify -[Mr]: https://github.com/montagejs/mr - -The new version has been refactored in two dimensions. -Support for Node.js and browsers have been separated, using Browserify -redirects and ASAP has been divided into two modules. -The "raw" layer depends on the tasks to catch thrown exceptions and unravel -Node.js domains. - -The full implementation of ASAP is loadable as `require("asap")` in both Node.js -and browsers. - -The raw layer that lacks exception handling overhead is loadable as -`require("asap/raw")`. -The interface is the same for both layers. - -Tasks are no longer required to be functions, but can rather be any object that -implements `task.call()`. -With this feature you can recycle task objects to avoid garbage collector churn -and avoid closures in general. - -The implementation has been rigorously documented so that our successors can -understand the scope of the problem that this module solves and all of its -nuances, ensuring that the next generation of implementations know what details -are essential. - -- [asap.js](https://github.com/kriskowal/asap/blob/master/asap.js) -- [raw.js](https://github.com/kriskowal/asap/blob/master/raw.js) -- [browser-asap.js](https://github.com/kriskowal/asap/blob/master/browser-asap.js) -- [browser-raw.js](https://github.com/kriskowal/asap/blob/master/browser-raw.js) - -The new version has also been rigorously tested across a broad spectrum of -browsers, in both the window and worker context. -The following charts capture the browser test results for the most recent -release. -The first chart shows test results for ASAP running in the main window context. -The second chart shows test results for ASAP running in a web worker context. -Test results are inconclusive (grey) on browsers that do not support web -workers. -These data are captured automatically by [Continuous -Integration][]. - -![Browser Compatibility](http://kriskowal-asap.s3-website-us-west-2.amazonaws.com/train/integration-2/saucelabs-results-matrix.svg) - -![Compatibility in Web Workers](http://kriskowal-asap.s3-website-us-west-2.amazonaws.com/train/integration-2/saucelabs-worker-results-matrix.svg) - -[Continuous Integration]: https://github.com/kriskowal/asap/blob/master/CONTRIBUTING.md - diff --git a/node_modules/asap/LICENSE.md b/node_modules/asap/LICENSE.md deleted file mode 100644 index ba18c61390db9..0000000000000 --- a/node_modules/asap/LICENSE.md +++ /dev/null @@ -1,21 +0,0 @@ - -Copyright 2009–2014 Contributors. All rights reserved. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to -deal in the Software without restriction, including without limitation the -rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -sell copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -IN THE SOFTWARE. - diff --git a/node_modules/asap/asap.js b/node_modules/asap/asap.js deleted file mode 100644 index f04fcd58fc0b2..0000000000000 --- a/node_modules/asap/asap.js +++ /dev/null @@ -1,65 +0,0 @@ -"use strict"; - -var rawAsap = require("./raw"); -var freeTasks = []; - -/** - * Calls a task as soon as possible after returning, in its own event, with - * priority over IO events. An exception thrown in a task can be handled by - * `process.on("uncaughtException") or `domain.on("error")`, but will otherwise - * crash the process. If the error is handled, all subsequent tasks will - * resume. - * - * @param {{call}} task A callable object, typically a function that takes no - * arguments. - */ -module.exports = asap; -function asap(task) { - var rawTask; - if (freeTasks.length) { - rawTask = freeTasks.pop(); - } else { - rawTask = new RawTask(); - } - rawTask.task = task; - rawTask.domain = process.domain; - rawAsap(rawTask); -} - -function RawTask() { - this.task = null; - this.domain = null; -} - -RawTask.prototype.call = function () { - if (this.domain) { - this.domain.enter(); - } - var threw = true; - try { - this.task.call(); - threw = false; - // If the task throws an exception (presumably) Node.js restores the - // domain stack for the next event. - if (this.domain) { - this.domain.exit(); - } - } finally { - // We use try/finally and a threw flag to avoid messing up stack traces - // when we catch and release errors. - if (threw) { - // In Node.js, uncaught exceptions are considered fatal errors. - // Re-throw them to interrupt flushing! - // Ensure that flushing continues if an uncaught exception is - // suppressed listening process.on("uncaughtException") or - // domain.on("error"). - rawAsap.requestFlush(); - } - // If the task threw an error, we do not want to exit the domain here. - // Exiting the domain would prevent the domain from catching the error. - this.task = null; - this.domain = null; - freeTasks.push(this); - } -}; - diff --git a/node_modules/asap/browser-asap.js b/node_modules/asap/browser-asap.js deleted file mode 100644 index 805c9824605b0..0000000000000 --- a/node_modules/asap/browser-asap.js +++ /dev/null @@ -1,66 +0,0 @@ -"use strict"; - -// rawAsap provides everything we need except exception management. -var rawAsap = require("./raw"); -// RawTasks are recycled to reduce GC churn. -var freeTasks = []; -// We queue errors to ensure they are thrown in right order (FIFO). -// Array-as-queue is good enough here, since we are just dealing with exceptions. -var pendingErrors = []; -var requestErrorThrow = rawAsap.makeRequestCallFromTimer(throwFirstError); - -function throwFirstError() { - if (pendingErrors.length) { - throw pendingErrors.shift(); - } -} - -/** - * Calls a task as soon as possible after returning, in its own event, with priority - * over other events like animation, reflow, and repaint. An error thrown from an - * event will not interrupt, nor even substantially slow down the processing of - * other events, but will be rather postponed to a lower priority event. - * @param {{call}} task A callable object, typically a function that takes no - * arguments. - */ -module.exports = asap; -function asap(task) { - var rawTask; - if (freeTasks.length) { - rawTask = freeTasks.pop(); - } else { - rawTask = new RawTask(); - } - rawTask.task = task; - rawAsap(rawTask); -} - -// We wrap tasks with recyclable task objects. A task object implements -// `call`, just like a function. -function RawTask() { - this.task = null; -} - -// The sole purpose of wrapping the task is to catch the exception and recycle -// the task object after its single use. -RawTask.prototype.call = function () { - try { - this.task.call(); - } catch (error) { - if (asap.onerror) { - // This hook exists purely for testing purposes. - // Its name will be periodically randomized to break any code that - // depends on its existence. - asap.onerror(error); - } else { - // In a web browser, exceptions are not fatal. However, to avoid - // slowing down the queue of pending tasks, we rethrow the error in a - // lower priority turn. - pendingErrors.push(error); - requestErrorThrow(); - } - } finally { - this.task = null; - freeTasks[freeTasks.length] = this; - } -}; diff --git a/node_modules/asap/browser-raw.js b/node_modules/asap/browser-raw.js deleted file mode 100644 index 9cee7e32eb5d3..0000000000000 --- a/node_modules/asap/browser-raw.js +++ /dev/null @@ -1,223 +0,0 @@ -"use strict"; - -// Use the fastest means possible to execute a task in its own turn, with -// priority over other events including IO, animation, reflow, and redraw -// events in browsers. -// -// An exception thrown by a task will permanently interrupt the processing of -// subsequent tasks. The higher level `asap` function ensures that if an -// exception is thrown by a task, that the task queue will continue flushing as -// soon as possible, but if you use `rawAsap` directly, you are responsible to -// either ensure that no exceptions are thrown from your task, or to manually -// call `rawAsap.requestFlush` if an exception is thrown. -module.exports = rawAsap; -function rawAsap(task) { - if (!queue.length) { - requestFlush(); - flushing = true; - } - // Equivalent to push, but avoids a function call. - queue[queue.length] = task; -} - -var queue = []; -// Once a flush has been requested, no further calls to `requestFlush` are -// necessary until the next `flush` completes. -var flushing = false; -// `requestFlush` is an implementation-specific method that attempts to kick -// off a `flush` event as quickly as possible. `flush` will attempt to exhaust -// the event queue before yielding to the browser's own event loop. -var requestFlush; -// The position of the next task to execute in the task queue. This is -// preserved between calls to `flush` so that it can be resumed if -// a task throws an exception. -var index = 0; -// If a task schedules additional tasks recursively, the task queue can grow -// unbounded. To prevent memory exhaustion, the task queue will periodically -// truncate already-completed tasks. -var capacity = 1024; - -// The flush function processes all tasks that have been scheduled with -// `rawAsap` unless and until one of those tasks throws an exception. -// If a task throws an exception, `flush` ensures that its state will remain -// consistent and will resume where it left off when called again. -// However, `flush` does not make any arrangements to be called again if an -// exception is thrown. -function flush() { - while (index < queue.length) { - var currentIndex = index; - // Advance the index before calling the task. This ensures that we will - // begin flushing on the next task the task throws an error. - index = index + 1; - queue[currentIndex].call(); - // Prevent leaking memory for long chains of recursive calls to `asap`. - // If we call `asap` within tasks scheduled by `asap`, the queue will - // grow, but to avoid an O(n) walk for every task we execute, we don't - // shift tasks off the queue after they have been executed. - // Instead, we periodically shift 1024 tasks off the queue. - if (index > capacity) { - // Manually shift all values starting at the index back to the - // beginning of the queue. - for (var scan = 0, newLength = queue.length - index; scan < newLength; scan++) { - queue[scan] = queue[scan + index]; - } - queue.length -= index; - index = 0; - } - } - queue.length = 0; - index = 0; - flushing = false; -} - -// `requestFlush` is implemented using a strategy based on data collected from -// every available SauceLabs Selenium web driver worker at time of writing. -// https://docs.google.com/spreadsheets/d/1mG-5UYGup5qxGdEMWkhP6BWCz053NUb2E1QoUTU16uA/edit#gid=783724593 - -// Safari 6 and 6.1 for desktop, iPad, and iPhone are the only browsers that -// have WebKitMutationObserver but not un-prefixed MutationObserver. -// Must use `global` or `self` instead of `window` to work in both frames and web -// workers. `global` is a provision of Browserify, Mr, Mrs, or Mop. - -/* globals self */ -var scope = typeof global !== "undefined" ? global : self; -var BrowserMutationObserver = scope.MutationObserver || scope.WebKitMutationObserver; - -// MutationObservers are desirable because they have high priority and work -// reliably everywhere they are implemented. -// They are implemented in all modern browsers. -// -// - Android 4-4.3 -// - Chrome 26-34 -// - Firefox 14-29 -// - Internet Explorer 11 -// - iPad Safari 6-7.1 -// - iPhone Safari 7-7.1 -// - Safari 6-7 -if (typeof BrowserMutationObserver === "function") { - requestFlush = makeRequestCallFromMutationObserver(flush); - -// MessageChannels are desirable because they give direct access to the HTML -// task queue, are implemented in Internet Explorer 10, Safari 5.0-1, and Opera -// 11-12, and in web workers in many engines. -// Although message channels yield to any queued rendering and IO tasks, they -// would be better than imposing the 4ms delay of timers. -// However, they do not work reliably in Internet Explorer or Safari. - -// Internet Explorer 10 is the only browser that has setImmediate but does -// not have MutationObservers. -// Although setImmediate yields to the browser's renderer, it would be -// preferrable to falling back to setTimeout since it does not have -// the minimum 4ms penalty. -// Unfortunately there appears to be a bug in Internet Explorer 10 Mobile (and -// Desktop to a lesser extent) that renders both setImmediate and -// MessageChannel useless for the purposes of ASAP. -// https://github.com/kriskowal/q/issues/396 - -// Timers are implemented universally. -// We fall back to timers in workers in most engines, and in foreground -// contexts in the following browsers. -// However, note that even this simple case requires nuances to operate in a -// broad spectrum of browsers. -// -// - Firefox 3-13 -// - Internet Explorer 6-9 -// - iPad Safari 4.3 -// - Lynx 2.8.7 -} else { - requestFlush = makeRequestCallFromTimer(flush); -} - -// `requestFlush` requests that the high priority event queue be flushed as -// soon as possible. -// This is useful to prevent an error thrown in a task from stalling the event -// queue if the exception handled by Node.js’s -// `process.on("uncaughtException")` or by a domain. -rawAsap.requestFlush = requestFlush; - -// To request a high priority event, we induce a mutation observer by toggling -// the text of a text node between "1" and "-1". -function makeRequestCallFromMutationObserver(callback) { - var toggle = 1; - var observer = new BrowserMutationObserver(callback); - var node = document.createTextNode(""); - observer.observe(node, {characterData: true}); - return function requestCall() { - toggle = -toggle; - node.data = toggle; - }; -} - -// The message channel technique was discovered by Malte Ubl and was the -// original foundation for this library. -// http://www.nonblocking.io/2011/06/windownexttick.html - -// Safari 6.0.5 (at least) intermittently fails to create message ports on a -// page's first load. Thankfully, this version of Safari supports -// MutationObservers, so we don't need to fall back in that case. - -// function makeRequestCallFromMessageChannel(callback) { -// var channel = new MessageChannel(); -// channel.port1.onmessage = callback; -// return function requestCall() { -// channel.port2.postMessage(0); -// }; -// } - -// For reasons explained above, we are also unable to use `setImmediate` -// under any circumstances. -// Even if we were, there is another bug in Internet Explorer 10. -// It is not sufficient to assign `setImmediate` to `requestFlush` because -// `setImmediate` must be called *by name* and therefore must be wrapped in a -// closure. -// Never forget. - -// function makeRequestCallFromSetImmediate(callback) { -// return function requestCall() { -// setImmediate(callback); -// }; -// } - -// Safari 6.0 has a problem where timers will get lost while the user is -// scrolling. This problem does not impact ASAP because Safari 6.0 supports -// mutation observers, so that implementation is used instead. -// However, if we ever elect to use timers in Safari, the prevalent work-around -// is to add a scroll event listener that calls for a flush. - -// `setTimeout` does not call the passed callback if the delay is less than -// approximately 7 in web workers in Firefox 8 through 18, and sometimes not -// even then. - -function makeRequestCallFromTimer(callback) { - return function requestCall() { - // We dispatch a timeout with a specified delay of 0 for engines that - // can reliably accommodate that request. This will usually be snapped - // to a 4 milisecond delay, but once we're flushing, there's no delay - // between events. - var timeoutHandle = setTimeout(handleTimer, 0); - // However, since this timer gets frequently dropped in Firefox - // workers, we enlist an interval handle that will try to fire - // an event 20 times per second until it succeeds. - var intervalHandle = setInterval(handleTimer, 50); - - function handleTimer() { - // Whichever timer succeeds will cancel both timers and - // execute the callback. - clearTimeout(timeoutHandle); - clearInterval(intervalHandle); - callback(); - } - }; -} - -// This is for `asap.js` only. -// Its name will be periodically randomized to break any code that depends on -// its existence. -rawAsap.makeRequestCallFromTimer = makeRequestCallFromTimer; - -// ASAP was originally a nextTick shim included in Q. This was factored out -// into this ASAP package. It was later adapted to RSVP which made further -// amendments. These decisions, particularly to marginalize MessageChannel and -// to capture the MutationObserver implementation in a closure, were integrated -// back into ASAP proper. -// https://github.com/tildeio/rsvp.js/blob/cddf7232546a9cf858524b75cde6f9edf72620a7/lib/rsvp/asap.js diff --git a/node_modules/asap/package.json b/node_modules/asap/package.json deleted file mode 100644 index ae9f303bcd15d..0000000000000 --- a/node_modules/asap/package.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "name": "asap", - "version": "2.0.6", - "description": "High-priority task queue for Node.js and browsers", - "keywords": [ - "event", - "task", - "queue" - ], - "license": "MIT", - "repository": { - "type": "git", - "url": "https://github.com/kriskowal/asap.git" - }, - "main": "./asap.js", - "browser": { - "./asap": "./browser-asap.js", - "./asap.js": "./browser-asap.js", - "./raw": "./browser-raw.js", - "./raw.js": "./browser-raw.js", - "./test/domain.js": "./test/browser-domain.js" - }, - "react-native": { - "domain": false - }, - "files": [ - "raw.js", - "asap.js", - "browser-raw.js", - "browser-asap.js" - ], - "scripts": { - "test": "npm run lint && npm run test-node", - "test-travis": "npm run lint && npm run test-node && npm run test-saucelabs && npm run test-saucelabs-worker", - "test-node": "node test/asap-test.js", - "test-publish": "node scripts/publish-bundle.js test/asap-test.js | pbcopy", - "test-browser": "node scripts/publish-bundle.js test/asap-test.js | xargs opener", - "test-saucelabs": "node scripts/saucelabs.js test/asap-test.js scripts/saucelabs-spot-configurations.json", - "test-saucelabs-all": "node scripts/saucelabs.js test/asap-test.js scripts/saucelabs-all-configurations.json", - "test-saucelabs-worker": "node scripts/saucelabs-worker-test.js scripts/saucelabs-spot-configurations.json", - "test-saucelabs-worker-all": "node scripts/saucelabs-worker-test.js scripts/saucelabs-all-configurations.json", - "lint": "jshint raw.js asap.js browser-raw.js browser-asap.js $(find scripts -name '*.js' | grep -v gauntlet)", - "benchmarks": "node benchmarks" - }, - "devDependencies": { - "events": "^1.0.1", - "jshint": "^2.5.1", - "knox": "^0.8.10", - "mr": "^2.0.5", - "opener": "^1.3.0", - "q": "^2.0.3", - "q-io": "^2.0.3", - "saucelabs": "^0.1.1", - "wd": "^0.2.21", - "weak-map": "^1.0.5", - "benchmark": "^1.0.0" - } -} diff --git a/node_modules/asap/raw.js b/node_modules/asap/raw.js deleted file mode 100644 index ae3b892316842..0000000000000 --- a/node_modules/asap/raw.js +++ /dev/null @@ -1,101 +0,0 @@ -"use strict"; - -var domain; // The domain module is executed on demand -var hasSetImmediate = typeof setImmediate === "function"; - -// Use the fastest means possible to execute a task in its own turn, with -// priority over other events including network IO events in Node.js. -// -// An exception thrown by a task will permanently interrupt the processing of -// subsequent tasks. The higher level `asap` function ensures that if an -// exception is thrown by a task, that the task queue will continue flushing as -// soon as possible, but if you use `rawAsap` directly, you are responsible to -// either ensure that no exceptions are thrown from your task, or to manually -// call `rawAsap.requestFlush` if an exception is thrown. -module.exports = rawAsap; -function rawAsap(task) { - if (!queue.length) { - requestFlush(); - flushing = true; - } - // Avoids a function call - queue[queue.length] = task; -} - -var queue = []; -// Once a flush has been requested, no further calls to `requestFlush` are -// necessary until the next `flush` completes. -var flushing = false; -// The position of the next task to execute in the task queue. This is -// preserved between calls to `flush` so that it can be resumed if -// a task throws an exception. -var index = 0; -// If a task schedules additional tasks recursively, the task queue can grow -// unbounded. To prevent memory excaustion, the task queue will periodically -// truncate already-completed tasks. -var capacity = 1024; - -// The flush function processes all tasks that have been scheduled with -// `rawAsap` unless and until one of those tasks throws an exception. -// If a task throws an exception, `flush` ensures that its state will remain -// consistent and will resume where it left off when called again. -// However, `flush` does not make any arrangements to be called again if an -// exception is thrown. -function flush() { - while (index < queue.length) { - var currentIndex = index; - // Advance the index before calling the task. This ensures that we will - // begin flushing on the next task the task throws an error. - index = index + 1; - queue[currentIndex].call(); - // Prevent leaking memory for long chains of recursive calls to `asap`. - // If we call `asap` within tasks scheduled by `asap`, the queue will - // grow, but to avoid an O(n) walk for every task we execute, we don't - // shift tasks off the queue after they have been executed. - // Instead, we periodically shift 1024 tasks off the queue. - if (index > capacity) { - // Manually shift all values starting at the index back to the - // beginning of the queue. - for (var scan = 0, newLength = queue.length - index; scan < newLength; scan++) { - queue[scan] = queue[scan + index]; - } - queue.length -= index; - index = 0; - } - } - queue.length = 0; - index = 0; - flushing = false; -} - -rawAsap.requestFlush = requestFlush; -function requestFlush() { - // Ensure flushing is not bound to any domain. - // It is not sufficient to exit the domain, because domains exist on a stack. - // To execute code outside of any domain, the following dance is necessary. - var parentDomain = process.domain; - if (parentDomain) { - if (!domain) { - // Lazy execute the domain module. - // Only employed if the user elects to use domains. - domain = require("domain"); - } - domain.active = process.domain = null; - } - - // `setImmediate` is slower that `process.nextTick`, but `process.nextTick` - // cannot handle recursion. - // `requestFlush` will only be called recursively from `asap.js`, to resume - // flushing after an error is thrown into a domain. - // Conveniently, `setImmediate` was introduced in the same version - // `process.nextTick` started throwing recursion errors. - if (flushing && hasSetImmediate) { - setImmediate(flush); - } else { - process.nextTick(flush); - } - - if (parentDomain) { - domain.active = process.domain = parentDomain; - } -} diff --git a/node_modules/debuglog/LICENSE b/node_modules/debuglog/LICENSE deleted file mode 100644 index a3187cc10022f..0000000000000 --- a/node_modules/debuglog/LICENSE +++ /dev/null @@ -1,19 +0,0 @@ -Copyright Joyent, Inc. and other Node contributors. All rights reserved. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to -deal in the Software without restriction, including without limitation the -rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -sell copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -IN THE SOFTWARE. diff --git a/node_modules/debuglog/debuglog.js b/node_modules/debuglog/debuglog.js deleted file mode 100644 index 748fd72a1a68f..0000000000000 --- a/node_modules/debuglog/debuglog.js +++ /dev/null @@ -1,22 +0,0 @@ -var util = require('util'); - -module.exports = (util && util.debuglog) || debuglog; - -var debugs = {}; -var debugEnviron = process.env.NODE_DEBUG || ''; - -function debuglog(set) { - set = set.toUpperCase(); - if (!debugs[set]) { - if (new RegExp('\\b' + set + '\\b', 'i').test(debugEnviron)) { - var pid = process.pid; - debugs[set] = function() { - var msg = util.format.apply(exports, arguments); - console.error('%s %d: %s', set, pid, msg); - }; - } else { - debugs[set] = function() {}; - } - } - return debugs[set]; -}; diff --git a/node_modules/debuglog/package.json b/node_modules/debuglog/package.json deleted file mode 100644 index e51ecc95f11b5..0000000000000 --- a/node_modules/debuglog/package.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "name": "debuglog", - "version": "1.0.1", - "description": "backport of util.debuglog from node v0.11", - "license": "MIT", - "main": "debuglog.js", - "repository": { - "type": "git", - "url": "https://github.com/sam-github/node-debuglog.git" - }, - "author": { - "name": "Sam Roberts", - "email": "sam@strongloop.com" - }, - "engines": { - "node": "*" - }, - "browser": { - "util": false - } -} diff --git a/node_modules/dezalgo/LICENSE b/node_modules/dezalgo/LICENSE deleted file mode 100644 index 19129e315fe59..0000000000000 --- a/node_modules/dezalgo/LICENSE +++ /dev/null @@ -1,15 +0,0 @@ -The ISC License - -Copyright (c) Isaac Z. Schlueter and Contributors - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR -IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. diff --git a/node_modules/dezalgo/dezalgo.js b/node_modules/dezalgo/dezalgo.js deleted file mode 100644 index 04fd3ba78146d..0000000000000 --- a/node_modules/dezalgo/dezalgo.js +++ /dev/null @@ -1,22 +0,0 @@ -var wrappy = require('wrappy') -module.exports = wrappy(dezalgo) - -var asap = require('asap') - -function dezalgo (cb) { - var sync = true - asap(function () { - sync = false - }) - - return function zalgoSafe() { - var args = arguments - var me = this - if (sync) - asap(function() { - cb.apply(me, args) - }) - else - cb.apply(me, args) - } -} diff --git a/node_modules/dezalgo/package.json b/node_modules/dezalgo/package.json deleted file mode 100644 index f8ba8ec2b6b7a..0000000000000 --- a/node_modules/dezalgo/package.json +++ /dev/null @@ -1,46 +0,0 @@ -{ - "name": "dezalgo", - "version": "1.0.4", - "description": "Contain async insanity so that the dark pony lord doesn't eat souls", - "main": "dezalgo.js", - "files": [ - "dezalgo.js" - ], - "directories": { - "test": "test" - }, - "dependencies": { - "asap": "^2.0.0", - "wrappy": "1" - }, - "devDependencies": { - "tap": "^12.4.0" - }, - "scripts": { - "test": "tap test/*.js" - }, - "repository": { - "type": "git", - "url": "https://github.com/npm/dezalgo" - }, - "keywords": [ - "async", - "zalgo", - "the dark pony", - "he comes", - "asynchrony of all holy and good", - "To invoke the hive mind representing chaos", - "Invoking the feeling of chaos. /Without order", - "The Nezperdian Hive Mind of Chaos, (zalgo………………)", - "He who waits beyond the wall", - "ZALGO", - "HE COMES", - "there used to be some funky unicode keywords here, but it broke the npm website on chrome, so they were removed, sorry" - ], - "author": "Isaac Z. Schlueter (http://blog.izs.me/)", - "license": "ISC", - "bugs": { - "url": "https://github.com/npm/dezalgo/issues" - }, - "homepage": "https://github.com/npm/dezalgo" -} diff --git a/node_modules/readdir-scoped-modules/LICENSE b/node_modules/readdir-scoped-modules/LICENSE deleted file mode 100644 index 19129e315fe59..0000000000000 --- a/node_modules/readdir-scoped-modules/LICENSE +++ /dev/null @@ -1,15 +0,0 @@ -The ISC License - -Copyright (c) Isaac Z. Schlueter and Contributors - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR -IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. diff --git a/node_modules/readdir-scoped-modules/package.json b/node_modules/readdir-scoped-modules/package.json deleted file mode 100644 index d41b99c2643a2..0000000000000 --- a/node_modules/readdir-scoped-modules/package.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "name": "readdir-scoped-modules", - "version": "1.1.0", - "description": "Like `fs.readdir` but handling `@org/module` dirs as if they were a single entry.", - "main": "readdir.js", - "directories": { - "test": "test" - }, - "dependencies": { - "debuglog": "^1.0.1", - "dezalgo": "^1.0.0", - "graceful-fs": "^4.1.2", - "once": "^1.3.0" - }, - "devDependencies": { - "tap": "^1.2.0" - }, - "scripts": { - "test": "tap test/*.js" - }, - "repository": { - "type": "git", - "url": "https://github.com/npm/readdir-scoped-modules" - }, - "author": "Isaac Z. Schlueter (http://blog.izs.me/)", - "license": "ISC", - "bugs": { - "url": "https://github.com/npm/readdir-scoped-modules/issues" - }, - "homepage": "https://github.com/npm/readdir-scoped-modules", - "files": [ - "readdir.js" - ] -} diff --git a/node_modules/readdir-scoped-modules/readdir.js b/node_modules/readdir-scoped-modules/readdir.js deleted file mode 100644 index 806d787051852..0000000000000 --- a/node_modules/readdir-scoped-modules/readdir.js +++ /dev/null @@ -1,121 +0,0 @@ -var fs = require ('graceful-fs') -var dz = require ('dezalgo') -var once = require ('once') -var path = require ('path') -var debug = require ('debuglog') ('rds') - -module . exports = readdir -readdir.sync = readdirSync - -function readdir (dir, cb) { - fs . readdir (dir, function (er, kids) { - if (er) - return cb (er) - - debug ('dir=%j, kids=%j', dir, kids) - readScopes (dir, kids, function (er, data) { - if (er) - return cb (er) - - // Sort for bonus consistency points - data = data . sort (function (a, b) { - return a > b ? 1 : -1 - }) - - return cb (null, data) - }) - }) -} - -function readdirSync (dir) { - var kids = fs . readdirSync (dir) - debug ('dir=%j, kids=%j', dir, kids) - var data = readScopesSync (dir, kids) - // Sort for bonus consistency points - data = data . sort (function (a, b) { - return a > b ? 1 : -1 - }) - - return data -} - -// Turn [ 'a', '@scope' ] into -// ['a', '@scope/foo', '@scope/bar'] -function readScopes (root, kids, cb) { - var scopes = kids . filter (function (kid) { - return kid . charAt (0) === '@' - }) - - kids = kids . filter (function (kid) { - return kid . charAt (0) !== '@' - }) - - debug ('scopes=%j', scopes) - - if (scopes . length === 0) - dz (cb) (null, kids) // prevent maybe-sync zalgo release - - cb = once (cb) - var l = scopes . length - scopes . forEach (function (scope) { - var scopedir = path . resolve (root, scope) - debug ('root=%j scope=%j scopedir=%j', root, scope, scopedir) - fs . readdir (scopedir, then . bind (null, scope)) - }) - - function then (scope, er, scopekids) { - if (er) - return cb (er) - - // XXX: Not sure how old this node bug is. Maybe superstition? - scopekids = scopekids . filter (function (scopekid) { - return !(scopekid === '.' || scopekid === '..' || !scopekid) - }) - - kids . push . apply (kids, scopekids . map (function (scopekid) { - return scope + '/' + scopekid - })) - - debug ('scope=%j scopekids=%j kids=%j', scope, scopekids, kids) - - if (--l === 0) - cb (null, kids) - } -} - -function readScopesSync (root, kids) { - var scopes = kids . filter (function (kid) { - return kid . charAt (0) === '@' - }) - - kids = kids . filter (function (kid) { - return kid . charAt (0) !== '@' - }) - - debug ('scopes=%j', scopes) - - if (scopes . length === 0) - return kids - - var l = scopes . length - scopes . forEach (function (scope) { - var scopedir = path . resolve (root, scope) - debug ('root=%j scope=%j scopedir=%j', root, scope, scopedir) - then (scope, fs . readdirSync (scopedir)) - }) - - function then (scope, scopekids) { - // XXX: Not sure how old this node bug is. Maybe superstition? - scopekids = scopekids . filter (function (scopekid) { - return !(scopekid === '.' || scopekid === '..' || !scopekid) - }) - - kids . push . apply (kids, scopekids . map (function (scopekid) { - return scope + '/' + scopekid - })) - - debug ('scope=%j scopekids=%j kids=%j', scope, scopekids, kids) - } - - return kids -} diff --git a/package-lock.json b/package-lock.json index ebe6671caa2ea..9ad0f788aa454 100644 --- a/package-lock.json +++ b/package-lock.json @@ -66,7 +66,6 @@ "read", "read-package-json", "read-package-json-fast", - "readdir-scoped-modules", "rimraf", "semver", "ssri", @@ -143,7 +142,6 @@ "read": "~1.0.7", "read-package-json": "^6.0.0", "read-package-json-fast": "^3.0.1", - "readdir-scoped-modules": "^1.1.0", "rimraf": "^3.0.2", "semver": "^7.3.8", "ssri": "^10.0.0", @@ -162,7 +160,7 @@ "devDependencies": { "@npmcli/docs": "^1.0.0", "@npmcli/eslint-config": "^4.0.0", - "@npmcli/fs": "^3.0.0", + "@npmcli/fs": "^3.1.0", "@npmcli/git": "^4.0.1", "@npmcli/promise-spawn": "^6.0.1", "@npmcli/template-oss": "4.8.0", @@ -2106,9 +2104,10 @@ } }, "node_modules/@npmcli/fs": { - "version": "3.0.0", + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/@npmcli/fs/-/fs-3.1.0.tgz", + "integrity": "sha512-7kZUAaLscfgbwBQRbvdMYaZOWyMEcPTH/tJjnyAWJ/dvvs9Ef+CERx/qJb9GExJpl1qipaDGn7KqHnFGGixd0w==", "inBundle": true, - "license": "ISC", "dependencies": { "semver": "^7.3.5" }, @@ -2872,7 +2871,7 @@ }, "node_modules/asap": { "version": "2.0.6", - "inBundle": true, + "dev": true, "license": "MIT" }, "node_modules/async-hook-domain": { @@ -3897,7 +3896,7 @@ }, "node_modules/debuglog": { "version": "1.0.1", - "inBundle": true, + "dev": true, "license": "MIT", "engines": { "node": "*" @@ -4083,7 +4082,7 @@ }, "node_modules/dezalgo": { "version": "1.0.4", - "inBundle": true, + "dev": true, "license": "ISC", "dependencies": { "asap": "^2.0.0", @@ -10823,7 +10822,7 @@ }, "node_modules/readdir-scoped-modules": { "version": "1.1.0", - "inBundle": true, + "dev": true, "license": "ISC", "dependencies": { "debuglog": "^1.0.1", @@ -15025,10 +15024,10 @@ "license": "ISC", "dependencies": { "@isaacs/string-locale-compare": "^1.1.0", + "@npmcli/fs": "^3.1.0", "@npmcli/installed-package-contents": "^2.0.0", "@npmcli/map-workspaces": "^3.0.0", "@npmcli/metavuln-calculator": "^5.0.0", - "@npmcli/move-file": "^3.0.0", "@npmcli/name-from-folder": "^1.0.1", "@npmcli/node-gyp": "^3.0.0", "@npmcli/package-json": "^3.0.0", @@ -15053,7 +15052,6 @@ "promise-all-reject-late": "^1.0.0", "promise-call-limit": "^1.0.1", "read-package-json-fast": "^3.0.1", - "readdir-scoped-modules": "^1.1.0", "semver": "^7.3.7", "ssri": "^10.0.0", "treeverse": "^3.0.0", diff --git a/package.json b/package.json index 3b0eb95f7c4a4..ca303c5a48580 100644 --- a/package.json +++ b/package.json @@ -113,7 +113,6 @@ "read": "~1.0.7", "read-package-json": "^6.0.0", "read-package-json-fast": "^3.0.1", - "readdir-scoped-modules": "^1.1.0", "rimraf": "^3.0.2", "semver": "^7.3.8", "ssri": "^10.0.0", @@ -184,7 +183,6 @@ "read", "read-package-json", "read-package-json-fast", - "readdir-scoped-modules", "rimraf", "semver", "ssri", @@ -199,7 +197,7 @@ "devDependencies": { "@npmcli/docs": "^1.0.0", "@npmcli/eslint-config": "^4.0.0", - "@npmcli/fs": "^3.0.0", + "@npmcli/fs": "^3.1.0", "@npmcli/git": "^4.0.1", "@npmcli/promise-spawn": "^6.0.1", "@npmcli/template-oss": "4.8.0", diff --git a/workspaces/arborist/lib/arborist/build-ideal-tree.js b/workspaces/arborist/lib/arborist/build-ideal-tree.js index afcb67903da6d..d64bdd7e496ae 100644 --- a/workspaces/arborist/lib/arborist/build-ideal-tree.js +++ b/workspaces/arborist/lib/arborist/build-ideal-tree.js @@ -7,9 +7,8 @@ const cacache = require('cacache') const promiseCallLimit = require('promise-call-limit') const realpath = require('../../lib/realpath.js') const { resolve, dirname } = require('path') -const { promisify } = require('util') const treeCheck = require('../tree-check.js') -const readdir = promisify(require('readdir-scoped-modules')) +const { readdirScoped } = require('@npmcli/fs') const { lstat, readlink } = require('fs/promises') const { depth } = require('treeverse') const log = require('proc-log') @@ -447,7 +446,8 @@ module.exports = cls => class IdealTreeBuilder extends cls { const globalExplicitUpdateNames = [] if (this[_global] && (this[_updateAll] || this[_updateNames].length)) { const nm = resolve(this.path, 'node_modules') - for (const name of await readdir(nm).catch(() => [])) { + const paths = await readdirScoped(nm).catch(() => []) + for (const name of paths.map((p) => p.replace(/\\/g, '/'))) { tree.package.dependencies = tree.package.dependencies || {} const updateName = this[_updateNames].includes(name) if (this[_updateAll] || updateName) { diff --git a/workspaces/arborist/lib/arborist/load-actual.js b/workspaces/arborist/lib/arborist/load-actual.js index bb813806e5556..6c3f917c6ac9d 100644 --- a/workspaces/arborist/lib/arborist/load-actual.js +++ b/workspaces/arborist/lib/arborist/load-actual.js @@ -3,8 +3,7 @@ const { relative, dirname, resolve, join, normalize } = require('path') const rpj = require('read-package-json-fast') -const { promisify } = require('util') -const readdir = promisify(require('readdir-scoped-modules')) +const { readdirScoped } = require('@npmcli/fs') const walkUp = require('walk-up-path') const ancestorPath = require('common-ancestor-path') const treeCheck = require('../tree-check.js') @@ -362,7 +361,7 @@ module.exports = cls => class ActualLoader extends cls { async [_loadFSChildren] (node) { const nm = resolve(node.realpath, 'node_modules') try { - const kids = await readdir(nm) + const kids = await readdirScoped(nm).then(paths => paths.map(p => p.replace(/\\/g, '/'))) return Promise.all( // ignore . dirs and retired scoped package folders kids.filter(kid => !/^(@[^/]+\/)?\./.test(kid)) @@ -411,8 +410,8 @@ module.exports = cls => class ActualLoader extends cls { break } - const entries = nmContents.get(p) || - await readdir(p + '/node_modules').catch(() => []) + const entries = nmContents.get(p) || await readdirScoped(p + '/node_modules') + .catch(() => []).then(paths => paths.map(p => p.replace(/\\/g, '/'))) nmContents.set(p, entries) if (!entries.includes(name)) { continue diff --git a/workspaces/arborist/lib/arborist/reify.js b/workspaces/arborist/lib/arborist/reify.js index c3cbf02b31080..36aabd6f0fcdd 100644 --- a/workspaces/arborist/lib/arborist/reify.js +++ b/workspaces/arborist/lib/arborist/reify.js @@ -19,7 +19,7 @@ const { rm, symlink, } = require('fs/promises') -const moveFile = require('@npmcli/move-file') +const { moveFile } = require('@npmcli/fs') const PackageJson = require('@npmcli/package-json') const packageContents = require('@npmcli/installed-package-contents') const runScript = require('@npmcli/run-script') diff --git a/workspaces/arborist/package.json b/workspaces/arborist/package.json index d739aa26ab7b8..68d0d1e505c66 100644 --- a/workspaces/arborist/package.json +++ b/workspaces/arborist/package.json @@ -4,10 +4,10 @@ "description": "Manage node_modules trees", "dependencies": { "@isaacs/string-locale-compare": "^1.1.0", + "@npmcli/fs": "^3.1.0", "@npmcli/installed-package-contents": "^2.0.0", "@npmcli/map-workspaces": "^3.0.0", "@npmcli/metavuln-calculator": "^5.0.0", - "@npmcli/move-file": "^3.0.0", "@npmcli/name-from-folder": "^1.0.1", "@npmcli/node-gyp": "^3.0.0", "@npmcli/package-json": "^3.0.0", @@ -32,7 +32,6 @@ "promise-all-reject-late": "^1.0.0", "promise-call-limit": "^1.0.1", "read-package-json-fast": "^3.0.1", - "readdir-scoped-modules": "^1.1.0", "semver": "^7.3.7", "ssri": "^10.0.0", "treeverse": "^3.0.0", diff --git a/workspaces/arborist/test/arborist/reify.js b/workspaces/arborist/test/arborist/reify.js index 257fcb4cbcf7b..7c250a34d236b 100644 --- a/workspaces/arborist/test/arborist/reify.js +++ b/workspaces/arborist/test/arborist/reify.js @@ -3,8 +3,9 @@ const t = require('tap') const runScript = require('@npmcli/run-script') const localeCompare = require('@isaacs/string-locale-compare')('en') const tnock = require('../fixtures/tnock') - const fs = require('fs') +const fsp = require('fs/promises') +const npmFs = require('@npmcli/fs') let failRm = false let failRename = null @@ -41,26 +42,41 @@ const fsMock = { realRm(...args) }, } -const mocks = { - fs: fsMock, - 'fs/promises': { - ...fs.promises, - mkdir: async (...args) => { - if (failMkdir) { - throw failMkdir - } +const fspMock = { + ...fsp, + mkdir: async (...args) => { + if (failMkdir) { + throw failMkdir + } - return fs.promises.mkdir(...args) - }, - rm: async (...args) => { - if (failRm) { - throw new Error('rm fail') - } + return fsp.mkdir(...args) + }, + rename: async (...args) => { + if (failRename) { + throw failRename + } else if (failRenameOnce) { + const er = failRenameOnce + failRenameOnce = null + throw er + } else { + return fsp.rename(...args) + } + }, + rm: async (...args) => { + if (failRm) { + throw new Error('rm fail') + } - return fs.promises.rm(...args) - }, + return fsp.rm(...args) }, } +// need this to be injected so that it doesn't pull from main cache +const { moveFile } = t.mock('@npmcli/fs', { 'fs/promises': fspMock }) +const mocks = { + fs: fsMock, + 'fs/promises': fspMock, + '@npmcli/fs': { ...npmFs, moveFile }, +} const oldLockfileWarning = [ 'warn', @@ -73,10 +89,6 @@ This is a one-time fix-up, please be patient... `, ] -// need this to be injected so that it doesn't pull from main cache -const moveFile = t.mock('@npmcli/move-file', { fs: fsMock }) -mocks['@npmcli/move-file'] = moveFile - // track the warnings that are emitted. returns a function that removes // the listener and provides the list of what it saw. const warningTracker = () => {