@sprucelabs/spruce-cli 17.0.17 → 17.1.2

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 (63) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/build/__tests__/behavioral/AddingADependency.test.js +2 -1
  3. package/build/__tests__/behavioral/AddingADependency.test.js.map +1 -1
  4. package/build/__tests__/behavioral/permissions/CreatingPermissions.test.d.ts +7 -0
  5. package/build/__tests__/behavioral/permissions/CreatingPermissions.test.js +137 -0
  6. package/build/__tests__/behavioral/permissions/CreatingPermissions.test.js.map +1 -0
  7. package/build/__tests__/behavioral/polish/SettingUpPolish.test.d.ts +10 -0
  8. package/build/__tests__/behavioral/polish/SettingUpPolish.test.js +305 -0
  9. package/build/__tests__/behavioral/polish/SettingUpPolish.test.js.map +1 -0
  10. package/build/__tests__/testDirsAndFiles/related_schemas/v2020_10_06/skillWithExtraField.builder.d.ts +10 -2
  11. package/build/features/FeatureInstaller.d.ts +1 -1
  12. package/build/features/FeatureInstallerFactory.js +6 -2
  13. package/build/features/FeatureInstallerFactory.js.map +1 -1
  14. package/build/features/event/actions/CreateAction.d.ts +24 -16
  15. package/build/features/event/actions/CreateAction.js +3 -5
  16. package/build/features/event/actions/CreateAction.js.map +1 -1
  17. package/build/features/node/actions/UpdateDependenciesAction.js +25 -32
  18. package/build/features/node/actions/UpdateDependenciesAction.js.map +1 -1
  19. package/build/features/organization/OrganizationFeature.d.ts +5 -5
  20. package/build/features/organization/OrganizationFeature.js.map +1 -1
  21. package/build/features/permission/PermissionFeature.d.ts +15 -0
  22. package/build/features/permission/PermissionFeature.js +66 -0
  23. package/build/features/permission/PermissionFeature.js.map +1 -0
  24. package/build/features/permission/actions/CreateAction.d.ts +46 -0
  25. package/build/features/permission/actions/CreateAction.js +96 -0
  26. package/build/features/permission/actions/CreateAction.js.map +1 -0
  27. package/build/features/person/PersonFeature.d.ts +5 -5
  28. package/build/features/person/PersonFeature.js.map +1 -1
  29. package/build/features/polish/PolishFeature.d.ts +19 -0
  30. package/build/features/polish/PolishFeature.js +69 -0
  31. package/build/features/polish/PolishFeature.js.map +1 -0
  32. package/build/features/polish/actions/SetupAction.d.ts +13 -0
  33. package/build/features/polish/actions/SetupAction.js +115 -0
  34. package/build/features/polish/actions/SetupAction.js.map +1 -0
  35. package/build/features/polish/writers/PolishWriter.d.ts +4 -0
  36. package/build/features/polish/writers/PolishWriter.js +84 -0
  37. package/build/features/polish/writers/PolishWriter.js.map +1 -0
  38. package/build/features/skill/stores/SkillStore.d.ts +9 -8
  39. package/build/features/skill/stores/SkillStore.js +4 -3
  40. package/build/features/skill/stores/SkillStore.js.map +1 -1
  41. package/build/tests/fixtures/SkillFixture.d.ts +3 -8
  42. package/build/tests/fixtures/SkillFixture.js.map +1 -1
  43. package/build/widgets/terminalKit/TkBaseWidget.js +11 -20
  44. package/build/widgets/terminalKit/TkBaseWidget.js.map +1 -1
  45. package/build/writers/WriterFactory.d.ts +2 -0
  46. package/build/writers/WriterFactory.js +4 -1
  47. package/build/writers/WriterFactory.js.map +1 -1
  48. package/package.json +33 -3
  49. package/src/__tests__/behavioral/AddingADependency.test.ts +1 -0
  50. package/src/__tests__/behavioral/permissions/CreatingPermissions.test.ts +25 -0
  51. package/src/__tests__/behavioral/polish/SettingUpPolish.test.ts +71 -0
  52. package/src/features/FeatureInstallerFactory.ts +6 -0
  53. package/src/features/event/actions/CreateAction.ts +5 -6
  54. package/src/features/organization/OrganizationFeature.ts +6 -6
  55. package/src/features/permission/PermissionFeature.ts +28 -0
  56. package/src/features/permission/actions/CreateAction.ts +29 -0
  57. package/src/features/person/PersonFeature.ts +6 -6
  58. package/src/features/polish/PolishFeature.ts +33 -0
  59. package/src/features/polish/actions/SetupAction.ts +36 -0
  60. package/src/features/polish/writers/PolishWriter.ts +23 -0
  61. package/src/features/skill/stores/SkillStore.ts +13 -11
  62. package/src/tests/fixtures/SkillFixture.ts +6 -3
  63. package/src/writers/WriterFactory.ts +3 -0
