Updates
This commit is contained in:
parent
0375c02931
commit
69eb6c1128
3
.vscode/settings.json
vendored
Normal file
3
.vscode/settings.json
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"cursor.aipreview.enabled": true
|
||||
}
|
@ -10,9 +10,11 @@ const WORK_DIR = process.cwd();
|
||||
|
||||
declare global {
|
||||
var REDEPLOYMENTS: number;
|
||||
var DEPLOYING: 0 | 1;
|
||||
}
|
||||
|
||||
global.REDEPLOYMENTS = 0;
|
||||
global.DEPLOYING = 0;
|
||||
|
||||
function run() {
|
||||
try {
|
||||
|
1
dist/buncid.d.ts
vendored
1
dist/buncid.d.ts
vendored
@ -1,5 +1,6 @@
|
||||
#!/usr/bin/env bun
|
||||
declare global {
|
||||
var REDEPLOYMENTS: number;
|
||||
var DEPLOYING: 0 | 1;
|
||||
}
|
||||
export {};
|
||||
|
1
dist/buncid.js
vendored
1
dist/buncid.js
vendored
@ -10,6 +10,7 @@ const console_colors_1 = __importDefault(require("./utils/console-colors"));
|
||||
const start_1 = __importDefault(require("./utils/start"));
|
||||
const WORK_DIR = process.cwd();
|
||||
global.REDEPLOYMENTS = 0;
|
||||
global.DEPLOYING = 0;
|
||||
function run() {
|
||||
try {
|
||||
const configText = fs_1.default.readFileSync(path_1.default.join(WORK_DIR, "buncid.config.json"), "utf-8");
|
||||
|
2
dist/tsconfig.tsbuildinfo
vendored
2
dist/tsconfig.tsbuildinfo
vendored
File diff suppressed because one or more lines are too long
13
dist/utils/start.js
vendored
13
dist/utils/start.js
vendored
@ -4,11 +4,11 @@ var __importDefault = (this && this.__importDefault) || function (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"));
|
||||
const chokidar_1 = __importDefault(require("chokidar"));
|
||||
let childProcess = null;
|
||||
const pTitle = "buncid";
|
||||
process.title = pTitle;
|
||||
@ -36,14 +36,16 @@ function startProcess({ command, preflight, postflight, redeploy_file, port, fir
|
||||
process.exit();
|
||||
}
|
||||
console.log("Watching", redeploy_file);
|
||||
const watcher = chokidar_1.default.watch(redeploy_file, { ignoreInitial: true });
|
||||
watcher.on("change", (path, stats) => {
|
||||
fs_1.default.watchFile(redeploy_file, { interval: 100 }, (curr, prev) => {
|
||||
if (global.DEPLOYING == 1)
|
||||
return;
|
||||
clearTimeout(timeout);
|
||||
timeout = setTimeout(() => {
|
||||
console.log(`${console_colors_1.default.BgBlue}File Changed${console_colors_1.default.Reset}`);
|
||||
if (global.REDEPLOYMENTS == 0) {
|
||||
return;
|
||||
}
|
||||
global.DEPLOYING = 1;
|
||||
if (childProcess) {
|
||||
console.log("******************************");
|
||||
console.log(`******** ${console_colors_1.default.FgBlue}Rebuilding ${console_colors_1.default.FgMagenta}${global.REDEPLOYMENTS}${console_colors_1.default.Reset} ********`);
|
||||
@ -60,10 +62,10 @@ function startProcess({ command, preflight, postflight, redeploy_file, port, fir
|
||||
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.`);
|
||||
}
|
||||
}
|
||||
global.DEPLOYING = 0;
|
||||
}
|
||||
else {
|
||||
process.exit();
|
||||
@ -76,6 +78,9 @@ function startProcess({ command, preflight, postflight, redeploy_file, port, fir
|
||||
process.exit();
|
||||
}
|
||||
}
|
||||
else {
|
||||
global.DEPLOYING = 0;
|
||||
}
|
||||
}, DEBOUNCE);
|
||||
});
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@moduletrace/buncid",
|
||||
"version": "1.0.6",
|
||||
"version": "1.0.7",
|
||||
"description": "Simple CI/CD process For Bun runtime",
|
||||
"main": "dist/index.js",
|
||||
"bin": {
|
||||
@ -22,7 +22,6 @@
|
||||
"author": "Benjamin Toby",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"chokidar": "^4.0.3",
|
||||
"kill-port": "^2.0.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
@ -4,7 +4,6 @@ import colors from "./console-colors";
|
||||
import preflightFn from "./preflight";
|
||||
import run from "./run";
|
||||
import killChild from "./kill-child";
|
||||
import chokidar from "chokidar";
|
||||
|
||||
let childProcess: ChildProcess | null = null;
|
||||
|
||||
@ -59,9 +58,9 @@ export default function startProcess({
|
||||
|
||||
console.log("Watching", redeploy_file);
|
||||
|
||||
const watcher = chokidar.watch(redeploy_file, { ignoreInitial: true });
|
||||
fs.watchFile(redeploy_file, { interval: 100 }, (curr, prev) => {
|
||||
if (global.DEPLOYING == 1) return;
|
||||
|
||||
watcher.on("change", (path, stats) => {
|
||||
clearTimeout(timeout);
|
||||
|
||||
timeout = setTimeout(() => {
|
||||
@ -71,6 +70,8 @@ export default function startProcess({
|
||||
return;
|
||||
}
|
||||
|
||||
global.DEPLOYING = 1;
|
||||
|
||||
if (childProcess) {
|
||||
console.log("******************************");
|
||||
console.log(
|
||||
@ -97,13 +98,13 @@ export default function startProcess({
|
||||
);
|
||||
|
||||
if (!runPostflight) {
|
||||
// TODO: Action to take if postflight fails
|
||||
|
||||
console.log(
|
||||
`${colors.FgRed}Error:${colors.Reset} Postflight Failed.`
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
global.DEPLOYING = 0;
|
||||
} else {
|
||||
process.exit();
|
||||
}
|
||||
@ -115,6 +116,8 @@ export default function startProcess({
|
||||
);
|
||||
process.exit();
|
||||
}
|
||||
} else {
|
||||
global.DEPLOYING = 0;
|
||||
}
|
||||
}, DEBOUNCE);
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user