Skip to content

Commit

Permalink
fix: adds node: specifier to all native node modules (#7559)
Browse files Browse the repository at this point in the history
  • Loading branch information
reggi authored May 28, 2024
1 parent fd6479f commit 2d1d8d0
Show file tree
Hide file tree
Showing 189 changed files with 358 additions and 384 deletions.
2 changes: 1 addition & 1 deletion bin/npm-prefix.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// without having to load all of npm first
// It does not accept argv params

const path = require('path')
const path = require('node:path')
const Config = require('@npmcli/config')
const { definitions, flatten, shorthands } = require('@npmcli/config/lib/definitions')
const config = new Config({
Expand Down
2 changes: 1 addition & 1 deletion lib/cli/entry.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ module.exports = async (process, validateEngines) => {
}

// Patch the global fs module here at the app level
require('graceful-fs').gracefulify(require('fs'))
require('graceful-fs').gracefulify(require('node:fs'))

const satisfies = require('semver/functions/satisfies')
const ExitHandler = require('./exit-handler.js')
Expand Down
4 changes: 2 additions & 2 deletions lib/cli/update-notifier.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ const ciInfo = require('ci-info')
const gt = require('semver/functions/gt')
const gte = require('semver/functions/gte')
const parse = require('semver/functions/parse')
const { stat, writeFile } = require('fs/promises')
const { resolve } = require('path')
const { stat, writeFile } = require('node:fs/promises')
const { resolve } = require('node:path')

// update check frequency
const DAILY = 1000 * 60 * 60 * 24
Expand Down
4 changes: 2 additions & 2 deletions lib/commands/cache.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const cacache = require('cacache')
const pacote = require('pacote')
const fs = require('fs/promises')
const { join } = require('path')
const fs = require('node:fs/promises')
const { join } = require('node:path')
const semver = require('semver')
const BaseCommand = require('../base-cmd.js')
const npa = require('npm-package-arg')
Expand Down
4 changes: 2 additions & 2 deletions lib/commands/ci.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const reifyFinish = require('../utils/reify-finish.js')
const runScript = require('@npmcli/run-script')
const fs = require('fs/promises')
const path = require('path')
const fs = require('node:fs/promises')
const path = require('node:path')
const { log, time } = require('proc-log')
const validateLockfile = require('../utils/validate-lockfile.js')
const ArboristWorkspaceCmd = require('../arborist-cmd.js')
Expand Down
4 changes: 2 additions & 2 deletions lib/commands/completion.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@
// one per line for the shell completion method to consume in IFS=$'\n' mode
// as an array.

const fs = require('fs/promises')
const fs = require('node:fs/promises')
const nopt = require('nopt')
const { resolve } = require('path')
const { resolve } = require('node:path')
const { output } = require('proc-log')
const Npm = require('../npm.js')
const { definitions, shorthands } = require('@npmcli/config/lib/definitions')
Expand Down
2 changes: 1 addition & 1 deletion lib/commands/diff.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { resolve } = require('path')
const { resolve } = require('node:path')
const semver = require('semver')
const libnpmdiff = require('libnpmdiff')
const npa = require('npm-package-arg')
Expand Down
4 changes: 2 additions & 2 deletions lib/commands/doctor.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
const cacache = require('cacache')
const { access, lstat, readdir, constants: { R_OK, W_OK, X_OK } } = require('fs/promises')
const { access, lstat, readdir, constants: { R_OK, W_OK, X_OK } } = require('node:fs/promises')
const fetch = require('make-fetch-happen')
const which = require('which')
const pacote = require('pacote')
const { resolve } = require('path')
const { resolve } = require('node:path')
const semver = require('semver')
const { log, output } = require('proc-log')
const ping = require('../utils/ping.js')
Expand Down
6 changes: 3 additions & 3 deletions lib/commands/edit.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const { resolve } = require('path')
const { lstat } = require('fs/promises')
const cp = require('child_process')
const { resolve } = require('node:path')
const { lstat } = require('node:fs/promises')
const cp = require('node:child_process')
const completion = require('../utils/installed-shallow.js')
const BaseCommand = require('../base-cmd.js')

Expand Down
2 changes: 1 addition & 1 deletion lib/commands/exec.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { resolve } = require('path')
const { resolve } = require('node:path')
const libexec = require('libnpmexec')
const BaseCommand = require('../base-cmd.js')

Expand Down
2 changes: 1 addition & 1 deletion lib/commands/explain.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const { explainNode } = require('../utils/explain-dep.js')
const npa = require('npm-package-arg')
const semver = require('semver')
const { relative, resolve } = require('path')
const { relative, resolve } = require('node:path')
const validName = require('validate-npm-package-name')
const { output } = require('proc-log')
const ArboristWorkspaceCmd = require('../arborist-cmd.js')
Expand Down
2 changes: 1 addition & 1 deletion lib/commands/explore.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const pkgJson = require('@npmcli/package-json')
const runScript = require('@npmcli/run-script')
const { join, relative } = require('path')
const { join, relative } = require('node:path')
const { log, output } = require('proc-log')
const completion = require('../utils/installed-shallow.js')
const BaseCommand = require('../base-cmd.js')
Expand Down
2 changes: 1 addition & 1 deletion lib/commands/help.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const spawn = require('@npmcli/promise-spawn')
const path = require('path')
const path = require('node:path')
const { openUrl } = require('../utils/open-url.js')
const { glob } = require('glob')
const { output, input } = require('proc-log')
Expand Down
6 changes: 3 additions & 3 deletions lib/commands/init.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const { statSync } = require('fs')
const { relative, resolve } = require('path')
const { mkdir } = require('fs/promises')
const { statSync } = require('node:fs')
const { relative, resolve } = require('node:path')
const { mkdir } = require('node:fs/promises')
const initJson = require('init-package-json')
const npa = require('npm-package-arg')
const libexec = require('libnpmexec')
Expand Down
4 changes: 2 additions & 2 deletions lib/commands/link.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const { readdir } = require('fs/promises')
const { resolve } = require('path')
const { readdir } = require('node:fs/promises')
const { resolve } = require('node:path')
const npa = require('npm-package-arg')
const pkgJson = require('@npmcli/package-json')
const semver = require('semver')
Expand Down
2 changes: 1 addition & 1 deletion lib/commands/ls.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { resolve, relative, sep } = require('path')
const { resolve, relative, sep } = require('node:path')
const archy = require('archy')
const { breadth } = require('treeverse')
const npa = require('npm-package-arg')
Expand Down
4 changes: 2 additions & 2 deletions lib/commands/profile.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const { inspect } = require('util')
const { URL } = require('url')
const { inspect } = require('node:util')
const { URL } = require('node:url')
const { log, output } = require('proc-log')
const { get, set, createToken } = require('npm-profile')
const qrcodeTerminal = require('qrcode-terminal')
Expand Down
2 changes: 1 addition & 1 deletion lib/commands/rebuild.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { resolve } = require('path')
const { resolve } = require('node:path')
const { output } = require('proc-log')
const npa = require('npm-package-arg')
const semver = require('semver')
Expand Down
2 changes: 1 addition & 1 deletion lib/commands/repo.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { URL } = require('url')
const { URL } = require('node:url')
const PackageUrlCmd = require('../package-url-cmd.js')

class Repo extends PackageUrlCmd {
Expand Down
4 changes: 2 additions & 2 deletions lib/commands/shrinkwrap.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const { resolve, basename } = require('path')
const { unlink } = require('fs/promises')
const { resolve, basename } = require('node:path')
const { unlink } = require('node:fs/promises')
const { log } = require('proc-log')
const BaseCommand = require('../base-cmd.js')

Expand Down
2 changes: 1 addition & 1 deletion lib/commands/uninstall.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { resolve } = require('path')
const { resolve } = require('node:path')
const pkgJson = require('@npmcli/package-json')
const reifyFinish = require('../utils/reify-finish.js')
const completion = require('../utils/installed-shallow.js')
Expand Down
2 changes: 1 addition & 1 deletion lib/commands/update.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const path = require('path')
const path = require('node:path')
const { log } = require('proc-log')
const reifyFinish = require('../utils/reify-finish.js')
const ArboristWorkspaceCmd = require('../arborist-cmd.js')
Expand Down
6 changes: 3 additions & 3 deletions lib/commands/view.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
const columns = require('cli-columns')
const { readFile } = require('fs/promises')
const { readFile } = require('node:fs/promises')
const jsonParse = require('json-parse-even-better-errors')
const { log, output, META } = require('proc-log')
const npa = require('npm-package-arg')
const { resolve } = require('path')
const { resolve } = require('node:path')
const formatBytes = require('../utils/format-bytes.js')
const relativeDate = require('tiny-relative-date')
const semver = require('semver')
const { inspect } = require('util')
const { inspect } = require('node:util')
const { packument } = require('pacote')
const Queryable = require('../utils/queryable.js')
const BaseCommand = require('../base-cmd.js')
Expand Down
2 changes: 1 addition & 1 deletion lib/utils/error-message.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ const errorMessage = (er, npm) => {
// Check whether we ran into a conflict in our own package.json
if (er.path === resolve(npm.prefix, 'package.json')) {
const { isDiff } = require('parse-conflict-json')
const txt = require('fs').readFileSync(er.path, 'utf8').replace(/\r\n/g, '\n')
const txt = require('node:fs').readFileSync(er.path, 'utf8').replace(/\r\n/g, '\n')
if (isDiff(txt)) {
detail.push(['', [
'Merge conflict detected in your package.json.',
Expand Down
2 changes: 1 addition & 1 deletion lib/utils/format.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { formatWithOptions: baseFormatWithOptions } = require('util')
const { formatWithOptions: baseFormatWithOptions } = require('node:util')

// These are most assuredly not a mistake
// https://eslint.org/docs/latest/rules/no-control-regex
Expand Down
2 changes: 1 addition & 1 deletion lib/utils/get-workspaces.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { resolve, relative } = require('path')
const { resolve, relative } = require('node:path')
const mapWorkspaces = require('@npmcli/map-workspaces')
const { minimatch } = require('minimatch')
const pkgJson = require('@npmcli/package-json')
Expand Down
2 changes: 1 addition & 1 deletion lib/utils/installed-deep.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { resolve } = require('path')
const { resolve } = require('node:path')
const localeCompare = require('@isaacs/string-locale-compare')('en')

const installedDeep = async (npm) => {
Expand Down
6 changes: 3 additions & 3 deletions lib/utils/log-file.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const os = require('os')
const { join, dirname, basename } = require('path')
const os = require('node:os')
const { join, dirname, basename } = require('node:path')
const fsMiniPass = require('fs-minipass')
const fs = require('fs/promises')
const fs = require('node:fs/promises')
const { log } = require('proc-log')
const { formatWithOptions } = require('./format')

Expand Down
2 changes: 1 addition & 1 deletion lib/utils/open-url.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const { open } = require('@npmcli/promise-spawn')
const { output, input } = require('proc-log')
const { URL } = require('url')
const { URL } = require('node:url')
const readline = require('node:readline/promises')
const { once } = require('node:events')

Expand Down
2 changes: 1 addition & 1 deletion lib/utils/queryable.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const util = require('util')
const util = require('node:util')
const _delete = Symbol('delete')
const _append = Symbol('append')

Expand Down
4 changes: 2 additions & 2 deletions lib/utils/reify-finish.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const reifyOutput = require('./reify-output.js')
const ini = require('ini')
const { writeFile } = require('fs/promises')
const { resolve } = require('path')
const { writeFile } = require('node:fs/promises')
const { resolve } = require('node:path')

const reifyFinish = async (npm, arb) => {
await saveBuiltinConfig(npm, arb)
Expand Down
2 changes: 1 addition & 1 deletion lib/utils/sbom-cyclonedx.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const crypto = require('crypto')
const crypto = require('node:crypto')
const normalizeData = require('normalize-package-data')
const parseLicense = require('spdx-expression-parse')
const npa = require('npm-package-arg')
Expand Down
2 changes: 1 addition & 1 deletion lib/utils/sbom-spdx.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

const crypto = require('crypto')
const crypto = require('node:crypto')
const normalizeData = require('normalize-package-data')
const npa = require('npm-package-arg')
const ssri = require('ssri')
Expand Down
2 changes: 1 addition & 1 deletion scripts/bundle-and-gitignore-deps.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const Arborist = require('@npmcli/arborist')
const packlist = require('npm-packlist')
const { join, relative } = require('path')
const { join, relative } = require('node:path')
const localeCompare = require('@isaacs/string-locale-compare')('en')
const PackageJson = require('@npmcli/package-json')
const { run, CWD, git, fs, pkg: rootPkg, EOL } = require('./util')
Expand Down
4 changes: 2 additions & 2 deletions scripts/create-node-pr.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const { join, basename } = require('path')
const fsp = require('fs/promises')
const { join, basename } = require('node:path')
const fsp = require('node:fs/promises')
const hgi = require('hosted-git-info')
const semver = require('semver')
const pacote = require('pacote')
Expand Down
6 changes: 3 additions & 3 deletions scripts/dependency-graph.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const Arborist = require('@npmcli/arborist')
const os = require('os')
const { readFileSync } = require('fs')
const { join } = require('path')
const os = require('node:os')
const { readFileSync } = require('node:fs')
const { join } = require('node:path')
const { log } = require('proc-log')
const { run, CWD, pkg, fs, EOL } = require('./util.js')

Expand Down
4 changes: 2 additions & 2 deletions scripts/fish-completion.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable no-console */
const fs = require('fs/promises')
const { resolve } = require('path')
const fs = require('node:fs/promises')
const { resolve } = require('node:path')

const { commands, aliases } = require('../lib/utils/cmd-list.js')
const { definitions } = require('@npmcli/config/lib/definitions')
Expand Down
4 changes: 2 additions & 2 deletions scripts/resetdeps.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const { join } = require('path')
const { symlink } = require('fs/promises')
const { join } = require('node:path')
const { symlink } = require('node:fs/promises')
const { CWD, run, pkg, fs, git, npm } = require('./util.js')

const cleanup = async () => {
Expand Down
2 changes: 1 addition & 1 deletion scripts/update-authors.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { join } = require('path')
const { join } = require('node:path')
const { CWD, run, git, fs, EOL } = require('./util.js')

const main = async () => {
Expand Down
2 changes: 1 addition & 1 deletion scripts/update-cli-repos.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { join } = require('path')
const { join } = require('node:path')
const { fs, gh, run } = require('./util.js')

const query = `
Expand Down
6 changes: 3 additions & 3 deletions scripts/util.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const fsp = require('fs/promises')
const { resolve, join, relative } = require('path')
const { formatWithOptions } = require('util')
const fsp = require('node:fs/promises')
const { resolve, join, relative } = require('node:path')
const { formatWithOptions } = require('node:util')
const { log } = require('proc-log')
const nopt = require('nopt')
const npmGit = require('@npmcli/git')
Expand Down
8 changes: 4 additions & 4 deletions smoke-tests/test/fixtures/setup.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
const fs = require('fs/promises')
const { existsSync } = require('fs')
const { join, resolve, sep, extname, relative, delimiter } = require('path')
const fs = require('node:fs/promises')
const { existsSync } = require('node:fs')
const { join, resolve, sep, extname, relative, delimiter } = require('node:path')
const which = require('which')
const spawn = require('@npmcli/promise-spawn')
const MockRegistry = require('@npmcli/mock-registry')
const http = require('http')
const http = require('node:http')
const { createProxy } = require('proxy')

const { SMOKE_PUBLISH_TARBALL, CI, PATH, Path } = process.env
Expand Down
2 changes: 1 addition & 1 deletion smoke-tests/test/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { join } = require('path')
const { join } = require('node:path')
const t = require('tap')
const setup = require('./fixtures/setup.js')

Expand Down
2 changes: 1 addition & 1 deletion smoke-tests/test/large-install.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const t = require('tap')
const path = require('path')
const path = require('node:path')
const setup = require('./fixtures/setup.js')

const getFixture = (p) => require(
Expand Down
4 changes: 2 additions & 2 deletions smoke-tests/test/npm-replace-global.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

const t = require('tap')
const { join, dirname, basename, extname } = require('path')
const fs = require('fs/promises')
const { join, dirname, basename, extname } = require('node:path')
const fs = require('node:fs/promises')
const _which = require('which')
const setup = require('./fixtures/setup.js')

Expand Down
6 changes: 3 additions & 3 deletions test/bin/windows-shims.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const t = require('tap')
const { spawnSync } = require('child_process')
const { resolve, join, extname, basename } = require('path')
const { readFileSync, chmodSync, readdirSync, statSync } = require('fs')
const { spawnSync } = require('node:child_process')
const { resolve, join, extname, basename } = require('node:path')
const { readFileSync, chmodSync, readdirSync, statSync } = require('node:fs')
const Diff = require('diff')
const { moveRemove } = require('rimraf')
const { sync: which } = require('which')
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/clean-snapshot.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { relative, dirname } = require('path')
const { relative, dirname } = require('node:path')

// normalize line endings (for ini)
const cleanNewlines = (s) => s.replace(/\r\n/g, '\n')
Expand Down
Loading

0 comments on commit 2d1d8d0

Please sign in to comment.