merge scripts, tasks and config folder and convert code to typescript

This commit is contained in:
dennis.ludwig
2021-06-12 16:11:51 +02:00
parent eb9e85e7a0
commit 8fa1bd1e0d
23 changed files with 336 additions and 582 deletions

60
scripts/buildRadar.ts Normal file
View File

@@ -0,0 +1,60 @@
#!/usr/bin/env node
import * as fs from "fs-extra";
import { spawn } from "child_process";
import * as paths from "./paths";
// Do this as the first thing so that any code reading it knows the right env.
process.env.BABEL_ENV = "production";
process.env.NODE_ENV = "production";
// Makes the script crash on unhandled rejections instead of silently
// ignoring them. In the future, promise rejections that are not handled will
// terminate the Node.js process with a non-zero exit code.
process.on("unhandledRejection", (err) => {
throw err;
});
const runCommand = (command: string) =>
new Promise((resolve, reject) => {
const executedCommand = spawn(command, {
stdio: "inherit",
shell: true,
});
executedCommand.on("error", (error) => {
reject(error);
});
executedCommand.on("exit", (code) => {
if (code === 0) {
resolve(code);
} else {
reject();
}
});
}).catch((error) => {
console.error(error);
process.exit(1);
});
const buildTemplate = () => {
const packageManager = fs.existsSync(paths.appYarnLock) ? "yarn" : "npx";
fs.emptyDirSync(paths.templateBuild);
process.chdir(paths.template);
return runCommand(`${packageManager} build`);
};
if (fs.existsSync(paths.appRdJson)) {
buildTemplate().then(() => {
fs.copySync(paths.templateBuild, paths.appBuild);
console.log(`${paths.appBuild} was created and can be deployed.`);
});
} else {
console.error(
`${paths.appRdJson} does not exist. You have to generate it first.`
);
process.exit(1);
}