eitri-cli 1.0.4 → 1.1.0-beta

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,214 @@
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
+ return `${tgt.label || tgt.name} (${tgt.organization?.name})`;
97
+ };
101
98
 
102
99
  const res = await inquirer.prompt([
103
100
  {
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
101
+ name: "accepted",
102
+ type: "rawlist",
103
+ message:
104
+ "Selecione a aplicação para qual destina-se seu eitri-app:",
105
+ choices: cliOptions.map(createLabel),
106
+ },
107
+ ]);
108
+ const clientApplication = cliOptions.find(
109
+ (tgt) => createLabel(tgt) === res.accepted
110
+ );
111
+ clientApplication.onSelected && clientApplication.onSelected();
112
+ return clientApplication;
114
113
  }
115
114
 
116
- async function askProjMetadata(target, cmdObj, projectName) {
117
- const factory = getCreateFactory(target.platform)
118
- let questions = createQuestions(projectName)
115
+ async function askProjMetadata(clientApplication, cmdObj, projectName) {
116
+ const factory = new WoodCoffee();
117
+ let questions = createQuestions(projectName);
119
118
  try {
120
- await workspace.init()
119
+ await workspace.init();
121
120
  } catch (e) {
122
- console.log(e.message)
123
- return
121
+ console.log(e.message);
122
+ return;
124
123
  }
125
- let answers
124
+ let answers;
126
125
  if (cmdObj.yes) {
127
126
  answers = {
128
127
  name: projectName,
129
128
  title: projectName,
130
- slug: projectName
131
- }
129
+ slug: projectName,
130
+ };
132
131
  } else {
133
- answers = await inquirer.prompt(questions)
132
+ answers = await inquirer.prompt(questions);
134
133
  }
135
- let conf = {...answers, organization: {id: target.organizationId}}
136
- delete conf.organizationName
137
-
138
- let keepGoing = true
134
+ let conf = {
135
+ ...answers,
136
+ organization: { id: clientApplication.organizationId },
137
+ };
138
+ delete conf.organizationName;
139
+
140
+ let keepGoing = true;
139
141
  while (keepGoing) {
140
142
  try {
141
- keepGoing = false
142
- await factory.verifyFolder(projectName, {supressLog: true})
143
+ keepGoing = false;
144
+ await factory.verifyFolder(projectName, { supressLog: true });
143
145
 
144
146
  // Comentado até implementarmos os múltiplos boilerplates nos targets do banco
145
147
  //const {template} = cmdObj
146
148
 
147
- const selectedTemplate = _getBoilerplateUrl(target, cmdObj)
149
+ const selectedTemplate = _getBoilerplateUrl(
150
+ clientApplication,
151
+ cmdObj
152
+ );
153
+ cmdObj.verbose &&
154
+ console.log(`Usando template ${selectedTemplate}`);
148
155
 
149
-
150
- cmdObj.verbose && console.log(`Usando template ${selectedTemplate}`)
151
-
152
- let templateProject = await factory.create(projectName, selectedTemplate, target)
156
+ let templateProject = await factory.create(
157
+ projectName,
158
+ selectedTemplate,
159
+ clientApplication
160
+ );
153
161
 
154
162
  // 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)
163
+ const eitriAppToCreate = {
164
+ ...conf,
165
+ organizationId: clientApplication.organization.id,
166
+ applicationId: clientApplication.id,
167
+ };
159
168
 
160
- conf['public-key'] = miniApp.publicKey
169
+ // Cria no banco no final das configs locais
170
+ const eitriApp = await eitriAppManager.create(eitriAppToCreate);
171
+ conf["id"] = eitriApp.id;
172
+ conf["public-key"] = eitriApp.publicKey;
161
173
 
162
- const templateMiniAppConf = templateProject.structure.miniAppConf
174
+ const templateEitriAppConf =
175
+ templateProject?.structure?.eitriAppConf;
163
176
 
164
177
  const finalConf = {
165
- ...templateMiniAppConf,
166
- ...conf
167
- }
168
-
169
- await factory.writeAmeConf(templateProject, finalConf)
178
+ ...templateEitriAppConf,
179
+ ...conf,
180
+ organizationId: clientApplication.organization.id,
181
+ applicationId: clientApplication.id,
182
+ };
170
183
 
184
+ await factory.writeEitriAppConf(templateProject, finalConf);
171
185
  } catch (err) {
172
- if(cmdObj.verbose) {
173
- console.error('Houve uma falha durante a criação do eitri-app', err)
186
+ if (cmdObj.verbose) {
187
+ console.error(
188
+ "Houve uma falha durante a criação do eitri-app",
189
+ err
190
+ );
174
191
  }
175
192
 
176
193
  if (err.isDuplicatedError) {
177
194
  if (cmdObj.yes) {
178
- process.exit(1)
195
+ process.exit(1);
179
196
  }
180
- if (err.field === 'name') {
181
- keepGoing = true
182
- conf.name = await askName(projectName)
197
+ if (err.field === "name") {
198
+ keepGoing = true;
199
+ conf.name = await askName(projectName);
183
200
  }
184
- if (err.field === 'slug') {
185
- keepGoing = true
186
- conf.slug = await askSlug(projectName)
201
+ if (err.field === "slug") {
202
+ keepGoing = true;
203
+ conf.slug = await askSlug(projectName);
187
204
  }
188
205
  } else {
189
206
  if (err.isAxiosError) {
190
- console.log(err.response && err.response.status)
207
+ console.log(err.response && err.response.status);
191
208
  } else {
192
- console.log(err)
209
+ console.log(err);
193
210
  }
194
- await trackingService.sendError(err)
211
+ await trackingService.sendError(err);
195
212
  }
196
213
  }
197
214
  }
@@ -200,82 +217,87 @@ async function askProjMetadata(target, cmdObj, projectName) {
200
217
  function createQuestions(projectName) {
201
218
  return [
202
219
  {
203
- type: 'input',
204
- name: 'name',
205
- message: 'Digite um nome legível para seu eitri-app',
220
+ type: "input",
221
+ name: "name",
222
+ message: "Digite um nome legível para seu eitri-app",
206
223
  validate: nameOrTitle,
207
224
  default: () => {
208
- return projectName
225
+ return projectName;
209
226
  },
210
227
  },
211
228
  {
212
- type: 'input',
213
- name: 'title',
214
- message: 'Digite um nome para divulgação',
229
+ type: "input",
230
+ name: "title",
231
+ message: "Digite um nome para divulgação",
215
232
  validate: nameOrTitle,
216
233
  default: () => {
217
- return projectName
234
+ return projectName;
218
235
  },
219
236
  },
220
237
  {
221
- type: 'input',
222
- name: 'slug',
223
- message: 'Digite um nome único para seu eitri-app. Não pode conter espaços',
238
+ type: "input",
239
+ name: "slug",
240
+ message:
241
+ "Digite um nome único para seu eitri-app. Não pode conter espaços",
224
242
  default: (currentAnswers) => {
225
- return slugify(currentAnswers.name).toLowerCase()
243
+ return slugify(currentAnswers.name).toLowerCase();
226
244
  },
227
245
  validate: slug,
228
- }
229
- ]
246
+ },
247
+ ];
230
248
  }
231
249
 
232
250
  async function askSlug(projectName) {
233
251
  let answer = await inquirer.prompt([
234
252
  {
235
- type: 'input',
236
- name: 'slug',
237
- message: 'Outro nome único para o eitri-app:',
253
+ type: "input",
254
+ name: "slug",
255
+ message: "Outro nome único para o eitri-app:",
238
256
  validate: slug,
239
257
  default: () => {
240
- return slugify(projectName).toLowerCase()
258
+ return slugify(projectName).toLowerCase();
241
259
  },
242
260
  },
243
- ])
244
- return answer.slug
261
+ ]);
262
+ return answer.slug;
245
263
  }
