@sprucelabs/spruce-cli 14.28.8 → 14.29.3

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 (139) 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 +3 -0
  12. package/build/__tests__/behavioral/events/CreatingAListener.test.js +200 -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/{ListeningToAnEventYouCreate.test.d.ts → events/ListeningToAnEventYouCreate.test.d.ts} +1 -1
  18. package/build/__tests__/behavioral/{ListeningToAnEventYouCreate.test.js → events/ListeningToAnEventYouCreate.test.js} +2 -2
  19. package/build/__tests__/behavioral/events/ListeningToAnEventYouCreate.test.js.map +1 -0
  20. package/build/__tests__/behavioral/events/SkillEmitsBootEvents.test.d.ts +1 -0
  21. package/build/__tests__/behavioral/events/SkillEmitsBootEvents.test.js +53 -21
  22. package/build/__tests__/behavioral/events/SkillEmitsBootEvents.test.js.map +1 -1
  23. package/build/__tests__/behavioral/skill/UpgradingWithListeners.test.d.ts +5 -0
  24. package/build/__tests__/behavioral/skill/UpgradingWithListeners.test.js +137 -0
  25. package/build/__tests__/behavioral/skill/UpgradingWithListeners.test.js.map +1 -0
  26. package/build/__tests__/behavioral/stores/KeepingDataStoresInSync.test.d.ts +3 -0
  27. package/build/__tests__/behavioral/stores/KeepingDataStoresInSync.test.js +105 -16
  28. package/build/__tests__/behavioral/stores/KeepingDataStoresInSync.test.js.map +1 -1
  29. package/build/__tests__/behavioral/tests/CreatingATest.test.js +14 -10
  30. package/build/__tests__/behavioral/tests/CreatingATest.test.js.map +1 -1
  31. package/build/__tests__/behavioral/views/TestingViewControllers.test.d.ts +1 -0
  32. package/build/__tests__/behavioral/views/TestingViewControllers.test.js +67 -35
  33. package/build/__tests__/behavioral/views/TestingViewControllers.test.js.map +1 -1
  34. package/build/__tests__/implementation/AuthService.test.d.ts +1 -0
  35. package/build/__tests__/implementation/AuthService.test.js +8 -0
  36. package/build/__tests__/implementation/AuthService.test.js.map +1 -1
  37. package/build/__tests__/implementation/EventStore.test.js +3 -1
  38. package/build/__tests__/implementation/EventStore.test.js.map +1 -1
  39. package/build/__tests__/implementation/LintService.test.d.ts +5 -0
  40. package/build/__tests__/implementation/LintService.test.js +130 -0
  41. package/build/__tests__/implementation/LintService.test.js.map +1 -0
  42. package/build/__tests__/implementation/StoreFeature.test.d.ts +4 -0
  43. package/build/__tests__/implementation/StoreFeature.test.js +132 -0
  44. package/build/__tests__/implementation/StoreFeature.test.js.map +1 -0
  45. package/build/errors/SpruceError.js +8 -4
  46. package/build/errors/SpruceError.js.map +1 -1
  47. package/build/features/event/EventFeature.d.ts +2 -2
  48. package/build/features/event/EventFeature.js +53 -13
  49. package/build/features/event/EventFeature.js.map +1 -1
  50. package/build/features/event/actions/ListenAction.d.ts +1 -0
  51. package/build/features/event/actions/ListenAction.js +60 -31
  52. package/build/features/event/actions/ListenAction.js.map +1 -1
  53. package/build/features/event/actions/SyncListenersAction.d.ts +15 -0
  54. package/build/features/event/actions/SyncListenersAction.js +115 -0
  55. package/build/features/event/actions/SyncListenersAction.js.map +1 -0
  56. package/build/features/event/builders/ListenerTemplateItemBuilder.d.ts +8 -0
  57. package/build/features/event/builders/ListenerTemplateItemBuilder.js +65 -0
  58. package/build/features/event/builders/ListenerTemplateItemBuilder.js.map +1 -0
  59. package/build/features/event/stores/EventStore.js +2 -2
  60. package/build/features/event/stores/EventStore.js.map +1 -1
  61. package/build/features/event/stores/ListenerStore.d.ts +9 -0
  62. package/build/features/event/stores/ListenerStore.js +122 -0
  63. package/build/features/event/stores/ListenerStore.js.map +1 -0
  64. package/build/features/event/writers/EventWriter.d.ts +4 -1
  65. package/build/features/event/writers/EventWriter.js +42 -8
  66. package/build/features/event/writers/EventWriter.js.map +1 -1
  67. package/build/features/node/NodeFeature.js +1 -1
  68. package/build/features/node/NodeFeature.js.map +1 -1
  69. package/build/features/skill/SkillFeature.js +1 -1
  70. package/build/features/skill/SkillFeature.js.map +1 -1
  71. package/build/features/skill/stores/SkillStore.js +4 -8
  72. package/build/features/skill/stores/SkillStore.js.map +1 -1
  73. package/build/features/store/StoreFeature.d.ts +1 -1
  74. package/build/features/store/StoreFeature.js +16 -11
  75. package/build/features/store/StoreFeature.js.map +1 -1
  76. package/build/schemas/v2020_07_22/personWithToken.builder.js +1 -0
  77. package/build/schemas/v2020_07_22/personWithToken.builder.js.map +1 -1
  78. package/build/services/AuthService.d.ts +4 -1
  79. package/build/services/AuthService.js +15 -4
  80. package/build/services/AuthService.js.map +1 -1
  81. package/build/services/GameService.js +14 -10
  82. package/build/services/GameService.js.map +1 -1
  83. package/build/services/LintService.d.ts +5 -2
  84. package/build/services/LintService.js +137 -92
  85. package/build/services/LintService.js.map +1 -1
  86. package/build/services/ServiceFactory.js +9 -3
  87. package/build/services/ServiceFactory.js.map +1 -1
  88. package/build/stores/StoreFactory.d.ts +2 -0
  89. package/build/stores/StoreFactory.js +4 -1
  90. package/build/stores/StoreFactory.js.map +1 -1
  91. package/build/tests/AbstractCliTest.js +3 -3
  92. package/build/tests/AbstractCliTest.js.map +1 -1
  93. package/build/writers/AbstractWriter.d.ts +0 -3
  94. package/build/writers/AbstractWriter.js +2 -18
  95. package/build/writers/AbstractWriter.js.map +1 -1
  96. package/package.json +11 -9
  97. package/src/__tests__/behavioral/SettingLogTransportsInASkill.test.ts +2 -0
  98. package/src/__tests__/behavioral/SyncingEventsOnlyFromDependencies.test.ts +10 -5
  99. package/src/__tests__/behavioral/TestingDataStores.test.ts +2 -0
  100. package/src/__tests__/behavioral/eventContract/PullingMercuryEventContract.test.ts +1 -0
  101. package/src/__tests__/behavioral/events/CreatingAListener.test.ts +48 -9
  102. package/src/__tests__/behavioral/events/KeepingListenersInSync.test.ts +47 -0
  103. package/src/__tests__/behavioral/{ListeningToAnEventYouCreate.test.ts → events/ListeningToAnEventYouCreate.test.ts} +2 -2
  104. package/src/__tests__/behavioral/events/SkillEmitsBootEvents.test.ts +6 -0
  105. package/src/__tests__/behavioral/skill/UpgradingWithListeners.test.ts +59 -0
  106. package/src/__tests__/behavioral/stores/KeepingDataStoresInSync.test.ts +31 -2
  107. package/src/__tests__/behavioral/tests/CreatingATest.test.ts +2 -0
  108. package/src/__tests__/behavioral/views/TestingViewControllers.test.ts +6 -0
  109. package/src/__tests__/implementation/AuthService.test.ts +6 -0
  110. package/src/__tests__/implementation/EventStore.test.ts +1 -0
  111. package/src/__tests__/implementation/LintService.test.ts +34 -0
  112. package/src/__tests__/implementation/StoreFeature.test.ts +40 -0
  113. package/src/errors/SpruceError.ts +9 -5
  114. package/src/features/event/EventFeature.ts +21 -4
  115. package/src/features/event/actions/ListenAction.ts +9 -3
  116. package/src/features/event/actions/SyncListenersAction.ts +38 -0
  117. package/src/features/event/builders/ListenerTemplateItemBuilder.ts +27 -0
  118. package/src/features/event/stores/EventStore.ts +1 -1
  119. package/src/features/event/stores/ListenerStore.ts +32 -0
  120. package/src/features/event/writers/EventWriter.ts +19 -0
  121. package/src/features/node/NodeFeature.ts +2 -1
  122. package/src/features/skill/SkillFeature.ts +1 -1
  123. package/src/features/skill/stores/SkillStore.ts +4 -3
  124. package/src/features/store/StoreFeature.ts +7 -4
  125. package/src/schemas/v2020_07_22/personWithToken.builder.ts +1 -0
  126. package/src/services/AuthService.ts +15 -5
  127. package/src/services/GameService.ts +1 -0
  128. package/src/services/LintService.ts +34 -5
  129. package/src/services/ServiceFactory.ts +8 -3
  130. package/src/stores/StoreFactory.ts +3 -0
  131. package/src/tests/AbstractCliTest.ts +2 -2
  132. package/src/writers/AbstractWriter.ts +2 -13
  133. package/build/__tests__/behavioral/ListeningToAnEventYouCreate.test.js.map +0 -1
  134. package/build/__tests__/behavioral/README.md +0 -8
  135. package/build/__tests__/implementation/README.md +0 -5
  136. package/build/components/README.md +0 -5
  137. package/src/__tests__/behavioral/README.md +0 -8
  138. package/src/__tests__/implementation/README.md +0 -5
  139. package/src/components/README.md +0 -5
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/tests/AbstractCliTest.ts"],"names":["AbstractCliTest","cleanTestDirsAndFiles","AbstractWriter","disableLinting","ImportService","setCacheDir","diskUtil","createRandomTempDir","enableCaching","process","env","ENABLE_INSTALL_INTERTAINMENT","originalEnv","testUtil","startLogTimer","SchemaRegistry","getInstance","forgetAllSchemas","cwd","freshTmpDir","homeDir","emitter","undefined","featureInstaller","OnboardingStore","overrideCwd","ui","reset","invocations","setCursorPosition","x","y","clearFixtures","clearCache","SkillStore","clearCurrentSkill","EventStore","CommandService","clearMockResponses","organizationFixture","clearAllOrgs","mercuryFixture","disconnectAll","_ui","isWaitingForInput","Error","doesDirExist","shouldClearCache","deleteDir","shouldCleanupTestSkillDirs","FeatureFixture","deleteOldSkillDirs","pattern","resolveTestPath","matches","match","deleteFile","personFixture","skillFixture","viewFixture","tmpDirectory","resolveTestDir","uuid","v4","fs","ensureDirSync","SpyInterface","CliGlobalEmitter","Emitter","pathAfterTestDirsAndFiles","pathUtil","join","cliRoot","options","Cli","fixture","linkLocalPackages","type","sf","ServiceFactory","Service","getEmitter","serviceFactory","apiClientFactory","getMercuryFixture","getApiClientFactory","getFeatureInstaller","MercuryFixture","PersonFixture","writerFactory","WriterFactory","viewWriter","Writer","fileDescriptions","ViewFixture","Action","templates","settings","execute","promise","waitForInput","sendInput","results","OrganizationFixture","getPersonFixture","StoreFactory","SkillFixture","filePath","resolveHashSprucePath","storeFactory","actionExecuter","ActionExecuter","FeatureInstallerFactory","WithAllFeatures","code","Store","isInstalled","assert","isTrue","files","file","checker","check","path","connectToApi","all","dir","wait","timeout","log","featureCode","actionCode","executer","shouldThrowOnListenerError","actionFactory","ActionFactory","optionOverrides","shouldInstallMissingDependencies","featureInstallerFactory","shouldAutoHandleDependencies","label","last","getLastInvocation","doesInclude","choices","find","o","value","AbstractSpruceTest","__dirname"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAIA;;AAGA;;AACA;;AAEA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAQA;;AACA;;AACA;;AAGA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;;;;;;;;;;;IAM8BA,e;;;;;;;;;;;;;qGAc7B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA,uBAEO,KAAKC,qBAAL,EAFP;;AAAA;AAICC,2CAAeC,cAAf;;AAEAC,0CAAcC,WAAd,CAA0BC,2BAASC,mBAAT,EAA1B;;AACAH,0CAAcI,aAAd;;AAEAC,gBAAAA,OAAO,CAACC,GAAR,CAAYC,4BAAZ,GAA2C,OAA3C;AAEA,qBAAKC,WAAL,qBAAwBH,OAAO,CAACC,GAAhC;;AAXD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,O;;;;;;;;;;;sGAcA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;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AL,CAAaA,OAAb,CAAqBuE,OAArB,CAA6BC,IAA7B,CACb,UAACC,CAAD;AAAA,eAAYA,CAAC,CAACN,KAAF,KAAYA,KAAxB;AAAA,OADa,CAAd;AAIA,WAAK,KAAKlH,EAAL,CAAQ2E,SAAR,WAAqB9C,KAAK,CAAC4F,KAA3B,EAAL;AACA;;;EA3aoDC,gB;;;iCAAxBpJ,e,aACFsE,iBAASC,IAAT,CAAc8E,SAAd,EAAyB,IAAzB,C;iCADErJ,e;iCAAAA,e;iCAAAA,e;iCAAAA,e;iCAAAA,e;iCAAAA,e;iCAAAA,e;iCAAAA,e;iCAAAA,e;iCAAAA,e","sourcesContent":["import pathUtil from 'path'\nimport { SchemaRegistry } from '@sprucelabs/schema'\nimport { diskUtil } from '@sprucelabs/spruce-skill-utils'\nimport { templates } from '@sprucelabs/spruce-templates'\nimport AbstractSpruceTest, { assert } from '@sprucelabs/test'\nimport fs from 'fs-extra'\nimport globby from 'globby'\nimport * as uuid from 'uuid'\nimport { CliBootOptions } from '../cli'\nimport AbstractAction from '../features/AbstractAction'\nimport { FeatureOptions } from '../features/AbstractFeature'\nimport ActionExecuter, {\n\tActionExecuterOptions,\n} from '../features/ActionExecuter'\nimport ActionFactory from '../features/ActionFactory'\nimport EventStore from '../features/event/stores/EventStore'\nimport FeatureInstaller from '../features/FeatureInstaller'\nimport FeatureInstallerFactory from '../features/FeatureInstallerFactory'\nimport { FeatureActionResponse, FeatureCode } from '../features/features.types'\nimport OnboardingStore from '../features/onboard/stores/OnboardingStore'\nimport SkillStore from '../features/skill/stores/SkillStore'\nimport CliGlobalEmitter, { GlobalEmitter } from '../GlobalEmitter'\nimport SpyInterface from '../interfaces/SpyInterface'\nimport CommandService from '../services/CommandService'\nimport ImportService from '../services/ImportService'\nimport ServiceFactory, { Service, ServiceMap } from '../services/ServiceFactory'\nimport StoreFactory, {\n\tStoreCode,\n\tStoreFactoryMethodOptions,\n\tStoreFactoryOptions,\n\tStoreMap,\n} from '../stores/StoreFactory'\nimport { ApiClientFactoryOptions } from '../types/apiClient.types'\nimport { OptionOverrides } from '../types/cli.types'\nimport AbstractWriter from '../writers/AbstractWriter'\nimport WriterFactory from '../writers/WriterFactory'\nimport FeatureFixture, {\n\tFeatureFixtureOptions,\n} from './fixtures/FeatureFixture'\nimport MercuryFixture from './fixtures/MercuryFixture'\nimport OrganizationFixture from './fixtures/OrganizationFixture'\nimport PersonFixture from './fixtures/PersonFixture'\nimport SkillFixture from './fixtures/SkillFixture'\nimport ViewFixture from './fixtures/ViewFixture'\nimport testUtil from './utilities/test.utility'\n\ntype ExecuterOptions = Partial<ActionExecuterOptions> & {\n\toptionOverrides?: OptionOverrides\n}\n\nexport default abstract class AbstractCliTest extends AbstractSpruceTest {\n\tprotected static cliRoot = pathUtil.join(__dirname, '..')\n\tprotected static homeDir: string\n\n\tprivate static _ui: SpyInterface\n\tprivate static emitter?: GlobalEmitter\n\tprivate static mercuryFixture?: MercuryFixture\n\tprivate static personFixture?: PersonFixture\n\tprivate static organizationFixture?: OrganizationFixture\n\tprivate static skillFixture?: SkillFixture\n\tprivate static featureInstaller?: FeatureInstaller\n\tprivate static viewFixture?: ViewFixture\n\tprivate static originalEnv: { [x: string]: string | undefined }\n\n\tprotected static async beforeAll() {\n\t\tawait super.beforeAll()\n\t\tawait this.cleanTestDirsAndFiles()\n\n\t\tAbstractWriter.disableLinting()\n\n\t\tImportService.setCacheDir(diskUtil.createRandomTempDir())\n\t\tImportService.enableCaching()\n\n\t\tprocess.env.ENABLE_INSTALL_INTERTAINMENT = 'false'\n\n\t\tthis.originalEnv = { ...process.env }\n\t}\n\n\tprotected static async beforeEach() {\n\t\tawait super.beforeEach()\n\n\t\t//@ts-ignore\n\t\tprocess.env = { ...this.originalEnv }\n\n\t\ttestUtil.startLogTimer()\n\n\t\tSchemaRegistry.getInstance().forgetAllSchemas()\n\n\t\tthis.cwd = this.freshTmpDir()\n\t\tthis.homeDir = this.freshTmpDir()\n\n\t\tthis.emitter = undefined\n\t\tthis.featureInstaller = undefined\n\n\t\tOnboardingStore.overrideCwd(diskUtil.createRandomTempDir())\n\n\t\tthis.ui.reset()\n\t\tthis.ui.invocations = []\n\t\tthis.ui.setCursorPosition({ x: 0, y: 0 })\n\n\t\tthis.clearFixtures()\n\n\t\tImportService.clearCache()\n\t\tSkillStore.clearCurrentSkill()\n\t\tEventStore.clearCache()\n\t\tCommandService.clearMockResponses()\n\t}\n\n\tprotected static async afterEach() {\n\t\tawait super.afterEach()\n\n\t\tawait this.organizationFixture?.clearAllOrgs()\n\t\tawait this.mercuryFixture?.disconnectAll()\n\n\t\tthis.clearFixtures()\n\n\t\tif (this._ui?.isWaitingForInput()) {\n\t\t\tthrow new Error(\n\t\t\t\t`Terminal interface is waiting for input. Make sure you are invoking this.term.sendInput() as many times as needed.`\n\t\t\t)\n\t\t}\n\n\t\tif (diskUtil.doesDirExist(this.cwd) && testUtil.shouldClearCache()) {\n\t\t\tdiskUtil.deleteDir(this.cwd)\n\t\t}\n\n\t\tif (diskUtil.doesDirExist(this.homeDir) && testUtil.shouldClearCache()) {\n\t\t\tdiskUtil.deleteDir(this.homeDir)\n\t\t}\n\t}\n\n\tprotected static async afterAll() {\n\t\tawait super.afterAll()\n\t\tif (testUtil.shouldCleanupTestSkillDirs()) {\n\t\t\tFeatureFixture.deleteOldSkillDirs()\n\t\t}\n\t}\n\n\tprivate static async cleanTestDirsAndFiles() {\n\t\tconst pattern = this.resolveTestPath('**/*.d.ts')\n\t\tconst matches = await globby(pattern)\n\n\t\tfor (const match of matches) {\n\t\t\tdiskUtil.deleteFile(match)\n\t\t}\n\t}\n\n\tprivate static clearFixtures() {\n\t\tthis.emitter = undefined\n\t\tthis.mercuryFixture = undefined\n\t\tthis.organizationFixture = undefined\n\t\tthis.personFixture = undefined\n\t\tthis.skillFixture = undefined\n\t\tthis.viewFixture = undefined\n\t}\n\n\tprotected static freshTmpDir() {\n\t\tconst tmpDirectory = testUtil.resolveTestDir(uuid.v4())\n\t\tfs.ensureDirSync(tmpDirectory)\n\t\treturn tmpDirectory\n\t}\n\n\tprotected static get ui() {\n\t\tif (!this._ui) {\n\t\t\tthis._ui = new SpyInterface()\n\t\t}\n\n\t\treturn this._ui\n\t}\n\n\tprotected static getEmitter() {\n\t\tif (!this.emitter) {\n\t\t\tthis.emitter = CliGlobalEmitter.Emitter()\n\t\t}\n\t\treturn this.emitter\n\t}\n\n\tprotected static resolveTestPath(...pathAfterTestDirsAndFiles: string[]) {\n\t\treturn pathUtil.join(\n\t\t\tthis.cliRoot,\n\t\t\t'__tests__',\n\t\t\t'testDirsAndFiles',\n\t\t\t...pathAfterTestDirsAndFiles\n\t\t)\n\t}\n\n\tprotected static async Cli(options?: CliBootOptions) {\n\t\treturn this.FeatureFixture(options).Cli({\n\t\t\tcwd: this.cwd,\n\t\t\thomeDir: this.homeDir,\n\t\t\t...(options ?? {}),\n\t\t})\n\t}\n\n\tprotected static async linkLocalPackages() {\n\t\tconst fixture = this.FeatureFixture()\n\t\tawait fixture.linkLocalPackages()\n\t}\n\n\tprotected static Service<S extends Service>(\n\t\ttype: S,\n\t\tcwd?: string\n\t): ServiceMap[S] {\n\t\tconst sf = this.ServiceFactory()\n\t\treturn sf.Service(cwd ?? this.cwd, type)\n\t}\n\n\tprotected static ServiceFactory() {\n\t\treturn new ServiceFactory()\n\t}\n\n\tprotected static FeatureFixture(options?: Partial<FeatureFixtureOptions>) {\n\t\tconst emitter = options?.emitter ?? this.getEmitter()\n\n\t\treturn new FeatureFixture({\n\t\t\tcwd: this.cwd,\n\t\t\tserviceFactory: this.ServiceFactory(),\n\t\t\tui: this.ui,\n\t\t\temitter,\n\t\t\tapiClientFactory: this.getMercuryFixture().getApiClientFactory(),\n\t\t\tfeatureInstaller: this.getFeatureInstaller({ emitter }),\n\t\t\t...options,\n\t\t})\n\t}\n\n\tprotected static getMercuryFixture() {\n\t\tif (!this.mercuryFixture) {\n\t\t\tthis.mercuryFixture = new MercuryFixture(this.cwd, this.ServiceFactory())\n\t\t}\n\n\t\treturn this.mercuryFixture\n\t}\n\n\tprotected static getPersonFixture() {\n\t\tif (!this.personFixture) {\n\t\t\tthis.personFixture = new PersonFixture(\n\t\t\t\tthis.getMercuryFixture().getApiClientFactory()\n\t\t\t)\n\t\t}\n\n\t\treturn this.personFixture\n\t}\n\n\tprotected static getViewFixture() {\n\t\tif (!this.viewFixture) {\n\t\t\tconst writerFactory = this.WriterFactory()\n\n\t\t\tconst viewWriter = writerFactory.Writer('view', { fileDescriptions: [] })\n\t\t\tthis.viewFixture = new ViewFixture(\n\t\t\t\tthis.cwd,\n\t\t\t\tviewWriter,\n\t\t\t\tthis.Action('view', 'sync')\n\t\t\t)\n\t\t}\n\n\t\treturn this.viewFixture\n\t}\n\n\tprivate static WriterFactory() {\n\t\treturn new WriterFactory({\n\t\t\ttemplates,\n\t\t\tui: this.ui,\n\t\t\tsettings: this.Service('settings'),\n\t\t})\n\t}\n\n\tprotected static async skipInstallSkillPrompts<\n\t\tE extends () => Promise<FeatureActionResponse>\n\t>(\n\t\texecute?: E\n\t): Promise<E extends undefined ? undefined : FeatureActionResponse> {\n\t\tconst promise = execute?.()\n\n\t\tawait this.waitForInput()\n\t\tawait this.ui.sendInput('n')\n\n\t\tawait this.waitForInput()\n\t\tawait this.ui.sendInput('')\n\n\t\tconst results = await promise\n\n\t\treturn results as any\n\t}\n\n\tprotected static getOrganizationFixture() {\n\t\tif (!this.organizationFixture) {\n\t\t\tthis.organizationFixture = new OrganizationFixture(\n\t\t\t\tthis.getPersonFixture(),\n\t\t\t\tthis.StoreFactory()\n\t\t\t)\n\t\t}\n\n\t\treturn this.organizationFixture\n\t}\n\n\tprotected static getSkillFixture() {\n\t\tif (!this.skillFixture) {\n\t\t\tthis.skillFixture = new SkillFixture(\n\t\t\t\tthis.getPersonFixture(),\n\t\t\t\tthis.StoreFactory(),\n\t\t\t\tthis.getMercuryFixture().getApiClientFactory()\n\t\t\t)\n\t\t}\n\n\t\treturn this.skillFixture\n\t}\n\n\tprotected static resolveHashSprucePath(...filePath: string[]) {\n\t\treturn diskUtil.resolveHashSprucePath(this.cwd, ...filePath)\n\t}\n\n\tprotected static getFeatureInstaller(options?: Partial<FeatureOptions>) {\n\t\tif (!this.featureInstaller) {\n\t\t\tconst serviceFactory = this.ServiceFactory()\n\t\t\tconst storeFactory = this.StoreFactory(options)\n\t\t\tconst emitter = this.getEmitter()\n\t\t\tconst apiClientFactory = this.getMercuryFixture().getApiClientFactory()\n\n\t\t\tconst actionExecuter = this.ActionExecuter()\n\n\t\t\tthis.featureInstaller = FeatureInstallerFactory.WithAllFeatures({\n\t\t\t\tcwd: this.cwd,\n\t\t\t\tserviceFactory,\n\t\t\t\tstoreFactory,\n\t\t\t\tui: this.ui,\n\t\t\t\temitter,\n\t\t\t\tapiClientFactory,\n\t\t\t\tactionExecuter,\n\t\t\t\t...options,\n\t\t\t})\n\t\t}\n\n\t\treturn this.featureInstaller\n\t}\n\n\tprotected static StoreFactory(options?: Partial<StoreFactoryOptions>) {\n\t\tconst serviceFactory = this.ServiceFactory()\n\n\t\treturn new StoreFactory({\n\t\t\tcwd: this.cwd,\n\t\t\tserviceFactory,\n\t\t\thomeDir: this.homeDir,\n\t\t\tapiClientFactory: this.getMercuryFixture().getApiClientFactory(),\n\t\t\temitter: this.getEmitter(),\n\t\t\t...options,\n\t\t})\n\t}\n\n\tprotected static Store<C extends StoreCode>(\n\t\tcode: C,\n\t\toptions?: StoreFactoryMethodOptions\n\t): StoreMap[C] {\n\t\treturn this.StoreFactory().Store(code, {\n\t\t\tcwd: this.cwd,\n\t\t\t...options,\n\t\t})\n\t}\n\n\tprotected static async waitForInput() {\n\t\treturn this.ui.waitForInput()\n\t}\n\n\tprotected static async assertIsFeatureInstalled(code: FeatureCode) {\n\t\tconst featureInstaller = this.getFeatureInstaller()\n\t\tconst isInstalled = await featureInstaller.isInstalled(code)\n\n\t\tassert.isTrue(isInstalled)\n\t}\n\n\tprotected static async assertValidActionResponseFiles(\n\t\tresults: FeatureActionResponse\n\t) {\n\t\tfor (const file of results.files ?? []) {\n\t\t\tconst checker = this.Service('typeChecker')\n\t\t\tawait checker.check(file.path)\n\t\t}\n\n\t\t// await Promise.all(\n\t\t// \t(results.files ?? []).map((file) => {\n\t\t// \t\tconst checker = this.Service('typeChecker')\n\t\t// \t\treturn checker.check(file.path)\n\t\t// \t})\n\t\t// )\n\t}\n\n\tprotected static async connectToApi(options?: ApiClientFactoryOptions) {\n\t\treturn this.getMercuryFixture().connectToApi(options)\n\t}\n\n\tprotected static async openInVsCode(options?: {\n\t\tfile?: string\n\t\tdir?: string\n\t\ttimeout?: number\n\t}) {\n\t\tawait this.Action('vscode', 'setup').execute({ all: true })\n\n\t\tawait this.Service('command').execute(\n\t\t\t`code ${options?.file ?? options?.dir ?? this.cwd}`\n\t\t)\n\t\tawait this.wait(options?.timeout ?? 99999999)\n\t}\n\n\tprotected static async openInFinder(options?: {\n\t\tfile?: string\n\t\tdir?: string\n\t\ttimeout?: number\n\t}) {\n\t\tawait this.Service('command').execute(\n\t\t\t`open ${options?.file ?? options?.dir ?? this.cwd}`\n\t\t)\n\t\tawait this.wait(options?.timeout ?? 99999999)\n\t}\n\n\tprotected static log(...args: any[]) {\n\t\ttestUtil.log(...args)\n\t}\n\n\tprotected static Action<\n\t\tAction extends AbstractAction = AbstractAction,\n\t\tF extends FeatureCode = FeatureCode\n\t>(featureCode: F, actionCode: string, options?: ExecuterOptions): Action {\n\t\tconst executer = this.ActionExecuter({\n\t\t\tshouldThrowOnListenerError: true,\n\t\t\t...options,\n\t\t}).Action(featureCode, actionCode)\n\n\t\treturn executer as any\n\t}\n\n\tprotected static ActionExecuter(options?: ExecuterOptions) {\n\t\tconst serviceFactory = this.ServiceFactory()\n\t\tconst writerFactory = this.WriterFactory()\n\n\t\tconst emitter = this.getEmitter()\n\n\t\tconst actionFactory = new ActionFactory({\n\t\t\twriterFactory,\n\t\t\tui: this.ui,\n\t\t\temitter,\n\t\t\tapiClientFactory: this.getMercuryFixture().getApiClientFactory(),\n\t\t\tcwd: this.cwd,\n\t\t\tserviceFactory,\n\t\t\tstoreFactory: this.StoreFactory(),\n\t\t\ttemplates,\n\t\t\toptionOverrides: {\n\t\t\t\t'sync.schemas': {\n\t\t\t\t\tshouldInstallMissingDependencies: true,\n\t\t\t\t},\n\t\t\t\t...options?.optionOverrides,\n\t\t\t},\n\t\t})\n\n\t\tconst executer = new ActionExecuter({\n\t\t\tui: this.ui,\n\t\t\temitter,\n\t\t\tactionFactory,\n\t\t\tfeatureInstallerFactory: () => {\n\t\t\t\treturn this.getFeatureInstaller()\n\t\t\t},\n\t\t\tshouldAutoHandleDependencies: false,\n\t\t\t...options,\n\t\t})\n\n\t\treturn executer\n\t}\n\n\tprotected static selectOptionBasedOnLabel(label: string) {\n\t\tconst last = this.ui.getLastInvocation()\n\t\tassert.doesInclude(last.options.options.choices, {\n\t\t\tlabel,\n\t\t})\n\n\t\tconst match = last.options.options.choices.find(\n\t\t\t(o: any) => o.label === label\n\t\t)\n\n\t\tvoid this.ui.sendInput(`${match.value}`)\n\t}\n}\n"],"file":"AbstractCliTest.js"}
1
+ {"version":3,"sources":["../../src/tests/AbstractCliTest.ts"],"names":["AbstractCliTest","cleanTestDirsAndFiles","LintService","disableLinting","ImportService","setCacheDir","diskUtil","createRandomTempDir","enableCaching","process","env","ENABLE_INSTALL_INTERTAINMENT","originalEnv","testUtil","startLogTimer","SchemaRegistry","getInstance","forgetAllSchemas","cwd","freshTmpDir","homeDir","emitter","undefined","featureInstaller","OnboardingStore","overrideCwd","ui","reset","invocations","setCursorPosition","x","y","clearFixtures","clearCache","SkillStore","clearCurrentSkill","EventStore","CommandService","clearMockResponses","organizationFixture","clearAllOrgs","mercuryFixture","disconnectAll","_ui","isWaitingForInput","Error","doesDirExist","shouldClearCache","deleteDir","shouldCleanupTestSkillDirs","FeatureFixture","deleteOldSkillDirs","pattern","resolveTestPath","matches","match","deleteFile","personFixture","skillFixture","viewFixture","tmpDirectory","resolveTestDir","uuid","v4","fs","ensureDirSync","SpyInterface","CliGlobalEmitter","Emitter","pathAfterTestDirsAndFiles","pathUtil","join","cliRoot","options","Cli","fixture","linkLocalPackages","type","sf","ServiceFactory","Service","getEmitter","serviceFactory","apiClientFactory","getMercuryFixture","getApiClientFactory","getFeatureInstaller","MercuryFixture","PersonFixture","writerFactory","WriterFactory","viewWriter","Writer","fileDescriptions","ViewFixture","Action","templates","settings","execute","promise","waitForInput","sendInput","results","OrganizationFixture","getPersonFixture","StoreFactory","SkillFixture","filePath","resolveHashSprucePath","storeFactory","actionExecuter","ActionExecuter","FeatureInstallerFactory","WithAllFeatures","code","Store","isInstalled","assert","isTrue","files","file","checker","check","path","connectToApi","all","dir","wait","timeout","log","featureCode","actionCode","executer","shouldThrowOnListenerError","actionFactory","ActionFactory","optionOverrides","shouldInstallMissingDependencies","featureInstallerFactory","shouldAutoHandleDependencies","label","last","getLastInvocation","doesInclude","choices","find","o","value","AbstractSpruceTest","__dirname"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAIA;;AAGA;;AACA;;AAEA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAQA;;AACA;;AAGA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;;;;;;;;;;;IAM8BA,e;;;;;;;;;;;;;qGAc7B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA,uBAEO,KAAKC,qBAAL,EAFP;;AAAA;AAICC,wCAAYC,cAAZ;;AAEAC,0CAAcC,WAAd,CAA0BC,2BAASC,mBAAT,EAA1B;;AACAH,0CAAcI,aAAd;;AAEAC,gBAAAA,OAAO,CAACC,GAAR,CAAYC,4BAAZ,GAA2C,OAA3C;AAEA,qBAAKC,WAAL,qBAAwBH,OAAO,CAACC,GAAhC;;AAXD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,O;;;;;;;;;;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;AAIA,UAAMrF,KAAK,GAAGsF,IAAI,CAACpE,OAAL,CAAaA,OAAb,CAAqBuE,OAArB,CAA6BC,IAA7B,CACb,UAACC,CAAD;AAAA,eAAYA,CAAC,CAACN,KAAF,KAAYA,KAAxB;AAAA,OADa,CAAd;AAIA,WAAK,KAAKlH,EAAL,CAAQ2E,SAAR,WAAqB9C,KAAK,CAAC4F,KAA3B,EAAL;AACA;;;EA3aoDC,gB;;;iCAAxBpJ,e,aACFsE,iBAASC,IAAT,CAAc8E,SAAd,EAAyB,IAAzB,C;iCADErJ,e;iCAAAA,e;iCAAAA,e;iCAAAA,e;iCAAAA,e;iCAAAA,e;iCAAAA,e;iCAAAA,e;iCAAAA,e;iCAAAA,e","sourcesContent":["import pathUtil from 'path'\nimport { SchemaRegistry } from '@sprucelabs/schema'\nimport { diskUtil } from '@sprucelabs/spruce-skill-utils'\nimport { templates } from '@sprucelabs/spruce-templates'\nimport AbstractSpruceTest, { assert } from '@sprucelabs/test'\nimport fs from 'fs-extra'\nimport globby from 'globby'\nimport * as uuid from 'uuid'\nimport { CliBootOptions } from '../cli'\nimport AbstractAction from '../features/AbstractAction'\nimport { FeatureOptions } from '../features/AbstractFeature'\nimport ActionExecuter, {\n\tActionExecuterOptions,\n} from '../features/ActionExecuter'\nimport ActionFactory from '../features/ActionFactory'\nimport EventStore from '../features/event/stores/EventStore'\nimport FeatureInstaller from '../features/FeatureInstaller'\nimport FeatureInstallerFactory from '../features/FeatureInstallerFactory'\nimport { FeatureActionResponse, FeatureCode } from '../features/features.types'\nimport OnboardingStore from '../features/onboard/stores/OnboardingStore'\nimport SkillStore from '../features/skill/stores/SkillStore'\nimport CliGlobalEmitter, { GlobalEmitter } from '../GlobalEmitter'\nimport SpyInterface from '../interfaces/SpyInterface'\nimport CommandService from '../services/CommandService'\nimport ImportService from '../services/ImportService'\nimport LintService from '../services/LintService'\nimport ServiceFactory, { Service, ServiceMap } from '../services/ServiceFactory'\nimport StoreFactory, {\n\tStoreCode,\n\tStoreFactoryMethodOptions,\n\tStoreFactoryOptions,\n\tStoreMap,\n} from '../stores/StoreFactory'\nimport { ApiClientFactoryOptions } from '../types/apiClient.types'\nimport { OptionOverrides } from '../types/cli.types'\nimport WriterFactory from '../writers/WriterFactory'\nimport FeatureFixture, {\n\tFeatureFixtureOptions,\n} from './fixtures/FeatureFixture'\nimport MercuryFixture from './fixtures/MercuryFixture'\nimport OrganizationFixture from './fixtures/OrganizationFixture'\nimport PersonFixture from './fixtures/PersonFixture'\nimport SkillFixture from './fixtures/SkillFixture'\nimport ViewFixture from './fixtures/ViewFixture'\nimport testUtil from './utilities/test.utility'\n\ntype ExecuterOptions = Partial<ActionExecuterOptions> & {\n\toptionOverrides?: OptionOverrides\n}\n\nexport default abstract class AbstractCliTest extends AbstractSpruceTest {\n\tprotected static cliRoot = pathUtil.join(__dirname, '..')\n\tprotected static homeDir: string\n\n\tprivate static _ui: SpyInterface\n\tprivate static emitter?: GlobalEmitter\n\tprivate static mercuryFixture?: MercuryFixture\n\tprivate static personFixture?: PersonFixture\n\tprivate static organizationFixture?: OrganizationFixture\n\tprivate static skillFixture?: SkillFixture\n\tprivate static featureInstaller?: FeatureInstaller\n\tprivate static viewFixture?: ViewFixture\n\tprivate static originalEnv: { [x: string]: string | undefined }\n\n\tprotected static async beforeAll() {\n\t\tawait super.beforeAll()\n\t\tawait this.cleanTestDirsAndFiles()\n\n\t\tLintService.disableLinting()\n\n\t\tImportService.setCacheDir(diskUtil.createRandomTempDir())\n\t\tImportService.enableCaching()\n\n\t\tprocess.env.ENABLE_INSTALL_INTERTAINMENT = 'false'\n\n\t\tthis.originalEnv = { ...process.env }\n\t}\n\n\tprotected static async beforeEach() {\n\t\tawait super.beforeEach()\n\n\t\t//@ts-ignore\n\t\tprocess.env = { ...this.originalEnv }\n\n\t\ttestUtil.startLogTimer()\n\n\t\tSchemaRegistry.getInstance().forgetAllSchemas()\n\n\t\tthis.cwd = this.freshTmpDir()\n\t\tthis.homeDir = this.freshTmpDir()\n\n\t\tthis.emitter = undefined\n\t\tthis.featureInstaller = undefined\n\n\t\tOnboardingStore.overrideCwd(diskUtil.createRandomTempDir())\n\n\t\tthis.ui.reset()\n\t\tthis.ui.invocations = []\n\t\tthis.ui.setCursorPosition({ x: 0, y: 0 })\n\n\t\tthis.clearFixtures()\n\n\t\tImportService.clearCache()\n\t\tSkillStore.clearCurrentSkill()\n\t\tEventStore.clearCache()\n\t\tCommandService.clearMockResponses()\n\t}\n\n\tprotected static async afterEach() {\n\t\tawait super.afterEach()\n\n\t\tawait this.organizationFixture?.clearAllOrgs()\n\t\tawait this.mercuryFixture?.disconnectAll()\n\n\t\tthis.clearFixtures()\n\n\t\tif (this._ui?.isWaitingForInput()) {\n\t\t\tthrow new Error(\n\t\t\t\t`Terminal interface is waiting for input. Make sure you are invoking this.term.sendInput() as many times as needed.`\n\t\t\t)\n\t\t}\n\n\t\tif (diskUtil.doesDirExist(this.cwd) && testUtil.shouldClearCache()) {\n\t\t\tdiskUtil.deleteDir(this.cwd)\n\t\t}\n\n\t\tif (diskUtil.doesDirExist(this.homeDir) && testUtil.shouldClearCache()) {\n\t\t\tdiskUtil.deleteDir(this.homeDir)\n\t\t}\n\t}\n\n\tprotected static async afterAll() {\n\t\tawait super.afterAll()\n\t\tif (testUtil.shouldCleanupTestSkillDirs()) {\n\t\t\tFeatureFixture.deleteOldSkillDirs()\n\t\t}\n\t}\n\n\tprivate static async cleanTestDirsAndFiles() {\n\t\tconst pattern = this.resolveTestPath('**/*.d.ts')\n\t\tconst matches = await globby(pattern)\n\n\t\tfor (const match of matches) {\n\t\t\tdiskUtil.deleteFile(match)\n\t\t}\n\t}\n\n\tprivate static clearFixtures() {\n\t\tthis.emitter = undefined\n\t\tthis.mercuryFixture = undefined\n\t\tthis.organizationFixture = undefined\n\t\tthis.personFixture = undefined\n\t\tthis.skillFixture = undefined\n\t\tthis.viewFixture = undefined\n\t}\n\n\tprotected static freshTmpDir() {\n\t\tconst tmpDirectory = testUtil.resolveTestDir(uuid.v4())\n\t\tfs.ensureDirSync(tmpDirectory)\n\t\treturn tmpDirectory\n\t}\n\n\tprotected static get ui() {\n\t\tif (!this._ui) {\n\t\t\tthis._ui = new SpyInterface()\n\t\t}\n\n\t\treturn this._ui\n\t}\n\n\tprotected static getEmitter() {\n\t\tif (!this.emitter) {\n\t\t\tthis.emitter = CliGlobalEmitter.Emitter()\n\t\t}\n\t\treturn this.emitter\n\t}\n\n\tprotected static resolveTestPath(...pathAfterTestDirsAndFiles: string[]) {\n\t\treturn pathUtil.join(\n\t\t\tthis.cliRoot,\n\t\t\t'__tests__',\n\t\t\t'testDirsAndFiles',\n\t\t\t...pathAfterTestDirsAndFiles\n\t\t)\n\t}\n\n\tprotected static async Cli(options?: CliBootOptions) {\n\t\treturn this.FeatureFixture(options).Cli({\n\t\t\tcwd: this.cwd,\n\t\t\thomeDir: this.homeDir,\n\t\t\t...(options ?? {}),\n\t\t})\n\t}\n\n\tprotected static async linkLocalPackages() {\n\t\tconst fixture = this.FeatureFixture()\n\t\tawait fixture.linkLocalPackages()\n\t}\n\n\tprotected static Service<S extends Service>(\n\t\ttype: S,\n\t\tcwd?: string\n\t): ServiceMap[S] {\n\t\tconst sf = this.ServiceFactory()\n\t\treturn sf.Service(cwd ?? this.cwd, type)\n\t}\n\n\tprotected static ServiceFactory() {\n\t\treturn new ServiceFactory()\n\t}\n\n\tprotected static FeatureFixture(options?: Partial<FeatureFixtureOptions>) {\n\t\tconst emitter = options?.emitter ?? this.getEmitter()\n\n\t\treturn new FeatureFixture({\n\t\t\tcwd: this.cwd,\n\t\t\tserviceFactory: this.ServiceFactory(),\n\t\t\tui: this.ui,\n\t\t\temitter,\n\t\t\tapiClientFactory: this.getMercuryFixture().getApiClientFactory(),\n\t\t\tfeatureInstaller: this.getFeatureInstaller({ emitter }),\n\t\t\t...options,\n\t\t})\n\t}\n\n\tprotected static getMercuryFixture() {\n\t\tif (!this.mercuryFixture) {\n\t\t\tthis.mercuryFixture = new MercuryFixture(this.cwd, this.ServiceFactory())\n\t\t}\n\n\t\treturn this.mercuryFixture\n\t}\n\n\tprotected static getPersonFixture() {\n\t\tif (!this.personFixture) {\n\t\t\tthis.personFixture = new PersonFixture(\n\t\t\t\tthis.getMercuryFixture().getApiClientFactory()\n\t\t\t)\n\t\t}\n\n\t\treturn this.personFixture\n\t}\n\n\tprotected static getViewFixture() {\n\t\tif (!this.viewFixture) {\n\t\t\tconst writerFactory = this.WriterFactory()\n\n\t\t\tconst viewWriter = writerFactory.Writer('view', { fileDescriptions: [] })\n\t\t\tthis.viewFixture = new ViewFixture(\n\t\t\t\tthis.cwd,\n\t\t\t\tviewWriter,\n\t\t\t\tthis.Action('view', 'sync')\n\t\t\t)\n\t\t}\n\n\t\treturn this.viewFixture\n\t}\n\n\tprivate static WriterFactory() {\n\t\treturn new WriterFactory({\n\t\t\ttemplates,\n\t\t\tui: this.ui,\n\t\t\tsettings: this.Service('settings'),\n\t\t})\n\t}\n\n\tprotected static async skipInstallSkillPrompts<\n\t\tE extends () => Promise<FeatureActionResponse>\n\t>(\n\t\texecute?: E\n\t): Promise<E extends undefined ? undefined : FeatureActionResponse> {\n\t\tconst promise = execute?.()\n\n\t\tawait this.waitForInput()\n\t\tawait this.ui.sendInput('n')\n\n\t\tawait this.waitForInput()\n\t\tawait this.ui.sendInput('')\n\n\t\tconst results = await promise\n\n\t\treturn results as any\n\t}\n\n\tprotected static getOrganizationFixture() {\n\t\tif (!this.organizationFixture) {\n\t\t\tthis.organizationFixture = new OrganizationFixture(\n\t\t\t\tthis.getPersonFixture(),\n\t\t\t\tthis.StoreFactory()\n\t\t\t)\n\t\t}\n\n\t\treturn this.organizationFixture\n\t}\n\n\tprotected static getSkillFixture() {\n\t\tif (!this.skillFixture) {\n\t\t\tthis.skillFixture = new SkillFixture(\n\t\t\t\tthis.getPersonFixture(),\n\t\t\t\tthis.StoreFactory(),\n\t\t\t\tthis.getMercuryFixture().getApiClientFactory()\n\t\t\t)\n\t\t}\n\n\t\treturn this.skillFixture\n\t}\n\n\tprotected static resolveHashSprucePath(...filePath: string[]) {\n\t\treturn diskUtil.resolveHashSprucePath(this.cwd, ...filePath)\n\t}\n\n\tprotected static getFeatureInstaller(options?: Partial<FeatureOptions>) {\n\t\tif (!this.featureInstaller) {\n\t\t\tconst serviceFactory = this.ServiceFactory()\n\t\t\tconst storeFactory = this.StoreFactory(options)\n\t\t\tconst emitter = this.getEmitter()\n\t\t\tconst apiClientFactory = this.getMercuryFixture().getApiClientFactory()\n\n\t\t\tconst actionExecuter = this.ActionExecuter()\n\n\t\t\tthis.featureInstaller = FeatureInstallerFactory.WithAllFeatures({\n\t\t\t\tcwd: this.cwd,\n\t\t\t\tserviceFactory,\n\t\t\t\tstoreFactory,\n\t\t\t\tui: this.ui,\n\t\t\t\temitter,\n\t\t\t\tapiClientFactory,\n\t\t\t\tactionExecuter,\n\t\t\t\t...options,\n\t\t\t})\n\t\t}\n\n\t\treturn this.featureInstaller\n\t}\n\n\tprotected static StoreFactory(options?: Partial<StoreFactoryOptions>) {\n\t\tconst serviceFactory = this.ServiceFactory()\n\n\t\treturn new StoreFactory({\n\t\t\tcwd: this.cwd,\n\t\t\tserviceFactory,\n\t\t\thomeDir: this.homeDir,\n\t\t\tapiClientFactory: this.getMercuryFixture().getApiClientFactory(),\n\t\t\temitter: this.getEmitter(),\n\t\t\t...options,\n\t\t})\n\t}\n\n\tprotected static Store<C extends StoreCode>(\n\t\tcode: C,\n\t\toptions?: StoreFactoryMethodOptions\n\t): StoreMap[C] {\n\t\treturn this.StoreFactory().Store(code, {\n\t\t\tcwd: this.cwd,\n\t\t\t...options,\n\t\t})\n\t}\n\n\tprotected static async waitForInput() {\n\t\treturn this.ui.waitForInput()\n\t}\n\n\tprotected static async assertIsFeatureInstalled(code: FeatureCode) {\n\t\tconst featureInstaller = this.getFeatureInstaller()\n\t\tconst isInstalled = await featureInstaller.isInstalled(code)\n\n\t\tassert.isTrue(isInstalled)\n\t}\n\n\tprotected static async assertValidActionResponseFiles(\n\t\tresults: FeatureActionResponse\n\t) {\n\t\tfor (const file of results.files ?? []) {\n\t\t\tconst checker = this.Service('typeChecker')\n\t\t\tawait checker.check(file.path)\n\t\t}\n\n\t\t// await Promise.all(\n\t\t// \t(results.files ?? []).map((file) => {\n\t\t// \t\tconst checker = this.Service('typeChecker')\n\t\t// \t\treturn checker.check(file.path)\n\t\t// \t})\n\t\t// )\n\t}\n\n\tprotected static async connectToApi(options?: ApiClientFactoryOptions) {\n\t\treturn this.getMercuryFixture().connectToApi(options)\n\t}\n\n\tprotected static async openInVsCode(options?: {\n\t\tfile?: string\n\t\tdir?: string\n\t\ttimeout?: number\n\t}) {\n\t\tawait this.Action('vscode', 'setup').execute({ all: true })\n\n\t\tawait this.Service('command').execute(\n\t\t\t`code ${options?.file ?? options?.dir ?? this.cwd}`\n\t\t)\n\t\tawait this.wait(options?.timeout ?? 99999999)\n\t}\n\n\tprotected static async openInFinder(options?: {\n\t\tfile?: string\n\t\tdir?: string\n\t\ttimeout?: number\n\t}) {\n\t\tawait this.Service('command').execute(\n\t\t\t`open ${options?.file ?? options?.dir ?? this.cwd}`\n\t\t)\n\t\tawait this.wait(options?.timeout ?? 99999999)\n\t}\n\n\tprotected static log(...args: any[]) {\n\t\ttestUtil.log(...args)\n\t}\n\n\tprotected static Action<\n\t\tAction extends AbstractAction = AbstractAction,\n\t\tF extends FeatureCode = FeatureCode\n\t>(featureCode: F, actionCode: string, options?: ExecuterOptions): Action {\n\t\tconst executer = this.ActionExecuter({\n\t\t\tshouldThrowOnListenerError: true,\n\t\t\t...options,\n\t\t}).Action(featureCode, actionCode)\n\n\t\treturn executer as any\n\t}\n\n\tprotected static ActionExecuter(options?: ExecuterOptions) {\n\t\tconst serviceFactory = this.ServiceFactory()\n\t\tconst writerFactory = this.WriterFactory()\n\n\t\tconst emitter = this.getEmitter()\n\n\t\tconst actionFactory = new ActionFactory({\n\t\t\twriterFactory,\n\t\t\tui: this.ui,\n\t\t\temitter,\n\t\t\tapiClientFactory: this.getMercuryFixture().getApiClientFactory(),\n\t\t\tcwd: this.cwd,\n\t\t\tserviceFactory,\n\t\t\tstoreFactory: this.StoreFactory(),\n\t\t\ttemplates,\n\t\t\toptionOverrides: {\n\t\t\t\t'sync.schemas': {\n\t\t\t\t\tshouldInstallMissingDependencies: true,\n\t\t\t\t},\n\t\t\t\t...options?.optionOverrides,\n\t\t\t},\n\t\t})\n\n\t\tconst executer = new ActionExecuter({\n\t\t\tui: this.ui,\n\t\t\temitter,\n\t\t\tactionFactory,\n\t\t\tfeatureInstallerFactory: () => {\n\t\t\t\treturn this.getFeatureInstaller()\n\t\t\t},\n\t\t\tshouldAutoHandleDependencies: false,\n\t\t\t...options,\n\t\t})\n\n\t\treturn executer\n\t}\n\n\tprotected static selectOptionBasedOnLabel(label: string) {\n\t\tconst last = this.ui.getLastInvocation()\n\t\tassert.doesInclude(last.options.options.choices, {\n\t\t\tlabel,\n\t\t})\n\n\t\tconst match = last.options.options.choices.find(\n\t\t\t(o: any) => o.label === label\n\t\t)\n\n\t\tvoid this.ui.sendInput(`${match.value}`)\n\t}\n}\n"],"file":"AbstractCliTest.js"}
@@ -28,14 +28,11 @@ export default abstract class AbstractWriter {
28
28
  private upgradeMode;
29
29
  private fileDescriptions;
30
30
  private shouldConfirmBeforeWriting;
31
- private static isLintingEnabled;
32
31
  private firstFileWriteMessage?;
33
32
  private hasShownFirstWriteMessage;
34
33
  private settings;
35
34
  constructor(options: WriterOptions);
36
35
  protected lint(file: string): Promise<void>;
37
- static disableLinting(): void;
38
- static enableLinting(): void;
39
36
  protected writeDirectoryTemplate(options: WriteDirectoryTemplateOptions): Promise<WriteResults>;
40
37
  protected writeFileIfChangedMixinResults(destination: string, contents: string, description: string, results?: WriteResults, cwd?: string): Promise<WriteResults>;
41
38
  private isFileDifferent;
@@ -65,16 +65,11 @@ var AbstractWriter = /*#__PURE__*/function () {
65
65
  while (1) {
66
66
  switch (_context.prev = _context.next) {
67
67
  case 0:
68
- if (!AbstractWriter.isLintingEnabled) {
69
- _context.next = 4;
70
- break;
71
- }
72
-
73
68
  this.ui.startLoading("Linting ".concat(_path["default"].basename(file), "..."));
74
- _context.next = 4;
69
+ _context.next = 3;
75
70
  return (_this$linter = this.linter) === null || _this$linter === void 0 ? void 0 : _this$linter.fix(file)["catch"](function () {});
76
71
 
77
- case 4:
72
+ case 3:
78
73
  case "end":
79
74
  return _context.stop();
80
75
  }
@@ -409,20 +404,9 @@ var AbstractWriter = /*#__PURE__*/function () {
409
404
  var isDir = _spruceSkillUtils.diskUtil.doesDirExist(dirOrFile) && _fs["default"].lstatSync(dirOrFile).isDirectory() && _path["default"].extname(dirOrFile).length === 0;
410
405
  return isDir ? _spruceSkillUtils.diskUtil.resolvePath(dirOrFile, fallbackFileName) : dirOrFile;
411
406
  }
412
- }], [{
413
- key: "disableLinting",
414
- value: function disableLinting() {
415
- this.isLintingEnabled = false;
416
- }
417
- }, {
418
- key: "enableLinting",
419
- value: function enableLinting() {
420
- this.isLintingEnabled = true;
421
- }
422
407
  }]);
423
408
  return AbstractWriter;
424
409
  }();
425
410
 
426
411
  exports["default"] = AbstractWriter;
427
- (0, _defineProperty2["default"])(AbstractWriter, "isLintingEnabled", true);
428
412
  //# sourceMappingURL=AbstractWriter.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/writers/AbstractWriter.ts"],"names":["AbstractWriter","options","templates","ui","term","upgradeMode","fileDescriptions","linter","settings","file","isLintingEnabled","startLoading","pathUtil","basename","fix","context","destinationDir","filesToWrite","filesToSkip","shouldConfirmBeforeWriting","firstFileWriteMessage","hasShownFirstWriteMessage","directoryTemplate","kind","code","files","results","generated","shouldWrite","indexOf","filename","shouldSkip","writeFileIfChangedMixinResults","join","relativePath","contents","destination","description","cwd","myResults","desc","name","action","diskUtil","isDir","Error","fileDescription","getFileDescription","doesFileExist","write","confirmPromptOnFirstWrite","stopLoading","confirm","writeFile","isFileDifferent","shouldOverwriteIfChanged","cleanedName","cleanFilename","skipped","get","isAlwaysSkipped","shouldAskForOverwrite","renderLine","prompt","type","label","choices","value","FILE_ACTION_OVERWRITE","FILE_ACTION_SKIP","FILE_ACTION_ALWAYS_SKIP","answer","push","set","replace","path","relativeFile","sep","substr","shouldOverwriteWhenChanged","lower","toLowerCase","d","search","undefined","dirOrFile","fallbackFileName","doesDirExist","fs","lstatSync","isDirectory","extname","length","resolvePath"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AAEA;;;;;;;;;;;;IA8B8BA,c;AAY7B,0BAAmBC,OAAnB,EAA2C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,+DAPG,EAOH;AAAA,yEANN,IAMM;AAAA;AAAA,wEAHP,KAGO;AAAA;AAC1C,SAAKC,SAAL,GAAiBD,OAAO,CAACC,SAAzB;AACA,SAAKC,EAAL,GAAUF,OAAO,CAACG,IAAlB;AACA,SAAKC,WAAL,GAAmBJ,OAAO,CAACI,WAA3B;AACA,SAAKC,gBAAL,GAAwBL,OAAO,CAACK,gBAAhC;AACA,SAAKC,MAAL,GAAcN,OAAO,CAACM,MAAtB;AACA,SAAKC,QAAL,GAAgBP,OAAO,CAACO,QAAxB;AACA;;;;;gGAED,iBAAqBC,IAArB;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA,qBACKT,cAAc,CAACU,gBADpB;AAAA;AAAA;AAAA;;AAEE,qBAAKP,EAAL,CAAQQ,YAAR,mBAAgCC,iBAASC,QAAT,CAAkBJ,IAAlB,CAAhC;AAFF;AAAA,uCAGQ,KAAKF,MAHb,iDAGQ,aAAaO,GAAb,CAAiBL,IAAjB,WAA6B,YAAM,CAAE,CAArC,CAHR;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,O;;;;;;;;;;;kHAeA,kBACCR,OADD;AAAA;;AAAA;AAAA;AAAA;AAAA;AAIEc,gBAAAA,OAJF,GAUKd,OAVL,CAIEc,OAJF,EAKEC,cALF,GAUKf,OAVL,CAKEe,cALF,EAMEC,Y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AAK,GAAGD,2BAASkD,WAAT,CAAqBR,SAArB,EAAgCC,gBAAhC,CAAH,GAAuDD,SAAnE;AACA;;;WApND,0BAA+B;AAC9B,WAAK3E,gBAAL,GAAwB,KAAxB;AACA;;;WAED,yBAA8B;AAC7B,WAAKA,gBAAL,GAAwB,IAAxB;AACA;;;;;;iCAlC4BV,c,sBAOK,I","sourcesContent":["import fs from 'fs'\nimport pathUtil from 'path'\nimport { diskUtil, SettingsService } from '@sprucelabs/spruce-skill-utils'\nimport { DirectoryTemplateCode, Templates } from '@sprucelabs/spruce-templates'\nimport {\n\tFILE_ACTION_ALWAYS_SKIP,\n\tFILE_ACTION_OVERWRITE,\n\tFILE_ACTION_SKIP,\n} from '../constants'\nimport LintService from '../services/LintService'\nimport { FileDescription, GeneratedFile, UpgradeMode } from '../types/cli.types'\nimport { GraphicsInterface } from '../types/cli.types'\n\nexport type WriteResults = GeneratedFile[]\n\nexport interface WriterOptions {\n\ttemplates: Templates\n\tterm: GraphicsInterface\n\tupgradeMode?: UpgradeMode\n\tfileDescriptions: FileDescription[]\n\tlinter?: LintService\n\tsettings: SettingsService\n}\n\nexport interface WriteDirectoryTemplateOptions {\n\tdestinationDir: string\n\tcode: DirectoryTemplateCode\n\tfilesToWrite?: string[]\n\tfilesToSkip?: string[]\n\tcontext: any\n\tshouldConfirmBeforeWriting?: boolean\n\tfirstFileWriteMessage?: string\n}\n\nexport default abstract class AbstractWriter {\n\tprotected templates: Templates\n\tprotected ui: GraphicsInterface\n\tprivate linter?: LintService\n\tprivate upgradeMode: UpgradeMode\n\tprivate fileDescriptions: FileDescription[] = []\n\tprivate shouldConfirmBeforeWriting = true\n\tprivate static isLintingEnabled = true\n\tprivate firstFileWriteMessage?: string\n\tprivate hasShownFirstWriteMessage = false\n\tprivate settings: SettingsService<string>\n\n\tpublic constructor(options: WriterOptions) {\n\t\tthis.templates = options.templates\n\t\tthis.ui = options.term\n\t\tthis.upgradeMode = options.upgradeMode\n\t\tthis.fileDescriptions = options.fileDescriptions\n\t\tthis.linter = options.linter\n\t\tthis.settings = options.settings\n\t}\n\n\tprotected async lint(file: string) {\n\t\tif (AbstractWriter.isLintingEnabled) {\n\t\t\tthis.ui.startLoading(`Linting ${pathUtil.basename(file)}...`)\n\t\t\tawait this.linter?.fix(file).catch(() => {})\n\t\t}\n\t}\n\n\tpublic static disableLinting() {\n\t\tthis.isLintingEnabled = false\n\t}\n\n\tpublic static enableLinting() {\n\t\tthis.isLintingEnabled = true\n\t}\n\n\tprotected async writeDirectoryTemplate(\n\t\toptions: WriteDirectoryTemplateOptions\n\t) {\n\t\tconst {\n\t\t\tcontext,\n\t\t\tdestinationDir,\n\t\t\tfilesToWrite,\n\t\t\tfilesToSkip,\n\t\t\tshouldConfirmBeforeWriting = true,\n\t\t\tfirstFileWriteMessage,\n\t\t} = options\n\n\t\tthis.shouldConfirmBeforeWriting = shouldConfirmBeforeWriting\n\t\tthis.firstFileWriteMessage = firstFileWriteMessage\n\t\tthis.hasShownFirstWriteMessage = false\n\n\t\tconst files = await this.templates.directoryTemplate({\n\t\t\tkind: options.code,\n\t\t\tcontext: context ?? {},\n\t\t})\n\n\t\tlet results: WriteResults = []\n\n\t\tfor (const generated of files) {\n\t\t\tconst shouldWrite =\n\t\t\t\t!filesToWrite || filesToWrite.indexOf(generated.filename) > -1\n\t\t\tconst shouldSkip =\n\t\t\t\tfilesToSkip && filesToSkip.indexOf(generated.filename) > -1\n\n\t\t\tif (shouldWrite && !shouldSkip) {\n\t\t\t\tresults = await this.writeFileIfChangedMixinResults(\n\t\t\t\t\tpathUtil.join(destinationDir, generated.relativePath),\n\t\t\t\t\tgenerated.contents,\n\t\t\t\t\t'',\n\t\t\t\t\tresults,\n\t\t\t\t\tdestinationDir\n\t\t\t\t)\n\t\t\t}\n\t\t}\n\n\t\treturn results\n\t}\n\n\tprotected async writeFileIfChangedMixinResults(\n\t\tdestination: string,\n\t\tcontents: string,\n\t\tdescription: string,\n\t\tresults?: WriteResults,\n\t\tcwd = ''\n\t): Promise<WriteResults> {\n\t\tconst myResults: WriteResults = results ?? []\n\t\tlet desc: string | undefined = description\n\n\t\tconst name = pathUtil.basename(destination)\n\t\tlet action: GeneratedFile['action'] = 'skipped'\n\n\t\tif (diskUtil.isDir(destination)) {\n\t\t\tthrow new Error(`Can't write to a directory ${destination}.`)\n\t\t}\n\n\t\tconst fileDescription = this.getFileDescription(destination)\n\n\t\tif (!diskUtil.doesFileExist(destination)) {\n\t\t\tlet write = true\n\n\t\t\tif (\n\t\t\t\tthis.shouldConfirmBeforeWriting &&\n\t\t\t\tfileDescription?.confirmPromptOnFirstWrite\n\t\t\t) {\n\t\t\t\tthis.ui.stopLoading()\n\t\t\t\twrite = await this.ui.confirm(fileDescription.confirmPromptOnFirstWrite)\n\t\t\t}\n\n\t\t\tif (write) {\n\t\t\t\tdiskUtil.writeFile(destination, contents)\n\t\t\t\taction = 'generated'\n\t\t\t}\n\t\t} else if (\n\t\t\tthis.isFileDifferent(destination, contents) &&\n\t\t\tthis.shouldOverwriteIfChanged(destination)\n\t\t) {\n\t\t\tconst cleanedName = this.cleanFilename(destination, cwd)\n\t\t\tconst settings = { skipped: [], ...this.settings.get('writer') }\n\t\t\tconst isAlwaysSkipped = settings.skipped.indexOf(cleanedName) > -1\n\t\t\tlet write = !isAlwaysSkipped\n\n\t\t\tif (!isAlwaysSkipped && this.shouldAskForOverwrite()) {\n\t\t\t\tif (!this.hasShownFirstWriteMessage && this.firstFileWriteMessage) {\n\t\t\t\t\tthis.hasShownFirstWriteMessage = true\n\t\t\t\t\tthis.ui.renderLine(this.firstFileWriteMessage)\n\t\t\t\t\tthis.ui.renderLine('')\n\t\t\t\t}\n\n\t\t\t\tconst answer = await this.ui.prompt({\n\t\t\t\t\ttype: 'select',\n\t\t\t\t\tlabel: `${cleanedName}`,\n\t\t\t\t\toptions: {\n\t\t\t\t\t\tchoices: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tvalue: FILE_ACTION_OVERWRITE,\n\t\t\t\t\t\t\t\tlabel: 'Overwrite',\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tvalue: FILE_ACTION_SKIP,\n\t\t\t\t\t\t\t\tlabel: 'Skip',\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tvalue: FILE_ACTION_ALWAYS_SKIP,\n\t\t\t\t\t\t\t\tlabel: 'Always skip',\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t},\n\t\t\t\t})\n\n\t\t\t\tif (answer === FILE_ACTION_ALWAYS_SKIP) {\n\t\t\t\t\tsettings.skipped.push(cleanedName)\n\t\t\t\t\tthis.settings.set('writer', settings)\n\t\t\t\t}\n\n\t\t\t\twrite = answer === FILE_ACTION_OVERWRITE\n\t\t\t}\n\n\t\t\tif (write) {\n\t\t\t\tdiskUtil.writeFile(destination, contents)\n\t\t\t\taction = 'updated'\n\t\t\t}\n\t\t}\n\n\t\tif (!desc) {\n\t\t\tdesc = fileDescription?.description\n\t\t}\n\n\t\tif (!desc) {\n\t\t\tthrow new Error(\n\t\t\t\t`No FileDescription provided for ${destination.replace(\n\t\t\t\t\tcwd,\n\t\t\t\t\t''\n\t\t\t\t)}. Check your feature's fileDescriptions property.`\n\t\t\t)\n\t\t}\n\n\t\tmyResults.push({ name, description: desc, path: destination, action })\n\n\t\treturn myResults\n\t}\n\n\tprivate isFileDifferent(destination: string, contents: string) {\n\t\treturn diskUtil.isFileDifferent(destination, contents)\n\t}\n\n\tprivate cleanFilename(destination: string, cwd: string) {\n\t\tlet relativeFile = destination.replace(cwd, '')\n\t\tif (relativeFile[0] === pathUtil.sep) {\n\t\t\trelativeFile = relativeFile.substr(1)\n\t\t}\n\t\treturn relativeFile\n\t}\n\n\tprivate shouldOverwriteIfChanged(destination: string): boolean {\n\t\tif (!this.upgradeMode) {\n\t\t\treturn true\n\t\t}\n\n\t\tif (this.upgradeMode === 'forceEverything') {\n\t\t\treturn true\n\t\t}\n\n\t\tlet description: FileDescription | undefined =\n\t\t\tthis.getFileDescription(destination)\n\n\t\treturn description?.shouldOverwriteWhenChanged ?? false\n\t}\n\n\tprivate getFileDescription(destination: string): FileDescription | undefined {\n\t\tconst lower = destination.toLowerCase()\n\t\tfor (const d of this.fileDescriptions ?? []) {\n\t\t\tif (lower.search(d.path.toLowerCase()) > -1) {\n\t\t\t\treturn d\n\t\t\t}\n\t\t}\n\n\t\treturn undefined\n\t}\n\n\tprivate shouldAskForOverwrite() {\n\t\tif (\n\t\t\tthis.shouldConfirmBeforeWriting &&\n\t\t\tthis.upgradeMode === 'askForChanged'\n\t\t) {\n\t\t\treturn true\n\t\t}\n\n\t\treturn false\n\t}\n\n\tprotected resolveFilenameWithFallback(\n\t\tdirOrFile: string,\n\t\tfallbackFileName: string\n\t) {\n\t\tconst isDir =\n\t\t\tdiskUtil.doesDirExist(dirOrFile) &&\n\t\t\tfs.lstatSync(dirOrFile).isDirectory() &&\n\t\t\tpathUtil.extname(dirOrFile).length === 0\n\t\treturn isDir ? diskUtil.resolvePath(dirOrFile, fallbackFileName) : dirOrFile\n\t}\n}\n"],"file":"AbstractWriter.js"}
1
+ {"version":3,"sources":["../../src/writers/AbstractWriter.ts"],"names":["AbstractWriter","options","templates","ui","term","upgradeMode","fileDescriptions","linter","settings","file","startLoading","pathUtil","basename","fix","context","destinationDir","filesToWrite","filesToSkip","shouldConfirmBeforeWriting","firstFileWriteMessage","hasShownFirstWriteMessage","directoryTemplate","kind","code","files","results","generated","shouldWrite","indexOf","filename","shouldSkip","writeFileIfChangedMixinResults","join","relativePath","contents","destination","description","cwd","myResults","desc","name","action","diskUtil","isDir","Error","fileDescription","getFileDescription","doesFileExist","write","confirmPromptOnFirstWrite","stopLoading","confirm","writeFile","isFileDifferent","shouldOverwriteIfChanged","cleanedName","cleanFilename","skipped","get","isAlwaysSkipped","shouldAskForOverwrite","renderLine","prompt","type","label","choices","value","FILE_ACTION_OVERWRITE","FILE_ACTION_SKIP","FILE_ACTION_ALWAYS_SKIP","answer","push","set","replace","path","relativeFile","sep","substr","shouldOverwriteWhenChanged","lower","toLowerCase","d","search","undefined","dirOrFile","fallbackFileName","doesDirExist","fs","lstatSync","isDirectory","extname","length","resolvePath"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AAEA;;;;;;;;;;;;IA8B8BA,c;AAW7B,0BAAmBC,OAAnB,EAA2C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,+DANG,EAMH;AAAA,yEALN,IAKM;AAAA;AAAA,wEAHP,KAGO;AAAA;AAC1C,SAAKC,SAAL,GAAiBD,OAAO,CAACC,SAAzB;AACA,SAAKC,EAAL,GAAUF,OAAO,CAACG,IAAlB;AACA,SAAKC,WAAL,GAAmBJ,OAAO,CAACI,WAA3B;AACA,SAAKC,gBAAL,GAAwBL,OAAO,CAACK,gBAAhC;AACA,SAAKC,MAAL,GAAcN,OAAO,CAACM,MAAtB;AACA,SAAKC,QAAL,GAAgBP,OAAO,CAACO,QAAxB;AACA;;;;;gGAED,iBAAqBC,IAArB;AAAA;;AAAA;AAAA;AAAA;AAAA;AACC,qBAAKN,EAAL,CAAQO,YAAR,mBAAgCC,iBAASC,QAAT,CAAkBH,IAAlB,CAAhC;AADD;AAAA,uCAEO,KAAKF,MAFZ,iDAEO,aAAaM,GAAb,CAAiBJ,IAAjB,WAA6B,YAAM,CAAE,CAArC,CAFP;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,O;;;;;;;;;;;kHAKA,kBACCR,OADD;AAAA;;AAAA;AAAA;AAAA;AAAA;AAIEa,gBAAAA,OAJF,GAUKb,OAVL,CAIEa,OAJF,EAKEC,cALF,GAUKd,OAVL,CAKEc,cALF,EAMEC,YANF,GAUKf,OAVL,CAMEe,YANF,EAOEC,WAPF,GAUKhB,OAVL,CAOEgB,WAPF,0BAUKhB,OAVL,CAQEiB,0BARF,EAQEA,0BARF,sCAQ+B,IAR/B,0B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ingsService } from '@sprucelabs/spruce-skill-utils'\nimport { DirectoryTemplateCode, Templates } from '@sprucelabs/spruce-templates'\nimport {\n\tFILE_ACTION_ALWAYS_SKIP,\n\tFILE_ACTION_OVERWRITE,\n\tFILE_ACTION_SKIP,\n} from '../constants'\nimport LintService from '../services/LintService'\nimport { FileDescription, GeneratedFile, UpgradeMode } from '../types/cli.types'\nimport { GraphicsInterface } from '../types/cli.types'\n\nexport type WriteResults = GeneratedFile[]\n\nexport interface WriterOptions {\n\ttemplates: Templates\n\tterm: GraphicsInterface\n\tupgradeMode?: UpgradeMode\n\tfileDescriptions: FileDescription[]\n\tlinter?: LintService\n\tsettings: SettingsService\n}\n\nexport interface WriteDirectoryTemplateOptions {\n\tdestinationDir: string\n\tcode: DirectoryTemplateCode\n\tfilesToWrite?: string[]\n\tfilesToSkip?: string[]\n\tcontext: any\n\tshouldConfirmBeforeWriting?: boolean\n\tfirstFileWriteMessage?: string\n}\n\nexport default abstract class AbstractWriter {\n\tprotected templates: Templates\n\tprotected ui: GraphicsInterface\n\tprivate linter?: LintService\n\tprivate upgradeMode: UpgradeMode\n\tprivate fileDescriptions: FileDescription[] = []\n\tprivate shouldConfirmBeforeWriting = true\n\tprivate firstFileWriteMessage?: string\n\tprivate hasShownFirstWriteMessage = false\n\tprivate settings: SettingsService<string>\n\n\tpublic constructor(options: WriterOptions) {\n\t\tthis.templates = options.templates\n\t\tthis.ui = options.term\n\t\tthis.upgradeMode = options.upgradeMode\n\t\tthis.fileDescriptions = options.fileDescriptions\n\t\tthis.linter = options.linter\n\t\tthis.settings = options.settings\n\t}\n\n\tprotected async lint(file: string) {\n\t\tthis.ui.startLoading(`Linting ${pathUtil.basename(file)}...`)\n\t\tawait this.linter?.fix(file).catch(() => {})\n\t}\n\n\tprotected async writeDirectoryTemplate(\n\t\toptions: WriteDirectoryTemplateOptions\n\t) {\n\t\tconst {\n\t\t\tcontext,\n\t\t\tdestinationDir,\n\t\t\tfilesToWrite,\n\t\t\tfilesToSkip,\n\t\t\tshouldConfirmBeforeWriting = true,\n\t\t\tfirstFileWriteMessage,\n\t\t} = options\n\n\t\tthis.shouldConfirmBeforeWriting = shouldConfirmBeforeWriting\n\t\tthis.firstFileWriteMessage = firstFileWriteMessage\n\t\tthis.hasShownFirstWriteMessage = false\n\n\t\tconst files = await this.templates.directoryTemplate({\n\t\t\tkind: options.code,\n\t\t\tcontext: context ?? {},\n\t\t})\n\n\t\tlet results: WriteResults = []\n\n\t\tfor (const generated of files) {\n\t\t\tconst shouldWrite =\n\t\t\t\t!filesToWrite || filesToWrite.indexOf(generated.filename) > -1\n\t\t\tconst shouldSkip =\n\t\t\t\tfilesToSkip && filesToSkip.indexOf(generated.filename) > -1\n\n\t\t\tif (shouldWrite && !shouldSkip) {\n\t\t\t\tresults = await this.writeFileIfChangedMixinResults(\n\t\t\t\t\tpathUtil.join(destinationDir, generated.relativePath),\n\t\t\t\t\tgenerated.contents,\n\t\t\t\t\t'',\n\t\t\t\t\tresults,\n\t\t\t\t\tdestinationDir\n\t\t\t\t)\n\t\t\t}\n\t\t}\n\n\t\treturn results\n\t}\n\n\tprotected async writeFileIfChangedMixinResults(\n\t\tdestination: string,\n\t\tcontents: string,\n\t\tdescription: string,\n\t\tresults?: WriteResults,\n\t\tcwd = ''\n\t): Promise<WriteResults> {\n\t\tconst myResults: WriteResults = results ?? []\n\t\tlet desc: string | undefined = description\n\n\t\tconst name = pathUtil.basename(destination)\n\t\tlet action: GeneratedFile['action'] = 'skipped'\n\n\t\tif (diskUtil.isDir(destination)) {\n\t\t\tthrow new Error(`Can't write to a directory ${destination}.`)\n\t\t}\n\n\t\tconst fileDescription = this.getFileDescription(destination)\n\n\t\tif (!diskUtil.doesFileExist(destination)) {\n\t\t\tlet write = true\n\n\t\t\tif (\n\t\t\t\tthis.shouldConfirmBeforeWriting &&\n\t\t\t\tfileDescription?.confirmPromptOnFirstWrite\n\t\t\t) {\n\t\t\t\tthis.ui.stopLoading()\n\t\t\t\twrite = await this.ui.confirm(fileDescription.confirmPromptOnFirstWrite)\n\t\t\t}\n\n\t\t\tif (write) {\n\t\t\t\tdiskUtil.writeFile(destination, contents)\n\t\t\t\taction = 'generated'\n\t\t\t}\n\t\t} else if (\n\t\t\tthis.isFileDifferent(destination, contents) &&\n\t\t\tthis.shouldOverwriteIfChanged(destination)\n\t\t) {\n\t\t\tconst cleanedName = this.cleanFilename(destination, cwd)\n\t\t\tconst settings = { skipped: [], ...this.settings.get('writer') }\n\t\t\tconst isAlwaysSkipped = settings.skipped.indexOf(cleanedName) > -1\n\t\t\tlet write = !isAlwaysSkipped\n\n\t\t\tif (!isAlwaysSkipped && this.shouldAskForOverwrite()) {\n\t\t\t\tif (!this.hasShownFirstWriteMessage && this.firstFileWriteMessage) {\n\t\t\t\t\tthis.hasShownFirstWriteMessage = true\n\t\t\t\t\tthis.ui.renderLine(this.firstFileWriteMessage)\n\t\t\t\t\tthis.ui.renderLine('')\n\t\t\t\t}\n\n\t\t\t\tconst answer = await this.ui.prompt({\n\t\t\t\t\ttype: 'select',\n\t\t\t\t\tlabel: `${cleanedName}`,\n\t\t\t\t\toptions: {\n\t\t\t\t\t\tchoices: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tvalue: FILE_ACTION_OVERWRITE,\n\t\t\t\t\t\t\t\tlabel: 'Overwrite',\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tvalue: FILE_ACTION_SKIP,\n\t\t\t\t\t\t\t\tlabel: 'Skip',\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tvalue: FILE_ACTION_ALWAYS_SKIP,\n\t\t\t\t\t\t\t\tlabel: 'Always skip',\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t},\n\t\t\t\t})\n\n\t\t\t\tif (answer === FILE_ACTION_ALWAYS_SKIP) {\n\t\t\t\t\tsettings.skipped.push(cleanedName)\n\t\t\t\t\tthis.settings.set('writer', settings)\n\t\t\t\t}\n\n\t\t\t\twrite = answer === FILE_ACTION_OVERWRITE\n\t\t\t}\n\n\t\t\tif (write) {\n\t\t\t\tdiskUtil.writeFile(destination, contents)\n\t\t\t\taction = 'updated'\n\t\t\t}\n\t\t}\n\n\t\tif (!desc) {\n\t\t\tdesc = fileDescription?.description\n\t\t}\n\n\t\tif (!desc) {\n\t\t\tthrow new Error(\n\t\t\t\t`No FileDescription provided for ${destination.replace(\n\t\t\t\t\tcwd,\n\t\t\t\t\t''\n\t\t\t\t)}. Check your feature's fileDescriptions property.`\n\t\t\t)\n\t\t}\n\n\t\tmyResults.push({ name, description: desc, path: destination, action })\n\n\t\treturn myResults\n\t}\n\n\tprivate isFileDifferent(destination: string, contents: string) {\n\t\treturn diskUtil.isFileDifferent(destination, contents)\n\t}\n\n\tprivate cleanFilename(destination: string, cwd: string) {\n\t\tlet relativeFile = destination.replace(cwd, '')\n\t\tif (relativeFile[0] === pathUtil.sep) {\n\t\t\trelativeFile = relativeFile.substr(1)\n\t\t}\n\t\treturn relativeFile\n\t}\n\n\tprivate shouldOverwriteIfChanged(destination: string): boolean {\n\t\tif (!this.upgradeMode) {\n\t\t\treturn true\n\t\t}\n\n\t\tif (this.upgradeMode === 'forceEverything') {\n\t\t\treturn true\n\t\t}\n\n\t\tlet description: FileDescription | undefined =\n\t\t\tthis.getFileDescription(destination)\n\n\t\treturn description?.shouldOverwriteWhenChanged ?? false\n\t}\n\n\tprivate getFileDescription(destination: string): FileDescription | undefined {\n\t\tconst lower = destination.toLowerCase()\n\t\tfor (const d of this.fileDescriptions ?? []) {\n\t\t\tif (lower.search(d.path.toLowerCase()) > -1) {\n\t\t\t\treturn d\n\t\t\t}\n\t\t}\n\n\t\treturn undefined\n\t}\n\n\tprivate shouldAskForOverwrite() {\n\t\tif (\n\t\t\tthis.shouldConfirmBeforeWriting &&\n\t\t\tthis.upgradeMode === 'askForChanged'\n\t\t) {\n\t\t\treturn true\n\t\t}\n\n\t\treturn false\n\t}\n\n\tprotected resolveFilenameWithFallback(\n\t\tdirOrFile: string,\n\t\tfallbackFileName: string\n\t) {\n\t\tconst isDir =\n\t\t\tdiskUtil.doesDirExist(dirOrFile) &&\n\t\t\tfs.lstatSync(dirOrFile).isDirectory() &&\n\t\t\tpathUtil.extname(dirOrFile).length === 0\n\t\treturn isDir ? diskUtil.resolvePath(dirOrFile, fallbackFileName) : dirOrFile\n\t}\n}\n"],"file":"AbstractWriter.js"}
package/package.json CHANGED
@@ -18,7 +18,7 @@
18
18
  ]
19
19
  },
20
20
  "license": "MIT",
21
- "version": "14.28.8",
21
+ "version": "14.29.3",
22
22
  "bin": {
23
23
  "spruce": "./build/index.js"
24
24
  },
@@ -84,11 +84,13 @@
84
84
  "@sprucelabs/mercury-types": "^26.1.992",
85
85
  "@sprucelabs/schema": "^25.4.67",
86
86
  "@sprucelabs/spruce-core-schemas": "^22.6.250",
87
- "@sprucelabs/spruce-event-plugin": "^17.0.4",
87
+ "@sprucelabs/spruce-event-plugin": "^18.1.0",
88
88
  "@sprucelabs/spruce-event-utils": "^17.1.272",
89
- "@sprucelabs/spruce-skill-booter": "^17.0.4",
89
+ "@sprucelabs/spruce-skill-booter": "^18.1.0",
90
90
  "@sprucelabs/spruce-skill-utils": "^22.1.50",
91
- "@sprucelabs/spruce-templates": "^14.28.8",
91
+ "@sprucelabs/spruce-templates": "^14.29.3",
92
+ "@typescript-eslint/eslint-plugin": "^5.6.0",
93
+ "@typescript-eslint/parser": "^5.6.0",
92
94
  "cfonts": "^2.10.0",
93
95
  "chalk": "^4.1.2",
94
96
  "chokidar": "^3.5.2",
@@ -121,10 +123,10 @@
121
123
  "@sprucelabs/jest-sheets-reporter": "^1.2.268",
122
124
  "@sprucelabs/mercury-core-events": "^1.6.215",
123
125
  "@sprucelabs/resolve-path-aliases": "^1.0.236",
124
- "@sprucelabs/spruce-conversation-plugin": "^17.0.4",
125
- "@sprucelabs/spruce-deploy-plugin": "^17.0.4",
126
- "@sprucelabs/spruce-store-plugin": "^17.0.4",
127
- "@sprucelabs/spruce-test-fixtures": "^17.0.4",
126
+ "@sprucelabs/spruce-conversation-plugin": "^18.1.0",
127
+ "@sprucelabs/spruce-deploy-plugin": "^18.1.0",
128
+ "@sprucelabs/spruce-store-plugin": "^18.1.0",
129
+ "@sprucelabs/spruce-test-fixtures": "^18.1.0",
128
130
  "@sprucelabs/test": "^7.7.248",
129
131
  "@sprucelabs/test-utils": "^3.0.301",
130
132
  "@types/blessed": "^0.1.19",
@@ -595,5 +597,5 @@
595
597
  "ora"
596
598
  ]
597
599
  },
