@sprucelabs/spruce-cli 15.2.17 → 15.2.20

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 +24 -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 +73 -35
  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 generateUrlEventContract = buildEventContract({
12
12
  emitPermissionContract: buildPermissionContract({
13
13
  id: 'generateUrlEmitPermissions',
14
14
  name: 'Generate url',
15
+ description: null,
15
16
  requireAllPermissions: false,
16
17
  permissions: [
17
18
  {
18
- name: 'Can generate url',
19
19
  id: 'can-generate-url',
20
+ name: 'Can generate url',
21
+ description: null,
22
+ requireAllStatuses: null,
20
23
  defaults: {
21
- loggedIn: {
24
+ skill: true,
25
+ owner: null,
26
+ groupManager: null,
27
+ manager: null,
28
+ teammate: null,
29
+ anonymous: {
22
30
  default: true,
31
+ clockedIn: null,
32
+ clockedOut: null,
33
+ onPrem: null,
34
+ offPrem: null,
23
35
  },
24
- anonymous: {
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
  }),
@@ -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