@sprucelabs/spruce-cli 15.4.12 → 17.0.1

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 (461) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/build/.spruce/errors/spruceCli/actionCancelled.schema.js.map +1 -1
  3. package/build/.spruce/errors/spruceCli/bootError.schema.js.map +1 -1
  4. package/build/.spruce/errors/spruceCli/buildFailed.schema.js.map +1 -1
  5. package/build/.spruce/errors/spruceCli/cacheNotEnabled.schema.js.map +1 -1
  6. package/build/.spruce/errors/spruceCli/commandAborted.schema.js.map +1 -1
  7. package/build/.spruce/errors/spruceCli/commandBlocked.schema.js.map +1 -1
  8. package/build/.spruce/errors/spruceCli/commandNotImplemented.schema.js.map +1 -1
  9. package/build/.spruce/errors/spruceCli/createAutoloaderFailed.schema.js.map +1 -1
  10. package/build/.spruce/errors/spruceCli/dependencyExists.schema.js.map +1 -1
  11. package/build/.spruce/errors/spruceCli/deployFailed.schema.js.map +1 -1
  12. package/build/.spruce/errors/spruceCli/directoryEmpty.schema.js.map +1 -1
  13. package/build/.spruce/errors/spruceCli/directoryNotSkill.schema.js.map +1 -1
  14. package/build/.spruce/errors/spruceCli/dockerNotStarted.schema.js.map +1 -1
  15. package/build/.spruce/errors/spruceCli/executingCommandFailed.schema.js.map +1 -1
  16. package/build/.spruce/errors/spruceCli/failedToImport.schema.js.map +1 -1
  17. package/build/.spruce/errors/spruceCli/featureNotInstalled.schema.js.map +1 -1
  18. package/build/.spruce/errors/spruceCli/fileExists.schema.js.map +1 -1
  19. package/build/.spruce/errors/spruceCli/generic.schema.js.map +1 -1
  20. package/build/.spruce/errors/spruceCli/invalidCommand.schema.js.map +1 -1
  21. package/build/.spruce/errors/spruceCli/invalidEventContract.schema.js.map +1 -1
  22. package/build/.spruce/errors/spruceCli/invalidFeatureCode.schema.js.map +1 -1
  23. package/build/.spruce/errors/spruceCli/invalidTestDirectory.schema.js.map +1 -1
  24. package/build/.spruce/errors/spruceCli/lintFailed.schema.js.map +1 -1
  25. package/build/.spruce/errors/spruceCli/mercuryResponseError.schema.js.map +1 -1
  26. package/build/.spruce/errors/spruceCli/missingDependencies.schema.js.map +1 -1
  27. package/build/.spruce/errors/spruceCli/missingDependenciesDependency.schema.js.map +1 -1
  28. package/build/.spruce/errors/spruceCli/noOrganizationsFound.schema.js.map +1 -1
  29. package/build/.spruce/errors/spruceCli/noSkillsRegistered.schema.js.map +1 -1
  30. package/build/.spruce/errors/spruceCli/notImplemented.schema.js.map +1 -1
  31. package/build/.spruce/errors/spruceCli/notLoggedIn.schema.js.map +1 -1
  32. package/build/.spruce/errors/spruceCli/schemaExists.schema.js.map +1 -1
  33. package/build/.spruce/errors/spruceCli/schemaFailedToImport.schema.js.map +1 -1
  34. package/build/.spruce/errors/spruceCli/schemaTemplateItemBuildingFailed.schema.js.map +1 -1
  35. package/build/.spruce/errors/spruceCli/skillNotFound.schema.js.map +1 -1
  36. package/build/.spruce/errors/spruceCli/skillNotRegistered.schema.js.map +1 -1
  37. package/build/.spruce/errors/spruceCli/skillViewExists.schema.js.map +1 -1
  38. package/build/.spruce/errors/spruceCli/storeExists.schema.js.map +1 -1
  39. package/build/.spruce/errors/spruceCli/testFailed.schema.js.map +1 -1
  40. package/build/.spruce/errors/spruceCli/themeExists.schema.js.map +1 -1
  41. package/build/.spruce/errors/spruceCli/transportAlreadyExists.schema.js.map +1 -1
  42. package/build/.spruce/errors/spruceCli/vscodeNotInstalled.schema.js.map +1 -1
  43. package/build/.spruce/events/heartwood/didRegisterSkillViews.v2021_02_11.contract.js.map +1 -1
  44. package/build/.spruce/events/heartwood/generateUrl.v2021_02_11.contract.js.map +1 -1
  45. package/build/.spruce/events/heartwood/getSkillViews.v2021_02_11.contract.js.map +1 -1
  46. package/build/.spruce/events/heartwood/listViews.v2021_02_11.contract.js.map +1 -1
  47. package/build/.spruce/events/heartwood/registerSkillViews.v2021_02_11.contract.js.map +1 -1
  48. package/build/.spruce/schemas/heartwood/v2021_02_11/didRegisterSkillViewsEmitPayload.schema.js.map +1 -1
  49. package/build/.spruce/schemas/heartwood/v2021_02_11/didRegisterSkillViewsEmitTarget.schema.js.map +1 -1
  50. package/build/.spruce/schemas/heartwood/v2021_02_11/didRegisterSkillViewsEmitTargetAndPayload.schema.js.map +1 -1
  51. package/build/.spruce/schemas/heartwood/v2021_02_11/generateUrlEmitPayload.schema.js.map +1 -1
  52. package/build/.spruce/schemas/heartwood/v2021_02_11/generateUrlEmitTarget.schema.js.map +1 -1
  53. package/build/.spruce/schemas/heartwood/v2021_02_11/generateUrlEmitTargetAndPayload.schema.js.map +1 -1
  54. package/build/.spruce/schemas/heartwood/v2021_02_11/generateUrlResponsePayload.schema.js.map +1 -1
  55. package/build/.spruce/schemas/heartwood/v2021_02_11/getSkillViewsEmitTargetAndPayload.schema.js.map +1 -1
  56. package/build/.spruce/schemas/heartwood/v2021_02_11/getSkillViewsResponsePayload.schema.js.map +1 -1
  57. package/build/.spruce/schemas/heartwood/v2021_02_11/getViewControllersEmitTarget.schema.js.map +1 -1
  58. package/build/.spruce/schemas/heartwood/v2021_02_11/listViewsResponsePayload.schema.js.map +1 -1
  59. package/build/.spruce/schemas/heartwood/v2021_02_11/listViewsResult.schema.js.map +1 -1
  60. package/build/.spruce/schemas/heartwood/v2021_02_11/registerSkillViewsEmitPayload.schema.js.map +1 -1
  61. package/build/.spruce/schemas/heartwood/v2021_02_11/registerSkillViewsEmitTargetAndPayload.schema.js.map +1 -1
  62. package/build/.spruce/schemas/heartwood/v2021_02_11/registerSkillViewsResponsePayload.schema.js.map +1 -1
  63. package/build/.spruce/schemas/spruceCli/v2020_07_22/bootSkillOptions.schema.js.map +1 -1
  64. package/build/.spruce/schemas/spruceCli/v2020_07_22/createConversationTopicOptions.schema.js.map +1 -1
  65. package/build/.spruce/schemas/spruceCli/v2020_07_22/createErrorOptions.schema.js.map +1 -1
  66. package/build/.spruce/schemas/spruceCli/v2020_07_22/createOrganizationOptions.schema.js.map +1 -1
  67. package/build/.spruce/schemas/spruceCli/v2020_07_22/createSchemaOptions.schema.js.map +1 -1
  68. package/build/.spruce/schemas/spruceCli/v2020_07_22/createTestOptions.schema.js.map +1 -1
  69. package/build/.spruce/schemas/spruceCli/v2020_07_22/generatedDir.schema.js.map +1 -1
  70. package/build/.spruce/schemas/spruceCli/v2020_07_22/generatedFile.schema.js.map +1 -1
  71. package/build/.spruce/schemas/spruceCli/v2020_07_22/installSkillAtOrganizationOptions.schema.js.map +1 -1
  72. package/build/.spruce/schemas/spruceCli/v2020_07_22/listenEventOptions.schema.js.map +1 -1
  73. package/build/.spruce/schemas/spruceCli/v2020_07_22/namedTemplateItem.schema.js.map +1 -1
  74. package/build/.spruce/schemas/spruceCli/v2020_07_22/nodeFeatureOptions.schema.js.map +1 -1
  75. package/build/.spruce/schemas/spruceCli/v2020_07_22/onboardOptions.schema.js.map +1 -1
  76. package/build/.spruce/schemas/spruceCli/v2020_07_22/onboarding.schema.js.map +1 -1
  77. package/build/.spruce/schemas/spruceCli/v2020_07_22/personWithToken.schema.js.map +1 -1
  78. package/build/.spruce/schemas/spruceCli/v2020_07_22/registerDashboardWidgetsEmitPayloadSchema.schema.js.map +1 -1
  79. package/build/.spruce/schemas/spruceCli/v2020_07_22/setupTestsOptions.schema.js.map +1 -1
  80. package/build/.spruce/schemas/spruceCli/v2020_07_22/setupVscodeOptions.schema.js.map +1 -1
  81. package/build/.spruce/schemas/spruceCli/v2020_07_22/skillFeature.schema.js.map +1 -1
  82. package/build/.spruce/schemas/spruceCli/v2020_07_22/syncErrorOptions.schema.js.map +1 -1
  83. package/build/.spruce/schemas/spruceCli/v2020_07_22/syncEventOptions.schema.js.map +1 -1
  84. package/build/.spruce/schemas/spruceCli/v2020_07_22/syncSchemaFieldsOptions.schema.js.map +1 -1
  85. package/build/.spruce/schemas/spruceCli/v2020_07_22/syncSchemasOptions.schema.js.map +1 -1
  86. package/build/.spruce/schemas/spruceCli/v2020_07_22/testOptions.schema.js.map +1 -1
  87. package/build/.spruce/schemas/spruceCli/v2020_07_22/upgradeSkillOptions.schema.js.map +1 -1
  88. package/build/.spruce/schemas/spruceCli/v2020_07_22/watcherDidDetectChangesEmitPayload.schema.js.map +1 -1
  89. package/build/GlobalEmitter.js.map +1 -1
  90. package/build/__tests__/behavioral/AddingADependency.test.js.map +1 -1
  91. package/build/__tests__/behavioral/BlockingCommands.test.js.map +1 -1
  92. package/build/__tests__/behavioral/BootingTheCli.test.js.map +1 -1
  93. package/build/__tests__/behavioral/BootingWithBadFiles.test.js.map +1 -1
  94. package/build/__tests__/behavioral/CreatingAConversationTopic.test.js.map +1 -1
  95. package/build/__tests__/behavioral/CreatingSchemasWithGenerics.test.js.map +1 -1
  96. package/build/__tests__/behavioral/DeployingASkill.test.js.map +1 -1
  97. package/build/__tests__/behavioral/DeployingToSandbox.test.js.map +1 -1
  98. package/build/__tests__/behavioral/EnablingAndDisablingCache.test.js.map +1 -1
  99. package/build/__tests__/behavioral/GettingCliVersion.test.js.map +1 -1
  100. package/build/__tests__/behavioral/InstallingASkillAtAnOrg.test.js.map +1 -1
  101. package/build/__tests__/behavioral/ListeningToCoreEvents.test.js.map +1 -1
  102. package/build/__tests__/behavioral/LoggingInAsASkill.test.js.map +1 -1
  103. package/build/__tests__/behavioral/ManagingDependencies.test.js.map +1 -1
  104. package/build/__tests__/behavioral/OverridingCommandsInPackageJson.test.js.map +1 -1
  105. package/build/__tests__/behavioral/RebuildingASkill.test.js.map +1 -1
  106. package/build/__tests__/behavioral/RegisteringConversationsOnBoot.test.js.map +1 -1
  107. package/build/__tests__/behavioral/RegisteringEventsOnBoot.test.js.map +1 -1
  108. package/build/__tests__/behavioral/RegisteringGlobalEvents.test.js.map +1 -1
  109. package/build/__tests__/behavioral/RegisteringSkillViewOnBoot.test.js.map +1 -1
  110. package/build/__tests__/behavioral/RememberingUpgradeSelections.test.js.map +1 -1
  111. package/build/__tests__/behavioral/SettingLogTransportsInASkill.test.js.map +1 -1
  112. package/build/__tests__/behavioral/SettingRemote.test.js.map +1 -1
  113. package/build/__tests__/behavioral/SettingUpASkillForTesting.test.js.map +1 -1
  114. package/build/__tests__/behavioral/SettingUpSchemasForModuleDistribution.test.js.map +1 -1
  115. package/build/__tests__/behavioral/SettingUpVscode.test.js.map +1 -1
  116. package/build/__tests__/behavioral/SyncingEventsOnlyFromDependencies.test.js.map +1 -1
  117. package/build/__tests__/behavioral/TestReporterSettingsRemembered.test.js.map +1 -1
  118. package/build/__tests__/behavioral/TestingAConversation.test.js.map +1 -1
  119. package/build/__tests__/behavioral/TestingDataStores.test.js.map +1 -1
  120. package/build/__tests__/behavioral/WatchingSkillViews.test.js.map +1 -1
  121. package/build/__tests__/behavioral/errors/CreatingANewErrorBuilder.test.js.map +1 -1
  122. package/build/__tests__/behavioral/errors/KeepingErrorClassInSync.test.js.map +1 -1
  123. package/build/__tests__/behavioral/errors/KeepingErrorsInSync.test.js.map +1 -1
  124. package/build/__tests__/behavioral/errors/SettingUpErrors.test.js.map +1 -1
  125. package/build/__tests__/behavioral/eventContract/PullingMercuryEventContract.test.js.map +1 -1
  126. package/build/__tests__/behavioral/events/CreatingAListener.test.js.map +1 -1
  127. package/build/__tests__/behavioral/events/CreatingAnEvent.test.js.map +1 -1
  128. package/build/__tests__/behavioral/events/KeepingEventsInSync.test.js.map +1 -1
  129. package/build/__tests__/behavioral/events/KeepingEventsInSync2.test.js.map +1 -1
  130. package/build/__tests__/behavioral/events/KeepingListenersInSync.test.js.map +1 -1
  131. package/build/__tests__/behavioral/events/ListeningToAnEventYouCreate.test.js.map +1 -1
  132. package/build/__tests__/behavioral/events/SettingUpEvents.test.js.map +1 -1
  133. package/build/__tests__/behavioral/events/SkillEmitsBootEvents.test.js.map +1 -1
  134. package/build/__tests__/behavioral/node/CreatingANodeModule.test.js.map +1 -1
  135. package/build/__tests__/behavioral/onboard/StartingOnboarding.test.js.map +1 -1
  136. package/build/__tests__/behavioral/organization/CreatingAnOrg.test.js.map +1 -1
  137. package/build/__tests__/behavioral/person/LoggingInAsPerson.test.js.map +1 -1
  138. package/build/__tests__/behavioral/person/SeeWhoIsLoggedIn.test.js.map +1 -1
  139. package/build/__tests__/behavioral/schemas/CreatingANewSchemaBuilder.test.js.map +1 -1
  140. package/build/__tests__/behavioral/schemas/GeneratingFieldTypesOnly.test.js.map +1 -1
  141. package/build/__tests__/behavioral/schemas/GettingSchemasFromHealthCheck.test.js.map +1 -1
  142. package/build/__tests__/behavioral/schemas/HandlesRelatedSchemas.test.js.map +1 -1
  143. package/build/__tests__/behavioral/schemas/ImportingSchemaImports.test.js.map +1 -1
  144. package/build/__tests__/behavioral/schemas/KeepingSchemasInSync.test.js.map +1 -1
  145. package/build/__tests__/behavioral/schemas/SettingUpSchemas.test.js.map +1 -1
  146. package/build/__tests__/behavioral/schemas/SyncingBadSchemasProvidesHelpfulErrorMessages.test.js.map +1 -1
  147. package/build/__tests__/behavioral/schemas/UsingSchemasInCli.test.js.map +1 -1
  148. package/build/__tests__/behavioral/skill/BootingASkill.test.js.map +1 -1
  149. package/build/__tests__/behavioral/skill/CreatingASkill.test.js.map +1 -1
  150. package/build/__tests__/behavioral/skill/RegisteringASkill.test.js.map +1 -1
  151. package/build/__tests__/behavioral/skill/SettingUpASkill.test.js.map +1 -1
  152. package/build/__tests__/behavioral/stores/CreatingADataStore.test.js.map +1 -1
  153. package/build/__tests__/behavioral/stores/KeepingDataStoresInSync.test.js.map +1 -1
  154. package/build/__tests__/behavioral/tests/CreatingATest.test.js +3 -3
  155. package/build/__tests__/behavioral/tests/CreatingATest.test.js.map +1 -1
  156. package/build/__tests__/behavioral/tests/RunningTests.test.js.map +1 -1
  157. package/build/__tests__/behavioral/tests/SelectingAnAbstractTestClass.test.js.map +1 -1
  158. package/build/__tests__/behavioral/tests/SettingUpTests.test.js.map +1 -1
  159. package/build/__tests__/behavioral/upgrading/UpdatingDependencies.test.js.map +1 -1
  160. package/build/__tests__/behavioral/upgrading/UpdatingDependencies2.test.js.map +1 -1
  161. package/build/__tests__/behavioral/upgrading/UpgradingANodeModule.test.js.map +1 -1
  162. package/build/__tests__/behavioral/upgrading/UpgradingASkill.test.js.map +1 -1
  163. package/build/__tests__/behavioral/upgrading/UpgradingASkill2.test.js.map +1 -1
  164. package/build/__tests__/behavioral/upgrading/UpgradingASkill3.test.js.map +1 -1
  165. package/build/__tests__/behavioral/upgrading/UpgradingASkill4.test.js.map +1 -1
  166. package/build/__tests__/behavioral/upgrading/UpgradingASkill5.test.js.map +1 -1
  167. package/build/__tests__/behavioral/upgrading/UpgradingWithListeners.test.js.map +1 -1
  168. package/build/__tests__/behavioral/upgrading/UpgradingWithSandboxFeatureInstalled.test.js.map +1 -1
  169. package/build/__tests__/behavioral/views/CreatingASkillView.test.js +1 -1
  170. package/build/__tests__/behavioral/views/CreatingASkillView.test.js.map +1 -1
  171. package/build/__tests__/behavioral/views/CreatingATheme.test.js.map +1 -1
  172. package/build/__tests__/behavioral/views/KeepingViewsInSync.test.js.map +1 -1
  173. package/build/__tests__/behavioral/views/SettingUpViews.test.js.map +1 -1
  174. package/build/__tests__/behavioral/views/TestingViewControllers.test.js.map +1 -1
  175. package/build/__tests__/behavioral/watchers/WatchingForChanges.test.js.map +1 -1
  176. package/build/__tests__/implementation/ActionExecuter.test.js.map +1 -1
  177. package/build/__tests__/implementation/ActionExecuter2.test.js.map +1 -1
  178. package/build/__tests__/implementation/ActionExecuter3.test.js.map +1 -1
  179. package/build/__tests__/implementation/ActionExecuter4.test.js.map +1 -1
  180. package/build/__tests__/implementation/ArgParser.test.js.map +1 -1
  181. package/build/__tests__/implementation/BuildService.test.js.map +1 -1
  182. package/build/__tests__/implementation/BulkImporting.test.js.map +1 -1
  183. package/build/__tests__/implementation/CachingImports.test.js.map +1 -1
  184. package/build/__tests__/implementation/CommandOptionBuilder.test.js.map +1 -1
  185. package/build/__tests__/implementation/CommanderCommandResultMapper.test.js.map +1 -1
  186. package/build/__tests__/implementation/DataStoreStore.test.js.map +1 -1
  187. package/build/__tests__/implementation/DeletingOrphanedSchemaDefinitions.test.js.map +1 -1
  188. package/build/__tests__/implementation/EventContractCleanerUtil.test.js.map +1 -1
  189. package/build/__tests__/implementation/EventStore.test.js.map +1 -1
  190. package/build/__tests__/implementation/EventTemplateItemBuilder.test.js.map +1 -1
  191. package/build/__tests__/implementation/FeatureCommandAttacher.test.js.map +1 -1
  192. package/build/__tests__/implementation/FeatureFixture.test.js.map +1 -1
  193. package/build/__tests__/implementation/FeatureInstaller.test.js.map +1 -1
  194. package/build/__tests__/implementation/FeaturesUtil.test.js.map +1 -1
  195. package/build/__tests__/implementation/FieldTemplateItemBuilder.test.js.map +1 -1
  196. package/build/__tests__/implementation/GlobalEmitter.js.map +1 -1
  197. package/build/__tests__/implementation/Introspection.test.js.map +1 -1
  198. package/build/__tests__/implementation/JestJsonParser.test.js.map +1 -1
  199. package/build/__tests__/implementation/LintService.test.js.map +1 -1
  200. package/build/__tests__/implementation/ListenerStore.test.js.map +1 -1
  201. package/build/__tests__/implementation/OnboardingScriptLoader.test.js.map +1 -1
  202. package/build/__tests__/implementation/OnboardingScriptPlayer.test.js.map +1 -1
  203. package/build/__tests__/implementation/OnboardingStore.test.js.map +1 -1
  204. package/build/__tests__/implementation/OrganizationStore.test.js.map +1 -1
  205. package/build/__tests__/implementation/ParentTestFinder.test.js.map +1 -1
  206. package/build/__tests__/implementation/PkgService.test.js.map +1 -1
  207. package/build/__tests__/implementation/SchemaStore.test.js.map +1 -1
  208. package/build/__tests__/implementation/SchemaTemplateItemBuilder.test.js.map +1 -1
  209. package/build/__tests__/implementation/SchemaValueTypeWriter.test.js.map +1 -1
  210. package/build/__tests__/implementation/ServiceFactory.test.js.map +1 -1
  211. package/build/__tests__/implementation/SettingUpANodeModule.test.js.map +1 -1
  212. package/build/__tests__/implementation/SkillStore.test.js.map +1 -1
  213. package/build/__tests__/implementation/StoreFeature.test.js.map +1 -1
  214. package/build/__tests__/implementation/TestReporter.test.js.map +1 -1
  215. package/build/__tests__/implementation/TestRunner.test.js.map +1 -1
  216. package/build/__tests__/implementation/ValueTypeMapping.test.js.map +1 -1
  217. package/build/__tests__/implementation/Widgets.test.js.map +1 -1
  218. package/build/__tests__/support/scripts/first.script.js.map +1 -1
  219. package/build/addons/filePrompt.addon.js.map +1 -1
  220. package/build/cli.js.map +1 -1
  221. package/build/components/FormComponent.js.map +1 -1
  222. package/build/components/QuizComponent.js.map +1 -1
  223. package/build/errors/SpruceError.js.map +1 -1
  224. package/build/errors/actionCancelled.builder.js.map +1 -1
  225. package/build/errors/bootError.builder.js.map +1 -1
  226. package/build/errors/buildFailed.builder.js.map +1 -1
  227. package/build/errors/cacheNotEnabled.builder.js.map +1 -1
  228. package/build/errors/commandAborted.builder.js.map +1 -1
  229. package/build/errors/commandBlocked.builder.js.map +1 -1
  230. package/build/errors/commandNotImplemented.builder.js.map +1 -1
  231. package/build/errors/createAutoloaderFailed.builder.js.map +1 -1
  232. package/build/errors/dependencyExists.builder.js.map +1 -1
  233. package/build/errors/deployFailed.builder.js.map +1 -1
  234. package/build/errors/directoryEmpty.builder.js.map +1 -1
  235. package/build/errors/directoryNotSkill.builder.js.map +1 -1
  236. package/build/errors/dockerNotStarted.builder.js.map +1 -1
  237. package/build/errors/executingCommandFailed.builder.js.map +1 -1
  238. package/build/errors/failedToImport.builder.js.map +1 -1
  239. package/build/errors/featureNotInstalled.builder.js.map +1 -1
  240. package/build/errors/fileExists.builder.js.map +1 -1
  241. package/build/errors/generic.builder.js.map +1 -1
  242. package/build/errors/invalidCommand.builder.js.map +1 -1
  243. package/build/errors/invalidEventContract.builder.js.map +1 -1
  244. package/build/errors/invalidFeatureCode.builder.js.map +1 -1
  245. package/build/errors/invalidTestDirectory.builder.js.map +1 -1
  246. package/build/errors/lintFailed.builder.js.map +1 -1
  247. package/build/errors/mercuryResponseError.builder.js.map +1 -1
  248. package/build/errors/missingDependencies.builder.js.map +1 -1
  249. package/build/errors/noOrganizationsFound.builder.js.map +1 -1
  250. package/build/errors/noSkillsRegistered.builder.js.map +1 -1
  251. package/build/errors/notImplemented.builder.js.map +1 -1
  252. package/build/errors/notLoggedIn.builder.js.map +1 -1
  253. package/build/errors/schemaExists.builder.js.map +1 -1
  254. package/build/errors/schemaFailedToImport.builder.js.map +1 -1
  255. package/build/errors/schemaTemplateItemBuildingFailed.builder.js.map +1 -1
  256. package/build/errors/skillNotFound.builder.js.map +1 -1
  257. package/build/errors/skillNotRegistered.builder.js.map +1 -1
  258. package/build/errors/skillViewExists.builder.js.map +1 -1
  259. package/build/errors/storeExists.builder.js.map +1 -1
  260. package/build/errors/testFailed.builder.js.map +1 -1
  261. package/build/errors/themeExists.builder.js.map +1 -1
  262. package/build/errors/transportAlreadyExists.builder.js.map +1 -1
  263. package/build/errors/vscodeNotInstalled.builder.js.map +1 -1
  264. package/build/features/AbstractAction.d.ts +1 -1
  265. package/build/features/AbstractAction.js.map +1 -1
  266. package/build/features/AbstractFeature.js.map +1 -1
  267. package/build/features/ActionExecuter.js.map +1 -1
  268. package/build/features/ActionFactory.js.map +1 -1
  269. package/build/features/ActionQuestionAsker.js.map +1 -1
  270. package/build/features/FeatureCommandAttacher.js.map +1 -1
  271. package/build/features/FeatureInstaller.js.map +1 -1
  272. package/build/features/OverrideActionDecorator.js.map +1 -1
  273. package/build/features/cache/CacheFeature.js.map +1 -1
  274. package/build/features/cache/actions/DisableAction.js.map +1 -1
  275. package/build/features/cache/actions/EnableAction.js.map +1 -1
  276. package/build/features/conversation/ConversationFeature.js.map +1 -1
  277. package/build/features/conversation/actions/TestAction.js.map +1 -1
  278. package/build/features/conversation/stores/ConversationStore.js.map +1 -1
  279. package/build/features/conversation/writers/ConversationWriter.js.map +1 -1
  280. package/build/features/dependencies/DependencyFeature.js.map +1 -1
  281. package/build/features/dependencies/actions/AddAction.js.map +1 -1
  282. package/build/features/dependencies/actions/ManageAction.js.map +1 -1
  283. package/build/features/deploy/DeployFeature.js.map +1 -1
  284. package/build/features/deploy/actions/HerokuAction.js.map +1 -1
  285. package/build/features/deploy/writers/DeployWriter.js.map +1 -1
  286. package/build/features/error/ErrorFeature.js.map +1 -1
  287. package/build/features/error/ParentTestFinder.js.map +1 -1
  288. package/build/features/error/actions/CreateAction.js.map +1 -1
  289. package/build/features/error/actions/SyncAction.js.map +1 -1
  290. package/build/features/error/writers/ErrorWriter.js.map +1 -1
  291. package/build/features/event/EventFeature.js.map +1 -1
  292. package/build/features/event/actions/CreateAction.js.map +1 -1
  293. package/build/features/event/actions/ListenAction.js.map +1 -1
  294. package/build/features/event/actions/SetRemoteAction.js.map +1 -1
  295. package/build/features/event/actions/SyncAction.js.map +1 -1
  296. package/build/features/event/actions/SyncListenersAction.js.map +1 -1
  297. package/build/features/event/builders/EventContractBuilder.js.map +1 -1
  298. package/build/features/event/builders/ListenerTemplateItemBuilder.js.map +1 -1
  299. package/build/features/event/stores/EventStore.js.map +1 -1
  300. package/build/features/event/stores/ListenerStore.js.map +1 -1
  301. package/build/features/event/writers/EventWriter.js.map +1 -1
  302. package/build/features/eventContract/EventContractFeature.js.map +1 -1
  303. package/build/features/eventContract/actions/PullAction.js.map +1 -1
  304. package/build/features/feature.utilities.js.map +1 -1
  305. package/build/features/features.types.js.map +1 -1
  306. package/build/features/log/LogFeature.js.map +1 -1
  307. package/build/features/log/actions/CreateTransportAction.js.map +1 -1
  308. package/build/features/log/writers/LogWriter.js.map +1 -1
  309. package/build/features/node/NodeFeature.js.map +1 -1
  310. package/build/features/node/actions/UpdateDependenciesAction.js.map +1 -1
  311. package/build/features/node/actions/UpgradeAction.js.map +1 -1
  312. package/build/features/node/writers/NodeWriter.js.map +1 -1
  313. package/build/features/onboard/OnboardFeature.js.map +1 -1
  314. package/build/features/onboard/ScriptLoader.js.map +1 -1
  315. package/build/features/onboard/scripts/onboarding.first.script.js.map +1 -1
  316. package/build/features/onboard/scripts/onboarding.immersive.script.js.map +1 -1
  317. package/build/features/onboard/scripts/onboarding.returning.script.js.map +1 -1
  318. package/build/features/onboard/scripts/onboarding.short.script.js.map +1 -1
  319. package/build/features/onboard/scripts/wrongCommand.script.js.map +1 -1
  320. package/build/features/onboard/stores/OnboardingStore.js.map +1 -1
  321. package/build/features/organization/OrganizationFeature.js.map +1 -1
  322. package/build/features/organization/stores/OrganizationStore.js.map +1 -1
  323. package/build/features/person/PersonFeature.js.map +1 -1
  324. package/build/features/person/actions/LoginAction.js.map +1 -1
  325. package/build/features/person/actions/LogoutAction.js.map +1 -1
  326. package/build/features/person/actions/WhoamiAction.js.map +1 -1
  327. package/build/features/sandbox/SandboxFeature.js.map +1 -1
  328. package/build/features/sandbox/actions/SetupAction.js.map +1 -1
  329. package/build/features/sandbox/writers/SandboxWriter.js.map +1 -1
  330. package/build/features/schema/SchemaFeature.js.map +1 -1
  331. package/build/features/schema/ValueTypeBuilder.js.map +1 -1
  332. package/build/features/schema/actions/CreateAction.js.map +1 -1
  333. package/build/features/schema/actions/SyncAction.js.map +1 -1
  334. package/build/features/schema/actions/SyncFieldsAction.js.map +1 -1
  335. package/build/features/schema/services/SchemaService.js.map +1 -1
  336. package/build/features/schema/stores/SchemaStore.d.ts +2 -1
  337. package/build/features/schema/stores/SchemaStore.js +2 -1
  338. package/build/features/schema/stores/SchemaStore.js.map +1 -1
  339. package/build/features/schema/utilities/schema.utility.js.map +1 -1
  340. package/build/features/schema/utilities/schemaDisk.utility.js.map +1 -1
  341. package/build/features/schema/utilities/schemaGenerator.utility.js.map +1 -1
  342. package/build/features/schema/writers/SchemaWriter.js.map +1 -1
  343. package/build/features/skill/SkillFeature.js.map +1 -1
  344. package/build/features/skill/actions/BootAction.js.map +1 -1
  345. package/build/features/skill/actions/CreateAction.js.map +1 -1
  346. package/build/features/skill/actions/DashboardAction.js.map +1 -1
  347. package/build/features/skill/actions/LoginAction.js.map +1 -1
  348. package/build/features/skill/actions/RebuildAction.js.map +1 -1
  349. package/build/features/skill/actions/RegisterAction.js.map +1 -1
  350. package/build/features/skill/stores/SkillStore.js.map +1 -1
  351. package/build/features/skill/updaters/Updater.js.map +1 -1
  352. package/build/features/skill/writers/SkillWriter.js.map +1 -1
  353. package/build/features/store/StoreFeature.js.map +1 -1
  354. package/build/features/store/actions/CreateAction.js.map +1 -1
  355. package/build/features/store/actions/SyncAction.js.map +1 -1
  356. package/build/features/store/stores/StoreStore.js.map +1 -1
  357. package/build/features/store/templateItemBuilders/StoreTemplateItemBuilder.js.map +1 -1
  358. package/build/features/store/writers/StoreWriter.js.map +1 -1
  359. package/build/features/test/TestFeature.js.map +1 -1
  360. package/build/features/test/TestLogItemGenerator.js.map +1 -1
  361. package/build/features/test/TestReporter.js.map +1 -1
  362. package/build/features/test/TestRunner.js.map +1 -1
  363. package/build/features/test/actions/CreateAction.js.map +1 -1
  364. package/build/features/test/actions/SetupAction.js.map +1 -1
  365. package/build/features/test/actions/TestAction.js.map +1 -1
  366. package/build/features/test/writers/TestWriter.js.map +1 -1
  367. package/build/features/validateAndNormalize.utility.js.map +1 -1
  368. package/build/features/view/ViewFeature.js.map +1 -1
  369. package/build/features/view/actions/CreateAction.js.map +1 -1
  370. package/build/features/view/actions/CreateThemeAction.js.map +1 -1
  371. package/build/features/view/actions/SyncAction.js.map +1 -1
  372. package/build/features/view/actions/WatchAction.js.map +1 -1
  373. package/build/features/view/stores/ViewStore.js.map +1 -1
  374. package/build/features/view/writers/ViewWriter.js.map +1 -1
  375. package/build/features/vscode/VsCodeFeature.js.map +1 -1
  376. package/build/features/vscode/services/VsCodeService.js.map +1 -1
  377. package/build/features/vscode/writers/VsCodeWriter.js.map +1 -1
  378. package/build/features/watch/WatchFeature.js.map +1 -1
  379. package/build/index.js.map +1 -1
  380. package/build/interfaces/SpyInterface.js +0 -1
  381. package/build/interfaces/SpyInterface.js.map +1 -1
  382. package/build/interfaces/TerminalInterface.js.map +1 -1
  383. package/build/schemas/v2020_07_22/bootSkillOptions.builder.js.map +1 -1
  384. package/build/schemas/v2020_07_22/createConversationTopicOptions.builder.js.map +1 -1
  385. package/build/schemas/v2020_07_22/createErrorOptions.builder.js.map +1 -1
  386. package/build/schemas/v2020_07_22/createOrganizationOptions.builder.js.map +1 -1
  387. package/build/schemas/v2020_07_22/createSchemaOptions.builder.js.map +1 -1
  388. package/build/schemas/v2020_07_22/createTestOptions.builder.js.map +1 -1
  389. package/build/schemas/v2020_07_22/installSkillAtOrganizationOptions.builder.js.map +1 -1
  390. package/build/schemas/v2020_07_22/listenEventOptions.builder.js.map +1 -1
  391. package/build/schemas/v2020_07_22/namedTemplateItem.builder.js.map +1 -1
  392. package/build/schemas/v2020_07_22/nodeFeatureOptions.builder.js.map +1 -1
  393. package/build/schemas/v2020_07_22/onboardOptions.builder.js.map +1 -1
  394. package/build/schemas/v2020_07_22/onboarding.builder.js.map +1 -1
  395. package/build/schemas/v2020_07_22/personWithToken.builder.js.map +1 -1
  396. package/build/schemas/v2020_07_22/registerDashboardWidgetsEmitPayloadSchema.builder.js.map +1 -1
  397. package/build/schemas/v2020_07_22/setupTestsOptions.builder.js.map +1 -1
  398. package/build/schemas/v2020_07_22/setupVscodeOptions.builder.js.map +1 -1
  399. package/build/schemas/v2020_07_22/skillFeature.builder.js.map +1 -1
  400. package/build/schemas/v2020_07_22/syncErrorOptions.builder.js.map +1 -1
  401. package/build/schemas/v2020_07_22/syncEventOptions.builder.js.map +1 -1
  402. package/build/schemas/v2020_07_22/syncSchemaFieldsOptions.builder.js.map +1 -1
  403. package/build/schemas/v2020_07_22/syncSchemasOptions.builder.js.map +1 -1
  404. package/build/schemas/v2020_07_22/testOptions.builder.js.map +1 -1
  405. package/build/schemas/v2020_07_22/upgradeSkillOptions.builder.js.map +1 -1
  406. package/build/schemas/v2020_07_22/watcherDidDetectChangesEmitPayload.builder.js.map +1 -1
  407. package/build/services/CommandService.d.ts +1 -0
  408. package/build/services/CommandService.js.map +1 -1
  409. package/build/services/GameService.js.map +1 -1
  410. package/build/services/ImportService.js.map +1 -1
  411. package/build/services/LintService.js.map +1 -1
  412. package/build/services/PkgService.js.map +1 -1
  413. package/build/services/ServiceFactory.js.map +1 -1
  414. package/build/templateItemBuilders/EventTemplateItemBuilder.js.map +1 -1
  415. package/build/templateItemBuilders/FieldTemplateItemBuilder.js.map +1 -1
  416. package/build/templateItemBuilders/SchemaTemplateItemBuilder.js.map +1 -1
  417. package/build/tests/AbstractCliTest.js.map +1 -1
  418. package/build/tests/AbstractEventTest.js.map +1 -1
  419. package/build/tests/AbstractSchemaTest.js.map +1 -1
  420. package/build/tests/AbstractTestTest.js.map +1 -1
  421. package/build/tests/CommandFaker.js.map +1 -1
  422. package/build/tests/JestJsonParser.js.map +1 -1
  423. package/build/tests/buildTestCache.js.map +1 -1
  424. package/build/tests/cleanTestCache.js.map +1 -1
  425. package/build/tests/cleanTestData.js.map +1 -1
  426. package/build/tests/fixtures/FeatureFixture.js.map +1 -1
  427. package/build/tests/fixtures/MercuryFixture.js.map +1 -1
  428. package/build/tests/fixtures/PersonFixture.js.map +1 -1
  429. package/build/tests/fixtures/SkillFixture.js.map +1 -1
  430. package/build/tests/utilities/test.utility.js.map +1 -1
  431. package/build/tests/utilities/uiAssert.utility.js.map +1 -1
  432. package/build/utilities/action.utility.js.map +1 -1
  433. package/build/utilities/apiClient.utility.d.ts +1 -1
  434. package/build/utilities/commander.utility.js.map +1 -1
  435. package/build/utilities/eventContractCleaner.utility.js.map +1 -1
  436. package/build/utilities/form.utility.js.map +1 -1
  437. package/build/utilities/introspection.utility.js.map +1 -1
  438. package/build/utilities/tsConfig.utility.js.map +1 -1
  439. package/build/widgets/Theme.js.map +1 -1
  440. package/build/widgets/WidgetFactory.js.map +1 -1
  441. package/build/widgets/terminalKit/TKButtonWidget.js.map +1 -1
  442. package/build/widgets/terminalKit/TkInputWidget.js.map +1 -1
  443. package/build/widgets/terminalKit/TkLayoutWidget.js.map +1 -1
  444. package/build/widgets/terminalKit/TkMenuBarWidget.js.map +1 -1
  445. package/build/widgets/terminalKit/TkPopupWidget.js.map +1 -1
  446. package/build/widgets/terminalKit/TkTextWidget.js.map +1 -1
  447. package/build/widgets/terminalKit/termKit.utility.d.ts +1 -1
  448. package/build/widgets/terminalKit/termKit.utility.js.map +1 -1
  449. package/build/widgets/types/input.types.js.map +1 -1
  450. package/build/widgets/types/menuBar.types.js.map +1 -1
  451. package/build/widgets/types/text.types.js.map +1 -1
  452. package/build/widgets/types/window.types.js.map +1 -1
  453. package/build/widgets/widget.utilities.d.ts +1 -1
  454. package/build/writers/AbstractWriter.js.map +1 -1
  455. package/package.json +36 -36
  456. package/src/__tests__/behavioral/views/CreatingASkillView.test.ts +3 -2
  457. package/src/features/schema/stores/SchemaStore.ts +4 -2
  458. package/build/.spruce/schemas/spruce/v2020_07_22/fullMessageChoices.schema.d.ts +0 -1
  459. package/build/.spruce/schemas/spruce/v2020_07_22/fullMessageChoices.schema.js +0 -14
  460. package/build/.spruce/schemas/spruce/v2020_07_22/fullMessageChoices.schema.js.map +0 -1
  461. package/src/.spruce/schemas/spruce/v2020_07_22/fullMessageChoices.schema.ts +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"CommandService.js","names":["process","setMaxListeners","CommandService","cwd","activeChildProcess","pid","ignoreCloseErrors","cmd","options","args","executable","shift","boundKill","kill","bind","Error","getMockResponse","mockResponse","mockKey","commandsRunCapturedByMockResponses","push","callback","code","SpruceError","join","stdout","stderr","on","Promise","resolve","reject","spawnOptions","shouldStream","stdio","env","PATH","IS_CLI","FORCE_COLOR","forceColor","shell","child","outStream","pipe","addListener","data","onData","toString","onError","closeHandler","off","undefined","setTimeout","removeAllListeners","ignoreErrors","search","ERROR_DIVIDER","stderrParts","split","err","AbstractSpruceError","parse","trim","commands","mockResponses","match","find","r","command","RegExp","replace","response","unshift"],"sources":["../../src/services/CommandService.ts"],"sourcesContent":["import { spawn, SpawnOptions, ChildProcess } from 'child_process'\nimport { Writable } from 'stream'\nimport AbstractSpruceError from '@sprucelabs/error'\nimport { ERROR_DIVIDER } from '@sprucelabs/spruce-skill-utils'\nimport escapeRegExp from 'lodash/escapeRegExp'\nimport stringArgv from 'string-argv'\nimport treeKill from 'tree-kill'\nimport SpruceError from '../errors/SpruceError'\n\nprocess.setMaxListeners(100)\n\ninterface MockResponse {\n\tcode: number\n\tstdout?: string\n\tstderr?: string\n\tcallback?: (executable: string, args: any[]) => void\n}\n\nexport default class CommandService {\n\tpublic cwd: string\n\tprivate activeChildProcess: ChildProcess | undefined\n\tprivate ignoreCloseErrors = false\n\tprivate static mockResponses: {\n\t\tcommand: string | RegExp\n\t\tresponse: MockResponse\n\t}[] = []\n\tprivate static commandsRunCapturedByMockResponses: string[] = []\n\n\tpublic constructor(cwd: string) {\n\t\tthis.cwd = cwd\n\t}\n\n\tpublic async execute(\n\t\tcmd: string,\n\t\toptions?: {\n\t\t\tignoreErrors?: boolean\n\t\t\targs?: string[]\n\t\t\tshouldStream?: boolean\n\t\t\toutStream?: Writable\n\t\t\tonError?: (error: string) => void\n\t\t\tonData?: (data: string) => void\n\t\t\tspawnOptions?: SpawnOptions\n\t\t\tforceColor?: boolean\n\t\t\tenv?: Record<string, any>\n\t\t}\n\t): Promise<{\n\t\tstdout: string\n\t}> {\n\t\tconst cwd = this.cwd\n\t\tconst args = options?.args || stringArgv(cmd)\n\t\tconst executable = options?.args ? cmd : args.shift()\n\t\tconst boundKill = this.kill.bind(this)\n\n\t\tif (!executable) {\n\t\t\tthrow new Error('Bad params sent to command service')\n\t\t}\n\n\t\tconst { mockResponse, mockKey } = this.getMockResponse(executable, args)\n\n\t\tif (mockResponse) {\n\t\t\tCommandService.commandsRunCapturedByMockResponses.push(mockKey)\n\t\t\tmockResponse.callback?.(executable, args)\n\n\t\t\tif (mockResponse.code !== 0) {\n\t\t\t\tthrow new SpruceError({\n\t\t\t\t\tcode: 'EXECUTING_COMMAND_FAILED',\n\t\t\t\t\tcmd: `${executable} ${args.join(' ')}`,\n\t\t\t\t\tcwd,\n\t\t\t\t\tstdout: mockResponse.stdout,\n\t\t\t\t\tstderr: mockResponse.stderr,\n\t\t\t\t})\n\t\t\t}\n\n\t\t\treturn { stdout: mockResponse.stdout ?? '' }\n\t\t}\n\n\t\tprocess.on('exit', boundKill)\n\n\t\treturn new Promise((resolve, reject) => {\n\t\t\tlet stdout = ''\n\t\t\tlet stderr = ''\n\t\t\tconst spawnOptions: SpawnOptions = options?.shouldStream\n\t\t\t\t? {\n\t\t\t\t\t\tstdio: 'inherit',\n\t\t\t\t\t\tcwd,\n\t\t\t\t\t\tenv: {\n\t\t\t\t\t\t\tPATH: process.env.PATH,\n\t\t\t\t\t\t\tIS_CLI: 'true',\n\t\t\t\t\t\t\tFORCE_COLOR: options?.forceColor ? '1' : '0',\n\t\t\t\t\t\t\t...options?.env,\n\t\t\t\t\t\t},\n\t\t\t\t }\n\t\t\t\t: {\n\t\t\t\t\t\tcwd,\n\t\t\t\t\t\tenv: {\n\t\t\t\t\t\t\tPATH: process.env.PATH,\n\t\t\t\t\t\t\tIS_CLI: 'true',\n\t\t\t\t\t\t\tFORCE_COLOR: options?.forceColor ? '1' : '0',\n\t\t\t\t\t\t\t...options?.env,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tshell: true,\n\t\t\t\t\t\t...options?.spawnOptions,\n\t\t\t\t }\n\n\t\t\tconst child = spawn(executable, args, spawnOptions)\n\t\t\tthis.activeChildProcess = child\n\n\t\t\tif (options?.outStream) {\n\t\t\t\tchild.stdout?.pipe(options.outStream)\n\t\t\t}\n\n\t\t\tchild.stdout?.addListener('data', (data) => {\n\t\t\t\toptions?.onData?.(data.toString())\n\t\t\t\tstdout += data\n\t\t\t})\n\n\t\t\tchild.stderr?.addListener('data', (data) => {\n\t\t\t\toptions?.onError?.(data.toString())\n\t\t\t\tstderr += data\n\t\t\t})\n\n\t\t\tconst closeHandler = (code: number) => {\n\t\t\t\tprocess.off('exit', boundKill)\n\n\t\t\t\tif (!this.activeChildProcess) {\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tthis.activeChildProcess = undefined\n\n\t\t\t\tsetTimeout(() => {\n\t\t\t\t\tchild.stdout?.removeAllListeners()\n\t\t\t\t\tchild.stderr?.removeAllListeners()\n\t\t\t\t\tchild.removeAllListeners()\n\n\t\t\t\t\tif (code === 0 || this.ignoreCloseErrors || options?.ignoreErrors) {\n\t\t\t\t\t\tresolve({ stdout })\n\t\t\t\t\t\tthis.ignoreCloseErrors = false\n\t\t\t\t\t} else {\n\t\t\t\t\t\tif (stderr.search(escapeRegExp(ERROR_DIVIDER)) > -1) {\n\t\t\t\t\t\t\tconst stderrParts = stderr.split(ERROR_DIVIDER)\n\t\t\t\t\t\t\tconst err = AbstractSpruceError.parse(stderrParts[1], SpruceError)\n\t\t\t\t\t\t\treject(err)\n\t\t\t\t\t\t\treturn\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\treject(\n\t\t\t\t\t\t\tnew SpruceError({\n\t\t\t\t\t\t\t\tcode: 'EXECUTING_COMMAND_FAILED',\n\t\t\t\t\t\t\t\tcmd: `${executable} ${args.join(' ')}`,\n\t\t\t\t\t\t\t\tcwd,\n\t\t\t\t\t\t\t\tstdout,\n\t\t\t\t\t\t\t\tstderr,\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}, 0)\n\t\t\t}\n\n\t\t\tchild.addListener('close', closeHandler)\n\t\t\tchild.addListener('exit', closeHandler)\n\t\t})\n\t}\n\n\tpublic kill = () => {\n\t\tif (this.activeChildProcess?.pid) {\n\t\t\tthis.ignoreCloseErrors = true\n\t\t\ttreeKill(this.activeChildProcess.pid, 'SIGTERM')\n\t\t}\n\t}\n\n\tpublic pid = () => {\n\t\treturn this.activeChildProcess?.pid\n\t}\n\n\tprivate getMockResponse(executable: string, args: string[]) {\n\t\tconst mockKey = `${executable} ${args.join(' ')}`.trim()\n\t\tconst commands = CommandService.mockResponses\n\t\tconst match = commands.find((r) =>\n\t\t\tr.command instanceof RegExp\n\t\t\t\t? mockKey.search(r.command) > -1\n\t\t\t\t: r.command.replace(/ +/gis, '') === mockKey.replace(/ +/gis, '')\n\t\t)\n\n\t\treturn { mockResponse: match?.response, mockKey }\n\t}\n\n\tpublic static fakeCommand(command: string | RegExp, response: MockResponse) {\n\t\tthis.mockResponses.unshift({\n\t\t\tcommand,\n\t\t\tresponse,\n\t\t})\n\t}\n\n\tpublic static clearMockResponses() {\n\t\tthis.mockResponses = []\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;AAEAA,OAAO,CAACC,eAAR,CAAwB,GAAxB;;IASqBC,c;EAUpB,wBAAmBC,GAAnB,EAAgC;IAAA;;IAAA;IAAA;IAAA;IAAA,4DAPJ,KAOI;IAAA,+CAuIlB,YAAM;MAAA;;MACnB,6BAAI,KAAI,CAACC,kBAAT,kDAAI,sBAAyBC,GAA7B,EAAkC;QACjC,KAAI,CAACC,iBAAL,GAAyB,IAAzB;QACA,0BAAS,KAAI,CAACF,kBAAL,CAAwBC,GAAjC,EAAsC,SAAtC;MACA;IACD,CA5I+B;IAAA,8CA8InB,YAAM;MAAA;;MAClB,iCAAO,KAAI,CAACD,kBAAZ,2DAAO,uBAAyBC,GAAhC;IACA,CAhJ+B;IAC/B,KAAKF,GAAL,GAAWA,GAAX;EACA;;;;;mGAED,iBACCI,GADD,EAECC,OAFD;QAAA;;QAAA;;QAAA;UAAA;YAAA;cAAA;gBAgBOL,GAhBP,GAgBa,KAAKA,GAhBlB;gBAiBOM,IAjBP,GAiBc,CAAAD,OAAO,SAAP,IAAAA,OAAO,WAAP,YAAAA,OAAO,CAAEC,IAAT,KAAiB,4BAAWF,GAAX,CAjB/B;gBAkBOG,UAlBP,GAkBoBF,OAAO,SAAP,IAAAA,OAAO,WAAP,IAAAA,OAAO,CAAEC,IAAT,GAAgBF,GAAhB,GAAsBE,IAAI,CAACE,KAAL,EAlB1C;gBAmBOC,SAnBP,GAmBmB,KAAKC,IAAL,CAAUC,IAAV,CAAe,IAAf,CAnBnB;;gBAAA,IAqBMJ,UArBN;kBAAA;kBAAA;gBAAA;;g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AF0B,CAA3B;IAIA;;;WAED,8BAAmC;MAClC,KAAKP,aAAL,GAAqB,EAArB;IACA;;;;;;iCAjLmB7D,c,mBAOd,E;iCAPcA,c,wCAQ0C,E"}
