Updates
This commit is contained in:
@@ -0,0 +1 @@
|
||||
export default function grabDefaultDistName(): string;
|
||||
@@ -0,0 +1,6 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = grabDefaultDistName;
|
||||
function grabDefaultDistName() {
|
||||
return ".buncid-next-dist";
|
||||
}
|
||||
Vendored
+5
-1
@@ -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 {};
|
||||
|
||||
Vendored
+8
-6
@@ -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();
|
||||
}
|
||||
|
||||
Vendored
+21
-3
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user