@appthreat/caxa 0.0.5 → 0.0.7
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 +0 -2
- package/build/index.d.mts +1 -4
- package/build/index.d.mts.map +1 -1
- package/build/index.mjs +16 -14
- package/build/index.mjs.map +1 -1
- package/package.json +2 -3
- package/source/index.mts +14 -27
package/README.md
CHANGED
|
@@ -69,8 +69,6 @@ Options:
|
|
|
69
69
|
-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.
|
|
70
70
|
-F, --no-force [Advanced] Don’t overwrite output if it exists.
|
|
71
71
|
-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.
|
|
72
|
-
-D, --no-dedupe [Advanced] Don’t run ‘npm dedupe --production’ on the build directory.
|
|
73
|
-
-p, --prepare-command <command> [Advanced] Command to run on the build directory after ‘npm dedupe --production’, before packaging.
|
|
74
72
|
-N, --no-include-node [Advanced] Don’t copy the Node.js executable to ‘{{caxa}}/node_modules/.bin/node’.
|
|
75
73
|
-s, --stub <path> [Advanced] Path to the stub.
|
|
76
74
|
--identifier <identifier> [Advanced] Build identifier, which is part of the path in which the application will be unpacked.
|
package/build/index.d.mts
CHANGED
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import fs from "fs-extra";
|
|
3
|
-
export default function caxa({ input, output, command, force, exclude, filter,
|
|
3
|
+
export default function caxa({ input, output, command, force, exclude, filter, includeNode, stub, identifier, removeBuildDirectory, uncompressionMessage, }: {
|
|
4
4
|
input: string;
|
|
5
5
|
output: string;
|
|
6
6
|
command: string[];
|
|
7
7
|
force?: boolean;
|
|
8
8
|
exclude?: string[];
|
|
9
9
|
filter?: fs.CopyFilterSync | fs.CopyFilterAsync;
|
|
10
|
-
dedupe?: boolean;
|
|
11
|
-
prepareCommand?: string;
|
|
12
|
-
prepare?: (buildDirectory: string) => Promise<void>;
|
|
13
10
|
includeNode?: boolean;
|
|
14
11
|
stub?: string;
|
|
15
12
|
identifier?: string;
|
package/build/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../source/index.mts"],"names":[],"mappings":";AAMA,OAAO,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../source/index.mts"],"names":[],"mappings":";AAMA,OAAO,EAAE,MAAM,UAAU,CAAC;AAiC1B,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,CAyIhB"}
|
package/build/index.mjs
CHANGED
|
@@ -5,7 +5,6 @@ import os from "node:os";
|
|
|
5
5
|
import stream from "node:stream/promises";
|
|
6
6
|
import fs from "fs-extra";
|
|
7
7
|
import { globbySync } from "globby";
|
|
8
|
-
import { execa, execaCommand } from "execa";
|
|
9
8
|
import cryptoRandomString from "crypto-random-string";
|
|
10
9
|
import bash from "dedent";
|
|
11
10
|
import archiver from "archiver";
|
|
@@ -15,11 +14,25 @@ import process from "node:process";
|
|
|
15
14
|
// Some default excludes
|
|
16
15
|
const defaultExcludes = [
|
|
17
16
|
".*",
|
|
17
|
+
"*.exe",
|
|
18
|
+
"*.exe.sha256",
|
|
19
|
+
"*.yml",
|
|
20
|
+
"*.sh",
|
|
21
|
+
"package-lock.json",
|
|
22
|
+
"pnpm-lock.yaml",
|
|
23
|
+
"tsconfig.json",
|
|
24
|
+
"deno.json",
|
|
25
|
+
"jsr.json",
|
|
18
26
|
".git/**",
|
|
27
|
+
".github/**",
|
|
19
28
|
".vscode/**",
|
|
20
29
|
"**/*/*.env",
|
|
21
30
|
"docs/**",
|
|
22
31
|
"test/**",
|
|
32
|
+
"types/**",
|
|
33
|
+
"bom.json",
|
|
34
|
+
"biome.json",
|
|
35
|
+
"jest.config.js",
|
|
23
36
|
];
|
|
24
37
|
export default async function caxa({ input, output, command, force = true, exclude = defaultExcludes, filter = (() => {
|
|
25
38
|
if (!exclude.length) {
|
|
@@ -30,11 +43,7 @@ export default async function caxa({ input, output, command, force = true, exclu
|
|
|
30
43
|
onlyFiles: false,
|
|
31
44
|
}).map((pathToExclude) => path.normalize(pathToExclude));
|
|
32
45
|
return (pathToCopy) => !pathsToExclude.includes(path.normalize(pathToCopy));
|
|
33
|
-
})(),
|
|
34
|
-
if (prepareCommand === undefined)
|
|
35
|
-
return;
|
|
36
|
-
await execaCommand(prepareCommand, { cwd: buildDirectory, shell: true });
|
|
37
|
-
}, 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, }) {
|
|
46
|
+
})(), 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, }) {
|
|
38
47
|
if (!(await fs.pathExists(input)) || !(await fs.lstat(input)).isDirectory())
|
|
39
48
|
throw new Error(`Input isn’t a directory: ‘${input}’.`);
|
|
40
49
|
if ((await fs.pathExists(output)) && !force)
|
|
@@ -43,9 +52,6 @@ export default async function caxa({ input, output, command, force = true, exclu
|
|
|
43
52
|
throw new Error("Windows executable must end in ‘.exe’.");
|
|
44
53
|
const buildDirectory = path.join(os.tmpdir(), "caxa/builds", cryptoRandomString({ length: 10, type: "alphanumeric" }).toLowerCase());
|
|
45
54
|
await fs.copy(input, buildDirectory, { filter });
|
|
46
|
-
if (dedupe)
|
|
47
|
-
await execa("npm", ["dedupe", "--production"], { cwd: buildDirectory });
|
|
48
|
-
await prepare(buildDirectory);
|
|
49
55
|
if (includeNode) {
|
|
50
56
|
const node = path.join(buildDirectory, "node_modules/.bin", path.basename(process.execPath));
|
|
51
57
|
await fs.ensureDir(path.dirname(node));
|
|
@@ -137,8 +143,6 @@ if (url.fileURLToPath(import.meta.url) === (await fs.realpath(process.argv[1])))
|
|
|
137
143
|
.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.")
|
|
138
144
|
.option("-F, --no-force", "[Advanced] Don’t overwrite output if it exists.")
|
|
139
145
|
.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.`)
|
|
140
|
-
.option("--dedupe", "[Advanced] Run ‘npm dedupe --production’ on the build directory.")
|
|
141
|
-
.option("-p, --prepare-command <command>", "[Advanced] Command to run on the build directory after ‘npm dedupe --production’, before packaging.")
|
|
142
146
|
.option("-N, --no-include-node", "[Advanced] Don’t copy the Node.js executable to ‘{{caxa}}/node_modules/.bin/node’.")
|
|
143
147
|
.option("-s, --stub <path>", "[Advanced] Path to the stub.")
|
|
144
148
|
.option("--identifier <identifier>", "[Advanced] Build identifier, which is part of the path in which the application will be unpacked.")
|
|
@@ -161,7 +165,7 @@ if (url.fileURLToPath(import.meta.url) === (await fs.realpath(process.argv[1])))
|
|
|
161
165
|
macOS (Application Bundle):
|
|
162
166
|
$ 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"
|
|
163
167
|
`)
|
|
164
|
-
.action(async (command, { input, output, force, exclude,
|
|
168
|
+
.action(async (command, { input, output, force, exclude, includeNode, stub, identifier, removeBuildDirectory, uncompressionMessage, }) => {
|
|
165
169
|
try {
|
|
166
170
|
await caxa({
|
|
167
171
|
input,
|
|
@@ -169,8 +173,6 @@ if (url.fileURLToPath(import.meta.url) === (await fs.realpath(process.argv[1])))
|
|
|
169
173
|
command,
|
|
170
174
|
force,
|
|
171
175
|
exclude,
|
|
172
|
-
dedupe,
|
|
173
|
-
prepareCommand,
|
|
174
176
|
includeNode,
|
|
175
177
|
stub,
|
|
176
178
|
identifier,
|
package/build/index.mjs.map
CHANGED
|
@@ -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,
|
|
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,QAAQ,MAAM,UAAU,CAAC;AAChC,OAAO,KAAK,SAAS,MAAM,WAAW,CAAC;AACvC,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,OAAO,MAAM,cAAc,CAAC;AAEnC,wBAAwB;AACxB,MAAM,eAAe,GAAG;IACtB,IAAI;IACJ,OAAO;IACP,cAAc;IACd,OAAO;IACP,MAAM;IACN,mBAAmB;IACnB,gBAAgB;IAChB,eAAe;IACf,WAAW;IACX,UAAU;IACV,SAAS;IACT,YAAY;IACZ,YAAY;IACZ,YAAY;IACZ,SAAS;IACT,SAAS;IACT,UAAU;IACV,UAAU;IACV,YAAY;IACZ,gBAAgB;CACjB,CAAC;AAE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AAE,MAAM,CAAC,CACvE,CAAC,OAAO,CACV;SACA,WAAW,CACV,OAAO,EACP,IAAI;QACF,MAAM,CAAA;;;;;;;;;;;;;SAaL,CACJ;SACA,MAAM,CACL,KAAK,EACH,OAAiB,EACjB,EACE,KAAK,EACL,MAAM,EACN,KAAK,EACL,OAAO,EACP,WAAW,EACX,IAAI,EACJ,UAAU,EACV,oBAAoB,EACpB,oBAAoB,GAWrB,EACD,EAAE;QACF,IAAI,CAAC;YACH,MAAM,IAAI,CAAC;gBACT,KAAK;gBACL,MAAM;gBACN,OAAO;gBACP,KAAK;gBACL,OAAO;gBACP,WAAW;gBACX,IAAI;gBACJ,UAAU;gBACV,oBAAoB;gBACpB,oBAAoB;aACrB,CAAC,CAAC;QACL,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YACpB,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;YAC7B,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;IACH,CAAC,CACF;SACA,kBAAkB,EAAE;SACpB,UAAU,EAAE,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@appthreat/caxa",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.7",
|
|
4
4
|
"description": "Package Node.js applications into executable binaries",
|
|
5
5
|
"author": "Team AppThreat <cloud@appthreat.com>",
|
|
6
6
|
"homepage": "https://github.com/appthreat/caxa",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"exports": "./build/index.mjs",
|
|
19
19
|
"types": "./build/index.d.mts",
|
|
20
20
|
"bin": {
|
|
21
|
-
"caxa": "
|
|
21
|
+
"caxa": "build/index.mjs"
|
|
22
22
|
},
|
|
23
23
|
"scripts": {
|
|
24
24
|
"prepare": "cd ./source/ && tsc",
|
|
@@ -30,7 +30,6 @@
|
|
|
30
30
|
"commander": "^12.1.0",
|
|
31
31
|
"crypto-random-string": "^5.0.0",
|
|
32
32
|
"dedent": "^1.5.3",
|
|
33
|
-
"execa": "^9.4.0",
|
|
34
33
|
"fs-extra": "^11.2.0",
|
|
35
34
|
"globby": "^14.0.2"
|
|
36
35
|
},
|
package/source/index.mts
CHANGED
|
@@ -6,7 +6,6 @@ import os from "node:os";
|
|
|
6
6
|
import stream from "node:stream/promises";
|
|
7
7
|
import fs from "fs-extra";
|
|
8
8
|
import { globbySync } from "globby";
|
|
9
|
-
import { execa, execaCommand } from "execa";
|
|
10
9
|
import cryptoRandomString from "crypto-random-string";
|
|
11
10
|
import bash from "dedent";
|
|
12
11
|
import archiver from "archiver";
|
|
@@ -17,11 +16,25 @@ import process from "node:process";
|
|
|
17
16
|
// Some default excludes
|
|
18
17
|
const defaultExcludes = [
|
|
19
18
|
".*",
|
|
19
|
+
"*.exe",
|
|
20
|
+
"*.exe.sha256",
|
|
21
|
+
"*.yml",
|
|
22
|
+
"*.sh",
|
|
23
|
+
"package-lock.json",
|
|
24
|
+
"pnpm-lock.yaml",
|
|
25
|
+
"tsconfig.json",
|
|
26
|
+
"deno.json",
|
|
27
|
+
"jsr.json",
|
|
20
28
|
".git/**",
|
|
29
|
+
".github/**",
|
|
21
30
|
".vscode/**",
|
|
22
31
|
"**/*/*.env",
|
|
23
32
|
"docs/**",
|
|
24
33
|
"test/**",
|
|
34
|
+
"types/**",
|
|
35
|
+
"bom.json",
|
|
36
|
+
"biome.json",
|
|
37
|
+
"jest.config.js",
|
|
25
38
|
];
|
|
26
39
|
|
|
27
40
|
export default async function caxa({
|
|
@@ -41,12 +54,6 @@ export default async function caxa({
|
|
|
41
54
|
return (pathToCopy: string) =>
|
|
42
55
|
!pathsToExclude.includes(path.normalize(pathToCopy));
|
|
43
56
|
})(),
|
|
44
|
-
dedupe = false,
|
|
45
|
-
prepareCommand,
|
|
46
|
-
prepare = async (buildDirectory: string) => {
|
|
47
|
-
if (prepareCommand === undefined) return;
|
|
48
|
-
await execaCommand(prepareCommand, { cwd: buildDirectory, shell: true });
|
|
49
|
-
},
|
|
50
57
|
includeNode = true,
|
|
51
58
|
stub = url.fileURLToPath(
|
|
52
59
|
new URL(
|
|
@@ -67,9 +74,6 @@ export default async function caxa({
|
|
|
67
74
|
force?: boolean;
|
|
68
75
|
exclude?: string[];
|
|
69
76
|
filter?: fs.CopyFilterSync | fs.CopyFilterAsync;
|
|
70
|
-
dedupe?: boolean;
|
|
71
|
-
prepareCommand?: string;
|
|
72
|
-
prepare?: (buildDirectory: string) => Promise<void>;
|
|
73
77
|
includeNode?: boolean;
|
|
74
78
|
stub?: string;
|
|
75
79
|
identifier?: string;
|
|
@@ -89,9 +93,6 @@ export default async function caxa({
|
|
|
89
93
|
cryptoRandomString({ length: 10, type: "alphanumeric" }).toLowerCase(),
|
|
90
94
|
);
|
|
91
95
|
await fs.copy(input, buildDirectory, { filter });
|
|
92
|
-
if (dedupe)
|
|
93
|
-
await execa("npm", ["dedupe", "--production"], { cwd: buildDirectory });
|
|
94
|
-
await prepare(buildDirectory);
|
|
95
96
|
if (includeNode) {
|
|
96
97
|
const node = path.join(
|
|
97
98
|
buildDirectory,
|
|
@@ -234,14 +235,6 @@ if (url.fileURLToPath(import.meta.url) === (await fs.realpath(process.argv[1])))
|
|
|
234
235
|
"-e, --exclude <path...>",
|
|
235
236
|
`[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.`,
|
|
236
237
|
)
|
|
237
|
-
.option(
|
|
238
|
-
"--dedupe",
|
|
239
|
-
"[Advanced] Run ‘npm dedupe --production’ on the build directory.",
|
|
240
|
-
)
|
|
241
|
-
.option(
|
|
242
|
-
"-p, --prepare-command <command>",
|
|
243
|
-
"[Advanced] Command to run on the build directory after ‘npm dedupe --production’, before packaging.",
|
|
244
|
-
)
|
|
245
238
|
.option(
|
|
246
239
|
"-N, --no-include-node",
|
|
247
240
|
"[Advanced] Don’t copy the Node.js executable to ‘{{caxa}}/node_modules/.bin/node’.",
|
|
@@ -294,8 +287,6 @@ if (url.fileURLToPath(import.meta.url) === (await fs.realpath(process.argv[1])))
|
|
|
294
287
|
output,
|
|
295
288
|
force,
|
|
296
289
|
exclude,
|
|
297
|
-
dedupe,
|
|
298
|
-
prepareCommand,
|
|
299
290
|
includeNode,
|
|
300
291
|
stub,
|
|
301
292
|
identifier,
|
|
@@ -306,8 +297,6 @@ if (url.fileURLToPath(import.meta.url) === (await fs.realpath(process.argv[1])))
|
|
|
306
297
|
output: string;
|
|
307
298
|
force?: boolean;
|
|
308
299
|
exclude?: string[];
|
|
309
|
-
dedupe?: boolean;
|
|
310
|
-
prepareCommand?: string;
|
|
311
300
|
includeNode?: boolean;
|
|
312
301
|
stub?: string;
|
|
313
302
|
identifier?: string;
|
|
@@ -322,8 +311,6 @@ if (url.fileURLToPath(import.meta.url) === (await fs.realpath(process.argv[1])))
|
|
|
322
311
|
command,
|
|
323
312
|
force,
|
|
324
313
|
exclude,
|
|
325
|
-
dedupe,
|
|
326
|
-
prepareCommand,
|
|
327
314
|
includeNode,
|
|
328
315
|
stub,
|
|
329
316
|
identifier,
|