提交 5ddffc04 编写于 作者: Huan (李卓桓)'s avatar Huan (李卓桓)

code clean by removing unused codes & deps

上级 60621f3b
......@@ -38,8 +38,7 @@
"typedoc": "bash scripts/typedoc.sh",
"io-client": "ts-node bin/io-client",
"demo": "ts-node examples/ding-dong-bot.ts",
"start": "npm run demo",
"postinstall": "opencollective-postinstall"
"start": "npm run demo"
},
"repository": {
"type": "git",
......@@ -83,7 +82,6 @@
},
"homepage": "https://github.com/wechaty/",
"dependencies": {
"brolog": "^1.12.4",
"clone-class": "^0.7.3",
"cuid": "^2.1.8",
"dotenv": "^10.0.0",
......@@ -91,14 +89,10 @@
"json-rpc-peer": "^0.17.0",
"npm-programmatic": "0.0.12",
"open-graph": "^0.2.4",
"opencollective": "^1.0.3",
"opencollective-postinstall": "^2.0.3",
"pkg-dir": "^5.0.0",
"portfinder": "^1.0.28",
"promise-retry": "^2.0.1",
"raven": "^2.6.4",
"read-pkg-up": "^7.0.1",
"watchdog": "^0.8.17",
"wechaty-puppet": "^0.41.1",
"wechaty-puppet-service": "^0.21.8",
"ws": "^7.4.6"
......@@ -134,8 +128,8 @@
"shx": "^0.3.3",
"sloc": "^0.2.1",
"tstest": "^0.4.10",
"typedoc": "^1.0.0-dev.4 ",
"typed-emitter": "^1.3.1",
"typedoc": "^1.0.0-dev.4 ",
"typescript": "^4.3",
"wechaty-puppet-mock": "^0.29.6"
},
......
#!/usr/bin/env ts-node
/**
* Wechaty Chatbot SDK - https://github.com/wechaty/wechaty
*
* @copyright 2016 Huan LI (李卓桓) <https://github.com/huan>, and
* Wechaty Contributors <https://github.com/wechaty>.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
import test from 'blue-tape'
import net from 'net'
import { getPort } from './get-port'
test('getPort() for an available socket port', async t => {
let port = await getPort()
let ttl = 17
const serverList = []
while (ttl-- > 0) {
try {
const server = net.createServer(socket => {
console.info(socket)
})
await new Promise<void>(resolve => server.listen(port, resolve))
serverList.push(server)
port = await getPort()
} catch (e) {
t.fail('should not exception: ' + e.message + ', ' + e.stack)
}
}
serverList.map(server => server.close())
t.pass('should has no exception after loop test')
})
/**
* Wechaty Chatbot SDK - https://github.com/wechaty/wechaty
*
* @copyright 2016 Huan LI (李卓桓) <https://github.com/huan>, and
* Wechaty Contributors <https://github.com/wechaty>.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
import portfinder from 'portfinder'
/**
*
* @param port is just a suggestion.
* there's no grantuee for the number
*
* The IANA suggested ephemeral port range.
* @see http://en.wikipedia.org/wiki/Ephemeral_ports
*
* const DEFAULT_IANA_RANGE = {min: 49152, max: 65535}
*
*/
export async function getPort (
basePort?: number,
): Promise<number> {
if (basePort) {
portfinder.basePort = basePort
}
return portfinder.getPortPromise()
}
......@@ -17,7 +17,6 @@
* limitations under the License.
*
*/
export { getPort } from './impure/get-port'
export { generateToken } from './impure/generate-token'
export { tryWait } from './pure/try-wait'
......
......@@ -20,7 +20,6 @@
import cuid from 'cuid'
import os from 'os'
import { Brolog } from 'brolog'
import { instanceToClass } from 'clone-class'
import {
......@@ -136,8 +135,8 @@ const PUPPET_MEMORY_NAME = 'puppet'
class Wechaty extends WechatyEventEmitter implements Sayable {
static readonly VERSION = VERSION
static readonly log: Brolog = log
readonly log: Brolog = log
static readonly log = log
readonly log = log
public readonly state : StateSwitch
private readonly readyState : StateSwitch
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册