eitri-cli 1.1.7-alpha.3 → 1.2.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/.husky/commit-msg +4 -0
- package/.releaserc.json +0 -4
- package/.vscode/settings.json +3 -1
- package/README.md +8 -9
- package/bitbucket-pipelines.yml +16 -4
- package/commitlint.config.js +6 -0
- package/config/dev.js +4 -4
- package/config/k8s-eitri.js +2 -2
- package/config/loc-eitri.js +2 -2
- package/config/prod-eitri.js +13 -11
- package/developer-folder/README.md +1 -0
- package/index-eitri.js +3 -0
- package/index.js +14 -63
- package/install-dev.sh +1 -1
- package/package.json +9 -6
- package/src/cmd/clean.js +18 -7
- package/src/cmd/create.js +41 -24
- package/src/cmd/credentials.js +1 -1
- package/src/cmd/invite.js +4 -4
- package/src/cmd/login.js +9 -8
- package/src/cmd/manage-env.js +4 -4
- package/src/cmd/push-version.js +29 -18
- package/src/cmd/signup.js +8 -6
- package/src/cmd/start.js +20 -32
- package/src/cmd/tail-logs.js +3 -3
- package/src/model/Payload.js +1 -1
- package/src/modules/vegvisir/VegvisirService.js +4 -4
- package/src/modules/vegvisir/cmd/list.js +2 -1
- package/src/modules/vegvisir/cmd/use.js +1 -1
- package/src/service/AuthConfig.js +9 -12
- package/src/service/BlindGuardian.js +16 -19
- package/src/service/CliLogin.js +7 -5
- package/src/service/ConfigService.js +0 -7
- package/src/service/CredentialsService.js +2 -2
- package/src/service/EitriAppManager.js +2 -2
- package/src/service/Http.js +3 -3
- package/src/service/InviteService.js +2 -2
- package/src/service/MiniLog.js +1 -1
- package/src/service/QRCodeFactory.js +2 -2
- package/src/service/Server.js +9 -9
- package/src/service/TargetService.js +2 -2
- package/src/service/TrackingEitriAnalytics.js +11 -21
- package/src/service/Workspace.js +10 -6
- package/src/service/WorkspaceManager.js +4 -4
- package/src/service/factories/DoubtsStarterFactory.js +2 -2
- package/src/util/AboutTemplate.jsx +1 -1
- package/src/util/UserLocalCredential.js +10 -4
- package/src/util/error-messages/invite/invite-error-messages.js +1 -1
- package/src/util/template-utils.js +2 -2
- package/test/Executor.js +46 -0
- package/test/Helper.js +13 -0
- package/test/_fixtures/factory.js +1 -1
- package/test/_fixtures/src/views/AboutTemplate.jsx +1 -1
- package/test/cmd/clean.test.js +3 -3
- package/test/cmd/create.test.js +8 -8
- package/test/e2e/cli.test.js +68 -0
- package/test/service/Workspace.test.js +17 -17
- package/CHANGELOG.md +0 -57
- package/publisher.js +0 -59
- package/targetMobileStickyness.md +0 -47
- package/targetWebStickyness.md +0 -40
- package/test/cmd/credentials.test.js +0 -159
- package/test/cmd/signup.test.js +0 -20
- package/test/cmd/start.test.js +0 -5
- package/thinQrCode.md +0 -58
- package/v1.5.0.md +0 -3
package/test/cmd/create.test.js
CHANGED
|
@@ -6,7 +6,7 @@ const create = require('../../src/cmd/create')
|
|
|
6
6
|
const nock = require('nock')
|
|
7
7
|
const inquirer = require('inquirer')
|
|
8
8
|
const {faker} = require('@faker-js/faker')
|
|
9
|
-
const
|
|
9
|
+
const WoodCoffee = require('../../src/service/factories/WoodCoffeeFactory')
|
|
10
10
|
const getCreateFactory = require('../../src/util/getCreateFactory')
|
|
11
11
|
const {getTarget} = require('../_fixtures/factory')
|
|
12
12
|
const {workspace} = require('../../src/service/Workspace')
|
|
@@ -135,7 +135,7 @@ describe('create', () => {
|
|
|
135
135
|
)
|
|
136
136
|
})
|
|
137
137
|
|
|
138
|
-
describe('--
|
|
138
|
+
describe('--application', () => {
|
|
139
139
|
const expectedTarget = getTarget()
|
|
140
140
|
|
|
141
141
|
// stub inquirer
|
|
@@ -192,9 +192,9 @@ describe('create', () => {
|
|
|
192
192
|
describe('--template', () => {
|
|
193
193
|
|
|
194
194
|
let projectName
|
|
195
|
-
let
|
|
195
|
+
let woodCoffee
|
|
196
196
|
let target
|
|
197
|
-
class
|
|
197
|
+
class WoodCoffeeStub extends WoodCoffee {
|
|
198
198
|
// eslint-disable-next-line no-unused-vars
|
|
199
199
|
verifyFolder(_projectName, _options) {
|
|
200
200
|
return new Promise(resolve => resolve('/tmp'))
|
|
@@ -211,7 +211,7 @@ describe('create', () => {
|
|
|
211
211
|
target = getTarget()
|
|
212
212
|
jest.spyOn(workspace, 'availableTargets').mockImplementationOnce(new Promise(resolve => resolve([target])))
|
|
213
213
|
projectName = faker.commerce.product() + Date.now()
|
|
214
|
-
|
|
214
|
+
woodCoffee = new WoodCoffeeStub()
|
|
215
215
|
})
|
|
216
216
|
|
|
217
217
|
afterAll(() => {
|
|
@@ -221,8 +221,8 @@ describe('create', () => {
|
|
|
221
221
|
|
|
222
222
|
it('should create miniapp with selected template', async () => {
|
|
223
223
|
jest.spyOn(inquirer, 'prompt').mockResolvedValueOnce({ accepted: 'CALINDRA_MOBILE' })
|
|
224
|
-
getCreateFactory.mockImplementation(() =>
|
|
225
|
-
const factorySpy = jest.spyOn(
|
|
224
|
+
getCreateFactory.mockImplementation(() => woodCoffee)
|
|
225
|
+
const factorySpy = jest.spyOn(woodCoffee, 'create')
|
|
226
226
|
const args = {
|
|
227
227
|
target: 'CALINDRA_MOBILE',
|
|
228
228
|
yes: true,
|
|
@@ -235,7 +235,7 @@ describe('create', () => {
|
|
|
235
235
|
|
|
236
236
|
it.skip('should return error on select invalid template', async () => {
|
|
237
237
|
jest.spyOn(inquirer, 'prompt').mockResolvedValueOnce({ accepted: 'CALINDRA_MOBILE' })
|
|
238
|
-
getCreateFactory.mockImplementation(() =>
|
|
238
|
+
getCreateFactory.mockImplementation(() => woodCoffee)
|
|
239
239
|
const consoleSpy = jest.spyOn(console, 'error')
|
|
240
240
|
jest.spyOn(process, 'exit')
|
|
241
241
|
.mockImplementation((number) => {return number})
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
const util = require("util")
|
|
2
|
+
const path = require("path")
|
|
3
|
+
const execAsync = util.promisify(require("child_process").exec)
|
|
4
|
+
const axios = require("axios")
|
|
5
|
+
const minutes = 60000
|
|
6
|
+
const Executor = require("../Executor.js")
|
|
7
|
+
const Helper = require("../Helper.js")
|
|
8
|
+
|
|
9
|
+
describe("eitri-cli", () => {
|
|
10
|
+
|
|
11
|
+
const EITRI_WORK_DIR = path.join(__dirname, '..', '..', 'developer-folder')
|
|
12
|
+
let devEnv = {
|
|
13
|
+
...process.env,
|
|
14
|
+
EITRI_CLI_CLIENT_ID: process.env.EITRI_CLI_CLIENT_ID,
|
|
15
|
+
EITRI_CLI_CLIENT_SECRET: process.env.EITRI_CLI_CLIENT_SECRET,
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
it("should works", async () => {
|
|
19
|
+
const EITRI_APP_NAME = `eitri-test-${Date.now()}`
|
|
20
|
+
try {
|
|
21
|
+
|
|
22
|
+
await execAsync(`cd ${EITRI_WORK_DIR} && rm -rf ./eitri-test-*`, { env: process.env })
|
|
23
|
+
|
|
24
|
+
const executor = new Executor({ env: devEnv })
|
|
25
|
+
await executor
|
|
26
|
+
.exec(`cd ${EITRI_WORK_DIR} && eitri create ${EITRI_APP_NAME} --yes --application=APPLICATION_CALINDRA`, { env: devEnv })
|
|
27
|
+
.waitFor(/Download de template completo/)
|
|
28
|
+
await new Promise(resolve => setTimeout(resolve, 200))
|
|
29
|
+
const EITRI_APP_FOLDER = path.resolve(EITRI_WORK_DIR, EITRI_APP_NAME)
|
|
30
|
+
|
|
31
|
+
const startExecution = new Executor({ env: devEnv })
|
|
32
|
+
await startExecution
|
|
33
|
+
.exec(`cd ${EITRI_APP_FOLDER} && eitri start`)
|
|
34
|
+
.waitFor(/Utilize o QR-Code para iniciar o seu Eitri-App/)
|
|
35
|
+
|
|
36
|
+
const line = await executor
|
|
37
|
+
.exec(`eitri workspace list`)
|
|
38
|
+
.waitFor(/Id:/i)
|
|
39
|
+
|
|
40
|
+
const workspaceId = line.split(/id:/i)[1].trim()
|
|
41
|
+
await axios.get(`https://api.eitri.tech/foundry/user/${workspaceId}/index.html`)
|
|
42
|
+
await axios.get(`https://api.eitri.tech/foundry/user/${workspaceId}/Home.html`)
|
|
43
|
+
|
|
44
|
+
const textContent = `SomeText${Date.now()}Content`
|
|
45
|
+
const promise = startExecution.waitFor(/Forjado em ([0-9])+ milissegundos/)
|
|
46
|
+
await execAsync(`echo "<Text>${textContent}</Text>" > ${EITRI_APP_FOLDER}/src/views/Home.jsx`)
|
|
47
|
+
await promise
|
|
48
|
+
|
|
49
|
+
let res = await axios.get(`https://api.eitri.tech/foundry/user/${workspaceId}/index.js`)
|
|
50
|
+
expect(res.data).toContain(textContent)
|
|
51
|
+
|
|
52
|
+
startExecution.child.kill()
|
|
53
|
+
executor.child.kill()
|
|
54
|
+
|
|
55
|
+
const pushVersion = new Executor({ env: devEnv })
|
|
56
|
+
await pushVersion.exec(`cd ${EITRI_APP_FOLDER} && eitri push-version`)
|
|
57
|
+
.waitFor(/disponível no Eitri Console/)
|
|
58
|
+
pushVersion.child.kill()
|
|
59
|
+
|
|
60
|
+
const conf = require(`../../developer-folder/${EITRI_APP_NAME}/eitri-app.conf.js`)
|
|
61
|
+
await Helper.delete(conf.id)
|
|
62
|
+
} catch (e) {
|
|
63
|
+
console.error(e)
|
|
64
|
+
throw e
|
|
65
|
+
}
|
|
66
|
+
}, 2 * minutes)
|
|
67
|
+
|
|
68
|
+
})
|
|
@@ -26,7 +26,7 @@ describe('Workspace', () => {
|
|
|
26
26
|
describe('.upsert(filePath)', () => {
|
|
27
27
|
it('envia o nome do arquivo para o servidor relativo a pasta do projeto local', (done) => {
|
|
28
28
|
nock('https://dev.eitri.calindra.com.br')
|
|
29
|
-
.post('/
|
|
29
|
+
.post('/foundry/fileupload', (body) => {
|
|
30
30
|
let m = body.match(/\s+\/src\/Home\.js/)
|
|
31
31
|
expect(m).not.toBeNull()
|
|
32
32
|
done()
|
|
@@ -38,7 +38,7 @@ describe('Workspace', () => {
|
|
|
38
38
|
})
|
|
39
39
|
it('envia o arquivo para o servidor', (done) => {
|
|
40
40
|
nock('https://dev.eitri.calindra.com.br')
|
|
41
|
-
.post('/
|
|
41
|
+
.post('/foundry/fileupload', (body) => {
|
|
42
42
|
let m = body.match(/name="file"; filename="Home\.js"/)
|
|
43
43
|
expect(m).not.toBeNull()
|
|
44
44
|
done()
|
|
@@ -50,11 +50,11 @@ describe('Workspace', () => {
|
|
|
50
50
|
})
|
|
51
51
|
it('envia em sequencia', (done) => {
|
|
52
52
|
nock('https://dev.eitri.calindra.com.br')
|
|
53
|
-
.post('/
|
|
53
|
+
.post('/foundry/fileupload')
|
|
54
54
|
.delayBody(1000)
|
|
55
55
|
.reply(200, { request: 1 })
|
|
56
56
|
nock('https://dev.eitri.calindra.com.br')
|
|
57
|
-
.post('/
|
|
57
|
+
.post('/foundry/fileupload')
|
|
58
58
|
.delayBody(100)
|
|
59
59
|
.reply(200, { request: 2 })
|
|
60
60
|
let filePath = path.resolve(folder2watch, 'src', 'Home.js')
|
|
@@ -70,11 +70,11 @@ describe('Workspace', () => {
|
|
|
70
70
|
|
|
71
71
|
it('deve enviar de forma concorrente', async (done) => {
|
|
72
72
|
nock('https://dev.eitri.calindra.com.br')
|
|
73
|
-
.post('/
|
|
73
|
+
.post('/foundry/fileupload')
|
|
74
74
|
.delayBody(1000)
|
|
75
75
|
.reply(200, { request: 1 })
|
|
76
76
|
nock('https://dev.eitri.calindra.com.br')
|
|
77
|
-
.post('/
|
|
77
|
+
.post('/foundry/fileupload')
|
|
78
78
|
.delayBody(100)
|
|
79
79
|
.reply(200, { request: 2 })
|
|
80
80
|
let filePath = path.resolve(folder2watch, 'src', 'Home.js')
|
|
@@ -105,7 +105,7 @@ describe('Workspace', () => {
|
|
|
105
105
|
describe('.delete(filePath)', () => {
|
|
106
106
|
it('pede para o servidor apagar o arquivo', async () => {
|
|
107
107
|
let scope = nock('https://dev.eitri.calindra.com.br')
|
|
108
|
-
.delete(/\/
|
|
108
|
+
.delete(/\/foundry\/fileupload.*/)
|
|
109
109
|
.reply(200, {})
|
|
110
110
|
let filePath = path.resolve(folder2watch, 'src', 'Home.js')
|
|
111
111
|
await workspace.delete(filePath)
|
|
@@ -192,7 +192,7 @@ describe('Workspace', () => {
|
|
|
192
192
|
it('should on invoke postLambda set webhooks if return hookData', async () => {
|
|
193
193
|
const fakeHookData = {FunctionUrl: 'FakeUrl.com', fileName: 'fakeFileName'}
|
|
194
194
|
nock('https://dev.eitri.calindra.com.br', { allowUnmocked: true })
|
|
195
|
-
.post('/
|
|
195
|
+
.post('/foundry/server', () => {
|
|
196
196
|
return true
|
|
197
197
|
})
|
|
198
198
|
.reply(200, { ok: true, hookData: fakeHookData })
|
|
@@ -203,7 +203,7 @@ describe('Workspace', () => {
|
|
|
203
203
|
|
|
204
204
|
it('should on invoke postLambda ignore set webhooks if no return', async () => {
|
|
205
205
|
nock('https://dev.eitri.calindra.com.br', { allowUnmocked: true })
|
|
206
|
-
.post('/
|
|
206
|
+
.post('/foundry/server', () => {
|
|
207
207
|
return true
|
|
208
208
|
})
|
|
209
209
|
.reply(200, { ok: true })
|
|
@@ -239,7 +239,7 @@ describe('Workspace', () => {
|
|
|
239
239
|
libUrl: 'https://www.npmjs.com/package/eitri-app-client',
|
|
240
240
|
runnerUrl: 'https://dev.eitri.calindra.com.br/app/',
|
|
241
241
|
bootstrapBaseUrl: 'http://localhost:3333',
|
|
242
|
-
askUserDataApiUrl: 'https://dev.eitri.calindra.com.br/miniapp-manager-api/p/mini-apps/:slug/token/
|
|
242
|
+
askUserDataApiUrl: 'https://dev.eitri.calindra.com.br/miniapp-manager-api/p/mini-apps/:slug/token/foundry'
|
|
243
243
|
}
|
|
244
244
|
],
|
|
245
245
|
default: true
|
|
@@ -249,7 +249,7 @@ describe('Workspace', () => {
|
|
|
249
249
|
beforeEach(() => {
|
|
250
250
|
nock.cleanAll()
|
|
251
251
|
nock('https://dev.eitri.calindra.com.br')
|
|
252
|
-
.get(
|
|
252
|
+
.get(/\/eitri-manager-api\/p\/users\/self\/targets/).reply(200, res)
|
|
253
253
|
})
|
|
254
254
|
|
|
255
255
|
it('deve receber a configuração correta', async () => {
|
|
@@ -279,7 +279,7 @@ describe('Workspace', () => {
|
|
|
279
279
|
libUrl: 'https://www.npmjs.com/package/eitri-app-client',
|
|
280
280
|
runnerUrl: 'https://dev.eitri.calindra.com.br/app/',
|
|
281
281
|
bootstrapBaseUrl: 'http://localhost:3333',
|
|
282
|
-
askUserDataApiUrl: 'https://dev.eitri.calindra.com.br/miniapp-manager-api/p/mini-apps/:slug/token/
|
|
282
|
+
askUserDataApiUrl: 'https://dev.eitri.calindra.com.br/miniapp-manager-api/p/mini-apps/:slug/token/foundry'
|
|
283
283
|
}
|
|
284
284
|
])
|
|
285
285
|
})
|
|
@@ -310,15 +310,15 @@ describe('Workspace', () => {
|
|
|
310
310
|
'libUrl': 'https://www.npmjs.com/package/eitri-app-client',
|
|
311
311
|
'runnerUrl': 'https://dev.eitri.calindra.com.br/app/',
|
|
312
312
|
'bootstrapBaseUrl': 'http://localhost:3333',
|
|
313
|
-
'askUserDataApiUrl': 'https://dev.eitri.calindra.com.br/miniapp-manager-api/p/mini-apps/:slug/token/
|
|
313
|
+
'askUserDataApiUrl': 'https://dev.eitri.calindra.com.br/miniapp-manager-api/p/mini-apps/:slug/token/foundry'
|
|
314
314
|
}
|
|
315
315
|
],
|
|
316
316
|
'default': false
|
|
317
317
|
}
|
|
318
318
|
|
|
319
|
-
it('should return targets', async () => {
|
|
319
|
+
it.skip('should return targets', async () => {
|
|
320
320
|
nock('https://dev.eitri.calindra.com.br', { allowUnmocked: true })
|
|
321
|
-
.get(
|
|
321
|
+
.get(/\/eitri-manager-api\/p\/users\/self\/targets/)
|
|
322
322
|
.reply(200, [expectedTarget])
|
|
323
323
|
const result = await workspace.availableTargets()
|
|
324
324
|
expect(result).toBeDefined()
|
|
@@ -333,7 +333,7 @@ describe('Workspace', () => {
|
|
|
333
333
|
it('deve invocar o postLambda quando o relativePath incluir a pasta server', async () => {
|
|
334
334
|
|
|
335
335
|
nock('https://dev.eitri.calindra.com.br')
|
|
336
|
-
.post('/
|
|
336
|
+
.post('/foundry/server')
|
|
337
337
|
.delayBody(1000)
|
|
338
338
|
.reply(200, { request: 1 })
|
|
339
339
|
|
|
@@ -348,7 +348,7 @@ describe('Workspace', () => {
|
|
|
348
348
|
|
|
349
349
|
it('deve invocar o postFormData quando o relativePath incluir o watchDir do miniapp', async () => {
|
|
350
350
|
nock('https://dev.eitri.calindra.com.br')
|
|
351
|
-
.post('/
|
|
351
|
+
.post('/foundry/fileupload')
|
|
352
352
|
.delayBody(1000)
|
|
353
353
|
.reply(200, { request: 1 })
|
|
354
354
|
|
package/CHANGELOG.md
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
## [1.1.7-alpha.3](http://bitbucket.org/smartsolutionteam/eitri-cli/compare/v1.1.7-alpha.2...v1.1.7-alpha.3) (2023-10-04)
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
### Bug Fixes
|
|
5
|
-
|
|
6
|
-
* Adicionado release/npm ao .releaserc ([15a7e7d](http://bitbucket.org/smartsolutionteam/eitri-cli/commits/15a7e7d2e0648d10cf3c6f409a81ef3fc00dd383))
|
|
7
|
-
|
|
8
|
-
## [1.1.7-alpha.2](http://bitbucket.org/smartsolutionteam/eitri-cli/compare/v1.1.7-alpha.1...v1.1.7-alpha.2) (2023-10-04)
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
### Bug Fixes
|
|
12
|
-
|
|
13
|
-
* teste de log de versão em novo step ([27f715d](http://bitbucket.org/smartsolutionteam/eitri-cli/commits/27f715d2709484b4c33627413f2974bfa433e2d0))
|
|
14
|
-
|
|
15
|
-
## [1.1.7-alpha.1](http://bitbucket.org/smartsolutionteam/eitri-cli/compare/v1.1.6...v1.1.7-alpha.1) (2023-10-04)
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
### Bug Fixes
|
|
19
|
-
|
|
20
|
-
* Log da versão do process.env ([716b4f6](http://bitbucket.org/smartsolutionteam/eitri-cli/commits/716b4f6f41238f0a69f6ac587e8d5171c4051dcf))
|
|
21
|
-
|
|
22
|
-
## [1.1.6](http://bitbucket.org/smartsolutionteam/eitri-cli/compare/v1.1.5...v1.1.6) (2023-10-04)
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
### Bug Fixes
|
|
26
|
-
|
|
27
|
-
* Alterada ordem de escrita ([eafbec7](http://bitbucket.org/smartsolutionteam/eitri-cli/commits/eafbec783aa5bc6f8fdb20ff35d2a343b411f2db))
|
|
28
|
-
|
|
29
|
-
## [1.1.5](http://bitbucket.org/smartsolutionteam/eitri-cli/compare/v1.1.4...v1.1.5) (2023-10-04)
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
### Bug Fixes
|
|
33
|
-
|
|
34
|
-
* alterado log ([0ec103a](http://bitbucket.org/smartsolutionteam/eitri-cli/commits/0ec103a44311bfae3044d0816ec4d9cae07a78e9))
|
|
35
|
-
|
|
36
|
-
## [1.1.4](http://bitbucket.org/smartsolutionteam/eitri-cli/compare/v1.1.3...v1.1.4) (2023-10-04)
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
### Bug Fixes
|
|
40
|
-
|
|
41
|
-
* Alterada alpha para testar se irá alterar versão no package.json (ou se muda somente na master) ([75f659b](http://bitbucket.org/smartsolutionteam/eitri-cli/commits/75f659ba6bc156e539eb7d8344f5584569ce016d))
|
|
42
|
-
* Log para verificar versão gerada ([31dff20](http://bitbucket.org/smartsolutionteam/eitri-cli/commits/31dff2006c704a3f58fad1d941b7daa07537b3bb))
|
|
43
|
-
* Teste para alteração de versão automaticamente. ([4913e12](http://bitbucket.org/smartsolutionteam/eitri-cli/commits/4913e12d605d2814d7ec387a01285a21fee6af1d))
|
|
44
|
-
|
|
45
|
-
## [1.1.4-alpha.2](http://bitbucket.org/smartsolutionteam/eitri-cli/compare/v1.1.4-alpha.1...v1.1.4-alpha.2) (2023-10-04)
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
### Bug Fixes
|
|
49
|
-
|
|
50
|
-
* Log para verificar versão gerada ([31dff20](http://bitbucket.org/smartsolutionteam/eitri-cli/commits/31dff2006c704a3f58fad1d941b7daa07537b3bb))
|
|
51
|
-
|
|
52
|
-
## [1.1.4-alpha.1](http://bitbucket.org/smartsolutionteam/eitri-cli/compare/v1.1.3...v1.1.4-alpha.1) (2023-10-04)
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
### Bug Fixes
|
|
56
|
-
|
|
57
|
-
* Teste para alteração de versão automaticamente. ([4913e12](http://bitbucket.org/smartsolutionteam/eitri-cli/commits/4913e12d605d2814d7ec387a01285a21fee6af1d))
|
package/publisher.js
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
const fs = require('fs');
|
|
2
|
-
const path = require('path');
|
|
3
|
-
const {execSync, exec} = require('child_process');
|
|
4
|
-
|
|
5
|
-
publishAsNeeded();
|
|
6
|
-
|
|
7
|
-
function publishAsNeeded() {
|
|
8
|
-
fs.readFile(path.join(__dirname, 'package.json'), 'utf8', (err, data) => {
|
|
9
|
-
|
|
10
|
-
if (err) {
|
|
11
|
-
console.error('Error:', err);
|
|
12
|
-
return;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
const _BRANCHS = {
|
|
16
|
-
MASTER: "master",
|
|
17
|
-
BETA: "beta",
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
const branch = process.env.BITBUCKET_BRANCH
|
|
21
|
-
console.log('Current branch on build: ', branch);
|
|
22
|
-
|
|
23
|
-
const allowedBranchs = [_BRANCHS.MASTER, _BRANCHS.BETA]
|
|
24
|
-
if(!allowedBranchs?.includes(branch)){
|
|
25
|
-
console.log(`${branch} is different from ${JSON.stringify(allowedBranchs)}. Skipping...`);
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
const packageJson = JSON.parse(data);
|
|
30
|
-
const localVersion = packageJson.version;
|
|
31
|
-
|
|
32
|
-
if (branch === _BRANCHS.BETA && !(/beta/.test(localVersion))) {
|
|
33
|
-
console.log(`${localVersion} version does not contain the "beta" suffix in the version name. Skipping...`);
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
const publishedVersions = JSON.parse(execSync('npm show ' + packageJson.name + ' versions --json').toString());
|
|
38
|
-
if (publishedVersions.includes(localVersion)) {
|
|
39
|
-
console.log('There is a published version identical to the one in package.json: ', localVersion);
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
console.log('Previously unpublished version. Allowed version name for publishing: ', localVersion);
|
|
44
|
-
|
|
45
|
-
const commandSuffix = branch === _BRANCHS.BETA ? "--tag beta" : "";
|
|
46
|
-
|
|
47
|
-
exec('npm run build && npm publish ' + commandSuffix, (err, stdout, stderr) => {
|
|
48
|
-
if (err) {
|
|
49
|
-
// node couldn't execute the command
|
|
50
|
-
console.log('Error:', err);
|
|
51
|
-
process.exit(2);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
// the *entire* stdout and stderr (buffered)
|
|
55
|
-
console.log(`stdout: ${stdout}`);
|
|
56
|
-
console.log(`stderr: ${stderr}`);
|
|
57
|
-
});
|
|
58
|
-
});
|
|
59
|
-
}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
```plantuml
|
|
2
|
-
@startuml
|
|
3
|
-
autonumber
|
|
4
|
-
title Fluxo de Stickyness para mobile
|
|
5
|
-
|
|
6
|
-
participant Developer
|
|
7
|
-
participant SuperApp
|
|
8
|
-
participant AmeAppTools
|
|
9
|
-
participant ALB
|
|
10
|
-
participant AmeCliReloader1
|
|
11
|
-
participant AmeCliReloader2
|
|
12
|
-
participant AmeCliReloader3
|
|
13
|
-
participant ShareApi
|
|
14
|
-
|
|
15
|
-
Developer->AmeAppTools: start()
|
|
16
|
-
AmeAppTools->AmeAppTools: cookie = loadCookie('~/.ame.cookie.json')
|
|
17
|
-
AmeAppTools->AmeAppTools: bootstrapUrl = bootstrapUrl.append(cookie)
|
|
18
|
-
AmeAppTools->AmeAppTools: data = buildQrCodeData(bootstrapUrl)
|
|
19
|
-
AmeAppTools->ALB: saveQrCodeData(data, cookie)
|
|
20
|
-
ALB->ALB: chooseWorkspaceInstance(cookie)
|
|
21
|
-
note over ALB
|
|
22
|
-
Se o Cookie veio vazio o ALB seleciona o AmeCliReloader1
|
|
23
|
-
Se o Cookie veio preenchido o ALB seleciona a instancia definida no cookie
|
|
24
|
-
end note
|
|
25
|
-
ALB->AmeCliReloader1: saveQrCodeData(data)
|
|
26
|
-
AmeCliReloader1->ShareApi: saveQrCodeData(data)
|
|
27
|
-
ShareApi-->AmeCliReloader1:
|
|
28
|
-
AmeCliReloader1-->ALB:
|
|
29
|
-
ALB-->AmeAppTools: cookie
|
|
30
|
-
AmeAppTools->ALB: uploadSourceCode(cookie, 'foo.js')
|
|
31
|
-
ALB->ALB: chooseWorkspaceInstance(cookie)
|
|
32
|
-
ALB->AmeCliReloader1: uploadSourceCode()
|
|
33
|
-
ALB<--AmeCliReloader1
|
|
34
|
-
ALB->ALB: Se o cookie expirou um novo será gerado
|
|
35
|
-
ALB-->AmeAppTools: cookie
|
|
36
|
-
AmeAppTools->AmeAppTools: save(cookie, '~/.ame.cookie.json')
|
|
37
|
-
AmeAppTools->AmeAppTools: showQrCode()
|
|
38
|
-
Developer->SuperApp: scanQrCode()
|
|
39
|
-
SuperApp->ShareApi: data = getQrCodeData()
|
|
40
|
-
SuperApp->ALB: getMiniApp(data.bootstrapUrl)
|
|
41
|
-
ALB->ALB: chooseWorkpaceInstance(bootstrapUrl.query('cid'))
|
|
42
|
-
ALB->AmeCliReloader1: getMiniApp(data.bootstrapUrl)
|
|
43
|
-
AmeCliReloader1-->ALB: html do miniapp
|
|
44
|
-
ALB-->SuperApp: html do miniapp
|
|
45
|
-
SuperApp->SuperApp: Exibe miniapp
|
|
46
|
-
@enduml
|
|
47
|
-
```
|
package/targetWebStickyness.md
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
```plantuml
|
|
2
|
-
@startuml
|
|
3
|
-
autonumber
|
|
4
|
-
title Fluxo de Stickyness para Web
|
|
5
|
-
|
|
6
|
-
participant Developer
|
|
7
|
-
participant SuperApp
|
|
8
|
-
participant AmeAppTools
|
|
9
|
-
participant Emulator
|
|
10
|
-
participant ALB
|
|
11
|
-
participant AmeCliReloader1
|
|
12
|
-
participant AmeCliReloader2
|
|
13
|
-
participant AmeCliReloader3
|
|
14
|
-
|
|
15
|
-
Developer->AmeAppTools: start()
|
|
16
|
-
AmeAppTools->AmeAppTools: cookie = loadCookie('~/.ame.cookie.json')
|
|
17
|
-
AmeAppTools->AmeAppTools: bootstrapUrl = bootstrapUrl.append(cookie)
|
|
18
|
-
AmeAppTools->ALB: uploadSourceCode(cookie, 'foo.js')
|
|
19
|
-
ALB->ALB: chooseWorkspaceInstance(cookie)
|
|
20
|
-
note over ALB
|
|
21
|
-
Se o Cookie veio vazio o ALB seleciona o AmeCliReloader1
|
|
22
|
-
Se o Cookie veio preenchido o ALB seleciona a instancia definida no cookie
|
|
23
|
-
end note
|
|
24
|
-
ALB->AmeCliReloader1: uploadSourceCode()
|
|
25
|
-
AmeCliReloader1-->ALB:
|
|
26
|
-
ALB->ALB: Se o cookie expirou um novo será gerado
|
|
27
|
-
ALB-->AmeAppTools: cookie
|
|
28
|
-
AmeAppTools->AmeAppTools: save(cookie, '~/.ame.cookie.json')
|
|
29
|
-
AmeAppTools->Emulator: openEmulator(bootstrapUrl)
|
|
30
|
-
Emulator->Emulator: abre url no iframe
|
|
31
|
-
Emulator->AmeAppTools: request pelo próprio localhost
|
|
32
|
-
AmeAppTools->AmeAppTools: troca o host
|
|
33
|
-
AmeAppTools->ALB: getMiniApp(cookie, bootstrapUrl)
|
|
34
|
-
ALB->AmeCliReloader1: getMiniApp(bootstrapUrl)
|
|
35
|
-
AmeCliReloader1-->ALB: html do miniapp
|
|
36
|
-
ALB-->AmeAppTools: html do miniapp + cookie
|
|
37
|
-
AmeAppTools-->Emulator: html do miniapp
|
|
38
|
-
Emulator->Emulator: Exibe miniapp
|
|
39
|
-
@enduml
|
|
40
|
-
```
|
|
@@ -1,159 +0,0 @@
|
|
|
1
|
-
/* eslint-disable no-undef */
|
|
2
|
-
const path = require('path')
|
|
3
|
-
const {workspace} = require('../../src/service/Workspace')
|
|
4
|
-
const { panicCheckEnvList, environmentVariable, buildEnvFile, sendEnvfile } = require('../../src/util/manage-env')
|
|
5
|
-
const config = require('config')
|
|
6
|
-
const CONFIG_WORKSPACE = config.get('workspace')
|
|
7
|
-
const nock = require('nock')
|
|
8
|
-
const ManageEnvService = require('../../src/service/ManageEnvService')
|
|
9
|
-
const manageEnvService = new ManageEnvService()
|
|
10
|
-
|
|
11
|
-
describe('manage-env', () => {
|
|
12
|
-
const MOCK = true
|
|
13
|
-
const blindGuardian = workspace.blindGuardian
|
|
14
|
-
|
|
15
|
-
beforeEach(() => {
|
|
16
|
-
nock.cleanAll()
|
|
17
|
-
})
|
|
18
|
-
|
|
19
|
-
afterEach(() => {
|
|
20
|
-
nock.cleanAll()
|
|
21
|
-
})
|
|
22
|
-
|
|
23
|
-
it('should fail when envList is empty', async () => {
|
|
24
|
-
expect.assertions(2)
|
|
25
|
-
try {
|
|
26
|
-
panicCheckEnvList([])
|
|
27
|
-
} catch (e) {
|
|
28
|
-
expect(e).toBeDefined()
|
|
29
|
-
expect(e.message).toBe('Nenhuma variavel de ambiente foi fornecida.')
|
|
30
|
-
}
|
|
31
|
-
})
|
|
32
|
-
|
|
33
|
-
it('should fail with wrong key', async () => {
|
|
34
|
-
expect.assertions(2)
|
|
35
|
-
try {
|
|
36
|
-
const envList = ['0FOO=bar']
|
|
37
|
-
environmentVariable(envList)
|
|
38
|
-
} catch (e) {
|
|
39
|
-
expect(e).toBeDefined()
|
|
40
|
-
expect(e.message).toEqual('A chave 0FOO é inválida')
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
})
|
|
44
|
-
|
|
45
|
-
it('should return a object', async () => {
|
|
46
|
-
const envList = ['FOO=bar', 'DEV=back-end']
|
|
47
|
-
const envVariable = environmentVariable(envList)
|
|
48
|
-
expect(envVariable).toEqual({ FOO: 'bar', DEV: 'back-end' })
|
|
49
|
-
})
|
|
50
|
-
|
|
51
|
-
it('should fail if there is no fileNames', () => {
|
|
52
|
-
expect.assertions(2)
|
|
53
|
-
try {
|
|
54
|
-
buildEnvFile('dev', [], { FOO: 'bar', DEV: 'back-end' }, 'miniapp-foo', '0.1.0')
|
|
55
|
-
} catch (e) {
|
|
56
|
-
expect(e).toBeDefined()
|
|
57
|
-
expect(e.message).toEqual('Não existe aquivo na pasta server.')
|
|
58
|
-
}
|
|
59
|
-
})
|
|
60
|
-
|
|
61
|
-
it('should send envFile to /colossus-api/v1', async () => {
|
|
62
|
-
let bodySentToServer, bodySentToCreateLambda
|
|
63
|
-
if (MOCK) {
|
|
64
|
-
nock(CONFIG_WORKSPACE.colossus.url, { allowUnmocked: true })
|
|
65
|
-
.post('/env', body => {
|
|
66
|
-
bodySentToServer = body
|
|
67
|
-
return true
|
|
68
|
-
})
|
|
69
|
-
.reply(200, { ok: true })
|
|
70
|
-
nock('https://dev.eitri.calindra.com.br', { allowUnmocked: true })
|
|
71
|
-
.post('/workspace/server', body => {
|
|
72
|
-
bodySentToCreateLambda = body
|
|
73
|
-
return true
|
|
74
|
-
})
|
|
75
|
-
.reply(200, { ok: true })
|
|
76
|
-
}
|
|
77
|
-
const folder2watch = path.resolve(__dirname, '..', '_fixtures', 'src')
|
|
78
|
-
workspace.setFolder2Watch(folder2watch)
|
|
79
|
-
blindGuardian.readConf()
|
|
80
|
-
|
|
81
|
-
workspace.setServerUrl(CONFIG_WORKSPACE.url)
|
|
82
|
-
await workspace.init()
|
|
83
|
-
try {
|
|
84
|
-
await workspace.postLambda(path.resolve(folder2watch, 'server', 'foo.js'), '/server/foo.js')
|
|
85
|
-
} catch (e) {
|
|
86
|
-
console.error(e)
|
|
87
|
-
throw e
|
|
88
|
-
}
|
|
89
|
-
let miniConf = workspace.getMiniConf()
|
|
90
|
-
const fileNames = await workspace.getFileNames('server')
|
|
91
|
-
|
|
92
|
-
const envFile = {
|
|
93
|
-
envCode: 'ws',
|
|
94
|
-
fileNames,
|
|
95
|
-
envVars: { FOO: 'bar', DEV: 'back-end' },
|
|
96
|
-
slug: miniConf.slug,
|
|
97
|
-
miniAppVersion: miniConf.version
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
const url = `${CONFIG_WORKSPACE.colossus.url}`
|
|
101
|
-
const resp = await sendEnvfile(workspace, url, envFile).catch(e => e)
|
|
102
|
-
expect(resp.constructor.name).not.toBe('Error')
|
|
103
|
-
expect(resp.data).toMatchObject({ ok: true })
|
|
104
|
-
if (MOCK) {
|
|
105
|
-
expect(bodySentToServer).toMatchObject({
|
|
106
|
-
envCode: 'ws',
|
|
107
|
-
fileNames,
|
|
108
|
-
envVars: { FOO: 'bar', DEV: 'back-end' },
|
|
109
|
-
slug: miniConf.slug,
|
|
110
|
-
miniAppVersion: miniConf.version
|
|
111
|
-
})
|
|
112
|
-
expect(bodySentToCreateLambda).toMatchObject({
|
|
113
|
-
'envCode': 'ws',
|
|
114
|
-
'miniAppVersion': '0.1.0',
|
|
115
|
-
'name': 'foo.js',
|
|
116
|
-
'publishing': false,
|
|
117
|
-
'slug': 'mini-app-colossus',
|
|
118
|
-
})
|
|
119
|
-
}
|
|
120
|
-
}, 60000)
|
|
121
|
-
|
|
122
|
-
it('should find environment variables', async () => {
|
|
123
|
-
const url = `${CONFIG_WORKSPACE.colossus.url}`
|
|
124
|
-
const query = {
|
|
125
|
-
env: 'ws',
|
|
126
|
-
slug: 'mini-app-colossus',
|
|
127
|
-
miniAppVersion: '0.1.0',
|
|
128
|
-
fileName: 'backend.js',
|
|
129
|
-
email: 'fabio.oshiro@gmail'
|
|
130
|
-
}
|
|
131
|
-
console.log('rota', CONFIG_WORKSPACE.colossus.url)
|
|
132
|
-
// https://dev.eitri.calindra.com.br/workspace/server?env=ws&slug=mini-app-colossus&miniAppVersion=0.1.0&fileName=backend.js&user=fabio.oshiro@gmail
|
|
133
|
-
nock('https://dev.eitri.calindra.com.br/workspace/server', { allowUnmocked: false })
|
|
134
|
-
.get('/env')
|
|
135
|
-
.query(query)
|
|
136
|
-
.reply(200, { FOO: 'BAR', BAR: 'FOO' })
|
|
137
|
-
|
|
138
|
-
const folder2watch = path.resolve(__dirname, '..', '_fixtures', 'src')
|
|
139
|
-
workspace.setFolder2Watch(folder2watch)
|
|
140
|
-
blindGuardian.readConf()
|
|
141
|
-
|
|
142
|
-
workspace.setServerUrl(CONFIG_WORKSPACE.url)
|
|
143
|
-
await workspace.init()
|
|
144
|
-
// await miniLog.connect(workspace.userEmail)
|
|
145
|
-
let miniConf = workspace.getMiniConf()
|
|
146
|
-
let envVariables
|
|
147
|
-
|
|
148
|
-
try {
|
|
149
|
-
envVariables = await manageEnvService.getEnvVariables(workspace, url, miniConf, 'ws', 'fabio.oshiro@gmail', 'backend.js')
|
|
150
|
-
} catch (e) {
|
|
151
|
-
console.error(e)
|
|
152
|
-
throw e
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
console.log('envVariables', envVariables)
|
|
156
|
-
|
|
157
|
-
expect(envVariables).toMatchObject({ FOO: 'BAR', BAR: 'FOO' })
|
|
158
|
-
})
|
|
159
|
-
})
|
package/test/cmd/signup.test.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/* eslint-disable no-undef */
|
|
2
|
-
|
|
3
|
-
const signup = require('../../src/cmd/signup')
|
|
4
|
-
const nock = require('nock')
|
|
5
|
-
|
|
6
|
-
jest.setTimeout(15000)
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
describe('signup', () => {
|
|
10
|
-
|
|
11
|
-
it('Should succesfully create an user', () => {
|
|
12
|
-
|
|
13
|
-
nock('https://dev.eitri.calindra.com.br')
|
|
14
|
-
.post('/blind-guardian-api/v1/user')
|
|
15
|
-
.reply(200, { id: 'xpto', scopes: [ 'foo', 'bar' ] })
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
})
|
|
19
|
-
|
|
20
|
-
})
|