fix(core): update
This commit is contained in:
parent
a1876963a8
commit
74c1324e55
@ -37,15 +37,23 @@ export let handleCli = async argvArg => {
|
||||
* authenticates npm with token from env var
|
||||
*/
|
||||
const prepare = async () => {
|
||||
const npmrcPrefix: string = '//registry.npmjs.org/:_authToken=';
|
||||
const npmToken: string = process.env.NPMCI_TOKEN_NPM;
|
||||
const npmrcFileString: string = npmrcPrefix + npmToken;
|
||||
if (npmToken) {
|
||||
logger.log('info', 'found access token');
|
||||
const config = await configModule.getConfig();
|
||||
let npmrcFileString: string = '';
|
||||
plugins.smartparam.forEachMinimatch(process.env, 'NPMCI_TOKEN_NPM*', npmEnvArg => {
|
||||
const npmRegistryUrl = npmEnvArg.split('|')[0];
|
||||
const npmToken = npmEnvArg.split('|')[1];
|
||||
npmrcFileString = `//${npmRegistryUrl}/:_authToken="${npmToken}"\n`;
|
||||
});
|
||||
|
||||
if (npmrcFileString.length > 0) {
|
||||
logger.log('info', 'found one or more access tokens');
|
||||
logger.log('info', `setting default npm registry to ${config.npmRegistryUrl}`);
|
||||
await bash(`npm set registry https:${config.npmRegistryUrl}`);
|
||||
} else {
|
||||
logger.log('error', 'no access token found! Exiting!');
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
plugins.smartfile.memory.toFsSync(npmrcFileString, '/root/.npmrc');
|
||||
return;
|
||||
};
|
||||
@ -55,6 +63,7 @@ const prepare = async () => {
|
||||
*/
|
||||
const publish = async () => {
|
||||
let npmAccessCliString = ``;
|
||||
let npmRegistryCliString = ``;
|
||||
const config = await configModule.getConfig();
|
||||
|
||||
// -> configure package access level
|
||||
@ -65,6 +74,14 @@ const publish = async () => {
|
||||
npmAccessCliString = `--access=${config.npmAccessLevel}`;
|
||||
}
|
||||
|
||||
// -> configure registry url
|
||||
if (config.npmRegistryUrl) {
|
||||
npmAccessCliString = `--registry=${config.npmRegistryUrl}`;
|
||||
} else {
|
||||
logger.log('error', `no registry url specified. Can't publish!`);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
// -> preparing
|
||||
logger.log('info', `now preparing environment:`);
|
||||
prepare();
|
||||
@ -84,7 +101,7 @@ const publish = async () => {
|
||||
|
||||
// -> publish it
|
||||
logger.log('info', `now invoking npm to publish the package!`);
|
||||
await bash(`npm publish ${npmAccessCliString}`);
|
||||
await bash(`npm publish ${npmAccessCliString} ${npmRegistryCliString}`);
|
||||
logger.log('success', `Package was successfully published!`);
|
||||
};
|
||||
|
||||
|
@ -8,6 +8,7 @@ import { KeyValueStore } from '@pushrocks/npmextra';
|
||||
export interface INpmciOptions {
|
||||
npmGlobalTools: string[];
|
||||
npmAccessLevel?: 'private' | 'public';
|
||||
npmRegistryUrl?: string;
|
||||
dockerRegistryRepoMap: any;
|
||||
dockerBuildargEnvMap: any;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user