Fix loading within the CLI (#27)
* Fix loading within the CLI * Remove app * Remove promise handle * Fix requested changes
This commit is contained in:
@ -1,7 +1,9 @@
|
||||
const fs = require("fs");
|
||||
const fse = require("fs-extra");
|
||||
const os = require("os");
|
||||
const path = require("path");
|
||||
const nexe = require("nexe");
|
||||
const zlib = require("zlib");
|
||||
|
||||
const nexeRoot = path.join(os.homedir(), ".nexe");
|
||||
if (!fs.existsSync(nexeRoot)) {
|
||||
@ -19,36 +21,52 @@ listed.forEach((list) => {
|
||||
}
|
||||
});
|
||||
|
||||
const tmpDir = path.join(__dirname, "../build");
|
||||
if (fs.existsSync(tmpDir)) {
|
||||
console.log("Removing old build dir...");
|
||||
fse.removeSync(tmpDir);
|
||||
}
|
||||
|
||||
console.log("Copying build files...");
|
||||
fse.copySync(path.join(__dirname, "../resources"), tmpDir, {
|
||||
recursive: true,
|
||||
});
|
||||
const modDir = path.join(tmpDir, "modules");
|
||||
fs.mkdirSync(modDir);
|
||||
fse.copySync(path.join(__dirname, "../../protocol/node_modules/node-pty/build/Release/pty.node"), path.join(modDir, "pty.node"));
|
||||
|
||||
const zipper = (p) => {
|
||||
const stat = fs.statSync(p);
|
||||
if (!stat.isDirectory()) {
|
||||
fs.writeFileSync(p + ".gz", zlib.gzipSync(fs.readFileSync(p)));
|
||||
fse.removeSync(p);
|
||||
return;
|
||||
}
|
||||
const files = fs.readdirSync(p);
|
||||
files.forEach((f) => zipper(path.join(p, f)));
|
||||
};
|
||||
|
||||
zipper(path.join(tmpDir, "web"));
|
||||
zipper(path.join(tmpDir, "bootstrap-fork.js"));
|
||||
|
||||
nexe.compile({
|
||||
debugBundle: true,
|
||||
input: path.join(__dirname, "../out/cli.js"),
|
||||
output: 'cli',
|
||||
targets: ["linux"],
|
||||
native: {
|
||||
"node-pty": {
|
||||
spdlog: {
|
||||
additionalFiles: [
|
||||
'./node_modules/node-pty/build/Release/pty',
|
||||
],
|
||||
},
|
||||
"spdlog": {
|
||||
additionalFiles: [
|
||||
'spdlog.node',
|
||||
'spdlog.node'
|
||||
],
|
||||
},
|
||||
},
|
||||
targets: ["linux"],
|
||||
/**
|
||||
* To include native extensions, do NOT install node_modules for each one. They
|
||||
* are not required as each extension is built using webpack.
|
||||
*/
|
||||
resources: [
|
||||
path.join(__dirname, "../package.json"),
|
||||
path.join(__dirname, "../build/**"),
|
||||
path.join(__dirname, "../build/**/*"),
|
||||
],
|
||||
});
|
||||
|
||||
/**
|
||||
* Notes for tmrw
|
||||
*
|
||||
* `upx ~/.nexe/linux` <- node binary before compiling with nexe
|
||||
* Use `testing.js` for bundling with nexe to build
|
||||
*/
|
Reference in New Issue
Block a user