Skip to content

Release/v7.0.7 #2090

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 16 commits into from
Oct 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ jobs:

# Run the installer script
- name: Install dependencies
run: node . install
run: |
node . install --ignore-scripts --no-audit
node . rebuild

# Run the tests, but not if we're just gonna do coveralls later anyway
- name: Run Tap tests
Expand Down
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -726,3 +726,4 @@ Gareth Jones <[email protected]>
Jake Champion <[email protected]>
takenspc <[email protected]>
iraj <[email protected]>
Michele Azzolari <[email protected]>
33 changes: 33 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,36 @@
## 7.0.7 (2020-10-30)

### BUG FIXES

* [`3990b422d`](https://github.com/npm/cli/commit/3990b422d3ff63c54d96b61596bdb8f26a45ca7b)
[#2067](https://github.com/npm/cli/pull/2067)
use sh as default unix shell, not bash
([@isaacs](https://github.com/isaacs))
* [`81d6ceef6`](https://github.com/npm/cli/commit/81d6ceef6947e46355eb3ddb05a73da50870dfc1)
[#1975](https://github.com/npm/cli/issues/1975)
fix npm exec on folders missing package.json
([@ruyadorno](https://github.com/ruyadorno))
* [`2a680e91a`](https://github.com/npm/cli/commit/2a680e91a2be1f3f03a6fbd946f74628ee1cb370)
[#2083](https://github.com/npm/cli/pull/2083)
delete the contents of `node_modules` only in `npm ci`
([@nlf](https://github.com/nlf))
* [`2636fe1f4`](https://github.com/npm/cli/commit/2636fe1f45383cb1b6fc164564dc49318815db37)
[#2086](https://github.com/npm/cli/pull/2086)
disable banner output if loglevel is silent in `npm run-script`
([@macno](https://github.com/macno))

### DEPENDENCIES

* [`4156f053e`](https://github.com/npm/cli/commit/4156f053ee8712a4b53a210e62fba1e6562ba43a)
`@npmcli/[email protected]`
* restore the default `npm start` script
* [`1900ae9ad`](https://github.com/npm/cli/commit/1900ae9adecd227dd6f8b49de61a99c978ba89cf)
`@npmcli/[email protected]`
* fix errors when processing scripts as root
* [`8cb0c166c`](https://github.com/npm/cli/commit/8cb0c166ccc019146a7a94d13c12723f001d2551)
`@npmcli/[email protected]`
* make sure missing bin links get set on reify

## 7.0.6 (2020-10-27)

### BUG FIXES
Expand Down
107 changes: 33 additions & 74 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ SHELL = bash
PUBLISHTAG = $(shell node scripts/publish-tag.js)
BRANCH = $(shell git rev-parse --abbrev-ref HEAD)

markdowns = $(shell find docs -name '*.md' | grep -v 'index') README.md
markdowns = $(shell find docs -name '*.md' | grep -v 'index')

# these docs have the @VERSION@ tag in them, so they have to be rebuilt
# whenever the package.json is touched, in case the version changed.
Expand All @@ -14,8 +14,7 @@ version_mandocs = $(shell grep -rl '@VERSION@' docs/content \

cli_mandocs = $(shell find docs/content/commands -name '*.md' \
|sed 's|.md|.1|g' \
|sed 's|docs/content/commands/|man/man1/|g' ) \
man/man1/npm-README.1
|sed 's|docs/content/commands/|man/man1/|g' )

files_mandocs = $(shell find docs/content/configuring-npm -name '*.md' \
|sed 's|.md|.5|g' \
Expand All @@ -29,63 +28,29 @@ mandocs = $(cli_mandocs) $(files_mandocs) $(misc_mandocs)

all: docs

latest:
@echo "Installing latest published npm"
@echo "Use 'make install' or 'make link' to install the code"
@echo "in this folder that you're looking at right now."
node bin/npm-cli.js install -g -f npm ${NPMOPTS}

install: all
node bin/npm-cli.js install -g -f ${NPMOPTS} $(shell node bin/npm-cli.js pack | tail -1)

# backwards compat
dev: install

link: uninstall
node bin/npm-cli.js link -f

clean: markedclean marked-manclean docs-clean
rm -rf npmrc
node bin/npm-cli.js cache clean --force

uninstall:
node bin/npm-cli.js rm npm -g -f
docs: mandocs htmldocs

mandocs: $(mandocs)
mandocs: dev-deps $(mandocs)

$(version_mandocs): package.json

htmldocs:
htmldocs: dev-deps
node bin/npm-cli.js rebuild
cd docs && node dockhand.js >&2

docs: mandocs htmldocs

markedclean:
rm -rf node_modules/marked node_modules/.bin/marked .building_marked

marked-manclean:
rm -rf node_modules/marked-man node_modules/.bin/marked-man .building_marked-man
clean: docs-clean gitclean

docsclean: docs-clean

docs-clean:
rm -rf \
.building_marked \
.building_marked-man \
man \
docs/node_modules \
docs/output \
docs/.cache

## build-time tools for the documentation
build-doc-tools := node_modules/.bin/marked \
node_modules/.bin/marked-man

# use `npm install marked-man` for this to work.
man/man1/npm-README.1: README.md scripts/docs-build.js $(build-doc-tools)
@[ -d man/man1 ] || mkdir -p man/man1
node scripts/docs-build.js $< $@
rm -rf man

man/man1/%.1: docs/content/commands/%.md scripts/docs-build.js $(build-doc-tools)
## build-time dependencies for the documentation
dev-deps:
node bin/npm-cli.js install --only=dev --no-audit --ignore-scripts

## targets for man files, these are encouraged to be only built by running `make docs` or `make mandocs`
man/man1/%.1: docs/content/commands/%.md scripts/docs-build.js
@[ -d man/man1 ] || mkdir -p man/man1
node scripts/docs-build.js $< $@

Expand All @@ -95,47 +60,41 @@ man/man5/npm-json.5: man/man5/package.json.5
man/man5/npm-global.5: man/man5/folders.5
cp $< $@

man/man5/%.5: docs/content/configuring-npm/%.md scripts/docs-build.js $(build-doc-tools)
man/man5/%.5: docs/content/configuring-npm/%.md scripts/docs-build.js
@[ -d man/man5 ] || mkdir -p man/man5
node scripts/docs-build.js $< $@

man/man7/%.7: docs/content/using-npm/%.md scripts/docs-build.js $(build-doc-tools)
man/man7/%.7: docs/content/using-npm/%.md scripts/docs-build.js
@[ -d man/man7 ] || mkdir -p man/man7
node scripts/docs-build.js $< $@

marked: node_modules/.bin/marked

node_modules/.bin/marked:
node bin/npm-cli.js install marked --no-global --no-timing --no-save

marked-man: node_modules/.bin/marked-man

node_modules/.bin/marked-man:
node bin/npm-cli.js install marked-man --no-global --no-timing --no-save

test: docs
test: dev-deps
node bin/npm-cli.js test

tag:
node bin/npm-cli.js tag npm@$(PUBLISHTAG) latest

ls-ok:
node . ls >/dev/null
node . ls --production >/dev/null

gitclean:
git clean -fd

publish: gitclean ls-ok link docs-clean docs
uninstall:
node bin/npm-cli.js rm -g -f npm

link: uninstall
node bin/npm-cli.js link -f --ignore-scripts

prune:
node bin/npm-cli.js prune --production --no-save --no-audit
@[[ "$(shell git status -s)" != "" ]] && echo "ERR: found unpruned files" && exit 1 || echo "git status is clean"


publish: gitclean ls-ok link test docs-clean docs prune
@git push origin :v$(shell node bin/npm-cli.js --no-timing -v) 2>&1 || true
git push origin $(BRANCH) &&\
git push origin --tags &&\
node bin/npm-cli.js publish --tag=$(PUBLISHTAG)

release: gitclean ls-ok markedclean marked-manclean docs-clean docs
node bin/npm-cli.js prune --production --no-save
release: gitclean ls-ok docs-clean docs prune
@bash scripts/release.sh

sandwich:
@[ $$(whoami) = "root" ] && (echo "ok"; echo "ham" > sandwich) || (echo "make it yourself" && exit 13)

.PHONY: all latest install dev link docs clean uninstall test man docs-clean docsclean release ls-ok realclean
.PHONY: all latest install dev link docs clean uninstall test man docs-clean docsclean release ls-ok dev-deps prune
2 changes: 1 addition & 1 deletion lib/ci.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const ci = async () => {
'later to generate a package-lock.json file, then try again.'
throw new Error(msg)
}),
rimraf(`${where}/node_modules/`),
rimraf(`${where}/node_modules/*`, { glob: { dot: true, nosort: true, silent: true } }),
])
// npm ci should never modify the lockfile or package.json
await arb.reify({ save: false })
Expand Down
83 changes: 40 additions & 43 deletions lib/exec.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,41 @@ const PATH = require('./utils/path.js')

const cmd = (args, cb) => exec(args).then(() => cb()).catch(cb)

const run = async ({ args, call, pathArr }) => {
// turn list of args into command string
const script = call || args.map(escapeArg).join(' ').trim()

// do the fakey runScript dance
// still should work if no package.json in cwd
const realPkg = await readPackageJson(`${npm.localPrefix}/package.json`)
.catch(() => ({}))
const pkg = {
...realPkg,
scripts: {
...(realPkg.scripts || {}),
npx: script,
},
}

npm.log.disableProgress()
try {
return await runScript({
pkg,
banner: false,
// we always run in cwd, not --prefix
path: process.cwd(),
stdioString: true,
event: 'npx',
env: {
PATH: pathArr.join(delimiter),
},
stdio: 'inherit',
})
} finally {
npm.log.enableProgress()
}
}

const exec = async args => {
const { package: packages, call } = npm.flatOptions

Expand All @@ -89,17 +124,10 @@ const exec = async args => {
}

if (binExists) {
return await runScript({
cmd: [args[0], ...args.slice(1).map(escapeArg)].join(' ').trim(),
banner: false,
// we always run in cwd, not --prefix
path: process.cwd(),
stdioString: true,
event: 'npx',
env: {
PATH: pathArr.join(delimiter),
},
stdio: 'inherit',
return await run({
args,
call: [args[0], ...args.slice(1).map(escapeArg)].join(' ').trim(),
pathArr,
})
}

Expand Down Expand Up @@ -129,9 +157,6 @@ const exec = async args => {
if (needPackageCommandSwap)
args[0] = getBinFromManifest(manis[0])

// turn list of args into command string
const script = call || args.map(escapeArg).join(' ').trim()

// figure out whether we need to install stuff, or if local is fine
const localArb = new Arborist({
...npm.flatOptions,
Expand Down Expand Up @@ -180,35 +205,7 @@ const exec = async args => {
pathArr.unshift(resolve(installDir, 'node_modules/.bin'))
}

// do the fakey runScript dance
// still should work if no package.json in cwd
const realPkg = await readPackageJson(`${npm.localPrefix}/package.json`)
.catch(() => ({}))
const pkg = {
...realPkg,
scripts: {
...(realPkg.scripts || {}),
npx: script,
},
}

npm.log.disableProgress()
try {
return await runScript({
pkg,
banner: false,
// we always run in cwd, not --prefix
path: process.cwd(),
stdioString: true,
event: 'npx',
env: {
PATH: pathArr.join(delimiter),
},
stdio: 'inherit',
})
} finally {
npm.log.enableProgress()
}
return await run({ args, call, pathArr })
}

const manifestMissing = (tree, mani) => {
Expand Down
1 change: 1 addition & 0 deletions lib/run-script.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ const runScript = async (args) => {
stdio: 'inherit',
stdioString: true,
pkg,
banner: log.level !== 'silent',
}

for (const [event, args] of events) {
Expand Down
2 changes: 1 addition & 1 deletion lib/utils/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const editor = process.env.EDITOR ||
(isWindows ? 'notepad.exe' : 'vi')

const shell = isWindows ? process.env.ComSpec || 'cmd'
: process.env.SHELL || 'bash'
: process.env.SHELL || 'sh'

const { tmpdir, networkInterfaces } = require('os')
const getLocalAddresses = () => {
Expand Down
8 changes: 6 additions & 2 deletions lib/utils/error-handler.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict'

let cbCalled = false
const log = require('npmlog')
const npm = require('../npm.js')
Expand All @@ -6,6 +8,7 @@ const path = require('path')
let wroteLogFile = false
let exitCode = 0
const errorMessage = require('./error-message.js')
const replaceInfo = require('./replace-info.js')
const stopMetrics = require('./metrics.js').stop

const cacheFile = require('./cache-file.js')
Expand Down Expand Up @@ -149,14 +152,15 @@ const errorHandler = (er) => {
for (const k of ['type', 'stack', 'statusCode', 'pkgid']) {
const v = er[k]
if (v)
log.verbose(k, v)
log.verbose(k, replaceInfo(v))
}

log.verbose('cwd', process.cwd())

const os = require('os')
const args = replaceInfo(process.argv)
log.verbose('', os.type() + ' ' + os.release())
log.verbose('argv', process.argv.map(JSON.stringify).join(' '))
log.verbose('argv', args.map(JSON.stringify).join(' '))
log.verbose('node', process.version)
log.verbose('npm ', 'v' + npm.version)

Expand Down
Loading