eitri-cli 1.1.0-beta.2 → 1.1.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/config/dev.js CHANGED
@@ -1,40 +1,44 @@
1
1
  /* eslint-disable no-undef */
2
- const HOST = 'dev.eitri.calindra.com.br'
3
- const packageJson = require('../package.json')
4
- const path = require('path')
2
+ const HOST = "dev.eitri.calindra.com.br";
3
+ const packageJson = require("../package.json");
4
+ const path = require("path");
5
5
 
6
6
  const config = {
7
7
  userAgent: packageJson.name,
8
8
  signup: {
9
- configFilePath: `.eitri/${path.basename(__filename).replace('.js', '.')}conf.js`,
10
- oldConfigFilePath: `.miniapp/${path.basename(__filename).replace('.js', '.')}conf.js`
9
+ configFilePath: `.eitri/${path
10
+ .basename(__filename)
11
+ .replace(".js", ".")}conf.js`,
12
+ oldConfigFilePath: `.miniapp/${path
13
+ .basename(__filename)
14
+ .replace(".js", ".")}conf.js`,
11
15
  },
12
16
  doc: {
13
- createUrl: `https://admin.${HOST}/docs`
17
+ createUrl: `https://admin.${HOST}/docs`,
14
18
  },
15
19
  blindGuardian: {
16
- url: `https://${HOST}/blind-guardian-api`
20
+ url: `https://${HOST}/blind-guardian-api`,
17
21
  },
18
22
  shareApi: {
19
23
  url: `https://${HOST}/share-api/share`,
20
24
  },
21
25
  workspace: {
22
26
  url: `https://${HOST}`,
23
- basePath: 'foundry',
24
- targetPath: '/foundry/targets',
27
+ basePath: "foundry",
28
+ targetPath: "/foundry/targets",
25
29
  target: {
26
30
  knownTargets: [
27
31
  {
28
32
  default: true,
29
- code: 'CALINDRA_MOBILE',
30
- description: 'CALINDRA_MOBILE',
31
- bootstrapBaseUrl: `https://${HOST}`
32
- }
33
- ]
33
+ code: "CALINDRA_MOBILE",
34
+ description: "CALINDRA_MOBILE",
35
+ bootstrapBaseUrl: `https://${HOST}`,
36
+ },
37
+ ],
34
38
  },
35
39
  apiVersion: {
36
- v1Header: 'application/vnd.workspace.api.v1+json',
37
- v2Header: 'application/vnd.workspace.api.v2+json'
40
+ v1Header: "application/vnd.workspace.api.v1+json",
41
+ v2Header: "application/vnd.workspace.api.v2+json",
38
42
  },
39
43
  colossus: {
40
44
  // url: 'https://colossus.lab.calindra.com.br/colossus-api/v1',
@@ -42,49 +46,51 @@ const config = {
42
46
  url: `https://${HOST}/workspace/server`,
43
47
 
44
48
  // pasta do miniapp dentro de src
45
- watchUserDir: '/server'
49
+ watchUserDir: "/server",
46
50
  },
47
51
  credentials: {
48
- approvalUrlPath: 'workspace/credential-approval',
49
- upsertUrlPath: 'workspace/miniapps/:publicKey/credential',
50
- defaultGrantType: 'client_credentials'
52
+ approvalUrlPath: "workspace/credential-approval",
53
+ upsertUrlPath: "workspace/miniapps/:publicKey/credential",
54
+ defaultGrantType: "client_credentials",
51
55
  },
52
56
  libs: {
53
- updateLibsEndpointVersion: 'application/vnd.workspace.api.v2+json'
54
- }
57
+ updateLibsEndpointVersion: "application/vnd.workspace.api.v2+json",
58
+ },
55
59
  },
56
60
  qrCode: {
57
- url: 'https://dev.eitri.calindra.com.br/workspace/share',
61
+ url: "https://dev.eitri.calindra.com.br/workspace/share",
58
62
  },
59
63
  miniLog: {
60
64
  url: `https://${HOST}/mini-log/rooms`,
61
- path: '/mini-log/socket.io'
65
+ path: "/mini-log/socket.io",
62
66
  },
