@sprucelabs/spruce-cli 19.1.42 → 19.2.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 (47) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/build/.spruce/errors/errors.types.d.ts +19 -0
  3. package/build/.spruce/errors/errors.types.js.map +1 -1
  4. package/build/.spruce/errors/options.types.d.ts +4 -1
  5. package/build/.spruce/errors/options.types.js.map +1 -1
  6. package/build/.spruce/errors/spruceCli/viewPluginAlreadyExists.schema.d.ts +3 -0
  7. package/build/.spruce/errors/spruceCli/viewPluginAlreadyExists.schema.js +23 -0
  8. package/build/.spruce/errors/spruceCli/viewPluginAlreadyExists.schema.js.map +1 -0
  9. package/build/__tests__/behavioral/views/CreatingASkillView.test.d.ts +1 -1
  10. package/build/__tests__/behavioral/views/CreatingASkillView.test.js +6 -6
  11. package/build/__tests__/behavioral/views/CreatingASkillView.test.js.map +1 -1
  12. package/build/__tests__/behavioral/views/KeepingViewsInSync.test.d.ts +1 -1
  13. package/build/__tests__/behavioral/views/KeepingViewsInSync.test.js +6 -6
  14. package/build/__tests__/behavioral/views/KeepingViewsInSync.test.js.map +1 -1
  15. package/build/__tests__/behavioral/views/plugins/CreatingAViewPlugin.test.d.ts +23 -0
  16. package/build/__tests__/behavioral/views/plugins/CreatingAViewPlugin.test.js +355 -0
  17. package/build/__tests__/behavioral/views/plugins/CreatingAViewPlugin.test.js.map +1 -0
  18. package/build/errors/SpruceError.js +3 -0
  19. package/build/errors/SpruceError.js.map +1 -1
  20. package/build/errors/viewPluginAlreadyExists.builder.d.ts +11 -0
  21. package/build/errors/viewPluginAlreadyExists.builder.js +18 -0
  22. package/build/errors/viewPluginAlreadyExists.builder.js.map +1 -0
  23. package/build/features/view/actions/CreateAction.d.ts +6 -6
  24. package/build/features/view/actions/CreateAction.js +59 -59
  25. package/build/features/view/actions/CreateAction.js.map +1 -1
  26. package/build/features/view/actions/CreatePluginAction.d.ts +56 -0
  27. package/build/features/view/actions/CreatePluginAction.js +95 -0
  28. package/build/features/view/actions/CreatePluginAction.js.map +1 -0
  29. package/build/features/view/actions/SyncAction.d.ts +6 -6
  30. package/build/features/view/actions/SyncAction.js +29 -15
  31. package/build/features/view/actions/SyncAction.js.map +1 -1
  32. package/build/features/view/writers/ViewWriter.d.ts +5 -0
  33. package/build/features/view/writers/ViewWriter.js +44 -7
  34. package/build/features/view/writers/ViewWriter.js.map +1 -1
  35. package/package.json +25 -25
  36. package/src/.spruce/errors/errors.types.ts +29 -0
  37. package/src/.spruce/errors/options.types.ts +4 -1
  38. package/src/.spruce/errors/spruceCli/viewPluginAlreadyExists.schema.ts +22 -0
  39. package/src/__tests__/behavioral/views/CreatingASkillView.test.ts +1 -1
  40. package/src/__tests__/behavioral/views/KeepingViewsInSync.test.ts +1 -1
  41. package/src/__tests__/behavioral/views/plugins/CreatingAViewPlugin.test.ts +161 -0
  42. package/src/errors/SpruceError.ts +4 -0
  43. package/src/errors/viewPluginAlreadyExists.builder.ts +12 -0
  44. package/src/features/view/actions/CreateAction.ts +72 -72
  45. package/src/features/view/actions/CreatePluginAction.ts +54 -0
  46. package/src/features/view/actions/SyncAction.ts +30 -14
  47. package/src/features/view/writers/ViewWriter.ts +45 -5
@@ -17,7 +17,7 @@ var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits
17
17
  var _spruceSkillUtils = require("@sprucelabs/spruce-skill-utils");
18
18
  var _SpruceError = _interopRequireDefault(require("../../../errors/SpruceError"));
19
19
  var _AbstractWriter2 = _interopRequireDefault(require("../../../writers/AbstractWriter"));
20
- var _excluded = ["vcTemplateItems", "svcTemplateItems"];
20
+ var _excluded = ["vcTemplateItems", "svcTemplateItems", "viewPluginItems"];
21
21
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
22
22
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2["default"])(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
23
23
  function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2["default"])(o), (0, _possibleConstructorReturn2["default"])(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2["default"])(t).constructor) : o.apply(t, e)); }