598
- "gitHead": "c6881eaf61ca60574a87b6cb8c15738f85ec4f96"
600
+ "gitHead": "26363b3f10fde5826aeaf7e4d574c075ad9e85c4"
599
601
  }
@@ -1,6 +1,7 @@
1
1
  import { diskUtil, namesUtil } from '@sprucelabs/spruce-skill-utils'
2
2
  import { test, assert } from '@sprucelabs/test'
3
3
  import { errorAssertUtil } from '@sprucelabs/test-utils'
4
+ import LintService from '../../services/LintService'
4
5
  import AbstractSkillTest from '../../tests/AbstractSkillTest'
5
6
  import testUtil from '../../tests/utilities/test.utility'
6
7
 
@@ -48,6 +49,7 @@ export default class SettingLogTransportsInASkillTest extends AbstractSkillTest
48
49
 
49
50
  @test()
50
51
  protected static async logsWriteToTransports() {
52
+ LintService.enableLinting()
51
53
  const transportContents = `
52
54
  import { diskUtil, Level, LogTransport } from '@sprucelabs/spruce-skill-utils'
53
55
 
@@ -8,7 +8,7 @@ export default class SyncingEventsOnlyFromDependenciesTest extends AbstractSkill
8
8
  protected static skillCacheKey = 'events'
9
9
 
10
10
  @test()
11
- protected static async doesntSyncAnythingToStart() {
11
+ protected static async doesntSyncAnythingButListenersToStart() {
12
12
  const skills = this.getSkillFixture()
13
13
  await skills.registerCurrentSkill({
14
14
  name: 'events in sync skill',
@@ -22,9 +22,11 @@ export default class SyncingEventsOnlyFromDependenciesTest extends AbstractSkill
22
22
 
23
23
  assert.isFalse(diskUtil.doesDirExist(eventFolder))
24
24
 
25
- const contents = fsUtil.readdirSync(this.resolveHashSprucePath('events'))
25
+ const files = fsUtil.readdirSync(this.resolveHashSprucePath('events'))
26
26
 
27
- assert.isLength(contents, 1)
27
+ assert.isLength(files, 2, 'The wrong number of files were generated.')
28
+ assert.isEqual(files[0], 'events.contract.ts')
29
+ assert.isEqual(files[1], 'listeners.ts')
28
30
  }
29
31
 
30
32
  @test()
@@ -43,9 +45,12 @@ export default class SyncingEventsOnlyFromDependenciesTest extends AbstractSkill
43
45
 
44
46
  assert.isTrue(diskUtil.doesDirExist(eventFolder))
45
47
 
46
- const contents = fsUtil.readdirSync(this.resolveHashSprucePath('events'))
48
+ const files = fsUtil.readdirSync(this.resolveHashSprucePath('events'))
47
49
 
48
- assert.isLength(contents, 2)
50
+ assert.isLength(files, 3, 'The wrong number of files were generated.')
51
+ assert.isEqual(files[0], namesUtil.toCamel(skill.slug))
52
+ assert.isEqual(files[1], 'events.contract.ts')
53
+ assert.isEqual(files[2], 'listeners.ts')
49
54
  }
50
55
 
51
56
  private static async registerGlobalEvent() {
@@ -1,5 +1,6 @@
1
1
  import { diskUtil } from '@sprucelabs/spruce-skill-utils'
2
2
  import { test, assert } from '@sprucelabs/test'
3
+ import LintService from '../../services/LintService'
3
4
  import AbstractSkillTest from '../../tests/AbstractSkillTest'
4
5
  import testUtil from '../../tests/utilities/test.utility'
5
6
 
@@ -32,6 +33,7 @@ export default class TestingDataStoresTest extends AbstractSkillTest {
32
33
 
33
34
  @test()
34
35
  protected static async letsYouSelectAbstractStoreTest() {
36
+ LintService.enableLinting()
35
37
  this.cli.getFeature('store').isInstalled = async () => true
36
38
 
37
39
  const promise = this.Action('test', 'create').execute({
@@ -11,6 +11,7 @@ export default class GeneratingMercuryEventContractTest extends AbstractCliTest
11
11
  protected static async beforeEach() {
12
12
  await super.beforeEach()
13
13
  this.cli = await this.Cli()
14
+ diskUtil.writeFile(this.resolvePath('package.json'), '{}')
14
15
  }
15
16
 
16
17
  @test()
@@ -52,18 +52,21 @@ export default class CreatingAListenerTest extends AbstractEventTest {
52
52
  }
53
53
 
54
54
  @test()
55
- protected static async createsValidListener() {
56
- const cli = await this.installEventFeature('events')
55
+ protected static async generatesMapFile() {
56
+ const { results } = await this.installEventsAndCreateListener()
57
57
 
58
- const version = 'v2020_01_01'
58
+ const match = testUtil.assertFileByNameInGeneratedFiles(
59
+ `listeners.ts`,
60
+ results.files
61
+ )
59
62
 
60
- const results = await this.Action('event', 'listen').execute({
61
- namespace: 'skill',
62
- eventName: 'will-boot',
63
- version,
64
- })
63
+ await this.Service('typeChecker').check(match)
64
+ }
65
65
 
66
- assert.isFalsy(results.errors)
66
+ @test()
67
+ protected static async createsValidListener() {
68
+ const { version, results, cli } =
69
+ await this.installEventsAndCreateListener()
67
70
 
68
71
  const match = testUtil.assertFileByNameInGeneratedFiles(
69
72
  `will-boot.${version}.listener.ts`,
@@ -76,6 +79,7 @@ export default class CreatingAListenerTest extends AbstractEventTest {
76
79
 
77
80
  const health = await cli.checkHealth()
78
81
 
82
+ assert.isFalsy(health?.event?.errors)
79
83
  assert.isTruthy(health.skill)
80
84
 
81
85
  assert.isUndefined(health.skill.errors)
@@ -261,6 +265,41 @@ export default class CreatingAListenerTest extends AbstractEventTest {
261
265
  )
262
266
  }
263
267
 
268
+ @test()
269
+ protected static async listeningToAnEventWithNoEmitTargetOrPayloadGeneratesValidListener() {
270
+ const { listenerPath } =
271
+ await this.setupSkillsInstallAtOrgRegisterEventContractAndGenerateListener(
272
+ {
273
+ isGlobal: true,
274
+ responsePayloadSchema: {
275
+ id: 'test',
276
+ fields: {
277
+ id: {
278
+ type: 'id',
279
+ },
280
+ },
281
+ },
282
+ }
283
+ )
284
+
285
+ await this.Service('typeChecker').check(listenerPath)
286
+ }
287
+
288
+ private static async installEventsAndCreateListener() {
289
+ const cli = await this.installEventFeature('events')
290
+
291
+ const version = 'v2020_01_01'
292
+
293
+ const results = await this.Action('event', 'listen').execute({
294
+ namespace: 'skill',
295
+ eventName: 'will-boot',
296
+ version,
297
+ })
298
+
299
+ assert.isFalsy(results.errors)
300
+ return { version, results, cli }
301
+ }
302
+
264
303
  private static async setupSkillsInstallAtOrgRegisterEventContractAndGenerateListener(
265
304
  eventSignature: EventSignature
266
305
  ) {
@@ -0,0 +1,47 @@
1
+ import { diskUtil } from '@sprucelabs/spruce-skill-utils'
2
+ import { test, assert } from '@sprucelabs/test'
3
+ import { FeatureActionResponse } from '../../../features/features.types'
4
+ import AbstractEventTest from '../../../tests/AbstractEventTest'
5
+ import testUtil from '../../../tests/utilities/test.utility'
6
+
7
+ export default class KeepingListenersInSyncTest extends AbstractEventTest {
8
+ @test()
9
+ protected static async hasSyncAction() {
10
+ assert.isFunction(this.Action('event', 'sync.listeners').execute)
11
+ }
12
+
13
+ @test()
14
+ protected static async deletingAListener() {
15
+ await this.FeatureFixture().installCachedFeatures('events')
16
+
17
+ await this.createBootListener('did-boot')
18
+ const results = await this.createBootListener('will-boot')
19
+
20
+ this.deleteLastFile(results)
21
+
22
+ const syncResults = await this.Action('event', 'sync.listeners').execute({})
23
+
24
+ const listenerMap = testUtil.assertFileByNameInGeneratedFiles(
25
+ 'listeners.ts',
26
+ syncResults.files
27
+ )
28
+
29
+ await this.Service('typeChecker').check(listenerMap)
30
+ }
31
+
32
+ private static deleteLastFile(results: FeatureActionResponse) {
33
+ const path = results.files?.pop()?.path
34
+ assert.isString(path)
35
+
36
+ diskUtil.deleteFile(path)
37
+ }
38
+
39
+ private static async createBootListener(name: 'will-boot' | 'did-boot') {
40
+ const results = await this.Action('event', 'listen').execute({
41
+ namespace: 'skill',
42
+ eventName: name,
43
+ })
44
+ assert.isFalsy(results.errors)
45
+ return results
46
+ }
47
+ }
@@ -1,8 +1,8 @@
1
1
  import { eventNameUtil } from '@sprucelabs/spruce-event-utils'
2
2
  import { diskUtil } from '@sprucelabs/spruce-skill-utils'
3
3
  import { test, assert } from '@sprucelabs/test'
4
- import AbstractEventTest from '../../tests/AbstractEventTest'
5
- import testUtil from '../../tests/utilities/test.utility'
4
+ import AbstractEventTest from '../../../tests/AbstractEventTest'
5
+ import testUtil from '../../../tests/utilities/test.utility'
6
6
 
7
7
  export default class ListeningToAnEventYouCreateTest extends AbstractEventTest {
8
8
  @test()
@@ -1,8 +1,14 @@
1
1
  import { test, assert } from '@sprucelabs/test'
2
2
  import { errorAssertUtil } from '@sprucelabs/test-utils'
3
+ import LintService from '../../../services/LintService'
3
4
  import AbstractEventTest from '../../../tests/AbstractEventTest'
4
5
 
5
6
  export default class SkillEmitsBootEventsTest extends AbstractEventTest {
7
+ protected static async beforeEach() {
8
+ await super.beforeEach()
9
+ LintService.enableLinting()
10
+ }
11
+
6
12
  @test()
7
13
  protected static async skillEmitsWillBootEvents() {
8
14
  await this.installEventFeature('events')
@@ -0,0 +1,59 @@
1
+ import { eventResponseUtil } from '@sprucelabs/spruce-event-utils'
2
+ import { test, assert } from '@sprucelabs/test'
3
+ import SpruceError from '../../../errors/SpruceError'
4
+ import { FeatureCode } from '../../../features/features.types'
5
+ import CommandService from '../../../services/CommandService'
6
+ import AbstractCliTest from '../../../tests/AbstractCliTest'
7
+
8
+ export default class UpgradingWithListeners extends AbstractCliTest {
9
+ @test('should sync listeners when installed', 'events', true)
10
+ @test('should not sync listeners when not installed', 'skills', false)
11
+ @test(
12
+ 'should not sync listeners when creating node when not installed',
13
+ 'testsInNodeModule',
14
+ false,
15
+ 'create'
16
+ )
17
+ @test(
18
+ 'should not sync listeners when creating node when installed',
19
+ 'events',
20
+ false,
21
+ 'create'
22
+ )
23
+ protected static async upgradingSyncsListeners(
24
+ featureCode: FeatureCode,
25
+ shouldHit: boolean,
26
+ actionCode = 'upgrade'
27
+ ) {
28
+ await this.FeatureFixture().installCachedFeatures(featureCode)
29
+
30
+ CommandService.setMockResponse(new RegExp(/yarn/), {
31
+ code: 0,
32
+ })
33
+
34
+ let wasHit = false
35
+
36
+ await this.getEmitter().on(
37
+ 'feature.will-execute',
38
+ async ({ featureCode, actionCode }) => {
39
+ if (featureCode === 'event' && actionCode === 'sync.listeners') {
40
+ wasHit = true
41
+ }
42
+ }
43
+ )
44
+
45
+ const results = await this.getEmitter().emit('feature.will-execute', {
46
+ featureCode: 'node',
47
+ actionCode,
48
+ })
49
+
50
+ const { errors } = eventResponseUtil.getAllResponsePayloadsAndErrors(
51
+ results,
52
+ SpruceError
53
+ )
54
+
55
+ assert.isFalsy(errors)
56
+
57
+ assert.isEqual(wasHit, shouldHit)
58
+ }
59
+ }