Author: Huan LI, Machine Learning Ph.D.

reduce weight

Picture Credit: Thumber.com

All about Wechaty v0.18 is to: Reduce Weight!

With v0.17, we have 27,630 source line of code with 377 unit tests(you can check it out at here if you are interested).

Start from v0.18, we have 7,817 lines of code left(v0.17 is 353% of this!), with 10+ related npm modules.

Let’s back to May 2016, when the first version of Wechaty was published, it only contains thousands of lines of the code, and at the end of the year 2016, we have about 10,000 lines of the code. (you can read our blog at this time)

As the time passed by in 2017 & 2018, we added more features to Wechaty, like send attachment files, support WeChat protocol other than web like ipad, which means we write more and more codes in Wechaty repository… at last we get almost 30,000 lines of the code, and to be precise: 27,630. (with 377 unit tests, you can check it out at here if you are interested)

Is that fat? 30,000 lines of the code, is not too much, but it is not a small number too. After we finished abstracting the puppet base class after v0.16, it seems we have very good reason to begin reducing weight:

  1. Abstract Puppet Class need to be imported by every puppet implementations, and it should to be a solo npm module, with good version management.
  2. Every Puppet Implentation Class is better to be a solo npm module, becasue we can only install the required source code that we needed.

So at this version (v0.18), we have the follow npm modules that splited out from Wechaty:

WECHATY PUPPET LIST

1. For Puppet User

Stage Name Wechaty Puppet Backend Version
Release puppeteer PuppetPuppeteer Web API via Browser Hooking PuppetPuppeteer
Beta padchat PuppetPadchat iPad Protocol PuppetPadchat
Alpha wechat4u PuppetWechat4u Web API via HTTP PuppetWechat4u
Alpha ioscat PuppetIoscat (WIP) iPhone App Hooking PuppetIoscat
Alpha hostie PuppetHostie Chatie Cloud PuppetHostie
TBW Android   Android Hook 0.0.0
TBW Win32   Win32 Hook 0.0.0

2. For Puppet Builder

Stage Name Wechaty Puppet Backend Version
Release N/A Puppet Abstract Base Class Puppet
Release mock PuppetMock Mocking PuppetMock

If we count the other npm modules that split out from Wechaty before, we can also list them as the following:

  1. @chatie/angular: Wechaty Component NgModule for Angular
  2. @chatie/graphql: GraphQL Schema, Providers and APIs for Chatie
  3. @chatie/grpc: gRPC for Chatie
  4. auth-angular: An Angular NgModule That Provide Auth0/Authing RxJS-ified Service with Lock UI
  5. botbuilder-wechaty-connector: Microsoft Bot Framework v3 Connector for Wechat PERSONAL Account
  6. Brolog: Brolog is Logger for Angular in Browser like Npmlog.
  7. cloneClass: Clone an ES6 Class as Another Class Name for Isolating Class Static Properties.
  8. finis: Node.js program finisher - run your last callback with exit code and signal name as arguments
  9. FileBox: Pack a File into Box for easy move/transfer between servers no matter of where it is.(local, remote url, or cloud storage)
  10. FlashStore: FlashStore is a Key-Value persistent
  11. hotImport: Hot Module Replacement(HMR) for Node.js storage with easy to use ES6 Map-like API(both Async and Sync support), powered by LevelDB and TypeScript.
  12. Listag: List Manager for Array Operations & Query by Tag
  13. MemoryCard: Memory Card is an Easy to Use Key/Value Store Implements ES6 Map with Async API, with Swagger & Serialization Support.
  14. RxQueue: Easy to Use RxJS Queue for Throttle/Debounce/Delay/DelayExecute
  15. StateSwitch: State Switch is a Monitor/Guard for Managing Your Async Operations.
  16. Watchdog: An Timer used to Detect and Recover from Malfunctions

Hmm… lots of them aha? So how can we keep all of them in one repository and manage them easily? It must be a nightmare!

So at last, as we published the v0.18, we only left 3,853 source lines of the code in Wechaty repository(7,817 physical lines). We can see a timeline from the history:

Source Lines of Code for Wechaty

Date SLOC Factor(%)
2016.5 3,000 38%
2017.1 10,000 128%
2018.1 20,000 256%
2018.6 27,630 353%
2018.7 7,817 100%

From 27,630 to 7,817, we are 72% off than before, cheers!

Change Log

v0.18.0 (2018-07-11)

Full Changelog

Implemented enhancements:

  • PuppetPadchat Upgrade TODO Lists #1442
  • Dynamic install puppet implementations instead of pre-install #1437
  • Split PuppetWechat4u as a NPM module #1419
  • PuppetPadchat: The contact.star() doesn’t work #1413
  • Promote PuppetPuppeteer to SOLO NPM Module wechaty-puppet-puppeteer #1371
  • Promote Puppet to SOLO NPM Module wechaty-puppet #1370
  • New Puppet: PuppetMock for Testing & Starter #1177

Fixed bugs:

  • Cannot detect the the environment WECHATY_PUPPET v0.17.118 #1456
  • PuppetPadchat Server logout and login cycle average 3-5mins #1446
  • WARN PuppetPuppeteer initWatchdogForPuppet() dog.on(reset) last food:inited, timeout:120000 #1439
  • ts-node 7.0 breaking change: Skip files by default #1383
  • Can not find room after add member to the room #1380
  • PuppetPadchat: friend value of ContactPayload is undefined #1359
  • WXGetContact cannot get user_name #1358
  • leveldown::Database::Close: Program terminated with signal SIGSEGV, Segmentation fault. #1355

Closed issues:

  • QR Code problem under screen/xterm #1455
  • How to get the room title in v0.17 wechaty? #1454
  • should not download chromium by default #1451
  • PuppetPadChat:Send media file. #1436
  • PuppetPadchat:My wechat accou can not login. #1416
  • It reports errors when the room delete one member. #1415
  • cannot get user\_name from raw payload: {} \[object Promise\] Error #1399
  • Where can I see the complete API documentation of puppet-padchat, such as createRoom and Moment #1391
  • still restart #1378
  • WARN PuppetPuppeteer #1376
  • m.say() repeat many many times #1216
  • room.say mention is not work #1185
  • 获取所有群 #1020
  • Any way to keep login for days? #988

Merged pull requests: