Compare commits

...

3 Commits

Author SHA1 Message Date
214c523306 3.0.9 2017-08-28 18:10:03 +02:00
1a465f336d now respoecting registryrepo maps 2017-08-28 18:09:59 +02:00
11ec419700 git improve npmextra.json config 2017-08-28 17:19:31 +02:00
9 changed files with 62 additions and 27 deletions

File diff suppressed because one or more lines are too long

View File

@@ -64,7 +64,7 @@ exports.install = (versionArg) => __awaiter(this, void 0, void 0, function* () {
yield npmciConfig.getConfig() yield npmciConfig.getConfig()
.then((configArg) => __awaiter(this, void 0, void 0, function* () { .then((configArg) => __awaiter(this, void 0, void 0, function* () {
plugins.beautylog.log('Now checking for needed global npm tools...'); plugins.beautylog.log('Now checking for needed global npm tools...');
for (let npmTool of configArg.globalNpmTools) { for (let npmTool of configArg.npmGlobalTools) {
plugins.beautylog.info(`Checking for global "${npmTool}"`); plugins.beautylog.info(`Checking for global "${npmTool}"`);
let whichOutput = yield npmci_bash_1.bashNoError(`which ${npmTool}`); let whichOutput = yield npmci_bash_1.bashNoError(`which ${npmTool}`);
let toolAvailable = !((/not\sfound/.test(whichOutput)) || whichOutput === ''); let toolAvailable = !((/not\sfound/.test(whichOutput)) || whichOutput === '');

View File

@@ -1,6 +1,8 @@
import { KeyValueStore } from 'npmextra'; import { KeyValueStore } from 'npmextra';
export interface INpmciOptions { export interface INpmciOptions {
globalNpmTools: string[]; npmGlobalTools: string[];
dockerRegistryRepoMap: any;
} }
export declare let kvStorage: KeyValueStore; export declare let kvStorage: KeyValueStore;
export declare let configObject: INpmciOptions;
export declare let getConfig: () => Promise<INpmciOptions>; export declare let getConfig: () => Promise<INpmciOptions>;

18
dist/npmci.config.js vendored
View File

@@ -13,13 +13,15 @@ const paths = require("./npmci.paths");
const npmci_env_1 = require("./npmci.env"); const npmci_env_1 = require("./npmci.env");
const npmextra_1 = require("npmextra"); const npmextra_1 = require("npmextra");
// instantiate a kvStorage for the current directory // instantiate a kvStorage for the current directory
exports.kvStorage = new npmextra_1.KeyValueStore('custom', npmci_env_1.repo.repo); exports.kvStorage = new npmextra_1.KeyValueStore('custom', `${npmci_env_1.repo.user}_${npmci_env_1.repo.repo}`);
// handle config retrival
let npmciNpmextra = new plugins.npmextra.Npmextra(paths.cwd);
let defaultConfig = {
npmGlobalTools: [],
dockerRegistryRepoMap: {}
};
exports.configObject = npmciNpmextra.dataFor('npmci', defaultConfig);
exports.getConfig = () => __awaiter(this, void 0, void 0, function* () { exports.getConfig = () => __awaiter(this, void 0, void 0, function* () {
let npmciNpmextra = new plugins.npmextra.Npmextra(paths.cwd); return exports.configObject;
let defaultConfig = {
globalNpmTools: []
};
let npmciConfig = npmciNpmextra.dataFor('npmci', defaultConfig);
return npmciConfig;
}); });
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibnBtY2kuY29uZmlnLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvbnBtY2kuY29uZmlnLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7Ozs7QUFFQSwyQ0FBMEM7QUFDMUMsdUNBQXNDO0FBRXRDLDJDQUFrQztBQUVsQyx1Q0FBd0M7QUFNeEMsb0RBQW9EO0FBQ3pDLFFBQUEsU0FBUyxHQUFHLElBQUksd0JBQWEsQ0FBQyxRQUFRLEVBQUUsZ0JBQUksQ0FBQyxJQUFJLENBQUMsQ0FBQTtBQUVsRCxRQUFBLFNBQVMsR0FBRztJQUNyQixJQUFJLGFBQWEsR0FBRyxJQUFJLE9BQU8sQ0FBQyxRQUFRLENBQUMsUUFBUSxDQUFDLEtBQUssQ0FBQyxHQUFHLENBQUMsQ0FBQTtJQUM1RCxJQUFJLGFBQWEsR0FBa0I7UUFDakMsY0FBYyxFQUFFLEVBQUU7S0FDbkIsQ0FBQTtJQUNELElBQUksV0FBVyxHQUFHLGFBQWEsQ0FBQyxPQUFPLENBQWdCLE9BQU8sRUFBRSxhQUFhLENBQUMsQ0FBQTtJQUM5RSxNQUFNLENBQUMsV0FBVyxDQUFBO0FBQ3BCLENBQUMsQ0FBQSxDQUFBIn0= //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibnBtY2kuY29uZmlnLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvbnBtY2kuY29uZmlnLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7Ozs7QUFFQSwyQ0FBMEM7QUFDMUMsdUNBQXNDO0FBRXRDLDJDQUFrQztBQUVsQyx1Q0FBd0M7QUFPeEMsb0RBQW9EO0FBQ3pDLFFBQUEsU0FBUyxHQUFHLElBQUksd0JBQWEsQ0FBQyxRQUFRLEVBQUUsR0FBRyxnQkFBSSxDQUFDLElBQUksSUFBSSxnQkFBSSxDQUFDLElBQUksRUFBRSxDQUFDLENBQUE7QUFFL0UseUJBQXlCO0FBQ3pCLElBQUksYUFBYSxHQUFHLElBQUksT0FBTyxDQUFDLFFBQVEsQ0FBQyxRQUFRLENBQUMsS0FBSyxDQUFDLEdBQUcsQ0FBQyxDQUFBO0FBQzVELElBQUksYUFBYSxHQUFrQjtJQUNqQyxjQUFjLEVBQUUsRUFBRTtJQUNsQixxQkFBcUIsRUFBRSxFQUFFO0NBQzFCLENBQUE7QUFDVSxRQUFBLFlBQVksR0FBRyxhQUFhLENBQUMsT0FBTyxDQUFnQixPQUFPLEVBQUUsYUFBYSxDQUFDLENBQUE7QUFFM0UsUUFBQSxTQUFTLEdBQUc7SUFDckIsTUFBTSxDQUFDLG9CQUFZLENBQUE7QUFDckIsQ0FBQyxDQUFBLENBQUEifQ==

View File

@@ -7,6 +7,9 @@
"npmci": { "npmci": {
"globalNpmTools": [ "globalNpmTools": [
"npmts" "npmts"
],
"npmGlobalTools": [
"npmts"
] ]
}, },
"npmdocker":{ "npmdocker":{

View File

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

View File

@@ -1,6 +1,7 @@
import * as plugins from './mod.plugins' import * as plugins from './mod.plugins'
import * as paths from '../npmci.paths' import * as paths from '../npmci.paths'
import * as NpmciEnv from '../npmci.env' import * as NpmciEnv from '../npmci.env'
import * as NpmciConfig from '../npmci.config'
import { bash } from '../npmci.bash' import { bash } from '../npmci.bash'
import { Dockerfile } from './mod.classes.dockerfile' import { Dockerfile } from './mod.classes.dockerfile'
@@ -130,13 +131,25 @@ export let dockerBaseImage = function (dockerfileContentArg: string) {
/** /**
* returns the docker tag * returns the docker tag
*/ */
export let getDockerTagString = function (registryArg: string, repoArg: string, versionArg: string, suffixArg?: string): string { export let getDockerTagString = (registryArg: string, repoArg: string, versionArg: string, suffixArg?: string): string => {
// determine wether the suffix is needed
// determine wether the repo should be mapped accordingly to the registry
let mappedRepo = NpmciConfig.configObject.dockerRegistryRepoMap[registryArg]
let repo = (() => {
if (mappedRepo) {
return mappedRepo
} else {
return repoArg
}
})()
// determine wether the version contais a suffix
let version = versionArg let version = versionArg
if (suffixArg) { if (suffixArg) {
version = versionArg + '_' + suffixArg version = versionArg + '_' + suffixArg
} }
let tagString = `${registryArg}/${repoArg}:${version}`
let tagString = `${registryArg}/${repo}:${version}`
return tagString return tagString
} }

View File

@@ -57,7 +57,7 @@ export let install = async (versionArg) => {
await npmciConfig.getConfig() await npmciConfig.getConfig()
.then(async configArg => { .then(async configArg => {
plugins.beautylog.log('Now checking for needed global npm tools...') plugins.beautylog.log('Now checking for needed global npm tools...')
for (let npmTool of configArg.globalNpmTools) { for (let npmTool of configArg.npmGlobalTools) {
plugins.beautylog.info(`Checking for global "${npmTool}"`) plugins.beautylog.info(`Checking for global "${npmTool}"`)
let whichOutput: string = await bashNoError(`which ${npmTool}`) let whichOutput: string = await bashNoError(`which ${npmTool}`)
let toolAvailable: boolean = !((/not\sfound/.test(whichOutput)) || whichOutput === '') let toolAvailable: boolean = !((/not\sfound/.test(whichOutput)) || whichOutput === '')

View File

@@ -8,17 +8,21 @@ import { repo } from './npmci.env'
import { KeyValueStore } from 'npmextra' import { KeyValueStore } from 'npmextra'
export interface INpmciOptions { export interface INpmciOptions {
globalNpmTools: string[] npmGlobalTools: string[]
dockerRegistryRepoMap: any
} }
// instantiate a kvStorage for the current directory // instantiate a kvStorage for the current directory
export let kvStorage = new KeyValueStore('custom', repo.user + repo.repo) export let kvStorage = new KeyValueStore('custom', `${repo.user}_${repo.repo}`)
// handle config retrival
let npmciNpmextra = new plugins.npmextra.Npmextra(paths.cwd)
let defaultConfig: INpmciOptions = {
npmGlobalTools: [],
dockerRegistryRepoMap: {}
}
export let configObject = npmciNpmextra.dataFor<INpmciOptions>('npmci', defaultConfig)
export let getConfig = async (): Promise<INpmciOptions> => { export let getConfig = async (): Promise<INpmciOptions> => {
let npmciNpmextra = new plugins.npmextra.Npmextra(paths.cwd) return configObject
let defaultConfig: INpmciOptions = {
globalNpmTools: []
}
let npmciConfig = npmciNpmextra.dataFor<INpmciOptions>('npmci', defaultConfig)
return npmciConfig
} }