63
67
  managerApi: {
64
68
  url: `https://${HOST}/miniapp-manager-api`,
65
69
  invites: {
66
- send: '/p/invites',
67
- slug: '/p/invites/s/:slug',
68
- my: '/p/myInvites',
69
- remove: '/p/invites/:inviteToken',
70
- accept: '/p/invites/accept',
70
+ send: "/p/invites",
71
+ slug: "/p/invites/s/:slug",
72
+ my: "/p/myInvites",
73
+ remove: "/p/invites/:inviteToken",
74
+ accept: "/p/invites/accept",
75
+ },
76
+ miniapp: {
77
+ miniAppsPath: "/o/mini-apps",
71
78
  },
72
- miniapp:{
73
- miniAppsPath: '/o/mini-apps',
74
- }
75
79
  },
76
80
  workspaceManager: {
77
81
  url: `https://${HOST}`,
78
- path: '/workspace-manager/socket.io',
79
- contextPath: '/workspace-manager'
82
+ path: "/workspace-manager/socket.io",
83
+ contextPath: "/workspace-manager",
80
84
  },
81
85
  eitriAnalytics: {
82
- url: "https://analytics.dev.eitri.calindra.com.br/analytics/event/cli"
86
+ url: "https://analytics.dev.eitri.calindra.com.br/analytics/event/cli",
83
87
  },
84
88
  managerFront: {
85
89
  url: `https://admin.${HOST}`,
86
90
  managerCredential: "/settings/manager-credential",
87
91
  cliGenerateLoginCredential: "/settings/cli-generate-credential",
92
+
93
+ url: `https://admin.${HOST}`,
88
94
  },
89
95
  vegvisir: {
90
96
  url: `https://${HOST}`,
@@ -96,6 +102,6 @@ const config = {
96
102
  eitriManager: {
97
103
  url: `https://${HOST}/eitri-manager-api`,
98
104
  },
99
- }
105
+ };
100
106
 
101
- module.exports = config
107
+ module.exports = config;
@@ -83,9 +83,7 @@ const config = {
83
83
  url: "https://analytics.dev.eitri.calindra.com.br/analytics/event/cli"
84
84
  },
85
85
  managerFront: {
86
- url: `https://admin.k8s.eitri.calindra.com.br`,
87
- managerCredential: "/settings/manager-credential",
88
- cliGenerateLoginCredential: "/settings/cli-generate-credential",
86
+ url: `https://admin.k8s.eitri.calindra.com.br`
89
87
  }
90
88
  }
91
89
 
@@ -1,42 +1,46 @@
1
- const ipv4 = require('../src/util/ipv4')
2
- const HOST = ipv4()[0]
3
- const packageJson = require('../package.json')
4
- const PORT = process.env.EITRI_APP_TOOLS_PORT || 3333
5
- const path = require('path')
6
- const HOST_EITRIAPPS = 'dev.eitri.calindra.com.br'
1
+ const ipv4 = require("../src/util/ipv4");
2
+ const HOST = ipv4()[0];
3
+ const packageJson = require("../package.json");
4
+ const PORT = process.env.EITRI_APP_TOOLS_PORT || 3333;
5
+ const path = require("path");
6
+ const HOST_EITRIAPPS = "dev.eitri.calindra.com.br";
7
7
 
