Compare commits

...

2 Commits

Author SHA1 Message Date
fiatjaf
b96159ad36 better publishing built files. 2022-12-20 16:56:05 -03:00
fiatjaf
6dede4a688 use semisol relay that has our desired event on test. 2022-12-20 16:26:55 -03:00
11 changed files with 36 additions and 25 deletions

View File

@@ -1,8 +1,8 @@
name: publish npm package
on:
release:
types: [created]
push:
tags: [v*]
jobs:
publish-npm:
@@ -11,8 +11,9 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16
registry-url: https://registry.npmjs.org/
node-version: 18
- run: yarn --ignore-engines
- run: node build.js
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{secrets.npm_token}}
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}

View File

@@ -1,6 +1,8 @@
name: test every commit
on:
- push
push:
branches:
- master
jobs:
test:
@@ -11,5 +13,5 @@ jobs:
with:
node-version: 18
- run: yarn --ignore-engines
- run: node build.cjs
- run: node build.js
- run: yarn test

4
.gitignore vendored
View File

@@ -3,7 +3,5 @@ dist
yarn.lock
package-lock.json
.envrc
standalone
cjs
esm
lib
test.html

View File

@@ -153,7 +153,7 @@ Please consult the tests or [the source code](https://github.com/fiatjaf/nostr-t
### Using from the browser (if you don't want to use a bundler)
```html
<script src="https://unpkg.com/nostr-tools/standalone/index.js"></script>
<script src="https://unpkg.com/nostr-tools/nostr.bundle.js"></script>
<script>
window.NostrTools.generatePrivateKey('...') // and so on
</script>

View File

@@ -15,17 +15,27 @@ let common = {
}
esbuild
.build({...common, outdir: 'esm/', format: 'esm', packages: 'external'})
.build({
...common,
outfile: 'lib/nostr.esm.js',
format: 'esm',
packages: 'external'
})
.then(() => console.log('esm build success.'))
esbuild
.build({...common, outdir: 'cjs/', format: 'cjs', packages: 'external'})
.build({
...common,
outfile: 'lib/nostr.cjs.js',
format: 'cjs',
packages: 'external'
})
.then(() => console.log('cjs build success.'))
esbuild
.build({
...common,
outdir: 'standalone/',
outfile: 'lib/nostr.bundle.js',
format: 'iife',
globalName: 'NostrTools',
define: {

View File

@@ -6,7 +6,7 @@ const {
signEvent,
getEventHash,
getPublicKey
} = require('./cjs')
} = require('./lib/nostr.cjs')
const event = {
id: 'd7dd5eb3ab747e16f8d0212d53032ea2a7cadef53837e5a6c66d42849fcb9027',

View File

@@ -1,6 +1,6 @@
/* eslint-env jest */
const {matchFilters} = require('./cjs')
const {matchFilters} = require('./lib/nostr.cjs')
test('test if filters match', () => {
;[

View File

@@ -1,6 +1,6 @@
/* eslint-env jest */
const {generatePrivateKey, getPublicKey} = require('./cjs')
const {generatePrivateKey, getPublicKey} = require('./lib/nostr.cjs')
test('test private key generation', () => {
expect(generatePrivateKey()).toMatch(/[a-f0-9]{64}/)

View File

@@ -1,6 +1,6 @@
/* eslint-env jest */
const {nip04, getPublicKey, generatePrivateKey} = require('./cjs')
const {nip04, getPublicKey, generatePrivateKey} = require('./lib/nostr.cjs')
test('encrypt and decrypt message', () => {
let sk1 = generatePrivateKey()

View File

@@ -1,13 +1,13 @@
{
"name": "nostr-tools",
"version": "1.0.0-alpha",
"version": "1.0.0-alpha2",
"description": "Tools for making a Nostr client.",
"repository": {
"type": "git",
"url": "https://github.com/fiatjaf/nostr-tools.git"
},
"main": "cjs/index.js",
"module": "esm/index.js",
"main": "lib/nostr.cjs.js",
"module": "lib/nostr.esm.js",
"dependencies": {
"@noble/hashes": "^0.5.7",
"@noble/secp256k1": "^1.7.0",
@@ -40,8 +40,8 @@
"typescript": "^4.9.4"
},
"scripts": {
"build": "node build.cjs",
"pretest": "node build.cjs",
"build": "node build.js",
"pretest": "node build.js",
"test": "jest"
}
}

View File

@@ -6,10 +6,10 @@ const {
getPublicKey,
getEventHash,
signEvent
} = require('./cjs')
} = require('./lib/nostr.cjs')
describe('relay interaction', () => {
let relay = relayInit('wss://nostr-pub.wellorder.net/')
let relay = relayInit('wss://nostr-pub.semisol.dev/')
beforeAll(() => {
relay.connect()