afterpack 0.1.0 → 0.2.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 +10 -8
- package/SKILL.md +15 -11
- package/dist/cli.js +3 -2
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -17,8 +17,9 @@ Use `afterpack@latest` so `npx` does not pick up an old cached copy. `afterpack
|
|
|
17
17
|
common options and `afterpack --help --all` lists every one.
|
|
18
18
|
|
|
19
19
|
If your project uses a framework with an AfterPack plugin (Vite, Next.js, webpack, Nuxt, Astro and
|
|
20
|
-
others), the plugin is the better fit
|
|
21
|
-
reaches disk
|
|
20
|
+
others), the plugin is the better fit. Most plugins obfuscate inside the build, so the readable
|
|
21
|
+
bundle never reaches disk; the Next.js, esbuild and Angular integrations run right after the tool
|
|
22
|
+
writes its output. Run `afterpack` with no path and it tells you which plugin to install.
|
|
22
23
|
|
|
23
24
|
## `afterpack [path]`
|
|
24
25
|
|
|
@@ -38,8 +39,8 @@ Each run writes:
|
|
|
38
39
|
- `.map` files next to the output, when your build has source maps and the run is not a production
|
|
39
40
|
build.
|
|
40
41
|
|
|
41
|
-
The backup and the Protection Map contain your original source.
|
|
42
|
-
|
|
42
|
+
The backup and the Protection Map contain your original source. `.afterpack/` carries its own
|
|
43
|
+
`.gitignore` and self-ignores. Never deploy or commit them.
|
|
43
44
|
|
|
44
45
|
With no path, `afterpack` looks at your project first. If it finds a framework, it prints the plugin
|
|
45
46
|
to install (or tells you the one you have already covers the build) and exits `1`. Otherwise it
|
|
@@ -122,11 +123,12 @@ and sends everything else to stderr. Use it in CI and scripts. `verify` and `aud
|
|
|
122
123
|
|
|
123
124
|
## Pro
|
|
124
125
|
|
|
125
|
-
Without a key, AfterPack runs on your machine
|
|
126
|
+
Without a key, AfterPack runs on your machine with the full pipeline at any preset. Set
|
|
126
127
|
[`AFTERPACK_KEY`][key] in your environment (or [`key`][key] in `afterpack.json`) and the same
|
|
127
|
-
command
|
|
128
|
-
|
|
129
|
-
|
|
128
|
+
command builds in AfterPack's cloud instead, which adds two hardening transforms you can turn on:
|
|
129
|
+
self-integrity (anti-tamper) and comparison hardening. If the cloud cannot be reached, the run
|
|
130
|
+
fails; it never falls back to a local build. Never commit the key. See [AfterPack
|
|
131
|
+
Pro](https://www.afterpack.dev/docs/pro).
|
|
130
132
|
|
|
131
133
|
## Exit codes
|
|
132
134
|
|
package/SKILL.md
CHANGED
|
@@ -11,8 +11,8 @@ the bundler. Never run it on source.
|
|
|
11
11
|
## Pick the right tool first
|
|
12
12
|
|
|
13
13
|
If the project uses a framework or bundler with an AfterPack plugin, install the plugin instead of
|
|
14
|
-
adding a CLI step.
|
|
15
|
-
disk:
|
|
14
|
+
adding a CLI step. Most plugins obfuscate inside the build, so the readable bundle never reaches
|
|
15
|
+
disk; the Next.js, esbuild and Angular ones run right after the tool writes its output:
|
|
16
16
|
|
|
17
17
|
| Project uses | Install |
|
|
18
18
|
| --- | --- |
|
|
@@ -73,24 +73,27 @@ Rules:
|
|
|
73
73
|
- `.afterpack/protectionMap.html`: the Protection Map report, when the build has source maps.
|
|
74
74
|
- `.map` files beside the output, when an input map exists and the run is not a production build.
|
|
75
75
|
|
|
76
|
-
The backup and the Protection Map contain the original source.
|
|
77
|
-
|
|
76
|
+
The backup and the Protection Map contain the original source. `.afterpack/` carries its own
|
|
77
|
+
`.gitignore` and self-ignores. Never deploy, publish or commit them.
|
|
78
78
|
|
|
79
79
|
## Configuration
|
|
80
80
|
|
|
81
81
|
Every option has one dot-delimited camelCase name, used the same way in every place:
|
|
82
82
|
|
|
83
|
-
1.
|
|
84
|
-
2.
|
|
85
|
-
3. `AFTERPACK_<key with dots as underscores>` in the environment, for example
|
|
83
|
+
1. `--key=value` on the command line
|
|
84
|
+
2. `AFTERPACK_<key with dots as underscores>` in the environment, for example
|
|
86
85
|
`AFTERPACK_diagnostics_format=json`
|
|
87
|
-
|
|
86
|
+
3. `afterpack.json`, the nearest one at or above the working directory
|
|
88
87
|
|
|
89
88
|
Higher in the list wins. A boolean flag on its own means `true`; `=false` turns it off. There is
|
|
90
89
|
no `--no-` form and no space-separated value (`--seed git` is wrong, `--seed=git` is right). The
|
|
91
90
|
only short flags are `-h` and `-v`. An unknown, kebab-cased or malformed key fails the run with
|
|
92
91
|
exit `64` and names the right spelling.
|
|
93
92
|
|
|
93
|
+
The CLI does not read `/* @afterpack */` source directives, and setting `directives.enabled` fails
|
|
94
|
+
the run: built output no longer carries the comments. A bundler plugin reads them before
|
|
95
|
+
minification.
|
|
96
|
+
|
|
94
97
|
| Key | Meaning | Default |
|
|
95
98
|
| --- | --- | --- |
|
|
96
99
|
| [`preset`][preset] | `minify`, `light`, `medium`, `hard` or `extreme` | `light` |
|
|
@@ -178,15 +181,16 @@ Lists are sorted and there are no timestamps, so two runs of one build give iden
|
|
|
178
181
|
|
|
179
182
|
## The Pro key
|
|
180
183
|
|
|
181
|
-
Without a key, builds run locally with
|
|
182
|
-
|
|
184
|
+
Without a key, builds run locally with the full pipeline at any preset. With a Pro key, the same
|
|
185
|
+
command builds in AfterPack's cloud instead, which adds two hardening transforms you can turn on:
|
|
186
|
+
self-integrity (anti-tamper) and comparison hardening.
|
|
183
187
|
|
|
184
188
|
- Set it as `AFTERPACK_KEY` in the environment (a CI secret), or [`key`][key] in an uncommitted
|
|
185
189
|
`afterpack.json`.
|
|
186
190
|
- Never put it in a plugin's options object. Plugins reject it there, because a bundler config is
|
|
187
191
|
committed source.
|
|
188
192
|
- Never commit it.
|
|
189
|
-
- If the cloud cannot be reached, the run fails with exit `1`. It never falls back to
|
|
193
|
+
- If the cloud cannot be reached, the run fails with exit `1`. It never falls back to a local build.
|
|
190
194
|
|
|
191
195
|
Details: https://www.afterpack.dev/docs/pro
|
|
192
196
|
|
package/dist/cli.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { existsSync, mkdirSync, readFileSync, rmSync, statSync, writeFileSync } from "node:fs";
|
|
3
3
|
import { processBatch, version } from "@afterpack/core";
|
|
4
|
-
import { AlreadyObfuscatedError, CLOUD_REFUSAL_SUMMARY, CONFIG_KEYS, CORE_FLOOR_SUMMARY, CloudApiError, CoreVersionError, DIAG_ALREADY_OBFUSCATED, PROTECTION_RECEIPT_FILE, UnreadableReceiptError, collectJsFiles, createTelemetryReporter, findUpward, getPath, installedRequiredLine, loadConfigFile, mergeConfig, npxAlternative, parseCliOptions, parseEnvOptions, resolveClientIdentity, resolvePluginConfig, runObfuscationPass, serverAddsInfo, sha256Of, toEngineConfig, toPluginOptions, verifyProtectionReceipt } from "@afterpack/integration-utils";
|
|
4
|
+
import { AlreadyObfuscatedError, CLOUD_REFUSAL_SUMMARY, CONFIG_KEYS, CORE_FLOOR_SUMMARY, CloudApiError, CoreVersionError, DIAG_ALREADY_OBFUSCATED, PROTECTION_RECEIPT_FILE, UnreadableReceiptError, collectJsFiles, createTelemetryReporter, ensureAfterpackGitignore, findUpward, getPath, installedRequiredLine, loadConfigFile, mergeConfig, npxAlternative, parseCliOptions, parseEnvOptions, resolveClientIdentity, resolvePluginConfig, runObfuscationPass, serverAddsInfo, sha256Of, toEngineConfig, toPluginOptions, verifyProtectionReceipt } from "@afterpack/integration-utils";
|
|
5
5
|
import { basename, dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
|
|
6
6
|
import { createHash } from "node:crypto";
|
|
7
7
|
|
|
@@ -933,6 +933,7 @@ function writeBackups(input) {
|
|
|
933
933
|
force: true
|
|
934
934
|
});
|
|
935
935
|
mkdirSync(dir, { recursive: true });
|
|
936
|
+
ensureAfterpackGitignore(dir);
|
|
936
937
|
const files = [];
|
|
937
938
|
for (const pending of input.pending) {
|
|
938
939
|
const dest = absoluteFilePath(dir, pending.relPath);
|
|
@@ -1578,7 +1579,7 @@ async function runObfuscationAndBackup(input) {
|
|
|
1578
1579
|
files: input.files,
|
|
1579
1580
|
engine: observeEngine(input.engine, captured),
|
|
1580
1581
|
label: "afterpack",
|
|
1581
|
-
|
|
1582
|
+
cwd: input.cwd,
|
|
1582
1583
|
startedAt: input.startedAt,
|
|
1583
1584
|
combinedProtectionMap: {
|
|
1584
1585
|
buildDir: input.buildDir,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "afterpack",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "AfterPack CLI: obfuscate the JavaScript in any build output, verify a build before deploy, and scan a live site",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
"dist"
|
|
15
15
|
],
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@afterpack/core": "~0.
|
|
18
|
-
"@afterpack/integration-utils": "0.
|
|
17
|
+
"@afterpack/core": "~0.2.0",
|
|
18
|
+
"@afterpack/integration-utils": "0.2.0"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
21
|
"@biomejs/biome": "2.4.4",
|