8
8
  const config = {
9
9
  userAgent: packageJson.name,
10
10
  signup: {
11
- configFilePath: `.eitri/${path.basename(__filename).replace('.js', '.')}conf.js`,
12
- oldConfigFilePath: `.miniapp/${path.basename(__filename).replace('.js', '.')}conf.js`
11
+ configFilePath: `.eitri/${path
12
+ .basename(__filename)
13
+ .replace(".js", ".")}conf.js`,
14
+ oldConfigFilePath: `.miniapp/${path
15
+ .basename(__filename)
16
+ .replace(".js", ".")}conf.js`,
13
17
  },
14
18
  doc: {
15
- createUrl: 'https://developer.eitri.calindra.com.br/#/?id=create'
19
+ createUrl: "https://developer.eitri.calindra.com.br/#/?id=create",
16
20
  },
17
21
  blindGuardian: {
18
- url: `https://${HOST_EITRIAPPS}/blind-guardian-api`
22
+ url: `https://${HOST_EITRIAPPS}/blind-guardian-api`,
19
23
  },
20
24
  shareApi: {
21
25
  url: `https://${HOST_EITRIAPPS}/share-api/share`,
22
26
  },
23
27
  workspace: {
24
28
  url: `http://${HOST}:3000`,
25
- targetPath: '/runes-foundry/targets',
26
- basePath: 'runes-foundry',
29
+ targetPath: "/runes-foundry/targets",
30
+ basePath: "runes-foundry",
27
31
  target: {
28
32
  knownTargets: [
29
33
  {
30
34
  default: true,
31
- code: 'CALINDRA_MOBILE',
32
- description: 'CALINDRA_MOBILE',
33
- bootstrapBaseUrl: `https://${HOST}`
34
- }
35
- ]
35
+ code: "CALINDRA_MOBILE",
36
+ description: "CALINDRA_MOBILE",
37
+ bootstrapBaseUrl: `https://${HOST}`,
38
+ },
39
+ ],
36
40
  },
37
41
  apiVersion: {
38
- v1Header: 'application/vnd.workspace.api.v1+json',
39
- v2Header: 'application/vnd.workspace.api.v2+json'
42
+ v1Header: "application/vnd.workspace.api.v1+json",
43
+ v2Header: "application/vnd.workspace.api.v2+json",
40
44
  },
41
45
  colossus: {
42
46
  // url: 'https://colossus.lab.calindra.com.br/colossus-api/v1',
@@ -44,47 +48,47 @@ const config = {
44
48
  url: `http://${HOST}:3000/workspace/server`,
45
49
 
46
50
  // pasta do miniapp dentro de src
47
- watchUserDir: '/server'
51
+ watchUserDir: "/server",
48
52
  },
49
53
  credentials: {
50
- approvalUrlPath: 'workspace/credential-approval',
51
- upsertUrlPath: 'workspace/miniapps/:publicKey/credential',
52
- defaultGrantType: 'client_credentials'
54
+ approvalUrlPath: "workspace/credential-approval",
55
+ upsertUrlPath: "workspace/miniapps/:publicKey/credential",
56
+ defaultGrantType: "client_credentials",
53
57
  },
54
58
  libs: {
55
- updateLibsEndpointVersion: 'application/vnd.workspace.api.v2+json'
56
- }
59
+ updateLibsEndpointVersion: "application/vnd.workspace.api.v2+json",
60
+ },
57
61
  },
58
62
  qrCode: {
59
- url: 'https://prod.eitri.calindra.com.br/workspace/share',
63
+ url: "https://prod.eitri.calindra.com.br/workspace/share",
60
64
  },
61
65
  miniLog: {
62
66
  url: `https://${HOST_EITRIAPPS}/mini-log/rooms`,
63
- path: '/mini-log/socket.io'
67
+ path: "/mini-log/socket.io",
64
68
  },
65
69
  managerApi: {
66
70
  url: `https://${HOST_EITRIAPPS}/miniapp-manager-api`,
67
71
  invites: {
68
- send: '/p/invites',
69
- slug: '/p/invites/s/:slug',
70
- my: '/p/myInvites',
71
- remove: '/p/invites/:inviteToken',
72
- accept: '/p/invites/accept',
72
+ send: "/p/invites",
73
+ slug: "/p/invites/s/:slug",
74
+ my: "/p/myInvites",
75
+ remove: "/p/invites/:inviteToken",
76
+ accept: "/p/invites/accept",
77
+ },
78
+ miniapp: {
79
+ miniAppsPath: "/o/mini-apps",
73
80
  },
74
- miniapp:{
75
- miniAppsPath: '/o/mini-apps',
76
- }
77
81
  },
78
82
  eitriManager: {
79
- url: `https://${HOST_EITRIAPPS}/eitri-manager-api`
83
+ url: `https://${HOST_EITRIAPPS}/eitri-manager-api`,
80
84
  },
81
85
  workspaceManager: {
82
86
  url: `https://${HOST_EITRIAPPS}`,
83
- path: '/workspace-manager/socket.io',
84
- contextPath: '/workspace-manager'
87
+ path: "/workspace-manager/socket.io",
88
+ contextPath: "/workspace-manager",
85
89
  },
86
90
  eitriAnalytics: {
87
- url: "https://analytics.dev.eitri.calindra.com.br/analytics/event/cli"
91
+ url: "https://analytics.dev.eitri.calindra.com.br/analytics/event/cli",
88
92
  },
89
93
  managerFront: {
90
94
  url: `https://admin.${HOST}`,
@@ -97,7 +101,7 @@ const config = {
97
101
  workspace: "/workspace",
98
102
  my: "/workspace/my",
99
103
  check: "/workspace/check",
100
- }
101
- }
104
+ },
105
+ };
102
106
 
103
- module.exports = config
107
+ module.exports = config;
@@ -1,41 +1,45 @@
1
1
  /* eslint-disable no-undef */
2
- const HOST = 'prod.eitri.calindra.com.br'
3
- const packageJson = require('../package.json')
4
- const path = require('path')
5
- const HOST_MINIAPPS = 'prod.eitri.calindra.com.br'
2
+ const HOST = "prod.eitri.calindra.com.br";
3
+ const packageJson = require("../package.json");
4
+ const path = require("path");
5
+ const HOST_MINIAPPS = "prod.eitri.calindra.com.br";
6
6
 
7
7
  const config = {
8
8
  userAgent: packageJson.name,
9
9
  signup: {
10
- configFilePath: `.eitri/${path.basename(__filename).replace('.js', '.')}conf.js`,
11
- oldConfigFilePath: `.miniapp/${path.basename(__filename).replace('.js', '.')}conf.js`
10
+ configFilePath: `.eitri/${path
11
+ .basename(__filename)
12
+ .replace(".js", ".")}conf.js`,
13
+ oldConfigFilePath: `.miniapp/${path
14
+ .basename(__filename)
15
+ .replace(".js", ".")}conf.js`,
12
16
  },
13
17
  doc: {
14
- createUrl: `https://admin.${HOST_MINIAPPS}/docs`
18
+ createUrl: `https://admin.${HOST_MINIAPPS}/docs`,
15
19
  },
16
20
  blindGuardian: {
17
- url: `https://${HOST_MINIAPPS}/blind-guardian-api`
21
+ url: `https://${HOST_MINIAPPS}/blind-guardian-api`,
18
22
  },
19
23
  shareApi: {
20
24
  url: `https://${HOST_MINIAPPS}/share-api/share`,
21
25
  },
22
26
  workspace: {
23
27
  url: `https://${HOST}`,
24
- basePath: 'foundry',
25
- targetPath: '/foundry/targets',
28
+ basePath: "foundry",
29
+ targetPath: "/foundry/targets",
26
30
  target: {
27
31
  knownTargets: [
28
32
  {
29
33
  default: true,
30
- code: 'CALINDRA_MOBILE',
31
- description: 'CALINDRA_MOBILE',
32
- bootstrapBaseUrl: `https://${HOST}`
33
- }
34
- ]
34
+ code: "CALINDRA_MOBILE",
35
+ description: "CALINDRA_MOBILE",
36
+ bootstrapBaseUrl: `https://${HOST}`,
37
+ },
38
+ ],
35
39
  },
36
40
  apiVersion: {
37
- v1Header: 'application/vnd.workspace.api.v1+json',
38
- v2Header: 'application/vnd.workspace.api.v2+json'
41
+ v1Header: "application/vnd.workspace.api.v1+json",
42
+ v2Header: "application/vnd.workspace.api.v2+json",
39
43
  },