1
+ {"version":3,"file":"CommandService.js","names":["process","setMaxListeners","CommandService","cwd","activeChildProcess","pid","ignoreCloseErrors","treeKill","cmd","options","args","stringArgv","executable","shift","boundKill","kill","bind","Error","getMockResponse","mockResponse","mockKey","commandsRunCapturedByMockResponses","push","callback","code","SpruceError","join","stdout","stderr","on","Promise","resolve","reject","spawnOptions","shouldStream","stdio","env","PATH","IS_CLI","FORCE_COLOR","forceColor","shell","child","spawn","outStream","pipe","addListener","data","onData","toString","onError","closeHandler","off","undefined","setTimeout","removeAllListeners","ignoreErrors","search","escapeRegExp","ERROR_DIVIDER","stderrParts","split","err","AbstractSpruceError","parse","trim","commands","mockResponses","match","find","r","command","RegExp","replace","response","unshift"],"sources":["../../src/services/CommandService.ts"],"sourcesContent":["import { spawn, SpawnOptions, ChildProcess } from 'child_process'\nimport { Writable } from 'stream'\nimport AbstractSpruceError from '@sprucelabs/error'\nimport { ERROR_DIVIDER } from '@sprucelabs/spruce-skill-utils'\nimport escapeRegExp from 'lodash/escapeRegExp'\nimport stringArgv from 'string-argv'\nimport treeKill from 'tree-kill'\nimport SpruceError from '../errors/SpruceError'\n\nprocess.setMaxListeners(100)\n\ninterface MockResponse {\n\tcode: number\n\tstdout?: string\n\tstderr?: string\n\tcallback?: (executable: string, args: any[]) => void\n}\n\nexport default class CommandService {\n\tpublic cwd: string\n\tprivate activeChildProcess: ChildProcess | undefined\n\tprivate ignoreCloseErrors = false\n\tprivate static mockResponses: {\n\t\tcommand: string | RegExp\n\t\tresponse: MockResponse\n\t}[] = []\n\tprivate static commandsRunCapturedByMockResponses: string[] = []\n\n\tpublic constructor(cwd: string) {\n\t\tthis.cwd = cwd\n\t}\n\n\tpublic async execute(\n\t\tcmd: string,\n\t\toptions?: {\n\t\t\tignoreErrors?: boolean\n\t\t\targs?: string[]\n\t\t\tshouldStream?: boolean\n\t\t\toutStream?: Writable\n\t\t\tonError?: (error: string) => void\n\t\t\tonData?: (data: string) => void\n\t\t\tspawnOptions?: SpawnOptions\n\t\t\tforceColor?: boolean\n\t\t\tenv?: Record<string, any>\n\t\t}\n\t): Promise<{\n\t\tstdout: string\n\t}> {\n\t\tconst cwd = this.cwd\n\t\tconst args = options?.args || stringArgv(cmd)\n\t\tconst executable = options?.args ? cmd : args.shift()\n\t\tconst boundKill = this.kill.bind(this)\n\n\t\tif (!executable) {\n\t\t\tthrow new Error('Bad params sent to command service')\n\t\t}\n\n\t\tconst { mockResponse, mockKey } = this.getMockResponse(executable, args)\n\n\t\tif (mockResponse) {\n\t\t\tCommandService.commandsRunCapturedByMockResponses.push(mockKey)\n\t\t\tmockResponse.callback?.(executable, args)\n\n\t\t\tif (mockResponse.code !== 0) {\n\t\t\t\tthrow new SpruceError({\n\t\t\t\t\tcode: 'EXECUTING_COMMAND_FAILED',\n\t\t\t\t\tcmd: `${executable} ${args.join(' ')}`,\n\t\t\t\t\tcwd,\n\t\t\t\t\tstdout: mockResponse.stdout,\n\t\t\t\t\tstderr: mockResponse.stderr,\n\t\t\t\t})\n\t\t\t}\n\n\t\t\treturn { stdout: mockResponse.stdout ?? '' }\n\t\t}\n\n\t\tprocess.on('exit', boundKill)\n\n\t\treturn new Promise((resolve, reject) => {\n\t\t\tlet stdout = ''\n\t\t\tlet stderr = ''\n\t\t\tconst spawnOptions: SpawnOptions = options?.shouldStream\n\t\t\t\t? {\n\t\t\t\t\t\tstdio: 'inherit',\n\t\t\t\t\t\tcwd,\n\t\t\t\t\t\tenv: {\n\t\t\t\t\t\t\tPATH: process.env.PATH,\n\t\t\t\t\t\t\tIS_CLI: 'true',\n\t\t\t\t\t\t\tFORCE_COLOR: options?.forceColor ? '1' : '0',\n\t\t\t\t\t\t\t...options?.env,\n\t\t\t\t\t\t},\n\t\t\t\t }\n\t\t\t\t: {\n\t\t\t\t\t\tcwd,\n\t\t\t\t\t\tenv: {\n\t\t\t\t\t\t\tPATH: process.env.PATH,\n\t\t\t\t\t\t\tIS_CLI: 'true',\n\t\t\t\t\t\t\tFORCE_COLOR: options?.forceColor ? '1' : '0',\n\t\t\t\t\t\t\t...options?.env,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tshell: true,\n\t\t\t\t\t\t...options?.spawnOptions,\n\t\t\t\t }\n\n\t\t\tconst child = spawn(executable, args, spawnOptions)\n\t\t\tthis.activeChildProcess = child\n\n\t\t\tif (options?.outStream) {\n\t\t\t\tchild.stdout?.pipe(options.outStream)\n\t\t\t}\n\n\t\t\tchild.stdout?.addListener('data', (data) => {\n\t\t\t\toptions?.onData?.(data.toString())\n\t\t\t\tstdout += data\n\t\t\t})\n\n\t\t\tchild.stderr?.addListener('data', (data) => {\n\t\t\t\toptions?.onError?.(data.toString())\n\t\t\t\tstderr += data\n\t\t\t})\n\n\t\t\tconst closeHandler = (code: number) => {\n\t\t\t\tprocess.off('exit', boundKill)\n\n\t\t\t\tif (!this.activeChildProcess) {\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tthis.activeChildProcess = undefined\n\n\t\t\t\tsetTimeout(() => {\n\t\t\t\t\tchild.stdout?.removeAllListeners()\n\t\t\t\t\tchild.stderr?.removeAllListeners()\n\t\t\t\t\tchild.removeAllListeners()\n\n\t\t\t\t\tif (code === 0 || this.ignoreCloseErrors || options?.ignoreErrors) {\n\t\t\t\t\t\tresolve({ stdout })\n\t\t\t\t\t\tthis.ignoreCloseErrors = false\n\t\t\t\t\t} else {\n\t\t\t\t\t\tif (stderr.search(escapeRegExp(ERROR_DIVIDER)) > -1) {\n\t\t\t\t\t\t\tconst stderrParts = stderr.split(ERROR_DIVIDER)\n\t\t\t\t\t\t\tconst err = AbstractSpruceError.parse(stderrParts[1], SpruceError)\n\t\t\t\t\t\t\treject(err)\n\t\t\t\t\t\t\treturn\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\treject(\n\t\t\t\t\t\t\tnew SpruceError({\n\t\t\t\t\t\t\t\tcode: 'EXECUTING_COMMAND_FAILED',\n\t\t\t\t\t\t\t\tcmd: `${executable} ${args.join(' ')}`,\n\t\t\t\t\t\t\t\tcwd,\n\t\t\t\t\t\t\t\tstdout,\n\t\t\t\t\t\t\t\tstderr,\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}, 0)\n\t\t\t}\n\n\t\t\tchild.addListener('close', closeHandler)\n\t\t\tchild.addListener('exit', closeHandler)\n\t\t})\n\t}\n\n\tpublic kill = () => {\n\t\tif (this.activeChildProcess?.pid) {\n\t\t\tthis.ignoreCloseErrors = true\n\t\t\ttreeKill(this.activeChildProcess.pid, 'SIGTERM')\n\t\t}\n\t}\n\n\tpublic pid = () => {\n\t\treturn this.activeChildProcess?.pid\n\t}\n\n\tprivate getMockResponse(executable: string, args: string[]) {\n\t\tconst mockKey = `${executable} ${args.join(' ')}`.trim()\n\t\tconst commands = CommandService.mockResponses\n\t\tconst match = commands.find((r) =>\n\t\t\tr.command instanceof RegExp\n\t\t\t\t? mockKey.search(r.command) > -1\n\t\t\t\t: r.command.replace(/ +/gis, '') === mockKey.replace(/ +/gis, '')\n\t\t)\n\n\t\treturn { mockResponse: match?.response, mockKey }\n\t}\n\n\tpublic static fakeCommand(command: string | RegExp, response: MockResponse) {\n\t\tthis.mockResponses.unshift({\n\t\t\tcommand,\n\t\t\tresponse,\n\t\t})\n\t}\n\n\tpublic static clearMockResponses() {\n\t\tthis.mockResponses = []\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;AAEAA,OAAO,CAACC,eAAR,CAAwB,GAAxB;;IASqBC,c;EAUpB,wBAAmBC,GAAnB,EAAgC;IAAA;;IAAA;IAAA;IAAA;IAAA,4DAPJ,KAOI;IAAA,+CAuIlB,YAAM;MAAA;;MACnB,6BAAI,KAAI,CAACC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A;YAAA;UAAA;QAAA;MAAA,C;;;;;;;;;;WA8IA,yBAAwBvC,UAAxB,EAA4CF,IAA5C,EAA4D;MAC3D,IAAMU,OAAO,GAAG,UAAGR,UAAH,cAAiBF,IAAI,CAACgB,IAAL,CAAU,GAAV,CAAjB,EAAkCuC,IAAlC,EAAhB;MACA,IAAMC,QAAQ,GAAGhE,cAAc,CAACiE,aAAhC;MACA,IAAMC,KAAK,GAAGF,QAAQ,CAACG,IAAT,CAAc,UAACC,CAAD;QAAA,OAC3BA,CAAC,CAACC,OAAF,YAAqBC,MAArB,GACGpD,OAAO,CAACqC,MAAR,CAAea,CAAC,CAACC,OAAjB,IAA4B,CAAC,CADhC,GAEGD,CAAC,CAACC,OAAF,CAAUE,OAAV,CAAkB,MAAlB,EAA2B,EAA3B,MAAmCrD,OAAO,CAACqD,OAAR,CAAgB,MAAhB,EAAyB,EAAzB,CAHX;MAAA,CAAd,CAAd;MAMA,OAAO;QAAEtD,YAAY,EAAEiD,KAAF,aAAEA,KAAF,uBAAEA,KAAK,CAAEM,QAAvB;QAAiCtD,OAAO,EAAPA;MAAjC,CAAP;IACA;;;WAED,qBAA0BmD,OAA1B,EAAoDG,QAApD,EAA4E;MAC3E,KAAKP,aAAL,CAAmBQ,OAAnB,CAA2B;QAC1BJ,OAAO,EAAPA,OAD0B;QAE1BG,QAAQ,EAARA;MAF0B,CAA3B;IAIA;;;WAED,8BAAmC;MAClC,KAAKP,aAAL,GAAqB,EAArB;IACA;;;;;;iCAjLmBjE,c,mBAOd,E;iCAPcA,c,wCAQ0C,E"}
@@ -1 +1 @@
1
- {"version":3,"file":"GameService.js","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"],"sources":["../../src/services/GameService.ts"],"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"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;IAIqBA,W;EAMpB,qBAAmBC,OAAnB,EAA4CC,E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sBACA,IAAI,KAAI,CAAClB,aAAT,EAAwB;wBAAA;;wBACvB,KAAI,CAACN,EAAL,CAAQ2B,UAAR;;wBACA,KAAI,CAAC3B,EAAL,CAAQ4B,YAAR,CAAqB,CAArB,EAAwB,EAAxB;;wBACA,KAAI,CAAC5B,EAAL,CAAQ6B,gBAAR;;wBACA,oBAAAR,OAAO,CAACI,MAAR,sEAAgBC,KAAhB,CAAsB,KAAI,CAACpB,aAA3B;;wBACA,KAAI,CAACN,EAAL,CAAQ8B,aAAR;sBACA;oBACD;kBACD;gBAfmE,CAA/D,CAdP;;cAAA;cAAA;gBAAA;YAAA;UAAA;QAAA;MAAA,C;;;;;;;;;;WAiCA,gBAAc;MACb,KAAKpB,MAAL,GAAc,IAAd;MACA,KAAKX,OAAL,CAAagC,IAAb;MACA,KAAK/B,EAAL,CAAQgC,KAAR;IACA"}
1
+ {"version":3,"file":"GameService.js","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"],"sources":["../../src/services/GameService.ts"],"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"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;IAIqBA,W;EAMpB,qBAAmBC,OAAnB,EAA4CC,EAA5C,EAAmE;IAAA;IAAA;IAAA;IAAA;IAAA,iDAFlD,KAEkD;IAClE,KAAKD,OAAL,GAAeA,OAAf;IACA,KAAKC,EAAL,GAAUA,EAAV;IACA,KAAKD,OAAL,CAAaE,GAAb,GAAmBC,0BAAA,CAASC,WAAT,CAAqBC,SAArB,EAAgC,QAAhC,CAAnB;EACA;;;;WAED,0BAAwBC,OAAxB,EAAyC;MACxC,KAAKC,aAAL,GAAqBD,OAArB;IACA;;;;gGAED;QAAA;;QAAA;QAAA;QAAA;QAAA;QAAA;UAAA;YAAA;cAAA;gBAAkBE,qBAAlB,2DAAoD,EAApD;gBACOC,eADP,uCAC6BD,qBAD7B;gBAAA;gBAAA,OAEO,KAAKP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AKpB,MAAL,GAAc,IAAd;MACA,KAAKX,OAAL,CAAagC,IAAb;MACA,KAAK/B,EAAL,CAAQgC,KAAR;IACA"}
@@ -1 +1 @@
1
- {"version":3,"file":"ImportService.js","names":["ImportService","options","file","isCachingEnabled","importAllUncached","pullHashAndContents","hash","fileContents","hasFileChanged","isDirty","haveImportsChanged","cachedImports","importAllCached","response","writeCacheFile","fs","existsSync","SpruceError","code","friendlyMessage","args","divider","errorDivider","search","command","execute","stdout","successParts","split","errParts","length","proxyError","buildErrorFromExecuteResponse","defaultImported","JSON","parse","originalError","importAll","imported","cwd","originalFilepath","contents","changed","importMatches","regex","exec","match","dir","pathUtil","dirname","nodeResolved","require","resolve","join","destination","resolveCacheFile","diskUtil","writeFile","stringify","cacheFile","readFile","err","Error","stack","files","filepath","resolvePath","filename","Date","getTime","imports","exports","idx","relative","replace","extname","fullPath","importDefault","results","deleteDir","resolvedFilePath","doesFileExist","cacheDir","importCacheDir","createTempDir"],"sources":["../../src/services/ImportService.ts"],"sourcesContent":["import pathUtil from 'path'\nimport { diskUtil } from '@sprucelabs/spruce-skill-utils'\nimport fs from 'fs-extra'\nimport md5 from 'md5'\nimport SpruceError from '../errors/SpruceError'\nimport CommandService from './CommandService'\n\nexport default class ImportService {\n\tpublic cwd: string\n\n\tprivate divider = '## SPRUCE-CLI DIVIDER ##'\n\tprivate errorDivider = '## SPRUCE-CLI ERROR DIVIDER ##'\n\n\tprivate static cachedImports: Record<string, Record<string, any>> = {}\n\tprivate static importCacheDir: string =\n\t\tdiskUtil.createTempDir('import-service')\n\tprivate command: CommandService\n\tprivate static isCachingEnabled: boolean\n\n\tpublic constructor(options: { cwd: string; command: CommandService }) {\n\t\tthis.cwd = options.cwd\n\t\tthis.command = options.command\n\t}\n\n\tpublic importAll = async <T extends Record<string, any>>(\n\t\tfile: string\n\t): Promise<T> => {\n\t\tif (!ImportService.isCachingEnabled) {\n\t\t\treturn this.importAllUncached(file)\n\t\t}\n\n\t\tconst { hash, fileContents } = this.pullHashAndContents(file)\n\n\t\tif (!this.hasFileChanged(hash)) {\n\t\t\tconst isDirty = this.haveImportsChanged(file, fileContents)\n\n\t\t\tif (!isDirty && ImportService.cachedImports[hash]) {\n\t\t\t\treturn ImportService.cachedImports[hash] as T\n\t\t\t} else if (!isDirty) {\n\t\t\t\tImportService.cachedImports[hash] = this.importAllCached(file)\n\t\t\t\treturn ImportService.cachedImports[hash] as T\n\t\t\t}\n\t\t}\n\n\t\tImportService.cachedImports[hash] = this.importAllUncached(file)\n\t\tconst response = (await ImportService.cachedImports[hash]) as T\n\t\tthis.writeCacheFile(hash, response)\n\n\t\treturn response\n\t}\n\n\tprivate haveImportsChanged(\n\t\toriginalFilepath: string,\n\t\tcontents: string\n\t): boolean {\n\t\tlet changed = false\n\t\tlet importMatches\n\n\t\t// only check files that start with dot because they are local and we can actually only check local files\n\t\tconst regex =\n\t\t\toriginalFilepath.search(/\\.js$/i) > -1\n\t\t\t\t? /require\\(['\"](\\..*?)['\"]\\)/gis\n\t\t\t\t: /import.*[\"'](\\..*?)[\"']/gis\n\n\t\twhile ((importMatches = regex.exec(contents)) !== null) {\n\t\t\ttry {\n\t\t\t\tconst match = importMatches[1]\n\t\t\t\tconst dir = pathUtil.dirname(originalFilepath)\n\t\t\t\tconst nodeResolved = require.resolve(pathUtil.join(dir, match))\n\t\t\t\tconst { hash } = this.pullHashAndContents(nodeResolved)\n\n\t\t\t\tif (this.hasFileChanged(hash)) {\n\t\t\t\t\tchanged = true\n\t\t\t\t}\n\t\t\t} catch {\n\t\t\t\tchanged = true\n\t\t\t}\n\t\t}\n\n\t\treturn changed\n\t}\n\n\tprivate writeCacheFile(hash: string, contents: Record<string, any>) {\n\t\tconst destination = this.resolveCacheFile(hash)\n\t\tdiskUtil.writeFile(destination, JSON.stringify(contents))\n\t}\n\n\tprivate importAllCached(file: string) {\n\t\tconst { hash } = this.pullHashAndContents(file)\n\n\t\tconst cacheFile = this.resolveCacheFile(hash)\n\t\tconst contents = diskUtil.readFile(cacheFile)\n\n\t\treturn JSON.parse(contents)\n\t}\n\n\tprivate importAllUncached = async <T extends Record<string, any>>(\n\t\tfile: string\n\t): Promise<T> => {\n\t\tlet defaultImported: T | undefined\n\n\t\tif (!fs.existsSync(file)) {\n\t\t\tthrow new SpruceError({\n\t\t\t\tcode: 'FAILED_TO_IMPORT',\n\t\t\t\tfile,\n\t\t\t\tfriendlyMessage: `I couldn't import ${file} because I couldn't find it!`,\n\t\t\t})\n\t\t}\n\n\t\tlet args = [\n\t\t\t'-e',\n\t\t\t`\"try { const imported = require('${file}');console.log('${this.divider}');console.log(JSON.stringify(imported)); } catch(err) { console.log('${this.errorDivider}');console.log(err.options ? err.toString() : err.stack); }\"`,\n\t\t]\n\n\t\tif (file.search(/\\.ts$/i) > -1) {\n\t\t\targs = [\n\t\t\t\t'-r',\n\t\t\t\t'ts-node/register',\n\t\t\t\t'-r',\n\t\t\t\t'tsconfig-paths/register',\n\t\t\t\t...args,\n\t\t\t]\n\t\t}\n\n\t\ttry {\n\t\t\tconst { stdout } = await this.command.execute('node', {\n\t\t\t\targs,\n\t\t\t})\n\n\t\t\tconst successParts = stdout.split(this.divider)\n\t\t\tconst errParts = stdout.split(this.errorDivider)\n\n\t\t\tif (errParts.length > 1) {\n\t\t\t\tconst proxyError = this.buildErrorFromExecuteResponse(\n\t\t\t\t\terrParts,\n\t\t\t\t\tfile,\n\t\t\t\t\tstdout\n\t\t\t\t)\n\n\t\t\t\tthrow proxyError\n\t\t\t} else {\n\t\t\t\tdefaultImported = JSON.parse(successParts[1])\n\t\t\t}\n\t\t} catch (err: any) {\n\t\t\tif (err instanceof SpruceError) {\n\t\t\t\tthrow err\n\t\t\t} else {\n\t\t\t\tthrow new SpruceError({\n\t\t\t\t\tcode: 'FAILED_TO_IMPORT',\n\t\t\t\t\tfile,\n\t\t\t\t\toriginalError: err,\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\n\t\treturn defaultImported as T\n\t}\n\n\tpublic importDefault = async <T extends Record<string, any>>(\n\t\tfile: string\n\t): Promise<T> => {\n\t\tconst imported: any = await this.importAll(file)\n\t\treturn imported.default as T\n\t}\n\n\tprivate buildErrorFromExecuteResponse(\n\t\terrParts: string[],\n\t\tfile: string,\n\t\tstdout: string\n\t) {\n\t\tlet err: Record<string, any> = {}\n\t\ttry {\n\t\t\terr = JSON.parse(errParts[1])\n\t\t\tif (!err.options) {\n\t\t\t\tthrow Error('Capture and reported below')\n\t\t\t}\n\t\t} catch {\n\t\t\terr = {\n\t\t\t\toptions: {\n\t\t\t\t\tcode: 'FAILED_TO_IMPORT',\n\t\t\t\t\tfile,\n\t\t\t\t\tfriendlyMessage: `Unknown error from import, output was: \\n\\n\"${\n\t\t\t\t\t\terrParts[1] ?? stdout\n\t\t\t\t\t}\"`,\n\t\t\t\t},\n\t\t\t}\n\t\t}\n\n\t\tconst proxyError = new SpruceError(err.options)\n\n\t\tif (err.stack) {\n\t\t\tproxyError.stack = err.stack\n\t\t}\n\t\treturn proxyError\n\t}\n\n\tpublic async bulkImport(files: string[]): Promise<any[]> {\n\t\tif (files.length === 0) {\n\t\t\treturn []\n\t\t}\n\t\tconst filepath = diskUtil.resolvePath(this.cwd, '.tmp')\n\t\tconst filename = 'bulk-import-' + new Date().getTime() + '.ts'\n\n\t\tlet imports = ``\n\t\tlet exports = `export default [\\n`\n\n\t\tlet idx = 0\n\t\tfor (const file of files) {\n\t\t\tconst relative = pathUtil\n\t\t\t\t.relative(filepath, file)\n\t\t\t\t.replace(pathUtil.extname(file), '')\n\n\t\t\timports += `import { default as import${idx}} from '${relative}'\\n`\n\t\t\texports += `import${idx},\\n`\n\t\t\tidx++\n\t\t}\n\n\t\texports += ']'\n\n\t\tconst contents = imports + `\\n\\n` + exports\n\t\tconst fullPath = pathUtil.join(filepath, filename)\n\t\tdiskUtil.writeFile(fullPath, contents)\n\n\t\ttry {\n\t\t\tconst results = (await this.importDefault(fullPath)) as any[]\n\n\t\t\treturn results as any\n\t\t} catch (err) {\n\t\t\t// if something failed, lets load one at a time until we find the one that failes\n\t\t\tfor (const file of files) {\n\t\t\t\tconst imported = await this.importDefault(file)\n\t\t\t\tif (!imported) {\n\t\t\t\t\tthrow new SpruceError({\n\t\t\t\t\t\tcode: 'FAILED_TO_IMPORT',\n\t\t\t\t\t\tfile,\n\t\t\t\t\t\tfriendlyMessage: `Looks like ${file} does not export default.`,\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tthrow err\n\t\t} finally {\n\t\t\tdiskUtil.deleteDir(filepath)\n\t\t}\n\t}\n\n\tpublic static clearCache() {\n\t\tImportService.cachedImports = {}\n\t\tdiskUtil.deleteDir(this.cacheDir())\n\t}\n\n\tpublic static setCacheDir(cacheDir: string) {\n\t\tthis.importCacheDir = cacheDir\n\t}\n\n\tpublic static disableCache() {\n\t\tthis.isCachingEnabled = false\n\t}\n\n\tpublic static enableCaching() {\n\t\tthis.isCachingEnabled = true\n\t}\n\n\tprivate hasFileChanged(hash: string) {\n\t\tconst resolvedFilePath = this.resolveCacheFile(hash)\n\t\treturn !diskUtil.doesFileExist(resolvedFilePath)\n\t}\n\n\tprivate resolveCacheFile(hash: string) {\n\t\treturn diskUtil.resolvePath(ImportService.cacheDir(), hash + '.json')\n\t}\n\n\tprivate static cacheDir(): string {\n\t\treturn this.importCacheDir\n\t}\n\n\tprivate pullHashAndContents(file: string) {\n\t\tconst fileContents = diskUtil.readFile(file)\n\t\tconst hash = md5(fileContents)\n\t\treturn { hash, fileContents }\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;;;;;;;IAGqBA,a;EAYpB,uBAAmBC,OAAnB,EAAsE;IAAA;;IAAA;IAAA;IAAA,kDATpD,0BASoD;IAAA,uDAR/C,gCAQ+C;IAAA;IAAA;MAAA,yFAKnD,iBAClBC,IADkB;QAAA;;QAAA;UAAA;YAAA;cAAA;gBAAA,IAGbF,aAAa,CAACG,gBAHD;kBAAA;kB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AK/E,gBAAL,GAAwB,KAAxB;IACA;;;WAED,yBAA8B;MAC7B,KAAKA,gBAAL,GAAwB,IAAxB;IACA;;;WAWD,oBAAkC;MACjC,OAAO,KAAKgF,cAAZ;IACA;;;;;;iCA3QmBnF,a,mBAMgD,E;iCANhDA,a,oBAQnBwD,2BAAS4B,aAAT,CAAuB,gBAAvB,C;iCARmBpF,a"}
1
+ {"version":3,"file":"ImportService.js","names":["ImportService","options","file","isCachingEnabled","importAllUncached","pullHashAndContents","hash","fileContents","hasFileChanged","isDirty","haveImportsChanged","cachedImports","importAllCached","response","writeCacheFile","fs","existsSync","SpruceError","code","friendlyMessage","args","divider","errorDivider","search","command","execute","stdout","successParts","split","errParts","length","proxyError","buildErrorFromExecuteResponse","defaultImported","JSON","parse","originalError","importAll","imported","cwd","originalFilepath","contents","changed","importMatches","regex","exec","match","dir","pathUtil","dirname","nodeResolved","require","resolve","join","destination","resolveCacheFile","diskUtil","writeFile","stringify","cacheFile","readFile","err","Error","stack","files","filepath","resolvePath","filename","Date","getTime","imports","exports","idx","relative","replace","extname","fullPath","importDefault","results","deleteDir","resolvedFilePath","doesFileExist","cacheDir","md5","importCacheDir","createTempDir"],"sources":["../../src/services/ImportService.ts"],"sourcesContent":["import pathUtil from 'path'\nimport { diskUtil } from '@sprucelabs/spruce-skill-utils'\nimport fs from 'fs-extra'\nimport md5 from 'md5'\nimport SpruceError from '../errors/SpruceError'\nimport CommandService from './CommandService'\n\nexport default class ImportService {\n\tpublic cwd: string\n\n\tprivate divider = '## SPRUCE-CLI DIVIDER ##'\n\tprivate errorDivider = '## SPRUCE-CLI ERROR DIVIDER ##'\n\n\tprivate static cachedImports: Record<string, Record<string, any>> = {}\n\tprivate static importCacheDir: string =\n\t\tdiskUtil.createTempDir('import-service')\n\tprivate command: CommandService\n\tprivate static isCachingEnabled: boolean\n\n\tpublic constructor(options: { cwd: string; command: CommandService }) {\n\t\tthis.cwd = options.cwd\n\t\tthis.command = options.command\n\t}\n\n\tpublic importAll = async <T extends Record<string, any>>(\n\t\tfile: string\n\t): Promise<T> => {\n\t\tif (!ImportService.isCachingEnabled) {\n\t\t\treturn this.importAllUncached(file)\n\t\t}\n\n\t\tconst { hash, fileContents } = this.pullHashAndContents(file)\n\n\t\tif (!this.hasFileChanged(hash)) {\n\t\t\tconst isDirty = this.haveImportsChanged(file, fileContents)\n\n\t\t\tif (!isDirty && ImportService.cachedImports[hash]) {\n\t\t\t\treturn ImportService.cachedImports[hash] as T\n\t\t\t} else if (!isDirty) {\n\t\t\t\tImportService.cachedImports[hash] = this.importAllCached(file)\n\t\t\t\treturn ImportService.cachedImports[hash] as T\n\t\t\t}\n\t\t}\n\n\t\tImportService.cachedImports[hash] = this.importAllUncached(file)\n\t\tconst response = (await ImportService.cachedImports[hash]) as T\n\t\tthis.writeCacheFile(hash, response)\n\n\t\treturn response\n\t}\n\n\tprivate haveImportsChanged(\n\t\toriginalFilepath: string,\n\t\tcontents: string\n\t): boolean {\n\t\tlet changed = false\n\t\tlet importMatches\n\n\t\t// only check files that start with dot because they are local and we can actually only check local files\n\t\tconst regex =\n\t\t\toriginalFilepath.search(/\\.js$/i) > -1\n\t\t\t\t? /require\\(['\"](\\..*?)['\"]\\)/gis\n\t\t\t\t: /import.*[\"'](\\..*?)[\"']/gis\n\n\t\twhile ((importMatches = regex.exec(contents)) !== null) {\n\t\t\ttry {\n\t\t\t\tconst match = importMatches[1]\n\t\t\t\tconst dir = pathUtil.dirname(originalFilepath)\n\t\t\t\tconst nodeResolved = require.resolve(pathUtil.join(dir, match))\n\t\t\t\tconst { hash } = this.pullHashAndContents(nodeResolved)\n\n\t\t\t\tif (this.hasFileChanged(hash)) {\n\t\t\t\t\tchanged = true\n\t\t\t\t}\n\t\t\t} catch {\n\t\t\t\tchanged = true\n\t\t\t}\n\t\t}\n\n\t\treturn changed\n\t}\n\n\tprivate writeCacheFile(hash: string, contents: Record<string, any>) {\n\t\tconst destination = this.resolveCacheFile(hash)\n\t\tdiskUtil.writeFile(destination, JSON.stringify(contents))\n\t}\n\n\tprivate importAllCached(file: string) {\n\t\tconst { hash } = this.pullHashAndContents(file)\n\n\t\tconst cacheFile = this.resolveCacheFile(hash)\n\t\tconst contents = diskUtil.readFile(cacheFile)\n\n\t\treturn JSON.parse(contents)\n\t}\n\n\tprivate importAllUncached = async <T extends Record<string, any>>(\n\t\tfile: string\n\t): Promise<T> => {\n\t\tlet defaultImported: T | undefined\n\n\t\tif (!fs.existsSync(file)) {\n\t\t\tthrow new SpruceError({\n\t\t\t\tcode: 'FAILED_TO_IMPORT',\n\t\t\t\tfile,\n\t\t\t\tfriendlyMessage: `I couldn't import ${file} because I couldn't find it!`,\n\t\t\t})\n\t\t}\n\n\t\tlet args = [\n\t\t\t'-e',\n\t\t\t`\"try { const imported = require('${file}');console.log('${this.divider}');console.log(JSON.stringify(imported)); } catch(err) { console.log('${this.errorDivider}');console.log(err.options ? err.toString() : err.stack); }\"`,\n\t\t]\n\n\t\tif (file.search(/\\.ts$/i) > -1) {\n\t\t\targs = [\n\t\t\t\t'-r',\n\t\t\t\t'ts-node/register',\n\t\t\t\t'-r',\n\t\t\t\t'tsconfig-paths/register',\n\t\t\t\t...args,\n\t\t\t]\n\t\t}\n\n\t\ttry {\n\t\t\tconst { stdout } = await this.command.execute('node', {\n\t\t\t\targs,\n\t\t\t})\n\n\t\t\tconst successParts = stdout.split(this.divider)\n\t\t\tconst errParts = stdout.split(this.errorDivider)\n\n\t\t\tif (errParts.length > 1) {\n\t\t\t\tconst proxyError = this.buildErrorFromExecuteResponse(\n\t\t\t\t\terrParts,\n\t\t\t\t\tfile,\n\t\t\t\t\tstdout\n\t\t\t\t)\n\n\t\t\t\tthrow proxyError\n\t\t\t} else {\n\t\t\t\tdefaultImported = JSON.parse(successParts[1])\n\t\t\t}\n\t\t} catch (err: any) {\n\t\t\tif (err instanceof SpruceError) {\n\t\t\t\tthrow err\n\t\t\t} else {\n\t\t\t\tthrow new SpruceError({\n\t\t\t\t\tcode: 'FAILED_TO_IMPORT',\n\t\t\t\t\tfile,\n\t\t\t\t\toriginalError: err,\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\n\t\treturn defaultImported as T\n\t}\n\n\tpublic importDefault = async <T extends Record<string, any>>(\n\t\tfile: string\n\t): Promise<T> => {\n\t\tconst imported: any = await this.importAll(file)\n\t\treturn imported.default as T\n\t}\n\n\tprivate buildErrorFromExecuteResponse(\n\t\terrParts: string[],\n\t\tfile: string,\n\t\tstdout: string\n\t) {\n\t\tlet err: Record<string, any> = {}\n\t\ttry {\n\t\t\terr = JSON.parse(errParts[1])\n\t\t\tif (!err.options) {\n\t\t\t\tthrow Error('Capture and reported below')\n\t\t\t}\n\t\t} catch {\n\t\t\terr = {\n\t\t\t\toptions: {\n\t\t\t\t\tcode: 'FAILED_TO_IMPORT',\n\t\t\t\t\tfile,\n\t\t\t\t\tfriendlyMessage: `Unknown error from import, output was: \\n\\n\"${\n\t\t\t\t\t\terrParts[1] ?? stdout\n\t\t\t\t\t}\"`,\n\t\t\t\t},\n\t\t\t}\n\t\t}\n\n\t\tconst proxyError = new SpruceError(err.options)\n\n\t\tif (err.stack) {\n\t\t\tproxyError.stack = err.stack\n\t\t}\n\t\treturn proxyError\n\t}\n\n\tpublic async bulkImport(files: string[]): Promise<any[]> {\n\t\tif (files.length === 0) {\n\t\t\treturn []\n\t\t}\n\t\tconst filepath = diskUtil.resolvePath(this.cwd, '.tmp')\n\t\tconst filename = 'bulk-import-' + new Date().getTime() + '.ts'\n\n\t\tlet imports = ``\n\t\tlet exports = `export default [\\n`\n\n\t\tlet idx = 0\n\t\tfor (const file of files) {\n\t\t\tconst relative = pathUtil\n\t\t\t\t.relative(filepath, file)\n\t\t\t\t.replace(pathUtil.extname(file), '')\n\n\t\t\timports += `import { default as import${idx}} from '${relative}'\\n`\n\t\t\texports += `import${idx},\\n`\n\t\t\tidx++\n\t\t}\n\n\t\texports += ']'\n\n\t\tconst contents = imports + `\\n\\n` + exports\n\t\tconst fullPath = pathUtil.join(filepath, filename)\n\t\tdiskUtil.writeFile(fullPath, contents)\n\n\t\ttry {\n\t\t\tconst results = (await this.importDefault(fullPath)) as any[]\n\n\t\t\treturn results as any\n\t\t} catch (err) {\n\t\t\t// if something failed, lets load one at a time until we find the one that failes\n\t\t\tfor (const file of files) {\n\t\t\t\tconst imported = await this.importDefault(file)\n\t\t\t\tif (!imported) {\n\t\t\t\t\tthrow new SpruceError({\n\t\t\t\t\t\tcode: 'FAILED_TO_IMPORT',\n\t\t\t\t\t\tfile,\n\t\t\t\t\t\tfriendlyMessage: `Looks like ${file} does not export default.`,\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tthrow err\n\t\t} finally {\n\t\t\tdiskUtil.deleteDir(filepath)\n\t\t}\n\t}\n\n\tpublic static clearCache() {\n\t\tImportService.cachedImports = {}\n\t\tdiskUtil.deleteDir(this.cacheDir())\n\t}\n\n\tpublic static setCacheDir(cacheDir: string) {\n\t\tthis.importCacheDir = cacheDir\n\t}\n\n\tpublic static disableCache() {\n\t\tthis.isCachingEnabled = false\n\t}\n\n\tpublic static enableCaching() {\n\t\tthis.isCachingEnabled = true\n\t}\n\n\tprivate hasFileChanged(hash: string) {\n\t\tconst resolvedFilePath = this.resolveCacheFile(hash)\n\t\treturn !diskUtil.doesFileExist(resolvedFilePath)\n\t}\n\n\tprivate resolveCacheFile(hash: string) {\n\t\treturn diskUtil.resolvePath(ImportService.cacheDir(), hash + '.json')\n\t}\n\n\tprivate static cacheDir(): string {\n\t\treturn this.importCacheDir\n\t}\n\n\tprivate pullHashAndContents(file: string) {\n\t\tconst fileContents = diskUtil.readFile(file)\n\t\tconst hash = md5(fileContents)\n\t\treturn { hash, fileContents }\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;;;;;;;IAGqBA,a;EAYpB,uBAAmBC,OAAnB,EAAsE;IAAA;;IAAA;IAAA;IAAA,kDATpD,0BASoD;IAAA,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ZA;MAAR,CAAP;IACA;;;WAlCD,sBAA2B;MAC1BP,aAAa,CAACW,aAAd,GAA8B,EAA9B;;MACA6C,0BAAA,CAASuB,SAAT,CAAmB,KAAKG,QAAL,EAAnB;IACA;;;WAED,qBAA0BA,QAA1B,EAA4C;MAC3C,KAAKE,cAAL,GAAsBF,QAAtB;IACA;;;WAED,wBAA6B;MAC5B,KAAK/E,gBAAL,GAAwB,KAAxB;IACA;;;WAED,yBAA8B;MAC7B,KAAKA,gBAAL,GAAwB,IAAxB;IACA;;;WAWD,oBAAkC;MACjC,OAAO,KAAKiF,cAAZ;IACA;;;;;;iCA3QmBpF,a,mBAMgD,E;iCANhDA,a,oBAQnBwD,0BAAA,CAAS6B,aAAT,CAAuB,gBAAvB,C;iCARmBrF,a"}
@@ -1 +1 @@
1
- {"version":3,"file":"LintService.js","names":["LintService","cwd","commandServiceFactory","pattern","SchemaError","code","parameters","isLintingEnabled","fixedFiles","fixedPaths","script","getCommand","execute","args","stdout","JSON","parse","SpruceError","originalError","i","length","fixedFile","output","fs","writeFile","filePath","push","messages","errorCount","friendlyMessage","map","m","message","join"],"sources":["../../src/services/LintService.ts"],"sourcesContent":["import { SchemaError } from '@sprucelabs/schema'\n// import { ESLint } from 'eslint'\nimport fs from 'fs-extra'\nimport SpruceError from '../errors/SpruceError'\nimport CommandService from './CommandService'\n\nexport default class LintService {\n\tpublic cwd: string\n\tprivate getCommand: () => CommandService\n\n\tprivate static isLintingEnabled = true\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\tpublic constructor(cwd: string, commandServiceFactory: () => CommandService) {\n\t\tthis.cwd = cwd\n\t\tthis.getCommand = commandServiceFactory\n\t}\n\n\tpublic fix = async (pattern: string): Promise<string[]> => {\n\t\tif (!pattern) {\n\t\t\tthrow new SchemaError({\n\t\t\t\tcode: 'MISSING_PARAMETERS',\n\t\t\t\tparameters: ['pattern'],\n\t\t\t})\n\t\t}\n\n\t\tif (!LintService.isLintingEnabled) {\n\t\t\treturn []\n\t\t}\n\n\t\tlet fixedFiles: any = {}\n\t\tconst fixedPaths: string[] = []\n\n\t\ttry {\n\t\t\t// const cli = new ESLint({ fix: true, cwd: this.cwd, cache: true })\n\t\t\t// fixedFiles = await cli.lintFiles([pattern])\n\t\t\tconst script = `\"(async function lint() { try { const { ESLint } = require('eslint'); const cli = new ESLint({ fix: true, cwd: '${this.cwd}', }); const result = await cli.lintFiles(['${pattern}']); console.log(JSON.stringify(result)); } catch (err) { console.log(err.toString()); }})()\"`\n\n\t\t\tconst { stdout } = await this.getCommand().execute('node', {\n\t\t\t\targs: ['-e', script],\n\t\t\t})\n\n\t\t\tfixedFiles = JSON.parse(stdout)\n\t\t} catch (err: any) {\n\t\t\tthrow new SpruceError({\n\t\t\t\tcode: 'LINT_FAILED',\n\t\t\t\tpattern,\n\t\t\t\toriginalError: err,\n\t\t\t})\n\t\t}\n\n\t\tif (fixedFiles) {\n\t\t\tfor (let i = 0; i < fixedFiles.length; i += 1) {\n\t\t\t\tconst fixedFile = fixedFiles[i]\n\n\t\t\t\tif (fixedFile?.output) {\n\t\t\t\t\tawait fs.writeFile(fixedFile.filePath, fixedFile.output)\n\t\t\t\t\tfixedPaths.push(fixedFile.filePath)\n\t\t\t\t} else if (fixedFile?.messages && fixedFile?.errorCount > 0) {\n\t\t\t\t\tthrow new SpruceError({\n\t\t\t\t\t\tcode: 'LINT_FAILED',\n\t\t\t\t\t\tpattern,\n\t\t\t\t\t\tfriendlyMessage: `Lint error with '${\n\t\t\t\t\t\t\tfixedFile.filePath\n\t\t\t\t\t\t}':\\n\\n${fixedFile.messages\n\t\t\t\t\t\t\t.map((m: any) => m?.message)\n\t\t\t\t\t\t\t.join('\\n')}`,\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn fixedPaths\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAA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,eAqCNA,SAAS,CAAEC,MArCL;kBAAA;kBAAA;gBAAA;;gBAAA;gBAAA,OAsCHC,oBAAGC,SAAH,CAAaH,SAAS,CAACI,QAAvB,EAAiCJ,SAAS,CAACC,MAA3C,CAtCG;;cAAA;gBAuCTb,UAAU,CAACiB,IAAX,CAAgBL,SAAS,CAACI,QAA1B;gBAvCS;gBAAA;;cAAA;gBAAA,MAwCCJ,SAAS,SAAT,IAAAA,SAAS,WAAT,IAAAA,SAAS,CAAEM,QAAX,IAAuB,CAAAN,SAAS,SAAT,IAAAA,SAAS,WAAT,YAAAA,SAAS,CAAEO,UAAX,IAAwB,CAxChD;kBAAA;kBAAA;gBAAA;;gBAAA,MAyCH,IAAIX,uBAAJ,CAAgB;kBACrBZ,IAAI,EAAE,aADe;kBAErBF,OAAO,EAAPA,OAFqB;kBAGrB0B,eAAe,6BACdR,SAAS,CAACI,QADI,mBAENJ,SAAS,CAACM,QAAV,CACPG,GADO,CACH,UAACC,CAAD;oBAAA,OAAYA,CAAZ,aAAYA,CAAZ,uBAAYA,CAAC,CAAEC,OAAf;kBAAA,CADG,EAEPC,IAFO,CAEF,IAFE,CAFM;gBAHM,CAAhB,CAzCG;;cAAA;gBAkC4Bd,CAAC,IAAI,CAlCjC;gBAAA;gBAAA;;cAAA;gBAAA,iCAsDLV,UAtDK;;cAAA;cAAA;gBAAA;YAAA;UAAA;QAAA;MAAA,CALgE;;MAAA;QAAA;MAAA;IAAA;IAC5E,KAAKR,GAAL,GAAWA,GAAX;IACA,KAAKU,UAAL,GAAkBT,qBAAlB;EACA;;;;WAXD,0BAA+B;MAC9B,KAAKK,gBAAL,GAAwB,KAAxB;IACA;;;WAED,yBAA8B;MAC7B,KAAKA,gBAAL,GAAwB,IAAxB;IACA;;;;;;iCAZmBP,W,sBAIc,I"}
1
+ {"version":3,"file":"LintService.js","names":["LintService","cwd","commandServiceFactory","pattern","SchemaError","code","parameters","isLintingEnabled","fixedFiles","fixedPaths","script","getCommand","execute","args","stdout","JSON","parse","SpruceError","originalError","i","length","fixedFile","output","fs","writeFile","filePath","push","messages","errorCount","friendlyMessage","map","m","message","join"],"sources":["../../src/services/LintService.ts"],"sourcesContent":["import { SchemaError } from '@sprucelabs/schema'\n// import { ESLint } from 'eslint'\nimport fs from 'fs-extra'\nimport SpruceError from '../errors/SpruceError'\nimport CommandService from './CommandService'\n\nexport default class LintService {\n\tpublic cwd: string\n\tprivate getCommand: () => CommandService\n\n\tprivate static isLintingEnabled = true\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\tpublic constructor(cwd: string, commandServiceFactory: () => CommandService) {\n\t\tthis.cwd = cwd\n\t\tthis.getCommand = commandServiceFactory\n\t}\n\n\tpublic fix = async (pattern: string): Promise<string[]> => {\n\t\tif (!pattern) {\n\t\t\tthrow new SchemaError({\n\t\t\t\tcode: 'MISSING_PARAMETERS',\n\t\t\t\tparameters: ['pattern'],\n\t\t\t})\n\t\t}\n\n\t\tif (!LintService.isLintingEnabled) {\n\t\t\treturn []\n\t\t}\n\n\t\tlet fixedFiles: any = {}\n\t\tconst fixedPaths: string[] = []\n\n\t\ttry {\n\t\t\t// const cli = new ESLint({ fix: true, cwd: this.cwd, cache: true })\n\t\t\t// fixedFiles = await cli.lintFiles([pattern])\n\t\t\tconst script = `\"(async function lint() { try { const { ESLint } = require('eslint'); const cli = new ESLint({ fix: true, cwd: '${this.cwd}', }); const result = await cli.lintFiles(['${pattern}']); console.log(JSON.stringify(result)); } catch (err) { console.log(err.toString()); }})()\"`\n\n\t\t\tconst { stdout } = await this.getCommand().execute('node', {\n\t\t\t\targs: ['-e', script],\n\t\t\t})\n\n\t\t\tfixedFiles = JSON.parse(stdout)\n\t\t} catch (err: any) {\n\t\t\tthrow new SpruceError({\n\t\t\t\tcode: 'LINT_FAILED',\n\t\t\t\tpattern,\n\t\t\t\toriginalError: err,\n\t\t\t})\n\t\t}\n\n\t\tif (fixedFiles) {\n\t\t\tfor (let i = 0; i < fixedFiles.length; i += 1) {\n\t\t\t\tconst fixedFile = fixedFiles[i]\n\n\t\t\t\tif (fixedFile?.output) {\n\t\t\t\t\tawait fs.writeFile(fixedFile.filePath, fixedFile.output)\n\t\t\t\t\tfixedPaths.push(fixedFile.filePath)\n\t\t\t\t} else if (fixedFile?.messages && fixedFile?.errorCount > 0) {\n\t\t\t\t\tthrow new SpruceError({\n\t\t\t\t\t\tcode: 'LINT_FAILED',\n\t\t\t\t\t\tpattern,\n\t\t\t\t\t\tfriendlyMessage: `Lint error with '${\n\t\t\t\t\t\t\tfixedFile.filePath\n\t\t\t\t\t\t}':\\n\\n${fixedFile.messages\n\t\t\t\t\t\t\t.map((m: any) => m?.message)\n\t\t\t\t\t\t\t.join('\\n')}`,\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn fixedPaths\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;;AAEA;;AACA;;AAFA;IAKqBA,W;EAcpB,qBAAmBC,GAAnB,EAAgCC,qBAAhC,EAA6E;IAAA;;IAAA;IAAA;IAAA;IAAA;MAAA,yFAKhE,iBAAOC,OAAP;QAAA;;QAAA;UAAA;YAAA;cAAA;gBAAA,IACPA,OADO;kBAAA;kBAAA;gBAAA;;gBAAA,MAEL,IAAIC,mBAAJ,CAAgB;kBACrBC,IAAI,EAAE,oBADe;kBAErBC,UAAU,EAAE,CAAC,SAAD;gBAFS,CAAhB,CAFK;;cAAA;gBAAA,IAQPN,WAAW,CAACO,gBARL;kBAAA;kBAAA;gBAAA;;gBAAA,iCASJ,EATI;;cAAA;gBAYRC,UAZQ,GAYU,EAZV;gBAaNC,UAbM,GAaiB,EAbjB;gBAAA;gBAgBX;gBACA;gBACMC,MAlBK,8HAkBuH,KAAI,CAACT,GAlB5H,yDAkB8KE,OAlB9K;gBAAA;gBAAA,OAoBc,KAAI,CAACQ,UAAL,GAAkBC,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CAAD;oBAAA,OAAYA,CAAZ,aAAYA,CAAZ,uBAAYA,CAAC,CAAEC,OAAf;kBAAA,CADG,EAEPC,IAFO,CAEF,IAFE,CAFM;gBAHM,CAAhB,CAzCG;;cAAA;gBAkC4Bd,CAAC,IAAI,CAlCjC;gBAAA;gBAAA;;cAAA;gBAAA,iCAsDLV,UAtDK;;cAAA;cAAA;gBAAA;YAAA;UAAA;QAAA;MAAA,CALgE;;MAAA;QAAA;MAAA;IAAA;IAC5E,KAAKR,GAAL,GAAWA,GAAX;IACA,KAAKU,UAAL,GAAkBT,qBAAlB;EACA;;;;WAXD,0BAA+B;MAC9B,KAAKK,gBAAL,GAAwB,KAAxB;IACA;;;WAED,yBAA8B;MAC7B,KAAKA,gBAAL,GAAwB,IAAxB;IACA;;;;;;iCAZmBP,W,sBAIc,I"}
@@ -1 +1 @@
1
- {"version":3,"file":"PkgService.js","names":["PkgService","cwd","commandService","pkg","options","shouldCleanupLockFiles","deleteLockFile","bind","execute","args","totalInstalled","totalSkipped","packages","Array","isArray","toInstall","labsModules","thisPackage","isInstalled","shouldForceInstall","startsWith","push","stripLatest","buildCommandAndArgs","executable","diskUtil","doesDirExist","pathUtil","join","_parsedPkg","undefined","length","install","createRandomTempDir","filter","a","isDev","BasePkgService"],"sources":["../../src/services/PkgService.ts"],"sourcesContent":["import pathUtil from 'path'\nimport {\n\tdiskUtil,\n\tPkgService as BasePkgService,\n} from '@sprucelabs/spruce-skill-utils'\nimport isCi from '../utilities/isCi'\nimport CommandService from './CommandService'\n\nexport interface AddOptions {\n\tisDev?: boolean\n\tshouldForceInstall?: boolean\n\tshouldCleanupLockFiles?: boolean\n}\n\nexport default class PkgService extends BasePkgService {\n\tprivate commandService: CommandService\n\n\tpublic constructor(cwd: string, commandService: CommandService) {\n\t\tsuper(cwd)\n\t\tthis.commandService = commandService\n\t}\n\n\tpublic async install(pkg?: string[] | string, options?: AddOptions) {\n\t\tconst shouldCleanupLockFiles = options?.shouldCleanupLockFiles !== false\n\t\tconst deleteLockFile = shouldCleanupLockFiles\n\t\t\t? this.deleteLockFile.bind(this)\n\t\t\t: () => {}\n\n\t\tif (!pkg) {\n\t\t\tawait this.commandService.execute('yarn', { args: ['install'] })\n\t\t\tdeleteLockFile()\n\t\t\treturn { totalInstalled: -1, totalSkipped: -1 }\n\t\t}\n\n\t\tdeleteLockFile()\n\n\t\tconst packages = Array.isArray(pkg) ? pkg : [pkg]\n\t\tconst toInstall = []\n\t\tconst labsModules: string[] = []\n\n\t\tlet totalInstalled = 0\n\t\tlet totalSkipped = 0\n\n\t\tfor (const thisPackage of packages) {\n\t\t\tconst isInstalled =\n\t\t\t\t!options?.shouldForceInstall && this.isInstalled(thisPackage)\n\t\t\tif (thisPackage.startsWith('@sprucelabs/') || !isInstalled) {\n\t\t\t\ttoInstall.push(this.stripLatest(thisPackage))\n\t\t\t\ttotalInstalled++\n\t\t\t} else {\n\t\t\t\ttotalSkipped++\n\t\t\t}\n\t\t}\n\n\t\tif (totalInstalled > 0) {\n\t\t\tconst { executable, args } = PkgService.buildCommandAndArgs(\n\t\t\t\ttoInstall,\n\t\t\t\toptions\n\t\t\t)\n\n\t\t\tawait this.commandService.execute(executable, {\n\t\t\t\targs,\n\t\t\t})\n\t\t} else if (\n\t\t\t!diskUtil.doesDirExist(pathUtil.join(this.cwd, 'node_modules'))\n\t\t) {\n\t\t\tawait this.commandService.execute('yarn', { args: ['install'] })\n\t\t}\n\n\t\tdeleteLockFile()\n\n\t\tthis._parsedPkg = undefined\n\n\t\treturn { totalInstalled: totalInstalled + labsModules.length, totalSkipped }\n\t}\n\n\tpublic static buildCommandAndArgs(\n\t\ttoInstall: string[],\n\t\toptions: AddOptions | undefined\n\t) {\n\t\tconst args: any[] = [\n\t\t\tisCi() && '--cache-folder',\n\t\t\tisCi() && diskUtil.createRandomTempDir(),\n\t\t\t'add',\n\t\t\t...toInstall,\n\t\t].filter((a) => !!a)\n\n\t\tif (options?.isDev) {\n\t\t\targs.push('-D')\n\t\t}\n\n\t\tconst executable = 'yarn'\n\t\treturn { executable, args }\n\t}\n\n\tpublic async uninstall(pkg: string[] | string) {\n\t\tconst packages = Array.isArray(pkg) ? pkg : [pkg]\n\t\tconst args: string[] = ['uninstall', ...packages]\n\t\tawait this.commandService.execute('npm', {\n\t\t\targs,\n\t\t})\n\n\t\tthis._parsedPkg = undefined\n\n\t\tawait this.install()\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AAIA;;;;;;;;;;;;IASqBA,U;;;;;EAGpB,oBAAmBC,GAAnB,EAAgCC,cAAhC,EAAgE;IAAA;;IAAA;IAC/D,0BAAMD,GAAN;IAD+D;IAE/D,MAAKC,cAAL,GAAsBA,cAAtB;IAF+D;EAG/D;;;;;mGAED,iBAAqBC,GAArB,EAA8CC,OAA9C;QAAA;;QAAA;UAAA;YAAA;cAAA;gBACOC,sBADP,GACgC,CAAAD,OAAO,SAAP,IAAAA,OAAO,WAAP,YAAAA,OAAO,CAAEC,sBAAT,MAAoC,KADpE;gBAEOC,cAFP,GAEwBD,sBAAsB,GAC1C,KAAKC,cAAL,CAAoBC,IAApB,CAAyB,IAAzB,CAD0C,GAE1C,YAAM,CAAE,CAJZ;;gBAAA,IAMMJ,GANN;kBAAA;kBAAA;gBAAA;;gBAAA;gBAAA,OAOQ,KAAKD,cAAL,CAAoBM,OAApB,CAA4B,MAA5B,EAAoC;kBAAEC,IAAI,EAAE,CAAC,SAAD;gBAAR,CAApC,CAPR;;cAAA;gBAQEH,cAAc;gBARhB,iCASS;kBAAEI,cAAc,EAAE,CAAC,CAAnB;kBAAsBC,YAAY,EAAE,CAAC;gBAArC,CATT;;cAAA;gBAYCL,cAAc;gBAERM,QAdP,GAckBC,KAAK,CAACC,OAAN,CAAcX,GAAd,IAAqBA,GAArB,GAA2B,CAACA,GAAD,CAd7C;gBAeOY,SAfP,GAemB,EAfnB;gBAgBOC,WAhBP,GAgB+B,EAhB/B;gBAkBKN,cAlBL,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AY,EAAZA;gBAAvD,CAnDR;;cAAA;cAAA;gBAAA;YAAA;UAAA;QAAA;MAAA,C;;;;;;;;;;;qGAyEA,kBAAuBR,GAAvB;QAAA;QAAA;UAAA;YAAA;cAAA;gBACOS,QADP,GACkBC,KAAK,CAACC,OAAN,CAAcX,GAAd,IAAqBA,GAArB,GAA2B,CAACA,GAAD,CAD7C;gBAEOM,IAFP,IAEyB,WAFzB,6CAEyCG,QAFzC;gBAAA;gBAAA,OAGO,KAAKV,cAAL,CAAoBM,OAApB,CAA4B,KAA5B,EAAmC;kBACxCC,IAAI,EAAJA;gBADwC,CAAnC,CAHP;;cAAA;gBAOC,KAAKoB,UAAL,GAAkBC,SAAlB;gBAPD;gBAAA,OASO,KAAKE,OAAL,EATP;;cAAA;cAAA;gBAAA;YAAA;UAAA;QAAA;MAAA,C;;;;;;;;;;WAnBA,6BACCjB,SADD,EAECX,OAFD,EAGE;MACD,IAAMK,IAAW,GAAG,CACnB,2BAAU,gBADS,EAEnB,2BAAUgB,2BAASQ,mBAAT,EAFS,EAGnB,KAHmB,6CAIhBlB,SAJgB,GAKlBmB,MALkB,CAKX,UAACC,CAAD;QAAA,OAAO,CAAC,CAACA,CAAT;MAAA,CALW,CAApB;;MAOA,IAAI/B,OAAJ,aAAIA,OAAJ,eAAIA,OAAO,CAAEgC,KAAb,EAAoB;QACnB3B,IAAI,CAACY,IAAL,CAAU,IAAV;MACA;;MAED,IAAMG,UAAU,GAAG,MAAnB;MACA,OAAO;QAAEA,UAAU,EAAVA,UAAF;QAAcf,IAAI,EAAJA;MAAd,CAAP;IACA;;;EA/EsC4B,4B"}
1
+ {"version":3,"file":"PkgService.js","names":["PkgService","cwd","commandService","pkg","options","shouldCleanupLockFiles","deleteLockFile","bind","execute","args","totalInstalled","totalSkipped","packages","Array","isArray","toInstall","labsModules","thisPackage","isInstalled","shouldForceInstall","startsWith","push","stripLatest","buildCommandAndArgs","executable","diskUtil","doesDirExist","pathUtil","join","_parsedPkg","undefined","length","install","isCi","createRandomTempDir","filter","a","isDev","BasePkgService"],"sources":["../../src/services/PkgService.ts"],"sourcesContent":["import pathUtil from 'path'\nimport {\n\tdiskUtil,\n\tPkgService as BasePkgService,\n} from '@sprucelabs/spruce-skill-utils'\nimport isCi from '../utilities/isCi'\nimport CommandService from './CommandService'\n\nexport interface AddOptions {\n\tisDev?: boolean\n\tshouldForceInstall?: boolean\n\tshouldCleanupLockFiles?: boolean\n}\n\nexport default class PkgService extends BasePkgService {\n\tprivate commandService: CommandService\n\n\tpublic constructor(cwd: string, commandService: CommandService) {\n\t\tsuper(cwd)\n\t\tthis.commandService = commandService\n\t}\n\n\tpublic async install(pkg?: string[] | string, options?: AddOptions) {\n\t\tconst shouldCleanupLockFiles = options?.shouldCleanupLockFiles !== false\n\t\tconst deleteLockFile = shouldCleanupLockFiles\n\t\t\t? this.deleteLockFile.bind(this)\n\t\t\t: () => {}\n\n\t\tif (!pkg) {\n\t\t\tawait this.commandService.execute('yarn', { args: ['install'] })\n\t\t\tdeleteLockFile()\n\t\t\treturn { totalInstalled: -1, totalSkipped: -1 }\n\t\t}\n\n\t\tdeleteLockFile()\n\n\t\tconst packages = Array.isArray(pkg) ? pkg : [pkg]\n\t\tconst toInstall = []\n\t\tconst labsModules: string[] = []\n\n\t\tlet totalInstalled = 0\n\t\tlet totalSkipped = 0\n\n\t\tfor (const thisPackage of packages) {\n\t\t\tconst isInstalled =\n\t\t\t\t!options?.shouldForceInstall && this.isInstalled(thisPackage)\n\t\t\tif (thisPackage.startsWith('@sprucelabs/') || !isInstalled) {\n\t\t\t\ttoInstall.push(this.stripLatest(thisPackage))\n\t\t\t\ttotalInstalled++\n\t\t\t} else {\n\t\t\t\ttotalSkipped++\n\t\t\t}\n\t\t}\n\n\t\tif (totalInstalled > 0) {\n\t\t\tconst { executable, args } = PkgService.buildCommandAndArgs(\n\t\t\t\ttoInstall,\n\t\t\t\toptions\n\t\t\t)\n\n\t\t\tawait this.commandService.execute(executable, {\n\t\t\t\targs,\n\t\t\t})\n\t\t} else if (\n\t\t\t!diskUtil.doesDirExist(pathUtil.join(this.cwd, 'node_modules'))\n\t\t) {\n\t\t\tawait this.commandService.execute('yarn', { args: ['install'] })\n\t\t}\n\n\t\tdeleteLockFile()\n\n\t\tthis._parsedPkg = undefined\n\n\t\treturn { totalInstalled: totalInstalled + labsModules.length, totalSkipped }\n\t}\n\n\tpublic static buildCommandAndArgs(\n\t\ttoInstall: string[],\n\t\toptions: AddOptions | undefined\n\t) {\n\t\tconst args: any[] = [\n\t\t\tisCi() && '--cache-folder',\n\t\t\tisCi() && diskUtil.createRandomTempDir(),\n\t\t\t'add',\n\t\t\t...toInstall,\n\t\t].filter((a) => !!a)\n\n\t\tif (options?.isDev) {\n\t\t\targs.push('-D')\n\t\t}\n\n\t\tconst executable = 'yarn'\n\t\treturn { executable, args }\n\t}\n\n\tpublic async uninstall(pkg: string[] | string) {\n\t\tconst packages = Array.isArray(pkg) ? pkg : [pkg]\n\t\tconst args: string[] = ['uninstall', ...packages]\n\t\tawait this.commandService.execute('npm', {\n\t\t\targs,\n\t\t})\n\n\t\tthis._parsedPkg = undefined\n\n\t\tawait this.install()\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AAIA;;;;;;;;;;;;IASqBA,U;;;;;EAGpB,oBAAmBC,GAAnB,EAAgCC,cAAhC,EAAgE;IAAA;;IAAA;IAC/D,0BAAMD,GAAN;IAD+D;IAE/D,MAAKC,cAAL,GAAsBA,cAAtB;IAF+D;EAG/D;;;;;mGAED,iBAAqBC,GAArB,EAA8CC,OAA9C;QAAA;;QAAA;UAAA;YAAA;cAAA;gBACOC,sBADP,GACgC,CAAAD,OAAO,SAAP,IAAAA,OAAO,WAAP,YAAAA,OAAO,CAAEC,sBAAT,MAAoC,KADpE;gBAEOC,cAFP,GAEwBD,sBAAsB,GAC1C,KAAKC,cAAL,CAAoBC,IAApB,CAAyB,IAAzB,CAD0C,GAE1C,YAAM,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C,CAAD;QAAA,OAAO,CAAC,CAACA,CAAT;MAAA,CALW,CAApB;;MAOA,IAAIhC,OAAJ,aAAIA,OAAJ,eAAIA,OAAO,CAAEiC,KAAb,EAAoB;QACnB5B,IAAI,CAACY,IAAL,CAAU,IAAV;MACA;;MAED,IAAMG,UAAU,GAAG,MAAnB;MACA,OAAO;QAAEA,UAAU,EAAVA,UAAF;QAAcf,IAAI,EAAJA;MAAd,CAAP;IACA;;;EA/EsC6B,4B"}
@@ -1 +1 @@
1
- {"version":3,"file":"ServiceFactory.js","names":["ServiceFactory","cwd","type","AuthService","Auth","PkgService","Service","EnvService","VsCodeService","SchemaService","command","CommandService","LintService","RemoteService","TypeCheckerService","buildImportService","SettingsService","DependencyService","commandService","BuildService","EventSettingsService","Error","ImportService"],"sources":["../../src/services/ServiceFactory.ts"],"sourcesContent":["import {\n\tSettingsService,\n\tEnvService,\n\tAuthService,\n} from '@sprucelabs/spruce-skill-utils'\nimport EventSettingsService from '../features/event/services/EventSettingsService'\nimport RemoteService from '../features/event/services/RemoteService'\nimport { FeatureCode } from '../features/features.types'\nimport SchemaService from '../features/schema/services/SchemaService'\nimport VsCodeService from '../features/vscode/services/VsCodeService'\nimport BuildService from './BuildService'\nimport CommandService from './CommandService'\nimport DependencyService from './DependencyService'\nimport ImportService from './ImportService'\nimport LintService from './LintService'\nimport PkgService from './PkgService'\nimport TypeCheckerService from './TypeCheckerService'\n\nexport interface ServiceMap {\n\tpkg: PkgService\n\tvsCode: VsCodeService\n\tschema: SchemaService\n\tlint: LintService\n\tcommand: CommandService\n\ttypeChecker: TypeCheckerService\n\timport: ImportService\n\tbuild: BuildService\n\tsettings: SettingsService\n\tenv: EnvService\n\tauth: AuthService\n\tremote: RemoteService\n\teventSettings: EventSettingsService\n\tdependency: DependencyService\n}\n\nexport type Service = keyof ServiceMap\n\nexport interface ServiceProvider {\n\tService<S extends Service>(type: S, cwd?: string): ServiceMap[S]\n}\nexport default class ServiceFactory {\n\tpublic Service<S extends Service>(cwd: string, type: S): ServiceMap[S] {\n\t\tswitch (type) {\n\t\t\tcase 'auth':\n\t\t\t\treturn AuthService.Auth(cwd) as ServiceMap[S]\n\t\t\tcase 'pkg':\n\t\t\t\treturn new PkgService(\n\t\t\t\t\tcwd,\n\t\t\t\t\tthis.Service(cwd, 'command')\n\t\t\t\t) as ServiceMap[S]\n\t\t\tcase 'env':\n\t\t\t\treturn new EnvService(cwd) as ServiceMap[S]\n\t\t\tcase 'vsCode':\n\t\t\t\treturn new VsCodeService(cwd) as ServiceMap[S]\n\t\t\tcase 'schema':\n\t\t\t\treturn new SchemaService({\n\t\t\t\t\tcwd,\n\t\t\t\t\tcommand: new CommandService(cwd),\n\t\t\t\t}) as ServiceMap[S]\n\t\t\tcase 'lint':\n\t\t\t\treturn new LintService(cwd, () =>\n\t\t\t\t\tthis.Service(cwd, 'command')\n\t\t\t\t) as ServiceMap[S]\n\t\t\tcase 'command': {\n\t\t\t\treturn new CommandService(cwd) as ServiceMap[S]\n\t\t\t}\n\t\t\tcase 'remote':\n\t\t\t\treturn new RemoteService(new EnvService(cwd)) as ServiceMap[S]\n\t\t\tcase 'typeChecker':\n\t\t\t\treturn new TypeCheckerService(\n\t\t\t\t\tthis.buildImportService(cwd)\n\t\t\t\t) as ServiceMap[S]\n\t\t\tcase 'settings':\n\t\t\t\treturn new SettingsService<FeatureCode>(cwd) as ServiceMap[S]\n\t\t\tcase 'dependency':\n\t\t\t\treturn new DependencyService(\n\t\t\t\t\tnew SettingsService<FeatureCode>(cwd)\n\t\t\t\t) as ServiceMap[S]\n\t\t\tcase 'import':\n\t\t\t\treturn this.buildImportService(cwd) as ServiceMap[S]\n\t\t\tcase 'build': {\n\t\t\t\tconst commandService = new CommandService(cwd)\n\t\t\t\treturn new BuildService(\n\t\t\t\t\tcommandService,\n\t\t\t\t\tnew LintService(cwd, () => this.Service(cwd, 'command'))\n\t\t\t\t) as ServiceMap[S]\n\t\t\t}\n\t\t\tcase 'eventSettings':\n\t\t\t\treturn new EventSettingsService(\n\t\t\t\t\tnew SettingsService(cwd)\n\t\t\t\t) as ServiceMap[S]\n\t\t\tdefault:\n\t\t\t\tthrow new Error(`Service \"${type}\" not found`)\n\t\t}\n\t}\n\n\tprivate buildImportService(cwd: string): ImportService {\n\t\treturn new ImportService({\n\t\t\tcwd,\n\t\t\tcommand: new CommandService(cwd),\n\t\t})\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;AAAA;;AAKA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;IAwBqBA,c;;;;;;;;;;;;;;;;;MACpB,UAAkCC,GAAlC,EAA+CC,IAA/C,EAAuE;MAAA;;MACtE,QAAQA,IAAR;QACC,KAAK,MAAL;UACC,OAAOC,8BAAYC,IAAZ,CAAiBH,GAAjB,CAAP;;QACD,KAAK,KAAL;UACC,OAAO,IAAII,sBAAJ,CACNJ,GADM,EAEN,KAAKK,OAAL,CAAaL,GAAb,EAAkB,SAAlB,CAFM,CAAP;;QAID,KAAK,KAAL;UACC,OAAO,IAAIM,4BAAJ,CAAeN,GAAf,CAAP;;QACD,KAAK,QAAL;UACC,OAAO,IAAIO,yBAAJ,CAAkBP,GAAlB,CAAP;;QACD,KAAK,QAAL;UACC,OAAO,IAAIQ,yBAAJ,CAAkB;YACxBR,GAAG,EAAHA,GADwB;YAExBS,OAAO,EAAE,IAAIC,0BAAJ,CAAmBV,GAAnB;UAFe,CAAlB,CAAP;;QAID,KAAK,MAAL;UACC,OAAO,IAAIW,uBAAJ,CAAgBX,GAAhB,EAAqB;YAAA,OAC3B,KAAI,CAACK,OAAL,CAAaL,GAAb,EAAkB,SAAlB,CAD2B;UAAA,CAArB,CAAP;;QAGD,KAAK,SAAL;UAAgB;YACf,OAAO,IAAIU,0BAAJ,CAAmBV,GAAnB,CAAP;UACA;;QACD,KAAK,QAAL;UACC,OAAO,IAAIY,yBAAJ,CAAkB,IAAIN,4BAAJ,CAAeN,GAAf,CAAlB,CAAP;;QACD,KAAK,aAAL;UACC,OAAO,IAAIa,8BAAJ,CACN,KAAKC,kBAAL,CAAwBd,GAAxB,CADM,CAAP;;QAGD,KAAK,UAAL;UACC,OAAO,IAAIe,iCAAJ,CAAiCf,GAAjC,CAAP;;QACD,KAAK,YAAL;UACC,OAAO,IAAIgB,6BAAJ,CACN,IAAID,iCAAJ,CAAiCf,GAAjC,CADM,CAAP;;QAGD,KAAK,QAAL;UACC,OAAO,KAAKc,kBAAL,CAAwBd,GAAxB,CAAP;;QACD,KAAK,OAAL;UAAc;YACb,IAAMiB,cAAc,GAAG,IAAIP,0BAAJ,CAAmBV,GAAnB,CAAvB;YACA,OAAO,IAAIkB,wBAAJ,CACND,cADM,EAEN,IAAIN,uBAAJ,CAAgBX,GAAhB,EAAqB;cAAA,OAAM,KAAI,CAACK,OAAL,CAAaL,GAAb,EAAkB,SAAlB,CAAN;YAAA,CAArB,CAFM,CAAP;UAIA;;QACD,KAAK,eAAL;UACC,OAAO,IAAImB,gCAAJ,CACN,IAAIJ,iCAAJ,CAAoBf,GAApB,CADM,CAAP;;QAGD;UACC,MAAM,IAAIoB,KAAJ,qBAAsBnB,IAAtB,kBAAN;MAlDF;IAoDA,C;;;WAED,4BAA2BD,GAA3B,EAAuD;MACtD,OAAO,IAAIqB,yBAAJ,CAAkB;QACxBrB,GAAG,EAAHA,GADwB;QAExBS,OAAO,EAAE,IAAIC,0BAAJ,CAAmBV,GAAnB;MAFe,CAAlB,CAAP;IAIA"}
1
+ {"version":3,"file":"ServiceFactory.js","names":["ServiceFactory","cwd","type","AuthService","Auth","PkgService","Service","EnvService","VsCodeService","SchemaService","command","CommandService","LintService","RemoteService","TypeCheckerService","buildImportService","SettingsService","DependencyService","commandService","BuildService","EventSettingsService","Error","ImportService"],"sources":["../../src/services/ServiceFactory.ts"],"sourcesContent":["import {\n\tSettingsService,\n\tEnvService,\n\tAuthService,\n} from '@sprucelabs/spruce-skill-utils'\nimport EventSettingsService from '../features/event/services/EventSettingsService'\nimport RemoteService from '../features/event/services/RemoteService'\nimport { FeatureCode } from '../features/features.types'\nimport SchemaService from '../features/schema/services/SchemaService'\nimport VsCodeService from '../features/vscode/services/VsCodeService'\nimport BuildService from './BuildService'\nimport CommandService from './CommandService'\nimport DependencyService from './DependencyService'\nimport ImportService from './ImportService'\nimport LintService from './LintService'\nimport PkgService from './PkgService'\nimport TypeCheckerService from './TypeCheckerService'\n\nexport interface ServiceMap {\n\tpkg: PkgService\n\tvsCode: VsCodeService\n\tschema: SchemaService\n\tlint: LintService\n\tcommand: CommandService\n\ttypeChecker: TypeCheckerService\n\timport: ImportService\n\tbuild: BuildService\n\tsettings: SettingsService\n\tenv: EnvService\n\tauth: AuthService\n\tremote: RemoteService\n\teventSettings: EventSettingsService\n\tdependency: DependencyService\n}\n\nexport type Service = keyof ServiceMap\n\nexport interface ServiceProvider {\n\tService<S extends Service>(type: S, cwd?: string): ServiceMap[S]\n}\nexport default class ServiceFactory {\n\tpublic Service<S extends Service>(cwd: string, type: S): ServiceMap[S] {\n\t\tswitch (type) {\n\t\t\tcase 'auth':\n\t\t\t\treturn AuthService.Auth(cwd) as ServiceMap[S]\n\t\t\tcase 'pkg':\n\t\t\t\treturn new PkgService(\n\t\t\t\t\tcwd,\n\t\t\t\t\tthis.Service(cwd, 'command')\n\t\t\t\t) as ServiceMap[S]\n\t\t\tcase 'env':\n\t\t\t\treturn new EnvService(cwd) as ServiceMap[S]\n\t\t\tcase 'vsCode':\n\t\t\t\treturn new VsCodeService(cwd) as ServiceMap[S]\n\t\t\tcase 'schema':\n\t\t\t\treturn new SchemaService({\n\t\t\t\t\tcwd,\n\t\t\t\t\tcommand: new CommandService(cwd),\n\t\t\t\t}) as ServiceMap[S]\n\t\t\tcase 'lint':\n\t\t\t\treturn new LintService(cwd, () =>\n\t\t\t\t\tthis.Service(cwd, 'command')\n\t\t\t\t) as ServiceMap[S]\n\t\t\tcase 'command': {\n\t\t\t\treturn new CommandService(cwd) as ServiceMap[S]\n\t\t\t}\n\t\t\tcase 'remote':\n\t\t\t\treturn new RemoteService(new EnvService(cwd)) as ServiceMap[S]\n\t\t\tcase 'typeChecker':\n\t\t\t\treturn new TypeCheckerService(\n\t\t\t\t\tthis.buildImportService(cwd)\n\t\t\t\t) as ServiceMap[S]\n\t\t\tcase 'settings':\n\t\t\t\treturn new SettingsService<FeatureCode>(cwd) as ServiceMap[S]\n\t\t\tcase 'dependency':\n\t\t\t\treturn new DependencyService(\n\t\t\t\t\tnew SettingsService<FeatureCode>(cwd)\n\t\t\t\t) as ServiceMap[S]\n\t\t\tcase 'import':\n\t\t\t\treturn this.buildImportService(cwd) as ServiceMap[S]\n\t\t\tcase 'build': {\n\t\t\t\tconst commandService = new CommandService(cwd)\n\t\t\t\treturn new BuildService(\n\t\t\t\t\tcommandService,\n\t\t\t\t\tnew LintService(cwd, () => this.Service(cwd, 'command'))\n\t\t\t\t) as ServiceMap[S]\n\t\t\t}\n\t\t\tcase 'eventSettings':\n\t\t\t\treturn new EventSettingsService(\n\t\t\t\t\tnew SettingsService(cwd)\n\t\t\t\t) as ServiceMap[S]\n\t\t\tdefault:\n\t\t\t\tthrow new Error(`Service \"${type}\" not found`)\n\t\t}\n\t}\n\n\tprivate buildImportService(cwd: string): ImportService {\n\t\treturn new ImportService({\n\t\t\tcwd,\n\t\t\tcommand: new CommandService(cwd),\n\t\t})\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;AAAA;;AAKA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;IAwBqBA,c;;;;;;;;;;;;;;;;;MACpB,UAAkCC,GAAlC,EAA+CC,IAA/C,EAAuE;MAAA;;MACtE,QAAQA,IAAR;QACC,KAAK,MAAL;UACC,OAAOC,6BAAA,CAAYC,IAAZ,CAAiBH,GAAjB,CAAP;;QACD,KAAK,KAAL;UACC,OAAO,IAAII,sBAAJ,CACNJ,GADM,EAEN,KAAKK,OAAL,CAAaL,GAAb,EAAkB,SAAlB,CAFM,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,CACN,IAAIJ,iCAAJ,CAAoBf,GAApB,CADM,CAAP;;QAGD;UACC,MAAM,IAAIoB,KAAJ,qBAAsBnB,IAAtB,kBAAN;MAlDF;IAoDA,C;;;WAED,4BAA2BD,GAA3B,EAAuD;MACtD,OAAO,IAAIqB,yBAAJ,CAAkB;QACxBrB,GAAG,EAAHA,GADwB;QAExBS,OAAO,EAAE,IAAIC,0BAAJ,CAAmBV,GAAnB;MAFe,CAAlB,CAAP;IAIA"}
@@ -1 +1 @@
1
- {"version":3,"file":"EventTemplateItemBuilder.js","names":["EventTemplateItemBuilder","options","contracts","localNamespace","eventBuilderFile","eventContractTemplateItems","schemaTemplateItems","contract","buildTemplateItemsForContract","schemaItems","contractItems","push","sort","a","b","nameCamel","fullyQualifiedEventName","namedSignatures","eventContractUtil","getNamedEventSignatures","namedSig","mapEventSigsToSchemaTemplateItems","signatureTemplateItem","buildEventSigTemplateItem","emitPayloadSchemaTemplateItem","emitPayloadSchema","responsePayloadSchemaTemplateItem","responsePayloadSchema","SchemaError","code","parameters","friendlyMessages","item","buildTemplateItemForEventSignature","eventNamespace","isLocal","namespacePascal","sigToNamespacePascal","namesUtil","toCamel","eventName","namePascal","toPascal","version","namespace","toKebab","MERCURY_API_NAMESPACE","namespaceCamel","imports","filter","i","map","schemaDiskUtil","resolvePath","destination","schema","shouldIncludeFileExtension","importAs","eventSignatures","signature","listenPermissionContract","emitPermissionContract","find","id","schemasByNamespace","mapEventSigsToSchemasByNamepace","schemaTemplateItemBuilder","SchemaTemplateItemBuilder","buildTemplateItems"],"sources":["../../src/templateItemBuilders/EventTemplateItemBuilder.ts"],"sourcesContent":["import { EventContract } from '@sprucelabs/mercury-types'\nimport { Schema, SchemaError, SchemaTemplateItem } from '@sprucelabs/schema'\nimport {\n\teventContractUtil,\n\tNamedEventSignature,\n} from '@sprucelabs/spruce-event-utils'\nimport {\n\tMERCURY_API_NAMESPACE,\n\tnamesUtil,\n} from '@sprucelabs/spruce-skill-utils'\nimport {\n\tEventContractTemplateItem,\n\tEventSignatureTemplateItem,\n} from '@sprucelabs/spruce-templates'\nimport schemaDiskUtil from '../features/schema/utilities/schemaDisk.utility'\nimport SchemaTemplateItemBuilder from './SchemaTemplateItemBuilder'\n\nexport default class EventTemplateItemBuilder {\n\tpublic buildTemplateItems(options: {\n\t\tcontracts: EventContract[]\n\t\tlocalNamespace?: string\n\t\teventBuilderFile?: string\n\t}): {\n\t\teventContractTemplateItems: EventContractTemplateItem[]\n\t\tschemaTemplateItems: SchemaTemplateItem[]\n\t} {\n\t\tconst { contracts, localNamespace, eventBuilderFile } = options\n\n\t\tconst eventContractTemplateItems: EventContractTemplateItem[] = []\n\t\tconst schemaTemplateItems: SchemaTemplateItem[] = []\n\n\t\tfor (const contract of contracts) {\n\t\t\tconst {\n\t\t\t\tschemaTemplateItems: schemaItems,\n\t\t\t\teventContractTemplateItems: contractItems,\n\t\t\t} = this.buildTemplateItemsForContract(\n\t\t\t\tcontract,\n\t\t\t\tlocalNamespace,\n\t\t\t\teventBuilderFile\n\t\t\t)\n\n\t\t\teventContractTemplateItems.push(...contractItems)\n\t\t\tschemaTemplateItems.push(...schemaItems)\n\t\t}\n\n\t\teventContractTemplateItems.sort((a, b) => {\n\t\t\tif (a.nameCamel > b.nameCamel) {\n\t\t\t\treturn 1\n\t\t\t} else if (a.nameCamel < b.nameCamel) {\n\t\t\t\treturn -1\n\t\t\t}\n\n\t\t\treturn 0\n\t\t})\n\n\t\treturn { eventContractTemplateItems, schemaTemplateItems }\n\t}\n\n\tpublic buildEventTemplateItemForName(\n\t\tcontracts: EventContract[],\n\t\tfullyQualifiedEventName: string\n\t): {\n\t\tresponsePayloadSchemaTemplateItem: SchemaTemplateItem | undefined\n\t\temitPayloadSchemaTemplateItem: SchemaTemplateItem | undefined\n\t} {\n\t\tfor (const contract of contracts) {\n\t\t\tconst namedSignatures =\n\t\t\t\teventContractUtil.getNamedEventSignatures(contract)\n\n\t\t\tfor (const namedSig of namedSignatures) {\n\t\t\t\tif (namedSig.fullyQualifiedEventName === fullyQualifiedEventName) {\n\t\t\t\t\tconst schemaTemplateItems: SchemaTemplateItem[] =\n\t\t\t\t\t\tthis.mapEventSigsToSchemaTemplateItems(namedSignatures)\n\n\t\t\t\t\tconst signatureTemplateItem: EventSignatureTemplateItem =\n\t\t\t\t\t\tthis.buildEventSigTemplateItem(namedSig, schemaTemplateItems)\n\n\t\t\t\t\treturn {\n\t\t\t\t\t\temitPayloadSchemaTemplateItem:\n\t\t\t\t\t\t\tsignatureTemplateItem.emitPayloadSchema,\n\t\t\t\t\t\tresponsePayloadSchemaTemplateItem:\n\t\t\t\t\t\t\tsignatureTemplateItem.responsePayloadSchema,\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tthrow new SchemaError({\n\t\t\tcode: 'INVALID_PARAMETERS',\n\t\t\tparameters: ['fullyQualifiedEventName'],\n\t\t\tfriendlyMessages: [\n\t\t\t\t`I could not find any events that match ${fullyQualifiedEventName}.`,\n\t\t\t],\n\t\t})\n\t}\n\n\tprivate buildTemplateItemsForContract(\n\t\tcontract: EventContract,\n\t\tlocalNamespace?: string,\n\t\teventBuilderFile?: string\n\t): {\n\t\teventContractTemplateItems: EventContractTemplateItem[]\n\t\tschemaTemplateItems: SchemaTemplateItem[]\n\t} {\n\t\tconst namedSignatures = eventContractUtil.getNamedEventSignatures(contract)\n\n\t\tconst schemaTemplateItems: SchemaTemplateItem[] =\n\t\t\tthis.mapEventSigsToSchemaTemplateItems(namedSignatures)\n\n\t\tconst eventContractTemplateItems: EventContractTemplateItem[] = []\n\n\t\tfor (const namedSig of namedSignatures) {\n\t\t\tconst item: EventContractTemplateItem =\n\t\t\t\tthis.buildTemplateItemForEventSignature(\n\t\t\t\t\tnamedSig,\n\t\t\t\t\tschemaTemplateItems,\n\t\t\t\t\tnamedSig.eventNamespace === localNamespace,\n\t\t\t\t\teventBuilderFile\n\t\t\t\t)\n\n\t\t\teventContractTemplateItems.push(item)\n\t\t}\n\n\t\treturn {\n\t\t\teventContractTemplateItems,\n\t\t\tschemaTemplateItems,\n\t\t}\n\t}\n\n\tprivate buildTemplateItemForEventSignature(\n\t\tnamedSig: NamedEventSignature,\n\t\tschemaTemplateItems: SchemaTemplateItem[],\n\t\tisLocal: boolean,\n\t\teventBuilderFile?: string\n\t) {\n\t\tconst namespacePascal = this.sigToNamespacePascal(namedSig)\n\n\t\tconst signatureTemplateItem: EventSignatureTemplateItem =\n\t\t\tthis.buildEventSigTemplateItem(namedSig, schemaTemplateItems)\n\n\t\tconst item: EventContractTemplateItem = {\n\t\t\tnameCamel: namesUtil.toCamel(namedSig.eventName),\n\t\t\tnamePascal: namesUtil.toPascal(namedSig.eventName),\n\t\t\tversion: namedSig.version ?? '***MISSING***',\n\t\t\tisLocal,\n\t\t\tnamespace: namesUtil.toKebab(\n\t\t\t\tnamedSig.eventNamespace ?? MERCURY_API_NAMESPACE\n\t\t\t),\n\t\t\tnamespaceCamel: namesUtil.toCamel(\n\t\t\t\tnamedSig.eventNamespace ?? MERCURY_API_NAMESPACE\n\t\t\t),\n\t\t\timports: [\n\t\t\t\tsignatureTemplateItem.emitPayloadSchema as SchemaTemplateItem,\n\t\t\t\tsignatureTemplateItem.responsePayloadSchema as SchemaTemplateItem,\n\t\t\t]\n\t\t\t\t.filter((i) => !!i)\n\t\t\t\t.map((item: SchemaTemplateItem) => ({\n\t\t\t\t\tpackage: schemaDiskUtil.resolvePath({\n\t\t\t\t\t\tdestination: '#spruce/schemas',\n\t\t\t\t\t\tschema: item.schema,\n\t\t\t\t\t\tshouldIncludeFileExtension: false,\n\t\t\t\t\t}),\n\t\t\t\t\timportAs: `${item.nameCamel}Schema`,\n\t\t\t\t})),\n\t\t\tnamespacePascal,\n\t\t\teventSignatures: {\n\t\t\t\t[namedSig.fullyQualifiedEventName]: signatureTemplateItem,\n\t\t\t},\n\t\t}\n\n\t\titem.imports.push({\n\t\t\timportAs: '{ buildEventContract }',\n\t\t\tpackage: eventBuilderFile ?? '@sprucelabs/mercury-types',\n\t\t})\n\n\t\tif (\n\t\t\tnamedSig.signature.listenPermissionContract ||\n\t\t\tnamedSig.signature.emitPermissionContract\n\t\t) {\n\t\t\titem.imports.push({\n\t\t\t\timportAs: '{ buildPermissionContract }',\n\t\t\t\tpackage: eventBuilderFile ?? '@sprucelabs/mercury-types',\n\t\t\t})\n\t\t}\n\n\t\treturn item\n\t}\n\n\tprivate buildEventSigTemplateItem(\n\t\tnamedSig: NamedEventSignature,\n\t\tschemaItems: SchemaTemplateItem[]\n\t) {\n\t\tconst { emitPayloadSchema, responsePayloadSchema, ...signature } =\n\t\t\tnamedSig.signature\n\n\t\tconst signatureTemplateItem: EventSignatureTemplateItem = { ...signature }\n\n\t\tif (emitPayloadSchema) {\n\t\t\tsignatureTemplateItem.emitPayloadSchema = schemaItems.find(\n\t\t\t\t(i) =>\n\t\t\t\t\ti.id === emitPayloadSchema.id &&\n\t\t\t\t\t(!emitPayloadSchema.namespace ||\n\t\t\t\t\t\ti.namespace === emitPayloadSchema.namespace)\n\t\t\t)\n\t\t}\n\n\t\tif (responsePayloadSchema) {\n\t\t\tsignatureTemplateItem.responsePayloadSchema = schemaItems.find(\n\t\t\t\t(i) =>\n\t\t\t\t\ti.id === responsePayloadSchema.id &&\n\t\t\t\t\t(!responsePayloadSchema.namespace ||\n\t\t\t\t\t\ti.namespace === responsePayloadSchema.namespace)\n\t\t\t)\n\t\t}\n\t\treturn signatureTemplateItem\n\t}\n\n\tprivate mapEventSigsToSchemaTemplateItems(\n\t\tnamedSignatures: NamedEventSignature[]\n\t) {\n\t\tconst schemasByNamespace: Record<string, Schema[]> =\n\t\t\tthis.mapEventSigsToSchemasByNamepace(namedSignatures)\n\n\t\tconst schemaTemplateItemBuilder = new SchemaTemplateItemBuilder('Cli')\n\t\tconst schemaItems: SchemaTemplateItem[] =\n\t\t\tschemaTemplateItemBuilder.buildTemplateItems(\n\t\t\t\tschemasByNamespace,\n\t\t\t\t'#spruce/events'\n\t\t\t)\n\n\t\treturn schemaItems\n\t}\n\n\tprivate mapEventSigsToSchemasByNamepace(\n\t\tnamedSignatures: NamedEventSignature[]\n\t) {\n\t\tconst schemasByNamespace: Record<string, Schema[]> = {}\n\n\t\tfor (const namedSig of namedSignatures) {\n\t\t\tconst namespacePascal = this.sigToNamespacePascal(namedSig)\n\t\t\tconst { emitPayloadSchema, responsePayloadSchema } = namedSig.signature\n\n\t\t\tif (!schemasByNamespace[namespacePascal]) {\n\t\t\t\tschemasByNamespace[namespacePascal] = []\n\t\t\t}\n\n\t\t\tif (emitPayloadSchema) {\n\t\t\t\tschemasByNamespace[namespacePascal].push({\n\t\t\t\t\tversion: namedSig.version,\n\t\t\t\t\t...emitPayloadSchema,\n\t\t\t\t})\n\t\t\t}\n\n\t\t\tif (responsePayloadSchema) {\n\t\t\t\tschemasByNamespace[namespacePascal].push({\n\t\t\t\t\tversion: namedSig.version,\n\t\t\t\t\t...responsePayloadSchema,\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\n\t\treturn schemasByNamespace\n\t}\n\n\tprivate sigToNamespacePascal(namedSig: NamedEventSignature) {\n\t\treturn namesUtil.toPascal(namedSig.eventNamespace ?? MERCURY_API_NAMESPACE)\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AACA;;AACA;;AAIA;;AAQA;;AACA;;;;;;;;;;;;;;IAEqBA,wB;;;;;;;WACpB,4BAA0BC,OAA1B,EAOE;MACD,IAAQC,SAAR,GAAwDD,OAAxD,CAAQC,SAAR;MAAA,IAAmBC,cAAnB,GAAwDF,OAAxD,CAAmBE,cAAnB;MAAA,IAAmCC,gBAAnC,GAAwDH,OAAxD,CAAmCG,gBAAnC;MAEA,IAAMC,0BAAuD,GAAG,EAAhE;MACA,IAAMC,mBAAyC,GAAG,EAAlD;;MAJC,2CAMsBJ,SANtB;MAAA;;MAAA;QAMD,oDAAkC;UAAA,IAAvBK,QAAuB;;UACjC,4BAGI,KAAKC,6BAAL,CACHD,QADG,EAEHJ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;UACA,2BAAqDA,QAAQ,CAACuC,SAA9D;UAAA,IAAQlC,iBAAR,wBAAQA,iBAAR;UAAA,IAA2BE,qBAA3B,wBAA2BA,qBAA3B;;UAEA,IAAI,CAACqC,kBAAkB,CAAC5B,eAAD,CAAvB,EAA0C;YACzC4B,kBAAkB,CAAC5B,eAAD,CAAlB,GAAsC,EAAtC;UACA;;UAED,IAAIX,iBAAJ,EAAuB;YACtBuC,kBAAkB,CAAC5B,eAAD,CAAlB,CAAoCzB,IAApC;cACCgC,OAAO,EAAEvB,QAAQ,CAACuB;YADnB,GAEIlB,iBAFJ;UAIA;;UAED,IAAIE,qBAAJ,EAA2B;YAC1BqC,kBAAkB,CAAC5B,eAAD,CAAlB,CAAoCzB,IAApC;cACCgC,OAAO,EAAEvB,QAAQ,CAACuB;YADnB,GAEIhB,qBAFJ;UAIA;QACD;MAxBA;QAAA;MAAA;QAAA;MAAA;;MA0BD,OAAOqC,kBAAP;IACA;;;WAED,8BAA6B5C,QAA7B,EAA4D;MAAA;;MAC3D,OAAOkB,4BAAUI,QAAV,2BAAmBtB,QAAQ,CAACc,cAA5B,2EAA8CY,uCAA9C,CAAP;IACA"}
1
+ {"version":3,"file":"EventTemplateItemBuilder.js","names":["EventTemplateItemBuilder","options","contracts","localNamespace","eventBuilderFile","eventContractTemplateItems","schemaTemplateItems","contract","buildTemplateItemsForContract","schemaItems","contractItems","push","sort","a","b","nameCamel","fullyQualifiedEventName","namedSignatures","eventContractUtil","getNamedEventSignatures","namedSig","mapEventSigsToSchemaTemplateItems","signatureTemplateItem","buildEventSigTemplateItem","emitPayloadSchemaTemplateItem","emitPayloadSchema","responsePayloadSchemaTemplateItem","responsePayloadSchema","SchemaError","code","parameters","friendlyMessages","item","buildTemplateItemForEventSignature","eventNamespace","isLocal","namespacePascal","sigToNamespacePascal","namesUtil","toCamel","eventName","namePascal","toPascal","version","namespace","toKebab","MERCURY_API_NAMESPACE","namespaceCamel","imports","filter","i","map","schemaDiskUtil","resolvePath","destination","schema","shouldIncludeFileExtension","importAs","eventSignatures","signature","listenPermissionContract","emitPermissionContract","find","id","schemasByNamespace","mapEventSigsToSchemasByNamepace","schemaTemplateItemBuilder","SchemaTemplateItemBuilder","buildTemplateItems"],"sources":["../../src/templateItemBuilders/EventTemplateItemBuilder.ts"],"sourcesContent":["import { EventContract } from '@sprucelabs/mercury-types'\nimport { Schema, SchemaError, SchemaTemplateItem } from '@sprucelabs/schema'\nimport {\n\teventContractUtil,\n\tNamedEventSignature,\n} from '@sprucelabs/spruce-event-utils'\nimport {\n\tMERCURY_API_NAMESPACE,\n\tnamesUtil,\n} from '@sprucelabs/spruce-skill-utils'\nimport {\n\tEventContractTemplateItem,\n\tEventSignatureTemplateItem,\n} from '@sprucelabs/spruce-templates'\nimport schemaDiskUtil from '../features/schema/utilities/schemaDisk.utility'\nimport SchemaTemplateItemBuilder from './SchemaTemplateItemBuilder'\n\nexport default class EventTemplateItemBuilder {\n\tpublic buildTemplateItems(options: {\n\t\tcontracts: EventContract[]\n\t\tlocalNamespace?: string\n\t\teventBuilderFile?: string\n\t}): {\n\t\teventContractTemplateItems: EventContractTemplateItem[]\n\t\tschemaTemplateItems: SchemaTemplateItem[]\n\t} {\n\t\tconst { contracts, localNamespace, eventBuilderFile } = options\n\n\t\tconst eventContractTemplateItems: EventContractTemplateItem[] = []\n\t\tconst schemaTemplateItems: SchemaTemplateItem[] = []\n\n\t\tfor (const contract of contracts) {\n\t\t\tconst {\n\t\t\t\tschemaTemplateItems: schemaItems,\n\t\t\t\teventContractTemplateItems: contractItems,\n\t\t\t} = this.buildTemplateItemsForContract(\n\t\t\t\tcontract,\n\t\t\t\tlocalNamespace,\n\t\t\t\teventBuilderFile\n\t\t\t)\n\n\t\t\teventContractTemplateItems.push(...contractItems)\n\t\t\tschemaTemplateItems.push(...schemaItems)\n\t\t}\n\n\t\teventContractTemplateItems.sort((a, b) => {\n\t\t\tif (a.nameCamel > b.nameCamel) {\n\t\t\t\treturn 1\n\t\t\t} else if (a.nameCamel < b.nameCamel) {\n\t\t\t\treturn -1\n\t\t\t}\n\n\t\t\treturn 0\n\t\t})\n\n\t\treturn { eventContractTemplateItems, schemaTemplateItems }\n\t}\n\n\tpublic buildEventTemplateItemForName(\n\t\tcontracts: EventContract[],\n\t\tfullyQualifiedEventName: string\n\t): {\n\t\tresponsePayloadSchemaTemplateItem: SchemaTemplateItem | undefined\n\t\temitPayloadSchemaTemplateItem: SchemaTemplateItem | undefined\n\t} {\n\t\tfor (const contract of contracts) {\n\t\t\tconst namedSignatures =\n\t\t\t\teventContractUtil.getNamedEventSignatures(contract)\n\n\t\t\tfor (const namedSig of namedSignatures) {\n\t\t\t\tif (namedSig.fullyQualifiedEventName === fullyQualifiedEventName) {\n\t\t\t\t\tconst schemaTemplateItems: SchemaTemplateItem[] =\n\t\t\t\t\t\tthis.mapEventSigsToSchemaTemplateItems(namedSignatures)\n\n\t\t\t\t\tconst signatureTemplateItem: EventSignatureTemplateItem =\n\t\t\t\t\t\tthis.buildEventSigTemplateItem(namedSig, schemaTemplateItems)\n\n\t\t\t\t\treturn {\n\t\t\t\t\t\temitPayloadSchemaTemplateItem:\n\t\t\t\t\t\t\tsignatureTemplateItem.emitPayloadSchema,\n\t\t\t\t\t\tresponsePayloadSchemaTemplateItem:\n\t\t\t\t\t\t\tsignatureTemplateItem.responsePayloadSchema,\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tthrow new SchemaError({\n\t\t\tcode: 'INVALID_PARAMETERS',\n\t\t\tparameters: ['fullyQualifiedEventName'],\n\t\t\tfriendlyMessages: [\n\t\t\t\t`I could not find any events that match ${fullyQualifiedEventName}.`,\n\t\t\t],\n\t\t})\n\t}\n\n\tprivate buildTemplateItemsForContract(\n\t\tcontract: EventContract,\n\t\tlocalNamespace?: string,\n\t\teventBuilderFile?: string\n\t): {\n\t\teventContractTemplateItems: EventContractTemplateItem[]\n\t\tschemaTemplateItems: SchemaTemplateItem[]\n\t} {\n\t\tconst namedSignatures = eventContractUtil.getNamedEventSignatures(contract)\n\n\t\tconst schemaTemplateItems: SchemaTemplateItem[] =\n\t\t\tthis.mapEventSigsToSchemaTemplateItems(namedSignatures)\n\n\t\tconst eventContractTemplateItems: EventContractTemplateItem[] = []\n\n\t\tfor (const namedSig of namedSignatures) {\n\t\t\tconst item: EventContractTemplateItem =\n\t\t\t\tthis.buildTemplateItemForEventSignature(\n\t\t\t\t\tnamedSig,\n\t\t\t\t\tschemaTemplateItems,\n\t\t\t\t\tnamedSig.eventNamespace === localNamespace,\n\t\t\t\t\teventBuilderFile\n\t\t\t\t)\n\n\t\t\teventContractTemplateItems.push(item)\n\t\t}\n\n\t\treturn {\n\t\t\teventContractTemplateItems,\n\t\t\tschemaTemplateItems,\n\t\t}\n\t}\n\n\tprivate buildTemplateItemForEventSignature(\n\t\tnamedSig: NamedEventSignature,\n\t\tschemaTemplateItems: SchemaTemplateItem[],\n\t\tisLocal: boolean,\n\t\teventBuilderFile?: string\n\t) {\n\t\tconst namespacePascal = this.sigToNamespacePascal(namedSig)\n\n\t\tconst signatureTemplateItem: EventSignatureTemplateItem =\n\t\t\tthis.buildEventSigTemplateItem(namedSig, schemaTemplateItems)\n\n\t\tconst item: EventContractTemplateItem = {\n\t\t\tnameCamel: namesUtil.toCamel(namedSig.eventName),\n\t\t\tnamePascal: namesUtil.toPascal(namedSig.eventName),\n\t\t\tversion: namedSig.version ?? '***MISSING***',\n\t\t\tisLocal,\n\t\t\tnamespace: namesUtil.toKebab(\n\t\t\t\tnamedSig.eventNamespace ?? MERCURY_API_NAMESPACE\n\t\t\t),\n\t\t\tnamespaceCamel: namesUtil.toCamel(\n\t\t\t\tnamedSig.eventNamespace ?? MERCURY_API_NAMESPACE\n\t\t\t),\n\t\t\timports: [\n\t\t\t\tsignatureTemplateItem.emitPayloadSchema as SchemaTemplateItem,\n\t\t\t\tsignatureTemplateItem.responsePayloadSchema as SchemaTemplateItem,\n\t\t\t]\n\t\t\t\t.filter((i) => !!i)\n\t\t\t\t.map((item: SchemaTemplateItem) => ({\n\t\t\t\t\tpackage: schemaDiskUtil.resolvePath({\n\t\t\t\t\t\tdestination: '#spruce/schemas',\n\t\t\t\t\t\tschema: item.schema,\n\t\t\t\t\t\tshouldIncludeFileExtension: false,\n\t\t\t\t\t}),\n\t\t\t\t\timportAs: `${item.nameCamel}Schema`,\n\t\t\t\t})),\n\t\t\tnamespacePascal,\n\t\t\teventSignatures: {\n\t\t\t\t[namedSig.fullyQualifiedEventName]: signatureTemplateItem,\n\t\t\t},\n\t\t}\n\n\t\titem.imports.push({\n\t\t\timportAs: '{ buildEventContract }',\n\t\t\tpackage: eventBuilderFile ?? '@sprucelabs/mercury-types',\n\t\t})\n\n\t\tif (\n\t\t\tnamedSig.signature.listenPermissionContract ||\n\t\t\tnamedSig.signature.emitPermissionContract\n\t\t) {\n\t\t\titem.imports.push({\n\t\t\t\timportAs: '{ buildPermissionContract }',\n\t\t\t\tpackage: eventBuilderFile ?? '@sprucelabs/mercury-types',\n\t\t\t})\n\t\t}\n\n\t\treturn item\n\t}\n\n\tprivate buildEventSigTemplateItem(\n\t\tnamedSig: NamedEventSignature,\n\t\tschemaItems: SchemaTemplateItem[]\n\t) {\n\t\tconst { emitPayloadSchema, responsePayloadSchema, ...signature } =\n\t\t\tnamedSig.signature\n\n\t\tconst signatureTemplateItem: EventSignatureTemplateItem = { ...signature }\n\n\t\tif (emitPayloadSchema) {\n\t\t\tsignatureTemplateItem.emitPayloadSchema = schemaItems.find(\n\t\t\t\t(i) =>\n\t\t\t\t\ti.id === emitPayloadSchema.id &&\n\t\t\t\t\t(!emitPayloadSchema.namespace ||\n\t\t\t\t\t\ti.namespace === emitPayloadSchema.namespace)\n\t\t\t)\n\t\t}\n\n\t\tif (responsePayloadSchema) {\n\t\t\tsignatureTemplateItem.responsePayloadSchema = schemaItems.find(\n\t\t\t\t(i) =>\n\t\t\t\t\ti.id === responsePayloadSchema.id &&\n\t\t\t\t\t(!responsePayloadSchema.namespace ||\n\t\t\t\t\t\ti.namespace === responsePayloadSchema.namespace)\n\t\t\t)\n\t\t}\n\t\treturn signatureTemplateItem\n\t}\n\n\tprivate mapEventSigsToSchemaTemplateItems(\n\t\tnamedSignatures: NamedEventSignature[]\n\t) {\n\t\tconst schemasByNamespace: Record<string, Schema[]> =\n\t\t\tthis.mapEventSigsToSchemasByNamepace(namedSignatures)\n\n\t\tconst schemaTemplateItemBuilder = new SchemaTemplateItemBuilder('Cli')\n\t\tconst schemaItems: SchemaTemplateItem[] =\n\t\t\tschemaTemplateItemBuilder.buildTemplateItems(\n\t\t\t\tschemasByNamespace,\n\t\t\t\t'#spruce/events'\n\t\t\t)\n\n\t\treturn schemaItems\n\t}\n\n\tprivate mapEventSigsToSchemasByNamepace(\n\t\tnamedSignatures: NamedEventSignature[]\n\t) {\n\t\tconst schemasByNamespace: Record<string, Schema[]> = {}\n\n\t\tfor (const namedSig of namedSignatures) {\n\t\t\tconst namespacePascal = this.sigToNamespacePascal(namedSig)\n\t\t\tconst { emitPayloadSchema, responsePayloadSchema } = namedSig.signature\n\n\t\t\tif (!schemasByNamespace[namespacePascal]) {\n\t\t\t\tschemasByNamespace[namespacePascal] = []\n\t\t\t}\n\n\t\t\tif (emitPayloadSchema) {\n\t\t\t\tschemasByNamespace[namespacePascal].push({\n\t\t\t\t\tversion: namedSig.version,\n\t\t\t\t\t...emitPayloadSchema,\n\t\t\t\t})\n\t\t\t}\n\n\t\t\tif (responsePayloadSchema) {\n\t\t\t\tschemasByNamespace[namespacePascal].push({\n\t\t\t\t\tversion: namedSig.version,\n\t\t\t\t\t...responsePayloadSchema,\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\n\t\treturn schemasByNamespace\n\t}\n\n\tprivate sigToNamespacePascal(namedSig: NamedEventSignature) {\n\t\treturn namesUtil.toPascal(namedSig.eventNamespace ?? MERCURY_API_NAMESPACE)\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AACA;;AACA;;AAIA;;AAQ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ilder.js","names":["FieldTemplateItemBuilder","fields","templateItems","generatedImportAsCount","field","registration","name","className","pkg","importAs","isLocal","item","namePascal","namesUtil","toPascal","nameCamel","toCamel","nameReadable","pascalType","type","camelType","description","valueTypeMapper","push"],"sources":["../../src/templateItemBuilders/FieldTemplateItemBuilder.ts"],"sourcesContent":["import { FieldTemplateItem } from '@sprucelabs/schema'\nimport { namesUtil } from '@sprucelabs/spruce-skill-utils'\nimport { FetchedField } from '../features/schema/stores/SchemaStore'\n\nexport default class FieldTemplateItemBuilder {\n\tpublic generateTemplateItems(fields: FetchedField[]) {\n\t\tconst templateItems: FieldTemplateItem[] = []\n\t\tlet generatedImportAsCount = 0\n\n\t\tfor (let field of fields) {\n\t\t\tconst { registration } = field\n\t\t\tconst name = registration.className\n\t\t\tlet pkg = registration.package\n\t\t\tlet importAs = registration.importAs\n\n\t\t\tif (field.isLocal) {\n\t\t\t\tpkg = `#spruce/../fields/${registration.className}`\n\t\t\t\timportAs = `generated_import_${generatedImportAsCount++}`\n\t\t\t}\n\n\t\t\tconst item: FieldTemplateItem = {\n\t\t\t\tnamePascal: namesUtil.toPascal(name),\n\t\t\t\tnameCamel: namesUtil.toCamel(name),\n\t\t\t\tpackage: pkg,\n\t\t\t\tclassName: registration.className,\n\t\t\t\timportAs,\n\t\t\t\tnameReadable: registration.className,\n\t\t\t\tpascalType: namesUtil.toPascal(registration.type),\n\t\t\t\tcamelType: namesUtil.toCamel(registration.type),\n\t\t\t\tisLocal: field.isLocal,\n\t\t\t\tdescription: registration.description,\n\t\t\t\tvalueTypeMapper: registration.valueTypeMapper,\n\t\t\t}\n\n\t\t\tgeneratedImportAsCount++\n\n\t\t\ttemplateItems.push(item)\n\t\t}\n\n\t\treturn templateItems\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;AACA;;;;;;;;IAGqBA,wB;;;;;;;WACpB,+BAA6BC,MAA7B,EAAqD;MACpD,IAAMC,aAAkC,GAAG,EAA3C;MACA,IAAIC,sBAAsB,GAAG,CAA7B;;MAFoD,2CAIlCF,MAJkC;MAAA;;MAAA;QAIpD,oDAA0B;UAAA,IAAjBG,KAAiB;UACzB,IAAQC,YAAR,GAAyBD,KAAzB,CAAQC,YAAR;UACA,IAAMC,IAAI,GAAGD,YAAY,CAACE,SAA1B;UACA,IAAIC,GAAG,GAAGH,YAAY,WAAtB;UACA,IAAII,QAAQ,GAAGJ,YAAY,CAACI,QAA5B;;UAEA,IAAIL,KAAK,CAACM,OAAV,EAAmB;YAClBF,GAAG,+BAAwBH,YAAY,CAACE,SAArC,CAAH;YACAE,QAAQ,8BAAuBN,sBAAsB,EAA7C,CAAR;UACA;;UAED,IAAMQ,IAAuB,GAAG;YAC/BC,UAAU,EAAEC,4BAAUC,QAAV,CAAmBR,IAAnB,CADmB;YAE/BS,SAAS,EAAEF,4BAAUG,OAAV,CAAkBV,IAAlB,CAFoB;YAG/B,WAASE,GAHsB;YAI/BD,SAAS,EAAEF,YAAY,CAACE,SAJO;YAK/BE,QAAQ,EAARA,QAL+B;YAM/BQ,YAAY,EAAEZ,YAAY,CAACE,SANI;YAO/BW,UAAU,EAAEL,4BAAUC,QAAV,CAAmBT,YAAY,CAACc,IAAhC,CAPmB;YAQ/BC,SAAS,EAAEP,4BAAUG,OAAV,CAAkBX,YAAY,CAACc,IAA/B,CARoB;YAS/BT,OAAO,EAAEN,KAAK,CAACM,OATgB;YAU/BW,WAAW,EAAEhB,YAAY,CAACgB,WAVK;YAW/BC,eAAe,EAAEjB,YAAY,CAACiB;UAXC,CAAhC;UAcAnB,sBAAsB;UAEtBD,aAAa,CAACqB,IAAd,CAAmBZ,IAAnB;QACA;MAhCmD;QAAA;MAAA;QAAA;MAAA;;MAkCpD,OAAOT,aAAP;IACA"}
1
+ {"version":3,"file":"FieldTemplateItemBuilder.js","names":["FieldTemplateItemBuilder","fields","templateItems","generatedImportAsCount","field","registration","name","className","pkg","importAs","isLocal","item","namePascal","namesUtil","toPascal","nameCamel","toCamel","nameReadable","pascalType","type","camelType","description","valueTypeMapper","push"],"sources":["../../src/templateItemBuilders/FieldTemplateItemBuilder.ts"],"sourcesContent":["import { FieldTemplateItem } from '@sprucelabs/schema'\nimport { namesUtil } from '@sprucelabs/spruce-skill-utils'\nimport { FetchedField } from '../features/schema/stores/SchemaStore'\n\nexport default class FieldTemplateItemBuilder {\n\tpublic generateTemplateItems(fields: FetchedField[]) {\n\t\tconst templateItems: FieldTemplateItem[] = []\n\t\tlet generatedImportAsCount = 0\n\n\t\tfor (let field of fields) {\n\t\t\tconst { registration } = field\n\t\t\tconst name = registration.className\n\t\t\tlet pkg = registration.package\n\t\t\tlet importAs = registration.importAs\n\n\t\t\tif (field.isLocal) {\n\t\t\t\tpkg = `#spruce/../fields/${registration.className}`\n\t\t\t\timportAs = `generated_import_${generatedImportAsCount++}`\n\t\t\t}\n\n\t\t\tconst item: FieldTemplateItem = {\n\t\t\t\tnamePascal: namesUtil.toPascal(name),\n\t\t\t\tnameCamel: namesUtil.toCamel(name),\n\t\t\t\tpackage: pkg,\n\t\t\t\tclassName: registration.className,\n\t\t\t\timportAs,\n\t\t\t\tnameReadable: registration.className,\n\t\t\t\tpascalType: namesUtil.toPascal(registration.type),\n\t\t\t\tcamelType: namesUtil.toCamel(registration.type),\n\t\t\t\tisLocal: field.isLocal,\n\t\t\t\tdescription: registration.description,\n\t\t\t\tvalueTypeMapper: registration.valueTypeMapper,\n\t\t\t}\n\n\t\t\tgeneratedImportAsCount++\n\n\t\t\ttemplateItems.push(item)\n\t\t}\n\n\t\treturn templateItems\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;AACA;;;;;;;;IAGqBA,wB;;;;;;;WACpB,+BAA6BC,MAA7B,EAAqD;MACpD,IAAMC,aAAkC,GAAG,EAA3C;MACA,IAAIC,sBAAsB,GAAG,CAA7B;;MAFoD,2CAIlCF,MAJkC;MAAA;;MAAA;QAIpD,oDAA0B;UAAA,IAAjBG,KAAiB;UACzB,IAAQC,YAAR,GAAyBD,KAAzB,CAAQC,YAAR;UACA,IAAMC,IAAI,GAAGD,YAAY,CAACE,SAA1B;UACA,IAAIC,GAAG,GAAGH,YAAY,WAAtB;UACA,IAAII,QAAQ,GAAGJ,YAAY,CAACI,QAA5B;;UAEA,IAAIL,KAAK,CAACM,OAAV,EAAmB;YAClBF,GAAG,+BAAwBH,YAAY,CAACE,SAArC,CAAH;YACAE,QAAQ,8BAAuBN,sBAAsB,EAA7C,CAAR;UACA;;UAED,IAAMQ,IAAuB,GAAG;YAC/BC,UAAU,EAAEC,2BAAA,CAAUC,QAAV,CAAmBR,IAAnB,CADmB;YAE/BS,SAAS,EAAEF,2BAAA,CAAUG,OAAV,CAAkBV,IAAlB,CAFoB;YAG/B,WAASE,GAHsB;YAI/BD,SAAS,EAAEF,YAAY,CAACE,SAJO;YAK/BE,QAAQ,EAARA,QAL+B;YAM/BQ,YAAY,EAAEZ,YAAY,CAACE,SANI;YAO/BW,UAAU,EAAEL,2BAAA,CAAUC,QAAV,CAAmBT,YAAY,CAACc,IAAhC,CAPmB;YAQ/BC,SAAS,EAAEP,2BAAA,CAAUG,OAAV,CAAkBX,YAAY,CAACc,IAA/B,CARoB;YAS/BT,OAAO,EAAEN,KAAK,CAACM,OATgB;YAU/BW,WAAW,EAAEhB,YAAY,CAACgB,WAVK;YAW/BC,eAAe,EAAEjB,YAAY,CAACiB;UAXC,CAAhC;UAcAnB,sBAAsB;UAEtBD,aAAa,CAACqB,IAAd,CAAmBZ,IAAnB;QACA;MAhCmD;QAAA;MAAA;QAAA;MAAA;;MAkCpD,OAAOT,aAAP;IACA"}
@@ -1 +1 @@
1
- {"version":3,"file":"SchemaTemplateItemBuilder.js","names":["SchemaTemplateItemBuilder","localNamespace","schemasByNamespace","destinationDir","schemas","namespaces","Object","keys","namespace","push","map","s","flattenSchemas","flattened","values","schemasByKey","sorted","sort","a","b","doesADependOnB","reverse","schemaTemplateItems","buildTemplateItem","dependencies","idWithVersion","schema","find","dep","forEach","def","flattenSchema","isNested","localSchema","namedFields","pluckFields","field","name","type","schemasOrIdsWithVersion","SchemaField","mapFieldDefinitionToSchemasOrIdsWithVersion","originalOptions","options","schemaId","schemaIds","schemaOrId","related","version","moduleToImportFromWhenRemote","relatedIdWithVersion","length","SpruceError","code","id","schemaNamespace","fieldName","fieldOptions","key","schemaUtil","generateCacheKey","fields","dynamicFieldSignature","dynamicField","importFrom","getImportFromForSchema","item","generateNamesForSchema","toLowerCase","importsWhenLocal","imports","importsWhenRemote","match","CORE_NAMESPACE","undefined"],"sources":["../../src/templateItemBuilders/SchemaTemplateItemBuilder.ts"],"sourcesContent":["import {\n\tSchema,\n\tSchemaTemplateItem,\n\tSchemaField,\n\tSchemaIdWithVersion,\n\tnormalizeSchemaToIdWithVersion,\n\tisIdWithVersion,\n} from '@sprucelabs/schema'\nimport { CORE_NAMESPACE } from '@sprucelabs/spruce-skill-utils'\nimport cloneDeep from 'lodash/cloneDeep'\nimport isEqual from 'lodash/isEqual'\nimport merge from 'lodash/merge'\nimport SpruceError from '../errors/SpruceError'\nimport { SchemasByNamespace } from '../features/schema/stores/SchemaStore'\nimport schemaUtil from '../features/schema/utilities/schema.utility'\n\ninterface SchemaWithDependencies {\n\tschema: Schema\n\tdependencies: SchemaIdWithVersion[]\n\tisNested: boolean\n}\n\nexport default class SchemaTemplateItemBuilder {\n\tprivate schemasByKey: Record<string, SchemaWithDependencies> = {}\n\tprivate localNamespace: string\n\n\tpublic constructor(localNamespace: string) {\n\t\tthis.localNamespace = localNamespace\n\t}\n\n\tpublic buildTemplateItems(\n\t\tschemasByNamespace: SchemasByNamespace,\n\t\tdestinationDir = '#spruce/schemas'\n\t) {\n\t\tconst schemas: Schema[] = []\n\t\tconst namespaces = Object.keys(schemasByNamespace)\n\n\t\tfor (const namespace of namespaces) {\n\t\t\tschemas.push(\n\t\t\t\t...schemasByNamespace[namespace].map((s) => ({ namespace, ...s }))\n\t\t\t)\n\t\t}\n\n\t\tthis.flattenSchemas(schemas)\n\n\t\tconst flattened = Object.values(this.schemasByKey)\n\t\tconst sorted = flattened\n\t\t\t.sort((a, b) => {\n\t\t\t\tif (this.doesADependOnB(a, b)) {\n\t\t\t\t\treturn -1\n\t\t\t\t} else if (this.doesADependOnB(b, a)) {\n\t\t\t\t\treturn 1\n\t\t\t\t}\n\t\t\t\treturn 0\n\t\t\t})\n\t\t\t.reverse()\n\n\t\tconst schemaTemplateItems = sorted.map((s) =>\n\t\t\tthis.buildTemplateItem({\n\t\t\t\t...s,\n\t\t\t\tdestinationDir,\n\t\t\t})\n\t\t)\n\n\t\treturn schemaTemplateItems\n\t}\n\n\tprivate doesADependOnB(a: SchemaWithDependencies, b: SchemaWithDependencies) {\n\t\tconst { dependencies } = a\n\t\tconst idWithVersion = normalizeSchemaToIdWithVersion(b.schema)\n\n\t\tif (dependencies.find((dep) => isEqual(dep, idWithVersion))) {\n\t\t\treturn true\n\t\t}\n\n\t\treturn false\n\t}\n\n\tprivate flattenSchemas(schemas: Schema[]) {\n\t\tschemas.forEach((def) => {\n\t\t\tthis.flattenSchema(def)\n\t\t})\n\t}\n\n\tprivate flattenSchema(schema: Schema, isNested = false) {\n\t\tconst localSchema = cloneDeep(schema)\n\n\t\tconst namedFields = this.pluckFields(localSchema)\n\t\tconst dependencies: SchemaIdWithVersion[] = []\n\n\t\tnamedFields.forEach(({ field, name }) => {\n\t\t\tif (field.type === 'schema') {\n\t\t\t\tconst schemasOrIdsWithVersion =\n\t\t\t\t\tSchemaField.mapFieldDefinitionToSchemasOrIdsWithVersion(field)\n\n\t\t\t\tconst { ...originalOptions } = field.options\n\t\t\t\tdelete field.options.schema\n\t\t\t\tdelete field.options.schemaId\n\t\t\t\tdelete field.options.schemaIds\n\t\t\t\tdelete field.options.schemas\n\t\t\t\tfield.options.schemaIds = []\n\n\t\t\t\tschemasOrIdsWithVersion.forEach((schemaOrId) => {\n\t\t\t\t\tconst related = { ...schemaOrId }\n\n\t\t\t\t\tif (localSchema.version && !related.version) {\n\t\t\t\t\t\trelated.version = localSchema.version\n\t\t\t\t\t}\n\n\t\t\t\t\tif (!related.namespace) {\n\t\t\t\t\t\trelated.namespace = schema.namespace\n\t\t\t\t\t}\n\n\t\t\t\t\tif (\n\t\t\t\t\t\tlocalSchema.moduleToImportFromWhenRemote &&\n\t\t\t\t\t\t//@ts-ignore\n\t\t\t\t\t\t!related.moduleToImportFromWhenRemote &&\n\t\t\t\t\t\t!isIdWithVersion(related)\n\t\t\t\t\t) {\n\t\t\t\t\t\t//@ts-ignore\n\t\t\t\t\t\trelated.moduleToImportFromWhenRemote =\n\t\t\t\t\t\t\tlocalSchema.moduleToImportFromWhenRemote\n\t\t\t\t\t}\n\n\t\t\t\t\tconst relatedIdWithVersion = normalizeSchemaToIdWithVersion(related)\n\n\t\t\t\t\tfield.options.schemaIds?.push(relatedIdWithVersion)\n\t\t\t\t\tdependencies.push(relatedIdWithVersion)\n\n\t\t\t\t\tthis.flattenSchema(related, true)\n\t\t\t\t})\n\n\t\t\t\tif (field.options.schemaIds.length === 0) {\n\t\t\t\t\tthrow new SpruceError({\n\t\t\t\t\t\tcode: 'SCHEMA_TEMPLATE_ITEM_BUILDING_FAILED',\n\t\t\t\t\t\tschemaId: schema.id,\n\t\t\t\t\t\tschemaNamespace: schema.namespace as string,\n\t\t\t\t\t\tfieldName: name,\n\t\t\t\t\t\tfieldOptions: originalOptions,\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t}\n\t\t})\n\n\t\tconst key = schemaUtil.generateCacheKey(localSchema)\n\t\tthis.schemasByKey[key] = merge(this.schemasByKey[key] ?? {}, {\n\t\t\tschema: localSchema,\n\t\t\tdependencies,\n\t\t\tisNested: this.schemasByKey[key]?.isNested === false ? false : isNested,\n\t\t})\n\t}\n\n\tprivate pluckFields(localSchema: Schema) {\n\t\tconst fields = localSchema.dynamicFieldSignature\n\t\t\t? { dynamicField: localSchema.dynamicFieldSignature }\n\t\t\t: localSchema.fields ?? {}\n\n\t\tconst namedFields = Object.keys(fields).map((name) => ({\n\t\t\tname,\n\t\t\tfield: fields[name],\n\t\t}))\n\t\treturn namedFields\n\t}\n\n\tprivate buildTemplateItem(options: {\n\t\tschema: Schema\n\t\tisNested: boolean\n\t\tdestinationDir: string\n\t}): SchemaTemplateItem {\n\t\tconst { schema, isNested, destinationDir } = options\n\t\tconst namespace = schema.namespace ?? this.localNamespace\n\n\t\tconst importFrom = this.getImportFromForSchema(schema)\n\t\tconst item: SchemaTemplateItem = {\n\t\t\tid: schema.id,\n\t\t\tnamespace,\n\t\t\tschema,\n\t\t\t...schemaUtil.generateNamesForSchema(schema),\n\t\t\tisNested,\n\t\t\tdestinationDir,\n\t\t}\n\n\t\tif (importFrom) {\n\t\t\titem.importFrom = importFrom\n\t\t}\n\n\t\tif (\n\t\t\tnamespace.toLowerCase() === this.localNamespace.toLowerCase() &&\n\t\t\tschema.importsWhenLocal\n\t\t) {\n\t\t\titem.imports = [...schema.importsWhenLocal]\n\t\t} else if (\n\t\t\tnamespace.toLowerCase() !== this.localNamespace.toLowerCase() &&\n\t\t\tschema.importsWhenRemote\n\t\t) {\n\t\t\titem.imports = [...schema.importsWhenRemote]\n\t\t}\n\n\t\tconst namedFields = this.pluckFields(schema)\n\n\t\tfor (const { field } of namedFields) {\n\t\t\tif (field.type === 'schema') {\n\t\t\t\tfield.options.schemaIds?.forEach((idWithVersion) => {\n\t\t\t\t\tconst key = schemaUtil.generateCacheKey(idWithVersion)\n\t\t\t\t\tconst match = this.schemasByKey[key]\n\n\t\t\t\t\tif (\n\t\t\t\t\t\tmatch.schema.importsWhenRemote &&\n\t\t\t\t\t\tmatch.schema.namespace &&\n\t\t\t\t\t\tmatch.schema.namespace.toLowerCase() !==\n\t\t\t\t\t\t\tthis.localNamespace.toLowerCase()\n\t\t\t\t\t) {\n\t\t\t\t\t\tif (!item.imports) {\n\t\t\t\t\t\t\titem.imports = []\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\titem.imports.push(...match.schema.importsWhenRemote)\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\n\t\treturn item\n\t}\n\n\tprivate getImportFromForSchema(schema: Schema): string | undefined {\n\t\tif (\n\t\t\tschema.moduleToImportFromWhenRemote &&\n\t\t\tschema.namespace !== this.localNamespace\n\t\t) {\n\t\t\treturn schema.moduleToImportFromWhenRemote\n\t\t}\n\t\tswitch (schema.namespace) {\n\t\t\tcase CORE_NAMESPACE:\n\t\t\t\tif (this.localNamespace !== CORE_NAMESPACE) {\n\t\t\t\t\treturn '@sprucelabs/spruce-core-schemas'\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t}\n\n\t\treturn undefined\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;;AAQA;;AACA;;AACA;;AACA;;AACA;;AAEA;;;;;;;;;;;;IAQqBA,yB;EAIpB,mCAAmBC,cAAnB,EAA2C;IAAA;IAAA,uDAHoB,EAGpB;IAAA;IAC1C,KAAKA,cAAL,GAAsBA,cAAtB;EACA;;;;WAED,4BACCC,kBADD,EAGE;MAAA;;MAAA,IADDC,cACC,uEADgB,iBAChB;MACD,IAAMC,OAAiB,GAAG,EAA1B;MACA,IAAMC,UAAU,GAAGC,MAAM,CAACC,IAAP,CAAYL,kBAAZ,CAAnB;;MAFC;QAII,IAAMM,SAAS,kBAAf;QACJJ,OAAO,CAACK,IAAR,OAAAL,OAAO,sCACHF,kBAAkB,CAACM,SAAD,CAAlB,CAA8BE,GAA9B,CAAkC,UAACC,CAAD;UAAA;YAAUH,SAAS,EAATA;UAAV,GAAwBG,CAAxB;QAAA,CAAlC,CADG,EAAP;MALA;;MAID,+BAAwBN,UAAxB,iCAAoC;QAAA;MAInC;;MAED,KAAKO,cAAL,CAAoBR,OAApB;MAEA,IAAMS,SAAS,GAAGP,MAAM,CAACQ,MAAP,CAAc,KAAKC,YAAnB,CAAlB;MACA,IAAMC,MAAM,GAAGH,SAAS,CACtBI,IADa,CACR,UAACC,CAAD,EAAIC,CAAJ,EAAU;QACf,IAAI,KAAI,CAACC,cAAL,CAAoBF,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L,CAAkB2C,GAAlB,CAAd;;cAEA,IACCc,KAAK,CAAC9C,MAAN,CAAa6C,iBAAb,IACAC,KAAK,CAAC9C,MAAN,CAAalB,SADb,IAEAgE,KAAK,CAAC9C,MAAN,CAAalB,SAAb,CAAuB4D,WAAvB,OACC,MAAI,CAACnE,cAAL,CAAoBmE,WAApB,EAJF,EAKE;gBAAA;;gBACD,IAAI,CAACF,IAAI,CAACI,OAAV,EAAmB;kBAClBJ,IAAI,CAACI,OAAL,GAAe,EAAf;gBACA;;gBAED,iBAAAJ,IAAI,CAACI,OAAL,EAAa7D,IAAb,0DAAqB+D,KAAK,CAAC9C,MAAN,CAAa6C,iBAAlC;cACA;YACD,CAhBD;UAiBA;QACD;MApDqB;QAAA;MAAA;QAAA;MAAA;;MAsDtB,OAAOL,IAAP;IACA;;;WAED,gCAA+BxC,MAA/B,EAAmE;MAClE,IACCA,MAAM,CAACuB,4BAAP,IACAvB,MAAM,CAAClB,SAAP,KAAqB,KAAKP,cAF3B,EAGE;QACD,OAAOyB,MAAM,CAACuB,4BAAd;MACA;;MACD,QAAQvB,MAAM,CAAClB,SAAf;QACC,KAAKiE,gCAAL;UACC,IAAI,KAAKxE,cAAL,KAAwBwE,gCAA5B,EAA4C;YAC3C,OAAO,iCAAP;UACA;;UACD;MALF;;MAQA,OAAOC,SAAP;IACA"}
1
+ {"version":3,"file":"SchemaTemplateItemBuilder.js","names":["SchemaTemplateItemBuilder","localNamespace","schemasByNamespace","destinationDir","schemas","namespaces","Object","keys","namespace","push","map","s","flattenSchemas","flattened","values","schemasByKey","sorted","sort","a","b","doesADependOnB","reverse","schemaTemplateItems","buildTemplateItem","dependencies","idWithVersion","normalizeSchemaToIdWithVersion","schema","find","dep","isEqual","forEach","def","flattenSchema","isNested","localSchema","cloneDeep","namedFields","pluckFields","field","name","type","schemasOrIdsWithVersion","SchemaField","mapFieldDefinitionToSchemasOrIdsWithVersion","originalOptions","options","schemaId","schemaIds","schemaOrId","related","version","moduleToImportFromWhenRemote","isIdWithVersion","relatedIdWithVersion","length","SpruceError","code","id","schemaNamespace","fieldName","fieldOptions","key","schemaUtil","generateCacheKey","merge","fields","dynamicFieldSignature","dynamicField","importFrom","getImportFromForSchema","item","generateNamesForSchema","toLowerCase","importsWhenLocal","imports","importsWhenRemote","match","CORE_NAMESPACE","undefined"],"sources":["../../src/templateItemBuilders/SchemaTemplateItemBuilder.ts"],"sourcesContent":["import {\n\tSchema,\n\tSchemaTemplateItem,\n\tSchemaField,\n\tSchemaIdWithVersion,\n\tnormalizeSchemaToIdWithVersion,\n\tisIdWithVersion,\n} from '@sprucelabs/schema'\nimport { CORE_NAMESPACE } from '@sprucelabs/spruce-skill-utils'\nimport cloneDeep from 'lodash/cloneDeep'\nimport isEqual from 'lodash/isEqual'\nimport merge from 'lodash/merge'\nimport SpruceError from '../errors/SpruceError'\nimport { SchemasByNamespace } from '../features/schema/stores/SchemaStore'\nimport schemaUtil from '../features/schema/utilities/schema.utility'\n\ninterface SchemaWithDependencies {\n\tschema: Schema\n\tdependencies: SchemaIdWithVersion[]\n\tisNested: boolean\n}\n\nexport default class SchemaTemplateItemBuilder {\n\tprivate schemasByKey: Record<string, SchemaWithDependencies> = {}\n\tprivate localNamespace: string\n\n\tpublic constructor(localNamespace: string) {\n\t\tthis.localNamespace = localNamespace\n\t}\n\n\tpublic buildTemplateItems(\n\t\tschemasByNamespace: SchemasByNamespace,\n\t\tdestinationDir = '#spruce/schemas'\n\t) {\n\t\tconst schemas: Schema[] = []\n\t\tconst namespaces = Object.keys(schemasByNamespace)\n\n\t\tfor (const namespace of namespaces) {\n\t\t\tschemas.push(\n\t\t\t\t...schemasByNamespace[namespace].map((s) => ({ namespace, ...s }))\n\t\t\t)\n\t\t}\n\n\t\tthis.flattenSchemas(schemas)\n\n\t\tconst flattened = Object.values(this.schemasByKey)\n\t\tconst sorted = flattened\n\t\t\t.sort((a, b) => {\n\t\t\t\tif (this.doesADependOnB(a, b)) {\n\t\t\t\t\treturn -1\n\t\t\t\t} else if (this.doesADependOnB(b, a)) {\n\t\t\t\t\treturn 1\n\t\t\t\t}\n\t\t\t\treturn 0\n\t\t\t})\n\t\t\t.reverse()\n\n\t\tconst schemaTemplateItems = sorted.map((s) =>\n\t\t\tthis.buildTemplateItem({\n\t\t\t\t...s,\n\t\t\t\tdestinationDir,\n\t\t\t})\n\t\t)\n\n\t\treturn schemaTemplateItems\n\t}\n\n\tprivate doesADependOnB(a: SchemaWithDependencies, b: SchemaWithDependencies) {\n\t\tconst { dependencies } = a\n\t\tconst idWithVersion = normalizeSchemaToIdWithVersion(b.schema)\n\n\t\tif (dependencies.find((dep) => isEqual(dep, idWithVersion))) {\n\t\t\treturn true\n\t\t}\n\n\t\treturn false\n\t}\n\n\tprivate flattenSchemas(schemas: Schema[]) {\n\t\tschemas.forEach((def) => {\n\t\t\tthis.flattenSchema(def)\n\t\t})\n\t}\n\n\tprivate flattenSchema(schema: Schema, isNested = false) {\n\t\tconst localSchema = cloneDeep(schema)\n\n\t\tconst namedFields = this.pluckFields(localSchema)\n\t\tconst dependencies: SchemaIdWithVersion[] = []\n\n\t\tnamedFields.forEach(({ field, name }) => {\n\t\t\tif (field.type === 'schema') {\n\t\t\t\tconst schemasOrIdsWithVersion =\n\t\t\t\t\tSchemaField.mapFieldDefinitionToSchemasOrIdsWithVersion(field)\n\n\t\t\t\tconst { ...originalOptions } = field.options\n\t\t\t\tdelete field.options.schema\n\t\t\t\tdelete field.options.schemaId\n\t\t\t\tdelete field.options.schemaIds\n\t\t\t\tdelete field.options.schemas\n\t\t\t\tfield.options.schemaIds = []\n\n\t\t\t\tschemasOrIdsWithVersion.forEach((schemaOrId) => {\n\t\t\t\t\tconst related = { ...schemaOrId }\n\n\t\t\t\t\tif (localSchema.version && !related.version) {\n\t\t\t\t\t\trelated.version = localSchema.version\n\t\t\t\t\t}\n\n\t\t\t\t\tif (!related.namespace) {\n\t\t\t\t\t\trelated.namespace = schema.namespace\n\t\t\t\t\t}\n\n\t\t\t\t\tif (\n\t\t\t\t\t\tlocalSchema.moduleToImportFromWhenRemote &&\n\t\t\t\t\t\t//@ts-ignore\n\t\t\t\t\t\t!related.moduleToImportFromWhenRemote &&\n\t\t\t\t\t\t!isIdWithVersion(related)\n\t\t\t\t\t) {\n\t\t\t\t\t\t//@ts-ignore\n\t\t\t\t\t\trelated.moduleToImportFromWhenRemote =\n\t\t\t\t\t\t\tlocalSchema.moduleToImportFromWhenRemote\n\t\t\t\t\t}\n\n\t\t\t\t\tconst relatedIdWithVersion = normalizeSchemaToIdWithVersion(related)\n\n\t\t\t\t\tfield.options.schemaIds?.push(relatedIdWithVersion)\n\t\t\t\t\tdependencies.push(relatedIdWithVersion)\n\n\t\t\t\t\tthis.flattenSchema(related, true)\n\t\t\t\t})\n\n\t\t\t\tif (field.options.schemaIds.length === 0) {\n\t\t\t\t\tthrow new SpruceError({\n\t\t\t\t\t\tcode: 'SCHEMA_TEMPLATE_ITEM_BUILDING_FAILED',\n\t\t\t\t\t\tschemaId: schema.id,\n\t\t\t\t\t\tschemaNamespace: schema.namespace as string,\n\t\t\t\t\t\tfieldName: name,\n\t\t\t\t\t\tfieldOptions: originalOptions,\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t}\n\t\t})\n\n\t\tconst key = schemaUtil.generateCacheKey(localSchema)\n\t\tthis.schemasByKey[key] = merge(this.schemasByKey[key] ?? {}, {\n\t\t\tschema: localSchema,\n\t\t\tdependencies,\n\t\t\tisNested: this.schemasByKey[key]?.isNested === false ? false : isNested,\n\t\t})\n\t}\n\n\tprivate pluckFields(localSchema: Schema) {\n\t\tconst fields = localSchema.dynamicFieldSignature\n\t\t\t? { dynamicField: localSchema.dynamicFieldSignature }\n\t\t\t: localSchema.fields ?? {}\n\n\t\tconst namedFields = Object.keys(fields).map((name) => ({\n\t\t\tname,\n\t\t\tfield: fields[name],\n\t\t}))\n\t\treturn namedFields\n\t}\n\n\tprivate buildTemplateItem(options: {\n\t\tschema: Schema\n\t\tisNested: boolean\n\t\tdestinationDir: string\n\t}): SchemaTemplateItem {\n\t\tconst { schema, isNested, destinationDir } = options\n\t\tconst namespace = schema.namespace ?? this.localNamespace\n\n\t\tconst importFrom = this.getImportFromForSchema(schema)\n\t\tconst item: SchemaTemplateItem = {\n\t\t\tid: schema.id,\n\t\t\tnamespace,\n\t\t\tschema,\n\t\t\t...schemaUtil.generateNamesForSchema(schema),\n\t\t\tisNested,\n\t\t\tdestinationDir,\n\t\t}\n\n\t\tif (importFrom) {\n\t\t\titem.importFrom = importFrom\n\t\t}\n\n\t\tif (\n\t\t\tnamespace.toLowerCase() === this.localNamespace.toLowerCase() &&\n\t\t\tschema.importsWhenLocal\n\t\t) {\n\t\t\titem.imports = [...schema.importsWhenLocal]\n\t\t} else if (\n\t\t\tnamespace.toLowerCase() !== this.localNamespace.toLowerCase() &&\n\t\t\tschema.importsWhenRemote\n\t\t) {\n\t\t\titem.imports = [...schema.importsWhenRemote]\n\t\t}\n\n\t\tconst namedFields = this.pluckFields(schema)\n\n\t\tfor (const { field } of namedFields) {\n\t\t\tif (field.type === 'schema') {\n\t\t\t\tfield.options.schemaIds?.forEach((idWithVersion) => {\n\t\t\t\t\tconst key = schemaUtil.generateCacheKey(idWithVersion)\n\t\t\t\t\tconst match = this.schemasByKey[key]\n\n\t\t\t\t\tif (\n\t\t\t\t\t\tmatch.schema.importsWhenRemote &&\n\t\t\t\t\t\tmatch.schema.namespace &&\n\t\t\t\t\t\tmatch.schema.namespace.toLowerCase() !==\n\t\t\t\t\t\t\tthis.localNamespace.toLowerCase()\n\t\t\t\t\t) {\n\t\t\t\t\t\tif (!item.imports) {\n\t\t\t\t\t\t\titem.imports = []\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\titem.imports.push(...match.schema.importsWhenRemote)\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\n\t\treturn item\n\t}\n\n\tprivate getImportFromForSchema(schema: Schema): string | undefined {\n\t\tif (\n\t\t\tschema.moduleToImportFromWhenRemote &&\n\t\t\tschema.namespace !== this.localNamespace\n\t\t) {\n\t\t\treturn schema.moduleToImportFromWhenRemote\n\t\t}\n\t\tswitch (schema.namespace) {\n\t\t\tcase CORE_NAMESPACE:\n\t\t\t\tif (this.localNamespace !== CORE_NAMESPACE) {\n\t\t\t\t\treturn '@sprucelabs/spruce-core-schemas'\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t}\n\n\t\treturn undefined\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;;AAQA;;AACA;;AACA;;AACA;;AACA;;AAEA;;;;;;;;;;;;IAQqBA,yB;EAIpB,mCAAmBC,cAAnB,EAA2C;IAAA;IAAA,uDAHoB,EAGpB;IAAA;IAC1C,KAAKA,cAAL,GAAsBA,cAAtB;EACA;;;;WAED,4BACCC,kBADD,EAGE;MAAA;;MAAA,IADDC,cACC,uEADgB,iBAChB;MACD,IAAMC,OAAiB,GAAG,EAA1B;MACA,IAAMC,UAAU,GAAGC,MAAM,CAACC,IAAP,CAAYL,kBAAZ,CAAnB;;MAFC;QAII,IAAMM,SAAS,kBAAf;QACJJ,OAAO,CAACK,IAAR,OAAAL,OAAO,sCACHF,kBAAkB,CAACM,SAAD,CAAlB,CAA8BE,GAA9B,CAAkC,UAACC,CAAD;UAAA;YAAUH,SAAS,EAATA;UAAV,GAAwBG,CAAxB;QAAA,CAAlC,CADG,EAAP;MALA;;MAID,+BAAwBN,UAAxB,iCAAoC;QAAA;MAInC;;MAED,KAAKO,cAAL,CAAoBR,OAApB;MAEA,IAAMS,SAAS,GAAGP,MAAM,CAACQ,MAAP,CAAc,KAAKC,YAAnB,CAAlB;MACA,IAAMC,MAAM,GAAGH,SAAS,CACtBI,IADa,CACR,UAACC,CAAD,EAAIC,CAAJ,EAAU;QACf,IAAI,KAAI,CAACC,cAAL,CAAoBF,CAApB,EAAuBC,CAAvB,CAAJ,EAA+B;UAC9B,OAAO,CAAC,CAAR;QACA,CAFD,MAEO,IAAI,KAAI,CAACC,c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CAAC9D,YAAL,CAAkB+C,GAAlB,CAAd;;cAEA,IACCe,KAAK,CAAClD,MAAN,CAAaiD,iBAAb,IACAC,KAAK,CAAClD,MAAN,CAAanB,SADb,IAEAqE,KAAK,CAAClD,MAAN,CAAanB,SAAb,CAAuBiE,WAAvB,OACC,MAAI,CAACxE,cAAL,CAAoBwE,WAApB,EAJF,EAKE;gBAAA;;gBACD,IAAI,CAACF,IAAI,CAACI,OAAV,EAAmB;kBAClBJ,IAAI,CAACI,OAAL,GAAe,EAAf;gBACA;;gBAED,iBAAAJ,IAAI,CAACI,OAAL,EAAalE,IAAb,0DAAqBoE,KAAK,CAAClD,MAAN,CAAaiD,iBAAlC;cACA;YACD,CAhBD;UAiBA;QACD;MApDqB;QAAA;MAAA;QAAA;MAAA;;MAsDtB,OAAOL,IAAP;IACA;;;WAED,gCAA+B5C,MAA/B,EAAmE;MAClE,IACCA,MAAM,CAACyB,4BAAP,IACAzB,MAAM,CAACnB,SAAP,KAAqB,KAAKP,cAF3B,EAGE;QACD,OAAO0B,MAAM,CAACyB,4BAAd;MACA;;MACD,QAAQzB,MAAM,CAACnB,SAAf;QACC,KAAKsE,gCAAL;UACC,IAAI,KAAK7E,cAAL,KAAwB6E,gCAA5B,EAA4C;YAC3C,OAAO,iCAAP;UACA;;UACD;MALF;;MAQA,OAAOC,SAAP;IACA"}
@@ -1 +1 @@
1
- {"version":3,"file":"AbstractCliTest.js","names":["AbstractCliTest","cleanTestDirsAndFiles","LintService","disableLinting","ImportService","setCacheDir","diskUtil","createRandomTempDir","enableCaching","process","env","ENABLE_INSTALL_ENTERTAINMENT","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","MercuryClientFactory","setIsTestMode","commandFaker","CommandFaker","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","people","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"],"sources":["../../src/tests/AbstractCliTest.ts"],"sourcesContent":["import pathUtil from 'path'\nimport { MercuryClientFactory } from '@sprucelabs/mercury-client'\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 CommandFaker from './CommandFaker'\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\tprotected static commandFaker: CommandFaker\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_ENTERTAINMENT = '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\tMercuryClientFactory.reset()\n\t\tMercuryClientFactory.setIsTestMode(false)\n\n\t\tthis.commandFaker = new CommandFaker()\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 get people() {\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.people,\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.people,\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"],"mappings":";;;;;;;;;;;;;;;;;;;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qH,aAAa,EAAbA,aAHgB;QAIhBI,uBAAuB,EAAE,mCAAM;UAC9B,OAAO,KAAI,CAACpD,mBAAL,EAAP;QACA,CANe;QAOhBqD,4BAA4B,EAAE;MAPd,GAQblE,OARa,EAAjB;MAWA,OAAO2D,QAAP;IACA;;;WAED,kCAA0CQ,KAA1C,EAAyD;MACxD,IAAMC,IAAI,GAAG,KAAKvH,EAAL,CAAQwH,iBAAR,EAAb;;MACAzB,aAAO0B,WAAP,CAAmBF,IAAI,CAACpE,OAAL,CAAaA,OAAb,CAAqBuE,OAAxC,EAAiD;QAChDJ,KAAK,EAALA;MADgD,CAAjD;;MAIA,IAAMrF,KAAK,GAAGsF,IAAI,CAACpE,OAAL,CAAaA,OAAb,CAAqBuE,OAArB,CAA6BC,IAA7B,CACb,UAACC,CAAD;QAAA,OAAYA,CAAC,CAACN,KAAF,KAAYA,KAAxB;MAAA,CADa,CAAd;MAIA,KAAK,KAAKtH,EAAL,CAAQ+E,SAAR,WAAqB9C,KAAK,CAAC4F,KAA3B,EAAL;IACA;;;EAhboDC,gB;;;iCAAxBxJ,e,aACF0E,iBAASC,IAAT,CAAc8E,SAAd,EAAyB,IAAzB,C;iCADEzJ,e;iCAAAA,e;iCAAAA,e;iCAAAA,e;iCAAAA,e;iCAAAA,e;iCAAAA,e;iCAAAA,e;iCAAAA,e;iCAAAA,e;iCAAAA,e"}
1
+ {"version":3,"file":"AbstractCliTest.js","names":["AbstractCliTest","cleanTestDirsAndFiles","LintService","disableLinting","ImportService","setCacheDir","diskUtil","createRandomTempDir","enableCaching","process","env","ENABLE_INSTALL_ENTERTAINMENT","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","MercuryClientFactory","setIsTestMode","commandFaker","CommandFaker","organizationFixture","clearAllOrgs","mercuryFixture","disconnectAll","_ui","isWaitingForInput","Error","doesDirExist","shouldClearCache","deleteDir","shouldCleanupTestSkillDirs","FeatureFixture","deleteOldSkillDirs","pattern","resolveTestPath","globby","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","people","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"],"sources":["../../src/tests/AbstractCliTest.ts"],"sourcesContent":["import pathUtil from 'path'\nimport { MercuryClientFactory } from '@sprucelabs/mercury-client'\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 CommandFaker from './CommandFaker'\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\tprotected static commandFaker: CommandFaker\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_ENTERTAINMENT = '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\tMercuryClientFactory.reset()\n\t\tMercuryClientFactory.setIsTestMode(false)\n\n\t\tthis.commandFaker = new CommandFaker()\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 get people() {\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.people,\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.people,\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"],"mappings":";;;;;;;;;;;;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