2018-04-04 20:25:13 +00:00
|
|
|
import * as plugins from './npmci.plugins';
|
|
|
|
import * as paths from './npmci.paths';
|
2016-11-24 22:21:40 +00:00
|
|
|
|
2018-04-04 20:25:13 +00:00
|
|
|
import { repo } from './npmci.env';
|
2017-08-28 15:11:47 +00:00
|
|
|
|
2018-09-22 12:13:25 +00:00
|
|
|
import { KeyValueStore } from '@pushrocks/npmextra';
|
2017-08-28 15:11:47 +00:00
|
|
|
|
2019-06-19 08:41:58 +00:00
|
|
|
/**
|
|
|
|
* the main config interface for npmci
|
|
|
|
*/
|
2016-11-24 22:21:40 +00:00
|
|
|
export interface INpmciOptions {
|
2018-12-23 16:29:25 +00:00
|
|
|
projectInfo: plugins.projectinfo.ProjectInfo;
|
2019-06-19 08:41:58 +00:00
|
|
|
|
|
|
|
// npm
|
2018-04-04 20:25:13 +00:00
|
|
|
npmGlobalTools: string[];
|
|
|
|
npmAccessLevel?: 'private' | 'public';
|
2018-12-11 00:02:21 +00:00
|
|
|
npmRegistryUrl: string;
|
2019-06-19 08:41:58 +00:00
|
|
|
|
|
|
|
// docker
|
|
|
|
dockerRegistries: string[];
|
|
|
|
dockerRegistryRepoMap: { [key: string]: string };
|
|
|
|
dockerBuildargEnvMap: { [key: string]: string };
|
2016-11-24 22:21:40 +00:00
|
|
|
}
|
|
|
|
|
2017-08-28 15:11:47 +00:00
|
|
|
// instantiate a kvStorage for the current directory
|
2018-04-04 20:25:13 +00:00
|
|
|
export let kvStorage = new KeyValueStore('custom', `${repo.user}_${repo.repo}`);
|
2017-08-28 15:11:47 +00:00
|
|
|
|
2017-08-28 16:09:59 +00:00
|
|
|
// handle config retrival
|
2018-11-24 14:00:19 +00:00
|
|
|
const npmciNpmextra = new plugins.npmextra.Npmextra(paths.cwd);
|
|
|
|
const defaultConfig: INpmciOptions = {
|
2018-12-23 16:29:25 +00:00
|
|
|
projectInfo: new plugins.projectinfo.ProjectInfo(paths.cwd),
|
2017-08-28 16:09:59 +00:00
|
|
|
npmGlobalTools: [],
|
2019-06-19 08:41:58 +00:00
|
|
|
dockerRegistries: [],
|
2017-08-28 17:11:24 +00:00
|
|
|
dockerRegistryRepoMap: {},
|
2018-12-11 00:02:21 +00:00
|
|
|
npmAccessLevel: 'private',
|
|
|
|
npmRegistryUrl: 'registry.npmjs.org',
|
2017-08-29 04:07:13 +00:00
|
|
|
dockerBuildargEnvMap: {}
|
2018-04-04 20:25:13 +00:00
|
|
|
};
|
|
|
|
export let configObject = npmciNpmextra.dataFor<INpmciOptions>('npmci', defaultConfig);
|
2017-08-28 16:09:59 +00:00
|
|
|
|
2018-04-04 20:25:13 +00:00
|
|
|
/**
|
|
|
|
* gets the npmci portion of the npmextra.json file
|
|
|
|
*/
|
2017-03-08 13:50:41 +00:00
|
|
|
export let getConfig = async (): Promise<INpmciOptions> => {
|
2018-04-04 20:25:13 +00:00
|
|
|
return configObject;
|
|
|
|
};
|