Updates
This commit is contained in:
parent
7d71316b2c
commit
4540404522
@ -132,4 +132,4 @@ const nextConfig: NextConfig = {
|
||||
export default nextConfig;
|
||||
```
|
||||
|
||||
That's it. This dynamically handles your distribution directory for both `dev` and `start` scripts. Your `development` environment uses the `.next` directory, while your `production` environment uses the `.dist` directory.
|
||||
That's it. This dynamically handles your distribution directory for both `dev` and `start` scripts. Your `development` environment uses the `.next` directory, while your `production` environment uses the `.buncid-next-dist` (or any dist name of your chosing) directory.
|
||||
|
1
dist/rebuilds/next-js/(utils)/grab-default-dist-name.d.ts
vendored
Normal file
1
dist/rebuilds/next-js/(utils)/grab-default-dist-name.d.ts
vendored
Normal file
@ -0,0 +1 @@
|
||||
export default function grabDefaultDistName(): string;
|
6
dist/rebuilds/next-js/(utils)/grab-default-dist-name.js
vendored
Normal file
6
dist/rebuilds/next-js/(utils)/grab-default-dist-name.js
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = grabDefaultDistName;
|
||||
function grabDefaultDistName() {
|
||||
return ".buncid-next-dist";
|
||||
}
|
6
dist/rebuilds/next-js/grabDist.d.ts
vendored
6
dist/rebuilds/next-js/grabDist.d.ts
vendored
@ -1,6 +1,10 @@
|
||||
type Param = {
|
||||
distDir?: string;
|
||||
};
|
||||
/**
|
||||
* # Grab the current distribution directory
|
||||
* @description This returns the relative path from the CWD. Eg `./.dist/build-1`
|
||||
* @returns {string | undefined}
|
||||
*/
|
||||
export default function grabDist(): string | undefined;
|
||||
export default function grabDist(params?: Param): string | undefined;
|
||||
export {};
|
||||
|
14
dist/rebuilds/next-js/grabDist.js
vendored
14
dist/rebuilds/next-js/grabDist.js
vendored
@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = grabDist;
|
||||
const fs_1 = __importDefault(require("fs"));
|
||||
const path_1 = __importDefault(require("path"));
|
||||
const grab_default_dist_name_1 = __importDefault(require("./(utils)/grab-default-dist-name"));
|
||||
const production = process.env.NODE_ENV == "production";
|
||||
const isBuilding = process.env.BUILDING_APP;
|
||||
/**
|
||||
@ -13,15 +14,16 @@ const isBuilding = process.env.BUILDING_APP;
|
||||
* @description This returns the relative path from the CWD. Eg `./.dist/build-1`
|
||||
* @returns {string | undefined}
|
||||
*/
|
||||
function grabDist() {
|
||||
const DIST_DIR = path_1.default.resolve(process.cwd(), "./.dist");
|
||||
function grabDist(params) {
|
||||
const distDirName = (params === null || params === void 0 ? void 0 : params.distDir) || (0, grab_default_dist_name_1.default)();
|
||||
const DIST_DIR = path_1.default.join(process.cwd(), distDirName);
|
||||
if (isBuilding) {
|
||||
const distDir = (() => {
|
||||
try {
|
||||
const buildNumber = fs_1.default.readFileSync(`${DIST_DIR}/BUILD`, "utf-8");
|
||||
return `.dist/build-${buildNumber}`;
|
||||
return `${distDirName}/build-${buildNumber}`;
|
||||
}
|
||||
catch ( /** @type {*} */error) {
|
||||
catch (error) {
|
||||
console.log("Build Number Generation Error =>", error.message);
|
||||
process.exit();
|
||||
}
|
||||
@ -32,9 +34,9 @@ function grabDist() {
|
||||
const distDir = (() => {
|
||||
try {
|
||||
const buildNumber = fs_1.default.readFileSync(`${DIST_DIR}/BUILD`, "utf-8");
|
||||
return `.dist/build-${buildNumber}`;
|
||||
return `${distDirName}/build-${buildNumber}`;
|
||||
}
|
||||
catch ( /** @type {*} */error) {
|
||||
catch (error) {
|
||||
console.log("Build Number Parse Error =>", error.message);
|
||||
process.exit();
|
||||
}
|
||||
|
24
dist/rebuilds/next-js/index.js
vendored
24
dist/rebuilds/next-js/index.js
vendored
@ -6,13 +6,31 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
var _a;
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const path_1 = __importDefault(require("path"));
|
||||
const util_1 = require("util");
|
||||
const fs_1 = __importDefault(require("fs"));
|
||||
const child_process_1 = require("child_process");
|
||||
const DIST_DIR = path_1.default.resolve(process.cwd(), "./.dist");
|
||||
const grab_default_dist_name_1 = __importDefault(require("./(utils)/grab-default-dist-name"));
|
||||
const args = (0, util_1.parseArgs)({
|
||||
args: process.argv,
|
||||
options: {
|
||||
maxBuilds: {
|
||||
type: "string",
|
||||
alias: "m",
|
||||
},
|
||||
distDir: {
|
||||
type: "string",
|
||||
alias: "d",
|
||||
},
|
||||
},
|
||||
});
|
||||
const distDirName = args.values.distDir || (0, grab_default_dist_name_1.default)();
|
||||
const DIST_DIR = path_1.default.join(process.cwd(), distDirName);
|
||||
let PREV_BUILD_NO = "0";
|
||||
const MAX_BUILDS = process.env.BUNCID_MAX_BUILDS
|
||||
? Number(process.env.BUNCID_MAX_BUILDS)
|
||||
: 10;
|
||||
: args.values.maxBuilds
|
||||
? Number(args.values.maxBuilds)
|
||||
: 10;
|
||||
if (MAX_BUILDS < 1 ||
|
||||
Number.isNaN(MAX_BUILDS) ||
|
||||
typeof MAX_BUILDS !== "number") {
|
||||
@ -67,7 +85,7 @@ const build = (0, child_process_1.spawnSync)("bunx", ["next", "build"], spawnSyn
|
||||
function grabNewDistDir() {
|
||||
try {
|
||||
const buildNumber = fs_1.default.readFileSync(`${DIST_DIR}/BUILD`, "utf-8");
|
||||
return `.dist/build-${buildNumber}`;
|
||||
return `${distDirName}/build-${buildNumber}`;
|
||||
}
|
||||
catch ( /** @type {*} */error) {
|
||||
console.log("Build Number Parse Error =>", error.message);
|
||||
|
2
dist/tsconfig.tsbuildinfo
vendored
2
dist/tsconfig.tsbuildinfo
vendored
File diff suppressed because one or more lines are too long
4
dist/utils/kill-child.js
vendored
4
dist/utils/kill-child.js
vendored
@ -31,11 +31,11 @@ function killChild(childProcess, port) {
|
||||
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));
|
||||
yield (0, kill_port_1.default)(Number(singlePort), "tcp");
|
||||
}
|
||||
}
|
||||
else if (port) {
|
||||
yield (0, kill_port_1.default)(Number(port));
|
||||
yield (0, kill_port_1.default)(Number(port), "tcp");
|
||||
}
|
||||
}
|
||||
catch (error) { }
|
||||
|
35
package.json
35
package.json
@ -1,34 +1,35 @@
|
||||
{
|
||||
"name": "@moduletrace/buncid",
|
||||
"version": "1.0.8",
|
||||
"description": "Simple CI/CD process For Bun runtime",
|
||||
"version": "1.0.9",
|
||||
"author": "Benjamin Toby",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://git.tben.me/Moduletrace/buncid.git"
|
||||
},
|
||||
"main": "dist/index.js",
|
||||
"devDependencies": {
|
||||
"@types/bun": "latest",
|
||||
"@types/kill-port": "^2.0.3",
|
||||
"@types/node": "^22.10.7"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"typescript": "^5.0.0"
|
||||
},
|
||||
"bin": {
|
||||
"buncid": "./dist/buncid.js",
|
||||
"buncid-builds-next": "./dist/rebuilds/next-js/index.js"
|
||||
},
|
||||
"scripts": {
|
||||
"compile": "bun build --compile --minify --sourcemap --bytecode index.ts --outfile bin/buncid"
|
||||
},
|
||||
"description": "Simple CI/CD process For Bun runtime",
|
||||
"keywords": [
|
||||
"CI/CD",
|
||||
"Continuous Integration",
|
||||
"Continous Deployment"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://git.tben.me/Moduletrace/buncid.git"
|
||||
},
|
||||
"author": "Benjamin Toby",
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"compile": "bun build --compile --minify --sourcemap --bytecode index.ts --outfile bin/buncid"
|
||||
},
|
||||
"dependencies": {
|
||||
"kill-port": "^2.0.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/bun": "latest",
|
||||
"@types/node": "^22.10.7"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"typescript": "^5.0.0"
|
||||
}
|
||||
}
|
||||
|
3
rebuilds/next-js/(utils)/grab-default-dist-name.ts
Normal file
3
rebuilds/next-js/(utils)/grab-default-dist-name.ts
Normal file
@ -0,0 +1,3 @@
|
||||
export default function grabDefaultDistName(): string {
|
||||
return ".buncid-next-dist";
|
||||
}
|
@ -25,4 +25,4 @@ const nextConfig: NextConfig = {
|
||||
export default nextConfig;
|
||||
```
|
||||
|
||||
That's it. This dynamically handles your distribution directory for both `dev` and `start` scripts. Your `development` environment uses the `.next` directory, while your `production` environment uses the `.dist` directory.
|
||||
That's it. This dynamically handles your distribution directory for both `dev` and `start` scripts. Your `development` environment uses the `.next` directory, while your `production` environment uses the `.buncid-next-dist` (or any dist name of your chosing) directory.
|
||||
|
@ -1,16 +1,22 @@
|
||||
import fs from "fs";
|
||||
import path from "path";
|
||||
import grabDefaultDistName from "./(utils)/grab-default-dist-name";
|
||||
|
||||
const production = process.env.NODE_ENV == "production";
|
||||
const isBuilding = process.env.BUILDING_APP;
|
||||
|
||||
type Param = {
|
||||
distDir?: string;
|
||||
};
|
||||
|
||||
/**
|
||||
* # Grab the current distribution directory
|
||||
* @description This returns the relative path from the CWD. Eg `./.dist/build-1`
|
||||
* @returns {string | undefined}
|
||||
*/
|
||||
export default function grabDist(): string | undefined {
|
||||
const DIST_DIR = path.resolve(process.cwd(), "./.dist");
|
||||
export default function grabDist(params?: Param): string | undefined {
|
||||
const distDirName = params?.distDir || grabDefaultDistName();
|
||||
const DIST_DIR = path.join(process.cwd(), distDirName);
|
||||
|
||||
if (isBuilding) {
|
||||
const distDir = (() => {
|
||||
@ -19,8 +25,8 @@ export default function grabDist(): string | undefined {
|
||||
`${DIST_DIR}/BUILD`,
|
||||
"utf-8"
|
||||
);
|
||||
return `.dist/build-${buildNumber}`;
|
||||
} catch (/** @type {*} */ error: any) {
|
||||
return `${distDirName}/build-${buildNumber}`;
|
||||
} catch (error: any) {
|
||||
console.log("Build Number Generation Error =>", error.message);
|
||||
process.exit();
|
||||
}
|
||||
@ -36,8 +42,8 @@ export default function grabDist(): string | undefined {
|
||||
`${DIST_DIR}/BUILD`,
|
||||
"utf-8"
|
||||
);
|
||||
return `.dist/build-${buildNumber}`;
|
||||
} catch (/** @type {*} */ error: any) {
|
||||
return `${distDirName}/build-${buildNumber}`;
|
||||
} catch (error: any) {
|
||||
console.log("Build Number Parse Error =>", error.message);
|
||||
process.exit();
|
||||
}
|
||||
|
@ -1,18 +1,37 @@
|
||||
#!/usr/bin/env bun
|
||||
|
||||
import path from "path";
|
||||
import { parseArgs } from "util";
|
||||
import fs from "fs";
|
||||
import {
|
||||
execSync,
|
||||
spawnSync,
|
||||
SpawnSyncOptionsWithStringEncoding,
|
||||
} from "child_process";
|
||||
import grabDefaultDistName from "./(utils)/grab-default-dist-name";
|
||||
|
||||
const DIST_DIR = path.resolve(process.cwd(), "./.dist");
|
||||
const args = parseArgs({
|
||||
args: process.argv,
|
||||
options: {
|
||||
maxBuilds: {
|
||||
type: "string",
|
||||
alias: "m",
|
||||
},
|
||||
distDir: {
|
||||
type: "string",
|
||||
alias: "d",
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const distDirName = args.values.distDir || grabDefaultDistName();
|
||||
const DIST_DIR = path.join(process.cwd(), distDirName);
|
||||
let PREV_BUILD_NO = "0";
|
||||
|
||||
const MAX_BUILDS = process.env.BUNCID_MAX_BUILDS
|
||||
? Number(process.env.BUNCID_MAX_BUILDS)
|
||||
: args.values.maxBuilds
|
||||
? Number(args.values.maxBuilds)
|
||||
: 10;
|
||||
|
||||
if (
|
||||
@ -81,7 +100,7 @@ const build = spawnSync("bunx", ["next", "build"], spawnSyncOptions);
|
||||
function grabNewDistDir(): string {
|
||||
try {
|
||||
const buildNumber = fs.readFileSync(`${DIST_DIR}/BUILD`, "utf-8");
|
||||
return `.dist/build-${buildNumber}`;
|
||||
return `${distDirName}/build-${buildNumber}`;
|
||||
} catch (/** @type {*} */ error: any) {
|
||||
console.log("Build Number Parse Error =>", error.message);
|
||||
process.exit();
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { ChildProcess } from "child_process";
|
||||
import colors from "./console-colors";
|
||||
import kill from "kill-port";
|
||||
import killPort from "kill-port";
|
||||
|
||||
/**
|
||||
* ## Kill Child Process Function
|
||||
@ -21,10 +21,10 @@ export default async function killChild(
|
||||
if (typeof port == "object" && port?.[0]) {
|
||||
for (let i = 0; i < port.length; i++) {
|
||||
const singlePort = port[i];
|
||||
await kill(Number(singlePort));
|
||||
await killPort(Number(singlePort), "tcp");
|
||||
}
|
||||
} else if (port) {
|
||||
await kill(Number(port));
|
||||
await killPort(Number(port), "tcp");
|
||||
}
|
||||
} catch (error) {}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user