portapack 0.2.1 → 0.3.1
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/.github/workflows/ci.yml +5 -4
- package/CHANGELOG.md +20 -0
- package/README.md +81 -219
- package/dist/cli/{cli-entry.js → cli-entry.cjs} +620 -513
- package/dist/cli/cli-entry.cjs.map +1 -0
- package/dist/index.d.ts +51 -56
- package/dist/index.js +517 -458
- package/dist/index.js.map +1 -1
- package/docs/.vitepress/config.ts +0 -1
- package/docs/cli.md +108 -45
- package/docs/configuration.md +101 -116
- package/docs/getting-started.md +74 -44
- package/jest.config.ts +18 -8
- package/jest.setup.cjs +66 -146
- package/package.json +5 -5
- package/src/cli/cli-entry.ts +15 -15
- package/src/cli/cli.ts +130 -119
- package/src/core/bundler.ts +174 -63
- package/src/core/extractor.ts +364 -277
- package/src/core/web-fetcher.ts +205 -141
- package/src/index.ts +161 -224
- package/tests/unit/cli/cli-entry.test.ts +66 -77
- package/tests/unit/cli/cli.test.ts +243 -145
- package/tests/unit/core/bundler.test.ts +334 -258
- package/tests/unit/core/extractor.test.ts +608 -1064
- package/tests/unit/core/minifier.test.ts +130 -221
- package/tests/unit/core/packer.test.ts +255 -106
- package/tests/unit/core/parser.test.ts +89 -458
- package/tests/unit/core/web-fetcher.test.ts +310 -265
- package/tests/unit/index.test.ts +206 -300
- package/tests/unit/utils/logger.test.ts +32 -28
- package/tsconfig.jest.json +8 -7
- package/tsup.config.ts +34 -29
- package/dist/cli/cli-entry.js.map +0 -1
- package/docs/demo.md +0 -46
- package/output.html +0 -1
- package/site-packed.html +0 -1
- package/test-output.html +0 -0
package/docs/cli.md
CHANGED
@@ -1,117 +1,180 @@
|
|
1
|
-
# ⚙️ CLI Reference
|
1
|
+
# ⚙️ PortaPack CLI Reference
|
2
2
|
|
3
|
-
PortaPack provides a powerful command-line interface for bundling HTML files and websites.
|
3
|
+
PortaPack provides a powerful command-line interface (CLI) for bundling local HTML files and remote websites into single, portable HTML files.
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
7
|
-
To use the CLI, install PortaPack globally:
|
7
|
+
To use the CLI, install PortaPack globally using npm (or your preferred package manager):
|
8
8
|
|
9
9
|
```bash
|
10
10
|
npm install -g portapack
|
11
|
+
# or
|
12
|
+
# yarn global add portapack
|
13
|
+
# or
|
14
|
+
# pnpm add -g portapack
|
11
15
|
```
|
12
16
|
|
13
17
|
## Command Syntax
|
14
18
|
|
15
|
-
The basic
|
19
|
+
The basic syntax for the PortaPack CLI is:
|
16
20
|
|
17
21
|
```bash
|
18
|
-
portapack [options]
|
22
|
+
portapack [input] [options]
|
19
23
|
```
|
20
24
|
|
25
|
+
Where `[input]` is the path to a local HTML file or a remote URL.
|
26
|
+
|
21
27
|
## Options
|
22
28
|
|
23
29
|
| Option | Shorthand | Description | Default |
|
24
|
-
|
25
|
-
|
|
26
|
-
| `--output <file>` | `-o` | Output file path | `{input}.packed.html` |
|
27
|
-
| `--
|
28
|
-
| `--
|
29
|
-
| `--
|
30
|
-
| `--
|
31
|
-
| `--
|
32
|
-
| `--
|
33
|
-
| `--
|
34
|
-
| `--
|
30
|
+
|--------|-----------|-------------|---------|
|
31
|
+
| `[input]` | | Required. Input local file path or remote URL (http/https) to process. | - |
|
32
|
+
| `--output <file>` | `-o` | Output file path for the bundled HTML. | `{input-basename}.packed.html` |
|
33
|
+
| `--recursive [depth]` | `-r` | Recursively bundle links up to depth. If depth omitted, defaults to true (no limit). Only applies to remote URLs. | `false` (disabled) |
|
34
|
+
| `--max-depth <n>` | | Set maximum depth for recursive crawling (alternative to `-r <n>`). | - |
|
35
|
+
| `--minify` | `-m` | Enable all minification (HTML, CSS, JS). | - |
|
36
|
+
| `--no-minify` | | Disable all asset minification (HTML, CSS, JS). | `false` |
|
37
|
+
| `--no-minify-html` | | Disable only HTML minification. | `false` |
|
38
|
+
| `--no-minify-css` | | Disable only CSS minification. | `false` |
|
39
|
+
| `--no-minify-js` | | Disable only JavaScript minification. | `false` |
|
40
|
+
| `--embed-assets` | `-e` | Embed external assets (CSS, JS, images, fonts) as data URIs or inline content. | `true` |
|
41
|
+
| `--no-embed-assets` | | Keep external assets as links (requires network access when viewing). | `false` |
|
42
|
+
| `--base-url <url>` | `-b` | Base URL for resolving relative URLs found in the input HTML. | Input path/URL |
|
43
|
+
| `--log-level <level>` | | Set logging level (debug, info, warn, error, silent, none). | `info` |
|
44
|
+
| `--verbose` | `-v` | Enable verbose logging (shortcut for `--log-level debug`). | `false` |
|
45
|
+
| `--dry-run` | `-d` | Perform all steps except writing the output file. Logs intended actions. | `false` |
|
46
|
+
| `--help` | `-h` | Show help information and exit. | - |
|
47
|
+
| `--version` | | Show PortaPack CLI version number and exit. | - |
|
35
48
|
|
36
49
|
## Examples
|
37
50
|
|
38
|
-
### Basic
|
51
|
+
### Basic Local File Bundling
|
52
|
+
|
53
|
+
Bundle `index.html` into `bundle.html`:
|
54
|
+
|
55
|
+
```bash
|
56
|
+
portapack ./index.html -o bundle.html
|
57
|
+
```
|
39
58
|
|
40
|
-
|
59
|
+
Use default output name (`index.packed.html`):
|
41
60
|
|
42
61
|
```bash
|
43
|
-
portapack
|
62
|
+
portapack ./index.html
|
44
63
|
```
|
45
64
|
|
46
65
|
### Web Page Bundling
|
47
66
|
|
48
|
-
Bundle a remote
|
67
|
+
Bundle a single remote webpage:
|
49
68
|
|
50
69
|
```bash
|
51
|
-
portapack
|
70
|
+
portapack https://example.com -o example-bundle.html
|
52
71
|
```
|
53
72
|
|
54
73
|
### Recursive Bundling
|
55
74
|
|
56
|
-
Bundle a website
|
75
|
+
Bundle a website, following links 1 level deep:
|
76
|
+
|
77
|
+
```bash
|
78
|
+
portapack https://example.com -r -o site-bundle-depth1.html
|
79
|
+
```
|
80
|
+
|
81
|
+
Bundle a website, following links up to 2 levels deep:
|
82
|
+
|
83
|
+
```bash
|
84
|
+
portapack https://example.com -r 2 -o site-bundle-depth2.html
|
85
|
+
```
|
86
|
+
|
87
|
+
Alternative using `--max-depth` option:
|
88
|
+
|
89
|
+
```bash
|
90
|
+
portapack https://example.com --max-depth 2 -o site-bundle-depth2.html
|
91
|
+
```
|
92
|
+
|
93
|
+
### Asset Handling
|
94
|
+
|
95
|
+
Bundle without embedding assets (keep external links):
|
96
|
+
|
97
|
+
```bash
|
98
|
+
portapack ./index.html --no-embed-assets -o linked-assets.html
|
99
|
+
```
|
100
|
+
|
101
|
+
Default behavior is to embed assets (which you can make explicit):
|
57
102
|
|
58
103
|
```bash
|
59
|
-
portapack
|
104
|
+
portapack ./index.html --embed-assets -o embedded-assets.html
|
60
105
|
```
|
61
106
|
|
62
107
|
### Minification Control
|
63
108
|
|
64
|
-
Apply
|
109
|
+
Apply all minification:
|
110
|
+
|
111
|
+
```bash
|
112
|
+
portapack ./index.html -m -o min-bundle.html
|
113
|
+
```
|
114
|
+
|
115
|
+
Disable minification completely:
|
65
116
|
|
66
117
|
```bash
|
67
|
-
portapack
|
118
|
+
portapack ./index.html --no-minify -o unmin-bundle.html
|
68
119
|
```
|
69
120
|
|
70
|
-
|
121
|
+
Selectively control minification:
|
71
122
|
|
72
123
|
```bash
|
73
|
-
|
124
|
+
# Minify CSS and JS but not HTML
|
125
|
+
portapack ./index.html --no-minify-html -o selective-min.html
|
126
|
+
|
127
|
+
# Minify HTML and CSS but not JS
|
128
|
+
portapack ./index.html --no-minify-js -o no-js-min.html
|
74
129
|
```
|
75
130
|
|
76
131
|
### Base URL for Relative Links
|
77
132
|
|
78
|
-
|
133
|
+
Process a local file as if it were hosted at https://example.com:
|
79
134
|
|
80
135
|
```bash
|
81
|
-
portapack
|
136
|
+
portapack ./docs/index.html -b https://example.com/docs/ -o bundle.html
|
137
|
+
```
|
138
|
+
|
139
|
+
### Logging and Debugging
|
140
|
+
|
141
|
+
Enable detailed debug logs:
|
142
|
+
|
143
|
+
```bash
|
144
|
+
portapack ./index.html -v -o bundle-debug.html
|
145
|
+
```
|
146
|
+
|
147
|
+
Only show errors:
|
148
|
+
|
149
|
+
```bash
|
150
|
+
portapack ./index.html --log-level error -o bundle-errors-only.html
|
82
151
|
```
|
83
152
|
|
84
153
|
### Dry Run
|
85
154
|
|
86
|
-
|
155
|
+
See what files and assets would be processed without saving:
|
87
156
|
|
88
157
|
```bash
|
89
|
-
portapack
|
158
|
+
portapack ./index.html --dry-run
|
90
159
|
```
|
91
160
|
|
92
|
-
###
|
161
|
+
### NPX Usage
|
93
162
|
|
94
|
-
|
163
|
+
Use PortaPack without installing globally:
|
95
164
|
|
96
165
|
```bash
|
97
|
-
portapack
|
166
|
+
npx portapack ./index.html -o bundle.html
|
98
167
|
```
|
99
168
|
|
100
169
|
## Exit Codes
|
101
170
|
|
102
171
|
| Code | Description |
|
103
172
|
|------|-------------|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
107
|
-
## Environment Variables
|
108
|
-
|
109
|
-
| Variable | Description |
|
110
|
-
|----------|-------------|
|
111
|
-
| `NODE_ENV` | Set to `test` during testing to suppress console output |
|
173
|
+
| 0 | Success |
|
174
|
+
| 1 | Error |
|
112
175
|
|
113
176
|
## Related Resources
|
114
177
|
|
115
|
-
- [Getting Started](/getting-started)
|
116
|
-
- [API Reference](/api/
|
117
|
-
- [Configuration Guide](/configuration)
|
178
|
+
- [Getting Started](https://manicinc.github.io/portapack/getting-started)
|
179
|
+
- [API Reference](https://manicinc.github.io/portapack/api/)
|
180
|
+
- [Configuration Guide](https://manicinc.github.io/portapack/configuration)
|
package/docs/configuration.md
CHANGED
@@ -1,151 +1,136 @@
|
|
1
|
-
#
|
1
|
+
# 🚀 Getting Started with PortaPack
|
2
2
|
|
3
|
-
##
|
3
|
+
## Prerequisites
|
4
4
|
|
5
|
-
|
5
|
+
- Node.js (v16.0.0+)
|
6
|
+
- npm (v8.0.0+)
|
6
7
|
|
7
|
-
|
8
|
+
## Quick Installation
|
8
9
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
| `-o, --output` | String | `{input}.packed.html` | Output file path |
|
13
|
-
| `-m, --minify` | Number | `2` | Minification level (0-3) |
|
14
|
-
| `--no-minify` | Flag | - | Disable minification |
|
15
|
-
| `-r, --recursive` | Boolean/Number | `false` | Crawl site recursively, optionally with depth |
|
16
|
-
| `-b, --base-url` | String | Detected | Base URL for resolving paths |
|
17
|
-
| `-d, --dry-run` | Flag | `false` | Preview without generating output |
|
18
|
-
| `-v, --verbose` | Flag | `false` | Enable verbose logging |
|
19
|
-
|
20
|
-
### Programmatic Configuration
|
21
|
-
|
22
|
-
```typescript
|
23
|
-
// Simple string input
|
24
|
-
await generatePortableHTML('./index.html');
|
25
|
-
|
26
|
-
// With options as second parameter
|
27
|
-
await generatePortableHTML('./index.html', {
|
28
|
-
minify: true,
|
29
|
-
minifyLevel: 2,
|
30
|
-
baseUrl: 'https://example.com'
|
31
|
-
});
|
10
|
+
```bash
|
11
|
+
# Global installation
|
12
|
+
npm install -g portapack
|
32
13
|
|
33
|
-
|
34
|
-
|
35
|
-
input: './index.html',
|
36
|
-
minify: true,
|
37
|
-
minifyLevel: 2,
|
38
|
-
baseUrl: 'https://example.com',
|
39
|
-
|
40
|
-
// Asset handling
|
41
|
-
embedAssets: true,
|
42
|
-
embedLimit: 1000000,
|
43
|
-
|
44
|
-
// Minification controls
|
45
|
-
minifyHtml: true,
|
46
|
-
minifyCss: true,
|
47
|
-
minifyJs: true,
|
48
|
-
|
49
|
-
// Advanced options
|
50
|
-
removeComments: true,
|
51
|
-
collapseWhitespace: true
|
52
|
-
});
|
14
|
+
# Or as a project dependency
|
15
|
+
npm install --save-dev portapack
|
53
16
|
```
|
54
17
|
|
55
|
-
##
|
18
|
+
## Basic Usage
|
56
19
|
|
57
|
-
### CLI
|
20
|
+
### CLI Quickstart
|
58
21
|
|
59
22
|
```bash
|
60
|
-
#
|
61
|
-
portapack
|
62
|
-
|
63
|
-
# Maximum minification
|
64
|
-
portapack -i ./site -m 3 -o min.html
|
23
|
+
# Bundle a local HTML file
|
24
|
+
portapack ./index.html -o portable.html
|
65
25
|
|
66
|
-
#
|
67
|
-
portapack -
|
26
|
+
# Bundle a remote website
|
27
|
+
portapack https://example.com --recursive -o site.html
|
28
|
+
```
|
68
29
|
|
69
|
-
|
70
|
-
portapack -i ./local/site -b https://example.com
|
30
|
+
### Node.js API Basic Example
|
71
31
|
|
72
|
-
|
73
|
-
|
32
|
+
```typescript
|
33
|
+
import { pack } from 'portapack';
|
74
34
|
|
75
|
-
|
76
|
-
|
35
|
+
// Simple usage with a string path
|
36
|
+
async function bundleLocalSite() {
|
37
|
+
const result = await pack('./index.html');
|
38
|
+
console.log(result.html);
|
39
|
+
|
40
|
+
// Access metadata about the build
|
41
|
+
console.log(`Output size: ${result.metadata.outputSize} bytes`);
|
42
|
+
console.log(`Build time: ${result.metadata.buildTimeMs} ms`);
|
43
|
+
}
|
44
|
+
|
45
|
+
// Advanced options using configuration object
|
46
|
+
async function bundleWithOptions() {
|
47
|
+
const result = await pack('./index.html', {
|
48
|
+
minifyHtml: true,
|
49
|
+
minifyCss: true,
|
50
|
+
minifyJs: true,
|
51
|
+
baseUrl: 'https://example.com',
|
52
|
+
embedAssets: true
|
53
|
+
});
|
54
|
+
|
55
|
+
// Use or save the bundled HTML
|
56
|
+
console.log(result.html);
|
57
|
+
}
|
58
|
+
|
59
|
+
// Recursive bundling of a website
|
60
|
+
async function bundleWebsite() {
|
61
|
+
const result = await pack('https://example.com', {
|
62
|
+
recursive: 2, // Crawl up to 2 levels deep
|
63
|
+
minifyHtml: true,
|
64
|
+
minifyCss: true,
|
65
|
+
minifyJs: true
|
66
|
+
});
|
67
|
+
|
68
|
+
console.log(`Bundled ${result.metadata.pagesBundled} pages`);
|
69
|
+
}
|
77
70
|
```
|
78
71
|
|
79
|
-
###
|
72
|
+
### Advanced API Usage
|
73
|
+
|
74
|
+
For more specific use cases, you can access individual components:
|
80
75
|
|
81
76
|
```typescript
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
77
|
+
import {
|
78
|
+
generatePortableHTML,
|
79
|
+
generateRecursivePortableHTML,
|
80
|
+
bundleMultiPageHTML,
|
81
|
+
fetchAndPackWebPage,
|
82
|
+
} from 'portapack';
|
83
|
+
|
84
|
+
// Bundle a single HTML file or URL
|
85
|
+
const singleResult = await generatePortableHTML('./index.html', {
|
86
|
+
minifyHtml: true
|
91
87
|
});
|
92
88
|
|
93
|
-
//
|
94
|
-
const
|
95
|
-
|
96
|
-
baseUrl: 'https://example.com',
|
97
|
-
embedAssets: true
|
89
|
+
// Recursively bundle a site
|
90
|
+
const recursiveResult = await generateRecursivePortableHTML('https://example.com', 2, {
|
91
|
+
minifyCss: true
|
98
92
|
});
|
99
93
|
|
100
|
-
//
|
101
|
-
await
|
102
|
-
'
|
103
|
-
'
|
104
|
-
|
105
|
-
);
|
94
|
+
// Create multi-page bundle
|
95
|
+
const multiPageBundle = await bundleMultiPageHTML([
|
96
|
+
{ path: '/', html: '<html>...</html>' },
|
97
|
+
{ path: '/about', html: '<html>...</html>' }
|
98
|
+
]);
|
106
99
|
```
|
107
100
|
|
108
|
-
##
|
101
|
+
## Configuration
|
109
102
|
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
103
|
+
See our full [Configuration Guide](https://manicinc.github.io/portapack/configuration) for detailed options.
|
104
|
+
|
105
|
+
## CLI Options
|
106
|
+
|
107
|
+
PortaPack offers many command-line options for customizing the bundling process:
|
108
|
+
|
109
|
+
```bash
|
110
|
+
# Get full help
|
111
|
+
portapack --help
|
112
|
+
```
|
119
113
|
|
120
|
-
|
114
|
+
For details, see the [CLI Reference](https://manicinc.github.io/portapack/cli).
|
121
115
|
|
122
|
-
|
123
|
-
- Large sites may require increased memory allocation
|
124
|
-
- Some asset embedding might fail with complex dynamic sites
|
125
|
-
- External scripts with CORS restrictions may not embed properly
|
116
|
+
## Next Steps
|
126
117
|
|
127
|
-
|
118
|
+
- 📖 [Explore CLI Options](https://manicinc.github.io/portapack/cli)
|
119
|
+
- 🛠 [Advanced Configuration](https://manicinc.github.io/portapack/configuration)
|
120
|
+
- 💻 [API Reference](https://manicinc.github.io/portapack/api/)
|
128
121
|
|
129
|
-
|
122
|
+
## Troubleshooting
|
130
123
|
|
131
|
-
|
132
|
-
- **CSS stylesheets**: Both inline and external
|
133
|
-
- **JavaScript**: Script files and inline scripts
|
134
|
-
- **Images**: PNG, JPEG, GIF, SVG, WebP (converted to data URLs)
|
135
|
-
- **Fonts**: WOFF, WOFF2, TTF, EOT (embedded)
|
136
|
-
- **Other assets**: PDFs, JSON, text files, etc.
|
124
|
+
Encountering issues? Check our [Troubleshooting Guide](https://manicinc.github.io/portapack/troubleshooting)
|
137
125
|
|
138
|
-
##
|
126
|
+
## Contributing
|
139
127
|
|
140
|
-
|
128
|
+
Interested in improving PortaPack?
|
129
|
+
- [View Contributing Guidelines](https://manicinc.github.io/portapack/contributing)
|
141
130
|
|
142
|
-
|
143
|
-
- `PORTAPACK_MINIFY_LEVEL`: Sets minification level
|
144
|
-
- `PORTAPACK_NO_EMBED`: Disables asset embedding when set to "true"
|
131
|
+
## Support
|
145
132
|
|
146
|
-
|
133
|
+
- 🐛 [Report an Issue](https://github.com/manicinc/portapack/issues)
|
134
|
+
- 💬 [Community Support](https://discord.gg/DzNgXdYm)
|
147
135
|
|
148
|
-
|
149
|
-
- [API Reference](/api/README)
|
150
|
-
- [Getting Started Guide](/getting-started)
|
151
|
-
- [Troubleshooting](/troubleshooting)
|
136
|
+
Built by [Manic.agency](https://manic.agency)
|
package/docs/getting-started.md
CHANGED
@@ -15,88 +15,118 @@ npm install -g portapack
|
|
15
15
|
npm install --save-dev portapack
|
16
16
|
```
|
17
17
|
|
18
|
-
## Documentation
|
19
|
-
|
20
|
-
Our documentation is automatically generated and hosted locally:
|
21
|
-
|
22
|
-
- 🌐 **Local Docs**: at `http://localhost:5173`
|
23
|
-
- 📦 **Auto-Generated API Docs**: Dynamically created from TypeDoc comments
|
24
|
-
- 🧩 **Sidebar Generation**: Intelligent, automated sidebar creation
|
25
|
-
|
26
|
-
### Running Documentation Locally
|
27
|
-
|
28
|
-
```bash
|
29
|
-
# Start documentation development server
|
30
|
-
npm run docs:dev
|
31
|
-
```
|
32
|
-
|
33
18
|
## Basic Usage
|
34
19
|
|
35
20
|
### CLI Quickstart
|
36
21
|
|
37
22
|
```bash
|
38
23
|
# Bundle a local HTML file
|
39
|
-
portapack
|
24
|
+
portapack ./index.html -o portable.html
|
40
25
|
|
41
26
|
# Bundle a remote website
|
42
|
-
portapack
|
27
|
+
portapack https://example.com --recursive -o site.html
|
43
28
|
```
|
44
29
|
|
45
30
|
### Node.js API Basic Example
|
46
31
|
|
47
32
|
```typescript
|
48
|
-
import {
|
33
|
+
import { pack } from 'portapack';
|
49
34
|
|
50
35
|
// Simple usage with a string path
|
51
36
|
async function bundleLocalSite() {
|
52
|
-
const
|
53
|
-
console.log(
|
37
|
+
const result = await pack('./index.html');
|
38
|
+
console.log(result.html);
|
39
|
+
|
40
|
+
// Access metadata about the build
|
41
|
+
console.log(`Output size: ${result.metadata.outputSize} bytes`);
|
42
|
+
console.log(`Build time: ${result.metadata.buildTimeMs} ms`);
|
54
43
|
}
|
55
44
|
|
56
45
|
// Advanced options using configuration object
|
57
46
|
async function bundleWithOptions() {
|
58
|
-
const
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
baseUrl: 'https://example.com'
|
47
|
+
const result = await pack('./index.html', {
|
48
|
+
minifyHtml: true,
|
49
|
+
minifyCss: true,
|
50
|
+
minifyJs: true,
|
51
|
+
baseUrl: 'https://example.com',
|
52
|
+
embedAssets: true
|
63
53
|
});
|
64
|
-
|
54
|
+
|
65
55
|
// Use or save the bundled HTML
|
66
|
-
console.log(
|
56
|
+
console.log(result.html);
|
67
57
|
}
|
58
|
+
|
59
|
+
// Recursive bundling of a website
|
60
|
+
async function bundleWebsite() {
|
61
|
+
const result = await pack('https://example.com', {
|
62
|
+
recursive: 2, // Crawl up to 2 levels deep
|
63
|
+
minifyHtml: true,
|
64
|
+
minifyCss: true,
|
65
|
+
minifyJs: true
|
66
|
+
});
|
67
|
+
|
68
|
+
console.log(`Bundled ${result.metadata.pagesBundled} pages`);
|
69
|
+
}
|
70
|
+
```
|
71
|
+
|
72
|
+
### Advanced API Usage
|
73
|
+
|
74
|
+
For more specific use cases, you can access individual components:
|
75
|
+
|
76
|
+
```typescript
|
77
|
+
import {
|
78
|
+
generatePortableHTML,
|
79
|
+
generateRecursivePortableHTML,
|
80
|
+
bundleMultiPageHTML,
|
81
|
+
fetchAndPackWebPage,
|
82
|
+
} from 'portapack';
|
83
|
+
|
84
|
+
// Bundle a single HTML file or URL
|
85
|
+
const singleResult = await generatePortableHTML('./index.html', {
|
86
|
+
minifyHtml: true
|
87
|
+
});
|
88
|
+
|
89
|
+
// Recursively bundle a site
|
90
|
+
const recursiveResult = await generateRecursivePortableHTML('https://example.com', 2, {
|
91
|
+
minifyCss: true
|
92
|
+
});
|
93
|
+
|
94
|
+
// Create multi-page bundle
|
95
|
+
const multiPageBundle = await bundleMultiPageHTML([
|
96
|
+
{ path: '/', html: '<html>...</html>' },
|
97
|
+
{ path: '/about', html: '<html>...</html>' }
|
98
|
+
]);
|
68
99
|
```
|
69
100
|
|
70
|
-
##
|
101
|
+
## Configuration
|
102
|
+
|
103
|
+
See our full [Configuration Guide](https://manicinc.github.io/portapack/configuration) for detailed options.
|
71
104
|
|
72
|
-
|
105
|
+
## CLI Options
|
73
106
|
|
74
|
-
PortaPack
|
75
|
-
- Automatically scan TypeDoc-generated markdown files
|
76
|
-
- Create dynamic, organized documentation sidebars
|
77
|
-
- Support multiple documentation types (modules, classes, interfaces, etc.)
|
107
|
+
PortaPack offers many command-line options for customizing the bundling process:
|
78
108
|
|
79
|
-
|
109
|
+
```bash
|
110
|
+
# Get full help
|
111
|
+
portapack --help
|
112
|
+
```
|
80
113
|
|
81
|
-
|
82
|
-
2. Custom sidebar generator reads generated files
|
83
|
-
3. VitePress renders dynamically generated sidebar
|
114
|
+
For details, see the [CLI Reference](https://manicinc.github.io/portapack/cli).
|
84
115
|
|
85
116
|
## Next Steps
|
86
117
|
|
87
|
-
- 📖 [Explore CLI Options](/cli)
|
88
|
-
- 🛠 [Advanced Configuration](/configuration)
|
89
|
-
- 💻 [API Reference](/api/
|
118
|
+
- 📖 [Explore CLI Options](https://manicinc.github.io/portapack/cli)
|
119
|
+
- 🛠 [Advanced Configuration](https://manicinc.github.io/portapack/configuration)
|
120
|
+
- 💻 [API Reference](https://manicinc.github.io/portapack/api/)
|
90
121
|
|
91
122
|
## Troubleshooting
|
92
123
|
|
93
|
-
Encountering issues? Check our [Troubleshooting Guide](/troubleshooting)
|
124
|
+
Encountering issues? Check our [Troubleshooting Guide](https://manicinc.github.io/portapack/troubleshooting)
|
94
125
|
|
95
126
|
## Contributing
|
96
127
|
|
97
|
-
Interested in improving PortaPack?
|
98
|
-
- [View Contributing Guidelines](/contributing)
|
99
|
-
- [Development Guide](/development)
|
128
|
+
Interested in improving PortaPack?
|
129
|
+
- [View Contributing Guidelines](https://manicinc.github.io/portapack/contributing)
|
100
130
|
|
101
131
|
## Support
|
102
132
|
|