40
44
  colossus: {
41
45
  // url: 'https://colossus.lab.calindra.com.br/colossus-api/v1',
@@ -43,47 +47,47 @@ const config = {
43
47
  url: `https://${HOST}/workspace/server`,
44
48
 
45
49
  // pasta do miniapp dentro de src
46
- watchUserDir: '/server'
50
+ watchUserDir: "/server",
47
51
  },
48
52
  credentials: {
49
- approvalUrlPath: 'workspace/credential-approval',
50
- upsertUrlPath: 'workspace/miniapps/:publicKey/credential',
51
- defaultGrantType: 'client_credentials'
53
+ approvalUrlPath: "workspace/credential-approval",
54
+ upsertUrlPath: "workspace/miniapps/:publicKey/credential",
55
+ defaultGrantType: "client_credentials",
52
56
  },
53
57
  libs: {
54
- updateLibsEndpointVersion: 'application/vnd.workspace.api.v2+json'
55
- }
58
+ updateLibsEndpointVersion: "application/vnd.workspace.api.v2+json",
59
+ },
56
60
  },
57
61
  qrCode: {
58
- url: 'https://prod.eitri.calindra.com.br/workspace/share',
62
+ url: "https://prod.eitri.calindra.com.br/workspace/share",
59
63
  },
60
64
  miniLog: {
61
65
  url: `https://${HOST_MINIAPPS}/mini-log/rooms`,
62
- path: '/mini-log/socket.io'
66
+ path: "/mini-log/socket.io",
63
67
  },
64
68
  managerApi: {
65
69
  url: `https://${HOST_MINIAPPS}/miniapp-manager-api`,
66
70
  invites: {
67
- send: '/p/invites',
68
- slug: '/p/invites/s/:slug',
69
- my: '/p/myInvites',
70
- remove: '/p/invites/:inviteToken',
71
- accept: '/p/invites/accept',
71
+ send: "/p/invites",
72
+ slug: "/p/invites/s/:slug",
73
+ my: "/p/myInvites",
74
+ remove: "/p/invites/:inviteToken",
75
+ accept: "/p/invites/accept",
76
+ },
77
+ miniapp: {
78
+ miniAppsPath: "/o/mini-apps",
72
79
  },
73
- miniapp:{
74
- miniAppsPath: '/o/mini-apps',
75
- }
76
80
  },
77
81
  eitriManager: {
78
- url: `https://${HOST_MINIAPPS}/eitri-manager-api`
82
+ url: `https://${HOST_MINIAPPS}/eitri-manager-api`,
79
83
  },
80
84
  workspaceManager: {
81
85
  url: `https://${HOST_MINIAPPS}`,
82
- path: '/workspace-manager/socket.io',
83
- contextPath: '/workspace-manager'
86
+ path: "/workspace-manager/socket.io",
87
+ contextPath: "/workspace-manager",
84
88
  },
85
89
  eitriAnalytics: {
86
- url: "https://analytics.dev.eitri.calindra.com.br/analytics/event/cli"
90
+ url: "https://analytics.dev.eitri.calindra.com.br/analytics/event/cli",
87
91
  },
88
92
  managerFront: {
89
93
  url: `https://admin.eitri.calindra.com.br`,
@@ -97,6 +101,6 @@ const config = {
97
101
  my: "/workspace/my",
98
102
  check: "/workspace/check",
99
103
  },
100
- }
104
+ };
101
105
 
102
- module.exports = config
106
+ module.exports = config;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eitri-cli",
3
- "version": "1.1.0-beta.2",
3
+ "version": "1.1.0",
4
4
  "description": "Command Line Interface to make \"eitri app\" with code and fire.",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -36,6 +36,7 @@
36
36
  "cli-progress": "^3.4.0",
37
37
  "commander": "^9.2.0",
38
38
  "config": "^3.3.0",
39
+ "cors": "^2.8.5",
39
40
  "emojilib": "^2.4.0",
40
41
  "express": "^4.17.3",
41
42
  "express-rate-limit": "^6.3.0",
package/src/cmd/login.js CHANGED
@@ -16,12 +16,13 @@ module.exports = async function login(args) {
16
16
  },
17
17
  ])
18
18
 
19
- const urlAdminManagerCredential = `${config.get("managerFront").url}${config.get("managerFront").cliGenerateLoginCredential}`
20
19
  const res = Server.startCliLogin()
