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

docs: add types and documentation #11

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ jobs:
- uses: actions/checkout@v2
- run: yarn
- run: yarn lint
# - uses: gozala/[email protected]
- uses: gozala/[email protected]
# - run: yarn build
- run: yarn aegir dep-check
# - run: yarn aegir dep-check
- uses: ipfs/aegir/actions/bundle-size@master
name: size
with:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
node_modules
dist
13 changes: 11 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@
"release": "aegir release",
"build": "aegir build",
"test": "aegir test",
"test:node": "aegir test --target node",
"test:browser": "aegir test --target browser"
"test:node": "aegir test --target node"
},
"dependencies": {
"ioredis": "^4.19.2",
"ipaddr.js": "^2.0.0",
"lodash.flatten": "^4.4.0",
"winston": "^3.3.3"
Comment on lines +34 to 35

Choose a reason for hiding this comment

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

would be better to use Array.flat and consider pino instead of winston

Copy link
Member Author

Choose a reason for hiding this comment

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

The linter complains because Array.flat was not available on Node 10. I could not change the engines to Node 12.

Thanks for the pino suggestion!

Choose a reason for hiding this comment

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

why are you supporting node10 ?

Copy link
Member Author

@hacdias hacdias Dec 11, 2020

Choose a reason for hiding this comment

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

image

Apparently it's the TS checker. The linter is Ok.

Edit: please ignore this.

Choose a reason for hiding this comment

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

wait why are flattening that method returns an object not a array

Copy link
Member Author

Choose a reason for hiding this comment

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

why are you supporting node10 ?

@hugomrdias every time I change the engines in package.json to:

  "engines": {
    "node": ">=12.0.0"
  },

I get:

./node_modules/.bin/aegir lint-package-json

./package.json
✖ valid-values-engines - node: engines - Invalid value for engines
1 error
0 warnings
Command failed with exit code 2: npmPkgJsonLint /Users/henriquedias/Code/testground/sdk-js/package.json -c /Users/henriquedias/Code/testground/sdk-js/node_modules/aegir/src/config/.npmpackagejsonlintrc.json

Then I saw this and assumed we had to support Node 10.

Choose a reason for hiding this comment

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

ah got it i will fix that, sorry my bad, that rule is dumb

},
"devDependencies": {
Expand All @@ -40,5 +40,14 @@
"engines": {
"node": ">=10.0.0",
"npm": ">=6.0.0"
},
"types": "dist/src/index.d.ts",
"typesVersions": {
"*": {
"src/*": [
"dist/src/*",
"dist/src/*/index"
]
}
}
}
3 changes: 2 additions & 1 deletion src/network/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

const os = require('os')
const ipaddr = require('ipaddr.js')
const flatten = require('lodash.flatten')

const ALLOW_ALL = 'allow_all'
const DENY_ALL = 'deny_all'
Expand Down Expand Up @@ -93,7 +94,7 @@ function getDataNetworkIP ({ client, runenv }) {
return '127.0.0.1'
}

const ifaces = os.networkInterfaces().flat()
const ifaces = flatten(os.networkInterfaces())

for (const { address, family } of ifaces) {
if (family !== 'IPv4') {
Expand Down
2 changes: 1 addition & 1 deletion src/sync/redis.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ async function redisClient (logger) {
const host = process.env[ENV_REDIS_HOST]

if (process.env[ENV_REDIS_PORT]) {
port = Number.parseInt(process.env[ENV_REDIS_PORT])
port = Number.parseInt(process.env[ENV_REDIS_PORT] || '0')
}

logger.debug('trying redis host', { host, port })
Expand Down
10 changes: 10 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": "./node_modules/aegir/src/config/tsconfig.aegir.json",
"compilerOptions": {
"outDir": "dist"
},
"include": [
"test", // remove this line if you don't want to type-check tests
"src"
]
}