@hakobu/hakobu 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +673 -0
- package/dictionary/angular-bridge.js +3 -0
- package/dictionary/any-promise.js +3 -0
- package/dictionary/async.js +3 -0
- package/dictionary/aws-sdk.js +7 -0
- package/dictionary/babel-core.js +3 -0
- package/dictionary/batch.js +3 -0
- package/dictionary/bcrypt.js +3 -0
- package/dictionary/better-sqlite3.js +3 -0
- package/dictionary/bignum.js +3 -0
- package/dictionary/bindings.js +3 -0
- package/dictionary/blessed.js +8 -0
- package/dictionary/body-parser.js +9 -0
- package/dictionary/browserify.js +7 -0
- package/dictionary/bson.js +3 -0
- package/dictionary/buffermaker.js +7 -0
- package/dictionary/bunyan.js +9 -0
- package/dictionary/busboy.js +7 -0
- package/dictionary/bytes.js +3 -0
- package/dictionary/callsites.js +3 -0
- package/dictionary/chokidar.js +3 -0
- package/dictionary/coffee-script.js +7 -0
- package/dictionary/colors.js +3 -0
- package/dictionary/compression.js +3 -0
- package/dictionary/compressjs.js +7 -0
- package/dictionary/connect-mongo.js +3 -0
- package/dictionary/connect-mongodb.js +3 -0
- package/dictionary/connect-redis.js +3 -0
- package/dictionary/connect.js +10 -0
- package/dictionary/consolidate.js +3 -0
- package/dictionary/cookie-parser.js +3 -0
- package/dictionary/cookie.js +3 -0
- package/dictionary/cors.js +3 -0
- package/dictionary/cron.js +3 -0
- package/dictionary/cross-env.js +11 -0
- package/dictionary/cross-spawn-async.js +3 -0
- package/dictionary/curve25519.js +3 -0
- package/dictionary/data-preflight.js +7 -0
- package/dictionary/debug.js +3 -0
- package/dictionary/denymount.js +3 -0
- package/dictionary/diff.js +3 -0
- package/dictionary/drivelist.js +22 -0
- package/dictionary/ed25519.js +3 -0
- package/dictionary/ejs.js +3 -0
- package/dictionary/elasticsearch.js +3 -0
- package/dictionary/electron.js +17 -0
- package/dictionary/emailjs.js +3 -0
- package/dictionary/engine.io.js +3 -0
- package/dictionary/epoll.js +3 -0
- package/dictionary/errorhandler.js +7 -0
- package/dictionary/errors.js +7 -0
- package/dictionary/eslint.js +7 -0
- package/dictionary/etcher-image-write.js +3 -0
- package/dictionary/exceljs.js +21 -0
- package/dictionary/exiftool.exe.js +13 -0
- package/dictionary/exiftool.pl.js +13 -0
- package/dictionary/express-load.js +12 -0
- package/dictionary/express-session.js +3 -0
- package/dictionary/express.js +14 -0
- package/dictionary/extender.js +11 -0
- package/dictionary/extsprintf.js +3 -0
- package/dictionary/faye-websocket.js +3 -0
- package/dictionary/feathers.js +3 -0
- package/dictionary/findup-sync.js +3 -0
- package/dictionary/floordate.js +3 -0
- package/dictionary/fmt.js +3 -0
- package/dictionary/formidable.js +3 -0
- package/dictionary/fs-extra.js +3 -0
- package/dictionary/fsevents.js +3 -0
- package/dictionary/geoip-lite.js +7 -0
- package/dictionary/github.js +7 -0
- package/dictionary/gm.js +3 -0
- package/dictionary/google-closure-compiler-java.js +13 -0
- package/dictionary/google-closure-compiler.js +13 -0
- package/dictionary/googleapis.js +7 -0
- package/dictionary/got.js +3 -0
- package/dictionary/graceful-fs.js +19 -0
- package/dictionary/grpc.js +11 -0
- package/dictionary/gulp.js +3 -0
- package/dictionary/hap-nodejs.js +3 -0
- package/dictionary/heapdump.js +3 -0
- package/dictionary/hoek.js +3 -0
- package/dictionary/homebridge.js +3 -0
- package/dictionary/http-proxy.js +3 -0
- package/dictionary/http-server.js +3 -0
- package/dictionary/image-size.js +3 -0
- package/dictionary/indexof.js +3 -0
- package/dictionary/inquirer.js +3 -0
- package/dictionary/j.js +16 -0
- package/dictionary/jade.js +3 -0
- package/dictionary/jsdom.js +3 -0
- package/dictionary/json-stringify-date.js +3 -0
- package/dictionary/json-stringify-safe.js +3 -0
- package/dictionary/jsonwebtoken.js +3 -0
- package/dictionary/kerberos.js +3 -0
- package/dictionary/knex.js +7 -0
- package/dictionary/later.js +7 -0
- package/dictionary/level.js +3 -0
- package/dictionary/leveldown.js +10 -0
- package/dictionary/levelup.js +3 -0
- package/dictionary/liftoff.js +12 -0
- package/dictionary/lodash.js +3 -0
- package/dictionary/log4js.js +7 -0
- package/dictionary/logform.js +7 -0
- package/dictionary/machinepack-urls.js +7 -0
- package/dictionary/markdown.js +3 -0
- package/dictionary/mdns.js +6 -0
- package/dictionary/method-override.js +3 -0
- package/dictionary/microjob.js +16 -0
- package/dictionary/mime-types.js +3 -0
- package/dictionary/mime.js +3 -0
- package/dictionary/minimatch.js +3 -0
- package/dictionary/minstache.js +3 -0
- package/dictionary/module-deps.js +3 -0
- package/dictionary/moment-timezone.js +3 -0
- package/dictionary/moment.js +7 -0
- package/dictionary/mongodb-core.js +22 -0
- package/dictionary/mongodb.js +7 -0
- package/dictionary/mongoose.js +7 -0
- package/dictionary/mongoskin.js +7 -0
- package/dictionary/ms.js +3 -0
- package/dictionary/msgpack.js +3 -0
- package/dictionary/multer.js +3 -0
- package/dictionary/muri.js +3 -0
- package/dictionary/native-or-bluebird.js +3 -0
- package/dictionary/natives.js +3 -0
- package/dictionary/nconf.js +7 -0
- package/dictionary/nedb.js +3 -0
- package/dictionary/negotiator.js +7 -0
- package/dictionary/newrelic.js +3 -0
- package/dictionary/nib.js +3 -0
- package/dictionary/nightmare.js +18 -0
- package/dictionary/node-forge.js +7 -0
- package/dictionary/node-libcurl.js +3 -0
- package/dictionary/node-notifier.js +30 -0
- package/dictionary/node-pre-gyp.js +7 -0
- package/dictionary/node-redis-pubsub.js +3 -0
- package/dictionary/node-sass.js +3 -0
- package/dictionary/node-uuid.js +3 -0
- package/dictionary/node-xlsx.js +3 -0
- package/dictionary/node-zookeeper-client.js +7 -0
- package/dictionary/nodegit.js +7 -0
- package/dictionary/nodemailer-sendmail-transport.js +3 -0
- package/dictionary/nodemailer.js +3 -0
- package/dictionary/npm-registry-client.js +7 -0
- package/dictionary/npm.js +7 -0
- package/dictionary/nssocket.js +3 -0
- package/dictionary/oauth2orize.js +7 -0
- package/dictionary/octobat.js +3 -0
- package/dictionary/open.js +13 -0
- package/dictionary/opn.js +4 -0
- package/dictionary/optimist.js +3 -0
- package/dictionary/passport-local.js +3 -0
- package/dictionary/passport.js +3 -0
- package/dictionary/pg-cursor.js +3 -0
- package/dictionary/pg-query-stream.js +3 -0
- package/dictionary/pg-types.js +7 -0
- package/dictionary/pg.js +7 -0
- package/dictionary/pg.js.js +7 -0
- package/dictionary/pgpass.js +7 -0
- package/dictionary/phantom.js +19 -0
- package/dictionary/phantomjs-prebuilt.js +16 -0
- package/dictionary/pkginfo.js +3 -0
- package/dictionary/pm2.js +7 -0
- package/dictionary/pmx.js +3 -0
- package/dictionary/pouchdb.js +3 -0
- package/dictionary/primus-emitter.js +3 -0
- package/dictionary/primus-spark-latency.js +3 -0
- package/dictionary/primus.js +3 -0
- package/dictionary/publicsuffixlist.js +15 -0
- package/dictionary/pug.js +3 -0
- package/dictionary/punt.js +3 -0
- package/dictionary/puppeteer.js +13 -0
- package/dictionary/pwd.js +3 -0
- package/dictionary/q.js +3 -0
- package/dictionary/raven.js +3 -0
- package/dictionary/rc.js +12 -0
- package/dictionary/readable-stream.js +3 -0
- package/dictionary/rechoir.js +3 -0
- package/dictionary/redis-parser.js +3 -0
- package/dictionary/redis.js +3 -0
- package/dictionary/regression.js +3 -0
- package/dictionary/reload.js +7 -0
- package/dictionary/request.js +3 -0
- package/dictionary/require-uncached.js +3 -0
- package/dictionary/require_optional.js +3 -0
- package/dictionary/s3.js +3 -0
- package/dictionary/safe_datejs.js +3 -0
- package/dictionary/sails.js +33 -0
- package/dictionary/sax.js +3 -0
- package/dictionary/scrypt.js +3 -0
- package/dictionary/semver.js +3 -0
- package/dictionary/sequelize.js +7 -0
- package/dictionary/serialport.js +3 -0
- package/dictionary/sha3.js +3 -0
- package/dictionary/sharp.js +11 -0
- package/dictionary/shelljs.js +7 -0
- package/dictionary/sinon.js +3 -0
- package/dictionary/socket.io-client.js +13 -0
- package/dictionary/socket.io.js +12 -0
- package/dictionary/sqip.js +7 -0
- package/dictionary/sqlite3.js +7 -0
- package/dictionary/steam-crypto.js +7 -0
- package/dictionary/steam-resources.js +19 -0
- package/dictionary/steam.js +3 -0
- package/dictionary/stripe-webhook-middleware.js +3 -0
- package/dictionary/stripe.js +3 -0
- package/dictionary/strong-globalize.js +3 -0
- package/dictionary/stylus.js +14 -0
- package/dictionary/supervisor.js +3 -0
- package/dictionary/svgo.js +8 -0
- package/dictionary/tabtab.js +3 -0
- package/dictionary/tesseract.js.js +7 -0
- package/dictionary/thread-stream.js +7 -0
- package/dictionary/throng.js +3 -0
- package/dictionary/time.js +3 -0
- package/dictionary/tinify.js +7 -0
- package/dictionary/tiny-worker.js +7 -0
- package/dictionary/tmp.js +3 -0
- package/dictionary/transformers.js +3 -0
- package/dictionary/uglify-js.js +9 -0
- package/dictionary/umd.js +19 -0
- package/dictionary/underscore.js +3 -0
- package/dictionary/union.js +3 -0
- package/dictionary/update-notifier.js +3 -0
- package/dictionary/usage.js +7 -0
- package/dictionary/v8flags.js +13 -0
- package/dictionary/verror.js +3 -0
- package/dictionary/voc.js +3 -0
- package/dictionary/webdriverio.js +7 -0
- package/dictionary/winston-uber.js +7 -0
- package/dictionary/winston.js +7 -0
- package/dictionary/ws.js +3 -0
- package/dictionary/xlsx.js +16 -0
- package/dictionary/xml2js.js +3 -0
- package/dictionary/yargs.js +3 -0
- package/dictionary/zeromq.js +13 -0
- package/lib-es5/addon-extract.js +164 -0
- package/lib-es5/analyzer.js +687 -0
- package/lib-es5/app-bundle.js +133 -0
- package/lib-es5/appdir.js +265 -0
- package/lib-es5/bin.js +304 -0
- package/lib-es5/bootstrap.js +179 -0
- package/lib-es5/bundler.js +496 -0
- package/lib-es5/chmod.js +15 -0
- package/lib-es5/colors.js +12 -0
- package/lib-es5/commands.js +376 -0
- package/lib-es5/common.js +328 -0
- package/lib-es5/compress_type.js +10 -0
- package/lib-es5/config.js +291 -0
- package/lib-es5/detector.js +421 -0
- package/lib-es5/esm-hooks.js +366 -0
- package/lib-es5/esm-resolver.js +292 -0
- package/lib-es5/esm-transformer.js +378 -0
- package/lib-es5/exports-resolver.js +184 -0
- package/lib-es5/external-artifacts.js +170 -0
- package/lib-es5/fabricator.js +137 -0
- package/lib-es5/follow.js +190 -0
- package/lib-es5/help.js +52 -0
- package/lib-es5/index.d.ts +2 -0
- package/lib-es5/index.js +552 -0
- package/lib-es5/log.js +7 -0
- package/lib-es5/mach-o.js +262 -0
- package/lib-es5/manifest.js +21 -0
- package/lib-es5/options.js +19 -0
- package/lib-es5/packager.js +1036 -0
- package/lib-es5/packer.js +137 -0
- package/lib-es5/pe-metadata.js +130 -0
- package/lib-es5/producer.js +378 -0
- package/lib-es5/refiner.js +87 -0
- package/lib-es5/resolver.js +142 -0
- package/lib-es5/runtime-diagnostics.js +172 -0
- package/lib-es5/sea.js +307 -0
- package/lib-es5/snapshot-fs-patch.js +396 -0
- package/lib-es5/snapshot-fs.js +255 -0
- package/lib-es5/snapshot-index.js +135 -0
- package/lib-es5/snapshot-path.js +168 -0
- package/lib-es5/types.js +9 -0
- package/lib-es5/walker.js +1019 -0
- package/lib-es5/windows-sign.js +139 -0
- package/package.json +99 -0
- package/prelude/bootstrap.js +2263 -0
- package/prelude/diagnostic.js +147 -0
package/lib-es5/bin.js
ADDED
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
+
};
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
const fs_1 = require("fs");
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
const minimist_1 = __importDefault(require("minimist"));
|
|
10
|
+
const log_1 = require("./log");
|
|
11
|
+
const packager_1 = require("./packager");
|
|
12
|
+
const commands_1 = require("./commands");
|
|
13
|
+
const config_1 = require("./config");
|
|
14
|
+
const { version } = JSON.parse((0, fs_1.readFileSync)(path_1.default.join(__dirname, '../package.json'), 'utf-8'));
|
|
15
|
+
const USAGE = `
|
|
16
|
+
hakobu v${version} — Package Node.js projects into executables
|
|
17
|
+
|
|
18
|
+
Usage:
|
|
19
|
+
hakobu <project-root> Package a project
|
|
20
|
+
hakobu targets Show available targets and cache
|
|
21
|
+
hakobu inspect <project-root> Analyze a project without packaging
|
|
22
|
+
hakobu doctor <project-root> [--target] Check if a project is ready to package
|
|
23
|
+
|
|
24
|
+
Options:
|
|
25
|
+
--target <spec> Target(s), comma-separated (e.g., node24-linux-x64,node24-win-x64)
|
|
26
|
+
Use 'all' for all published targets. Default: host
|
|
27
|
+
--output <path> Output executable path
|
|
28
|
+
--entry <file> Entry file (relative to project root)
|
|
29
|
+
--help, -h Show this help
|
|
30
|
+
--version, -v Show version
|
|
31
|
+
--debug, -d Show detailed packaging diagnostics
|
|
32
|
+
|
|
33
|
+
Bundle mode (optional — for TypeScript / monorepo projects):
|
|
34
|
+
--bundle [name] Pre-bundle with Rolldown before packaging
|
|
35
|
+
--external <mod> Keep module external when bundling (repeatable)
|
|
36
|
+
|
|
37
|
+
Advanced:
|
|
38
|
+
--bytecode Compile JS to V8 bytecode before packaging
|
|
39
|
+
--compress <algo> Compress snapshot payload (Brotli or GZip)
|
|
40
|
+
--options <flags> Bake V8 flags into executable (comma-separated)
|
|
41
|
+
--build, -b Force local build of base binary (skip download)
|
|
42
|
+
Example: --options "expose-gc,max-heap-size=34"
|
|
43
|
+
--app-bundle Wrap macOS output in a .app bundle (macOS only)
|
|
44
|
+
Output path becomes the .app directory
|
|
45
|
+
--appdir Wrap Linux output in an AppDir (Linux only)
|
|
46
|
+
Output path becomes the .AppDir directory
|
|
47
|
+
--appimage Build an AppImage from AppDir (Linux only)
|
|
48
|
+
Requires external appimagetool in PATH
|
|
49
|
+
|
|
50
|
+
macOS bundle metadata (used with --app-bundle):
|
|
51
|
+
--bundle-id <id> CFBundleIdentifier (e.g., com.example.my-app)
|
|
52
|
+
--bundle-version <v> CFBundleVersion (e.g., 1.2.3)
|
|
53
|
+
--short-version <v> CFBundleShortVersionString (defaults to bundle-version)
|
|
54
|
+
--display-name <n> CFBundleDisplayName
|
|
55
|
+
--copyright <s> NSHumanReadableCopyright
|
|
56
|
+
--macos-icon <path> Path to .icns file for the app icon
|
|
57
|
+
Also configurable via "hakobu.macos" in package.json
|
|
58
|
+
|
|
59
|
+
Linux AppDir metadata (used with --appdir):
|
|
60
|
+
--desktop-name <n> Application name in .desktop file
|
|
61
|
+
--desktop-comment <s> Short description / tooltip
|
|
62
|
+
--desktop-categories <c> Semicolon-separated categories (e.g., Utility;Development;)
|
|
63
|
+
--desktop-terminal App needs a terminal (default: true)
|
|
64
|
+
--no-desktop-terminal App does not need a terminal
|
|
65
|
+
--linux-icon <path> Path to .png file for the app icon
|
|
66
|
+
Also configurable via "hakobu.linux" in package.json
|
|
67
|
+
|
|
68
|
+
Signing:
|
|
69
|
+
--sign-identity <id> macOS code-signing identity (default: ad-hoc)
|
|
70
|
+
Also: HAKOBU_SIGN_IDENTITY env var
|
|
71
|
+
--notarize Submit to Apple notarization after signing
|
|
72
|
+
Requires: HAKOBU_APPLE_ID, HAKOBU_APPLE_PASSWORD,
|
|
73
|
+
HAKOBU_APPLE_TEAM_ID env vars
|
|
74
|
+
See docs/macos-notarization.md
|
|
75
|
+
--win-cert <path> Windows Authenticode .pfx/.p12 certificate
|
|
76
|
+
Also: HAKOBU_WIN_CERT env var
|
|
77
|
+
--win-cert-password Certificate password
|
|
78
|
+
Also: HAKOBU_WIN_CERT_PASSWORD env var
|
|
79
|
+
See docs/windows-signing.md
|
|
80
|
+
|
|
81
|
+
Windows metadata (PE VERSIONINFO):
|
|
82
|
+
--product-name <n> Product name in file properties
|
|
83
|
+
--file-description <d> Description shown in Task Manager
|
|
84
|
+
--company-name <n> Company / publisher name
|
|
85
|
+
--file-version <v> File version (e.g., 1.2.3)
|
|
86
|
+
--product-version <v> Product version (defaults to file version)
|
|
87
|
+
--icon <path> .ico file to embed as application icon
|
|
88
|
+
See docs/exe-metadata.md
|
|
89
|
+
|
|
90
|
+
Without --bundle, Hakobu packages JS files directly (native mode).
|
|
91
|
+
With --bundle, Rolldown compiles TS and resolves dependencies first.
|
|
92
|
+
See docs/bundle-mode.md for semantic differences and caveats.
|
|
93
|
+
|
|
94
|
+
Config:
|
|
95
|
+
Hakobu reads the "hakobu" field from package.json:
|
|
96
|
+
{ "hakobu": { "entry": "src/index.js", "assets": ["templates/**"] } }
|
|
97
|
+
|
|
98
|
+
Legacy "pkg" config is accepted with migration warnings.
|
|
99
|
+
CLI flags override package.json config.
|
|
100
|
+
|
|
101
|
+
Examples:
|
|
102
|
+
hakobu ./my-app --output ./dist/app Native mode
|
|
103
|
+
hakobu ./my-ts-app --bundle --output ./dist/app Bundle mode
|
|
104
|
+
hakobu ./app --bundle --entry src/cli.ts --external electron
|
|
105
|
+
`.trim();
|
|
106
|
+
function printConfigWarnings(warnings) {
|
|
107
|
+
let hasUnsupported = false;
|
|
108
|
+
for (const w of warnings) {
|
|
109
|
+
if (w.type === 'unsupported') {
|
|
110
|
+
log_1.log.error(`[config] ${w.message}`);
|
|
111
|
+
hasUnsupported = true;
|
|
112
|
+
}
|
|
113
|
+
else if (w.type === 'deprecated') {
|
|
114
|
+
log_1.log.warn(`[config] ${w.message}`);
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
log_1.log.info(`[config] ${w.message}`);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
return hasUnsupported;
|
|
121
|
+
}
|
|
122
|
+
async function main() {
|
|
123
|
+
if (process.env.CHDIR && process.env.CHDIR !== process.cwd()) {
|
|
124
|
+
process.chdir(process.env.CHDIR);
|
|
125
|
+
}
|
|
126
|
+
const argv = (0, minimist_1.default)(process.argv.slice(2), {
|
|
127
|
+
string: ['target', 'targets', 'output', 'entry', 'external', 'config',
|
|
128
|
+
'out-path', 'outdir', 'out-dir', 'compress', 'public-packages',
|
|
129
|
+
'options', 'no-dict', 'sign-identity', 'win-cert', 'win-cert-password',
|
|
130
|
+
'product-name', 'file-description', 'company-name', 'file-version',
|
|
131
|
+
'product-version', 'icon',
|
|
132
|
+
'bundle-id', 'bundle-version', 'short-version', 'display-name', 'copyright',
|
|
133
|
+
'macos-icon', 'desktop-name', 'desktop-comment', 'desktop-categories',
|
|
134
|
+
'linux-icon'],
|
|
135
|
+
boolean: ['help', 'version', 'bytecode', 'no-bytecode', 'build', 'public', 'sea',
|
|
136
|
+
'no-native-build', 'notarize', 'app-bundle', 'appdir',
|
|
137
|
+
'desktop-terminal', 'no-desktop-terminal', 'appimage'],
|
|
138
|
+
alias: { h: 'help', v: 'version', o: 'output', t: 'target',
|
|
139
|
+
c: 'config', b: 'build', d: 'debug', C: 'compress' },
|
|
140
|
+
});
|
|
141
|
+
if (argv.version) {
|
|
142
|
+
console.log(version);
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
if (argv.help || argv._.length === 0) {
|
|
146
|
+
console.log(USAGE);
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
// Debug mode — activates verbose logging throughout the pipeline
|
|
150
|
+
if (argv.debug) {
|
|
151
|
+
log_1.log.debugMode = true;
|
|
152
|
+
}
|
|
153
|
+
const command = argv._[0];
|
|
154
|
+
switch (command) {
|
|
155
|
+
case 'targets':
|
|
156
|
+
await (0, commands_1.commandTargets)();
|
|
157
|
+
break;
|
|
158
|
+
case 'inspect':
|
|
159
|
+
await (0, commands_1.commandInspect)(argv._[1] || '.');
|
|
160
|
+
break;
|
|
161
|
+
case 'doctor':
|
|
162
|
+
await (0, commands_1.commandDoctor)(argv._[1] || '.', argv.target);
|
|
163
|
+
break;
|
|
164
|
+
default: {
|
|
165
|
+
const { options, warnings } = (0, config_1.normalizeConfig)({
|
|
166
|
+
projectRoot: path_1.default.resolve(command),
|
|
167
|
+
entry: argv.entry,
|
|
168
|
+
target: argv.target,
|
|
169
|
+
output: argv.output,
|
|
170
|
+
bundle: argv.bundle,
|
|
171
|
+
external: argv.external,
|
|
172
|
+
bytecode: argv.bytecode,
|
|
173
|
+
// Legacy aliases
|
|
174
|
+
targets: argv.targets,
|
|
175
|
+
config: argv.config,
|
|
176
|
+
'out-path': argv['out-path'],
|
|
177
|
+
outdir: argv.outdir,
|
|
178
|
+
'out-dir': argv['out-dir'],
|
|
179
|
+
'no-bytecode': argv['no-bytecode'],
|
|
180
|
+
compress: argv.compress,
|
|
181
|
+
build: argv.build,
|
|
182
|
+
public: argv.public,
|
|
183
|
+
'public-packages': argv['public-packages'],
|
|
184
|
+
sea: argv.sea,
|
|
185
|
+
options: argv.options,
|
|
186
|
+
'no-native-build': argv['no-native-build'],
|
|
187
|
+
'no-dict': argv['no-dict'],
|
|
188
|
+
});
|
|
189
|
+
const hasUnsupported = printConfigWarnings(warnings);
|
|
190
|
+
if (hasUnsupported) {
|
|
191
|
+
log_1.log.error('Unsupported options detected. Remove them or see migration guidance above.');
|
|
192
|
+
process.exit(1);
|
|
193
|
+
}
|
|
194
|
+
// Detect multi-target: comma-separated --target or 'all'
|
|
195
|
+
const targetStr = options.target || '';
|
|
196
|
+
const isMulti = targetStr.includes(',') || targetStr === 'all';
|
|
197
|
+
// Signing options
|
|
198
|
+
if (argv['sign-identity'])
|
|
199
|
+
options.signIdentity = argv['sign-identity'];
|
|
200
|
+
if (argv.notarize)
|
|
201
|
+
options.notarize = true;
|
|
202
|
+
if (argv['win-cert'])
|
|
203
|
+
options.winCertPath = argv['win-cert'];
|
|
204
|
+
if (argv['win-cert-password'])
|
|
205
|
+
options.winCertPassword = argv['win-cert-password'];
|
|
206
|
+
// App bundle / AppDir
|
|
207
|
+
if (argv['app-bundle'])
|
|
208
|
+
options.appBundle = true;
|
|
209
|
+
if (argv.appdir)
|
|
210
|
+
options.appDir = true;
|
|
211
|
+
if (argv.appimage)
|
|
212
|
+
options.appImage = true;
|
|
213
|
+
// macOS bundle metadata — CLI flags override config
|
|
214
|
+
const cliMacos = {};
|
|
215
|
+
if (argv['bundle-id'])
|
|
216
|
+
cliMacos.bundleId = argv['bundle-id'];
|
|
217
|
+
if (argv['bundle-version'])
|
|
218
|
+
cliMacos.bundleVersion = argv['bundle-version'];
|
|
219
|
+
if (argv['short-version'])
|
|
220
|
+
cliMacos.shortVersion = argv['short-version'];
|
|
221
|
+
if (argv['display-name'])
|
|
222
|
+
cliMacos.displayName = argv['display-name'];
|
|
223
|
+
if (argv.copyright)
|
|
224
|
+
cliMacos.copyright = argv.copyright;
|
|
225
|
+
if (argv['macos-icon'])
|
|
226
|
+
cliMacos.icon = argv['macos-icon'];
|
|
227
|
+
if (Object.keys(cliMacos).length > 0) {
|
|
228
|
+
options.macos = { ...options.macos, ...cliMacos };
|
|
229
|
+
}
|
|
230
|
+
// Linux desktop metadata — CLI flags override config
|
|
231
|
+
const cliLinux = {};
|
|
232
|
+
if (argv['desktop-name'])
|
|
233
|
+
cliLinux.name = argv['desktop-name'];
|
|
234
|
+
if (argv['desktop-comment'])
|
|
235
|
+
cliLinux.comment = argv['desktop-comment'];
|
|
236
|
+
if (argv['desktop-categories'])
|
|
237
|
+
cliLinux.categories = argv['desktop-categories'];
|
|
238
|
+
if (argv['desktop-terminal'])
|
|
239
|
+
cliLinux.terminal = true;
|
|
240
|
+
if (argv['no-desktop-terminal'])
|
|
241
|
+
cliLinux.terminal = false;
|
|
242
|
+
if (argv['linux-icon'])
|
|
243
|
+
cliLinux.iconPath = argv['linux-icon'];
|
|
244
|
+
if (Object.keys(cliLinux).length > 0) {
|
|
245
|
+
options.linux = { ...options.linux, ...cliLinux };
|
|
246
|
+
}
|
|
247
|
+
// PE metadata — CLI flags override config
|
|
248
|
+
const cliMeta = {};
|
|
249
|
+
if (argv['product-name'])
|
|
250
|
+
cliMeta.productName = argv['product-name'];
|
|
251
|
+
if (argv['file-description'])
|
|
252
|
+
cliMeta.fileDescription = argv['file-description'];
|
|
253
|
+
if (argv['company-name'])
|
|
254
|
+
cliMeta.companyName = argv['company-name'];
|
|
255
|
+
if (argv['file-version'])
|
|
256
|
+
cliMeta.fileVersion = argv['file-version'];
|
|
257
|
+
if (argv['product-version'])
|
|
258
|
+
cliMeta.productVersion = argv['product-version'];
|
|
259
|
+
if (argv.icon)
|
|
260
|
+
cliMeta.icon = argv.icon;
|
|
261
|
+
if (Object.keys(cliMeta).length > 0) {
|
|
262
|
+
options.metadata = { ...options.metadata, ...cliMeta };
|
|
263
|
+
}
|
|
264
|
+
if (isMulti) {
|
|
265
|
+
const results = await (0, packager_1.packageMultiple)({
|
|
266
|
+
projectRoot: options.projectRoot,
|
|
267
|
+
targets: [targetStr],
|
|
268
|
+
outputDir: options.output,
|
|
269
|
+
entry: options.entry,
|
|
270
|
+
assets: options.assets,
|
|
271
|
+
externals: options.externals,
|
|
272
|
+
bundle: options.bundle,
|
|
273
|
+
bundleExternal: options.bundleExternal,
|
|
274
|
+
signIdentity: options.signIdentity,
|
|
275
|
+
notarize: options.notarize,
|
|
276
|
+
winCertPath: options.winCertPath,
|
|
277
|
+
winCertPassword: options.winCertPassword,
|
|
278
|
+
metadata: options.metadata,
|
|
279
|
+
appBundle: options.appBundle,
|
|
280
|
+
macos: options.macos,
|
|
281
|
+
appDir: options.appDir,
|
|
282
|
+
linux: options.linux,
|
|
283
|
+
appImage: options.appImage,
|
|
284
|
+
compress: options.compress,
|
|
285
|
+
options: options.options,
|
|
286
|
+
forceBuild: options.forceBuild,
|
|
287
|
+
});
|
|
288
|
+
const failed = results.filter(r => r.status === 'failed');
|
|
289
|
+
if (failed.length > 0)
|
|
290
|
+
process.exit(1);
|
|
291
|
+
}
|
|
292
|
+
else {
|
|
293
|
+
await (0, packager_1.packageApp)(options);
|
|
294
|
+
}
|
|
295
|
+
break;
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
main().catch((error) => {
|
|
300
|
+
if (!error.wasReported)
|
|
301
|
+
log_1.log.error(error);
|
|
302
|
+
process.exit(2);
|
|
303
|
+
});
|
|
304
|
+
//# sourceMappingURL=bin.js.map
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Hakobu Runtime Bootstrap
|
|
4
|
+
*
|
|
5
|
+
* Initializes the snapshot filesystem and loads the packaged entrypoint.
|
|
6
|
+
*
|
|
7
|
+
* Startup sequence:
|
|
8
|
+
* 1. Mount the snapshot FS (patch Node's fs module)
|
|
9
|
+
* 2. Determine entry format (ESM or CJS)
|
|
10
|
+
* 3. For ESM: register loader hooks via module.register(), then import()
|
|
11
|
+
* 4. For CJS: require() the entry directly
|
|
12
|
+
*/
|
|
13
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.determineBootstrapMode = exports.bootstrap = void 0;
|
|
18
|
+
const node_module_1 = require("node:module");
|
|
19
|
+
const node_module_2 = __importDefault(require("node:module"));
|
|
20
|
+
const node_url_1 = require("node:url");
|
|
21
|
+
const snapshot_fs_patch_1 = require("./snapshot-fs-patch");
|
|
22
|
+
const snapshot_path_1 = require("./snapshot-path");
|
|
23
|
+
const esm_hooks_1 = require("./esm-hooks");
|
|
24
|
+
// ─────────────────────────────────────────────────────────────────────
|
|
25
|
+
// Bootstrap
|
|
26
|
+
// ─────────────────────────────────────────────────────────────────────
|
|
27
|
+
async function bootstrap(sfs, options) {
|
|
28
|
+
const unpatch = (0, snapshot_fs_patch_1.patchFS)(sfs);
|
|
29
|
+
const entrySnapshotPath = options?.entry ?? sfs.getEntrypoint();
|
|
30
|
+
const format = sfs.getModuleFormat(entrySnapshotPath) ?? sfs.getEntrypointFormat();
|
|
31
|
+
if (format === 'esm') {
|
|
32
|
+
return bootstrapESM(sfs, entrySnapshotPath, unpatch, options?.dryRun ?? false);
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
return bootstrapCJS(sfs, entrySnapshotPath, unpatch, options?.dryRun ?? false);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
exports.bootstrap = bootstrap;
|
|
39
|
+
// ─────────────────────────────────────────────────────────────────────
|
|
40
|
+
// ESM bootstrap — registers real loader hooks
|
|
41
|
+
// ─────────────────────────────────────────────────────────────────────
|
|
42
|
+
async function bootstrapESM(sfs, entrySnapshotPath, unpatch, dryRun) {
|
|
43
|
+
const entryUrl = (0, snapshot_path_1.toFileUrl)(entrySnapshotPath);
|
|
44
|
+
if (!dryRun) {
|
|
45
|
+
// Build the transfer data for the loader hooks
|
|
46
|
+
const transferData = buildHookTransferData(sfs);
|
|
47
|
+
// Register the ESM loader hooks via data: URL.
|
|
48
|
+
// The hooks run in Node's loader thread and receive the snapshot
|
|
49
|
+
// data via initialize(). They handle resolve + load for all
|
|
50
|
+
// snapshot-owned modules.
|
|
51
|
+
const hookSource = (0, esm_hooks_1.getHookSource)();
|
|
52
|
+
const hookUrl = `data:text/javascript,${encodeURIComponent(hookSource)}`;
|
|
53
|
+
(0, node_module_1.register)(hookUrl, {
|
|
54
|
+
parentURL: (0, node_url_1.pathToFileURL)(__filename).href,
|
|
55
|
+
data: transferData,
|
|
56
|
+
transferList: [transferData.blob],
|
|
57
|
+
});
|
|
58
|
+
// Pre-cache all CJS modules from the snapshot in Node's module
|
|
59
|
+
// cache. This is needed because Node 24's CJS translator creates
|
|
60
|
+
// its own require() that doesn't go through the hooks for nested
|
|
61
|
+
// CJS requires. By pre-caching, require() finds the module in
|
|
62
|
+
// cache and skips the file-existence validation.
|
|
63
|
+
preloadCJSModules(sfs);
|
|
64
|
+
// Now import the entry. The registered hooks will handle
|
|
65
|
+
// resolution and loading for ESM snapshot modules.
|
|
66
|
+
//
|
|
67
|
+
// Use Function constructor to get the real import() that goes
|
|
68
|
+
// through the ESM loader, not TypeScript's CJS-compiled require().
|
|
69
|
+
const dynamicImport = new Function('url', 'return import(url)');
|
|
70
|
+
await dynamicImport(entryUrl);
|
|
71
|
+
}
|
|
72
|
+
return {
|
|
73
|
+
mode: 'esm',
|
|
74
|
+
entrypoint: entrySnapshotPath,
|
|
75
|
+
entryUrl,
|
|
76
|
+
unpatch,
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
// ─────────────────────────────────────────────────────────────────────
|
|
80
|
+
// CJS bootstrap
|
|
81
|
+
// ─────────────────────────────────────────────────────────────────────
|
|
82
|
+
async function bootstrapCJS(sfs, entrySnapshotPath, unpatch, dryRun) {
|
|
83
|
+
const nativePath = (0, snapshot_path_1.toNative)(entrySnapshotPath);
|
|
84
|
+
if (!dryRun) {
|
|
85
|
+
// CJS entry is loaded directly via require(). The patched
|
|
86
|
+
// Module._resolveFilename + Module._compile handle snapshot
|
|
87
|
+
// resolution and source loading. No preloading needed.
|
|
88
|
+
require(nativePath);
|
|
89
|
+
}
|
|
90
|
+
return {
|
|
91
|
+
mode: 'cjs',
|
|
92
|
+
entrypoint: entrySnapshotPath,
|
|
93
|
+
entryUrl: null,
|
|
94
|
+
unpatch,
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
// ─────────────────────────────────────────────────────────────────────
|
|
98
|
+
// Hook data builder
|
|
99
|
+
// ─────────────────────────────────────────────────────────────────────
|
|
100
|
+
function buildHookTransferData(sfs) {
|
|
101
|
+
const index = sfs.index;
|
|
102
|
+
// Build entries map: path → { offset, size, format }
|
|
103
|
+
const entries = {};
|
|
104
|
+
for (const entry of index.entries) {
|
|
105
|
+
entries[entry.path] = {
|
|
106
|
+
offset: entry.offset,
|
|
107
|
+
size: entry.size,
|
|
108
|
+
format: entry.format,
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
// Build packages map: path → { type, main, directory }
|
|
112
|
+
const packages = {};
|
|
113
|
+
for (const [path, pkg] of Object.entries(index.packages)) {
|
|
114
|
+
packages[path] = {
|
|
115
|
+
type: pkg.type,
|
|
116
|
+
main: pkg.main,
|
|
117
|
+
directory: pkg.directory,
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
// Get directory paths for existence checks
|
|
121
|
+
const directories = Object.keys(index.directories);
|
|
122
|
+
// Copy the blob to a transferable ArrayBuffer
|
|
123
|
+
const blob = sfs.blob;
|
|
124
|
+
const blobCopy = new ArrayBuffer(blob.length);
|
|
125
|
+
new Uint8Array(blobCopy).set(blob);
|
|
126
|
+
return {
|
|
127
|
+
entries,
|
|
128
|
+
packages,
|
|
129
|
+
blob: blobCopy,
|
|
130
|
+
appId: index.appId,
|
|
131
|
+
directories,
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
// ─────────────────────────────────────────────────────────────────────
|
|
135
|
+
// CJS preloading
|
|
136
|
+
// ─────────────────────────────────────────────────────────────────────
|
|
137
|
+
/**
|
|
138
|
+
* Pre-populate Node's CJS module cache for JSON/package.json files in
|
|
139
|
+
* the snapshot. CJS scripts are NOT preloaded — they're loaded lazily
|
|
140
|
+
* when require() is called, using the _resolveFilename + _compile
|
|
141
|
+
* patches on the main thread.
|
|
142
|
+
*
|
|
143
|
+
* JSON files are preloaded eagerly because they have no side effects
|
|
144
|
+
* and are frequently needed for package resolution.
|
|
145
|
+
*/
|
|
146
|
+
function preloadCJSModules(sfs) {
|
|
147
|
+
const index = sfs.index;
|
|
148
|
+
for (const entry of index.entries) {
|
|
149
|
+
// Only preload JSON files eagerly (no side effects)
|
|
150
|
+
if (entry.kind !== 'json' && entry.kind !== 'package-json')
|
|
151
|
+
continue;
|
|
152
|
+
const filename = (0, snapshot_path_1.toNative)(entry.path);
|
|
153
|
+
if (node_module_2.default._cache[filename])
|
|
154
|
+
continue;
|
|
155
|
+
try {
|
|
156
|
+
const content = sfs.readFileSync(entry.path).toString('utf8');
|
|
157
|
+
const mod = new node_module_2.default(filename, null);
|
|
158
|
+
mod.filename = filename;
|
|
159
|
+
mod.exports = JSON.parse(content);
|
|
160
|
+
mod.loaded = true;
|
|
161
|
+
node_module_2.default._cache[filename] = mod;
|
|
162
|
+
}
|
|
163
|
+
catch {
|
|
164
|
+
// Skip invalid JSON
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
// ─────────────────────────────────────────────────────────────────────
|
|
169
|
+
// Diagnostics
|
|
170
|
+
// ─────────────────────────────────────────────────────────────────────
|
|
171
|
+
function determineBootstrapMode(sfs) {
|
|
172
|
+
const entrypoint = sfs.getEntrypoint();
|
|
173
|
+
const format = sfs.getEntrypointFormat();
|
|
174
|
+
const entryUrl = (0, snapshot_path_1.toFileUrl)(entrypoint);
|
|
175
|
+
const nativePath = (0, snapshot_path_1.toNative)(entrypoint);
|
|
176
|
+
return { entrypoint, format, entryUrl, nativePath };
|
|
177
|
+
}
|
|
178
|
+
exports.determineBootstrapMode = determineBootstrapMode;
|
|
179
|
+
//# sourceMappingURL=bootstrap.js.map
|