@sprucelabs/spruce-cli 15.2.17 → 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.
Files changed (50) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/build/.spruce/events/events.contract.d.ts +102 -4
  3. package/build/.spruce/events/events.contract.js +3 -1
  4. package/build/.spruce/events/events.contract.js.map +1 -1
  5. package/build/.spruce/events/heartwood/didRegisterSkillViews.v2021_02_11.contract.d.ts +15 -0
  6. package/build/.spruce/events/heartwood/didRegisterSkillViews.v2021_02_11.contract.js +18 -3
  7. package/build/.spruce/events/heartwood/didRegisterSkillViews.v2021_02_11.contract.js.map +1 -1
  8. package/build/.spruce/events/heartwood/generateUrl.v2021_02_11.contract.d.ts +21 -4
  9. package/build/.spruce/events/heartwood/generateUrl.v2021_02_11.contract.js +24 -7
  10. package/build/.spruce/events/heartwood/generateUrl.v2021_02_11.contract.js.map +1 -1
  11. package/build/.spruce/events/heartwood/getSkillViews.v2021_02_11.contract.d.ts +18 -1
  12. package/build/.spruce/events/heartwood/getSkillViews.v2021_02_11.contract.js +21 -4
  13. package/build/.spruce/events/heartwood/getSkillViews.v2021_02_11.contract.js.map +1 -1
  14. package/build/.spruce/events/heartwood/listViews.v2021_02_11.contract.d.ts +39 -0
  15. package/build/.spruce/events/heartwood/listViews.v2021_02_11.contract.js +53 -0
  16. package/build/.spruce/events/heartwood/listViews.v2021_02_11.contract.js.map +1 -0
  17. package/build/.spruce/events/heartwood/registerSkillViews.v2021_02_11.contract.d.ts +11 -0
  18. package/build/.spruce/events/heartwood/registerSkillViews.v2021_02_11.contract.js +13 -2
  19. package/build/.spruce/events/heartwood/registerSkillViews.v2021_02_11.contract.js.map +1 -1
  20. package/build/__tests__/behavioral/skill/UpgradingASkill.test.d.ts +0 -7
  21. package/build/__tests__/behavioral/skill/UpgradingASkill.test.js +38 -403
  22. package/build/__tests__/behavioral/skill/UpgradingASkill.test.js.map +1 -1
  23. package/build/__tests__/behavioral/skill/UpgradingASkill2.test.d.ts +7 -15
  24. package/build/__tests__/behavioral/skill/UpgradingASkill2.test.js +218 -341
  25. package/build/__tests__/behavioral/skill/UpgradingASkill2.test.js.map +1 -1
  26. package/build/__tests__/behavioral/skill/UpgradingASkill3.test.d.ts +16 -5
  27. package/build/__tests__/behavioral/skill/UpgradingASkill3.test.js +416 -141
  28. package/build/__tests__/behavioral/skill/UpgradingASkill3.test.js.map +1 -1
  29. package/build/__tests__/behavioral/skill/UpgradingASkill4.test.d.ts +5 -8
  30. package/build/__tests__/behavioral/skill/UpgradingASkill4.test.js +147 -205
  31. package/build/__tests__/behavioral/skill/UpgradingASkill4.test.js.map +1 -1
  32. package/build/__tests__/behavioral/skill/UpgradingASkill5.test.d.ts +11 -0
  33. package/build/__tests__/behavioral/skill/UpgradingASkill5.test.js +357 -0
  34. package/build/__tests__/behavioral/skill/UpgradingASkill5.test.js.map +1 -0
  35. package/build/__tests__/behavioral/tests/CreatingATest.test.d.ts +3 -0
  36. package/build/__tests__/behavioral/tests/CreatingATest.test.js +142 -45
  37. package/build/__tests__/behavioral/tests/CreatingATest.test.js.map +1 -1
  38. package/package.json +34 -34
  39. package/src/.spruce/events/events.contract.ts +6 -0
  40. package/src/.spruce/events/heartwood/didRegisterSkillViews.v2021_02_11.contract.ts +15 -0
  41. package/src/.spruce/events/heartwood/generateUrl.v2021_02_11.contract.ts +21 -4
  42. package/src/.spruce/events/heartwood/getSkillViews.v2021_02_11.contract.ts +18 -1
  43. package/src/.spruce/events/heartwood/listViews.v2021_02_11.contract.ts +47 -0
  44. package/src/.spruce/events/heartwood/registerSkillViews.v2021_02_11.contract.ts +11 -0
  45. package/src/__tests__/behavioral/skill/UpgradingASkill.test.ts +0 -184
  46. package/src/__tests__/behavioral/skill/UpgradingASkill2.test.ts +120 -157
  47. package/src/__tests__/behavioral/skill/UpgradingASkill3.test.ts +184 -78
  48. package/src/__tests__/behavioral/skill/UpgradingASkill4.test.ts +90 -91
  49. package/src/__tests__/behavioral/skill/UpgradingASkill5.test.ts +128 -0
  50. package/src/__tests__/behavioral/tests/CreatingATest.test.ts +29 -12
