@sprucelabs/spruce-cli 14.28.6 → 14.29.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 (125) hide show
  1. package/CHANGELOG.md +35 -0
  2. package/build/__tests__/behavioral/SettingLogTransportsInASkill.test.js +13 -9
  3. package/build/__tests__/behavioral/SettingLogTransportsInASkill.test.js.map +1 -1
  4. package/build/__tests__/behavioral/SyncingEventsOnlyFromDependencies.test.d.ts +1 -1
  5. package/build/__tests__/behavioral/SyncingEventsOnlyFromDependencies.test.js +24 -14
  6. package/build/__tests__/behavioral/SyncingEventsOnlyFromDependencies.test.js.map +1 -1
  7. package/build/__tests__/behavioral/TestingDataStores.test.js +15 -11
  8. package/build/__tests__/behavioral/TestingDataStores.test.js.map +1 -1
  9. package/build/__tests__/behavioral/eventContract/PullingMercuryEventContract.test.js +3 -1
  10. package/build/__tests__/behavioral/eventContract/PullingMercuryEventContract.test.js.map +1 -1
  11. package/build/__tests__/behavioral/events/CreatingAListener.test.d.ts +2 -0
  12. package/build/__tests__/behavioral/events/CreatingAListener.test.js +157 -81
  13. package/build/__tests__/behavioral/events/CreatingAListener.test.js.map +1 -1
  14. package/build/__tests__/behavioral/events/KeepingListenersInSync.test.d.ts +7 -0
  15. package/build/__tests__/behavioral/events/KeepingListenersInSync.test.js +171 -0
  16. package/build/__tests__/behavioral/events/KeepingListenersInSync.test.js.map +1 -0
  17. package/build/__tests__/behavioral/events/SkillEmitsBootEvents.test.d.ts +1 -0
  18. package/build/__tests__/behavioral/events/SkillEmitsBootEvents.test.js +53 -21
  19. package/build/__tests__/behavioral/events/SkillEmitsBootEvents.test.js.map +1 -1
  20. package/build/__tests__/behavioral/skill/UpgradingWithListeners.test.d.ts +5 -0
  21. package/build/__tests__/behavioral/skill/UpgradingWithListeners.test.js +137 -0
  22. package/build/__tests__/behavioral/skill/UpgradingWithListeners.test.js.map +1 -0
  23. package/build/__tests__/behavioral/stores/CreatingADataStore.test.js +4 -1
  24. package/build/__tests__/behavioral/stores/CreatingADataStore.test.js.map +1 -1
  25. package/build/__tests__/behavioral/stores/KeepingDataStoresInSync.test.d.ts +4 -1
  26. package/build/__tests__/behavioral/stores/KeepingDataStoresInSync.test.js +136 -47
  27. package/build/__tests__/behavioral/stores/KeepingDataStoresInSync.test.js.map +1 -1
  28. package/build/__tests__/behavioral/tests/CreatingATest.test.js +14 -10
  29. package/build/__tests__/behavioral/tests/CreatingATest.test.js.map +1 -1
  30. package/build/__tests__/behavioral/views/TestingViewControllers.test.d.ts +1 -0
  31. package/build/__tests__/behavioral/views/TestingViewControllers.test.js +67 -35
  32. package/build/__tests__/behavioral/views/TestingViewControllers.test.js.map +1 -1
  33. package/build/__tests__/implementation/AuthService.test.d.ts +1 -0
  34. package/build/__tests__/implementation/AuthService.test.js +8 -0
  35. package/build/__tests__/implementation/AuthService.test.js.map +1 -1
  36. package/build/__tests__/implementation/EventStore.test.js +3 -1
  37. package/build/__tests__/implementation/EventStore.test.js.map +1 -1
  38. package/build/__tests__/implementation/LintService.test.d.ts +5 -0
  39. package/build/__tests__/implementation/LintService.test.js +130 -0
  40. package/build/__tests__/implementation/LintService.test.js.map +1 -0
  41. package/build/__tests__/implementation/StoreFeature.test.d.ts +4 -0
  42. package/build/__tests__/implementation/StoreFeature.test.js +132 -0
  43. package/build/__tests__/implementation/StoreFeature.test.js.map +1 -0
  44. package/build/errors/SpruceError.js +8 -4
  45. package/build/errors/SpruceError.js.map +1 -1
  46. package/build/features/event/EventFeature.d.ts +2 -2
  47. package/build/features/event/EventFeature.js +53 -13
  48. package/build/features/event/EventFeature.js.map +1 -1
  49. package/build/features/event/actions/ListenAction.d.ts +1 -0
  50. package/build/features/event/actions/ListenAction.js +60 -31
  51. package/build/features/event/actions/ListenAction.js.map +1 -1
  52. package/build/features/event/actions/SyncListenersAction.d.ts +15 -0
  53. package/build/features/event/actions/SyncListenersAction.js +115 -0
  54. package/build/features/event/actions/SyncListenersAction.js.map +1 -0
  55. package/build/features/event/builders/ListenerTemplateItemBuilder.d.ts +8 -0
  56. package/build/features/event/builders/ListenerTemplateItemBuilder.js +65 -0
  57. package/build/features/event/builders/ListenerTemplateItemBuilder.js.map +1 -0
  58. package/build/features/event/stores/EventStore.js +2 -2
  59. package/build/features/event/stores/EventStore.js.map +1 -1
  60. package/build/features/event/stores/ListenerStore.d.ts +9 -0
  61. package/build/features/event/stores/ListenerStore.js +122 -0
  62. package/build/features/event/stores/ListenerStore.js.map +1 -0
  63. package/build/features/event/writers/EventWriter.d.ts +4 -1
  64. package/build/features/event/writers/EventWriter.js +42 -8
  65. package/build/features/event/writers/EventWriter.js.map +1 -1
  66. package/build/features/skill/SkillFeature.js +1 -1
  67. package/build/features/skill/SkillFeature.js.map +1 -1
  68. package/build/features/skill/stores/SkillStore.js +4 -8
  69. package/build/features/skill/stores/SkillStore.js.map +1 -1
  70. package/build/features/store/StoreFeature.d.ts +1 -1
  71. package/build/features/store/StoreFeature.js +16 -11
  72. package/build/features/store/StoreFeature.js.map +1 -1
  73. package/build/services/AuthService.d.ts +4 -1
  74. package/build/services/AuthService.js +15 -4
  75. package/build/services/AuthService.js.map +1 -1
  76. package/build/services/GameService.js +14 -10
  77. package/build/services/GameService.js.map +1 -1
  78. package/build/services/LintService.d.ts +5 -2
  79. package/build/services/LintService.js +137 -92
  80. package/build/services/LintService.js.map +1 -1
  81. package/build/services/ServiceFactory.js +9 -3
  82. package/build/services/ServiceFactory.js.map +1 -1
  83. package/build/stores/StoreFactory.d.ts +2 -0
  84. package/build/stores/StoreFactory.js +4 -1
  85. package/build/stores/StoreFactory.js.map +1 -1
  86. package/build/tests/AbstractCliTest.js +3 -3
  87. package/build/tests/AbstractCliTest.js.map +1 -1
  88. package/build/writers/AbstractWriter.d.ts +0 -3
  89. package/build/writers/AbstractWriter.js +2 -18
  90. package/build/writers/AbstractWriter.js.map +1 -1
  91. package/package.json +30 -28
  92. package/src/__tests__/behavioral/SettingLogTransportsInASkill.test.ts +2 -0
  93. package/src/__tests__/behavioral/SyncingEventsOnlyFromDependencies.test.ts +10 -5
  94. package/src/__tests__/behavioral/TestingDataStores.test.ts +2 -0
  95. package/src/__tests__/behavioral/eventContract/PullingMercuryEventContract.test.ts +1 -0
  96. package/src/__tests__/behavioral/events/CreatingAListener.test.ts +28 -9
  97. package/src/__tests__/behavioral/events/KeepingListenersInSync.test.ts +47 -0
  98. package/src/__tests__/behavioral/events/SkillEmitsBootEvents.test.ts +6 -0
  99. package/src/__tests__/behavioral/skill/UpgradingWithListeners.test.ts +59 -0
  100. package/src/__tests__/behavioral/stores/CreatingADataStore.test.ts +1 -0
  101. package/src/__tests__/behavioral/stores/KeepingDataStoresInSync.test.ts +35 -6
  102. package/src/__tests__/behavioral/tests/CreatingATest.test.ts +2 -0
  103. package/src/__tests__/behavioral/views/TestingViewControllers.test.ts +6 -0
  104. package/src/__tests__/implementation/AuthService.test.ts +6 -0
  105. package/src/__tests__/implementation/EventStore.test.ts +1 -0
  106. package/src/__tests__/implementation/LintService.test.ts +34 -0
  107. package/src/__tests__/implementation/StoreFeature.test.ts +40 -0
  108. package/src/errors/SpruceError.ts +9 -5
  109. package/src/features/event/EventFeature.ts +21 -4
  110. package/src/features/event/actions/ListenAction.ts +9 -3
  111. package/src/features/event/actions/SyncListenersAction.ts +38 -0
  112. package/src/features/event/builders/ListenerTemplateItemBuilder.ts +27 -0
  113. package/src/features/event/stores/EventStore.ts +1 -1
  114. package/src/features/event/stores/ListenerStore.ts +32 -0
  115. package/src/features/event/writers/EventWriter.ts +19 -0
  116. package/src/features/skill/SkillFeature.ts +1 -1
  117. package/src/features/skill/stores/SkillStore.ts +4 -3
  118. package/src/features/store/StoreFeature.ts +7 -4
  119. package/src/services/AuthService.ts +15 -5
  120. package/src/services/GameService.ts +1 -0
  121. package/src/services/LintService.ts +34 -5
  122. package/src/services/ServiceFactory.ts +8 -3
  123. package/src/stores/StoreFactory.ts +3 -0
  124. package/src/tests/AbstractCliTest.ts +2 -2
  125. package/src/writers/AbstractWriter.ts +2 -13
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/services/LintService.ts"],"names":["LintService","cwd","command","pattern","SchemaError","code","parameters","fixedFiles","fixedPaths","script","execute","args","stdout","JSON","parse","SpruceError","originalError","i","length","fixedFile","output","fs","writeFile","filePath","push"],"mappings":";;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;IAGqBA,W,GAIpB,qBAAmBC,GAAnB,EAAgCC,OAAhC,EAAyD;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA,6FAK5C,iBAAOC,OAAP;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA,kBACPA,OADO;AAAA;AAAA;AAAA;;AAAA,oBAEL,IAAIC,mBAAJ,CAAgB;AACrBC,gBAAAA,IAAI,EAAE,oBADe;AAErBC,gBAAAA,UAAU,EAAE,CAAC,SAAD;AAFS,eAAhB,CAFK;;AAAA;AAQRC,cAAAA,UARQ,GAQU,EARV;AASNC,cAAAA,UATM,GASiB,EATjB;AAAA;AAWLC,cAAAA,MAXK,8HAWuH,KAAI,CAACR,GAX5H,yDAW8KE,OAX9K;AAAA;AAAA,qBAac,KAAI,CAACD,OAAL,CAAaQ,OAAb,CAAqB,MAArB,EAA6B;AACrDC,gBAAAA,IAAI,EAAE,CAAC,IAAD,EAAOF,MAAP;AAD+C,eAA7B,CAbd;;AAAA;AAAA;AAaHG,cAAAA,MAbG,yBAaHA,MAbG;AAiBXL,cAAAA,UAAU,GAAGM,IAAI,CAACC,KAAL,CAAWF,MAAX,CAAb;AAjBW;AAAA;;AAAA;AAAA;AAAA;AAAA,oBAmBL,IAAIG,uBAAJ,CAAgB;AACrBV,gBAAAA,IAAI,EAAE,aADe;AAErBF,gBAAAA,OAAO,EAAPA,OAFqB;AAGrBa,gBAAAA,aAAa;AAHQ,eAAhB,CAnBK;;AAAA;AAAA,mBA0BRT,UA1BQ;AAAA;AAAA;AAAA;;AA2BFU,cAAAA,CA3BE,GA2BE,CA3BF;;AAAA;AAAA,oBA2BKA,CAAC,GAAGV,UAAU,CAACW,MA3BpB;AAAA;AAAA;AAAA;;AA4BJC,cAAAA,SA5BI,GA4BQZ,UAAU,CAACU,CAAD,CA5BlB;;AAAA,oBA6BNE,SAAS,IAAIA,SAAS,CAACC,MA7BjB;AAAA;AAAA;AAAA;;AAAA;AAAA,qBA8BHC,oBAAGC,SAAH,CAAaH,SAAS,CAACI,QAAvB,EAAiCJ,SAAS,CAACC,MAA3C,CA9BG;;AAAA;AA+BTZ,cAAAA,UAAU,CAACgB,IAAX,CAAgBL,SAAS,CAACI,QAA1B;;AA/BS;AA2B4BN,cAAAA,CAAC,IAAI,CA3BjC;AAAA;AAAA;;AAAA;AAAA,+CAoCLT,UApCK;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,KAL4C;;AAAA;AAAA;AAAA;AAAA;AACxD,OAAKP,GAAL,GAAWA,GAAX;AACA,OAAKC,OAAL,GAAeA,OAAf;AACA,C","sourcesContent":["import { SchemaError } from '@sprucelabs/schema'\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 command: CommandService\n\n\tpublic constructor(cwd: string, command: CommandService) {\n\t\tthis.cwd = cwd\n\t\tthis.command = command\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\tlet fixedFiles: any = {}\n\t\tconst fixedPaths: string[] = []\n\t\ttry {\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.command.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\t\t\t\tif (fixedFile && 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}\n\t\t\t}\n\t\t}\n\n\t\treturn fixedPaths\n\t}\n}\n"],"file":"LintService.js"}
1
+ {"version":3,"sources":["../../src/services/LintService.ts"],"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"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;;AAEA;;AACA;;AAFA;IAKqBA,W;AAcpB,uBAAmBC,GAAnB,EAAgCC,qBAAhC,EAA6E;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA,+FAKhE,iBAAOC,OAAP;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA,oBACPA,OADO;AAAA;AAAA;AAAA;;AAAA,sBAEL,IAAIC,mBAAJ,CAAgB;AACrBC,kBAAAA,IAAI,EAAE,oBADe;AAErBC,kBAAAA,UAAU,EAAE,CAAC,SAAD;AAFS,iBAAhB,CAFK;;AAAA;AAAA,oBAQPN,WAAW,CAACO,gBARL;AAAA;AAAA;AAAA;;AAAA,iDASJ,EATI;;AAAA;AAYRC,gBAAAA,UAZQ,GAYU,EAZV;AAaNC,gBAAAA,UAbM,GAaiB,EAbjB;AAAA;AAgBX;AACA;AACMC,gB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;AACrBZ,kBAAAA,IAAI,EAAE,aADe;AAErBF,kBAAAA,OAAO,EAAPA,OAFqB;AAGrB0B,kBAAAA,eAAe,6BACdR,SAAS,CAACI,QADI,mBAENJ,SAAS,CAACM,QAAV,CACPG,GADO,CACH,UAACC,CAAD;AAAA,2BAAYA,CAAZ,aAAYA,CAAZ,uBAAYA,CAAC,CAAEC,OAAf;AAAA,mBADG,EAEPC,IAFO,CAEF,IAFE,CAFM;AAHM,iBAAhB,CAzCG;;AAAA;AAkC4Bd,gBAAAA,CAAC,IAAI,CAlCjC;AAAA;AAAA;;AAAA;AAAA,iDAsDLV,UAtDK;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,OALgE;;AAAA;AAAA;AAAA;AAAA;AAC5E,SAAKR,GAAL,GAAWA,GAAX;AACA,SAAKU,UAAL,GAAkBT,qBAAlB;AACA;;;;WAXD,0BAA+B;AAC9B,WAAKK,gBAAL,GAAwB,KAAxB;AACA;;;WAED,yBAA8B;AAC7B,WAAKA,gBAAL,GAAwB,IAAxB;AACA;;;;;;iCAZmBP,W,sBAIc,I","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"],"file":"LintService.js"}
@@ -55,9 +55,11 @@ var ServiceFactory = /*#__PURE__*/function () {
55
55
 
56
56
  return Service;
57
57
  }(function (cwd, type) {
58
+ var _this = this;
59
+
58
60
  switch (type) {
59
61
  case 'auth':
60
- return new _AuthService["default"](new _spruceSkillUtils.EnvService(cwd));
62
+ return new _AuthService["default"](new _spruceSkillUtils.EnvService(cwd), new _PkgService["default"](cwd));
61
63
 
62
64
  case 'pkg':
63
65
  return new _PkgService["default"](cwd);
@@ -75,7 +77,9 @@ var ServiceFactory = /*#__PURE__*/function () {
75
77
  });
76
78
 
77
79
  case 'lint':
78
- return new _LintService["default"](cwd, new _CommandService["default"](cwd));
80
+ return new _LintService["default"](cwd, function () {
81
+ return _this.Service(cwd, 'command');
82
+ });
79
83
 
80
84
  case 'command':
81
85
  {
@@ -100,7 +104,9 @@ var ServiceFactory = /*#__PURE__*/function () {
100
104
  case 'build':
101
105
  {
102
106
  var commandService = new _CommandService["default"](cwd);
103
- return new _BuildService["default"](commandService, new _LintService["default"](cwd, commandService));
107
+ return new _BuildService["default"](commandService, new _LintService["default"](cwd, function () {
108
+ return _this.Service(cwd, 'command');
109
+ }));
104
110
  }
105
111
 
106
112
  case 'eventSettings':
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/services/ServiceFactory.ts"],"names":["ServiceFactory","cwd","type","AuthService","EnvService","PkgService","VsCodeService","SchemaService","command","CommandService","LintService","RemoteService","TypeCheckerService","buildImportService","SettingsService","DependencyService","commandService","BuildService","EventSettingsService","Error","ImportService"],"mappings":";;;;;;;;;;;;;AAAA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;IAwBqBA,c;;;;;;;;;;;;;;;;;MACpB,UAAkCC,GAAlC,EAA+CC,IAA/C,EAAuE;AACtE,cAAQA,IAAR;AACC,aAAK,MAAL;AACC,iBAAO,IAAIC,uBAAJ,CAAgB,IAAIC,4BAAJ,CAAeH,GAAf,CAAhB,CAAP;;AACD,aAAK,KAAL;AACC,iBAAO,IAAII,sBAAJ,CAAeJ,GAAf,CA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,qBAAsBjB,IAAtB,kBAAN;AA7CF;AA+CA,K;;;WAED,4BAA2BD,GAA3B,EAAuD;AACtD,aAAO,IAAImB,yBAAJ,CAAkB;AACxBnB,QAAAA,GAAG,EAAHA,GADwB;AAExBO,QAAAA,OAAO,EAAE,IAAIC,0BAAJ,CAAmBR,GAAnB;AAFe,OAAlB,CAAP;AAIA","sourcesContent":["import { SettingsService, EnvService } 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 AuthService from './AuthService'\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 new AuthService(new EnvService(cwd)) as ServiceMap[S]\n\t\t\tcase 'pkg':\n\t\t\t\treturn new PkgService(cwd) 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, new CommandService(cwd)) 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, commandService)\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"],"file":"ServiceFactory.js"}
1
+ {"version":3,"sources":["../../src/services/ServiceFactory.ts"],"names":["ServiceFactory","cwd","type","AuthService","EnvService","PkgService","VsCodeService","SchemaService","command","CommandService","LintService","Service","RemoteService","TypeCheckerService","buildImportService","SettingsService","DependencyService","commandService","BuildService","EventSettingsService","Error","ImportService"],"mappings":";;;;;;;;;;;;;AAAA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;IAwBqBA,c;;;;;;;;;;;;;;;;;MACpB,UAAkCC,GAAlC,EAA+CC,IAA/C,EAAuE;AAAA;;AACtE,cAAQA,IAAR;AACC,aAAK,MAAL;AACC,iBAAO,IAAIC,uBAAJ,CACN,IAAIC,4BAAJ,CAAeH,GAAf,CADM,EAEN,IAAII,sBAAJ,CAAeJ,GAAf,CAFM,CAAP;;AAID,aAAK,KAAL;AACC,iBAAO,IAAII,sBAAJ,CAAeJ,GAAf,CAAP;;AACD,aAAK,KAAL;AACC,iBAAO,IAAIG,4BAAJ,CAAeH,GAAf,CAAP;;AACD,aAAK,QAAL;AACC,iBAAO,IAAIK,yBAAJ,CAAkBL,GAAlB,CAAP;;AACD,aAAK,QAAL;AACC,iBAAO,IAAIM,yBAAJ,CAAkB;AACxBN,YAAAA,GAAG,EAAHA,GADwB;AAExBO,YAAAA,OAAO,EAAE,IAAIC,0BAAJ,CAAmBR,GAAnB;AAFe,WAAlB,CAAP;;AAID,aAAK,MAAL;AACC,iBAAO,IAAIS,uBAAJ,CAAgBT,GAAhB,EAAqB;AAAA,mBAC3B,KAAI,CAACU,OAAL,CAAaV,GAAb,EAAkB,SAAlB,CAD2B;AAAA,WAArB,CAAP;;AAGD,aAAK,SAAL;AAAgB;AACf,mBAAO,IAAIQ,0BAAJ,CAAmBR,GAAnB,CAAP;AACA;;AACD,aAAK,QAAL;AACC,iBAAO,IAAIW,yBAAJ,CAAkB,IAAIR,4BAAJ,CAAeH,GAAf,CAAlB,CAAP;;AACD,aAAK,aAAL;AACC,iBAAO,IAAIY,8BAAJ,CACN,KAAKC,kBAAL,CAAwBb,GAAxB,CADM,CAAP;;AAGD,aAAK,UAAL;AACC,iBAAO,IAAIc,iCAAJ,CAAiCd,GAAjC,CAAP;;AACD,aAAK,YAAL;AACC,iBAAO,IAAIe,6BAAJ,CACN,IAAID,iCAAJ,CAAiCd,GAAjC,CADM,CAAP;;AAGD,aAAK,QAAL;AACC,iBAAO,KAAKa,kBAAL,CAAwBb,GAAxB,CAAP;;AACD,aAAK,OAAL;AAAc;AACb,gBAAMgB,cAAc,GAAG,IAAIR,0BAAJ,CAAmBR,GAAnB,CAAvB;AACA,mBAAO,IAAIiB,wBAAJ,CACND,cADM,EAEN,IAAIP,uBAAJ,CAAgBT,GAAhB,EAAqB;AAAA,qBAAM,KAAI,CAACU,OAAL,CAAaV,GAAb,EAAkB,SAAlB,CAAN;AAAA,aAArB,CAFM,CAAP;AAIA;;AACD,aAAK,eAAL;AACC,iBAAO,IAAIkB,gCAAJ,CACN,IAAIJ,iCAAJ,CAAoBd,GAApB,CADM,CAAP;;AAGD;AACC,gBAAM,IAAImB,KAAJ,qBAAsBlB,IAAtB,kBAAN;AAlDF;AAoDA,K;;;WAED,4BAA2BD,GAA3B,EAAuD;AACtD,aAAO,IAAIoB,yBAAJ,CAAkB;AACxBpB,QAAAA,GAAG,EAAHA,GADwB;AAExBO,QAAAA,OAAO,EAAE,IAAIC,0BAAJ,CAAmBR,GAAnB;AAFe,OAAlB,CAAP;AAIA","sourcesContent":["import { SettingsService, EnvService } 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 AuthService from './AuthService'\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 new AuthService(\n\t\t\t\t\tnew EnvService(cwd),\n\t\t\t\t\tnew PkgService(cwd)\n\t\t\t\t) as ServiceMap[S]\n\t\t\tcase 'pkg':\n\t\t\t\treturn new PkgService(cwd) 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"],"file":"ServiceFactory.js"}
@@ -1,5 +1,6 @@
1
1
  import ConversationStore from '../features/conversation/stores/ConversationStore';
2
2
  import EventStore from '../features/event/stores/EventStore';
3
+ import ListenerStore from '../features/event/stores/ListenerStore';
3
4
  import OnboardingStore from '../features/onboard/stores/OnboardingStore';
4
5
  import OrganizationStore from '../features/organization/stores/OrganizationStore';
5
6
  import SchemaStore from '../features/schema/stores/SchemaStore';
@@ -18,6 +19,7 @@ export interface StoreMap {
18
19
  conversation: ConversationStore;
19
20
  store: StoreStore;
20
21
  view: ViewStore;
22
+ listener: ListenerStore;
21
23
  }
22
24
  export declare type StoreCode = keyof StoreMap;
23
25
  export interface StoreFactoryMethodOptions {
@@ -17,6 +17,8 @@ var _ConversationStore = _interopRequireDefault(require("../features/conversatio
17
17
 
18
18
  var _EventStore = _interopRequireDefault(require("../features/event/stores/EventStore"));
19
19
 
20
+ var _ListenerStore = _interopRequireDefault(require("../features/event/stores/ListenerStore"));
21
+
20
22
  var _OnboardingStore = _interopRequireDefault(require("../features/onboard/stores/OnboardingStore"));
21
23
 
22
24
  var _OrganizationStore = _interopRequireDefault(require("../features/organization/stores/OrganizationStore"));
@@ -37,7 +39,8 @@ var storeMap = {
37
39
  organization: _OrganizationStore["default"],
38
40
  conversation: _ConversationStore["default"],
39
41
  store: _StoreStore["default"],
40
- view: _ViewStore["default"]
42
+ view: _ViewStore["default"],
43
+ listener: _ListenerStore["default"]
41
44
  };
42
45
 
43
46
  var StoreFactory = /*#__PURE__*/function () {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/stores/StoreFactory.ts"],"names":["storeMap","onboarding","OnboardingStore","schema","SchemaStore","event","EventStore","skill","SkillStore","organization","OrganizationStore","conversation","ConversationStore","store","StoreStore","view","ViewStore","StoreFactory","options","cwd","serviceFactory","homeDir","apiClientFactory","emitter","code","storeOptions","Error"],"mappings":";;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAmBA,IAAMA,QAAQ,GAAG;AAChBC,EAAAA,UAAU,EAAEC,2BADI;AAEhBC,EAAAA,MAAM,EAAEC,uBAFQ;AAGhBC,EAAAA,KAAK,EAAEC,sBAHS;AAIhBC,EAAAA,KAAK,EAAEC,sBAJS;AAKhBC,EAAAA,YAAY,EAAEC,6BALE;AAMhBC,EAAAA,YAAY,EAAEC,6BANE;AAOhBC,EAAAA,KAAK,EAAEC,sBAPS;AAQhBC,EAAAA,IAAI,EAAEC;AARU,CAAjB;;IAwBqBC,Y;AAOpB,wBAAmBC,OAAnB,EAAiD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAChD,QAAQC,GAAR,GAAoED,OAApE,CAAQC,GAAR;AAAA,QAAaC,cAAb,GAAoEF,OAApE,CAAaE,cAAb;AAAA,QAA6BC,OAA7B,GAAoEH,OAApE,CAA6BG,OAA7B;AAAA,QAAsCC,gBAAtC,GAAoEJ,OAApE,CAAsCI,gBAAtC;AAAA,QAAwDC,OAAxD,GAAoEL,OAApE,CAAwDK,OAAxD;AAEA,SAAKJ,GAAL,GAAWA,GAAX;AACA,SAAKC,cAAL,GAAsBA,cAAtB;AACA,SAAKC,OAAL,GAAeA,OAAf;AACA,SAAKC,gBAAL,GAAwBA,gBAAxB;AACA,SAAKC,OAAL,GAAeA,OAAf;AACA;;;;WAED,eACCC,IADD,EAECN,OAFD,EAGe;AAAA;;AACd,UAAMO,YAA0B,GAAG;AAClCN,QAAAA,GAAG,kBAAED,OAAF,aAAEA,OAAF,uBAAEA,OAAO,CAAEC,GAAX,uDAAkB,KAAKA,GADQ;AAElCC,QAAAA,cAAc,EAAE,KAAKA,cAFa;AAGlCC,QAAAA,OAAO,EAAE,KAAKA,OAHoB;AAIlCC,QAAAA,gBAAgB,2BAAEJ,OAAF,aAAEA,OAAF,uBAAEA,OAAO,CAAEI,gBAAX,yEAA+B,KAAKA,gBAJlB;AAKlCC,QAAAA,OAAO,EAAE,KAAKA;AALoB,OAAnC;;AAQA,UAAI,CAACvB,QAAQ,CAACwB,IAAD,CAAb,EAAqB;AACpB,cAAM,IAAIE,KAAJ,2CAA6CF,IAA7C,QAAN;AACA;;AAED,UAAMX,KAAK,GAAG,IAAIb,QAAQ,CAACwB,IAAD,CAAZ,CAAmBC,YAAnB,CAAd;AAEA,aAAOZ,KAAP;AACA","sourcesContent":["import ConversationStore from '../features/conversation/stores/ConversationStore'\nimport EventStore from '../features/event/stores/EventStore'\nimport OnboardingStore from '../features/onboard/stores/OnboardingStore'\nimport OrganizationStore from '../features/organization/stores/OrganizationStore'\nimport SchemaStore from '../features/schema/stores/SchemaStore'\nimport SkillStore from '../features/skill/stores/SkillStore'\nimport StoreStore from '../features/store/stores/StoreStore'\nimport ViewStore from '../features/view/stores/ViewStore'\nimport { GlobalEmitter } from '../GlobalEmitter'\nimport ServiceFactory from '../services/ServiceFactory'\nimport { ApiClientFactory } from '../types/apiClient.types'\nimport { StoreOptions } from './AbstractStore'\n\nexport interface StoreMap {\n\tonboarding: OnboardingStore\n\tschema: SchemaStore\n\tevent: EventStore\n\tskill: SkillStore\n\torganization: OrganizationStore\n\tconversation: ConversationStore\n\tstore: StoreStore\n\tview: ViewStore\n}\n\nexport type StoreCode = keyof StoreMap\n\nconst storeMap = {\n\tonboarding: OnboardingStore,\n\tschema: SchemaStore,\n\tevent: EventStore,\n\tskill: SkillStore,\n\torganization: OrganizationStore,\n\tconversation: ConversationStore,\n\tstore: StoreStore,\n\tview: ViewStore,\n}\n\nexport interface StoreFactoryMethodOptions {\n\tcwd?: string\n\tapiClientFactory?: ApiClientFactory\n}\n\nexport interface StoreFactoryOptions {\n\tcwd: string\n\tserviceFactory: ServiceFactory\n\thomeDir: string\n\tapiClientFactory: ApiClientFactory\n\temitter: GlobalEmitter\n}\n\nexport default class StoreFactory {\n\tprivate serviceFactory: ServiceFactory\n\tprivate cwd: string\n\tprivate homeDir: string\n\tprivate apiClientFactory: ApiClientFactory\n\tprivate emitter: GlobalEmitter\n\n\tpublic constructor(options: StoreFactoryOptions) {\n\t\tconst { cwd, serviceFactory, homeDir, apiClientFactory, emitter } = options\n\n\t\tthis.cwd = cwd\n\t\tthis.serviceFactory = serviceFactory\n\t\tthis.homeDir = homeDir\n\t\tthis.apiClientFactory = apiClientFactory\n\t\tthis.emitter = emitter\n\t}\n\n\tpublic Store<C extends StoreCode>(\n\t\tcode: C,\n\t\toptions?: StoreFactoryMethodOptions\n\t): StoreMap[C] {\n\t\tconst storeOptions: StoreOptions = {\n\t\t\tcwd: options?.cwd ?? this.cwd,\n\t\t\tserviceFactory: this.serviceFactory,\n\t\t\thomeDir: this.homeDir,\n\t\t\tapiClientFactory: options?.apiClientFactory ?? this.apiClientFactory,\n\t\t\temitter: this.emitter,\n\t\t}\n\n\t\tif (!storeMap[code]) {\n\t\t\tthrow new Error(`Could not find store with code '${code}'.`)\n\t\t}\n\n\t\tconst store = new storeMap[code](storeOptions)\n\n\t\treturn store as StoreMap[C]\n\t}\n}\n"],"file":"StoreFactory.js"}
1
+ {"version":3,"sources":["../../src/stores/StoreFactory.ts"],"names":["storeMap","onboarding","OnboardingStore","schema","SchemaStore","event","EventStore","skill","SkillStore","organization","OrganizationStore","conversation","ConversationStore","store","StoreStore","view","ViewStore","listener","ListenerStore","StoreFactory","options","cwd","serviceFactory","homeDir","apiClientFactory","emitter","code","storeOptions","Error"],"mappings":";;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAoBA,IAAMA,QAAQ,GAAG;AAChBC,EAAAA,UAAU,EAAEC,2BADI;AAEhBC,EAAAA,MAAM,EAAEC,uBAFQ;AAGhBC,EAAAA,KAAK,EAAEC,sBAHS;AAIhBC,EAAAA,KAAK,EAAEC,sBAJS;AAKhBC,EAAAA,YAAY,EAAEC,6BALE;AAMhBC,EAAAA,YAAY,EAAEC,6BANE;AAOhBC,EAAAA,KAAK,EAAEC,sBAPS;AAQhBC,EAAAA,IAAI,EAAEC,qBARU;AAShBC,EAAAA,QAAQ,EAAEC;AATM,CAAjB;;IAyBqBC,Y;AAOpB,wBAAmBC,OAAnB,EAAiD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAChD,QAAQC,GAAR,GAAoED,OAApE,CAAQC,GAAR;AAAA,QAAaC,cAAb,GAAoEF,OAApE,CAAaE,cAAb;AAAA,QAA6BC,OAA7B,GAAoEH,OAApE,CAA6BG,OAA7B;AAAA,QAAsCC,gBAAtC,GAAoEJ,OAApE,CAAsCI,gBAAtC;AAAA,QAAwDC,OAAxD,GAAoEL,OAApE,CAAwDK,OAAxD;AAEA,SAAKJ,GAAL,GAAWA,GAAX;AACA,SAAKC,cAAL,GAAsBA,cAAtB;AACA,SAAKC,OAAL,GAAeA,OAAf;AACA,SAAKC,gBAAL,GAAwBA,gBAAxB;AACA,SAAKC,OAAL,GAAeA,OAAf;AACA;;;;WAED,eACCC,IADD,EAECN,OAFD,EAGe;AAAA;;AACd,UAAMO,YAA0B,GAAG;AAClCN,QAAAA,GAAG,kBAAED,OAAF,aAAEA,OAAF,uBAAEA,OAAO,CAAEC,GAAX,uDAAkB,KAAKA,GADQ;AAElCC,QAAAA,cAAc,EAAE,KAAKA,cAFa;AAGlCC,QAAAA,OAAO,EAAE,KAAKA,OAHoB;AAIlCC,QAAAA,gBAAgB,2BAAEJ,OAAF,aAAEA,OAAF,uBAAEA,OAAO,CAAEI,gBAAX,yEAA+B,KAAKA,gBAJlB;AAKlCC,QAAAA,OAAO,EAAE,KAAKA;AALoB,OAAnC;;AAQA,UAAI,CAACzB,QAAQ,CAAC0B,IAAD,CAAb,EAAqB;AACpB,cAAM,IAAIE,KAAJ,2CAA6CF,IAA7C,QAAN;AACA;;AAED,UAAMb,KAAK,GAAG,IAAIb,QAAQ,CAAC0B,IAAD,CAAZ,CAAmBC,YAAnB,CAAd;AAEA,aAAOd,KAAP;AACA","sourcesContent":["import ConversationStore from '../features/conversation/stores/ConversationStore'\nimport EventStore from '../features/event/stores/EventStore'\nimport ListenerStore from '../features/event/stores/ListenerStore'\nimport OnboardingStore from '../features/onboard/stores/OnboardingStore'\nimport OrganizationStore from '../features/organization/stores/OrganizationStore'\nimport SchemaStore from '../features/schema/stores/SchemaStore'\nimport SkillStore from '../features/skill/stores/SkillStore'\nimport StoreStore from '../features/store/stores/StoreStore'\nimport ViewStore from '../features/view/stores/ViewStore'\nimport { GlobalEmitter } from '../GlobalEmitter'\nimport ServiceFactory from '../services/ServiceFactory'\nimport { ApiClientFactory } from '../types/apiClient.types'\nimport { StoreOptions } from './AbstractStore'\n\nexport interface StoreMap {\n\tonboarding: OnboardingStore\n\tschema: SchemaStore\n\tevent: EventStore\n\tskill: SkillStore\n\torganization: OrganizationStore\n\tconversation: ConversationStore\n\tstore: StoreStore\n\tview: ViewStore\n\tlistener: ListenerStore\n}\n\nexport type StoreCode = keyof StoreMap\n\nconst storeMap = {\n\tonboarding: OnboardingStore,\n\tschema: SchemaStore,\n\tevent: EventStore,\n\tskill: SkillStore,\n\torganization: OrganizationStore,\n\tconversation: ConversationStore,\n\tstore: StoreStore,\n\tview: ViewStore,\n\tlistener: ListenerStore,\n}\n\nexport interface StoreFactoryMethodOptions {\n\tcwd?: string\n\tapiClientFactory?: ApiClientFactory\n}\n\nexport interface StoreFactoryOptions {\n\tcwd: string\n\tserviceFactory: ServiceFactory\n\thomeDir: string\n\tapiClientFactory: ApiClientFactory\n\temitter: GlobalEmitter\n}\n\nexport default class StoreFactory {\n\tprivate serviceFactory: ServiceFactory\n\tprivate cwd: string\n\tprivate homeDir: string\n\tprivate apiClientFactory: ApiClientFactory\n\tprivate emitter: GlobalEmitter\n\n\tpublic constructor(options: StoreFactoryOptions) {\n\t\tconst { cwd, serviceFactory, homeDir, apiClientFactory, emitter } = options\n\n\t\tthis.cwd = cwd\n\t\tthis.serviceFactory = serviceFactory\n\t\tthis.homeDir = homeDir\n\t\tthis.apiClientFactory = apiClientFactory\n\t\tthis.emitter = emitter\n\t}\n\n\tpublic Store<C extends StoreCode>(\n\t\tcode: C,\n\t\toptions?: StoreFactoryMethodOptions\n\t): StoreMap[C] {\n\t\tconst storeOptions: StoreOptions = {\n\t\t\tcwd: options?.cwd ?? this.cwd,\n\t\t\tserviceFactory: this.serviceFactory,\n\t\t\thomeDir: this.homeDir,\n\t\t\tapiClientFactory: options?.apiClientFactory ?? this.apiClientFactory,\n\t\t\temitter: this.emitter,\n\t\t}\n\n\t\tif (!storeMap[code]) {\n\t\t\tthrow new Error(`Could not find store with code '${code}'.`)\n\t\t}\n\n\t\tconst store = new storeMap[code](storeOptions)\n\n\t\treturn store as StoreMap[C]\n\t}\n}\n"],"file":"StoreFactory.js"}
@@ -63,12 +63,12 @@ var _CommandService = _interopRequireDefault(require("../services/CommandService
63
63
 
64
64
  var _ImportService = _interopRequireDefault(require("../services/ImportService"));
65
65
 
66
+ var _LintService = _interopRequireDefault(require("../services/LintService"));
67
+
66
68
  var _ServiceFactory2 = _interopRequireDefault(require("../services/ServiceFactory"));
67
69
 
68
70
  var _StoreFactory2 = _interopRequireDefault(require("../stores/StoreFactory"));
69
71
 
70
- var _AbstractWriter = _interopRequireDefault(require("../writers/AbstractWriter"));
71
-
72
72
  var _WriterFactory2 = _interopRequireDefault(require("../writers/WriterFactory"));
73
73
 
74
74
  var _FeatureFixture2 = _interopRequireDefault(require("./fixtures/FeatureFixture"));
@@ -129,7 +129,7 @@ var AbstractCliTest = /*#__PURE__*/function (_AbstractSpruceTest) {
129
129
  return this.cleanTestDirsAndFiles();
130
130
 
131
131
  case 4:
132
- _AbstractWriter["default"].disableLinting();
132
+ _LintService["default"].disableLinting();
133
133
 
134
134
  _ImportService["default"].setCacheDir(_spruceSkillUtils.diskUtil.createRandomTempDir());
135
135
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/tests/AbstractCliTest.ts"],"names":["AbstractCliTest","cleanTestDirsAndFiles","AbstractWriter","disableLinting","ImportService","setCacheDir","diskUtil","createRandomTempDir","enableCaching","process","env","ENABLE_INSTALL_INTERTAINMENT","originalEnv","testUtil","startLogTimer","SchemaRegistry","getInstance","forgetAllSchemas","cwd","freshTmpDir","homeDir","emitter","undefined","featureInstaller","OnboardingStore","overrideCwd","ui","reset","invocations","setCursorPosition","x","y","clearFixtures","clearCache","SkillStore","clearCurrentSkill","EventStore","CommandService","clearMockResponses","organizationFixture","clearAllOrgs","mercuryFixture","disconnectAll","_ui","isWaitingForInput","Error","doesDirExist","shouldClearCache","deleteDir","shouldCleanupTestSkillDirs","FeatureFixture","deleteOldSkillDirs","pattern","resolveTestPath","matches","match","deleteFile","personFixture","skillFixture","viewFixture","tmpDirectory","resolveTestDir","uuid","v4","fs","ensureDirSync","SpyInterface","CliGlobalEmitter","Emitter","pathAfterTestDirsAndFiles","pathUtil","join","cliRoot","options","Cli","fixture","linkLocalPackages","type","sf","ServiceFactory","Service","getEmitter","serviceFactory","apiClientFactory","getMercuryFixture","getApiClientFactory","getFeatureInstaller","MercuryFixture","PersonFixture","writerFactory","WriterFactory","viewWriter","Writer","fileDescriptions","ViewFixture","Action","templates","settings","execute","promise","waitForInput","sendInput","results","OrganizationFixture","getPersonFixture","StoreFactory","SkillFixture","filePath","resolveHashSprucePath","storeFactory","actionExecuter","ActionExecuter","FeatureInstallerFactory","WithAllFeatures","code","Store","isInstalled","assert","isTrue","files","file","checker","check","path","connectToApi","all","dir","wait","timeout","log","featureCode","actionCode","executer","shouldThrowOnListenerError","actionFactory","ActionFactory","optionOverrides","shouldInstallMissingDependencies","featureInstallerFactory","shouldAutoHandleDependencies","label","last","getLastInvocation","doesInclude","choices","find","o","value","AbstractSpruceTest","__dirname"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAIA;;AAGA;;AACA;;AAEA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAQA;;AACA;;AACA;;AAGA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;;;;;;;;;;;IAM8BA,e;;;;;;;;;;;;;qGAc7B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA,uBAEO,KAAKC,qBAAL,EAFP;;AAAA;AAICC,2CAAeC,cAAf;;AAEAC,0CAAcC,WAAd,CAA0BC,2BAASC,mBAAT,EAA1B;;AACAH,0CAAcI,aAAd;;AAEAC,gBAAAA,OAAO,CAACC,GAAR,CAAYC,4BAAZ,GAA2C,OAA3C;AAEA,qBAAKC,WAAL,qBAAwBH,OAAO,CAACC,GAAhC;;AAXD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,O;;;;;;;;;;;sGAcA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;AAGC;AACAD,gBAAAA,OAAO,CAACC,GAAR,qBAAmB,KAAKE,WAAxB;;AAEAC,kCAASC,aAAT;;AAEAC,uCAAeC,WAAf,GAA6BC,gBAA7B;;AAEA,qBAAKC,GAAL,GAAW,KAAKC,WAAL,EAAX;AACA,qBAAKC,OAAL,GAAe,KAAKD,WAAL,EAAf;AAEA,qBAAKE,OAAL,GAAeC,SAAf;AACA,qBAAKC,gBAAL,GAAwBD,SAAxB;;AAEAE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CADErJ,e;iCAAAA,e;iCAAAA,e;iCAAAA,e;iCAAAA,e;iCAAAA,e;iCAAAA,e;iCAAAA,e;iCAAAA,e;iCAAAA,e","sourcesContent":["import pathUtil from 'path'\nimport { SchemaRegistry } from '@sprucelabs/schema'\nimport { diskUtil } from '@sprucelabs/spruce-skill-utils'\nimport { templates } from '@sprucelabs/spruce-templates'\nimport AbstractSpruceTest, { assert } from '@sprucelabs/test'\nimport fs from 'fs-extra'\nimport globby from 'globby'\nimport * as uuid from 'uuid'\nimport { CliBootOptions } from '../cli'\nimport AbstractAction from '../features/AbstractAction'\nimport { FeatureOptions } from '../features/AbstractFeature'\nimport ActionExecuter, {\n\tActionExecuterOptions,\n} from '../features/ActionExecuter'\nimport ActionFactory from '../features/ActionFactory'\nimport EventStore from '../features/event/stores/EventStore'\nimport FeatureInstaller from '../features/FeatureInstaller'\nimport FeatureInstallerFactory from '../features/FeatureInstallerFactory'\nimport { FeatureActionResponse, FeatureCode } from '../features/features.types'\nimport OnboardingStore from '../features/onboard/stores/OnboardingStore'\nimport SkillStore from '../features/skill/stores/SkillStore'\nimport CliGlobalEmitter, { GlobalEmitter } from '../GlobalEmitter'\nimport SpyInterface from '../interfaces/SpyInterface'\nimport CommandService from '../services/CommandService'\nimport ImportService from '../services/ImportService'\nimport ServiceFactory, { Service, ServiceMap } from '../services/ServiceFactory'\nimport StoreFactory, {\n\tStoreCode,\n\tStoreFactoryMethodOptions,\n\tStoreFactoryOptions,\n\tStoreMap,\n} from '../stores/StoreFactory'\nimport { ApiClientFactoryOptions } from '../types/apiClient.types'\nimport { OptionOverrides } from '../types/cli.types'\nimport AbstractWriter from '../writers/AbstractWriter'\nimport WriterFactory from '../writers/WriterFactory'\nimport FeatureFixture, {\n\tFeatureFixtureOptions,\n} from './fixtures/FeatureFixture'\nimport MercuryFixture from './fixtures/MercuryFixture'\nimport OrganizationFixture from './fixtures/OrganizationFixture'\nimport PersonFixture from './fixtures/PersonFixture'\nimport SkillFixture from './fixtures/SkillFixture'\nimport ViewFixture from './fixtures/ViewFixture'\nimport testUtil from './utilities/test.utility'\n\ntype ExecuterOptions = Partial<ActionExecuterOptions> & {\n\toptionOverrides?: OptionOverrides\n}\n\nexport default abstract class AbstractCliTest extends AbstractSpruceTest {\n\tprotected static cliRoot = pathUtil.join(__dirname, '..')\n\tprotected static homeDir: string\n\n\tprivate static _ui: SpyInterface\n\tprivate static emitter?: GlobalEmitter\n\tprivate static mercuryFixture?: MercuryFixture\n\tprivate static personFixture?: PersonFixture\n\tprivate static organizationFixture?: OrganizationFixture\n\tprivate static skillFixture?: SkillFixture\n\tprivate static featureInstaller?: FeatureInstaller\n\tprivate static viewFixture?: ViewFixture\n\tprivate static originalEnv: { [x: string]: string | undefined }\n\n\tprotected static async beforeAll() {\n\t\tawait super.beforeAll()\n\t\tawait this.cleanTestDirsAndFiles()\n\n\t\tAbstractWriter.disableLinting()\n\n\t\tImportService.setCacheDir(diskUtil.createRandomTempDir())\n\t\tImportService.enableCaching()\n\n\t\tprocess.env.ENABLE_INSTALL_INTERTAINMENT = 'false'\n\n\t\tthis.originalEnv = { ...process.env }\n\t}\n\n\tprotected static async beforeEach() {\n\t\tawait super.beforeEach()\n\n\t\t//@ts-ignore\n\t\tprocess.env = { ...this.originalEnv }\n\n\t\ttestUtil.startLogTimer()\n\n\t\tSchemaRegistry.getInstance().forgetAllSchemas()\n\n\t\tthis.cwd = this.freshTmpDir()\n\t\tthis.homeDir = this.freshTmpDir()\n\n\t\tthis.emitter = undefined\n\t\tthis.featureInstaller = undefined\n\n\t\tOnboardingStore.overrideCwd(diskUtil.createRandomTempDir())\n\n\t\tthis.ui.reset()\n\t\tthis.ui.invocations = []\n\t\tthis.ui.setCursorPosition({ x: 0, y: 0 })\n\n\t\tthis.clearFixtures()\n\n\t\tImportService.clearCache()\n\t\tSkillStore.clearCurrentSkill()\n\t\tEventStore.clearCache()\n\t\tCommandService.clearMockResponses()\n\t}\n\n\tprotected static async afterEach() {\n\t\tawait super.afterEach()\n\n\t\tawait this.organizationFixture?.clearAllOrgs()\n\t\tawait this.mercuryFixture?.disconnectAll()\n\n\t\tthis.clearFixtures()\n\n\t\tif (this._ui?.isWaitingForInput()) {\n\t\t\tthrow new Error(\n\t\t\t\t`Terminal interface is waiting for input. Make sure you are invoking this.term.sendInput() as many times as needed.`\n\t\t\t)\n\t\t}\n\n\t\tif (diskUtil.doesDirExist(this.cwd) && testUtil.shouldClearCache()) {\n\t\t\tdiskUtil.deleteDir(this.cwd)\n\t\t}\n\n\t\tif (diskUtil.doesDirExist(this.homeDir) && testUtil.shouldClearCache()) {\n\t\t\tdiskUtil.deleteDir(this.homeDir)\n\t\t}\n\t}\n\n\tprotected static async afterAll() {\n\t\tawait super.afterAll()\n\t\tif (testUtil.shouldCleanupTestSkillDirs()) {\n\t\t\tFeatureFixture.deleteOldSkillDirs()\n\t\t}\n\t}\n\n\tprivate static async cleanTestDirsAndFiles() {\n\t\tconst pattern = this.resolveTestPath('**/*.d.ts')\n\t\tconst matches = await globby(pattern)\n\n\t\tfor (const match of matches) {\n\t\t\tdiskUtil.deleteFile(match)\n\t\t}\n\t}\n\n\tprivate static clearFixtures() {\n\t\tthis.emitter = undefined\n\t\tthis.mercuryFixture = undefined\n\t\tthis.organizationFixture = undefined\n\t\tthis.personFixture = undefined\n\t\tthis.skillFixture = undefined\n\t\tthis.viewFixture = undefined\n\t}\n\n\tprotected static freshTmpDir() {\n\t\tconst tmpDirectory = testUtil.resolveTestDir(uuid.v4())\n\t\tfs.ensureDirSync(tmpDirectory)\n\t\treturn tmpDirectory\n\t}\n\n\tprotected static get ui() {\n\t\tif (!this._ui) {\n\t\t\tthis._ui = new SpyInterface()\n\t\t}\n\n\t\treturn this._ui\n\t}\n\n\tprotected static getEmitter() {\n\t\tif (!this.emitter) {\n\t\t\tthis.emitter = CliGlobalEmitter.Emitter()\n\t\t}\n\t\treturn this.emitter\n\t}\n\n\tprotected static resolveTestPath(...pathAfterTestDirsAndFiles: string[]) {\n\t\treturn pathUtil.join(\n\t\t\tthis.cliRoot,\n\t\t\t'__tests__',\n\t\t\t'testDirsAndFiles',\n\t\t\t...pathAfterTestDirsAndFiles\n\t\t)\n\t}\n\n\tprotected static async Cli(options?: CliBootOptions) {\n\t\treturn this.FeatureFixture(options).Cli({\n\t\t\tcwd: this.cwd,\n\t\t\thomeDir: this.homeDir,\n\t\t\t...(options ?? {}),\n\t\t})\n\t}\n\n\tprotected static async linkLocalPackages() {\n\t\tconst fixture = this.FeatureFixture()\n\t\tawait fixture.linkLocalPackages()\n\t}\n\n\tprotected static Service<S extends Service>(\n\t\ttype: S,\n\t\tcwd?: string\n\t): ServiceMap[S] {\n\t\tconst sf = this.ServiceFactory()\n\t\treturn sf.Service(cwd ?? this.cwd, type)\n\t}\n\n\tprotected static ServiceFactory() {\n\t\treturn new ServiceFactory()\n\t}\n\n\tprotected static FeatureFixture(options?: Partial<FeatureFixtureOptions>) {\n\t\tconst emitter = options?.emitter ?? this.getEmitter()\n\n\t\treturn new FeatureFixture({\n\t\t\tcwd: this.cwd,\n\t\t\tserviceFactory: this.ServiceFactory(),\n\t\t\tui: this.ui,\n\t\t\temitter,\n\t\t\tapiClientFactory: this.getMercuryFixture().getApiClientFactory(),\n\t\t\tfeatureInstaller: this.getFeatureInstaller({ emitter }),\n\t\t\t...options,\n\t\t})\n\t}\n\n\tprotected static getMercuryFixture() {\n\t\tif (!this.mercuryFixture) {\n\t\t\tthis.mercuryFixture = new MercuryFixture(this.cwd, this.ServiceFactory())\n\t\t}\n\n\t\treturn this.mercuryFixture\n\t}\n\n\tprotected static getPersonFixture() {\n\t\tif (!this.personFixture) {\n\t\t\tthis.personFixture = new PersonFixture(\n\t\t\t\tthis.getMercuryFixture().getApiClientFactory()\n\t\t\t)\n\t\t}\n\n\t\treturn this.personFixture\n\t}\n\n\tprotected static getViewFixture() {\n\t\tif (!this.viewFixture) {\n\t\t\tconst writerFactory = this.WriterFactory()\n\n\t\t\tconst viewWriter = writerFactory.Writer('view', { fileDescriptions: [] })\n\t\t\tthis.viewFixture = new ViewFixture(\n\t\t\t\tthis.cwd,\n\t\t\t\tviewWriter,\n\t\t\t\tthis.Action('view', 'sync')\n\t\t\t)\n\t\t}\n\n\t\treturn this.viewFixture\n\t}\n\n\tprivate static WriterFactory() {\n\t\treturn new WriterFactory({\n\t\t\ttemplates,\n\t\t\tui: this.ui,\n\t\t\tsettings: this.Service('settings'),\n\t\t})\n\t}\n\n\tprotected static async skipInstallSkillPrompts<\n\t\tE extends () => Promise<FeatureActionResponse>\n\t>(\n\t\texecute?: E\n\t): Promise<E extends undefined ? undefined : FeatureActionResponse> {\n\t\tconst promise = execute?.()\n\n\t\tawait this.waitForInput()\n\t\tawait this.ui.sendInput('n')\n\n\t\tawait this.waitForInput()\n\t\tawait this.ui.sendInput('')\n\n\t\tconst results = await promise\n\n\t\treturn results as any\n\t}\n\n\tprotected static getOrganizationFixture() {\n\t\tif (!this.organizationFixture) {\n\t\t\tthis.organizationFixture = new OrganizationFixture(\n\t\t\t\tthis.getPersonFixture(),\n\t\t\t\tthis.StoreFactory()\n\t\t\t)\n\t\t}\n\n\t\treturn this.organizationFixture\n\t}\n\n\tprotected static getSkillFixture() {\n\t\tif (!this.skillFixture) {\n\t\t\tthis.skillFixture = new SkillFixture(\n\t\t\t\tthis.getPersonFixture(),\n\t\t\t\tthis.StoreFactory(),\n\t\t\t\tthis.getMercuryFixture().getApiClientFactory()\n\t\t\t)\n\t\t}\n\n\t\treturn this.skillFixture\n\t}\n\n\tprotected static resolveHashSprucePath(...filePath: string[]) {\n\t\treturn diskUtil.resolveHashSprucePath(this.cwd, ...filePath)\n\t}\n\n\tprotected static getFeatureInstaller(options?: Partial<FeatureOptions>) {\n\t\tif (!this.featureInstaller) {\n\t\t\tconst serviceFactory = this.ServiceFactory()\n\t\t\tconst storeFactory = this.StoreFactory(options)\n\t\t\tconst emitter = this.getEmitter()\n\t\t\tconst apiClientFactory = this.getMercuryFixture().getApiClientFactory()\n\n\t\t\tconst actionExecuter = this.ActionExecuter()\n\n\t\t\tthis.featureInstaller = FeatureInstallerFactory.WithAllFeatures({\n\t\t\t\tcwd: this.cwd,\n\t\t\t\tserviceFactory,\n\t\t\t\tstoreFactory,\n\t\t\t\tui: this.ui,\n\t\t\t\temitter,\n\t\t\t\tapiClientFactory,\n\t\t\t\tactionExecuter,\n\t\t\t\t...options,\n\t\t\t})\n\t\t}\n\n\t\treturn this.featureInstaller\n\t}\n\n\tprotected static StoreFactory(options?: Partial<StoreFactoryOptions>) {\n\t\tconst serviceFactory = this.ServiceFactory()\n\n\t\treturn new StoreFactory({\n\t\t\tcwd: this.cwd,\n\t\t\tserviceFactory,\n\t\t\thomeDir: this.homeDir,\n\t\t\tapiClientFactory: this.getMercuryFixture().getApiClientFactory(),\n\t\t\temitter: this.getEmitter(),\n\t\t\t...options,\n\t\t})\n\t}\n\n\tprotected static Store<C extends StoreCode>(\n\t\tcode: C,\n\t\toptions?: StoreFactoryMethodOptions\n\t): StoreMap[C] {\n\t\treturn this.StoreFactory().Store(code, {\n\t\t\tcwd: this.cwd,\n\t\t\t...options,\n\t\t})\n\t}\n\n\tprotected static async waitForInput() {\n\t\treturn this.ui.waitForInput()\n\t}\n\n\tprotected static async assertIsFeatureInstalled(code: FeatureCode) {\n\t\tconst featureInstaller = this.getFeatureInstaller()\n\t\tconst isInstalled = await featureInstaller.isInstalled(code)\n\n\t\tassert.isTrue(isInstalled)\n\t}\n\n\tprotected static async assertValidActionResponseFiles(\n\t\tresults: FeatureActionResponse\n\t) {\n\t\tfor (const file of results.files ?? []) {\n\t\t\tconst checker = this.Service('typeChecker')\n\t\t\tawait checker.check(file.path)\n\t\t}\n\n\t\t// await Promise.all(\n\t\t// \t(results.files ?? []).map((file) => {\n\t\t// \t\tconst checker = this.Service('typeChecker')\n\t\t// \t\treturn checker.check(file.path)\n\t\t// \t})\n\t\t// )\n\t}\n\n\tprotected static async connectToApi(options?: ApiClientFactoryOptions) {\n\t\treturn this.getMercuryFixture().connectToApi(options)\n\t}\n\n\tprotected static async openInVsCode(options?: {\n\t\tfile?: string\n\t\tdir?: string\n\t\ttimeout?: number\n\t}) {\n\t\tawait this.Action('vscode', 'setup').execute({ all: true })\n\n\t\tawait this.Service('command').execute(\n\t\t\t`code ${options?.file ?? options?.dir ?? this.cwd}`\n\t\t)\n\t\tawait this.wait(options?.timeout ?? 99999999)\n\t}\n\n\tprotected static async openInFinder(options?: {\n\t\tfile?: string\n\t\tdir?: string\n\t\ttimeout?: number\n\t}) {\n\t\tawait this.Service('command').execute(\n\t\t\t`open ${options?.file ?? options?.dir ?? this.cwd}`\n\t\t)\n\t\tawait this.wait(options?.timeout ?? 99999999)\n\t}\n\n\tprotected static log(...args: any[]) {\n\t\ttestUtil.log(...args)\n\t}\n\n\tprotected static Action<\n\t\tAction extends AbstractAction = AbstractAction,\n\t\tF extends FeatureCode = FeatureCode\n\t>(featureCode: F, actionCode: string, options?: ExecuterOptions): Action {\n\t\tconst executer = this.ActionExecuter({\n\t\t\tshouldThrowOnListenerError: true,\n\t\t\t...options,\n\t\t}).Action(featureCode, actionCode)\n\n\t\treturn executer as any\n\t}\n\n\tprotected static ActionExecuter(options?: ExecuterOptions) {\n\t\tconst serviceFactory = this.ServiceFactory()\n\t\tconst writerFactory = this.WriterFactory()\n\n\t\tconst emitter = this.getEmitter()\n\n\t\tconst actionFactory = new ActionFactory({\n\t\t\twriterFactory,\n\t\t\tui: this.ui,\n\t\t\temitter,\n\t\t\tapiClientFactory: this.getMercuryFixture().getApiClientFactory(),\n\t\t\tcwd: this.cwd,\n\t\t\tserviceFactory,\n\t\t\tstoreFactory: this.StoreFactory(),\n\t\t\ttemplates,\n\t\t\toptionOverrides: {\n\t\t\t\t'sync.schemas': {\n\t\t\t\t\tshouldInstallMissingDependencies: true,\n\t\t\t\t},\n\t\t\t\t...options?.optionOverrides,\n\t\t\t},\n\t\t})\n\n\t\tconst executer = new ActionExecuter({\n\t\t\tui: this.ui,\n\t\t\temitter,\n\t\t\tactionFactory,\n\t\t\tfeatureInstallerFactory: () => {\n\t\t\t\treturn this.getFeatureInstaller()\n\t\t\t},\n\t\t\tshouldAutoHandleDependencies: false,\n\t\t\t...options,\n\t\t})\n\n\t\treturn executer\n\t}\n\n\tprotected static selectOptionBasedOnLabel(label: string) {\n\t\tconst last = this.ui.getLastInvocation()\n\t\tassert.doesInclude(last.options.options.choices, {\n\t\t\tlabel,\n\t\t})\n\n\t\tconst match = last.options.options.choices.find(\n\t\t\t(o: any) => o.label === label\n\t\t)\n\n\t\tvoid this.ui.sendInput(`${match.value}`)\n\t}\n}\n"],"file":"AbstractCliTest.js"}
1
+ {"version":3,"sources":["../../src/tests/AbstractCliTest.ts"],"names":["AbstractCliTest","cleanTestDirsAndFiles","LintService","disableLinting","ImportService","setCacheDir","diskUtil","createRandomTempDir","enableCaching","process","env","ENABLE_INSTALL_INTERTAINMENT","originalEnv","testUtil","startLogTimer","SchemaRegistry","getInstance","forgetAllSchemas","cwd","freshTmpDir","homeDir","emitter","undefined","featureInstaller","OnboardingStore","overrideCwd","ui","reset","invocations","setCursorPosition","x","y","clearFixtures","clearCache","SkillStore","clearCurrentSkill","EventStore","CommandService","clearMockResponses","organizationFixture","clearAllOrgs","mercuryFixture","disconnectAll","_ui","isWaitingForInput","Error","doesDirExist","shouldClearCache","deleteDir","shouldCleanupTestSkillDirs","FeatureFixture","deleteOldSkillDirs","pattern","resolveTestPath","matches","match","deleteFile","personFixture","skillFixture","viewFixture","tmpDirectory","resolveTestDir","uuid","v4","fs","ensureDirSync","SpyInterface","CliGlobalEmitter","Emitter","pathAfterTestDirsAndFiles","pathUtil","join","cliRoot","options","Cli","fixture","linkLocalPackages","type","sf","ServiceFactory","Service","getEmitter","serviceFactory","apiClientFactory","getMercuryFixture","getApiClientFactory","getFeatureInstaller","MercuryFixture","PersonFixture","writerFactory","WriterFactory","viewWriter","Writer","fileDescriptions","ViewFixture","Action","templates","settings","execute","promise","waitForInput","sendInput","results","OrganizationFixture","getPersonFixture","StoreFactory","SkillFixture","filePath","resolveHashSprucePath","storeFactory","actionExecuter","ActionExecuter","FeatureInstallerFactory","WithAllFeatures","code","Store","isInstalled","assert","isTrue","files","file","checker","check","path","connectToApi","all","dir","wait","timeout","log","featureCode","actionCode","executer","shouldThrowOnListenerError","actionFactory","ActionFactory","optionOverrides","shouldInstallMissingDependencies","featureInstallerFactory","shouldAutoHandleDependencies","label","last","getLastInvocation","doesInclude","choices","find","o","value","AbstractSpruceTest","__dirname"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAIA;;AAGA;;AACA;;AAEA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAQA;;AACA;;AAGA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;;;;;;;;;;;IAM8BA,e;;;;;;;;;;;;;qGAc7B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA,uBAEO,KAAKC,qBAAL,EAFP;;AAAA;AAICC,wCAAYC,cAAZ;;AAEAC,0CAAcC,WAAd,CAA0BC,2BAASC,mBAAT,EAA1B;;AACAH,0CAAcI,aAAd;;AAEAC,gBAAAA,OAAO,CAACC,GAAR,CAAYC,4BAAZ,GAA2C,OAA3C;AAEA,qBAAKC,WAAL,qBAAwBH,OAAO,CAACC,GAAhC;;AAXD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,O;;;;;;;;;;;sGAcA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;AAGC;AACAD,gBAAAA,OAAO,CAACC,GAAR,qBAAmB,KAAKE,WAAxB;;AAEAC,kCAASC,aAAT;;AAEAC,uCAAeC,WAAf,GAA6BC,gBAA7B;;AAEA,qBAAKC,GAAL,GAAW,KAAKC,WAAL,EAAX;AACA,qBAAKC,OAAL,GAAe,KAAKD,WAAL,EAAf;AAEA,qBAAKE,OAAL,GAAeC,SAA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iBAASC,IAAT,CAAc8E,SAAd,EAAyB,IAAzB,C;iCADErJ,e;iCAAAA,e;iCAAAA,e;iCAAAA,e;iCAAAA,e;iCAAAA,e;iCAAAA,e;iCAAAA,e;iCAAAA,e;iCAAAA,e","sourcesContent":["import pathUtil from 'path'\nimport { SchemaRegistry } from '@sprucelabs/schema'\nimport { diskUtil } from '@sprucelabs/spruce-skill-utils'\nimport { templates } from '@sprucelabs/spruce-templates'\nimport AbstractSpruceTest, { assert } from '@sprucelabs/test'\nimport fs from 'fs-extra'\nimport globby from 'globby'\nimport * as uuid from 'uuid'\nimport { CliBootOptions } from '../cli'\nimport AbstractAction from '../features/AbstractAction'\nimport { FeatureOptions } from '../features/AbstractFeature'\nimport ActionExecuter, {\n\tActionExecuterOptions,\n} from '../features/ActionExecuter'\nimport ActionFactory from '../features/ActionFactory'\nimport EventStore from '../features/event/stores/EventStore'\nimport FeatureInstaller from '../features/FeatureInstaller'\nimport FeatureInstallerFactory from '../features/FeatureInstallerFactory'\nimport { FeatureActionResponse, FeatureCode } from '../features/features.types'\nimport OnboardingStore from '../features/onboard/stores/OnboardingStore'\nimport SkillStore from '../features/skill/stores/SkillStore'\nimport CliGlobalEmitter, { GlobalEmitter } from '../GlobalEmitter'\nimport SpyInterface from '../interfaces/SpyInterface'\nimport CommandService from '../services/CommandService'\nimport ImportService from '../services/ImportService'\nimport LintService from '../services/LintService'\nimport ServiceFactory, { Service, ServiceMap } from '../services/ServiceFactory'\nimport StoreFactory, {\n\tStoreCode,\n\tStoreFactoryMethodOptions,\n\tStoreFactoryOptions,\n\tStoreMap,\n} from '../stores/StoreFactory'\nimport { ApiClientFactoryOptions } from '../types/apiClient.types'\nimport { OptionOverrides } from '../types/cli.types'\nimport WriterFactory from '../writers/WriterFactory'\nimport FeatureFixture, {\n\tFeatureFixtureOptions,\n} from './fixtures/FeatureFixture'\nimport MercuryFixture from './fixtures/MercuryFixture'\nimport OrganizationFixture from './fixtures/OrganizationFixture'\nimport PersonFixture from './fixtures/PersonFixture'\nimport SkillFixture from './fixtures/SkillFixture'\nimport ViewFixture from './fixtures/ViewFixture'\nimport testUtil from './utilities/test.utility'\n\ntype ExecuterOptions = Partial<ActionExecuterOptions> & {\n\toptionOverrides?: OptionOverrides\n}\n\nexport default abstract class AbstractCliTest extends AbstractSpruceTest {\n\tprotected static cliRoot = pathUtil.join(__dirname, '..')\n\tprotected static homeDir: string\n\n\tprivate static _ui: SpyInterface\n\tprivate static emitter?: GlobalEmitter\n\tprivate static mercuryFixture?: MercuryFixture\n\tprivate static personFixture?: PersonFixture\n\tprivate static organizationFixture?: OrganizationFixture\n\tprivate static skillFixture?: SkillFixture\n\tprivate static featureInstaller?: FeatureInstaller\n\tprivate static viewFixture?: ViewFixture\n\tprivate static originalEnv: { [x: string]: string | undefined }\n\n\tprotected static async beforeAll() {\n\t\tawait super.beforeAll()\n\t\tawait this.cleanTestDirsAndFiles()\n\n\t\tLintService.disableLinting()\n\n\t\tImportService.setCacheDir(diskUtil.createRandomTempDir())\n\t\tImportService.enableCaching()\n\n\t\tprocess.env.ENABLE_INSTALL_INTERTAINMENT = 'false'\n\n\t\tthis.originalEnv = { ...process.env }\n\t}\n\n\tprotected static async beforeEach() {\n\t\tawait super.beforeEach()\n\n\t\t//@ts-ignore\n\t\tprocess.env = { ...this.originalEnv }\n\n\t\ttestUtil.startLogTimer()\n\n\t\tSchemaRegistry.getInstance().forgetAllSchemas()\n\n\t\tthis.cwd = this.freshTmpDir()\n\t\tthis.homeDir = this.freshTmpDir()\n\n\t\tthis.emitter = undefined\n\t\tthis.featureInstaller = undefined\n\n\t\tOnboardingStore.overrideCwd(diskUtil.createRandomTempDir())\n\n\t\tthis.ui.reset()\n\t\tthis.ui.invocations = []\n\t\tthis.ui.setCursorPosition({ x: 0, y: 0 })\n\n\t\tthis.clearFixtures()\n\n\t\tImportService.clearCache()\n\t\tSkillStore.clearCurrentSkill()\n\t\tEventStore.clearCache()\n\t\tCommandService.clearMockResponses()\n\t}\n\n\tprotected static async afterEach() {\n\t\tawait super.afterEach()\n\n\t\tawait this.organizationFixture?.clearAllOrgs()\n\t\tawait this.mercuryFixture?.disconnectAll()\n\n\t\tthis.clearFixtures()\n\n\t\tif (this._ui?.isWaitingForInput()) {\n\t\t\tthrow new Error(\n\t\t\t\t`Terminal interface is waiting for input. Make sure you are invoking this.term.sendInput() as many times as needed.`\n\t\t\t)\n\t\t}\n\n\t\tif (diskUtil.doesDirExist(this.cwd) && testUtil.shouldClearCache()) {\n\t\t\tdiskUtil.deleteDir(this.cwd)\n\t\t}\n\n\t\tif (diskUtil.doesDirExist(this.homeDir) && testUtil.shouldClearCache()) {\n\t\t\tdiskUtil.deleteDir(this.homeDir)\n\t\t}\n\t}\n\n\tprotected static async afterAll() {\n\t\tawait super.afterAll()\n\t\tif (testUtil.shouldCleanupTestSkillDirs()) {\n\t\t\tFeatureFixture.deleteOldSkillDirs()\n\t\t}\n\t}\n\n\tprivate static async cleanTestDirsAndFiles() {\n\t\tconst pattern = this.resolveTestPath('**/*.d.ts')\n\t\tconst matches = await globby(pattern)\n\n\t\tfor (const match of matches) {\n\t\t\tdiskUtil.deleteFile(match)\n\t\t}\n\t}\n\n\tprivate static clearFixtures() {\n\t\tthis.emitter = undefined\n\t\tthis.mercuryFixture = undefined\n\t\tthis.organizationFixture = undefined\n\t\tthis.personFixture = undefined\n\t\tthis.skillFixture = undefined\n\t\tthis.viewFixture = undefined\n\t}\n\n\tprotected static freshTmpDir() {\n\t\tconst tmpDirectory = testUtil.resolveTestDir(uuid.v4())\n\t\tfs.ensureDirSync(tmpDirectory)\n\t\treturn tmpDirectory\n\t}\n\n\tprotected static get ui() {\n\t\tif (!this._ui) {\n\t\t\tthis._ui = new SpyInterface()\n\t\t}\n\n\t\treturn this._ui\n\t}\n\n\tprotected static getEmitter() {\n\t\tif (!this.emitter) {\n\t\t\tthis.emitter = CliGlobalEmitter.Emitter()\n\t\t}\n\t\treturn this.emitter\n\t}\n\n\tprotected static resolveTestPath(...pathAfterTestDirsAndFiles: string[]) {\n\t\treturn pathUtil.join(\n\t\t\tthis.cliRoot,\n\t\t\t'__tests__',\n\t\t\t'testDirsAndFiles',\n\t\t\t...pathAfterTestDirsAndFiles\n\t\t)\n\t}\n\n\tprotected static async Cli(options?: CliBootOptions) {\n\t\treturn this.FeatureFixture(options).Cli({\n\t\t\tcwd: this.cwd,\n\t\t\thomeDir: this.homeDir,\n\t\t\t...(options ?? {}),\n\t\t})\n\t}\n\n\tprotected static async linkLocalPackages() {\n\t\tconst fixture = this.FeatureFixture()\n\t\tawait fixture.linkLocalPackages()\n\t}\n\n\tprotected static Service<S extends Service>(\n\t\ttype: S,\n\t\tcwd?: string\n\t): ServiceMap[S] {\n\t\tconst sf = this.ServiceFactory()\n\t\treturn sf.Service(cwd ?? this.cwd, type)\n\t}\n\n\tprotected static ServiceFactory() {\n\t\treturn new ServiceFactory()\n\t}\n\n\tprotected static FeatureFixture(options?: Partial<FeatureFixtureOptions>) {\n\t\tconst emitter = options?.emitter ?? this.getEmitter()\n\n\t\treturn new FeatureFixture({\n\t\t\tcwd: this.cwd,\n\t\t\tserviceFactory: this.ServiceFactory(),\n\t\t\tui: this.ui,\n\t\t\temitter,\n\t\t\tapiClientFactory: this.getMercuryFixture().getApiClientFactory(),\n\t\t\tfeatureInstaller: this.getFeatureInstaller({ emitter }),\n\t\t\t...options,\n\t\t})\n\t}\n\n\tprotected static getMercuryFixture() {\n\t\tif (!this.mercuryFixture) {\n\t\t\tthis.mercuryFixture = new MercuryFixture(this.cwd, this.ServiceFactory())\n\t\t}\n\n\t\treturn this.mercuryFixture\n\t}\n\n\tprotected static getPersonFixture() {\n\t\tif (!this.personFixture) {\n\t\t\tthis.personFixture = new PersonFixture(\n\t\t\t\tthis.getMercuryFixture().getApiClientFactory()\n\t\t\t)\n\t\t}\n\n\t\treturn this.personFixture\n\t}\n\n\tprotected static getViewFixture() {\n\t\tif (!this.viewFixture) {\n\t\t\tconst writerFactory = this.WriterFactory()\n\n\t\t\tconst viewWriter = writerFactory.Writer('view', { fileDescriptions: [] })\n\t\t\tthis.viewFixture = new ViewFixture(\n\t\t\t\tthis.cwd,\n\t\t\t\tviewWriter,\n\t\t\t\tthis.Action('view', 'sync')\n\t\t\t)\n\t\t}\n\n\t\treturn this.viewFixture\n\t}\n\n\tprivate static WriterFactory() {\n\t\treturn new WriterFactory({\n\t\t\ttemplates,\n\t\t\tui: this.ui,\n\t\t\tsettings: this.Service('settings'),\n\t\t})\n\t}\n\n\tprotected static async skipInstallSkillPrompts<\n\t\tE extends () => Promise<FeatureActionResponse>\n\t>(\n\t\texecute?: E\n\t): Promise<E extends undefined ? undefined : FeatureActionResponse> {\n\t\tconst promise = execute?.()\n\n\t\tawait this.waitForInput()\n\t\tawait this.ui.sendInput('n')\n\n\t\tawait this.waitForInput()\n\t\tawait this.ui.sendInput('')\n\n\t\tconst results = await promise\n\n\t\treturn results as any\n\t}\n\n\tprotected static getOrganizationFixture() {\n\t\tif (!this.organizationFixture) {\n\t\t\tthis.organizationFixture = new OrganizationFixture(\n\t\t\t\tthis.getPersonFixture(),\n\t\t\t\tthis.StoreFactory()\n\t\t\t)\n\t\t}\n\n\t\treturn this.organizationFixture\n\t}\n\n\tprotected static getSkillFixture() {\n\t\tif (!this.skillFixture) {\n\t\t\tthis.skillFixture = new SkillFixture(\n\t\t\t\tthis.getPersonFixture(),\n\t\t\t\tthis.StoreFactory(),\n\t\t\t\tthis.getMercuryFixture().getApiClientFactory()\n\t\t\t)\n\t\t}\n\n\t\treturn this.skillFixture\n\t}\n\n\tprotected static resolveHashSprucePath(...filePath: string[]) {\n\t\treturn diskUtil.resolveHashSprucePath(this.cwd, ...filePath)\n\t}\n\n\tprotected static getFeatureInstaller(options?: Partial<FeatureOptions>) {\n\t\tif (!this.featureInstaller) {\n\t\t\tconst serviceFactory = this.ServiceFactory()\n\t\t\tconst storeFactory = this.StoreFactory(options)\n\t\t\tconst emitter = this.getEmitter()\n\t\t\tconst apiClientFactory = this.getMercuryFixture().getApiClientFactory()\n\n\t\t\tconst actionExecuter = this.ActionExecuter()\n\n\t\t\tthis.featureInstaller = FeatureInstallerFactory.WithAllFeatures({\n\t\t\t\tcwd: this.cwd,\n\t\t\t\tserviceFactory,\n\t\t\t\tstoreFactory,\n\t\t\t\tui: this.ui,\n\t\t\t\temitter,\n\t\t\t\tapiClientFactory,\n\t\t\t\tactionExecuter,\n\t\t\t\t...options,\n\t\t\t})\n\t\t}\n\n\t\treturn this.featureInstaller\n\t}\n\n\tprotected static StoreFactory(options?: Partial<StoreFactoryOptions>) {\n\t\tconst serviceFactory = this.ServiceFactory()\n\n\t\treturn new StoreFactory({\n\t\t\tcwd: this.cwd,\n\t\t\tserviceFactory,\n\t\t\thomeDir: this.homeDir,\n\t\t\tapiClientFactory: this.getMercuryFixture().getApiClientFactory(),\n\t\t\temitter: this.getEmitter(),\n\t\t\t...options,\n\t\t})\n\t}\n\n\tprotected static Store<C extends StoreCode>(\n\t\tcode: C,\n\t\toptions?: StoreFactoryMethodOptions\n\t): StoreMap[C] {\n\t\treturn this.StoreFactory().Store(code, {\n\t\t\tcwd: this.cwd,\n\t\t\t...options,\n\t\t})\n\t}\n\n\tprotected static async waitForInput() {\n\t\treturn this.ui.waitForInput()\n\t}\n\n\tprotected static async assertIsFeatureInstalled(code: FeatureCode) {\n\t\tconst featureInstaller = this.getFeatureInstaller()\n\t\tconst isInstalled = await featureInstaller.isInstalled(code)\n\n\t\tassert.isTrue(isInstalled)\n\t}\n\n\tprotected static async assertValidActionResponseFiles(\n\t\tresults: FeatureActionResponse\n\t) {\n\t\tfor (const file of results.files ?? []) {\n\t\t\tconst checker = this.Service('typeChecker')\n\t\t\tawait checker.check(file.path)\n\t\t}\n\n\t\t// await Promise.all(\n\t\t// \t(results.files ?? []).map((file) => {\n\t\t// \t\tconst checker = this.Service('typeChecker')\n\t\t// \t\treturn checker.check(file.path)\n\t\t// \t})\n\t\t// )\n\t}\n\n\tprotected static async connectToApi(options?: ApiClientFactoryOptions) {\n\t\treturn this.getMercuryFixture().connectToApi(options)\n\t}\n\n\tprotected static async openInVsCode(options?: {\n\t\tfile?: string\n\t\tdir?: string\n\t\ttimeout?: number\n\t}) {\n\t\tawait this.Action('vscode', 'setup').execute({ all: true })\n\n\t\tawait this.Service('command').execute(\n\t\t\t`code ${options?.file ?? options?.dir ?? this.cwd}`\n\t\t)\n\t\tawait this.wait(options?.timeout ?? 99999999)\n\t}\n\n\tprotected static async openInFinder(options?: {\n\t\tfile?: string\n\t\tdir?: string\n\t\ttimeout?: number\n\t}) {\n\t\tawait this.Service('command').execute(\n\t\t\t`open ${options?.file ?? options?.dir ?? this.cwd}`\n\t\t)\n\t\tawait this.wait(options?.timeout ?? 99999999)\n\t}\n\n\tprotected static log(...args: any[]) {\n\t\ttestUtil.log(...args)\n\t}\n\n\tprotected static Action<\n\t\tAction extends AbstractAction = AbstractAction,\n\t\tF extends FeatureCode = FeatureCode\n\t>(featureCode: F, actionCode: string, options?: ExecuterOptions): Action {\n\t\tconst executer = this.ActionExecuter({\n\t\t\tshouldThrowOnListenerError: true,\n\t\t\t...options,\n\t\t}).Action(featureCode, actionCode)\n\n\t\treturn executer as any\n\t}\n\n\tprotected static ActionExecuter(options?: ExecuterOptions) {\n\t\tconst serviceFactory = this.ServiceFactory()\n\t\tconst writerFactory = this.WriterFactory()\n\n\t\tconst emitter = this.getEmitter()\n\n\t\tconst actionFactory = new ActionFactory({\n\t\t\twriterFactory,\n\t\t\tui: this.ui,\n\t\t\temitter,\n\t\t\tapiClientFactory: this.getMercuryFixture().getApiClientFactory(),\n\t\t\tcwd: this.cwd,\n\t\t\tserviceFactory,\n\t\t\tstoreFactory: this.StoreFactory(),\n\t\t\ttemplates,\n\t\t\toptionOverrides: {\n\t\t\t\t'sync.schemas': {\n\t\t\t\t\tshouldInstallMissingDependencies: true,\n\t\t\t\t},\n\t\t\t\t...options?.optionOverrides,\n\t\t\t},\n\t\t})\n\n\t\tconst executer = new ActionExecuter({\n\t\t\tui: this.ui,\n\t\t\temitter,\n\t\t\tactionFactory,\n\t\t\tfeatureInstallerFactory: () => {\n\t\t\t\treturn this.getFeatureInstaller()\n\t\t\t},\n\t\t\tshouldAutoHandleDependencies: false,\n\t\t\t...options,\n\t\t})\n\n\t\treturn executer\n\t}\n\n\tprotected static selectOptionBasedOnLabel(label: string) {\n\t\tconst last = this.ui.getLastInvocation()\n\t\tassert.doesInclude(last.options.options.choices, {\n\t\t\tlabel,\n\t\t})\n\n\t\tconst match = last.options.options.choices.find(\n\t\t\t(o: any) => o.label === label\n\t\t)\n\n\t\tvoid this.ui.sendInput(`${match.value}`)\n\t}\n}\n"],"file":"AbstractCliTest.js"}
@@ -28,14 +28,11 @@ export default abstract class AbstractWriter {
28
28
  private upgradeMode;
29
29
  private fileDescriptions;
30
30
  private shouldConfirmBeforeWriting;
31
- private static isLintingEnabled;
32
31
  private firstFileWriteMessage?;
33
32
  private hasShownFirstWriteMessage;
34
33
  private settings;
35
34
  constructor(options: WriterOptions);
36
35
  protected lint(file: string): Promise<void>;
37
- static disableLinting(): void;
38
- static enableLinting(): void;
39
36
  protected writeDirectoryTemplate(options: WriteDirectoryTemplateOptions): Promise<WriteResults>;
40
37
  protected writeFileIfChangedMixinResults(destination: string, contents: string, description: string, results?: WriteResults, cwd?: string): Promise<WriteResults>;
41
38
  private isFileDifferent;
@@ -65,16 +65,11 @@ var AbstractWriter = /*#__PURE__*/function () {
65
65
  while (1) {
66
66
  switch (_context.prev = _context.next) {
67
67
  case 0:
68
- if (!AbstractWriter.isLintingEnabled) {
69
- _context.next = 4;
70
- break;
71
- }
72
-
73
68
  this.ui.startLoading("Linting ".concat(_path["default"].basename(file), "..."));
74
- _context.next = 4;
69
+ _context.next = 3;
75
70
  return (_this$linter = this.linter) === null || _this$linter === void 0 ? void 0 : _this$linter.fix(file)["catch"](function () {});
76
71
 
77
- case 4:
72
+ case 3:
78
73
  case "end":
79
74
  return _context.stop();
80
75
  }
@@ -409,20 +404,9 @@ var AbstractWriter = /*#__PURE__*/function () {
409
404
  var isDir = _spruceSkillUtils.diskUtil.doesDirExist(dirOrFile) && _fs["default"].lstatSync(dirOrFile).isDirectory() && _path["default"].extname(dirOrFile).length === 0;
410
405
  return isDir ? _spruceSkillUtils.diskUtil.resolvePath(dirOrFile, fallbackFileName) : dirOrFile;
411
406
  }
412
- }], [{
413
- key: "disableLinting",
414
- value: function disableLinting() {
415
- this.isLintingEnabled = false;
416
- }
417
- }, {
418
- key: "enableLinting",
419
- value: function enableLinting() {
420
- this.isLintingEnabled = true;
421
- }
422
407
  }]);
423
408
  return AbstractWriter;
424
409
  }();
425
410
 
426
411
  exports["default"] = AbstractWriter;
427
- (0, _defineProperty2["default"])(AbstractWriter, "isLintingEnabled", true);
428
412
  //# sourceMappingURL=AbstractWriter.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/writers/AbstractWriter.ts"],"names":["AbstractWriter","options","templates","ui","term","upgradeMode","fileDescriptions","linter","settings","file","isLintingEnabled","startLoading","pathUtil","basename","fix","context","destinationDir","filesToWrite","filesToSkip","shouldConfirmBeforeWriting","firstFileWriteMessage","hasShownFirstWriteMessage","directoryTemplate","kind","code","files","results","generated","shouldWrite","indexOf","filename","shouldSkip","writeFileIfChangedMixinResults","join","relativePath","contents","destination","description","cwd","myResults","desc","name","action","diskUtil","isDir","Error","fileDescription","getFileDescription","doesFileExist","write","confirmPromptOnFirstWrite","stopLoading","confirm","writeFile","isFileDifferent","shouldOverwriteIfChanged","cleanedName","cleanFilename","skipped","get","isAlwaysSkipped","shouldAskForOverwrite","renderLine","prompt","type","label","choices","value","FILE_ACTION_OVERWRITE","FILE_ACTION_SKIP","FILE_ACTION_ALWAYS_SKIP","answer","push","set","replace","path","relativeFile","sep","substr","shouldOverwriteWhenChanged","lower","toLowerCase","d","search","undefined","dirOrFile","fallbackFileName","doesDirExist","fs","lstatSync","isDirectory","extname","length","resolvePath"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AAEA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spruce-skill-utils'\nimport { DirectoryTemplateCode, Templates } from '@sprucelabs/spruce-templates'\nimport {\n\tFILE_ACTION_ALWAYS_SKIP,\n\tFILE_ACTION_OVERWRITE,\n\tFILE_ACTION_SKIP,\n} from '../constants'\nimport LintService from '../services/LintService'\nimport { FileDescription, GeneratedFile, UpgradeMode } from '../types/cli.types'\nimport { GraphicsInterface } from '../types/cli.types'\n\nexport type WriteResults = GeneratedFile[]\n\nexport interface WriterOptions {\n\ttemplates: Templates\n\tterm: GraphicsInterface\n\tupgradeMode?: UpgradeMode\n\tfileDescriptions: FileDescription[]\n\tlinter?: LintService\n\tsettings: SettingsService\n}\n\nexport interface WriteDirectoryTemplateOptions {\n\tdestinationDir: string\n\tcode: DirectoryTemplateCode\n\tfilesToWrite?: string[]\n\tfilesToSkip?: string[]\n\tcontext: any\n\tshouldConfirmBeforeWriting?: boolean\n\tfirstFileWriteMessage?: string\n}\n\nexport default abstract class AbstractWriter {\n\tprotected templates: Templates\n\tprotected ui: GraphicsInterface\n\tprivate linter?: LintService\n\tprivate upgradeMode: UpgradeMode\n\tprivate fileDescriptions: FileDescription[] = []\n\tprivate shouldConfirmBeforeWriting = true\n\tprivate static isLintingEnabled = true\n\tprivate firstFileWriteMessage?: string\n\tprivate hasShownFirstWriteMessage = false\n\tprivate settings: SettingsService<string>\n\n\tpublic constructor(options: WriterOptions) {\n\t\tthis.templates = options.templates\n\t\tthis.ui = options.term\n\t\tthis.upgradeMode = options.upgradeMode\n\t\tthis.fileDescriptions = options.fileDescriptions\n\t\tthis.linter = options.linter\n\t\tthis.settings = options.settings\n\t}\n\n\tprotected async lint(file: string) {\n\t\tif (AbstractWriter.isLintingEnabled) {\n\t\t\tthis.ui.startLoading(`Linting ${pathUtil.basename(file)}...`)\n\t\t\tawait this.linter?.fix(file).catch(() => {})\n\t\t}\n\t}\n\n\tpublic static disableLinting() {\n\t\tthis.isLintingEnabled = false\n\t}\n\n\tpublic static enableLinting() {\n\t\tthis.isLintingEnabled = true\n\t}\n\n\tprotected async writeDirectoryTemplate(\n\t\toptions: WriteDirectoryTemplateOptions\n\t) {\n\t\tconst {\n\t\t\tcontext,\n\t\t\tdestinationDir,\n\t\t\tfilesToWrite,\n\t\t\tfilesToSkip,\n\t\t\tshouldConfirmBeforeWriting = true,\n\t\t\tfirstFileWriteMessage,\n\t\t} = options\n\n\t\tthis.shouldConfirmBeforeWriting = shouldConfirmBeforeWriting\n\t\tthis.firstFileWriteMessage = firstFileWriteMessage\n\t\tthis.hasShownFirstWriteMessage = false\n\n\t\tconst files = await this.templates.directoryTemplate({\n\t\t\tkind: options.code,\n\t\t\tcontext: context ?? {},\n\t\t})\n\n\t\tlet results: WriteResults = []\n\n\t\tfor (const generated of files) {\n\t\t\tconst shouldWrite =\n\t\t\t\t!filesToWrite || filesToWrite.indexOf(generated.filename) > -1\n\t\t\tconst shouldSkip =\n\t\t\t\tfilesToSkip && filesToSkip.indexOf(generated.filename) > -1\n\n\t\t\tif (shouldWrite && !shouldSkip) {\n\t\t\t\tresults = await this.writeFileIfChangedMixinResults(\n\t\t\t\t\tpathUtil.join(destinationDir, generated.relativePath),\n\t\t\t\t\tgenerated.contents,\n\t\t\t\t\t'',\n\t\t\t\t\tresults,\n\t\t\t\t\tdestinationDir\n\t\t\t\t)\n\t\t\t}\n\t\t}\n\n\t\treturn results\n\t}\n\n\tprotected async writeFileIfChangedMixinResults(\n\t\tdestination: string,\n\t\tcontents: string,\n\t\tdescription: string,\n\t\tresults?: WriteResults,\n\t\tcwd = ''\n\t): Promise<WriteResults> {\n\t\tconst myResults: WriteResults = results ?? []\n\t\tlet desc: string | undefined = description\n\n\t\tconst name = pathUtil.basename(destination)\n\t\tlet action: GeneratedFile['action'] = 'skipped'\n\n\t\tif (diskUtil.isDir(destination)) {\n\t\t\tthrow new Error(`Can't write to a directory ${destination}.`)\n\t\t}\n\n\t\tconst fileDescription = this.getFileDescription(destination)\n\n\t\tif (!diskUtil.doesFileExist(destination)) {\n\t\t\tlet write = true\n\n\t\t\tif (\n\t\t\t\tthis.shouldConfirmBeforeWriting &&\n\t\t\t\tfileDescription?.confirmPromptOnFirstWrite\n\t\t\t) {\n\t\t\t\tthis.ui.stopLoading()\n\t\t\t\twrite = await this.ui.confirm(fileDescription.confirmPromptOnFirstWrite)\n\t\t\t}\n\n\t\t\tif (write) {\n\t\t\t\tdiskUtil.writeFile(destination, contents)\n\t\t\t\taction = 'generated'\n\t\t\t}\n\t\t} else if (\n\t\t\tthis.isFileDifferent(destination, contents) &&\n\t\t\tthis.shouldOverwriteIfChanged(destination)\n\t\t) {\n\t\t\tconst cleanedName = this.cleanFilename(destination, cwd)\n\t\t\tconst settings = { skipped: [], ...this.settings.get('writer') }\n\t\t\tconst isAlwaysSkipped = settings.skipped.indexOf(cleanedName) > -1\n\t\t\tlet write = !isAlwaysSkipped\n\n\t\t\tif (!isAlwaysSkipped && this.shouldAskForOverwrite()) {\n\t\t\t\tif (!this.hasShownFirstWriteMessage && this.firstFileWriteMessage) {\n\t\t\t\t\tthis.hasShownFirstWriteMessage = true\n\t\t\t\t\tthis.ui.renderLine(this.firstFileWriteMessage)\n\t\t\t\t\tthis.ui.renderLine('')\n\t\t\t\t}\n\n\t\t\t\tconst answer = await this.ui.prompt({\n\t\t\t\t\ttype: 'select',\n\t\t\t\t\tlabel: `${cleanedName}`,\n\t\t\t\t\toptions: {\n\t\t\t\t\t\tchoices: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tvalue: FILE_ACTION_OVERWRITE,\n\t\t\t\t\t\t\t\tlabel: 'Overwrite',\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tvalue: FILE_ACTION_SKIP,\n\t\t\t\t\t\t\t\tlabel: 'Skip',\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tvalue: FILE_ACTION_ALWAYS_SKIP,\n\t\t\t\t\t\t\t\tlabel: 'Always skip',\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t},\n\t\t\t\t})\n\n\t\t\t\tif (answer === FILE_ACTION_ALWAYS_SKIP) {\n\t\t\t\t\tsettings.skipped.push(cleanedName)\n\t\t\t\t\tthis.settings.set('writer', settings)\n\t\t\t\t}\n\n\t\t\t\twrite = answer === FILE_ACTION_OVERWRITE\n\t\t\t}\n\n\t\t\tif (write) {\n\t\t\t\tdiskUtil.writeFile(destination, contents)\n\t\t\t\taction = 'updated'\n\t\t\t}\n\t\t}\n\n\t\tif (!desc) {\n\t\t\tdesc = fileDescription?.description\n\t\t}\n\n\t\tif (!desc) {\n\t\t\tthrow new Error(\n\t\t\t\t`No FileDescription provided for ${destination.replace(\n\t\t\t\t\tcwd,\n\t\t\t\t\t''\n\t\t\t\t)}. Check your feature's fileDescriptions property.`\n\t\t\t)\n\t\t}\n\n\t\tmyResults.push({ name, description: desc, path: destination, action })\n\n\t\treturn myResults\n\t}\n\n\tprivate isFileDifferent(destination: string, contents: string) {\n\t\treturn diskUtil.isFileDifferent(destination, contents)\n\t}\n\n\tprivate cleanFilename(destination: string, cwd: string) {\n\t\tlet relativeFile = destination.replace(cwd, '')\n\t\tif (relativeFile[0] === pathUtil.sep) {\n\t\t\trelativeFile = relativeFile.substr(1)\n\t\t}\n\t\treturn relativeFile\n\t}\n\n\tprivate shouldOverwriteIfChanged(destination: string): boolean {\n\t\tif (!this.upgradeMode) {\n\t\t\treturn true\n\t\t}\n\n\t\tif (this.upgradeMode === 'forceEverything') {\n\t\t\treturn true\n\t\t}\n\n\t\tlet description: FileDescription | undefined =\n\t\t\tthis.getFileDescription(destination)\n\n\t\treturn description?.shouldOverwriteWhenChanged ?? false\n\t}\n\n\tprivate getFileDescription(destination: string): FileDescription | undefined {\n\t\tconst lower = destination.toLowerCase()\n\t\tfor (const d of this.fileDescriptions ?? []) {\n\t\t\tif (lower.search(d.path.toLowerCase()) > -1) {\n\t\t\t\treturn d\n\t\t\t}\n\t\t}\n\n\t\treturn undefined\n\t}\n\n\tprivate shouldAskForOverwrite() {\n\t\tif (\n\t\t\tthis.shouldConfirmBeforeWriting &&\n\t\t\tthis.upgradeMode === 'askForChanged'\n\t\t) {\n\t\t\treturn true\n\t\t}\n\n\t\treturn false\n\t}\n\n\tprotected resolveFilenameWithFallback(\n\t\tdirOrFile: string,\n\t\tfallbackFileName: string\n\t) {\n\t\tconst isDir =\n\t\t\tdiskUtil.doesDirExist(dirOrFile) &&\n\t\t\tfs.lstatSync(dirOrFile).isDirectory() &&\n\t\t\tpathUtil.extname(dirOrFile).length === 0\n\t\treturn isDir ? diskUtil.resolvePath(dirOrFile, fallbackFileName) : dirOrFile\n\t}\n}\n"],"file":"AbstractWriter.js"}
1
+ {"version":3,"sources":["../../src/writers/AbstractWriter.ts"],"names":["AbstractWriter","options","templates","ui","term","upgradeMode","fileDescriptions","linter","settings","file","startLoading","pathUtil","basename","fix","context","destinationDir","filesToWrite","filesToSkip","shouldConfirmBeforeWriting","firstFileWriteMessage","hasShownFirstWriteMessage","directoryTemplate","kind","code","files","results","generated","shouldWrite","indexOf","filename","shouldSkip","writeFileIfChangedMixinResults","join","relativePath","contents","destination","description","cwd","myResults","desc","name","action","diskUtil","isDir","Error","fileDescription","getFileDescription","doesFileExist","write","confirmPromptOnFirstWrite","stopLoading","confirm","writeFile","isFileDifferent","shouldOverwriteIfChanged","cleanedName","cleanFilename","skipped","get","isAlwaysSkipped","shouldAskForOverwrite","renderLine","prompt","type","label","choices","value","FILE_ACTION_OVERWRITE","FILE_ACTION_SKIP","FILE_ACTION_ALWAYS_SKIP","answer","push","set","replace","path","relativeFile","sep","substr","shouldOverwriteWhenChanged","lower","toLowerCase","d","search","undefined","dirOrFile","fallbackFileName","doesDirExist","fs","lstatSync","isDirectory","extname","length","resolvePath"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AAEA;;;;;;;;;;;;IA8B8BA,c;AAW7B,0BAAmBC,OAAnB,EAA2C;AAAA;AAAA;AAAA;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AAW,CAAE0C,0BAApB,yEAAkD,KAAlD;AACA;;;WAED,4BAA2B3C,WAA3B,EAA6E;AAAA;;AAC5E,UAAM4C,KAAK,GAAG5C,WAAW,CAAC6C,WAAZ,EAAd;;AAD4E,2EAE5D,KAAK1E,gBAFuD,yEAEnC,EAFmC;AAAA;;AAAA;AAE5E,+DAA6C;AAAA,cAAlC2E,CAAkC;;AAC5C,cAAIF,KAAK,CAACG,MAAN,CAAaD,CAAC,CAACP,IAAF,CAAOM,WAAP,EAAb,IAAqC,CAAC,CAA1C,EAA6C;AAC5C,mBAAOC,CAAP;AACA;AACD;AAN2E;AAAA;AAAA;AAAA;AAAA;;AAQ5E,aAAOE,SAAP;AACA;;;WAED,iCAAgC;AAC/B,UACC,KAAKjE,0BAAL,IACA,KAAKb,WAAL,KAAqB,eAFtB,EAGE;AACD,eAAO,IAAP;AACA;;AAED,aAAO,KAAP;AACA;;;WAED,qCACC+E,SADD,EAECC,gBAFD,EAGE;AACD,UAAM1C,KAAK,GACVD,2BAAS4C,YAAT,CAAsBF,SAAtB,KACAG,eAAGC,SAAH,CAAaJ,SAAb,EAAwBK,WAAxB,EADA,IAEA9E,iBAAS+E,OAAT,CAAiBN,SAAjB,EAA4BO,MAA5B,KAAuC,CAHxC;AAIA,aAAOhD,KAAK,GAAGD,2BAASkD,WAAT,CAAqBR,SAArB,EAAgCC,gBAAhC,CAAH,GAAuDD,SAAnE;AACA","sourcesContent":["import fs from 'fs'\nimport pathUtil from 'path'\nimport { diskUtil, SettingsService } from '@sprucelabs/spruce-skill-utils'\nimport { DirectoryTemplateCode, Templates } from '@sprucelabs/spruce-templates'\nimport {\n\tFILE_ACTION_ALWAYS_SKIP,\n\tFILE_ACTION_OVERWRITE,\n\tFILE_ACTION_SKIP,\n} from '../constants'\nimport LintService from '../services/LintService'\nimport { FileDescription, GeneratedFile, UpgradeMode } from '../types/cli.types'\nimport { GraphicsInterface } from '../types/cli.types'\n\nexport type WriteResults = GeneratedFile[]\n\nexport interface WriterOptions {\n\ttemplates: Templates\n\tterm: GraphicsInterface\n\tupgradeMode?: UpgradeMode\n\tfileDescriptions: FileDescription[]\n\tlinter?: LintService\n\tsettings: SettingsService\n}\n\nexport interface WriteDirectoryTemplateOptions {\n\tdestinationDir: string\n\tcode: DirectoryTemplateCode\n\tfilesToWrite?: string[]\n\tfilesToSkip?: string[]\n\tcontext: any\n\tshouldConfirmBeforeWriting?: boolean\n\tfirstFileWriteMessage?: string\n}\n\nexport default abstract class AbstractWriter {\n\tprotected templates: Templates\n\tprotected ui: GraphicsInterface\n\tprivate linter?: LintService\n\tprivate upgradeMode: UpgradeMode\n\tprivate fileDescriptions: FileDescription[] = []\n\tprivate shouldConfirmBeforeWriting = true\n\tprivate firstFileWriteMessage?: string\n\tprivate hasShownFirstWriteMessage = false\n\tprivate settings: SettingsService<string>\n\n\tpublic constructor(options: WriterOptions) {\n\t\tthis.templates = options.templates\n\t\tthis.ui = options.term\n\t\tthis.upgradeMode = options.upgradeMode\n\t\tthis.fileDescriptions = options.fileDescriptions\n\t\tthis.linter = options.linter\n\t\tthis.settings = options.settings\n\t}\n\n\tprotected async lint(file: string) {\n\t\tthis.ui.startLoading(`Linting ${pathUtil.basename(file)}...`)\n\t\tawait this.linter?.fix(file).catch(() => {})\n\t}\n\n\tprotected async writeDirectoryTemplate(\n\t\toptions: WriteDirectoryTemplateOptions\n\t) {\n\t\tconst {\n\t\t\tcontext,\n\t\t\tdestinationDir,\n\t\t\tfilesToWrite,\n\t\t\tfilesToSkip,\n\t\t\tshouldConfirmBeforeWriting = true,\n\t\t\tfirstFileWriteMessage,\n\t\t} = options\n\n\t\tthis.shouldConfirmBeforeWriting = shouldConfirmBeforeWriting\n\t\tthis.firstFileWriteMessage = firstFileWriteMessage\n\t\tthis.hasShownFirstWriteMessage = false\n\n\t\tconst files = await this.templates.directoryTemplate({\n\t\t\tkind: options.code,\n\t\t\tcontext: context ?? {},\n\t\t})\n\n\t\tlet results: WriteResults = []\n\n\t\tfor (const generated of files) {\n\t\t\tconst shouldWrite =\n\t\t\t\t!filesToWrite || filesToWrite.indexOf(generated.filename) > -1\n\t\t\tconst shouldSkip =\n\t\t\t\tfilesToSkip && filesToSkip.indexOf(generated.filename) > -1\n\n\t\t\tif (shouldWrite && !shouldSkip) {\n\t\t\t\tresults = await this.writeFileIfChangedMixinResults(\n\t\t\t\t\tpathUtil.join(destinationDir, generated.relativePath),\n\t\t\t\t\tgenerated.contents,\n\t\t\t\t\t'',\n\t\t\t\t\tresults,\n\t\t\t\t\tdestinationDir\n\t\t\t\t)\n\t\t\t}\n\t\t}\n\n\t\treturn results\n\t}\n\n\tprotected async writeFileIfChangedMixinResults(\n\t\tdestination: string,\n\t\tcontents: string,\n\t\tdescription: string,\n\t\tresults?: WriteResults,\n\t\tcwd = ''\n\t): Promise<WriteResults> {\n\t\tconst myResults: WriteResults = results ?? []\n\t\tlet desc: string | undefined = description\n\n\t\tconst name = pathUtil.basename(destination)\n\t\tlet action: GeneratedFile['action'] = 'skipped'\n\n\t\tif (diskUtil.isDir(destination)) {\n\t\t\tthrow new Error(`Can't write to a directory ${destination}.`)\n\t\t}\n\n\t\tconst fileDescription = this.getFileDescription(destination)\n\n\t\tif (!diskUtil.doesFileExist(destination)) {\n\t\t\tlet write = true\n\n\t\t\tif (\n\t\t\t\tthis.shouldConfirmBeforeWriting &&\n\t\t\t\tfileDescription?.confirmPromptOnFirstWrite\n\t\t\t) {\n\t\t\t\tthis.ui.stopLoading()\n\t\t\t\twrite = await this.ui.confirm(fileDescription.confirmPromptOnFirstWrite)\n\t\t\t}\n\n\t\t\tif (write) {\n\t\t\t\tdiskUtil.writeFile(destination, contents)\n\t\t\t\taction = 'generated'\n\t\t\t}\n\t\t} else if (\n\t\t\tthis.isFileDifferent(destination, contents) &&\n\t\t\tthis.shouldOverwriteIfChanged(destination)\n\t\t) {\n\t\t\tconst cleanedName = this.cleanFilename(destination, cwd)\n\t\t\tconst settings = { skipped: [], ...this.settings.get('writer') }\n\t\t\tconst isAlwaysSkipped = settings.skipped.indexOf(cleanedName) > -1\n\t\t\tlet write = !isAlwaysSkipped\n\n\t\t\tif (!isAlwaysSkipped && this.shouldAskForOverwrite()) {\n\t\t\t\tif (!this.hasShownFirstWriteMessage && this.firstFileWriteMessage) {\n\t\t\t\t\tthis.hasShownFirstWriteMessage = true\n\t\t\t\t\tthis.ui.renderLine(this.firstFileWriteMessage)\n\t\t\t\t\tthis.ui.renderLine('')\n\t\t\t\t}\n\n\t\t\t\tconst answer = await this.ui.prompt({\n\t\t\t\t\ttype: 'select',\n\t\t\t\t\tlabel: `${cleanedName}`,\n\t\t\t\t\toptions: {\n\t\t\t\t\t\tchoices: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tvalue: FILE_ACTION_OVERWRITE,\n\t\t\t\t\t\t\t\tlabel: 'Overwrite',\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tvalue: FILE_ACTION_SKIP,\n\t\t\t\t\t\t\t\tlabel: 'Skip',\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tvalue: FILE_ACTION_ALWAYS_SKIP,\n\t\t\t\t\t\t\t\tlabel: 'Always skip',\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t},\n\t\t\t\t})\n\n\t\t\t\tif (answer === FILE_ACTION_ALWAYS_SKIP) {\n\t\t\t\t\tsettings.skipped.push(cleanedName)\n\t\t\t\t\tthis.settings.set('writer', settings)\n\t\t\t\t}\n\n\t\t\t\twrite = answer === FILE_ACTION_OVERWRITE\n\t\t\t}\n\n\t\t\tif (write) {\n\t\t\t\tdiskUtil.writeFile(destination, contents)\n\t\t\t\taction = 'updated'\n\t\t\t}\n\t\t}\n\n\t\tif (!desc) {\n\t\t\tdesc = fileDescription?.description\n\t\t}\n\n\t\tif (!desc) {\n\t\t\tthrow new Error(\n\t\t\t\t`No FileDescription provided for ${destination.replace(\n\t\t\t\t\tcwd,\n\t\t\t\t\t''\n\t\t\t\t)}. Check your feature's fileDescriptions property.`\n\t\t\t)\n\t\t}\n\n\t\tmyResults.push({ name, description: desc, path: destination, action })\n\n\t\treturn myResults\n\t}\n\n\tprivate isFileDifferent(destination: string, contents: string) {\n\t\treturn diskUtil.isFileDifferent(destination, contents)\n\t}\n\n\tprivate cleanFilename(destination: string, cwd: string) {\n\t\tlet relativeFile = destination.replace(cwd, '')\n\t\tif (relativeFile[0] === pathUtil.sep) {\n\t\t\trelativeFile = relativeFile.substr(1)\n\t\t}\n\t\treturn relativeFile\n\t}\n\n\tprivate shouldOverwriteIfChanged(destination: string): boolean {\n\t\tif (!this.upgradeMode) {\n\t\t\treturn true\n\t\t}\n\n\t\tif (this.upgradeMode === 'forceEverything') {\n\t\t\treturn true\n\t\t}\n\n\t\tlet description: FileDescription | undefined =\n\t\t\tthis.getFileDescription(destination)\n\n\t\treturn description?.shouldOverwriteWhenChanged ?? false\n\t}\n\n\tprivate getFileDescription(destination: string): FileDescription | undefined {\n\t\tconst lower = destination.toLowerCase()\n\t\tfor (const d of this.fileDescriptions ?? []) {\n\t\t\tif (lower.search(d.path.toLowerCase()) > -1) {\n\t\t\t\treturn d\n\t\t\t}\n\t\t}\n\n\t\treturn undefined\n\t}\n\n\tprivate shouldAskForOverwrite() {\n\t\tif (\n\t\t\tthis.shouldConfirmBeforeWriting &&\n\t\t\tthis.upgradeMode === 'askForChanged'\n\t\t) {\n\t\t\treturn true\n\t\t}\n\n\t\treturn false\n\t}\n\n\tprotected resolveFilenameWithFallback(\n\t\tdirOrFile: string,\n\t\tfallbackFileName: string\n\t) {\n\t\tconst isDir =\n\t\t\tdiskUtil.doesDirExist(dirOrFile) &&\n\t\t\tfs.lstatSync(dirOrFile).isDirectory() &&\n\t\t\tpathUtil.extname(dirOrFile).length === 0\n\t\treturn isDir ? diskUtil.resolvePath(dirOrFile, fallbackFileName) : dirOrFile\n\t}\n}\n"],"file":"AbstractWriter.js"}
package/package.json CHANGED
@@ -18,7 +18,7 @@
18
18
  ]
19
19
  },
20
20
  "license": "MIT",
21
- "version": "14.28.6",
21
+ "version": "14.29.1",
22
22
  "bin": {
23
23
  "spruce": "./build/index.js"
24
24
  },
@@ -76,25 +76,27 @@
76
76
  "@babel/plugin-proposal-decorators": "^7.16.4",
77
77
  "@babel/runtime": "^7.16.3",
78
78
  "@jest/reporters": "^27.4.2",
79
- "@sprucelabs/error": "^5.0.313",
80
- "@sprucelabs/heartwood-view-controllers": "^51.6.23",
81
- "@sprucelabs/jest-json-reporter": "^6.0.262",
82
- "@sprucelabs/mercury-client": "^17.4.13",
83
- "@sprucelabs/mercury-event-emitter": "^17.4.13",
84
- "@sprucelabs/mercury-types": "^26.1.973",
85
- "@sprucelabs/schema": "^25.4.58",
86
- "@sprucelabs/spruce-core-schemas": "^22.6.236",
87
- "@sprucelabs/spruce-event-plugin": "^17.0.2",
88
- "@sprucelabs/spruce-event-utils": "^17.1.249",
89
- "@sprucelabs/spruce-skill-booter": "^17.0.2",
90
- "@sprucelabs/spruce-skill-utils": "^22.1.40",
91
- "@sprucelabs/spruce-templates": "^14.28.6",
79
+ "@sprucelabs/error": "^5.0.317",
80
+ "@sprucelabs/heartwood-view-controllers": "^51.6.51",
81
+ "@sprucelabs/jest-json-reporter": "^6.0.265",
82
+ "@sprucelabs/mercury-client": "^17.4.29",
83
+ "@sprucelabs/mercury-event-emitter": "^17.4.29",
84
+ "@sprucelabs/mercury-types": "^26.1.992",
85
+ "@sprucelabs/schema": "^25.4.67",
86
+ "@sprucelabs/spruce-core-schemas": "^22.6.250",
87
+ "@sprucelabs/spruce-event-plugin": "^18.1.0",
88
+ "@sprucelabs/spruce-event-utils": "^17.1.272",
89
+ "@sprucelabs/spruce-skill-booter": "^18.1.0",
90
+ "@sprucelabs/spruce-skill-utils": "^22.1.50",
91
+ "@sprucelabs/spruce-templates": "^14.29.1",
92
+ "@typescript-eslint/eslint-plugin": "^5.6.0",
93
+ "@typescript-eslint/parser": "^5.6.0",
92
94
  "cfonts": "^2.10.0",
93
95
  "chalk": "^4.1.2",
94
96
  "chokidar": "^3.5.2",
95
97
  "cli-table3": "^0.6.0",
96
98
  "commander": "^7.2.0",
97
- "core-js": "^3.19.2",
99
+ "core-js": "^3.19.3",
98
100
  "emphasize": "^4.2.0",
99
101
  "fs-extra": "^10.0.0",
100
102
  "gifwrap": "SimenB/gifwrap#patch-1",
@@ -117,16 +119,16 @@
117
119
  "uuid": "^8.3.2"
118
120
  },
119
121
  "devDependencies": {
120
- "@sprucelabs/data-stores": "^7.1.46",
121
- "@sprucelabs/jest-sheets-reporter": "^1.2.267",
122
- "@sprucelabs/mercury-core-events": "^1.6.188",
123
- "@sprucelabs/resolve-path-aliases": "^1.0.235",
124
- "@sprucelabs/spruce-conversation-plugin": "^17.0.2",
125
- "@sprucelabs/spruce-deploy-plugin": "^17.0.2",
126
- "@sprucelabs/spruce-store-plugin": "^17.0.2",
127
- "@sprucelabs/spruce-test-fixtures": "^17.0.2",
128
- "@sprucelabs/test": "^7.7.245",
129
- "@sprucelabs/test-utils": "^3.0.296",
122
+ "@sprucelabs/data-stores": "^7.2.0",
123
+ "@sprucelabs/jest-sheets-reporter": "^1.2.268",
124
+ "@sprucelabs/mercury-core-events": "^1.6.215",
125
+ "@sprucelabs/resolve-path-aliases": "^1.0.236",
126
+ "@sprucelabs/spruce-conversation-plugin": "^18.1.0",
127
+ "@sprucelabs/spruce-deploy-plugin": "^18.1.0",
128
+ "@sprucelabs/spruce-store-plugin": "^18.1.0",
129
+ "@sprucelabs/spruce-test-fixtures": "^18.1.0",
130
+ "@sprucelabs/test": "^7.7.248",
131
+ "@sprucelabs/test-utils": "^3.0.301",
130
132
  "@types/blessed": "^0.1.19",
131
133
  "@types/eslint": "^8.2.1",
132
134
  "@types/fs-extra": "^9.0.13",
@@ -157,10 +159,10 @@
157
159
  "jest-circus": "^27.4.2",
158
160
  "jest-junit": "^13.0.0",
159
161
  "jest-reporters": "^0.0.2",
160
- "prettier": "^2.5.0",
162
+ "prettier": "^2.5.1",
161
163
  "ps-node": "^0.1.6",
162
164
  "rimraf": "^3.0.2",
163
- "ts-jest": "^27.0.7",
165
+ "ts-jest": "^27.1.0",
164
166
  "ts-node": "^10.4.0",
165
167
  "tsc-watch": "^4.5.0",
166
168
  "tsconfig-paths": "^3.12.0",
@@ -595,5 +597,5 @@
595
597
  "ora"
596
598
  ]
597
599
  },
598
- "gitHead": "3f4f8dba43a7588da686e8253b4a90b487debe28"
600
+ "gitHead": "579a55e27144f666c196327802e452e74abee424"
599
601
  }
@@ -1,6 +1,7 @@
1
1
  import { diskUtil, namesUtil } from '@sprucelabs/spruce-skill-utils'
2
2
  import { test, assert } from '@sprucelabs/test'
3
3
  import { errorAssertUtil } from '@sprucelabs/test-utils'
4
+ import LintService from '../../services/LintService'
4
5
  import AbstractSkillTest from '../../tests/AbstractSkillTest'
5
6
  import testUtil from '../../tests/utilities/test.utility'
6
7
 
@@ -48,6 +49,7 @@ export default class SettingLogTransportsInASkillTest extends AbstractSkillTest
48
49
 
49
50
  @test()
50
51
  protected static async logsWriteToTransports() {
52
+ LintService.enableLinting()
51
53
  const transportContents = `
52
54
  import { diskUtil, Level, LogTransport } from '@sprucelabs/spruce-skill-utils'
53
55
 
@@ -8,7 +8,7 @@ export default class SyncingEventsOnlyFromDependenciesTest extends AbstractSkill
8
8
  protected static skillCacheKey = 'events'
9
9
 
10
10
  @test()
11
- protected static async doesntSyncAnythingToStart() {
11
+ protected static async doesntSyncAnythingButListenersToStart() {
12
12
  const skills = this.getSkillFixture()
13
13
  await skills.registerCurrentSkill({
14
14
  name: 'events in sync skill',
@@ -22,9 +22,11 @@ export default class SyncingEventsOnlyFromDependenciesTest extends AbstractSkill
22
22
 
23
23
  assert.isFalse(diskUtil.doesDirExist(eventFolder))
24
24
 
25
- const contents = fsUtil.readdirSync(this.resolveHashSprucePath('events'))
25
+ const files = fsUtil.readdirSync(this.resolveHashSprucePath('events'))
26
26
 
27
- assert.isLength(contents, 1)
27
+ assert.isLength(files, 2, 'The wrong number of files were generated.')
28
+ assert.isEqual(files[0], 'events.contract.ts')
29
+ assert.isEqual(files[1], 'listeners.ts')
28
30
  }
29
31
 
30
32
  @test()
@@ -43,9 +45,12 @@ export default class SyncingEventsOnlyFromDependenciesTest extends AbstractSkill
43
45
 
44
46
  assert.isTrue(diskUtil.doesDirExist(eventFolder))
45
47
 
46
- const contents = fsUtil.readdirSync(this.resolveHashSprucePath('events'))
48
+ const files = fsUtil.readdirSync(this.resolveHashSprucePath('events'))
47
49
 
48
- assert.isLength(contents, 2)
50
+ assert.isLength(files, 3, 'The wrong number of files were generated.')
51
+ assert.isEqual(files[0], namesUtil.toCamel(skill.slug))
52
+ assert.isEqual(files[1], 'events.contract.ts')
53
+ assert.isEqual(files[2], 'listeners.ts')
49
54
  }
50
55
 
51
56
  private static async registerGlobalEvent() {