@@ -25,6 +25,8 @@ var _LogWriter = _interopRequireDefault(require("../features/log/writers/LogWrit
25
25
 
26
26
  var _NodeWriter = _interopRequireDefault(require("../features/node/writers/NodeWriter"));
27
27
 
28
+ var _PolishWriter = _interopRequireDefault(require("../features/polish/writers/PolishWriter"));
29
+
28
30
  var _SandboxWriter = _interopRequireDefault(require("../features/sandbox/writers/SandboxWriter"));
29
31
 
30
32
  var _SchemaWriter = _interopRequireDefault(require("../features/schema/writers/SchemaWriter"));
@@ -56,7 +58,8 @@ var classMap = {
56
58
  sandbox: _SandboxWriter["default"],
57
59
  store: _StoreWriter["default"],
58
60
  view: _ViewWriter["default"],
59
- log: _LogWriter["default"]
61
+ log: _LogWriter["default"],
62
+ polish: _PolishWriter["default"]
60
63
  };
61
64
 
62
65
  var WriterFactory = /*#__PURE__*/function () {
@@ -1 +1 @@
1
- {"version":3,"file":"WriterFactory.js","names":["classMap","error","ErrorWriter","event","EventWriter","schema","SchemaWriter","skill","SkillGenerator","test","TestGenerator","node","NodeWriter","vscode","VsCodeWriter","conversation","ConversationWriter","deploy","DeployWriter","sandbox","SandboxWriter","store","StoreWriter","view","ViewWriter","log","LogWriter","WriterFactory","options","templates","ui","linter","settings","code","Class","term"],"sources":["../../src/writers/WriterFactory.ts"],"sourcesContent":["import { SettingsService } from '@sprucelabs/spruce-skill-utils'\nimport { Templates } from '@sprucelabs/spruce-templates'\nimport ConversationWriter from '../features/conversation/writers/ConversationWriter'\nimport DeployWriter from '../features/deploy/writers/DeployWriter'\nimport ErrorWriter from '../features/error/writers/ErrorWriter'\nimport EventWriter from '../features/event/writers/EventWriter'\nimport LogWriter from '../features/log/writers/LogWriter'\nimport NodeWriter from '../features/node/writers/NodeWriter'\nimport SandboxWriter from '../features/sandbox/writers/SandboxWriter'\nimport SchemaWriter from '../features/schema/writers/SchemaWriter'\nimport SkillGenerator from '../features/skill/writers/SkillWriter'\nimport StoreWriter from '../features/store/writers/StoreWriter'\nimport TestGenerator from '../features/test/writers/TestWriter'\nimport ViewWriter from '../features/view/writers/ViewWriter'\nimport VsCodeWriter from '../features/vscode/writers/VsCodeWriter'\nimport LintService from '../services/LintService'\nimport { FileDescription } from '../types/cli.types'\nimport { GraphicsInterface } from '../types/cli.types'\nimport { WriterOptions } from './AbstractWriter'\n\nconst classMap = {\n\terror: ErrorWriter,\n\tevent: EventWriter,\n\tschema: SchemaWriter,\n\tskill: SkillGenerator,\n\ttest: TestGenerator,\n\tnode: NodeWriter,\n\tvscode: VsCodeWriter,\n\tconversation: ConversationWriter,\n\tdeploy: DeployWriter,\n\tsandbox: SandboxWriter,\n\tstore: StoreWriter,\n\tview: ViewWriter,\n\tlog: LogWriter,\n}\n\nexport interface WriterMap {\n\terror: ErrorWriter\n\tevent: EventWriter\n\tschema: SchemaWriter\n\tskill: SkillGenerator\n\ttest: TestGenerator\n\tnode: NodeWriter\n\tvscode: VsCodeWriter\n\tconversation: ConversationWriter\n\tdeploy: DeployWriter\n\tsandbox: SandboxWriter\n\tstore: StoreWriter\n\tview: ViewWriter\n\tlog: LogWriter\n}\n\nexport type WriterCode = keyof WriterMap\n\nexport default class WriterFactory {\n\tprivate templates: Templates\n\tprivate ui: GraphicsInterface\n\tprivate linter?: LintService\n\tprivate settings: SettingsService<string>\n\n\tpublic constructor(options: {\n\t\ttemplates: Templates\n\t\tui: GraphicsInterface\n\t\tlinter?: LintService\n\t\tsettings: SettingsService\n\t}) {\n\t\tconst { templates, ui, linter, settings } = options\n\n\t\tthis.templates = templates\n\t\tthis.ui = ui\n\t\tthis.linter = linter\n\t\tthis.settings = settings\n\t}\n\n\tpublic Writer<C extends WriterCode>(\n\t\tcode: C,\n\t\toptions: Partial<WriterOptions> & { fileDescriptions: FileDescription[] }\n\t): WriterMap[C] {\n\t\tconst Class = classMap[code]\n\t\treturn new Class({\n\t\t\ttemplates: this.templates,\n\t\t\tterm: this.ui,\n\t\t\tlinter: this.linter,\n\t\t\tsettings: this.settings,\n\t\t\t...(options || {}),\n\t\t}) as WriterMap[C]\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;AAEA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;AAMA,IAAMA,QAAQ,GAAG;EAChBC,KAAK,EAAEC,uBADS;EAEhBC,KAAK,EAAEC,uBAFS;EAGhBC,MAAM,EAAEC,wBAHQ;EAIhBC,KAAK,EAAEC,uBAJS;EAKhBC,IAAI,EAAEC,sBALU;EAMhBC,IAAI,EAAEC,sBANU;EAOhBC,MAAM,EAAEC,wBAPQ;EAQhBC,YAAY,EAAEC,8BARE;EAShBC,MAAM,EAAEC,wBATQ;EAUhBC,OAAO,EAAEC,yBAVO;EAWhBC,KAAK,EAAEC,uBAXS;EAYhBC,IAAI,EAAEC,sBAZU;EAahBC,GAAG,EAAEC;AAbW,CAAjB;;IAkCqBC,a;EAMpB,uBAAmBC,OAAnB,EAKG;IAAA;IAAA;IAAA;IAAA;IAAA;IACF,IAAQC,SAAR,GAA4CD,OAA5C,CAAQC,SAAR;IAAA,IAAmBC,EAAnB,GAA4CF,OAA5C,CAAmBE,EAAnB;IAAA,IAAuBC,MAAvB,GAA4CH,OAA5C,CAAuBG,MAAvB;IAAA,IAA+BC,QAA/B,GAA4CJ,OAA5C,CAA+BI,QAA/B;IAEA,KAAKH,SAAL,GAAiBA,SAAjB;IACA,KAAKC,EAAL,GAAUA,EAAV;IACA,KAAKC,MAAL,GAAcA,MAAd;IACA,KAAKC,QAAL,GAAgBA,QAAhB;EACA;;;;WAED,gBACCC,IADD,EAECL,OAFD,EAGgB;MACf,IAAMM,KAAK,GAAGlC,QAAQ,CAACiC,IAAD,CAAtB;MACA,OAAO,IAAIC,KAAJ;QACNL,SAAS,EAAE,KAAKA,SADV;QAENM,IAAI,EAAE,KAAKL,EAFL;QAGNC,MAAM,EAAE,KAAKA,MAHP;QAINC,QAAQ,EAAE,KAAKA;MAJT,GAKFJ,OAAO,IAAI,EALT,EAAP;IAOA"}
1
+ {"version":3,"file":"WriterFactory.js","names":["classMap","error","ErrorWriter","event","EventWriter","schema","SchemaWriter","skill","SkillGenerator","test","TestGenerator","node","NodeWriter","vscode","VsCodeWriter","conversation","ConversationWriter","deploy","DeployWriter","sandbox","SandboxWriter","store","StoreWriter","view","ViewWriter","log","LogWriter","polish","PolishWriter","WriterFactory","options","templates","ui","linter","settings","code","Class","term"],"sources":["../../src/writers/WriterFactory.ts"],"sourcesContent":["import { SettingsService } from '@sprucelabs/spruce-skill-utils'\nimport { Templates } from '@sprucelabs/spruce-templates'\nimport ConversationWriter from '../features/conversation/writers/ConversationWriter'\nimport DeployWriter from '../features/deploy/writers/DeployWriter'\nimport ErrorWriter from '../features/error/writers/ErrorWriter'\nimport EventWriter from '../features/event/writers/EventWriter'\nimport LogWriter from '../features/log/writers/LogWriter'\nimport NodeWriter from '../features/node/writers/NodeWriter'\nimport PolishWriter from '../features/polish/writers/PolishWriter'\nimport SandboxWriter from '../features/sandbox/writers/SandboxWriter'\nimport SchemaWriter from '../features/schema/writers/SchemaWriter'\nimport SkillGenerator from '../features/skill/writers/SkillWriter'\nimport StoreWriter from '../features/store/writers/StoreWriter'\nimport TestGenerator from '../features/test/writers/TestWriter'\nimport ViewWriter from '../features/view/writers/ViewWriter'\nimport VsCodeWriter from '../features/vscode/writers/VsCodeWriter'\nimport LintService from '../services/LintService'\nimport { FileDescription } from '../types/cli.types'\nimport { GraphicsInterface } from '../types/cli.types'\nimport { WriterOptions } from './AbstractWriter'\n\nconst classMap = {\n\terror: ErrorWriter,\n\tevent: EventWriter,\n\tschema: SchemaWriter,\n\tskill: SkillGenerator,\n\ttest: TestGenerator,\n\tnode: NodeWriter,\n\tvscode: VsCodeWriter,\n\tconversation: ConversationWriter,\n\tdeploy: DeployWriter,\n\tsandbox: SandboxWriter,\n\tstore: StoreWriter,\n\tview: ViewWriter,\n\tlog: LogWriter,\n\tpolish: PolishWriter,\n}\n\nexport interface WriterMap {\n\terror: ErrorWriter\n\tevent: EventWriter\n\tschema: SchemaWriter\n\tskill: SkillGenerator\n\ttest: TestGenerator\n\tnode: NodeWriter\n\tvscode: VsCodeWriter\n\tconversation: ConversationWriter\n\tdeploy: DeployWriter\n\tsandbox: SandboxWriter\n\tstore: StoreWriter\n\tview: ViewWriter\n\tlog: LogWriter\n\tpolish: PolishWriter\n}\n\nexport type WriterCode = keyof WriterMap\n\nexport default class WriterFactory {\n\tprivate templates: Templates\n\tprivate ui: GraphicsInterface\n\tprivate linter?: LintService\n\tprivate settings: SettingsService<string>\n\n\tpublic constructor(options: {\n\t\ttemplates: Templates\n\t\tui: GraphicsInterface\n\t\tlinter?: LintService\n\t\tsettings: SettingsService\n\t}) {\n\t\tconst { templates, ui, linter, settings } = options\n\n\t\tthis.templates = templates\n\t\tthis.ui = ui\n\t\tthis.linter = linter\n\t\tthis.settings = settings\n\t}\n\n\tpublic Writer<C extends WriterCode>(\n\t\tcode: C,\n\t\toptions: Partial<WriterOptions> & { fileDescriptions: FileDescription[] }\n\t): WriterMap[C] {\n\t\tconst Class = classMap[code]\n\t\treturn new Class({\n\t\t\ttemplates: this.templates,\n\t\t\tterm: this.ui,\n\t\t\tlinter: this.linter,\n\t\t\tsettings: this.settings,\n\t\t\t...(options || {}),\n\t\t}) as WriterMap[C]\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;AAEA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;AAMA,IAAMA,QAAQ,GAAG;EAChBC,KAAK,EAAEC,uBADS;EAEhBC,KAAK,EAAEC,uBAFS;EAGhBC,MAAM,EAAEC,wBAHQ;EAIhBC,KAAK,EAAEC,uBAJS;EAKhBC,IAAI,EAAEC,sBALU;EAMhBC,IAAI,EAAEC,sBANU;EAOhBC,MAAM,EAAEC,wBAPQ;EAQhBC,YAAY,EAAEC,8BARE;EAShBC,MAAM,EAAEC,wBATQ;EAUhBC,OAAO,EAAEC,yBAVO;EAWhBC,KAAK,EAAEC,uBAXS;EAYhBC,IAAI,EAAEC,sBAZU;EAahBC,GAAG,EAAEC,qBAbW;EAchBC,MAAM,EAAEC;AAdQ,CAAjB;;IAoCqBC,a;EAMpB,uBAAmBC,OAAnB,EAKG;IAAA;IAAA;IAAA;IAAA;IAAA;IACF,IAAQC,SAAR,GAA4CD,OAA5C,CAAQC,SAAR;IAAA,IAAmBC,EAAnB,GAA4CF,OAA5C,CAAmBE,EAAnB;IAAA,IAAuBC,MAAvB,GAA4CH,OAA5C,CAAuBG,MAAvB;IAAA,IAA+BC,QAA/B,GAA4CJ,OAA5C,CAA+BI,QAA/B;IAEA,KAAKH,SAAL,GAAiBA,SAAjB;IACA,KAAKC,EAAL,GAAUA,EAAV;IACA,KAAKC,MAAL,GAAcA,MAAd;IACA,KAAKC,QAAL,GAAgBA,QAAhB;EACA;;;;WAED,gBACCC,IADD,EAECL,OAFD,EAGgB;MACf,IAAMM,KAAK,GAAGpC,QAAQ,CAACmC,IAAD,CAAtB;MACA,OAAO,IAAIC,KAAJ;QACNL,SAAS,EAAE,KAAKA,SADV;QAENM,IAAI,EAAE,KAAKL,EAFL;QAGNC,MAAM,EAAE,KAAKA,MAHP;QAINC,QAAQ,EAAE,KAAKA;MAJT,GAKFJ,OAAO,IAAI,EALT,EAAP;IAOA"}
package/package.json CHANGED
@@ -18,7 +18,7 @@
18
18
  ]
19
19
  },
20
20
  "license": "MIT",
21
- "version": "17.0.17",
21
+ "version": "17.1.2",
22
22
  "bin": {
23
23
  "spruce": "./build/index.js"
24
24
  },
@@ -88,7 +88,7 @@
88
88
  "@sprucelabs/spruce-event-utils": "^27.0.5",
89
89
  "@sprucelabs/spruce-skill-booter": "^41.0.4",
90
90
  "@sprucelabs/spruce-skill-utils": "^26.0.88",
91
- "@sprucelabs/spruce-templates": "^17.0.17",
91
+ "@sprucelabs/spruce-templates": "^17.1.2",
92
92
  "@typescript-eslint/eslint-plugin": "^5.27.1",
93
93
  "@typescript-eslint/parser": "^5.27.1",
94
94
  "cfonts": "^3.1.0",
@@ -194,6 +194,9 @@
194
194
  },
195
195
  {
196
196
  "code": "conversation"
197
+ },
198
+ {
199
+ "code": "polish"
197
200
  }
198
201
  ],
199
202
  "everythingInNode": [
@@ -277,6 +280,18 @@
277
280
  "code": "event"
278
281
  }
279
282
  ],
