Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP convert to monorepos #324

Open
wants to merge 1 commit into
base: release
Choose a base branch
from
Open

WIP convert to monorepos #324

wants to merge 1 commit into from

Conversation

chuan6
Copy link
Contributor

@chuan6 chuan6 commented Aug 7, 2017

No description provided.

@chuan6 chuan6 added the REFACTOR label Aug 7, 2017
@chuan6 chuan6 self-assigned this Aug 7, 2017
@chuan6
Copy link
Contributor Author

chuan6 commented Aug 8, 2017

/cc @bjmin @Saviio @Miloas 这个将 SDK 在一个项目库里拆分成 core 和 fetches 两个包的尝试,会需要一些时间推进,我会持续更新,学习相关的知识 👌

@chuan6 chuan6 force-pushed the pkg-fetch-apis branch 2 times, most recently from 3c29938 to 8f9ab21 Compare August 16, 2017 06:12
@Brooooooklyn
Copy link
Contributor

react router 是一个仓库管理多个包 https://github.com/ReactTraining/react-router
https://github.com/lerna/lerna 管理的

@chuan6
Copy link
Contributor Author

chuan6 commented Aug 16, 2017

@Brooooooklyn 谢谢!正在学 lerna,我参考参考这个项目看 :)

@chuan6 chuan6 force-pushed the pkg-fetch-apis branch 5 times, most recently from ef47eeb to 99fedbf Compare August 21, 2017 10:30
@coveralls
Copy link

Coverage Status

Coverage decreased (-15.2%) to 80.959% when pulling 99fedbf on pkg-fetch-apis into c67e577 on release.

@coveralls
Copy link

Coverage Status

Coverage decreased (-8.9%) to 87.291% when pulling c043399 on pkg-fetch-apis into c67e577 on release.

@coveralls
Copy link

Coverage Status

Coverage decreased (-8.9%) to 87.291% when pulling a3d0050 on pkg-fetch-apis into c67e577 on release.

@coveralls
Copy link

Coverage Status

Coverage decreased (-7.8%) to 88.418% when pulling adbd6d8 on pkg-fetch-apis into c67e577 on release.

@coveralls
Copy link

Coverage Status

Coverage decreased (-7.2%) to 89.041% when pulling 53af3e9 on pkg-fetch-apis into c67e577 on release.

@coveralls
Copy link

Coverage Status

Coverage decreased (-48.7%) to 47.449% when pulling b343516 on pkg-fetch-apis into c67e577 on release.

@coveralls
Copy link

Coverage Status

Coverage decreased (-50.4%) to 45.842% when pulling 8211755 on pkg-fetch-apis into c67e577 on release.

@coveralls
Copy link

Coverage Status

Coverage decreased (-59.2%) to 37.038% when pulling 8b067d1 on pkg-fetch-apis into c67e577 on release.

@coveralls
Copy link

Coverage Status

Coverage decreased (-59.07%) to 37.124% when pulling 02d713c on pkg-fetch-apis into c67e577 on release.

@coveralls
Copy link

Coverage Status

Coverage decreased (-12.5%) to 83.649% when pulling 9d55272 on pkg-fetch-apis into c67e577 on release.

@teambition teambition deleted a comment from coveralls Aug 23, 2017
@teambition teambition deleted a comment from coveralls Aug 23, 2017
@teambition teambition deleted a comment from coveralls Aug 23, 2017
@teambition teambition deleted a comment from coveralls Aug 23, 2017
@teambition teambition deleted a comment from coveralls Aug 23, 2017
@teambition teambition deleted a comment from coveralls Aug 23, 2017
@chuan6 chuan6 force-pushed the pkg-fetch-apis branch 2 times, most recently from eb37495 to 83dd945 Compare August 24, 2017 07:48
@coveralls
Copy link

Coverage Status

Coverage decreased (-9.8%) to 84.862% when pulling 83dd945 on pkg-fetch-apis into 1b564dd on release.

@chuan6
Copy link
Contributor Author

chuan6 commented Aug 24, 2017

关于生成 coverage,.nycrc.json 文件里 include 字段的 **/src/** 被替换为 **/spec-js/src/**,排除了原 src 目录下的 ts 文件,就不会再遇到之前 circleci 中跑 yarn test 抛出错误的问题。生成的报表依然会显示相应的 ts 文件,而不是 **/spec-js/src 下的 js 文件,应该是因为 nyc 可以通过 **/spec-js/src 下的 sourcemap 文件映射回 ts 文件上去。

主要包为:

- teambition-sdk-core:包含较基础的代码
- teambition-sdk-request:包含接口代码,期待能够更快地相应应用需求,独
立更新

将使用 lift 的接口也包含在 fetches 包内

