Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

CoderMrG/hap-toolkit

Open more actions menu

Repository files navigation

开发指南

准备

npm install
# 让 lerna 安装各个模块的依赖,再链接依赖
npx lerna bootstrap
npx lerna link

构建

基本

npm run gulp
# 推荐使用 npx (须在根目录执行)
npx gulp
# 查看所有任务
npx gulp --tasks

构建指定模块

# 构建全部
npx gulp # npm run gulp
npx gulp toolkit # npm run gulp -- toolkit
npx gulp toolkit packager # npm run gulp -- toolkit packager
npx gulp build # 不包含测试

开发和测试

以下满足大部分开发测试需求(希望),如果特殊需求,可自行修改 gulpfiles.

跳过minify

执行 gulpgulp {toolkit, debugger, packager, build} 这几个命令时,传入 --dev 将跳过 minify,方便开发时调试代码

watch 模式

监听文件,当文件修改时执行任务。

npx gulp watch                            # 监听全部
npx gulp watch --modules toolkit          # 监听 toolkit
npx gulp watch --modules toolkit,packager # 监听 toolkit 和 packager
npx gulp watch -m t,p                     # 同上
npm run dev                               # gulp watch --dev

单元测试

npx gulp test

项目测试/调试

npx gulp # 构建项目
node bin/index.js init <testapp> # 创建一个测试项目
cd <testapp> # 进入测试项目
node ../bin/index.js server --watch # 启动服务
node inspect ../bin/index.js server --watch # 调试

项目测试

使用npm link 命令创建软链接。 假设有测试项目 testapp,则可以通过下面的方式 创建软链接。

cd <hap-toolkit-root>
[sudo] npm link
cd <path-to-testapp>
npm link hap-toolkit

cd <path-to-testapp>
npm link <hap-toolkit-root>

创建软链接后,hap-toolkit 中的修改都会映射到 testapp 项目下的hap-toolkit

jest-snapshot

测试使用了[jest snapshot],避免人工编写预期结果的繁琐。测试修改时,应认真对比 snapshot,确保它是正确的,还要记得提交snapshot

使用 -u 参数更新snapshot:

npx jest ./server/__tests__/server.js -u

代码检查

使用eslint做代码检查,基于standard 规则。配置了huskylint-staged,提交 代码时会自动做一次检查并尝试矫正(fix)

About

快应用的编译时工具

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published
Morty Proxy This is a proxified and sanitized view of the page, visit original site.