Skip to content
Open
Show file tree
Hide file tree
Changes from 8 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
2 changes: 1 addition & 1 deletion lib/utils/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const adduser = async (npm, { creds, ...opts }) => {
if (!res) {
const username = await read.username('Username:', creds.username)
const password = await read.password('Password:', creds.password)
const email = await read.email('Email: (this IS public) ', creds.email)
const email = await read.email('Email (this will be public):', creds.email)
// npm registry quirk: If you "add" an existing user with their current
// password, it's effectively a login, and if that account has otp you'll
// be prompted for it.
Expand Down
12 changes: 7 additions & 5 deletions lib/utils/display.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ class Display {

// progress
#progress
#promptCount = 0

// options
#command
Expand Down Expand Up @@ -340,15 +341,19 @@ class Display {
#inputHandler = withMeta((level, meta, ...args) => {
switch (level) {
case input.KEYS.start:
this.#promptCount++
log.pause()
this.#outputState.buffering = true
this.#progress.off()
break

case input.KEYS.end:
this.#promptCount--
log.resume()
output.flush()
this.#progress.resume()
if (this.#promptCount === 0) {
this.#progress.resume()
}
break

case input.KEYS.read: {
Expand All @@ -357,10 +362,7 @@ class Display {
const [res, rej, p] = args
return input.start(() => p()
.then(res)
.catch(rej)
// Any call to procLog.input.read will render a prompt to the user, so we always
// add a single newline of output to stdout to move the cursor to the next line
.finally(() => output.standard('')))
.catch(rej))
}
}
})
Expand Down
3 changes: 3 additions & 0 deletions lib/utils/read-user-info.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ function readOTP (msg = otpPrompt, otp, isRetry) {

function readPassword (msg = passwordPrompt, password, isRetry) {
if (isRetry && password) {
// because the prompt is silent and we need to move the cursor
// to the next line so the next output is on a new line.
process.stdout.write('\n')
return password
}

Expand Down
1 change: 0 additions & 1 deletion tap-snapshots/test/lib/commands/init.js.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,5 @@ Press ^C at any time to quit.

exports[`test/lib/commands/init.js TAP workspaces no args -- yes > should print helper info 1`] = `


added 1 package in {TIME}
`
1 change: 0 additions & 1 deletion tap-snapshots/test/lib/utils/open-url.js.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ https://www.npmjs.com
exports[`test/lib/utils/open-url.js TAP open url prompt does not error when opener can not find command > Outputs extra Browser unavailable message and url 1`] = `
npm home:
https://www.npmjs.com

Browser unavailable. Please open the URL manually:
https://www.npmjs.com
`
Expand Down
10 changes: 4 additions & 6 deletions test/lib/commands/token.js
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,6 @@ t.test('token create', async t => {
registry.createToken({ password, cidr })
await npm.exec('token', ['create'])
t.strictSame(outputs, [
'',
'Created publish token n3wt0k3n',
'with IP whitelist: 10.0.0.0/8,192.168.1.0/24',
])
Expand All @@ -292,7 +291,6 @@ t.test('token create read only', async t => {
registry.createToken({ readonly: true, password })
await npm.exec('token', ['create'])
t.strictSame(outputs, [
'',
'Created read only token n3wt0k3n',
])
})
Expand Down Expand Up @@ -349,10 +347,10 @@ t.test('token create parseable output', async t => {
}, { replace: true })
registry.createToken({ password, cidr })
await npm.exec('token', ['create'])
t.equal(outputs[1], 'token\tn3wt0k3n')
t.ok(outputs[2].startsWith('created\t'))
t.equal(outputs[3], 'readonly\tfalse')
t.equal(outputs[4], 'cidr_whitelist\t10.0.0.0/8,192.168.1.0/24')
t.equal(outputs[0], 'token\tn3wt0k3n')
t.ok(outputs[1].startsWith('created\t'))
t.equal(outputs[2], 'readonly\tfalse')
t.equal(outputs[3], 'cidr_whitelist\t10.0.0.0/8,192.168.1.0/24')
})

t.test('token create ipv6 cidr', async t => {
Expand Down
Loading