eitri-cli 1.6.0-beta.3 → 1.6.0-beta.4
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/index.js +3 -0
- package/package.json +1 -1
- package/src/cmd/start.js +21 -0
- package/src/modules/vegvisir/VegvisirService.js +8 -0
package/index.js
CHANGED
|
@@ -7,13 +7,16 @@ const path = require("path");
|
|
|
7
7
|
const { workspace } = require("./src/service/Workspace");
|
|
8
8
|
const configService = require("./src/service/ConfigService");
|
|
9
9
|
const VegvisirCommand = require("./src/modules/vegvisir/VegvisirCommand");
|
|
10
|
+
const debug = require('debug')('eitri:run')
|
|
10
11
|
|
|
11
12
|
const run = async () => {
|
|
13
|
+
debug("Iniciando run()")
|
|
12
14
|
try {
|
|
13
15
|
const srcFolder2watch = path.join(process.cwd(), "src");
|
|
14
16
|
workspace.setFolder2Watch(srcFolder2watch);
|
|
15
17
|
workspace.setServerUrl(`${configService.get("workspace").url}`);
|
|
16
18
|
} catch (e) {
|
|
19
|
+
debug("Erro no set da pasta", {message: e?.message, error: e})
|
|
17
20
|
if (process.env.LOG_LEVEL === "full") {
|
|
18
21
|
console.log("Current directory listening has failed", e);
|
|
19
22
|
}
|
package/package.json
CHANGED
package/src/cmd/start.js
CHANGED
|
@@ -17,14 +17,19 @@ const hashFolder = workspace.hashFolder
|
|
|
17
17
|
const trackingService = new TrackingService(blindGuardian, { ignoreCredentialError: true })
|
|
18
18
|
const watcher = new Watcher(workspace, hashFolder, trackingService)
|
|
19
19
|
const vegvisirService = new VegvisirService()
|
|
20
|
+
const debug = require('debug')('eitri:start')
|
|
20
21
|
|
|
21
22
|
module.exports = async function start(args) {
|
|
23
|
+
debug("Iniciando start()")
|
|
24
|
+
|
|
22
25
|
const separator = '======================================================================='
|
|
23
26
|
let displayFriendlyErrorAtEnd = ""
|
|
24
27
|
|
|
25
28
|
try {
|
|
26
29
|
UserLocalCredential.checkForCredentials()
|
|
30
|
+
debug("Successo na checagem de credenciais")
|
|
27
31
|
} catch (error) {
|
|
32
|
+
debug("ERRO na checagem de credenciais", {message: error?.message, error})
|
|
28
33
|
const errorMessage = args?.verbose ? error : error?.message
|
|
29
34
|
console.error("\n", errorMessage, "\n")
|
|
30
35
|
return
|
|
@@ -36,6 +41,7 @@ module.exports = async function start(args) {
|
|
|
36
41
|
}
|
|
37
42
|
|
|
38
43
|
const miniLog = new MiniLog(config.get('miniLog'))
|
|
44
|
+
debug("Obtendo informações do MiniLog", miniLog)
|
|
39
45
|
|
|
40
46
|
const resourceFolders2watch = [path.join(process.cwd(), 'public')]
|
|
41
47
|
if (fs.existsSync(resourceFolders2watch)) {
|
|
@@ -44,9 +50,12 @@ module.exports = async function start(args) {
|
|
|
44
50
|
|
|
45
51
|
const miniConf = workspace.getMiniConf()
|
|
46
52
|
await vegvisirService.check(miniConf.slug)
|
|
53
|
+
debug("Fim da busca e validação do EitriAppConf", {miniConf})
|
|
47
54
|
|
|
48
55
|
const url = config.get('workspace').url
|
|
49
56
|
const setupResult = await workspace.setup()
|
|
57
|
+
debug("Informações do setupResult do workspace", {setupResult})
|
|
58
|
+
|
|
50
59
|
const target = setupResult.target.name
|
|
51
60
|
|
|
52
61
|
let targetConfig = {}
|
|
@@ -56,6 +65,7 @@ module.exports = async function start(args) {
|
|
|
56
65
|
process.exit(1)
|
|
57
66
|
}
|
|
58
67
|
|
|
68
|
+
debug("Verificando se há targetConfig nos argumentos", {targetConfig: args?.targetConfig})
|
|
59
69
|
if(args.targetConfig) {
|
|
60
70
|
targetConfig = await askTargetConfig(args, target)
|
|
61
71
|
} else {
|
|
@@ -71,7 +81,11 @@ module.exports = async function start(args) {
|
|
|
71
81
|
}
|
|
72
82
|
workspace.setServerUrl(url)
|
|
73
83
|
workspace.setQrCodeUrl(qrCodeUrl)
|
|
84
|
+
|
|
85
|
+
debug("Iniciando workspace", {workspace})
|
|
74
86
|
await workspace.init()
|
|
87
|
+
debug("Workspace iniciado", {workspace})
|
|
88
|
+
|
|
75
89
|
const silentOnConnect = args.verbose ? false : true
|
|
76
90
|
const userWorkspace = await vegvisirService.getWorkspace()
|
|
77
91
|
await miniLog.connect(userWorkspace.id, silentOnConnect)
|
|
@@ -79,8 +93,10 @@ module.exports = async function start(args) {
|
|
|
79
93
|
console.log("Construindo...");
|
|
80
94
|
const isDevMode = true
|
|
81
95
|
try {
|
|
96
|
+
debug("Iniciando workspace.uploadZip", {isDevMode, workspace})
|
|
82
97
|
await workspace.uploadZip(isDevMode);
|
|
83
98
|
} catch (error) {
|
|
99
|
+
debug("Erro no workspace.uploadZip", {isDevMode, workspace, error})
|
|
84
100
|
if(args.verbose){
|
|
85
101
|
console.error("::uploadZip::", error?.message)
|
|
86
102
|
console.error(":::uploadZip::: ", error)
|
|
@@ -95,12 +111,16 @@ module.exports = async function start(args) {
|
|
|
95
111
|
console.log("Pronto!");
|
|
96
112
|
|
|
97
113
|
const loadedTarget = await workspace.getTarget()
|
|
114
|
+
debug("Target carregado do workspace", {loadedTarget})
|
|
115
|
+
|
|
98
116
|
const platform = loadedTarget.platform
|
|
99
117
|
const argsWithDeeplinks = {
|
|
100
118
|
...args,
|
|
101
119
|
deepLinks: loadedTarget?.deepLinks || []
|
|
102
120
|
}
|
|
121
|
+
debug("Iniciando servidor", {argsWithDeeplinks, trackingService, watcher, workspace, target, targetConfig, platform})
|
|
103
122
|
await handleStartServer(argsWithDeeplinks, trackingService, watcher, workspace, target, targetConfig, platform)
|
|
123
|
+
debug("Servidor iniciado", {loadedTarget})
|
|
104
124
|
|
|
105
125
|
TrackingEitriAnalytics.sendEvent({
|
|
106
126
|
eventName:"start",
|
|
@@ -113,6 +133,7 @@ module.exports = async function start(args) {
|
|
|
113
133
|
}
|
|
114
134
|
})
|
|
115
135
|
} catch (e) {
|
|
136
|
+
debug("Erro no processo de start", {message: e?.message, error: e})
|
|
116
137
|
TrackingEitriAnalytics.sendEvent({
|
|
117
138
|
eventName: "start.error",
|
|
118
139
|
userId: workspace?.userEmail,
|
|
@@ -8,6 +8,8 @@ const os = require("os");
|
|
|
8
8
|
const {validateUUID} = require("../../util/GenericUtils");
|
|
9
9
|
const path = require("path");
|
|
10
10
|
const fs = require('fs')
|
|
11
|
+
const debug = require('debug')('eitri:VegvisirService')
|
|
12
|
+
|
|
11
13
|
module.exports = class VegvisirService {
|
|
12
14
|
constructor() {
|
|
13
15
|
const blindGuardian = new BlindGuardian();
|
|
@@ -55,10 +57,14 @@ module.exports = class VegvisirService {
|
|
|
55
57
|
}
|
|
56
58
|
|
|
57
59
|
async check(slug) {
|
|
60
|
+
debug("Iniciando check")
|
|
58
61
|
try {
|
|
59
62
|
let workspace = await this.getWorkspace()
|
|
63
|
+
debug("Workspace carregado", {workspace})
|
|
60
64
|
if(!workspace) {
|
|
65
|
+
debug("Nenhum workspace obtido. Inciando busca de Workspaces")
|
|
61
66
|
const workspaces = await this.listMyWorkspaces();
|
|
67
|
+
debug("Lista de Workspaces", {workspaces})
|
|
62
68
|
const defaultWorkspace = await workspaces.find(w => w.name === 'DEFAULT')
|
|
63
69
|
await writeGlobalWorkspaceConfig(defaultWorkspace)
|
|
64
70
|
workspace = defaultWorkspace;
|
|
@@ -73,7 +79,9 @@ module.exports = class VegvisirService {
|
|
|
73
79
|
const url =`${this.config.url}${this.config.basePath}${this.config.check}`;
|
|
74
80
|
|
|
75
81
|
await this.http.put(url, data)
|
|
82
|
+
debug("Atualização realizada", {url, data})
|
|
76
83
|
} catch (error) {
|
|
84
|
+
debug("Erro na realização do check", {message: error?.message, error})
|
|
77
85
|
console.error(error.message)
|
|
78
86
|
if (axios.isAxiosError(error)) {
|
|
79
87
|
if (error?.response?.status === 404) {
|