@zktx.io/walrus-sites-preview 0.0.2 → 0.1.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 zktx.io
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,95 +1,252 @@
1
- # Walrus Sites Preview (CLI)
1
+ <p align="center">
2
+ <img src="https://raw.githubusercontent.com/zktx-io/walrus-sites-preview/main/Walrus_Logotype_Black.png" alt="Walrus" width="360" />
3
+ </p>
2
4
 
3
- Installable CLI to preview Walrus Sites locally:
5
+ # Walrus Sites Preview
4
6
 
5
- - **site mode**: fetch resources via Sui RPC + Walrus aggregator for a given site object ID
7
+ Preview Walrus Sites already deployed on testnet or mainnet through a familiar
8
+ **npm → localhost** workflow.
9
+
10
+ Walrus Sites Preview is a small CLI for opening a current deployment locally
11
+ during design review, QA, planning review, or stakeholder feedback. It is meant
12
+ to sit alongside existing Walrus portal and deployment workflows, not replace
13
+ them.
14
+
15
+ A developer can share one command, and teammates can review the deployed site on
16
+ `localhost` using the same kind of browser workflow they use for regular web
17
+ projects.
18
+
19
+ ---
20
+
21
+ ## Demo Video
22
+
23
+ A short demo showing how to preview a deployed Walrus Site locally:
24
+
25
+ https://github.com/user-attachments/assets/c28c033a-92c5-4ee9-82e0-1406319842c7
26
+
27
+ ---
28
+
29
+ ## Quickstart (one-liner)
30
+
31
+ Preview a deployed Walrus Site in a single command:
32
+
33
+ ```sh
34
+ npx @zktx.io/walrus-sites-preview -testnet -id 0xYOUR_SITE_OBJECT_ID
35
+ ```
36
+
37
+ Then open:
38
+
39
+ ```text
40
+ http://localhost:3000
41
+ ```
42
+
43
+ You can also add `--open` to open the browser automatically:
44
+
45
+ ```sh
46
+ npx @zktx.io/walrus-sites-preview -testnet -id 0xYOUR_SITE_OBJECT_ID --open
47
+ ```
48
+
49
+ ---
50
+
51
+ ## Why this exists
52
+
53
+ Walrus portals remain the right place for production access, integration
54
+ testing, and portal-specific behavior. This CLI covers a narrower case: quickly
55
+ checking an already deployed site during an internal review cycle.
56
+
57
+ In that situation, teams often need a simple browser URL for the current
58
+ deployment while keeping the existing deployment pipeline unchanged. Provide a
59
+ site object ID, and this CLI fetches the resources and serves a local preview.
60
+
61
+ The goal is to make review handoff simpler while preserving the established
62
+ Walrus workflow.
63
+
64
+ ---
65
+
66
+ ## What it does
67
+
68
+ - Loads a Walrus Site using a site object ID
69
+ - Fetches resources via Sui RPC and the Walrus aggregator
70
+ - Serves the site locally (for example, `http://localhost:3000`)
71
+ - Provides a local review path that can sit alongside portal-based workflows
72
+ - Supports preview, debugging, QA, and review workflows
73
+
74
+ This is **not** a production hosting solution and does not replace Walrus portals.
75
+
76
+ ---
77
+
78
+ ## Who this is for
79
+
80
+ - Developers who want a quick local preview of an already deployed Walrus Site
81
+ - Web designers reviewing visual changes from a testnet deployment
82
+ - Planners, PMs, and QA reviewers checking an in-progress site before release
83
+ - Teams that want a lightweight local review command for deployed Walrus Sites
84
+
85
+ For many internal review sessions, a reviewer can start with the command and the
86
+ site object ID. Wallets and deployment keys are not part of the preview flow.
87
+
88
+ ---
6
89
 
7
90
  ## Requirements
8
91
 
9
- - Node.js 18+
92
+ - Node.js 18 or later
93
+
94
+ ---
10
95
 
11
- ## Install (as dev dependency)
96
+ ## Install
12
97
 
13
98
  ```sh
14
99
  npm i -D @zktx.io/walrus-sites-preview
15
100
  ```
16
101
 
17
- ## Run (via npm script)
102
+ > Note: This package is published as a scoped npm package:
103
+ > `@zktx.io/walrus-sites-preview`
104
+
105
+ ---
106
+
107
+ ## Quick Start (npm scripts)
18
108
 
19
- Add this to your project:
109
+ Add an npm script to your project so teammates can run a familiar command:
20
110
 
21
111
  ```json
22
112
  {
23
113
  "scripts": {
24
114
  "preview:testnet": "preview -testnet -id 0xYOUR_SITE_OBJECT_ID -port 3000",
25
- "preview:mainnet": "preview -mainnet -id 0xYOUR_SITE_OBJECT_ID -port 3000",
26
- "preview": "preview"
115
+ "preview:mainnet": "preview -mainnet -id 0xYOUR_SITE_OBJECT_ID -port 3000"
27
116
  }
28
117
  }
29
118
  ```
30
119
 
31
- Then run:
120
+ Run:
32
121
 
33
122
  ```sh
34
123
  npm run preview:testnet
35
124
  ```
36
125
 
37
- This starts a local server at `http://localhost:3000`.
38
-
39
- You can inspect the effective config at `http://localhost:3000/__config`.
126
+ Then open:
40
127
 
41
- If you prefer a file-based config, create `config.json` next to your `package.json` and pass overrides as needed (the CLI flags win).
128
+ ```text
129
+ http://localhost:3000
130
+ ```
42
131
 
43
- To pass arguments dynamically, use `--`:
132
+ You can inspect the resolved configuration at:
44
133
 
