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

refactor to es6 syntax with classes #665

Merged
merged 31 commits into from Nov 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
ee4e8ea
refactor to es6 syntax with classes
hornta Oct 3, 2021
54f8c97
Refactored ConnectionsManager to class
hornta Oct 4, 2021
8b94b1a
Refactored ManagementTokenProvider to use es6 class
hornta Oct 4, 2021
3da4f1c
Got rid of dependency on es6-promisify by using the native Promise ob…
hornta Oct 4, 2021
6befd38
Upgrade docker node image to 12
hornta Oct 4, 2021
b1c1639
Add some linting to aid in working with promises
hornta Oct 4, 2021
e222f32
Converted the remaining prototypes to classes
hornta Oct 5, 2021
fb49243
Refactor test to use async/await for increased readability
hornta Oct 5, 2021
8f3b0b2
Merge remote-tracking branch 'upstream/master' into es6
hornta Oct 5, 2021
caf4740
Merge branch 'master' into es6
hornta Oct 15, 2021
7ed1742
remove engine requirements
hornta Oct 19, 2021
93f2bf7
Merge branch 'es6' of https://github.com/hornta/node-auth0 into es6
hornta Oct 19, 2021
95d9c64
Merge remote-tracking branch 'upstream/master' into es6
hornta Oct 19, 2021
3f6ce91
Merge branch 'master' into es6
adamjmcgrath Oct 19, 2021
eef7e91
add node v16 to ci
hornta Oct 19, 2021
dd4085d
Merge branch 'es6' of https://github.com/hornta/node-auth0 into es6
hornta Oct 19, 2021
1db9d4b
set minimum support node version
hornta Oct 20, 2021
042003a
run ci on node 8 and 10 without eslint
hornta Oct 20, 2021
6e2a0e7
remove eslint for the no-lint script, duh...
hornta Oct 20, 2021
79f5423
disable running test on 8 and 10 because mocha has no support for ver…
hornta Oct 20, 2021
7afa69f
test downgrading mocha to 8
hornta Oct 20, 2021
4413912
run eslint conditionally in job
hornta Oct 20, 2021
1f301ac
update husky hooks placement
hornta Oct 22, 2021
e45438f
run the tests on node 8 in mocha 6 with npx
hornta Oct 22, 2021
9dd4d30
Update src/management/ConnectionsManager.js
hornta Oct 28, 2021
64146b8
Update src/management/LogsManager.js
hornta Oct 28, 2021
18f79a7
cleanup
hornta Oct 28, 2021
738e065
Merge branch 'es6' of https://github.com/hornta/node-auth0 into es6
hornta Oct 28, 2021
4dfb600
Revert back to using proxyquire and
hornta Oct 30, 2021
9f395f2
Made the `getCachedAccessToken` a promise again
hornta Oct 30, 2021
f50f779
Merge branch 'master' into es6
adamjmcgrath Nov 19, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
35 changes: 30 additions & 5 deletions .circleci/config.yml
Expand Up @@ -24,24 +24,49 @@ jobs:
key: yarn-packages-{{ checksum "yarn.lock" }}
paths:
- ~/.cache/yarn
- run:
name: Tests
command: yarn test:ci
- when:
condition:
# ESLint has dropped support for version 8 and 10.
and:
- not:
equal: [ "8", << parameters.node-version >> ]
- not:
equal: [ "10", << parameters.node-version >> ]
steps:
- run:
name: ESLint
command: yarn lint
- when:
condition:
# mocha@>=6 doesn't support node 8 so we use mocha@6 with npx to run the tests
equal: ["8", << parameters.node-version >>]
steps:
- run:
name: Tests
command: "npx mocha@6 --reporter spec './test/**/*.tests.js'"
- when:
condition:
and:
- not:
equal: ["8", << parameters.node-version >>]
steps:
- run:
name: Tests
command: yarn test:ci
- when:
condition:
equal: [ "12", << parameters.node-version >> ]
steps:
- run:
name: Generate Coverage
command: yarn test:coverage

