@yeci226/nhentai-ts
Version:
A scraper for NHentai with types
96 lines (95 loc) • 3.22 kB
JavaScript
;
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var import_child_process = require("child_process");
var import_esbuild = require("esbuild");
var import_fs = require("fs");
var import_perf_hooks = require("perf_hooks");
var import_tiny_glob = __toESM(require("tiny-glob"));
(async () => {
const startTime = import_perf_hooks.performance.now();
console.log("\x1B[32mCleaning dist directory\x1B[0m");
(0, import_fs.rmSync)("dist", {
force: true,
recursive: true
});
const target = ["ESNext", "node8.17"];
const entryPoints = await (0, import_tiny_glob.default)("./src/**/*.ts");
console.log("\x1B[34mBuilding dist for node (cjs)...\x1B[0m");
(0, import_esbuild.buildSync)({
entryPoints,
outdir: "./dist/cjs",
bundle: false,
sourcemap: false,
minify: false,
format: "cjs",
platform: "node",
target
});
(0, import_fs.writeFileSync)("./dist/cjs/package.json", '{"type": "commonjs"}', {
flag: "w"
});
console.log("\x1B[34mBuilding dist for node type=module (esm)...\x1B[0m");
(0, import_esbuild.buildSync)({
entryPoints: [
"./src/index.ts",
"./src/lib/index.ts",
"./src/Parser/index.ts"
],
outdir: "./dist/esm",
bundle: true,
sourcemap: false,
minify: false,
splitting: true,
format: "esm",
target,
platform: "node",
outExtension: {
".js": ".mjs"
},
external: [
"axios",
"cheerio",
"http-cookie-agent",
"jszip",
"pdfkit",
"rimraf",
"tough-cookie",
"deasync"
]
});
(0, import_fs.writeFileSync)("./dist/esm/package.json", '{"type": "module"}', {
flag: "w"
});
console.log("\x1B[34mGenerating typescript declaration ...\x1B[0m");
(0, import_child_process.execSync)(
"tsc --declaration --emitDeclarationOnly --declarationDir ./dist/types/"
);
const endTime = import_perf_hooks.performance.now();
const executionTime = (endTime - startTime) / 1e3;
console.log(
"\x1B[32mBuild Success with execution time ".concat(executionTime.toFixed(
2
), " s\x1B[0m")
);
})();