afterpack 0.0.1 → 0.0.9
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/dist/cli.js +82 -5
- package/dist/cli.js.map +1 -1
- package/package.json +15 -5
- package/readme.md +8 -9
package/dist/cli.js
CHANGED
|
@@ -1,11 +1,88 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import { existsSync, statSync } from "node:fs";
|
|
3
|
+
import { basename, extname, relative, resolve } from "node:path";
|
|
4
|
+
import { processFile, version } from "@afterpack/core";
|
|
5
|
+
|
|
2
6
|
//#region src/cli.ts
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
console.log(
|
|
7
|
+
const args = process.argv.slice(2);
|
|
8
|
+
function showBanner() {
|
|
9
|
+
console.log(`
|
|
10
|
+
╔═══════════════════════════════════════════════════════╗
|
|
11
|
+
║ AfterPack v${version().padEnd(42)}║
|
|
12
|
+
║ High-performance JavaScript obfuscator ║
|
|
13
|
+
╚═══════════════════════════════════════════════════════╝
|
|
14
|
+
`);
|
|
15
|
+
}
|
|
16
|
+
function showHelp() {
|
|
17
|
+
showBanner();
|
|
18
|
+
console.log(`
|
|
19
|
+
Usage:
|
|
20
|
+
npx afterpack <file.js> Process a JavaScript file
|
|
21
|
+
npx afterpack --version Show version
|
|
22
|
+
npx afterpack --help Show this help
|
|
23
|
+
|
|
24
|
+
Options:
|
|
25
|
+
-h, --help Show this help message
|
|
26
|
+
-v, --version Show version number
|
|
27
|
+
|
|
28
|
+
Examples:
|
|
29
|
+
npx afterpack dist/app.js
|
|
30
|
+
npx afterpack build/index.mjs
|
|
31
|
+
|
|
32
|
+
Learn more: https://afterpack.dev
|
|
33
|
+
`);
|
|
34
|
+
}
|
|
35
|
+
if (args.includes("--version") || args.includes("-v")) {
|
|
36
|
+
console.log(`AfterPack v${version()}`);
|
|
37
|
+
process.exit(0);
|
|
38
|
+
}
|
|
39
|
+
if (args.length === 0 || args.includes("--help") || args.includes("-h")) {
|
|
40
|
+
showHelp();
|
|
41
|
+
process.exit(0);
|
|
42
|
+
}
|
|
43
|
+
const files = args.filter((arg) => !arg.startsWith("-"));
|
|
44
|
+
if (files.length === 0) {
|
|
45
|
+
console.error("Error: No file specified");
|
|
46
|
+
console.error("Run 'npx afterpack --help' for usage information");
|
|
47
|
+
process.exit(1);
|
|
48
|
+
}
|
|
49
|
+
showBanner();
|
|
50
|
+
let hasErrors = false;
|
|
51
|
+
for (const file of files) {
|
|
52
|
+
const filePath = resolve(file);
|
|
53
|
+
const relativePath = relative(process.cwd(), filePath);
|
|
54
|
+
if (!existsSync(filePath)) {
|
|
55
|
+
console.error(`Error: File not found: ${relativePath}`);
|
|
56
|
+
hasErrors = true;
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
if (statSync(filePath).isDirectory()) {
|
|
60
|
+
console.error(`Error: Expected a file, got directory: ${relativePath}`);
|
|
61
|
+
console.error(" Hint: Directory processing coming soon!");
|
|
62
|
+
hasErrors = true;
|
|
63
|
+
continue;
|
|
64
|
+
}
|
|
65
|
+
const ext = extname(filePath).toLowerCase();
|
|
66
|
+
if (ext !== ".js" && ext !== ".mjs" && ext !== ".cjs") {
|
|
67
|
+
console.error(`Error: Expected JavaScript file (.js, .mjs, .cjs), got: ${basename(filePath)}`);
|
|
68
|
+
hasErrors = true;
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
try {
|
|
72
|
+
console.log(`Processing: ${relativePath}`);
|
|
73
|
+
processFile(filePath);
|
|
74
|
+
console.log(` Done!`);
|
|
75
|
+
} catch (err) {
|
|
76
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
77
|
+
console.error(`Error processing ${relativePath}: ${message}`);
|
|
78
|
+
hasErrors = true;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
6
81
|
console.log("");
|
|
7
|
-
|
|
8
|
-
console.log("
|
|
82
|
+
if (hasErrors) {
|
|
83
|
+
console.log("Completed with errors.");
|
|
84
|
+
process.exit(1);
|
|
85
|
+
} else console.log("All files processed successfully.");
|
|
9
86
|
|
|
10
87
|
//#endregion
|
|
11
88
|
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","names":[],"sources":["../src/cli.ts"],"sourcesContent":["#!/usr/bin/env node\n\nconst
|
|
1
|
+
{"version":3,"file":"cli.js","names":[],"sources":["../src/cli.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport { existsSync, statSync } from \"node:fs\";\nimport { resolve, relative, extname, basename } from \"node:path\";\n\n// Import the native addon\n// @ts-expect-error - Types will be available after @afterpack/core is published\nimport { processFile, version } from \"@afterpack/core\";\n\nconst args = process.argv.slice(2);\n\n// Banner\nfunction showBanner(): void {\n console.log(`\n ╔═══════════════════════════════════════════════════════╗\n ║ AfterPack v${version().padEnd(42)}║\n ║ High-performance JavaScript obfuscator ║\n ╚═══════════════════════════════════════════════════════╝\n`);\n}\n\n// Help text\nfunction showHelp(): void {\n showBanner();\n console.log(`\nUsage:\n npx afterpack <file.js> Process a JavaScript file\n npx afterpack --version Show version\n npx afterpack --help Show this help\n\nOptions:\n -h, --help Show this help message\n -v, --version Show version number\n\nExamples:\n npx afterpack dist/app.js\n npx afterpack build/index.mjs\n\nLearn more: https://afterpack.dev\n`);\n}\n\n// Version\nif (args.includes(\"--version\") || args.includes(\"-v\")) {\n console.log(`AfterPack v${version()}`);\n process.exit(0);\n}\n\n// Help or no args\nif (args.length === 0 || args.includes(\"--help\") || args.includes(\"-h\")) {\n showHelp();\n process.exit(0);\n}\n\n// Filter out flags\nconst files = args.filter((arg) => !arg.startsWith(\"-\"));\n\nif (files.length === 0) {\n console.error(\"Error: No file specified\");\n console.error(\"Run 'npx afterpack --help' for usage information\");\n process.exit(1);\n}\n\n// Process each file\nshowBanner();\n\nlet hasErrors = false;\n\nfor (const file of files) {\n const filePath = resolve(file);\n const relativePath = relative(process.cwd(), filePath);\n\n // Check file exists\n if (!existsSync(filePath)) {\n console.error(`Error: File not found: ${relativePath}`);\n hasErrors = true;\n continue;\n }\n\n // Check it's a file, not a directory\n if (statSync(filePath).isDirectory()) {\n console.error(`Error: Expected a file, got directory: ${relativePath}`);\n console.error(\" Hint: Directory processing coming soon!\");\n hasErrors = true;\n continue;\n }\n\n // Check extension\n const ext = extname(filePath).toLowerCase();\n if (ext !== \".js\" && ext !== \".mjs\" && ext !== \".cjs\") {\n console.error(\n `Error: Expected JavaScript file (.js, .mjs, .cjs), got: ${basename(filePath)}`\n );\n hasErrors = true;\n continue;\n }\n\n // Process the file\n try {\n console.log(`Processing: ${relativePath}`);\n processFile(filePath);\n console.log(` Done!`);\n } catch (err) {\n const message = err instanceof Error ? err.message : String(err);\n console.error(`Error processing ${relativePath}: ${message}`);\n hasErrors = true;\n }\n}\n\n// Summary\nconsole.log(\"\");\nif (hasErrors) {\n console.log(\"Completed with errors.\");\n process.exit(1);\n} else {\n console.log(\"All files processed successfully.\");\n}\n"],"mappings":";;;;;;AASA,MAAM,OAAO,QAAQ,KAAK,MAAM,EAAE;AAGlC,SAAS,aAAmB;AAC1B,SAAQ,KAAK;;kBAEG,SAAS,CAAC,OAAO,GAAG,CAAC;;;EAGrC;AACD;AAGD,SAAS,WAAiB;AACxB,aAAY;AACZ,SAAQ,KAAK;;;;;;;;;;;;;;;EAeb;AACD;AAGD,IAAI,KAAK,SAAS,YAAY,IAAI,KAAK,SAAS,KAAK,EAAE;AACrD,SAAQ,KAAK,aAAa,SAAS,CAAC,EAAE;AACtC,SAAQ,KAAK,EAAE;AAChB;AAGD,IAAI,KAAK,WAAW,KAAK,KAAK,SAAS,SAAS,IAAI,KAAK,SAAS,KAAK,EAAE;AACvE,WAAU;AACV,SAAQ,KAAK,EAAE;AAChB;AAGD,MAAM,QAAQ,KAAK,OAAO,CAAC,SAAS,IAAI,WAAW,IAAI,CAAC;AAExD,IAAI,MAAM,WAAW,GAAG;AACtB,SAAQ,MAAM,2BAA2B;AACzC,SAAQ,MAAM,mDAAmD;AACjE,SAAQ,KAAK,EAAE;AAChB;AAGD,YAAY;AAEZ,IAAI,YAAY;AAEhB,KAAK,MAAM,QAAQ,OAAO;CACxB,MAAM,WAAW,QAAQ,KAAK;CAC9B,MAAM,eAAe,SAAS,QAAQ,KAAK,EAAE,SAAS;AAGtD,MAAK,WAAW,SAAS,EAAE;AACzB,UAAQ,OAAO,yBAAyB,aAAa,EAAE;AACvD,cAAY;AACZ;CACD;AAGD,KAAI,SAAS,SAAS,CAAC,aAAa,EAAE;AACpC,UAAQ,OAAO,yCAAyC,aAAa,EAAE;AACvE,UAAQ,MAAM,4CAA4C;AAC1D,cAAY;AACZ;CACD;CAGD,MAAM,MAAM,QAAQ,SAAS,CAAC,aAAa;AAC3C,KAAI,QAAQ,SAAS,QAAQ,UAAU,QAAQ,QAAQ;AACrD,UAAQ,OACL,0DAA0D,SAAS,SAAS,CAAC,EAC/E;AACD,cAAY;AACZ;CACD;AAGD,KAAI;AACF,UAAQ,KAAK,cAAc,aAAa,EAAE;AAC1C,cAAY,SAAS;AACrB,UAAQ,KAAK,SAAS;CACvB,SAAQ,KAAK;EACZ,MAAM,UAAU,eAAe,QAAQ,IAAI,UAAU,OAAO,IAAI;AAChE,UAAQ,OAAO,mBAAmB,aAAa,IAAI,QAAQ,EAAE;AAC7D,cAAY;CACb;AACF;AAGD,QAAQ,IAAI,GAAG;AACf,IAAI,WAAW;AACb,SAAQ,IAAI,yBAAyB;AACrC,SAAQ,KAAK,EAAE;AAChB,MACC,SAAQ,IAAI,oCAAoC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "afterpack",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.9",
|
|
4
4
|
"description": "A high-performance post-build JavaScript obfuscator and minifier",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/cli.js",
|
|
@@ -13,27 +13,37 @@
|
|
|
13
13
|
"scripts": {
|
|
14
14
|
"build": "tsdown src/cli.ts --format esm --dts",
|
|
15
15
|
"dev": "tsdown src/cli.ts --format esm --watch",
|
|
16
|
-
"
|
|
16
|
+
"test": "vitest run",
|
|
17
|
+
"test:watch": "vitest",
|
|
18
|
+
"prepublishOnly": "pnpm build"
|
|
17
19
|
},
|
|
18
20
|
"keywords": [
|
|
19
21
|
"obfuscator",
|
|
20
22
|
"minifier",
|
|
21
23
|
"javascript",
|
|
22
24
|
"protection",
|
|
23
|
-
"security"
|
|
25
|
+
"security",
|
|
26
|
+
"afterpack"
|
|
24
27
|
],
|
|
25
|
-
"author": "AfterPack",
|
|
28
|
+
"author": "AfterPack <hello@afterpack.dev>",
|
|
26
29
|
"license": "MIT",
|
|
27
30
|
"repository": {
|
|
28
31
|
"type": "git",
|
|
29
32
|
"url": "https://github.com/afterpack-dev/afterpack.git"
|
|
30
33
|
},
|
|
31
34
|
"homepage": "https://afterpack.dev",
|
|
35
|
+
"bugs": {
|
|
36
|
+
"url": "https://github.com/afterpack-dev/afterpack/issues"
|
|
37
|
+
},
|
|
32
38
|
"engines": {
|
|
33
39
|
"node": ">=18"
|
|
34
40
|
},
|
|
41
|
+
"dependencies": {
|
|
42
|
+
"@afterpack/core": "^0.0.9"
|
|
43
|
+
},
|
|
35
44
|
"devDependencies": {
|
|
36
45
|
"tsdown": "^0.11.0",
|
|
37
|
-
"typescript": "^5.0.0"
|
|
46
|
+
"typescript": "^5.0.0",
|
|
47
|
+
"vitest": "^2.0.0"
|
|
38
48
|
}
|
|
39
49
|
}
|
package/readme.md
CHANGED
|
@@ -12,15 +12,14 @@ npx afterpack
|
|
|
12
12
|
|
|
13
13
|
## Features
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
-
|
|
18
|
-
-
|
|
19
|
-
-
|
|
20
|
-
-
|
|
21
|
-
-
|
|
22
|
-
-
|
|
23
|
-
- And many more
|
|
15
|
+
- **Free & Production-Ready** — Full obfuscation at no cost. Pro unlocks multi-file and edge features
|
|
16
|
+
- **20-70x Faster** — Rust-powered engine leaves JavaScript-based tools in the dust
|
|
17
|
+
- **Irreversible** — Non-linear transforms that can't be undone by deobfuscators or AI
|
|
18
|
+
- **Any Complexity** — From minimal to extreme protection with `--inflate`
|
|
19
|
+
- **Deterministic** — Same input = same output. Works with Turborepo, Nx, Bazel
|
|
20
|
+
- **Source Maps** — Generate and chain for Sentry/Datadog error tracking
|
|
21
|
+
- **Framework Presets** — Safe defaults for Next.js, Vite, Astro
|
|
22
|
+
- **Dual Runtime** — Native bindings + WASM for edge deployment
|
|
24
23
|
|
|
25
24
|
## License
|
|
26
25
|
|