eitri-cli 1.10.0 → 1.10.1-beta.1
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 +1 -1
- package/src/modules/vegvisir/VegvisirService.js +1 -1
- package/src/service/Emulator/AndroidEmulatorService.js +25 -3
- package/src/service/MiniLog.js +5 -46
- package/eitri-cli-v2/src/commands/mod.rs +0 -2
- package/eitri-cli-v2/src/commands/publish.rs +0 -35
- package/eitri-cli-v2/src/commands/run_test.rs +0 -41
- package/eitri-cli-v2/src/config/mod.rs +0 -1
- package/eitri-cli-v2/src/config/user_credentials.rs +0 -38
- package/eitri-cli-v2/src/infra/http_client.rs +0 -493
- package/eitri-cli-v2/src/infra/mod.rs +0 -1
- package/eitri-cli-v2/src/lib.rs +0 -30
- package/eitri-cli-v2/src/model/auth_response.rs +0 -8
- package/eitri-cli-v2/src/model/credentials.rs +0 -8
- package/eitri-cli-v2/src/model/eitri_conf.rs +0 -43
- package/eitri-cli-v2/src/model/mod.rs +0 -8
- package/eitri-cli-v2/src/model/process_output.rs +0 -8
- package/eitri-cli-v2/src/model/revision.rs +0 -14
- package/eitri-cli-v2/src/model/test_config.rs +0 -7
- package/eitri-cli-v2/src/model/url.rs +0 -11
- package/eitri-cli-v2/src/model/workspace_auth.rs +0 -4
- package/eitri-cli-v2/src/services/blind_guardian.rs +0 -87
- package/eitri-cli-v2/src/services/eitri_foundry.rs +0 -84
- package/eitri-cli-v2/src/services/eitri_manager.rs +0 -78
- package/eitri-cli-v2/src/services/mod.rs +0 -4
- package/eitri-cli-v2/src/services/workspace.rs +0 -49
- package/eitri-cli-v2/src/utils/convert_eitri_conf.rs +0 -98
- package/eitri-cli-v2/src/utils/mod.rs +0 -1
- package/test/Executor.js +0 -60
- package/test/Factory.js +0 -13
- package/test/Helper.js +0 -15
- package/test/_fixtures/factory.js +0 -30
- package/test/_fixtures/miniWebApp/miniapp.conf.js +0 -4
- package/test/_fixtures/miniapp.conf.js +0 -5
- package/test/_fixtures/server/HelloWorldBackend.js +0 -7
- package/test/_fixtures/src/Home.js +0 -5
- package/test/_fixtures/src/Home2.js +0 -5
- package/test/_fixtures/src/commons/util.js +0 -3
- package/test/_fixtures/src/components/TagA.jsx +0 -4
- package/test/_fixtures/src/components/TagB.jsx +0 -4
- package/test/_fixtures/src/components/TagC.jsx +0 -3
- package/test/_fixtures/src/components/TagD.jsx +0 -3
- package/test/_fixtures/src/server/foo.js +0 -7
- package/test/_fixtures/src/views/AboutTemplate.jsx +0 -14
- package/test/_fixtures/woodcoffee/miniapp.conf.js +0 -5
- package/test/ame.conf.js +0 -3
- package/test/cmd/clean.test.js +0 -66
- package/test/cmd/create.test.js +0 -252
- package/test/cmd/list.test.js +0 -74
- package/test/cmd/manage-env.test.js +0 -168
- package/test/e2e/cli.test.js +0 -473
- package/test/miniapp.conf.js +0 -3
- package/test/model/Payload.test.js +0 -35
- package/test/modules/vegvisir/VegvisirService.test.js +0 -37
- package/test/service/BlindGuardian.test.js +0 -84
- package/test/service/CheckAmeConf.test.js +0 -313
- package/test/service/Http.test.js +0 -312
- package/test/service/InviteService.test.js +0 -117
- package/test/service/MiniWebAppFactory.test.js +0 -40
- package/test/service/TagTree.test.js +0 -81
- package/test/service/TargetService.test.js +0 -48
- package/test/service/TrackingService.test.js +0 -105
- package/test/service/UserAmeConf.test.js +0 -47
- package/test/service/WoodCoffeeFactory.test.js +0 -148
- package/test/service/Workspace.test.js +0 -211
- package/test/utils/getWorkspaceId.test.js +0 -17
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
/* eslint-disable no-undef */
|
|
2
|
-
|
|
3
|
-
const path = require('path')
|
|
4
|
-
const nock = require('nock')
|
|
5
|
-
const InviteService = require('../../src/service/InviteService')
|
|
6
|
-
|
|
7
|
-
describe('InviteService', () => {
|
|
8
|
-
|
|
9
|
-
let workspace, folder2watch, inviteService, invite
|
|
10
|
-
|
|
11
|
-
beforeEach(() => {
|
|
12
|
-
nock.cleanAll()
|
|
13
|
-
invite = {
|
|
14
|
-
id: 18,
|
|
15
|
-
email: 'dev@calindra.com.br',
|
|
16
|
-
miniAppName: 'Nome do miniapp',
|
|
17
|
-
slug: 'miniapp-slug',
|
|
18
|
-
status: 'ACTIVE',
|
|
19
|
-
token: 'RandwYNDBvsebQpR721',
|
|
20
|
-
inviterEmail: 'revisor@calindra.com.br',
|
|
21
|
-
}
|
|
22
|
-
folder2watch = path.resolve(__dirname, '..', '_fixtures')
|
|
23
|
-
|
|
24
|
-
workspace = require('../../src/service/Workspace').workspace
|
|
25
|
-
workspace.setFolder2Watch(folder2watch)
|
|
26
|
-
workspace.setServerUrl('https://dev.eitri.calindra.com.br')
|
|
27
|
-
|
|
28
|
-
// para pegar um token de verdade basta comentar o codigo abaixo
|
|
29
|
-
workspace.blindGuardian.getToken = async () => {
|
|
30
|
-
return { accessToken: 'xpto' }
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
inviteService = new InviteService(workspace)
|
|
35
|
-
})
|
|
36
|
-
|
|
37
|
-
afterEach(() => {
|
|
38
|
-
nock.cleanAll()
|
|
39
|
-
})
|
|
40
|
-
|
|
41
|
-
const mockReadInvitesEndPoint = () => {
|
|
42
|
-
nock('https://dev.eitri.calindra.com.br', { allowUnmocked: true })
|
|
43
|
-
.get('/miniapp-manager-api/p/myInvites')
|
|
44
|
-
.reply(200, [invite])
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
const mockFindInvitesBySlugEndPoint = () => {
|
|
48
|
-
nock('https://dev.eitri.calindra.com.br', { allowUnmocked: true })
|
|
49
|
-
.get(/\/miniapp-manager-api\/p\/invites\/s\/.*/)
|
|
50
|
-
.reply(200, [invite])
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
it('lista os convites do desenvolvedor', async () => {
|
|
54
|
-
mockReadInvitesEndPoint()
|
|
55
|
-
let invites = await inviteService.findAllPending()
|
|
56
|
-
expect(invites[0].email).toBeDefined()
|
|
57
|
-
expect(invites[0].miniAppName).toBeDefined()
|
|
58
|
-
expect(invites[0].slug).toBeDefined()
|
|
59
|
-
expect(invites[0].status).toBeDefined()
|
|
60
|
-
expect(invites[0].token).toBeDefined()
|
|
61
|
-
expect(invites[0].inviterEmail).toBeDefined()
|
|
62
|
-
})
|
|
63
|
-
|
|
64
|
-
it('aceita um convite', async () => {
|
|
65
|
-
let bodySentToApi
|
|
66
|
-
mockReadInvitesEndPoint()
|
|
67
|
-
nock('https://dev.eitri.calindra.com.br', { allowUnmocked: true })
|
|
68
|
-
.put(`/miniapp-manager-api/p/invites/accept`, body => {
|
|
69
|
-
bodySentToApi = body
|
|
70
|
-
return true
|
|
71
|
-
})
|
|
72
|
-
.reply(200, {})
|
|
73
|
-
let invites = await inviteService.findAllPending()
|
|
74
|
-
await inviteService.accept(invites[0])
|
|
75
|
-
expect(bodySentToApi).toBeDefined()
|
|
76
|
-
})
|
|
77
|
-
|
|
78
|
-
it('envia um convite', async () => {
|
|
79
|
-
let bodySentToApi
|
|
80
|
-
nock('https://dev.eitri.calindra.com.br', { allowUnmocked: true })
|
|
81
|
-
.post('/miniapp-manager-api/p/invites', body => {
|
|
82
|
-
bodySentToApi = body
|
|
83
|
-
return true
|
|
84
|
-
})
|
|
85
|
-
.reply(200, {})
|
|
86
|
-
await inviteService.sendInvite('teste-convite-dev', 'fabio.oshiro@calindra.com.br')
|
|
87
|
-
expect(bodySentToApi.email).toBe('fabio.oshiro@calindra.com.br')
|
|
88
|
-
expect(bodySentToApi.slug).toBe('teste-convite-dev')
|
|
89
|
-
})
|
|
90
|
-
|
|
91
|
-
it('lista os convites de um miniapp', async () => {
|
|
92
|
-
mockFindInvitesBySlugEndPoint()
|
|
93
|
-
let invites = await inviteService.findAllBySlug('teste-convite-dev')
|
|
94
|
-
expect(invites[0]).toBeDefined()
|
|
95
|
-
expect(invites[0].email).toBeDefined()
|
|
96
|
-
expect(invites[0].token).toBeDefined()
|
|
97
|
-
expect(invites[0].slug).toBeDefined()
|
|
98
|
-
})
|
|
99
|
-
|
|
100
|
-
it('remove um convite', async () => {
|
|
101
|
-
let bodySentToApi
|
|
102
|
-
mockFindInvitesBySlugEndPoint()
|
|
103
|
-
nock('https://dev.eitri.calindra.com.br', { allowUnmocked: true })
|
|
104
|
-
.delete(`/miniapp-manager-api/p/invites/${invite.token}`, body => {
|
|
105
|
-
bodySentToApi = body
|
|
106
|
-
return true
|
|
107
|
-
})
|
|
108
|
-
.reply(200, {})
|
|
109
|
-
|
|
110
|
-
// somente para testar a vera
|
|
111
|
-
// await inviteService.sendInvite('teste-convite-dev', 'fabio.oshiro@calindra.com.br')
|
|
112
|
-
|
|
113
|
-
let invites = await inviteService.findAllBySlug('teste-convite-dev')
|
|
114
|
-
await inviteService.remove(invites.find(inv => inv.status !== 'CANCELLED'))
|
|
115
|
-
expect(bodySentToApi).toBeDefined()
|
|
116
|
-
})
|
|
117
|
-
})
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
/* eslint-disable no-undef */
|
|
2
|
-
|
|
3
|
-
const fs = require('fs')
|
|
4
|
-
const path = require('path')
|
|
5
|
-
|
|
6
|
-
const MiniWebAppFactory = require('../../src/service/factories/MiniWebAppFactory')
|
|
7
|
-
|
|
8
|
-
describe('MiniWebAppFactory', () => {
|
|
9
|
-
let miniWebAppFactory
|
|
10
|
-
beforeEach(() => {
|
|
11
|
-
miniWebAppFactory = new MiniWebAppFactory()
|
|
12
|
-
})
|
|
13
|
-
|
|
14
|
-
describe('.writeAmeConf(project, conf, libsName)', () => {
|
|
15
|
-
it('valida se o miniapp.conf.js foi criado corretamente', async () => {
|
|
16
|
-
let conf = {}
|
|
17
|
-
conf['version'] = '0.1.0'
|
|
18
|
-
|
|
19
|
-
let project = {}
|
|
20
|
-
project['projectPath'] = path.resolve(__dirname, '..', '_fixtures', 'miniWebApp')
|
|
21
|
-
|
|
22
|
-
let libsName = ['eitri-mini-app-sdk-support']
|
|
23
|
-
await miniWebAppFactory.writeAmeConf(project, conf, libsName)
|
|
24
|
-
|
|
25
|
-
let expectedConf = {
|
|
26
|
-
'version': '0.1.0',
|
|
27
|
-
'eitri-mini-app-sdk-support': '2.0.0'
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
let expected = `module.exports = ${JSON.stringify(expectedConf, null, 4)}`
|
|
31
|
-
|
|
32
|
-
const data = fs.readFileSync(path.join(project.projectPath, 'miniapp.conf.js'), {
|
|
33
|
-
encoding: 'utf-8',
|
|
34
|
-
flag: 'r'
|
|
35
|
-
})
|
|
36
|
-
|
|
37
|
-
expect(data).toBe(expected)
|
|
38
|
-
})
|
|
39
|
-
})
|
|
40
|
-
})
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
/* eslint-disable no-undef */
|
|
2
|
-
|
|
3
|
-
const path = require('path')
|
|
4
|
-
const TagTree = require('../../src/service/TagTree')
|
|
5
|
-
const componentsPath = path.resolve(
|
|
6
|
-
__dirname,
|
|
7
|
-
'..',
|
|
8
|
-
'_fixtures',
|
|
9
|
-
'src',
|
|
10
|
-
'components'
|
|
11
|
-
)
|
|
12
|
-
describe('TagTree', () => {
|
|
13
|
-
describe('.tagsFilesSorted(tagsPath)', () => {
|
|
14
|
-
it('ordena os arquivos de acordo com a sua dependencia', async () => {
|
|
15
|
-
let expected = ['TagC.jsx', 'TagB.jsx', 'TagA.jsx', 'TagD.jsx']
|
|
16
|
-
let filesSorted = await new TagTree().tagsFilesSorted(
|
|
17
|
-
componentsPath
|
|
18
|
-
)
|
|
19
|
-
expect(filesSorted).toEqual(expected)
|
|
20
|
-
})
|
|
21
|
-
})
|
|
22
|
-
describe('.extractTagsFromContent(markup)', () => {
|
|
23
|
-
it('encontra as tags dentro de um jsx', () => {
|
|
24
|
-
let markup = '<View><MyTag>Content</MyTag></View>'
|
|
25
|
-
let tags = new TagTree().extractTagsFromContent(markup)
|
|
26
|
-
expect(tags).toContain('View')
|
|
27
|
-
expect(tags).toContain('MyTag')
|
|
28
|
-
})
|
|
29
|
-
})
|
|
30
|
-
describe('.buildTagMap(tagsPath)', () => {
|
|
31
|
-
it('gera uma estrutura das tags em um diretorio', async () => {
|
|
32
|
-
let expected = {
|
|
33
|
-
TagA: {
|
|
34
|
-
name: 'TagA',
|
|
35
|
-
fileName: 'TagA.jsx',
|
|
36
|
-
children: [
|
|
37
|
-
{
|
|
38
|
-
name: 'TagB',
|
|
39
|
-
fileName: 'TagB.jsx',
|
|
40
|
-
children: [
|
|
41
|
-
{
|
|
42
|
-
name: 'TagC',
|
|
43
|
-
fileName: 'TagC.jsx',
|
|
44
|
-
children: [],
|
|
45
|
-
},
|
|
46
|
-
],
|
|
47
|
-
},
|
|
48
|
-
{
|
|
49
|
-
name: 'TagC',
|
|
50
|
-
fileName: 'TagC.jsx',
|
|
51
|
-
children: [],
|
|
52
|
-
},
|
|
53
|
-
],
|
|
54
|
-
},
|
|
55
|
-
TagB: {
|
|
56
|
-
name: 'TagB',
|
|
57
|
-
fileName: 'TagB.jsx',
|
|
58
|
-
children: [
|
|
59
|
-
{
|
|
60
|
-
name: 'TagC',
|
|
61
|
-
fileName: 'TagC.jsx',
|
|
62
|
-
children: [],
|
|
63
|
-
},
|
|
64
|
-
],
|
|
65
|
-
},
|
|
66
|
-
TagC: {
|
|
67
|
-
name: 'TagC',
|
|
68
|
-
fileName: 'TagC.jsx',
|
|
69
|
-
children: [],
|
|
70
|
-
},
|
|
71
|
-
TagD: {
|
|
72
|
-
name: 'TagD',
|
|
73
|
-
fileName: 'TagD.jsx',
|
|
74
|
-
children: [],
|
|
75
|
-
},
|
|
76
|
-
}
|
|
77
|
-
let tree = await new TagTree().buildTagMap(componentsPath)
|
|
78
|
-
expect(tree).toEqual(expected)
|
|
79
|
-
})
|
|
80
|
-
})
|
|
81
|
-
})
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
/* eslint-disable no-undef */
|
|
2
|
-
const TargetService = require('../../src/service/TargetService')
|
|
3
|
-
const {workspace} = require('../../src/service/Workspace')
|
|
4
|
-
const nock = require('nock')
|
|
5
|
-
describe('TargetService Tests', () => {
|
|
6
|
-
/**
|
|
7
|
-
* @type {TargetService}
|
|
8
|
-
*/
|
|
9
|
-
let service, targets
|
|
10
|
-
beforeEach(() => {
|
|
11
|
-
workspace.setServerUrl('https://dev.eitri.calindra.com.br')
|
|
12
|
-
service = new TargetService(workspace)
|
|
13
|
-
targets = [
|
|
14
|
-
{
|
|
15
|
-
id: 7,
|
|
16
|
-
name: 'CALINDRA_MOBILE',
|
|
17
|
-
minimumCliVersion: '1.16.5',
|
|
18
|
-
boilerplateUrl: 'https://github.com/Calindra/servless-backend-template.git',
|
|
19
|
-
superAppClientLibName: 'eitri-app-client',
|
|
20
|
-
componentsLibName: 'eitri-app-components',
|
|
21
|
-
description: 'AME_DIGITAL_MOBILE',
|
|
22
|
-
status: 'ACTIVE',
|
|
23
|
-
platform: 'mobile',
|
|
24
|
-
targetConfig: [],
|
|
25
|
-
bodyClass: 'eitri-mobile',
|
|
26
|
-
sdkSupport: 'eitri-mini-app-sdk-support',
|
|
27
|
-
default: true,
|
|
28
|
-
miniAppBoilerplate: [
|
|
29
|
-
{
|
|
30
|
-
name: 'serverless',
|
|
31
|
-
boilerplateUrl: 'https://github.com/Calindra/servless-backend-template.git',
|
|
32
|
-
description: 'Para uso de miniapp com serverless'
|
|
33
|
-
}
|
|
34
|
-
]
|
|
35
|
-
}
|
|
36
|
-
]
|
|
37
|
-
|
|
38
|
-
nock('https://dev.eitri.calindra.com.br', { allowUnmocked: true })
|
|
39
|
-
.get('/workspace/targets')
|
|
40
|
-
.reply(200, targets)
|
|
41
|
-
})
|
|
42
|
-
|
|
43
|
-
it('should return all targets', async () => {
|
|
44
|
-
const response = await service.getTargets()
|
|
45
|
-
expect(response.length).toBeGreaterThan(0)
|
|
46
|
-
expect(response).toEqual(targets)
|
|
47
|
-
})
|
|
48
|
-
})
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
/* eslint-disable no-undef */
|
|
2
|
-
const nock = require('nock')
|
|
3
|
-
const path = require('path')
|
|
4
|
-
const TrackingService = require('../../src/service/TrackingService')
|
|
5
|
-
const { v4: uuidv4 } = require('uuid')
|
|
6
|
-
|
|
7
|
-
describe('TrackingService', () => {
|
|
8
|
-
let workspace, blindGuardian, trackingService
|
|
9
|
-
|
|
10
|
-
beforeEach(() => {
|
|
11
|
-
nock.cleanAll()
|
|
12
|
-
folder2watch = path.resolve(__dirname, '..', '_fixtures')
|
|
13
|
-
|
|
14
|
-
workspace = require('../../src/service/Workspace').workspace
|
|
15
|
-
// workspace.setFolder2Watch(folder2watch)
|
|
16
|
-
workspace.setServerUrl('https://dev.eitri.calindra.com.br')
|
|
17
|
-
|
|
18
|
-
blindGuardian = workspace.blindGuardian
|
|
19
|
-
blindGuardian.getToken = async () => {
|
|
20
|
-
return { accessToken: 'xpto' }
|
|
21
|
-
}
|
|
22
|
-
trackingService = new TrackingService(blindGuardian)
|
|
23
|
-
})
|
|
24
|
-
|
|
25
|
-
it('testa envio de error', async () => {
|
|
26
|
-
let params = []
|
|
27
|
-
nock('https://www.google-analytics.com')
|
|
28
|
-
.get('/collect')
|
|
29
|
-
.query(q => {
|
|
30
|
-
params.push(q)
|
|
31
|
-
return true
|
|
32
|
-
})
|
|
33
|
-
.reply(200, '')
|
|
34
|
-
.persist()
|
|
35
|
-
await trackingService.sendError(new Error('Meu erro'))
|
|
36
|
-
expect(params[0].v).toBe('1')
|
|
37
|
-
expect(params[0].exd).toContain('Meu erro')
|
|
38
|
-
expect(params[0].exd).toContain(path.basename(__filename))
|
|
39
|
-
})
|
|
40
|
-
|
|
41
|
-
it('testa envio de save', async () => {
|
|
42
|
-
let params = []
|
|
43
|
-
nock('https://www.google-analytics.com')
|
|
44
|
-
.get('/collect')
|
|
45
|
-
.query(q => {
|
|
46
|
-
params.push(q)
|
|
47
|
-
return true
|
|
48
|
-
})
|
|
49
|
-
.reply(200, '')
|
|
50
|
-
.persist()
|
|
51
|
-
let event = {
|
|
52
|
-
superClientVersion: '1.2.2',
|
|
53
|
-
componentsVersion: '1.4.5',
|
|
54
|
-
miniAppSlug: 'algum-slug',
|
|
55
|
-
miniAppVersion: '0.1.0',
|
|
56
|
-
timeMs: 3000,
|
|
57
|
-
}
|
|
58
|
-
await trackingService.sendSave(event)
|
|
59
|
-
expect(params[0].v).toBe('1')
|
|
60
|
-
})
|
|
61
|
-
|
|
62
|
-
it('testa envio de publish', async () => {
|
|
63
|
-
let params = []
|
|
64
|
-
nock('https://www.google-analytics.com')
|
|
65
|
-
.get('/collect')
|
|
66
|
-
.query(q => {
|
|
67
|
-
params.push(q)
|
|
68
|
-
return true
|
|
69
|
-
})
|
|
70
|
-
.reply(200, '')
|
|
71
|
-
.persist()
|
|
72
|
-
trackingService._clientId = uuidv4()
|
|
73
|
-
let event = {
|
|
74
|
-
superClientVersion: '1.2.2',
|
|
75
|
-
componentsVersion: '1.4.5',
|
|
76
|
-
miniAppSlug: 'algum-slug',
|
|
77
|
-
miniAppVersion: '0.1.0',
|
|
78
|
-
timeMs: 3000,
|
|
79
|
-
}
|
|
80
|
-
await trackingService.sendPublish(event)
|
|
81
|
-
expect(params[0].v).toBe('1')
|
|
82
|
-
})
|
|
83
|
-
|
|
84
|
-
it('testa envio de build', async () => {
|
|
85
|
-
let params = []
|
|
86
|
-
nock('https://www.google-analytics.com')
|
|
87
|
-
.get('/collect')
|
|
88
|
-
.query(q => {
|
|
89
|
-
params.push(q)
|
|
90
|
-
return true
|
|
91
|
-
})
|
|
92
|
-
.reply(200, '')
|
|
93
|
-
.persist()
|
|
94
|
-
trackingService._clientId = uuidv4()
|
|
95
|
-
let event = {
|
|
96
|
-
superClientVersion: '1.2.2',
|
|
97
|
-
componentsVersion: '1.4.5',
|
|
98
|
-
miniAppSlug: 'algum-slug',
|
|
99
|
-
miniAppVersion: '0.1.0',
|
|
100
|
-
timeMs: 3000,
|
|
101
|
-
}
|
|
102
|
-
await trackingService.sendBuild(event)
|
|
103
|
-
expect(params[0].v).toBe('1')
|
|
104
|
-
})
|
|
105
|
-
})
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
/* eslint-disable no-undef */
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const BlindGuardian = require('../../src/service/BlindGuardian')
|
|
5
|
-
|
|
6
|
-
describe('UserAmeConf', () => {
|
|
7
|
-
let blindGuardian
|
|
8
|
-
|
|
9
|
-
beforeEach(() => {
|
|
10
|
-
blindGuardian = new BlindGuardian()
|
|
11
|
-
})
|
|
12
|
-
|
|
13
|
-
it('deve ler arquivo de configuracao do [env].conf na versão antiga', () => {
|
|
14
|
-
blindGuardian.readConf = () => {
|
|
15
|
-
return {
|
|
16
|
-
devUser: 'foo',
|
|
17
|
-
devKey: 'bar',
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
let credential = blindGuardian.readClientCredentials()
|
|
22
|
-
expect(credential.client_id).toEqual('foo')
|
|
23
|
-
expect(credential.client_secret).toEqual('bar')
|
|
24
|
-
})
|
|
25
|
-
|
|
26
|
-
it('deve ler arquivo de configuracao do [env].conf com configuracões distintas para diversos ambientes', () => {
|
|
27
|
-
|
|
28
|
-
blindGuardian.readConf = () => {
|
|
29
|
-
return {
|
|
30
|
-
'test': {
|
|
31
|
-
'devUser': 'foo-test',
|
|
32
|
-
'devKey': 'bar-test'
|
|
33
|
-
},
|
|
34
|
-
'local': {
|
|
35
|
-
'devUser': 'foo-local',
|
|
36
|
-
'devKey': 'bar-local'
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
let credential = blindGuardian.readClientCredentials()
|
|
42
|
-
expect(credential.client_id).toEqual('foo-test')
|
|
43
|
-
expect(credential.client_secret).toEqual('bar-test')
|
|
44
|
-
})
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
})
|
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
/* eslint-disable no-undef */
|
|
2
|
-
const fs = require('fs')
|
|
3
|
-
const path = require('path')
|
|
4
|
-
|
|
5
|
-
const WoodCoffeeFactory = require('../../src/service/factories/WoodCoffeeFactory')
|
|
6
|
-
const { after } = require('../../node_modules/cheerio/lib/api/manipulation')
|
|
7
|
-
const { getTarget } = require('../_fixtures/factory')
|
|
8
|
-
const child_process = require('child_process')
|
|
9
|
-
|
|
10
|
-
describe('WoodCoffeeFactory', () => {
|
|
11
|
-
let woodCoffeeFactory
|
|
12
|
-
beforeEach(() => {
|
|
13
|
-
woodCoffeeFactory = new WoodCoffeeFactory()
|
|
14
|
-
})
|
|
15
|
-
describe('.validateFileName(projectName)', () => {
|
|
16
|
-
it('valida o nome do projeto contra caracteres estranhos', async () => {
|
|
17
|
-
let valid = woodCoffeeFactory.validateFileName('../lalala')
|
|
18
|
-
expect(valid).toBe(false)
|
|
19
|
-
})
|
|
20
|
-
it('valida pasta aux da morte do windows', async () => {
|
|
21
|
-
let valid = woodCoffeeFactory.validateFileName('aux')
|
|
22
|
-
expect(valid).toBe(false)
|
|
23
|
-
})
|
|
24
|
-
it('valida um nome ok', async () => {
|
|
25
|
-
let valid = woodCoffeeFactory.validateFileName('meu-projeto')
|
|
26
|
-
expect(valid).toBe(true)
|
|
27
|
-
})
|
|
28
|
-
})
|
|
29
|
-
describe('.writeAmeConf(project, conf, libsName)', () => {
|
|
30
|
-
it('valida se o miniapp.conf.js foi criado corretamente', async () => {
|
|
31
|
-
let conf = {}
|
|
32
|
-
conf['version'] = '0.1.0'
|
|
33
|
-
|
|
34
|
-
let project = {}
|
|
35
|
-
project['projectPath'] = path.resolve(__dirname, '..', '_fixtures', 'woodcoffee')
|
|
36
|
-
|
|
37
|
-
jest.spyOn(woodCoffeeFactory, '_getLatestLibVersion').mockReturnValueOnce('0.0.1')
|
|
38
|
-
|
|
39
|
-
let libsName = ['test_lib_1']
|
|
40
|
-
await woodCoffeeFactory.writeAmeConf(project, conf, libsName)
|
|
41
|
-
|
|
42
|
-
let expectedConf = {
|
|
43
|
-
version: '0.1.0'
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
let expected = `module.exports = ${JSON.stringify(expectedConf, null, 4)}`
|
|
47
|
-
|
|
48
|
-
const data = fs.readFileSync(path.join(project.projectPath, 'miniapp.conf.js'), {
|
|
49
|
-
encoding: 'utf-8',
|
|
50
|
-
flag: 'r'
|
|
51
|
-
})
|
|
52
|
-
|
|
53
|
-
expect(data).toBe(expected)
|
|
54
|
-
})
|
|
55
|
-
})
|
|
56
|
-
|
|
57
|
-
describe('.template(projectName, templateUrl, projectPath)', () => {
|
|
58
|
-
const COMPONENTS_LIBRARY_VERSION_HIGHLIGHTER = '###COMPONENTS_LIBRARY_VERSION_HIGHLIGHTER###'
|
|
59
|
-
const SUPER_APP_CLIENT_VERSION_HIGHLIGHTER = '###SUPER_APP_CLIENT_VERSION_HIGHLIGHTER###'
|
|
60
|
-
const templateFileName = 'AboutTemplate.jsx'
|
|
61
|
-
const aboutTemplatePath = path.join(path.dirname(__dirname), '_fixtures', 'src', 'views', templateFileName)
|
|
62
|
-
const destinyFolder = path.join(path.dirname(__dirname), '_fixtures', 'src', 'views', 'About.jsx')
|
|
63
|
-
let target;
|
|
64
|
-
beforeEach(() => {
|
|
65
|
-
target = getTarget()
|
|
66
|
-
fs.copyFile(aboutTemplatePath, destinyFolder, (error) => {
|
|
67
|
-
|
|
68
|
-
if (error) {
|
|
69
|
-
console.error(`O arquivo [${templateFileName}] não foi copiado para a pasta de destino [${destinyFolder}] \n`, error)
|
|
70
|
-
return
|
|
71
|
-
}
|
|
72
|
-
})
|
|
73
|
-
})
|
|
74
|
-
|
|
75
|
-
afterEach(() => {
|
|
76
|
-
fs.unlink(destinyFolder, (error) => {
|
|
77
|
-
if (error) {
|
|
78
|
-
console.error(`O arquivo [${templateFileName}] não foi deletado do destino [${destinyFolder}] \n`, error)
|
|
79
|
-
return
|
|
80
|
-
}
|
|
81
|
-
})
|
|
82
|
-
})
|
|
83
|
-
|
|
84
|
-
it('deve verificar se as versões das bibliotecas foram atualizadas', async () => {
|
|
85
|
-
const file = await getFile()
|
|
86
|
-
expect(file.includes(COMPONENTS_LIBRARY_VERSION_HIGHLIGHTER) && file.includes(SUPER_APP_CLIENT_VERSION_HIGHLIGHTER)).toBeTruthy()
|
|
87
|
-
const newConf = {
|
|
88
|
-
'eitri-app-client': '2.26.0',
|
|
89
|
-
'eitri-app-components': '2.26.0'
|
|
90
|
-
}
|
|
91
|
-
await woodCoffeeFactory.updateAboutJSXFile(destinyFolder, newConf)
|
|
92
|
-
|
|
93
|
-
const updatedFile = await getFile()
|
|
94
|
-
expect(updatedFile.includes('2.26.0') && updatedFile.includes('2.26.0')).toBeTruthy()
|
|
95
|
-
})
|
|
96
|
-
|
|
97
|
-
it('deve lançar um erro quando o About.jsx for baixado sem os marcadores', async () => {
|
|
98
|
-
await updateFile()
|
|
99
|
-
try {
|
|
100
|
-
const result = await woodCoffeeFactory.checkAboutJsx(destinyFolder)
|
|
101
|
-
expect(result).toBe('Caiu aqui tá errado!')
|
|
102
|
-
} catch (error) {
|
|
103
|
-
expect(error.message).toBe('Faltam placeholders para exibicao da versao do components e client')
|
|
104
|
-
|
|
105
|
-
}
|
|
106
|
-
})
|
|
107
|
-
|
|
108
|
-
it('deve usar o arquivo de template ao invés do baixado no github', async () => {
|
|
109
|
-
await updateFile()
|
|
110
|
-
jest.spyOn(woodCoffeeFactory, 'downloadFromGithub').mockResolvedValueOnce(new Promise(resolve => resolve()))
|
|
111
|
-
jest.spyOn(woodCoffeeFactory, '_getLatestLibVersion').mockReturnValueOnce(() => '2.26.0')
|
|
112
|
-
jest.spyOn(child_process, 'execSync').mockReturnValue("2.26.0")
|
|
113
|
-
const projectPath = path.join(path.dirname(__dirname), '_fixtures')
|
|
114
|
-
await woodCoffeeFactory.template('woodcoffee', 'https://template-url', projectPath, target)
|
|
115
|
-
const updatedFile = await getFile()
|
|
116
|
-
expect(updatedFile.includes('2.26.0') && updatedFile.includes('2.26.0')).toBeTruthy()
|
|
117
|
-
})
|
|
118
|
-
|
|
119
|
-
async function updateFile() {
|
|
120
|
-
const contents = await getFile()
|
|
121
|
-
return new Promise((resolve, reject) => {
|
|
122
|
-
const replaced = contents
|
|
123
|
-
.replace(COMPONENTS_LIBRARY_VERSION_HIGHLIGHTER, '2.0.0')
|
|
124
|
-
.replace(SUPER_APP_CLIENT_VERSION_HIGHLIGHTER, '2.8.1')
|
|
125
|
-
fs.writeFile(destinyFolder, replaced, 'utf-8', function (err) {
|
|
126
|
-
if (err) {
|
|
127
|
-
console.log(err)
|
|
128
|
-
reject()
|
|
129
|
-
}
|
|
130
|
-
resolve()
|
|
131
|
-
})
|
|
132
|
-
})
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
function getFile() {
|
|
136
|
-
return new Promise((resolve, reject) => {
|
|
137
|
-
fs.readFile(destinyFolder, 'utf-8', function (err, contents) {
|
|
138
|
-
if (err) {
|
|
139
|
-
console.log(err)
|
|
140
|
-
reject(err)
|
|
141
|
-
}
|
|
142
|
-
resolve(contents)
|
|
143
|
-
})
|
|
144
|
-
|
|
145
|
-
})
|
|
146
|
-
}
|
|
147
|
-
})
|
|
148
|
-
})
|