portapack 0.2.1 โ†’ 0.3.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/CHANGELOG.md CHANGED
@@ -1,3 +1,15 @@
1
+ # [0.3.0](https://github.com/manicinc/portapack/compare/v0.2.1...v0.3.0) (2025-04-13)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **cli:** fix CLI execution via npx and global install ([88774e8](https://github.com/manicinc/portapack/commit/88774e80d28d0ac9292906ac7454d4528a5396ec))
7
+
8
+
9
+ ### Features
10
+
11
+ * api upgrades / revamps; update types; more robust core features and test fixes; update docs ([34e7b4a](https://github.com/manicinc/portapack/commit/34e7b4af55c6c934af8be0f1c43d427fd00a9594))
12
+
1
13
  ## [0.2.1](https://github.com/manicinc/portapack/compare/v0.2.0...v0.2.1) (2025-04-11)
2
14
 
3
15
 
package/README.md CHANGED
@@ -1,18 +1,12 @@
1
1
  # ๐Ÿ“ฆ PortaPack
2
2
 
3
- <div align="center">
4
- <img src="./docs/portapack-transparent.png" alt="PortaPack Logo" style="max-width: 50%; height: auto; margin-bottom: 20px;">
5
-
6
3
  [![npm version](https://img.shields.io/npm/v/portapack.svg?style=for-the-badge&logo=npm&color=CB3837)](https://www.npmjs.com/package/portapack)
7
4
  [![Build Status](https://img.shields.io/github/actions/workflow/status/manicinc/portapack/ci.yml?branch=master&style=for-the-badge&logo=github)](https://github.com/manicinc/portapack/actions)
8
5
  [![Coverage Status](https://img.shields.io/coveralls/github/manicinc/portapack?style=for-the-badge&logo=codecov)](https://coveralls.io/github/manicinc/portapack)
9
- </div>
10
6
 
11
- ## ๐ŸŒŸ Introduction
7
+ **PortaPack** bundles your entire website โ€” HTML, CSS, JS, images, and fonts โ€” into one self-contained HTML file. Perfect for snapshots, demos, testing, and offline apps.
12
8
 
13
- **PortaPack** is a powerful, lightning-fast HTML bundling tool that transforms websites into compact, portable files. Pack entire web experiences into a single, self-contained HTML document with minimal effort.
14
-
15
- See our [roadmap]() (coming soon!)
9
+ *Minimal input. Maximal output.*
16
10
 
17
11
  ## ๐Ÿ“š Documentation
18
12
 
@@ -22,267 +16,140 @@ See our [roadmap]() (coming soon!)
22
16
  - [๐Ÿ’ป API Reference](https://manicinc.github.io/portapack/api/)
23
17
  - [๐Ÿค Contributing Guidelines](https://manicinc.github.io/portapack/contributing)
24
18
 
25
- ## โœจ Killer Features
26
-
27
- | Feature | Description |
28
- |---------|-------------|
29
- | ๐Ÿงฉ **Recursive Packing** | Bundle entire websites into a single, portable file |
30
- | ๐ŸŽฏ **Total Asset Embedding** | Inline CSS, JS, images, and fonts seamlessly |
31
- | ๐Ÿงผ **Smart Minification** | Optimize HTML, CSS, and JS for minimal file size |
32
- | ๐ŸŒ **Universal Compatibility** | Works flawlessly with local and remote sites |
33
- | ๐Ÿš€ **Blazing Fast** | Lightweight, efficient processing for quick results |
34
-
35
19
  ## ๐Ÿš€ Quick Start
36
20
 
37
- ### Installation
21
+ ### ๐Ÿ“ฆ Install
38
22
 
39
23
  ```bash
40
- # Global install
24
+ # Global CLI (recommended)
41
25
  npm install -g portapack
42
26
 
43
- # Project dependency
44
- npm install --save-dev portapack
27
+ # OR use npx (no install needed)
28
+ npx portapack ./index.html -o bundle.html
45
29
  ```
46
30
 
47
- ### Basic Usage
31
+ ### ๐Ÿงฐ CLI Options
48
32
 
49
33
  ```bash
50
- # Bundle a local HTML file
51
- portapack ./index.html -o portable.html
52
-
53
- # Crawl a remote website
54
- portapack https://example.com --recursive -o site.html
34
+ portapack [input] [options]
55
35
  ```
56
36
 
57
- ## ๐Ÿ’ป CLI Reference
58
-
59
- ### Command Syntax
60
-
61
- ```bash
62
- portapack [options] [input]
63
- ```
64
-
65
- ### Core Options
66
-
67
37
  | Option | Description |
68
38
  |--------|-------------|
69
39
  | `-o, --output <file>` | Output file path |
70
- | `-m, --minify` | Enable all minification (HTML, CSS, JS) |
71
- | `--no-minify` | Disable all minification |
72
- | `-e, --embed-assets` | Embed assets as data URIs (default) |
73
- | `--no-embed-assets` | Keep asset links relative/absolute |
74
- | `-b, --base-url <url>` | Base URL for resolving relative links |
75
- | `-d, --dry-run` | Run without writing output file |
76
- | `-v, --verbose` | Enable verbose (debug) logging |
77
-
78
- ### Minification Options
79
-
80
- | Option | Description |
81
- |--------|-------------|
82
- | `--no-minify-html` | Disable HTML minification |
83
- | `--no-minify-css` | Disable CSS minification |
84
- | `--no-minify-js` | Disable JavaScript minification |
85
-
86
- ### Recursive Crawling
87
-
88
- | Option | Description |
89
- |--------|-------------|
90
- | `-r, --recursive [depth]` | Recursively crawl site (default depth: 1) |
91
- | `--max-depth <n>` | Set maximum depth for recursive crawl |
92
-
93
- ### Logging
94
-
95
- | Option | Description |
96
- |--------|-------------|
97
- | `--log-level <level>` | Set logging level: debug, info, warn, error, silent, none |
98
-
99
- ## ๐Ÿ“‹ CLI Examples
100
-
101
- ### Basic Examples
40
+ | `-r, --recursive [n]` | Crawl site up to n levels deep |
41
+ | `--max-depth <n>` | Explicit crawl depth |
42
+ | `-m, --minify` | Enable all minification |
43
+ | `--no-minify-*` | Disable html, css, or js minify |
44
+ | `-e, --embed-assets` | Inline all assets (default: true) |
45
+ | `--no-embed-assets` | Leave links as-is |
46
+ | `-b, --base-url <url>` | Override base URL resolution |
47
+ | `-v, --verbose` | Show debug output |
48
+ | `--log-level <lvl>` | Set log level: debug, info, warn, error |
49
+ | `-d, --dry-run` | Run without writing file |
50
+
51
+ ### ๐Ÿ“‹ CLI Examples
102
52
 
103
53
  ```bash
104
- # Bundle a local HTML file with default settings
54
+ # Basic
105
55
  portapack ./index.html
56
+ portapack https://example.com
106
57
 
107
- # Bundle a remote page
108
- portapack https://example.com -o example.html
109
-
110
- # Bundle with verbose logging
111
- portapack ./index.html -v
112
- ```
113
-
114
- ### Advanced Options
115
-
116
- ```bash
117
- # Disable all minification
118
- portapack ./index.html --no-minify
119
-
120
- # Disable only CSS minification
121
- portapack ./index.html --no-minify-css
58
+ # With output path
59
+ portapack ./page.html -o dist/output.html
122
60
 
123
- # Customize base URL for asset resolution
124
- portapack ./index.html --base-url https://cdn.example.com
61
+ # Full recursive bundle
62
+ portapack https://example.com --recursive 2 -o full.html
125
63
 
126
- # Keep external links instead of embedding assets
127
- portapack ./index.html --no-embed-assets
128
- ```
64
+ # Dev mode (no minify, verbose)
65
+ portapack ./src/index.html --no-minify -v
129
66
 
130
- ### Recursive Website Bundling
67
+ # Production mode (optimized)
68
+ portapack ./src/index.html -m -o dist/prod.html
131
69
 
132
- ```bash
133
- # Recursively bundle a website (default depth: 1)
134
- portapack https://example.com --recursive
135
-
136
- # Set custom crawl depth (3 levels)
137
- portapack https://example.com --recursive 3
138
-
139
- # Alternative depth syntax
140
- portapack https://example.com --max-depth 3
141
-
142
- # Recursive bundle with all options
143
- portapack https://example.com \
144
- --recursive 2 \
145
- --base-url https://example.com \
146
- --no-minify-js \
147
- --log-level debug \
148
- -o example-site.html
70
+ # Dry run preview
71
+ portapack ./index.html --dry-run
149
72
  ```
150
73
 
151
- ### Customized Workflow Examples
74
+ ## ๐Ÿ“ฆ Node.js API
152
75
 
153
- ```bash
154
- # Development workflow: no minification + verbose logs
155
- portapack ./dev/index.html --no-minify -v -o ./dev/bundle.html
76
+ PortaPack is fully usable via code.
156
77
 
157
- # Production workflow: full optimization
158
- portapack ./src/index.html -o ./dist/index.html
78
+ ### Simple Usage
159
79
 
160
- # Test run without writing output
161
- portapack ./index.html --dry-run -v
80
+ ```typescript
81
+ import { pack } from 'portapack';
162
82
 
163
- # Custom logging level
164
- portapack ./index.html --log-level warn
83
+ const result = await pack('./index.html'); // local or URL
84
+ console.log(result.html); // bundled HTML
165
85
  ```
166
86
 
167
- ## ๐Ÿ›  Node.js API
168
-
169
- PortaPack provides a flexible JavaScript/TypeScript API that can be used in your own projects.
170
-
171
- ### Main Functions
172
-
173
- The library exports these primary functions:
174
-
175
- | Function | Description |
176
- |----------|-------------|
177
- | `generatePortableHTML()` | Bundle a single HTML file or URL with its assets |
178
- | `generateRecursivePortableHTML()` | Recursively crawl and bundle a website |
179
- | `fetchAndPackWebPage()` | Fetch and pack a single web page |
180
- | `bundleMultiPageHTML()` | Bundle multiple HTML pages into a single file |
181
-
182
- ### Basic API Usage
87
+ ### With Options
183
88
 
184
89
  ```typescript
185
- import { generatePortableHTML } from 'portapack';
90
+ import { pack, LogLevel } from 'portapack';
91
+
92
+ const result = await pack('https://example.com', {
93
+ minifyCss: true,
94
+ minifyJs: false,
95
+ recursive: 2,
96
+ output: 'site.html',
97
+ logLevel: LogLevel.INFO
98
+ });
99
+ ```
186
100
 
187
- // Simple usage with local file
188
- const result = await generatePortableHTML('./index.html');
189
- console.log(`Generated HTML: ${result.html.length} bytes`);
190
- console.log(`Build time: ${result.metadata.buildTimeMs}ms`);
101
+ ### Save to Disk
191
102
 
192
- // Simple usage with remote URL
193
- const remoteResult = await generatePortableHTML('https://example.com');
103
+ ```typescript
104
+ import fs from 'fs';
105
+ fs.writeFileSync('output.html', result.html);
194
106
  ```
195
107
 
196
108
  ### Advanced API Usage
197
109
 
110
+ You can access individual building blocks too:
111
+
198
112
  ```typescript
199
- import {
200
- generatePortableHTML,
113
+ import {
114
+ generatePortableHTML,
201
115
  generateRecursivePortableHTML,
202
- LogLevel
116
+ bundleMultiPageHTML,
117
+ fetchAndPackWebPage,
203
118
  } from 'portapack';
204
-
205
- // With full options
206
- const result = await generatePortableHTML('./index.html', {
207
- embedAssets: true, // Embed assets as data URIs
208
- minifyHtml: true, // Minify HTML
209
- minifyCss: true, // Minify CSS
210
- minifyJs: true, // Minify JavaScript
211
- baseUrl: './src', // Base URL for resolving assets
212
- logLevel: LogLevel.INFO // Set logging level
213
- });
214
-
215
- // Save the HTML to a file
216
- import fs from 'fs';
217
- fs.writeFileSync('output.html', result.html, 'utf-8');
218
-
219
- // Access build metadata
220
- console.log(`Build Stats:
221
- - Input: ${result.metadata.input}
222
- - Output Size: ${result.metadata.outputSize} bytes
223
- - Assets: ${result.metadata.assetCount}
224
- - Build Time: ${result.metadata.buildTimeMs}ms
225
- `);
226
119
  ```
227
120
 
228
- ### Recursive Website Crawling
229
-
230
- ```typescript
231
- import { generateRecursivePortableHTML } from 'portapack';
232
-
233
- // Crawl a website with depth 2
234
- const result = await generateRecursivePortableHTML(
235
- 'https://example.com',
236
- 2,
237
- { logLevel: LogLevel.DEBUG }
238
- );
121
+ | Function | Purpose |
122
+ |----------|---------|
123
+ | `generatePortableHTML()` | Bundle a single file or URL |
124
+ | `generateRecursivePortableHTML()` | Crawl & bundle entire site |
125
+ | `fetchAndPackWebPage()` | Just fetch HTML (no asset processing) |
126
+ | `bundleMultiPageHTML()` | Combine multiple HTMLs with router |
239
127
 
240
- console.log(`Bundled ${result.metadata.pagesBundled} pages`);
241
- ```
128
+ ## ๐Ÿงช Use Cases
242
129
 
243
- ### Multi-page Bundling
130
+ - Archive pages for offline use
131
+ - Create demo bundles without a web server
132
+ - Simplify distribution of small apps
133
+ - QA test static assets
134
+ - Embed pages in PDFs or ebooks
135
+ - Analyze asset weight impact
244
136
 
245
- ```typescript
246
- import { bundleMultiPageHTML } from 'portapack';
137
+ ## ๐Ÿค Contribute
247
138
 
248
- // Define multiple pages to bundle
249
- const pages = [
250
- { url: '/home', html: '<h1>Home</h1>' },
251
- { url: '/about', html: '<h1>About</h1>' },
252
- { url: '/contact', html: '<h1>Contact</h1>' }
253
- ];
254
-
255
- // Bundle into a single HTML with client-side router
256
- const html = bundleMultiPageHTML(pages);
139
+ ```bash
140
+ # Get started
141
+ git clone https://github.com/manicinc/portapack
142
+ cd portapack
143
+ npm install
144
+ npm run dev
257
145
  ```
258
146
 
259
- ## ๐Ÿค Contribute & Support
260
-
261
- [![GitHub Sponsors](https://img.shields.io/badge/Sponsor-Manic_Agency-red?style=for-the-badge&logo=github&logoColor=white)](https://github.com/sponsors/manicinc)
262
- [![Discord](https://img.shields.io/discord/your-discord-invite?style=for-the-badge&logo=discord&logoColor=white&label=Join%20Community&color=5865F2)](https://discord.gg/DzNgXdYm)
263
-
264
- 1. Fork the repo
265
- 2. Create a feature branch
266
- 3. Commit with `npm run commit`
267
- 4. Push & open a PR
268
-
269
147
  ## ๐Ÿ“Š Project Health
270
148
 
271
- <!-- | Aspect | Status |
272
- |--------|--------|
273
- | **Tests** | [![Coverage](https://img.shields.io/codecov/c/github/manicinc/portapack?style=flat-square)](https://codecov.io/gh/manicinc/portapack) |
274
- | **Code Quality** | [![Maintainability](https://img.shields.io/codeclimate/maintainability/manicinc/portapack?style=flat-square)](https://codeclimate.com/github/manicinc/portapack) |
275
- | **Dependencies** | [![Dependencies](https://img.shields.io/librariesio/github/manicinc/portapack?style=flat-square)](https://libraries.io/github/manicinc/portapack) | -->
276
-
277
- ## ๐ŸŒ Connect
278
-
279
- [![Twitter](https://img.shields.io/twitter/follow/manicagency?style=social)](https://x.com/manicagency)
280
- [![LinkedIn](https://img.shields.io/badge/LinkedIn-Manic_Agency-0A66C2?style=flat-square&logo=linkedin)](https://www.linkedin.com/company/manic-agency-llc/)
149
+ (Metrics auto-generated coming soon)
281
150
 
282
151
  ## ๐Ÿ“„ License
283
152
 
284
- **MIT** โ€” Built by [Manic Agency](https://manicagency.com)
153
+ MIT โ€” Built with โœจ by Manic Agency
285
154
 
286
- <div align="center">
287
- <sub>Open Source Empowering Designers and Developers ๐Ÿ–ฅ๏ธ</sub>
288
- </div>
155
+ *Open Source Empowering Designers and Developers ๐Ÿ–ฅ๏ธ*