This commit is contained in:
Benjamin Toby 2025-01-22 12:31:32 +01:00
parent 1c26586478
commit cee4bc0478
9 changed files with 21 additions and 14 deletions

3
dist/index.d.ts vendored
View File

@ -1,2 +1,5 @@
#!/usr/bin/env bun #!/usr/bin/env bun
declare global {
var REDEPLOYMENTS: number;
}
export {}; export {};

1
dist/index.js vendored
View File

@ -9,6 +9,7 @@ const path_1 = __importDefault(require("path"));
const console_colors_1 = __importDefault(require("./utils/console-colors")); const console_colors_1 = __importDefault(require("./utils/console-colors"));
const start_1 = __importDefault(require("./utils/start")); const start_1 = __importDefault(require("./utils/start"));
const WORK_DIR = process.cwd(); const WORK_DIR = process.cwd();
global.REDEPLOYMENTS = 0;
function run() { function run() {
try { try {
const configText = fs_1.default.readFileSync(path_1.default.join(WORK_DIR, "buncid.config.json"), "utf-8"); const configText = fs_1.default.readFileSync(path_1.default.join(WORK_DIR, "buncid.config.json"), "utf-8");

File diff suppressed because one or more lines are too long

3
dist/utils/run.js vendored
View File

@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
exports.default = run; exports.default = run;
const child_process_1 = require("child_process"); const child_process_1 = require("child_process");
const console_colors_1 = __importDefault(require("./console-colors")); const console_colors_1 = __importDefault(require("./console-colors"));
let redeployments = 0;
const KILL_SIGNAL = "SIGTERM"; const KILL_SIGNAL = "SIGTERM";
/** /**
* ## Preflight Function * ## Preflight Function
@ -27,7 +26,7 @@ function run(command) {
stdio: "inherit", stdio: "inherit",
killSignal: KILL_SIGNAL, killSignal: KILL_SIGNAL,
}); });
redeployments++; global.REDEPLOYMENTS = global.REDEPLOYMENTS + 1;
return newChildProcess; return newChildProcess;
} }
catch (error) { catch (error) {

6
dist/utils/start.js vendored
View File

@ -9,7 +9,6 @@ const console_colors_1 = __importDefault(require("./console-colors"));
const preflight_1 = __importDefault(require("./preflight")); const preflight_1 = __importDefault(require("./preflight"));
const run_1 = __importDefault(require("./run")); const run_1 = __importDefault(require("./run"));
const kill_child_1 = __importDefault(require("./kill-child")); const kill_child_1 = __importDefault(require("./kill-child"));
let redeployments = 0;
let childProcess = null; let childProcess = null;
const pTitle = "buncid"; const pTitle = "buncid";
process.title = pTitle; process.title = pTitle;
@ -41,11 +40,12 @@ function startProcess({ command, preflight, postflight, redeploy_file, port, fir
console.log("Watching", redeploy_file); console.log("Watching", redeploy_file);
fs_1.default.watchFile(redeploy_file, { interval: 100 }, (curr, prev) => { fs_1.default.watchFile(redeploy_file, { interval: 100 }, (curr, prev) => {
console.log(`${console_colors_1.default.BgBlue}File Changed${console_colors_1.default.Reset}`); console.log(`${console_colors_1.default.BgBlue}File Changed${console_colors_1.default.Reset}`);
if (redeployments == 0) if (global.REDEPLOYMENTS == 0) {
return; return;
}
if (childProcess) { if (childProcess) {
console.log("******************************"); console.log("******************************");
console.log(`******** ${console_colors_1.default.FgBlue}Rebuilding ${console_colors_1.default.FgMagenta}${redeployments}${console_colors_1.default.Reset} ********`); console.log(`******** ${console_colors_1.default.FgBlue}Rebuilding ${console_colors_1.default.FgMagenta}${global.REDEPLOYMENTS}${console_colors_1.default.Reset} ********`);
console.log("******************************"); console.log("******************************");
try { try {
const runPreflight = (0, preflight_1.default)(preflight); const runPreflight = (0, preflight_1.default)(preflight);

View File

@ -8,6 +8,12 @@ import type { NodeCIConfig } from "./types";
const WORK_DIR = process.cwd(); const WORK_DIR = process.cwd();
declare global {
var REDEPLOYMENTS: number;
}
global.REDEPLOYMENTS = 0;
function run() { function run() {
try { try {
const configText = fs.readFileSync( const configText = fs.readFileSync(

View File

@ -1,6 +1,6 @@
{ {
"name": "@moduletrace/buncid", "name": "@moduletrace/buncid",
"version": "1.0.2", "version": "1.0.3",
"description": "Simple CI/CD process For Bun runtime", "description": "Simple CI/CD process For Bun runtime",
"main": "dist/index.js", "main": "dist/index.js",
"bin": { "bin": {

View File

@ -1,8 +1,6 @@
import { spawn, ChildProcess } from "child_process"; import { spawn, ChildProcess } from "child_process";
import colors from "./console-colors"; import colors from "./console-colors";
let redeployments = 0;
const KILL_SIGNAL: NodeJS.Signals | number = "SIGTERM"; const KILL_SIGNAL: NodeJS.Signals | number = "SIGTERM";
/** /**
@ -31,7 +29,7 @@ export default function run(command: string): ChildProcess | null {
killSignal: KILL_SIGNAL, killSignal: KILL_SIGNAL,
}); });
redeployments++; global.REDEPLOYMENTS = global.REDEPLOYMENTS + 1;
return newChildProcess; return newChildProcess;
} catch (error: any) { } catch (error: any) {

View File

@ -5,8 +5,6 @@ import preflightFn from "./preflight";
import run from "./run"; import run from "./run";
import killChild from "./kill-child"; import killChild from "./kill-child";
let redeployments = 0;
let childProcess: ChildProcess | null = null; let childProcess: ChildProcess | null = null;
const pTitle = "buncid"; const pTitle = "buncid";
@ -64,12 +62,14 @@ export default function startProcess({
fs.watchFile(redeploy_file, { interval: 100 }, (curr, prev) => { fs.watchFile(redeploy_file, { interval: 100 }, (curr, prev) => {
console.log(`${colors.BgBlue}File Changed${colors.Reset}`); console.log(`${colors.BgBlue}File Changed${colors.Reset}`);
if (redeployments == 0) return; if (global.REDEPLOYMENTS == 0) {
return;
}
if (childProcess) { if (childProcess) {
console.log("******************************"); console.log("******************************");
console.log( console.log(
`******** ${colors.FgBlue}Rebuilding ${colors.FgMagenta}${redeployments}${colors.Reset} ********` `******** ${colors.FgBlue}Rebuilding ${colors.FgMagenta}${global.REDEPLOYMENTS}${colors.Reset} ********`
); );
console.log("******************************"); console.log("******************************");