eitri-cli 1.7.0-beta.2 → 1.7.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eitri-cli",
3
- "version": "1.7.0-beta.2",
3
+ "version": "1.7.0",
4
4
  "description": "Command Line Interface to make \"Eitri-App\" with code and fire.",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -19,6 +19,7 @@ const vegvisirService = new VegvisirService()
19
19
  const standardVersion = require('standard-version')
20
20
  const releaseService = require('../service/ReleaseService')
21
21
  const {isGitRepo} = require('../util/GenericUtils')
22
+ const debug = require('debug')('eitri:pushVersion')
22
23
 
23
24
  module.exports = async function pushVersion(cmdObj) {
24
25
  try {
@@ -29,6 +30,9 @@ module.exports = async function pushVersion(cmdObj) {
29
30
  return
30
31
  }
31
32
 
33
+ const {slug: miniConfSlug} = workspace.getMiniConf()
34
+ await vegvisirService.isCurrentWorkspaceOwnedByUser(miniConfSlug)
35
+
32
36
  const separator = '======================================================================='
33
37
 
34
38
  try {
package/src/cmd/start.js CHANGED
@@ -16,11 +16,14 @@ const blindGuardian = workspace.blindGuardian
16
16
  const hashFolder = workspace.hashFolder
17
17
  const trackingService = new TrackingService(blindGuardian, { ignoreCredentialError: true })
18
18
  const watcher = new Watcher(workspace, hashFolder, trackingService)
19
- const vegvisirService = new VegvisirService()
19
+ const vegvisirService = new VegvisirService(workspace)
20
20
  const debug = require('debug')('eitri:start')
21
21
 
22
22
  module.exports = async function start(args) {
23
23
  debug("Iniciando start()")
24
+ const miniConf = workspace.getMiniConf()
25
+
26
+ await vegvisirService.isCurrentWorkspaceOwnedByUser(miniConf.slug)
24
27
 
25
28
  const separator = '======================================================================='
26
29
  let displayFriendlyErrorAtEnd = ""
@@ -48,7 +51,6 @@ module.exports = async function start(args) {
48
51
  workspace.setResourceFolder2Watch(resourceFolders2watch)
49
52
  }
50
53
 
51
- const miniConf = workspace.getMiniConf()
52
54
  await vegvisirService.check(miniConf.slug)
53
55
  debug("Fim da busca e validação do EitriAppConf", {miniConf})
54
56
 
@@ -9,6 +9,8 @@ const {validateUUID} = require("../../util/GenericUtils");
9
9
  const path = require("path");
10
10
  const fs = require('fs')
11
11
  const debug = require('debug')('eitri:VegvisirService')
12
+ const inquirer = require("inquirer");
13
+ const chalk = require("chalk");
12
14
 
13
15
  module.exports = class VegvisirService {
14
16
  constructor() {
@@ -134,4 +136,57 @@ module.exports = class VegvisirService {
134
136
  return process.exit(1)
135
137
  }
136
138
  };
139
+
140
+ async isCurrentWorkspaceOwnedByUser(slug = "") {
141
+ const localWorkspace = await this.getWorkspace()
142
+ if (!localWorkspace?.id) {
143
+ return
144
+ }
145
+
146
+ const workspacesRemote = await this.listMyWorkspaces()
147
+
148
+ const isOwner = workspacesRemote.find(w => w?.id === localWorkspace?.id)
149
+ if (isOwner) return
150
+
151
+ debug("Workspace local é diferente do remoto para esse usuário", {localWorkspace, workspacesRemote})
152
+
153
+ const reseted = await this.redefineWorkspace(slug)
154
+ if (reseted) return debug("Workspace validado com sucesso. Continuando...")
155
+
156
+ console.log("Parece que você está usando um workspace de outro usuário. Como não foi redefinido, não podemos prosseguir.")
157
+ process.exit(1)
158
+ };
159
+
160
+ async redefineWorkspace(slug = "") {
161
+ const question1 = "\n Deseja redefinir o seu workspace?"
162
+ const question2 = chalk.italic(" O workspace atual pertence a outro usuário, portanto, é necessária a redefinição.")
163
+ const question3 = chalk.italic(" Atenção! A redefinição do workspace poderá acarretar na alteração do tema.")
164
+
165
+ const res = await inquirer.prompt([
166
+ {
167
+ name: "confirm",
168
+ type: "confirm",
169
+ message:
170
+ question1 + "\n" + question2 + "\n" + question3 + "\n",
171
+ default: true,
172
+ },
173
+ ]);
174
+
175
+ if (res.confirm) {
176
+ const workspaceGlobalPath = path.resolve(
177
+ os.homedir(),
178
+ ".eitri",
179
+ "workspaces",
180
+ "workspace"
181
+ );
182
+
183
+ if (fs.existsSync(workspaceGlobalPath)) {
184
+ fs.unlinkSync(workspaceGlobalPath);
185
+ }
186
+
187
+ await this.check(slug)
188
+ }
189
+
190
+ return res.confirm
191
+ }
137
192
  };
@@ -1,5 +1,6 @@
1
1
  const util = require('util');
2
2
  const exec = util.promisify(require("child_process").exec)
3
+ const inquirer = require("inquirer");
3
4
 
4
5
  module.exports = class IOSEmulatorService {
5
6