2018-05-18 11:09:14 +00:00
|
|
|
import * as plugins from './npmdocker.plugins';
|
|
|
|
import * as paths from './npmdocker.paths';
|
2016-07-18 22:37:13 +00:00
|
|
|
|
2016-08-04 20:25:15 +00:00
|
|
|
// interfaces
|
2018-09-16 19:08:13 +00:00
|
|
|
import { IKeyValueObject } from '@pushrocks/qenv';
|
2016-08-04 20:25:15 +00:00
|
|
|
|
2016-07-18 22:59:57 +00:00
|
|
|
export interface IConfig {
|
2018-05-18 11:09:14 +00:00
|
|
|
baseImage: string;
|
|
|
|
command: string;
|
|
|
|
dockerSock: boolean;
|
|
|
|
exitCode?: number;
|
|
|
|
keyValueObjectArray: IKeyValueObject[];
|
|
|
|
}
|
2016-07-18 22:59:57 +00:00
|
|
|
|
2017-03-28 23:01:37 +00:00
|
|
|
let getQenvKeyValueObject = async () => {
|
2018-05-18 11:09:14 +00:00
|
|
|
let qenvKeyValueObjectArray: IKeyValueObject[];
|
2017-02-11 19:23:10 +00:00
|
|
|
if (plugins.smartfile.fs.fileExistsSync(plugins.path.join(paths.cwd, 'qenv.yml'))) {
|
2018-05-18 11:09:14 +00:00
|
|
|
qenvKeyValueObjectArray = new plugins.qenv.Qenv(paths.cwd, '.nogit/').keyValueObjectArray;
|
2017-02-11 19:23:10 +00:00
|
|
|
} else {
|
2018-05-18 11:09:14 +00:00
|
|
|
qenvKeyValueObjectArray = [];
|
2017-10-13 14:44:25 +00:00
|
|
|
}
|
2018-05-18 11:09:14 +00:00
|
|
|
return qenvKeyValueObjectArray;
|
|
|
|
};
|
2016-07-18 22:37:13 +00:00
|
|
|
|
2017-03-28 23:01:37 +00:00
|
|
|
let buildConfig = async (qenvKeyValueObjectArrayArg: IKeyValueObject[]) => {
|
2018-05-18 11:09:14 +00:00
|
|
|
let npmextra = new plugins.npmextra.Npmextra(paths.cwd);
|
|
|
|
let config = npmextra.dataFor<IConfig>('npmdocker', {
|
|
|
|
baseImage: 'hosttoday/ht-docker-node:npmdocker',
|
|
|
|
init: 'rm -rf node_nodules/ && yarn install',
|
|
|
|
command: 'npmci npm test',
|
|
|
|
dockerSock: false,
|
|
|
|
keyValueObjectArray: qenvKeyValueObjectArrayArg
|
|
|
|
});
|
|
|
|
return config;
|
|
|
|
};
|
2016-08-04 20:25:15 +00:00
|
|
|
|
2017-03-28 23:01:37 +00:00
|
|
|
export let run = async (): Promise<IConfig> => {
|
2018-05-18 11:09:14 +00:00
|
|
|
let config = await getQenvKeyValueObject().then(buildConfig);
|
|
|
|
return config;
|
|
|
|
};
|