From d386bffda939a6590e1e70c6c6b1fde054b246e2 Mon Sep 17 00:00:00 2001 From: Jonathan Rainville Date: Mon, 29 Apr 2019 13:03:50 -0400 Subject: [PATCH] refactor(@embark/authenticator): move authenticator to a package --- packages/embark-authenticator/.npmrc | 4 ++ packages/embark-authenticator/README.md | 6 ++ packages/embark-authenticator/package.json | 69 +++++++++++++++++++ .../src}/index.js | 4 +- packages/embark-authenticator/tsconfig.json | 4 ++ packages/embark-authenticator/tslint.json | 3 + packages/embark/src/lib/core/engine.js | 2 +- 7 files changed, 89 insertions(+), 3 deletions(-) create mode 100644 packages/embark-authenticator/.npmrc create mode 100644 packages/embark-authenticator/README.md create mode 100644 packages/embark-authenticator/package.json rename packages/{embark/src/lib/modules/authenticator => embark-authenticator/src}/index.js (97%) create mode 100644 packages/embark-authenticator/tsconfig.json create mode 100644 packages/embark-authenticator/tslint.json diff --git a/packages/embark-authenticator/.npmrc b/packages/embark-authenticator/.npmrc new file mode 100644 index 000000000..e031d3432 --- /dev/null +++ b/packages/embark-authenticator/.npmrc @@ -0,0 +1,4 @@ +engine-strict = true +package-lock = false +save-exact = true +scripts-prepend-node-path = true diff --git a/packages/embark-authenticator/README.md b/packages/embark-authenticator/README.md new file mode 100644 index 000000000..a6d3a2a42 --- /dev/null +++ b/packages/embark-authenticator/README.md @@ -0,0 +1,6 @@ +# `embark-authenticator` + +Authenticator module for Embark's Cockpit + +Visit [embark.status.im](https://embark.status.im/) to get started with +[Embark](https://github.com/embark-framework/embark). diff --git a/packages/embark-authenticator/package.json b/packages/embark-authenticator/package.json new file mode 100644 index 000000000..d54a731b1 --- /dev/null +++ b/packages/embark-authenticator/package.json @@ -0,0 +1,69 @@ +{ + "name": "embark-authenticator", + "version": "4.1.0-beta.0", + "author": "Iuri Matias ", + "contributors": [], + "description": "Authenticator module for Embark's Cockpit", + "homepage": "https://github.com/embark-framework/embark/tree/master/packages/embark-authenticator#readme", + "bugs": "https://github.com/embark-framework/embark/issues", + "keywords": [ + "blockchain", + "dapps", + "ethereum", + "ipfs", + "serverless", + "solc", + "solidity" + ], + "files": [ + "dist" + ], + "license": "MIT", + "repository": { + "directory": "packages/embark-authenticator", + "type": "git", + "url": "https://github.com/embark-framework/embark.git" + }, + "main": "./dist/index.js", + "scripts": { + "build": "cross-env BABEL_ENV=node babel src --extensions \".js,.ts\" --out-dir dist --root-mode upward --source-maps", + "ci": "npm run qa", + "clean": "npm run reset", + "lint": "npm-run-all lint:*", + "lint:js": "eslint src/", + "// lint:ts": "tslint -c tslint.json \"src/**/*.ts\"", + "package": "npm pack", + "// qa": "npm-run-all lint typecheck build package", + "qa": "npm-run-all lint build package", + "reset": "npx rimraf dist embark-*.tgz package", + "start": "npm run watch", + "// typecheck": "tsc", + "watch": "run-p watch:*", + "watch:build": "npm run build -- --verbose --watch", + "// watch:typecheck": "npm run typecheck -- --preserveWatchOutput --watch" + }, + "eslintConfig": { + "extends": "../../.eslintrc.json" + }, + "dependencies": { + "@babel/runtime-corejs2": "7.3.1", + "embark-utils": "^4.1.0-beta.0", + "keccakjs": "0.2.3", + "uuid": "3.3.2" + }, + "devDependencies": { + "@babel/cli": "7.2.3", + "@babel/core": "7.2.2", + "cross-env": "5.2.0", + "eslint": "5.7.0", + "npm-run-all": "4.1.5", + "rimraf": "2.6.3", + "tslint": "5.11.0", + "typescript": "3.3.1" + }, + "engines": { + "node": ">=8.12.0", + "npm": ">=6.4.1", + "yarn": ">=1.12.3" + } +} diff --git a/packages/embark/src/lib/modules/authenticator/index.js b/packages/embark-authenticator/src/index.js similarity index 97% rename from packages/embark/src/lib/modules/authenticator/index.js rename to packages/embark-authenticator/src/index.js index 7b5fe4665..47fdc92aa 100644 --- a/packages/embark/src/lib/modules/authenticator/index.js +++ b/packages/embark-authenticator/src/index.js @@ -1,5 +1,5 @@ const uuid = require('uuid/v4'); -const utils = require("../../utils/utils.js"); +const {copyToClipboard} = require("embark-utils"); const keccak = require('keccakjs'); const ERROR_OBJ = {error: __('Wrong authentication token. Get your token from the Embark console by typing `token`')}; @@ -80,7 +80,7 @@ class Authenticator { matches: ["token"], description: __("Copies and prints the token for the cockpit"), process: (cmd, callback) => { - utils.copyToClipboard(this.authToken); + copyToClipboard(this.authToken); callback(null, __('Token copied to clipboard: %s', this.authToken)); } }); diff --git a/packages/embark-authenticator/tsconfig.json b/packages/embark-authenticator/tsconfig.json new file mode 100644 index 000000000..52d43eaaa --- /dev/null +++ b/packages/embark-authenticator/tsconfig.json @@ -0,0 +1,4 @@ +{ + "extends": "../../tsconfig.json", + "include": ["src/**/*"] +} diff --git a/packages/embark-authenticator/tslint.json b/packages/embark-authenticator/tslint.json new file mode 100644 index 000000000..0946f2096 --- /dev/null +++ b/packages/embark-authenticator/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "../../tslint.json" +} diff --git a/packages/embark/src/lib/core/engine.js b/packages/embark/src/lib/core/engine.js index c6145d055..5a31f72ce 100644 --- a/packages/embark/src/lib/core/engine.js +++ b/packages/embark/src/lib/core/engine.js @@ -264,7 +264,7 @@ class Engine { } cockpitService() { - this.registerModule('authenticator', {singleUseAuthToken: this.singleUseAuthToken}); + this.registerModulePackage('embark-authenticator', {singleUseAuthToken: this.singleUseAuthToken}); this.registerModule('api', {plugins: this.plugins}); }