2019-01-14 10:03:30 -05:00
|
|
|
/**
|
2019-01-15 09:08:42 -05:00
|
|
|
* This script automatically generates empty default files
|
2019-01-14 10:03:30 -05:00
|
|
|
*
|
2019-01-14 10:25:14 -05:00
|
|
|
* @author David B Heise [david@heiseink.com]
|
2019-01-14 10:03:30 -05:00
|
|
|
* @copyright Crown Copyright 2018
|
|
|
|
* @license Apache-2.0
|
|
|
|
*/
|
|
|
|
|
|
|
|
import path from "path";
|
|
|
|
import fs from "fs";
|
|
|
|
import process from "process";
|
2019-01-14 10:25:14 -05:00
|
|
|
import childProcess from "child_process";
|
2019-01-14 10:03:30 -05:00
|
|
|
|
|
|
|
|
|
|
|
const mkdirSync = function (dirPath) {
|
2019-01-15 09:08:42 -05:00
|
|
|
console.log("Ensuring Folder: " + dirPath)
|
2019-01-14 10:03:30 -05:00
|
|
|
try {
|
2019-01-14 10:25:14 -05:00
|
|
|
fs.mkdirSync(dirPath);
|
2019-01-14 10:03:30 -05:00
|
|
|
} catch (err) {
|
2019-01-14 10:25:14 -05:00
|
|
|
if (err.code !== "EEXIST") throw err;
|
2019-01-14 10:03:30 -05:00
|
|
|
}
|
2019-01-14 10:25:14 -05:00
|
|
|
};
|
2019-01-14 10:03:30 -05:00
|
|
|
|
|
|
|
const mkdirpSync = function (dirPath) {
|
2019-01-14 10:25:14 -05:00
|
|
|
const parts = dirPath.split(path.sep);
|
2019-01-14 10:03:30 -05:00
|
|
|
for (let i = 1; i <= parts.length; i++) {
|
2019-01-14 10:25:14 -05:00
|
|
|
mkdirSync(path.join.apply(null, parts.slice(0, i)));
|
2019-01-14 10:03:30 -05:00
|
|
|
}
|
2019-01-14 10:25:14 -05:00
|
|
|
};
|
2019-01-14 10:03:30 -05:00
|
|
|
|
|
|
|
|
|
|
|
const dir = process.cwd();
|
2019-01-15 09:08:42 -05:00
|
|
|
const newPath = path.join(dir, "src/core/config/modules");
|
2019-01-14 10:03:30 -05:00
|
|
|
|
|
|
|
//Create the Destination Folder
|
2019-01-15 09:08:42 -05:00
|
|
|
mkdirpSync(newPath);
|
2019-01-14 10:03:30 -05:00
|
|
|
|
|
|
|
//Create the default files
|
2019-01-15 09:08:42 -05:00
|
|
|
fs.writeFileSync(path.join(dir, "src/core/config/modules/OpModules.mjs"), "export default{};\n", {"flag": "w"});
|
|
|
|
fs.writeFileSync(path.join(dir, "src/core/config/OperationConfig.json"), "[]\n", {"flag": "w"});
|
2019-01-14 10:03:30 -05:00
|
|
|
|
|
|
|
//Run the generateOpsIndex.mjs file
|
2019-01-15 09:08:42 -05:00
|
|
|
childProcess.fork(path.join(dir, "src/core/config/scripts/generateOpsIndex.mjs"), { execArgv: ["--experimental-modules", "--no-warnings", "--no-deprecation"]});
|
2019-01-14 10:03:30 -05:00
|
|
|
|
|
|
|
//Run the generateConfig.mjs file
|
2019-01-15 09:08:42 -05:00
|
|
|
childProcess.fork(path.join(dir, "src/core/config/scripts/generateConfig.mjs"), { execArgv: ["--experimental-modules", "--no-warnings", "--no-deprecation"]});
|