nappup 1.8.0 → 1.8.2
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 +23 -3
- package/package.json +1 -1
- package/src/index.js +4 -4
- package/src/services/blossom-upload.js +10 -4
package/README.md
CHANGED
|
@@ -27,8 +27,7 @@ nappup [directory] [options]
|
|
|
27
27
|
| Flag | Description |
|
|
28
28
|
|------|-------------|
|
|
29
29
|
| `-s <secret_key>` | Your Nostr secret key (hex or nsec format) used to sign the application event. See [Authentication](#authentication) for alternatives. |
|
|
30
|
-
| `-
|
|
31
|
-
| `-d <d_tag>` | The exact identifier (`d` tag) for your application. Only use this if you know the exact `d` tag you want. Otherwise, use `-D`. If both are omitted, defaults to deriving the identifier from the directory name. Avoid generic names like `dist` or `build` - use something unique among your other apps like `mycoolapp`. |
|
|
30
|
+
| `-d <d_tag>` | The identifier (`d` tag) for your application. Any UTF-8 text up to 260 characters. If omitted, defaults to the directory name. Avoid generic names like `dist` or `build` - use something unique among your other apps like `mycoolapp`. |
|
|
32
31
|
| `-y` | Skip confirmation prompt. Useful for CI/CD pipelines or automated scripts. |
|
|
33
32
|
| `-r` | Force re-upload. By default, Napp Up! might skip files that haven't changed. Use this flag to ensure everything is pushed fresh. |
|
|
34
33
|
| `--main` | Publish to the **main** release channel. This is the default behavior. |
|
|
@@ -66,10 +65,31 @@ NOSTR_SECRET_KEY=nsec1... nappup
|
|
|
66
65
|
|
|
67
66
|
Upload a specific `dist` folder with a custom identifier to the `next` channel:
|
|
68
67
|
```bash
|
|
69
|
-
nappup ./dist -s nsec1... -
|
|
68
|
+
nappup ./dist -s nsec1... -d "My App #1" --next
|
|
70
69
|
```
|
|
71
70
|
|
|
72
71
|
Force re-upload a draft:
|
|
73
72
|
```bash
|
|
74
73
|
nappup ~/my-repos/projectx/build/projectx --draft -r
|
|
75
74
|
```
|
|
75
|
+
|
|
76
|
+
## Programmatic Usage
|
|
77
|
+
|
|
78
|
+
Napp Up! also exports a function that works in both Node.js and the browser, so you can integrate app uploads directly into your own tooling:
|
|
79
|
+
|
|
80
|
+
```js
|
|
81
|
+
import publishApp from 'nappup'
|
|
82
|
+
|
|
83
|
+
await publishApp(fileList, signer, {
|
|
84
|
+
dTag: 'my-app',
|
|
85
|
+
channel: 'main', // 'main' | 'next' | 'draft'
|
|
86
|
+
shouldReupload: false,
|
|
87
|
+
onEvent ({ type, progress }) {
|
|
88
|
+
console.log(`${type} — ${progress}%`)
|
|
89
|
+
}
|
|
90
|
+
})
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
- **`fileList`** — a `FileList` or array of `File` objects (each needs `webkitRelativePath`).
|
|
94
|
+
- **`signer`** — a [NIP-07](https://github.com/nostr-protocol/nips/blob/master/07.md)-compatible signer. In the browser, `window.nostr` is used automatically if omitted.
|
|
95
|
+
- **`onEvent`** — optional callback that receives progress events with a `type` (`'init'`, `'file-uploaded'`, `'complete'`, `'error'`, …) and `progress` (0–100).
|
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -340,7 +340,7 @@ async function uploadSiteManifest ({ dTag, channel, fileMetadata, uploadService,
|
|
|
340
340
|
draft: 35130 // vibe coded preview
|
|
341
341
|
}[channel] ?? 35128
|
|
342
342
|
|
|
343
|
-
const pathTags = fileMetadata.map(v => ['path', v.
|
|
343
|
+
const pathTags = fileMetadata.map(v => ['path', v.filename, v.rootHash])
|
|
344
344
|
const tags = [
|
|
345
345
|
['d', dTag],
|
|
346
346
|
...pathTags,
|
|
@@ -369,11 +369,11 @@ async function uploadSiteManifest ({ dTag, channel, fileMetadata, uploadService,
|
|
|
369
369
|
|
|
370
370
|
if (!shouldReupload && mostRecentEvent) {
|
|
371
371
|
const recentPathTags = mostRecentEvent.tags
|
|
372
|
-
.filter(t => t[0] === 'path' && t[
|
|
372
|
+
.filter(t => t[0] === 'path' && t[1] !== '.well-known/napp.json')
|
|
373
373
|
.sort((a, b) => (a[1] < b[1] ? -1 : a[1] > b[1] ? 1 : 0))
|
|
374
374
|
|
|
375
375
|
const currentPathTags = pathTags
|
|
376
|
-
.filter(t => t[
|
|
376
|
+
.filter(t => t[1] !== '.well-known/napp.json')
|
|
377
377
|
.sort((a, b) => (a[1] < b[1] ? -1 : a[1] > b[1] ? 1 : 0))
|
|
378
378
|
|
|
379
379
|
const recentServiceTag = mostRecentEvent.tags.find(t => t[0] === 'service')
|
|
@@ -381,7 +381,7 @@ async function uploadSiteManifest ({ dTag, channel, fileMetadata, uploadService,
|
|
|
381
381
|
|
|
382
382
|
const isSame = !serviceChanged && currentPathTags.length === recentPathTags.length && currentPathTags.every((t, i) => {
|
|
383
383
|
const rt = recentPathTags[i]
|
|
384
|
-
return rt.length >=
|
|
384
|
+
return rt.length >= 3 && rt[1] === t[1] && rt[2] === t[2]
|
|
385
385
|
})
|
|
386
386
|
|
|
387
387
|
if (isSame) {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { sha256 } from '@noble/hashes/sha2.js'
|
|
1
2
|
import { BlossomClient } from 'nostr-tools/nipb7'
|
|
2
3
|
import nostrRelays from '#services/nostr-relays.js'
|
|
3
4
|
import { bytesToBase16 } from '#helpers/base16.js'
|
|
@@ -67,12 +68,17 @@ export async function healthCheckServers (servers, signer, { log = () => {} } =
|
|
|
67
68
|
}
|
|
68
69
|
|
|
69
70
|
/**
|
|
70
|
-
* Computes the sha256 hex hash of a File/Blob.
|
|
71
|
+
* Computes the sha256 hex hash of a File/Blob using streaming for memory efficiency.
|
|
71
72
|
*/
|
|
72
73
|
export async function computeFileHash (file) {
|
|
73
|
-
const
|
|
74
|
-
const
|
|
75
|
-
|
|
74
|
+
const hash = sha256.create()
|
|
75
|
+
const reader = file.stream().getReader()
|
|
76
|
+
while (true) {
|
|
77
|
+
const { done, value } = await reader.read()
|
|
78
|
+
if (done) break
|
|
79
|
+
hash.update(value)
|
|
80
|
+
}
|
|
81
|
+
return bytesToBase16(hash.digest())
|
|
76
82
|
}
|
|
77
83
|
|
|
78
84
|
/**
|