Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
regUser(function (err, auth) {
if (err ||!auth || !auth._auth) return callback(err);
// saves for publish auth and maintainer
npm.config.set("username", auth.username);
npm.config.set("email", auth.email);
npm.config.set("_auth", auth._auth);
// make sure there's a package.json
checkPackage(pjs, arg, gh, function (err) {
if (err) return callback(err);
// bump version
process.chdir(arg.dir); // this must be run in the package dir, grr
npm.commands.version(["patch"], function (err) {
process.chdir(lconfig.lockerDir); // restore
if (err) return callback(err);
// finally !!!
npm.commands.publish([arg.dir], function (err) {
if (err) return callback(err);
var updated = JSON.parse(fs.readFileSync(pjs));
serviceManager.mapUpsert(pjs);
// create an issue to track this publish request
npm.commands.config(["set", "registry", changeTo.url], function (
err,
data
) {
if (err) return "";
var newR = npm.config.get("registry");
console.log(`
npm registry is set to ${STATIC.COLORS.FgGreen}${newR}${STATIC.COLORS.Reset }
Updating configurations ....`);
//Setting all active to false
for(var key in currData) {
if (currData.hasOwnProperty(key)) {
currData[key].active = false;
}
}
//Setting newly activated registry to active
currData[args[1]].active = true;
if (arguments.length > 0) {
var cb = arguments[arguments.length - 1];
if (cb && typeof cb === 'function') cb(null, true);
}
};
registry.settings = fakeSettings;
fakeLoad = spyOn(npm, 'load').and.callFake(function () { arguments[arguments.length - 1](null, true); });
fakeNPMCommands = {};
['config', 'adduser', 'cache', 'publish', 'unpublish', 'search'].forEach(function (cmd) {
fakeNPMCommands[cmd] = jasmine.createSpy(cmd).and.callFake(fakeNPM);
});
npm.commands = fakeNPMCommands;
npm.config.set = function () {};
npm.config.get = function () {};
npm.config.del = function () {};
});
it('Test 005 : should run config', function (done) {
default: info.options['npm-username'] || npm.config.get('username'),
validate: _.ary(_.bind(validator.isLength, null, _, 1), 1),
when: () => !_.has(info.options, 'npm-token'),
},
{
type: 'password',
name: 'password',
message: 'What is your npm password?',
validate: _.ary(_.bind(validator.isLength, null, _, 1), 1),
when: () => !_.has(info.options, 'npm-token'),
},
{
type: 'input',
name: 'email',
message: 'What is your npm email address?',
default: info.options['npm-username'] || npm.config.get('init-author-email'),
validate: _.ary(_.bind(validator.isLength, null, _, 1), 1),
when: answers => answers.authmethod === 'legacy',
},
]);
info.npm.authmethod = info.npm.authmethod || 'token';
if (_.has(info.options, 'npm-token')) {
info.npm.token = info.options['npm-token'];
log.info('Using npm token from command line argument.');
return;
}
if (info.npm.authmethod === 'token') {
await getNpmToken(info);
}
return new Promise((resolve, reject) => {
debug('Running \'npm shrinkwrap --also=dev\'...');
npm.config.set('only', null);
npm.config.set('also', 'dev');
npm.commands.shrinkwrap({}, (error) => (
error ? reject(error) : resolve()
));
});
}
Object.keys(npmConfig).forEach(k => {
npm.config.set(k, npmConfig[k]);
});
callback();
return Q.nfcall(npm.load, settings).then(function () {
for (var prop in settings) {
var currentValue = npm.config.get(prop);
var newValue = settings[prop];
if (currentValue !== newValue) {
cachedSettingsValues = cachedSettingsValues || {};
cachedSettings = cachedSettings || [];
cachedSettings.push(prop);
if (typeof currentValue !== 'undefined') {
cachedSettingsValues[prop] = currentValue;
}
npm.config.set(prop, newValue);
}
}
});
}
//prepare a context object
var statements = [];
var context = {
logOutput: statements,
logListener: function(message) {
statements.push(message);
}
};
//we set the prefix manually here. See:
//https://github.com/pencilblue/pencilblue/issues/214
//this is a hack to keep it working until the npm team can decouple the
//npmconf module from npm and create a scenario where it can be reloaded.
npm.on('log', context.logListener);
npm.config.prefix = prefixPath;
cb(err, context);
});
};
_createLinkNPM: function(command, installName, moduleName, preview) {
var self = this;
var loglevel = npm.config.get('loglevel');
npm.config.set('loglevel', 'silent');
return exec('npm uninstall ' + installName)
.then(function(results) {
return exec(command);
}).then(function() {
npm.config.set('loglevel', loglevel);
debug(('Successfully installed ' + installName).green);
return self._buildFromNPM(moduleName, preview);
});
},
get: function() {
return npm.config.loaded ? npm.config : null;
},
enumerable: true,