@@ -41,25 +41,27 @@ var ViewWriter = exports["default"] = /*#__PURE__*/function (_AbstractWriter) {
41
41
  key: "writeCombinedViewsFile",
42
42
  value: function () {
43
43
  var _writeCombinedViewsFile = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(cwd, options) {
44
- var vcTemplateItems, svcTemplateItems, rest, destinationDir, destination, contents, results;
44
+ var vcTemplateItems, svcTemplateItems, viewPluginItems, rest, destinationDir, destination, contents, results;
45
45
  return _regenerator["default"].wrap(function _callee$(_context) {
46
46
  while (1) switch (_context.prev = _context.next) {
47
47
  case 0:
48
- vcTemplateItems = options.vcTemplateItems, svcTemplateItems = options.svcTemplateItems, rest = (0, _objectWithoutProperties2["default"])(options, _excluded);
48
+ vcTemplateItems = options.vcTemplateItems, svcTemplateItems = options.svcTemplateItems, viewPluginItems = options.viewPluginItems, rest = (0, _objectWithoutProperties2["default"])(options, _excluded);
49
49
  destinationDir = _spruceSkillUtils.diskUtil.resolveHashSprucePath(cwd, 'views');
50
50
  destination = _spruceSkillUtils.diskUtil.resolvePath(destinationDir, 'views.ts');
51
51
  vcTemplateItems = this.removeFileExtensionsFromTemplateItems(vcTemplateItems, destinationDir);
52
52
  svcTemplateItems = this.removeFileExtensionsFromTemplateItems(svcTemplateItems, destinationDir);
53
+ viewPluginItems = this.removeFileExtensionsFromTemplateItems(viewPluginItems, destinationDir);
53
54
  contents = this.templates.views(_objectSpread({
54
55
  vcTemplateItems: vcTemplateItems,
55
- svcTemplateItems: svcTemplateItems
56
+ svcTemplateItems: svcTemplateItems,
57
+ viewPluginItems: viewPluginItems
56
58
  }, rest));
57
- _context.next = 8;
59
+ _context.next = 9;
58
60
  return this.writeFileIfChangedMixinResults(destination, contents, 'Used to export your controllers to Heartwood.');
59
- case 8:
61
+ case 9:
60
62
  results = _context.sent;
61
63
  return _context.abrupt("return", results);
62
- case 10:
64
+ case 11:
63
65
  case "end":
64
66
  return _context.stop();
65
67
  }
@@ -135,6 +137,41 @@ var ViewWriter = exports["default"] = /*#__PURE__*/function (_AbstractWriter) {
135
137
  path = _this$buildViewContro3.path;
136
138
  return _spruceSkillUtils.diskUtil.doesFileExist(path);
137
139
  }
140
+ }, {
141
+ key: "writeViewControllerPlugin",
142
+ value: function () {
143
+ var _writeViewControllerPlugin = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3(options) {
144
+ var nameCamel, namePascal, cwd, destination, contents;
145
+ return _regenerator["default"].wrap(function _callee3$(_context3) {
146
+ while (1) switch (_context3.prev = _context3.next) {
147
+ case 0:
148
+ nameCamel = options.nameCamel, namePascal = options.namePascal, cwd = options.cwd;
149
+ destination = _spruceSkillUtils.diskUtil.resolvePath(cwd, 'src', 'viewPlugins', "".concat(nameCamel, ".view.plugin.ts"));
150
+ contents = this.templates.viewControllerPlugin({
151
+ nameCamel: nameCamel,
152
+ namePascal: namePascal
153
+ });
154
+ if (!_spruceSkillUtils.diskUtil.doesFileExist(destination)) {
155
+ _context3.next = 5;
156
+ break;
157
+ }
158
+ throw new _SpruceError["default"]({
159
+ code: 'VIEW_PLUGIN_ALREADY_EXISTS',
160
+ name: nameCamel
161
+ });
162
+ case 5:
163
+ return _context3.abrupt("return", this.writeFileIfChangedMixinResults(destination, contents, "Your new view plugin!"));
164
+ case 6:
165
+ case "end":
166
+ return _context3.stop();
167
+ }
168
+ }, _callee3, this);
169
+ }));
170
+ function writeViewControllerPlugin(_x5) {
171
+ return _writeViewControllerPlugin.apply(this, arguments);
172
+ }
173
+ return writeViewControllerPlugin;
174
+ }()
138
175
  }, {
139
176
  key: "writePlugin",
140
177
  value: function writePlugin(cwd) {
@@ -1 +1 @@
1
- {"version":3,"file":"ViewWriter.js","names":["_spruceSkillUtils","require","_SpruceError","_interopRequireDefault","_AbstractWriter2","_excluded","ownKeys","e","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty2","getOwnPropertyDescriptors","defineProperties","defineProperty","_callSuper","_getPrototypeOf2","_possibleConstructorReturn2","_isNativeReflectConstruct","Reflect","construct","constructor","Boolean","prototype","valueOf","call","ViewWriter","exports","_AbstractWriter","_inherits2","_classCallCheck2","_createClass2","key","value","writeSkillViewController","cwd","options","_this$buildViewContro","buildViewControllerPath","namePascal","path","writeController","viewType","_writeCombinedViewsFile","_asyncToGenerator2","_regenerator","mark","_callee","vcTemplateItems","svcTemplateItems","rest","destinationDir","destination","contents","results","wrap","_callee$","_context","prev","next","_objectWithoutProperties2","diskUtil","resolveHashSprucePath","resolvePath","removeFileExtensionsFromTemplateItems","templates","views","writeFileIfChangedMixinResults","sent","abrupt","stop","writeCombinedViewsFile","_x","_x2","map","i","resolveRelativePath","replace","writeViewController","_this$buildViewContro2","_writeController","_callee2","viewModel","nameKebab","_callee2$","_context2","doesFileExist","SpruceError","code","name","skillViewController","viewController","lint","_x3","_x4","doesRootControllerExist","_this$buildViewContro3","writePlugin","pluginContents","viewPlugin","writeTheme","buildThemePath","theme","doesThemeFileExist","ext","filename","AbstractWriter"],"sources":["../../../../src/features/view/writers/ViewWriter.ts"],"sourcesContent":["import { diskUtil } from '@sprucelabs/spruce-skill-utils'\nimport {\n\tVcTemplateItem,\n\tViewsOptions,\n} from '../../../../../spruce-templates/build'\nimport SpruceError from '../../../errors/SpruceError'\nimport AbstractWriter from '../../../writers/AbstractWriter'\n\nexport default class ViewWriter extends AbstractWriter {\n\tpublic writeSkillViewController(\n\t\tcwd: string,\n\t\toptions: {\n\t\t\tnamePascal: string\n\t\t\tnameKebab: string\n\t\t}\n\t) {\n\t\tconst { path } = this.buildViewControllerPath(\n\t\t\tcwd,\n\t\t\t'skillView',\n\t\t\toptions.namePascal\n\t\t)\n\n\t\treturn this.writeController(path, { ...options, viewType: 'skillView' })\n\t}\n\n\tpublic async writeCombinedViewsFile(cwd: string, options: ViewsOptions) {\n\t\tlet { vcTemplateItems, svcTemplateItems, ...rest } = options\n\n\t\tconst destinationDir = diskUtil.resolveHashSprucePath(cwd, 'views')\n\t\tconst destination = diskUtil.resolvePath(destinationDir, 'views.ts')\n\n\t\tvcTemplateItems = this.removeFileExtensionsFromTemplateItems(\n\t\t\tvcTemplateItems,\n\t\t\tdestinationDir\n\t\t)\n\n\t\tsvcTemplateItems = this.removeFileExtensionsFromTemplateItems(\n\t\t\tsvcTemplateItems,\n\t\t\tdestinationDir\n\t\t)\n\n\t\tconst contents = this.templates.views({\n\t\t\tvcTemplateItems,\n\t\t\tsvcTemplateItems,\n\t\t\t...rest,\n\t\t})\n\n\t\tconst results = await this.writeFileIfChangedMixinResults(\n\t\t\tdestination,\n\t\t\tcontents,\n\t\t\t'Used to export your controllers to Heartwood.'\n\t\t)\n\n\t\treturn results\n\t}\n\n\tprivate removeFileExtensionsFromTemplateItems(\n\t\tvcTemplateItems: VcTemplateItem[],\n\t\tdestinationDir: string\n\t): VcTemplateItem[] {\n\t\treturn vcTemplateItems.map((i) => ({\n\t\t\t...i,\n\t\t\tpath: diskUtil\n\t\t\t\t.resolveRelativePath(destinationDir, i.path)\n\t\t\t\t.replace('.ts', ''),\n\t\t}))\n\t}\n\n\tpublic writeViewController(\n\t\tcwd: string,\n\t\toptions: {\n\t\t\tviewType: string\n\t\t\tnamePascal: string\n\t\t\tviewModel: string\n\t\t\tnameKebab: string\n\t\t}\n\t) {\n\t\tconst { path } = this.buildViewControllerPath(\n\t\t\tcwd,\n\t\t\t'view',\n\t\t\toptions.namePascal\n\t\t)\n\n\t\treturn this.writeController(path, options)\n\t}\n\n\tprivate async writeController(path: string, options: any) {\n\t\tconst { namePascal, viewModel, viewType, nameKebab } = options\n\n\t\tif (diskUtil.doesFileExist(path)) {\n\t\t\tthrow new SpruceError({\n\t\t\t\tcode: 'SKILL_VIEW_EXISTS',\n\t\t\t\tname: namePascal,\n\t\t\t})\n\t\t}\n\n\t\tconst contents =\n\t\t\tviewType === 'skillView'\n\t\t\t\t? this.templates.skillViewController({ namePascal, nameKebab })\n\t\t\t\t: this.templates.viewController({ namePascal, viewModel, nameKebab })\n\n\t\tconst results = this.writeFileIfChangedMixinResults(path, contents, 'Test')\n\n\t\tawait this.lint(path)\n\n\t\treturn results\n\t}\n\n\tpublic doesRootControllerExist(cwd: string) {\n\t\tconst { path } = this.buildViewControllerPath(cwd, 'skillView', 'Root')\n\t\treturn diskUtil.doesFileExist(path)\n\t}\n\n\tpublic writePlugin(cwd: string) {\n\t\tconst destination = diskUtil.resolveHashSprucePath(\n\t\t\tcwd,\n\t\t\t'features',\n\t\t\t'view.plugin.ts'\n\t\t)\n\n\t\tconst pluginContents = this.templates.viewPlugin()\n\n\t\tconst results = this.writeFileIfChangedMixinResults(\n\t\t\tdestination,\n\t\t\tpluginContents,\n\t\t\t'Supports your skill with rendering views.'\n\t\t)\n\n\t\treturn results\n\t}\n\n\tpublic writeTheme(cwd: string) {\n\t\tconst destination = this.buildThemePath(cwd)\n\n\t\tconst contents = this.templates.theme()\n\n\t\tconst results = this.writeFileIfChangedMixinResults(\n\t\t\tdestination,\n\t\t\tcontents,\n\t\t\t'Your brand new theme file!'\n\t\t)\n\n\t\treturn results\n\t}\n\n\tprivate buildThemePath(cwd: string) {\n\t\treturn diskUtil.resolvePath(cwd, 'src', 'themes', 'skill.theme.ts')\n\t}\n\n\tpublic doesThemeFileExist(cwd: string) {\n\t\tconst destination = this.buildThemePath(cwd)\n\t\treturn diskUtil.doesFileExist(destination)\n\t}\n\n\tprivate buildViewControllerPath(\n\t\tcwd: string,\n\t\tviewType: 'skillView' | 'view',\n\t\tnamePascal: string\n\t) {\n\t\tconst ext = viewType === 'skillView' ? '.svc.ts' : '.vc.ts'\n\t\tconst filename = namePascal + ext\n\t\tconst path = diskUtil.resolvePath(\n\t\t\tcwd,\n\t\t\t'src',\n\t\t\tviewType + 'Controllers',\n\t\t\tfilename\n\t\t)\n\t\treturn { path, filename }\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAAA,IAAAA,iBAAA,GAAAC,OAAA;AAKA,IAAAC,YAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,gBAAA,GAAAD,sBAAA,CAAAF,OAAA;AAA4D,IAAAI,SAAA;AAAA,SAAAC,QAAAC,CAAA,EAAAC,CAAA,QAAAC,CAAA,GAAAC,MAAA,CAAAC,IAAA,CAAAJ,CAAA,OAAAG,MAAA,CAAAE,qBAAA,QAAAC,CAAA,GAAAH,MAAA,CAAAE,qBAAA,CAAAL,CAAA,GAAAC,CAAA,KAAAK,CAAA,GAAAA,CAAA,CAAAC,MAAA,WAAAN,CAAA,WAAAE,MAAA,CAAAK,wBAAA,CAAAR,CAAA,EAAAC,CAAA,EAAAQ,UAAA,OAAAP,CAAA,CAAAQ,IAAA,CAAAC,KAAA,CAAAT,CAAA,EAAAI,CAAA,YAAAJ,CAAA;AAAA,SAAAU,cAAAZ,CAAA,aAAAC,CAAA,MAAAA,CAAA,GAAAY,SAAA,CAAAC,MAAA,EAAAb,CAAA,UAAAC,CAAA,WAAAW,SAAA,CAAAZ,CAAA,IAAAY,SAAA,CAAAZ,CAAA,QAAAA,CAAA,OAAAF,OAAA,CAAAI,MAAA,CAAAD,CAAA,OAAAa,OAAA,WAAAd,CAAA,QAAAe,gBAAA,aAAAhB,CAAA,EAAAC,CAAA,EAAAC,CAA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AAAC,KAAA,EAED,SAAAK,wBACCH,GAAW,EACXO,QAA8B,EAC9BH,UAAkB,EACjB;MACD,IAAMiE,GAAG,GAAG9D,QAAQ,KAAK,WAAW,GAAG,SAAS,GAAG,QAAQ;MAC3D,IAAM+D,QAAQ,GAAGlE,UAAU,GAAGiE,GAAG;MACjC,IAAMhE,IAAI,GAAGqB,0BAAQ,CAACE,WAAW,CAChC5B,GAAG,EACH,KAAK,EACLO,QAAQ,GAAG,aAAa,EACxB+D,QACD,CAAC;MACD,OAAO;QAAEjE,IAAI,EAAJA,IAAI;QAAEiE,QAAQ,EAARA;MAAS,CAAC;IAC1B;EAAC;EAAA,OAAA/E,UAAA;AAAA,EAhKsCgF,2BAAc","ignoreList":[]}
1
+ {"version":3,"file":"ViewWriter.js","names":["_spruceSkillUtils","require","_SpruceError","_interopRequireDefault","_AbstractWriter2","_excluded","ownKeys","e","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty2","getOwnPropertyDescriptors","defineProperties","defineProperty","_callSuper","_getPrototypeOf2","_possibleConstructorReturn2","_isNativeReflectConstruct","Reflect","construct","constructor","Boolean","prototype","valueOf","call","ViewWriter","exports","_AbstractWriter","_inherits2","_classCallCheck2","_createClass2","key","value","writeSkillViewController","cwd","options","_this$buildViewContro","buildViewControllerPath","namePascal","path","writeController","viewType","_writeCombinedViewsFile","_asyncToGenerator2","_regenerator","mark","_callee","vcTemplateItems","svcTemplateItems","viewPluginItems","rest","destinationDir","destination","contents","results","wrap","_callee$","_context","prev","next","_objectWithoutProperties2","diskUtil","resolveHashSprucePath","resolvePath","removeFileExtensionsFromTemplateItems","templates","views","writeFileIfChangedMixinResults","sent","abrupt","stop","writeCombinedViewsFile","_x","_x2","map","i","resolveRelativePath","replace","writeViewController","_this$buildViewContro2","_writeController","_callee2","viewModel","nameKebab","_callee2$","_context2","doesFileExist","SpruceError","code","name","skillViewController","viewController","lint","_x3","_x4","doesRootControllerExist","_this$buildViewContro3","_writeViewControllerPlugin","_callee3","nameCamel","_callee3$","_context3","concat","viewControllerPlugin","writeViewControllerPlugin","_x5","writePlugin","pluginContents","viewPlugin","writeTheme","buildThemePath","theme","doesThemeFileExist","ext","filename","AbstractWriter"],"sources":["../../../../src/features/view/writers/ViewWriter.ts"],"sourcesContent":["import { diskUtil } from '@sprucelabs/spruce-skill-utils'\nimport {\n\tVcTemplateItem,\n\tViewControllerPluginItem,\n\tViewsOptions,\n} from '../../../../../spruce-templates/build'\nimport SpruceError from '../../../errors/SpruceError'\nimport AbstractWriter from '../../../writers/AbstractWriter'\n\nexport default class ViewWriter extends AbstractWriter {\n\tpublic writeSkillViewController(\n\t\tcwd: string,\n\t\toptions: {\n\t\t\tnamePascal: string\n\t\t\tnameKebab: string\n\t\t}\n\t) {\n\t\tconst { path } = this.buildViewControllerPath(\n\t\t\tcwd,\n\t\t\t'skillView',\n\t\t\toptions.namePascal\n\t\t)\n\n\t\treturn this.writeController(path, { ...options, viewType: 'skillView' })\n\t}\n\n\tpublic async writeCombinedViewsFile(cwd: string, options: ViewsOptions) {\n\t\tlet { vcTemplateItems, svcTemplateItems, viewPluginItems, ...rest } =\n\t\t\toptions\n\n\t\tconst destinationDir = diskUtil.resolveHashSprucePath(cwd, 'views')\n\t\tconst destination = diskUtil.resolvePath(destinationDir, 'views.ts')\n\n\t\tvcTemplateItems = this.removeFileExtensionsFromTemplateItems(\n\t\t\tvcTemplateItems,\n\t\t\tdestinationDir\n\t\t)\n\n\t\tsvcTemplateItems = this.removeFileExtensionsFromTemplateItems(\n\t\t\tsvcTemplateItems,\n\t\t\tdestinationDir\n\t\t)\n\n\t\tviewPluginItems = this.removeFileExtensionsFromTemplateItems(\n\t\t\tviewPluginItems,\n\t\t\tdestinationDir\n\t\t)\n\n\t\tconst contents = this.templates.views({\n\t\t\tvcTemplateItems,\n\t\t\tsvcTemplateItems,\n\t\t\tviewPluginItems,\n\t\t\t...rest,\n\t\t})\n\n\t\tconst results = await this.writeFileIfChangedMixinResults(\n\t\t\tdestination,\n\t\t\tcontents,\n\t\t\t'Used to export your controllers to Heartwood.'\n\t\t)\n\n\t\treturn results\n\t}\n\n\tprivate removeFileExtensionsFromTemplateItems<\n\t\tT extends VcTemplateItem | ViewControllerPluginItem,\n\t>(vcTemplateItems: T[], destinationDir: string): T[] {\n\t\treturn vcTemplateItems.map((i) => ({\n\t\t\t...i,\n\t\t\tpath: diskUtil\n\t\t\t\t.resolveRelativePath(destinationDir, i.path)\n\t\t\t\t.replace('.ts', ''),\n\t\t}))\n\t}\n\n\tpublic writeViewController(\n\t\tcwd: string,\n\t\toptions: {\n\t\t\tviewType: string\n\t\t\tnamePascal: string\n\t\t\tviewModel: string\n\t\t\tnameKebab: string\n\t\t}\n\t) {\n\t\tconst { path } = this.buildViewControllerPath(\n\t\t\tcwd,\n\t\t\t'view',\n\t\t\toptions.namePascal\n\t\t)\n\n\t\treturn this.writeController(path, options)\n\t}\n\n\tprivate async writeController(path: string, options: any) {\n\t\tconst { namePascal, viewModel, viewType, nameKebab } = options\n\n\t\tif (diskUtil.doesFileExist(path)) {\n\t\t\tthrow new SpruceError({\n\t\t\t\tcode: 'SKILL_VIEW_EXISTS',\n\t\t\t\tname: namePascal,\n\t\t\t})\n\t\t}\n\n\t\tconst contents =\n\t\t\tviewType === 'skillView'\n\t\t\t\t? this.templates.skillViewController({ namePascal, nameKebab })\n\t\t\t\t: this.templates.viewController({ namePascal, viewModel, nameKebab })\n\n\t\tconst results = this.writeFileIfChangedMixinResults(path, contents, 'Test')\n\n\t\tawait this.lint(path)\n\n\t\treturn results\n\t}\n\n\tpublic doesRootControllerExist(cwd: string) {\n\t\tconst { path } = this.buildViewControllerPath(cwd, 'skillView', 'Root')\n\t\treturn diskUtil.doesFileExist(path)\n\t}\n\n\tpublic async writeViewControllerPlugin(options: {\n\t\tcwd: string\n\t\tnameCamel: string\n\t\tnamePascal: string\n\t}) {\n\t\tconst { nameCamel, namePascal, cwd } = options\n\n\t\tconst destination = diskUtil.resolvePath(\n\t\t\tcwd,\n\t\t\t'src',\n\t\t\t'viewPlugins',\n\t\t\t`${nameCamel}.view.plugin.ts`\n\t\t)\n\n\t\tconst contents = this.templates.viewControllerPlugin({\n\t\t\tnameCamel,\n\t\t\tnamePascal,\n\t\t})\n\n\t\tif (diskUtil.doesFileExist(destination)) {\n\t\t\tthrow new SpruceError({\n\t\t\t\tcode: 'VIEW_PLUGIN_ALREADY_EXISTS',\n\t\t\t\tname: nameCamel,\n\t\t\t})\n\t\t}\n\n\t\treturn this.writeFileIfChangedMixinResults(\n\t\t\tdestination,\n\t\t\tcontents,\n\t\t\t`Your new view plugin!`\n\t\t)\n\t}\n\n\tpublic writePlugin(cwd: string) {\n\t\tconst destination = diskUtil.resolveHashSprucePath(\n\t\t\tcwd,\n\t\t\t'features',\n\t\t\t'view.plugin.ts'\n\t\t)\n\n\t\tconst pluginContents = this.templates.viewPlugin()\n\n\t\tconst results = this.writeFileIfChangedMixinResults(\n\t\t\tdestination,\n\t\t\tpluginContents,\n\t\t\t'Supports your skill with rendering views.'\n\t\t)\n\n\t\treturn results\n\t}\n\n\tpublic writeTheme(cwd: string) {\n\t\tconst destination = this.buildThemePath(cwd)\n\n\t\tconst contents = this.templates.theme()\n\n\t\tconst results = this.writeFileIfChangedMixinResults(\n\t\t\tdestination,\n\t\t\tcontents,\n\t\t\t'Your brand new theme file!'\n\t\t)\n\n\t\treturn results\n\t}\n\n\tprivate buildThemePath(cwd: string) {\n\t\treturn diskUtil.resolvePath(cwd, 'src', 'themes', 'skill.theme.ts')\n\t}\n\n\tpublic doesThemeFileExist(cwd: string) {\n\t\tconst destination = this.buildThemePath(cwd)\n\t\treturn diskUtil.doesFileExist(destination)\n\t}\n\n\tprivate buildViewControllerPath(\n\t\tcwd: string,\n\t\tviewType: 'skillView' | 'view',\n\t\tnamePascal: string\n\t) {\n\t\tconst ext = viewType === 'skillView' ? '.svc.ts' : '.vc.ts'\n\t\tconst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GxE,QAAQ,KAAK,WAAW,GAAG,SAAS,GAAG,QAAQ;MAC3D,IAAMyE,QAAQ,GAAG5E,UAAU,GAAG2E,GAAG;MACjC,IAAM1E,IAAI,GAAGsB,0BAAQ,CAACE,WAAW,CAChC7B,GAAG,EACH,KAAK,EACLO,QAAQ,GAAG,aAAa,EACxByE,QACD,CAAC;MACD,OAAO;QAAE3E,IAAI,EAAJA,IAAI;QAAE2E,QAAQ,EAARA;MAAS,CAAC;IAC1B;EAAC;EAAA,OAAAzF,UAAA;AAAA,EAvMsC0F,2BAAc","ignoreList":[]}
package/package.json CHANGED
@@ -17,7 +17,7 @@
17
17
  ]
18
18
  },
19
19
  "license": "MIT",
20
- "version": "19.1.42",
20
+ "version": "19.2.1",
21
21
  "bin": {
22
22
  "spruce": "./build/index.js"
23
23
  },
@@ -75,18 +75,18 @@
75
75
  "@babel/plugin-proposal-decorators": "^7.24.0",
76
76
  "@babel/runtime": "^7.24.0",
77
77
  "@jest/reporters": "^29.7.0",
78
- "@sprucelabs/error": "^5.1.66",
79
- "@sprucelabs/globby": "^1.0.16",
80
- "@sprucelabs/heartwood-view-controllers": "^108.41.1",
81
- "@sprucelabs/jest-json-reporter": "^7.0.175",
82
- "@sprucelabs/mercury-client": "^41.0.321",
83
- "@sprucelabs/mercury-event-emitter": "^41.0.321",
84
- "@sprucelabs/mercury-types": "^46.0.246",
85
- "@sprucelabs/schema": "^29.4.12",
86
- "@sprucelabs/spruce-core-schemas": "^39.0.244",
87
- "@sprucelabs/spruce-event-utils": "^38.0.289",
88
- "@sprucelabs/spruce-skill-utils": "^30.3.3",
89
- "@sprucelabs/spruce-templates": "^19.1.42",
78
+ "@sprucelabs/error": "^5.1.76",
79
+ "@sprucelabs/globby": "^1.0.19",
80
+ "@sprucelabs/heartwood-view-controllers": "^109.0.23",
81
+ "@sprucelabs/jest-json-reporter": "^7.0.183",
82
+ "@sprucelabs/mercury-client": "^41.0.339",
83
+ "@sprucelabs/mercury-event-emitter": "^41.0.339",
84
+ "@sprucelabs/mercury-types": "^46.0.260",
85
+ "@sprucelabs/schema": "^29.4.23",
86
+ "@sprucelabs/spruce-core-schemas": "^39.0.257",
87
+ "@sprucelabs/spruce-event-utils": "^38.1.0",
88
+ "@sprucelabs/spruce-skill-utils": "^30.3.16",
89
+ "@sprucelabs/spruce-templates": "^19.2.1",
90
90
  "@typescript-eslint/eslint-plugin": "^5.27.1",
91
91
  "@typescript-eslint/parser": "^5.27.1",
92
92
  "cfonts": "^3.2.0",
@@ -113,23 +113,23 @@
113
113
  "uuid": "^9.0.1"
114
114
  },
115
115
  "devDependencies": {
116
- "@sprucelabs/data-stores": "^26.4.38",
116
+ "@sprucelabs/data-stores": "^26.4.50",
117
117
  "@sprucelabs/jest-sheets-reporter": "^3.0.26",
118
- "@sprucelabs/mercury-core-events": "^22.2.25",
119
- "@sprucelabs/resolve-path-aliases": "^1.1.284",
120
- "@sprucelabs/spruce-conversation-plugin": "^60.1.275",
121
- "@sprucelabs/spruce-deploy-plugin": "^60.1.275",
122
- "@sprucelabs/spruce-store-plugin": "^60.1.275",
123
- "@sprucelabs/spruce-test-fixtures": "^60.1.275",
124
- "@sprucelabs/test": "^8.0.42",
125
- "@sprucelabs/test-utils": "^4.0.110",
118
+ "@sprucelabs/mercury-core-events": "^22.2.42",
119
+ "@sprucelabs/resolve-path-aliases": "^1.1.288",
120
+ "@sprucelabs/spruce-conversation-plugin": "^60.1.293",
121
+ "@sprucelabs/spruce-deploy-plugin": "^60.1.293",
122
+ "@sprucelabs/spruce-store-plugin": "^60.1.293",
123
+ "@sprucelabs/spruce-test-fixtures": "^60.1.293",
124
+ "@sprucelabs/test": "^8.0.44",
125
+ "@sprucelabs/test-utils": "^4.0.122",
126
126
  "@types/blessed": "^0.1.25",
127
127
  "@types/eslint": "^8.56.5",
128
128
  "@types/fs-extra": "^11.0.4",
129
129
  "@types/inquirer": "^8.2.1",
130
- "@types/lodash": "^4.14.202",
130
+ "@types/lodash": "^4.17.0",
131
131
  "@types/md5": "^2.3.5",
132
- "@types/node": "^20.11.25",
132
+ "@types/node": "^20.11.28",
133
133
  "@types/promise.allsettled": "^1.0.6",
134
134
  "@types/ps-node": "^0.1.3",
135
135
  "@types/semver": "^7.5.8",
@@ -590,5 +590,5 @@
590
590
  "terminal-kit"
591
591
  ]
592
592
  },
593
- "gitHead": "6f9742070613d95d278021627afb5fe72cb7f8b6"
593
+ "gitHead": "5b9df671bf36f0d87aa7682bdffc9cb64f74042d"
594
594
  }
@@ -29,6 +29,35 @@ export declare namespace SpruceErrors.SpruceCli {
29
29
 
30
30
 
31
31
 
32
+ export declare namespace SpruceErrors.SpruceCli {
33
+
34
+
35
+ export interface ViewPluginAlreadyExists {
36
+
37
+
38
+ 'name': string
39
+ }
40
+
41
+ export interface ViewPluginAlreadyExistsSchema extends SpruceSchema.Schema {
42
+ id: 'viewPluginAlreadyExists',
43
+ namespace: 'SpruceCli',
44
+ name: 'View plugin already exists',
45
+ fields: {
46
+ /** . */
47
+ 'name': {
48
+ type: 'text',
49
+ isRequired: true,
50
+ options: undefined
51
+ },
52
+ }
53
+ }
54
+
55
+ export type ViewPluginAlreadyExistsEntity = SchemaEntity<SpruceErrors.SpruceCli.ViewPluginAlreadyExistsSchema>
56
+
57
+ }
58
+
59
+
60
+
32
61
  export declare namespace SpruceErrors.SpruceCli {
33
62
 
34
63
 
@@ -4,6 +4,9 @@ import { ErrorOptions as ISpruceErrorOptions} from "@sprucelabs/error"
4
4
  export interface VscodeNotInstalledErrorOptions extends SpruceErrors.SpruceCli.VscodeNotInstalled, ISpruceErrorOptions {
5
5
  code: 'VSCODE_NOT_INSTALLED'
6
6
  }
7
+ export interface ViewPluginAlreadyExistsErrorOptions extends SpruceErrors.SpruceCli.ViewPluginAlreadyExists, ISpruceErrorOptions {
8
+ code: 'VIEW_PLUGIN_ALREADY_EXISTS'
9
+ }
7
10
  export interface TransportAlreadyExistsErrorOptions extends SpruceErrors.SpruceCli.TransportAlreadyExists, ISpruceErrorOptions {
8
11
  code: 'TRANSPORT_ALREADY_EXISTS'
9
12
  }
@@ -122,6 +125,6 @@ export interface ActionCancelledErrorOptions extends SpruceErrors.SpruceCli.Acti
122
125
  code: 'ACTION_CANCELLED'
123
126
  }
124
127
 
125
- type ErrorOptions = | VscodeNotInstalledErrorOptions | TransportAlreadyExistsErrorOptions | ThemeExistsErrorOptions | TestFailedErrorOptions | StoreExistsErrorOptions | SkillViewExistsErrorOptions | SkillNotRegisteredErrorOptions | SkillNotFoundErrorOptions | SchemaTemplateItemBuildingFailedErrorOptions | SchemaFailedToImportErrorOptions | SchemaExistsErrorOptions | NotLoggedInErrorOptions | NotImplementedErrorOptions | NoSkillsRegisteredErrorOptions | NoOrganizationsFoundErrorOptions | MissingDependenciesErrorOptions | MercuryResponseErrorErrorOptions | LintFailedErrorOptions | InvalidTestDirectoryErrorOptions | InvalidFeatureCodeErrorOptions | InvalidEventContractErrorOptions | InvalidCommandErrorOptions | GenericErrorOptions | FileExistsErrorOptions | FeatureNotInstalledErrorOptions | FailedToImportErrorOptions | ExecutingCommandFailedErrorOptions | DockerNotStartedErrorOptions | DirectoryNotSkillErrorOptions | DirectoryEmptyErrorOptions | DeployFailedErrorOptions | DependencyExistsErrorOptions | CreateAutoloaderFailedErrorOptions | CommandNotImplementedErrorOptions | CommandBlockedErrorOptions | CommandAbortedErrorOptions | CacheNotEnabledErrorOptions | BuildFailedErrorOptions | BootErrorErrorOptions | ActionCancelledErrorOptions
128
+ type ErrorOptions = | VscodeNotInstalledErrorOptions | ViewPluginAlreadyExistsErrorOptions | TransportAlreadyExistsErrorOptions | ThemeExistsErrorOptions | TestFailedErrorOptions | StoreExistsErrorOptions | SkillViewExistsErrorOptions | SkillNotRegisteredErrorOptions | SkillNotFoundErrorOptions | SchemaTemplateItemBuildingFailedErrorOptions | SchemaFailedToImportErrorOptions | SchemaExistsErrorOptions | NotLoggedInErrorOptions | NotImplementedErrorOptions | NoSkillsRegisteredErrorOptions | NoOrganizationsFoundErrorOptions | MissingDependenciesErrorOptions | MercuryResponseErrorErrorOptions | LintFailedErrorOptions | InvalidTestDirectoryErrorOptions | InvalidFeatureCodeErrorOptions | InvalidEventContractErrorOptions | InvalidCommandErrorOptions | GenericErrorOptions | FileExistsErrorOptions | FeatureNotInstalledErrorOptions | FailedToImportErrorOptions | ExecutingCommandFailedErrorOptions | DockerNotStartedErrorOptions | DirectoryNotSkillErrorOptions | DirectoryEmptyErrorOptions | DeployFailedErrorOptions | DependencyExistsErrorOptions | CreateAutoloaderFailedErrorOptions | CommandNotImplementedErrorOptions | CommandBlockedErrorOptions | CommandAbortedErrorOptions | CacheNotEnabledErrorOptions | BuildFailedErrorOptions | BootErrorErrorOptions | ActionCancelledErrorOptions
126
129
 
127
130
  export default ErrorOptions
@@ -0,0 +1,22 @@
1
+ import { SchemaRegistry } from '@sprucelabs/schema'
2
+ import { SpruceErrors } from '../errors.types'
3
+
4
+
5
+
6
+ const viewPluginAlreadyExistsSchema: SpruceErrors.SpruceCli.ViewPluginAlreadyExistsSchema = {
7
+ id: 'viewPluginAlreadyExists',
8
+ namespace: 'SpruceCli',
9
+ name: 'View plugin already exists',
10
+ fields: {
11
+ /** . */
12
+ 'name': {
13
+ type: 'text',
14
+ isRequired: true,
15
+ options: undefined
16
+ },
17
+ }
18
+ }
19
+
20
+ SchemaRegistry.getInstance().trackSchema(viewPluginAlreadyExistsSchema)
21
+
22
+ export default viewPluginAlreadyExistsSchema
@@ -23,7 +23,7 @@ export default class CreatingASkillViewTest extends AbstractSkillTest {
23
23
  }
24
24
 
25
25
  @test()
26
- protected static async viewFieatureHasExpectedDependencies() {
26
+ protected static async viewFeatureHasExpectedDependencies() {
27
27
  const features = await this.featureInstaller
28
28
  const view = features.getFeature('view')
29
29
  assert.isEqualDeep(view.dependencies, [
@@ -36,7 +36,7 @@ export default class KeepingViewsInSyncTest extends AbstractSkillTest {
36
36
  }
37
37
 
38
38
  @test()
39
- protected static async generatesValidTypesFileWithNoSkillViewsC() {
39
+ protected static async generatesValidTypesFileWithNoSkillViews() {
40
40
  const results = await this.Action('view', 'create').execute({
41
41
  viewType: 'view',
42
42
  nameReadable: 'test',
@@ -0,0 +1,161 @@
1
+ import { diskUtil } from '@sprucelabs/spruce-skill-utils'
2
+ import { test, assert, errorAssert } from '@sprucelabs/test-utils'
3
+ import { FeatureActionResponse } from '../../../../features/features.types'
4
+ import CreatePluginAction from '../../../../features/view/actions/CreatePluginAction'
5
+ import AbstractSkillTest from '../../../../tests/AbstractSkillTest'
6
+
7
+ export default class CreatingAViewPluginTest extends AbstractSkillTest {
8
+ protected static skillCacheKey = 'views'
9
+ private static action: CreatePluginAction
10
+
11
+ protected static async beforeEach(): Promise<void> {
12
+ await super.beforeEach()
13
+ this.action = this.Action('view', 'createPlugin')
14
+ }
15
+
16
+ @test()
17
+ protected static async hasAction() {
18
+ assert.isFunction(this.action.execute)
19
+ }
20
+
21
+ @test('creates expected plugin file 1', 'test', 'test', 'updated')
22
+ @test('creates expected plugin file 2', 'another', 'another', 'updated')
23
+ @test('creates expected plugin file 3', 'a third', 'aThird', 'generated')
24
+ protected static async createsExpectedFile(
25
+ readable: string,
26
+ expected: string,
27
+ combinedViewAction: string
28
+ ) {
29
+ const results = await this.execute({ nameReadable: readable })
30
+ this.assertExpectedFileCreated(results, expected, combinedViewAction)
31
+ assert.isFalsy(
32
+ results.errors,
33
+ 'Errors were returned and none were expected!'
34
+ )
35
+ }
36
+
37
+ @test()
38
+ protected static async usesCamelNameIfProvided() {
39
+ const results = await this.execute({
40
+ nameReadable: 'test',
41
+ nameCamel: 'testCamel',
42
+ })
43
+
44
+ this.assertExpectedFileCreated(results, 'testCamel', 'updated')
45
+ }
46
+
47
+ @test()
48
+ protected static async actuallyCreatesFile() {
49
+ this.assertViewPluginWritten('test')
50
+ this.assertViewPluginWritten('another')
51
+ this.assertViewPluginWritten('aThird')
52
+ }
53
+
54
+ @test()
55
+ protected static async throwsIfPluginAlreadyExists() {
56
+ await this.assertThrowsAlreadyExists('test')
57
+ await this.assertThrowsAlreadyExists('another')
58
+ }
59
+
60
+ @test()
61
+ protected static async contentsAreEqualToExpected() {
62
+ this.assertPluginContentsEqualExpected('test', 'Test')
63
+ this.assertPluginContentsEqualExpected('another', 'Another')
64
+ this.assertPluginContentsEqualExpected('aThird', 'AThird')
65
+ }
66
+
67
+ @test()
68
+ protected static async combineViewsFileIsValid() {
69
+ const combined = this.getPathToCombinedViewsFile()
70
+ await this.Service('typeChecker').check(combined)
71
+ }
72
+
73
+ @test()
74
+ protected static async updatesViewCombinedFileWithTypesAsExpected() {
75
+ const expected = ` interface ViewControllerPlugins {
76
+ aThird: AThirdViewPlugin
77
+ another: AnotherViewPlugin
78
+ test: TestViewPlugin
79
+ testCamel: TestCamelViewPlugin
80
+ }`
81
+ this.assertCombinedFileIncludes(expected)
82
+ }
83
+
84
+ @test()
85
+ protected static async updatesViewCombinedWithPluginsAsExpected() {
86
+ const expected = `export const pluginClasses = {
87
+ aThird: AThirdViewPlugin,
88
+ another: AnotherViewPlugin,
89
+ test: TestViewPlugin,
90
+ testCamel: TestCamelViewPlugin,
91
+ }
92
+ `
93
+
94
+ this.assertCombinedFileIncludes(expected)
95
+ this.assertCombinedFileIncludes('heartwood(vcs, pluginClasses)')
96
+ }
97
+
98
+ private static assertCombinedFileIncludes(expected: string) {
99
+ const combined = this.getPathToCombinedViewsFile()
100
+ const contents = diskUtil.readFile(combined)
101
+ assert.doesInclude(contents, expected)
102
+ }
103
+
104
+ private static assertPluginContentsEqualExpected(
105
+ nameCamel: string,
106
+ namePascal: string
107
+ ) {
108
+ const contents = diskUtil.readFile(this.buildPathToViewPlugin(nameCamel))
109
+ const expected = `export default class ${namePascal}ViewPlugin {}`
110
+
111
+ assert.isEqual(contents.trim(), expected.trim())
112
+ }
113
+
114
+ private static async assertThrowsAlreadyExists(name: string) {
115
+ const results = await this.execute({ nameReadable: name })
116
+ assert.isTruthy(results.errors)
117
+ errorAssert.assertError(results.errors[0], 'VIEW_PLUGIN_ALREADY_EXISTS', {
118
+ name,
119
+ })
120
+ }
121
+
122
+ private static assertViewPluginWritten(name: string) {
123
+ const path = this.buildPathToViewPlugin(name)
124
+ assert.isTrue(diskUtil.doesFileExist(path), `File ${path} was not written!`)
125
+ }
126
+
127
+ private static buildPathToViewPlugin(name: string) {
128
+ return this.resolvePath('src', 'viewPlugins', `${name}.view.plugin.ts`)
129
+ }
130
+
131
+ private static async execute(options: {
132
+ nameReadable: string
133
+ nameCamel?: string
134
+ }) {
135
+ return await this.action.execute(options)
136
+ }
137
+
138
+ private static assertExpectedFileCreated(
139
+ results: FeatureActionResponse,
140
+ expected: string,
141
+ combinedViewAction: string
142
+ ) {
143
+ const expectedName = `${expected}.view.plugin.ts`
144
+
145
+ assert.doesInclude(results.files?.[0], {
146
+ action: 'generated',
147
+ name: expectedName,
148
+ path: this.resolvePath('src', 'viewPlugins', expectedName),
149
+ })
150
+
151
+ assert.doesInclude(results.files?.[1], {
152
+ action: combinedViewAction,
153
+ name: 'views.ts',
154
+ path: this.getPathToCombinedViewsFile(),
155
+ })
156
+ }
157
+
158
+ private static getPathToCombinedViewsFile() {
159
+ return this.resolveHashSprucePath('views', 'views.ts')
160
+ }
161
+ }
@@ -260,6 +260,10 @@ export default class SpruceError extends AbstractSpruceError<ErrorOptions> {
260
260
  message = `You already have ${options.namespace} as a dependency!`
261
261
  break
262
262
 
263
+ case 'VIEW_PLUGIN_ALREADY_EXISTS':
264
+ message = `A view plugin by the name ${options.name} already exists!`
265
+ break
266
+
263
267
  default:
264
268
  message = super.friendlyMessage()
265
269
  }
@@ -0,0 +1,12 @@
1
+ import { buildErrorSchema } from '@sprucelabs/schema'
2
+
3
+ export default buildErrorSchema({
4
+ id: 'viewPluginAlreadyExists',
5
+ name: 'View plugin already exists',
6
+ fields: {
7
+ name: {
8
+ type: 'text',
9
+ isRequired: true,
10
+ },
11
+ },
12
+ })