finish integrating node bindings into core repository

don't ignore core sourcefiles,
prevented npm installation on architectures with no prebuild
don't run lint checks on windows
github actions don't like double quotes apparently
minimize node.js CI
update ubuntu runner to 22.04
README: update link to node bindings source
simplify link in readme
node: fix crash with invalid account id
(throw error when getContext failed)
fix typo in readme
remove node specific changelog
change prebuild machine back to ubuntu 18.04
move package.json to root level to include rust source in npm package
change path in m1 patch
github action to upload to download.delta.chat/node/ on tag
try build with ubuntu 20.04
Update node/README.md
try building it with newer ubuntu because it wants glibc 2.33
fix path for prebuildify script
throw error when instanciating a wrapper class on `null`
(Context, Message, Chat, ChatList and so on)
try fix selecting the right cache
to fix the strange glibc bug
also revert back ubuntu version to 18.04
also bump package.json version with release script
fix paths since we moved around package.json
github action: fix path
document npm release - it's so much easier now!
there are no PR checks to post to if this action is executed on a tag
github action: fix artifact names
fix paths? wtf do I know, it's 3AM and I'm drunk
fix syntax error
don't upload preview if action is run on tag
is the tag ID an empty string or null?
node-package github action is done so far
also include scripts in package
only publish docs on push to master branch
actually bump package.json version in set_core_version script
prettify package.json
fix test - we don't really need to assert that
remove unnecessary ls statement from github action
This commit is contained in:
missytake
2022-05-05 15:54:46 +02:00
committed by Simon Laux
parent b238c7e743
commit c9beaa2aa1
25 changed files with 246 additions and 1977 deletions

View File

@@ -4,7 +4,6 @@ on:
push: push:
branches: branches:
- master - master
- integrate-node-into-repo
jobs: jobs:
generate: generate:

View File

@@ -1,10 +1,14 @@
name: 'Build node.js bindings from PR' name: 'node.js'
on: on:
pull_request: pull_request:
push:
tags:
- '*'
jobs: jobs:
prebuild: prebuild:
name: 'Prebuild' name: 'Tests & Prebuild'
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
strategy: strategy:
matrix: matrix:
@@ -29,7 +33,7 @@ jobs:
path: | path: |
${{ env.APPDATA }}/npm-cache ${{ env.APPDATA }}/npm-cache
~/.npm ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package.json') }} key: ${{ matrix.os }}-node-${{ hashFiles('**/package.json') }}
- name: Cache cargo index - name: Cache cargo index
uses: actions/cache@v2 uses: actions/cache@v2
@@ -38,7 +42,7 @@ jobs:
~/.cargo/registry/ ~/.cargo/registry/
~/.cargo/git ~/.cargo/git
target target
key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}-2 key: ${{ matrix.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}-2
- name: Install dependencies & build - name: Install dependencies & build
if: steps.cache.outputs.cache-hit != 'true' if: steps.cache.outputs.cache-hit != 'true'
@@ -46,6 +50,20 @@ jobs:
cd node cd node
npm install --verbose npm install --verbose
- name: Test
if: runner.os != 'Windows'
run: |
cd node
npm run test
env:
DCC_NEW_TMP_EMAIL: ${{ secrets.DCC_NEW_TMP_EMAIL }}
- name: Run tests on Windows, except lint
if: runner.os == 'Windows'
run: |
cd node
npm run test:mocha
env:
DCC_NEW_TMP_EMAIL: ${{ secrets.DCC_NEW_TMP_EMAIL }}
- name: Build Prebuild - name: Build Prebuild
run: | run: |
cd node cd node
@@ -60,7 +78,7 @@ jobs:
pack-module: pack-module:
needs: prebuild needs: prebuild
name: 'Package the node_module and upload as artifact for testing' name: 'Package deltachat-node and upload to download.delta.chat'
runs-on: ubuntu-18.04 runs-on: ubuntu-18.04
steps: steps:
- name: install tree - name: install tree
@@ -70,10 +88,19 @@ jobs:
- uses: actions/setup-node@v2 - uses: actions/setup-node@v2
with: with:
node-version: '16' node-version: '16'
- name: get tag
id: tag
uses: dawidd6/action-get-tag@v1
continue-on-error: true
- name: Get Pullrequest ID - name: Get Pullrequest ID
id: prepare id: prepare
run: | run: |
node -e "console.log('::set-output name=prid::' + '${{ github.ref }}'.split('/')[2])" tag=${{ steps.tag.outputs.tag }}
if [ -z "$tag" ]; then
node -e "console.log('::set-output name=prid::' + '${{ github.ref }}'.split('/')[2])"
else
echo "No preview will be uploaded this time, but the $tag release"
fi
- name: System info - name: System info
run: | run: |
rustc -vV rustc -vV
@@ -85,38 +112,30 @@ jobs:
uses: actions/download-artifact@v1 uses: actions/download-artifact@v1
with: with:
name: ubuntu-18.04 name: ubuntu-18.04
path: node/
- name: Download macos prebuild - name: Download macos prebuild
uses: actions/download-artifact@v1 uses: actions/download-artifact@v1
with: with:
name: macos-latest name: macos-latest
path: node/
- name: Download windows prebuild - name: Download windows prebuild
uses: actions/download-artifact@v1 uses: actions/download-artifact@v1
with: with:
name: windows-latest name: windows-latest
path: node/
- shell: bash - shell: bash
run: | run: |
cd node
ls -lah
mkdir prebuilds mkdir prebuilds
tar -xvzf ubuntu-18.04.tar.gz -C prebuilds tar -xvzf ubuntu-18.04/ubuntu-18.04.tar.gz -C prebuilds
tar -xvzf macos-latest.tar.gz -C prebuilds tar -xvzf macos-latest/macos-latest.tar.gz -C prebuilds
tar -xvzf windows-latest.tar.gz -C prebuilds tar -xvzf windows-latest/windows-latest.tar.gz -C prebuilds
tree prebuilds tree prebuilds
- name: install dependencies without running scripts - name: install dependencies without running scripts
run: | run: |
cd node
npm install --ignore-scripts npm install --ignore-scripts
- name: build typescript part - name: build typescript part
run: | run: |
cd node
npm run build:bindings:ts npm run build:bindings:ts
- name: package - name: package
shell: bash shell: bash
run: | run: |
cd node
npm pack . npm pack .
ls -lah ls -lah
mv $(find deltachat-node-*) deltachat-node-${{ steps.prepare.outputs.prid }}.tar.gz mv $(find deltachat-node-*) deltachat-node-${{ steps.prepare.outputs.prid }}.tar.gz
@@ -124,20 +143,28 @@ jobs:
uses: actions/upload-artifact@v1 uses: actions/upload-artifact@v1
with: with:
name: deltachat-node.tgz name: deltachat-node.tgz
path: node/deltachat-node-${{ steps.prepare.outputs.prid }}.tar.gz path: deltachat-node-${{ steps.prepare.outputs.prid }}.tar.gz
# Upload Step # Upload to download.delta.chat/node/preview/
- name: upload folder - name: Upload deltachat-node preview to download.delta.chat/node/preview/
id: upload-preview
shell: bash
run: |
echo -e "${{ secrets.SSH_KEY }}" >__TEMP_INPUT_KEY_FILE
chmod 600 __TEMP_INPUT_KEY_FILE
scp -o StrictHostKeyChecking=no -v -i __TEMP_INPUT_KEY_FILE -P "22" -r deltachat-node-${{ steps.prepare.outputs.prid }}.tar.gz "${{ secrets.USERNAME }}"@"download.delta.chat":"/var/www/html/download/node/preview/"
continue-on-error: true
- name: "Post links to details"
if: steps.upload-preview.outcome == 'success'
run: node ./node/scripts/postLinksToDetails.js
env:
URL: preview/deltachat-node-${{ steps.prepare.outputs.prid }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Upload to download.delta.chat/node/
- name: Upload deltachat-node build to download.delta.chat/node/
if: ${{ steps.tag.outputs.tag }}
id: upload id: upload
shell: bash shell: bash
run: | run: |
cd node
echo -e "${{ secrets.SSH_KEY }}" >__TEMP_INPUT_KEY_FILE echo -e "${{ secrets.SSH_KEY }}" >__TEMP_INPUT_KEY_FILE
chmod 600 __TEMP_INPUT_KEY_FILE chmod 600 __TEMP_INPUT_KEY_FILE
scp -o StrictHostKeyChecking=no -v -i __TEMP_INPUT_KEY_FILE -P "22" -r deltachat-node-${{ steps.prepare.outputs.prid }}.tar.gz "${{ secrets.USERNAME }}"@"download.delta.chat":"/var/www/html/download/node/" scp -o StrictHostKeyChecking=no -v -i __TEMP_INPUT_KEY_FILE -P "22" -r deltachat-node-${{ steps.prepare.outputs.prid }}.tar.gz "${{ secrets.USERNAME }}"@"download.delta.chat":"/var/www/html/download/node/"
continue-on-error: true
- name: "Post links to details"
if: steps.upload.outcome == 'success'
run: node ./node/scripts/postLinksToDetails.js
env:
PR_ID: ${{ steps.prepare.outputs.prid }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

View File

@@ -1,65 +0,0 @@
name: 'Run node.js tests'
on:
pull_request:
push:
branches:
- master
- staging
- trying
jobs:
build-and-test:
name: 'Build & Test'
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-18.04, macos-latest, windows-latest]
steps:
- name: Checkout
uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '16'
- name: System info
run: |
rustc -vV
rustup -vV
cargo -vV
npm --version
node --version
- name: Cache node modules
uses: actions/cache@v1
with:
path: ${{ env.APPDATA }}/npm-cache # npm cache files are stored in `~/.npm` on Linux/macOS
key: ${{ runner.os }}-node-${{ hashFiles('**/package.json') }}
- name: Cache cargo index
uses: actions/cache@v2
with:
path: |
~/.cargo/registry/
~/.cargo/git
target
key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}-2
- name: Install dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: |
cd node
npm install --ignore-scripts --verbose
- name: Build deltachat-core-rust & bindings
if: steps.cache.outputs.cache-hit != 'true'
run: |
cd node
npm run build
- name: Test
run: |
cd node
npm run lint-fix
git diff
npm run test
env:
DCC_NEW_TMP_EMAIL: ${{ secrets.DCC_NEW_TMP_EMAIL }}

2
.gitignore vendored
View File

@@ -35,7 +35,7 @@ python/all-testaccounts.txt
tmp/ tmp/
# from deltachat-node # from deltachat-node
node/node_modules/ node_modules/
node/build/ node/build/
node/dist/ node/dist/
node/prebuilds/ node/prebuilds/

42
.npmignore Normal file
View File

@@ -0,0 +1,42 @@
.circleci/
.gitmodules
node/.nyc_output/
.travis.yml
appveyor.yml
node/build/
node/README.md
rustfmt.toml
spec.md
test-data/
build2/
node_modules
.git
.idea/
.pytest_cache
CMakeLists.txt
README.md
contrib/
node/ci_scripts/
coverage/
node/.circleci
node/appveyor.yml
ci/
ci_scripts/
python/
target
proptest-regressions
deltachat-ffi/Doxyfile
scripts
webxdc.md
standards.md
draft/
node/examples/
# deltachat-core-rust/assets # don't exclude assets, otherwise it won't build
node/images/
node/test/
node/windows.md
node/*.tar.gz
node/old_docs.md
.vscode/
.github/
node/.prettierrc.yml

View File

View File

@@ -11,6 +11,16 @@
- deprecate unused `marker1before` argument of `dc_get_chat_msgs` - deprecate unused `marker1before` argument of `dc_get_chat_msgs`
and remove `DC_MSG_ID_MARKER1` constant #3274 and remove `DC_MSG_ID_MARKER1` constant #3274
### Added
- Now the node-bindings are also part of this repository 🎉
### Fixes
- node: throw error when getting context with an invalid account id
- node: throw error when instanciating a wrapper class on `null` (Context, Message, Chat, ChatList and so on)
### Removed
- node: remove unmaintained coverage scripts
## 1.80.0 ## 1.80.0

View File

@@ -128,7 +128,7 @@ $ cargo test -- --ignored
Language bindings are available for: Language bindings are available for:
- **C** \[[📂 source](./deltachat-ffi) | [📚 docs](https://c.delta.chat)\] - **C** \[[📂 source](./deltachat-ffi) | [📚 docs](https://c.delta.chat)\]
- **Node.js** \[[📂 source](https://github.com/deltachat/deltachat-node) | [📦 npm](https://www.npmjs.com/package/deltachat-node) | [📚 docs](https://js.delta.chat)\] - **Node.js** \[[📂 source](./node) | [📦 npm](https://www.npmjs.com/package/deltachat-node) | [📚 docs](https://js.delta.chat)\]
- **Python** \[[📂 source](./python) | [📦 pypi](https://pypi.org/project/deltachat) | [📚 docs](https://py.delta.chat)\] - **Python** \[[📂 source](./python) | [📦 pypi](https://pypi.org/project/deltachat) | [📚 docs](https://py.delta.chat)\]
- **Go** \[[📂 source](https://github.com/deltachat/go-deltachat/)\] - **Go** \[[📂 source](https://github.com/deltachat/go-deltachat/)\]
- **Free Pascal** \[[📂 source](https://github.com/deltachat/deltachat-fp/)\] - **Free Pascal** \[[📂 source](https://github.com/deltachat/deltachat-fp/)\]

View File

@@ -1,40 +0,0 @@
.circleci/
.gitmodules
.nyc_output/
.travis.yml
appveyor.yml
build/
build2/
node_modules
.git
ci_scripts/
coverage/
deltachat-core-rust/.circleci
deltachat-core-rust/.git
deltachat-core-rust/.github
deltachat-core-rust/.gitattributes
deltachat-core-rust/appveyor.yml
deltachat-core-rust/ci/
deltachat-core-rust/ci_scripts/
deltachat-core-rust/examples/
deltachat-core-rust/python/
deltachat-core-rust/tests/
deltachat-core-rust/target
deltachat-core-rust/test-data
deltachat-core-rust/proptest-regressions
deltachat-core-rust/deltachat-ffi/Doxyfile
deltachat-core-rust/scripts
deltachat-core-rust/benches
deltachat-core-rust/webxdc.md
deltachat-core-rust/standards.md
deltachat-core-rust/draft/
examples/
# deltachat-core-rust/assets # don't exclude assets, otherwise it won't build
images/
test/
windows.md
*.tar.gz
old_docs.md
.vscode/
.github/
.prettierrc.yml

File diff suppressed because it is too large Load Diff

View File

@@ -1,19 +1,17 @@
# deltachat-node # deltachat-node
> node.js bindings for [`deltachat-core-rust`][deltachat-core-rust] > node.js bindings for [`deltachat-core-rust`](..)
[![npm](https://img.shields.io/npm/v/deltachat-node.svg)](https://www.npmjs.com/package/deltachat-node) [![npm](https://img.shields.io/npm/v/deltachat-node.svg)](https://www.npmjs.com/package/deltachat-node)
![Node version](https://img.shields.io/node/v/deltachat-node.svg) ![Node version](https://img.shields.io/node/v/deltachat-node.svg)
[![Coverage Status](https://coveralls.io/repos/github/deltachat/deltachat-node/badge.svg)](https://coveralls.io/github/deltachat/deltachat-node)
[![dependencies](https://david-dm.org/deltachat/deltachat-node.svg)](https://david-dm.org/deltachat/deltachat-node)
[![JavaScript Style Guide](https://img.shields.io/badge/code_style-prettier-brightgreen.svg)](https://prettier.io) [![JavaScript Style Guide](https://img.shields.io/badge/code_style-prettier-brightgreen.svg)](https://prettier.io)
`deltachat-node` primarily aims to offer two things: `deltachat-node` primarily aims to offer two things:
- A high level JavaScript api with syntactic sugar - A high level JavaScript api with syntactic sugar
- A low level c binding api around [`deltachat-core-rust`][deltachat-core-rust] - A low level c binding api around [`deltachat-core-rust`](..)
This code used to live at [`deltachat-node`][deltachat-node]. This code used to live at [`deltachat-node`](https://github.com/deltachat/deltachat-node)
## Table of Contents ## Table of Contents
@@ -31,13 +29,13 @@ This code used to live at [`deltachat-node`][deltachat-node].
## Install ## Install
By default the installation will build try to use the bundled prebuilds in the By default the installation will build try to use the bundled prebuilds in the
npm package. If this fails it falls back to compile `deltachat-core-rust` from npm package. If this fails it falls back to compile `../deltachat-core-rust` from
this repository, using `scripts/rebuild-core.js`. this repository, using `scripts/rebuild-core.js`.
To install from npm use: To install from npm use:
``` ```
npm install deltchat-node npm install deltachat-node
``` ```
## Dependencies ## Dependencies
@@ -53,11 +51,15 @@ If you want to build from source, make sure that you have `rustup` installed.
You can either use `npm install deltachat-node --build-from-source` to force You can either use `npm install deltachat-node --build-from-source` to force
building from source or clone this repository and follow this steps: building from source or clone this repository and follow this steps:
1. `git clone https://github.com/deltachat/deltachat-node.git` 1. `git clone https://github.com/deltachat/deltachat-core-rust.git`
2. `cd deltachat-node` 2. `cd deltachat-core-rust`
3. `npm i` 3. `npm i`
4. `npm run build` 4. `npm run build`
> Our `package.json` file is located in the root directory of this repository,
> not inside this folder. (We need this in order to include the rust source
> code in the npm package.)
### Use build-from-source in deltachat-desktop ### Use build-from-source in deltachat-desktop
If you want to use the manually built node bindings in the desktop client (for If you want to use the manually built node bindings in the desktop client (for
@@ -73,15 +75,15 @@ deltachat-desktop's package.json. You need to change
``` ```
diff --git i/package.json w/package.json diff --git i/package.json w/package.json
index d3fb3f23..b6ee6b7f 100644 index 45893894..5154512c 100644
--- i/package.json --- i/package.json
+++ w/package.json +++ w/package.json
@@ -83,7 +83,7 @@ @@ -83,7 +83,7 @@
"application-config": "^1.0.1", "application-config": "^1.0.1",
"classnames": "^2.3.1", "classnames": "^2.3.1",
"debounce": "^1.2.0", "debounce": "^1.2.0",
- "deltachat-node": "1.77.1", - "deltachat-node": "1.79.3",
+ "deltachat-node": "file:../deltachat-core-rust/node", + "deltachat-node": "file:../deltachat-core-rust/",
"emoji-js-clean": "^4.0.0", "emoji-js-clean": "^4.0.0",
"emoji-mart": "^3.0.1", "emoji-mart": "^3.0.1",
"emoji-regex": "^9.2.2", "emoji-regex": "^9.2.2",
@@ -218,17 +220,8 @@ We have the following scripts for building, testing and coverage:
The following steps are needed to make a release: The following steps are needed to make a release:
1. Update `CHANGELOG.md` (and run `npm run hallmark` to adjust markdown) 1. Wait until `pack-module` github action is completed
2. Run `npm publish https://download.delta.chat/node/deltachat-node-v1.x.x.tar.gz` to publish it to npm. You probably need write rights to npm.
- Add release changelog in top section
- Also adjust links to github prepare links at the end of the file
2. Bump version number in package.json
3. Commit the changed files, commit message should be similiar to `Prepare node-bindings npm release`
4. Tag the release with `git tag -a v1.0.0-foo.number`
5. Push to github with `git push origin master --tags`
6. Wait until `Make Package` github action is completed
7. Download `deltachat-node.tgz` from the github release and run `npm publish deltachat-node.tgz` to publish it to npm. You probably need write rights to npm.
## License ## License

View File

@@ -15,6 +15,9 @@ interface NativeChat {}
export class Chat { export class Chat {
constructor(public dc_chat: NativeChat) { constructor(public dc_chat: NativeChat) {
debug('Chat constructor') debug('Chat constructor')
if (dc_chat === null) {
throw new Error('native chat can not be null')
}
} }
getVisibility(): getVisibility():

View File

@@ -12,6 +12,9 @@ interface NativeChatList {}
export class ChatList { export class ChatList {
constructor(private dc_chatlist: NativeChatList) { constructor(private dc_chatlist: NativeChatList) {
debug('ChatList constructor') debug('ChatList constructor')
if (dc_chatlist === null) {
throw new Error('native chat list can not be null')
}
} }
getChatId(index: number): number { getChatId(index: number): number {

View File

@@ -12,6 +12,9 @@ interface NativeContact {}
export class Contact { export class Contact {
constructor(public dc_contact: NativeContact) { constructor(public dc_contact: NativeContact) {
debug('Contact constructor') debug('Contact constructor')
if (dc_contact === null) {
throw new Error('native contact can not be null')
}
} }
toJson() { toJson() {

View File

@@ -31,6 +31,9 @@ export class Context extends EventEmitter {
) { ) {
super() super()
debug('DeltaChat constructor') debug('DeltaChat constructor')
if (inner_dcn_context === null) {
throw new Error('inner_dcn_context can not be null')
}
} }
/** Opens a stanalone context (without an account manager) /** Opens a stanalone context (without an account manager)

View File

@@ -57,6 +57,11 @@ export class AccountManager extends EventEmitter {
this.dcn_accounts, this.dcn_accounts,
account_id account_id
) )
if (native_context === null) {
throw new Error(
`could not get context with id ${account_id}, does it even exist? please check your ids`
)
}
return new Context(this, native_context, account_id) return new Context(this, native_context, account_id)
} }

View File

@@ -10,6 +10,9 @@ interface NativeLocations {}
export class Locations { export class Locations {
constructor(public dc_locations: NativeLocations) { constructor(public dc_locations: NativeLocations) {
debug('Locations constructor') debug('Locations constructor')
if (dc_locations === null) {
throw new Error('dc_locations can not be null')
}
} }
locationToJson(index: number) { locationToJson(index: number) {

View File

@@ -10,6 +10,9 @@ interface NativeLot {}
export class Lot { export class Lot {
constructor(public dc_lot: NativeLot) { constructor(public dc_lot: NativeLot) {
debug('Lot constructor') debug('Lot constructor')
if (dc_lot === null) {
throw new Error('dc_lot can not be null')
}
} }
toJson() { toJson() {

View File

@@ -108,6 +108,9 @@ interface NativeMessage {}
export class Message { export class Message {
constructor(public dc_msg: NativeMessage) { constructor(public dc_msg: NativeMessage) {
debug('Message constructor') debug('Message constructor')
if (dc_msg === null) {
throw new Error('dc_msg can not be null')
}
} }
toJson() { toJson() {

View File

@@ -1,66 +0,0 @@
{
"name": "deltachat-node",
"version": "1.79.3",
"description": "node.js bindings for deltachat-core",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"scripts": {
"coverage": "nyc report --reporter=text-lcov | coveralls",
"coverage-html-report": "rm -rf coverage/ && nyc report --reporter=html && xdg-open coverage/index.html",
"install": "node scripts/install.js",
"install:prebuilds": "node-gyp-build \"npm run build:core\" \"npm run build:bindings:c:postinstall\"",
"clean": "rm -rf ./dist ./build ./prebuilds ./node_modules ../target",
"build": "npm run build:core && npm run build:bindings",
"build:core": "npm run build:core:rust && npm run build:core:constants",
"build:core:rust": "node scripts/rebuild-core.js",
"build:core:constants": "node scripts/generate-constants.js",
"build:bindings": "npm run build:bindings:c && npm run build:bindings:ts",
"build:bindings:c": "npm run build:bindings:c:c && npm run build:bindings:c:postinstall",
"build:bindings:c:c": "npx node-gyp rebuild",
"build:bindings:c:postinstall": "node scripts/postinstall.js",
"build:bindings:ts": "tsc",
"prebuildify": "prebuildify -t 16.13.0 --napi --strip --postinstall \"node scripts/postinstall.js --prebuild\"",
"download-prebuilds": "prebuildify-ci download",
"test": "npm run test:lint && npm run test:mocha",
"test:mocha": "mocha -r esm test/test.js --growl --reporter=spec",
"test:lint": "npm run lint",
"testCoverage": "nyc mocha -r esm test/test.js --growl --reporter=spec",
"hallmark": "hallmark --fix",
"lint": "prettier --check \"lib/**/*.{ts,tsx}\"",
"lint-fix": "prettier --write \"lib/**/*.{ts,tsx}\" \"test/**/*.js\""
},
"homepage": "https://github.com/deltachat/deltachat-node",
"repository": {
"type": "git",
"url": "https://github.com/deltachat/deltachat-node.git"
},
"engines": {
"node": ">=16.0.0"
},
"license": "GPL-3.0-or-later",
"dependencies": {
"debug": "^4.1.1",
"napi-macros": "^2.0.0",
"node-gyp-build": "^4.1.0",
"split2": "^3.1.1"
},
"devDependencies": {
"@types/debug": "^4.1.7",
"@types/node": "^16.11.26",
"chai": "^4.2.0",
"chai-as-promised": "^7.1.1",
"coveralls": "^3.0.3",
"esm": "^3.2.25",
"hallmark": "^2.0.0",
"mocha": "^8.2.1",
"node-fetch": "^2.6.7",
"node-gyp": "^9.0.0",
"nyc": "^15.0.0",
"opn-cli": "^5.0.0",
"prebuildify": "^3.0.0",
"prebuildify-ci": "^1.0.4",
"prettier": "^2.0.5",
"typedoc": "^0.17.0",
"typescript": "^3.9.10"
}
}