workflows:
build-test-report:
jobs:
- build-and-test:
matrix:
parameters:
node-version: ["8", "10", "12", "14"]
node-version: ["8", "10", "12", "14", "16"]
- ship/node-publish:
pkg-manager: yarn
requires:
Expand Down
2 changes: 2 additions & 0 deletions .eslintignore
@@ -0,0 +1,2 @@
!.mocharc.js
docs
55 changes: 55 additions & 0 deletions .eslintrc.js
@@ -0,0 +1,55 @@
module.exports = {
env: {
node: true,
commonjs: true,
es2017: true,
mocha: true,
},
extends: [
'eslint:recommended',
'plugin:jsdoc/recommended',
'plugin:node/recommended',
'plugin:promise/recommended',
'plugin:prettier/recommended',
],
plugins: ['jsdoc'],
parserOptions: {
ecmaVersion: 9,
},
rules: {
'arrow-body-style': 'error',
'arrow-parens': 'error',
'arrow-spacing': 'error',
'generator-star-spacing': 'error',
'no-confusing-arrow': 'error',
'no-duplicate-imports': 'error',
'no-restricted-exports': 'error',
'no-restricted-imports': 'error',
'no-useless-computed-key': 'error',
'no-useless-constructor': 'error',
'no-useless-rename': 'error',
'no-var': 'error',
'object-shorthand': 'error',
'prefer-arrow-callback': 'error',
'prefer-const': 'error',
'prefer-destructuring': 'error',
'prefer-numeric-literals': 'error',
'prefer-rest-params': 'error',
'prefer-spread': 'error',
'prefer-template': 'error',
'rest-spread-spacing': 'error',
'sort-imports': 'error',
'symbol-description': 'error',
'template-curly-spacing': 'error',
'yield-star-spacing': 'error',

'jsdoc/require-jsdoc': ['warn', { publicOnly: true }],
'jsdoc/require-returns-description': 'off',
'jsdoc/no-undefined-types': 'off',
'jsdoc/require-param': 'off',
'jsdoc/check-param-names': 'off',

'promise/catch-or-return': 'off',
'promise/always-return': 'off',
},
};
54 changes: 23 additions & 31 deletions .jsdoc.json
@@ -1,32 +1,24 @@
{
"tags": {
"allowUnknownTags": true,
"dictionaries": [
"jsdoc"
]
},
"source": {
"include": [
"src",
"package.json",
"README.md"
],
"includePattern": ".js$",
"excludePattern": "(node_modules/|docs|test)"
},
"plugins": [
"./node_modules/jsdoc/plugins/markdown"
],
"templates": {
"cleverLinks": false,
"monospaceLinks": true,
"useLongnameInNav": false
},
"opts": {
"destination": "./out/",
"encoding": "utf8",
"private": false,
"recurse": true,
"template": "./node_modules/minami"
}
}
"tags": {
"allowUnknownTags": true,
"dictionaries": ["jsdoc"]
},
"source": {
"include": ["src", "package.json", "README.md"],
"includePattern": ".js$",
"excludePattern": "(node_modules/|docs|test)"
},
"plugins": ["./node_modules/jsdoc/plugins/markdown"],
"templates": {
"cleverLinks": false,
"monospaceLinks": true,
"useLongnameInNav": false
},
"opts": {
"destination": "./out/",
"encoding": "utf8",
"private": false,
"recurse": true,
"template": "./node_modules/minami"
}
}
18 changes: 9 additions & 9 deletions README.md
Expand Up @@ -36,7 +36,7 @@ var AuthenticationClient = require('auth0').AuthenticationClient;

var auth0 = new AuthenticationClient({
domain: '{YOUR_ACCOUNT}.auth0.com',
clientId: '{OPTIONAL_CLIENT_ID}'
clientId: '{OPTIONAL_CLIENT_ID}',
});
```

Expand All @@ -51,7 +51,7 @@ var ManagementClient = require('auth0').ManagementClient;

var management = new ManagementClient({
token: '{YOUR_API_V2_TOKEN}',
domain: '{YOUR_ACCOUNT}.auth0.com'
domain: '{YOUR_ACCOUNT}.auth0.com',
});
```

