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/src/cmd/create.js CHANGED
@@ -1,197 +1,215 @@
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')
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('../model/Target')
16
- const TrackingEitriAnalytics = require('../service/TrackingEitriAnalytics')
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, { ignoreCredentialError: true })
22
- const watcher = new Watcher(workspace, hashFolder, trackingService)
23
- const ITEM_DOUBT = 'DOUBTS'
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 'Não pode ficar em branco'
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 'Não use caracteres especiais'
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 'Não use caracteres especiais'
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('\x1b[34mVamos criar o seu eitri-app. Para isso basta responder algumas perguntas:\x1b[0m');
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('workspace').url
53
- workspace.setServerUrl(url)
54
- const platform = await askProjectPlatform()
55
- if(platform.name === ITEM_DOUBT){
56
- handleStartServer(cmdObj, trackingService, watcher, workspace, platform.name )
57
- return
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
- const res = await askProjMetadata(platform, cmdObj, projectName)
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
- async function askProjectPlatform() {
81
-
82
- const defaultTarget = await workspace.getDefaultTarget();
83
- const availableTargets = await workspace.availableTargets() || workspace.getKnownAvailableTargets()
84
- if(availableTargets.length <= 0) {
85
- console.log("Sua organização não contém nenhuma aplicação disponível para prosseguir com a criação.")
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 = [...availableTargets, { name: ITEM_DOUBT, label: 'Dúvidas? Veja documentação no browser'}]
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
- let organizationLabel = tgt.organizationName || tgt.organizationId
95
- if(tgt.organization) {
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: 'accepted',
105
- type: 'rawlist',
106
- message: 'Selecione a aplicação para qual destina-se seu eitri-app:',
107
- choices: cliOptions.map(createLabel)
108
- }
109
- ])
110
- const target = cliOptions.find(tgt => createLabel(tgt) === res.accepted)
111
-
112
- target.onSelected && target.onSelected()
113
- return target
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(target, cmdObj, projectName) {
117
- const factory = getCreateFactory(target.platform)
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 = {...answers, organization: {id: target.organizationId}}
136
- delete conf.organizationName
137
-
138
- let keepGoing = true
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(target, cmdObj)
150
+ const selectedTemplate = _getBoilerplateUrl(
151
+ clientApplication,
152
+ cmdObj
153
+ );
154
+ cmdObj.verbose &&
155
+ console.log(`Usando template ${selectedTemplate}`);
148
156
 
149
-
150
- cmdObj.verbose && console.log(`Usando template ${selectedTemplate}`)
151
-
152
- let templateProject = await factory.create(projectName, selectedTemplate, target)
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 miniAppRequest = {...conf, target: target.name}
156
-
157
- // Cria no banco no final das configs locais
158
- const miniApp = await workspace.create(miniAppRequest)
164
+ const eitriAppToCreate = {
165
+ ...conf,
166
+ organizationId: clientApplication.organization.id,
167
+ applicationId: clientApplication.id,
168
+ };
159
169
 
160
- conf['public-key'] = miniApp.publicKey
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 templateMiniAppConf = templateProject.structure.miniAppConf
175
+ const templateEitriAppConf =
176
+ templateProject?.structure?.eitriAppConf;
163
177
 
164
178
  const finalConf = {
165
- ...templateMiniAppConf,
166
- ...conf
167
- }
168
-
169
- await factory.writeAmeConf(templateProject, finalConf)
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('Houve uma falha durante a criação do eitri-app', err)
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 === 'name') {
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 === 'slug') {
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: 'input',
204
- name: 'name',
205
- message: 'Digite um nome legível para seu eitri-app',
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: 'input',
213
- name: 'title',
214
- message: 'Digite um nome para divulgação',
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: 'input',
222
- name: 'slug',
223
- message: 'Digite um nome único para seu eitri-app. Não pode conter espaços',
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: 'input',
236
- name: 'slug',
237
- message: 'Outro nome único para o eitri-app:',
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: 'input',
251
- name: 'name',
252
- message: 'Outro nome para o eitri-app:',
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
- if(!boilerplate) {
276
- console.error(`O template [${template}] não existe para a aplicação que você selecionou.`)
277
- return process.exit(0)
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
  }
@@ -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
- let miniConf = workspace.getMiniConf()
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 miniLog.connect(workspace.userEmail)
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.message)
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
- superClientVersion: miniConf[libs.superAppClientLibName],
142
- componentsVersion: miniConf[libs.componentsLibName],
143
- miniAppSlug: miniConf.slug,
144
- miniAppVersion: miniConf.version,
145
- timeMs: Date.now() - start,
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 miniLog.connect(workspace.userEmail, silentOnConnect)
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 avaiableConfigs = await workspace.getTargetConfig(args.targetConfig, target)
150
+ const availableConfigs = await workspace.getTargetConfig(args.targetConfig, target)
144
151
 
145
- console.log(`Utilizando configuração: ${avaiableConfigs[0].id}`)
146
- return avaiableConfigs[0]
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 avaiableConfigs = await workspace.getAllTargetConfigs(target)
163
+ const availableConfigs = await workspace.getAllTargetConfigs(target)
157
164
 
158
- const avaiableConfigsIds = avaiableConfigs.map(config => config.id)
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: avaiableConfigsIds
172
+ choices: availableConfigsIds
166
173
  }
167
174
  ]).then(input => input)
168
175
 
169
- const config = avaiableConfigs.find(cfg => cfg.id === res.accepted)
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
+ };