eitri-cli 1.2.0-beta.1 → 1.2.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.vscode/settings.json +3 -1
- package/README.md +1 -1
- package/bitbucket-pipelines.yml +12 -0
- package/config/dev.js +2 -2
- package/config/k8s-eitri.js +1 -1
- package/config/loc-eitri.js +1 -1
- package/config/prod-eitri.js +13 -11
- package/developer-folder/README.md +1 -0
- package/index.js +4 -4
- package/install-dev.sh +1 -1
- package/package.json +2 -1
- package/src/cmd/create.js +12 -12
- package/src/cmd/credentials.js +1 -1
- package/src/cmd/login.js +2 -2
- package/src/cmd/manage-env.js +4 -4
- package/src/cmd/tail-logs.js +3 -3
- package/src/modules/vegvisir/VegvisirService.js +2 -2
- package/src/modules/vegvisir/cmd/list.js +2 -1
- package/src/service/AuthConfig.js +9 -12
- package/src/service/BlindGuardian.js +16 -19
- package/src/service/ConfigService.js +0 -7
- package/src/service/CredentialsService.js +2 -2
- package/src/service/EitriAppManager.js +2 -2
- package/src/service/Http.js +3 -3
- package/src/service/InviteService.js +2 -2
- package/src/service/Server.js +7 -7
- package/src/service/TargetService.js +2 -2
- package/src/service/TrackingEitriAnalytics.js +2 -2
- package/src/service/Workspace.js +9 -5
- package/src/service/WorkspaceManager.js +4 -4
- package/src/service/factories/DoubtsStarterFactory.js +2 -2
- package/src/util/UserLocalCredential.js +6 -4
- package/test/Executor.js +46 -0
- package/test/Helper.js +13 -0
- package/test/cmd/clean.test.js +3 -3
- package/test/cmd/create.test.js +7 -7
- package/test/e2e/cli.test.js +68 -0
- package/test/service/Workspace.test.js +17 -17
- package/test/cmd/credentials.test.js +0 -159
- package/test/cmd/signup.test.js +0 -20
- package/test/cmd/start.test.js +0 -5
package/.vscode/settings.json
CHANGED
package/README.md
CHANGED
package/bitbucket-pipelines.yml
CHANGED
|
@@ -1,7 +1,19 @@
|
|
|
1
1
|
image: node:18
|
|
2
2
|
pipelines:
|
|
3
|
+
default:
|
|
4
|
+
- step: &runTests
|
|
5
|
+
name: Run tests
|
|
6
|
+
caches:
|
|
7
|
+
- node
|
|
8
|
+
script:
|
|
9
|
+
- yarn
|
|
10
|
+
- npm i -g .
|
|
11
|
+
- yarn test cli.test.js --force-exit
|
|
3
12
|
branches:
|
|
13
|
+
"**":
|
|
14
|
+
- step: *runTests
|
|
4
15
|
'{beta,master}':
|
|
16
|
+
- step: *runTests
|
|
5
17
|
- step:
|
|
6
18
|
name: "Generation of a new version: beta or stable."
|
|
7
19
|
caches:
|
package/config/dev.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* eslint-disable no-undef */
|
|
2
|
-
const HOST = "
|
|
2
|
+
const HOST = "api.eitri.tech";
|
|
3
3
|
const packageJson = require("../package.json");
|
|
4
4
|
const path = require("path");
|
|
5
5
|
|
|
@@ -43,7 +43,7 @@ const config = {
|
|
|
43
43
|
colossus: {
|
|
44
44
|
// url: 'https://colossus.lab.calindra.com.br/colossus-api/v1',
|
|
45
45
|
// url: 'https://a32bcb528a6a.ngrok.io/colossus-api/v1',
|
|
46
|
-
url: `https://${HOST}/
|
|
46
|
+
url: `https://${HOST}/foundry/server`,
|
|
47
47
|
|
|
48
48
|
// pasta do Eitri-App dentro de src
|
|
49
49
|
watchUserDir: "/server",
|
package/config/k8s-eitri.js
CHANGED
|
@@ -40,7 +40,7 @@ const config = {
|
|
|
40
40
|
colossus: {
|
|
41
41
|
// url: 'https://colossus.lab.calindra.com.br/colossus-api/v1',
|
|
42
42
|
// url: 'https://a32bcb528a6a.ngrok.io/colossus-api/v1',
|
|
43
|
-
url: `https://${HOST}/
|
|
43
|
+
url: `https://${HOST}/foundry/server`,
|
|
44
44
|
|
|
45
45
|
// pasta do miniapp dentro de src
|
|
46
46
|
watchUserDir: '/server'
|
package/config/loc-eitri.js
CHANGED
|
@@ -45,7 +45,7 @@ const config = {
|
|
|
45
45
|
colossus: {
|
|
46
46
|
// url: 'https://colossus.lab.calindra.com.br/colossus-api/v1',
|
|
47
47
|
// url: 'https://a32bcb528a6a.ngrok.io/colossus-api/v1',
|
|
48
|
-
url: `http://${HOST}:3000/
|
|
48
|
+
url: `http://${HOST}:3000/foundry/server`,
|
|
49
49
|
|
|
50
50
|
// pasta do miniapp dentro de src
|
|
51
51
|
watchUserDir: "/server",
|
package/config/prod-eitri.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
/* eslint-disable no-undef */
|
|
2
2
|
const HOST = "prod.eitri.calindra.com.br";
|
|
3
|
+
const EITRI_TECH_HOST = "eitri.tech";
|
|
4
|
+
const API_EITRI_TECH_URL = `api.${EITRI_TECH_HOST}`
|
|
3
5
|
const packageJson = require("../package.json");
|
|
4
6
|
const path = require("path");
|
|
5
7
|
const FOUNDRY_CONTEXT_PATH = process.env.FOUNDRY_CONTEXT_PATH ?? 'foundry'
|
|
@@ -15,16 +17,16 @@ const config = {
|
|
|
15
17
|
.replace(".js", ".")}conf.js`,
|
|
16
18
|
},
|
|
17
19
|
doc: {
|
|
18
|
-
createUrl: `https://
|
|
20
|
+
createUrl: `https://console.${EITRI_TECH_HOST}/docs`,
|
|
19
21
|
},
|
|
20
22
|
blindGuardian: {
|
|
21
|
-
url: `https://${
|
|
23
|
+
url: `https://${API_EITRI_TECH_URL}/blind-guardian-api`,
|
|
22
24
|
},
|
|
23
25
|
shareApi: {
|
|
24
|
-
url: `https://${
|
|
26
|
+
url: `https://${API_EITRI_TECH_URL}/share-api/share`,
|
|
25
27
|
},
|
|
26
28
|
workspace: {
|
|
27
|
-
url: `https://${
|
|
29
|
+
url: `https://${API_EITRI_TECH_URL}`,
|
|
28
30
|
basePath: FOUNDRY_CONTEXT_PATH,
|
|
29
31
|
targetPath: "/foundry/targets",
|
|
30
32
|
target: {
|
|
@@ -42,7 +44,7 @@ const config = {
|
|
|
42
44
|
v2Header: "application/vnd.workspace.api.v2+json",
|
|
43
45
|
},
|
|
44
46
|
colossus: {
|
|
45
|
-
url: `https://${HOST}/
|
|
47
|
+
url: `https://${HOST}/foundry/server`,
|
|
46
48
|
|
|
47
49
|
// pasta do miniapp dentro de src
|
|
48
50
|
watchUserDir: "/server",
|
|
@@ -57,14 +59,14 @@ const config = {
|
|
|
57
59
|
},
|
|
58
60
|
},
|
|
59
61
|
qrCode: {
|
|
60
|
-
url:
|
|
62
|
+
url: `https://${HOST}/workspace/share`,
|
|
61
63
|
},
|
|
62
64
|
miniLog: {
|
|
63
65
|
url: `https://${HOST}/mini-log/rooms`,
|
|
64
66
|
path: "/mini-log/socket.io",
|
|
65
67
|
},
|
|
66
68
|
managerApi: {
|
|
67
|
-
url: `https://${
|
|
69
|
+
url: `https://${API_EITRI_TECH_URL}/miniapp-manager-api`,
|
|
68
70
|
invites: {
|
|
69
71
|
send: "/p/invites",
|
|
70
72
|
slug: "/p/invites/s/:slug",
|
|
@@ -77,7 +79,7 @@ const config = {
|
|
|
77
79
|
},
|
|
78
80
|
},
|
|
79
81
|
eitriManager: {
|
|
80
|
-
url: `https://${
|
|
82
|
+
url: `https://${API_EITRI_TECH_URL}/eitri-manager-api`,
|
|
81
83
|
},
|
|
82
84
|
workspaceManager: {
|
|
83
85
|
url: `https://${HOST}`,
|
|
@@ -85,15 +87,15 @@ const config = {
|
|
|
85
87
|
contextPath: "/workspace-manager",
|
|
86
88
|
},
|
|
87
89
|
eitriAnalytics: {
|
|
88
|
-
url:
|
|
90
|
+
url: `https://${API_EITRI_TECH_URL}/analytics/event`,
|
|
89
91
|
},
|
|
90
92
|
managerFront: {
|
|
91
|
-
url: `https://
|
|
93
|
+
url: `https://console.${EITRI_TECH_HOST}`,
|
|
92
94
|
managerCredential: "/settings/manager-credential",
|
|
93
95
|
cliGenerateLoginCredential: "/settings/cli-generate-credential",
|
|
94
96
|
},
|
|
95
97
|
vegvisir: {
|
|
96
|
-
url: `https://${
|
|
98
|
+
url: `https://${API_EITRI_TECH_URL}`,
|
|
97
99
|
basePath: "/eitri-vegvisir-api",
|
|
98
100
|
workspace: "/workspace",
|
|
99
101
|
my: "/workspace/my",
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Pasta para fazer o teste e2e
|
package/index.js
CHANGED
|
@@ -5,14 +5,14 @@ const program = new commander.Command();
|
|
|
5
5
|
const emoji = require("emojilib");
|
|
6
6
|
const path = require("path");
|
|
7
7
|
const { workspace } = require("./src/service/Workspace");
|
|
8
|
-
const
|
|
8
|
+
const configService = require("./src/service/ConfigService");
|
|
9
9
|
const VegvisirCommand = require("./src/modules/vegvisir/VegvisirCommand");
|
|
10
10
|
|
|
11
11
|
const run = async () => {
|
|
12
12
|
try {
|
|
13
13
|
const srcFolder2watch = path.join(process.cwd(), "src");
|
|
14
14
|
workspace.setFolder2Watch(srcFolder2watch);
|
|
15
|
-
workspace.setServerUrl(`${
|
|
15
|
+
workspace.setServerUrl(`${configService.get("workspace").url}`);
|
|
16
16
|
} catch (e) {
|
|
17
17
|
if (process.env.LOG_LEVEL === "full") {
|
|
18
18
|
console.log("Current directory listening has failed", e);
|
|
@@ -39,9 +39,9 @@ const run = async () => {
|
|
|
39
39
|
.description(`Cria um projeto com um Eitri-App totalmente funcional.`)
|
|
40
40
|
.option(
|
|
41
41
|
"--yes",
|
|
42
|
-
"Aceita os valores default para nome
|
|
42
|
+
"Aceita os valores default para nome título e organização"
|
|
43
43
|
)
|
|
44
|
-
.option("--application", "Define o application de execução do Eitri-App")
|
|
44
|
+
.option("--application <application>", "Define o application de execução do Eitri-App")
|
|
45
45
|
.option("-v, --verbose", "Exibe mais logs")
|
|
46
46
|
.action((projectName, cmdObj) => {
|
|
47
47
|
require("./src/cmd/create")(projectName, cmdObj);
|
package/install-dev.sh
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
npm uninstall eitri -g && npm i -g
|
|
1
|
+
npm uninstall eitri-cli -g && npm i -g .
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eitri-cli",
|
|
3
|
-
"version": "1.2.0-beta.
|
|
3
|
+
"version": "1.2.0-beta.2",
|
|
4
4
|
"description": "Command Line Interface to make \"Eitri-App\" with code and fire.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"bin": {
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
},
|
|
9
9
|
"scripts": {
|
|
10
10
|
"test-eitri": "NODE_APP_INSTANCE=eitri jest --detectOpenHandles",
|
|
11
|
+
"test": "NODE_APP_INSTANCE=eitri jest --detectOpenHandles",
|
|
11
12
|
"linter": "./node_modules/.bin/eslint --fix ./src/**/*.js",
|
|
12
13
|
"docsify:run": "cd docsify && docsify serve",
|
|
13
14
|
"build": "echo \"no build\"",
|
package/src/cmd/create.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const Watcher = require("../service/Watcher");
|
|
2
2
|
const inquirer = require("inquirer");
|
|
3
3
|
const slugify = require("slugify");
|
|
4
|
-
const
|
|
4
|
+
const configService = require("../service/ConfigService");
|
|
5
5
|
const { Workspace } = require("../service/Workspace");
|
|
6
6
|
const BlindGuardian = require("../service/BlindGuardian");
|
|
7
7
|
const HashFolder = require("../service/HashFolder");
|
|
@@ -28,14 +28,6 @@ const watcher = new Watcher(workspace, hashFolder, trackingService);
|
|
|
28
28
|
const ITEM_DOUBT = "DOUBTS";
|
|
29
29
|
const eitriAppManager = new EitriAppManager(blindGuardian);
|
|
30
30
|
|
|
31
|
-
const notBlank = (inpt) => {
|
|
32
|
-
if (!inpt || !inpt.trim()) {
|
|
33
|
-
return "Não pode ficar em branco";
|
|
34
|
-
} else {
|
|
35
|
-
return true;
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
|
|
39
31
|
const nameOrTitle = (inpt) => {
|
|
40
32
|
if (!NAME_TITLE_REGEX.test(inpt)) {
|
|
41
33
|
return "Não use caracteres especiais";
|
|
@@ -66,9 +58,9 @@ module.exports = async function create(projectName, cmdObj) {
|
|
|
66
58
|
);
|
|
67
59
|
|
|
68
60
|
try {
|
|
69
|
-
const url =
|
|
61
|
+
const url = configService.get("workspace").url;
|
|
70
62
|
workspace.setServerUrl(url);
|
|
71
|
-
const clientApplication = await askClientApplication();
|
|
63
|
+
const clientApplication = await askClientApplication(cmdObj.application);
|
|
72
64
|
if (clientApplication.name === ITEM_DOUBT) {
|
|
73
65
|
handleStartServer(
|
|
74
66
|
cmdObj,
|
|
@@ -97,7 +89,7 @@ module.exports = async function create(projectName, cmdObj) {
|
|
|
97
89
|
}
|
|
98
90
|
};
|
|
99
91
|
|
|
100
|
-
async function askClientApplication() {
|
|
92
|
+
async function askClientApplication(applicationName) {
|
|
101
93
|
const availableApplications = await eitriAppManager.findAllApplications();
|
|
102
94
|
if (availableApplications.length <= 0) {
|
|
103
95
|
console.log(
|
|
@@ -105,6 +97,14 @@ async function askClientApplication() {
|
|
|
105
97
|
);
|
|
106
98
|
process.exit(0);
|
|
107
99
|
}
|
|
100
|
+
if (applicationName) {
|
|
101
|
+
const clientApplication = availableApplications.find(application => application.name === applicationName)
|
|
102
|
+
if (clientApplication) {
|
|
103
|
+
return clientApplication
|
|
104
|
+
} else {
|
|
105
|
+
throw new Error(`Application not found by name ${applicationName}`)
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
108
|
const cliOptions = [
|
|
109
109
|
...availableApplications,
|
|
110
110
|
{ name: ITEM_DOUBT, label: "Dúvidas? Veja documentação no browser" },
|
package/src/cmd/credentials.js
CHANGED
|
@@ -11,7 +11,7 @@ const workspace = new Workspace(blindGuardian, new HashFolder())
|
|
|
11
11
|
const credentialService = new CredentialsService(workspace)
|
|
12
12
|
const trackingService = new TrackingService(blindGuardian, { ignoreCredentialError: true })
|
|
13
13
|
|
|
14
|
-
const config = require('
|
|
14
|
+
const config = require('../service/ConfigService')
|
|
15
15
|
|
|
16
16
|
const credentialStrategies = {
|
|
17
17
|
[credentialService.upsert.name]: credentialService.upsert,
|
package/src/cmd/login.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const inquirer = require('inquirer')
|
|
2
|
-
const
|
|
2
|
+
const configService = require('../service/ConfigService')
|
|
3
3
|
const open = require('open')
|
|
4
4
|
const TrackingEitriAnalytics = require('../service/TrackingEitriAnalytics')
|
|
5
5
|
const Server = require('../service/Server')
|
|
@@ -18,7 +18,7 @@ module.exports = async function login(args) {
|
|
|
18
18
|
|
|
19
19
|
const res = Server.startCliLogin()
|
|
20
20
|
|
|
21
|
-
const urlAdminManagerCredential = `${
|
|
21
|
+
const urlAdminManagerCredential = `${configService.get("managerFront").url}`
|
|
22
22
|
const urlAdminManagerCredentialWithParams = `${urlAdminManagerCredential}?loginType=EITRI_CLI&port=${res?.port}`
|
|
23
23
|
|
|
24
24
|
let portalOpenMessage = ""
|
package/src/cmd/manage-env.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const path = require('path')
|
|
2
|
-
const
|
|
2
|
+
const configService = require('../service/ConfigService')
|
|
3
3
|
|
|
4
4
|
const { workspace } = require('../service/Workspace')
|
|
5
5
|
const MiniLog = require('../service/MiniLog')
|
|
@@ -15,7 +15,7 @@ const ManageEnvService = require('../service/ManageEnvService')
|
|
|
15
15
|
const manageEnvService = new ManageEnvService()
|
|
16
16
|
|
|
17
17
|
const blindGuardian = workspace.blindGuardian
|
|
18
|
-
const CONFIG_WORKSPACE =
|
|
18
|
+
const CONFIG_WORKSPACE = configService.get('workspace')
|
|
19
19
|
|
|
20
20
|
module.exports = async function manageEnv(envList, cmd) {
|
|
21
21
|
try {
|
|
@@ -31,7 +31,7 @@ module.exports = async function manageEnv(envList, cmd) {
|
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
const getEnv = async (cmd) => {
|
|
34
|
-
const miniLog = new MiniLog(
|
|
34
|
+
const miniLog = new MiniLog(configService.get('miniLog'))
|
|
35
35
|
const folder2watch = path.join(process.cwd(), 'src')
|
|
36
36
|
|
|
37
37
|
workspace.setFolder2Watch(folder2watch)
|
|
@@ -72,7 +72,7 @@ const setEnv = async (envList, cmd) => {
|
|
|
72
72
|
try {
|
|
73
73
|
panicCheckEnvList(envList)
|
|
74
74
|
const environmentVariables = environmentVariable(envList)
|
|
75
|
-
const miniLog = new MiniLog(
|
|
75
|
+
const miniLog = new MiniLog(configService.get('miniLog'))
|
|
76
76
|
const folder2watch = path.join(process.cwd(), 'src')
|
|
77
77
|
|
|
78
78
|
workspace.setFolder2Watch(folder2watch)
|
package/src/cmd/tail-logs.js
CHANGED
|
@@ -9,14 +9,14 @@ const hashFolder = new HashFolder()
|
|
|
9
9
|
const workspace = new Workspace(blindGuardian, hashFolder)
|
|
10
10
|
|
|
11
11
|
module.exports = async function tailLogs(clientEmail) {
|
|
12
|
-
const
|
|
13
|
-
const miniLog = new MiniLog(
|
|
12
|
+
const configService = require('../service/ConfigService')
|
|
13
|
+
const miniLog = new MiniLog(configService.get('miniLog'))
|
|
14
14
|
version()
|
|
15
15
|
const folder2watch = path.join(process.cwd(), 'src')
|
|
16
16
|
workspace.setFolder2Watch(folder2watch)
|
|
17
17
|
blindGuardian.readConf()
|
|
18
18
|
|
|
19
|
-
const url =
|
|
19
|
+
const url = configService.get('workspace').url
|
|
20
20
|
workspace.setServerUrl(url)
|
|
21
21
|
await workspace.init()
|
|
22
22
|
await miniLog.connect(workspace.userEmail)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const { default: axios } = require("../../../node_modules/axios/index");
|
|
2
2
|
const BlindGuardian = require("../../service/BlindGuardian");
|
|
3
3
|
const Http = require("../../service/Http");
|
|
4
|
-
const
|
|
4
|
+
const configService = require("../../service/ConfigService");
|
|
5
5
|
const getWorkspace = require("../../util/getWorkspace");
|
|
6
6
|
const writeGlobalWorkspaceConfig = require("./utils/writeGlobalWorkspaceConfig");
|
|
7
7
|
|
|
@@ -9,7 +9,7 @@ module.exports = class VegvisirService {
|
|
|
9
9
|
constructor() {
|
|
10
10
|
const blindGuardian = new BlindGuardian();
|
|
11
11
|
this.http = new Http(blindGuardian);
|
|
12
|
-
this.config =
|
|
12
|
+
this.config = configService.get("vegvisir");
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
async listMyWorkspaces() {
|
|
@@ -8,6 +8,7 @@ module.exports = async function list(cmdObj) {
|
|
|
8
8
|
console.log("\tWorkspaces Disponíveis");
|
|
9
9
|
console.log("=======================================\n");
|
|
10
10
|
for (const workspace of workspaces) {
|
|
11
|
-
console.log(
|
|
11
|
+
console.log(`Workspace: ${workspace.name}`);
|
|
12
|
+
console.log(` Id: ${workspace.id}`);
|
|
12
13
|
}
|
|
13
14
|
};
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
const fs = require('fs')
|
|
2
|
-
const os = require('os')
|
|
3
|
-
const path = require('path')
|
|
4
1
|
const axios = require('axios')
|
|
5
|
-
const
|
|
2
|
+
const configService = require('../service/ConfigService')
|
|
6
3
|
const { exit } = require('process')
|
|
7
4
|
|
|
8
5
|
const DEFAULT_ENV = 'hml'
|
|
@@ -10,7 +7,7 @@ const DEFAULT_ENV = 'hml'
|
|
|
10
7
|
class AuthConfig { // abastract
|
|
11
8
|
|
|
12
9
|
constructor() {
|
|
13
|
-
this.blindGuardianUrl =
|
|
10
|
+
this.blindGuardianUrl = configService.get('blindGuardian').url
|
|
14
11
|
}
|
|
15
12
|
|
|
16
13
|
getConfPath() {}
|
|
@@ -18,12 +15,12 @@ class AuthConfig { // abastract
|
|
|
18
15
|
readConf() {}
|
|
19
16
|
|
|
20
17
|
readClientCredentials() {
|
|
21
|
-
const
|
|
18
|
+
const credentialConfig = this.readConf()
|
|
22
19
|
let data
|
|
23
|
-
if (this._isOldProfileVersion(
|
|
20
|
+
if (this._isOldProfileVersion(credentialConfig)) {
|
|
24
21
|
data = {
|
|
25
|
-
client_id:
|
|
26
|
-
client_secret:
|
|
22
|
+
client_id: credentialConfig.devUser,
|
|
23
|
+
client_secret: credentialConfig.devKey,
|
|
27
24
|
grant_type: 'client_credentials'
|
|
28
25
|
}
|
|
29
26
|
}
|
|
@@ -31,8 +28,8 @@ class AuthConfig { // abastract
|
|
|
31
28
|
const env = process.env.NODE_ENV || DEFAULT_ENV
|
|
32
29
|
try {
|
|
33
30
|
data = {
|
|
34
|
-
client_id:
|
|
35
|
-
client_secret:
|
|
31
|
+
client_id: credentialConfig[env].devUser,
|
|
32
|
+
client_secret: credentialConfig[env].devKey,
|
|
36
33
|
grant_type: 'client_credentials'
|
|
37
34
|
}
|
|
38
35
|
}
|
|
@@ -61,7 +58,7 @@ class AuthConfig { // abastract
|
|
|
61
58
|
const url = `${this.blindGuardianUrl}/v1/o/auth`
|
|
62
59
|
const options = {
|
|
63
60
|
headers : {
|
|
64
|
-
'User-Agent':
|
|
61
|
+
'User-Agent': configService.get('userAgent')
|
|
65
62
|
}
|
|
66
63
|
}
|
|
67
64
|
const auth = await axios.post(url, clientCredentials, options)
|
|
@@ -1,17 +1,15 @@
|
|
|
1
|
-
const fs = require('fs')
|
|
2
1
|
const os = require('os')
|
|
3
2
|
const path = require('path')
|
|
4
3
|
const axios = require('axios')
|
|
5
|
-
const
|
|
4
|
+
const configService = require('../service/ConfigService')
|
|
6
5
|
const { exit } = require('process')
|
|
7
|
-
const AmeCredential = require('../util/UserLocalCredential')
|
|
8
6
|
const UserLocalCredential = require('../util/UserLocalCredential')
|
|
9
7
|
|
|
10
8
|
const DEFAULT_ENV = 'hml'
|
|
11
9
|
|
|
12
10
|
class BlindGuardian {
|
|
13
11
|
constructor() {
|
|
14
|
-
this.blindGuardianUrl =
|
|
12
|
+
this.blindGuardianUrl = configService.get('blindGuardian').url
|
|
15
13
|
}
|
|
16
14
|
|
|
17
15
|
/**
|
|
@@ -20,41 +18,40 @@ class BlindGuardian {
|
|
|
20
18
|
getConfPath() {
|
|
21
19
|
let configPath = path.resolve(
|
|
22
20
|
os.homedir(),
|
|
23
|
-
|
|
21
|
+
configService.get('signup').get('configFilePath')
|
|
24
22
|
)
|
|
25
23
|
|
|
26
24
|
return configPath
|
|
27
25
|
}
|
|
28
26
|
|
|
29
27
|
readConf() {
|
|
30
|
-
const ameCredencial = new AmeCredential()
|
|
31
28
|
if (
|
|
32
|
-
process.env.
|
|
33
|
-
process.env.
|
|
29
|
+
process.env.EITRI_CLI_CLIENT_ID &&
|
|
30
|
+
process.env.EITRI_CLI_CLIENT_SECRET
|
|
34
31
|
) {
|
|
35
32
|
return {
|
|
36
|
-
devUser: process.env.
|
|
37
|
-
devKey: process.env.
|
|
33
|
+
devUser: process.env.EITRI_CLI_CLIENT_ID,
|
|
34
|
+
devKey: process.env.EITRI_CLI_CLIENT_SECRET,
|
|
38
35
|
}
|
|
39
36
|
}
|
|
40
37
|
return new UserLocalCredential()._getNewConfigPath()
|
|
41
38
|
}
|
|
42
39
|
|
|
43
40
|
readClientCredentials() {
|
|
44
|
-
const
|
|
41
|
+
const credentialConfig = this.readConf()
|
|
45
42
|
let data
|
|
46
|
-
if (this._isOldProfileVersion(
|
|
43
|
+
if (this._isOldProfileVersion(credentialConfig)) {
|
|
47
44
|
data = {
|
|
48
|
-
client_id:
|
|
49
|
-
client_secret:
|
|
45
|
+
client_id: credentialConfig.devUser,
|
|
46
|
+
client_secret: credentialConfig.devKey,
|
|
50
47
|
grant_type: 'client_credentials',
|
|
51
48
|
}
|
|
52
49
|
} else {
|
|
53
50
|
const env = process.env.NODE_ENV || DEFAULT_ENV
|
|
54
51
|
try {
|
|
55
52
|
data = {
|
|
56
|
-
client_id:
|
|
57
|
-
client_secret:
|
|
53
|
+
client_id: credentialConfig[env].devUser,
|
|
54
|
+
client_secret: credentialConfig[env].devKey,
|
|
58
55
|
grant_type: 'client_credentials',
|
|
59
56
|
}
|
|
60
57
|
} catch (e) {
|
|
@@ -80,7 +77,7 @@ class BlindGuardian {
|
|
|
80
77
|
const url = `${this.blindGuardianUrl}/v1/o/auth`
|
|
81
78
|
const options = {
|
|
82
79
|
headers: {
|
|
83
|
-
'User-Agent':
|
|
80
|
+
'User-Agent': configService.get('userAgent'),
|
|
84
81
|
},
|
|
85
82
|
}
|
|
86
83
|
const auth = await axios.post(url, clientCredentials, options)
|
|
@@ -94,7 +91,7 @@ class BlindGuardian {
|
|
|
94
91
|
if (e.response && e.response.status === 403) {
|
|
95
92
|
throw new Error('Credencial inválida')
|
|
96
93
|
}
|
|
97
|
-
throw new Error('Por favor tente novamente mais tarde.')
|
|
94
|
+
throw new Error('AuthError: Por favor tente novamente mais tarde.')
|
|
98
95
|
}
|
|
99
96
|
}
|
|
100
97
|
}
|
|
@@ -105,7 +102,7 @@ class BlindGuardian {
|
|
|
105
102
|
const url = `${this.blindGuardianUrl}/v1/o/users`
|
|
106
103
|
const options = {
|
|
107
104
|
headers: {
|
|
108
|
-
'User-Agent':
|
|
105
|
+
'User-Agent': configService.get('userAgent'),
|
|
109
106
|
},
|
|
110
107
|
}
|
|
111
108
|
const auth = await axios.post(url, userVo, options)
|
|
@@ -1,15 +1,8 @@
|
|
|
1
1
|
const config = require('config')
|
|
2
|
-
const {workspace} = require('../service/Workspace')
|
|
3
2
|
|
|
4
3
|
class ConfigService {
|
|
5
4
|
constructor() {
|
|
6
5
|
this.configuration = config
|
|
7
|
-
if(workspace.isRollout()) {
|
|
8
|
-
this.configuration = require(`../../config/${process.env.NODE_ENV}`)
|
|
9
|
-
this.configuration.get = (key) => {
|
|
10
|
-
return this.configuration[key]
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
6
|
}
|
|
14
7
|
}
|
|
15
8
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
const
|
|
1
|
+
const configService = require('./ConfigService')
|
|
2
2
|
|
|
3
3
|
class CredentialsService {
|
|
4
4
|
|
|
5
5
|
constructor(workspace) {
|
|
6
6
|
this.workspace = workspace
|
|
7
|
-
this.conf =
|
|
7
|
+
this.conf = configService.get('workspace')
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
async upsert(args) {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
const
|
|
1
|
+
const configService = require('./ConfigService')
|
|
2
2
|
const Http = require("./Http")
|
|
3
3
|
|
|
4
4
|
class EitriAppManager {
|
|
5
5
|
constructor(blindGuardian) {
|
|
6
6
|
this.http = new Http(blindGuardian)
|
|
7
|
-
this.config =
|
|
7
|
+
this.config = configService.get('eitriManager')
|
|
8
8
|
this.managerBaseURL = this.config.url
|
|
9
9
|
}
|
|
10
10
|
|
package/src/service/Http.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
const axiosCookieJarSupport = require('axios-cookiejar-support').default
|
|
2
2
|
const FileCookieStore = require('tough-cookie-file-store').FileCookieStore
|
|
3
3
|
const CookieJar = require('tough-cookie').CookieJar
|
|
4
|
-
const { v4: uuidv4 } = require('uuid')
|
|
5
4
|
|
|
6
5
|
const os = require('os')
|
|
7
6
|
const path = require('path')
|
|
8
7
|
const getCliVersion = require('../util/getCliVersion')
|
|
9
8
|
const getWorkspace = require('../util/getWorkspace')
|
|
9
|
+
const { randomUUID } = require('crypto')
|
|
10
10
|
|
|
11
11
|
const filePath = path.join(os.homedir(), './.eitri.cookie.json')
|
|
12
12
|
const jar = new CookieJar(new FileCookieStore(filePath))
|
|
@@ -80,7 +80,7 @@ class Http {
|
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
async _getHeader(url) {
|
|
83
|
-
const tid =
|
|
83
|
+
const tid = randomUUID()
|
|
84
84
|
const headers = {
|
|
85
85
|
Authorization: `Bearer ${this.token.accessToken}`,
|
|
86
86
|
'X-Transaction-Id': tid,
|
|
@@ -121,7 +121,7 @@ class Http {
|
|
|
121
121
|
|
|
122
122
|
_delete(url, options, headers) {
|
|
123
123
|
return new Promise((resolve, reject) => {
|
|
124
|
-
this.__delete(url, options, headers, resolve, reject)
|
|
124
|
+
this.__delete(url, options || {}, headers, resolve, reject)
|
|
125
125
|
})
|
|
126
126
|
}
|
|
127
127
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
const
|
|
1
|
+
const configService = require('./ConfigService')
|
|
2
2
|
|
|
3
3
|
class InviteService {
|
|
4
4
|
|
|
5
5
|
constructor(workspace) {
|
|
6
6
|
this.workspace = workspace
|
|
7
|
-
this.conf =
|
|
7
|
+
this.conf = configService.get('managerApi')
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
async findAllPending() {
|