21
- const urlAdminManagerCredentialWithParams = `${urlAdminManagerCredential}?cli_login=true&redirect_url=http://${res?.host}:${res?.port}/cli-login`
20
+
21
+ const urlAdminManagerCredential = `${config.get("managerFront").url}`
22
+ const urlAdminManagerCredentialWithParams = `${urlAdminManagerCredential}?loginType=EITRI_CLI&port=${res?.port}`
23
+
22
24
  let portalOpenMessage = ""
23
25
 
24
-
25
26
  if (openPortalAnwser) {
26
27
  console.log("\n", "Abrindo o portal...")
27
28
  try {
@@ -3,6 +3,7 @@ const BlindGuardian = require("../../service/BlindGuardian");
3
3
  const Http = require("../../service/Http");
4
4
  const config = require("config");
5
5
  const getWorkspace = require("../../util/getWorkspace");
6
+ const writeGlobalWorkspaceConfig = require("./utils/writeGlobalWorkspaceConfig");
6
7
 
7
8
  module.exports = class VegvisirService {
8
9
  constructor() {
@@ -19,9 +20,15 @@ module.exports = class VegvisirService {
19
20
  } catch (error) {
20
21
  if (axios.isAxiosError(error)) {
21
22
  if (error.response.status === 404) {
22
- console.error(
23
- "Você não possui workspaces cadastrados, utilize o comando 'eitri workspace create' para cadastrar"
23
+ console.log(
24
+ "Você não possui nenhum workspace criado, estamos criando um default para você!"
24
25
  );
26
+ const createdWorkspace = await this.create({
27
+ name: 'DEFAULT'
28
+ })
29
+
30
+ return [createdWorkspace]
31
+
25
32
  }
26
33
  } else {
27
34
  console.error("Houve um erro inesperado ao listar workspaces");
@@ -31,16 +38,19 @@ module.exports = class VegvisirService {
31
38
 
32
39
  async create(createData) {
33
40
  const url = `${this.config.url}${this.config.basePath}${this.config.workspace}`;
34
- await this.http.post(url, createData);
41
+ const response = await this.http.post(url, createData);
42
+ return response.data;
35
43
  }
36
44
 
37
45
  async check(slug) {
38
46
  try {
39
- const workspace = await getWorkspace()
47
+ let workspace = await getWorkspace()
40
48
  if(!workspace) {
41
- console.log("É necessário ter um workspace definido para realizar essa ação, certifique-se de estar em um workspace.")
42
- console.log("Execute o comando 'eitri workspace current' para checar você está em um workspace.")
43
- return process.exit(0)
49
+ const workspaces = await this.listMyWorkspaces();
50
+ const defaultWorkspace = await workspaces.find(w => w.name === 'DEFAULT')
51
+ await writeGlobalWorkspaceConfig(defaultWorkspace)
52
+ workspace = defaultWorkspace;
53
+ return;
44
54
  }
45
55
 
46
56
  const data = {
@@ -3,6 +3,10 @@ const getWorkspace = require("../../../util/getWorkspace");
3
3
  module.exports = async function current(cmdObj) {
4
4
  try {
5
5
  const workspace = await getWorkspace()
6
+ if(!workspace) {
7
+ console.log("Você não possui workspace selecionado para desenvolvimento.")
8
+ return;
9
+ }
6
10
  console.log("====================================================")
7
11
  console.log('\t Workspace Atual: ', workspace.name)
8
12
  console.log("====================================================")
@@ -4,6 +4,7 @@ const VegvisirService = require("../VegvisirService");
4
4
  const path = require("path");
5
5
  const { mkdir, writeFile } = require("fs/promises");
6
6
  const { existsSync } = require("fs");
7
+ const writeGlobalWorkspaceConfig = require("../utils/writeGlobalWorkspaceConfig");
7
8
  const vegvisirService = new VegvisirService();
8
9
 
9
10
  module.exports = async function use(cmdArgs) {
@@ -30,28 +31,13 @@ module.exports = async function use(cmdArgs) {
30
31
  await writeGlobalWorkspaceConfig(selectedWorkspace);
31
32
  };
32
33
 
33
- async function writeGlobalWorkspaceConfig(selectedWorkspace) {
34
- const eitriFolderPath = path.resolve(os.homedir(), ".eitri");
35
- const workspaceFolderPath = path.resolve(eitriFolderPath, "workspaces");
36
- const workspaceFilePath = path.resolve(workspaceFolderPath, "workspace");
37
-
38
- await mkdir(workspaceFolderPath, { recursive: true });
39
-
40
- const workspaceConfig = JSON.stringify({
41
- name: selectedWorkspace.name,
42
- id: selectedWorkspace.id,
43
- });
44
-
45
- await writeFile(workspaceFilePath, workspaceConfig, { encoding: "utf8" });
46
-
47
- console.log("\nWorkspace configurado com sucesso!");
48
- }
49
-
50
34
  async function writeLocalWorkspaceConfig(selectedWorkspace) {
51
- const miniAppConfPath = path.resolve(process.cwd(), "eitri-app.conf.js");
52
- if (!existsSync(miniAppConfPath)) {
35
+ const eitriAppConfPath = path.resolve(process.cwd(), "eitri-app.conf.js");
36
+ const oldConfPath = path.resolve(process.cwd(), "miniapp.conf.js");
37
+
38
+ if (!existsSync(oldConfPath) && !existsSync(eitriAppConfPath)) {
53
39
  console.error(
54
- "Você só pode selecionar um workspace como local dentro de um eitri-app"
40
+ "Você só pode selecionar um workspace como local dentro de um projeto de eitri-app"
55
41
  );
56
42
  return;
57
43
  }
@@ -0,0 +1,20 @@
1
+ const os = require("os");
2
+ const path = require("path");
3
+ const { mkdir, writeFile } = require("fs/promises");
4
+
5
+ module.exports = async function writeGlobalWorkspaceConfig(selectedWorkspace) {
6
+ const eitriFolderPath = path.resolve(os.homedir(), ".eitri");
7
+ const workspaceFolderPath = path.resolve(eitriFolderPath, "workspaces");
8
+ const workspaceFilePath = path.resolve(workspaceFolderPath, "workspace");
9
+
10
+ await mkdir(workspaceFolderPath, { recursive: true });
11
+
12
+ const workspaceConfig = JSON.stringify({
13
+ name: selectedWorkspace.name,
14
+ id: selectedWorkspace.id,
15
+ });
16
+
17
+ await writeFile(workspaceFilePath, workspaceConfig, { encoding: "utf8" });
18
+
19
+ console.log(`Workspace configurado com sucesso! (${selectedWorkspace.name})`);
20
+ }
@@ -11,7 +11,9 @@ const TERMINAL_PRINTER_NAME = 'terminal'
11
11
  let serverInstance
12
12
  const requestListenerHelper = require('../helpers/request-listener-helper')
13
13
  const CliLogin = require('./CliLogin')
14
+ const cors = require("cors")
14
15
 
16
+ const WHITE_LIST = ["https://admin.eitri.calindra.com.br", "https://admin.dev.eitri.calindra.com.br"]
15
17
 
16
18
  const expressRateLimiter = rateLimit({
17
19
  windowMs: 15 * 60 * 1000,
@@ -199,7 +201,10 @@ class Server {
199
201
  }
200
202
  })
201
203
 
202
- serverInstance.get('/cli-login', async (req, res) => {
204
+ const myRouteOptions = {
205
+ origin: WHITE_LIST,
206
+ }
207
+ serverInstance.get('/cli-login', cors(myRouteOptions) ,async (req, res) => {
203
208
  const {email, credential} = req?.query || {}
204
209
  res.send('hello world')
205
210
  await new CliLogin().saveCredentials({
@@ -29,8 +29,7 @@ module.exports = async function getWorkspace() {
29
29
  return workspace;
30
30
  } catch (error) {
31
31
  if(error.code === "ENOENT") {
32
- console.error("Você não tem nenhum workspace definido para desenvolvimento, execute o comando 'eitri workspace use' para definir um workspace.")
33
- return process.exit(1)
32
+ return;
34
33
  }
35
34
  console.error("Houve um erro inesperado ao tentar ler o workspace atual.")
36
35
  return process.exit(1)