246
264
 
247
265
  async function askName(projectName) {
248
266
  let answer = await inquirer.prompt([
249
267
  {
250
- type: 'input',
251
- name: 'name',
252
- message: 'Outro nome para o eitri-app:',
268
+ type: "input",
269
+ name: "name",
270
+ message: "Outro nome para o eitri-app:",
253
271
  validate: nameOrTitle,
254
272
  default: () => {
255
- return projectName
273
+ return projectName;
256
274
  },
257
275
  },
258
- ])
259
- return answer.name
276
+ ]);
277
+ return answer.name;
260
278
  }
261
279
 
262
280
  /**
263
- *
264
- * @param {Target} target
265
- * @param {*} cmdObj
281
+ *
282
+ * @param {Target} target
283
+ * @param {*} cmdObj
266
284
  */
267
285
  function _getBoilerplateUrl(target, cmdObj) {
268
- const {template} = cmdObj
269
- if(!template || !target.miniAppBoilerplateList) {
270
- return target.boilerplateUrl
286
+ const { template } = cmdObj;
287
+ if (!template || !target.miniAppBoilerplateList) {
288
+ return target.boilerplateUrl;
271
289
  }
272
-
273
- const boilerplate = target.miniAppBoilerplateList.find(bp => bp.name === template)
274
290
 
275
- if(!boilerplate) {
276
- console.error(`O template [${template}] não existe para a aplicação que você selecionou.`)
277
- return process.exit(0)
291
+ const boilerplate = target.miniAppBoilerplateList.find(
292
+ (bp) => bp.name === template
293
+ );
294
+
295
+ if (!boilerplate) {
296
+ console.error(
297
+ `O template [${template}] não existe para a aplicação que você selecionou.`
298
+ );
299
+ return process.exit(0);
278
300
  }
279
301
 
280
- return boilerplate.boilerplateUrl
302
+ return boilerplate.boilerplateUrl;
281
303
  }
@@ -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
+ };