eitri-cli 1.12.0 → 1.13.0-beta.2
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/eitri-cli-v2/eitri-cli-v2.darwin-arm64.node +0 -0
- package/eitri-cli-v2/eitri-cli-v2.darwin-x64.node +0 -0
- package/eitri-cli-v2/eitri-cli-v2.linux-x64-gnu.node +0 -0
- package/eitri-cli-v2/eitri-cli-v2.win32-x64-msvc.node +0 -0
- package/package.json +2 -3
- package/src/service/QRCodeFactory.js +13 -8
- package/src/service/TrackingEitriAnalytics.js +5 -1
- package/src/service/Workspace.js +81 -0
- package/src/service/WorkspaceManager.js +4 -2
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eitri-cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.13.0-beta.2",
|
|
4
4
|
"description": "Command Line Interface to make \"Eitri-App\" with code and fire.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"bin": {
|
|
@@ -54,8 +54,7 @@
|
|
|
54
54
|
"node-watch": "^0.6.3",
|
|
55
55
|
"open": "^7.0.0",
|
|
56
56
|
"ps-node": "^0.1.6",
|
|
57
|
-
"qrcode": "^1.
|
|
58
|
-
"qrcode-terminal": "^0.12.0",
|
|
57
|
+
"qrcode": "^1.5.3",
|
|
59
58
|
"semver": "^7.1.3",
|
|
60
59
|
"slugify": "^1.4.0",
|
|
61
60
|
"socket.io-client": "^4.5.2",
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
const tmp = require('tmp')
|
|
2
2
|
const qrcode = require('qrcode')
|
|
3
3
|
const GenericUtils = require('../util/GenericUtils')
|
|
4
|
-
const qrcodeTerminal = require('qrcode-terminal')
|
|
5
4
|
const open = require('open')
|
|
6
5
|
|
|
7
6
|
// Fabrica de QR code :-)
|
|
@@ -14,7 +13,9 @@ class QRCodeFactory {
|
|
|
14
13
|
return
|
|
15
14
|
}
|
|
16
15
|
|
|
17
|
-
|
|
16
|
+
qrcode.toString(args?.fullUrl, {type:"terminal", small: true}, function(_, qrCode) {
|
|
17
|
+
console.log(qrCode)
|
|
18
|
+
})
|
|
18
19
|
}
|
|
19
20
|
|
|
20
21
|
async create(data, eitriAppSlug = "", displayOutsideTerminal = false) {
|
|
@@ -34,12 +35,16 @@ class QRCodeFactory {
|
|
|
34
35
|
|
|
35
36
|
createQRCodeImage(qrCodeTempPath, data) {
|
|
36
37
|
return new Promise((resolve, reject) => {
|
|
37
|
-
qrcode.toFile(
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
|
|
38
|
+
qrcode.toFile(
|
|
39
|
+
qrCodeTempPath,
|
|
40
|
+
data,
|
|
41
|
+
{small: true},
|
|
42
|
+
(err) => {
|
|
43
|
+
if (err) {
|
|
44
|
+
return reject(err)
|
|
45
|
+
}
|
|
46
|
+
resolve()
|
|
47
|
+
})
|
|
43
48
|
})
|
|
44
49
|
}
|
|
45
50
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
const axios = require('axios')
|
|
2
2
|
const configService = require('./ConfigService')
|
|
3
3
|
const EITRI_ANALYTICS_URL = configService.get('eitriAnalytics')?.url
|
|
4
|
+
const packageJson = require('../../package.json')
|
|
4
5
|
|
|
5
6
|
class TrackingEitriAnalytics {
|
|
6
7
|
|
|
@@ -12,7 +13,10 @@ class TrackingEitriAnalytics {
|
|
|
12
13
|
eventName,
|
|
13
14
|
sessionId: process?.env?.["NODE_APP_SESSION_ID"] ?? "",
|
|
14
15
|
userId,
|
|
15
|
-
data
|
|
16
|
+
data: {
|
|
17
|
+
cliVersion: packageJson?.version || "0.0.0",
|
|
18
|
+
...data
|
|
19
|
+
}
|
|
16
20
|
}
|
|
17
21
|
await axios.post(EITRI_ANALYTICS_URL, event).catch(_err => null)
|
|
18
22
|
}
|
package/src/service/Workspace.js
CHANGED
|
@@ -54,6 +54,7 @@ class Workspace {
|
|
|
54
54
|
console.warn("Missing colossus config inside workspace.");
|
|
55
55
|
}
|
|
56
56
|
this.shareApi = configService.get("shareApi");
|
|
57
|
+
this.vegvisir = configService.get("vegvisir");
|
|
57
58
|
this.targets = [];
|
|
58
59
|
|
|
59
60
|
/**
|
|
@@ -432,9 +433,89 @@ class Workspace {
|
|
|
432
433
|
},
|
|
433
434
|
};
|
|
434
435
|
|
|
436
|
+
if(process.env.APP_START_WORKSPACE_CONFIG){
|
|
437
|
+
const startAppsConfig = await this.getEitriStartAppsWorkspacesConfig()
|
|
438
|
+
if(startAppsConfig){
|
|
439
|
+
config.focusedEitriApp = startAppsConfig.focusedEitriApp
|
|
440
|
+
config.applicationId = startAppsConfig.applicationId
|
|
441
|
+
config.environmentId = startAppsConfig.environmentId
|
|
442
|
+
config.devEnvKey = startAppsConfig.devEnvKey
|
|
443
|
+
config.workspaces = startAppsConfig.workspaces
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
|
|
435
447
|
return config;
|
|
436
448
|
}
|
|
437
449
|
|
|
450
|
+
async getEitriStartAppsWorkspacesConfig() {
|
|
451
|
+
try {
|
|
452
|
+
const appConfig = await this.getAppConfig()
|
|
453
|
+
const url = `${this.vegvisir.url}${this.vegvisir.basePath}${this.vegvisir.my}`
|
|
454
|
+
const responseWorkspaces = await this.http.get(url)
|
|
455
|
+
|
|
456
|
+
const workspaces = [];
|
|
457
|
+
let focusedEitriApp = ""
|
|
458
|
+
let workspaceFocused = ""
|
|
459
|
+
|
|
460
|
+
for (const eitriApp of appConfig.eitriApps) {
|
|
461
|
+
const eitriAppPath = eitriApp.path;
|
|
462
|
+
|
|
463
|
+
const eitriAppConfPath = path.resolve(
|
|
464
|
+
process.cwd(),
|
|
465
|
+
"..",
|
|
466
|
+
eitriAppPath,
|
|
467
|
+
'eitri-app.conf.js'
|
|
468
|
+
);
|
|
469
|
+
|
|
470
|
+
|
|
471
|
+
if (fs.existsSync(eitriAppConfPath)) {
|
|
472
|
+
const eitriAppContent = require(eitriAppConfPath);
|
|
473
|
+
const workspaceRemoteInfo = responseWorkspaces.find(rw => rw.name === eitriApp.workspace)
|
|
474
|
+
|
|
475
|
+
if(eitriApp.focus){
|
|
476
|
+
focusedEitriApp = eitriAppContent.slug
|
|
477
|
+
workspaceFocused = workspaceRemoteInfo.id
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
|
|
481
|
+
const foundryContextPath = process.env.FOUNDRY_CONTEXT_PATH || 'foundry'
|
|
482
|
+
const workspaceUrl = `https://api.eitri.tech/${foundryContextPath}/user/${workspaceRemoteInfo.id}/index.html`
|
|
483
|
+
|
|
484
|
+
workspaces.push({
|
|
485
|
+
name: eitriApp?.workspace,
|
|
486
|
+
id: workspaceRemoteInfo?.id,
|
|
487
|
+
url: workspaceUrl,
|
|
488
|
+
slug: eitriAppContent?.slug,
|
|
489
|
+
eitriAppId: eitriAppContent?.id,
|
|
490
|
+
});
|
|
491
|
+
} else {
|
|
492
|
+
console.error(`Eitri-App Conf não encontrado: ${eitriAppConfPath}`);
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
const isValidConfigs = startAppsConfig.applicationId
|
|
497
|
+
&& startAppsConfig.devEnvKey
|
|
498
|
+
&& startAppsConfig.focusedEitriApp
|
|
499
|
+
&& startAppsConfig.environmentId
|
|
500
|
+
&& startAppsConfig.workspaces?.length > 0
|
|
501
|
+
|
|
502
|
+
if(!isValidConfigs){
|
|
503
|
+
return
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
const fakerDevEnvKey = `dev-${new Date().getTime()}-${workspaceFocused}`
|
|
507
|
+
return {
|
|
508
|
+
focusedEitriApp,
|
|
509
|
+
applicationId: appConfig?.applicationId,
|
|
510
|
+
environmentId: appConfig?.environmentId,
|
|
511
|
+
devEnvKey: fakerDevEnvKey,
|
|
512
|
+
workspaces,
|
|
513
|
+
};
|
|
514
|
+
} catch (error) {
|
|
515
|
+
console.error("Erro ao obter configurações do Workspaces: ", error?.message)
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
|
|
438
519
|
getRelativePath(filePath) {
|
|
439
520
|
return filePath
|
|
440
521
|
.replace(this.folder2watch, "")
|
|
@@ -5,7 +5,7 @@ const QRCodeFactory = require('../service/QRCodeFactory')
|
|
|
5
5
|
const TrackingService = require('../service/TrackingService')
|
|
6
6
|
const configService = require('./ConfigService')
|
|
7
7
|
const Server = require('../service/Server')
|
|
8
|
-
const
|
|
8
|
+
const qrcode = require('qrcode')
|
|
9
9
|
const TERMINAL_PRINTER_NAME = 'terminal'
|
|
10
10
|
|
|
11
11
|
class WorkspaceManager {
|
|
@@ -36,7 +36,9 @@ class WorkspaceManager {
|
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
if(process.env.AAT_QRCODE_PRINTER === TERMINAL_PRINTER_NAME || args && args.qrPrinter === TERMINAL_PRINTER_NAME) {
|
|
39
|
-
|
|
39
|
+
qrcode.toString(fullUrl, {type:"terminal", small: true}, function(_, qrCode) {
|
|
40
|
+
console.log(qrCode)
|
|
41
|
+
})
|
|
40
42
|
} else {
|
|
41
43
|
const qrCodePath = await new QRCodeFactory().create(fullUrl)
|
|
42
44
|
const sanitizedQrCodePath = qrCodePath.replace('/~', '')
|