@appthreat/caxa 1.0.13 → 2.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/README.md CHANGED
@@ -1,41 +1,34 @@
1
- Forked from caxa [3.0.1](https://github.com/leafac/caxa/releases/tag/v3.0.1) with the following changes:
1
+ # caxa
2
2
 
3
- - Updated packages.
4
- - Added default excludes to ignore .git and some test directories.
5
- - Removed broken unit tests from source/index.mts.
6
- - Excluded build and binary stubs using .gitignore. The published package would include binary stubs not present in this git repository.
3
+ **Package Node.js applications into executable binaries.**
7
4
 
8
- Original README below:
5
+ This is a high-performance fork of `caxa` (v3.0.1) maintained by AppThreat. Version 2.0 introduces significant architectural changes focused on build speed, runtime performance, and supply chain security.
9
6
 
10
- <h1 align="center">caxa</h1>
11
- <h3 align="center">📦 Package Node.js applications into executable binaries 📦</h3>
7
+ ### Key Improvements in v2
12
8
 
13
- ### Why Package Node.js Applications into Executable Binaries?
9
+ - **Streaming Builds**: Eliminated the intermediate build directory. Files are streamed directly from the source to the compressed archive, halving disk I/O during the packaging process.
10
+ - **High-Performance Decompression**: Switched the runtime stub to use SIMD-accelerated Gzip (`klauspost/compress/gzip`). This significantly reduces the "Time to First Hello World" compared to standard implementations.
11
+ - **Parallel Extraction & Smart Buffering**: The runtime stub now utilizes a worker pool to extract small files (like `node_modules`) concurrently, maximizing disk I/O saturation. Large files (>1MB) are streamed synchronously to prevent memory spikes.
12
+ - **Atomic Extraction**: Implemented a lock-based extraction mechanism in the runtime stub. This prevents corruption if the application process is killed during the initial extraction.
13
+ - **SBOM Ready**: Automatically generates a `binary-metadata.json` sidecar file containing a full dependency graph (components and relationship tree). This facilitates high-fidelity SBOM generation using tools like [cdxgen](https://github.com/cdxgen/cdxgen).
14
+ - **Optimized Defaults**: Includes robust default exclusion patterns to prevent bundling git history, lock files, tests, and documentation, resulting in smaller binaries.
14
15
 
15
- - Simple deploys. Transfer the binary into a machine and run it.
16
- - Let users test an application even if they don’t have Node.js installed.
17
- - Simple installation story for command-line applications.
18
- - It’s like the much-praised distribution story of [Go](https://golang.org) programs but for Node.js.
16
+ ### How it Works
19
17
 
20
- ### Features
18
+ caxa does not compile Node.js from source or mess with V8 internals. It works by concatenating three components into a single file:
21
19
 
22
- - Works on Windows, macOS (Intel & ARM), and Linux (Intel, ARM6, ARM7, ARM64).
23
- - Simple to use. `npm install @appthreat/caxa` and call `caxa` from the command line. No need to declare which files to include; no need to bundle the application into a single file.
24
- - Supports any kind of Node.js project, including those with native modules.
25
- - Works with any Node.js version.
26
- - Packages in seconds.
27
- - Relatively small binaries. A “Hello World!” application is ~30MB, which is terrible if compared to Go’s ~2MB, and worse still if compared to C’s ~50KB, but best-in-class if compared to other packaging solutions for Node.js.
28
- - Produces `.exe`s for Windows, simple binaries for macOS/Linux, and macOS Application Bundles (`.app`).
29
- - Based on a simple but powerful idea. Implemented in ~200 lines of code.
30
- - No magic. No traversal of `require()`s trying to find which files to include; no patches to Node.js source.
20
+ 1. **Go Stub**: A small, pre-compiled Go binary responsible for bootstrapping.
21
+ 2. **Payload**: A Gzip-compressed TAR archive containing your application and the Node.js executable.
22
+ 3. **Footer**: A JSON configuration block defining the command to execute.
31
23
 
32
- ### Anti-Features
24
+ When the binary is executed, the stub reads its own file content, locates the payload, extracts it to a temporary directory (if not already cached), and executes the Node.js process.
25
+
26
+ ### Features
33
27
 
34
- - Doesn’t patch the Node.js source code.
35
- - Doesn’t build Node.js from source.
36
- - Doesn’t support cross-compilation (for example, building a Windows executable from a macOS development machine).
37
- - Doesn’t support packaging with a Node.js version different from the one that’s running caxa (for example, bundling Node.js 15 while running caxa with Node.js 14).
38
- - Doesn’t hide your JavaScript source code in any way.
28
+ - **Cross-Platform**: Supports Windows, macOS (Intel & ARM), and Linux (Intel, ARM64, ARMv6/7).
29
+ - **Zero Config**: No need to manually define assets.
30
+ - **Native Modules**: Fully supports projects with native C++ bindings (`.node` files).
31
+ - **No Magic**: Does not patch `require()`. Filesystem access works exactly as it does in a standard Node.js environment.
39
32
 
40
33
  ### Installation
41
34
 
@@ -45,72 +38,114 @@ $ npm install --save-dev @appthreat/caxa
45
38
 
46
39
  ### Usage
47
40
 
48
- #### Prepare the Project for Packaging
41
+ #### 1. Prepare the Project
42
+
43
+ Ensure your project is built (e.g., TypeScript compiled to JavaScript) and dependencies are installed.
44
+
45
+ ```bash
46
+ npm ci
47
+ npm run build
48
+ ```
49
49
 
50
- - Install any dependencies with `npm install` or `npm ci`.
51
- - Build. For example, compile TypeScript with `tsc`, bundle with webpack, and whatever else you need to get the project ready to start. Typically this is the kind of thing that goes into an [npm `prepare` script](https://docs.npmjs.com/cli/v7/using-npm/scripts#prepare-and-prepublish), so the `npm ci` from the previous point may already have taken care of this.
52
- - If there are files that shouldn’t be in the package, remove them from the directory. For example, you may wish to remove the `.git` directory.
53
- - It’s recommended that you run caxa on a Continuous Integration server. (GitHub Actions, for example, does a shallow fetch of the repository, so removing the `.git` directory becomes negligible—but you can always do that with the `--exclude` advanced option.)
50
+ #### 2. Run caxa
54
51
 
55
- #### Call caxa from the Command Line
52
+ Call `caxa` from the command line:
56
53
 
57
54
  ```console
58
- $ npx caxa --help
59
- Usage: caxa [options] <command...>
55
+ $ npx caxa --input "." --output "my-app" -- "{{caxa}}/node_modules/.bin/node" "{{caxa}}/dist/index.js"
56
+ ```
57
+
58
+ ### CLI Reference
60
59
 
61
- Package Node.js applications into executable binaries
60
+ ```text
61
+ Usage: caxa [options] <command...>
62
62
 
63
63
  Arguments:
64
- command The command to run and optional arguments to pass to the command every time the executable is called. Paths must be absolute. The ‘{{caxa}}’ placeholder is substituted for the folder from which the package runs. The ‘node’ executable is available at ‘{{caxa}}/node_modules/.bin/node’. Use double quotes to delimit the command and each argument.
64
+ command The command to run. Paths must be absolute.
65
+ The '{{caxa}}' placeholder is substituted for the extraction directory.
66
+ The 'node' executable is available at '{{caxa}}/node_modules/.bin/node'.
65
67
 
66
68
  Options:
67
69
  -i, --input <input> [Required] The input directory to package.
68
- -o, --output <output> [Required] The path where the executable will be produced. On Windows, must end in ‘.exe’. In macOS and Linux, may have no extension to produce regular binary. In macOS and Linux, may end in ‘.sh’ to use the Shell Stub, which is a bit smaller, but depends on some tools being installed on the end-user machine, for example, ‘tar’, ‘tail’, and so forth. In macOS, may end in ‘.app’ to generate a macOS Application Bundle.
69
- -F, --no-force [Advanced] Don’t overwrite output if it exists.
70
- -e, --exclude <path...> [Advanced] Paths to exclude from the build. The paths are passed to https://github.com/sindresorhus/globby and paths that match will be excluded. [Super-Advanced, Please don’t use] If you wish to emulate ‘--include’, you may use ‘--exclude "*" ".*" "!path-to-include" ...’. The problem with ‘--include’ is that if you change your project structure but forget to change the caxa invocation, then things will subtly fail only in the packaged version.
71
- -N, --no-include-node [Advanced] Don’t copy the Node.js executable to ‘{{caxa}}/node_modules/.bin/node’.
72
- -s, --stub <path> [Advanced] Path to the stub.
73
- --identifier <identifier> [Advanced] Build identifier, which is part of the path in which the application will be unpacked.
74
- -B, --no-remove-build-directory [Advanced] Remove the build directory after the build.
75
- -m, --uncompression-message <message> [Advanced] A message to show when uncompressing, for example, ‘This may take a while to run the first time, please wait...’.
70
+ -o, --output <output> [Required] The path where the executable will be produced.
71
+ On Windows, must end in '.exe'.
72
+ -F, --no-force Don't overwrite output if it exists.
73
+ -e, --exclude <path...> Paths to exclude from the build (glob patterns).
74
+ -N, --no-include-node Don't copy the Node.js executable into the package.
75
+ -s, --stub <path> Path to a custom stub.
76
+ --identifier <identifier> Build identifier used for the extraction path.
77
+ -B, --no-remove-build-directory [Legacy] Ignored in v2 due to streaming build architecture.
78
+ -m, --uncompression-message <message> A message to show to the user while uncompressing.
76
79
  -V, --version output the version number
77
80
  -h, --help display help for command
78
-
79
- Examples:
80
- Windows:
81
- > caxa --input "examples/echo-command-line-parameters" --output "echo-command-line-parameters.exe" -- "{{caxa}}/node_modules/.bin/node" "{{caxa}}/index.mjs" "some" "embedded arguments" "--an-option-thats-part-of-the-command"
82
-
83
- macOS/Linux:
84
- $ caxa --input "examples/echo-command-line-parameters" --output "echo-command-line-parameters" -- "{{caxa}}/node_modules/.bin/node" "{{caxa}}/index.mjs" "some" "embedded arguments" "--an-option-thats-part-of-the-command"
85
-
86
- macOS/Linux (Shell Stub):
87
- $ caxa --input "examples/echo-command-line-parameters" --output "echo-command-line-parameters.sh" -- "{{caxa}}/node_modules/.bin/node" "{{caxa}}/index.mjs" "some" "embedded arguments" "--an-option-thats-part-of-the-command"
88
-
89
- macOS (Application Bundle):
90
- $ caxa --input "examples/echo-command-line-parameters" --output "Echo Command Line Parameters.app" -- "{{caxa}}/node_modules/.bin/node" "{{caxa}}/index.mjs" "some" "embedded arguments" "--an-option-thats-part-of-the-command"
91
81
  ```
92
82
 
93
- Here’s [a real-world example of using caxa](https://github.com/courselore/courselore/blob/c0b541d63fc656986ebeab4af3f3dc9bc2909972/.github/workflows/main.yml). This example includes packaging for Windows, macOS, and Linux; distributing tags with GitHub Releases Assets; distributing Insiders Builds for every push with GitHub Actions Artifacts; and deploying a binary to a server with `rsync` (and publishing an npm package as well, but that’s beyond the scope of caxa).
83
+ ### Programmatic Usage
94
84
 
95
- #### Call caxa from TypeScript/JavaScript
96
-
97
- Instead of calling caxa from the command line, you may prefer to write a program that builds your application, for example:
85
+ You can invoke caxa directly from TypeScript or JavaScript build scripts.
98
86
 
99
87
  ```typescript
100
- import caxa from "caxa";
88
+ import caxa from "@appthreat/caxa";
101
89
 
102
90
  (async () => {
103
91
  await caxa({
104
- input: "examples/echo-command-line-parameters",
105
- output: "echo-command-line-parameters",
92
+ input: ".",
93
+ output: "bin/my-app",
106
94
  command: [
107
95
  "{{caxa}}/node_modules/.bin/node",
108
- "{{caxa}}/index.mjs",
109
- "some",
110
- "embedded arguments",
96
+ "{{caxa}}/dist/index.js",
97
+ "--custom-flag",
111
98
  ],
99
+ exclude: ["*.log", "tmp/**"],
112
100
  });
113
101
  })();
114
102
  ```
115
103
 
116
- You may need to inspect `process.platform` to determine which operating system you’re running and come up with the appropriate parameters.
104
+ ### Runtime Behavior
105
+
106
+ #### Temporary Directory
107
+
108
+ By default, the application extracts to the system temporary directory (`os.tmpdir()` joined with `caxa`).
109
+
110
+ To override this location (e.g., for containerized environments with read-only `/tmp`), set the environment variable `CAXA_TEMP_DIR`:
111
+
112
+ ```bash
113
+ export CAXA_TEMP_DIR=/var/opt/my-app
114
+ ./my-app
115
+ ```
116
+
117
+ #### Supply Chain Security
118
+
119
+ Every build produces a `binary-metadata.json` file alongside the executable. This file captures the full dependency graph of the packaged application, structured to align with SBOM standards.
120
+
121
+ Example `binary-metadata.json`:
122
+
123
+ ```json
124
+ {
125
+ "components": [
126
+ {
127
+ "group": "",
128
+ "name": "my-app",
129
+ "version": "1.0.0",
130
+ "purl": "pkg:npm/my-app@1.0.0"
131
+ },
132
+ {
133
+ "group": "",
134
+ "name": "commander",
135
+ "version": "12.0.0",
136
+ "purl": "pkg:npm/commander@12.0.0"
137
+ }
138
+ ],
139
+ "dependencies": [
140
+ {
141
+ "ref": "pkg:npm/my-app@1.0.0",
142
+ "dependsOn": ["pkg:npm/commander@12.0.0"]
143
+ }
144
+ ]
145
+ }
146
+ ```
147
+
148
+ ### Anti-Features
149
+
150
+ - **No Source Hiding**: This is a packaging tool, not an obfuscator. The source code is extracted to the disk at runtime.
151
+ - **No Cross-Compilation**: The machine running `caxa` must have the same architecture/OS as the target if you want to bundle the _correct_ Node.js binary. You cannot bundle a Windows Node.js executable from a macOS machine (unless you provide it manually via custom scripts).
package/build/index.d.mts CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import fs from "fs-extra";
3
- export default function caxa({ input, output, command, force, exclude, filter, includeNode, stub, identifier, removeBuildDirectory, uncompressionMessage, }: {
3
+ export default function caxa({ input, output, command, force, exclude, includeNode, stub, identifier, uncompressionMessage, }: {
4
4
  input: string;
5
5
  output: string;
6
6
  command: string[];
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../source/index.mts"],"names":[],"mappings":";AAMA,OAAO,EAAE,MAAM,UAAU,CAAC;AA2C1B,wBAA8B,IAAI,CAAC,EACjC,KAAK,EACL,MAAM,EACN,OAAO,EACP,KAAY,EACZ,OAAyB,EACzB,MAUI,EACJ,WAAkB,EAClB,IAKC,EACD,UAGC,EACD,oBAA2B,EAC3B,oBAAoB,GACrB,EAAE;IACD,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,MAAM,CAAC,EAAE,EAAE,CAAC,cAAc,GAAG,EAAE,CAAC,eAAe,CAAC;IAChD,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,oBAAoB,CAAC,EAAE,MAAM,CAAC;CAC/B,GAAG,OAAO,CAAC,IAAI,CAAC,CA2IhB"}
1
+ {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../source/index.mts"],"names":[],"mappings":";AAKA,OAAO,EAAE,MAAM,UAAU,CAAC;AAyC1B,wBAA8B,IAAI,CAAC,EACjC,KAAK,EACL,MAAM,EACN,OAAO,EACP,KAAY,EACZ,OAAyB,EACzB,WAAkB,EAClB,IAKC,EACD,UAGC,EACD,oBAAoB,GACrB,EAAE;IACD,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,MAAM,CAAC,EAAE,EAAE,CAAC,cAAc,GAAG,EAAE,CAAC,eAAe,CAAC;IAChD,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,oBAAoB,CAAC,EAAE,MAAM,CAAC;CAC/B,GAAG,OAAO,CAAC,IAAI,CAAC,CAkPhB"}
package/build/index.mjs CHANGED
@@ -1,17 +1,14 @@
1
1
  #!/usr/bin/env node
2
2
  import path from "node:path";
3
3
  import url from "node:url";
4
- import os from "node:os";
5
4
  import stream from "node:stream/promises";
6
5
  import fs from "fs-extra";
7
- import { globbySync } from "globby";
6
+ import { globby } from "globby";
8
7
  import cryptoRandomString from "crypto-random-string";
9
8
  import bash from "dedent";
10
- import dedent from "dedent";
11
9
  import archiver from "archiver";
12
10
  import * as commander from "commander";
13
11
  import process from "node:process";
14
- // Some default excludes
15
12
  const defaultExcludes = [
16
13
  ".*",
17
14
  "*.exe",
@@ -44,37 +41,111 @@ const defaultExcludes = [
44
41
  "biome.json",
45
42
  "jest.config.js",
46
43
  ];
47
- export default async function caxa({ input, output, command, force = true, exclude = defaultExcludes, filter = (() => {
48
- if (!exclude.length) {
49
- exclude = defaultExcludes;
50
- }
51
- const pathsToExclude = globbySync(exclude, {
52
- expandDirectories: false,
53
- onlyFiles: false,
54
- }).map((pathToExclude) => path.normalize(pathToExclude));
55
- return (pathToCopy) => !pathsToExclude.includes(path.normalize(pathToCopy));
56
- })(), includeNode = true, stub = url.fileURLToPath(new URL(`../stubs/stub--${process.platform}--${process.arch}`, import.meta.url)), identifier = path.join(path.basename(path.basename(path.basename(output, ".exe"), ".app"), ".sh"), cryptoRandomString({ length: 10, type: "alphanumeric" }).toLowerCase()), removeBuildDirectory = true, uncompressionMessage, }) {
44
+ export default async function caxa({ input, output, command, force = true, exclude = defaultExcludes, includeNode = true, stub = url.fileURLToPath(new URL(`../stubs/stub--${process.platform}--${process.arch}`, import.meta.url)), identifier = path.join(path.basename(path.basename(path.basename(output, ".exe"), ".app"), ".sh"), cryptoRandomString({ length: 10, type: "alphanumeric" }).toLowerCase()), uncompressionMessage, }) {
57
45
  if (!(await fs.pathExists(input)) || !(await fs.lstat(input)).isDirectory())
58
46
  throw new Error(`Input isn’t a directory: ‘${input}’.`);
59
47
  if ((await fs.pathExists(output)) && !force)
60
48
  throw new Error(`Output already exists: ‘${output}’.`);
61
49
  if (process.platform === "win32" && !output.endsWith(".exe"))
62
50
  throw new Error("Windows executable must end in ‘.exe’.");
63
- const buildDirectory = path.join(os.tmpdir(), "caxa", "builds", cryptoRandomString({ length: 10, type: "alphanumeric" }).toLowerCase());
64
- await fs.copy(input, buildDirectory, { filter });
65
- if (includeNode) {
66
- const node = path.join(buildDirectory, "node_modules", ".bin", path.basename(process.execPath));
67
- await fs.ensureDir(path.dirname(node));
68
- await fs.copyFile(process.execPath, node);
69
- }
70
51
  await fs.ensureDir(path.dirname(output));
71
52
  await fs.remove(output);
53
+ if (!exclude)
54
+ exclude = defaultExcludes;
55
+ const files = await globby(["**/*", ...exclude.map((e) => `!${e}`)], {
56
+ cwd: input,
57
+ onlyFiles: true,
58
+ dot: true,
59
+ followSymbolicLinks: false,
60
+ });
61
+ const components = [];
62
+ const purlLookup = new Map();
63
+ for (const file of files) {
64
+ if (path.basename(file) === "package.json") {
65
+ try {
66
+ const pkg = await fs.readJson(path.join(input, file));
67
+ if (pkg.name && pkg.version) {
68
+ let name = pkg.name;
69
+ let namespace = "";
70
+ if (name.startsWith("@")) {
71
+ const parts = name.split("/");
72
+ namespace = parts[0];
73
+ name = parts[1];
74
+ }
75
+ let purl = "pkg:npm/";
76
+ if (namespace) {
77
+ purl += `${encodeURIComponent(namespace)}/`;
78
+ }
79
+ purl += `${name}@${pkg.version}`;
80
+ purlLookup.set(pkg.name, purl);
81
+ components.push({
82
+ group: namespace,
83
+ name: name,
84
+ version: pkg.version,
85
+ purl: purl,
86
+ _rawDeps: pkg.dependencies,
87
+ });
88
+ }
89
+ }
90
+ catch (e) {
91
+ // Ignore
92
+ }
93
+ }
94
+ }
95
+ const dependencies = [];
96
+ for (const comp of components) {
97
+ const childPurls = [];
98
+ if (comp._rawDeps) {
99
+ for (const depName of Object.keys(comp._rawDeps)) {
100
+ const resolvedPurl = purlLookup.get(depName);
101
+ if (resolvedPurl) {
102
+ childPurls.push(resolvedPurl);
103
+ }
104
+ }
105
+ delete comp._rawDeps;
106
+ }
107
+ if (childPurls.length > 0) {
108
+ dependencies.push({
109
+ ref: comp.purl,
110
+ dependsOn: childPurls,
111
+ });
112
+ }
113
+ }
114
+ await fs.writeJson(path.join(path.dirname(output), "binary-metadata.json"), {
115
+ components,
116
+ dependencies,
117
+ }, { spaces: 0 });
118
+ const appendApplicationPayload = async (destination, prefix = "") => {
119
+ const archive = archiver("tar", {
120
+ gzip: true,
121
+ gzipOptions: { level: 6 },
122
+ });
123
+ const outputStream = fs.createWriteStream(destination, { flags: "a" });
124
+ archive.pipe(outputStream);
125
+ for (const file of files) {
126
+ const absPath = path.join(input, file);
127
+ let name = path.join(prefix, file);
128
+ if (process.platform === "win32") {
129
+ name = name.replace(/\\/g, "/");
130
+ }
131
+ archive.file(absPath, { name });
132
+ }
133
+ if (includeNode) {
134
+ const nodePath = process.execPath;
135
+ let nodeDest = path.join(prefix, "node_modules", ".bin", path.basename(nodePath));
136
+ if (process.platform === "win32") {
137
+ nodeDest = nodeDest.replace(/\\/g, "/");
138
+ }
139
+ archive.file(nodePath, { name: nodeDest });
140
+ }
141
+ await archive.finalize();
142
+ await stream.finished(outputStream);
143
+ };
72
144
  if (output.endsWith(".app")) {
73
145
  if (process.platform !== "darwin")
74
146
  throw new Error("macOS Application Bundles (.app) are supported in macOS only.");
75
- await fs.ensureDir(path.join(output, "Contents", "Resources"));
76
- await fs.move(buildDirectory, path.join(output, "Contents", "Resources", "application"));
77
147
  await fs.ensureDir(path.join(output, "Contents", "MacOS"));
148
+ await fs.ensureDir(path.join(output, "Contents", "Resources"));
78
149
  const name = path.basename(output, ".app");
79
150
  await fs.writeFile(path.join(output, "Contents", "MacOS", name), bash `
80
151
  #!/usr/bin/env sh
@@ -83,112 +154,81 @@ export default async function caxa({ input, output, command, force = true, exclu
83
154
  await fs.writeFile(path.join(output, "Contents", "Resources", name), bash `
84
155
  #!/usr/bin/env sh
85
156
  ${command
86
- .map((part) => `"${part.replace(/\{\{\s*caxa\s*\}\}/g, `$(dirname "$0")/application`)}"`)
157
+ .map((p) => `"${p.replace(/\{\{\s*caxa\s*}}/g, `$(dirname "$0")/application`)}"`)
87
158
  .join(" ")}
88
159
  ` + "\n", { mode: 0o755 });
160
+ const appDest = path.join(output, "Contents", "Resources", "application");
161
+ await fs.ensureDir(appDest);
162
+ for (const file of files) {
163
+ const src = path.join(input, file);
164
+ const dest = path.join(appDest, file);
165
+ await fs.copy(src, dest);
166
+ }
167
+ if (includeNode) {
168
+ const nodeDest = path.join(appDest, "node_modules", ".bin", path.basename(process.execPath));
169
+ await fs.ensureDir(path.dirname(nodeDest));
170
+ await fs.copyFile(process.execPath, nodeDest);
171
+ }
89
172
  }
90
173
  else if (output.endsWith(".sh")) {
91
174
  if (process.platform === "win32")
92
175
  throw new Error("The Shell Stub (.sh) isn’t supported in Windows.");
93
- let stub = bash `
176
+ let shellStub = bash `
94
177
  #!/usr/bin/env sh
95
- export CAXA_TEMPORARY_DIRECTORY="$(dirname $(mktemp))/caxa"
96
- export CAXA_EXTRACTION_ATTEMPT=-1
178
+ export CAXA_TMP="$(dirname $(mktemp))/caxa"
179
+ export CAXA_ID="${identifier}"
97
180
  while true
98
181
  do
99
- export CAXA_EXTRACTION_ATTEMPT=$(( CAXA_EXTRACTION_ATTEMPT + 1 ))
100
- export CAXA_LOCK="$CAXA_TEMPORARY_DIRECTORY/locks/${identifier}/$CAXA_EXTRACTION_ATTEMPT"
101
- export CAXA_APPLICATION_DIRECTORY="$CAXA_TEMPORARY_DIRECTORY/applications/${identifier}/$CAXA_EXTRACTION_ATTEMPT"
102
- if [ -d "$CAXA_APPLICATION_DIRECTORY" ]
103
- then
104
- if [ -d "$CAXA_LOCK" ]
105
- then
106
- continue
107
- else
108
- break
109
- fi
110
- else
111
- ${uncompressionMessage === undefined
112
- ? bash ``
113
- : bash `echo "${uncompressionMessage}" >&2`}
114
- mkdir -p "$CAXA_LOCK"
115
- mkdir -p "$CAXA_APPLICATION_DIRECTORY"
116
- tail -n+{{caxa-number-of-lines}} "$0" | tar -xz -C "$CAXA_APPLICATION_DIRECTORY"
117
- rmdir "$CAXA_LOCK"
118
- break
182
+ export CAXA_LOCK="$CAXA_TMP/locks/$CAXA_ID"
183
+ export CAXA_APP="$CAXA_TMP/apps/$CAXA_ID"
184
+ if [ -d "$CAXA_APP" ] && [ ! -d "$CAXA_LOCK" ]; then
185
+ break
119
186
  fi
187
+
188
+ ${uncompressionMessage ? bash `echo "${uncompressionMessage}" >&2` : ""}
189
+ mkdir -p "$CAXA_LOCK" "$CAXA_APP"
190
+
191
+ # Use atomic extraction pattern
192
+ tail -n+{{lines}} "$0" | tar -xz -C "$CAXA_APP"
193
+
194
+ rmdir "$CAXA_LOCK"
195
+ break
120
196
  done
121
197
  exec ${command
122
- .map((commandPart) => `"${commandPart.replace(/\{\{\s*caxa\s*\}\}/g, `"$CAXA_APPLICATION_DIRECTORY"`)}"`)
198
+ .map((p) => `"${p.replace(/\{\{\s*caxa\s*}}/g, `"$CAXA_APP"`)}"`)
123
199
  .join(" ")} "$@"
124
200
  ` + "\n";
125
- stub = stub.replace("{{caxa-number-of-lines}}", String(stub.split("\n").length));
126
- await fs.writeFile(output, stub, { mode: 0o755 });
127
- await appendTarballOfBuildDirectoryToOutput();
201
+ shellStub = shellStub.replace("{{lines}}", String(shellStub.split("\n").length));
202
+ await fs.writeFile(output, shellStub, { mode: 0o755 });
203
+ await appendApplicationPayload(output);
128
204
  }
129
205
  else {
130
206
  if (!(await fs.pathExists(stub)))
131
207
  throw new Error(`Stub not found (your operating system / architecture may be unsupported): ‘${stub}’`);
132
208
  await fs.copyFile(stub, output);
133
209
  await fs.chmod(output, 0o755);
134
- await appendTarballOfBuildDirectoryToOutput();
210
+ await appendApplicationPayload(output);
135
211
  await fs.appendFile(output, "\n" + JSON.stringify({ identifier, command, uncompressionMessage }));
136
212
  }
137
- if (removeBuildDirectory)
138
- await fs.remove(buildDirectory);
139
- async function appendTarballOfBuildDirectoryToOutput() {
140
- const archive = archiver("tar", { gzip: true });
141
- const archiveStream = fs.createWriteStream(output, { flags: "a" });
142
- archive.pipe(archiveStream);
143
- archive.directory(buildDirectory, false);
144
- await archive.finalize();
145
- await stream.finished(archiveStream);
146
- }
147
213
  }
148
214
  if (url.fileURLToPath(import.meta.url) === (await fs.realpath(process.argv[1])))
149
215
  await commander.program
150
216
  .name("caxa")
151
217
  .description("Package Node.js applications into executable binaries")
152
- .requiredOption("-i, --input <input>", "[Required] The input directory to package.")
153
- .requiredOption("-o, --output <output>", "[Required] The path where the executable will be produced. On Windows, must end in ‘.exe’. In macOS and Linux, may have no extension to produce regular binary. In macOS and Linux, may end in ‘.sh’ to use the Shell Stub, which is a bit smaller, but depends on some tools being installed on the end-user machine, for example, ‘tar’, ‘tail’, and so forth. In macOS, may end in ‘.app’ to generate a macOS Application Bundle.")
154
- .option("-F, --no-force", "[Advanced] Don’t overwrite output if it exists.")
155
- .option("-e, --exclude <path...>", `[Advanced] Paths to exclude from the build. The paths are passed to https://github.com/sindresorhus/globby and paths that match will be excluded. [Super-Advanced, Please don’t use] If you wish to emulate ‘--include’, you may use ‘--exclude "*" ".*" "!path-to-include" ...’. The problem with ‘--include’ is that if you change your project structure but forget to change the caxa invocation, then things will subtly fail only in the packaged version.`)
156
- .option("-N, --no-include-node", "[Advanced] Don’t copy the Node.js executable to ‘{{caxa}}/node_modules/.bin/node’.")
157
- .option("-s, --stub <path>", "[Advanced] Path to the stub.")
158
- .option("--identifier <identifier>", "[Advanced] Build identifier, which is part of the path in which the application will be unpacked.")
159
- .option("-B, --no-remove-build-directory", "[Advanced] Remove the build directory after the build.")
160
- .option("-m, --uncompression-message <message>", "[Advanced] A message to show when uncompressing, for example, ‘This may take a while to run the first time, please wait...’.")
161
- .argument("<command...>", "The command to run and optional arguments to pass to the command every time the executable is called. Paths must be absolute. The ‘{{caxa}}’ placeholder is substituted for the folder from which the package runs. The ‘node’ executable is available at ‘{{caxa}}/node_modules/.bin/node’. Use double quotes to delimit the command and each argument.")
218
+ .requiredOption("-i, --input <input>", "Input directory to package.")
219
+ .requiredOption("-o, --output <output>", "Path where the executable will be produced.")
220
+ .option("-F, --no-force", "Don’t overwrite output if it exists.")
221
+ .option("-e, --exclude <path...>", "Paths to exclude from the build.")
222
+ .option("-N, --no-include-node", "Don’t copy the Node.js executable.")
223
+ .option("-s, --stub <path>", "Path to the stub.")
224
+ .option("--identifier <id>", "Build identifier.")
225
+ .option("-B, --no-remove-build-directory", "Ignored in v2 (streaming build).")
226
+ .option("-m, --uncompression-message <msg>", "Message to show during extraction.")
227
+ .argument("<command...>", "Command to run.")
162
228
  .version(JSON.parse(await fs.readFile(new URL("../package.json", import.meta.url), "utf8")).version)
163
- .addHelpText("after", "\n" +
164
- dedent `
165
- Examples:
166
- Windows:
167
- > caxa --input "examples/echo-command-line-parameters" --output "echo-command-line-parameters.exe" -- "{{caxa}}/node_modules/.bin/node" "{{caxa}}/index.mjs" "some" "embedded arguments" "--an-option-thats-part-of-the-command"
168
-
169
- macOS/Linux:
170
- $ caxa --input "examples/echo-command-line-parameters" --output "echo-command-line-parameters" -- "{{caxa}}/node_modules/.bin/node" "{{caxa}}/index.mjs" "some" "embedded arguments" "--an-option-thats-part-of-the-command"
171
-
172
- macOS/Linux (Shell Stub):
173
- $ caxa --input "examples/echo-command-line-parameters" --output "echo-command-line-parameters.sh" -- "{{caxa}}/node_modules/.bin/node" "{{caxa}}/index.mjs" "some" "embedded arguments" "--an-option-thats-part-of-the-command"
174
-
175
- macOS (Application Bundle):
176
- $ caxa --input "examples/echo-command-line-parameters" --output "Echo Command Line Parameters.app" -- "{{caxa}}/node_modules/.bin/node" "{{caxa}}/index.mjs" "some" "embedded arguments" "--an-option-thats-part-of-the-command"
177
- `)
178
- .action(async (command, { input, output, force, exclude, includeNode, stub, identifier, removeBuildDirectory, uncompressionMessage, }) => {
229
+ .action(async (command, opts) => {
179
230
  try {
180
- await caxa({
181
- input,
182
- output,
183
- command,
184
- force,
185
- exclude,
186
- includeNode,
187
- stub,
188
- identifier,
189
- removeBuildDirectory,
190
- uncompressionMessage,
191
- });
231
+ await caxa({ command, ...opts });
192
232
  }
193
233
  catch (error) {
194
234
  console.error(error.message);
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sourceRoot":"","sources":["../source/index.mts"],"names":[],"mappings":";AAEA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,GAAG,MAAM,UAAU,CAAC;AAC3B,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,MAAM,MAAM,sBAAsB,CAAC;AAC1C,OAAO,EAAE,MAAM,UAAU,CAAC;AAC1B,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AACpC,OAAO,kBAAkB,MAAM,sBAAsB,CAAC;AACtD,OAAO,IAAI,MAAM,QAAQ,CAAC;AAC1B,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,QAAQ,MAAM,UAAU,CAAC;AAChC,OAAO,KAAK,SAAS,MAAM,WAAW,CAAC;AACvC,OAAO,OAAO,MAAM,cAAc,CAAC;AAEnC,wBAAwB;AACxB,MAAM,eAAe,GAAG;IACtB,IAAI;IACJ,OAAO;IACP,cAAc;IACd,cAAc;IACd,UAAU;IACV,UAAU;IACV,SAAS;IACT,UAAU;IACV,gBAAgB;IAChB,OAAO;IACP,eAAe;IACf,YAAY;IACZ,OAAO;IACP,MAAM;IACN,mBAAmB;IACnB,gBAAgB;IAChB,eAAe;IACf,WAAW;IACX,UAAU;IACV,SAAS;IACT,YAAY;IACZ,YAAY;IACZ,YAAY;IACZ,YAAY;IACZ,SAAS;IACT,SAAS;IACT,UAAU;IACV,UAAU;IACV,YAAY;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