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.
@@ -23,11 +23,12 @@ jobs:
23
23
  cache: 'npm'
24
24
 
25
25
  - run: npm ci
26
- # - run: npm run test:ci
27
- # - run: npm run lint
28
- # - run: npm run format:check
29
- - run: npm run build # for now we keep it simple to release
26
+ - run: npm run test:ci
30
27
 
28
+ - name: Upload coverage to Codecov
29
+ uses: codecov/codecov-action@v4
30
+ with:
31
+ token: ${{ secrets.CODECOV_TOKEN }}
31
32
  # coverage:
32
33
  # needs: build
33
34
  # runs-on: ubuntu-latest
package/CHANGELOG.md CHANGED
@@ -1,3 +1,23 @@
1
+ ## [0.3.1](https://github.com/manicinc/portapack/compare/v0.3.0...v0.3.1) (2025-04-14)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **ci:** update Codecov config [skip release] ([593b126](https://github.com/manicinc/portapack/commit/593b1262183d05a9a7099463b6da0f4deb916576))
7
+ * **extractor:** resolve test failures and coverage issues ([40ea42c](https://github.com/manicinc/portapack/commit/40ea42cbdbeec67657225c50eb97ef0965cd2769))
8
+
9
+ # [0.3.0](https://github.com/manicinc/portapack/compare/v0.2.1...v0.3.0) (2025-04-13)
10
+
11
+
12
+ ### Bug Fixes
13
+
14
+ * **cli:** fix CLI execution via npx and global install ([88774e8](https://github.com/manicinc/portapack/commit/88774e80d28d0ac9292906ac7454d4528a5396ec))
15
+
16
+
17
+ ### Features
18
+
19
+ * api upgrades / revamps; update types; more robust core features and test fixes; update docs ([34e7b4a](https://github.com/manicinc/portapack/commit/34e7b4af55c6c934af8be0f1c43d427fd00a9594))
20
+
1
21
  ## [0.2.1](https://github.com/manicinc/portapack/compare/v0.2.0...v0.2.1) (2025-04-11)
2
22
 
3
23
 
package/README.md CHANGED
@@ -1,18 +1,13 @@
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
- [![Coverage Status](https://img.shields.io/coveralls/github/manicinc/portapack?style=for-the-badge&logo=codecov)](https://coveralls.io/github/manicinc/portapack)
9
- </div>
5
+ [![Codecov](https://img.shields.io/codecov/c/github/manicinc/portapack?style=for-the-badge&logo=codecov)](https://codecov.io/gh/manicinc/portapack)
6
+ [![License: MIT](https://img.shields.io/badge/license-MIT-green.svg?style=for-the-badge)](./LICENSE)
10
7
 
11
- ## ๐ŸŒŸ Introduction
8
+ **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
9
 
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!)
10
+ *Minimal input. Maximal output.*
16
11
 
17
12
  ## ๐Ÿ“š Documentation
18
13
 
@@ -22,267 +17,134 @@ See our [roadmap]() (coming soon!)
22
17
  - [๐Ÿ’ป API Reference](https://manicinc.github.io/portapack/api/)
23
18
  - [๐Ÿค Contributing Guidelines](https://manicinc.github.io/portapack/contributing)
24
19
 
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
20
  ## ๐Ÿš€ Quick Start
36
21
 
37
- ### Installation
22
+ ### ๐Ÿ“ฆ Install
38
23
 
39
24
  ```bash
40
- # Global install
25
+ # Global CLI (recommended)
41
26
  npm install -g portapack
42
27
 
43
- # Project dependency
44
- npm install --save-dev portapack
45
- ```
46
-
47
- ### Basic Usage
48
-
49
- ```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
28
+ # OR use npx (no install needed)
29
+ npx portapack ./index.html -o bundle.html
55
30
  ```
56
31
 
57
- ## ๐Ÿ’ป CLI Reference
58
-
59
- ### Command Syntax
32
+ ### ๐Ÿงฐ CLI Options
60
33
 
61
34
  ```bash
62
- portapack [options] [input]
35
+ portapack [input] [options]
63
36
  ```
64
37
 
65
- ### Core Options
66
-
67
38
  | Option | Description |
68
39
  |--------|-------------|
69
40
  | `-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
41
+ | `-r, --recursive [n]` | Crawl site up to n levels deep |
42
+ | `--max-depth <n>` | Explicit crawl depth |
43
+ | `-m, --minify` | Enable all minification |
44
+ | `--no-minify-*` | Disable html, css, or js minify |
45
+ | `-e, --embed-assets` | Inline all assets (default: true) |
46
+ | `--no-embed-assets` | Leave links as-is |
47
+ | `-b, --base-url <url>` | Override base URL resolution |
48
+ | `-v, --verbose` | Show debug output |
49
+ | `--log-level <lvl>` | Set log level: debug, info, warn, error |
50
+ | `-d, --dry-run` | Run without writing file |
51
+
52
+ ### ๐Ÿ“‹ CLI Examples
102
53
 
103
54
  ```bash
104
- # Bundle a local HTML file with default settings
55
+ # Basic
105
56
  portapack ./index.html
57
+ portapack https://example.com
106
58
 
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
122
-
123
- # Customize base URL for asset resolution
124
- portapack ./index.html --base-url https://cdn.example.com
59
+ # With output path
60
+ portapack ./page.html -o dist/output.html
125
61
 
126
- # Keep external links instead of embedding assets
127
- portapack ./index.html --no-embed-assets
128
- ```
129
-
130
- ### Recursive Website Bundling
131
-
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
149
- ```
150
-
151
- ### Customized Workflow Examples
152
-
153
- ```bash
154
- # Development workflow: no minification + verbose logs
155
- portapack ./dev/index.html --no-minify -v -o ./dev/bundle.html
62
+ # Full recursive bundle
63
+ portapack https://example.com --recursive 2 -o full.html
156
64
 
157
- # Production workflow: full optimization
158
- portapack ./src/index.html -o ./dist/index.html
65
+ # Dev mode (no minify, verbose)
66
+ portapack ./src/index.html --no-minify -v
159
67
 
160
- # Test run without writing output
161
- portapack ./index.html --dry-run -v
68
+ # Production mode (optimized)
69
+ portapack ./src/index.html -m -o dist/prod.html
162
70
 
163
- # Custom logging level
164
- portapack ./index.html --log-level warn
71
+ # Dry run preview
72
+ portapack ./index.html --dry-run
165
73
  ```
166
74
 
167
- ## ๐Ÿ›  Node.js API
75
+ ## ๐Ÿ“ฆ Node.js API
168
76
 
169
- PortaPack provides a flexible JavaScript/TypeScript API that can be used in your own projects.
77
+ PortaPack is fully usable via code.
170
78
 
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
79
+ ### Simple Usage
183
80
 
184
81
  ```typescript
185
- import { generatePortableHTML } from 'portapack';
186
-
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`);
82
+ import { pack } from 'portapack';
191
83
 
192
- // Simple usage with remote URL
193
- const remoteResult = await generatePortableHTML('https://example.com');
84
+ const result = await pack('./index.html'); // local or URL
85
+ console.log(result.html); // bundled HTML
194
86
  ```
195
87
 
196
- ### Advanced API Usage
88
+ ### With Options
197
89
 
198
90
  ```typescript
199
- import {
200
- generatePortableHTML,
201
- generateRecursivePortableHTML,
202
- LogLevel
203
- } 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
91
+ import { pack, LogLevel } from 'portapack';
92
+
93
+ const result = await pack('https://example.com', {
94
+ minifyCss: true,
95
+ minifyJs: false,
96
+ recursive: 2,
97
+ output: 'site.html',
98
+ logLevel: LogLevel.INFO
213
99
  });
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
100
  ```
227
101
 
228
- ### Recursive Website Crawling
102
+ ### Save to Disk
229
103
 
230
104
  ```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
- );
239
-
240
- console.log(`Bundled ${result.metadata.pagesBundled} pages`);
105
+ import fs from 'fs';
106
+ fs.writeFileSync('output.html', result.html);
241
107
  ```
242
108
 
243
- ### Multi-page Bundling
244
-
245
- ```typescript
246
- import { bundleMultiPageHTML } from 'portapack';
109
+ ### Advanced API Usage
247
110
 
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
- ];
111
+ You can access individual building blocks too:
254
112
 
255
- // Bundle into a single HTML with client-side router
256
- const html = bundleMultiPageHTML(pages);
113
+ ```typescript
114
+ import {
115
+ generatePortableHTML,
116
+ generateRecursivePortableHTML,
117
+ bundleMultiPageHTML,
118
+ fetchAndPackWebPage,
119
+ } from 'portapack';
257
120
  ```
258
121
 
259
- ## ๐Ÿค Contribute & Support
122
+ | Function | Purpose |
123
+ |----------|---------|
124
+ | `generatePortableHTML()` | Bundle a single file or URL |
125
+ | `generateRecursivePortableHTML()` | Crawl & bundle entire site |
126
+ | `fetchAndPackWebPage()` | Just fetch HTML (no asset processing) |
127
+ | `bundleMultiPageHTML()` | Combine multiple HTMLs with router |
260
128
 
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)
129
+ ## ๐Ÿค Contribute
263
130
 
264
- 1. Fork the repo
265
- 2. Create a feature branch
266
- 3. Commit with `npm run commit`
267
- 4. Push & open a PR
131
+ ```bash
132
+ # Get started
133
+ git clone https://github.com/manicinc/portapack
134
+ cd portapack
135
+ npm install
136
+ npm run dev
137
+ ```
268
138
 
269
139
  ## ๐Ÿ“Š Project Health
270
140
 
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/)
141
+ | Metric | Value |
142
+ |--------------|-------|
143
+ | ๐Ÿ“ฆ Version | [![npm](https://img.shields.io/npm/v/portapack.svg)](https://www.npmjs.com/package/portapack) |
144
+ | โœ… Build | [![Build Status](https://img.shields.io/github/actions/workflow/status/manicinc/portapack/ci.yml?branch=master)](https://github.com/manicinc/portapack/actions) |
145
+ | ๐Ÿงช Coverage | [![Codecov](https://img.shields.io/codecov/c/github/manicinc/portapack)](https://codecov.io/gh/manicinc/portapack) |
281
146
 
282
147
  ## ๐Ÿ“„ License
283
148
 
284
- **MIT** โ€” Built by [Manic Agency](https://manicagency.com)
149
+ MIT โ€” Built by Manic.agency
285
150
 
286
- <div align="center">
287
- <sub>Open Source Empowering Designers and Developers ๐Ÿ–ฅ๏ธ</sub>
288
- </div>