eitri-cli 1.7.0-beta.5 → 1.7.0-beta.7
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/index.js +7 -0
- package/package.json +1 -1
- package/src/cmd/doctor.js +70 -0
- package/src/cmd/push-version.js +5 -12
- package/src/cmd/start.js +4 -12
- package/src/modules/vegvisir/VegvisirService.js +1 -1
- package/src/service/CliLogin.js +5 -0
- package/src/service/PrerequisitesValidator.js +84 -0
- package/src/service/Workspace.js +2 -2
package/index.js
CHANGED
|
@@ -125,6 +125,13 @@ const run = async () => {
|
|
|
125
125
|
require("./src/cmd/eitriLibs")(cmdObj);
|
|
126
126
|
});
|
|
127
127
|
|
|
128
|
+
program
|
|
129
|
+
.command("doctor")
|
|
130
|
+
.description("Valida as dependências externas para execução da CLI do Eitri")
|
|
131
|
+
.action((cmdObj) => {
|
|
132
|
+
require("./src/cmd/doctor")(cmdObj);
|
|
133
|
+
});
|
|
134
|
+
|
|
128
135
|
program.addCommand(VegvisirCommand());
|
|
129
136
|
|
|
130
137
|
if (
|
package/package.json
CHANGED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
const child_process = require("child_process");
|
|
2
|
+
const chalk = require("chalk");
|
|
3
|
+
const exec = child_process.exec;
|
|
4
|
+
const os = require("os");
|
|
5
|
+
module.exports = function () {
|
|
6
|
+
console.log("Checando dependências externas do Eitri CLI.\n");
|
|
7
|
+
checkGitDependency();
|
|
8
|
+
adbDependency();
|
|
9
|
+
xcodeCLIDependency();
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
const checkGitDependency = () => {
|
|
13
|
+
exec("git -v", (error, _, stderr) => {
|
|
14
|
+
if (error) {
|
|
15
|
+
console.log(
|
|
16
|
+
`[${chalk.red(
|
|
17
|
+
"✘"
|
|
18
|
+
)}] GIT. Para instalar basta acessar o link e seguir a documentação: https://git-scm.com/`
|
|
19
|
+
);
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
if (stderr) {
|
|
23
|
+
console.log(
|
|
24
|
+
`[✘] GIT. Para instalar basta acessar o link e seguir a documentação: https://git-scm.com/`
|
|
25
|
+
);
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
console.log(`[${chalk.green("✔")}] GIT`);
|
|
29
|
+
});
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const adbDependency = () => {
|
|
33
|
+
exec("adb version", (error, _, stderr) => {
|
|
34
|
+
if (error) {
|
|
35
|
+
console.log(
|
|
36
|
+
`[${chalk.red(
|
|
37
|
+
"✘"
|
|
38
|
+
)}] ADB. Para instalar basta acessar o link e seguir a documentação: https://developer.android.com/tools/releases/platform-tools?hl=pt-br`
|
|
39
|
+
);
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
if (stderr) {
|
|
43
|
+
console.log(
|
|
44
|
+
`[✘] ADB. Para instalar basta acessar o link e seguir a documentação: https://developer.android.com/tools/releases/platform-tools?hl=pt-br`
|
|
45
|
+
);
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
console.log(`[${chalk.green("✔")}] ADB`);
|
|
49
|
+
});
|
|
50
|
+
};
|
|
51
|
+
const xcodeCLIDependency = () => {
|
|
52
|
+
if (os.platform() !== "darwin") return;
|
|
53
|
+
exec("xcrun version", (error, _, stderr) => {
|
|
54
|
+
if (error) {
|
|
55
|
+
console.log(
|
|
56
|
+
`[${chalk.red(
|
|
57
|
+
"✘"
|
|
58
|
+
)}] XCode. Para instalar basta acessar o link e seguir a documentação: https://developer.apple.com/documentation/Xcode`
|
|
59
|
+
);
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
if (stderr) {
|
|
63
|
+
console.log(
|
|
64
|
+
`[✘] XCode. Para instalar basta acessar o link e seguir a documentação: https://developer.apple.com/documentation/Xcode`
|
|
65
|
+
);
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
console.log(`[${chalk.green("✔")}] XCode`);
|
|
69
|
+
});
|
|
70
|
+
};
|
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)
|
|
@@ -184,8 +176,9 @@ ${await targetService.getAppConfExampleSnippet()}
|
|
|
184
176
|
...miniConf,
|
|
185
177
|
organization
|
|
186
178
|
},
|
|
187
|
-
target,
|
|
179
|
+
application: target,
|
|
188
180
|
startDate: `${start}`,
|
|
181
|
+
tempWorkspaceId
|
|
189
182
|
}
|
|
190
183
|
})
|
|
191
184
|
process.exit(0)
|
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) {
|
|
@@ -119,8 +112,7 @@ module.exports = async function start(args) {
|
|
|
119
112
|
eventName:"start",
|
|
120
113
|
userId: workspace?.userEmail,
|
|
121
114
|
data: {
|
|
122
|
-
|
|
123
|
-
userWorkspace,
|
|
115
|
+
workspaceId: userWorkspace.id,
|
|
124
116
|
miniConf,
|
|
125
117
|
args
|
|
126
118
|
}
|
|
@@ -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) {
|
package/src/service/CliLogin.js
CHANGED
|
@@ -17,6 +17,11 @@ class CliLogin {
|
|
|
17
17
|
|
|
18
18
|
devUser = developerKeyParsed?.clientId
|
|
19
19
|
devKey = developerKeyParsed?.clientSecret
|
|
20
|
+
TrackingEitriAnalytics.sendEvent({
|
|
21
|
+
eventName: 'login',
|
|
22
|
+
userId: email,
|
|
23
|
+
data: {}
|
|
24
|
+
})
|
|
20
25
|
} catch (error) {
|
|
21
26
|
console.error("\n", "Não foi possível realizar o seu login. Por favor, verique as credenciais.")
|
|
22
27
|
TrackingEitriAnalytics.sendEvent({
|
|
@@ -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() {
|