即时通讯im源码使用ThinkPHP7和Swoole构建的简单、美观、移动优先的即时消息渐进式Web应用程序。
仓库源码:im.jstxym.top
本文目录:
●点击展开
●安装
●依赖项
●源代码构建
●用法
●发布
安装
默认情况下,安装将尝试使用npm包中捆绑的预构建。如果失败,它会退回到deltachat-core-rust使用scripts/rebuild-core.js.要从npm安装,请使用:
npm install deltchat-node
依赖项
●节点>=v16.0.0
●rustup(如果您不能使用预构建,则可选)
在Windows上,您可能还需要安装Perl才能编译deltachat-core。
源代码构建
如果要从源代码构建,请确保已rustup安装。您可以使用npm install deltachat-node
在Apple的M1上为x86_64构建的解决方法
deltachat还不支持通用(胖)二进制文件(包含两种cpu架构的构建),在它支持之前,您可以使用以下解决方法来获取x86_64构建:
$fnm install 17--arch x64
$fnm use 17
$node-p process.arch
#result should be x64
$cd deltachat-core-rust&&rustup target add x86_64-apple-darwin&&cd-
$git apply patches/m1_build_use_x86_64.patch
$CARGO_BUILD_TARGET=x86_64-apple-darwin npm run build
$npm run test
(当使用fnm而不是nvm时,您可以选择架构)如果您的节点和电子已经为arm64构建,您也可以尝试为arm构建:
$fnm install 16--arch arm64
$fnm use 16
$node-p process.arch
#result should be arm64
$npm_config_arch=arm64 npm run build
$npm run test
用法
const{Context}=require('deltachat-node')
const opts={
addr:'[email]',
mail_pw:'[password]',
}
const contact='[email]'
async function main(){
const dc=Context.open('./')
dc.on('ALL',console.log.bind(null,'core|'))
try{
await dc.configure(opts)
}catch(err){
console.error('Failed to configure because of:',err)
dc.unref()
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.unref()
})
}
main()
此示例也可以在示例文件夹示例/send_message.js中找到
生成文档
我们目前正在迁移到自动生成的文档。您可以在old_docs找到旧文档。
要生成文档,请运行:
npx typedoc
拓展
测试和覆盖
运行npm test以显示代码覆盖率报告结束,该报告由nyc.
测试输出
控制台中的覆盖率报告nyc相当有限。要获得更详细的覆盖率报告,您可以运行npm run coverage-html-report.这将从nyc数据中生成一个html报告,并将其显示在本地计算机上的浏览器中。
要运行集成测试,您需要设置DCC_NEW_TMP_EMAIL环境变量。例如:
$export DCC_NEW_TMP_EMAIL=https://testrun.org/new_email?t=[token]
$npm run test
脚本
我们有以下用于构建、测试和覆盖的脚本:
●npm run coverage创建覆盖率报告并将其传递给coveralls.仅由完成Travis。
●npm run coverage-html-report从覆盖数据生成html报告并在本地计算机上的浏览器中打开它。
●npm run generate-constants生成constants.js并events.js基于deltachat-core-rust/deltachat-ffi/deltachat.h头文件。
●npm install安装依赖项后,运行node-gyp-build以查看是否需要重新构建本机代码。
●npm run build重建所有代码。
●npm run build:core在deltachat-core-rust.
●npm run build:bindings用重建绑定和链接deltachat-core-rust。
●ǹpm run clean删除所有构建的代码
●npm run prebuildify将预构建的二进制文件构建为prebuilds/$PLATFORM-$ARCH.复制deltachat.dll自deltachat-core-rustfor windows。
●npm run download-prebuilds之前从github下载所有预构建的二进制文件npm publish。
●npm run submodule更新deltachat-core-rust子模块。
●npm test运行standard,然后在test/index.js.
●npm run test-integration运行集成测试。
●npm run hallmarkhallmark在所有降价文件上运行。
发布
1、发布版本需要以下步骤:
●更新CHANGELOG.md(并运行npm run hallmark以调整降价)
●在顶部添加发布更改日志
●还要调整指向github的链接准备文件末尾的链接
2、package.json中的凹凸版本号
3、提交更改的文件,提交消息应该类似于Prepare for v1.0.0-foo.number
4、标记发布git tag-a v1.0.0-foo.number
5、推送到githubgit push origin master--tags
6、等到Make Packagegithub操作完成
7、deltachat-node.tgz从github版本下载并运行npm publish deltachat-node.tgz以将其发布到npm。您可能需要对npm的写入权限。