45
- ```sh
46
- npm run preview -- -testnet -id 0xYOUR_SITE_OBJECT_ID -port 3000
134
+ ```text
135
+ http://localhost:3000/__config
47
136
  ```
48
137
 
49
- ## Where `dist` comes from (portal build)
138
+ ---
50
139
 
51
- This section is for maintainers of this package. Consumers don’t need to build `dist/` manually (it ships in the npm package).
140
+ ## How to get a Site Object ID
52
141
 
53
- - Vendored from the walrus-sites portal codebase:
54
- - Source repo: https://github.com/MystenLabs/walrus-sites/tree/main/portal
55
- - `portal/worker` → `./portal-worker`
56
- - `portal/common` → `./portal-common`
57
- - Source: `./portal-worker/src` (service worker TS) and `./portal-worker/static` (static assets)
58
- - Shared libs: `./portal-common/lib/src` (shared implementation used by the worker)
59
- - Build configs: `./webpack.config.*.cjs` (kept in this repo, not published)
60
- - Build command:
142
+ `walrus-sites-preview` requires a **Walrus Site Object ID**.
61
143
 
62
- ```sh
63
- npm install
64
- npm run build
144
+ When a site is deployed to Walrus Sites — whether via the official site-builder CLI or a CI workflow — the **Site Object ID is printed in the deployment output**.
145
+
146
+ Look for a line similar to:
147
+
148
+ ```text
149
+ Site object ID: 0x...
150
+ ```
151
+
152
+ or:
153
+
154
+ ```text
155
+ "site_obj_id": "0x..."
65
156
  ```
66
157
 
67
- ## Publish
158
+ Copy this value and pass it to the preview command.
68
159
 
69
- This package is set up to publish with `dist/` included. `npm pack` / `npm publish` runs `prepack`, which rebuilds `dist/` via `npm run build`.
160
+ For detailed deployment guides, see:
70
161
 
71
- ## Maintainers: static mode
162
+ - Publishing a Walrus Site (official docs):
163
+ [https://docs.wal.app/docs/sites/getting-started/publishing-your-first-site](https://docs.wal.app/docs/sites/getting-started/publishing-your-first-site)
164
+ - Deploying via GitHub Actions (walrus-sites-provenance):
165
+ [https://github.com/marketplace/actions/walrus-sites-provenance](https://github.com/marketplace/actions/walrus-sites-provenance)
72
166
 
73
- If you only want to serve a local static folder as a SPA:
167
+ > This tool does not deploy or update sites.
168
+ > It only previews already deployed Walrus Sites.
74
169
 
75
- ```sh
76
- npx preview --mode static --dist ./dist -port 3000
170
+ ---
171
+
172
+ ## Configuration
173
+
174
+ You may optionally create a `config.json` next to your `package.json`.
175
+
176
+ CLI flags always override file-based configuration.
177
+
178
+ When using `-testnet` or `-mainnet`, the following values are filled automatically:
179
+
180
+ - `rpcUrlList`
181
+ - `aggregatorUrl`
182
+ - `sitePackage`
183
+
184
+ ### Supported fields
185
+
186
+ - `siteObjectId` (required)
187
+ - `rpcUrlList` (required unless using `-testnet` / `-mainnet`)
188
+ - `aggregatorUrl` (required unless using `-testnet` / `-mainnet`)
189
+ - `sitePackage` (required unless using `-testnet` / `-mainnet`)
190
+ - `network` (optional, informational)
191
+ - `host`, `port` (via CLI flags)
192
+
193
+ ### Example
194
+
195
+ ```json
196
+ {
197
+ "network": "testnet",
198
+ "rpcUrlList": ["https://fullnode.testnet.sui.io"],
199
+ "aggregatorUrl": "https://aggregator.walrus-testnet.walrus.space",
200
+ "sitePackage": "0x...",
201
+ "siteObjectId": "0x..."
202
+ }
77
203
  ```
78
204
 
79
- If your `dist` lives somewhere else:
205
+ ---
206
+
207
+ ## Passing arguments dynamically
208
+
209
+ Install the package:
80
210
 
81
211
  ```sh
82
- npx preview --mode static --dist /absolute/path/to/dist
212
+ npm i -D @zktx.io/walrus-sites-preview
83
213
  ```
84
214
 
85
- ## Options
215
+ Add a pass-through script:
86
216
 
87
- ```sh
88
- npx preview -port 8090 --open
217
+ ```json
218
+ {
219
+ "scripts": {
220
+ "preview": "preview"
221
+ }
222
+ }
89
223
  ```
90
224
 
91
- Override site config without editing `config.json`:
225
+ Then run:
92
226
 
93
227
  ```sh
94
- npx preview --site-object-id 0x... --rpc https://fullnode.mainnet.sui.io --aggregator https://aggregator.walrus-mainnet.walrus.space --site-package 0x...
228
+ npm run preview -- -testnet -id 0xYOUR_SITE_OBJECT_ID -port 3000
95
229
  ```
230
+
231
+ ---
232
+
233
+ ## Source attribution
234
+
235
+ This package vendors and adapts parts of the Walrus Sites portal source code.
236
+
237
+ The vendored portal worker code is currently aligned with the upstream
238
+ `portal/worker` package version `2.9.0`.
239
+
240
+ Origin of the bundled `dist` assets (portal build):
241
+
242
+ - Source repository:
243
+ [https://github.com/MystenLabs/walrus-sites/tree/main/portal](https://github.com/MystenLabs/walrus-sites/tree/main/portal)
244
+ - `portal/worker` → `./portal-worker`
245
+ - `portal/common` → `./portal-common`
246
+ - Included sources:
247
+ - `./portal-worker/src` (service worker TypeScript)
248
+ - `./portal-worker/static` (static assets)
249
+
250
+ ## License
251
+
252
+ MIT