Compare commits

...

11 Commits

Author SHA1 Message Date
f26606f757 3.1.11 2018-12-09 15:22:20 +01:00
99b03aa796 fix(core): update 2018-12-09 15:22:20 +01:00
f30dd3da65 3.1.10 2018-12-09 14:59:51 +01:00
d4decddb4b fix(core): update 2018-12-09 14:59:51 +01:00
5c2880da1a 3.1.9 2018-12-09 14:53:44 +01:00
bfffc5b130 3.1.8 2018-12-09 14:39:25 +01:00
8900a13c6b fix(core): update 2018-12-09 14:39:24 +01:00
d42acf737f 3.1.7 2018-12-09 02:51:04 +01:00
77e3b2912d fix(core): update 2018-12-09 02:51:03 +01:00
103e470eb4 3.1.6 2018-12-09 02:50:00 +01:00
74c1324e55 fix(core): update 2018-12-09 02:50:00 +01:00
5 changed files with 28 additions and 9 deletions

View File

@@ -6,7 +6,8 @@
},
"npmci": {
"npmGlobalTools": [],
"npmAccessLevel": "public"
"npmAccessLevel": "public",
"npmRegistryUrl": "registry.npmjs.org"
},
"npmdocker":{
"baseImage":"hosttoday/ht-docker-node:npmci",

2
package-lock.json generated
View File

@@ -1,6 +1,6 @@
{
"name": "@shipzone/npmci",
"version": "3.1.5",
"version": "3.1.11",
"lockfileVersion": 1,
"requires": true,
"dependencies": {

View File

@@ -1,6 +1,6 @@
{
"name": "@shipzone/npmci",
"version": "3.1.5",
"version": "3.1.11",
"description": "node and docker in gitlab ci on steroids",
"main": "dist/index.js",
"typings": "dist/index.d.ts",

View File

@@ -37,16 +37,24 @@ 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');
} else {
logger.log('error', 'no access token found! Exiting!');
process.exit(1);
}
plugins.smartfile.memory.toFsSync(npmrcFileString, '/root/.npmrc');
logger.log('info', `setting default npm registry to ${config.npmRegistryUrl}`);
await bash(`npm set registry https://${config.npmRegistryUrl}`);
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=https://${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!`);
};

View File

@@ -8,6 +8,7 @@ import { KeyValueStore } from '@pushrocks/npmextra';
export interface INpmciOptions {
npmGlobalTools: string[];
npmAccessLevel?: 'private' | 'public';
npmRegistryUrl?: string;
dockerRegistryRepoMap: any;
dockerBuildargEnvMap: any;
}