@sprucelabs/spruce-cli 15.2.16 → 15.2.19
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/CHANGELOG.md +24 -0
- package/build/.spruce/events/events.contract.d.ts +102 -4
- package/build/.spruce/events/events.contract.js +3 -1
- package/build/.spruce/events/events.contract.js.map +1 -1
- package/build/.spruce/events/heartwood/didRegisterSkillViews.v2021_02_11.contract.d.ts +15 -0
- package/build/.spruce/events/heartwood/didRegisterSkillViews.v2021_02_11.contract.js +18 -3
- package/build/.spruce/events/heartwood/didRegisterSkillViews.v2021_02_11.contract.js.map +1 -1
- package/build/.spruce/events/heartwood/generateUrl.v2021_02_11.contract.d.ts +21 -4
- package/build/.spruce/events/heartwood/generateUrl.v2021_02_11.contract.js +24 -7
- package/build/.spruce/events/heartwood/generateUrl.v2021_02_11.contract.js.map +1 -1
- package/build/.spruce/events/heartwood/getSkillViews.v2021_02_11.contract.d.ts +18 -1
- package/build/.spruce/events/heartwood/getSkillViews.v2021_02_11.contract.js +21 -4
- package/build/.spruce/events/heartwood/getSkillViews.v2021_02_11.contract.js.map +1 -1
- package/build/.spruce/events/heartwood/listViews.v2021_02_11.contract.d.ts +39 -0
- package/build/.spruce/events/heartwood/listViews.v2021_02_11.contract.js +53 -0
- package/build/.spruce/events/heartwood/listViews.v2021_02_11.contract.js.map +1 -0
- package/build/.spruce/events/heartwood/registerSkillViews.v2021_02_11.contract.d.ts +11 -0
- package/build/.spruce/events/heartwood/registerSkillViews.v2021_02_11.contract.js +13 -2
- package/build/.spruce/events/heartwood/registerSkillViews.v2021_02_11.contract.js.map +1 -1
- package/build/__tests__/behavioral/skill/UpgradingASkill.test.d.ts +0 -7
- package/build/__tests__/behavioral/skill/UpgradingASkill.test.js +38 -403
- package/build/__tests__/behavioral/skill/UpgradingASkill.test.js.map +1 -1
- package/build/__tests__/behavioral/skill/UpgradingASkill2.test.d.ts +7 -15
- package/build/__tests__/behavioral/skill/UpgradingASkill2.test.js +218 -341
- package/build/__tests__/behavioral/skill/UpgradingASkill2.test.js.map +1 -1
- package/build/__tests__/behavioral/skill/UpgradingASkill3.test.d.ts +16 -5
- package/build/__tests__/behavioral/skill/UpgradingASkill3.test.js +416 -141
- package/build/__tests__/behavioral/skill/UpgradingASkill3.test.js.map +1 -1
- package/build/__tests__/behavioral/skill/UpgradingASkill4.test.d.ts +5 -8
- package/build/__tests__/behavioral/skill/UpgradingASkill4.test.js +147 -205
- package/build/__tests__/behavioral/skill/UpgradingASkill4.test.js.map +1 -1
- package/build/__tests__/behavioral/skill/UpgradingASkill5.test.d.ts +11 -0
- package/build/__tests__/behavioral/skill/UpgradingASkill5.test.js +357 -0
- package/build/__tests__/behavioral/skill/UpgradingASkill5.test.js.map +1 -0
- package/build/__tests__/behavioral/tests/CreatingATest.test.d.ts +3 -0
- package/build/__tests__/behavioral/tests/CreatingATest.test.js +142 -45
- package/build/__tests__/behavioral/tests/CreatingATest.test.js.map +1 -1
- package/package.json +74 -36
- package/src/.spruce/events/events.contract.ts +6 -0
- package/src/.spruce/events/heartwood/didRegisterSkillViews.v2021_02_11.contract.ts +15 -0
- package/src/.spruce/events/heartwood/generateUrl.v2021_02_11.contract.ts +21 -4
- package/src/.spruce/events/heartwood/getSkillViews.v2021_02_11.contract.ts +18 -1
- package/src/.spruce/events/heartwood/listViews.v2021_02_11.contract.ts +47 -0
- package/src/.spruce/events/heartwood/registerSkillViews.v2021_02_11.contract.ts +11 -0
- package/src/__tests__/behavioral/skill/UpgradingASkill.test.ts +0 -184
- package/src/__tests__/behavioral/skill/UpgradingASkill2.test.ts +120 -157
- package/src/__tests__/behavioral/skill/UpgradingASkill3.test.ts +184 -78
- package/src/__tests__/behavioral/skill/UpgradingASkill4.test.ts +90 -91
- package/src/__tests__/behavioral/skill/UpgradingASkill5.test.ts +128 -0
- package/src/__tests__/behavioral/tests/CreatingATest.test.ts +29 -12
|
@@ -1,233 +1,196 @@
|
|
|
1
|
-
import
|
|
1
|
+
import fsUtil from 'fs'
|
|
2
2
|
import { diskUtil } from '@sprucelabs/spruce-skill-utils'
|
|
3
3
|
import { test, assert } from '@sprucelabs/test'
|
|
4
|
-
import SyncAction from '../../../features/error/actions/SyncAction'
|
|
5
|
-
import UpdateDependenciesAction from '../../../features/node/actions/UpdateDependenciesAction'
|
|
6
4
|
import CommandService from '../../../services/CommandService'
|
|
7
5
|
import AbstractCliTest from '../../../tests/AbstractCliTest'
|
|
8
6
|
import testUtil from '../../../tests/utilities/test.utility'
|
|
9
7
|
export default class UpgradingASkill2Test extends AbstractCliTest {
|
|
10
|
-
private static originalErrorSyncExecute: any
|
|
11
8
|
protected static async beforeEach() {
|
|
12
|
-
if (!this.originalErrorSyncExecute) {
|
|
13
|
-
this.originalErrorSyncExecute = SyncAction.prototype.execute
|
|
14
|
-
} else {
|
|
15
|
-
SyncAction.prototype.execute = this.originalErrorSyncExecute
|
|
16
|
-
}
|
|
17
|
-
|
|
18
9
|
await super.beforeEach()
|
|
19
10
|
CommandService.setMockResponse(new RegExp(/yarn rebuild/gis), {
|
|
20
11
|
code: 0,
|
|
21
12
|
})
|
|
22
13
|
}
|
|
23
14
|
|
|
24
|
-
@test(
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
15
|
+
@test(
|
|
16
|
+
'Upgrades error.plugin (even if skill is broken)',
|
|
17
|
+
'error.plugin.ts',
|
|
18
|
+
'errors'
|
|
19
|
+
)
|
|
20
|
+
@test(
|
|
21
|
+
'Upgrades schema.plugin (even if skill is broken)',
|
|
22
|
+
'schema.plugin.ts',
|
|
23
|
+
'schemas'
|
|
24
|
+
)
|
|
25
|
+
@test(
|
|
26
|
+
'Upgrades conversation.plugin (even if skill is broken)',
|
|
27
|
+
'conversation.plugin.ts',
|
|
28
|
+
'conversation',
|
|
29
|
+
false
|
|
30
|
+
)
|
|
31
|
+
@test(
|
|
32
|
+
'Upgrades view.plugin (even if skill is broken)',
|
|
33
|
+
'view.plugin.ts',
|
|
34
|
+
'views',
|
|
35
|
+
false
|
|
36
|
+
)
|
|
37
|
+
protected static async upgradesPlugins(
|
|
38
|
+
pluginName: string,
|
|
39
|
+
cacheKey: string,
|
|
40
|
+
shouldMockYarn = true
|
|
41
|
+
) {
|
|
42
|
+
await this.FeatureFixture().installCachedFeatures(cacheKey)
|
|
43
|
+
|
|
44
|
+
shouldMockYarn && CommandService.setMockResponse(/yarn/, { code: 0 })
|
|
45
|
+
|
|
46
|
+
const pluginPath = this.resolveHashSprucePath(`features/${pluginName}`)
|
|
47
|
+
const originalContents = diskUtil.readFile(pluginPath)
|
|
48
|
+
|
|
49
|
+
diskUtil.writeFile(pluginPath, 'aoeuaoeuaoeuaoeu')
|
|
40
50
|
|
|
41
51
|
const results = await this.Action('node', 'upgrade').execute({})
|
|
42
52
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
assert.isFalsy(dependencies['@sprucelabs/resolve-path-aliases'])
|
|
46
|
-
|
|
47
|
-
assert.doesThrow(() =>
|
|
48
|
-
testUtil.assertFileByNameInGeneratedFiles(
|
|
49
|
-
'events.contract.ts',
|
|
50
|
-
results.files
|
|
51
|
-
)
|
|
52
|
-
)
|
|
53
|
-
|
|
54
|
-
this.assertViewPluginNotWritten()
|
|
55
|
-
}
|
|
53
|
+
assert.isFalsy(results.errors)
|
|
56
54
|
|
|
57
|
-
|
|
58
|
-
protected static async upgradingSkillSyncsEvents() {
|
|
59
|
-
await this.FeatureFixture().installCachedFeatures('events')
|
|
55
|
+
testUtil.assertFileByNameInGeneratedFiles(pluginName, results.files)
|
|
60
56
|
|
|
61
|
-
const
|
|
62
|
-
const events = eventDiskUtil.resolveCombinedEventsContractFile(this.cwd)
|
|
57
|
+
const updatedContents = diskUtil.readFile(pluginPath)
|
|
63
58
|
|
|
64
|
-
assert.
|
|
59
|
+
assert.isEqual(updatedContents, originalContents)
|
|
65
60
|
|
|
66
|
-
|
|
67
|
-
'events.contract.ts',
|
|
68
|
-
results.files
|
|
69
|
-
)
|
|
61
|
+
assert.doesInclude(results.summaryLines ?? [], 'successfully')
|
|
70
62
|
}
|
|
71
63
|
|
|
72
64
|
@test()
|
|
73
|
-
protected static async
|
|
65
|
+
protected static async canSkipPackageScriptChanges() {
|
|
74
66
|
await this.FeatureFixture().installCachedFeatures('skills')
|
|
75
67
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
}
|
|
68
|
+
const pkg = this.Service('pkg')
|
|
69
|
+
pkg.set({ path: ['scripts', 'build.dev'], value: 'taco' })
|
|
79
70
|
|
|
80
|
-
const
|
|
71
|
+
const promise = this.Action('node', 'upgrade').execute({})
|
|
81
72
|
|
|
82
|
-
|
|
83
|
-
assert.doesInclude(results.errors[0].message, 'baaaaad')
|
|
84
|
-
}
|
|
73
|
+
await this.waitForInput()
|
|
85
74
|
|
|
86
|
-
|
|
87
|
-
protected static async callsCleanFixAndBuildDev() {
|
|
88
|
-
await this.FeatureFixture().installCachedFeatures('skills')
|
|
75
|
+
const last = this.ui.getLastInvocation()
|
|
89
76
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
}
|
|
77
|
+
assert.isEqual(last.command, 'prompt')
|
|
78
|
+
assert.doesInclude(last.options.options.choices, { value: 'skip' })
|
|
79
|
+
assert.doesInclude(last.options.options.choices, { value: 'skipAll' })
|
|
80
|
+
assert.doesInclude(last.options.options.choices, { value: 'overwrite' })
|
|
94
81
|
|
|
95
|
-
|
|
96
|
-
code: 0,
|
|
97
|
-
callback: () => {
|
|
98
|
-
wasCleanBuildCalled = true
|
|
99
|
-
},
|
|
100
|
-
})
|
|
82
|
+
await this.ui.sendInput('skip')
|
|
101
83
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
CommandService.setMockResponse('yarn build.dev', {
|
|
105
|
-
code: 0,
|
|
106
|
-
callback: () => {
|
|
107
|
-
wasBuildDevCalled = true
|
|
108
|
-
},
|
|
109
|
-
})
|
|
110
|
-
|
|
111
|
-
const results = await this.Action('node', 'upgrade').execute({})
|
|
84
|
+
await promise
|
|
112
85
|
|
|
113
|
-
assert.
|
|
114
|
-
assert.isTrue(wasCleanBuildCalled)
|
|
115
|
-
assert.isTrue(wasBuildDevCalled)
|
|
86
|
+
assert.isEqual(pkg.get(['scripts', 'build.dev']), 'taco')
|
|
116
87
|
}
|
|
117
88
|
|
|
118
89
|
@test()
|
|
119
|
-
protected static async
|
|
120
|
-
await this.FeatureFixture().installCachedFeatures('
|
|
121
|
-
|
|
122
|
-
const plugin = this.getViewsPluginPath()
|
|
123
|
-
assert.isTrue(diskUtil.doesFileExist(plugin))
|
|
90
|
+
protected static async asksForEachScriptChange() {
|
|
91
|
+
await this.FeatureFixture().installCachedFeatures('skills')
|
|
124
92
|
|
|
125
|
-
|
|
93
|
+
const pkg = this.Service('pkg')
|
|
94
|
+
pkg.set({ path: ['scripts', 'build.dev'], value: 'taco' })
|
|
95
|
+
pkg.set({ path: ['scripts', 'watch.build.dev'], value: 'taco' })
|
|
126
96
|
|
|
127
|
-
|
|
97
|
+
const promise = this.Action('node', 'upgrade').execute({})
|
|
128
98
|
|
|
129
|
-
await this.
|
|
99
|
+
await this.waitForInput()
|
|
130
100
|
|
|
131
|
-
|
|
132
|
-
}
|
|
101
|
+
let last = this.ui.getLastInvocation()
|
|
133
102
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
protected static async upgradeSyncsErrors(isInstalled = true) {
|
|
137
|
-
await this.FeatureFixture().installCachedFeatures(
|
|
138
|
-
isInstalled ? 'errors' : 'schemas'
|
|
139
|
-
)
|
|
103
|
+
assert.isEqual(last.command, 'prompt')
|
|
104
|
+
await this.ui.sendInput('skip')
|
|
140
105
|
|
|
141
|
-
|
|
106
|
+
await this.waitForInput()
|
|
142
107
|
|
|
143
|
-
|
|
144
|
-
wasHit = true
|
|
145
|
-
return {}
|
|
146
|
-
}
|
|
108
|
+
last = this.ui.getLastInvocation()
|
|
147
109
|
|
|
148
|
-
|
|
110
|
+
assert.isEqual(last.command, 'prompt')
|
|
111
|
+
await this.ui.sendInput('skip')
|
|
149
112
|
|
|
150
|
-
await
|
|
113
|
+
await promise
|
|
151
114
|
|
|
152
|
-
assert.isEqual(
|
|
115
|
+
assert.isEqual(pkg.get(['scripts', 'build.dev']), 'taco')
|
|
116
|
+
assert.isEqual(pkg.get(['scripts', 'watch.build.dev']), 'taco')
|
|
153
117
|
}
|
|
154
118
|
|
|
155
119
|
@test()
|
|
156
|
-
protected static async
|
|
120
|
+
protected static async canSkipAllScriptChanges() {
|
|
157
121
|
await this.FeatureFixture().installCachedFeatures('skills')
|
|
158
122
|
|
|
159
|
-
const
|
|
123
|
+
const pkg = this.Service('pkg')
|
|
124
|
+
pkg.set({ path: ['scripts', 'build.dev'], value: 'taco' })
|
|
125
|
+
pkg.set({ path: ['scripts', 'watch.build.dev'], value: 'taco' })
|
|
160
126
|
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
const promise = this.Action('node', 'upgrade').execute({
|
|
164
|
-
upgradeMode: 'askForChanged',
|
|
165
|
-
})
|
|
127
|
+
const promise = this.Action('node', 'upgrade').execute({})
|
|
166
128
|
|
|
167
129
|
await this.waitForInput()
|
|
168
|
-
await this.ui.sendInput('overwrite')
|
|
169
130
|
|
|
170
|
-
|
|
131
|
+
let last = this.ui.getLastInvocation()
|
|
171
132
|
|
|
172
|
-
|
|
133
|
+
assert.isEqual(last.command, 'prompt')
|
|
134
|
+
await this.ui.sendInput('skipAll')
|
|
173
135
|
|
|
174
|
-
|
|
136
|
+
await promise
|
|
137
|
+
|
|
138
|
+
assert.isEqual(pkg.get(['scripts', 'build.dev']), 'taco')
|
|
139
|
+
assert.isEqual(pkg.get(['scripts', 'watch.build.dev']), 'taco')
|
|
175
140
|
}
|
|
176
141
|
|
|
177
142
|
@test()
|
|
178
|
-
protected static async
|
|
179
|
-
await this.FeatureFixture().installCachedFeatures('
|
|
143
|
+
protected static async canOverwriteChangedScript() {
|
|
144
|
+
await this.FeatureFixture().installCachedFeatures('skills')
|
|
180
145
|
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
nameCamel: 'testPass',
|
|
184
|
-
})
|
|
146
|
+
const pkg = this.Service('pkg')
|
|
147
|
+
pkg.set({ path: ['scripts', 'build.dev'], value: 'taco' })
|
|
185
148
|
|
|
186
|
-
const
|
|
149
|
+
const promise = this.Action('node', 'upgrade').execute({})
|
|
187
150
|
|
|
188
|
-
this.
|
|
151
|
+
await this.waitForInput()
|
|
189
152
|
|
|
190
|
-
|
|
191
|
-
upgradeMode: 'askForChanged',
|
|
192
|
-
})
|
|
153
|
+
let last = this.ui.getLastInvocation()
|
|
193
154
|
|
|
194
|
-
assert.
|
|
195
|
-
|
|
155
|
+
assert.isEqual(last.command, 'prompt')
|
|
156
|
+
await this.ui.sendInput('overwrite')
|
|
157
|
+
|
|
158
|
+
await promise
|
|
196
159
|
|
|
197
|
-
assert.
|
|
160
|
+
assert.isNotEqual(pkg.get(['scripts', 'build.dev']), 'taco')
|
|
198
161
|
}
|
|
199
162
|
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
163
|
+
@test()
|
|
164
|
+
protected static async upgradingSkillWithSandboxUpgradesTheListener() {
|
|
165
|
+
await this.FeatureFixture().installCachedFeatures('sandbox')
|
|
166
|
+
const results = await this.Action('sandbox', 'setup').execute({})
|
|
203
167
|
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
168
|
+
const match = testUtil.assertFileByNameInGeneratedFiles(
|
|
169
|
+
/will-boot/,
|
|
170
|
+
results.files
|
|
171
|
+
)
|
|
207
172
|
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
}
|
|
173
|
+
const originalContents = diskUtil.readFile(match)
|
|
174
|
+
diskUtil.writeFile(match, 'broken')
|
|
211
175
|
|
|
212
|
-
|
|
213
|
-
assert.isFalse(diskUtil.doesFileExist(this.getViewsPluginPath()))
|
|
214
|
-
}
|
|
176
|
+
CommandService.setMockResponse(/yarn/, { code: 0 })
|
|
215
177
|
|
|
216
|
-
|
|
217
|
-
this.disableCleanAndBuild()
|
|
178
|
+
await this.Action('node', 'upgrade').execute({})
|
|
218
179
|
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
})
|
|
180
|
+
const newContents = diskUtil.readFile(match)
|
|
181
|
+
assert.isEqual(originalContents, newContents)
|
|
222
182
|
}
|
|
223
183
|
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
184
|
+
protected static assertSandboxListenerNotWritten() {
|
|
185
|
+
const listeners = this.resolvePath('src', 'listeners')
|
|
186
|
+
if (!diskUtil.doesDirExist(listeners)) {
|
|
187
|
+
return
|
|
188
|
+
}
|
|
189
|
+
const matches = fsUtil.readdirSync(listeners)
|
|
190
|
+
assert.isLength(
|
|
191
|
+
matches,
|
|
192
|
+
0,
|
|
193
|
+
'A sandbox listeners was written and it should not have been.'
|
|
194
|
+
)
|
|
232
195
|
}
|
|
233
196
|
}
|
|
@@ -1,11 +1,20 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { eventDiskUtil } from '@sprucelabs/spruce-event-utils'
|
|
2
2
|
import { diskUtil } from '@sprucelabs/spruce-skill-utils'
|
|
3
3
|
import { test, assert } from '@sprucelabs/test'
|
|
4
|
+
import SyncAction from '../../../features/error/actions/SyncAction'
|
|
5
|
+
import UpdateDependenciesAction from '../../../features/node/actions/UpdateDependenciesAction'
|
|
4
6
|
import CommandService from '../../../services/CommandService'
|
|
5
7
|
import AbstractCliTest from '../../../tests/AbstractCliTest'
|
|
6
|
-
|
|
7
|
-
export default class
|
|
8
|
+
import testUtil from '../../../tests/utilities/test.utility'
|
|
9
|
+
export default class UpgradingASkill3Test extends AbstractCliTest {
|
|
10
|
+
private static originalErrorSyncExecute: any
|
|
8
11
|
protected static async beforeEach() {
|
|
12
|
+
if (!this.originalErrorSyncExecute) {
|
|
13
|
+
this.originalErrorSyncExecute = SyncAction.prototype.execute
|
|
14
|
+
} else {
|
|
15
|
+
SyncAction.prototype.execute = this.originalErrorSyncExecute
|
|
16
|
+
}
|
|
17
|
+
|
|
9
18
|
await super.beforeEach()
|
|
10
19
|
CommandService.setMockResponse(new RegExp(/yarn rebuild/gis), {
|
|
11
20
|
code: 0,
|
|
@@ -13,115 +22,212 @@ export default class UpgradingASkillTest extends AbstractCliTest {
|
|
|
13
22
|
}
|
|
14
23
|
|
|
15
24
|
@test()
|
|
16
|
-
protected static async
|
|
25
|
+
protected static async doesNotAddResolvePathAliasesToDependenciesAfterUpgrade() {
|
|
26
|
+
CommandService.clearMockResponses()
|
|
17
27
|
await this.FeatureFixture().installCachedFeatures('views')
|
|
18
28
|
|
|
19
|
-
|
|
20
|
-
|
|
29
|
+
await this.Action('node', 'upgrade').execute({})
|
|
30
|
+
|
|
31
|
+
const dependencies = this.Service('pkg').get('dependencies')
|
|
32
|
+
|
|
33
|
+
assert.isFalsy(dependencies['@sprucelabs/resolve-path-aliases'])
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
@test()
|
|
37
|
+
protected static async featuresNotEnabledDontInstall() {
|
|
38
|
+
CommandService.clearMockResponses()
|
|
39
|
+
await this.FeatureFixture().installCachedFeatures('schemas')
|
|
40
|
+
|
|
41
|
+
const results = await this.Action('node', 'upgrade').execute({})
|
|
42
|
+
|
|
43
|
+
const dependencies = this.Service('pkg').get('dependencies')
|
|
44
|
+
|
|
45
|
+
assert.isFalsy(dependencies['@sprucelabs/resolve-path-aliases'])
|
|
46
|
+
|
|
47
|
+
assert.doesThrow(() =>
|
|
48
|
+
testUtil.assertFileByNameInGeneratedFiles(
|
|
49
|
+
'events.contract.ts',
|
|
50
|
+
results.files
|
|
51
|
+
)
|
|
21
52
|
)
|
|
22
53
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
54
|
+
this.assertViewPluginNotWritten()
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
@test()
|
|
58
|
+
protected static async upgradingSkillSyncsEvents() {
|
|
59
|
+
await this.FeatureFixture().installCachedFeatures('events')
|
|
60
|
+
|
|
61
|
+
const results = await this.Action('node', 'upgrade').execute({})
|
|
62
|
+
const events = eventDiskUtil.resolveCombinedEventsContractFile(this.cwd)
|
|
63
|
+
|
|
64
|
+
assert.isTrue(diskUtil.doesFileExist(events))
|
|
65
|
+
|
|
66
|
+
testUtil.assertFileByNameInGeneratedFiles(
|
|
67
|
+
'events.contract.ts',
|
|
68
|
+
results.files
|
|
69
|
+
)
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
@test()
|
|
73
|
+
protected static async upgradeCallsUpdateDependencies() {
|
|
74
|
+
await this.FeatureFixture().installCachedFeatures('skills')
|
|
39
75
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
pkg.unset(['dependencies', check.nodeModule])
|
|
43
|
-
}
|
|
44
|
-
if (check.plugin) {
|
|
45
|
-
diskUtil.deleteFile(check.plugin)
|
|
46
|
-
}
|
|
76
|
+
UpdateDependenciesAction.prototype.execute = () => {
|
|
77
|
+
throw new Error('baaaaad')
|
|
47
78
|
}
|
|
48
79
|
|
|
49
|
-
|
|
50
|
-
CommandService.setMockResponse(/yarn build.dev/, { code: 0 })
|
|
80
|
+
const results = await this.Action('node', 'upgrade').execute({})
|
|
51
81
|
|
|
52
|
-
|
|
82
|
+
assert.isTruthy(results.errors)
|
|
83
|
+
assert.doesInclude(results.errors[0].message, 'baaaaad')
|
|
84
|
+
}
|
|
53
85
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}
|
|
61
|
-
if (check.plugin) {
|
|
62
|
-
assert.isTrue(
|
|
63
|
-
diskUtil.doesFileExist(check.plugin),
|
|
64
|
-
`${check.plugin} was not rewritten.`
|
|
65
|
-
)
|
|
66
|
-
}
|
|
86
|
+
@test()
|
|
87
|
+
protected static async callsCleanFixAndBuildDev() {
|
|
88
|
+
await this.FeatureFixture().installCachedFeatures('skills')
|
|
89
|
+
|
|
90
|
+
let wasCleanBuildCalled = false
|
|
91
|
+
UpdateDependenciesAction.prototype.execute = async () => {
|
|
92
|
+
return {}
|
|
67
93
|
}
|
|
94
|
+
|
|
95
|
+
CommandService.setMockResponse('yarn clean.build', {
|
|
96
|
+
code: 0,
|
|
97
|
+
callback: () => {
|
|
98
|
+
wasCleanBuildCalled = true
|
|
99
|
+
},
|
|
100
|
+
})
|
|
101
|
+
|
|
102
|
+
let wasBuildDevCalled = false
|
|
103
|
+
|
|
104
|
+
CommandService.setMockResponse('yarn build.dev', {
|
|
105
|
+
code: 0,
|
|
106
|
+
callback: () => {
|
|
107
|
+
wasBuildDevCalled = true
|
|
108
|
+
},
|
|
109
|
+
})
|
|
110
|
+
|
|
111
|
+
const results = await this.Action('node', 'upgrade').execute({})
|
|
112
|
+
|
|
113
|
+
assert.isFalsy(results.errors)
|
|
114
|
+
assert.isTrue(wasCleanBuildCalled)
|
|
115
|
+
assert.isTrue(wasBuildDevCalled)
|
|
68
116
|
}
|
|
69
117
|
|
|
70
118
|
@test()
|
|
71
|
-
protected static async
|
|
72
|
-
|
|
119
|
+
protected static async writesViewPlugin() {
|
|
120
|
+
await this.FeatureFixture().installCachedFeatures('views')
|
|
73
121
|
|
|
74
|
-
const
|
|
122
|
+
const plugin = this.getViewsPluginPath()
|
|
123
|
+
assert.isTrue(diskUtil.doesFileExist(plugin))
|
|
75
124
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
125
|
+
diskUtil.deleteFile(plugin)
|
|
126
|
+
|
|
127
|
+
assert.isFalse(diskUtil.doesFileExist(plugin))
|
|
79
128
|
|
|
80
129
|
await this.Action('node', 'upgrade').execute({})
|
|
81
130
|
|
|
82
|
-
assert.
|
|
131
|
+
assert.isTrue(diskUtil.doesFileExist(plugin))
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
@test('sync with errors installed')
|
|
135
|
+
@test('sync with errors not installed', false)
|
|
136
|
+
protected static async upgradeSyncsErrors(isInstalled = true) {
|
|
137
|
+
await this.FeatureFixture().installCachedFeatures(
|
|
138
|
+
isInstalled ? 'errors' : 'schemas'
|
|
139
|
+
)
|
|
140
|
+
|
|
141
|
+
let wasHit = false
|
|
142
|
+
|
|
143
|
+
SyncAction.prototype.execute = async () => {
|
|
144
|
+
wasHit = true
|
|
145
|
+
return {}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
this.disableCleanBuildAndYarnAdd()
|
|
83
149
|
|
|
84
|
-
this.
|
|
150
|
+
await this.Action('node', 'upgrade').execute({})
|
|
151
|
+
|
|
152
|
+
assert.isEqual(wasHit, isInstalled)
|
|
85
153
|
}
|
|
86
154
|
|
|
87
155
|
@test()
|
|
88
|
-
protected static async
|
|
156
|
+
protected static async resetsErrorPluginInSkill() {
|
|
89
157
|
await this.FeatureFixture().installCachedFeatures('skills')
|
|
90
158
|
|
|
91
|
-
const
|
|
92
|
-
pkg.set({ path: ['scripts', 'build.dev'], value: 'taco' })
|
|
93
|
-
pkg.set({ path: ['scripts', 'watch.build.dev'], value: 'taco' })
|
|
159
|
+
const { plugin, expectedContents } = this.destroyErrorPlugin()
|
|
94
160
|
|
|
95
|
-
|
|
161
|
+
await this.disableCleanBuildAndYarnAdd()
|
|
162
|
+
|
|
163
|
+
const promise = this.Action('node', 'upgrade').execute({
|
|
164
|
+
upgradeMode: 'askForChanged',
|
|
165
|
+
})
|
|
96
166
|
|
|
97
167
|
await this.waitForInput()
|
|
168
|
+
await this.ui.sendInput('overwrite')
|
|
98
169
|
|
|
99
|
-
|
|
170
|
+
await promise
|
|
100
171
|
|
|
101
|
-
|
|
102
|
-
await this.ui.sendInput('overwrite')
|
|
172
|
+
const actualContents = diskUtil.readFile(plugin)
|
|
103
173
|
|
|
104
|
-
|
|
174
|
+
assert.isEqual(actualContents, expectedContents)
|
|
175
|
+
}
|
|
105
176
|
|
|
106
|
-
|
|
107
|
-
|
|
177
|
+
@test()
|
|
178
|
+
protected static async resetsErrorPluginWhenErrorInstalled() {
|
|
179
|
+
await this.FeatureFixture().installCachedFeatures('errors')
|
|
108
180
|
|
|
109
|
-
await
|
|
181
|
+
await this.Action('error', 'create').execute({
|
|
182
|
+
nameReadable: 'Test pass',
|
|
183
|
+
nameCamel: 'testPass',
|
|
184
|
+
})
|
|
185
|
+
|
|
186
|
+
const { plugin, expectedContents } = this.destroyErrorPlugin()
|
|
187
|
+
|
|
188
|
+
this.disableCleanAndBuild()
|
|
189
|
+
|
|
190
|
+
const results = await this.Action('node', 'upgrade').execute({
|
|
191
|
+
upgradeMode: 'askForChanged',
|
|
192
|
+
})
|
|
193
|
+
|
|
194
|
+
assert.isFalsy(results.errors)
|
|
195
|
+
const actualContents = diskUtil.readFile(plugin)
|
|
110
196
|
|
|
111
|
-
assert.
|
|
112
|
-
assert.isNotEqual(pkg.get(['scripts', 'watch.build.dev']), 'taco')
|
|
197
|
+
assert.isEqual(actualContents, expectedContents)
|
|
113
198
|
}
|
|
114
199
|
|
|
115
|
-
|
|
116
|
-
const
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
200
|
+
private static destroyErrorPlugin() {
|
|
201
|
+
const plugin = this.resolveHashSprucePath('errors', 'options.types.ts')
|
|
202
|
+
const expectedContents = diskUtil.readFile(plugin)
|
|
203
|
+
|
|
204
|
+
diskUtil.writeFile(plugin, 'waka')
|
|
205
|
+
return { plugin, expectedContents }
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
private static getViewsPluginPath() {
|
|
209
|
+
return this.resolveHashSprucePath('features', 'view.plugin.ts')
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
protected static assertViewPluginNotWritten() {
|
|
213
|
+
assert.isFalse(diskUtil.doesFileExist(this.getViewsPluginPath()))
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
private static disableCleanBuildAndYarnAdd() {
|
|
217
|
+
this.disableCleanAndBuild()
|
|
218
|
+
|
|
219
|
+
CommandService.setMockResponse(/yarn.*?add/gis, {
|
|
220
|
+
code: 0,
|
|
221
|
+
})
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
private static disableCleanAndBuild() {
|
|
225
|
+
CommandService.setMockResponse('yarn clean.build', {
|
|
226
|
+
code: 0,
|
|
227
|
+
})
|
|
228
|
+
|
|
229
|
+
CommandService.setMockResponse('yarn build.dev', {
|
|
230
|
+
code: 0,
|
|
231
|
+
})
|
|
126
232
|
}
|
|
127
233
|
}
|