Skip to content

Commit b96159a

Browse files
committed
better publishing built files.
1 parent 6dede4a commit b96159a

11 files changed

+35
-24
lines changed

.github/workflows/npm-publish.yml

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
name: publish npm package
22

33
on:
4-
release:
5-
types: [created]
4+
push:
5+
tags: [v*]
66

77
jobs:
88
publish-npm:
@@ -11,8 +11,9 @@ jobs:
1111
- uses: actions/checkout@v3
1212
- uses: actions/setup-node@v3
1313
with:
14-
node-version: 16
15-
registry-url: https://registry.npmjs.org/
14+
node-version: 18
15+
- run: yarn --ignore-engines
16+
- run: node build.js
1617
- run: npm publish
1718
env:
18-
NODE_AUTH_TOKEN: ${{secrets.npm_token}}
19+
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}

.github/workflows/test.yml

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
name: test every commit
22
on:
3-
- push
3+
push:
4+
branches:
5+
- master
46

57
jobs:
68
test:
@@ -11,5 +13,5 @@ jobs:
1113
with:
1214
node-version: 18
1315
- run: yarn --ignore-engines
14-
- run: node build.cjs
16+
- run: node build.js
1517
- run: yarn test

.gitignore

+1-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,5 @@ dist
33
yarn.lock
44
package-lock.json
55
.envrc
6-
standalone
7-
cjs
8-
esm
6+
lib
97
test.html

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ Please consult the tests or [the source code](https://github.com/fiatjaf/nostr-t
153153
### Using from the browser (if you don't want to use a bundler)
154154

155155
```html
156-
<script src="https://unpkg.com/nostr-tools/standalone/index.js"></script>
156+
<script src="https://unpkg.com/nostr-tools/nostr.bundle.js"></script>
157157
<script>
158158
window.NostrTools.generatePrivateKey('...') // and so on
159159
</script>

build.cjs build.js

+13-3
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,27 @@ let common = {
1515
}
1616

1717
esbuild
18-
.build({...common, outdir: 'esm/', format: 'esm', packages: 'external'})
18+
.build({
19+
...common,
20+
outfile: 'lib/nostr.esm.js',
21+
format: 'esm',
22+
packages: 'external'
23+
})
1924
.then(() => console.log('esm build success.'))
2025

2126
esbuild
22-
.build({...common, outdir: 'cjs/', format: 'cjs', packages: 'external'})
27+
.build({
28+
...common,
29+
outfile: 'lib/nostr.cjs.js',
30+
format: 'cjs',
31+
packages: 'external'
32+
})
2333
.then(() => console.log('cjs build success.'))
2434

2535
esbuild
2636
.build({
2737
...common,
28-
outdir: 'standalone/',
38+
outfile: 'lib/nostr.bundle.js',
2939
format: 'iife',
3040
globalName: 'NostrTools',
3141
define: {

event.test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const {
66
signEvent,
77
getEventHash,
88
getPublicKey
9-
} = require('./cjs')
9+
} = require('./lib/nostr.cjs')
1010

1111
const event = {
1212
id: 'd7dd5eb3ab747e16f8d0212d53032ea2a7cadef53837e5a6c66d42849fcb9027',

filter.test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* eslint-env jest */
22

3-
const {matchFilters} = require('./cjs')
3+
const {matchFilters} = require('./lib/nostr.cjs')
44

55
test('test if filters match', () => {
66
;[

keys.test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* eslint-env jest */
22

3-
const {generatePrivateKey, getPublicKey} = require('./cjs')
3+
const {generatePrivateKey, getPublicKey} = require('./lib/nostr.cjs')
44

55
test('test private key generation', () => {
66
expect(generatePrivateKey()).toMatch(/[a-f0-9]{64}/)

nip04.test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* eslint-env jest */
22

3-
const {nip04, getPublicKey, generatePrivateKey} = require('./cjs')
3+
const {nip04, getPublicKey, generatePrivateKey} = require('./lib/nostr.cjs')
44

55
test('encrypt and decrypt message', () => {
66
let sk1 = generatePrivateKey()

package.json

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
{
22
"name": "nostr-tools",
3-
"version": "1.0.0-alpha",
3+
"version": "1.0.0-alpha2",
44
"description": "Tools for making a Nostr client.",
55
"repository": {
66
"type": "git",
77
"url": "https://github.com/fiatjaf/nostr-tools.git"
88
},
9-
"main": "cjs/index.js",
10-
"module": "esm/index.js",
9+
"main": "lib/nostr.cjs.js",
10+
"module": "lib/nostr.esm.js",
1111
"dependencies": {
1212
"@noble/hashes": "^0.5.7",
1313
"@noble/secp256k1": "^1.7.0",
@@ -40,8 +40,8 @@
4040
"typescript": "^4.9.4"
4141
},
4242
"scripts": {
43-
"build": "node build.cjs",
44-
"pretest": "node build.cjs",
43+
"build": "node build.js",
44+
"pretest": "node build.js",
4545
"test": "jest"
4646
}
4747
}

relay.test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const {
66
getPublicKey,
77
getEventHash,
88
signEvent
9-
} = require('./cjs')
9+
} = require('./lib/nostr.cjs')
1010

1111
describe('relay interaction', () => {
1212
let relay = relayInit('wss://nostr-pub.semisol.dev/')

0 commit comments

Comments
 (0)