eitri-cli 1.7.0-beta.3 → 1.7.0-beta.5
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/config/dev.js +11 -0
- package/config/k8s-eitri.js +11 -0
- package/config/loc-eitri.js +11 -0
- package/config/prod-eitri.js +11 -0
- package/index.js +11 -0
- package/package.json +1 -1
- package/src/cmd/eitriLibs.js +38 -0
- package/src/cmd/start.js +2 -48
- package/src/model/Target.js +0 -15
- package/src/service/LibsService.js +154 -0
- package/src/service/StarterService.js +2 -2
- package/src/service/Workspace.js +8 -98
- package/src/service/factories/QRCodeStarterFactory.js +7 -16
- package/test/_fixtures/woodcoffee/miniapp.conf.js +2 -2
- package/test/e2e/cli.test.js +37 -0
- package/test/service/Workspace.test.js +0 -120
package/config/dev.js
CHANGED
|
@@ -100,6 +100,17 @@ const config = {
|
|
|
100
100
|
eitriManager: {
|
|
101
101
|
url: `https://${HOST}/eitri-manager-api`,
|
|
102
102
|
},
|
|
103
|
+
cdn: {
|
|
104
|
+
library: {
|
|
105
|
+
url: "https://cdn.83io.com.br/library",
|
|
106
|
+
bifrost: {
|
|
107
|
+
versions: "/eitri-bifrost/versions/index.json"
|
|
108
|
+
},
|
|
109
|
+
luminusUi: {
|
|
110
|
+
versions: "/luminus-ui/versions/index.json"
|
|
111
|
+
},
|
|
112
|
+
}
|
|
113
|
+
}
|
|
103
114
|
};
|
|
104
115
|
|
|
105
116
|
module.exports = config;
|
package/config/k8s-eitri.js
CHANGED
|
@@ -84,6 +84,17 @@ const config = {
|
|
|
84
84
|
},
|
|
85
85
|
managerFront: {
|
|
86
86
|
url: `https://admin.k8s.eitri.calindra.com.br`
|
|
87
|
+
},
|
|
88
|
+
cdn: {
|
|
89
|
+
library: {
|
|
90
|
+
url: "https://cdn.83io.com.br/library",
|
|
91
|
+
bifrost: {
|
|
92
|
+
versions: "/eitri-bifrost/versions/index.json"
|
|
93
|
+
},
|
|
94
|
+
luminusUi: {
|
|
95
|
+
versions: "/luminus-ui/versions/index.json"
|
|
96
|
+
},
|
|
97
|
+
}
|
|
87
98
|
}
|
|
88
99
|
}
|
|
89
100
|
|
package/config/loc-eitri.js
CHANGED
|
@@ -102,6 +102,17 @@ const config = {
|
|
|
102
102
|
my: "/workspace/my",
|
|
103
103
|
check: "/workspace/check",
|
|
104
104
|
},
|
|
105
|
+
cdn: {
|
|
106
|
+
library: {
|
|
107
|
+
url: "https://cdn.83io.com.br/library",
|
|
108
|
+
bifrost: {
|
|
109
|
+
versions: "/eitri-bifrost/versions/index.json"
|
|
110
|
+
},
|
|
111
|
+
luminusUi: {
|
|
112
|
+
versions: "/luminus-ui/versions/index.json"
|
|
113
|
+
},
|
|
114
|
+
}
|
|
115
|
+
}
|
|
105
116
|
};
|
|
106
117
|
|
|
107
118
|
module.exports = config;
|
package/config/prod-eitri.js
CHANGED
|
@@ -103,6 +103,17 @@ const config = {
|
|
|
103
103
|
my: "/workspace/my",
|
|
104
104
|
check: "/workspace/check",
|
|
105
105
|
},
|
|
106
|
+
cdn: {
|
|
107
|
+
library: {
|
|
108
|
+
url: "https://cdn.83io.com.br/library",
|
|
109
|
+
bifrost: {
|
|
110
|
+
versions: "/eitri-bifrost/versions/index.json"
|
|
111
|
+
},
|
|
112
|
+
luminusUi: {
|
|
113
|
+
versions: "/luminus-ui/versions/index.json"
|
|
114
|
+
},
|
|
115
|
+
}
|
|
116
|
+
}
|
|
106
117
|
};
|
|
107
118
|
|
|
108
119
|
module.exports = config;
|
package/index.js
CHANGED
|
@@ -114,6 +114,17 @@ const run = async () => {
|
|
|
114
114
|
);
|
|
115
115
|
});
|
|
116
116
|
|
|
117
|
+
program
|
|
118
|
+
.command("libs")
|
|
119
|
+
.description("Bibliotecas do Eitri")
|
|
120
|
+
.option(
|
|
121
|
+
"-l, --list",
|
|
122
|
+
"Lista as bibliotecas do Eitri com suas versões"
|
|
123
|
+
)
|
|
124
|
+
.action((cmdObj) => {
|
|
125
|
+
require("./src/cmd/eitriLibs")(cmdObj);
|
|
126
|
+
});
|
|
127
|
+
|
|
117
128
|
program.addCommand(VegvisirCommand());
|
|
118
129
|
|
|
119
130
|
if (
|
package/package.json
CHANGED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
const {workspace} = require('../service/Workspace')
|
|
2
|
+
const TrackingService = require('../service/TrackingService')
|
|
3
|
+
const TrackingEitriAnalytics = require('../service/TrackingEitriAnalytics')
|
|
4
|
+
const LibsService = require('../service/LibsService')
|
|
5
|
+
|
|
6
|
+
const blindGuardian = workspace.blindGuardian
|
|
7
|
+
const trackingService = new TrackingService(blindGuardian)
|
|
8
|
+
|
|
9
|
+
module.exports = async function eitriLibs(cmdObj) {
|
|
10
|
+
if(cmdObj.list){
|
|
11
|
+
await listLibs()
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
async function listLibs() {
|
|
16
|
+
try {
|
|
17
|
+
const libsVersions = await LibsService.simultaneousRequestAndHandleData()
|
|
18
|
+
console.log("libsVersions", libsVersions)
|
|
19
|
+
TrackingEitriAnalytics.sendEvent({
|
|
20
|
+
eventName: "eitriLibs.listLibs",
|
|
21
|
+
userId: workspace?.userEmail,
|
|
22
|
+
data: libsVersions
|
|
23
|
+
})
|
|
24
|
+
process.exit(0)
|
|
25
|
+
} catch (e) {
|
|
26
|
+
TrackingEitriAnalytics.sendEvent({
|
|
27
|
+
eventName: "clean.error",
|
|
28
|
+
userId: workspace?.userEmail,
|
|
29
|
+
data: {
|
|
30
|
+
errorMessage: e?.message || ""
|
|
31
|
+
}
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
await trackingService.sendError(e)
|
|
36
|
+
process.exit(1)
|
|
37
|
+
}
|
|
38
|
+
}
|
package/src/cmd/start.js
CHANGED
|
@@ -7,7 +7,6 @@ const TrackingService = require('../service/TrackingService')
|
|
|
7
7
|
const fs = require('fs')
|
|
8
8
|
const config = require('../service/ConfigService')
|
|
9
9
|
const handleStartServer = require('../service/StarterService')
|
|
10
|
-
const inquirer = require('inquirer')
|
|
11
10
|
const TrackingEitriAnalytics = require('../service/TrackingEitriAnalytics')
|
|
12
11
|
const VegvisirService = require('../modules/vegvisir/VegvisirService')
|
|
13
12
|
const UserLocalCredential = require('../util/UserLocalCredential')
|
|
@@ -59,20 +58,6 @@ module.exports = async function start(args) {
|
|
|
59
58
|
debug("Informações do setupResult do workspace", {setupResult})
|
|
60
59
|
|
|
61
60
|
const target = setupResult.target.name
|
|
62
|
-
|
|
63
|
-
let targetConfig = {}
|
|
64
|
-
|
|
65
|
-
if(args.listTargetConfigs) {
|
|
66
|
-
await listTargetConfigs(target)
|
|
67
|
-
process.exit(1)
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
debug("Verificando se há targetConfig nos argumentos", {targetConfig: args?.targetConfig})
|
|
71
|
-
if(args.targetConfig) {
|
|
72
|
-
targetConfig = await askTargetConfig(args, target)
|
|
73
|
-
} else {
|
|
74
|
-
targetConfig = await getDefaultTargetConfig(target)
|
|
75
|
-
}
|
|
76
61
|
|
|
77
62
|
blindGuardian.readConf()
|
|
78
63
|
const qrCodeUrl = config.get('qrCode').url
|
|
@@ -126,8 +111,8 @@ module.exports = async function start(args) {
|
|
|
126
111
|
...args,
|
|
127
112
|
deepLinks: loadedTarget?.deepLinks || []
|
|
128
113
|
}
|
|
129
|
-
debug("Iniciando servidor", {argsWithDeeplinks, trackingService, watcher, workspace, target,
|
|
130
|
-
await handleStartServer(argsWithDeeplinks, trackingService, watcher, workspace, target,
|
|
114
|
+
debug("Iniciando servidor", {argsWithDeeplinks, trackingService, watcher, workspace, target, setupResult, platform})
|
|
115
|
+
await handleStartServer(argsWithDeeplinks, trackingService, watcher, workspace, target, setupResult, platform)
|
|
131
116
|
debug("Servidor iniciado", {loadedTarget})
|
|
132
117
|
|
|
133
118
|
TrackingEitriAnalytics.sendEvent({
|
|
@@ -177,34 +162,3 @@ module.exports = async function start(args) {
|
|
|
177
162
|
}
|
|
178
163
|
}
|
|
179
164
|
}
|
|
180
|
-
|
|
181
|
-
async function askTargetConfig(args, target) {
|
|
182
|
-
const availableConfigs = await workspace.getTargetConfig(args.targetConfig, target)
|
|
183
|
-
|
|
184
|
-
console.log(`Utilizando configuração: ${availableConfigs[0].id}`)
|
|
185
|
-
return availableConfigs[0]
|
|
186
|
-
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
async function getDefaultTargetConfig(target) {
|
|
190
|
-
const configs = await workspace.getTargetConfig('default', target)
|
|
191
|
-
return configs[0]
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
async function listTargetConfigs(target) {
|
|
195
|
-
const availableConfigs = await workspace.getAllTargetConfigs(target)
|
|
196
|
-
|
|
197
|
-
const availableConfigsIds = availableConfigs.map(config => config.id)
|
|
198
|
-
|
|
199
|
-
const res = await inquirer.prompt([
|
|
200
|
-
{
|
|
201
|
-
name: 'accepted',
|
|
202
|
-
type: 'rawlist',
|
|
203
|
-
message: 'Configurações disponíveis:',
|
|
204
|
-
choices: availableConfigsIds
|
|
205
|
-
}
|
|
206
|
-
]).then(input => input)
|
|
207
|
-
|
|
208
|
-
const config = availableConfigs.find(cfg => cfg.id === res.accepted)
|
|
209
|
-
console.log(`Utilize o comando --target-config ${config.id} para iniciar o Eitri-App com a configuração desejada`)
|
|
210
|
-
}
|
package/src/model/Target.js
CHANGED
|
@@ -1,15 +1,4 @@
|
|
|
1
1
|
/* eslint-disable no-unused-vars */
|
|
2
|
-
class TargetConfig {
|
|
3
|
-
constructor() {
|
|
4
|
-
this.id = ''
|
|
5
|
-
this.libUrl = ''
|
|
6
|
-
this.runnerUrl = ''
|
|
7
|
-
this.bootstrapBaseUrl = ''
|
|
8
|
-
this.askUserDataApiUrl = ''
|
|
9
|
-
this.default = ''
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
|
|
13
2
|
class MiniAppBoilerplateList {
|
|
14
3
|
constructor() {
|
|
15
4
|
this.name = ''
|
|
@@ -57,10 +46,6 @@ module.exports = class Target {
|
|
|
57
46
|
*/
|
|
58
47
|
this.platform= ''
|
|
59
48
|
/**
|
|
60
|
-
* @type {TargetConfig[]}
|
|
61
|
-
*/
|
|
62
|
-
this.targetConfig= ''
|
|
63
|
-
/**
|
|
64
49
|
* @type {string}
|
|
65
50
|
*/
|
|
66
51
|
this.sdkSupport= ''
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
const axios = require('axios')
|
|
2
|
+
const configService = require('./ConfigService')
|
|
3
|
+
const CDN_83io_LIBRARY = configService.get('cdn')?.library
|
|
4
|
+
const TrackingEitriAnalytics = require('./TrackingEitriAnalytics')
|
|
5
|
+
|
|
6
|
+
class LibsService {
|
|
7
|
+
|
|
8
|
+
static async validateLibsVersions({libs = [], eitriAppConf = {}}) {
|
|
9
|
+
const {luminusUiVersion, bifrostVersion} = this.getEitriConfLibsVersions(libs)
|
|
10
|
+
if (!luminusUiVersion) {
|
|
11
|
+
throw new Error("Nenhuma versão do [luminus-ui/eitri-app-components] encontrada em seu eitri-app.conf");
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
if (!bifrostVersion) {
|
|
15
|
+
throw new Error("Nenhuma versão do [bifrost/eitri-app-client] encontrada em seu eitri-app.conf");
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const {luminusUiVersions, bifrostVersions} = await this.simultaneousRequestAndHandleData();
|
|
19
|
+
const allBifrostVersions = bifrostVersions?.versions?.concat(bifrostVersions?.betaVersions, bifrostVersions?.alphaVersions);
|
|
20
|
+
|
|
21
|
+
const existsLuminus = luminusUiVersions?.versions?.some(version => version === luminusUiVersion);
|
|
22
|
+
if (!existsLuminus) {
|
|
23
|
+
this.throwNonExistentLibError({
|
|
24
|
+
libName: "luminus-ui/eitri-app-components",
|
|
25
|
+
eitriConfLibVersion: luminusUiVersion,
|
|
26
|
+
availableVersions: luminusUiVersions,
|
|
27
|
+
eitriAppConf,
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const existsBifrost = allBifrostVersions.some(version => version === bifrostVersion);
|
|
32
|
+
if (!existsBifrost) {
|
|
33
|
+
this.throwNonExistentLibError({
|
|
34
|
+
libName: "bifrost/eitri-app-client",
|
|
35
|
+
eitriConfLibVersion: bifrostVersion,
|
|
36
|
+
availableVersions: allBifrostVersions,
|
|
37
|
+
eitriAppConf,
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
static getEitriConfLibsVersions(libs = []) {
|
|
44
|
+
const luminusUiNames = ["eitri-app-components", "eitri-luminus"];
|
|
45
|
+
const biFrostNames = ["eitri-app-client", "eitri-bifrost"];
|
|
46
|
+
const bifrostVersion = libs.find(lib => biFrostNames?.includes(lib.name))?.version;
|
|
47
|
+
const luminusUiVersion = libs.find(lib => luminusUiNames?.includes(lib.name))?.version;
|
|
48
|
+
|
|
49
|
+
return {
|
|
50
|
+
luminusUiVersion,
|
|
51
|
+
bifrostVersion
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
static async simultaneousRequestAndHandleData() {
|
|
56
|
+
const promises = await Promise.allSettled([
|
|
57
|
+
this.getBifrostVersions(), this.getLuminusUiVersions()
|
|
58
|
+
]).then(res => res).catch(err => err)
|
|
59
|
+
|
|
60
|
+
const [bifrost, luminus] = promises;
|
|
61
|
+
|
|
62
|
+
let allBifrostVersions = {};
|
|
63
|
+
if (bifrost?.status === "fulfilled") {
|
|
64
|
+
allBifrostVersions = bifrost.value
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
let allLuminusVersions = {};
|
|
68
|
+
if (luminus?.status === "fulfilled") {
|
|
69
|
+
allLuminusVersions = luminus.value
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return {
|
|
73
|
+
luminusUiVersions: allLuminusVersions,
|
|
74
|
+
bifrostVersions: allBifrostVersions
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
static handleRawDatas(promises = []) {
|
|
79
|
+
|
|
80
|
+
const [bifrost, luminus] = promises;
|
|
81
|
+
|
|
82
|
+
const allBifrostVersions = [];
|
|
83
|
+
if (bifrost?.status === "fulfilled") {
|
|
84
|
+
const versions = bifrost?.value?.versions?.concat(bifrost?.value?.betaVersions, bifrost?.value?.alphaVersions);
|
|
85
|
+
allBifrostVersions.push(...versions)
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const allLuminusVersions = [];
|
|
89
|
+
if (luminus?.status === "fulfilled") {
|
|
90
|
+
allLuminusVersions.push(...luminus.value.versions)
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
return {
|
|
94
|
+
luminusUiVersions: allLuminusVersions,
|
|
95
|
+
bifrostVersions: allBifrostVersions,
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
static async getBifrostVersions() {
|
|
101
|
+
const fullUrl = `${CDN_83io_LIBRARY.url}${CDN_83io_LIBRARY.bifrost.versions}`;
|
|
102
|
+
try {
|
|
103
|
+
const response = await axios.get(fullUrl)
|
|
104
|
+
return response.data
|
|
105
|
+
} catch (error) {
|
|
106
|
+
const errorMessage = error?.message || "Erro na obtenção de versões do Bifrost"
|
|
107
|
+
this.sendErrorToAnalytics("getBifrostVersions", errorMessage)
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
static async getLuminusUiVersions() {
|
|
112
|
+
const fullUrl = `${CDN_83io_LIBRARY.url}${CDN_83io_LIBRARY.luminusUi.versions}`;
|
|
113
|
+
try {
|
|
114
|
+
const response = await axios.get(fullUrl)
|
|
115
|
+
return response.data
|
|
116
|
+
} catch (error) {
|
|
117
|
+
const errorMessage = error?.message || "Erro na obtenção de versões do LuminusUI"
|
|
118
|
+
this.sendErrorToAnalytics("getLuminusUiVersions", errorMessage)
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
static sendErrorToAnalytics(method = "", errorMessage = "") {
|
|
123
|
+
TrackingEitriAnalytics.sendEvent({
|
|
124
|
+
eventName: `${method}.error`,
|
|
125
|
+
userId: "",
|
|
126
|
+
data: {errorMessage}
|
|
127
|
+
})
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
static throwNonExistentLibError(input = {libName: "", eitriConfLibVersion: "", availableVersions: [], eitriAppConf: {}}) {
|
|
131
|
+
const {libName, eitriConfLibVersion, availableVersions, eitriAppConf} = input
|
|
132
|
+
|
|
133
|
+
const friendlyErrorMessage = `Versão da biblioteca [${libName}] não encontrada`;
|
|
134
|
+
console.log(`\n\x1b[1m\x1b[31m${friendlyErrorMessage}\x1b[0m\n`);
|
|
135
|
+
console.log("Veja as versões disponíveis abaixo e atualize o arquivo eitri-app.conf\n");
|
|
136
|
+
console.log(availableVersions)
|
|
137
|
+
|
|
138
|
+
TrackingEitriAnalytics.sendEvent({
|
|
139
|
+
eventName: "version.eitri-libs.not.found",
|
|
140
|
+
userId: "",
|
|
141
|
+
data: {
|
|
142
|
+
errorMessage: `Versão da biblioteca ${libName} não encontrada`,
|
|
143
|
+
eitriConfLibVersion,
|
|
144
|
+
availableVersions,
|
|
145
|
+
eitriAppConf,
|
|
146
|
+
}
|
|
147
|
+
})
|
|
148
|
+
|
|
149
|
+
process.exit(1)
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
module.exports = LibsService
|
|
@@ -4,7 +4,7 @@ const WebStarterFactory = require('./factories/WebStarterFactory')
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
const strategy = require('./GATrackingStrategy')
|
|
7
|
-
async function handleStartServer(args, trackingService, watcher, workspace, factoryName,
|
|
7
|
+
async function handleStartServer(args, trackingService, watcher, workspace, factoryName, setupConfig, platform) {
|
|
8
8
|
const factories = {
|
|
9
9
|
mobile: new QRCodeStarterFactory(),
|
|
10
10
|
web: new WebStarterFactory(),
|
|
@@ -24,7 +24,7 @@ async function handleStartServer(args, trackingService, watcher, workspace, fact
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
|
|
27
|
-
const starter = await factory.create(args, trackingService, watcher, workspace,
|
|
27
|
+
const starter = await factory.create(args, trackingService, watcher, workspace, setupConfig)
|
|
28
28
|
await starter.startServer()
|
|
29
29
|
}
|
|
30
30
|
|
package/src/service/Workspace.js
CHANGED
|
@@ -29,6 +29,7 @@ const VegvisirService = require("../modules/vegvisir/VegvisirService");
|
|
|
29
29
|
const HuginService = require("./HuginService");
|
|
30
30
|
const EitriAppType = require("../model/EitriAppType");
|
|
31
31
|
const chalk = require("chalk");
|
|
32
|
+
const LibsService = require("./LibsService");
|
|
32
33
|
const vegvisirService = new VegvisirService()
|
|
33
34
|
const huginService = new HuginService()
|
|
34
35
|
|
|
@@ -93,49 +94,6 @@ class Workspace {
|
|
|
93
94
|
return this.resourceFolders2watch;
|
|
94
95
|
}
|
|
95
96
|
|
|
96
|
-
|
|
97
|
-
async getTargetConfig(id, target) {
|
|
98
|
-
try {
|
|
99
|
-
const configs = await this.getAllTargetConfigs(target);
|
|
100
|
-
const config = configs.find((cfg) => cfg.id === id);
|
|
101
|
-
|
|
102
|
-
if (!config) {
|
|
103
|
-
console.log(
|
|
104
|
-
`TargetConfig [${target}] não encontrado, utilize o comando --list-target-configs para ver as configurações disponíveis`
|
|
105
|
-
);
|
|
106
|
-
process.exit(1);
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
return [config];
|
|
110
|
-
} catch (e) {
|
|
111
|
-
console.log(`Erro ao buscar configuração: ${e}`);
|
|
112
|
-
if (process.env.NODE_ENV !== 'test') {
|
|
113
|
-
process.exit(1);
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
async getAllTargetConfigs(applicationName) {
|
|
119
|
-
// const targetUrl = `${this.config.url}${this.config.targetPath}?name=${target}`
|
|
120
|
-
try {
|
|
121
|
-
// const response = await axios.get(targetUrl)
|
|
122
|
-
// const fullTarget = response.data
|
|
123
|
-
|
|
124
|
-
const targets = await this.availableTargets();
|
|
125
|
-
const fullTarget = targets.filter(
|
|
126
|
-
(a) => a.name === applicationName
|
|
127
|
-
);
|
|
128
|
-
const configs = fullTarget[0].targetConfig;
|
|
129
|
-
|
|
130
|
-
return configs;
|
|
131
|
-
} catch (e) {
|
|
132
|
-
console.log(`Erro ao buscar configuração: ${e}`);
|
|
133
|
-
if (process.env.NODE_ENV !== 'test') {
|
|
134
|
-
process.exit(1);
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
|
|
139
97
|
getTarget() {
|
|
140
98
|
if (!this.target) {
|
|
141
99
|
console.warn("Target não foi detectado no setup()");
|
|
@@ -250,6 +208,8 @@ class Workspace {
|
|
|
250
208
|
await this.eitriAppService.writeEitriConf(remoteEitriConf, miniConf, this.folder2watch);
|
|
251
209
|
}
|
|
252
210
|
|
|
211
|
+
await LibsService.validateLibsVersions({libs: state.libs, eitriAppConf: miniConf});
|
|
212
|
+
|
|
253
213
|
this.printLibsVersion(state);
|
|
254
214
|
|
|
255
215
|
await this.loadTarget(remoteTarget);
|
|
@@ -357,51 +317,6 @@ class Workspace {
|
|
|
357
317
|
return Base64.encode(JSON.stringify(miniAppData));
|
|
358
318
|
}
|
|
359
319
|
|
|
360
|
-
async getWorkspaceURL(args, targetConfig) {
|
|
361
|
-
args = args || {};
|
|
362
|
-
const cookie = await this.http.getCookieSession(this.serverUrl);
|
|
363
|
-
let paramOrderId = "";
|
|
364
|
-
let paramShareId = "";
|
|
365
|
-
let cid;
|
|
366
|
-
const viewHtml = (args.view || "index") + ".html";
|
|
367
|
-
const miniAppConf = this.getMiniConf();
|
|
368
|
-
const data = {
|
|
369
|
-
publicKey: miniAppConf["public-key"],
|
|
370
|
-
metadata: miniAppConf["metadata"],
|
|
371
|
-
slug: miniAppConf["slug"],
|
|
372
|
-
title: miniAppConf["title"],
|
|
373
|
-
};
|
|
374
|
-
if (args.orderId) {
|
|
375
|
-
paramOrderId = "&orderId=" + encodeURIComponent(args.orderId);
|
|
376
|
-
}
|
|
377
|
-
if (args.shareId) {
|
|
378
|
-
paramShareId = "&shareId=" + encodeURIComponent(args.shareId);
|
|
379
|
-
}
|
|
380
|
-
if (args.initializationParams) {
|
|
381
|
-
data.initializationParams = args.initializationParams;
|
|
382
|
-
}
|
|
383
|
-
const encodedData = Base64.encode(JSON.stringify(data));
|
|
384
|
-
if (cookie) {
|
|
385
|
-
cid = Base64.encode(cookie.cookieString());
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
if (!targetConfig.bootstrapBaseUrl) {
|
|
389
|
-
throw new Error(
|
|
390
|
-
"Workspace.getWorkspaceURL.internalError#missingBootstrapBaseUrl"
|
|
391
|
-
);
|
|
392
|
-
}
|
|
393
|
-
|
|
394
|
-
let miniAppUrl = `${this.getBootstrapURL(
|
|
395
|
-
targetConfig.bootstrapBaseUrl
|
|
396
|
-
)}/${this.config.basePath || "workspace"
|
|
397
|
-
}/user/${(await vegvisirService.getWorkspace()).id}/${viewHtml}?data=${encodedData}${paramOrderId}${paramShareId}&devmode=true`;
|
|
398
|
-
|
|
399
|
-
if (cid) {
|
|
400
|
-
miniAppUrl = miniAppUrl + "&cid=" + cid;
|
|
401
|
-
}
|
|
402
|
-
return miniAppUrl;
|
|
403
|
-
}
|
|
404
|
-
|
|
405
320
|
/**
|
|
406
321
|
*
|
|
407
322
|
* @param {string} bootstrapBaseUrl
|
|
@@ -419,13 +334,11 @@ class Workspace {
|
|
|
419
334
|
return bootstrapBaseUrl;
|
|
420
335
|
}
|
|
421
336
|
|
|
422
|
-
async getNewWorkspaceURL(args,
|
|
423
|
-
const qrCodeConfig = await this.getQrCodeConfig(args,
|
|
337
|
+
async getNewWorkspaceURL(args, setupConfig) {
|
|
338
|
+
const qrCodeConfig = await this.getQrCodeConfig(args, setupConfig);
|
|
424
339
|
const stateData = await this.saveShareState(qrCodeConfig);
|
|
425
340
|
const stateId = stateData.id;
|
|
426
|
-
const miniAppUrl = `${this.qrCodeUrl}/${stateId}
|
|
427
|
-
"hml"
|
|
428
|
-
}`;
|
|
341
|
+
const miniAppUrl = `${this.qrCodeUrl}/${stateId}`;
|
|
429
342
|
return {
|
|
430
343
|
miniAppConf: {
|
|
431
344
|
...qrCodeConfig,
|
|
@@ -448,7 +361,7 @@ class Workspace {
|
|
|
448
361
|
return response.data;
|
|
449
362
|
}
|
|
450
363
|
|
|
451
|
-
async getQrCodeConfig(args,
|
|
364
|
+
async getQrCodeConfig(args, setupConfig) {
|
|
452
365
|
args = args || {};
|
|
453
366
|
const cookie = await this.http.getCookieSession(this.serverUrl);
|
|
454
367
|
let cid;
|
|
@@ -468,10 +381,7 @@ class Workspace {
|
|
|
468
381
|
slug: miniAppConf["slug"],
|
|
469
382
|
title: miniAppConf["title"],
|
|
470
383
|
permissions: miniAppConf["permissions"],
|
|
471
|
-
|
|
472
|
-
// Se nao enviarmos essa url pronta, o superapp tera que monta-la
|
|
473
|
-
// Essa url chama a funcao users.js do workspace-api
|
|
474
|
-
miniAppBootstrapUrl: await this.getWorkspaceURL(args, targetConfig),
|
|
384
|
+
miniAppBootstrapUrl: this.getBootstrapURL(setupConfig.eitriAppBootstrapURL),
|
|
475
385
|
initializationParams,
|
|
476
386
|
orderId,
|
|
477
387
|
view,
|
|
@@ -9,29 +9,20 @@ function QRCodeStarter(
|
|
|
9
9
|
trackingService,
|
|
10
10
|
watcher,
|
|
11
11
|
workspace,
|
|
12
|
-
|
|
12
|
+
setupConfig
|
|
13
13
|
) {
|
|
14
14
|
this.args = args;
|
|
15
15
|
this.trackingService = trackingService;
|
|
16
16
|
this.watcher = watcher;
|
|
17
17
|
this.workspace = workspace;
|
|
18
|
-
this.
|
|
18
|
+
this.setupConfig = setupConfig;
|
|
19
19
|
|
|
20
20
|
this.startServer = async function () {
|
|
21
|
-
|
|
22
|
-
if (this.args.oldQrcode) {
|
|
23
|
-
fullUrl = await this.workspace.getWorkspaceURL(
|
|
21
|
+
const workspaceURLConfig = await this.workspace.getNewWorkspaceURL(
|
|
24
22
|
this.args,
|
|
25
|
-
this.
|
|
23
|
+
this.setupConfig
|
|
26
24
|
);
|
|
27
|
-
|
|
28
|
-
const { miniAppUrl } = await this.workspace.getNewWorkspaceURL(
|
|
29
|
-
this.args,
|
|
30
|
-
this.targetConfig
|
|
31
|
-
);
|
|
32
|
-
fullUrl = miniAppUrl;
|
|
33
|
-
}
|
|
34
|
-
|
|
25
|
+
const fullUrl = workspaceURLConfig.miniAppUrl
|
|
35
26
|
if (this.args.verbose) {
|
|
36
27
|
console.log(`QrCodeUrl: ${fullUrl}`);
|
|
37
28
|
}
|
|
@@ -130,14 +121,14 @@ function QRCodeContentFactory() {
|
|
|
130
121
|
trackingService,
|
|
131
122
|
watcher,
|
|
132
123
|
workspace,
|
|
133
|
-
|
|
124
|
+
setupConfig
|
|
134
125
|
) {
|
|
135
126
|
return new QRCodeStarter(
|
|
136
127
|
args,
|
|
137
128
|
trackingService,
|
|
138
129
|
watcher,
|
|
139
130
|
workspace,
|
|
140
|
-
|
|
131
|
+
setupConfig
|
|
141
132
|
);
|
|
142
133
|
};
|
|
143
134
|
}
|
package/test/e2e/cli.test.js
CHANGED
|
@@ -212,6 +212,43 @@ describe("eitri-cli", () => {
|
|
|
212
212
|
2 * minutes
|
|
213
213
|
);
|
|
214
214
|
|
|
215
|
+
it(
|
|
216
|
+
"should list eitri libs versions",
|
|
217
|
+
async () => {
|
|
218
|
+
try {
|
|
219
|
+
await execAsync(
|
|
220
|
+
`cd ${EITRI_WORK_DIR} && rm -rf ./eitri-test-*`,
|
|
221
|
+
{ env: process.env }
|
|
222
|
+
);
|
|
223
|
+
|
|
224
|
+
const executor = new Executor({env: devEnv});
|
|
225
|
+
await executor
|
|
226
|
+
.exec("eitri libs -l")
|
|
227
|
+
.waitFor(/libsVersions/);
|
|
228
|
+
await executor
|
|
229
|
+
.exec("eitri libs -l")
|
|
230
|
+
.waitFor(/luminusUiVersions/);
|
|
231
|
+
await executor
|
|
232
|
+
.exec("eitri libs -l")
|
|
233
|
+
.waitFor(/versions/);
|
|
234
|
+
await executor
|
|
235
|
+
.exec("eitri libs -l")
|
|
236
|
+
.waitFor(/bifrostVersions/);
|
|
237
|
+
await executor
|
|
238
|
+
.exec("eitri libs -l")
|
|
239
|
+
.waitFor(/betaVersions/);
|
|
240
|
+
await executor
|
|
241
|
+
.exec("eitri libs -l")
|
|
242
|
+
.waitFor(/alphaVersions/);
|
|
243
|
+
|
|
244
|
+
} catch (e) {
|
|
245
|
+
console.error(e);
|
|
246
|
+
throw e;
|
|
247
|
+
}
|
|
248
|
+
},
|
|
249
|
+
2 * minutes
|
|
250
|
+
);
|
|
251
|
+
|
|
215
252
|
const getPublishedVersion = async (version, eitriAppId) => {
|
|
216
253
|
const blindGuardian = new BlindGuardian();
|
|
217
254
|
const http = new Http(blindGuardian);
|
|
@@ -131,126 +131,6 @@ describe('Workspace', () => {
|
|
|
131
131
|
])
|
|
132
132
|
})
|
|
133
133
|
})
|
|
134
|
-
|
|
135
|
-
describe('.getWorkspaceURL()', () => {
|
|
136
|
-
beforeEach(() => {
|
|
137
|
-
workspace.userEmail = 'dev@calindra.com.br'
|
|
138
|
-
workspace.target = {
|
|
139
|
-
bootstrapBaseUrl: 'http://minhaconta.base.url'
|
|
140
|
-
}
|
|
141
|
-
workspace.folder2watch = path.resolve(
|
|
142
|
-
__dirname,
|
|
143
|
-
'..',
|
|
144
|
-
'_fixtures',
|
|
145
|
-
'src'
|
|
146
|
-
)
|
|
147
|
-
})
|
|
148
|
-
|
|
149
|
-
it('retorna a url do workspace do usuario apontando para index.html', async () => {
|
|
150
|
-
let url = await workspace.getWorkspaceURL('', {bootstrapBaseUrl: 'http://minhaconta.base.url'})
|
|
151
|
-
expect(url).toContain('/index.html?')
|
|
152
|
-
})
|
|
153
|
-
|
|
154
|
-
it('Deve retornar queries string ', async () => {
|
|
155
|
-
let args = {
|
|
156
|
-
initializationParams: {
|
|
157
|
-
foo: 'bar'
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
let urlValue = await workspace.getWorkspaceURL(args, {bootstrapBaseUrl: 'http://minhaconta.base.url'})
|
|
161
|
-
console.log(urlValue)
|
|
162
|
-
let query = url.parse(urlValue, true).query
|
|
163
|
-
let dataString = Buffer.from(query.data, 'base64').toString()
|
|
164
|
-
let data = JSON.parse(dataString)
|
|
165
|
-
expect(data.initializationParams).toMatchObject(args.initializationParams)
|
|
166
|
-
})
|
|
167
|
-
|
|
168
|
-
it('retorna a url do workspace do usuario apontando para OrderDetails.html', async () => {
|
|
169
|
-
let url = await workspace.getWorkspaceURL({ view: 'OrderDetails' }, {bootstrapBaseUrl: 'http://minhaconta.base.url'})
|
|
170
|
-
expect(url).toContain('/OrderDetails.html?')
|
|
171
|
-
})
|
|
172
|
-
|
|
173
|
-
it('retorna a url do workspace do usuario com o parametro order id', async () => {
|
|
174
|
-
let url = await workspace.getWorkspaceURL({
|
|
175
|
-
view: 'OrderDetails',
|
|
176
|
-
orderId: 'e08a2547-b8d6-4437-91a7-0bc67987689d',
|
|
177
|
-
}, {bootstrapBaseUrl: 'http://minhaconta.base.url'})
|
|
178
|
-
expect(url).toContain(
|
|
179
|
-
'orderId=e08a2547-b8d6-4437-91a7-0bc67987689d'
|
|
180
|
-
)
|
|
181
|
-
})
|
|
182
|
-
})
|
|
183
|
-
describe('.getTargetConfig() & .getAllTargetConfigs()', () => {
|
|
184
|
-
const target = 'CALINDRA_MOBILE'
|
|
185
|
-
const res = [
|
|
186
|
-
{
|
|
187
|
-
id: 7,
|
|
188
|
-
name: 'CALINDRA_MOBILE',
|
|
189
|
-
minimumCliVersion: '1.16.5',
|
|
190
|
-
boilerplateUrl: 'https://github.com/Calindra/servless-backend-template.git',
|
|
191
|
-
superAppClientLibName: 'eitri-app-client',
|
|
192
|
-
componentsLibName: 'eitri-app-components',
|
|
193
|
-
description: 'CALINDRA_MOBILE',
|
|
194
|
-
status: 'ACTIVE',
|
|
195
|
-
platform: 'mobile',
|
|
196
|
-
targetConfig: [
|
|
197
|
-
{
|
|
198
|
-
id: 'default',
|
|
199
|
-
libUrl: 'https://www.npmjs.com/package/eitri-app-client',
|
|
200
|
-
runnerUrl: 'https://dev.eitri.calindra.com.br/app/',
|
|
201
|
-
bootstrapBaseUrl: 'https://dev.eitri.calindra.com.br',
|
|
202
|
-
askUserDataApiUrl: 'https://dev.eitri.calindra.com.br/miniapp-manager-api/o/mini-apps/:slug/token'
|
|
203
|
-
},
|
|
204
|
-
{
|
|
205
|
-
id: 'ws',
|
|
206
|
-
libUrl: 'https://www.npmjs.com/package/eitri-app-client',
|
|
207
|
-
runnerUrl: 'https://dev.eitri.calindra.com.br/app/',
|
|
208
|
-
bootstrapBaseUrl: 'http://localhost:3333',
|
|
209
|
-
askUserDataApiUrl: 'https://dev.eitri.calindra.com.br/miniapp-manager-api/p/mini-apps/:slug/token/foundry'
|
|
210
|
-
}
|
|
211
|
-
],
|
|
212
|
-
default: true
|
|
213
|
-
}
|
|
214
|
-
]
|
|
215
|
-
|
|
216
|
-
beforeEach(() => {
|
|
217
|
-
nock.cleanAll()
|
|
218
|
-
nock('https://dev.eitri.calindra.com.br')
|
|
219
|
-
.get(/\/eitri-manager-api\/p\/users\/self\/targets/).reply(200, res)
|
|
220
|
-
})
|
|
221
|
-
|
|
222
|
-
it('deve receber a configuração correta', async () => {
|
|
223
|
-
const config = await workspace.getTargetConfig('default', target)
|
|
224
|
-
expect(config[0]).toStrictEqual({
|
|
225
|
-
id: 'default',
|
|
226
|
-
libUrl: 'https://www.npmjs.com/package/eitri-app-client',
|
|
227
|
-
runnerUrl: 'https://dev.eitri.calindra.com.br/app/',
|
|
228
|
-
bootstrapBaseUrl: 'https://dev.eitri.calindra.com.br',
|
|
229
|
-
askUserDataApiUrl: 'https://dev.eitri.calindra.com.br/miniapp-manager-api/o/mini-apps/:slug/token'
|
|
230
|
-
})
|
|
231
|
-
|
|
232
|
-
}
|
|
233
|
-
)
|
|
234
|
-
it('deve retornar todos os configs', async () => {
|
|
235
|
-
const config = await workspace.getAllTargetConfigs(target)
|
|
236
|
-
expect(config).toMatchObject([
|
|
237
|
-
{
|
|
238
|
-
id: 'default',
|
|
239
|
-
libUrl: 'https://www.npmjs.com/package/eitri-app-client',
|
|
240
|
-
runnerUrl: 'https://dev.eitri.calindra.com.br/app/',
|
|
241
|
-
bootstrapBaseUrl: 'https://dev.eitri.calindra.com.br',
|
|
242
|
-
askUserDataApiUrl: 'https://dev.eitri.calindra.com.br/miniapp-manager-api/o/mini-apps/:slug/token'
|
|
243
|
-
},
|
|
244
|
-
{
|
|
245
|
-
id: 'ws',
|
|
246
|
-
libUrl: 'https://www.npmjs.com/package/eitri-app-client',
|
|
247
|
-
runnerUrl: 'https://dev.eitri.calindra.com.br/app/',
|
|
248
|
-
bootstrapBaseUrl: 'http://localhost:3333',
|
|
249
|
-
askUserDataApiUrl: 'https://dev.eitri.calindra.com.br/miniapp-manager-api/p/mini-apps/:slug/token/foundry'
|
|
250
|
-
}
|
|
251
|
-
])
|
|
252
|
-
})
|
|
253
|
-
})
|
|
254
134
|
|
|
255
135
|
describe('.availableTargets()', () => {
|
|
256
136
|
|