283
+ "polish": [
284
+ {
285
+ "code": "skill",
286
+ "options": {
287
+ "name": "testing polish",
288
+ "description": "this too, is a great test!"
289
+ }
290
+ },
291
+ {
292
+ "code": "polish"
293
+ }
294
+ ],
280
295
  "sandbox": [
281
296
  {
282
297
  "code": "skill",
@@ -379,6 +394,21 @@
379
394
  "code": "event"
380
395
  }
381
396
  ],
397
+ "permissions": [
398
+ {
399
+ "code": "skill",
400
+ "options": {
401
+ "name": "testing permissions",
402
+ "description": "This is for permissions"
403
+ }
404
+ },
405
+ {
406
+ "code": "event"
407
+ },
408
+ {
409
+ "code": "permission"
410
+ }
411
+ ],
382
412
  "organizations": [
383
413
  {
384
414
  "code": "skill",
@@ -597,5 +627,5 @@
597
627
  "terminal-kit"
598
628
  ]
599
629
  },
600
- "gitHead": "7afbeaf171496cd15e1057d07ae1524bbfbddd9b"
630
+ "gitHead": "dd59e470e34ad2dd6729caf3325c90695d5f1a82"
601
631
  }
@@ -121,6 +121,7 @@ export default class ConfiguringDependenciesTest extends AbstractSkillTest {
121
121
  protected static async canAddSkillThatWasCreatedBySomeoneElse() {
122
122
  const skill = await this.getSkillFixture().seedDemoSkill({
123
123
  name: 'global dependency skill',
124
+ isPublished: true,
124
125
  })
125
126
 
126
127
  await this.people.loginAsDemoPerson(DEMO_NUMBER_GLOBAL_EVENTS)
@@ -0,0 +1,25 @@
1
+ import { test, assert } from '@sprucelabs/test'
2
+ import CreateAction from '../../../features/permission/actions/CreateAction'
3
+ import AbstractCliTest from '../../../tests/AbstractCliTest'
4
+
5
+ export default class CreatingPermissionsTest extends AbstractCliTest {
6
+ private static create: CreateAction
7
+
8
+ protected static async beforeEach() {
9
+ await super.beforeEach()
10
+ await this.FeatureFixture().installCachedFeatures('permissions')
11
+ this.create = this.Action('permission', 'create')
12
+ }
13
+
14
+ @test()
15
+ protected static async canCreateCreatingPermissions() {
16
+ assert.isFunction(this.create.execute)
17
+ }
18
+
19
+ @test()
20
+ protected static async createsFileBasedOnName() {
21
+ await this.create.execute({
22
+ nameReadable: 'booking',
23
+ })
24
+ }
25
+ }
@@ -0,0 +1,71 @@
1
+ import { diskUtil } from '@sprucelabs/spruce-skill-utils'
2
+ import { test, assert } from '@sprucelabs/test'
3
+ import AbstractCliTest from '../../../tests/AbstractCliTest'
4
+
5
+ export default class SettingUpPolishTest extends AbstractCliTest {
6
+ @test()
7
+ protected static async hasCreateAction() {
8
+ assert.isFunction(this.Action('polish', 'setup').execute)
9
+ }
10
+
11
+ @test()
12
+ protected static async setsUpExpectedScript() {
13
+ await this.setupPolish()
14
+
15
+ const { destination } = await this.generateExpectedFile()
16
+
17
+ assert.isTrue(
18
+ diskUtil.doesFileExist(destination),
19
+ `Did not find polish script at ${destination}!`
20
+ )
21
+ }
22
+
23
+ @test()
24
+ protected static async polishResultsAreExpected() {
25
+ const results = await this.setupPolish()
26
+ const { filename, destination } = await this.generateExpectedFile()
27
+
28
+ assert.isLength(results.files, 1)
29
+ assert.isEqualDeep(results, {
30
+ files: [
31
+ {
32
+ name: filename,
33
+ description: `Polish script at ${filename}!`,
34
+ path: destination,
35
+ action: 'generated',
36
+ },
37
+ ],
38
+ })
39
+ }
40
+
41
+ @test()
42
+ protected static async createsExpectedScript() {
43
+ await this.setupPolish()
44
+ const pkg = this.Service('pkg')
45
+ const scripts = pkg.get('scripts')
46
+ assert.isEqual(scripts.polish, 'heartwood-polish')
47
+ }
48
+
49
+ @test()
50
+ protected static async makeSureScriptHasSomethingAndIsValid() {
51
+ const results = await this.setupPolish()
52
+ const { destination } = await this.generateExpectedFile()
53
+ const contents = diskUtil.readFile(destination)
54
+ assert.isNotEqual(contents, '')
55
+ await this.assertValidActionResponseFiles(results)
56
+ }
57
+
58
+ private static async generateExpectedFile() {
59
+ const store = this.Store('skill')
60
+ const namespace = await store.loadCurrentSkillsNamespace()
61
+ const filename = `${namespace.toLowerCase()}.polish.ts`
62
+ const destination = this.resolvePath('src', filename)
63
+ return { filename, destination }
64
+ }
65
+
66
+ private static async setupPolish() {
67
+ await this.FeatureFixture().installCachedFeatures('polish')
68
+ const results = await this.Action('polish', 'setup').execute({})
69
+ return results
70
+ }
71
+ }
@@ -19,7 +19,9 @@ import LogFeature from './log/LogFeature'
19
19
  import NodeFeature from './node/NodeFeature'
20
20
  import OnboardFeature from './onboard/OnboardFeature'
21
21
  import OrganizationFeature from './organization/OrganizationFeature'
22
+ import PermissionFeature from './permission/PermissionFeature'
22
23
  import PersonFeature from './person/PersonFeature'
24
+ import PolishFeature from './polish/PolishFeature'
23
25
  import SandboxFeature from './sandbox/SandboxFeature'
24
26
  import SchemaFeature from './schema/SchemaFeature'
25
27
  import SkillFeature from './skill/SkillFeature'
@@ -50,6 +52,8 @@ export default class FeatureInstallerFactory {
50
52
  CacheFeature,
51
53
  LogFeature,
52
54
  DependencyFeature,
55
+ PolishFeature,
56
+ PermissionFeature,
53
57
  ]
54
58
 
55
59
  public static readonly featureCodes: FeatureCode[] = [
@@ -73,6 +77,8 @@ export default class FeatureInstallerFactory {
73
77
  'cache',
74
78
  'log',
75
79
  'dependency',
80
+ 'polish',
81
+ 'permission',
76
82
  ]
77
83
 
78
84
  public static WithAllFeatures(options: {
@@ -5,10 +5,9 @@ import {
5
5
  } from '@sprucelabs/schema'
6
6
  import { eventNameUtil } from '@sprucelabs/spruce-event-utils'
7
7
  import { diskUtil } from '@sprucelabs/spruce-skill-utils'
8
+ import namedTemplateItemSchema from '#spruce/schemas/spruceCli/v2020_07_22/namedTemplateItem.schema'
8
9
  import syncEventActionSchema from '#spruce/schemas/spruceCli/v2020_07_22/syncEventOptions.schema'
9
10
  import SpruceError from '../../../errors/SpruceError'
10
- import namedTemplateItemBuilder from '../../../schemas/v2020_07_22/namedTemplateItem.builder'
11
- import syncEventActionBuilder from '../../../schemas/v2020_07_22/syncEventOptions.builder'
12
11
  import actionUtil from '../../../utilities/action.utility'
13
12
  import AbstractAction from '../../AbstractAction'
14
13
  import { FeatureActionResponse } from '../../features.types'
@@ -19,17 +18,17 @@ const optionsSchema = buildSchema({
19
18
  "Create a new event and I'll register it with Mercury when you boot the skill!",
20
19
  fields: {
21
20
  nameReadable: {
22
- ...namedTemplateItemBuilder.fields.nameReadable,
21
+ ...namedTemplateItemSchema.fields.nameReadable,
23
22
  isRequired: true,
24
23
  },
25
24
  nameKebab: {
26
- ...namedTemplateItemBuilder.fields.nameKebab,
25
+ ...namedTemplateItemSchema.fields.nameKebab,
27
26
  label: 'Event name',
28
27
  hint: `kebab-case`,
29
28
  isRequired: true,
30
29
  },
31
30
  nameCamel: {
32
- ...namedTemplateItemBuilder.fields.nameCamel,
31
+ ...namedTemplateItemSchema.fields.nameCamel,
33
32
  isRequired: true,
34
33
  },
35
34
  isGlobal: {
@@ -42,7 +41,7 @@ const optionsSchema = buildSchema({
42
41
  label: 'Version',
43
42
  isPrivate: true,
44
43
  },
45
- ...syncEventActionBuilder.fields,
44
+ ...syncEventActionSchema.fields,
46
45
  },
47
46
  })
48
47
 
@@ -2,12 +2,6 @@ import { diskUtil } from '@sprucelabs/spruce-skill-utils'
2
2
  import AbstractFeature, { FeatureDependency } from '../AbstractFeature'
3
3
  import { FeatureCode } from '../features.types'
4
4
 
5
- declare module '../../features/features.types' {
6
- interface FeatureMap {
7
- organization: OrganizationFeature
8
- }
9
- }
10
-
11
5
  export default class OrganizationFeature extends AbstractFeature {
12
6
  public code: FeatureCode = 'organization'
13
7
  public nameReadable = 'Organization'
@@ -26,3 +20,9 @@ export default class OrganizationFeature extends AbstractFeature {
26
20
 
27
21
  public actionsDir = diskUtil.resolvePath(__dirname, 'actions')
28
22
  }
23
+
24
+ declare module '../../features/features.types' {
25
+ interface FeatureMap {
26
+ organization: OrganizationFeature
27
+ }
28
+ }
@@ -0,0 +1,28 @@
1
+ import { diskUtil } from '@sprucelabs/spruce-skill-utils'
2
+ import AbstractFeature, { FeatureDependency } from '../AbstractFeature'
3
+ import { FeatureCode } from '../features.types'
4
+
5
+ export default class PermissionFeature extends AbstractFeature {
6
+ public code: FeatureCode = 'permission'
7
+ public nameReadable = 'permission'
8
+ public description = 'Manage permissions for your skill'
9
+ public dependencies: FeatureDependency[] = [
10
+ {
11
+ code: 'skill',
12
+ isRequired: true,
13
+ },
14
+ {
15
+ code: 'event',
16
+ isRequired: true,
17
+ },
18
+ ]
19
+ public packageDependencies = []
20
+
21
+ public actionsDir = diskUtil.resolvePath(__dirname, 'actions')
22
+ }
23
+
24
+ declare module '../../features/features.types' {
25
+ interface FeatureMap {
26
+ permission: PermissionFeature
27
+ }
28
+ }
@@ -0,0 +1,29 @@
1
+ import { buildSchema, pickFields, SchemaValues } from '@sprucelabs/schema'
2
+ import namedTemplateItemSchema from '#spruce/schemas/spruceCli/v2020_07_22/namedTemplateItem.schema'
3
+ import AbstractAction from '../../AbstractAction'
4
+ import { FeatureActionResponse } from '../../features.types'
5
+
6
+ const schema = buildSchema({
7
+ id: 'createPermission',
8
+ fields: {
9
+ ...pickFields(namedTemplateItemSchema.fields, [
10
+ 'nameReadable',
11
+ 'nameKebab',
12
+ ]),
13
+ },
14
+ })
15
+
16
+ type OptionsSchema = typeof schema
17
+ type Options = SchemaValues<OptionsSchema>
18
+
19
+ export default class CreateAction extends AbstractAction<OptionsSchema> {
20
+ public optionsSchema = schema
21
+ public invocationMessage = 'Creating a permission contract... 🛡'
22
+
23
+ public async execute(_options: Options): Promise<FeatureActionResponse> {
24
+ // const { nameKebab, nameReadable } =
25
+ // this.validateAndNormalizeOptions(options)
26
+
27
+ return {}
28
+ }
29
+ }
@@ -2,12 +2,6 @@ import { diskUtil } from '@sprucelabs/spruce-skill-utils'
2
2
  import AbstractFeature, { FeatureDependency } from '../AbstractFeature'
3
3
  import { FeatureCode } from '../features.types'
4
4
 
5
- declare module '../../features/features.types' {
6
- interface FeatureMap {
7
- person: PersonFeature
8
- }
9
- }
10
-
11
5
  export default class PersonFeature extends AbstractFeature {
12
6
  public code: FeatureCode = 'person'
13
7
  public nameReadable = 'Person'
@@ -26,3 +20,9 @@ export default class PersonFeature extends AbstractFeature {
26
20
  return this.featureInstaller.isInstalled('skill')
27
21
  }
28
22
  }
23
+
24
+ declare module '../../features/features.types' {
25
+ interface FeatureMap {
26
+ person: PersonFeature
27
+ }
28
+ }
@@ -0,0 +1,33 @@
1
+ import { diskUtil, NpmPackage } from '@sprucelabs/spruce-skill-utils'
2
+ import AbstractFeature, { FeatureDependency } from '../AbstractFeature'
3
+ import { FeatureCode } from '../features.types'
4
+
5
+ export default class PolishFeature extends AbstractFeature {
6
+ public code: FeatureCode = 'polish'
7
+ public nameReadable = 'Polish'
8
+ public description =
9
+ 'Run through your skill as a robot, clicking and typing and asserting!'
10
+ public dependencies: FeatureDependency[] = [
11
+ {
12
+ code: 'skill',
13
+ isRequired: true,
14
+ },
15
+ ]
16
+ public packageDependencies: NpmPackage[] = [
17
+ {
18
+ name: '@sprucelabs/heartwood-polish',
19
+ isDev: true,
20
+ },
21
+ ]
22
+
23
+ public actionsDir = diskUtil.resolvePath(__dirname, 'actions')
24
+ public scripts = {
25
+ polish: 'heartwood-polish',
26
+ }
27
+ }
28
+
29
+ declare module '../../features/features.types' {
30
+ interface FeatureMap {
31
+ polish: PolishFeature
32
+ }
33
+ }
@@ -0,0 +1,36 @@
1
+ import { buildSchema } from '@sprucelabs/schema'
2
+ import { diskUtil } from '@sprucelabs/spruce-skill-utils'
3
+ import ScriptUpdater from '../../../updaters/ScriptUpdater'
4
+ import AbstractAction from '../../AbstractAction'
5
+ import { FeatureActionResponse } from '../../features.types'
6
+
7
+ const optionsSchema = buildSchema({
8
+ id: 'setupPolishAction',
9
+ fields: {},
10
+ })
11
+
12
+ type OptionsSchema = typeof optionsSchema
13
+
14
+ export default class SetupAction extends AbstractAction<OptionsSchema> {
15
+ public optionsSchema: OptionsSchema = optionsSchema
16
+ public invocationMessage = 'Setting up polish... ✨'
17
+
18
+ public async execute(): Promise<FeatureActionResponse> {
19
+ const namespace = await this.Store('skill').loadCurrentSkillsNamespace()
20
+ const writer = this.Writer('polish')
21
+ const files = await writer.writePolishScript(
22
+ diskUtil.resolvePath(this.cwd, 'src'),
23
+ namespace.toLowerCase()
24
+ )
25
+
26
+ const scriptUpdater = ScriptUpdater.FromFeature(this.parent, {
27
+ cwd: this.cwd,
28
+ })
29
+
30
+ await scriptUpdater.update()
31
+
32
+ return {
33
+ files,
34
+ }
35
+ }
36
+ }
@@ -0,0 +1,23 @@
1
+ import pathUtil from 'path'
2
+ import AbstractWriter from '../../../writers/AbstractWriter'
3
+
4
+ export default class PolishWriter extends AbstractWriter {
5
+ public async writePolishScript(
6
+ destinationDir: string,
7
+ skillNamespace: string
8
+ ) {
9
+ const filename = `${skillNamespace}.polish.ts`
10
+ const resolvedDestination = pathUtil.join(destinationDir, filename)
11
+ const content = this.templates.polish()
12
+
13
+ const results = await this.writeFileIfChangedMixinResults(
14
+ resolvedDestination,
15
+ content,
16
+ `Polish script at ${filename}!`
17
+ )
18
+
19
+ await this.lint(resolvedDestination)
20
+
21
+ return results
22
+ }
23
+ }
@@ -4,16 +4,6 @@ import SpruceError from '../../../errors/SpruceError'
4
4
  import AbstractStore from '../../../stores/AbstractStore'
5
5
  import { CurrentSkill, RegisteredSkill } from '../../../types/cli.types'
6
6
 
7
- export interface CreateSkill {
8
- name: string
9
- slug: string
10
- description?: string
11
- }
12
-
13
- export interface RegisterSkillOptions {
14
- isRegisteringCurrentSkill?: boolean
15
- }
16
-
17
7
  export default class SkillStore extends AbstractStore {
18
8
  public readonly name = 'skill'
19
9
  private static currentSkill?: CurrentSkill
@@ -31,7 +21,7 @@ export default class SkillStore extends AbstractStore {
31
21
 
32
22
  isRegisteringCurrentSkill && this.assertInSkill()
33
23
 
34
- const { name, slug, description } = values
24
+ const { name, slug, description, isPublished } = values
35
25
  const client = await this.connectToApi()
36
26
 
37
27
  const results = await client.emit('register-skill::v2020_12_25', {
@@ -39,6 +29,7 @@ export default class SkillStore extends AbstractStore {
39
29
  name,
40
30
  slug,
41
31
  description,
32
+ isPublished,
42
33
  },
43
34
  })
44
35
 
@@ -189,3 +180,14 @@ export default class SkillStore extends AbstractStore {
189
180
  return skills
190
181
  }
191
182
  }
183
+
184
+ export interface CreateSkill {
185
+ name: string
186
+ slug?: string
187
+ description?: string
188
+ isPublished?: boolean
189
+ }
190
+
191
+ export interface RegisterSkillOptions {
192
+ isRegisteringCurrentSkill?: boolean
193
+ }
@@ -1,6 +1,9 @@
1
1
  import { EventContract, SpruceSchemas } from '@sprucelabs/mercury-types'
2
2
  import { namesUtil } from '@sprucelabs/spruce-skill-utils'
3
- import { RegisterSkillOptions } from '../../features/skill/stores/SkillStore'
3
+ import {
4
+ CreateSkill,
5
+ RegisterSkillOptions,
6
+ } from '../../features/skill/stores/SkillStore'
4
7
  import StoreFactory from '../../stores/StoreFactory'
5
8
  import {
6
9
  ApiClientFactory,
@@ -27,7 +30,7 @@ export default class SkillFixture {
27
30
  }
28
31
 
29
32
  public async seedDemoSkill(
30
- values: { name: string },
33
+ values: CreateSkill,
31
34
  options?: { phone?: string }
32
35
  ) {
33
36
  return this.registerCurrentSkill(values, {
@@ -37,7 +40,7 @@ export default class SkillFixture {
37
40
  }
38
41
 
39
42
  public async registerCurrentSkill(
40
- values: { name: string; slug?: string },
43
+ values: CreateSkill,
41
44
  options?: RegisterSkillOptions & { phone?: string }
42
45
  ) {
43
46
  await this.personFixture.loginAsDemoPerson(options?.phone)
@@ -6,6 +6,7 @@ import ErrorWriter from '../features/error/writers/ErrorWriter'
6
6
  import EventWriter from '../features/event/writers/EventWriter'
7
7
  import LogWriter from '../features/log/writers/LogWriter'
8
8
  import NodeWriter from '../features/node/writers/NodeWriter'
9
+ import PolishWriter from '../features/polish/writers/PolishWriter'
9
10
  import SandboxWriter from '../features/sandbox/writers/SandboxWriter'
10
11
  import SchemaWriter from '../features/schema/writers/SchemaWriter'
11
12
  import SkillGenerator from '../features/skill/writers/SkillWriter'
@@ -32,6 +33,7 @@ const classMap = {
32
33
  store: StoreWriter,
33
34
  view: ViewWriter,
34
35
  log: LogWriter,
36
+ polish: PolishWriter,
35
37
  }
36
38
 
37
39
  export interface WriterMap {
@@ -48,6 +50,7 @@ export interface WriterMap {
48
50
  store: StoreWriter
49
51
  view: ViewWriter
50
52
  log: LogWriter
53
+ polish: PolishWriter
51
54
  }
52
55
 
53
56
  export type WriterCode = keyof WriterMap