eitri-cli 1.0.5 → 1.1.0-beta.1
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 +5 -0
- package/config/dev.js +13 -3
- package/config/loc-eitri.js +19 -8
- package/config/prod-eitri.js +13 -3
- package/index.js +115 -66
- package/package.json +1 -1
- package/src/cmd/create.js +185 -162
- package/src/cmd/push-version.js +24 -15
- package/src/cmd/start.js +15 -8
- package/src/modules/vegvisir/VegvisirCommand.js +38 -0
- package/src/modules/vegvisir/VegvisirService.js +71 -0
- package/src/modules/vegvisir/cmd/create.js +43 -0
- package/src/modules/vegvisir/cmd/current.js +22 -0
- package/src/modules/vegvisir/cmd/list.js +13 -0
- package/src/modules/vegvisir/cmd/use.js +71 -0
- package/src/service/EitriAppManager.js +32 -0
- package/src/service/Http.js +45 -14
- package/src/service/Server.js +14 -38
- package/src/service/Workspace.js +767 -586
- package/src/service/factories/MiniWebAppFactory.js +4 -3
- package/src/service/factories/WoodCoffeeFactory.js +170 -123
- package/src/util/getCreateFactory.js +2 -2
- package/src/util/getWorkspace.js +38 -0
- package/test/Factory.js +13 -0
- package/test/_fixtures/woodcoffee/miniapp.conf.js +3 -1
- package/test/modules/vegvisir/VegvisirService.test.js +37 -0
- package/test/utils/getWorkspaceId.test.js +16 -0
package/src/cmd/create.js
CHANGED
|
@@ -1,197 +1,215 @@
|
|
|
1
|
-
const Watcher = require(
|
|
2
|
-
const inquirer = require(
|
|
3
|
-
const slugify = require(
|
|
4
|
-
const config = require(
|
|
5
|
-
const { Workspace } = require(
|
|
6
|
-
const BlindGuardian = require(
|
|
7
|
-
const HashFolder = require(
|
|
8
|
-
const TrackingService = require(
|
|
9
|
-
const { NAME_TITLE_REGEX, SLUG_REGEX } = require(
|
|
10
|
-
const handleStartServer = require(
|
|
11
|
-
const getCreateFactory = require(
|
|
12
|
-
const UrlUtils = require(
|
|
1
|
+
const Watcher = require("../service/Watcher");
|
|
2
|
+
const inquirer = require("inquirer");
|
|
3
|
+
const slugify = require("slugify");
|
|
4
|
+
const config = require("config");
|
|
5
|
+
const { Workspace } = require("../service/Workspace");
|
|
6
|
+
const BlindGuardian = require("../service/BlindGuardian");
|
|
7
|
+
const HashFolder = require("../service/HashFolder");
|
|
8
|
+
const TrackingService = require("../service/TrackingService");
|
|
9
|
+
const { NAME_TITLE_REGEX, SLUG_REGEX } = require("./validate");
|
|
10
|
+
const handleStartServer = require("../service/StarterService");
|
|
11
|
+
const getCreateFactory = require("../util/getCreateFactory");
|
|
12
|
+
const UrlUtils = require("../util/UrlUtils");
|
|
13
13
|
|
|
14
14
|
// eslint-disable-next-line no-unused-vars
|
|
15
|
-
const Target = require(
|
|
16
|
-
const
|
|
15
|
+
const Target = require("../model/Target");
|
|
16
|
+
const EitriAppManager = require("../service/EitriAppManager");
|
|
17
|
+
const WoodCoffee = require("../service/factories/WoodCoffeeFactory");
|
|
18
|
+
const TrackingEitriAnalytics = require("../service/TrackingEitriAnalytics");
|
|
17
19
|
|
|
18
|
-
const blindGuardian = new BlindGuardian()
|
|
19
|
-
const hashFolder = new HashFolder()
|
|
20
|
-
const workspace = new Workspace(blindGuardian, hashFolder)
|
|
21
|
-
const trackingService = new TrackingService(blindGuardian, {
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
const blindGuardian = new BlindGuardian();
|
|
21
|
+
const hashFolder = new HashFolder();
|
|
22
|
+
const workspace = new Workspace(blindGuardian, hashFolder);
|
|
23
|
+
const trackingService = new TrackingService(blindGuardian, {
|
|
24
|
+
ignoreCredentialError: true,
|
|
25
|
+
});
|
|
26
|
+
const watcher = new Watcher(workspace, hashFolder, trackingService);
|
|
27
|
+
const ITEM_DOUBT = "DOUBTS";
|
|
28
|
+
const eitriAppManager = new EitriAppManager(blindGuardian);
|
|
24
29
|
|
|
25
30
|
const notBlank = (inpt) => {
|
|
26
31
|
if (!inpt || !inpt.trim()) {
|
|
27
|
-
return
|
|
32
|
+
return "Não pode ficar em branco";
|
|
28
33
|
} else {
|
|
29
|
-
return true
|
|
34
|
+
return true;
|
|
30
35
|
}
|
|
31
|
-
}
|
|
36
|
+
};
|
|
32
37
|
|
|
33
38
|
const nameOrTitle = (inpt) => {
|
|
34
39
|
if (!NAME_TITLE_REGEX.test(inpt)) {
|
|
35
|
-
return
|
|
40
|
+
return "Não use caracteres especiais";
|
|
36
41
|
}
|
|
37
|
-
return true
|
|
38
|
-
}
|
|
42
|
+
return true;
|
|
43
|
+
};
|
|
39
44
|
|
|
40
45
|
const slug = (inpt) => {
|
|
41
46
|
if (!SLUG_REGEX.test(inpt)) {
|
|
42
|
-
return
|
|
47
|
+
return "Não use caracteres especiais";
|
|
43
48
|
}
|
|
44
|
-
return true
|
|
45
|
-
}
|
|
49
|
+
return true;
|
|
50
|
+
};
|
|
46
51
|
|
|
47
52
|
// eslint-disable-next-line no-unused-vars
|
|
48
53
|
module.exports = async function create(projectName, cmdObj) {
|
|
49
|
-
console.log(
|
|
54
|
+
console.log(
|
|
55
|
+
"\x1b[34mVamos criar o seu eitri-app. Para isso basta responder algumas perguntas:\x1b[0m"
|
|
56
|
+
);
|
|
50
57
|
|
|
51
58
|
try {
|
|
52
|
-
const url = config.get(
|
|
53
|
-
workspace.setServerUrl(url)
|
|
54
|
-
const
|
|
55
|
-
if(
|
|
56
|
-
handleStartServer(
|
|
57
|
-
|
|
59
|
+
const url = config.get("workspace").url;
|
|
60
|
+
workspace.setServerUrl(url);
|
|
61
|
+
const clientApplication = await askClientApplication();
|
|
62
|
+
if (clientApplication.name === ITEM_DOUBT) {
|
|
63
|
+
handleStartServer(
|
|
64
|
+
cmdObj,
|
|
65
|
+
trackingService,
|
|
66
|
+
watcher,
|
|
67
|
+
workspace,
|
|
68
|
+
clientApplication.name
|
|
69
|
+
);
|
|
70
|
+
return;
|
|
58
71
|
}
|
|
59
|
-
|
|
60
|
-
TrackingEitriAnalytics.sendEvent({
|
|
61
|
-
command: "create",
|
|
62
|
-
success: true,
|
|
63
|
-
data: {
|
|
64
|
-
projectName,
|
|
65
|
-
platform
|
|
66
|
-
}
|
|
67
|
-
})
|
|
68
|
-
return res
|
|
72
|
+
return await askProjMetadata(clientApplication, cmdObj, projectName);
|
|
69
73
|
} catch (e) {
|
|
70
74
|
await TrackingEitriAnalytics.sendEvent({
|
|
71
75
|
command: "create",
|
|
72
76
|
success: false,
|
|
73
|
-
errorMessage: e?.message
|
|
74
|
-
})
|
|
75
|
-
console.error(e?.message)
|
|
77
|
+
errorMessage: e?.message,
|
|
78
|
+
});
|
|
79
|
+
console.error(e?.message);
|
|
76
80
|
}
|
|
77
|
-
}
|
|
81
|
+
};
|
|
78
82
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
process.exit(0)
|
|
87
|
-
}
|
|
88
|
-
if (!availableTargets.length) {
|
|
89
|
-
return defaultTarget
|
|
83
|
+
async function askClientApplication() {
|
|
84
|
+
const availableApplications = await eitriAppManager.findAllApplications();
|
|
85
|
+
if (availableApplications.length <= 0) {
|
|
86
|
+
console.log(
|
|
87
|
+
"Sua organização não contém nenhuma aplicação disponível para prosseguir com a criação."
|
|
88
|
+
);
|
|
89
|
+
process.exit(0);
|
|
90
90
|
}
|
|
91
|
-
const cliOptions = [
|
|
91
|
+
const cliOptions = [
|
|
92
|
+
...availableApplications,
|
|
93
|
+
{ name: ITEM_DOUBT, label: "Dúvidas? Veja documentação no browser" },
|
|
94
|
+
];
|
|
92
95
|
const createLabel = (tgt) => {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
organizationLabel = tgt.organization.name || tgt.organization.id
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
return `${tgt.label || `${tgt.name} (${organizationLabel})`}`
|
|
100
|
-
}
|
|
96
|
+
const orgLabel = tgt.organization?.name ? `(${tgt.organization?.name})`: ''
|
|
97
|
+
return `${tgt.label || tgt.name} ${orgLabel}`;
|
|
98
|
+
};
|
|
101
99
|
|
|
102
100
|
const res = await inquirer.prompt([
|
|
103
101
|
{
|
|
104
|
-
name:
|
|
105
|
-
type:
|
|
106
|
-
message:
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
102
|
+
name: "accepted",
|
|
103
|
+
type: "rawlist",
|
|
104
|
+
message:
|
|
105
|
+
"Selecione a aplicação para qual destina-se seu eitri-app:",
|
|
106
|
+
choices: cliOptions.map(createLabel),
|
|
107
|
+
},
|
|
108
|
+
]);
|
|
109
|
+
const clientApplication = cliOptions.find(
|
|
110
|
+
(tgt) => createLabel(tgt) === res.accepted
|
|
111
|
+
);
|
|
112
|
+
clientApplication.onSelected && clientApplication.onSelected();
|
|
113
|
+
return clientApplication;
|
|
114
114
|
}
|
|
115
115
|
|
|
116
|
-
async function askProjMetadata(
|
|
117
|
-
const factory =
|
|
118
|
-
let questions = createQuestions(projectName)
|
|
116
|
+
async function askProjMetadata(clientApplication, cmdObj, projectName) {
|
|
117
|
+
const factory = new WoodCoffee();
|
|
118
|
+
let questions = createQuestions(projectName);
|
|
119
119
|
try {
|
|
120
|
-
await workspace.init()
|
|
120
|
+
await workspace.init();
|
|
121
121
|
} catch (e) {
|
|
122
|
-
console.log(e.message)
|
|
123
|
-
return
|
|
122
|
+
console.log(e.message);
|
|
123
|
+
return;
|
|
124
124
|
}
|
|
125
|
-
let answers
|
|
125
|
+
let answers;
|
|
126
126
|
if (cmdObj.yes) {
|
|
127
127
|
answers = {
|
|
128
128
|
name: projectName,
|
|
129
129
|
title: projectName,
|
|
130
|
-
slug: projectName
|
|
131
|
-
}
|
|
130
|
+
slug: projectName,
|
|
131
|
+
};
|
|
132
132
|
} else {
|
|
133
|
-
answers = await inquirer.prompt(questions)
|
|
133
|
+
answers = await inquirer.prompt(questions);
|
|
134
134
|
}
|
|
135
|
-
let conf = {
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
135
|
+
let conf = {
|
|
136
|
+
...answers,
|
|
137
|
+
organization: { id: clientApplication.organizationId },
|
|
138
|
+
};
|
|
139
|
+
delete conf.organizationName;
|
|
140
|
+
|
|
141
|
+
let keepGoing = true;
|
|
139
142
|
while (keepGoing) {
|
|
140
143
|
try {
|
|
141
|
-
keepGoing = false
|
|
142
|
-
await factory.verifyFolder(projectName, {supressLog: true})
|
|
144
|
+
keepGoing = false;
|
|
145
|
+
await factory.verifyFolder(projectName, { supressLog: true });
|
|
143
146
|
|
|
144
147
|
// Comentado até implementarmos os múltiplos boilerplates nos targets do banco
|
|
145
148
|
//const {template} = cmdObj
|
|
146
149
|
|
|
147
|
-
const selectedTemplate = _getBoilerplateUrl(
|
|
150
|
+
const selectedTemplate = _getBoilerplateUrl(
|
|
151
|
+
clientApplication,
|
|
152
|
+
cmdObj
|
|
153
|
+
);
|
|
154
|
+
cmdObj.verbose &&
|
|
155
|
+
console.log(`Usando template ${selectedTemplate}`);
|
|
148
156
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
157
|
+
let templateProject = await factory.create(
|
|
158
|
+
projectName,
|
|
159
|
+
selectedTemplate,
|
|
160
|
+
clientApplication
|
|
161
|
+
);
|
|
153
162
|
|
|
154
163
|
// conf sera usado pra escrever o arquivo miniapp.conf.js e nao queremos 'target' la.
|
|
155
|
-
const
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
164
|
+
const eitriAppToCreate = {
|
|
165
|
+
...conf,
|
|
166
|
+
organizationId: clientApplication.organization.id,
|
|
167
|
+
applicationId: clientApplication.id,
|
|
168
|
+
};
|
|
159
169
|
|
|
160
|
-
|
|
170
|
+
// Cria no banco no final das configs locais
|
|
171
|
+
const eitriApp = await eitriAppManager.create(eitriAppToCreate);
|
|
172
|
+
conf["id"] = eitriApp.id;
|
|
173
|
+
conf["public-key"] = eitriApp.publicKey;
|
|
161
174
|
|
|
162
|
-
const
|
|
175
|
+
const templateEitriAppConf =
|
|
176
|
+
templateProject?.structure?.eitriAppConf;
|
|
163
177
|
|
|
164
178
|
const finalConf = {
|
|
165
|
-
...
|
|
166
|
-
...conf
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
179
|
+
...templateEitriAppConf,
|
|
180
|
+
...conf,
|
|
181
|
+
organizationId: clientApplication.organization.id,
|
|
182
|
+
applicationId: clientApplication.id,
|
|
183
|
+
};
|
|
170
184
|
|
|
185
|
+
await factory.writeEitriAppConf(templateProject, finalConf);
|
|
171
186
|
} catch (err) {
|
|
172
|
-
if(cmdObj.verbose) {
|
|
173
|
-
console.error(
|
|
187
|
+
if (cmdObj.verbose) {
|
|
188
|
+
console.error(
|
|
189
|
+
"Houve uma falha durante a criação do eitri-app",
|
|
190
|
+
err
|
|
191
|
+
);
|
|
174
192
|
}
|
|
175
193
|
|
|
176
194
|
if (err.isDuplicatedError) {
|
|
177
195
|
if (cmdObj.yes) {
|
|
178
|
-
process.exit(1)
|
|
196
|
+
process.exit(1);
|
|
179
197
|
}
|
|
180
|
-
if (err.field ===
|
|
181
|
-
keepGoing = true
|
|
182
|
-
conf.name = await askName(projectName)
|
|
198
|
+
if (err.field === "name") {
|
|
199
|
+
keepGoing = true;
|
|
200
|
+
conf.name = await askName(projectName);
|
|
183
201
|
}
|
|
184
|
-
if (err.field ===
|
|
185
|
-
keepGoing = true
|
|
186
|
-
conf.slug = await askSlug(projectName)
|
|
202
|
+
if (err.field === "slug") {
|
|
203
|
+
keepGoing = true;
|
|
204
|
+
conf.slug = await askSlug(projectName);
|
|
187
205
|
}
|
|
188
206
|
} else {
|
|
189
207
|
if (err.isAxiosError) {
|
|
190
|
-
console.log(err.response && err.response.status)
|
|
208
|
+
console.log(err.response && err.response.status);
|
|
191
209
|
} else {
|
|
192
|
-
console.log(err)
|
|
210
|
+
console.log(err);
|
|
193
211
|
}
|
|
194
|
-
await trackingService.sendError(err)
|
|
212
|
+
await trackingService.sendError(err);
|
|
195
213
|
}
|
|
196
214
|
}
|
|
197
215
|
}
|
|
@@ -200,82 +218,87 @@ async function askProjMetadata(target, cmdObj, projectName) {
|
|
|
200
218
|
function createQuestions(projectName) {
|
|
201
219
|
return [
|
|
202
220
|
{
|
|
203
|
-
type:
|
|
204
|
-
name:
|
|
205
|
-
message:
|
|
221
|
+
type: "input",
|
|
222
|
+
name: "name",
|
|
223
|
+
message: "Digite um nome legível para seu eitri-app",
|
|
206
224
|
validate: nameOrTitle,
|
|
207
225
|
default: () => {
|
|
208
|
-
return projectName
|
|
226
|
+
return projectName;
|
|
209
227
|
},
|
|
210
228
|
},
|
|
211
229
|
{
|
|
212
|
-
type:
|
|
213
|
-
name:
|
|
214
|
-
message:
|
|
230
|
+
type: "input",
|
|
231
|
+
name: "title",
|
|
232
|
+
message: "Digite um nome para divulgação",
|
|
215
233
|
validate: nameOrTitle,
|
|
216
234
|
default: () => {
|
|
217
|
-
return projectName
|
|
235
|
+
return projectName;
|
|
218
236
|
},
|
|
219
237
|
},
|
|
220
238
|
{
|
|
221
|
-
type:
|
|
222
|
-
name:
|
|
223
|
-
message:
|
|
239
|
+
type: "input",
|
|
240
|
+
name: "slug",
|
|
241
|
+
message:
|
|
242
|
+
"Digite um nome único para seu eitri-app. Não pode conter espaços",
|
|
224
243
|
default: (currentAnswers) => {
|
|
225
|
-
return slugify(currentAnswers.name).toLowerCase()
|
|
244
|
+
return slugify(currentAnswers.name).toLowerCase();
|
|
226
245
|
},
|
|
227
246
|
validate: slug,
|
|
228
|
-
}
|
|
229
|
-
]
|
|
247
|
+
},
|
|
248
|
+
];
|
|
230
249
|
}
|
|
231
250
|
|
|
232
251
|
async function askSlug(projectName) {
|
|
233
252
|
let answer = await inquirer.prompt([
|
|
234
253
|
{
|
|
235
|
-
type:
|
|
236
|
-
name:
|
|
237
|
-
message:
|
|
254
|
+
type: "input",
|
|
255
|
+
name: "slug",
|
|
256
|
+
message: "Outro nome único para o eitri-app:",
|
|
238
257
|
validate: slug,
|
|
239
258
|
default: () => {
|
|
240
|
-
return slugify(projectName).toLowerCase()
|
|
259
|
+
return slugify(projectName).toLowerCase();
|
|
241
260
|
},
|
|
242
261
|
},
|
|
243
|
-
])
|
|
244
|
-
return answer.slug
|
|
262
|
+
]);
|
|
263
|
+
return answer.slug;
|
|
245
264
|
}
|
|
246
265
|
|
|
247
266
|
async function askName(projectName) {
|
|
248
267
|
let answer = await inquirer.prompt([
|
|
249
268
|
{
|
|
250
|
-
type:
|
|
251
|
-
name:
|
|
252
|
-
message:
|
|
269
|
+
type: "input",
|
|
270
|
+
name: "name",
|
|
271
|
+
message: "Outro nome para o eitri-app:",
|
|
253
272
|
validate: nameOrTitle,
|
|
254
273
|
default: () => {
|
|
255
|
-
return projectName
|
|
274
|
+
return projectName;
|
|
256
275
|
},
|
|
257
276
|
},
|
|
258
|
-
])
|
|
259
|
-
return answer.name
|
|
277
|
+
]);
|
|
278
|
+
return answer.name;
|
|
260
279
|
}
|
|
261
280
|
|
|
262
281
|
/**
|
|
263
|
-
*
|
|
264
|
-
* @param {Target} target
|
|
265
|
-
* @param {*} cmdObj
|
|
282
|
+
*
|
|
283
|
+
* @param {Target} target
|
|
284
|
+
* @param {*} cmdObj
|
|
266
285
|
*/
|
|
267
286
|
function _getBoilerplateUrl(target, cmdObj) {
|
|
268
|
-
const {template} = cmdObj
|
|
269
|
-
if(!template || !target.miniAppBoilerplateList) {
|
|
270
|
-
return target.boilerplateUrl
|
|
287
|
+
const { template } = cmdObj;
|
|
288
|
+
if (!template || !target.miniAppBoilerplateList) {
|
|
289
|
+
return target.boilerplateUrl;
|
|
271
290
|
}
|
|
272
|
-
|
|
273
|
-
const boilerplate = target.miniAppBoilerplateList.find(bp => bp.name === template)
|
|
274
291
|
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
292
|
+
const boilerplate = target.miniAppBoilerplateList.find(
|
|
293
|
+
(bp) => bp.name === template
|
|
294
|
+
);
|
|
295
|
+
|
|
296
|
+
if (!boilerplate) {
|
|
297
|
+
console.error(
|
|
298
|
+
`O template [${template}] não existe para a aplicação que você selecionou.`
|
|
299
|
+
);
|
|
300
|
+
return process.exit(0);
|
|
278
301
|
}
|
|
279
302
|
|
|
280
|
-
return boilerplate.boilerplateUrl
|
|
303
|
+
return boilerplate.boilerplateUrl;
|
|
281
304
|
}
|
package/src/cmd/push-version.js
CHANGED
|
@@ -8,10 +8,13 @@ const config = require('../service/ConfigService')
|
|
|
8
8
|
const TargetService = require('../service/TargetService')
|
|
9
9
|
const inquirer = require('inquirer')
|
|
10
10
|
const TrackingEitriAnalytics = require('../service/TrackingEitriAnalytics')
|
|
11
|
+
const VegvisirService = require('../modules/vegvisir/VegvisirService')
|
|
12
|
+
const getWorkspace = require('../util/getWorkspace')
|
|
11
13
|
|
|
12
14
|
const blindGuardian = workspace.blindGuardian
|
|
13
15
|
const trackingService = new TrackingService(blindGuardian)
|
|
14
16
|
const targetService = new TargetService(workspace)
|
|
17
|
+
const vegvisirService = new VegvisirService()
|
|
15
18
|
|
|
16
19
|
module.exports = async function pushVersion(cmdObj) {
|
|
17
20
|
try {
|
|
@@ -26,7 +29,9 @@ module.exports = async function pushVersion(cmdObj) {
|
|
|
26
29
|
workspace.setResourceFolder2Watch(resourceFolders2watch)
|
|
27
30
|
}
|
|
28
31
|
workspace.publishing = true
|
|
29
|
-
|
|
32
|
+
const miniConf = workspace.getMiniConf()
|
|
33
|
+
await vegvisirService.check(miniConf.slug)
|
|
34
|
+
|
|
30
35
|
let validateResult = checkErros(miniConf)
|
|
31
36
|
|
|
32
37
|
if (!validateResult.isSuccess()) {
|
|
@@ -69,14 +74,18 @@ ${await targetService.getAppConfExampleSnippet()}
|
|
|
69
74
|
workspace.setServerUrl(config.get('workspace').url)
|
|
70
75
|
console.log('Conectando à forja de Eitri')
|
|
71
76
|
await workspace.init()
|
|
72
|
-
await
|
|
77
|
+
const userWorkspace = await getWorkspace()
|
|
78
|
+
await miniLog.connect(userWorkspace.id)
|
|
73
79
|
console.log(separator)
|
|
74
80
|
console.log('Analisando versões')
|
|
81
|
+
await workspace.checkVersions()
|
|
82
|
+
|
|
83
|
+
// Verificar se precisamos dessa parte
|
|
75
84
|
const {target} = await workspace.checkVersions()
|
|
85
|
+
// const {addedPermissions, removedPermissions} = await workspace.comparePermissions(target)
|
|
86
|
+
// await logPermissionsAndOpenPrompt(addedPermissions, removedPermissions, cmdObj)
|
|
87
|
+
// console.log(separator)
|
|
76
88
|
|
|
77
|
-
const {addedPermissions, removedPermissions} = await workspace.comparePermissions(target)
|
|
78
|
-
await logPermissionsAndOpenPrompt(addedPermissions, removedPermissions, cmdObj)
|
|
79
|
-
console.log(separator)
|
|
80
89
|
console.log('Preparando os arquivos do seu eitri-app')
|
|
81
90
|
|
|
82
91
|
await workspace.uploadAll()
|
|
@@ -88,7 +97,7 @@ ${await targetService.getAppConfExampleSnippet()}
|
|
|
88
97
|
|
|
89
98
|
const start = Date.now()
|
|
90
99
|
let pushVersionPromise = miniLog.awaitForPushVersion()
|
|
91
|
-
await workspace.pushVersionAsJson(cmdObj
|
|
100
|
+
await workspace.pushVersionAsJson(cmdObj)
|
|
92
101
|
await pushVersionPromise
|
|
93
102
|
console.log(separator)
|
|
94
103
|
console.log('\x1b[1m\x1b[32mSucesso!!\x1b[0m');
|
|
@@ -136,15 +145,15 @@ function printAvailableWebhooks(webhooks) {
|
|
|
136
145
|
}
|
|
137
146
|
|
|
138
147
|
async function track(miniConf, start) {
|
|
139
|
-
let libs = await targetService.getLibs()
|
|
140
|
-
let event = {
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
}
|
|
147
|
-
await trackingService.sendPushedVersion(event)
|
|
148
|
+
// let libs = await targetService.getLibs()
|
|
149
|
+
// let event = {
|
|
150
|
+
// superClientVersion: miniConf[libs.superAppClientLibName],
|
|
151
|
+
// componentsVersion: miniConf[libs.componentsLibName],
|
|
152
|
+
// miniAppSlug: miniConf.slug,
|
|
153
|
+
// miniAppVersion: miniConf.version,
|
|
154
|
+
// timeMs: Date.now() - start,
|
|
155
|
+
// }
|
|
156
|
+
// await trackingService.sendPushedVersion(event)
|
|
148
157
|
}
|
|
149
158
|
|
|
150
159
|
function checkErros(miniConf) {
|
package/src/cmd/start.js
CHANGED
|
@@ -11,11 +11,14 @@ const config = require('../service/ConfigService')
|
|
|
11
11
|
const handleStartServer = require('../service/StarterService')
|
|
12
12
|
const inquirer = require('inquirer')
|
|
13
13
|
const TrackingEitriAnalytics = require('../service/TrackingEitriAnalytics')
|
|
14
|
+
const VegvisirService = require('../modules/vegvisir/VegvisirService')
|
|
15
|
+
const getWorkspace = require('../util/getWorkspace')
|
|
14
16
|
|
|
15
17
|
const blindGuardian = workspace.blindGuardian
|
|
16
18
|
const hashFolder = workspace.hashFolder
|
|
17
19
|
const trackingService = new TrackingService(blindGuardian, { ignoreCredentialError: true })
|
|
18
20
|
const watcher = new Watcher(workspace, hashFolder, trackingService)
|
|
21
|
+
const vegvisirService = new VegvisirService()
|
|
19
22
|
|
|
20
23
|
module.exports = async function start(args) {
|
|
21
24
|
try {
|
|
@@ -32,6 +35,9 @@ module.exports = async function start(args) {
|
|
|
32
35
|
if (fs.existsSync(resourceFolders2watch)) {
|
|
33
36
|
workspace.setResourceFolder2Watch(resourceFolders2watch)
|
|
34
37
|
}
|
|
38
|
+
|
|
39
|
+
const miniConf = workspace.getMiniConf()
|
|
40
|
+
await vegvisirService.check(miniConf.slug)
|
|
35
41
|
|
|
36
42
|
const url = config.get('workspace').url
|
|
37
43
|
const setupResult = await workspace.setup()
|
|
@@ -61,7 +67,8 @@ module.exports = async function start(args) {
|
|
|
61
67
|
workspace.setQrCodeUrl(qrCodeUrl)
|
|
62
68
|
await workspace.init()
|
|
63
69
|
const silentOnConnect = args.verbose ? false : true
|
|
64
|
-
await
|
|
70
|
+
const userWorkspace = await getWorkspace()
|
|
71
|
+
await miniLog.connect(userWorkspace.id, silentOnConnect)
|
|
65
72
|
|
|
66
73
|
// TODO EITRI: descomentar apos publicacao das libs no npm
|
|
67
74
|
// setupResult.state.libs.forEach(lib => {
|
|
@@ -140,10 +147,10 @@ module.exports = async function start(args) {
|
|
|
140
147
|
}
|
|
141
148
|
|
|
142
149
|
async function askTargetConfig(args, target) {
|
|
143
|
-
const
|
|
150
|
+
const availableConfigs = await workspace.getTargetConfig(args.targetConfig, target)
|
|
144
151
|
|
|
145
|
-
console.log(`Utilizando configuração: ${
|
|
146
|
-
return
|
|
152
|
+
console.log(`Utilizando configuração: ${availableConfigs[0].id}`)
|
|
153
|
+
return availableConfigs[0]
|
|
147
154
|
|
|
148
155
|
}
|
|
149
156
|
|
|
@@ -153,19 +160,19 @@ async function getDefaultTargetConfig(target) {
|
|
|
153
160
|
}
|
|
154
161
|
|
|
155
162
|
async function listTargetConfigs(target) {
|
|
156
|
-
const
|
|
163
|
+
const availableConfigs = await workspace.getAllTargetConfigs(target)
|
|
157
164
|
|
|
158
|
-
const
|
|
165
|
+
const availableConfigsIds = availableConfigs.map(config => config.id)
|
|
159
166
|
|
|
160
167
|
const res = await inquirer.prompt([
|
|
161
168
|
{
|
|
162
169
|
name: 'accepted',
|
|
163
170
|
type: 'rawlist',
|
|
164
171
|
message: 'Configurações disponíveis:',
|
|
165
|
-
choices:
|
|
172
|
+
choices: availableConfigsIds
|
|
166
173
|
}
|
|
167
174
|
]).then(input => input)
|
|
168
175
|
|
|
169
|
-
const config =
|
|
176
|
+
const config = availableConfigs.find(cfg => cfg.id === res.accepted)
|
|
170
177
|
console.log(`Utilize o comando --target-config ${config.id} para iniciar o miniapp com a configuração desejada`)
|
|
171
178
|
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
const commander = require("commander");
|
|
2
|
+
|
|
3
|
+
module.exports = function VegvisirCommand() {
|
|
4
|
+
const workspaceCommand = commander.command("workspace");
|
|
5
|
+
workspaceCommand
|
|
6
|
+
.command("list")
|
|
7
|
+
.description("Lista os workspaces do usuário")
|
|
8
|
+
.action(async (cmdObj) => {
|
|
9
|
+
require("./cmd/list")(cmdObj);
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
workspaceCommand
|
|
13
|
+
.command("use")
|
|
14
|
+
.description("Seleciona qual workspace a ser utilizado")
|
|
15
|
+
.option(
|
|
16
|
+
"--local",
|
|
17
|
+
"Seleciona um workspace para um diretório de Eitri-App específico"
|
|
18
|
+
)
|
|
19
|
+
.action(async (cmdObj) => {
|
|
20
|
+
require("./cmd/use.js")(cmdObj);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
workspaceCommand
|
|
24
|
+
.command("create")
|
|
25
|
+
.description("Cria um workspace para desenvolvimento de Eitri-Apps")
|
|
26
|
+
.action((cmdObj) => {
|
|
27
|
+
require("./cmd/create")(cmdObj);
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
workspaceCommand
|
|
31
|
+
.command("current")
|
|
32
|
+
.description("Exibe o workspace atual, obedecendo a prioridade Local > Global.")
|
|
33
|
+
.action((cmdObj) => {
|
|
34
|
+
require("./cmd/current")(cmdObj);
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
return workspaceCommand;
|
|
38
|
+
};
|