...并将相关 helper 函数和类型定义移到 fetches 包内。

save

sdk-request: 添加扩充 SDK 和 SDKFetch 对象的机制

sdk-request: 令现有测试跑起来

初步实现在跟目录上跑全局测试的脚本

...待完成:完善 teambition-sdk-request 的测试。

基本完成 teambition-sdk-request 相关测试,同时令mock成为packaege之一

基本完成对测试的分离和整理,并令 fixture 成为一个私有包

修复 core 和 reuqest 包的 watch 脚本,这两个包都可以执行 yarn watch

避免 watch 生成的 background process 在退出测试后继续跑

...相关命令:

 `npm run watch_test & ts-node ../../tools/tasks/test.ts $!`

即:令 watch_test 作为 background process 跑,及时将 test 目录下的代码
更新编译到 spec-js 目录,同时有 test.ts 的 nodejs 进程作为 foreground
process 在跑,及时在最新的 spec-js 目录上运行测试代码。当用户输入
Ctrl+C,即:SIGINT 信号,作为 foreground process 跑的 test.ts 会被终结。
而作为 background process 跑的 watch_test 通过 process.kill($!) 也终结
掉。注:$! 符号记录最近创建的 background process 的 pid。

修复跑全局测试的脚本,在根目录跑 yarn test,会跑所有测试

...包括每个 package 内的测试,以及根目录下 test/ 里的测试。

调整个别测试

修复 circle.yml,“修复” coverage,修复 .travis.yml

将顶层 test 里包含的 asyncLoadRDB 测试下移至 teambition-sdk-request 内

...简化项目结构

将 fixture 和 mock 放置到 teambition-sdk-testutil 包内

...简化项目结构。

修复 lint,并在代码中做相应调整,消除 lint 报错:no-shadowed-variables
@coveralls
Copy link

Coverage Status

Coverage decreased (-9.8%) to 84.862% when pulling 5e55eb4 on pkg-fetch-apis into 2a2b56e on release.

@chuan6
Copy link
Contributor Author

chuan6 commented Sep 9, 2017

@Brooooooklyn
Copy link
Contributor

use axios instead of Observable.ajax

@chuan6
Copy link
Contributor Author

chuan6 commented Sep 9, 2017

@Brooooooklyn 谢谢!我看看。

@Brooooooklyn
Copy link
Contributor

createRequest<T> (options: AxiosRequestConfig): Observable<T> {
  return Observable.create((observer: Observer<T>) => {
    const source = axios.CancelToken.source()
    axios.request({ ...this.defaultOptions, cancelToken: source.token, ...options })
        .then(response => {
          const { status } = response
          if (status >= 200 && response.status < 400) {
            let resp: T
            try {
              resp = JSON.parse(response.data)
            } catch (e) {
              resp = response.data
            }
            observer.next(resp)
            observer.complete()
          }
          observer.error(response)
        })
        .catch(e => {
          observer.error(e)
        })

    return () => source.cancel(cancelText)
  })
}

@Saviio
Copy link
Collaborator

Saviio commented Sep 9, 2017

我觉得不要, axios一进来又增加bundle size....

而且相比 Observable.ajax 也没看出什么很明显的优势,如果我们没有 Http 这个类,那我觉得直接用 axios 做 http client会不错。

@Brooooooklyn
Copy link
Contributor

引入 axios 就会去掉 Observable.ajax,bundle size 并不会增大多少(Observable.ajax 很大,而 axios minify 之后才 12k 不到)
Observable.ajax 有很多相关的 open 的 issue,RxJS 团队并没有精力去维护相关的东西,而且已经讨论要把 ajax websocket 相关的东西从 RxJS 的仓库中拿出去了

@mr-pinzhang
Copy link
Contributor

@Brooooooklyn really? wtf

@chuan6
Copy link
Contributor Author

chuan6 commented Jan 27, 2018

refs:

@chuan6 chuan6 closed this Jun 15, 2018
@chuan6 chuan6 deleted the pkg-fetch-apis branch June 15, 2018 05:18
@mr-pinzhang
Copy link
Contributor

why closed?

@chuan6
Copy link
Contributor Author

chuan6 commented Jun 20, 2018

@bjminhuang 暂时关掉了,等 ts3.0 出来的时候我再看看可行性吧

@chuan6 chuan6 restored the pkg-fetch-apis branch July 31, 2018 01:10
@chuan6
Copy link
Contributor Author

chuan6 commented Jul 31, 2018

ts3.0 'project references' out!

And more details: here and here.

Use yarn workspace with project references: example.

@chuan6 chuan6 reopened this Jul 31, 2018
@mr-pinzhang
Copy link
Contributor

@chuan6 awesome

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants