mirror of
https://github.com/chatmail/core.git
synced 2026-04-17 21:46:35 +03:00
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:
@@ -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
|
||||
@@ -1 +0,0 @@
|
||||
package-lock=false
|
||||
1737
node/CHANGELOG.md
1737
node/CHANGELOG.md
File diff suppressed because it is too large
Load Diff
@@ -1,19 +1,17 @@
|
||||
# deltachat-node
|
||||
|
||||
> node.js bindings for [`deltachat-core-rust`][deltachat-core-rust]
|
||||
> node.js bindings for [`deltachat-core-rust`](..)
|
||||
|
||||
[](https://www.npmjs.com/package/deltachat-node)
|
||||

|
||||
[](https://coveralls.io/github/deltachat/deltachat-node)
|
||||
[](https://david-dm.org/deltachat/deltachat-node)
|
||||
[](https://prettier.io)
|
||||
|
||||
`deltachat-node` primarily aims to offer two things:
|
||||
|
||||
- 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
|
||||
|
||||
@@ -31,13 +29,13 @@ This code used to live at [`deltachat-node`][deltachat-node].
|
||||
## Install
|
||||
|
||||
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`.
|
||||
|
||||
To install from npm use:
|
||||
|
||||
```
|
||||
npm install deltchat-node
|
||||
npm install deltachat-node
|
||||
```
|
||||
|
||||
## 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
|
||||
building from source or clone this repository and follow this steps:
|
||||
|
||||
1. `git clone https://github.com/deltachat/deltachat-node.git`
|
||||
2. `cd deltachat-node`
|
||||
1. `git clone https://github.com/deltachat/deltachat-core-rust.git`
|
||||
2. `cd deltachat-core-rust`
|
||||
3. `npm i`
|
||||
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
|
||||
|
||||
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
|
||||
index d3fb3f23..b6ee6b7f 100644
|
||||
index 45893894..5154512c 100644
|
||||
--- i/package.json
|
||||
+++ w/package.json
|
||||
@@ -83,7 +83,7 @@
|
||||
"application-config": "^1.0.1",
|
||||
"classnames": "^2.3.1",
|
||||
"debounce": "^1.2.0",
|
||||
- "deltachat-node": "1.77.1",
|
||||
+ "deltachat-node": "file:../deltachat-core-rust/node",
|
||||
- "deltachat-node": "1.79.3",
|
||||
+ "deltachat-node": "file:../deltachat-core-rust/",
|
||||
"emoji-js-clean": "^4.0.0",
|
||||
"emoji-mart": "^3.0.1",
|
||||
"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:
|
||||
|
||||
1. Update `CHANGELOG.md` (and run `npm run hallmark` to adjust markdown)
|
||||
|
||||
- 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.
|
||||
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.
|
||||
|
||||
## License
|
||||
|
||||
|
||||
@@ -15,6 +15,9 @@ interface NativeChat {}
|
||||
export class Chat {
|
||||
constructor(public dc_chat: NativeChat) {
|
||||
debug('Chat constructor')
|
||||
if (dc_chat === null) {
|
||||
throw new Error('native chat can not be null')
|
||||
}
|
||||
}
|
||||
|
||||
getVisibility():
|
||||
|
||||
@@ -12,6 +12,9 @@ interface NativeChatList {}
|
||||
export class ChatList {
|
||||
constructor(private dc_chatlist: NativeChatList) {
|
||||
debug('ChatList constructor')
|
||||
if (dc_chatlist === null) {
|
||||
throw new Error('native chat list can not be null')
|
||||
}
|
||||
}
|
||||
|
||||
getChatId(index: number): number {
|
||||
|
||||
@@ -12,6 +12,9 @@ interface NativeContact {}
|
||||
export class Contact {
|
||||
constructor(public dc_contact: NativeContact) {
|
||||
debug('Contact constructor')
|
||||
if (dc_contact === null) {
|
||||
throw new Error('native contact can not be null')
|
||||
}
|
||||
}
|
||||
|
||||
toJson() {
|
||||
|
||||
@@ -31,6 +31,9 @@ export class Context extends EventEmitter {
|
||||
) {
|
||||
super()
|
||||
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)
|
||||
|
||||
@@ -57,6 +57,11 @@ export class AccountManager extends EventEmitter {
|
||||
this.dcn_accounts,
|
||||
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)
|
||||
}
|
||||
|
||||
|
||||
@@ -10,6 +10,9 @@ interface NativeLocations {}
|
||||
export class Locations {
|
||||
constructor(public dc_locations: NativeLocations) {
|
||||
debug('Locations constructor')
|
||||
if (dc_locations === null) {
|
||||
throw new Error('dc_locations can not be null')
|
||||
}
|
||||
}
|
||||
|
||||
locationToJson(index: number) {
|
||||
|
||||
@@ -10,6 +10,9 @@ interface NativeLot {}
|
||||
export class Lot {
|
||||
constructor(public dc_lot: NativeLot) {
|
||||
debug('Lot constructor')
|
||||
if (dc_lot === null) {
|
||||
throw new Error('dc_lot can not be null')
|
||||
}
|
||||
}
|
||||
|
||||
toJson() {
|
||||
|
||||
@@ -108,6 +108,9 @@ interface NativeMessage {}
|
||||
export class Message {
|
||||
constructor(public dc_msg: NativeMessage) {
|
||||
debug('Message constructor')
|
||||
if (dc_msg === null) {
|
||||
throw new Error('dc_msg can not be null')
|
||||
}
|
||||
}
|
||||
|
||||
toJson() {
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,13 @@
|
||||
diff --git a/binding.gyp b/binding.gyp
|
||||
index 199f4d3..15b47f8 100644
|
||||
--- a/binding.gyp
|
||||
+++ b/binding.gyp
|
||||
@@ -42,7 +42,7 @@
|
||||
{
|
||||
"include_dirs": ["deltachat-core-rust/deltachat-ffi"],
|
||||
diff --git i/node/binding.gyp w/node/binding.gyp
|
||||
index b0d92eae..c5e504fa 100644
|
||||
--- i/node/binding.gyp
|
||||
+++ w/node/binding.gyp
|
||||
@@ -43,7 +43,7 @@
|
||||
"include_dirs": ["../deltachat-ffi"],
|
||||
"ldflags": ["-Wl,-Bsymbolic"], # Prevent sqlite3 from electron from overriding sqlcipher
|
||||
"libraries": [
|
||||
- "../deltachat-core-rust/target/release/libdeltachat.a",
|
||||
+ "../deltachat-core-rust/target/x86_64-apple-darwin/release/libdeltachat.a",
|
||||
- "../../target/release/libdeltachat.a",
|
||||
+ "../../target/x86_64-apple-darwin/release/libdeltachat.a",
|
||||
"-ldl",
|
||||
],
|
||||
"conditions": [],
|
||||
|
||||
@@ -5,19 +5,19 @@ const sha = JSON.parse(
|
||||
).pull_request.head.sha
|
||||
|
||||
const base_url =
|
||||
'https://download.delta.chat/node/deltachat-node-'
|
||||
'https://download.delta.chat/node/'
|
||||
|
||||
const GITHUB_API_URL =
|
||||
'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 STATUS_DATA = {
|
||||
state: 'success',
|
||||
description: '⏩ Click on "Details" to download →',
|
||||
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')
|
||||
|
||||
@@ -738,8 +738,6 @@ describe('Integration tests', function () {
|
||||
'selfavatar 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(
|
||||
context.getConfig('save_mime_headers'),
|
||||
'',
|
||||
|
||||
Reference in New Issue
Block a user