-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
publish: adapt config for publish RegClient (#16762)
Fixes: #16746 PR-URL: npm/npm#16762 Credit: @zkat
- Loading branch information
Showing
4 changed files
with
67 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
'use strict' | ||
|
||
module.exports = regClientConfig | ||
function regClientConfig (npm, log, config) { | ||
return { | ||
proxy: { | ||
http: config.get('proxy'), | ||
https: config.get('https-proxy'), | ||
localAddress: config.get('local-address') | ||
}, | ||
ssl: { | ||
certificate: config.get('cert'), | ||
key: config.get('key'), | ||
ca: config.get('ca'), | ||
strict: config.get('strict-ssl') | ||
}, | ||
retry: { | ||
retries: config.get('fetch-retries'), | ||
factor: config.get('fetch-retry-factor'), | ||
minTimeout: config.get('fetch-retry-mintimeout'), | ||
maxTimeout: config.get('fetch-retry-maxtimeout') | ||
}, | ||
userAgent: config.get('user-agent'), | ||
log: log, | ||
defaultTag: config.get('tag'), | ||
maxSockets: config.get('maxsockets'), | ||
scope: npm.projectScope | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,43 @@ | ||
var common = require('../common-tap.js') | ||
var test = require('tap').test | ||
var fs = require('fs') | ||
var osenv = require('osenv') | ||
var pkg = process.env.npm_config_tmp || '/tmp' | ||
pkg += '/npm-test-publish-config' | ||
'use strict' | ||
|
||
const common = require('../common-tap.js') | ||
const test = require('tap').test | ||
const fs = require('fs') | ||
const osenv = require('osenv') | ||
const pkg = `${process.env.npm_config_tmp || '/tmp'}/npm-test-publish-config` | ||
|
||
require('mkdirp').sync(pkg) | ||
|
||
fs.writeFileSync(pkg + '/package.json', JSON.stringify({ | ||
name: 'npm-test-publish-config', | ||
version: '1.2.3', | ||
publishConfig: { registry: common.registry } | ||
publishConfig: { | ||
registry: common.registry | ||
} | ||
}), 'utf8') | ||
|
||
fs.writeFileSync(pkg + '/fixture_npmrc', | ||
'//localhost:1337/:email = [email protected]\n' + | ||
'//localhost:1337/:username = fancy\n' + | ||
'//localhost:1337/:_password = ' + new Buffer('feast').toString('base64') + '\n' + | ||
'registry = http://localhost:1337/') | ||
'//localhost:1337/:_password = ' + new Buffer('feast').toString('base64')) | ||
|
||
test(function (t) { | ||
var child | ||
t.plan(4) | ||
let child | ||
t.plan(5) | ||
require('http').createServer(function (req, res) { | ||
t.pass('got request on the fakey fake registry') | ||
this.close() | ||
res.statusCode = 500 | ||
res.end(JSON.stringify({ | ||
error: 'sshhh. naptime nao. \\^O^/ <(YAWWWWN!)' | ||
})) | ||
child.kill('SIGINT') | ||
}).listen(common.port, function () { | ||
let body = '' | ||
req.on('data', (d) => { body += d }) | ||
req.on('end', () => { | ||
this.close() | ||
res.statusCode = 500 | ||
res.end(JSON.stringify({ | ||
error: 'sshhh. naptime nao. \\^O^/ <(YAWWWWN!)' | ||
})) | ||
t.match(body, /"beta"/, 'got expected tag') | ||
child.kill('SIGINT') | ||
}) | ||
}).listen(common.port, () => { | ||
t.pass('server is listening') | ||
|
||
// don't much care about listening to the child's results | ||
|
@@ -40,7 +47,7 @@ test(function (t) { | |
// itself functions normally. | ||
// | ||
// Make sure that we don't sit around waiting for lock files | ||
child = common.npm(['publish', '--userconfig=' + pkg + '/fixture_npmrc'], { | ||
child = common.npm(['publish', '--userconfig=' + pkg + '/fixture_npmrc', '--tag=beta'], { | ||
cwd: pkg, | ||
stdio: 'inherit', | ||
env: { | ||
|