node.js bindings for
deltachat-core-rust
If you are upgrading: please see UPGRADING.md.
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
Click to expand
By default the installation will build try to use the bundled prebuilds in the
npm package. If this fails it falls back to compile the bundled
deltachat-core-rust from the submodule using scripts/rebuild-core.js.
To install from npm use:
npm install deltchat-node
Node > v10.0.0 rustup (optional if you can't use the prebuilds)
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:
git clone https://github.com/deltachat/deltachat-node.gitcd deltachat-nodenpm run submodulenpm run build
const DeltaChat = require('deltachat-node').default
const dc = new DeltaChat()
const opts = {
addr: '[email]',
mail_pw: '[password]'
}
const contact = '[email]'
async function main() {
const dc = new DeltaChat()
dc.on('ALL', console.log.bind(null, 'core |'))
await dc.open('./')
try {
await dc.configure(opts)
} catch (err) {
console.error("Failed to configure because of: ", err)
dc.close()
return
}
dc.startIO()
console.log('fully configured')
const contactId = dc.createContact('Test', contact)
const chatId = dc.createChatByContactId(contactId)
dc.sendMessage(chatId, 'Hi!')
console.log('sent message')
dc.once('DC_EVENT_SMTP_MESSAGE_SENT', async () => {
console.log('Message sent, shutting down...')
dc.stopIO()
console.log('stopped io')
dc.close()
})
}
main()We are curently migrating to automaticaly generated documentation. You can find the old documentation at old_docs.
to generate the documentation, run:
npx typedoc
The resulting documentation can be found in the docs/ folder.
An online version can be found under js.delta.chat.
Running npm test ends with showing a code coverage report, which is produced by nyc.
The coverage report from nyc in the console is rather limited. To get a more detailed coverage report you can run npm run coverage-html-report. This will produce a html report from the nyc data and display it in a browser on your local machine.
To run the integration tests you need to set the DCC_NEW_TMP_EMAIL environment variables. E.g.:
$ export DCC_NEW_TMP_EMAIL=https://testrun.org/new_email?t=[token]
$ npm run test
We have the following scripts for building, testing and coverage:
npm run coverageCreates a coverage report and passes it tocoveralls. Only done byTravis.npm run coverage-html-reportGenerates a html report from the coverage data and opens it in a browser on the local machine.npm run generate-constantsGeneratesconstants.jsandevents.jsbased on thedeltachat-core-rust/deltachat-ffi/deltachat.hheader file.npm installAfter dependencies are installed, runsnode-gyp-buildto see if the native code needs to be rebuilt.npm run buildRebuilds all code.npm run build:coreRebuilds code indeltachat-core-rust.npm run build:bindingsRebuilds the bindings and links withdeltachat-core-rust.ǹpm run cleanRemoves all built codenpm run prebuildifyBuilds prebuilt binary toprebuilds/$PLATFORM-$ARCH. Copiesdeltachat.dllfromdeltachat-core-rustfor windows.npm run download-prebuildsDownloads all prebuilt binaries from github beforenpm publish.npm run submoduleUpdates thedeltachat-core-rustsubmodule.npm testRunsstandardand then the tests intest/index.js.npm run test-integrationRuns the integration tests.npm run hallmarkRunshallmarkon all markdown files.
The following steps are needed to make a release:
- Update
CHANGELOG.md(and runnpm run hallmarkto adjust markdown)
- Add release changelog in top section
- Also adjust links to github prepare links at the end of the file
- Bump version number in package.json
- Commit the changed files, commit message should be similiar to
Prepare for v1.0.0-foo.number - Tag the release with
git tag -a v1.0.0-foo.number - Push to github with
git push origin master --tags - Wait until
Make Packagegithub action is completed - Download
deltachat-node.tgzfrom the github release and runnpm publish deltachat-node.tgzto publish it to npm. You probably need write rights to npm.
Licensed under GPL-3.0-or-later, see LICENSE file for details.
Copyright © 2018
DeltaChatcontributors.This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.
