@sprucelabs/spruce-cli 15.2.15 → 15.2.18
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/build/__tests__/implementation/EventTemplateItemBuilder.test.d.ts +1 -0
- package/build/__tests__/implementation/EventTemplateItemBuilder.test.js +105 -11
- package/build/__tests__/implementation/EventTemplateItemBuilder.test.js.map +1 -1
- package/build/templateItemBuilders/EventTemplateItemBuilder.js +2 -2
- package/build/templateItemBuilders/EventTemplateItemBuilder.js.map +1 -1
- package/package.json +37 -37
- 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
- package/src/__tests__/implementation/EventTemplateItemBuilder.test.ts +124 -9
- package/src/templateItemBuilders/EventTemplateItemBuilder.ts +8 -2
|
@@ -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
|
}
|
|
@@ -1,128 +1,127 @@
|
|
|
1
|
+
import fsUtil from 'fs'
|
|
2
|
+
import { diskUtil } from '@sprucelabs/spruce-skill-utils'
|
|
1
3
|
import { test, assert } from '@sprucelabs/test'
|
|
2
4
|
import CommandService from '../../../services/CommandService'
|
|
3
5
|
import AbstractCliTest from '../../../tests/AbstractCliTest'
|
|
4
6
|
|
|
5
7
|
export default class UpgradingASkill4Test extends AbstractCliTest {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
this.Action('node', 'upgrade').execute({})
|
|
12
|
-
)
|
|
13
|
-
|
|
14
|
-
const value = this.Settings().getListenerCache()
|
|
15
|
-
assert.isFalsy(value)
|
|
8
|
+
protected static async beforeEach() {
|
|
9
|
+
await super.beforeEach()
|
|
10
|
+
CommandService.setMockResponse(new RegExp(/yarn rebuild/gis), {
|
|
11
|
+
code: 0,
|
|
12
|
+
})
|
|
16
13
|
}
|
|
17
14
|
|
|
18
15
|
@test()
|
|
19
|
-
protected static async
|
|
20
|
-
await this.
|
|
21
|
-
|
|
22
|
-
await assert.doesThrowAsync(() => this.Action('schema', 'sync').execute({}))
|
|
16
|
+
protected static async restoresMissingPackagesAndPlugins() {
|
|
17
|
+
await this.FeatureFixture().installCachedFeatures('views')
|
|
23
18
|
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
@test('syncs schemas when schemas installed and schemas folder exists', true)
|
|
29
|
-
@test(
|
|
30
|
-
'does not syncs schemas when schemas installed but schemas folder does not exist',
|
|
31
|
-
false
|
|
32
|
-
)
|
|
33
|
-
protected static async shouldSyncSchemasIfSchemasIsInstalledAndSchemaFolderExists(
|
|
34
|
-
shouldCreateSchema: boolean
|
|
35
|
-
) {
|
|
36
|
-
await this.FeatureFixture().installCachedFeatures('schemas')
|
|
37
|
-
|
|
38
|
-
CommandService.setMockResponse(new RegExp(/yarn/gis), {
|
|
39
|
-
code: 0,
|
|
40
|
-
})
|
|
19
|
+
const features = this.Service('pkg', process.cwd()).get(
|
|
20
|
+
'testSkillCache.everything'
|
|
21
|
+
)
|
|
41
22
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
23
|
+
const pkg = this.Service('pkg')
|
|
24
|
+
const checks: { nodeModule?: string; plugin?: string }[] = []
|
|
25
|
+
|
|
26
|
+
for (const feat of features) {
|
|
27
|
+
const { code } = feat
|
|
28
|
+
const nodeModule = `@sprucelabs/spruce-${code}-plugin`
|
|
29
|
+
const path = this.resolveHashSprucePath('features', `${code}.plugin.ts`)
|
|
30
|
+
const plugin = diskUtil.doesFileExist(path) ? path : undefined
|
|
31
|
+
|
|
32
|
+
checks.push({
|
|
33
|
+
nodeModule: pkg.get(['dependencies', nodeModule])
|
|
34
|
+
? nodeModule
|
|
35
|
+
: undefined,
|
|
36
|
+
plugin,
|
|
48
37
|
})
|
|
49
38
|
}
|
|
50
39
|
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
await emitter.on('feature.will-execute', (payload) => {
|
|
56
|
-
if (payload.featureCode === 'schema' && payload.actionCode === 'sync') {
|
|
57
|
-
wasHit = true
|
|
40
|
+
for (const check of checks) {
|
|
41
|
+
if (check.nodeModule) {
|
|
42
|
+
pkg.unset(['dependencies', check.nodeModule])
|
|
58
43
|
}
|
|
44
|
+
if (check.plugin) {
|
|
45
|
+
diskUtil.deleteFile(check.plugin)
|
|
46
|
+
}
|
|
47
|
+
}
|
|
59
48
|
|
|
60
|
-
|
|
61
|
-
})
|
|
49
|
+
CommandService.setMockResponse(/yarn clean/, { code: 0 })
|
|
50
|
+
CommandService.setMockResponse(/yarn build.dev/, { code: 0 })
|
|
62
51
|
|
|
63
52
|
await this.Action('node', 'upgrade').execute({})
|
|
64
53
|
|
|
65
|
-
|
|
54
|
+
for (const check of checks) {
|
|
55
|
+
if (check.nodeModule) {
|
|
56
|
+
assert.isTruthy(
|
|
57
|
+
pkg.get(['dependencies', check.nodeModule]),
|
|
58
|
+
`${check.nodeModule} was not added back as a dependencies.`
|
|
59
|
+
)
|
|
60
|
+
}
|
|
61
|
+
if (check.plugin) {
|
|
62
|
+
assert.isTrue(
|
|
63
|
+
diskUtil.doesFileExist(check.plugin),
|
|
64
|
+
`${check.plugin} was not rewritten.`
|
|
65
|
+
)
|
|
66
|
+
}
|
|
67
|
+
}
|
|
66
68
|
}
|
|
67
69
|
|
|
68
70
|
@test()
|
|
69
|
-
protected static async
|
|
70
|
-
await this.FeatureFixture().installCachedFeatures('skills')
|
|
71
|
-
|
|
72
|
-
await this.moveDependencyToProd('@sprucelabs/resolve-path-aliases')
|
|
73
|
-
await this.moveDependencyToDev('@sprucelabs/error')
|
|
71
|
+
protected static async doesNotAskIfNewScriptsAreAddedToSkillFeature() {
|
|
72
|
+
const cli = await this.FeatureFixture().installCachedFeatures('skills')
|
|
74
73
|
|
|
75
|
-
|
|
76
|
-
let wasMovedBackToProd = false
|
|
74
|
+
const pkg = this.Service('pkg')
|
|
77
75
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
if (
|
|
82
|
-
args.indexOf('-D') > -1 &&
|
|
83
|
-
args.indexOf('@sprucelabs/resolve-path-aliases') > -1
|
|
84
|
-
) {
|
|
85
|
-
wasMovedBackToDev = true
|
|
86
|
-
} else if (
|
|
87
|
-
args.indexOf('-D') === -1 &&
|
|
88
|
-
args.indexOf('@sprucelabs/error') > -1
|
|
89
|
-
) {
|
|
90
|
-
wasMovedBackToProd = true
|
|
91
|
-
}
|
|
92
|
-
},
|
|
93
|
-
})
|
|
76
|
+
const skillFeature = cli.getFeature('skill')
|
|
77
|
+
//@ts-ignore
|
|
78
|
+
skillFeature.scripts['taco'] = 'bravo'
|
|
94
79
|
|
|
95
80
|
await this.Action('node', 'upgrade').execute({})
|
|
96
81
|
|
|
97
|
-
assert.
|
|
98
|
-
assert.isFalse(wasMovedBackToProd, 'dependency moved back to prod')
|
|
99
|
-
}
|
|
82
|
+
assert.isEqual(pkg.get(['scripts', 'taco']), 'bravo')
|
|
100
83
|
|
|
101
|
-
|
|
102
|
-
const pkg = this.Service('pkg')
|
|
103
|
-
await pkg.uninstall(name)
|
|
104
|
-
await pkg.install(name, { isDev: true })
|
|
84
|
+
this.assertSandboxListenerNotWritten()
|
|
105
85
|
}
|
|
106
|
-
|
|
86
|
+
|
|
87
|
+
@test()
|
|
88
|
+
protected static async canOverwriteMultipleChangedScript() {
|
|
89
|
+
await this.FeatureFixture().installCachedFeatures('skills')
|
|
90
|
+
|
|
107
91
|
const pkg = this.Service('pkg')
|
|
92
|
+
pkg.set({ path: ['scripts', 'build.dev'], value: 'taco' })
|
|
93
|
+
pkg.set({ path: ['scripts', 'watch.build.dev'], value: 'taco' })
|
|
108
94
|
|
|
109
|
-
|
|
110
|
-
await pkg.install(name)
|
|
111
|
-
}
|
|
95
|
+
const promise = this.Action('node', 'upgrade').execute({})
|
|
112
96
|
|
|
113
|
-
|
|
114
|
-
await this.FeatureFixture().installCachedFeatures('events')
|
|
97
|
+
await this.waitForInput()
|
|
115
98
|
|
|
116
|
-
|
|
117
|
-
settings.setListenerCache({ shouldBeDeleted: true })
|
|
99
|
+
let last = this.ui.getLastInvocation()
|
|
118
100
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
101
|
+
assert.isEqual(last.command, 'prompt')
|
|
102
|
+
await this.ui.sendInput('overwrite')
|
|
103
|
+
|
|
104
|
+
last = this.ui.getLastInvocation()
|
|
105
|
+
|
|
106
|
+
assert.isEqual(last.command, 'prompt')
|
|
107
|
+
await this.ui.sendInput('overwrite')
|
|
108
|
+
|
|
109
|
+
await promise
|
|
110
|
+
|
|
111
|
+
assert.isNotEqual(pkg.get(['scripts', 'build.dev']), 'taco')
|
|
112
|
+
assert.isNotEqual(pkg.get(['scripts', 'watch.build.dev']), 'taco')
|
|
123
113
|
}
|
|
124
114
|
|
|
125
|
-
|
|
126
|
-
|
|
115
|
+
protected static assertSandboxListenerNotWritten() {
|
|
116
|
+
const listeners = this.resolvePath('src', 'listeners')
|
|
117
|
+
if (!diskUtil.doesDirExist(listeners)) {
|
|
118
|
+
return
|
|
119
|
+
}
|
|
120
|
+
const matches = fsUtil.readdirSync(listeners)
|
|
121
|
+
assert.isLength(
|
|
122
|
+
matches,
|
|
123
|
+
0,
|
|
124
|
+
'A sandbox listeners was written and it should not have been.'
|
|
125
|
+
)
|
|
127
126
|
}
|
|
128
127
|
}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { test, assert } from '@sprucelabs/test'
|
|
2
|
+
import CommandService from '../../../services/CommandService'
|
|
3
|
+
import AbstractCliTest from '../../../tests/AbstractCliTest'
|
|
4
|
+
|
|
5
|
+
export default class UpgradingASkill5Test extends AbstractCliTest {
|
|
6
|
+
@test()
|
|
7
|
+
protected static async upgradeResetsEventCache() {
|
|
8
|
+
await this.installSetListenerCacheAndBlockExecute()
|
|
9
|
+
|
|
10
|
+
await assert.doesThrowAsync(() =>
|
|
11
|
+
this.Action('node', 'upgrade').execute({})
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
const value = this.Settings().getListenerCache()
|
|
15
|
+
assert.isFalsy(value)
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
@test()
|
|
19
|
+
protected static async doesNotResetEventCacheWithOtherAction() {
|
|
20
|
+
await this.installSetListenerCacheAndBlockExecute()
|
|
21
|
+
|
|
22
|
+
await assert.doesThrowAsync(() => this.Action('schema', 'sync').execute({}))
|
|
23
|
+
|
|
24
|
+
const value = this.Settings().getListenerCache()
|
|
25
|
+
assert.isEqualDeep(value, { shouldBeDeleted: true })
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
@test('syncs schemas when schemas installed and schemas folder exists', true)
|
|
29
|
+
@test(
|
|
30
|
+
'does not syncs schemas when schemas installed but schemas folder does not exist',
|
|
31
|
+
false
|
|
32
|
+
)
|
|
33
|
+
protected static async shouldSyncSchemasIfSchemasIsInstalledAndSchemaFolderExists(
|
|
34
|
+
shouldCreateSchema: boolean
|
|
35
|
+
) {
|
|
36
|
+
await this.FeatureFixture().installCachedFeatures('schemas')
|
|
37
|
+
|
|
38
|
+
CommandService.setMockResponse(new RegExp(/yarn/gis), {
|
|
39
|
+
code: 0,
|
|
40
|
+
})
|
|
41
|
+
|
|
42
|
+
if (shouldCreateSchema) {
|
|
43
|
+
await this.Action('schema', 'create').execute({
|
|
44
|
+
nameReadable: 'Test schema!',
|
|
45
|
+
namePascal: 'AnotherTest',
|
|
46
|
+
nameCamel: 'anotherTest',
|
|
47
|
+
description: 'this is so great!',
|
|
48
|
+
})
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const emitter = this.getEmitter()
|
|
52
|
+
|
|
53
|
+
let wasHit = false
|
|
54
|
+
|
|
55
|
+
await emitter.on('feature.will-execute', (payload) => {
|
|
56
|
+
if (payload.featureCode === 'schema' && payload.actionCode === 'sync') {
|
|
57
|
+
wasHit = true
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return {}
|
|
61
|
+
})
|
|
62
|
+
|
|
63
|
+
await this.Action('node', 'upgrade').execute({})
|
|
64
|
+
|
|
65
|
+
assert.isTrue(wasHit === shouldCreateSchema)
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
@test()
|
|
69
|
+
protected static async modulesMovedFromDevToProdDependenciesStayThere() {
|
|
70
|
+
await this.FeatureFixture().installCachedFeatures('skills')
|
|
71
|
+
|
|
72
|
+
await this.moveDependencyToProd('@sprucelabs/resolve-path-aliases')
|
|
73
|
+
await this.moveDependencyToDev('@sprucelabs/error')
|
|
74
|
+
|
|
75
|
+
let wasMovedBackToDev = false
|
|
76
|
+
let wasMovedBackToProd = false
|
|
77
|
+
|
|
78
|
+
CommandService.setMockResponse(new RegExp(/yarn/gis), {
|
|
79
|
+
code: 0,
|
|
80
|
+
callback: (_, args) => {
|
|
81
|
+
if (
|
|
82
|
+
args.indexOf('-D') > -1 &&
|
|
83
|
+
args.indexOf('@sprucelabs/resolve-path-aliases') > -1
|
|
84
|
+
) {
|
|
85
|
+
wasMovedBackToDev = true
|
|
86
|
+
} else if (
|
|
87
|
+
args.indexOf('-D') === -1 &&
|
|
88
|
+
args.indexOf('@sprucelabs/error') > -1
|
|
89
|
+
) {
|
|
90
|
+
wasMovedBackToProd = true
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
})
|
|
94
|
+
|
|
95
|
+
await this.Action('node', 'upgrade').execute({})
|
|
96
|
+
|
|
97
|
+
assert.isFalse(wasMovedBackToDev, 'dependency moved back to dev')
|
|
98
|
+
assert.isFalse(wasMovedBackToProd, 'dependency moved back to prod')
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
private static async moveDependencyToDev(name: string) {
|
|
102
|
+
const pkg = this.Service('pkg')
|
|
103
|
+
await pkg.uninstall(name)
|
|
104
|
+
await pkg.install(name, { isDev: true })
|
|
105
|
+
}
|
|
106
|
+
private static async moveDependencyToProd(name: string) {
|
|
107
|
+
const pkg = this.Service('pkg')
|
|
108
|
+
|
|
109
|
+
await pkg.uninstall(name)
|
|
110
|
+
await pkg.install(name)
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
private static async installSetListenerCacheAndBlockExecute() {
|
|
114
|
+
await this.FeatureFixture().installCachedFeatures('events')
|
|
115
|
+
|
|
116
|
+
const settings = this.Settings()
|
|
117
|
+
settings.setListenerCache({ shouldBeDeleted: true })
|
|
118
|
+
|
|
119
|
+
const emitter = this.getEmitter()
|
|
120
|
+
void emitter.on('feature.will-execute', () => {
|
|
121
|
+
throw new Error('Stop!')
|
|
122
|
+
})
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
private static Settings() {
|
|
126
|
+
return this.Service('eventSettings')
|
|
127
|
+
}
|
|
128
|
+
}
|