@sprucelabs/spruce-cli 14.28.7 → 14.29.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 (128) hide show
  1. package/CHANGELOG.md +35 -0
  2. package/build/__tests__/behavioral/SettingLogTransportsInASkill.test.js +13 -9
  3. package/build/__tests__/behavioral/SettingLogTransportsInASkill.test.js.map +1 -1
  4. package/build/__tests__/behavioral/SyncingEventsOnlyFromDependencies.test.d.ts +1 -1
  5. package/build/__tests__/behavioral/SyncingEventsOnlyFromDependencies.test.js +24 -14
  6. package/build/__tests__/behavioral/SyncingEventsOnlyFromDependencies.test.js.map +1 -1
  7. package/build/__tests__/behavioral/TestingDataStores.test.js +15 -11
  8. package/build/__tests__/behavioral/TestingDataStores.test.js.map +1 -1
  9. package/build/__tests__/behavioral/eventContract/PullingMercuryEventContract.test.js +3 -1
  10. package/build/__tests__/behavioral/eventContract/PullingMercuryEventContract.test.js.map +1 -1
  11. package/build/__tests__/behavioral/events/CreatingAListener.test.d.ts +2 -0
  12. package/build/__tests__/behavioral/events/CreatingAListener.test.js +157 -81
  13. package/build/__tests__/behavioral/events/CreatingAListener.test.js.map +1 -1
  14. package/build/__tests__/behavioral/events/KeepingListenersInSync.test.d.ts +7 -0
  15. package/build/__tests__/behavioral/events/KeepingListenersInSync.test.js +171 -0
  16. package/build/__tests__/behavioral/events/KeepingListenersInSync.test.js.map +1 -0
  17. package/build/__tests__/behavioral/events/SkillEmitsBootEvents.test.d.ts +1 -0
  18. package/build/__tests__/behavioral/events/SkillEmitsBootEvents.test.js +53 -21
  19. package/build/__tests__/behavioral/events/SkillEmitsBootEvents.test.js.map +1 -1
  20. package/build/__tests__/behavioral/skill/UpgradingWithListeners.test.d.ts +5 -0
  21. package/build/__tests__/behavioral/skill/UpgradingWithListeners.test.js +137 -0
  22. package/build/__tests__/behavioral/skill/UpgradingWithListeners.test.js.map +1 -0
  23. package/build/__tests__/behavioral/stores/CreatingADataStore.test.js +4 -1
  24. package/build/__tests__/behavioral/stores/CreatingADataStore.test.js.map +1 -1
  25. package/build/__tests__/behavioral/stores/KeepingDataStoresInSync.test.d.ts +4 -1
  26. package/build/__tests__/behavioral/stores/KeepingDataStoresInSync.test.js +136 -47
  27. package/build/__tests__/behavioral/stores/KeepingDataStoresInSync.test.js.map +1 -1
  28. package/build/__tests__/behavioral/tests/CreatingATest.test.js +14 -10
  29. package/build/__tests__/behavioral/tests/CreatingATest.test.js.map +1 -1
  30. package/build/__tests__/behavioral/views/TestingViewControllers.test.d.ts +1 -0
  31. package/build/__tests__/behavioral/views/TestingViewControllers.test.js +67 -35
  32. package/build/__tests__/behavioral/views/TestingViewControllers.test.js.map +1 -1
  33. package/build/__tests__/implementation/AuthService.test.d.ts +1 -0
  34. package/build/__tests__/implementation/AuthService.test.js +8 -0
  35. package/build/__tests__/implementation/AuthService.test.js.map +1 -1
  36. package/build/__tests__/implementation/EventStore.test.js +3 -1
  37. package/build/__tests__/implementation/EventStore.test.js.map +1 -1
  38. package/build/__tests__/implementation/LintService.test.d.ts +5 -0
  39. package/build/__tests__/implementation/LintService.test.js +130 -0
  40. package/build/__tests__/implementation/LintService.test.js.map +1 -0
  41. package/build/__tests__/implementation/StoreFeature.test.d.ts +4 -0
  42. package/build/__tests__/implementation/StoreFeature.test.js +132 -0
  43. package/build/__tests__/implementation/StoreFeature.test.js.map +1 -0
  44. package/build/errors/SpruceError.js +8 -4
  45. package/build/errors/SpruceError.js.map +1 -1
  46. package/build/features/event/EventFeature.d.ts +2 -2
  47. package/build/features/event/EventFeature.js +53 -13
  48. package/build/features/event/EventFeature.js.map +1 -1
  49. package/build/features/event/actions/ListenAction.d.ts +1 -0
  50. package/build/features/event/actions/ListenAction.js +60 -31
  51. package/build/features/event/actions/ListenAction.js.map +1 -1
  52. package/build/features/event/actions/SyncListenersAction.d.ts +15 -0
  53. package/build/features/event/actions/SyncListenersAction.js +115 -0
  54. package/build/features/event/actions/SyncListenersAction.js.map +1 -0
  55. package/build/features/event/builders/ListenerTemplateItemBuilder.d.ts +8 -0
  56. package/build/features/event/builders/ListenerTemplateItemBuilder.js +65 -0
  57. package/build/features/event/builders/ListenerTemplateItemBuilder.js.map +1 -0
  58. package/build/features/event/stores/EventStore.js +2 -2
  59. package/build/features/event/stores/EventStore.js.map +1 -1
  60. package/build/features/event/stores/ListenerStore.d.ts +9 -0
  61. package/build/features/event/stores/ListenerStore.js +122 -0
  62. package/build/features/event/stores/ListenerStore.js.map +1 -0
  63. package/build/features/event/writers/EventWriter.d.ts +4 -1
  64. package/build/features/event/writers/EventWriter.js +42 -8
  65. package/build/features/event/writers/EventWriter.js.map +1 -1
  66. package/build/features/node/NodeFeature.js +1 -1
  67. package/build/features/node/NodeFeature.js.map +1 -1
  68. package/build/features/skill/SkillFeature.js +1 -1
  69. package/build/features/skill/SkillFeature.js.map +1 -1
  70. package/build/features/skill/stores/SkillStore.js +4 -8
  71. package/build/features/skill/stores/SkillStore.js.map +1 -1
  72. package/build/features/store/StoreFeature.d.ts +1 -1
  73. package/build/features/store/StoreFeature.js +16 -11
  74. package/build/features/store/StoreFeature.js.map +1 -1
  75. package/build/services/AuthService.d.ts +4 -1
  76. package/build/services/AuthService.js +15 -4
  77. package/build/services/AuthService.js.map +1 -1
  78. package/build/services/GameService.js +14 -10
  79. package/build/services/GameService.js.map +1 -1
  80. package/build/services/LintService.d.ts +5 -2
  81. package/build/services/LintService.js +137 -92
  82. package/build/services/LintService.js.map +1 -1
  83. package/build/services/ServiceFactory.js +9 -3
  84. package/build/services/ServiceFactory.js.map +1 -1
  85. package/build/stores/StoreFactory.d.ts +2 -0
  86. package/build/stores/StoreFactory.js +4 -1
  87. package/build/stores/StoreFactory.js.map +1 -1
  88. package/build/tests/AbstractCliTest.js +3 -3
  89. package/build/tests/AbstractCliTest.js.map +1 -1
  90. package/build/writers/AbstractWriter.d.ts +0 -3
  91. package/build/writers/AbstractWriter.js +2 -18
  92. package/build/writers/AbstractWriter.js.map +1 -1
  93. package/package.json +11 -9
  94. package/src/__tests__/behavioral/SettingLogTransportsInASkill.test.ts +2 -0
  95. package/src/__tests__/behavioral/SyncingEventsOnlyFromDependencies.test.ts +10 -5
  96. package/src/__tests__/behavioral/TestingDataStores.test.ts +2 -0
  97. package/src/__tests__/behavioral/eventContract/PullingMercuryEventContract.test.ts +1 -0
  98. package/src/__tests__/behavioral/events/CreatingAListener.test.ts +28 -9
  99. package/src/__tests__/behavioral/events/KeepingListenersInSync.test.ts +47 -0
  100. package/src/__tests__/behavioral/events/SkillEmitsBootEvents.test.ts +6 -0
  101. package/src/__tests__/behavioral/skill/UpgradingWithListeners.test.ts +59 -0
  102. package/src/__tests__/behavioral/stores/CreatingADataStore.test.ts +1 -0
  103. package/src/__tests__/behavioral/stores/KeepingDataStoresInSync.test.ts +35 -6
  104. package/src/__tests__/behavioral/tests/CreatingATest.test.ts +2 -0
  105. package/src/__tests__/behavioral/views/TestingViewControllers.test.ts +6 -0
  106. package/src/__tests__/implementation/AuthService.test.ts +6 -0
  107. package/src/__tests__/implementation/EventStore.test.ts +1 -0
  108. package/src/__tests__/implementation/LintService.test.ts +34 -0
  109. package/src/__tests__/implementation/StoreFeature.test.ts +40 -0
  110. package/src/errors/SpruceError.ts +9 -5
  111. package/src/features/event/EventFeature.ts +21 -4
  112. package/src/features/event/actions/ListenAction.ts +9 -3
  113. package/src/features/event/actions/SyncListenersAction.ts +38 -0
  114. package/src/features/event/builders/ListenerTemplateItemBuilder.ts +27 -0
  115. package/src/features/event/stores/EventStore.ts +1 -1
  116. package/src/features/event/stores/ListenerStore.ts +32 -0
  117. package/src/features/event/writers/EventWriter.ts +19 -0
  118. package/src/features/node/NodeFeature.ts +2 -1
  119. package/src/features/skill/SkillFeature.ts +1 -1
  120. package/src/features/skill/stores/SkillStore.ts +4 -3
  121. package/src/features/store/StoreFeature.ts +7 -4
  122. package/src/services/AuthService.ts +15 -5
  123. package/src/services/GameService.ts +1 -0
  124. package/src/services/LintService.ts +34 -5
  125. package/src/services/ServiceFactory.ts +8 -3
  126. package/src/stores/StoreFactory.ts +3 -0
  127. package/src/tests/AbstractCliTest.ts +2 -2
  128. package/src/writers/AbstractWriter.ts +2 -13
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/features/skill/SkillFeature.ts"],"names":["SkillFeature","options","name","version","isDev","universalDevDependencies","skillFeatureSchema","diskUtil","resolvePath","__dirname","node","yarn","boot","health","universalScripts","universalFileDescriptions","path","description","shouldOverwriteWhenChanged","emitter","on","handleRegisterAbstractTestClasses","bind","handleWillExecute","abstractClasses","label","featureCode","install","files","cwd","resolveDestination","destination","Store","setCurrentSkillsNamespace","doesDirExist","createDir","skillGenerator","Writer","writeSkill","installScripts","setEngines","env","Service","set","scriptUpdater","ScriptUpdater","FromFeature","update","pkg","engines","get","all","value","actionCode","upgradeOptions","featureInstaller","isInstalled","updater","Updater","updateFiles","AbstractFeature"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AAEA;;AAEA;;AACA;;AAEA;;AACA;;AACA;;AACA;;;;;;;;;;IAkBqBA,Y;;;;;AAyEpB,wBAAmBC,OAAnB,EAA4C;AAAA;;AAAA;AAC3C,8BAAMA,OAAN;AAD2C,qGAtEtB,OAsEsB;AAAA,6FArEjB,OAqEiB;AAAA,oGApEvB,uCAoEuB;AAAA,2GAnEP,GAmEO;AAAA,6GAhE3C;AAAEC,MAAAA,IAAI,EAAE;AAAR,KAgE2C,EA/D3C;AAAEA,MAAAA,IAAI,EAAE;AAAR,KA+D2C,EA9D3C;AAAEA,MAAAA,IAAI,EAAE;AAAR,KA8D2C,EA7D3C;AAAEA,MAAAA,IAAI,EAAE;AAAR,KA6D2C,EA5D3C;AAAEA,MAAAA,IAAI,EAAE;AAAR,KA4D2C,EA3D3C;AAAEA,MAAAA,IAAI,EAAE;AAAR,KA2D2C,EA1D3C;AAAEA,MAAAA,IAAI,EAAE;AAAR,KA0D2C,EAzD3C;AAAEA,MAAAA,IAAI,EAAE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diskUtil } from '@sprucelabs/spruce-skill-utils'\nimport { SpruceSchemas } from '#spruce/schemas/schemas.types'\nimport skillFeatureSchema from '#spruce/schemas/spruceCli/v2020_07_22/skillFeature.schema'\nimport { FileDescription, NpmPackage } from '../../types/cli.types'\nimport ScriptUpdater from '../../updaters/ScriptUpdater'\nimport AbstractFeature, { FeatureOptions } from '../AbstractFeature'\nimport { FeatureCode } from '../features.types'\nimport universalDevDependencies from '../universalDevDependencies'\nimport universalFileDescriptions from '../universalFileDescriptions'\nimport universalScripts from '../universalScripts'\nimport Updater from './updaters/Updater'\n\ntype SkillFeatureOptionsSchema =\n\tSpruceSchemas.SpruceCli.v2020_07_22.SkillFeatureSchema\ntype SkillFeatureOptions = SpruceSchemas.SpruceCli.v2020_07_22.SkillFeature\n\ndeclare module '../../features/features.types' {\n\tinterface FeatureMap {\n\t\tskill: SkillFeature\n\t}\n\n\tinterface FeatureOptionsMap {\n\t\tskill: SchemaValues<SkillFeatureOptionsSchema>\n\t}\n}\n\ntype UpgradeOptions = SpruceSchemas.SpruceCli.v2020_07_22.UpgradeSkillOptions\n\nexport default class SkillFeature<\n\tS extends SkillFeatureOptionsSchema = SkillFeatureOptionsSchema\n> extends AbstractFeature<S> {\n\tpublic nameReadable = 'Skill'\n\tpublic code: FeatureCode = 'skill'\n\tpublic description = 'The scaffolding needed to run a Skill'\n\tpublic readonly installOrderWeight = 100\n\n\tpublic packageDependencies: NpmPackage[] = [\n\t\t{ name: '@sprucelabs/error' },\n\t\t{ name: '@sprucelabs/spruce-skill-utils' },\n\t\t{ name: '@sprucelabs/spruce-skill-booter' },\n\t\t{ name: '@sprucelabs/spruce-event-utils' },\n\t\t{ name: '@sprucelabs/spruce-event-plugin' },\n\t\t{ name: '@sprucelabs/spruce-core-schemas' },\n\t\t{ name: 'dotenv' },\n\t\t{ name: 'globby', version: '^11.0.4' },\n\t\t{\n\t\t\tname: '@sprucelabs/mercury-types',\n\t\t},\n\t\t{ name: 'tsconfig-paths', isDev: true },\n\t\t{ name: 'ts-node', isDev: true },\n\t\t...universalDevDependencies,\n\t]\n\n\tpublic optionsSchema = skillFeatureSchema as S\n\tpublic actionsDir = diskUtil.resolvePath(__dirname, 'actions')\n\tprivate engines = {\n\t\tnode: '16.x',\n\t\tyarn: '1.x',\n\t}\n\tpublic scripts = {\n\t\tboot: 'node build/index',\n\t\t'boot.local':\n\t\t\t'node -r ts-node/register -r tsconfig-paths/register ./src/index',\n\n\t\thealth: 'yarn boot --health',\n\t\t'health.local': 'yarn boot.local --health',\n\n\t\t...universalScripts,\n\t}\n\n\tpublic readonly fileDescriptions: FileDescription[] = [\n\t\t...universalFileDescriptions,\n\t\t{\n\t\t\tpath: 'src/index.ts',\n\t\t\tdescription: 'The file that \"boots\" the skill.',\n\t\t\tshouldOverwriteWhenChanged: true,\n\t\t},\n\t\t{\n\t\t\tpath: 'errors/SpruceError.ts',\n\t\t\tdescription: 'Starting error class that you can edit.',\n\t\t\tshouldOverwriteWhenChanged: false,\n\t\t},\n\t\t{\n\t\t\tpath: '.spruce/skill.ts',\n\t\t\tdescription: 'Used to support booting the skill.',\n\t\t\tshouldOverwriteWhenChanged: true,\n\t\t},\n\t\t{\n\t\t\tpath: '.spruce/errors/options.types.ts',\n\t\t\tdescription:\n\t\t\t\t'Holds all possible error codes and options. Will be updated as you create more errors (spruce create.error).',\n\t\t\tshouldOverwriteWhenChanged: true,\n\t\t},\n\t\t{\n\t\t\tpath: 'src/.spruce/features/event.plugin.ts',\n\t\t\tdescription:\n\t\t\t\t'Gives your skill event support through local boot events and optionall Mercury (spruce event.listen).',\n\t\t\tshouldOverwriteWhenChanged: true,\n\t\t},\n\t]\n\n\tpublic constructor(options: FeatureOptions) {\n\t\tsuper(options)\n\n\t\tvoid this.emitter.on(\n\t\t\t`test.register-abstract-test-classes`,\n\t\t\tthis.handleRegisterAbstractTestClasses.bind(this)\n\t\t)\n\n\t\tvoid this.emitter.on(\n\t\t\t'feature.will-execute',\n\t\t\tthis.handleWillExecute.bind(this)\n\t\t)\n\t}\n\n\tprivate async handleRegisterAbstractTestClasses() {\n\t\treturn {\n\t\t\tabstractClasses: [\n\t\t\t\t{\n\t\t\t\t\tname: 'AbstractSpruceFixtureTest',\n\t\t\t\t\tlabel: 'AbstractSpruceFixtureTest',\n\t\t\t\t\timport: '@sprucelabs/spruce-test-fixtures',\n\t\t\t\t\tfeatureCode: 'skill',\n\t\t\t\t},\n\t\t\t],\n\t\t}\n\t}\n\n\tpublic async beforePackageInstall(options: SkillFeatureOptions) {\n\t\tconst { files } = await this.install(options)\n\t\treturn { files, cwd: this.resolveDestination(options) }\n\t}\n\n\tpublic async afterPackageInstall(options: SkillFeatureOptions) {\n\t\tconst destination = this.resolveDestination(options)\n\t\tawait this.Store('skill', { cwd: destination }).setCurrentSkillsNamespace(\n\t\t\toptions.name\n\t\t)\n\t\treturn {}\n\t}\n\n\tprivate async install(options: SkillFeatureOptions) {\n\t\tvalidateSchemaValues(skillFeatureSchema, options)\n\n\t\tconst destination = this.resolveDestination(options)\n\t\tif (!diskUtil.doesDirExist(destination)) {\n\t\t\tdiskUtil.createDir(destination)\n\t\t}\n\n\t\tconst skillGenerator = this.Writer('skill')\n\n\t\tconst files = await skillGenerator.writeSkill(destination, options)\n\n\t\tawait this.installScripts(destination)\n\n\t\tthis.setEngines(destination)\n\n\t\tconst env = this.Service('env', destination)\n\t\tenv.set('SKILL_NAME', options.name)\n\n\t\treturn { files }\n\t}\n\n\tprivate resolveDestination(options: SkillFeatureOptions) {\n\t\treturn diskUtil.resolvePath(this.cwd, options.destination ?? '')\n\t}\n\n\tpublic async installScripts(destination = this.cwd) {\n\t\tconst scriptUpdater = ScriptUpdater.FromFeature(this, {\n\t\t\tcwd: destination,\n\t\t})\n\n\t\tawait scriptUpdater.update()\n\t}\n\n\tpublic setEngines(destination: string) {\n\t\tconst pkg = this.Service('pkg', destination)\n\t\tconst engines = (pkg.get('engines') as Record<string, string>) || {}\n\n\t\tfor (const name in this.engines) {\n\t\t\tconst all = this.engines\n\t\t\tengines[name] = this.engines[name as keyof typeof all]\n\t\t}\n\n\t\tpkg.set({ path: 'engines', value: engines })\n\t}\n\n\tpublic async handleWillExecute(options: {\n\t\tfeatureCode: string\n\t\tactionCode: string\n\t\toptions?: UpgradeOptions\n\t}) {\n\t\tconst { featureCode, actionCode, options: upgradeOptions } = options\n\t\tconst isInstalled = await this.featureInstaller.isInstalled('skill')\n\n\t\tif (isInstalled && featureCode === 'node' && actionCode === 'upgrade') {\n\t\t\tconst updater = new Updater(this, this.emitter)\n\t\t\tconst files = await updater.updateFiles(upgradeOptions as any)\n\t\t\treturn {\n\t\t\t\tfiles,\n\t\t\t}\n\t\t}\n\n\t\treturn {}\n\t}\n}\n"],"file":"SkillFeature.js"}
1
+ {"version":3,"sources":["../../../src/features/skill/SkillFeature.ts"],"names":["SkillFeature","options","name","version","isDev","universalDevDependencies","skillFeatureSchema","diskUtil","resolvePath","__dirname","node","yarn","boot","health","universalScripts","universalFileDescriptions","path","description","shouldOverwriteWhenChanged","emitter","on","handleRegisterAbstractTestClasses","bind","handleWillExecute","abstractClasses","label","featureCode","install","files","cwd","resolveDestination","destination","Store","setCurrentSkillsNamespace","doesDirExist","createDir","skillGenerator","Writer","writeSkill","installScripts","setEngines","env","Service","set","scriptUpdater","ScriptUpdater","FromFeature","update","pkg","engines","get","all","value","actionCode","upgradeOptions","featureInstaller","isInstalled","updater","Updater","updateFiles","AbstractFeature"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AAEA;;AAEA;;AACA;;AAEA;;AACA;;AACA;;AACA;;;;;;;;;;IAkBqBA,Y;;;;;AAyEpB,wBAAmBC,OAAnB,EAA4C;AAAA;;AAAA;AAC3C,8BAAMA,OAAN;AAD2C,qGAtEtB,OAsEsB;AAAA,6FArEjB,OAqEiB;AAAA,oGApEvB,uCAoEuB;AAAA,2GAnEP,GAmEO;AAAA,6GAhE3C;AAAEC,MAAAA,IAAI,EAAE;AAAR,KAgE2C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Z,EAAkB,KAAKvC,OAAvB,CATlB;AAAA;AAAA,uBAUsBsC,OAAO,CAACE,WAAR,CAAoBL,cAApB,aAAoBA,cAApB,cAAoBA,cAApB,GAAsC,EAAtC,CAVtB;;AAAA;AAUQ1B,gBAAAA,KAVR;AAAA,kDAWS;AACNA,kBAAAA,KAAK,EAALA;AADM,iBAXT;;AAAA;AAAA,kDAgBQ,EAhBR;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,O;;;;;;;;;;EA7JSgC,4B","sourcesContent":["import { SchemaValues, validateSchemaValues } from '@sprucelabs/schema'\nimport { diskUtil } from '@sprucelabs/spruce-skill-utils'\nimport { SpruceSchemas } from '#spruce/schemas/schemas.types'\nimport skillFeatureSchema from '#spruce/schemas/spruceCli/v2020_07_22/skillFeature.schema'\nimport { FileDescription, NpmPackage } from '../../types/cli.types'\nimport ScriptUpdater from '../../updaters/ScriptUpdater'\nimport AbstractFeature, { FeatureOptions } from '../AbstractFeature'\nimport { FeatureCode } from '../features.types'\nimport universalDevDependencies from '../universalDevDependencies'\nimport universalFileDescriptions from '../universalFileDescriptions'\nimport universalScripts from '../universalScripts'\nimport Updater from './updaters/Updater'\n\ntype SkillFeatureOptionsSchema =\n\tSpruceSchemas.SpruceCli.v2020_07_22.SkillFeatureSchema\ntype SkillFeatureOptions = SpruceSchemas.SpruceCli.v2020_07_22.SkillFeature\n\ndeclare module '../../features/features.types' {\n\tinterface FeatureMap {\n\t\tskill: SkillFeature\n\t}\n\n\tinterface FeatureOptionsMap {\n\t\tskill: SchemaValues<SkillFeatureOptionsSchema>\n\t}\n}\n\ntype UpgradeOptions = SpruceSchemas.SpruceCli.v2020_07_22.UpgradeSkillOptions\n\nexport default class SkillFeature<\n\tS extends SkillFeatureOptionsSchema = SkillFeatureOptionsSchema\n> extends AbstractFeature<S> {\n\tpublic nameReadable = 'Skill'\n\tpublic code: FeatureCode = 'skill'\n\tpublic description = 'The scaffolding needed to run a Skill'\n\tpublic readonly installOrderWeight = 100\n\n\tpublic packageDependencies: NpmPackage[] = [\n\t\t{ name: '@sprucelabs/error' },\n\t\t{ name: '@sprucelabs/spruce-skill-utils' },\n\t\t{ name: '@sprucelabs/spruce-skill-booter' },\n\t\t{ name: '@sprucelabs/spruce-event-utils' },\n\t\t{ name: '@sprucelabs/spruce-event-plugin' },\n\t\t{ name: '@sprucelabs/spruce-core-schemas' },\n\t\t{ name: 'dotenv' },\n\t\t{ name: 'globby', version: '^11.0.4' },\n\t\t{\n\t\t\tname: '@sprucelabs/mercury-types',\n\t\t},\n\t\t{ name: 'tsconfig-paths', isDev: true },\n\t\t{ name: 'ts-node', isDev: true },\n\t\t...universalDevDependencies,\n\t]\n\n\tpublic optionsSchema = skillFeatureSchema as S\n\tpublic actionsDir = diskUtil.resolvePath(__dirname, 'actions')\n\tprivate engines = {\n\t\tnode: '16.x',\n\t\tyarn: '1.x',\n\t}\n\tpublic scripts = {\n\t\tboot: 'node build/index',\n\t\t'boot.local':\n\t\t\t'node -r ts-node/register -r tsconfig-paths/register ./src/index',\n\n\t\thealth: 'yarn boot --health',\n\t\t'health.local': 'yarn boot.local --health',\n\n\t\t...universalScripts,\n\t}\n\n\tpublic readonly fileDescriptions: FileDescription[] = [\n\t\t...universalFileDescriptions,\n\t\t{\n\t\t\tpath: 'src/index.ts',\n\t\t\tdescription: 'The file that \"boots\" the skill.',\n\t\t\tshouldOverwriteWhenChanged: true,\n\t\t},\n\t\t{\n\t\t\tpath: 'errors/SpruceError.ts',\n\t\t\tdescription: 'Starting error class that you can edit.',\n\t\t\tshouldOverwriteWhenChanged: false,\n\t\t},\n\t\t{\n\t\t\tpath: '.spruce/skill.ts',\n\t\t\tdescription: 'Used to support booting the skill.',\n\t\t\tshouldOverwriteWhenChanged: true,\n\t\t},\n\t\t{\n\t\t\tpath: '.spruce/errors/options.types.ts',\n\t\t\tdescription:\n\t\t\t\t'Holds all possible error codes and options. Will be updated as you create more errors (spruce create.error).',\n\t\t\tshouldOverwriteWhenChanged: true,\n\t\t},\n\t\t{\n\t\t\tpath: 'src/.spruce/features/event.plugin.ts',\n\t\t\tdescription:\n\t\t\t\t'Gives your skill event support through local boot events and optionall Mercury (spruce event.listen).',\n\t\t\tshouldOverwriteWhenChanged: true,\n\t\t},\n\t]\n\n\tpublic constructor(options: FeatureOptions) {\n\t\tsuper(options)\n\n\t\tvoid this.emitter.on(\n\t\t\t`test.register-abstract-test-classes`,\n\t\t\tthis.handleRegisterAbstractTestClasses.bind(this)\n\t\t)\n\n\t\tvoid this.emitter.on(\n\t\t\t'feature.will-execute',\n\t\t\tthis.handleWillExecute.bind(this)\n\t\t)\n\t}\n\n\tprivate async handleRegisterAbstractTestClasses() {\n\t\treturn {\n\t\t\tabstractClasses: [\n\t\t\t\t{\n\t\t\t\t\tname: 'AbstractSpruceFixtureTest',\n\t\t\t\t\tlabel: 'AbstractSpruceFixtureTest',\n\t\t\t\t\timport: '@sprucelabs/spruce-test-fixtures',\n\t\t\t\t\tfeatureCode: 'skill',\n\t\t\t\t},\n\t\t\t],\n\t\t}\n\t}\n\n\tpublic async beforePackageInstall(options: SkillFeatureOptions) {\n\t\tconst { files } = await this.install(options)\n\t\treturn { files, cwd: this.resolveDestination(options) }\n\t}\n\n\tpublic async afterPackageInstall(options: SkillFeatureOptions) {\n\t\tconst destination = this.resolveDestination(options)\n\t\tawait this.Store('skill', { cwd: destination }).setCurrentSkillsNamespace(\n\t\t\toptions.name\n\t\t)\n\t\treturn {}\n\t}\n\n\tprivate async install(options: SkillFeatureOptions) {\n\t\tvalidateSchemaValues(skillFeatureSchema, options)\n\n\t\tconst destination = this.resolveDestination(options)\n\t\tif (!diskUtil.doesDirExist(destination)) {\n\t\t\tdiskUtil.createDir(destination)\n\t\t}\n\n\t\tconst skillGenerator = this.Writer('skill')\n\n\t\tconst files = await skillGenerator.writeSkill(destination, options)\n\n\t\tawait this.installScripts(destination)\n\n\t\tthis.setEngines(destination)\n\n\t\tconst env = this.Service('env', destination)\n\t\tenv.set('SKILL_NAME', options.name)\n\n\t\treturn { files }\n\t}\n\n\tprivate resolveDestination(options: SkillFeatureOptions) {\n\t\treturn diskUtil.resolvePath(this.cwd, options.destination ?? '')\n\t}\n\n\tpublic async installScripts(destination = this.cwd) {\n\t\tconst scriptUpdater = ScriptUpdater.FromFeature(this, {\n\t\t\tcwd: destination,\n\t\t})\n\n\t\tawait scriptUpdater.update()\n\t}\n\n\tpublic setEngines(destination: string) {\n\t\tconst pkg = this.Service('pkg', destination)\n\t\tconst engines = (pkg.get('engines') as Record<string, string>) || {}\n\n\t\tfor (const name in this.engines) {\n\t\t\tconst all = this.engines\n\t\t\tengines[name] = this.engines[name as keyof typeof all]\n\t\t}\n\n\t\tpkg.set({ path: 'engines', value: engines })\n\t}\n\n\tpublic async handleWillExecute(options: {\n\t\tfeatureCode: string\n\t\tactionCode: string\n\t\toptions?: UpgradeOptions\n\t}) {\n\t\tconst { featureCode, actionCode, options: upgradeOptions } = options\n\t\tconst isInstalled = await this.featureInstaller.isInstalled('skill')\n\n\t\tif (isInstalled && featureCode === 'node' && actionCode === 'upgrade') {\n\t\t\tconst updater = new Updater(this, this.emitter)\n\t\t\tconst files = await updater.updateFiles(upgradeOptions ?? {})\n\t\t\treturn {\n\t\t\t\tfiles,\n\t\t\t}\n\t\t}\n\n\t\treturn {}\n\t}\n}\n"],"file":"SkillFeature.js"}
@@ -289,7 +289,7 @@ var SkillStore = /*#__PURE__*/function (_AbstractStore) {
289
289
  key: "setCurrentSkillsNamespace",
290
290
  value: function () {
291
291
  var _setCurrentSkillsNamespace = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee5(namespace) {
292
- var isRegistered, pkg;
292
+ var isRegistered;
293
293
  return _regenerator["default"].wrap(function _callee5$(_context5) {
294
294
  while (1) {
295
295
  switch (_context5.prev = _context5.next) {
@@ -316,17 +316,13 @@ var SkillStore = /*#__PURE__*/function (_AbstractStore) {
316
316
 
317
317
  throw new _SpruceError["default"]({
318
318
  code: 'GENERIC',
319
- friendlyMessage: "You can't change the namespace of a skill that is registered."
319
+ friendlyMessage: "You can't set the namespace of a skill that is registered."
320
320
  });
321
321
 
322
322
  case 11:
323
- pkg = this.Service('pkg');
324
- pkg.set({
325
- path: 'skill.namespace',
326
- value: _spruceSkillUtils.namesUtil.toKebab(namespace)
327
- });
323
+ this.Service('auth').updateCurrentSkillNamespace(namespace);
328
324
 
329
- case 13:
325
+ case 12:
330
326
  case "end":
331
327
  return _context5.stop();
332
328
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/features/skill/stores/SkillStore.ts"],"names":["SkillStore","values","options","isRegisteringCurrentSkill","assertInSkill","name","slug","description","connectToApi","client","emit","payload","results","eventResponseUtil","getFirstResponseOrThrow","skill","setCurrentSkillsNamespace","Service","updateCurrentSkill","isInstalled","isMarkedAsInstalled","SpruceError","code","currentSkill","getCurrentSkill","shouldAuthAsCurrentSkill","target","skillId","id","response","namespacePascal","namesUtil","toPascal","isRegistered","apiKey","getNamespaceFromPkg","getEventNamespaceForNotRegistered","getSkillDescriptionFromPkg","loadCurrentSkill","pkg","nameFromPackage","get","Error","fallback","current","namespace","isCurrentSkillRegistered","friendlyMessage","set","path","value","toKebab","undefined","logoutCurrentSkill","fetchAllSkills","shouldOnlyShowMine","query","skills","AbstractStore"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;;;;;;;;;IAaqBA,U;;;;;;;;;;;;;;;6FACG,O;;;;;;;oGAOvB,iBACCC,MADD,EAECC,OAFD;AAAA;;AAAA;AAAA;AAAA;AAAA;AAIOC,gBAAAA,yBAJP,GAKE,CAAAD,OAAO,SAAP,IAAAA,OAAO,WAAP,YAAAA,OAAO,CAAEC,yBAAT,MAAuC,KALzC;AAOCA,gBAAAA,yBAAyB,IAAI,KAAKC,aAAL,EAA7B;AAEQC,gBAAAA,IATT,GASqCJ,MATrC,CASSI,IATT,EASeC,IATf,GASqCL,MATrC,CASeK,IATf,EASq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C,uBAAlB,CAA0Ce,QAA1C,CAZpB,EAYS4B,MAZT,0BAYSA,MAZT;AAAA,kDAcQA,MAdR;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,O;;;;;;;;;;WAzJA,6BAAkC;AACjC,WAAKlC,YAAL,GAAoB6B,SAApB;AACA;;;EANsCM,0B;;;iCAAnB1D,U","sourcesContent":["import { eventResponseUtil } from '@sprucelabs/spruce-event-utils'\nimport { namesUtil } from '@sprucelabs/spruce-skill-utils'\nimport SpruceError from '../../../errors/SpruceError'\nimport AbstractStore from '../../../stores/AbstractStore'\nimport { CurrentSkill, RegisteredSkill } from '../../../types/cli.types'\n\nexport interface CreateSkill {\n\tname: string\n\tslug: string\n\tdescription?: string\n}\n\nexport interface RegisterSkillOptions {\n\tisRegisteringCurrentSkill?: boolean\n}\n\nexport default class SkillStore extends AbstractStore {\n\tpublic readonly name = 'skill'\n\tprivate static currentSkill?: CurrentSkill\n\n\tpublic static clearCurrentSkill() {\n\t\tthis.currentSkill = undefined\n\t}\n\n\tpublic async register(\n\t\tvalues: CreateSkill,\n\t\toptions?: RegisterSkillOptions\n\t): Promise<RegisteredSkill> {\n\t\tconst isRegisteringCurrentSkill =\n\t\t\toptions?.isRegisteringCurrentSkill !== false\n\n\t\tisRegisteringCurrentSkill && this.assertInSkill()\n\n\t\tconst { name, slug, description } = values\n\t\tconst client = await this.connectToApi()\n\n\t\tconst results = await client.emit('register-skill::v2020_12_25', {\n\t\t\tpayload: {\n\t\t\t\tname,\n\t\t\t\tslug,\n\t\t\t\tdescription,\n\t\t\t},\n\t\t})\n\n\t\tconst { skill } = eventResponseUtil.getFirstResponseOrThrow(results)\n\n\t\tif (isRegisteringCurrentSkill) {\n\t\t\tawait this.setCurrentSkillsNamespace(skill.slug)\n\t\t\tthis.Service('auth').updateCurrentSkill(skill)\n\t\t}\n\n\t\treturn skill\n\t}\n\n\tprivate assertInSkill() {\n\t\tconst isInstalled = this.Service('settings').isMarkedAsInstalled('skill')\n\n\t\tif (!isInstalled) {\n\t\t\tthrow new SpruceError({ code: 'DIRECTORY_NOT_SKILL' })\n\t\t}\n\t}\n\n\tpublic async loadCurrentSkill(): Promise<CurrentSkill> {\n\t\tif (SkillStore.currentSkill) {\n\t\t\treturn SkillStore.currentSkill\n\t\t}\n\n\t\tthis.assertInSkill()\n\n\t\tconst currentSkill = this.Service('auth').getCurrentSkill()\n\n\t\tif (currentSkill) {\n\t\t\tconst client = await this.connectToApi({ shouldAuthAsCurrentSkill: true })\n\t\t\tconst response = await client.emit('get-skill::v2020_12_25', {\n\t\t\t\ttarget: {\n\t\t\t\t\tskillId: currentSkill.id,\n\t\t\t\t},\n\t\t\t})\n\n\t\t\tconst { skill } = eventResponseUtil.getFirstResponseOrThrow(response)\n\n\t\t\tSkillStore.currentSkill = {\n\t\t\t\t...skill,\n\t\t\t\tnamespacePascal: namesUtil.toPascal(skill.slug),\n\t\t\t\tisRegistered: true,\n\t\t\t\tapiKey: currentSkill.apiKey,\n\t\t\t}\n\t\t\treturn SkillStore.currentSkill as CurrentSkill\n\t\t}\n\n\t\treturn {\n\t\t\tname: this.getNamespaceFromPkg(),\n\t\t\tnamespacePascal: this.getEventNamespaceForNotRegistered(),\n\t\t\tdescription: this.getSkillDescriptionFromPkg(),\n\t\t\tisRegistered: false,\n\t\t}\n\t}\n\n\tpublic async isCurrentSkillRegistered() {\n\t\tconst skill = await this.loadCurrentSkill()\n\t\treturn skill.isRegistered\n\t}\n\n\tprivate getNamespaceFromPkg() {\n\t\tconst pkg = this.Service('pkg')\n\t\tconst nameFromPackage = pkg.get('skill.namespace')\n\t\tif (!nameFromPackage) {\n\t\t\tthrow new Error(\n\t\t\t\t'You need need to set skill.namespace in the package.json'\n\t\t\t)\n\t\t}\n\t\treturn nameFromPackage\n\t}\n\n\tpublic async loadCurrentSkillsNamespace() {\n\t\tconst fallback = namesUtil.toPascal(this.getNamespaceFromPkg())\n\n\t\tif (this.Service('auth').getCurrentSkill()) {\n\t\t\tconst current = await this.loadCurrentSkill()\n\t\t\treturn namesUtil.toPascal(current.slug ?? fallback)\n\t\t}\n\n\t\treturn fallback\n\t}\n\n\tpublic async setCurrentSkillsNamespace(namespace: string) {\n\t\tlet isRegistered = false\n\t\ttry {\n\t\t\tisRegistered = await this.isCurrentSkillRegistered()\n\t\t\t// eslint-disable-next-line no-empty\n\t\t} catch {}\n\n\t\tif (isRegistered) {\n\t\t\tthrow new SpruceError({\n\t\t\t\tcode: 'GENERIC',\n\t\t\t\tfriendlyMessage: `You can't change the namespace of a skill that is registered.`,\n\t\t\t})\n\t\t}\n\n\t\tconst pkg = this.Service('pkg')\n\t\tpkg.set({ path: 'skill.namespace', value: namesUtil.toKebab(namespace) })\n\t}\n\n\tprivate getEventNamespaceForNotRegistered() {\n\t\treturn namesUtil.toPascal(this.getNamespaceFromPkg())\n\t}\n\n\tprivate getSkillDescriptionFromPkg() {\n\t\tconst pkg = this.Service('pkg')\n\t\treturn pkg.get('description')\n\t}\n\n\tpublic async unregisterSkill(skillId: string) {\n\t\tconst client = await this.connectToApi()\n\n\t\tconst response = await client.emit('unregister-skill::v2020_12_25', {\n\t\t\ttarget: {\n\t\t\t\tskillId,\n\t\t\t},\n\t\t})\n\n\t\teventResponseUtil.getFirstResponseOrThrow(response)\n\n\t\tif (SkillStore.currentSkill?.id === skillId) {\n\t\t\tSkillStore.currentSkill = undefined\n\t\t\tthis.Service('auth').logoutCurrentSkill()\n\t\t}\n\t}\n\n\tpublic async fetchMySkills() {\n\t\treturn this.fetchAllSkills({ shouldOnlyShowMine: true })\n\t}\n\n\tpublic async fetchAllSkills(query?: {\n\t\tshouldOnlyShowMine?: boolean\n\t\tnamespaces?: string[]\n\t}) {\n\t\tconst client = await this.connectToApi()\n\n\t\tconst response = await client.emit('list-skills::v2020_12_25', {\n\t\t\tpayload: {\n\t\t\t\t...query,\n\t\t\t},\n\t\t})\n\n\t\tconst { skills } = eventResponseUtil.getFirstResponseOrThrow(response)\n\n\t\treturn skills\n\t}\n}\n"],"file":"SkillStore.js"}
1
+ {"version":3,"sources":["../../../../src/features/skill/stores/SkillStore.ts"],"names":["SkillStore","values","options","isRegisteringCurrentSkill","assertInSkill","name","slug","description","connectToApi","client","emit","payload","results","eventResponseUtil","getFirstResponseOrThrow","skill","setCurrentSkillsNamespace","Service","updateCurrentSkill","isInstalled","isMarkedAsInstalled","SpruceError","code","currentSkill","getCurrentSkill","shouldAuthAsCurrentSkill","target","skillId","id","response","namespacePascal","namesUtil","toPascal","isRegistered","apiKey","getNamespaceFromPkg","getEventNamespaceForNotRegistered","getSkillDescriptionFromPkg","loadCurrentSkill","pkg","nameFromPackage","get","Error","fallback","current","namespace","isCurrentSkillRegistered","friendlyMessage","updateCurrentSkillNamespace","undefined","logoutCurrentSkill","fetchAllSkills","shouldOnlyShowMine","query","skills","AbstractStore"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;;;;;;;;;IAaqBA,U;;;;;;;;;;;;;;;6FACG,O;;;;;;;oGAOvB,iBACCC,MADD,EAECC,OAFD;AAAA;;AAAA;AAAA;AAAA;AAAA;AAIOC,gBAAAA,yBAJP,GAKE,CAAAD,OAAO,SAAP,IAAAA,OAAO,WAAP,YAAAA,OAAO,CAAEC,yBAAT,MAAuC,KALzC;AAOCA,gBAAAA,yBAAyB,IAAI,KAAKC,aAAL,EAA7B;AAEQC,gBAAAA,IATT,GASqCJ,MATrC,CASSI,IATT,EASeC,IATf,GASqCL,MATrC,CASeK,IATf,EASqBC,WATrB,GASqCN,MATrC,CASqBM,WATrB;AAAA;AAAA,uBAUsB,KAAKC,YAAL,EAVtB;;AAAA;AAUOC,gBAAAA,MAVP;AAAA;AAAA,uBAYuBA,MAAM,CAACC,IAAP,CAAY,6BAAZ,EAA2C;AAChEC,kBAAAA,OAAO,EAAE;AACRN,oBAAAA,IAAI,EAAJA,IADQ;AAERC,oBAAAA,IAAI,EAAJA,IAFQ;AAGRC,oBAAAA,WAAW,EAAXA;A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;AAAA;AAGOE,gBAAAA,QAHP;;AASChB,oDAAkBC,uBAAlB,CAA0Ce,QAA1C;;AAEA,oBAAI,0BAAA7B,UAAU,CAACuB,YAAX,gFAAyBK,EAAzB,MAAgCD,OAApC,EAA6C;AAC5C3B,kBAAAA,UAAU,CAACuB,YAAX,GAA0B0B,SAA1B;AACA,uBAAKhC,OAAL,CAAa,MAAb,EAAqBiC,kBAArB;AACA;;AAdF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,O;;;;;;;;;;;yGAiBA;AAAA;AAAA;AAAA;AAAA;AAAA,kDACQ,KAAKC,cAAL,CAAoB;AAAEC,kBAAAA,kBAAkB,EAAE;AAAtB,iBAApB,CADR;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,O;;;;;;;;;;;0GAIA,kBAA4BC,KAA5B;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAIsB,KAAK7C,YAAL,EAJtB;;AAAA;AAIOC,gBAAAA,MAJP;AAAA;AAAA,uBAMwBA,MAAM,CAACC,IAAP,CAAY,0BAAZ,EAAwC;AAC9DC,kBAAAA,OAAO,oBACH0C,KADG;AADuD,iBAAxC,CANxB;;AAAA;AAMOxB,gBAAAA,QANP;AAAA,yCAYoBhB,oCAAkBC,uBAAlB,CAA0Ce,QAA1C,CAZpB,EAYSyB,MAZT,0BAYSA,MAZT;AAAA,kDAcQA,MAdR;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,O;;;;;;;;;;WA1JA,6BAAkC;AACjC,WAAK/B,YAAL,GAAoB0B,SAApB;AACA;;;EANsCM,0B;;;iCAAnBvD,U","sourcesContent":["import { eventResponseUtil } from '@sprucelabs/spruce-event-utils'\nimport { namesUtil } from '@sprucelabs/spruce-skill-utils'\nimport SpruceError from '../../../errors/SpruceError'\nimport AbstractStore from '../../../stores/AbstractStore'\nimport { CurrentSkill, RegisteredSkill } from '../../../types/cli.types'\n\nexport interface CreateSkill {\n\tname: string\n\tslug: string\n\tdescription?: string\n}\n\nexport interface RegisterSkillOptions {\n\tisRegisteringCurrentSkill?: boolean\n}\n\nexport default class SkillStore extends AbstractStore {\n\tpublic readonly name = 'skill'\n\tprivate static currentSkill?: CurrentSkill\n\n\tpublic static clearCurrentSkill() {\n\t\tthis.currentSkill = undefined\n\t}\n\n\tpublic async register(\n\t\tvalues: CreateSkill,\n\t\toptions?: RegisterSkillOptions\n\t): Promise<RegisteredSkill> {\n\t\tconst isRegisteringCurrentSkill =\n\t\t\toptions?.isRegisteringCurrentSkill !== false\n\n\t\tisRegisteringCurrentSkill && this.assertInSkill()\n\n\t\tconst { name, slug, description } = values\n\t\tconst client = await this.connectToApi()\n\n\t\tconst results = await client.emit('register-skill::v2020_12_25', {\n\t\t\tpayload: {\n\t\t\t\tname,\n\t\t\t\tslug,\n\t\t\t\tdescription,\n\t\t\t},\n\t\t})\n\n\t\tconst { skill } = eventResponseUtil.getFirstResponseOrThrow(results)\n\n\t\tif (isRegisteringCurrentSkill) {\n\t\t\tawait this.setCurrentSkillsNamespace(skill.slug)\n\t\t\tthis.Service('auth').updateCurrentSkill(skill)\n\t\t}\n\n\t\treturn skill\n\t}\n\n\tprivate assertInSkill() {\n\t\tconst isInstalled = this.Service('settings').isMarkedAsInstalled('skill')\n\n\t\tif (!isInstalled) {\n\t\t\tthrow new SpruceError({ code: 'DIRECTORY_NOT_SKILL' })\n\t\t}\n\t}\n\n\tpublic async loadCurrentSkill(): Promise<CurrentSkill> {\n\t\tif (SkillStore.currentSkill) {\n\t\t\treturn SkillStore.currentSkill\n\t\t}\n\n\t\tthis.assertInSkill()\n\n\t\tconst currentSkill = this.Service('auth').getCurrentSkill()\n\n\t\tif (currentSkill) {\n\t\t\tconst client = await this.connectToApi({ shouldAuthAsCurrentSkill: true })\n\n\t\t\tconst response = await client.emit('get-skill::v2020_12_25', {\n\t\t\t\ttarget: {\n\t\t\t\t\tskillId: currentSkill.id,\n\t\t\t\t},\n\t\t\t})\n\n\t\t\tconst { skill } = eventResponseUtil.getFirstResponseOrThrow(response)\n\n\t\t\tSkillStore.currentSkill = {\n\t\t\t\t...skill,\n\t\t\t\tnamespacePascal: namesUtil.toPascal(skill.slug),\n\t\t\t\tisRegistered: true,\n\t\t\t\tapiKey: currentSkill.apiKey,\n\t\t\t}\n\n\t\t\treturn SkillStore.currentSkill as CurrentSkill\n\t\t}\n\n\t\treturn {\n\t\t\tname: this.getNamespaceFromPkg(),\n\t\t\tnamespacePascal: this.getEventNamespaceForNotRegistered(),\n\t\t\tdescription: this.getSkillDescriptionFromPkg(),\n\t\t\tisRegistered: false,\n\t\t}\n\t}\n\n\tpublic async isCurrentSkillRegistered() {\n\t\tconst skill = await this.loadCurrentSkill()\n\t\treturn skill.isRegistered\n\t}\n\n\tprivate getNamespaceFromPkg() {\n\t\tconst pkg = this.Service('pkg')\n\t\tconst nameFromPackage = pkg.get('skill.namespace')\n\t\tif (!nameFromPackage) {\n\t\t\tthrow new Error(\n\t\t\t\t'You need need to set skill.namespace in the package.json'\n\t\t\t)\n\t\t}\n\t\treturn nameFromPackage\n\t}\n\n\tpublic async loadCurrentSkillsNamespace() {\n\t\tconst fallback = namesUtil.toPascal(this.getNamespaceFromPkg())\n\n\t\tif (this.Service('auth').getCurrentSkill()) {\n\t\t\tconst current = await this.loadCurrentSkill()\n\t\t\treturn namesUtil.toPascal(current.slug ?? fallback)\n\t\t}\n\n\t\treturn fallback\n\t}\n\n\tpublic async setCurrentSkillsNamespace(namespace: string) {\n\t\tlet isRegistered = false\n\t\ttry {\n\t\t\tisRegistered = await this.isCurrentSkillRegistered()\n\t\t\t// eslint-disable-next-line no-empty\n\t\t} catch {}\n\n\t\tif (isRegistered) {\n\t\t\tthrow new SpruceError({\n\t\t\t\tcode: 'GENERIC',\n\t\t\t\tfriendlyMessage: `You can't set the namespace of a skill that is registered.`,\n\t\t\t})\n\t\t}\n\n\t\tthis.Service('auth').updateCurrentSkillNamespace(namespace)\n\t}\n\n\tprivate getEventNamespaceForNotRegistered() {\n\t\treturn namesUtil.toPascal(this.getNamespaceFromPkg())\n\t}\n\n\tprivate getSkillDescriptionFromPkg() {\n\t\tconst pkg = this.Service('pkg')\n\t\treturn pkg.get('description')\n\t}\n\n\tpublic async unregisterSkill(skillId: string) {\n\t\tconst client = await this.connectToApi()\n\n\t\tconst response = await client.emit('unregister-skill::v2020_12_25', {\n\t\t\ttarget: {\n\t\t\t\tskillId,\n\t\t\t},\n\t\t})\n\n\t\teventResponseUtil.getFirstResponseOrThrow(response)\n\n\t\tif (SkillStore.currentSkill?.id === skillId) {\n\t\t\tSkillStore.currentSkill = undefined\n\t\t\tthis.Service('auth').logoutCurrentSkill()\n\t\t}\n\t}\n\n\tpublic async fetchMySkills() {\n\t\treturn this.fetchAllSkills({ shouldOnlyShowMine: true })\n\t}\n\n\tpublic async fetchAllSkills(query?: {\n\t\tshouldOnlyShowMine?: boolean\n\t\tnamespaces?: string[]\n\t}) {\n\t\tconst client = await this.connectToApi()\n\n\t\tconst response = await client.emit('list-skills::v2020_12_25', {\n\t\t\tpayload: {\n\t\t\t\t...query,\n\t\t\t},\n\t\t})\n\n\t\tconst { skills } = eventResponseUtil.getFirstResponseOrThrow(response)\n\n\t\treturn skills\n\t}\n}\n"],"file":"SkillStore.js"}
@@ -17,7 +17,7 @@ export default class StoreFeature extends AbstractFeature {
17
17
  actionsDir: string;
18
18
  constructor(options: FeatureOptions);
19
19
  private registerAbstractTestClassHandler;
20
- private didExecuterHandler;
20
+ private handleWillExecute;
21
21
  afterPackageInstall(): Promise<{
22
22
  files: import("../../writers/AbstractWriter").WriteResults;
23
23
  }>;
@@ -61,7 +61,7 @@ var StoreFeature = /*#__PURE__*/function (_AbstractFeature) {
61
61
  }]);
62
62
  (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "actionsDir", _spruceSkillUtils.diskUtil.resolvePath(__dirname, 'actions'));
63
63
  void _this.emitter.on('test.register-abstract-test-classes', _this.registerAbstractTestClassHandler.bind((0, _assertThisInitialized2["default"])(_this)));
64
- void _this.emitter.on('feature.did-execute', _this.didExecuterHandler.bind((0, _assertThisInitialized2["default"])(_this)));
64
+ void _this.emitter.on('feature.will-execute', _this.handleWillExecute.bind((0, _assertThisInitialized2["default"])(_this)));
65
65
  return _this;
66
66
  }
67
67
 
@@ -97,10 +97,10 @@ var StoreFeature = /*#__PURE__*/function (_AbstractFeature) {
97
97
  return registerAbstractTestClassHandler;
98
98
  }()
99
99
  }, {
100
- key: "didExecuterHandler",
100
+ key: "handleWillExecute",
101
101
  value: function () {
102
- var _didExecuterHandler = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2(payload) {
103
- var isInstalled;
102
+ var _handleWillExecute = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2(payload) {
103
+ var isInstalled, results;
104
104
  return _regenerator["default"].wrap(function _callee2$(_context2) {
105
105
  while (1) {
106
106
  switch (_context2.prev = _context2.next) {
@@ -112,7 +112,7 @@ var StoreFeature = /*#__PURE__*/function (_AbstractFeature) {
112
112
  isInstalled = _context2.sent;
113
113
 
114
114
  if (!(isInstalled && payload.featureCode === 'node' && payload.actionCode === 'upgrade')) {
115
- _context2.next = 6;
115
+ _context2.next = 9;
116
116
  break;
117
117
  }
118
118
 
@@ -121,12 +121,17 @@ var StoreFeature = /*#__PURE__*/function (_AbstractFeature) {
121
121
  headline: 'Resyncing data stores...'
122
122
  });
123
123
 
124
- return _context2.abrupt("return", this.Action('store', 'sync').execute({}));
124
+ _context2.next = 7;
125
+ return this.Action('store', 'sync').execute({});
125
126
 
126
- case 6:
127
+ case 7:
128
+ results = _context2.sent;
129
+ return _context2.abrupt("return", results);
130
+
131
+ case 9:
127
132
  return _context2.abrupt("return", {});
128
133
 
129
- case 7:
134
+ case 10:
130
135
  case "end":
131
136
  return _context2.stop();
132
137
  }
@@ -134,11 +139,11 @@ var StoreFeature = /*#__PURE__*/function (_AbstractFeature) {
134
139
  }, _callee2, this);
135
140
  }));
136
141
 
137
- function didExecuterHandler(_x) {
138
- return _didExecuterHandler.apply(this, arguments);
142
+ function handleWillExecute(_x) {
143
+ return _handleWillExecute.apply(this, arguments);
139
144
  }
140
145
 
141
- return didExecuterHandler;
146
+ return handleWillExecute;
142
147
  }()
143
148
  }, {
144
149
  key: "afterPackageInstall",
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/features/store/StoreFeature.ts"],"names":["StoreFeature","options","code","isRequired","name","isDev","diskUtil","resolvePath","__dirname","emitter","on","registerAbstractTestClassHandler","bind","didExecuterHandler","abstractClasses","label","featureCode","payload","featureInstaller","isInstalled","actionCode","uiUtil","renderMasthead","ui","headline","Action","execute","Writer","writePlugin","cwd","files","AbstractFeature"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;;;;;IAYqBA,Y;;;;;AAiBpB,wBAAmBC,OAAnB,EAA4C;AAAA;;AAAA;AAC3C,8BAAMA,OAAN;AAD2C,qGAhBtB,aAgBsB;AAAA,oGAfvB,4CAeuB;AAAA,6FAdjB,OAciB;AAAA,qGAbD,CAC1C;AACCC,MAAAA,IAAI,EAAE,OADP;AAECC,MAAAA,UAAU,EAAE;AAFb,KAD0C,CAaC;AAAA,4GAPf,CAC5B;AAAEC,MAAAA,IAAI,EAAE,wCAAR;AAAkDC,MAAAA,KAAK,EAAE;AAAzD,KAD4B,EAE5B;AAAED,MAAAA,IAAI,EAAE,gCAAR;AAA0CC,MAAAA,KAAK,EAAE;AAAjD,KAF4B,CAOe;AAAA,mGAFxBC,2BAASC,WAAT,CAAqBC,SAArB,EAAgC,SAAhC,CAEwB;AAG3C,SAAK,MAAKC,OAAL,CAAaC,EAAb,CACJ,qCADI,EAEJ,MAAKC,gCAAL,CAAsCC,IAAtC,gDAFI,CAAL;AAIA,SAAK,MAAKH,OAAL,CAAaC,EAAb,CACJ,qBADI,EAEJ,MAAKG,kBAAL,CAAwBD,IAAxB,gDAFI,CAAL;AAP2C;AAW3C;;;;;4HAED;AAAA;AAAA;AAAA;AAAA;AAAA,iDACQ;AACNE,kBAAAA,eAAe,EAAE,CAChB;AACCV,oBAAAA,IAAI,EAAE,mBADP;AAECW,oBAAAA,KAAK,EAAE,mBAFR;AAGC,8BAAQ,iCAHT;AAICC,oBAAAA,WAAW,EAAE;AAJd,mBADgB;AADX,iBADR;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,O;;;;;;;;;;;8GAaA,kBAAiCC,OAAjC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAI2B,KAAKC,gBAAL,CAAsBC,WAAtB,CAAkC,OAAlC,CAJ3B;;AAAA;AAIOA,gBAAAA,WAJP;;AAAA,sBAOEA,WAAW,IACXF,OAAO,CAACD,WAAR,KAAwB,MADxB,IAEAC,OAAO,CAACG,UAAR,KAAuB,SATzB;AAAA;AAAA;AAAA;;AAWEC,+BAAOC,cAAP,CAAsB;AACrBC,kBAAAA,EAAE,EAAE,KAAKA,EADY;AAErBC,kBAAAA,QAAQ,EAAE;AAFW,iBAAtB;;AAXF,kDAeS,KAAKC,MAAL,CAAY,OAAZ,EAAqB,MAArB,EAA6BC,OAA7B,CAAqC,EAArC,CAfT;;AAAA;AAAA,kDAkBQ,EAlBR;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,O;;;;;;;;;;;+GAqBA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBACqB,KAAKC,MAAL,CAAY,OAAZ,EAAqBC,WAArB,CAAiC,KAAKC,GAAtC,CADrB;;AAAA;AACOC,gBAAAA,KADP;AAAA,kDAEQ;AACNA,kBAAAA,KAAK,EAALA;AADM,iBAFR;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,O;;;;;;;;;;EAhEyCC,4B","sourcesContent":["import { diskUtil } from '@sprucelabs/spruce-skill-utils'\nimport uiUtil from '../../utilities/ui.utility'\nimport AbstractFeature, {\n\tFeatureDependency,\n\tFeatureOptions,\n} from '../AbstractFeature'\nimport { FeatureCode } from '../features.types'\n\ndeclare module '../../features/features.types' {\n\tinterface FeatureMap {\n\t\tstore: StoreFeature\n\t}\n}\n\nexport default class StoreFeature extends AbstractFeature {\n\tpublic nameReadable = 'Data Stores'\n\tpublic description = 'For working with remote places of storage.'\n\tpublic code: FeatureCode = 'store'\n\tpublic dependencies: FeatureDependency[] = [\n\t\t{\n\t\t\tcode: 'skill',\n\t\t\tisRequired: true,\n\t\t},\n\t]\n\tpublic packageDependencies = [\n\t\t{ name: '@sprucelabs/spruce-store-plugin@latest', isDev: false },\n\t\t{ name: '@sprucelabs/data-stores@latest', isDev: false },\n\t]\n\n\tpublic actionsDir = diskUtil.resolvePath(__dirname, 'actions')\n\n\tpublic constructor(options: FeatureOptions) {\n\t\tsuper(options)\n\n\t\tvoid this.emitter.on(\n\t\t\t'test.register-abstract-test-classes',\n\t\t\tthis.registerAbstractTestClassHandler.bind(this)\n\t\t)\n\t\tvoid this.emitter.on(\n\t\t\t'feature.did-execute',\n\t\t\tthis.didExecuterHandler.bind(this)\n\t\t)\n\t}\n\n\tprivate async registerAbstractTestClassHandler() {\n\t\treturn {\n\t\t\tabstractClasses: [\n\t\t\t\t{\n\t\t\t\t\tname: 'AbstractStoreTest',\n\t\t\t\t\tlabel: 'AbstractStoreTest',\n\t\t\t\t\timport: '@sprucelabs/spruce-store-plugin',\n\t\t\t\t\tfeatureCode: 'store',\n\t\t\t\t},\n\t\t\t],\n\t\t}\n\t}\n\n\tprivate async didExecuterHandler(payload: {\n\t\tfeatureCode: string\n\t\tactionCode: string\n\t}) {\n\t\tconst isInstalled = await this.featureInstaller.isInstalled('store')\n\n\t\tif (\n\t\t\tisInstalled &&\n\t\t\tpayload.featureCode === 'node' &&\n\t\t\tpayload.actionCode === 'upgrade'\n\t\t) {\n\t\t\tuiUtil.renderMasthead({\n\t\t\t\tui: this.ui,\n\t\t\t\theadline: 'Resyncing data stores...',\n\t\t\t})\n\t\t\treturn this.Action('store', 'sync').execute({})\n\t\t}\n\n\t\treturn {}\n\t}\n\n\tpublic async afterPackageInstall() {\n\t\tconst files = await this.Writer('store').writePlugin(this.cwd)\n\t\treturn {\n\t\t\tfiles,\n\t\t}\n\t}\n}\n"],"file":"StoreFeature.js"}
1
+ {"version":3,"sources":["../../../src/features/store/StoreFeature.ts"],"names":["StoreFeature","options","code","isRequired","name","isDev","diskUtil","resolvePath","__dirname","emitter","on","registerAbstractTestClassHandler","bind","handleWillExecute","abstractClasses","label","featureCode","payload","featureInstaller","isInstalled","actionCode","uiUtil","renderMasthead","ui","headline","Action","execute","results","Writer","writePlugin","cwd","files","AbstractFeature"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;;;;;IAYqBA,Y;;;;;AAiBpB,wBAAmBC,OAAnB,EAA4C;AAAA;;AAAA;AAC3C,8BAAMA,OAAN;AAD2C,qGAhBtB,aAgBsB;AAAA,oGAfvB,4CAeuB;AAAA,6FAdjB,OAciB;AAAA,qGAbD,CAC1C;AACCC,MAAAA,IAAI,EAAE,OADP;AAECC,MAAAA,UAAU,EAAE;AAFb,KAD0C,CAaC;AAAA,4GAPf,CAC5B;AAAEC,MAAAA,IAAI,EAAE,wCAAR;AAAkDC,MAAAA,KAAK,EAAE;AAAzD,KAD4B,EAE5B;AAAED,MAAAA,IAAI,EAAE,gCAAR;AAA0CC,MAAAA,KAAK,EAAE;AAAjD,KAF4B,CAOe;AAAA,mGAFxBC,2BAASC,WAAT,CAAqBC,SAArB,EAAgC,SAAhC,CAEwB;AAG3C,SAAK,MAAKC,OAAL,CAAaC,EAAb,CACJ,qCADI,EAEJ,MAAKC,gCAAL,CAAsCC,IAAtC,gDAFI,CAAL;AAIA,SAAK,MAAKH,OAAL,CAAaC,EAAb,CACJ,sBADI,EAEJ,MAAKG,iBAAL,CAAuBD,IAAvB,gDAFI,CAAL;AAP2C;AAW3C;;;;;4HAED;AAAA;AAAA;AAAA;AAAA;AAAA,iDACQ;AACNE,kBAAAA,eAAe,EAAE,CAChB;AACCV,oBAAAA,IAAI,EAAE,mBADP;AAECW,oBAAAA,KAAK,EAAE,mBAFR;AAGC,8BAAQ,iCAHT;AAICC,oBAAAA,WAAW,EAAE;AAJd,mBADgB;AADX,iBADR;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,O;;;;;;;;;;;6GAaA,kBAAgCC,OAAhC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAI2B,KAAKC,gBAAL,CAAsBC,WAAtB,CAAkC,OAAlC,CAJ3B;;AAAA;AAIOA,gBAAAA,WAJP;;AAAA,sBAOEA,WAAW,IACXF,OAAO,CAACD,WAAR,KAAwB,MADxB,IAEAC,OAAO,CAACG,UAAR,KAAuB,SATzB;AAAA;AAAA;AAAA;;AAWEC,+BAAOC,cAAP,CAAsB;AACrBC,kBAAAA,EAAE,EAAE,KAAKA,EADY;AAErBC,kBAAAA,QAAQ,EAAE;AAFW,iBAAtB;;AAXF;AAAA,uBAgBwB,KAAKC,MAAL,CAAY,OAAZ,EAAqB,MAArB,EAA6BC,OAA7B,CAAqC,EAArC,CAhBxB;;AAAA;AAgBQC,gBAAAA,OAhBR;AAAA,kDAkBSA,OAlBT;;AAAA;AAAA,kDAqBQ,EArBR;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,O;;;;;;;;;;;+GAwBA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBACqB,KAAKC,MAAL,CAAY,OAAZ,EAAqBC,WAArB,CAAiC,KAAKC,GAAtC,CADrB;;AAAA;AACOC,gBAAAA,KADP;AAAA,kDAEQ;AACNA,kBAAAA,KAAK,EAALA;AADM,iBAFR;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,O;;;;;;;;;;EAnEyCC,4B","sourcesContent":["import { diskUtil } from '@sprucelabs/spruce-skill-utils'\nimport uiUtil from '../../utilities/ui.utility'\nimport AbstractFeature, {\n\tFeatureDependency,\n\tFeatureOptions,\n} from '../AbstractFeature'\nimport { FeatureCode } from '../features.types'\n\ndeclare module '../../features/features.types' {\n\tinterface FeatureMap {\n\t\tstore: StoreFeature\n\t}\n}\n\nexport default class StoreFeature extends AbstractFeature {\n\tpublic nameReadable = 'Data Stores'\n\tpublic description = 'For working with remote places of storage.'\n\tpublic code: FeatureCode = 'store'\n\tpublic dependencies: FeatureDependency[] = [\n\t\t{\n\t\t\tcode: 'skill',\n\t\t\tisRequired: true,\n\t\t},\n\t]\n\tpublic packageDependencies = [\n\t\t{ name: '@sprucelabs/spruce-store-plugin@latest', isDev: false },\n\t\t{ name: '@sprucelabs/data-stores@latest', isDev: false },\n\t]\n\n\tpublic actionsDir = diskUtil.resolvePath(__dirname, 'actions')\n\n\tpublic constructor(options: FeatureOptions) {\n\t\tsuper(options)\n\n\t\tvoid this.emitter.on(\n\t\t\t'test.register-abstract-test-classes',\n\t\t\tthis.registerAbstractTestClassHandler.bind(this)\n\t\t)\n\t\tvoid this.emitter.on(\n\t\t\t'feature.will-execute',\n\t\t\tthis.handleWillExecute.bind(this)\n\t\t)\n\t}\n\n\tprivate async registerAbstractTestClassHandler() {\n\t\treturn {\n\t\t\tabstractClasses: [\n\t\t\t\t{\n\t\t\t\t\tname: 'AbstractStoreTest',\n\t\t\t\t\tlabel: 'AbstractStoreTest',\n\t\t\t\t\timport: '@sprucelabs/spruce-store-plugin',\n\t\t\t\t\tfeatureCode: 'store',\n\t\t\t\t},\n\t\t\t],\n\t\t}\n\t}\n\n\tprivate async handleWillExecute(payload: {\n\t\tfeatureCode: string\n\t\tactionCode: string\n\t}) {\n\t\tconst isInstalled = await this.featureInstaller.isInstalled('store')\n\n\t\tif (\n\t\t\tisInstalled &&\n\t\t\tpayload.featureCode === 'node' &&\n\t\t\tpayload.actionCode === 'upgrade'\n\t\t) {\n\t\t\tuiUtil.renderMasthead({\n\t\t\t\tui: this.ui,\n\t\t\t\theadline: 'Resyncing data stores...',\n\t\t\t})\n\n\t\t\tconst results = await this.Action('store', 'sync').execute({})\n\n\t\t\treturn results\n\t\t}\n\n\t\treturn {}\n\t}\n\n\tpublic async afterPackageInstall() {\n\t\tconst files = await this.Writer('store').writePlugin(this.cwd)\n\t\treturn {\n\t\t\tfiles,\n\t\t}\n\t}\n}\n"],"file":"StoreFeature.js"}
@@ -1,5 +1,6 @@
1
1
  import { SpruceSchemas } from '@sprucelabs/mercury-types';
2
2
  import { EnvService } from '@sprucelabs/spruce-skill-utils';
3
+ import PkgService from './PkgService';
3
4
  declare type PersonWithToken = SpruceSchemas.SpruceCli.v2020_07_22.PersonWithToken;
4
5
  export interface SkillAuth {
5
6
  id: string;
@@ -9,12 +10,14 @@ export interface SkillAuth {
9
10
  }
10
11
  export default class AuthService {
11
12
  private env;
12
- constructor(envService: EnvService);
13
+ private pkg;
14
+ constructor(envService: EnvService, pkgService: PkgService);
13
15
  getLoggedInPerson(): PersonWithToken | null;
14
16
  setLoggedInPerson(person: PersonWithToken): void;
15
17
  logOutPerson(): void;
16
18
  getCurrentSkill(): SkillAuth | null;
17
19
  logoutCurrentSkill(): void;
18
20
  updateCurrentSkill(skill: SkillAuth): void;
21
+ updateCurrentSkillNamespace(namespace: string): void;
19
22
  }
20
23
  export {};
@@ -15,6 +15,8 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
15
15
 
16
16
  var _schema = require("@sprucelabs/schema");
17
17
 
18
+ var _spruceSkillUtils = require("@sprucelabs/spruce-skill-utils");
19
+
18
20
  var _personWithToken = _interopRequireDefault(require("../.spruce/schemas/spruceCli/v2020_07_22/personWithToken.schema"));
19
21
 
20
22
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
@@ -24,10 +26,12 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
24
26
  var LOGGED_IN_PERSON_KEY = 'LOGGED_IN_PERSON';
25
27
 
26
28
  var AuthService = /*#__PURE__*/function () {
27
- function AuthService(envService) {
29
+ function AuthService(envService, pkgService) {
28
30
  (0, _classCallCheck2["default"])(this, AuthService);
29
31
  (0, _defineProperty2["default"])(this, "env", void 0);
32
+ (0, _defineProperty2["default"])(this, "pkg", void 0);
30
33
  this.env = envService;
34
+ this.pkg = pkgService;
31
35
  }
32
36
 
33
37
  (0, _createClass2["default"])(AuthService, [{
@@ -61,7 +65,7 @@ var AuthService = /*#__PURE__*/function () {
61
65
  var id = this.env.get('SKILL_ID');
62
66
  var apiKey = this.env.get('SKILL_API_KEY');
63
67
  var name = this.env.get('SKILL_NAME');
64
- var slug = this.env.get('SKILL_SLUG');
68
+ var slug = this.pkg.get('skill.namespace');
65
69
 
66
70
  if (id && apiKey) {
67
71
  return {
@@ -80,7 +84,6 @@ var AuthService = /*#__PURE__*/function () {
80
84
  this.env.unset('SKILL_ID');
81
85
  this.env.unset('SKILL_API_KEY');
82
86
  this.env.unset('SKILL_NAME');
83
- this.env.unset('SKILL_SLUG');
84
87
  }
85
88
  }, {
86
89
  key: "updateCurrentSkill",
@@ -88,7 +91,15 @@ var AuthService = /*#__PURE__*/function () {
88
91
  this.env.set('SKILL_ID', skill.id);
89
92
  this.env.set('SKILL_API_KEY', skill.apiKey);
90
93
  this.env.set('SKILL_NAME', skill.name);
91
- this.env.set('SKILL_SLUG', skill.slug);
94
+ this.updateCurrentSkillNamespace(skill.slug);
95
+ }
96
+ }, {
97
+ key: "updateCurrentSkillNamespace",
98
+ value: function updateCurrentSkillNamespace(namespace) {
99
+ this.pkg.set({
100
+ path: 'skill.namespace',
101
+ value: _spruceSkillUtils.namesUtil.toKebab(namespace)
102
+ });
92
103
  }
93
104
  }]);
94
105
  return AuthService;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/services/AuthService.ts"],"names":["LOGGED_IN_PERSON_KEY","AuthService","envService","env","p","get","JSON","parse","person","normalized","personWithTokenSchema","set","stringify","isLoggedIn","unset","id","apiKey","name","slug","skill"],"mappings":";;;;;;;;;;;;;;;AACA;;AAEA;;;;;;AAWA,IAAMA,oBAAoB,GAAG,kBAA7B;;IAEqBC,W;AAGpB,uBAAmBC,UAAnB,EAA2C;AAAA;AAAA;AAC1C,SAAKC,GAAL,GAAWD,UAAX;AACA;;;;WAED,6BAAmD;AAClD,UAAME,CAAC,GAAG,KAAKD,GAAL,CAASE,GAAT,CAAaL,oBAAb,CAAV;;AACA,UAAI,OAAOI,CAAP,KAAa,QAAjB,EAA2B;AAC1B,eAAOE,IAAI,CAACC,KAAL,CAAWH,CAAX,CAAP;AACA;;AAED,aAAO,IAAP;AACA;;;WAED,2BAAyBI,MAAzB,EAAkD;AACjD,UAAMC,UAAU,GAAG,mCAAsBC,2BAAtB,EAA6CF,MAA7C,CAAnB;AACA,wCAAqBE,2BAArB,EAA4CD,UAA5C;AAEA,WAAKN,GAAL,CAASQ,GAAT,CACCX,oBADD,EAECM,IAAI,CAACM,SAAL,iCACIH,UADJ;AAECI,QAAAA,UAAU,EAAE;AAFb,SAFD;AAOA;;;WAED,wBAAsB;AACrB,WAAKV,GAAL,CAASW,KAAT,CAAed,oBAAf;AACA;;;WAED,2BAA2C;AAC1C,UAAMe,EAAE,GAAG,KAAKZ,GAAL,CAASE,GAAT,CAAa,UAAb,CAAX;AACA,UAAMW,MAAM,GAAG,KAAKb,GAAL,CAASE,GAAT,CAAa,eAAb,CAAf;AACA,UAAMY,IAAI,GAAG,KAAKd,GAAL,CAASE,GAAT,CAAa,YAAb,CAAb;AACA,UAAMa,IAAI,GAAG,KAAKf,GAAL,CAASE,GAAT,CAAa,YAAb,CAAb;;AAEA,UAAIU,EAAE,IAAIC,MAAV,EAAkB;AACjB,eAAO;AACND,UAAAA,EAAE,EAAFA,EADM;AAENC,UAAAA,MAAM,EAANA,MAFM;AAGNC,UAAAA,IAAI,EAAJA,IAHM;AAINC,UAAAA,IAAI,EAAJA;AAJM,SAAP;AAMA;;AAED,aAAO,IAAP;AACA;;;WAED,8BAA4B;AAC3B,WAAKf,GAAL,CAASW,KAAT,CAAe,UAAf;AACA,WAAKX,GAAL,CAASW,KAAT,CAAe,eAAf;AACA,WAAKX,GAAL,CAASW,KAAT,CAAe,YAAf;AACA,WAAKX,GAAL,CAASW,KAAT,CAAe,YAAf;AACA;;;WAED,4BAA0BK,KAA1B,EAA4C;AAC3C,WAAKhB,GAAL,CAASQ,GAAT,CAAa,UAAb,EAAyBQ,KAAK,CAACJ,EAA/B;AACA,WAAKZ,GAAL,CAASQ,GAAT,CAAa,eAAb,EAA8BQ,KAAK,CAACH,MAApC;AACA,WAAKb,GAAL,CAASQ,GAAT,CAAa,YAAb,EAA2BQ,KAAK,CAACF,IAAjC;AACA,WAAKd,GAAL,CAASQ,GAAT,CAAa,YAAb,EAA2BQ,KAAK,CAACD,IAAjC;AACA","sourcesContent":["import { SpruceSchemas } from '@sprucelabs/mercury-types'\nimport { normalizeSchemaValues, validateSchemaValues } from '@sprucelabs/schema'\nimport { EnvService } from '@sprucelabs/spruce-skill-utils'\nimport personWithTokenSchema from '#spruce/schemas/spruceCli/v2020_07_22/personWithToken.schema'\n\ntype PersonWithToken = SpruceSchemas.SpruceCli.v2020_07_22.PersonWithToken\n\nexport interface SkillAuth {\n\tid: string\n\tapiKey: string\n\tname: string\n\tslug: string\n}\n\nconst LOGGED_IN_PERSON_KEY = 'LOGGED_IN_PERSON'\n\nexport default class AuthService {\n\tprivate env: EnvService\n\n\tpublic constructor(envService: EnvService) {\n\t\tthis.env = envService\n\t}\n\n\tpublic getLoggedInPerson(): PersonWithToken | null {\n\t\tconst p = this.env.get(LOGGED_IN_PERSON_KEY)\n\t\tif (typeof p === 'string') {\n\t\t\treturn JSON.parse(p)\n\t\t}\n\n\t\treturn null\n\t}\n\n\tpublic setLoggedInPerson(person: PersonWithToken) {\n\t\tconst normalized = normalizeSchemaValues(personWithTokenSchema, person)\n\t\tvalidateSchemaValues(personWithTokenSchema, normalized)\n\n\t\tthis.env.set(\n\t\t\tLOGGED_IN_PERSON_KEY,\n\t\t\tJSON.stringify({\n\t\t\t\t...normalized,\n\t\t\t\tisLoggedIn: true,\n\t\t\t})\n\t\t)\n\t}\n\n\tpublic logOutPerson() {\n\t\tthis.env.unset(LOGGED_IN_PERSON_KEY)\n\t}\n\n\tpublic getCurrentSkill(): SkillAuth | null {\n\t\tconst id = this.env.get('SKILL_ID') as string\n\t\tconst apiKey = this.env.get('SKILL_API_KEY') as string\n\t\tconst name = this.env.get('SKILL_NAME') as string\n\t\tconst slug = this.env.get('SKILL_SLUG') as string\n\n\t\tif (id && apiKey) {\n\t\t\treturn {\n\t\t\t\tid,\n\t\t\t\tapiKey,\n\t\t\t\tname,\n\t\t\t\tslug,\n\t\t\t}\n\t\t}\n\n\t\treturn null\n\t}\n\n\tpublic logoutCurrentSkill() {\n\t\tthis.env.unset('SKILL_ID')\n\t\tthis.env.unset('SKILL_API_KEY')\n\t\tthis.env.unset('SKILL_NAME')\n\t\tthis.env.unset('SKILL_SLUG')\n\t}\n\n\tpublic updateCurrentSkill(skill: SkillAuth) {\n\t\tthis.env.set('SKILL_ID', skill.id)\n\t\tthis.env.set('SKILL_API_KEY', skill.apiKey)\n\t\tthis.env.set('SKILL_NAME', skill.name)\n\t\tthis.env.set('SKILL_SLUG', skill.slug)\n\t}\n}\n"],"file":"AuthService.js"}
1
+ {"version":3,"sources":["../../src/services/AuthService.ts"],"names":["LOGGED_IN_PERSON_KEY","AuthService","envService","pkgService","env","pkg","p","get","JSON","parse","person","normalized","personWithTokenSchema","set","stringify","isLoggedIn","unset","id","apiKey","name","slug","skill","updateCurrentSkillNamespace","namespace","path","value","namesUtil","toKebab"],"mappings":";;;;;;;;;;;;;;;AACA;;AACA;;AACA;;;;;;AAYA,IAAMA,oBAAoB,GAAG,kBAA7B;;IAEqBC,W;AAIpB,uBAAmBC,UAAnB,EAA2CC,UAA3C,EAAmE;AAAA;AAAA;AAA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,GAAL,CAASY,KAAT,CAAe,YAAf;AACA;;;WAED,4BAA0BK,KAA1B,EAA4C;AAC3C,WAAKjB,GAAL,CAASS,GAAT,CAAa,UAAb,EAAyBQ,KAAK,CAACJ,EAA/B;AACA,WAAKb,GAAL,CAASS,GAAT,CAAa,eAAb,EAA8BQ,KAAK,CAACH,MAApC;AACA,WAAKd,GAAL,CAASS,GAAT,CAAa,YAAb,EAA2BQ,KAAK,CAACF,IAAjC;AAEA,WAAKG,2BAAL,CAAiCD,KAAK,CAACD,IAAvC;AACA;;;WAED,qCAAmCG,SAAnC,EAAsD;AACrD,WAAKlB,GAAL,CAASQ,GAAT,CAAa;AACZW,QAAAA,IAAI,EAAE,iBADM;AAEZC,QAAAA,KAAK,EAAEC,4BAAUC,OAAV,CAAkBJ,SAAlB;AAFK,OAAb;AAIA","sourcesContent":["import { SpruceSchemas } from '@sprucelabs/mercury-types'\nimport { normalizeSchemaValues, validateSchemaValues } from '@sprucelabs/schema'\nimport { EnvService, namesUtil } from '@sprucelabs/spruce-skill-utils'\nimport personWithTokenSchema from '#spruce/schemas/spruceCli/v2020_07_22/personWithToken.schema'\nimport PkgService from './PkgService'\n\ntype PersonWithToken = SpruceSchemas.SpruceCli.v2020_07_22.PersonWithToken\n\nexport interface SkillAuth {\n\tid: string\n\tapiKey: string\n\tname: string\n\tslug: string\n}\n\nconst LOGGED_IN_PERSON_KEY = 'LOGGED_IN_PERSON'\n\nexport default class AuthService {\n\tprivate env: EnvService\n\tprivate pkg: PkgService\n\n\tpublic constructor(envService: EnvService, pkgService: PkgService) {\n\t\tthis.env = envService\n\t\tthis.pkg = pkgService\n\t}\n\n\tpublic getLoggedInPerson(): PersonWithToken | null {\n\t\tconst p = this.env.get(LOGGED_IN_PERSON_KEY)\n\t\tif (typeof p === 'string') {\n\t\t\treturn JSON.parse(p)\n\t\t}\n\n\t\treturn null\n\t}\n\n\tpublic setLoggedInPerson(person: PersonWithToken) {\n\t\tconst normalized = normalizeSchemaValues(personWithTokenSchema, person)\n\t\tvalidateSchemaValues(personWithTokenSchema, normalized)\n\n\t\tthis.env.set(\n\t\t\tLOGGED_IN_PERSON_KEY,\n\t\t\tJSON.stringify({\n\t\t\t\t...normalized,\n\t\t\t\tisLoggedIn: true,\n\t\t\t})\n\t\t)\n\t}\n\n\tpublic logOutPerson() {\n\t\tthis.env.unset(LOGGED_IN_PERSON_KEY)\n\t}\n\n\tpublic getCurrentSkill(): SkillAuth | null {\n\t\tconst id = this.env.get('SKILL_ID') as string\n\t\tconst apiKey = this.env.get('SKILL_API_KEY') as string\n\t\tconst name = this.env.get('SKILL_NAME') as string\n\t\tconst slug = this.pkg.get('skill.namespace') as string\n\n\t\tif (id && apiKey) {\n\t\t\treturn {\n\t\t\t\tid,\n\t\t\t\tapiKey,\n\t\t\t\tname,\n\t\t\t\tslug,\n\t\t\t}\n\t\t}\n\n\t\treturn null\n\t}\n\n\tpublic logoutCurrentSkill() {\n\t\tthis.env.unset('SKILL_ID')\n\t\tthis.env.unset('SKILL_API_KEY')\n\t\tthis.env.unset('SKILL_NAME')\n\t}\n\n\tpublic updateCurrentSkill(skill: SkillAuth) {\n\t\tthis.env.set('SKILL_ID', skill.id)\n\t\tthis.env.set('SKILL_API_KEY', skill.apiKey)\n\t\tthis.env.set('SKILL_NAME', skill.name)\n\n\t\tthis.updateCurrentSkillNamespace(skill.slug)\n\t}\n\n\tpublic updateCurrentSkillNamespace(namespace: string) {\n\t\tthis.pkg.set({\n\t\t\tpath: 'skill.namespace',\n\t\t\tvalue: namesUtil.toKebab(namespace),\n\t\t})\n\t}\n}\n"],"file":"AuthService.js"}
@@ -54,35 +54,39 @@ var GameService = /*#__PURE__*/function () {
54
54
  case 0:
55
55
  introductionSentences = _args.length > 0 && _args[0] !== undefined ? _args[0] : [];
56
56
  sentencesToPlay = (0, _toConsumableArray2["default"])(introductionSentences);
57
+ _context.next = 4;
58
+ return this.ui.stopLoading();
59
+
60
+ case 4:
57
61
  this.killed = false;
58
62
 
59
- case 3:
63
+ case 5:
60
64
  if (!(sentencesToPlay.length > 0)) {
61
- _context.next = 12;
65
+ _context.next = 14;
62
66
  break;
63
67
  }
64
68
 
65
69
  next = sentencesToPlay.shift();
66
70
  this.ui.renderLine(next);
67
- _context.next = 8;
71
+ _context.next = 10;
68
72
  return new Promise(function (r) {
69
73
  return setTimeout(r, 2000);
70
74
  });
71
75
 
72
- case 8:
76
+ case 10:
73
77
  if (!this.killed) {
74
- _context.next = 10;
78
+ _context.next = 12;
75
79
  break;
76
80
  }
77
81
 
78
82
  return _context.abrupt("return");
79
83
 
80
- case 10:
81
- _context.next = 3;
84
+ case 12:
85
+ _context.next = 5;
82
86
  break;
83
87
 
84
- case 12:
85
- _context.next = 14;
88
+ case 14:
89
+ _context.next = 16;
86
90
  return this.command.execute('node ./node_modules/.bin/js-tetris-cli', {
87
91
  spawnOptions: {
88
92
  stdio: [process.stdin, 'pipe', 'pipe']
@@ -110,7 +114,7 @@ var GameService = /*#__PURE__*/function () {
110
114
  }
111
115
  });
112
116
 
113
- case 14:
117
+ case 16:
114
118
  case "end":
115
119
  return _context.stop();
116
120
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/services/GameService.ts"],"names":["GameService","command","ui","cwd","diskUtil","resolvePath","__dirname","message","statusMessage","introductionSentences","sentencesToPlay","killed","length","next","shift","renderLine","Promise","r","setTimeout","execute","spawnOptions","stdio","process","stdin","onData","data","stdout","write","saveCursor","moveCursorTo","clearBelowCursor","restoreCursor","kill","clear"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;IAIqBA,W;AAMpB,uBAAmBC,OAAnB,EAA4CC,EAA5C,EAAmE;AAAA;AAAA;AAAA;AAAA;AAAA,qDAFlD,KAEkD;AAClE,SAAKD,OAAL,GAAeA,OAAf;AACA,SAAKC,EAAL,GAAUA,EAAV;AACA,SAAKD,OAAL,CAAaE,GAAb,GAAmBC,2BAASC,WAAT,CAAqBC,SAArB,EAAgC,QAAhC,CAAnB;AACA;;;;WAED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AAgBC,KAAhB,CAAsB,KAAI,CAACnB,aAA3B;;AACA,wBAAA,KAAI,CAACN,EAAL,CAAQ6B,aAAR;AACA;AACD;AACD;AAfmE,iBAA/D,CAbP;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,O;;;;;;;;;;WAgCA,gBAAc;AACb,WAAKpB,MAAL,GAAc,IAAd;AACA,WAAKV,OAAL,CAAa+B,IAAb;AACA,WAAK9B,EAAL,CAAQ+B,KAAR;AACA","sourcesContent":["import { diskUtil } from '@sprucelabs/spruce-skill-utils'\nimport TerminalInterface from '../interfaces/TerminalInterface'\nimport CommandService from './CommandService'\n\nexport default class GameService {\n\tprivate command: CommandService\n\tprivate ui: TerminalInterface\n\tprivate statusMessage?: string\n\tprivate killed = false\n\n\tpublic constructor(command: CommandService, ui: TerminalInterface) {\n\t\tthis.command = command\n\t\tthis.ui = ui\n\t\tthis.command.cwd = diskUtil.resolvePath(__dirname, '../../')\n\t}\n\n\tpublic setStatusMessage(message: string) {\n\t\tthis.statusMessage = message\n\t}\n\n\tpublic async play(introductionSentences: string[] = []) {\n\t\tconst sentencesToPlay = [...introductionSentences]\n\t\tthis.killed = false\n\n\t\twhile (sentencesToPlay.length > 0) {\n\t\t\tconst next = sentencesToPlay.shift() as string\n\t\t\tthis.ui.renderLine(next)\n\t\t\tawait new Promise((r) => setTimeout(r, 2000))\n\t\t\tif (this.killed) {\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\n\t\tawait this.command.execute('node ./node_modules/.bin/js-tetris-cli', {\n\t\t\tspawnOptions: {\n\t\t\t\tstdio: [process.stdin, 'pipe', 'pipe'],\n\t\t\t},\n\t\t\tonData: (data: string) => {\n\t\t\t\tif (!this.killed) {\n\t\t\t\t\tprocess.stdout?.write(data)\n\t\t\t\t\tif (this.statusMessage) {\n\t\t\t\t\t\tthis.ui.saveCursor()\n\t\t\t\t\t\tthis.ui.moveCursorTo(0, 25)\n\t\t\t\t\t\tthis.ui.clearBelowCursor()\n\t\t\t\t\t\tprocess.stdout?.write(this.statusMessage)\n\t\t\t\t\t\tthis.ui.restoreCursor()\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t},\n\t\t})\n\t}\n\n\tpublic kill() {\n\t\tthis.killed = true\n\t\tthis.command.kill()\n\t\tthis.ui.clear()\n\t}\n}\n"],"file":"GameService.js"}
1
+ {"version":3,"sources":["../../src/services/GameService.ts"],"names":["GameService","command","ui","cwd","diskUtil","resolvePath","__dirname","message","statusMessage","introductionSentences","sentencesToPlay","stopLoading","killed","length","next","shift","renderLine","Promise","r","setTimeout","execute","spawnOptions","stdio","process","stdin","onData","data","stdout","write","saveCursor","moveCursorTo","clearBelowCursor","restoreCursor","kill","clear"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;IAIqBA,W;AAMpB,uBAAmBC,OAAnB,EAA4CC,EAA5C,EAAmE;AAAA;AAAA;AAAA;AAAA;AAAA,qDAFlD,KAEkD;AAClE,SAAKD,OAAL,GAAeA,OAAf;AACA,SAAKC,EAAL,GAAUA,EAAV;AACA,SAAKD,OAAL,CAAaE,GAAb,GAAmBC,2BAASC,WAAT,CAAqBC,SAArB,EAAgC,QAAhC,CAAnB;AACA;;;;WAED,0BAAwBC,OAAxB,EAAyC;AACxC,WAAKC,aAAL,GAAqBD,OAArB;AACA;;;;gGAED;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAkBE,gBAAAA,qBAAlB,2DAAoD,EAApD;AACOC,gBAAAA,eADP,uCAC6BD,qBAD7B;AAAA;AAAA,uBAEO,KAAKP,EAAL,CAAQS,WAAR,EAFP;;AAAA;AAGC,qBAAKC,MAAL,GAAc,KAAd;;AAHD;AAAA,sBAKQF,eAAe,CAACG,MAAhB,GAAyB,CALjC;AAAA;AAAA;AAAA;;AAMQC,gBAAAA,IANR,GAMeJ,eAAe,CAACK,KAAhB,EANf;AAOE,qBAAKb,EAAL,CAAQc,UAAR,CAAmBF,IAAnB;AAPF;AAAA,uBAQQ,IAAIG,OAAJ,CAAY,UAACC,CAAD;AAAA,yBAAOC,UAAU,CAACD,CAAD,EAAI,IAAJ,CAAjB;AAAA,iBAAZ,CARR;;AAAA;AAAA,qBASM,KAAKN,MATX;AAAA;AAAA;AAAA;;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA,uBAcO,KAAKX,OAAL,CAAamB,OAAb,CAAqB,wCAArB,EAA+D;AACpEC,kBAAAA,YAAY,EAAE;AACbC,oBAAAA,KAAK,EAAE,CAACC,OAAO,CAACC,KAAT,EAAgB,MAAhB,EAAwB,MAAxB;AADM,mBADsD;AAIpEC,kBAAAA,MAAM,EAAE,gBAACC,IAAD,EAAkB;AACzB,wBAAI,CAAC,KAAI,CAACd,MAAV,EAAkB;AAAA;;AACjB,yCAAAW,OAAO,CAACI,MAAR,oEAAgBC,KAAhB,CAAsBF,IAAtB;;AACA,0BAAI,KAAI,CAAClB,aAAT,EAAwB;AAAA;;AACvB,wBAAA,KAAI,CAACN,EAAL,CAAQ2B,UAAR;;AACA,wBAAA,KAAI,CAAC3B,EAAL,CAAQ4B,YAAR,CAAqB,CAArB,EAAwB,EAAxB;;AACA,wBAAA,KAAI,CAAC5B,EAAL,CAAQ6B,gBAAR;;AACA,4CAAAR,OAAO,CAACI,MAAR,sEAAgBC,KAAhB,CAAsB,KAAI,CAACpB,aAA3B;;AACA,wBAAA,KAAI,CAACN,EAAL,CAAQ8B,aAAR;AACA;AACD;AACD;AAfmE,iBAA/D,CAdP;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,O;;;;;;;;;;WAiCA,gBAAc;AACb,WAAKpB,MAAL,GAAc,IAAd;AACA,WAAKX,OAAL,CAAagC,IAAb;AACA,WAAK/B,EAAL,CAAQgC,KAAR;AACA","sourcesContent":["import { diskUtil } from '@sprucelabs/spruce-skill-utils'\nimport TerminalInterface from '../interfaces/TerminalInterface'\nimport CommandService from './CommandService'\n\nexport default class GameService {\n\tprivate command: CommandService\n\tprivate ui: TerminalInterface\n\tprivate statusMessage?: string\n\tprivate killed = false\n\n\tpublic constructor(command: CommandService, ui: TerminalInterface) {\n\t\tthis.command = command\n\t\tthis.ui = ui\n\t\tthis.command.cwd = diskUtil.resolvePath(__dirname, '../../')\n\t}\n\n\tpublic setStatusMessage(message: string) {\n\t\tthis.statusMessage = message\n\t}\n\n\tpublic async play(introductionSentences: string[] = []) {\n\t\tconst sentencesToPlay = [...introductionSentences]\n\t\tawait this.ui.stopLoading()\n\t\tthis.killed = false\n\n\t\twhile (sentencesToPlay.length > 0) {\n\t\t\tconst next = sentencesToPlay.shift() as string\n\t\t\tthis.ui.renderLine(next)\n\t\t\tawait new Promise((r) => setTimeout(r, 2000))\n\t\t\tif (this.killed) {\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\n\t\tawait this.command.execute('node ./node_modules/.bin/js-tetris-cli', {\n\t\t\tspawnOptions: {\n\t\t\t\tstdio: [process.stdin, 'pipe', 'pipe'],\n\t\t\t},\n\t\t\tonData: (data: string) => {\n\t\t\t\tif (!this.killed) {\n\t\t\t\t\tprocess.stdout?.write(data)\n\t\t\t\t\tif (this.statusMessage) {\n\t\t\t\t\t\tthis.ui.saveCursor()\n\t\t\t\t\t\tthis.ui.moveCursorTo(0, 25)\n\t\t\t\t\t\tthis.ui.clearBelowCursor()\n\t\t\t\t\t\tprocess.stdout?.write(this.statusMessage)\n\t\t\t\t\t\tthis.ui.restoreCursor()\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t},\n\t\t})\n\t}\n\n\tpublic kill() {\n\t\tthis.killed = true\n\t\tthis.command.kill()\n\t\tthis.ui.clear()\n\t}\n}\n"],"file":"GameService.js"}
@@ -1,7 +1,10 @@
1
1
  import CommandService from './CommandService';
2
2
  export default class LintService {
3
3
  cwd: string;
4
- private command;
5
- constructor(cwd: string, command: CommandService);
4
+ private getCommand;
5
+ private static isLintingEnabled;
6
+ static disableLinting(): void;
7
+ static enableLinting(): void;
8
+ constructor(cwd: string, commandServiceFactory: () => CommandService);
6
9
  fix: (pattern: string) => Promise<string[]>;
7
10
  }