@@ -12,20 +12,37 @@ const getSkillViewsEventContract = buildEventContract({
12
12
  emitPermissionContract: buildPermissionContract({
13
13
  id: 'getSkillViewsEmitPermissions',
14
14
  name: 'Get skill views',
15
+ description: null,
15
16
  requireAllPermissions: false,
16
17
  permissions: [
17
18
  {
18
19
  id: 'can-get-skill-views',
19
20
  name: 'Can get skill views',
21
+ description: null,
22
+ requireAllStatuses: null,
20
23
  defaults: {
24
+ skill: true,
25
+ owner: null,
26
+ groupManager: null,
27
+ manager: null,
28
+ teammate: null,
21
29
  anonymous: {
22
30
  default: true,
31
+ clockedIn: null,
32
+ clockedOut: null,
33
+ onPrem: null,
34
+ offPrem: null,
23
35
  },
24
36
  loggedIn: {
25
37
  default: true,
38
+ clockedIn: null,
39
+ clockedOut: null,
40
+ onPrem: null,
41
+ offPrem: null,
26
42
  },
27
- skill: true,
43
+ guest: null,
28
44
  },
45
+ can: null,
29
46
  },
30
47
  ],
31
48
  }),
@@ -0,0 +1,47 @@
1
+ import { buildEventContract } from '@sprucelabs/mercury-types'
2
+ import { buildPermissionContract } from '@sprucelabs/mercury-types'
3
+ import listViewsResponsePayloadSchema from '#spruce/schemas/heartwood/v2021_02_11/listViewsResponsePayload.schema'
4
+
5
+ const listViewsEventContract = buildEventContract({
6
+ eventSignatures: {
7
+ 'heartwood.list-views::v2021_02_11': {
8
+ isGlobal: true,
9
+
10
+ responsePayloadSchema: listViewsResponsePayloadSchema,
11
+ emitPermissionContract: buildPermissionContract({
12
+ id: 'listViewsEmitPermissions',
13
+ name: 'List skill views',
14
+ description: null,
15
+ requireAllPermissions: false,
16
+ permissions: [
17
+ {
18
+ id: 'can-list-skill-views',
19
+ name: 'Can list skill views',
20
+ description: null,
21
+ requireAllStatuses: false,
22
+ defaults: {
23
+ skill: null,
24
+ owner: null,
25
+ groupManager: null,
26
+ manager: null,
27
+ teammate: null,
28
+ anonymous: null,
29
+ loggedIn: {
30
+ default: true,
31
+ clockedIn: null,
32
+ clockedOut: null,
33
+ onPrem: null,
34
+ offPrem: null,
35
+ },
36
+ guest: null,
37
+ },
38
+ can: null,
39
+ },
40
+ ],
41
+ }),
42
+ },
43
+ },
44
+ })
45
+ export default listViewsEventContract
46
+
47
+ export type ListViewsEventContract = typeof listViewsEventContract
@@ -12,14 +12,25 @@ const registerSkillViewsEventContract = buildEventContract({
12
12
  emitPermissionContract: buildPermissionContract({
13
13
  id: 'registerSkillViewsEmitPermissions',
14
14
  name: 'Register skill views',
15
+ description: null,
15
16
  requireAllPermissions: false,
16
17
  permissions: [
17
18
  {
18
19
  id: 'can-register-skill-views',
19
20
  name: 'Can register skill views',
21
+ description: null,
22
+ requireAllStatuses: null,
20
23
  defaults: {
21
24
  skill: true,
25
+ owner: null,
26
+ groupManager: null,
27
+ manager: null,
28
+ teammate: null,
29
+ anonymous: null,
30
+ loggedIn: null,
31
+ guest: null,
22
32
  },
33
+ can: null,
23
34
  },
24
35
  ],
25
36
  }),
@@ -1,4 +1,3 @@
1
- import fsUtil from 'fs'
2
1
  import { diskUtil } from '@sprucelabs/spruce-skill-utils'
3
2
  import { test, assert } from '@sprucelabs/test'
4
3
  import { CliInterface } from '../../../cli'
@@ -9,7 +8,6 @@ import {
9
8
  } from '../../../constants'
10
9
  import CommandService from '../../../services/CommandService'
11
10
  import AbstractCliTest from '../../../tests/AbstractCliTest'
12
- import testUtil from '../../../tests/utilities/test.utility'
13
11
  import { GeneratedFile } from '../../../types/cli.types'
14
12
  const BROKEN_SKILL_INDEX_CONTENTS = "throw new Error('cheese!')\n"
15
13
  export default class UpgradingASkillTest extends AbstractCliTest {
@@ -191,175 +189,6 @@ export default class UpgradingASkillTest extends AbstractCliTest {
191
189
  assert.isEqual(passedHealth.skill.status, 'passed')
192
190
  }
193
191
 
194
- @test(
195
- 'Upgrades error.plugin (even if skill is broken)',
196
- 'error.plugin.ts',
197
- 'errors'
198
- )
199
- @test(
200
- 'Upgrades schema.plugin (even if skill is broken)',
201
- 'schema.plugin.ts',
202
- 'schemas'
203
- )
204
- @test(
205
- 'Upgrades conversation.plugin (even if skill is broken)',
206
- 'conversation.plugin.ts',
207
- 'conversation',
208
- false
209
- )
210
- @test(
211
- 'Upgrades view.plugin (even if skill is broken)',
212
- 'view.plugin.ts',
213
- 'views',
214
- false
215
- )
216
- protected static async upgradesPlugins(
217
- pluginName: string,
218
- cacheKey: string,
219
- shouldMockYarn = true
220
- ) {
221
- await this.FeatureFixture().installCachedFeatures(cacheKey)
222
-
223
- shouldMockYarn && CommandService.setMockResponse(/yarn/, { code: 0 })
224
-
225
- const pluginPath = this.resolveHashSprucePath(`features/${pluginName}`)
226
- const originalContents = diskUtil.readFile(pluginPath)
227
-
228
- diskUtil.writeFile(pluginPath, 'aoeuaoeuaoeuaoeu')
229
-
230
- const results = await this.Action('node', 'upgrade').execute({})
231
-
232
- assert.isFalsy(results.errors)
233
-
234
- testUtil.assertFileByNameInGeneratedFiles(pluginName, results.files)
235
-
236
- const updatedContents = diskUtil.readFile(pluginPath)
237
-
238
- assert.isEqual(updatedContents, originalContents)
239
-
240
- assert.doesInclude(results.summaryLines ?? [], 'successfully')
241
- }
242
-
243
- @test()
244
- protected static async canSkipPackageScriptChanges() {
245
- await this.FeatureFixture().installCachedFeatures('skills')
246
-
247
- const pkg = this.Service('pkg')
248
- pkg.set({ path: ['scripts', 'build.dev'], value: 'taco' })
249
-
250
- const promise = this.Action('node', 'upgrade').execute({})
251
-
252
- await this.waitForInput()
253
-
254
- const last = this.ui.getLastInvocation()
255
-
256
- assert.isEqual(last.command, 'prompt')
257
- assert.doesInclude(last.options.options.choices, { value: 'skip' })
258
- assert.doesInclude(last.options.options.choices, { value: 'skipAll' })
259
- assert.doesInclude(last.options.options.choices, { value: 'overwrite' })
260
-
261
- await this.ui.sendInput('skip')
262
-
263
- await promise
264
-
265
- assert.isEqual(pkg.get(['scripts', 'build.dev']), 'taco')
266
- }
267
-
268
- @test()
269
- protected static async asksForEachScriptChange() {
270
- await this.FeatureFixture().installCachedFeatures('skills')
271
-
272
- const pkg = this.Service('pkg')
273
- pkg.set({ path: ['scripts', 'build.dev'], value: 'taco' })
274
- pkg.set({ path: ['scripts', 'watch.build.dev'], value: 'taco' })
275
-
276
- const promise = this.Action('node', 'upgrade').execute({})
277
-
278
- await this.waitForInput()
279
-
280
- let last = this.ui.getLastInvocation()
281
-
282
- assert.isEqual(last.command, 'prompt')
283
- await this.ui.sendInput('skip')
284
-
285
- await this.waitForInput()
286
-
287
- last = this.ui.getLastInvocation()
288
-
289
- assert.isEqual(last.command, 'prompt')
290
- await this.ui.sendInput('skip')
291
-
292
- await promise
293
-
294
- assert.isEqual(pkg.get(['scripts', 'build.dev']), 'taco')
295
- assert.isEqual(pkg.get(['scripts', 'watch.build.dev']), 'taco')
296
- }
297
-
298
- @test()
299
- protected static async canSkipAllScriptChanges() {
300
- await this.FeatureFixture().installCachedFeatures('skills')
301
-
302
- const pkg = this.Service('pkg')
303
- pkg.set({ path: ['scripts', 'build.dev'], value: 'taco' })
304
- pkg.set({ path: ['scripts', 'watch.build.dev'], value: 'taco' })
305
-
306
- const promise = this.Action('node', 'upgrade').execute({})
307
-
308
- await this.waitForInput()
309
-
310
- let last = this.ui.getLastInvocation()
311
-
312
- assert.isEqual(last.command, 'prompt')
313
- await this.ui.sendInput('skipAll')
314
-
315
- await promise
316
-
317
- assert.isEqual(pkg.get(['scripts', 'build.dev']), 'taco')
318
- assert.isEqual(pkg.get(['scripts', 'watch.build.dev']), 'taco')
319
- }
320
-
321
- @test()
322
- protected static async canOverwriteChangedScript() {
323
- await this.FeatureFixture().installCachedFeatures('skills')
324
-
325
- const pkg = this.Service('pkg')
326
- pkg.set({ path: ['scripts', 'build.dev'], value: 'taco' })
327
-
328
- const promise = this.Action('node', 'upgrade').execute({})
329
-
330
- await this.waitForInput()
331
-
332
- let last = this.ui.getLastInvocation()
333
-
334
- assert.isEqual(last.command, 'prompt')
335
- await this.ui.sendInput('overwrite')
336
-
337
- await promise
338
-
339
- assert.isNotEqual(pkg.get(['scripts', 'build.dev']), 'taco')
340
- }
341
-
342
- @test()
343
- protected static async upgradingSkillWithSandboxUpgradesTheListener() {
344
- await this.FeatureFixture().installCachedFeatures('sandbox')
345
- const results = await this.Action('sandbox', 'setup').execute({})
346
-
347
- const match = testUtil.assertFileByNameInGeneratedFiles(
348
- /will-boot/,
349
- results.files
350
- )
351
-
352
- const originalContents = diskUtil.readFile(match)
353
- diskUtil.writeFile(match, 'broken')
354
-
355
- CommandService.setMockResponse(/yarn/, { code: 0 })
356
-
357
- await this.Action('node', 'upgrade').execute({})
358
-
359
- const newContents = diskUtil.readFile(match)
360
- assert.isEqual(originalContents, newContents)
361
- }
362
-
363
192
  private static clearFileIfAboutToBeUpdated(
364
193
  file: {
365
194
  name: string
@@ -409,19 +238,6 @@ export default class UpgradingASkillTest extends AbstractCliTest {
409
238
  })
410
239
  }
411
240
 
412
- protected static assertSandboxListenerNotWritten() {
413
- const listeners = this.resolvePath('src', 'listeners')
414
- if (!diskUtil.doesDirExist(listeners)) {
415
- return
416
- }
417
- const matches = fsUtil.readdirSync(listeners)
418
- assert.isLength(
419
- matches,
420
- 0,
421
- 'A sandbox listeners was written and it should not have been.'
422
- )
423
- }
424
-
425
241
  private static async installBreakAndUpgradeSkill() {
426
242
  await this.installAndBreakSkill('skills')
427
243
 
@@ -1,233 +1,196 @@
1
- import { eventDiskUtil } from '@sprucelabs/spruce-event-utils'
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
- protected static async doesNotAddResolvePathAliasesToDependenciesAfterUpgrade() {
26
- CommandService.clearMockResponses()
27
- await this.FeatureFixture().installCachedFeatures('views')
28
-
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')
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
- 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
- )
52
- )
53
-
54
- this.assertViewPluginNotWritten()
55
- }
53
+ assert.isFalsy(results.errors)
56
54
 
57
- @test()
58
- protected static async upgradingSkillSyncsEvents() {
59
- await this.FeatureFixture().installCachedFeatures('events')
55
+ testUtil.assertFileByNameInGeneratedFiles(pluginName, results.files)
60
56
 
61
- const results = await this.Action('node', 'upgrade').execute({})
62
- const events = eventDiskUtil.resolveCombinedEventsContractFile(this.cwd)
57
+ const updatedContents = diskUtil.readFile(pluginPath)
63
58
 
64
- assert.isTrue(diskUtil.doesFileExist(events))
59
+ assert.isEqual(updatedContents, originalContents)
65
60
 
66
- testUtil.assertFileByNameInGeneratedFiles(
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 upgradeCallsUpdateDependencies() {
65
+ protected static async canSkipPackageScriptChanges() {
74
66
  await this.FeatureFixture().installCachedFeatures('skills')
75
67
 
76
- UpdateDependenciesAction.prototype.execute = () => {
77
- throw new Error('baaaaad')
78
- }
68
+ const pkg = this.Service('pkg')
69
+ pkg.set({ path: ['scripts', 'build.dev'], value: 'taco' })
79
70
 
80
- const results = await this.Action('node', 'upgrade').execute({})
71
+ const promise = this.Action('node', 'upgrade').execute({})
81
72
 
82
- assert.isTruthy(results.errors)
83
- assert.doesInclude(results.errors[0].message, 'baaaaad')
84
- }
73
+ await this.waitForInput()
85
74
 
86
- @test()
87
- protected static async callsCleanFixAndBuildDev() {
88
- await this.FeatureFixture().installCachedFeatures('skills')
75
+ const last = this.ui.getLastInvocation()
89
76
 
90
- let wasCleanBuildCalled = false
91
- UpdateDependenciesAction.prototype.execute = async () => {
92
- return {}
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
- CommandService.setMockResponse('yarn clean.build', {
96
- code: 0,
97
- callback: () => {
98
- wasCleanBuildCalled = true
99
- },
100
- })
82
+ await this.ui.sendInput('skip')
101
83
 
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({})
84
+ await promise
112
85
 
113
- assert.isFalsy(results.errors)
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 writesViewPlugin() {
120
- await this.FeatureFixture().installCachedFeatures('views')
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
- diskUtil.deleteFile(plugin)
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
- assert.isFalse(diskUtil.doesFileExist(plugin))
97
+ const promise = this.Action('node', 'upgrade').execute({})
128
98
 
129
- await this.Action('node', 'upgrade').execute({})
99
+ await this.waitForInput()
130
100
 
131
- assert.isTrue(diskUtil.doesFileExist(plugin))
132
- }
101
+ let last = this.ui.getLastInvocation()
133
102
 
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
- )
103
+ assert.isEqual(last.command, 'prompt')
104
+ await this.ui.sendInput('skip')
140
105
 
141
- let wasHit = false
106
+ await this.waitForInput()
142
107
 
143
- SyncAction.prototype.execute = async () => {
144
- wasHit = true
145
- return {}
146
- }
108
+ last = this.ui.getLastInvocation()
147
109
 
148
- this.disableCleanBuildAndYarnAdd()
110
+ assert.isEqual(last.command, 'prompt')
111
+ await this.ui.sendInput('skip')
149
112
 
150
- await this.Action('node', 'upgrade').execute({})
113
+ await promise
151
114
 
152
- assert.isEqual(wasHit, isInstalled)
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 resetsErrorPluginInSkill() {
120
+ protected static async canSkipAllScriptChanges() {
157
121
  await this.FeatureFixture().installCachedFeatures('skills')
158
122
 
159
- const { plugin, expectedContents } = this.destroyErrorPlugin()
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
- await this.disableCleanBuildAndYarnAdd()
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
- await promise
131
+ let last = this.ui.getLastInvocation()
171
132
 
172
- const actualContents = diskUtil.readFile(plugin)
133
+ assert.isEqual(last.command, 'prompt')
134
+ await this.ui.sendInput('skipAll')
173
135
 
174
- assert.isEqual(actualContents, expectedContents)
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 resetsErrorPluginWhenErrorInstalled() {
179
- await this.FeatureFixture().installCachedFeatures('errors')
143
+ protected static async canOverwriteChangedScript() {
144
+ await this.FeatureFixture().installCachedFeatures('skills')
180
145
 
181
- await this.Action('error', 'create').execute({
182
- nameReadable: 'Test pass',
183
- nameCamel: 'testPass',
184
- })
146
+ const pkg = this.Service('pkg')
147
+ pkg.set({ path: ['scripts', 'build.dev'], value: 'taco' })
185
148
 
186
- const { plugin, expectedContents } = this.destroyErrorPlugin()
149
+ const promise = this.Action('node', 'upgrade').execute({})
187
150
 
188
- this.disableCleanAndBuild()
151
+ await this.waitForInput()
189
152
 
190
- const results = await this.Action('node', 'upgrade').execute({
191
- upgradeMode: 'askForChanged',
192
- })
153
+ let last = this.ui.getLastInvocation()
193
154
 
194
- assert.isFalsy(results.errors)
195
- const actualContents = diskUtil.readFile(plugin)
155
+ assert.isEqual(last.command, 'prompt')
156
+ await this.ui.sendInput('overwrite')
157
+
158
+ await promise
196
159
 
197
- assert.isEqual(actualContents, expectedContents)
160
+ assert.isNotEqual(pkg.get(['scripts', 'build.dev']), 'taco')
198
161
  }
199
162
 
200
- private static destroyErrorPlugin() {
201
- const plugin = this.resolveHashSprucePath('errors', 'options.types.ts')
202
- const expectedContents = diskUtil.readFile(plugin)
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
- diskUtil.writeFile(plugin, 'waka')
205
- return { plugin, expectedContents }
206
- }
168
+ const match = testUtil.assertFileByNameInGeneratedFiles(
169
+ /will-boot/,
170
+ results.files
171
+ )
207
172
 
208
- private static getViewsPluginPath() {
209
- return this.resolveHashSprucePath('features', 'view.plugin.ts')
210
- }
173
+ const originalContents = diskUtil.readFile(match)
174
+ diskUtil.writeFile(match, 'broken')
211
175
 
212
- protected static assertViewPluginNotWritten() {
213
- assert.isFalse(diskUtil.doesFileExist(this.getViewsPluginPath()))
214
- }
176
+ CommandService.setMockResponse(/yarn/, { code: 0 })
215
177
 
216
- private static disableCleanBuildAndYarnAdd() {
217
- this.disableCleanAndBuild()
178
+ await this.Action('node', 'upgrade').execute({})
218
179
 
219
- CommandService.setMockResponse(/yarn.*?add/gis, {
220
- code: 0,
221
- })
180
+ const newContents = diskUtil.readFile(match)
181
+ assert.isEqual(originalContents, newContents)
222
182
  }
223
183
 
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
- })
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
  }