eitri-cli 1.7.0-beta.5 → 1.7.0-beta.6
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
package/src/cmd/push-version.js
CHANGED
|
@@ -8,27 +8,19 @@ 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 UserLocalCredential = require('../util/UserLocalCredential')
|
|
12
11
|
const VegvisirService = require('../modules/vegvisir/VegvisirService')
|
|
13
12
|
const {randomUUID} = require('crypto')
|
|
14
13
|
const childProcess = require('child_process')
|
|
15
14
|
const blindGuardian = workspace.blindGuardian
|
|
16
|
-
const trackingService = new TrackingService(blindGuardian)
|
|
17
15
|
const targetService = new TargetService(workspace)
|
|
18
16
|
const vegvisirService = new VegvisirService()
|
|
19
|
-
const standardVersion = require('standard-version')
|
|
20
17
|
const releaseService = require('../service/ReleaseService')
|
|
21
18
|
const {isGitRepo} = require('../util/GenericUtils')
|
|
22
|
-
const
|
|
19
|
+
const PrerequisitesValidator = require('../service/PrerequisitesValidator')
|
|
20
|
+
const prerequisitesValidator = new PrerequisitesValidator(workspace)
|
|
23
21
|
|
|
24
22
|
module.exports = async function pushVersion(cmdObj) {
|
|
25
|
-
|
|
26
|
-
UserLocalCredential.checkForCredentials()
|
|
27
|
-
} catch (error) {
|
|
28
|
-
const errorMessage = cmdObj?.verbose ? error : error?.message
|
|
29
|
-
console.error("\n", errorMessage, "\n")
|
|
30
|
-
return
|
|
31
|
-
}
|
|
23
|
+
prerequisitesValidator.checkCredentials()
|
|
32
24
|
|
|
33
25
|
const {slug: miniConfSlug} = workspace.getMiniConf()
|
|
34
26
|
await vegvisirService.isCurrentWorkspaceOwnedByUser(miniConfSlug)
|
package/src/cmd/start.js
CHANGED
|
@@ -9,13 +9,14 @@ const config = require('../service/ConfigService')
|
|
|
9
9
|
const handleStartServer = require('../service/StarterService')
|
|
10
10
|
const TrackingEitriAnalytics = require('../service/TrackingEitriAnalytics')
|
|
11
11
|
const VegvisirService = require('../modules/vegvisir/VegvisirService')
|
|
12
|
-
const
|
|
12
|
+
const PrerequisitesValidator = require('../service/PrerequisitesValidator')
|
|
13
13
|
|
|
14
14
|
const blindGuardian = workspace.blindGuardian
|
|
15
15
|
const hashFolder = workspace.hashFolder
|
|
16
16
|
const trackingService = new TrackingService(blindGuardian, { ignoreCredentialError: true })
|
|
17
17
|
const watcher = new Watcher(workspace, hashFolder, trackingService)
|
|
18
18
|
const vegvisirService = new VegvisirService(workspace)
|
|
19
|
+
const prerequisitesValidator = new PrerequisitesValidator(workspace)
|
|
19
20
|
const debug = require('debug')('eitri:start')
|
|
20
21
|
|
|
21
22
|
module.exports = async function start(args) {
|
|
@@ -27,15 +28,7 @@ module.exports = async function start(args) {
|
|
|
27
28
|
const separator = '======================================================================='
|
|
28
29
|
let displayFriendlyErrorAtEnd = ""
|
|
29
30
|
|
|
30
|
-
|
|
31
|
-
UserLocalCredential.checkForCredentials()
|
|
32
|
-
debug("Successo na checagem de credenciais")
|
|
33
|
-
} catch (error) {
|
|
34
|
-
debug("ERRO na checagem de credenciais", {message: error?.message, error})
|
|
35
|
-
const errorMessage = args?.verbose ? error : error?.message
|
|
36
|
-
console.error("\n", errorMessage, "\n")
|
|
37
|
-
return
|
|
38
|
-
}
|
|
31
|
+
await prerequisitesValidator.checkAll()
|
|
39
32
|
|
|
40
33
|
try {
|
|
41
34
|
if (!args.force) {
|
|
@@ -125,7 +125,7 @@ module.exports = class VegvisirService {
|
|
|
125
125
|
);
|
|
126
126
|
const fileContent = await readFile(workspaceGlobalPath, "utf8");
|
|
127
127
|
const workspace = JSON.parse(fileContent);
|
|
128
|
-
console.log(
|
|
128
|
+
console.log(`Construindo para o Workspace [${workspace.id}]`)
|
|
129
129
|
workspace.id = validateUUID(this.workspaceId) ? this.workspaceId : workspace.id;
|
|
130
130
|
return workspace;
|
|
131
131
|
} catch (error) {
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
const configService = require('./ConfigService')
|
|
2
|
+
const UserLocalCredential = require('../util/UserLocalCredential');
|
|
3
|
+
const Http = require('./Http');
|
|
4
|
+
const TrackingEitriAnalytics = require('./TrackingEitriAnalytics');
|
|
5
|
+
const MANAGER_URL = configService.get('eitriManager')?.url
|
|
6
|
+
const {workspace} = require('../service/Workspace')
|
|
7
|
+
const debug = require('debug')('eitri:PrerequisitesValidator')
|
|
8
|
+
class PrerequisitesValidator {
|
|
9
|
+
|
|
10
|
+
constructor(workspace) {
|
|
11
|
+
this.workspace = workspace
|
|
12
|
+
this.blindGuardian = workspace.blindGuardian;
|
|
13
|
+
this.http = new Http(workspace.blindGuardian);
|
|
14
|
+
this.userInfo = {id: "", email: ""}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
async checkAll() {
|
|
18
|
+
this.checkCredentials()
|
|
19
|
+
await this.isUserInOrg()
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
checkCredentials() {
|
|
23
|
+
try {
|
|
24
|
+
UserLocalCredential.checkForCredentials()
|
|
25
|
+
debug("Successo na checagem de credenciais")
|
|
26
|
+
} catch (error) {
|
|
27
|
+
this.sendErrorToAnalytics("checkCredentials.error", error)
|
|
28
|
+
|
|
29
|
+
debug("ERRO na checagem de credenciais", {message: error?.message, error})
|
|
30
|
+
console.error("\nError: ", {message: error?.message, error})
|
|
31
|
+
process.exit(1);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
async isUserInOrg() {
|
|
36
|
+
const eitriAppConf = workspace.getMiniConf();
|
|
37
|
+
|
|
38
|
+
const respEitriAppData = await this.http.get(`${MANAGER_URL}/v2/eitri-apps/${eitriAppConf.id}`);
|
|
39
|
+
const respMyOrgsData = await this.http.get(`${MANAGER_URL}/users/me/organizations`);
|
|
40
|
+
|
|
41
|
+
const belongTo = respMyOrgsData?.some(org => org?.id === respEitriAppData?.organizationId)
|
|
42
|
+
const myOrgs = respMyOrgsData?.length > 0
|
|
43
|
+
if (myOrgs && belongTo) {
|
|
44
|
+
return
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
this.sendErrorToAnalytics("isUserInOrg.error", {confOrgId: respEitriAppData.organizationId, organizations: respMyOrgsData})
|
|
48
|
+
|
|
49
|
+
const friendlyErrorMessage = `Você ainda não foi registrado em nenhuma organização. Por favor, entre em contato com o administrador da sua organização.`
|
|
50
|
+
console.log(`\n\x1b[1m\x1b[31m ${friendlyErrorMessage} \x1b[0m\n`)
|
|
51
|
+
process.exit(1)
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
async getUserBasicInfo() {
|
|
55
|
+
if (this.userInfo.id && this.userInfo.email) {
|
|
56
|
+
return this.userInfo
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const token = await this.blindGuardian.getToken().then(res => res).catch(_err => null)
|
|
60
|
+
this.userInfo = {
|
|
61
|
+
id: token?.id || "",
|
|
62
|
+
email: token?.email || ""
|
|
63
|
+
}
|
|
64
|
+
return {
|
|
65
|
+
id: token?.id || "",
|
|
66
|
+
email: token?.email || ""
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
sendErrorToAnalytics(eventName = "", data = {}) {
|
|
72
|
+
TrackingEitriAnalytics.sendEvent({
|
|
73
|
+
eventName,
|
|
74
|
+
userId: this.userInfo.id,
|
|
75
|
+
data: {
|
|
76
|
+
userData: this.userInfo,
|
|
77
|
+
...data
|
|
78
|
+
}
|
|
79
|
+
}).catch(_err => null)
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
module.exports = PrerequisitesValidator
|
package/src/service/Workspace.js
CHANGED
|
@@ -239,10 +239,10 @@ class Workspace {
|
|
|
239
239
|
if (m) {
|
|
240
240
|
version = m[1];
|
|
241
241
|
}
|
|
242
|
-
libVersionsOutput += ` ${lib.name} [${version}]
|
|
242
|
+
libVersionsOutput += ` ${lib.name} [${version}]`;
|
|
243
243
|
}
|
|
244
244
|
});
|
|
245
|
-
console.log(libVersionsOutput);
|
|
245
|
+
console.log("\n",libVersionsOutput, "\n");
|
|
246
246
|
}
|
|
247
247
|
|
|
248
248
|
async checkVersions() {
|