Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

feat: type check & generate defs from jsdoc #3281

Merged
merged 79 commits into from
Oct 21, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
79 commits
Select commit Hold shift + click to select a range
4c13ab8
feat: type check & generate defs from jsdoc
Gozala Sep 11, 2020
aecf4aa
chore: Add `NonNullable<Condition>` to avoid any type on `strictNullC…
Gozala Sep 15, 2020
f35a83e
chore: merge with upstream/master
Gozala Oct 5, 2020
bb8e833
Merge branch 'type-gen' of github.com:ipfs/js-ipfs into type-gen
Gozala Oct 5, 2020
65fa5da
chore: merge upstream/master
Gozala Oct 6, 2020
38e3d1d
fix: eslint complaints after merging master
Gozala Oct 6, 2020
7ae81dc
chore: add build:types script
Gozala Oct 6, 2020
d5a8668
fix: type check ipfs-core
Gozala Oct 6, 2020
398e7dd
fix: post-merge regression
Gozala Oct 6, 2020
3d9ef4d
fix: build types before running type check
Gozala Oct 6, 2020
c5fd61f
fix: failing test
Gozala Oct 6, 2020
59b3aff
fix: build ipfs-core to gen types
Gozala Oct 6, 2020
affabd9
chore: cleanup json files
Gozala Oct 7, 2020
7d508ff
Merge remote-tracking branch 'origin/master' into type-gen
achingbrain Oct 7, 2020
c20b6fa
fix: typo
Gozala Oct 8, 2020
671a50b
chore: apply suggestions from code review
Gozala Oct 8, 2020
73012d0
fix: add types to cat,get,ls APIs
Gozala Oct 9, 2020
98fa7b2
Merge remote-tracking branch 'origin/master' into type-gen
achingbrain Oct 12, 2020
6724379
chore: add dummy build steps for node-only projects
achingbrain Oct 12, 2020
a22eae1
Apply suggestions from code review
Gozala Oct 12, 2020
94b3b2c
chore: read files as strings
Gozala Oct 12, 2020
504ee49
chore: address more review comments
Gozala Oct 12, 2020
9c297e2
Update packages/ipfs-cli/package.json
Gozala Oct 12, 2020
313c214
fix: add missing jsdocs
Gozala Oct 12, 2020
0f3aee9
chore: swich to default param for optional options
Gozala Oct 12, 2020
f74e95b
fix: type error
Gozala Oct 13, 2020
993b25e
chore: add missing types
achingbrain Oct 13, 2020
80df297
add more typings
Gozala Oct 14, 2020
f7f6a64
cover more files with types
Gozala Oct 15, 2020
2dd670e
fix: imports to any-signal
Gozala Oct 15, 2020
58eaaea
chore: add types to mfs methods in core and client
achingbrain Oct 15, 2020
758172a
Merge branch 'type-gen' of github.com:ipfs/js-ipfs into type-gen
achingbrain Oct 15, 2020
f90d012
chore: cleanup imports
Gozala Oct 15, 2020
55e9525
chore: add dev-dep on ipfs-core need for types
Gozala Oct 15, 2020
e991bcb
chore: change imports to ipfs-core
Gozala Oct 15, 2020
ef75e21
Merge remote-tracking branch 'upstream/type-gen' into type-gen
Gozala Oct 15, 2020
e05ff3f
fix: post-merge regerssion
Gozala Oct 15, 2020
711af52
fix: import ipfs-core import paths
Gozala Oct 15, 2020
b06699a
feat: typecheck action (#3327)
Gozala Oct 15, 2020
7e10999
Apply suggestions from code review
Gozala Oct 15, 2020
02e919f
entype ipfs-core-utils
Gozala Oct 15, 2020
d26fc1d
add ipfs-http-client to typecheck action
Gozala Oct 15, 2020
5b2fd65
fix: types in message-port packages
Gozala Oct 16, 2020
8c77086
Merge remote-tracking branch 'upstream/master' into type-gen
Gozala Oct 16, 2020
a72541b
fix: postmerge regressions
Gozala Oct 16, 2020
b4f8289
fix: mfs typedefs
Gozala Oct 16, 2020
23a30be
fix: dev-dep version
Gozala Oct 16, 2020
9a15ce9
remove typecheck
Gozala Oct 16, 2020
692b00f
chore: fix up type gen and checking for cli and http
achingbrain Oct 16, 2020
4c8da56
chore: typesVersions seems to cause source to be loaded from dist
achingbrain Oct 16, 2020
81c08b6
chore: remove unused deps
achingbrain Oct 16, 2020
8c7d587
chore: fix linting
achingbrain Oct 16, 2020
456f34e
chore: align bootstrap method output types and document
achingbrain Oct 16, 2020
44b0328
chore: merge options the right way round
achingbrain Oct 16, 2020
2dc6d02
chore: fix up read test and remove redundant file
achingbrain Oct 16, 2020
a0a43fa
fix: typegen on http-client
Gozala Oct 16, 2020
0a69a5d
chore: run tsc during lint phase for non-browser modules
achingbrain Oct 16, 2020
5069eeb
chore: have http client add version to version output
achingbrain Oct 16, 2020
c35838e
Merge branch 'type-gen' of github.com:ipfs/js-ipfs into type-gen
achingbrain Oct 16, 2020
b0786c8
chore: run type check during build
achingbrain Oct 16, 2020
311941c
fix: how we generate types
Gozala Oct 16, 2020
27679d3
fix: remove old type generator
Gozala Oct 16, 2020
326ab5c
fix: add project refs support to typecheck
Gozala Oct 16, 2020
e6f6873
feat: rewrite the typecheck action
Gozala Oct 17, 2020
4f75b44
chore: build packages before installing deps for examples
achingbrain Oct 19, 2020
e8943d4
fix: typecheck action
Gozala Oct 20, 2020
0b86462
chore: opt-out of size checks in node only cases
Gozala Oct 20, 2020
7f37144
chore: opt in to size checks
achingbrain Oct 20, 2020
05291fc
chore: try running as a matrix
achingbrain Oct 20, 2020
eb81175
chore: fix gh action
achingbrain Oct 20, 2020
3379ae7
chore: only run on pr
achingbrain Oct 20, 2020
849850c
chore: add version to bundlesize
achingbrain Oct 20, 2020
5b2b0d4
chore: use branch again
achingbrain Oct 20, 2020
0c89bff
chore: pass project dir as argument
achingbrain Oct 20, 2020
173fc1b
chore: update bundle sizes
achingbrain Oct 20, 2020
88770f9
chore: upgrade aegir
achingbrain Oct 20, 2020
edb367a
chore: update deps & remove obsolete ignores
Gozala Oct 20, 2020
265555a
Revert "chore: update deps & remove obsolete ignores"
Gozala Oct 21, 2020
e6f3541
chore: update delegate module deps
achingbrain Oct 21, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ jobs:
- npm run build -- $RUN_SINCE --scope={ipfs,ipfs-http-client,ipfs-message-port-*}
- npm run dep-check -- $RUN_SINCE -- -- -- -i electron-webrtc
- npm run lint -- $RUN_SINCE --concurrency 1
- npm run check -- $RUN_SINCE --concurrency 1

- stage: test
name: chrome
Expand Down
1 change: 0 additions & 1 deletion packages/ipfs-http-client/src/add-all.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ const anySignal = require('any-signal')
const AbortController = require('abort-controller').default

module.exports = configure((api) => {
// eslint-disable-next-line valid-jsdoc
/**
* @type {import('../../ipfs/src/core/components/add-all').AddAll<import('.').HttpOptions>}
*/
Expand Down
2 changes: 0 additions & 2 deletions packages/ipfs-http-client/src/add.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,13 @@ const configure = require('./lib/configure')
* @typedef {import("./lib/core").ClientOptions} ClientOptions
*/

// eslint-disable-next-line valid-jsdoc
/**
* @param {ClientOptions} options
*/
module.exports = (options) => {
const all = addAll(options)

return configure(() => {
// eslint-disable-next-line valid-jsdoc
/**
* @type {import('../../ipfs/src/core/components/add').Add<import('.').HttpOptions>}
*/
Expand Down
1 change: 0 additions & 1 deletion packages/ipfs-http-client/src/bitswap/stat.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ const configure = require('../lib/configure')
const toUrlSearchParams = require('../lib/to-url-search-params')

module.exports = configure(api => {
// eslint-disable-next-line valid-jsdoc
/**
* @type {import('../../../ipfs/src/core/components/bitswap/stat').Stat<import('..').HttpOptions>}
*/
Expand Down
1 change: 0 additions & 1 deletion packages/ipfs-http-client/src/bitswap/unwant.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ const configure = require('../lib/configure')
const toUrlSearchParams = require('../lib/to-url-search-params')

module.exports = configure(api => {
// eslint-disable-next-line valid-jsdoc
/**
* @type {import('../../../ipfs/src/core/components/bitswap/unwant').Unwant<import('..').HttpOptions>}
*/
Expand Down
1 change: 0 additions & 1 deletion packages/ipfs-http-client/src/bitswap/wantlist-for-peer.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ const configure = require('../lib/configure')
const toUrlSearchParams = require('../lib/to-url-search-params')

module.exports = configure(api => {
// eslint-disable-next-line valid-jsdoc
/**
* @type {import('../../../ipfs/src/core/components/bitswap/wantlist-for-peer').WantlistForPeer<import('..').HttpOptions>}
*/
Expand Down
1 change: 0 additions & 1 deletion packages/ipfs-http-client/src/bitswap/wantlist.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ const configure = require('../lib/configure')
const toUrlSearchParams = require('../lib/to-url-search-params')

module.exports = configure(api => {
// eslint-disable-next-line valid-jsdoc
/**
* @type {import('../../../ipfs/src/core/components/bitswap/wantlist').WantlistFn<import('..').HttpOptions>}
*/
Expand Down
1 change: 0 additions & 1 deletion packages/ipfs-http-client/src/block/get.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ const configure = require('../lib/configure')
const toUrlSearchParams = require('../lib/to-url-search-params')

module.exports = configure(api => {
// eslint-disable-next-line valid-jsdoc
/**
* @type {import('../../../ipfs/src/core/components/block/get').BlockGet<import('..').HttpOptions>}
*/
Expand Down
1 change: 0 additions & 1 deletion packages/ipfs-http-client/src/block/put.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ const anySignal = require('any-signal')
const AbortController = require('abort-controller').default

module.exports = configure(api => {
// eslint-disable-next-line valid-jsdoc
/**
* @type {import('../../../ipfs/src/core/components/block/put').BlockPut<import('..').HttpOptions>}
*/
Expand Down
1 change: 0 additions & 1 deletion packages/ipfs-http-client/src/id.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ const configure = require('./lib/configure')
const toUrlSearchParams = require('./lib/to-url-search-params')

module.exports = configure(api => {
// eslint-disable-next-line valid-jsdoc
/**
* @type {import('../../ipfs/src/core/components/id').Id<import('.').HttpOptions>}
*/
Expand Down
1 change: 0 additions & 1 deletion packages/ipfs-http-client/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ const urlSource = require('ipfs-utils/src/files/url-source')
* @property {(format: string) => Promise<any>} [ipld.loadFormat] - an async function that takes the name of an [IPLD format](https://github.com/ipld/interface-ipld-format) as a string and should return the implementation of that codec
*/

// eslint-disable-next-line valid-jsdoc
/**
* @param {ClientOptions} options
*/
Expand Down
1 change: 0 additions & 1 deletion packages/ipfs-http-client/src/resolve.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ const configure = require('./lib/configure')
const toUrlSearchParams = require('./lib/to-url-search-params')

module.exports = configure(api => {
// eslint-disable-next-line valid-jsdoc
/**
* @type {import('../../ipfs/src/core/components/resolve').Resolve<import('.').HttpOptions>}
*/
Expand Down
1 change: 0 additions & 1 deletion packages/ipfs-http-client/src/version.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ const configure = require('./lib/configure')
const toUrlSearchParams = require('./lib/to-url-search-params')

module.exports = configure(api => {
// eslint-disable-next-line valid-jsdoc
/**
* @type {import('../../ipfs/src/core/components/version').Version<import('.').HttpOptions>}
*/
Expand Down
6 changes: 6 additions & 0 deletions packages/ipfs/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
Gozala marked this conversation as resolved.
Show resolved Hide resolved
"extends": "ipfs",
"rules": {
"jsdoc/no-undefined-types": 0
}
}
17 changes: 14 additions & 3 deletions packages/ipfs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@
},
"scripts": {
"lint": "aegir lint",
"build": "aegir build",
"build": "npm run build:bundle && npm run build:types",
"build:bundle": "aegir build",
"build:types": "tsc --emitDeclarationOnly --declarationDir dist",
"test": "aegir test",
"test:node": "aegir test -t node",
"test:browser": "aegir test -t browser",
Expand Down Expand Up @@ -193,7 +195,16 @@
"stream-to-promise": "^3.0.0",
"string-argv": "^0.3.1",
"temp-write": "^4.0.0",
"wrtc": "^0.4.4"
"wrtc": "^0.4.4",
"typescript": "4.0.2",
"eslint-config-ipfs": "git://github.com/gozala/eslint-config-ipfs#default"
Gozala marked this conversation as resolved.
Show resolved Hide resolved
},
"typesVersions": {
"*": {
"*": [
"dist/*"
]
}
},
"optionalDependencies": {
"prom-client": "^12.0.0",
Expand Down Expand Up @@ -348,4 +359,4 @@
"Максим Ильин <negamaxi@gmail.com>",
"Xmader <xmader@outlook.com>"
]
}
}
2 changes: 2 additions & 0 deletions packages/ipfs/src/cli/commands/block/put.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

const fs = require('fs')
const multibase = require('multibase')
/** @type {typeof import('it-concat').default} */
// @ts-ignore - it-contact has invalid type defs for commonjs
Gozala marked this conversation as resolved.
Show resolved Hide resolved
Gozala marked this conversation as resolved.
Show resolved Hide resolved
const concat = require('it-concat')
const { cidToString } = require('../../../utils/cid')
const parseDuration = require('parse-duration').default
Expand Down
3 changes: 0 additions & 3 deletions packages/ipfs/src/cli/commands/bootstrap/rm.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
'use strict'

const debug = require('debug')
const log = debug('cli:bootstrap')
log.error = debug('cli:bootstrap:error')
const parseDuration = require('parse-duration').default

module.exports = {
Expand Down
2 changes: 1 addition & 1 deletion packages/ipfs/src/cli/commands/config/profile/apply.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ module.exports = {
timeout
})
const delta = JSONDiff.diff(diff.original, diff.updated)
const res = JSONDiff.formatters.console.format(delta, diff.original)
const res = delta && JSONDiff.formatters.console.format(delta, diff.original)

if (res) {
print(res)
Expand Down
3 changes: 0 additions & 3 deletions packages/ipfs/src/cli/commands/config/show.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
'use strict'

const debug = require('debug')
const log = debug('cli:config')
log.error = debug('cli:config:error')
const parseDuration = require('parse-duration').default

module.exports = {
Expand Down
5 changes: 4 additions & 1 deletion packages/ipfs/src/cli/commands/daemon.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ module.exports = {
if (argv.initConfig) {
try {
const raw = fs.readFileSync(argv.initConfig)
config = JSON.parse(raw)
config = JSON.parse(raw.toString())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be better here to specify the encoding as utf8 to fs.readFileSync? Then it will return a string.

Copy link
Contributor Author

@Gozala Gozala Oct 8, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think following would work if you'd prefer that:

const raw = fs.readFileSync({ ...argv.initConfig, encoding: 'utf8' })

The reason I did not do it is I was not confident that initConfig may not have encoding in it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

argv.initConfig is a string so it would need to be:

const raw = fs.readFileSync(argv.initConfig, { encoding: 'utf8' })

} catch (error) {
debug(error)
throw new Error('Default config couldn\'t be found or content isn\'t valid JSON.')
Expand All @@ -83,12 +83,15 @@ module.exports = {

try {
await daemon.start()
// @ts-ignore - _httpApi is possibly undefined
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a good thing? If _httpApi is undefined the next line will fail.

daemon._httpApi._apiServers.forEach(apiServer => {
print(`API listening on ${apiServer.info.ma}`)
})
// @ts-ignore - _httpApi is possibly undefined
daemon._httpApi._gatewayServers.forEach(gatewayServer => {
print(`Gateway (read only) listening on ${gatewayServer.info.ma}`)
})
// @ts-ignore - _httpApi is possibly undefined
daemon._httpApi._apiServers.forEach(apiServer => {
print(`Web UI available at ${toUri(apiServer.info.ma)}/webui`)
})
Expand Down
2 changes: 2 additions & 0 deletions packages/ipfs/src/cli/commands/dag/put.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ const mh = require('multihashing-async').multihash
const multibase = require('multibase')
const dagCBOR = require('ipld-dag-cbor')
const dagPB = require('ipld-dag-pb')
/** @type {typeof import('it-concat').default} */
// @ts-ignore - incorrect typedefs
Gozala marked this conversation as resolved.
Show resolved Hide resolved
const concat = require('it-concat')
const CID = require('cids')
const { cidToString } = require('../../../utils/cid')
Expand Down
2 changes: 1 addition & 1 deletion packages/ipfs/src/cli/commands/get.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
const fs = require('fs')
const path = require('path')
const toIterable = require('stream-to-it')
const pipe = require('it-pipe')
const { pipe } = require('it-pipe')
const { map } = require('streaming-iterables')
const parseDuration = require('parse-duration').default

Expand Down
2 changes: 1 addition & 1 deletion packages/ipfs/src/cli/commands/id.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@ module.exports = {
return
}

print(JSON.stringify(id, '', 2))
print(JSON.stringify(id, null, 2))
}
}
2 changes: 1 addition & 1 deletion packages/ipfs/src/cli/commands/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ module.exports = {
if (argv.defaultConfig) {
try {
const raw = fs.readFileSync(argv.defaultConfig)
Gozala marked this conversation as resolved.
Show resolved Hide resolved
config = JSON.parse(raw)
config = JSON.parse(raw.toString())
} catch (error) {
debug(error)
throw new Error('Default config couldn\'t be found or content isn\'t valid JSON.')
Expand Down
2 changes: 1 addition & 1 deletion packages/ipfs/src/cli/commands/key/import.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ module.exports = {
describe: 'Input PEM file',
type: 'string',
demandOption: true,
coerce: ('input', input => fs.readFileSync(input, 'utf8'))
coerce: input => fs.readFileSync(input, 'utf8')
},
timeout: {
type: 'string',
Expand Down
2 changes: 2 additions & 0 deletions packages/ipfs/src/cli/commands/object/patch/append-data.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
'use strict'

/** @type {typeof import('it-concat').default} */
// @ts-ignore - incorrect type defs
const concat = require('it-concat')
const fs = require('fs')
const multibase = require('multibase')
Expand Down
2 changes: 2 additions & 0 deletions packages/ipfs/src/cli/commands/object/patch/set-data.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
'use strict'

const fs = require('fs')
/** @type {typeof import('it-concat').default} */
// @ts-ignore - incorrect type defs
const concat = require('it-concat')
const multibase = require('multibase')
const { cidToString } = require('../../../../utils/cid')
Expand Down
2 changes: 2 additions & 0 deletions packages/ipfs/src/cli/commands/object/put.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
'use strict'

const fs = require('fs')
/** @type {typeof import('it-concat').default} */
// @ts-ignore - incorrect type defs
const concat = require('it-concat')
const multibase = require('multibase')
const { cidToString } = require('../../../utils/cid')
Expand Down
2 changes: 1 addition & 1 deletion packages/ipfs/src/cli/commands/refs-local.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ module.exports = {
}
},

async handler ({ ctx: { ipfs, print }, timeout, cidBase, multihash }) {
async handler ({ ctx: { ipfs, print }, timeout, multihash }) {
for await (const { ref, err } of ipfs.refs.local({
timeout
})) {
Expand Down
9 changes: 5 additions & 4 deletions packages/ipfs/src/cli/commands/stats/bitswap.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
'use strict'

// This is an alias for `bitswap stat`.
const bitswapStats = require('../bitswap/stat.js')
// The command needs to be renamed, else it would be `stats stat` instead of
// `stats bitswap`
bitswapStats.command = 'bitswap'
const bitswapStats = Object.assign(require('../bitswap/stat.js'), {
// The command needs to be renamed, else it would be `stats stat` instead of
// `stats bitswap`
command: 'bitswap'
})
module.exports = bitswapStats
3 changes: 0 additions & 3 deletions packages/ipfs/src/cli/commands/swarm/addrs/local.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
'use strict'

const debug = require('debug')
const log = debug('cli:object')
log.error = debug('cli:object:error')
const parseDuration = require('parse-duration').default

module.exports = {
Expand Down
6 changes: 6 additions & 0 deletions packages/ipfs/src/cli/daemon.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class Daemon {
const prometheusClient = require('prom-client')
const prometheusGcStats = require('prometheus-gc-stats')
const collectDefaultMetrics = prometheusClient.collectDefaultMetrics
// @ts-ignore - timeout isn't in typedefs
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should it be? Can you PR prom-client to add it?

collectDefaultMetrics({ timeout: 5000 })
prometheusGcStats(prometheusClient.register)()
}
Expand All @@ -42,7 +43,9 @@ class Daemon {
this._httpApi = await httpApi.start()

// for the CLI to know the where abouts of the API
// @ts-ignore - _apiServers is possibly undefined
if (this._httpApi._apiServers.length) {
// @ts-ignore - _apiServers is possibly undefined
await repo.apiAddr.set(this._httpApi._apiServers[0].info.ma)
}

Expand All @@ -54,6 +57,7 @@ class Daemon {
log('stopping')
await Promise.all([
this._httpApi && this._httpApi.stop(),
// @ts-ignore - may not have stop if init was false
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stop should be present, but it should throw.

this._ipfs && this._ipfs.stop()
])
log('stopped')
Expand All @@ -66,6 +70,7 @@ function getLibp2p ({ libp2pOptions, options, config, peerId }) {
let electronWebRTC
let wrtc
try {
// @ts-ignore - cant find type info
electronWebRTC = require('electron-webrtc')()
} catch (err) {
log('failed to load optional electron-webrtc dependency')
Expand Down Expand Up @@ -94,6 +99,7 @@ function getLibp2p ({ libp2pOptions, options, config, peerId }) {
const delegateApiOptions = {
host: delegateAddr.host,
// port is a string atm, so we need to convert for the check
// @ts-ignore - parseInt(input:string) => number
protocol: parseInt(delegateAddr.port) === 443 ? 'https' : 'http',
port: delegateAddr.port
}
Expand Down
3 changes: 2 additions & 1 deletion packages/ipfs/src/cli/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const print = (msg, includeNewline = true, isError = false) => {
}

print.clearLine = () => {
return process.stdout.clearLine()
return process.stdout.clearLine(0)
}

print.cursorTo = (pos) => {
Expand Down Expand Up @@ -92,6 +92,7 @@ async function getIpfs (argv) {
start: false,
pass: argv.pass
})

return {
isDaemon: false,
ipfs,
Expand Down
Loading