View File

@@ -1,13 +1,13 @@
diff --git a/binding.gyp b/binding.gyp diff --git i/node/binding.gyp w/node/binding.gyp
index 199f4d3..15b47f8 100644 index b0d92eae..c5e504fa 100644
--- a/binding.gyp --- i/node/binding.gyp
+++ b/binding.gyp +++ w/node/binding.gyp
@@ -42,7 +42,7 @@ @@ -43,7 +43,7 @@
{ "include_dirs": ["../deltachat-ffi"],
"include_dirs": ["deltachat-core-rust/deltachat-ffi"], "ldflags": ["-Wl,-Bsymbolic"], # Prevent sqlite3 from electron from overriding sqlcipher
"libraries": [ "libraries": [
- "../deltachat-core-rust/target/release/libdeltachat.a", - "../../target/release/libdeltachat.a",
+ "../deltachat-core-rust/target/x86_64-apple-darwin/release/libdeltachat.a", + "../../target/x86_64-apple-darwin/release/libdeltachat.a",
"-ldl", "-ldl",
], ],
"conditions": [], "conditions": [],

View File

@@ -5,19 +5,19 @@ const sha = JSON.parse(
).pull_request.head.sha ).pull_request.head.sha
const base_url = const base_url =
'https://download.delta.chat/node/deltachat-node-' 'https://download.delta.chat/node/'
const GITHUB_API_URL = const GITHUB_API_URL =
'https://api.github.com/repos/deltachat/deltachat-core-rust/statuses/' + sha 'https://api.github.com/repos/deltachat/deltachat-core-rust/statuses/' + sha
const prId = process.env['PR_ID'] const file_url = process.env['URL']
const GITHUB_TOKEN = process.env['GITHUB_TOKEN'] const GITHUB_TOKEN = process.env['GITHUB_TOKEN']
const STATUS_DATA = { const STATUS_DATA = {
state: 'success', state: 'success',
description: '⏩ Click on "Details" to download →', description: '⏩ Click on "Details" to download →',
context: 'Download the node-bindings.tar.gz', context: 'Download the node-bindings.tar.gz',
target_url: base_url + prId + '.tar.gz', target_url: base_url + file_url + '.tar.gz',
} }
const http = require('https') const http = require('https')

View File

@@ -738,8 +738,6 @@ describe('Integration tests', function () {
'selfavatar correct' 'selfavatar correct'
) )
strictEqual(context.getConfig('e2ee_enabled'), '1', 'e2ee_enabled correct') strictEqual(context.getConfig('e2ee_enabled'), '1', 'e2ee_enabled correct')
strictEqual(context.getConfig('sentbox_watch'), '0', 'sentbox_watch')
strictEqual(context.getConfig('mvbox_move'), '0', 'mvbox_move')
strictEqual( strictEqual(
context.getConfig('save_mime_headers'), context.getConfig('save_mime_headers'),
'', '',

62
package.json Normal file
View File

@@ -0,0 +1,62 @@
{
"name": "deltachat-node",
"version": "1.80.0",
"description": "node.js bindings for deltachat-core",
"main": "node/dist/index.js",
"types": "node/dist/index.d.ts",
"files": ["node/scripts/*", "*"],
"scripts": {
"install": "node node/scripts/install.js",
"install:prebuilds": "cd node && node-gyp-build \"npm run build:core\" \"npm run build:bindings:c:postinstall\"",
"clean": "rm -rf node/dist node/build node/prebuilds node/node_modules ./target",
"build": "npm run build:core && npm run build:bindings",
"build:core": "npm run build:core:rust && npm run build:core:constants",
"build:core:rust": "node node/scripts/rebuild-core.js",
"build:core:constants": "node node/scripts/generate-constants.js",
"build:bindings": "npm run build:bindings:c && npm run build:bindings:ts",
"build:bindings:c": "npm run build:bindings:c:c && npm run build:bindings:c:postinstall",
"build:bindings:c:c": "cd node && npx node-gyp rebuild",
"build:bindings:c:postinstall": "node node/scripts/postinstall.js",
"build:bindings:ts": "cd node && tsc",
"prebuildify": "cd node && prebuildify -t 16.13.0 --napi --strip --postinstall \"node scripts/postinstall.js --prebuild\"",
"download-prebuilds": "prebuildify-ci download",
"test": "npm run test:lint && npm run test:mocha",
"test:mocha": "mocha -r esm node/test/test.js --growl --reporter=spec",
"test:lint": "npm run lint",
"hallmark": "hallmark --fix",
"lint": "prettier --check \"node/lib/**/*.{ts,tsx}\"",
"lint-fix": "prettier --write \"node/lib/**/*.{ts,tsx}\" \"node/test/**/*.js\""
},
"homepage": "https://github.com/deltachat/deltachat-core-rust/tree/master/node",
"repository": {
"type": "git",
"url": "https://github.com/deltachat/deltachat-core-rust.git"
},
"engines": {
"node": ">=16.0.0"
},
"license": "GPL-3.0-or-later",
"dependencies": {
"debug": "^4.1.1",
"napi-macros": "^2.0.0",
"node-gyp-build": "^4.1.0",
"split2": "^3.1.1"
},
"devDependencies": {
"@types/debug": "^4.1.7",
"@types/node": "^16.11.26",
"chai": "^4.2.0",
"chai-as-promised": "^7.1.1",
"esm": "^3.2.25",
"hallmark": "^2.0.0",
"mocha": "^8.2.1",
"node-fetch": "^2.6.7",
"node-gyp": "^9.0.0",
"opn-cli": "^5.0.0",
"prebuildify": "^3.0.0",
"prebuildify-ci": "^1.0.4",
"prettier": "^2.0.5",
"typedoc": "^0.17.0",
"typescript": "^3.9.10"
}
}

View File

@@ -1,7 +1,7 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
import os import os
import sys import json
import re import re
import pathlib import pathlib
import subprocess import subprocess
@@ -41,6 +41,24 @@ def replace_toml_version(relpath, newversion):
os.rename(tmp_path, str(p)) os.rename(tmp_path, str(p))
def read_json_version(relpath):
p = pathlib.Path("package.json")
assert p.exists()
with open(p, "r") as f:
json_data = json.loads(f.read())
return json_data["version"]
def update_package_json(newversion):
p = pathlib.Path("package.json")
assert p.exists()
with open(p, "r") as f:
json_data = json.loads(f.read())
json_data["version"] = newversion
with open(p, "w") as f:
f.write(json.dumps(json_data, sort_keys=True, indent=2))
def main(): def main():
parser = ArgumentParser(prog="set_core_version") parser = ArgumentParser(prog="set_core_version")
parser.add_argument("newversion") parser.add_argument("newversion")
@@ -52,6 +70,7 @@ def main():
print() print()
for x in toml_list: for x in toml_list:
print("{}: {}".format(x, read_toml_version(x))) print("{}: {}".format(x, read_toml_version(x)))
print("package.json:", str(read_json_version("package.json")))
print() print()
raise SystemExit("need argument: new version, example: 1.25.0") raise SystemExit("need argument: new version, example: 1.25.0")
@@ -74,6 +93,7 @@ def main():
replace_toml_version("Cargo.toml", newversion) replace_toml_version("Cargo.toml", newversion)
replace_toml_version("deltachat-ffi/Cargo.toml", newversion) replace_toml_version("deltachat-ffi/Cargo.toml", newversion)
update_package_json(newversion)
print("running cargo check") print("running cargo check")
subprocess.call(["cargo", "check"]) subprocess.call(["cargo", "check"])