2016-06-03 00:56:20 +00:00
|
|
|
import "typings-global";
|
|
|
|
import * as plugins from "./npmci.plugins";
|
2016-06-05 21:24:11 +00:00
|
|
|
import * as paths from "./npmci.paths";
|
2016-06-03 00:56:20 +00:00
|
|
|
import {GitRepo} from "smartstring";
|
2016-06-05 00:17:55 +00:00
|
|
|
import {Dockerfile} from "./npmci.build.docker"
|
2016-06-03 00:56:20 +00:00
|
|
|
|
2016-06-10 06:07:04 +00:00
|
|
|
export let repo:GitRepo;
|
|
|
|
if(process.env.CI_BUILD_REPO) repo = new GitRepo(process.env.CI_BUILD_REPO);
|
2016-06-05 19:11:30 +00:00
|
|
|
|
|
|
|
export let buildStage:string = process.env.CI_BUILD_STAGE;
|
2016-06-03 01:44:24 +00:00
|
|
|
|
2016-06-05 21:24:11 +00:00
|
|
|
// handling config between commands
|
2016-07-18 14:56:53 +00:00
|
|
|
export let dockerRegistry:string; // will be set by npmci.prepare
|
2016-07-18 16:39:04 +00:00
|
|
|
export let setDockerRegistry = (dockerRegistryArg:string) => {
|
|
|
|
dockerRegistry = dockerRegistryArg;
|
|
|
|
}
|
2016-06-05 03:16:14 +00:00
|
|
|
export let dockerFilesBuilt:Dockerfile[] = [];
|
|
|
|
export let dockerFiles:Dockerfile[] = [];
|
2016-06-26 02:40:58 +00:00
|
|
|
export let config = {
|
2016-06-26 03:21:24 +00:00
|
|
|
dockerRegistry: undefined, // this will be set later on store
|
2016-06-26 02:40:58 +00:00
|
|
|
dockerFilesBuilt: dockerFilesBuilt,
|
|
|
|
dockerFiles: dockerFiles,
|
|
|
|
project: undefined
|
|
|
|
};
|
2016-06-05 00:17:55 +00:00
|
|
|
|
2016-06-05 21:53:01 +00:00
|
|
|
export let configStore = () => {
|
2016-06-26 03:21:24 +00:00
|
|
|
config.dockerRegistry = dockerRegistry;
|
2016-06-05 21:53:01 +00:00
|
|
|
plugins.smartfile.memory.toFsSync(
|
|
|
|
JSON.stringify(config),
|
2016-06-25 01:19:29 +00:00
|
|
|
paths.NpmciPackageConfig
|
2016-06-05 21:53:01 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2016-06-19 00:30:50 +00:00
|
|
|
let configLoad = () => {
|
|
|
|
// internal config to transfer information in between npmci shell calls
|
2016-06-05 21:53:01 +00:00
|
|
|
try {
|
2016-06-26 02:40:58 +00:00
|
|
|
plugins.lodash.assign(config,plugins.smartfile.fs.toObjectSync(paths.NpmciPackageConfig,"json"));
|
2016-06-05 21:53:01 +00:00
|
|
|
}
|
|
|
|
catch(err){
|
|
|
|
configStore();
|
2016-06-07 10:36:00 +00:00
|
|
|
plugins.beautylog.log("config initialized!");
|
2016-06-05 21:53:01 +00:00
|
|
|
}
|
2016-06-19 00:30:50 +00:00
|
|
|
|
|
|
|
// project config
|
|
|
|
try {
|
|
|
|
if(!config.project){
|
2016-06-23 20:22:03 +00:00
|
|
|
config.project = plugins.smartfile.fs.toObjectSync(paths.NpmciProjectDir,"npmci.json");
|
2016-06-19 00:30:50 +00:00
|
|
|
plugins.beautylog.ok("project config found!");
|
|
|
|
};
|
|
|
|
}
|
|
|
|
catch(err){
|
|
|
|
config.project = {};
|
|
|
|
plugins.beautylog.log("no project config found, so proceeding with default behaviour!");
|
|
|
|
}
|
2016-06-05 21:53:01 +00:00
|
|
|
|
2016-06-05 21:24:11 +00:00
|
|
|
config.dockerRegistry ? dockerRegistry = config.dockerRegistry : void(0);
|
|
|
|
config.dockerFilesBuilt ? dockerFilesBuilt = config.dockerFilesBuilt : void(0);
|
|
|
|
}
|
2016-06-05 21:53:01 +00:00
|
|
|
configLoad();
|