From ba2cd9d765efa058d287d3863bbdd93989c54963 Mon Sep 17 00:00:00 2001 From: Benjamin Toby Date: Thu, 16 Jan 2025 07:18:29 +0100 Subject: [PATCH] Updates --- .gitignore | 1 + bun.lockb | Bin 0 -> 3970 bytes console-colors.ts | 31 +++ dist/console-colors.d.ts | 28 ++ console-colors.js => dist/console-colors.js | 61 +++-- dist/index.d.ts | 1 + dist/index.js | 276 ++++++++++++++++++++ index.js => index.ts | 50 ++-- package-lock.json | 37 --- package.json | 17 +- publish.sh | 14 + push.sh | 11 + tsconfig.json | 21 ++ 13 files changed, 443 insertions(+), 105 deletions(-) create mode 100755 bun.lockb create mode 100644 console-colors.ts create mode 100644 dist/console-colors.d.ts rename console-colors.js => dist/console-colors.js (85%) create mode 100644 dist/index.d.ts create mode 100644 dist/index.js rename index.js => index.ts (87%) delete mode 100644 package-lock.json create mode 100755 publish.sh create mode 100755 push.sh create mode 100644 tsconfig.json diff --git a/.gitignore b/.gitignore index 4e8b4f1..f53ba98 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ node_modules /test +tsconfig.tsbuildinfo diff --git a/bun.lockb b/bun.lockb new file mode 100755 index 0000000000000000000000000000000000000000..6e3b6b6cb4a2f6926f066a94008fcf54e749bf8d GIT binary patch literal 3970 zcmeHKYfuwc6yAg=7!@fG$D(4uimi~{BqRYP4bW<jTtD~=-yKB|I`QK9!PdvQf8OzRJS^vv9xz1j19 z_uO;Ny*U}{Nn|iIkw94p(vm4l$goJkkejW>R1;+;wu=Zky_}%-b zyW7_vv2C4td}QSHF%4DozkGL`Z~N^CedWe`j=%`Wpl*dZ^wN3!oJ0oP+zrF>g22;Y zpbLN=0<;EbDbNE&9NSCpL;3H0c)NMxGv)95elfn3m|N_9;KPZ7th!^Z5t|R682CYT zm?FP@(aog#RnBc*z28^Vm1S>FIZJIHm*?xVoJ;_;|4Cq!poD@k5%@nGXs{2=9*q77 z!mk0wA#nddyY>gj+aUaDFxLV++z%X1{QJHX!Vd$WKmi`cxj%yNkpMpl;GypzpBP^l zeNrHNF~Ela`~ZM(2LtN<2*RHNcs0Po3WV69{Q(0Tgm(lFI(~haJG*}3p&7J=1Gs=m zz<>fZoI_vW8justg(n2gg$Lu!@N^FAgv4)B0G|l!<`q&)V#7nL7f&f{`{e5#i{eA) z4$YoUolE~-Tamt+b#5K(wSLkZlQ{HY$Ajppsk%SMs)^+vXL@Klnofk3t6NrF+2tN_ zg7Ozc>MHGHYp>3@(UK!M<5gGNTI8L(MelujOrT@ng{HL3w9)HRAN}l;Gg9)7O};6r z?at)zcC*yUR$Wpe;6>*I`YgF$;1=p98P&Bs#O2NX8FQd=h-Ew7BP)?gV7x1EdA&p}3wrJ=V8voWOu+9JF zZHPc6f2&{RwN%H@Mx3%Rtif!?QLlwZ(IlytsT4AX$|0>LUzu8FFjGkus|j`x7}nX< zE$|thUzlH1zi1BcP4tX@W1PC-n1a_*U51}Z57_@<9morLAUC`(;T;4yA>RU?V_84B z;JHP=g@_aKAWpc}k33g7XaJ!|b@No(xQqZ03vG{&$`@mS`aaaRIf>#mxB^#T80s8R z=jR|c8(5NIF%0#Xs0VZq#j8|!0Pc?!fK_4FiMmFyXo(hAK|0ibqW)1VQsPQn?FTwM z;5x`>9_k51zudVPs2{Nn(>8+NHecYAdDA(mlC8h8}fAj_X+ z3VS35Nr#bL7N9vP%5v=7!SAA#ZwNsxf;=n#Da}}Lnl&-QOtQ4WND|07PRoIpi4?;U zlqHeO!c!PF+eR`*nzFIM+#>=0$nZ}VYa*G-B;8r?`5Lgj% z0vgLfVJH>2Kh7rQz-5e-oa1~AiO>wN2&eMyVuEC^A$aaJfWtpwu+o%Th=Q}e*6*?5 z(VRWUq4t9uJpDqZZx>($dIG^!u2S8H^TO@+-aS|1nm!16+ym%^jGQ}4oZsCQ)?HPv Zah=;PmwiC+d?MF?Byv1l*}jDze*-br>c0R0 literal 0 HcmV?d00001 diff --git a/console-colors.ts b/console-colors.ts new file mode 100644 index 0000000..4d0e6a6 --- /dev/null +++ b/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/dist/console-colors.d.ts b/dist/console-colors.d.ts new file mode 100644 index 0000000..ab20fc1 --- /dev/null +++ b/dist/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/console-colors.js b/dist/console-colors.js similarity index 85% rename from console-colors.js rename to dist/console-colors.js index 708acf6..f1d612e 100644 --- a/console-colors.js +++ b/dist/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/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..3224195 --- /dev/null +++ b/dist/index.js @@ -0,0 +1,276 @@ +"use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +var _a; +Object.defineProperty(exports, "__esModule", { value: true }); +const fs_1 = __importDefault(require("fs")); +const path_1 = __importDefault(require("path")); +const child_process_1 = require("child_process"); +const readline_1 = __importDefault(require("readline")); +const console_colors_1 = __importDefault(require("./console-colors")); +setInterval(() => { + console.log(`Batchrun Running for ${process.uptime().toLocaleString()}s ...`); +}, 60000); +if ((_a = process.argv[process.argv.length - 1]) === null || _a === void 0 ? void 0 : _a.match(/^--version$|^-v$/)) { + console.log(`Batchrun v${require("./package.json").version}`); + process.exit(); +} +const processesStrings = []; +let processes = []; +const isWindows = process.platform.match(/win/i); +const isMac = process.platform.match(/darwin/i); +const isLinux = process.platform.match(/linux/i); +//////////////////////////////////////////// +//////////////////////////////////////////// +//////////////////////////////////////////// +const rl = readline_1.default.createInterface({ + input: process.stdin, + output: process.stdout, +}); +rl.on("line", (input) => { + readCommands(input); +}); +/** + * Read Lines and execute commands + * @param {string} input + * @returns + */ +function readCommands(input) { + if (input === null || input === void 0 ? void 0 : input.match(/^(reload|restart|reboot|r)$/i)) { + console.log(` - ${console_colors_1.default.FgBlue}Reloading processes ...${console_colors_1.default.Reset}`); + restartAll(); + } + else if (input === null || input === void 0 ? void 0 : input.match(/^(reload|restart|reboot|r) \d/i)) { + const processedIndexesString = input.split(" ")[1]; + const processedIndexes = processedIndexesString + ? processedIndexesString.split(",") + : null; + if (!(processedIndexes === null || processedIndexes === void 0 ? void 0 : processedIndexes.length)) { + console.log(` - ${console_colors_1.default.FgRed}Error:${console_colors_1.default.Reset} No processes to reload`); + return; + } + else { + console.log(` - ${console_colors_1.default.FgBlue}Reloading processes ${processedIndexesString} ...${console_colors_1.default.Reset}`); + processedIndexes.forEach((index) => { + restartOne(parseInt(index)); + }); + console.log(` - ${console_colors_1.default.FgGreen}Processes Restarted Successfully ${processedIndexesString} ...${console_colors_1.default.Reset}`); + } + } + if (input === null || input === void 0 ? void 0 : input.match(/^kill$/i)) { + console.log(` - ${console_colors_1.default.FgYellow}Killing processes ...${console_colors_1.default.Reset}`); + process.exit(); + } + else if (input === null || input === void 0 ? void 0 : input.match(/^kill \d/i)) { + const processedIndexesString = input.split(" ")[1]; + const processedIndexes = processedIndexesString + ? processedIndexesString.split(",") + : null; + if (!(processedIndexes === null || processedIndexes === void 0 ? void 0 : processedIndexes.length)) { + console.log(` - ${console_colors_1.default.FgRed}Error:${console_colors_1.default.Reset} No processes to reload`); + return; + } + else { + console.log(` - ${console_colors_1.default.FgYellow}Killing processes ${processedIndexesString} ...${console_colors_1.default.Reset}`); + processedIndexes.forEach((index) => { + killOne(index); + }); + console.log(` - ${console_colors_1.default.FgGreen}Processes Killed ${processedIndexesString} ...${console_colors_1.default.Reset}`); + } + } +} +process.stdin.on("keypress", (character, key) => { + if (key.ctrl && key.name === "r") { + console.log(` - ${console_colors_1.default.FgBlue}Reloading processes ...${console_colors_1.default.Reset}`); + restartAll(); + } +}); +/** + * Cleanup function to kill all child processes + */ +function cleanupChildProcesses() { + for (const childProcess of processes) { + try { + if (childProcess.pid) { + console.log(` - ${console_colors_1.default.FgYellow}Killing process PID: ${childProcess.pid}${console_colors_1.default.Reset}`); + killProcessForce(childProcess.pid); + } + childProcess.kill(); + } + catch (error) { + console.error(` - ${console_colors_1.default.FgRed}Error:${console_colors_1.default.Reset} Failed to kill process PID: ${childProcess.pid}`); + } + } + processes = []; +} +process.on("exit", (code) => { + console.log(` - ${console_colors_1.default.FgBlue}Process exited with code ${code}${console_colors_1.default.Reset}`); + rl.close(); + cleanupChildProcesses(); +}); +process.on("SIGINT", () => { + console.log(` - ${console_colors_1.default.FgYellow}SIGINT received, exiting...${console_colors_1.default.Reset}`); + process.exit(); +}); +process.on("SIGTERM", () => { + console.log(` - ${console_colors_1.default.FgYellow}SIGTERM received, exiting...${console_colors_1.default.Reset}`); + process.exit(); +}); +//////////////////////////////////////////// +//////////////////////////////////////////// +//////////////////////////////////////////// +const argvProcessListIndex = process.argv.indexOf("batch-run") + 1; +const argvProcessList = process.argv.at(-1); +const processesFilePath = path_1.default.resolve(process.cwd(), "batchrun.config.json"); +if ((argvProcessList === null || argvProcessList === void 0 ? void 0 : argvProcessList.match(/batchrun/i)) && !fs_1.default.existsSync(processesFilePath)) { + console.error(` - ${console_colors_1.default.FgRed}Error:${console_colors_1.default.Reset} No arguments to run`); + process.exit(1); +} +if (fs_1.default.existsSync(processesFilePath)) { + const processesFile = fs_1.default.readFileSync(processesFilePath, "utf8"); + const processesArray = JSON.parse(processesFile); + for (let i = 0; i < processesArray.length; i++) { + const processString = processesArray[i]; + const strippedProcessString = processString.trim(); + processesStrings.push(strippedProcessString); + } +} +else if (argvProcessList) { + const processesArray = argvProcessList.split(","); + for (let i = 0; i < processesArray.length; i++) { + const processString = processesArray[i]; + const strippedProcessString = processString.trim(); + processesStrings.push(strippedProcessString); + } +} +else { + console.error(` - ${console_colors_1.default.FgRed}Error:${console_colors_1.default.Reset} No arguments to run or \`batchrun.config.json\` file present`); + process.exit(1); +} +if (!(processesStrings === null || processesStrings === void 0 ? void 0 : processesStrings[0])) { + console.error(` - ${console_colors_1.default.FgRed}Error:${console_colors_1.default.Reset} No processes to run`); + process.exit(1); +} +/** @type {import("child_process").SpawnOptions} */ +const spawnOptions = { + cwd: process.cwd(), + shell: isWindows ? "bash.exe" : undefined, + stdio: ["pipe", "inherit", "inherit"], + detached: false, +}; +/** + * Start all processes + */ +function startProcesses() { + for (let i = 0; i < processesStrings.length; i++) { + const processString = processesStrings[i]; + const processStringArray = processString.split(" "); + const targetProcess = processStringArray.shift(); + if (targetProcess) { + const childProcess = (0, child_process_1.spawn)(targetProcess, processStringArray, spawnOptions); + if (childProcess) { + childProcess.on("exit", (code, signal) => { + console.log(` - ${console_colors_1.default.FgRed}Process ${i} exited with code ${code} and signal ${signal}${console_colors_1.default.Reset}`); + }); + childProcess.on("error", (err) => { + console.error(` - ${console_colors_1.default.FgYellow}Error:${console_colors_1.default.Reset} Failed to start process ${i}: ${err.message}`); + }); + childProcess.on("close", (code, signal) => { + console.log(` - ${console_colors_1.default.FgRed}Process ${i} closed with code ${code} and signal ${signal}${console_colors_1.default.Reset}`); + }); + processes.push(childProcess); + } + else { + console.error(` - ${console_colors_1.default.FgRed}Error:${console_colors_1.default.Reset} Failed to start process ${i}`); + process.exit(1); + } + } + else { + console.error(` - ${console_colors_1.default.FgRed}Error:${console_colors_1.default.Reset} A target process is not defined in \`${processString}\``); + process.exit(1); + } + } +} +/** + * Restart All Processes + */ +function restartAll() { + for (let i = 0; i < processes.length; i++) { + const childProcess = processes[i]; + try { + if (childProcess.pid) + killProcessForce(childProcess.pid); + childProcess.kill(); + // processes.splice(i, 1); + } + catch (error) { + console.log(` - ${console_colors_1.default.FgRed}Error:${console_colors_1.default.Reset} Failed to kill process ${childProcess.pid}`); + process.exit(); + } + } + console.log(` - ${console_colors_1.default.FgGreen}Restarted ${processes.length} processes${console_colors_1.default.Reset}`); + processes = []; + setTimeout(() => { + startProcesses(); + }, 500); +} +/** + * Restart a single process + * @param {string} index + */ +function restartOne(index) { + const childProcess = processes[index]; + try { + if (childProcess.pid) + killProcessForce(childProcess.pid); + childProcess.kill(); + } + catch (error) { + console.log(` - ${console_colors_1.default.FgRed}Error:${console_colors_1.default.Reset} Failed to kill process ${childProcess.pid}`); + process.exit(); + } + const processString = processesStrings[index]; + const processStringArray = processString.split(" "); + const targetProcess = processStringArray.shift(); + if (!targetProcess) + return; + const newChildProcess = (0, child_process_1.spawn)(targetProcess, processStringArray, spawnOptions); + processes.splice(index, 1, newChildProcess); +} +/** + * Kill a single process + * @param {string} index + */ +function killOne(index) { + const childProcess = processes[parseInt(index)]; + if (childProcess.pid) + killProcessForce(childProcess.pid); + childProcess.kill(); + try { + } + catch (error) { + console.log(` - ${console_colors_1.default.FgRed}Error:${console_colors_1.default.Reset} Failed to kill process ${childProcess.pid}`); + process.exit(); + } +} +/** + * Kill a process by PID + * @param {number} pid + */ +function killProcessForce(pid) { + if (typeof pid !== "number") { + return; + } + try { + if (isWindows) { + (0, child_process_1.execSync)(`taskkill /F /PID ${pid} /T`); + } + else { + (0, child_process_1.execSync)(`kill -9 ${pid}`); + } + } + catch (error) { } +} +console.log(` - ${console_colors_1.default.FgGreen}Started ${processesStrings.length} processes${console_colors_1.default.Reset}`); +startProcesses(); diff --git a/index.js b/index.ts similarity index 87% rename from index.js rename to index.ts index 03864eb..8201983 100644 --- a/index.js +++ b/index.ts @@ -1,15 +1,8 @@ -#! /usr/bin/env node -// @ts-check - -const fs = require("fs"); -const path = require("path"); -const { spawn, ChildProcess, execSync } = require("child_process"); -const readline = require("readline"); -const colors = require("./console-colors"); - -//////////////////////////////////////////// -//////////////////////////////////////////// -//////////////////////////////////////////// +import fs from "fs"; +import path from "path"; +import { spawn, ChildProcess, execSync } from "child_process"; +import readline from "readline"; +import colors from "./console-colors"; setInterval(() => { console.log( @@ -17,24 +10,14 @@ setInterval(() => { ); }, 60000); -//////////////////////////////////////////// -//////////////////////////////////////////// -//////////////////////////////////////////// - if (process.argv[process.argv.length - 1]?.match(/^--version$|^-v$/)) { console.log(`Batchrun v${require("./package.json").version}`); process.exit(); } -//////////////////////////////////////////// -//////////////////////////////////////////// -//////////////////////////////////////////// +const processesStrings: string[] = []; -/** @type {string[]} */ -const processesStrings = []; - -/** @type {ChildProcess[]} */ -let processes = []; +let processes: ChildProcess[] = []; const isWindows = process.platform.match(/win/i); const isMac = process.platform.match(/darwin/i); @@ -58,7 +41,7 @@ rl.on("line", (input) => { * @param {string} input * @returns */ -function readCommands(input) { +function readCommands(input: string) { if (input?.match(/^(reload|restart|reboot|r)$/i)) { console.log( ` - ${colors.FgBlue}Reloading processes ...${colors.Reset}` @@ -80,7 +63,7 @@ function readCommands(input) { ` - ${colors.FgBlue}Reloading processes ${processedIndexesString} ...${colors.Reset}` ); processedIndexes.forEach((index) => { - restartOne(index); + restartOne(parseInt(index)); }); console.log( ` - ${colors.FgGreen}Processes Restarted Successfully ${processedIndexesString} ...${colors.Reset}` @@ -217,7 +200,7 @@ if (!processesStrings?.[0]) { } /** @type {import("child_process").SpawnOptions} */ -const spawnOptions = { +const spawnOptions: import("child_process").SpawnOptions = { cwd: process.cwd(), shell: isWindows ? "bash.exe" : undefined, stdio: ["pipe", "inherit", "inherit"], @@ -309,8 +292,8 @@ function restartAll() { * Restart a single process * @param {string} index */ -function restartOne(index) { - const childProcess = processes[parseInt(index)]; +function restartOne(index: number) { + const childProcess = processes[index]; try { if (childProcess.pid) killProcessForce(childProcess.pid); @@ -325,19 +308,22 @@ function restartOne(index) { const processString = processesStrings[index]; const processStringArray = processString.split(" "); const targetProcess = processStringArray.shift(); + + if (!targetProcess) return; + const newChildProcess = spawn( targetProcess, processStringArray, spawnOptions ); - processes.splice(parseInt(index), 1, newChildProcess); + processes.splice(index, 1, newChildProcess); } /** * Kill a single process * @param {string} index */ -function killOne(index) { +function killOne(index: string) { const childProcess = processes[parseInt(index)]; if (childProcess.pid) killProcessForce(childProcess.pid); childProcess.kill(); @@ -355,7 +341,7 @@ function killOne(index) { * Kill a process by PID * @param {number} pid */ -function killProcessForce(pid) { +function killProcessForce(pid: number) { if (typeof pid !== "number") { return; } diff --git a/package-lock.json b/package-lock.json deleted file mode 100644 index e44c056..0000000 --- a/package-lock.json +++ /dev/null @@ -1,37 +0,0 @@ -{ - "name": "batchrun", - "version": "1.0.7", - "lockfileVersion": 3, - "requires": true, - "packages": { - "": { - "name": "batchrun", - "version": "1.0.7", - "license": "MIT", - "bin": { - "batch-run": "index.js", - "batchrun": "index.js" - }, - "devDependencies": { - "@types/node": "^22.8.7" - } - }, - "node_modules/@types/node": { - "version": "22.8.7", - "resolved": "https://registry.npmjs.org/@types/node/-/node-22.8.7.tgz", - "integrity": "sha512-LidcG+2UeYIWcMuMUpBKOnryBWG/rnmOHQR5apjn8myTQcx3rinFRn7DcIFhMnS0PPFSC6OafdIKEad0lj6U0Q==", - "dev": true, - "license": "MIT", - "dependencies": { - "undici-types": "~6.19.8" - } - }, - "node_modules/undici-types": { - "version": "6.19.8", - "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.19.8.tgz", - "integrity": "sha512-ve2KP6f/JnbPBFyobGHuerC9g1FYGn/F8n1LWTwNxCEzd6IfqTwUQcNXgEtmmQ6DlRrC1hrSrBnCZPokRrDHjw==", - "dev": true, - "license": "MIT" - } - } -} diff --git a/package.json b/package.json index c382f62..917a202 100644 --- a/package.json +++ b/package.json @@ -1,11 +1,14 @@ { "name": "@moduletrace/batchrun", - "version": "1.0.1", + "version": "1.0.3", "description": "Run and manage multiple processes concurrently in one terminal", - "main": "index.js", + "main": "dist/index.js", "bin": { - "batch-run": "./index.js", - "batchrun": "./index.js" + "batch-run": "dist/index.js", + "batchrun": "dist/index.js" + }, + "scripts": { + "build:binary": "bun build --compile --minify --sourcemap --bytecode ./index.js --outfile bin/batchrun" }, "repository": { "type": "git", @@ -23,6 +26,10 @@ "author": "Benjamin Toby", "license": "MIT", "devDependencies": { - "@types/node": "^22.8.7" + "@types/node": "^22.8.7", + "@types/bun": "latest" + }, + "peerDependencies": { + "typescript": "^5.0.0" } } diff --git a/publish.sh b/publish.sh new file mode 100755 index 0000000..30ebeea --- /dev/null +++ b/publish.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +tsc + +if [ -z "$1" ]; then + msg="Updates" +else + msg="$1" +fi + +git add . +git commit -m "$msg" +git push +bun publish diff --git a/push.sh b/push.sh new file mode 100755 index 0000000..f8a4555 --- /dev/null +++ b/push.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +if [ -z "$1" ]; then + msg="Updates" +else + msg="$1" +fi + +git add . +git commit -m "$msg" +git push 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"] +}