diff --git a/.npmrc b/.npmrc new file mode 100644 index 0000000..6bc2539 --- /dev/null +++ b/.npmrc @@ -0,0 +1,2 @@ +@moduletrace:registry=https://git.tben.me/api/packages/moduletrace/npm/ +//git.tben.me/api/packages/moduletrace/npm/:_authToken=${GITBEN_NPM_TOKEN} diff --git a/bin/nodecid b/bin/nodecid new file mode 100755 index 0000000..8434521 Binary files /dev/null and b/bin/nodecid differ diff --git a/bun.lockb b/bun.lockb new file mode 100755 index 0000000..8ecc377 Binary files /dev/null and b/bun.lockb differ diff --git a/deploy/start.js b/deploy/start.js deleted file mode 100755 index ddaec2c..0000000 --- a/deploy/start.js +++ /dev/null @@ -1,263 +0,0 @@ -// @ts-check - -const path = require("path"); -const fs = require("fs"); -const { - execSync, - spawnSync, - spawn, - execFile, - execFileSync, - ChildProcess, -} = require("child_process"); -const colors = require("../utils/console-colors"); -const kill = require("kill-port"); - -//////////////////////////////////////////// -//////////////////////////////////////////// -//////////////////////////////////////////// - -let redeployments = 0; - -/** @type {NodeJS.Signals | number} */ -const KILL_SIGNAL = "SIGTERM"; -// const KILL_SIGNAL = "SIGINT"; - -/** @type {ChildProcess | null} */ -let childProcess = null; - -const pTitle = "nodecid"; -process.title = pTitle; - -/** - * # Start the process - * @param {object} param0 - * @param {string} param0.command - * @param {string[] | string} param0.preflight - * @param {string[] | string} [param0.postflight] - * @param {string} param0.redeploy_file - * @param {string | number | (string | number)[]} [param0.port] - The port to kill on rebuild - * @param {boolean} [param0.first_run] - Whether to run the preflight on first run. Default `false` - */ -function startProcess({ - command, - preflight, - postflight, - redeploy_file, - port, - first_run, -}) { - try { - if (first_run) { - console.log("First Run ..."); - const runPreflight = preflightFn(preflight); - } - - if (!preflight) { - console.log( - `${colors.FgRed}Error:${colors.Reset} No preflight included in config file. If you don't want to run any preflight command simply add an empty array.` - ); - process.exit(); - } - - childProcess = run(command); - - if (!childProcess) { - console.log( - `${colors.FgRed}Error:${colors.Reset} Process couldn't start. Exiting...` - ); - process.exit(); - } - - console.log("Watching", redeploy_file); - - fs.watchFile(redeploy_file, { interval: 100 }, (curr, prev) => { - console.log(`${colors.BgBlue}File Changed${colors.Reset}`); - - if (redeployments == 0) return; - - if (childProcess) { - console.log("******************************"); - console.log( - `******** ${colors.FgBlue}Rebuilding ${colors.FgMagenta}${redeployments}${colors.Reset} ********` - ); - console.log("******************************"); - - try { - const runPreflight = preflightFn(preflight); - - if (!runPreflight) { - // TODO: Action to take if preflight fails - - console.log( - `${colors.FgRed}Error:${colors.Reset} Preflight Failed.` - ); - } else { - killChild(port).then((kill) => { - if (kill) { - childProcess = run(command); - - if (postflight) { - const runPostflight = preflightFn( - postflight, - true - ); - - if (!runPostflight) { - // TODO: Action to take if postflight fails - - console.log( - `${colors.FgRed}Error:${colors.Reset} Postflight Failed.` - ); - } - } - } else { - process.exit(); - } - }); - } - } catch (/** @type {*} */ error) { - console.log( - `${colors.FgRed}Error:${colors.Reset} killing child processes => ${error.message}` - ); - process.exit(); - } - } - }); - } catch (/** @type {*} */ error) { - console.log( - `${colors.FgRed}Error:${colors.Reset} First run failed! => ${error.message}` - ); - } -} - -//////////////////////////////////////////// -//////////////////////////////////////////// -//////////////////////////////////////////// - -/** - * ## Preflight Function - * @param {string} command - * @returns {ChildProcess | null} - */ -function run(command) { - console.log("\n******************************"); - console.log( - `****** ${colors.FgGreen}Starting App ...${colors.Reset} ******` - ); - console.log("******************************\n"); - - const startCommandArray = command.split(" ").filter((str) => str.trim()); - - try { - const firstCommand = startCommandArray.shift(); - - if (!firstCommand) { - throw new Error("No Starting Command Found in command string!"); - } - - let childProcess = spawn(firstCommand, startCommandArray, { - stdio: "inherit", - killSignal: KILL_SIGNAL, - }); - - // let childProcess = execSync(command, { - // stdio: "inherit", - // }); - - redeployments++; - - return childProcess; - } catch (/** @type {*} */ error) { - console.log( - `${colors.FgRed}Error:${colors.Reset} running start command => ${error.message}` - ); - return null; - } -} - -//////////////////////////////////////////// -//////////////////////////////////////////// -//////////////////////////////////////////// - -/** - * ## Preflight Function - * @param {string[] | string} preflight - * @param {boolean} [postflight] - * @returns {boolean} - */ -function preflightFn(preflight, postflight) { - const tag = postflight ? "Postflight" : "Preflight"; - console.log(`${tag} Running ...`); - - /** @type {import("child_process").ExecSyncOptions} */ - const options = { - cwd: process.cwd(), - stdio: "inherit", - }; - - try { - if (typeof preflight == "string") { - execFileSync(preflight, options); - } else if (typeof preflight == "object" && preflight?.[0]) { - for (let i = 0; i < preflight.length; i++) { - const cmd = preflight[i]; - try { - const execCmd = execSync(cmd, options); - } catch (error) { - console.log( - `${colors.FgRed}Error:${colors.Reset} ${tag} command ${cmd} Failed! => ${error.message}` - ); - return false; - break; - } - } - } - return true; - } catch (error) { - console.log( - `${colors.FgRed}Error:${colors.Reset} ${tag} Failed! => ${error.message}` - ); - return false; - } -} - -//////////////////////////////////////////// -//////////////////////////////////////////// -//////////////////////////////////////////// - -/** - * ## Kill Child Process Function - * @param {string | number | (string | number)[]} [port] - * @returns {Promise} - */ -async function killChild(port) { - if (!childProcess) return false; - - try { - const childProcessPID = childProcess.pid; - childProcess.kill(); - - if (typeof port == "object" && port?.[0]) { - for (let i = 0; i < port.length; i++) { - const singlePort = port[i]; - await kill(Number(singlePort)); - } - } else if (port) { - await kill(Number(port)); - } - - return true; - } catch (error) { - console.log( - `${colors.FgRed}Error:${colors.Reset} Child Process couldn't be killed! ${error.message}` - ); - return false; - } -} - -//////////////////////////////////////////// -//////////////////////////////////////////// -//////////////////////////////////////////// - -module.exports = startProcess; diff --git a/dist/index.d.ts b/dist/index.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/dist/index.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/dist/index.js b/dist/index.js new file mode 100644 index 0000000..c73a659 --- /dev/null +++ b/dist/index.js @@ -0,0 +1,50 @@ +"use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +const fs_1 = __importDefault(require("fs")); +const path_1 = __importDefault(require("path")); +const console_colors_1 = __importDefault(require("./utils/console-colors")); +const start_1 = __importDefault(require("./utils/start")); +const WORK_DIR = process.cwd(); +function run() { + try { + const configText = fs_1.default.readFileSync(path_1.default.join(WORK_DIR, "nodecid.config.json"), "utf-8"); + const config = JSON.parse(configText); + const { start, preflight, postflight, build, redeploy_path, first_run, port, } = config; + /** @type {string | undefined} */ + let redeployFile; + if (!redeploy_path) { + const defaultRedeployPath = path_1.default.join(WORK_DIR, "REDEPLOY"); + const checkExistingPath = fs_1.default.existsSync(defaultRedeployPath); + if (!checkExistingPath) { + fs_1.default.writeFileSync(defaultRedeployPath, Date.now().toString(), "utf-8"); + } + redeployFile = path_1.default.join(WORK_DIR, "REDEPLOY"); + } + else { + redeployFile = path_1.default.resolve(WORK_DIR, redeploy_path); + } + if (!redeployFile) + throw new Error("Redeploy file not found!"); + (0, start_1.default)({ + command: start, + preflight, + redeploy_file: redeployFile, + first_run, + port, + postflight, + }); + } + catch (error) { + console.log(`${console_colors_1.default.FgRed}ERROR:${console_colors_1.default.Reset} CI process failed! => ${error.message}`); + } +} +run(); +process.on("exit", () => { + console.log("Process exiting ..."); +}); +process.on("beforeExit", () => { + console.log("Process Before exit ..."); +}); diff --git a/dist/tsconfig.tsbuildinfo b/dist/tsconfig.tsbuildinfo new file mode 100644 index 0000000..39871b6 --- /dev/null +++ b/dist/tsconfig.tsbuildinfo @@ -0,0 +1 @@ +{"fileNames":["../../../../../.bun/install/global/node_modules/typescript/lib/lib.es5.d.ts","../../../../../.bun/install/global/node_modules/typescript/lib/lib.es2015.d.ts","../../../../../.bun/install/global/node_modules/typescript/lib/lib.es2016.d.ts","../../../../../.bun/install/global/node_modules/typescript/lib/lib.es2017.d.ts","../../../../../.bun/install/global/node_modules/typescript/lib/lib.es2018.d.ts","../../../../../.bun/install/global/node_modules/typescript/lib/lib.es2019.d.ts","../../../../../.bun/install/global/node_modules/typescript/lib/lib.es2020.d.ts","../../../../../.bun/install/global/node_modules/typescript/lib/lib.es2021.d.ts","../../../../../.bun/install/global/node_modules/typescript/lib/lib.es2022.d.ts","../../../../../.bun/install/global/node_modules/typescript/lib/lib.es2023.d.ts","../../../../../.bun/install/global/node_modules/typescript/lib/lib.es2024.d.ts","../../../../../.bun/install/global/node_modules/typescript/lib/lib.esnext.d.ts","../../../../../.bun/install/global/node_modules/typescript/lib/lib.dom.d.ts","../../../../../.bun/install/global/node_modules/typescript/lib/lib.dom.iterable.d.ts","../../../../../.bun/install/global/node_modules/typescript/lib/lib.es2015.core.d.ts","../../../../../.bun/install/global/node_modules/typescript/lib/lib.es2015.collection.d.ts","../../../../../.bun/install/global/node_modules/typescript/lib/lib.es2015.generator.d.ts","../../../../../.bun/install/global/node_modules/typescript/lib/lib.es2015.iterable.d.ts","../../../../../.bun/install/global/node_modules/typescript/lib/lib.es2015.promise.d.ts","../../../../../.bun/install/global/node_modules/typescript/lib/lib.es2015.proxy.d.ts","../../../../../.bun/install/global/node_modules/typescript/lib/lib.es2015.reflect.d.ts","../../../../../.bun/install/global/node_modules/typescript/lib/lib.es2015.symbol.d.ts","../../../../../.bun/install/global/node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts","../../../../../.bun/install/global/node_modules/typescript/lib/lib.es2016.array.include.d.ts","../../../../../.bun/install/global/node_modules/typescript/lib/lib.es2016.intl.d.ts","../../../../../.bun/install/global/node_modules/typescript/lib/lib.es2017.arraybuffer.d.ts","../../../../../.bun/install/global/node_modules/typescript/lib/lib.es2017.date.d.ts","../../../../../.bun/install/global/node_modules/typescript/lib/lib.es2017.object.d.ts","../../../../../.bun/install/global/node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts","../../../../../.bun/install/global/node_modules/typescript/lib/lib.es2017.string.d.ts","../../../../../.bun/install/global/node_modules/typescript/lib/lib.es2017.intl.d.ts","../../../../../.bun/install/global/node_modules/typescript/lib/lib.es2017.typedarrays.d.ts","../../../../../.bun/install/global/node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts","../../../../../.bun/install/global/node_modules/typescript/lib/lib.es2018.asynciterable.d.ts","../../../../../.bun/install/global/node_modules/typescript/lib/lib.es2018.intl.d.ts","../../../../../.bun/install/global/node_modules/typescript/lib/lib.es2018.promise.d.ts","../../../../../.bun/install/global/node_modules/typescript/lib/lib.es2018.regexp.d.ts","../../../../../.bun/install/global/node_modules/typescript/lib/lib.es2019.array.d.ts","../../../../../.bun/install/global/node_modules/typescript/lib/lib.es2019.object.d.ts","../../../../../.bun/install/global/node_modules/typescript/lib/lib.es2019.string.d.ts","../../../../../.bun/install/global/node_modules/typescript/lib/lib.es2019.symbol.d.ts","../../../../../.bun/install/global/node_modules/typescript/lib/lib.es2019.intl.d.ts","../../../../../.bun/install/global/node_modules/typescript/lib/lib.es2020.bigint.d.ts","../../../../../.bun/install/global/node_modules/typescript/lib/lib.es2020.date.d.ts","../../../../../.bun/install/global/node_modules/typescript/lib/lib.es2020.promise.d.ts","../../../../../.bun/install/global/node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts","../../../../../.bun/install/global/node_modules/typescript/lib/lib.es2020.string.d.ts","../../../../../.bun/install/global/node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts","../../../../../.bun/install/global/node_modules/typescript/lib/lib.es2020.intl.d.ts","../../../../../.bun/install/global/node_modules/typescript/lib/lib.es2020.number.d.ts","../../../../../.bun/install/global/node_modules/typescript/lib/lib.es2021.promise.d.ts","../../../../../.bun/install/global/node_modules/typescript/lib/lib.es2021.string.d.ts","../../../../../.bun/install/global/node_modules/typescript/lib/lib.es2021.weakref.d.ts","../../../../../.bun/install/global/node_modules/typescript/lib/lib.es2021.intl.d.ts","../../../../../.bun/install/global/node_modules/typescript/lib/lib.es2022.array.d.ts","../../../../../.bun/install/global/node_modules/typescript/lib/lib.es2022.error.d.ts","../../../../../.bun/install/global/node_modules/typescript/lib/lib.es2022.intl.d.ts","../../../../../.bun/install/global/node_modules/typescript/lib/lib.es2022.object.d.ts","../../../../../.bun/install/global/node_modules/typescript/lib/lib.es2022.string.d.ts","../../../../../.bun/install/global/node_modules/typescript/lib/lib.es2022.regexp.d.ts","../../../../../.bun/install/global/node_modules/typescript/lib/lib.es2023.array.d.ts","../../../../../.bun/install/global/node_modules/typescript/lib/lib.es2023.collection.d.ts","../../../../../.bun/install/global/node_modules/typescript/lib/lib.es2023.intl.d.ts","../../../../../.bun/install/global/node_modules/typescript/lib/lib.es2024.arraybuffer.d.ts","../../../../../.bun/install/global/node_modules/typescript/lib/lib.es2024.collection.d.ts","../../../../../.bun/install/global/node_modules/typescript/lib/lib.es2024.object.d.ts","../../../../../.bun/install/global/node_modules/typescript/lib/lib.es2024.promise.d.ts","../../../../../.bun/install/global/node_modules/typescript/lib/lib.es2024.regexp.d.ts","../../../../../.bun/install/global/node_modules/typescript/lib/lib.es2024.sharedmemory.d.ts","../../../../../.bun/install/global/node_modules/typescript/lib/lib.es2024.string.d.ts","../../../../../.bun/install/global/node_modules/typescript/lib/lib.esnext.array.d.ts","../../../../../.bun/install/global/node_modules/typescript/lib/lib.esnext.collection.d.ts","../../../../../.bun/install/global/node_modules/typescript/lib/lib.esnext.intl.d.ts","../../../../../.bun/install/global/node_modules/typescript/lib/lib.esnext.disposable.d.ts","../../../../../.bun/install/global/node_modules/typescript/lib/lib.esnext.decorators.d.ts","../../../../../.bun/install/global/node_modules/typescript/lib/lib.esnext.iterator.d.ts","../../../../../.bun/install/global/node_modules/typescript/lib/lib.decorators.d.ts","../../../../../.bun/install/global/node_modules/typescript/lib/lib.decorators.legacy.d.ts","../utils/console-colors.ts","../node_modules/shell-exec/index.js","../node_modules/kill-port/index.js","../utils/preflight.ts","../utils/run.ts","../utils/kill-child.ts","../utils/start.ts","../types.ts","../index.ts","../utils/triggers/github.ts","../node_modules/@types/node/compatibility/disposable.d.ts","../node_modules/@types/node/compatibility/indexable.d.ts","../node_modules/@types/node/compatibility/iterators.d.ts","../node_modules/@types/node/compatibility/index.d.ts","../node_modules/@types/node/globals.typedarray.d.ts","../node_modules/@types/node/buffer.buffer.d.ts","../node_modules/undici-types/header.d.ts","../node_modules/undici-types/readable.d.ts","../node_modules/undici-types/file.d.ts","../node_modules/undici-types/fetch.d.ts","../node_modules/undici-types/formdata.d.ts","../node_modules/undici-types/connector.d.ts","../node_modules/undici-types/client.d.ts","../node_modules/undici-types/errors.d.ts","../node_modules/undici-types/dispatcher.d.ts","../node_modules/undici-types/global-dispatcher.d.ts","../node_modules/undici-types/global-origin.d.ts","../node_modules/undici-types/pool-stats.d.ts","../node_modules/undici-types/pool.d.ts","../node_modules/undici-types/handlers.d.ts","../node_modules/undici-types/balanced-pool.d.ts","../node_modules/undici-types/agent.d.ts","../node_modules/undici-types/mock-interceptor.d.ts","../node_modules/undici-types/mock-agent.d.ts","../node_modules/undici-types/mock-client.d.ts","../node_modules/undici-types/mock-pool.d.ts","../node_modules/undici-types/mock-errors.d.ts","../node_modules/undici-types/proxy-agent.d.ts","../node_modules/undici-types/env-http-proxy-agent.d.ts","../node_modules/undici-types/retry-handler.d.ts","../node_modules/undici-types/retry-agent.d.ts","../node_modules/undici-types/api.d.ts","../node_modules/undici-types/interceptors.d.ts","../node_modules/undici-types/util.d.ts","../node_modules/undici-types/cookies.d.ts","../node_modules/undici-types/patch.d.ts","../node_modules/undici-types/websocket.d.ts","../node_modules/undici-types/eventsource.d.ts","../node_modules/undici-types/filereader.d.ts","../node_modules/undici-types/diagnostics-channel.d.ts","../node_modules/undici-types/content-type.d.ts","../node_modules/undici-types/cache.d.ts","../node_modules/undici-types/index.d.ts","../node_modules/@types/node/globals.d.ts","../node_modules/@types/node/assert.d.ts","../node_modules/@types/node/assert/strict.d.ts","../node_modules/@types/node/async_hooks.d.ts","../node_modules/@types/node/buffer.d.ts","../node_modules/@types/node/child_process.d.ts","../node_modules/@types/node/cluster.d.ts","../node_modules/@types/node/console.d.ts","../node_modules/@types/node/constants.d.ts","../node_modules/@types/node/crypto.d.ts","../node_modules/@types/node/dgram.d.ts","../node_modules/@types/node/diagnostics_channel.d.ts","../node_modules/@types/node/dns.d.ts","../node_modules/@types/node/dns/promises.d.ts","../node_modules/@types/node/domain.d.ts","../node_modules/@types/node/dom-events.d.ts","../node_modules/@types/node/events.d.ts","../node_modules/@types/node/fs.d.ts","../node_modules/@types/node/fs/promises.d.ts","../node_modules/@types/node/http.d.ts","../node_modules/@types/node/http2.d.ts","../node_modules/@types/node/https.d.ts","../node_modules/@types/node/inspector.d.ts","../node_modules/@types/node/module.d.ts","../node_modules/@types/node/net.d.ts","../node_modules/@types/node/os.d.ts","../node_modules/@types/node/path.d.ts","../node_modules/@types/node/perf_hooks.d.ts","../node_modules/@types/node/process.d.ts","../node_modules/@types/node/punycode.d.ts","../node_modules/@types/node/querystring.d.ts","../node_modules/@types/node/readline.d.ts","../node_modules/@types/node/readline/promises.d.ts","../node_modules/@types/node/repl.d.ts","../node_modules/@types/node/sea.d.ts","../node_modules/@types/node/sqlite.d.ts","../node_modules/@types/node/stream.d.ts","../node_modules/@types/node/stream/promises.d.ts","../node_modules/@types/node/stream/consumers.d.ts","../node_modules/@types/node/stream/web.d.ts","../node_modules/@types/node/string_decoder.d.ts","../node_modules/@types/node/test.d.ts","../node_modules/@types/node/timers.d.ts","../node_modules/@types/node/timers/promises.d.ts","../node_modules/@types/node/tls.d.ts","../node_modules/@types/node/trace_events.d.ts","../node_modules/@types/node/tty.d.ts","../node_modules/@types/node/url.d.ts","../node_modules/@types/node/util.d.ts","../node_modules/@types/node/v8.d.ts","../node_modules/@types/node/vm.d.ts","../node_modules/@types/node/wasi.d.ts","../node_modules/@types/node/worker_threads.d.ts","../node_modules/@types/node/zlib.d.ts","../node_modules/@types/node/index.d.ts","../node_modules/@types/ws/index.d.ts","../node_modules/bun-types/fetch.d.ts","../node_modules/bun-types/globals.d.ts","../node_modules/bun-types/bun.d.ts","../node_modules/bun-types/overrides.d.ts","../node_modules/bun-types/ffi.d.ts","../node_modules/bun-types/test.d.ts","../node_modules/bun-types/html-rewriter.d.ts","../node_modules/bun-types/jsc.d.ts","../node_modules/bun-types/sqlite.d.ts","../node_modules/bun-types/wasm.d.ts","../node_modules/bun-types/deprecated.d.ts","../node_modules/bun-types/ambient.d.ts","../node_modules/bun-types/index.d.ts","../node_modules/@types/bun/index.d.ts"],"fileIdsList":[[94,136,190,198],[79,85,86,94,136,149,158,190,198],[94,136,190,198,200],[94,133,136,190,198],[94,135,136,190,198],[136,190,198],[94,136,141,171,190,198],[94,136,137,142,148,149,156,168,179,190,198],[94,136,137,138,148,156,190,198],[89,90,91,94,136,190,198],[94,136,139,180,190,198],[94,136,140,141,149,157,190,198],[94,136,141,168,176,190,198],[94,136,142,144,148,156,190,198],[94,135,136,143,190,198],[94,136,144,145,190,198],[94,136,148,190,198],[94,136,146,148,190,198],[94,135,136,148,190,198],[94,136,148,149,150,168,179,190,198],[94,136,148,149,150,163,168,171,190,191,198],[94,131,136,184,190,198],[94,131,136,144,148,151,156,168,179,190,198],[94,136,148,149,151,152,156,168,176,179,190,198],[94,136,151,153,168,176,179,190,198],[92,93,94,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,190,198],[94,136,148,154,190,198],[94,136,155,179,184,190,198],[94,136,144,148,156,168,190,198],[94,136,157,190,198],[94,136,158,190,198],[94,135,136,159,190,198],[94,133,134,135,136,137,138,139,140,141,142,143,144,145,146,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,190,191,198],[94,136,161,190,198],[94,136,162,190,198],[94,136,148,163,164,190,198],[94,136,163,165,180,182,190,198],[94,136,148,168,169,170,171,190,198],[94,136,168,170,190,198],[94,136,168,169,190,198],[94,136,171,190,198],[94,136,172,190,198],[94,133,136,168,190,198],[94,136,148,174,175,190,198],[94,136,174,175,190,198],[94,136,141,156,168,176,190,191,198],[94,136,177,190,198],[94,136,156,178,190,198],[94,136,151,162,179,190,198],[94,136,141,180,190,198],[94,136,168,181,190,198],[94,136,155,182,190,198],[94,136,183,190,198],[94,136,141,148,150,159,168,179,182,184,190,198],[94,136,168,185,190,198],[94,136,148,151,153,168,176,179,185,186,190,191,198],[94,136,141,149,176,180,191,192,198],[94,136,190],[94,131,136,190,198],[94,131,136,141,159,168,171,180,184,187,188,190,198],[94,136,186,187,188,189,190,191,192,193,194,195,196,197,198,199],[94,136,150,176,190,198],[94,136,190,193,198],[80,94,136,190,198],[94,136,137,190,198],[94,103,107,136,179,190,198],[94,103,136,168,179,190,198],[94,98,136,190,198],[94,100,103,136,176,179,190,191,198],[94,136,156,176,190,191,198],[94,136,186,190,198],[94,98,136,186,190,198],[94,100,103,136,156,179,190,198],[94,95,96,99,102,136,148,168,179,190,198],[94,103,110,136,190,198],[94,95,101,136,190,198],[94,103,124,125,136,190,198],[94,99,103,136,171,179,186,190,198],[94,124,136,186,190,198],[94,97,98,136,186,190,198],[94,103,136,190,198],[94,97,98,99,100,101,102,103,104,105,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,125,126,127,128,129,130,136,190,198],[94,103,118,136,190,198],[94,103,110,111,136,190,198],[94,101,103,111,112,136,190,198],[94,102,136,190,198],[94,95,98,103,136,190,198],[94,103,107,111,112,136,190,198],[94,107,136,190,198],[94,101,103,106,136,179,190,198],[94,95,100,103,110,136,190,198],[94,136,168,190,198],[94,98,103,124,136,184,186,190,198],[79,81,94,136,137,190,198],[79,94,136,137,190,198],[79,81,82,83,84,94,136,137,149,190,198]],"fileInfos":[{"version":"e41c290ef7dd7dab3493e6cbe5909e0148edf4a8dad0271be08edec368a0f7b9","affectsGlobalScope":true,"impliedFormat":1},{"version":"45b7ab580deca34ae9729e97c13cfd999df04416a79116c3bfb483804f85ded4","impliedFormat":1},{"version":"3facaf05f0c5fc569c5649dd359892c98a85557e3e0c847964caeb67076f4d75","impliedFormat":1},{"version":"e44bb8bbac7f10ecc786703fe0a6a4b952189f908707980ba8f3c8975a760962","impliedFormat":1},{"version":"5e1c4c362065a6b95ff952c0eab010f04dcd2c3494e813b493ecfd4fcb9fc0d8","impliedFormat":1},{"version":"68d73b4a11549f9c0b7d352d10e91e5dca8faa3322bfb77b661839c42b1ddec7","impliedFormat":1},{"version":"5efce4fc3c29ea84e8928f97adec086e3dc876365e0982cc8479a07954a3efd4","impliedFormat":1},{"version":"feecb1be483ed332fad555aff858affd90a48ab19ba7272ee084704eb7167569","impliedFormat":1},{"version":"ee7bad0c15b58988daa84371e0b89d313b762ab83cb5b31b8a2d1162e8eb41c2","impliedFormat":1},{"version":"27bdc30a0e32783366a5abeda841bc22757c1797de8681bbe81fbc735eeb1c10","impliedFormat":1},{"version":"8fd575e12870e9944c7e1d62e1f5a73fcf23dd8d3a321f2a2c74c20d022283fe","impliedFormat":1},{"version":"e12a46ce14b817d4c9e6b2b478956452330bf00c9801b79de46f7a1815b5bd40","impliedFormat":1},{"version":"4fd3f3422b2d2a3dfd5cdd0f387b3a8ec45f006c6ea896a4cb41264c2100bb2c","affectsGlobalScope":true,"impliedFormat":1},{"version":"69e65d976bf166ce4a9e6f6c18f94d2424bf116e90837ace179610dbccad9b42","affectsGlobalScope":true,"impliedFormat":1},{"version":"c57796738e7f83dbc4b8e65132f11a377649c00dd3eee333f672b8f0a6bea671","affectsGlobalScope":true,"impliedFormat":1},{"version":"dc2df20b1bcdc8c2d34af4926e2c3ab15ffe1160a63e58b7e09833f616efff44","affectsGlobalScope":true,"impliedFormat":1},{"version":"515d0b7b9bea2e31ea4ec968e9edd2c39d3eebf4a2d5cbd04e88639819ae3b71","affectsGlobalScope":true,"impliedFormat":1},{"version":"62bb211266ee48b2d0edf0d8d1b191f0c24fc379a82bd4c1692a082c540bc6b1","affectsGlobalScope":true,"impliedFormat":1},{"version":"0dc1e7ceda9b8b9b455c3a2d67b0412feab00bd2f66656cd8850e8831b08b537","affectsGlobalScope":true,"impliedFormat":1},{"version":"ce691fb9e5c64efb9547083e4a34091bcbe5bdb41027e310ebba8f7d96a98671","affectsGlobalScope":true,"impliedFormat":1},{"version":"8d697a2a929a5fcb38b7a65594020fcef05ec1630804a33748829c5ff53640d0","affectsGlobalScope":true,"impliedFormat":1},{"version":"4ff2a353abf8a80ee399af572debb8faab2d33ad38c4b4474cff7f26e7653b8d","affectsGlobalScope":true,"impliedFormat":1},{"version":"936e80ad36a2ee83fc3caf008e7c4c5afe45b3cf3d5c24408f039c1d47bdc1df","affectsGlobalScope":true,"impliedFormat":1},{"version":"d15bea3d62cbbdb9797079416b8ac375ae99162a7fba5de2c6c505446486ac0a","affectsGlobalScope":true,"impliedFormat":1},{"version":"68d18b664c9d32a7336a70235958b8997ebc1c3b8505f4f1ae2b7e7753b87618","affectsGlobalScope":true,"impliedFormat":1},{"version":"eb3d66c8327153d8fa7dd03f9c58d351107fe824c79e9b56b462935176cdf12a","affectsGlobalScope":true,"impliedFormat":1},{"version":"38f0219c9e23c915ef9790ab1d680440d95419ad264816fa15009a8851e79119","affectsGlobalScope":true,"impliedFormat":1},{"version":"69ab18c3b76cd9b1be3d188eaf8bba06112ebbe2f47f6c322b5105a6fbc45a2e","affectsGlobalScope":true,"impliedFormat":1},{"version":"fef8cfad2e2dc5f5b3d97a6f4f2e92848eb1b88e897bb7318cef0e2820bceaab","affectsGlobalScope":true,"impliedFormat":1},{"version":"2f11ff796926e0832f9ae148008138ad583bd181899ab7dd768a2666700b1893","affectsGlobalScope":true,"impliedFormat":1},{"version":"4de680d5bb41c17f7f68e0419412ca23c98d5749dcaaea1896172f06435891fc","affectsGlobalScope":true,"impliedFormat":1},{"version":"954296b30da6d508a104a3a0b5d96b76495c709785c1d11610908e63481ee667","affectsGlobalScope":true,"impliedFormat":1},{"version":"ac9538681b19688c8eae65811b329d3744af679e0bdfa5d842d0e32524c73e1c","affectsGlobalScope":true,"impliedFormat":1},{"version":"0a969edff4bd52585473d24995c5ef223f6652d6ef46193309b3921d65dd4376","affectsGlobalScope":true,"impliedFormat":1},{"version":"9e9fbd7030c440b33d021da145d3232984c8bb7916f277e8ffd3dc2e3eae2bdb","affectsGlobalScope":true,"impliedFormat":1},{"version":"811ec78f7fefcabbda4bfa93b3eb67d9ae166ef95f9bff989d964061cbf81a0c","affectsGlobalScope":true,"impliedFormat":1},{"version":"717937616a17072082152a2ef351cb51f98802fb4b2fdabd32399843875974ca","affectsGlobalScope":true,"impliedFormat":1},{"version":"d7e7d9b7b50e5f22c915b525acc5a49a7a6584cf8f62d0569e557c5cfc4b2ac2","affectsGlobalScope":true,"impliedFormat":1},{"version":"71c37f4c9543f31dfced6c7840e068c5a5aacb7b89111a4364b1d5276b852557","affectsGlobalScope":true,"impliedFormat":1},{"version":"576711e016cf4f1804676043e6a0a5414252560eb57de9faceee34d79798c850","affectsGlobalScope":true,"impliedFormat":1},{"version":"89c1b1281ba7b8a96efc676b11b264de7a8374c5ea1e6617f11880a13fc56dc6","affectsGlobalScope":true,"impliedFormat":1},{"version":"74f7fa2d027d5b33eb0471c8e82a6c87216223181ec31247c357a3e8e2fddc5b","affectsGlobalScope":true,"impliedFormat":1},{"version":"f1e2a172204962276504466a6393426d2ca9c54894b1ad0a6c9dad867a65f876","affectsGlobalScope":true,"impliedFormat":1},{"version":"063600664504610fe3e99b717a1223f8b1900087fab0b4cad1496a114744f8df","affectsGlobalScope":true,"impliedFormat":1},{"version":"934019d7e3c81950f9a8426d093458b65d5aff2c7c1511233c0fd5b941e608ab","affectsGlobalScope":true,"impliedFormat":1},{"version":"52ada8e0b6e0482b728070b7639ee42e83a9b1c22d205992756fe020fd9f4a47","affectsGlobalScope":true,"impliedFormat":1},{"version":"3bdefe1bfd4d6dee0e26f928f93ccc128f1b64d5d501ff4a8cf3c6371200e5e6","affectsGlobalScope":true,"impliedFormat":1},{"version":"59fb2c069260b4ba00b5643b907ef5d5341b167e7d1dbf58dfd895658bda2867","affectsGlobalScope":true,"impliedFormat":1},{"version":"639e512c0dfc3fad96a84caad71b8834d66329a1f28dc95e3946c9b58176c73a","affectsGlobalScope":true,"impliedFormat":1},{"version":"368af93f74c9c932edd84c58883e736c9e3d53cec1fe24c0b0ff451f529ceab1","affectsGlobalScope":true,"impliedFormat":1},{"version":"af3dd424cf267428f30ccfc376f47a2c0114546b55c44d8c0f1d57d841e28d74","affectsGlobalScope":true,"impliedFormat":1},{"version":"995c005ab91a498455ea8dfb63aa9f83fa2ea793c3d8aa344be4a1678d06d399","affectsGlobalScope":true,"impliedFormat":1},{"version":"959d36cddf5e7d572a65045b876f2956c973a586da58e5d26cde519184fd9b8a","affectsGlobalScope":true,"impliedFormat":1},{"version":"965f36eae237dd74e6cca203a43e9ca801ce38824ead814728a2807b1910117d","affectsGlobalScope":true,"impliedFormat":1},{"version":"3925a6c820dcb1a06506c90b1577db1fdbf7705d65b62b99dce4be75c637e26b","affectsGlobalScope":true,"impliedFormat":1},{"version":"0a3d63ef2b853447ec4f749d3f368ce642264246e02911fcb1590d8c161b8005","affectsGlobalScope":true,"impliedFormat":1},{"version":"b5ce7a470bc3628408429040c4e3a53a27755022a32fd05e2cb694e7015386c7","affectsGlobalScope":true,"impliedFormat":1},{"version":"8444af78980e3b20b49324f4a16ba35024fef3ee069a0eb67616ea6ca821c47a","affectsGlobalScope":true,"impliedFormat":1},{"version":"3287d9d085fbd618c3971944b65b4be57859f5415f495b33a6adc994edd2f004","affectsGlobalScope":true,"impliedFormat":1},{"version":"b4b67b1a91182421f5df999988c690f14d813b9850b40acd06ed44691f6727ad","affectsGlobalScope":true,"impliedFormat":1},{"version":"bab26767638ab3557de12c900f0b91f710c7dc40ee9793d5a27d32c04f0bf646","affectsGlobalScope":true,"impliedFormat":1},{"version":"436aaf437562f276ec2ddbee2f2cdedac7664c1e4c1d2c36839ddd582eeb3d0a","affectsGlobalScope":true,"impliedFormat":1},{"version":"8e3c06ea092138bf9fa5e874a1fdbc9d54805d074bee1de31b99a11e2fec239d","affectsGlobalScope":true,"impliedFormat":1},{"version":"87dc0f382502f5bbce5129bdc0aea21e19a3abbc19259e0b43ae038a9fc4e326","affectsGlobalScope":true,"impliedFormat":1},{"version":"b1cb28af0c891c8c96b2d6b7be76bd394fddcfdb4709a20ba05a7c1605eea0f9","affectsGlobalScope":true,"impliedFormat":1},{"version":"2fef54945a13095fdb9b84f705f2b5994597640c46afeb2ce78352fab4cb3279","affectsGlobalScope":true,"impliedFormat":1},{"version":"ac77cb3e8c6d3565793eb90a8373ee8033146315a3dbead3bde8db5eaf5e5ec6","affectsGlobalScope":true,"impliedFormat":1},{"version":"56e4ed5aab5f5920980066a9409bfaf53e6d21d3f8d020c17e4de584d29600ad","affectsGlobalScope":true,"impliedFormat":1},{"version":"4ece9f17b3866cc077099c73f4983bddbcb1dc7ddb943227f1ec070f529dedd1","affectsGlobalScope":true,"impliedFormat":1},{"version":"0a6282c8827e4b9a95f4bf4f5c205673ada31b982f50572d27103df8ceb8013c","affectsGlobalScope":true,"impliedFormat":1},{"version":"1c9319a09485199c1f7b0498f2988d6d2249793ef67edda49d1e584746be9032","affectsGlobalScope":true,"impliedFormat":1},{"version":"e3a2a0cee0f03ffdde24d89660eba2685bfbdeae955a6c67e8c4c9fd28928eeb","affectsGlobalScope":true,"impliedFormat":1},{"version":"811c71eee4aa0ac5f7adf713323a5c41b0cf6c4e17367a34fbce379e12bbf0a4","affectsGlobalScope":true,"impliedFormat":1},{"version":"51ad4c928303041605b4d7ae32e0c1ee387d43a24cd6f1ebf4a2699e1076d4fa","affectsGlobalScope":true,"impliedFormat":1},{"version":"d4b1d2c51d058fc21ec2629fff7a76249dec2e36e12960ea056e3ef89174080f","affectsGlobalScope":true,"impliedFormat":1},{"version":"61d6a2092f48af66dbfb220e31eea8b10bc02b6932d6e529005fd2d7b3281290","affectsGlobalScope":true,"impliedFormat":1},{"version":"8e7f8264d0fb4c5339605a15daadb037bf238c10b654bb3eee14208f860a32ea","affectsGlobalScope":true,"impliedFormat":1},{"version":"782dec38049b92d4e85c1585fbea5474a219c6984a35b004963b00beb1aab538","affectsGlobalScope":true,"impliedFormat":1},{"version":"b6d329daa27f8566be687cd4d7230721a911dd646ddc4f1a8670e6f36899ff4a","signature":"33dfadb81add09d56537ac985bebca096d5bb6f497b5cea94121eb75ed0d4bce"},{"version":"d6b070bc4931f5bdb949bc104248b3714c13d4656791f71e00d8e0694364a4a2","impliedFormat":1},{"version":"a74de5086c7157f2e3bff6562e4f2593183ef7317399cd855e5c1f36f811a779","impliedFormat":1},{"version":"1258223998a3acc5723b741e9908a220416745bbe3c558d9bb8a84e9ece5ac76","signature":"45540b802bf4662e83cdf0c26357717af50364d56c977c9df845dee67faed6ac"},{"version":"a26ca4b3b9f6c4215686561365369ea9e3bf3ba6d0cadfddf59f773f162f5a0b","signature":"ba6fe53f7df0fc5832b676fbc1a647af6b1a91423959c87fff6b6ef01584b987"},{"version":"b443dd350daa130042f5ea94de0ec6c151a1e25c645612f4036ed31824819980","signature":"0abd746930dd3bcc17d7ae0aa8e30987a1386ba838c9d38e5212e71e90cba2a5"},{"version":"17feb3bb71bb9425cebf91e6248a2fbbb66dfc46294a7f6978a738a19844b596","signature":"592026b7b913b97f82aa206437105ae1d020ebb281a8376f71673f242425bf06"},{"version":"16ad44212cb5a792b44f7f59cf78714e8b35eb48909d978cda5ba9470944464d","signature":"9feda3c3f33a863e3534f66fa1ad90e8a2b08457b1a7ca589c246e8cff9ab43a"},{"version":"8b9e2523af43839dae91045f62aaf60a480c665741583b8333e48fd34ea063a9","signature":"8e609bb71c20b858c77f0e9f90bb1319db8477b13f9f965f1a1e18524bf50881"},{"version":"2e66bd2555fc707421f2a5288754f17ab1eda3b69b5166cefce0c374558cc29b","signature":"1b9df659299259451837f8eb0c103f08857e1cb0933dabc92969ad4a353f2588","affectsGlobalScope":true},{"version":"70521b6ab0dcba37539e5303104f29b721bfb2940b2776da4cc818c07e1fefc1","affectsGlobalScope":true,"impliedFormat":1},{"version":"030e350db2525514580ed054f712ffb22d273e6bc7eddc1bb7eda1e0ba5d395e","affectsGlobalScope":true,"impliedFormat":1},{"version":"d153a11543fd884b596587ccd97aebbeed950b26933ee000f94009f1ab142848","affectsGlobalScope":true,"impliedFormat":1},{"version":"21d819c173c0cf7cc3ce57c3276e77fd9a8a01d35a06ad87158781515c9a438a","impliedFormat":1},{"version":"a79e62f1e20467e11a904399b8b18b18c0c6eea6b50c1168bf215356d5bebfaf","affectsGlobalScope":true,"impliedFormat":1},{"version":"0fd06258805d26c72f5997e07a23155d322d5f05387adb3744a791fe6a0b042d","affectsGlobalScope":true,"impliedFormat":1},{"version":"5929864ce17fba74232584d90cb721a89b7ad277220627cc97054ba15a98ea8f","impliedFormat":1},{"version":"24bd580b5743dc56402c440dc7f9a4f5d592ad7a419f25414d37a7bfe11e342b","impliedFormat":1},{"version":"25c8056edf4314820382a5fdb4bb7816999acdcb929c8f75e3f39473b87e85bc","impliedFormat":1},{"version":"c464d66b20788266e5353b48dc4aa6bc0dc4a707276df1e7152ab0c9ae21fad8","impliedFormat":1},{"version":"78d0d27c130d35c60b5e5566c9f1e5be77caf39804636bc1a40133919a949f21","impliedFormat":1},{"version":"c6fd2c5a395f2432786c9cb8deb870b9b0e8ff7e22c029954fabdd692bff6195","impliedFormat":1},{"version":"1d6e127068ea8e104a912e42fc0a110e2aa5a66a356a917a163e8cf9a65e4a75","impliedFormat":1},{"version":"5ded6427296cdf3b9542de4471d2aa8d3983671d4cac0f4bf9c637208d1ced43","impliedFormat":1},{"version":"6bdc71028db658243775263e93a7db2fd2abfce3ca569c3cca5aee6ed5eb186d","impliedFormat":1},{"version":"cadc8aced301244057c4e7e73fbcae534b0f5b12a37b150d80e5a45aa4bebcbd","impliedFormat":1},{"version":"385aab901643aa54e1c36f5ef3107913b10d1b5bb8cbcd933d4263b80a0d7f20","impliedFormat":1},{"version":"9670d44354bab9d9982eca21945686b5c24a3f893db73c0dae0fd74217a4c219","impliedFormat":1},{"version":"0b8a9268adaf4da35e7fa830c8981cfa22adbbe5b3f6f5ab91f6658899e657a7","impliedFormat":1},{"version":"11396ed8a44c02ab9798b7dca436009f866e8dae3c9c25e8c1fbc396880bf1bb","impliedFormat":1},{"version":"ba7bc87d01492633cb5a0e5da8a4a42a1c86270e7b3d2dea5d156828a84e4882","impliedFormat":1},{"version":"4893a895ea92c85345017a04ed427cbd6a1710453338df26881a6019432febdd","impliedFormat":1},{"version":"c21dc52e277bcfc75fac0436ccb75c204f9e1b3fa5e12729670910639f27343e","impliedFormat":1},{"version":"13f6f39e12b1518c6650bbb220c8985999020fe0f21d818e28f512b7771d00f9","impliedFormat":1},{"version":"9b5369969f6e7175740bf51223112ff209f94ba43ecd3bb09eefff9fd675624a","impliedFormat":1},{"version":"4fe9e626e7164748e8769bbf74b538e09607f07ed17c2f20af8d680ee49fc1da","impliedFormat":1},{"version":"24515859bc0b836719105bb6cc3d68255042a9f02a6022b3187948b204946bd2","impliedFormat":1},{"version":"ea0148f897b45a76544ae179784c95af1bd6721b8610af9ffa467a518a086a43","impliedFormat":1},{"version":"24c6a117721e606c9984335f71711877293a9651e44f59f3d21c1ea0856f9cc9","impliedFormat":1},{"version":"dd3273ead9fbde62a72949c97dbec2247ea08e0c6952e701a483d74ef92d6a17","impliedFormat":1},{"version":"405822be75ad3e4d162e07439bac80c6bcc6dbae1929e179cf467ec0b9ee4e2e","impliedFormat":1},{"version":"0db18c6e78ea846316c012478888f33c11ffadab9efd1cc8bcc12daded7a60b6","impliedFormat":1},{"version":"e61be3f894b41b7baa1fbd6a66893f2579bfad01d208b4ff61daef21493ef0a8","impliedFormat":1},{"version":"bd0532fd6556073727d28da0edfd1736417a3f9f394877b6d5ef6ad88fba1d1a","impliedFormat":1},{"version":"89167d696a849fce5ca508032aabfe901c0868f833a8625d5a9c6e861ef935d2","impliedFormat":1},{"version":"615ba88d0128ed16bf83ef8ccbb6aff05c3ee2db1cc0f89ab50a4939bfc1943f","impliedFormat":1},{"version":"a4d551dbf8746780194d550c88f26cf937caf8d56f102969a110cfaed4b06656","impliedFormat":1},{"version":"8bd86b8e8f6a6aa6c49b71e14c4ffe1211a0e97c80f08d2c8cc98838006e4b88","impliedFormat":1},{"version":"317e63deeb21ac07f3992f5b50cdca8338f10acd4fbb7257ebf56735bf52ab00","impliedFormat":1},{"version":"4732aec92b20fb28c5fe9ad99521fb59974289ed1e45aecb282616202184064f","impliedFormat":1},{"version":"2e85db9e6fd73cfa3d7f28e0ab6b55417ea18931423bd47b409a96e4a169e8e6","impliedFormat":1},{"version":"c46e079fe54c76f95c67fb89081b3e399da2c7d109e7dca8e4b58d83e332e605","impliedFormat":1},{"version":"bf67d53d168abc1298888693338cb82854bdb2e69ef83f8a0092093c2d562107","impliedFormat":1},{"version":"ba97261afafe85aafe76d988e65e531da8e8cf791c49caf0531f5dd1689bd91b","affectsGlobalScope":true,"impliedFormat":1},{"version":"f52e8dacc97d71dcc96af29e49584353f9c54cb916d132e3e768d8b8129c928d","impliedFormat":1},{"version":"7394959e5a741b185456e1ef5d64599c36c60a323207450991e7a42e08911419","impliedFormat":1},{"version":"76103716ba397bbb61f9fa9c9090dca59f39f9047cb1352b2179c5d8e7f4e8d0","impliedFormat":1},{"version":"53eac70430b30089a3a1959d8306b0f9cfaf0de75224b68ef25243e0b5ad1ca3","affectsGlobalScope":true,"impliedFormat":1},{"version":"4314c7a11517e221f7296b46547dbc4df047115b182f544d072bdccffa57fc72","impliedFormat":1},{"version":"115971d64632ea4742b5b115fb64ed04bcaae2c3c342f13d9ba7e3f9ee39c4e7","impliedFormat":1},{"version":"c2510f124c0293ab80b1777c44d80f812b75612f297b9857406468c0f4dafe29","affectsGlobalScope":true,"impliedFormat":1},{"version":"a40826e8476694e90da94aa008283a7de50d1dafd37beada623863f1901cb7fb","impliedFormat":1},{"version":"86956cc2eb9dd371d6fab493d326a574afedebf76eef3fa7833b8e0d9b52d6f1","affectsGlobalScope":true,"impliedFormat":1},{"version":"24642567d3729bcc545bacb65ee7c0db423400c7f1ef757cab25d05650064f98","impliedFormat":1},{"version":"e6f5a38687bebe43a4cef426b69d34373ef68be9a6b1538ec0a371e69f309354","impliedFormat":1},{"version":"a6bf63d17324010ca1fbf0389cab83f93389bb0b9a01dc8a346d092f65b3605f","impliedFormat":1},{"version":"e009777bef4b023a999b2e5b9a136ff2cde37dc3f77c744a02840f05b18be8ff","impliedFormat":1},{"version":"1e0d1f8b0adfa0b0330e028c7941b5a98c08b600efe7f14d2d2a00854fb2f393","impliedFormat":1},{"version":"ee1ee365d88c4c6c0c0a5a5701d66ebc27ccd0bcfcfaa482c6e2e7fe7b98edf7","affectsGlobalScope":true,"impliedFormat":1},{"version":"88bc59b32d0d5b4e5d9632ac38edea23454057e643684c3c0b94511296f2998c","affectsGlobalScope":true,"impliedFormat":1},{"version":"e9ad08a376ac84948fcca0013d6f1d4ae4f9522e26b91f87945b97c99d7cc30b","impliedFormat":1},{"version":"eaf9ee1d90a35d56264f0bf39842282c58b9219e112ac7d0c1bce98c6c5da672","impliedFormat":1},{"version":"c15c4427ae7fd1dcd7f312a8a447ac93581b0d4664ddf151ecd07de4bf2bb9d7","impliedFormat":1},{"version":"5135bdd72cc05a8192bd2e92f0914d7fc43ee077d1293dc622a049b7035a0afb","impliedFormat":1},{"version":"4f80de3a11c0d2f1329a72e92c7416b2f7eab14f67e92cac63bb4e8d01c6edc8","impliedFormat":1},{"version":"6d386bc0d7f3afa1d401afc3e00ed6b09205a354a9795196caed937494a713e6","impliedFormat":1},{"version":"aeac7c51bde4658c192bc45819344eb20fc64743264b0465be6025201220a6b7","affectsGlobalScope":true,"impliedFormat":1},{"version":"d4047ed87e765bd3bcc316a0c4c4c8b0061628460d8a5412d1c4b53a4658665a","impliedFormat":1},{"version":"b1b6ee0d012aeebe11d776a155d8979730440082797695fc8e2a5c326285678f","impliedFormat":1},{"version":"45875bcae57270aeb3ebc73a5e3fb4c7b9d91d6b045f107c1d8513c28ece71c0","impliedFormat":1},{"version":"3eb62baae4df08c9173e6903d3ca45942ccec8c3659b0565684a75f3292cffbb","affectsGlobalScope":true,"impliedFormat":1},{"version":"42aaa94addeed66a04b61e433c14e829c43d1efd653cf2fda480c5fb3d722ed8","affectsGlobalScope":true,"impliedFormat":1},{"version":"3f16a7e4deafa527ed9995a772bb380eb7d3c2c0fd4ae178c5263ed18394db2c","impliedFormat":1},{"version":"c6b4e0a02545304935ecbf7de7a8e056a31bb50939b5b321c9d50a405b5a0bba","impliedFormat":1},{"version":"fab29e6d649aa074a6b91e3bdf2bff484934a46067f6ee97a30fcd9762ae2213","impliedFormat":1},{"version":"8145e07aad6da5f23f2fcd8c8e4c5c13fb26ee986a79d03b0829b8fce152d8b2","impliedFormat":1},{"version":"e1120271ebbc9952fdc7b2dd3e145560e52e06956345e6fdf91d70ca4886464f","impliedFormat":1},{"version":"15c5e91b5f08be34a78e3d976179bf5b7a9cc28dc0ef1ffebffeb3c7812a2dca","impliedFormat":1},{"version":"58832ded29e0094047596544ac391d68c799d7bd7d35936f47221857141628f1","impliedFormat":1},{"version":"553870e516f8c772b89f3820576152ebc70181d7994d96917bb943e37da7f8a7","impliedFormat":1},{"version":"37ba7b45141a45ce6e80e66f2a96c8a5ab1bcef0fc2d0f56bb58df96ec67e972","impliedFormat":1},{"version":"93452d394fdd1dc551ec62f5042366f011a00d342d36d50793b3529bfc9bd633","impliedFormat":1},{"version":"745c4240220559bd340c8aeb6e3c5270a709d3565e934dc22a69c304703956bc","affectsGlobalScope":true,"impliedFormat":1},{"version":"2754d8221d77c7b382096651925eb476f1066b3348da4b73fe71ced7801edada","impliedFormat":1},{"version":"9212c6e9d80cb45441a3614e95afd7235a55a18584c2ed32d6c1aca5a0c53d93","affectsGlobalScope":true,"impliedFormat":1},{"version":"bef91efa0baea5d0e0f0f27b574a8bc100ce62a6d7e70220a0d58af6acab5e89","affectsGlobalScope":true,"impliedFormat":1},{"version":"282fd2a1268a25345b830497b4b7bf5037a5e04f6a9c44c840cb605e19fea841","impliedFormat":1},{"version":"5360a27d3ebca11b224d7d3e38e3e2c63f8290cb1fcf6c3610401898f8e68bc3","impliedFormat":1},{"version":"66ba1b2c3e3a3644a1011cd530fb444a96b1b2dfe2f5e837a002d41a1a799e60","impliedFormat":1},{"version":"7e514f5b852fdbc166b539fdd1f4e9114f29911592a5eb10a94bb3a13ccac3c4","impliedFormat":1},{"version":"7d6ff413e198d25639f9f01f16673e7df4e4bd2875a42455afd4ecc02ef156da","affectsGlobalScope":true,"impliedFormat":1},{"version":"6bd91a2a356600dee28eb0438082d0799a18a974a6537c4410a796bab749813c","affectsGlobalScope":true,"impliedFormat":1},{"version":"f689c4237b70ae6be5f0e4180e8833f34ace40529d1acc0676ab8fb8f70457d7","impliedFormat":1},{"version":"ae25afbbf1ed5df63a177d67b9048bf7481067f1b8dc9c39212e59db94fc9fc6","impliedFormat":1},{"version":"ac5ed35e649cdd8143131964336ab9076937fa91802ec760b3ea63b59175c10a","impliedFormat":1},{"version":"52a8e7e8a1454b6d1b5ad428efae3870ffc56f2c02d923467f2940c454aa9aec","affectsGlobalScope":true,"impliedFormat":1},{"version":"78dc0513cc4f1642906b74dda42146bcbd9df7401717d6e89ea6d72d12ecb539","impliedFormat":1},{"version":"ad90122e1cb599b3bc06a11710eb5489101be678f2920f2322b0ac3e195af78d","impliedFormat":1},{"version":"eb15edfcef078300657e1d5d678e1944b3518c2dd8f26792fdba2fe29f73d32b","impliedFormat":1},{"version":"720f5d028d71bc22ed4a5311a6ea884329db475d994f805ea86470111eccc1a1","impliedFormat":1},{"version":"d6c2c4fb5bba7591d69bf2c48e969fe41806f4c68b18748500f142094265ff44","affectsGlobalScope":true,"impliedFormat":1},{"version":"4b8184ed151703851c149ce9302e3654a5c6f403c19091cace8ffb65ae90698c","affectsGlobalScope":true,"impliedFormat":1},{"version":"3de9f829f53966384023e023185c0515d18b747f0001924a1919751e6ac5308d","affectsGlobalScope":true,"impliedFormat":1},{"version":"3928f2b2cba6532b58af2723fd61d605d78ce4ef7ee1fc6e5cb186d5677ba39a","impliedFormat":1},{"version":"6f309df87d1f1867976bca71fe2531b500851610c455255b70e29fad542795ec","affectsGlobalScope":true,"impliedFormat":1},{"version":"3995f3ebce77233680db109fae9d2d896eb660533af1ebc7e8aeda63d13fb924","affectsGlobalScope":true,"impliedFormat":1},{"version":"86e6299a65515b986e2989ec15a7ff0ce8562736037336fed47739ce599270dc","impliedFormat":1},{"version":"ad9f6d45cd99038489cb54ec5922add2486ec8b0a888e9d6387e4f2eae73cddc","impliedFormat":1},{"version":"d2e66d9477edaa0e4dea79d699f0855a5a7419915da740e28fbfdb322c6a60a6","affectsGlobalScope":true,"impliedFormat":1},{"version":"ca69bbf884a17e7a485bb4fcd129386874050916b275e414af14b2170b4ea728","affectsGlobalScope":true,"impliedFormat":1},{"version":"2450773bc38bd11f0630b85fa4121ecb628f222ed5569d6676864c08f27fb631","impliedFormat":1},{"version":"ef93250912eb74949caaeb3bd4fa7d4a191b5b8dde20b0f32c12efd5f5c13c28","impliedFormat":1},{"version":"37be812b06e518320ba82e2aff3ac2ca37370a9df917db708f081b9043fa3315","impliedFormat":1}],"root":[79,[82,88]],"options":{"allowJs":true,"declaration":true,"esModuleInterop":true,"jsx":1,"module":1,"outDir":"./","skipLibCheck":true,"strict":true,"target":2},"referencedMap":[[77,1],[78,1],[13,1],[14,1],[16,1],[15,1],[2,1],[17,1],[18,1],[19,1],[20,1],[21,1],[22,1],[23,1],[24,1],[3,1],[25,1],[26,1],[4,1],[27,1],[31,1],[28,1],[29,1],[30,1],[32,1],[33,1],[34,1],[5,1],[35,1],[36,1],[37,1],[38,1],[6,1],[42,1],[39,1],[40,1],[41,1],[43,1],[7,1],[44,1],[49,1],[50,1],[45,1],[46,1],[47,1],[48,1],[8,1],[54,1],[51,1],[52,1],[53,1],[55,1],[9,1],[56,1],[57,1],[58,1],[60,1],[59,1],[61,1],[62,1],[10,1],[63,1],[64,1],[65,1],[11,1],[66,1],[67,1],[68,1],[69,1],[70,1],[1,1],[71,1],[72,1],[12,1],[75,1],[74,1],[73,1],[76,1],[87,2],[201,3],[133,4],[134,4],[135,5],[94,6],[136,7],[137,8],[138,9],[89,1],[92,10],[90,1],[91,1],[139,11],[140,12],[141,13],[142,14],[143,15],[144,16],[145,16],[147,17],[146,18],[148,19],[149,20],[150,21],[132,22],[93,1],[151,23],[152,24],[153,25],[186,26],[154,27],[155,28],[156,29],[157,30],[158,31],[159,32],[160,33],[161,34],[162,35],[163,36],[164,36],[165,37],[166,1],[167,1],[168,38],[170,39],[169,40],[171,41],[172,42],[173,43],[174,44],[175,45],[176,46],[177,47],[178,48],[179,49],[180,50],[181,51],[182,52],[183,53],[184,54],[185,55],[187,56],[199,1],[190,57],[198,58],[188,59],[192,1],[189,60],[194,1],[200,61],[195,1],[191,62],[196,1],[193,63],[197,1],[81,64],[80,65],[110,66],[120,67],[109,66],[130,68],[101,69],[100,70],[129,71],[123,72],[128,73],[103,74],[117,75],[102,76],[126,77],[98,78],[97,71],[127,79],[99,80],[104,81],[105,1],[108,81],[95,1],[131,82],[121,83],[112,84],[113,85],[115,86],[111,87],[114,88],[124,71],[106,89],[107,90],[116,91],[96,92],[119,83],[118,81],[122,1],[125,93],[86,1],[79,1],[84,94],[82,95],[83,95],[85,96],[88,1]],"version":"5.7.3"} \ No newline at end of file diff --git a/dist/types.d.ts b/dist/types.d.ts new file mode 100644 index 0000000..d68acbd --- /dev/null +++ b/dist/types.d.ts @@ -0,0 +1,13 @@ +export interface NodeCIConfig { + start: string; + preflight: string[] | string; + postflight?: string[] | string; + redeploy_path?: string; + first_run?: boolean; + port?: string | number | (string | number)[]; + build?: NodeCIBuild; +} +export interface NodeCIBuild { + paradigm: "Next.JS" | "Remix"; + out_dir?: string; +} diff --git a/dist/types.js b/dist/types.js new file mode 100644 index 0000000..c8ad2e5 --- /dev/null +++ b/dist/types.js @@ -0,0 +1,2 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/dist/utils/console-colors.d.ts b/dist/utils/console-colors.d.ts new file mode 100644 index 0000000..ab20fc1 --- /dev/null +++ b/dist/utils/console-colors.d.ts @@ -0,0 +1,28 @@ +declare const colors: { + Reset: string; + Bright: string; + Dim: string; + Underscore: string; + Blink: string; + Reverse: string; + Hidden: string; + FgBlack: string; + FgRed: string; + FgGreen: string; + FgYellow: string; + FgBlue: string; + FgMagenta: string; + FgCyan: string; + FgWhite: string; + FgGray: string; + BgBlack: string; + BgRed: string; + BgGreen: string; + BgYellow: string; + BgBlue: string; + BgMagenta: string; + BgCyan: string; + BgWhite: string; + BgGray: string; +}; +export default colors; diff --git a/utils/console-colors.js b/dist/utils/console-colors.js old mode 100755 new mode 100644 similarity index 85% rename from utils/console-colors.js rename to dist/utils/console-colors.js index 708acf6..f1d612e --- a/utils/console-colors.js +++ b/dist/utils/console-colors.js @@ -1,31 +1,30 @@ -const colors = { - Reset: "\x1b[0m", - Bright: "\x1b[1m", - Dim: "\x1b[2m", - Underscore: "\x1b[4m", - Blink: "\x1b[5m", - Reverse: "\x1b[7m", - Hidden: "\x1b[8m", - - FgBlack: "\x1b[30m", - FgRed: "\x1b[31m", - FgGreen: "\x1b[32m", - FgYellow: "\x1b[33m", - FgBlue: "\x1b[34m", - FgMagenta: "\x1b[35m", - FgCyan: "\x1b[36m", - FgWhite: "\x1b[37m", - FgGray: "\x1b[90m", - - BgBlack: "\x1b[40m", - BgRed: "\x1b[41m", - BgGreen: "\x1b[42m", - BgYellow: "\x1b[43m", - BgBlue: "\x1b[44m", - BgMagenta: "\x1b[45m", - BgCyan: "\x1b[46m", - BgWhite: "\x1b[47m", - BgGray: "\x1b[100m", -}; - -module.exports = colors; +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const colors = { + Reset: "\x1b[0m", + Bright: "\x1b[1m", + Dim: "\x1b[2m", + Underscore: "\x1b[4m", + Blink: "\x1b[5m", + Reverse: "\x1b[7m", + Hidden: "\x1b[8m", + FgBlack: "\x1b[30m", + FgRed: "\x1b[31m", + FgGreen: "\x1b[32m", + FgYellow: "\x1b[33m", + FgBlue: "\x1b[34m", + FgMagenta: "\x1b[35m", + FgCyan: "\x1b[36m", + FgWhite: "\x1b[37m", + FgGray: "\x1b[90m", + BgBlack: "\x1b[40m", + BgRed: "\x1b[41m", + BgGreen: "\x1b[42m", + BgYellow: "\x1b[43m", + BgBlue: "\x1b[44m", + BgMagenta: "\x1b[45m", + BgCyan: "\x1b[46m", + BgWhite: "\x1b[47m", + BgGray: "\x1b[100m", +}; +exports.default = colors; diff --git a/dist/utils/kill-child.d.ts b/dist/utils/kill-child.d.ts new file mode 100644 index 0000000..a4df468 --- /dev/null +++ b/dist/utils/kill-child.d.ts @@ -0,0 +1,6 @@ +/** + * ## Kill Child Process Function + * @param {string | number | (string | number)[]} [port] + * @returns {Promise} + */ +export default function killChild(port?: string | number | (string | number)[]): Promise; diff --git a/dist/utils/kill-child.js b/dist/utils/kill-child.js new file mode 100644 index 0000000..5a0226f --- /dev/null +++ b/dist/utils/kill-child.js @@ -0,0 +1,49 @@ +"use strict"; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.default = killChild; +const console_colors_1 = __importDefault(require("./console-colors")); +const kill_port_1 = __importDefault(require("kill-port")); +let childProcess = null; +const pTitle = "nodecid"; +process.title = pTitle; +/** + * ## Kill Child Process Function + * @param {string | number | (string | number)[]} [port] + * @returns {Promise} + */ +function killChild(port) { + return __awaiter(this, void 0, void 0, function* () { + if (!childProcess) + return false; + try { + const childProcessPID = childProcess.pid; + childProcess.kill(); + if (typeof port == "object" && (port === null || port === void 0 ? void 0 : port[0])) { + for (let i = 0; i < port.length; i++) { + const singlePort = port[i]; + yield (0, kill_port_1.default)(Number(singlePort)); + } + } + else if (port) { + yield (0, kill_port_1.default)(Number(port)); + } + return true; + } + catch (error) { + console.log(`${console_colors_1.default.FgRed}Error:${console_colors_1.default.Reset} Child Process couldn't be killed! ${error.message}`); + return false; + } + }); +} diff --git a/dist/utils/preflight.d.ts b/dist/utils/preflight.d.ts new file mode 100644 index 0000000..df52f01 --- /dev/null +++ b/dist/utils/preflight.d.ts @@ -0,0 +1,7 @@ +/** + * ## Preflight Function + * @param {string[] | string} preflight + * @param {boolean} [postflight] + * @returns {boolean} + */ +export default function preflightFn(preflight?: string[] | string, postflight?: boolean): boolean; diff --git a/dist/utils/preflight.js b/dist/utils/preflight.js new file mode 100644 index 0000000..72503d7 --- /dev/null +++ b/dist/utils/preflight.js @@ -0,0 +1,45 @@ +"use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.default = preflightFn; +const child_process_1 = require("child_process"); +const console_colors_1 = __importDefault(require("../utils/console-colors")); +/** + * ## Preflight Function + * @param {string[] | string} preflight + * @param {boolean} [postflight] + * @returns {boolean} + */ +function preflightFn(preflight, postflight) { + const tag = postflight ? "Postflight" : "Preflight"; + console.log(`${tag} Running ...`); + const options = { + cwd: process.cwd(), + stdio: "inherit", + }; + try { + if (typeof preflight == "string") { + (0, child_process_1.execFileSync)(preflight, options); + } + else if (typeof preflight == "object" && (preflight === null || preflight === void 0 ? void 0 : preflight[0])) { + for (let i = 0; i < preflight.length; i++) { + const cmd = preflight[i]; + try { + const execCmd = (0, child_process_1.execSync)(cmd, options); + } + catch (error) { + console.log(`${console_colors_1.default.FgRed}Error:${console_colors_1.default.Reset} ${tag} command ${cmd} Failed! => ${error.message}`); + return false; + break; + } + } + } + return true; + } + catch (error) { + console.log(`${console_colors_1.default.FgRed}Error:${console_colors_1.default.Reset} ${tag} Failed! => ${error.message}`); + return false; + } +} diff --git a/dist/utils/run.d.ts b/dist/utils/run.d.ts new file mode 100644 index 0000000..949069b --- /dev/null +++ b/dist/utils/run.d.ts @@ -0,0 +1,7 @@ +import { ChildProcess } from "child_process"; +/** + * ## Preflight Function + * @param {string} command + * @returns {ChildProcess | null} + */ +export default function run(command: string): ChildProcess | null; diff --git a/dist/utils/run.js b/dist/utils/run.js new file mode 100644 index 0000000..b0c1257 --- /dev/null +++ b/dist/utils/run.js @@ -0,0 +1,39 @@ +"use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.default = run; +const child_process_1 = require("child_process"); +const console_colors_1 = __importDefault(require("./console-colors")); +let redeployments = 0; +const KILL_SIGNAL = "SIGTERM"; +const pTitle = "nodecid"; +process.title = pTitle; +/** + * ## Preflight Function + * @param {string} command + * @returns {ChildProcess | null} + */ +function run(command) { + console.log("\n******************************"); + console.log(`****** ${console_colors_1.default.FgGreen}Starting App ...${console_colors_1.default.Reset} ******`); + console.log("******************************\n"); + const startCommandArray = command.split(" ").filter((str) => str.trim()); + try { + const firstCommand = startCommandArray.shift(); + if (!firstCommand) { + throw new Error("No Starting Command Found in command string!"); + } + let childProcess = (0, child_process_1.spawn)(firstCommand, startCommandArray, { + stdio: "inherit", + killSignal: KILL_SIGNAL, + }); + redeployments++; + return childProcess; + } + catch (error) { + console.log(`${console_colors_1.default.FgRed}Error:${console_colors_1.default.Reset} running start command => ${error.message}`); + return null; + } +} diff --git a/dist/utils/start.d.ts b/dist/utils/start.d.ts new file mode 100644 index 0000000..401b10b --- /dev/null +++ b/dist/utils/start.d.ts @@ -0,0 +1,18 @@ +/** + * # Start the process + * @param {object} param0 + * @param {string} param0.command + * @param {string[] | string} param0.preflight + * @param {string[] | string} [param0.postflight] + * @param {string} param0.redeploy_file + * @param {string | number | (string | number)[]} [param0.port] - The port to kill on rebuild + * @param {boolean} [param0.first_run] - Whether to run the preflight on first run. Default `false` + */ +export default function startProcess({ command, preflight, postflight, redeploy_file, port, first_run, }: { + command: string; + preflight: string[] | string; + postflight?: string[] | string; + redeploy_file: string; + port?: string | number | (string | number)[]; + first_run?: boolean; +}): void; diff --git a/dist/utils/start.js b/dist/utils/start.js new file mode 100644 index 0000000..aa1b962 --- /dev/null +++ b/dist/utils/start.js @@ -0,0 +1,84 @@ +"use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.default = startProcess; +const fs_1 = __importDefault(require("fs")); +const console_colors_1 = __importDefault(require("./console-colors")); +const preflight_1 = __importDefault(require("./preflight")); +const run_1 = __importDefault(require("./run")); +const kill_child_1 = __importDefault(require("./kill-child")); +let redeployments = 0; +let childProcess = null; +const pTitle = "nodecid"; +process.title = pTitle; +/** + * # Start the process + * @param {object} param0 + * @param {string} param0.command + * @param {string[] | string} param0.preflight + * @param {string[] | string} [param0.postflight] + * @param {string} param0.redeploy_file + * @param {string | number | (string | number)[]} [param0.port] - The port to kill on rebuild + * @param {boolean} [param0.first_run] - Whether to run the preflight on first run. Default `false` + */ +function startProcess({ command, preflight, postflight, redeploy_file, port, first_run, }) { + try { + if (first_run) { + console.log("First Run ..."); + const runPreflight = (0, preflight_1.default)(preflight); + } + if (!preflight) { + console.log(`${console_colors_1.default.FgRed}Error:${console_colors_1.default.Reset} No preflight included in config file. If you don't want to run any preflight command simply add an empty array.`); + process.exit(); + } + childProcess = (0, run_1.default)(command); + if (!childProcess) { + console.log(`${console_colors_1.default.FgRed}Error:${console_colors_1.default.Reset} Process couldn't start. Exiting...`); + process.exit(); + } + console.log("Watching", redeploy_file); + fs_1.default.watchFile(redeploy_file, { interval: 100 }, (curr, prev) => { + console.log(`${console_colors_1.default.BgBlue}File Changed${console_colors_1.default.Reset}`); + if (redeployments == 0) + return; + if (childProcess) { + console.log("******************************"); + console.log(`******** ${console_colors_1.default.FgBlue}Rebuilding ${console_colors_1.default.FgMagenta}${redeployments}${console_colors_1.default.Reset} ********`); + console.log("******************************"); + try { + const runPreflight = (0, preflight_1.default)(preflight); + if (!runPreflight) { + // TODO: Action to take if preflight fails + console.log(`${console_colors_1.default.FgRed}Error:${console_colors_1.default.Reset} Preflight Failed.`); + } + else { + (0, kill_child_1.default)(port).then((kill) => { + if (kill) { + childProcess = (0, run_1.default)(command); + if (postflight) { + const runPostflight = (0, preflight_1.default)(postflight, true); + if (!runPostflight) { + // TODO: Action to take if postflight fails + console.log(`${console_colors_1.default.FgRed}Error:${console_colors_1.default.Reset} Postflight Failed.`); + } + } + } + else { + process.exit(); + } + }); + } + } + catch (error) { + console.log(`${console_colors_1.default.FgRed}Error:${console_colors_1.default.Reset} killing child processes => ${error.message}`); + process.exit(); + } + } + }); + } + catch (error) { + console.log(`${console_colors_1.default.FgRed}Error:${console_colors_1.default.Reset} First run failed! => ${error.message}`); + } +} diff --git a/dist/utils/triggers/github.d.ts b/dist/utils/triggers/github.d.ts new file mode 100644 index 0000000..dc6a1c1 --- /dev/null +++ b/dist/utils/triggers/github.d.ts @@ -0,0 +1 @@ +declare function githubWebhook(): boolean; diff --git a/dist/utils/triggers/github.js b/dist/utils/triggers/github.js new file mode 100644 index 0000000..0c4edfe --- /dev/null +++ b/dist/utils/triggers/github.js @@ -0,0 +1,4 @@ +"use strict"; +function githubWebhook() { + return true; +} diff --git a/index.js b/index.ts similarity index 68% rename from index.js rename to index.ts index 97830ef..4ed56f5 100755 --- a/index.js +++ b/index.ts @@ -1,21 +1,11 @@ -#! /usr/bin/env node -// @ts-check - -const fs = require("fs"); -const path = require("path"); -const colors = require("./utils/console-colors"); -const startProcess = require("./deploy/start"); - -/////////////////////////////////////////////// -/////////////////////////////////////////////// -/////////////////////////////////////////////// +import fs from "fs"; +import path from "path"; +import colors from "./utils/console-colors"; +import startProcess from "./utils/start"; +import type { NodeCIConfig } from "./types"; const WORK_DIR = process.cwd(); -/////////////////////////////////////////////// -/////////////////////////////////////////////// -/////////////////////////////////////////////// - function run() { try { const configText = fs.readFileSync( @@ -23,8 +13,7 @@ function run() { "utf-8" ); - /** @type {NodeCIConfig} */ - const config = JSON.parse(configText); + const config: NodeCIConfig = JSON.parse(configText); const { start, @@ -66,7 +55,7 @@ function run() { port, postflight, }); - } catch (error) { + } catch (error: any) { console.log( `${colors.FgRed}ERROR:${colors.Reset} CI process failed! => ${error.message}` ); @@ -75,10 +64,6 @@ function run() { run(); -//////////////////////////////////////////// -//////////////////////////////////////////// -//////////////////////////////////////////// - process.on("exit", () => { console.log("Process exiting ..."); }); diff --git a/jsconfig.json b/jsconfig.json new file mode 100644 index 0000000..238655f --- /dev/null +++ b/jsconfig.json @@ -0,0 +1,27 @@ +{ + "compilerOptions": { + // Enable latest features + "lib": ["ESNext", "DOM"], + "target": "ESNext", + "module": "ESNext", + "moduleDetection": "force", + "jsx": "react-jsx", + "allowJs": true, + + // Bundler mode + "moduleResolution": "bundler", + "allowImportingTsExtensions": true, + "verbatimModuleSyntax": true, + "noEmit": true, + + // Best practices + "strict": true, + "skipLibCheck": true, + "noFallthroughCasesInSwitch": true, + + // Some stricter flags (disabled by default) + "noUnusedLocals": false, + "noUnusedParameters": false, + "noPropertyAccessFromIndexSignature": false + } +} diff --git a/package-lock.json b/package-lock.json deleted file mode 100644 index 45ac17d..0000000 --- a/package-lock.json +++ /dev/null @@ -1,42 +0,0 @@ -{ - "name": "nodecid", - "version": "1.0.5", - "lockfileVersion": 3, - "requires": true, - "packages": { - "": { - "name": "nodecid", - "version": "1.0.5", - "license": "MIT", - "dependencies": { - "kill-port": "^2.0.1" - }, - "bin": { - "node-ci-cd": "index.js", - "nodecid": "index.js" - } - }, - "node_modules/get-them-args": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/get-them-args/-/get-them-args-1.3.2.tgz", - "integrity": "sha512-LRn8Jlk+DwZE4GTlDbT3Hikd1wSHgLMme/+7ddlqKd7ldwR6LjJgTVWzBnR01wnYGe4KgrXjg287RaI22UHmAw==" - }, - "node_modules/kill-port": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/kill-port/-/kill-port-2.0.1.tgz", - "integrity": "sha512-e0SVOV5jFo0mx8r7bS29maVWp17qGqLBZ5ricNSajON6//kmb7qqqNnml4twNE8Dtj97UQD+gNFOaipS/q1zzQ==", - "dependencies": { - "get-them-args": "1.3.2", - "shell-exec": "1.0.2" - }, - "bin": { - "kill-port": "cli.js" - } - }, - "node_modules/shell-exec": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/shell-exec/-/shell-exec-1.0.2.tgz", - "integrity": "sha512-jyVd+kU2X+mWKMmGhx4fpWbPsjvD53k9ivqetutVW/BQ+WIZoDoP4d8vUMGezV6saZsiNoW2f9GIhg9Dondohg==" - } - } -} diff --git a/package.json b/package.json index 3b9acdb..260d4de 100644 --- a/package.json +++ b/package.json @@ -1,11 +1,14 @@ { - "name": "nodecid", + "name": "@moduletrace/nodecid", "version": "1.0.7", "description": "Simple CI/CD process", - "main": "index.js", + "main": "dist/index.js", "bin": { - "nodecid": "./index.js", - "node-ci-cd": "./index.js" + "nodecid": "./dist/index.js", + "node-ci-cd": "./dist/index.js" + }, + "scripts": { + "compile": "bun build --compile --minify --sourcemap --bytecode index.ts --outfile bin/nodecid" }, "keywords": [ "CI/CD", @@ -16,5 +19,12 @@ "license": "MIT", "dependencies": { "kill-port": "^2.0.1" + }, + "devDependencies": { + "@types/bun": "latest", + "@types/node": "^22.10.7" + }, + "peerDependencies": { + "typescript": "^5.0.0" } } diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..c4baee1 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,21 @@ +{ + "compilerOptions": { + "target": "ES2015", + "module": "commonjs", + "maxNodeModuleJsDepth": 10, + "esModuleInterop": true, + "forceConsistentCasingInFileNames": true, + "strict": true, + "skipLibCheck": true, + "lib": ["dom", "dom.iterable", "esnext"], + "allowJs": true, + "incremental": true, + "resolveJsonModule": true, + "jsx": "preserve", + "moduleResolution": "node", + "declaration": true, + "outDir": "dist" + }, + "include": ["**/*.ts"], + "exclude": ["node_modules", "dist"] +} diff --git a/types.d.js b/types.d.js deleted file mode 100644 index 62494a4..0000000 --- a/types.d.js +++ /dev/null @@ -1,19 +0,0 @@ -/** - * @typedef {object} NodeCIConfig - * @property {string} start - Start command. Eg `node index.js` - * @property {string[] | string} preflight - And array of commands to run before - * the application starts, or a single `.sh` file path. - * @property {string[] | string} [postflight] - And array of commands to run after - * the application starts. - * @property {string} [redeploy_path] - The path to the file that will trigger a - * redeployment if content is changed. Default file path is `./REDEPLOY` - * @property {boolean} [first_run] - Whether to run the preflight on first run. Default `false` - * @property {string | number | (string | number)[]} [port] - The port to kill on reload - * @property {NodeCIBuild} [build] - Build configurations - */ - -/** - * @typedef {object} NodeCIBuild - * @property {"Next.JS" | "Remix"} paradigm - The paradigm to build on - * @property {string} [out_dir] - The output Directory. Default `.dist`. - */ diff --git a/types.ts b/types.ts new file mode 100644 index 0000000..a417166 --- /dev/null +++ b/types.ts @@ -0,0 +1,14 @@ +export interface NodeCIConfig { + start: string; + preflight: string[] | string; + postflight?: string[] | string; + redeploy_path?: string; + first_run?: boolean; + port?: string | number | (string | number)[]; + build?: NodeCIBuild; +} + +export interface NodeCIBuild { + paradigm: "Next.JS" | "Remix"; + out_dir?: string; +} diff --git a/utils/console-colors.ts b/utils/console-colors.ts new file mode 100755 index 0000000..4d0e6a6 --- /dev/null +++ b/utils/console-colors.ts @@ -0,0 +1,31 @@ +const colors = { + Reset: "\x1b[0m", + Bright: "\x1b[1m", + Dim: "\x1b[2m", + Underscore: "\x1b[4m", + Blink: "\x1b[5m", + Reverse: "\x1b[7m", + Hidden: "\x1b[8m", + + FgBlack: "\x1b[30m", + FgRed: "\x1b[31m", + FgGreen: "\x1b[32m", + FgYellow: "\x1b[33m", + FgBlue: "\x1b[34m", + FgMagenta: "\x1b[35m", + FgCyan: "\x1b[36m", + FgWhite: "\x1b[37m", + FgGray: "\x1b[90m", + + BgBlack: "\x1b[40m", + BgRed: "\x1b[41m", + BgGreen: "\x1b[42m", + BgYellow: "\x1b[43m", + BgBlue: "\x1b[44m", + BgMagenta: "\x1b[45m", + BgCyan: "\x1b[46m", + BgWhite: "\x1b[47m", + BgGray: "\x1b[100m", +}; + +export default colors; diff --git a/utils/kill-child.ts b/utils/kill-child.ts new file mode 100755 index 0000000..bf367a2 --- /dev/null +++ b/utils/kill-child.ts @@ -0,0 +1,40 @@ +import { ChildProcess } from "child_process"; +import colors from "./console-colors"; +import kill from "kill-port"; + +let childProcess: ChildProcess | null = null; + +const pTitle = "nodecid"; +process.title = pTitle; + +/** + * ## Kill Child Process Function + * @param {string | number | (string | number)[]} [port] + * @returns {Promise} + */ +export default async function killChild( + port?: string | number | (string | number)[] +): Promise { + if (!childProcess) return false; + + try { + const childProcessPID = childProcess.pid; + childProcess.kill(); + + if (typeof port == "object" && port?.[0]) { + for (let i = 0; i < port.length; i++) { + const singlePort = port[i]; + await kill(Number(singlePort)); + } + } else if (port) { + await kill(Number(port)); + } + + return true; + } catch (error: any) { + console.log( + `${colors.FgRed}Error:${colors.Reset} Child Process couldn't be killed! ${error.message}` + ); + return false; + } +} diff --git a/utils/preflight.ts b/utils/preflight.ts new file mode 100755 index 0000000..772a5ce --- /dev/null +++ b/utils/preflight.ts @@ -0,0 +1,46 @@ +import { execSync, execFileSync, type ExecSyncOptions } from "child_process"; +import colors from "../utils/console-colors"; + +/** + * ## Preflight Function + * @param {string[] | string} preflight + * @param {boolean} [postflight] + * @returns {boolean} + */ +export default function preflightFn( + preflight?: string[] | string, + postflight?: boolean +): boolean { + const tag = postflight ? "Postflight" : "Preflight"; + console.log(`${tag} Running ...`); + + const options: ExecSyncOptions = { + cwd: process.cwd(), + stdio: "inherit", + }; + + try { + if (typeof preflight == "string") { + execFileSync(preflight, options); + } else if (typeof preflight == "object" && preflight?.[0]) { + for (let i = 0; i < preflight.length; i++) { + const cmd = preflight[i]; + try { + const execCmd = execSync(cmd, options); + } catch (error: any) { + console.log( + `${colors.FgRed}Error:${colors.Reset} ${tag} command ${cmd} Failed! => ${error.message}` + ); + return false; + break; + } + } + } + return true; + } catch (error: any) { + console.log( + `${colors.FgRed}Error:${colors.Reset} ${tag} Failed! => ${error.message}` + ); + return false; + } +} diff --git a/utils/run.ts b/utils/run.ts new file mode 100755 index 0000000..0674f70 --- /dev/null +++ b/utils/run.ts @@ -0,0 +1,46 @@ +import { spawn, ChildProcess } from "child_process"; +import colors from "./console-colors"; + +let redeployments = 0; + +const KILL_SIGNAL: NodeJS.Signals | number = "SIGTERM"; + +const pTitle = "nodecid"; +process.title = pTitle; + +/** + * ## Preflight Function + * @param {string} command + * @returns {ChildProcess | null} + */ +export default function run(command: string): ChildProcess | null { + console.log("\n******************************"); + console.log( + `****** ${colors.FgGreen}Starting App ...${colors.Reset} ******` + ); + console.log("******************************\n"); + + const startCommandArray = command.split(" ").filter((str) => str.trim()); + + try { + const firstCommand = startCommandArray.shift(); + + if (!firstCommand) { + throw new Error("No Starting Command Found in command string!"); + } + + let childProcess = spawn(firstCommand, startCommandArray, { + stdio: "inherit", + killSignal: KILL_SIGNAL, + }); + + redeployments++; + + return childProcess; + } catch (error: any) { + console.log( + `${colors.FgRed}Error:${colors.Reset} running start command => ${error.message}` + ); + return null; + } +} diff --git a/utils/start.ts b/utils/start.ts new file mode 100755 index 0000000..3d5f01a --- /dev/null +++ b/utils/start.ts @@ -0,0 +1,123 @@ +import fs from "fs"; +import { ChildProcess } from "child_process"; +import colors from "./console-colors"; +import kill from "kill-port"; +import preflightFn from "./preflight"; +import run from "./run"; +import killChild from "./kill-child"; + +let redeployments = 0; + +let childProcess: ChildProcess | null = null; + +const pTitle = "nodecid"; +process.title = pTitle; + +/** + * # Start the process + * @param {object} param0 + * @param {string} param0.command + * @param {string[] | string} param0.preflight + * @param {string[] | string} [param0.postflight] + * @param {string} param0.redeploy_file + * @param {string | number | (string | number)[]} [param0.port] - The port to kill on rebuild + * @param {boolean} [param0.first_run] - Whether to run the preflight on first run. Default `false` + */ +export default function startProcess({ + command, + preflight, + postflight, + redeploy_file, + port, + first_run, +}: { + command: string; + preflight: string[] | string; + postflight?: string[] | string; + redeploy_file: string; + port?: string | number | (string | number)[]; + first_run?: boolean; +}) { + try { + if (first_run) { + console.log("First Run ..."); + const runPreflight = preflightFn(preflight); + } + + if (!preflight) { + console.log( + `${colors.FgRed}Error:${colors.Reset} No preflight included in config file. If you don't want to run any preflight command simply add an empty array.` + ); + process.exit(); + } + + childProcess = run(command); + + if (!childProcess) { + console.log( + `${colors.FgRed}Error:${colors.Reset} Process couldn't start. Exiting...` + ); + process.exit(); + } + + console.log("Watching", redeploy_file); + + fs.watchFile(redeploy_file, { interval: 100 }, (curr, prev) => { + console.log(`${colors.BgBlue}File Changed${colors.Reset}`); + + if (redeployments == 0) return; + + if (childProcess) { + console.log("******************************"); + console.log( + `******** ${colors.FgBlue}Rebuilding ${colors.FgMagenta}${redeployments}${colors.Reset} ********` + ); + console.log("******************************"); + + try { + const runPreflight = preflightFn(preflight); + + if (!runPreflight) { + // TODO: Action to take if preflight fails + + console.log( + `${colors.FgRed}Error:${colors.Reset} Preflight Failed.` + ); + } else { + killChild(port).then((kill) => { + if (kill) { + childProcess = run(command); + + if (postflight) { + const runPostflight = preflightFn( + postflight, + true + ); + + if (!runPostflight) { + // TODO: Action to take if postflight fails + + console.log( + `${colors.FgRed}Error:${colors.Reset} Postflight Failed.` + ); + } + } + } else { + process.exit(); + } + }); + } + } catch (error: any) { + console.log( + `${colors.FgRed}Error:${colors.Reset} killing child processes => ${error.message}` + ); + process.exit(); + } + } + }); + } catch (error: any) { + console.log( + `${colors.FgRed}Error:${colors.Reset} First run failed! => ${error.message}` + ); + } +} diff --git a/utils/triggers/github.js b/utils/triggers/github.ts similarity index 100% rename from utils/triggers/github.js rename to utils/triggers/github.ts