Expand All @@ -66,7 +66,7 @@ var auth0 = new ManagementClient({
domain: '{YOUR_ACCOUNT}.auth0.com',
clientId: '{YOUR_NON_INTERACTIVE_CLIENT_ID}',
clientSecret: '{YOUR_NON_INTERACTIVE_CLIENT_SECRET}',
scope: 'read:users update:users'
scope: 'read:users update:users',
});
```

Expand All @@ -80,15 +80,15 @@ var AuthenticationClient = require('auth0').AuthenticationClient;
var auth0 = new AuthenticationClient({
domain: '{YOUR_ACCOUNT}.auth0.com',
clientId: '{CLIENT_ID}',
clientSecret: '{CLIENT_SECRET}'
clientSecret: '{CLIENT_SECRET}',
});

auth0.clientCredentialsGrant(
{
audience: 'https://{YOUR_ACCOUNT}.auth0.com/api/v2/',
scope: '{MANAGEMENT_API_SCOPES}'
scope: '{MANAGEMENT_API_SCOPES}',
},
function(err, response) {
function (err, response) {
if (err) {
// Handle error.
}
Expand All @@ -105,7 +105,7 @@ Be aware that all methods can be used with promises or callbacks. However, when

```js
// Using callbacks.
management.getUsers(function(err, users) {
management.getUsers(function (err, users) {
if (err) {
// handle error.
}
Expand All @@ -115,10 +115,10 @@ management.getUsers(function(err, users) {
// Using promises.
management
.getUsers()
.then(function(users) {
.then(function (users) {
console.log(users);
})
.catch(function(err) {
.catch(function (err) {
// Handle error.
});
```
Expand Down
30 changes: 19 additions & 11 deletions package.json
Expand Up @@ -8,17 +8,21 @@
"src"
],
"scripts": {
"test": "mocha --reporter spec ./test/**/*.tests.js ./test/*.tests.js",
"test": "mocha --reporter spec './test/**/*.tests.js'",
"test:ci": "nyc npm run test -- --forbid-only --reporter mocha-junit-reporter",
"test:coverage": "codecov",
"test:watch": "cross-env NODE_ENV=test mocha --timeout 5000 ./test/**/*.tests.js ./test/*.tests.js --watch",
"test:watch": "cross-env NODE_ENV=test mocha --timeout 5000 './test/**/*.tests.js' './test/*.tests.js' --watch",
"jsdoc:generate": "jsdoc --configure .jsdoc.json --verbose",
"precommit": "pretty-quick --staged"
"precommit": "pretty-quick --staged",
"lint": "eslint ."
},
"repository": {
"type": "git",
"url": "https://github.com/auth0/node-auth0"
},
"engines": {
"node": ">=8.3.0"
},
"keywords": [
"auth0",
"api"
Expand All @@ -31,7 +35,6 @@
"homepage": "https://github.com/auth0/node-auth0",
"dependencies": {
"axios": "^0.21.4",
"es6-promisify": "^6.1.1",
"form-data": "^3.0.1",
"jsonwebtoken": "^8.5.1",
"jwks-rsa": "^1.12.1",
Expand All @@ -43,21 +46,26 @@
"chai": "^4.2.0",
"codecov": "^3.7.2",
"cross-env": "^5.2.0",
"eslint": "^8.1.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-jsdoc": "^37.0.3",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-prettier": "^4.0.0",
"eslint-plugin-promise": "^5.1.1",
"husky": "^3.0.1",
"jsdoc": "^3.6.3",
"jsdoc": "^3.6.7",
"json-loader": "^0.5.7",
"jws": "^3.2.2",
"minami": "^1.2.3",
"mocha": "^6.2.0",
"mocha-junit-reporter": "^1.23.1",
"moment": "^2.24.0",
"mocha": "^8.4.0",
"mocha-junit-reporter": "^2.0.0",
"nock": "^10.0.6",
"nyc": "^14.1.1",
"pem": "^1.14.2",
"prettier": "^1.18.2",
"prettier": "2.4.1",
"pretty-quick": "^1.11.1",
"proxyquire": "^2.1.1",
"sinon": "^9.0.3",
"proxyquire": "^2.1.3",
"sinon": "^11.1.2",
"string-replace-webpack-plugin": "0.1.3",
"webpack": "^4.36.1"
}
Expand Down
4 changes: 2 additions & 2 deletions scripts/jsdocs.js
@@ -1,11 +1,11 @@
const fs = require('fs');
const execSync = require('child_process').execSync;
const { execSync } = require('child_process');
const library = require('../package.json');

execSync('npm run jsdoc:generate', { stdio: 'inherit' });
if (fs.existsSync('docs')) {
execSync('rm -r docs', { stdio: 'inherit' });
}
execSync(`mv out/auth0/${library.version}/ docs`, {
stdio: 'inherit'
stdio: 'inherit',
});