@sprucelabs/spruce-cli 14.28.5 → 14.28.6
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.
- package/CHANGELOG.md +8 -0
- package/build/__tests__/behavioral/BootingWithBadFiles.test.js +26 -13
- package/build/__tests__/behavioral/BootingWithBadFiles.test.js.map +1 -1
- package/build/__tests__/behavioral/events/KeepingEventsInSync2.test.js +1 -1
- package/build/__tests__/behavioral/events/KeepingEventsInSync2.test.js.map +1 -1
- package/build/__tests__/behavioral/skill/UpgradingASkill2.test.d.ts +1 -1
- package/build/__tests__/behavioral/skill/UpgradingASkill2.test.js +10 -20
- package/build/__tests__/behavioral/skill/UpgradingASkill2.test.js.map +1 -1
- package/build/__tests__/behavioral/{CreatingADataStore.test.d.ts → stores/CreatingADataStore.test.d.ts} +2 -1
- package/build/__tests__/behavioral/{CreatingADataStore.test.js → stores/CreatingADataStore.test.js} +84 -57
- package/build/__tests__/behavioral/stores/CreatingADataStore.test.js.map +1 -0
- package/build/__tests__/behavioral/{KeepingDataStoresInSync.test.d.ts → stores/KeepingDataStoresInSync.test.d.ts} +1 -1
- package/build/__tests__/behavioral/{KeepingDataStoresInSync.test.js → stores/KeepingDataStoresInSync.test.js} +2 -2
- package/build/__tests__/behavioral/stores/KeepingDataStoresInSync.test.js.map +1 -0
- package/build/cli.d.ts +1 -1
- package/build/cli.js +1 -1
- package/build/cli.js.map +1 -1
- package/build/features/node/NodeFeature.js +6 -11
- package/build/features/node/NodeFeature.js.map +1 -1
- package/build/features/store/actions/SyncAction.js +11 -10
- package/build/features/store/actions/SyncAction.js.map +1 -1
- package/build/features/store/writers/StoreWriter.d.ts +6 -0
- package/build/features/store/writers/StoreWriter.js +78 -8
- package/build/features/store/writers/StoreWriter.js.map +1 -1
- package/package.json +3 -3
- package/src/__tests__/behavioral/BootingWithBadFiles.test.ts +8 -3
- package/src/__tests__/behavioral/events/KeepingEventsInSync2.test.ts +1 -1
- package/src/__tests__/behavioral/skill/UpgradingASkill2.test.ts +1 -10
- package/src/__tests__/behavioral/{CreatingADataStore.test.ts → stores/CreatingADataStore.test.ts} +12 -6
- package/src/__tests__/behavioral/{KeepingDataStoresInSync.test.ts → stores/KeepingDataStoresInSync.test.ts} +2 -2
- package/src/cli.ts +2 -2
- package/src/features/node/NodeFeature.ts +0 -3
- package/src/features/store/actions/SyncAction.ts +2 -1
- package/src/features/store/writers/StoreWriter.ts +30 -0
- package/build/__tests__/behavioral/CreatingADataStore.test.js.map +0 -1
- package/build/__tests__/behavioral/KeepingDataStoresInSync.test.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/features/node/NodeFeature.ts"],"names":["NodeFeature","options","nodeFeatureOptionsSchema","universalDevDependencies","universalScripts","universalFileDescriptions","diskUtil","resolvePath","__dirname","doesFileExist","cwd","emitter","on","payload","featureCode","actionCode","handleUpgrade","ui","startLoading","Service","execute","summaryLines","errors","destination","resolveDestination","doesDirExist","createDir","files","name","path","action","Writer","writeNodeModule","written","push","installScripts","pkg","set","value","namesUtil","toKebab","description","unset","Store","setCurrentSkillsNamespace","scriptUpdater","ScriptUpdater","FromFeature","update","AbstractFeature"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA;;AACA;;AAEA;;AACA;;AAMA;;AACA;;AACA;;;;;;;;;;IAgBqBA,W;;;;;AAoBpB,uBAAmBC,OAAnB,EAA2C;AAAA;;AAAA;AAC1C,8BAAMA,OAAN;AAD0C,6FAjBhB,MAiBgB;AAAA,qGAhBrB,gBAgBqB;AAAA,oGAftB,EAesB;AAAA,qGAdA,EAcA;AAAA,sGAbpBC,8BAaoB;AAAA,gJAZVC,oCAYU;AAAA,kHATvCC,4BASuC;AAAA,6IALvCC,qCAKuC;AAAA,mGAFvBC,2BAASC,WAAT,CAAqBC,SAArB,EAAgC,SAAhC,CAEuB;AAAA,+
|
|
1
|
+
{"version":3,"sources":["../../../src/features/node/NodeFeature.ts"],"names":["NodeFeature","options","nodeFeatureOptionsSchema","universalDevDependencies","universalScripts","universalFileDescriptions","diskUtil","resolvePath","__dirname","doesFileExist","cwd","emitter","on","payload","featureCode","actionCode","handleUpgrade","ui","startLoading","Service","execute","summaryLines","errors","destination","resolveDestination","doesDirExist","createDir","files","name","path","action","Writer","writeNodeModule","written","push","installScripts","pkg","set","value","namesUtil","toKebab","description","unset","Store","setCurrentSkillsNamespace","scriptUpdater","ScriptUpdater","FromFeature","update","AbstractFeature"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA;;AACA;;AAEA;;AACA;;AAMA;;AACA;;AACA;;;;;;;;;;IAgBqBA,W;;;;;AAoBpB,uBAAmBC,OAAnB,EAA2C;AAAA;;AAAA;AAC1C,8BAAMA,OAAN;AAD0C,6FAjBhB,MAiBgB;AAAA,qGAhBrB,gBAgBqB;AAAA,oGAftB,EAesB;AAAA,qGAdA,EAcA;AAAA,sGAbpBC,8BAaoB;AAAA,gJAZVC,oCAYU;AAAA,kHATvCC,4BASuC;AAAA,6IALvCC,qCAKuC;AAAA,mGAFvBC,2BAASC,WAAT,CAAqBC,SAArB,EAAgC,SAAhC,CAEuB;AAAA,+LAyFtB;AAAA;AAAA;AAAA;AAAA;AAAA,+CACbF,2BAASG,aAAT,CACNH,2BAASC,WAAT,CAAqB,MAAKG,GAA1B,EAA+B,cAA/B,CADM,CADa;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,KAzFsB;AAG1C,SAAK,MAAKC,OAAL,CAAaC,EAAb,CAAgB,qBAAhB;AAAA,gGAAuC,kBAAOC,OAAP;AAAA;AAAA;AAAA;AAAA;AAAA,sBACvCA,OAAO,CAACC,WAAR,KAAwB,MAAxB,IAAkCD,OAAO,CAACE,UAAR,KAAuB,SADlB;AAAA;AAAA;AAAA;;AAAA,kDAEnC,MAAKC,aAAL,EAFmC;;AAAA;AAAA,kDAKpC,EALoC;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAA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AA7B,CAAuD3C,OAAO,CAAC2B,IAA/D,CAbP;;AAAA;AAAA,kDAeQ,EAfR;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,O;;;;;;;;;;;0GAkBA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAA6BL,gBAAAA,WAA7B,8DAA2C,KAAKb,GAAhD;AACOmC,gBAAAA,aADP,GACuBC,0BAAcC,WAAd,CAA0B,IAA1B,EAAgC;AACrDrC,kBAAAA,GAAG,EAAEa;AADgD,iBAAhC,CADvB;AAAA;AAAA,uBAKOsB,aAAa,CAACG,MAAd,EALP;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,O;;;;;;;;;;EAnGSC,4B","sourcesContent":["import { Schema, SchemaValues } from '@sprucelabs/schema'\nimport { SpruceSchemas } from '@sprucelabs/spruce-core-schemas'\nimport { diskUtil, namesUtil } from '@sprucelabs/spruce-skill-utils'\nimport nodeFeatureOptionsSchema from '#spruce/schemas/spruceCli/v2020_07_22/nodeFeatureOptions.schema'\nimport { FileDescription, GeneratedFile } from '../../types/cli.types'\nimport ScriptUpdater from '../../updaters/ScriptUpdater'\nimport AbstractFeature, { FeatureDependency } from '../AbstractFeature'\nimport {\n\tActionOptions,\n\tFeatureActionResponse,\n\tFeatureCode,\n} from '../features.types'\nimport universalDevDependencies from '../universalDevDependencies'\nimport universalFileDescriptions from '../universalFileDescriptions'\nimport universalScripts from '../universalScripts'\n\ntype OptionsSchema =\n\tSpruceSchemas.SpruceCli.v2020_07_22.NodeFeatureOptionsSchema\ntype Options = SpruceSchemas.SpruceCli.v2020_07_22.NodeFeatureOptions\n\ndeclare module '../../features/features.types' {\n\tinterface FeatureMap {\n\t\tnode: NodeFeature\n\t}\n\n\tinterface FeatureOptionsMap {\n\t\tnode: SchemaValues<OptionsSchema>\n\t}\n}\n\nexport default class NodeFeature<\n\tS extends OptionsSchema = OptionsSchema\n> extends AbstractFeature<S> {\n\tpublic code: FeatureCode = 'node'\n\tpublic nameReadable = 'nodejs support'\n\tpublic description = ''\n\tpublic dependencies: FeatureDependency[] = []\n\tpublic optionsSchema = nodeFeatureOptionsSchema as S\n\tpublic packageDependencies = [...universalDevDependencies]\n\n\tpublic scripts = {\n\t\t...universalScripts,\n\t}\n\n\tpublic readonly fileDescriptions: FileDescription[] = [\n\t\t...universalFileDescriptions,\n\t]\n\n\tpublic actionsDir = diskUtil.resolvePath(__dirname, 'actions')\n\n\tpublic constructor(options: ActionOptions) {\n\t\tsuper(options)\n\n\t\tvoid this.emitter.on('feature.did-execute', async (payload) => {\n\t\t\tif (payload.featureCode === 'node' && payload.actionCode === 'upgrade') {\n\t\t\t\treturn this.handleUpgrade()\n\t\t\t}\n\n\t\t\treturn {}\n\t\t})\n\t}\n\tprivate async handleUpgrade(): Promise<FeatureActionResponse> {\n\t\ttry {\n\t\t\tthis.ui.startLoading('Cleaning build...')\n\t\t\tawait this.Service('command').execute('yarn clean.build')\n\n\t\t\tthis.ui.startLoading('Rebuilding...')\n\t\t\tawait this.Service('command').execute('yarn build.dev')\n\n\t\t\treturn {\n\t\t\t\tsummaryLines: [\n\t\t\t\t\t'Build cleared.',\n\t\t\t\t\t'Lint rules applied to source.',\n\t\t\t\t\t'Code rebuilt successfully.',\n\t\t\t\t],\n\t\t\t}\n\t\t} catch (err) {\n\t\t\treturn {\n\t\t\t\terrors: [err],\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic async beforePackageInstall(options: Options) {\n\t\tconst destination = this.resolveDestination(options)\n\n\t\tif (!diskUtil.doesDirExist(destination)) {\n\t\t\tdiskUtil.createDir(destination)\n\t\t}\n\n\t\tconst files: GeneratedFile[] = [\n\t\t\t{\n\t\t\t\tname: 'package.json',\n\t\t\t\tpath: diskUtil.resolvePath(destination, 'package.json'),\n\t\t\t\taction: 'generated',\n\t\t\t},\n\t\t]\n\n\t\tawait this.Service('command', destination).execute('yarn init -y')\n\n\t\tconst written = await this.Writer('node').writeNodeModule(destination)\n\n\t\tfiles.push(...written)\n\n\t\tawait this.installScripts(destination)\n\n\t\treturn { files, cwd: destination }\n\t}\n\n\tprivate resolveDestination(options: Options) {\n\t\treturn diskUtil.resolvePath(this.cwd, options.destination ?? '')\n\t}\n\n\tpublic async afterPackageInstall(\n\t\toptions: S extends Schema ? SchemaValues<S> : undefined\n\t) {\n\t\tconst cwd = this.resolveDestination(options)\n\t\tconst pkg = this.Service('pkg', cwd)\n\n\t\tpkg.set({ path: 'name', value: namesUtil.toKebab(options.name) })\n\t\tpkg.set({ path: 'description', value: options.description })\n\t\tpkg.set({ path: 'version', value: '0.0.1' })\n\n\t\tpkg.unset('main')\n\t\tpkg.unset('license')\n\n\t\tawait this.Store('skill', { cwd }).setCurrentSkillsNamespace(options.name)\n\n\t\treturn {}\n\t}\n\n\tprivate async installScripts(destination = this.cwd) {\n\t\tconst scriptUpdater = ScriptUpdater.FromFeature(this, {\n\t\t\tcwd: destination,\n\t\t})\n\n\t\tawait scriptUpdater.update()\n\t}\n\n\tpublic isInstalled = async (): Promise<boolean> => {\n\t\treturn diskUtil.doesFileExist(\n\t\t\tdiskUtil.resolvePath(this.cwd, 'package.json')\n\t\t)\n\t}\n}\n"],"file":"NodeFeature.js"}
|
|
@@ -68,7 +68,7 @@ var SyncAction = /*#__PURE__*/function (_AbstractAction) {
|
|
|
68
68
|
key: "execute",
|
|
69
69
|
value: function () {
|
|
70
70
|
var _execute = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(_options) {
|
|
71
|
-
var stores, files, destination, builder, templateItems;
|
|
71
|
+
var stores, files, destination, builder, templateItems, writer;
|
|
72
72
|
return _regenerator["default"].wrap(function _callee$(_context) {
|
|
73
73
|
while (1) {
|
|
74
74
|
switch (_context.prev = _context.next) {
|
|
@@ -82,39 +82,40 @@ var SyncAction = /*#__PURE__*/function (_AbstractAction) {
|
|
|
82
82
|
files = [];
|
|
83
83
|
|
|
84
84
|
if (!(stores.length > 0)) {
|
|
85
|
-
_context.next =
|
|
85
|
+
_context.next = 13;
|
|
86
86
|
break;
|
|
87
87
|
}
|
|
88
88
|
|
|
89
89
|
destination = _spruceSkillUtils.diskUtil.resolveHashSprucePath(this.cwd, 'stores');
|
|
90
90
|
builder = new _StoreTemplateItemBuilder["default"]();
|
|
91
91
|
templateItems = builder.buildTemplateItems(stores, destination);
|
|
92
|
-
|
|
93
|
-
|
|
92
|
+
writer = this.Writer('store');
|
|
93
|
+
_context.next = 12;
|
|
94
|
+
return writer.writeTypesAndMap(destination, {
|
|
94
95
|
stores: templateItems
|
|
95
96
|
});
|
|
96
97
|
|
|
97
|
-
case
|
|
98
|
+
case 12:
|
|
98
99
|
files = _context.sent;
|
|
99
100
|
|
|
100
|
-
case
|
|
101
|
+
case 13:
|
|
101
102
|
return _context.abrupt("return", {
|
|
102
103
|
files: files
|
|
103
104
|
});
|
|
104
105
|
|
|
105
|
-
case
|
|
106
|
-
_context.prev =
|
|
106
|
+
case 16:
|
|
107
|
+
_context.prev = 16;
|
|
107
108
|
_context.t0 = _context["catch"](0);
|
|
108
109
|
return _context.abrupt("return", {
|
|
109
110
|
errors: [_context.t0]
|
|
110
111
|
});
|
|
111
112
|
|
|
112
|
-
case
|
|
113
|
+
case 19:
|
|
113
114
|
case "end":
|
|
114
115
|
return _context.stop();
|
|
115
116
|
}
|
|
116
117
|
}
|
|
117
|
-
}, _callee, this, [[0,
|
|
118
|
+
}, _callee, this, [[0, 16]]);
|
|
118
119
|
}));
|
|
119
120
|
|
|
120
121
|
function execute(_x) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/features/store/actions/SyncAction.ts"],"names":["optionsSchema","id","description","fields","SyncAction","_options","Store","fetchStores","stores","files","length","destination","diskUtil","resolveHashSprucePath","cwd","builder","StoreTemplateItemBuilder","templateItems","buildTemplateItems","Writer","
|
|
1
|
+
{"version":3,"sources":["../../../../src/features/store/actions/SyncAction.ts"],"names":["optionsSchema","id","description","fields","SyncAction","_options","Store","fetchStores","stores","files","length","destination","diskUtil","resolveHashSprucePath","cwd","builder","StoreTemplateItemBuilder","templateItems","buildTemplateItems","writer","Writer","writeTypesAndMap","errors","AbstractAction"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AAEA;;AACA;;;;;;AAEA,IAAMA,aAAa,GAAG,yBAAY;AACjCC,EAAAA,EAAE,EAAE,sBAD6B;AAEjCC,EAAAA,WAAW,EACV,uEAHgC;AAIjCC,EAAAA,MAAM,EAAE;AAJyB,CAAZ,CAAtB;;IAUqBC,U;;;;;;;;;;;;;;;sGACGJ,a;uGACC,CAAC,aAAD,C;0GAEvB,2D;;;;;;;mGAED,iBAAqBK,QAArB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAEuB,KAAKC,KAAL,CAAW,OAAX,EAAoBC,WAApB,EAFvB;;AAAA;AAEQC,gBAAAA,MAFR;AAIMC,gBAAAA,KAJN,GAI+B,EAJ/B;;AAAA,sBAMMD,MAAM,CAACE,MAAP,GAAgB,CANtB;AAAA;AAAA;AAAA;;AAOSC,gBAAAA,WAPT,GAOuBC,2BAASC,qBAAT,CAA+B,KAAKC,GAApC,EAAyC,QAAzC,CAPvB;AAQSC,gBAAAA,OART,GAQmB,IAAIC,oCAAJ,EARnB;AASSC,gBAAAA,aATT,GASyBF,OAAO,CAACG,kBAAR,CAA2BV,MAA3B,EAAmCG,WAAnC,CATzB;AAWSQ,gBAAAA,MAXT,GAWkB,KAAKC,MAAL,CAAY,OAAZ,CAXlB;AAAA;AAAA,uBAYiBD,MAAM,CAACE,gBAAP,CAAwBV,WAAxB,EAAqC;AAClDH,kBAAAA,MAAM,EAAES;AAD0C,iBAArC,CAZjB;;AAAA;AAYGR,gBAAAA,KAZH;;AAAA;AAAA,iDAiBS;AACNA,kBAAAA,KAAK,EAALA;AADM,iBAjBT;;AAAA;AAAA;AAAA;AAAA,iDAqBS;AACNa,kBAAAA,MAAM,EAAE;AADF,iBArBT;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,O;;;;;;;;;;EANuCC,2B","sourcesContent":["import { buildSchema, SchemaValues } from '@sprucelabs/schema'\nimport { diskUtil } from '@sprucelabs/spruce-skill-utils'\nimport { GeneratedFile } from '../../../types/cli.types'\nimport AbstractAction from '../../AbstractAction'\nimport StoreTemplateItemBuilder from '../templateItemBuilders/StoreTemplateItemBuilder'\n\nconst optionsSchema = buildSchema({\n\tid: 'syncDataStoreOptions',\n\tdescription:\n\t\t\"Only needed if you change a store's name, manually add or remove one.\",\n\tfields: {},\n})\n\ntype OptionsSchema = typeof optionsSchema\ntype Options = SchemaValues<OptionsSchema>\n\nexport default class SyncAction extends AbstractAction<OptionsSchema> {\n\tpublic optionsSchema = optionsSchema\n\tpublic commandAliases = ['sync.stores']\n\tpublic invocationMessage =\n\t\t'Generating store types and setting up store factory... 💿'\n\n\tpublic async execute(_options: Options) {\n\t\ttry {\n\t\t\tconst stores = await this.Store('store').fetchStores()\n\n\t\t\tlet files: GeneratedFile[] = []\n\n\t\t\tif (stores.length > 0) {\n\t\t\t\tconst destination = diskUtil.resolveHashSprucePath(this.cwd, 'stores')\n\t\t\t\tconst builder = new StoreTemplateItemBuilder()\n\t\t\t\tconst templateItems = builder.buildTemplateItems(stores, destination)\n\n\t\t\t\tconst writer = this.Writer('store')\n\t\t\t\tfiles = await writer.writeTypesAndMap(destination, {\n\t\t\t\t\tstores: templateItems,\n\t\t\t\t})\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tfiles,\n\t\t\t}\n\t\t} catch (err) {\n\t\t\treturn {\n\t\t\t\terrors: [err],\n\t\t\t}\n\t\t}\n\t}\n}\n"],"file":"SyncAction.js"}
|
|
@@ -3,7 +3,13 @@ import AbstractWriter from '../../../writers/AbstractWriter';
|
|
|
3
3
|
export default class StoreWriter extends AbstractWriter {
|
|
4
4
|
writeStore(destination: string, options: StoreTemplateOptions): Promise<import("@sprucelabs/mercury-types").SpruceSchemas.SpruceCli.v2020_07_22.GeneratedFile[]>;
|
|
5
5
|
writePlugin(cwd: string): Promise<import("../../../writers/AbstractWriter").WriteResults>;
|
|
6
|
+
writeTypesAndMap(destination: string, options: {
|
|
7
|
+
stores: StoreTemplateItem[];
|
|
8
|
+
}): Promise<import("@sprucelabs/mercury-types").SpruceSchemas.SpruceCli.v2020_07_22.GeneratedFile[]>;
|
|
6
9
|
writeTypes(destination: string, options: {
|
|
7
10
|
stores: StoreTemplateItem[];
|
|
8
11
|
}): Promise<import("../../../writers/AbstractWriter").WriteResults>;
|
|
12
|
+
writeMap(destination: string, options: {
|
|
13
|
+
stores: StoreTemplateItem[];
|
|
14
|
+
}): Promise<import("../../../writers/AbstractWriter").WriteResults>;
|
|
9
15
|
}
|
|
@@ -9,6 +9,10 @@ exports["default"] = void 0;
|
|
|
9
9
|
|
|
10
10
|
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
11
11
|
|
|
12
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
13
|
+
|
|
14
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
15
|
+
|
|
12
16
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
13
17
|
|
|
14
18
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
@@ -104,37 +108,103 @@ var StoreWriter = /*#__PURE__*/function (_AbstractWriter) {
|
|
|
104
108
|
return results;
|
|
105
109
|
}
|
|
106
110
|
}, {
|
|
107
|
-
key: "
|
|
111
|
+
key: "writeTypesAndMap",
|
|
108
112
|
value: function () {
|
|
109
|
-
var
|
|
110
|
-
var
|
|
113
|
+
var _writeTypesAndMap = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2(destination, options) {
|
|
114
|
+
var _yield$Promise$all, _yield$Promise$all2, types, map;
|
|
115
|
+
|
|
111
116
|
return _regenerator["default"].wrap(function _callee2$(_context2) {
|
|
112
117
|
while (1) {
|
|
113
118
|
switch (_context2.prev = _context2.next) {
|
|
119
|
+
case 0:
|
|
120
|
+
_context2.next = 2;
|
|
121
|
+
return Promise.all([this.writeTypes(destination, options), this.writeMap(destination, options)]);
|
|
122
|
+
|
|
123
|
+
case 2:
|
|
124
|
+
_yield$Promise$all = _context2.sent;
|
|
125
|
+
_yield$Promise$all2 = (0, _slicedToArray2["default"])(_yield$Promise$all, 2);
|
|
126
|
+
types = _yield$Promise$all2[0];
|
|
127
|
+
map = _yield$Promise$all2[1];
|
|
128
|
+
return _context2.abrupt("return", [].concat((0, _toConsumableArray2["default"])(types), (0, _toConsumableArray2["default"])(map)));
|
|
129
|
+
|
|
130
|
+
case 7:
|
|
131
|
+
case "end":
|
|
132
|
+
return _context2.stop();
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}, _callee2, this);
|
|
136
|
+
}));
|
|
137
|
+
|
|
138
|
+
function writeTypesAndMap(_x3, _x4) {
|
|
139
|
+
return _writeTypesAndMap.apply(this, arguments);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
return writeTypesAndMap;
|
|
143
|
+
}()
|
|
144
|
+
}, {
|
|
145
|
+
key: "writeTypes",
|
|
146
|
+
value: function () {
|
|
147
|
+
var _writeTypes = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3(destination, options) {
|
|
148
|
+
var file, typesContent, files;
|
|
149
|
+
return _regenerator["default"].wrap(function _callee3$(_context3) {
|
|
150
|
+
while (1) {
|
|
151
|
+
switch (_context3.prev = _context3.next) {
|
|
114
152
|
case 0:
|
|
115
153
|
file = _spruceSkillUtils.diskUtil.resolvePath(destination, 'stores.types.ts');
|
|
116
154
|
typesContent = this.templates.storeTypes(options);
|
|
117
155
|
files = this.writeFileIfChangedMixinResults(file, typesContent, 'The type merging for so the StoreFactory properly types you stores.');
|
|
118
|
-
|
|
156
|
+
_context3.next = 5;
|
|
119
157
|
return this.lint(file);
|
|
120
158
|
|
|
121
159
|
case 5:
|
|
122
|
-
return
|
|
160
|
+
return _context3.abrupt("return", files);
|
|
123
161
|
|
|
124
162
|
case 6:
|
|
125
163
|
case "end":
|
|
126
|
-
return
|
|
164
|
+
return _context3.stop();
|
|
127
165
|
}
|
|
128
166
|
}
|
|
129
|
-
},
|
|
167
|
+
}, _callee3, this);
|
|
130
168
|
}));
|
|
131
169
|
|
|
132
|
-
function writeTypes(
|
|
170
|
+
function writeTypes(_x5, _x6) {
|
|
133
171
|
return _writeTypes.apply(this, arguments);
|
|
134
172
|
}
|
|
135
173
|
|
|
136
174
|
return writeTypes;
|
|
137
175
|
}()
|
|
176
|
+
}, {
|
|
177
|
+
key: "writeMap",
|
|
178
|
+
value: function () {
|
|
179
|
+
var _writeMap = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee4(destination, options) {
|
|
180
|
+
var file, mapContent, files;
|
|
181
|
+
return _regenerator["default"].wrap(function _callee4$(_context4) {
|
|
182
|
+
while (1) {
|
|
183
|
+
switch (_context4.prev = _context4.next) {
|
|
184
|
+
case 0:
|
|
185
|
+
file = _spruceSkillUtils.diskUtil.resolvePath(destination, 'stores.ts');
|
|
186
|
+
mapContent = this.templates.stores(options);
|
|
187
|
+
files = this.writeFileIfChangedMixinResults(file, mapContent, 'A reference to all your data stores for easy inclusion.');
|
|
188
|
+
_context4.next = 5;
|
|
189
|
+
return this.lint(file);
|
|
190
|
+
|
|
191
|
+
case 5:
|
|
192
|
+
return _context4.abrupt("return", files);
|
|
193
|
+
|
|
194
|
+
case 6:
|
|
195
|
+
case "end":
|
|
196
|
+
return _context4.stop();
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
}, _callee4, this);
|
|
200
|
+
}));
|
|
201
|
+
|
|
202
|
+
function writeMap(_x7, _x8) {
|
|
203
|
+
return _writeMap.apply(this, arguments);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
return writeMap;
|
|
207
|
+
}()
|
|
138
208
|
}]);
|
|
139
209
|
return StoreWriter;
|
|
140
210
|
}(_AbstractWriter2["default"]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/features/store/writers/StoreWriter.ts"],"names":["StoreWriter","destination","options","namePascalPlural","files","filename","fileDest","diskUtil","resolvePath","doesFileExist","SpruceError","code","contents","templates","store","writeFile","lint","push","action","name","path","cwd","resolveHashSprucePath","pluginContents","storePlugin","results","writeFileIfChangedMixinResults","file","typesContent","storeTypes","AbstractWriter"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../../src/features/store/writers/StoreWriter.ts"],"names":["StoreWriter","destination","options","namePascalPlural","files","filename","fileDest","diskUtil","resolvePath","doesFileExist","SpruceError","code","contents","templates","store","writeFile","lint","push","action","name","path","cwd","resolveHashSprucePath","pluginContents","storePlugin","results","writeFileIfChangedMixinResults","Promise","all","writeTypes","writeMap","types","map","file","typesContent","storeTypes","mapContent","stores","AbstractWriter"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AAKA;;AAEA;;;;;;IAEqBA,W;;;;;;;;;;;;;sGACpB,iBAAwBC,WAAxB,EAA6CC,OAA7C;AAAA;AAAA;AAAA;AAAA;AAAA;AACSC,gBAAAA,gBADT,GAC8BD,OAD9B,CACSC,gBADT;AAGOC,gBAAAA,KAHP,GAGgC,EAHhC;AAKOC,gBAAAA,QALP,aAKqBF,gBALrB;AAOOG,gBAAAA,QAPP,GAOkBC,2BAASC,WAAT,CAChBP,WADgB,EAEhB,KAFgB,EAGhB,QAHgB,EAIhBI,QAJgB,CAPlB;;AAAA,qBAcKE,2BAASE,aAAT,CAAuBH,QAAvB,CAdL;AAAA;AAAA;AAAA;;AAAA,sBAeQ,IAAII,uBAAJ,CAAgB;AAAEC,kBAAAA,IAAI,EAAE;AAAR,iBAAhB,CAfR;;AAAA;AAkBOC,gBAAAA,QAlBP,GAkBkB,KAAK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;AAMOiC,gBAAAA,YANP,GAMsB,KAAKrB,SAAL,CAAesB,UAAf,CAA0BjC,OAA1B,CANtB;AAQOE,gBAAAA,KARP,GAQe,KAAKsB,8BAAL,CACbO,IADa,EAEbC,YAFa,EAGb,qEAHa,CARf;AAAA;AAAA,uBAcO,KAAKlB,IAAL,CAAUiB,IAAV,CAdP;;AAAA;AAAA,kDAgBQ7B,KAhBR;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,O;;;;;;;;;;;oGAmBA,kBACCH,WADD,EAECC,OAFD;AAAA;AAAA;AAAA;AAAA;AAAA;AAIO+B,gBAAAA,IAJP,GAIc1B,2BAASC,WAAT,CAAqBP,WAArB,EAAkC,WAAlC,CAJd;AAKOmC,gBAAAA,UALP,GAKoB,KAAKvB,SAAL,CAAewB,MAAf,CAAsBnC,OAAtB,CALpB;AAOOE,gBAAAA,KAPP,GAOe,KAAKsB,8BAAL,CACbO,IADa,EAEbG,UAFa,EAGb,yDAHa,CAPf;AAAA;AAAA,uBAaO,KAAKpB,IAAL,CAAUiB,IAAV,CAbP;;AAAA;AAAA,kDAeQ7B,KAfR;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,O;;;;;;;;;;EAnFwCkC,2B","sourcesContent":["import { diskUtil } from '@sprucelabs/spruce-skill-utils'\nimport {\n\tStoreTemplateItem,\n\tStoreTemplateOptions,\n} from '@sprucelabs/spruce-templates'\nimport SpruceError from '../../../errors/SpruceError'\nimport { GeneratedFile } from '../../../types/cli.types'\nimport AbstractWriter from '../../../writers/AbstractWriter'\n\nexport default class StoreWriter extends AbstractWriter {\n\tpublic async writeStore(destination: string, options: StoreTemplateOptions) {\n\t\tconst { namePascalPlural } = options\n\n\t\tconst files: GeneratedFile[] = []\n\n\t\tconst filename = `${namePascalPlural}.store.ts`\n\n\t\tconst fileDest = diskUtil.resolvePath(\n\t\t\tdestination,\n\t\t\t'src',\n\t\t\t'stores',\n\t\t\tfilename\n\t\t)\n\n\t\tif (diskUtil.doesFileExist(fileDest)) {\n\t\t\tthrow new SpruceError({ code: 'STORE_EXISTS' })\n\t\t}\n\n\t\tconst contents = this.templates.store(options)\n\n\t\tdiskUtil.writeFile(fileDest, contents)\n\n\t\tawait this.lint(fileDest)\n\n\t\tfiles.push({\n\t\t\taction: 'generated',\n\t\t\tname: filename,\n\t\t\tpath: fileDest,\n\t\t})\n\n\t\treturn files\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'store.plugin.ts'\n\t\t)\n\n\t\tconst pluginContents = this.templates.storePlugin()\n\n\t\tconst results = this.writeFileIfChangedMixinResults(\n\t\t\tdestination,\n\t\t\tpluginContents,\n\t\t\t'Loads all your data stores and connects you to any databases you have configured.'\n\t\t)\n\n\t\treturn results\n\t}\n\n\tpublic async writeTypesAndMap(\n\t\tdestination: string,\n\t\toptions: { stores: StoreTemplateItem[] }\n\t) {\n\t\tconst [types, map] = await Promise.all([\n\t\t\tthis.writeTypes(destination, options),\n\t\t\tthis.writeMap(destination, options),\n\t\t])\n\n\t\treturn [...types, ...map]\n\t}\n\n\tpublic async writeTypes(\n\t\tdestination: string,\n\t\toptions: { stores: StoreTemplateItem[] }\n\t) {\n\t\tconst file = diskUtil.resolvePath(destination, 'stores.types.ts')\n\n\t\tconst typesContent = this.templates.storeTypes(options)\n\n\t\tconst files = this.writeFileIfChangedMixinResults(\n\t\t\tfile,\n\t\t\ttypesContent,\n\t\t\t'The type merging for so the StoreFactory properly types you stores.'\n\t\t)\n\n\t\tawait this.lint(file)\n\n\t\treturn files\n\t}\n\n\tpublic async writeMap(\n\t\tdestination: string,\n\t\toptions: { stores: StoreTemplateItem[] }\n\t) {\n\t\tconst file = diskUtil.resolvePath(destination, 'stores.ts')\n\t\tconst mapContent = this.templates.stores(options)\n\n\t\tconst files = this.writeFileIfChangedMixinResults(\n\t\t\tfile,\n\t\t\tmapContent,\n\t\t\t'A reference to all your data stores for easy inclusion.'\n\t\t)\n\n\t\tawait this.lint(file)\n\n\t\treturn files\n\t}\n}\n"],"file":"StoreWriter.js"}
|
package/package.json
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
]
|
|
19
19
|
},
|
|
20
20
|
"license": "MIT",
|
|
21
|
-
"version": "14.28.
|
|
21
|
+
"version": "14.28.6",
|
|
22
22
|
"bin": {
|
|
23
23
|
"spruce": "./build/index.js"
|
|
24
24
|
},
|
|
@@ -88,7 +88,7 @@
|
|
|
88
88
|
"@sprucelabs/spruce-event-utils": "^17.1.249",
|
|
89
89
|
"@sprucelabs/spruce-skill-booter": "^17.0.2",
|
|
90
90
|
"@sprucelabs/spruce-skill-utils": "^22.1.40",
|
|
91
|
-
"@sprucelabs/spruce-templates": "^14.28.
|
|
91
|
+
"@sprucelabs/spruce-templates": "^14.28.6",
|
|
92
92
|
"cfonts": "^2.10.0",
|
|
93
93
|
"chalk": "^4.1.2",
|
|
94
94
|
"chokidar": "^3.5.2",
|
|
@@ -595,5 +595,5 @@
|
|
|
595
595
|
"ora"
|
|
596
596
|
]
|
|
597
597
|
},
|
|
598
|
-
"gitHead": "
|
|
598
|
+
"gitHead": "3f4f8dba43a7588da686e8253b4a90b487debe28"
|
|
599
599
|
}
|
|
@@ -6,6 +6,7 @@ import testUtil from '../../tests/utilities/test.utility'
|
|
|
6
6
|
export default class BootingWithBadFilesTest extends AbstractCliTest {
|
|
7
7
|
@test()
|
|
8
8
|
protected static async bootingWithAEmptySchemaThrowsErrorWithNameOfBadSchema() {
|
|
9
|
+
await this.FeatureFixture().installCachedFeatures('schemas')
|
|
9
10
|
const bootResults = await this.breakSchemaAndBoot()
|
|
10
11
|
assert.isTruthy(bootResults.errors)
|
|
11
12
|
assert.doesInclude(bootResults.errors[0].message, 'location.schema.ts')
|
|
@@ -13,12 +14,16 @@ export default class BootingWithBadFilesTest extends AbstractCliTest {
|
|
|
13
14
|
|
|
14
15
|
@test()
|
|
15
16
|
protected static async disablesSchemaCheckingWithFlag() {
|
|
16
|
-
|
|
17
|
+
await this.FeatureFixture().installCachedFeatures('schemas')
|
|
18
|
+
diskUtil.writeFile(
|
|
19
|
+
this.resolvePath('.env'),
|
|
20
|
+
'SHOULD_VALIDATE_SCHEMAS_ON_BOOT=false'
|
|
21
|
+
)
|
|
22
|
+
const bootResults = await this.breakSchemaAndBoot()
|
|
23
|
+
assert.isFalsy(bootResults.errors)
|
|
17
24
|
}
|
|
18
25
|
|
|
19
26
|
private static async breakSchemaAndBoot() {
|
|
20
|
-
await this.FeatureFixture().installCachedFeatures('schemas')
|
|
21
|
-
|
|
22
27
|
const results = await this.Action('schema', 'sync').execute({})
|
|
23
28
|
|
|
24
29
|
const match = testUtil.assertFileByNameInGeneratedFiles(
|
|
@@ -79,7 +79,7 @@ export default class KeepingEventsInSyncTest extends AbstractEventTest {
|
|
|
79
79
|
|
|
80
80
|
await this.Service('build').build()
|
|
81
81
|
|
|
82
|
-
const health = await cli.checkHealth({
|
|
82
|
+
const health = await cli.checkHealth({ shouldRunOnSourceFiles: false })
|
|
83
83
|
|
|
84
84
|
assert.isTruthy(health.skill)
|
|
85
85
|
assert.isFalsy(health.skill.errors)
|
|
@@ -84,7 +84,7 @@ export default class UpgradingASkill2Test extends AbstractCliTest {
|
|
|
84
84
|
}
|
|
85
85
|
|
|
86
86
|
@test()
|
|
87
|
-
protected static async
|
|
87
|
+
protected static async callsCleanFixAndBuildDev() {
|
|
88
88
|
await this.FeatureFixture().installCachedFeatures('skills')
|
|
89
89
|
|
|
90
90
|
let wasCleanBuildCalled = false
|
|
@@ -92,7 +92,6 @@ export default class UpgradingASkill2Test extends AbstractCliTest {
|
|
|
92
92
|
return {}
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
-
let wasFixLintCalled = false
|
|
96
95
|
CommandService.setMockResponse('yarn clean.build', {
|
|
97
96
|
code: 0,
|
|
98
97
|
callback: () => {
|
|
@@ -100,13 +99,6 @@ export default class UpgradingASkill2Test extends AbstractCliTest {
|
|
|
100
99
|
},
|
|
101
100
|
})
|
|
102
101
|
|
|
103
|
-
CommandService.setMockResponse('yarn fix.lint', {
|
|
104
|
-
code: 0,
|
|
105
|
-
callback: () => {
|
|
106
|
-
wasFixLintCalled = true
|
|
107
|
-
},
|
|
108
|
-
})
|
|
109
|
-
|
|
110
102
|
let wasBuildDevCalled = false
|
|
111
103
|
|
|
112
104
|
CommandService.setMockResponse('yarn build.dev', {
|
|
@@ -121,7 +113,6 @@ export default class UpgradingASkill2Test extends AbstractCliTest {
|
|
|
121
113
|
assert.isFalsy(results.errors)
|
|
122
114
|
assert.isTrue(wasCleanBuildCalled)
|
|
123
115
|
assert.isTrue(wasBuildDevCalled)
|
|
124
|
-
assert.isTrue(wasFixLintCalled)
|
|
125
116
|
}
|
|
126
117
|
|
|
127
118
|
@test()
|
package/src/__tests__/behavioral/{CreatingADataStore.test.ts → stores/CreatingADataStore.test.ts}
RENAMED
|
@@ -2,9 +2,9 @@ import { diskUtil } from '@sprucelabs/spruce-skill-utils'
|
|
|
2
2
|
import { test, assert } from '@sprucelabs/test'
|
|
3
3
|
import { errorAssertUtil } from '@sprucelabs/test-utils'
|
|
4
4
|
import '@sprucelabs/spruce-store-plugin'
|
|
5
|
-
import CommandService from '
|
|
6
|
-
import AbstractSkillTest from '
|
|
7
|
-
import testUtil from '
|
|
5
|
+
import CommandService from '../../../services/CommandService'
|
|
6
|
+
import AbstractSkillTest from '../../../tests/AbstractSkillTest'
|
|
7
|
+
import testUtil from '../../../tests/utilities/test.utility'
|
|
8
8
|
|
|
9
9
|
export default class CreatingDataStoresTest extends AbstractSkillTest {
|
|
10
10
|
protected static skillCacheKey = 'stores'
|
|
@@ -16,7 +16,7 @@ export default class CreatingDataStoresTest extends AbstractSkillTest {
|
|
|
16
16
|
|
|
17
17
|
@test()
|
|
18
18
|
protected static async getsNoStoresBackFromHealthCheck() {
|
|
19
|
-
const health = await this.cli.checkHealth({
|
|
19
|
+
const health = await this.cli.checkHealth({ shouldRunOnSourceFiles: true })
|
|
20
20
|
|
|
21
21
|
assert.isFalsy(health.skill.errors)
|
|
22
22
|
assert.isTruthy(health.store)
|
|
@@ -43,9 +43,15 @@ export default class CreatingDataStoresTest extends AbstractSkillTest {
|
|
|
43
43
|
await this.Service('typeChecker').check(path)
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
+
@test()
|
|
47
|
+
protected static async generatesAMapFile() {
|
|
48
|
+
const file = this.resolveHashSprucePath('stores', 'stores.ts')
|
|
49
|
+
assert.isTrue(diskUtil.doesFileExist(file))
|
|
50
|
+
}
|
|
51
|
+
|
|
46
52
|
@test()
|
|
47
53
|
protected static async getsOneStoresBackFromHealthCheck() {
|
|
48
|
-
const health = await this.cli.checkHealth({
|
|
54
|
+
const health = await this.cli.checkHealth({ shouldRunOnSourceFiles: true })
|
|
49
55
|
assert.isTruthy(health.store)
|
|
50
56
|
assert.isFalsy(health.store.errors)
|
|
51
57
|
assert.isLength(health.store.stores, 1)
|
|
@@ -72,7 +78,7 @@ export default class CreatingDataStoresTest extends AbstractSkillTest {
|
|
|
72
78
|
|
|
73
79
|
@test()
|
|
74
80
|
protected static async getsSecondStoresBackFromHealthCheck() {
|
|
75
|
-
const health = await this.cli.checkHealth({
|
|
81
|
+
const health = await this.cli.checkHealth({ shouldRunOnSourceFiles: true })
|
|
76
82
|
|
|
77
83
|
assert.isTruthy(health.store)
|
|
78
84
|
assert.isFalsy(health.store.errors)
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { diskUtil } from '@sprucelabs/spruce-skill-utils'
|
|
2
2
|
import { test, assert } from '@sprucelabs/test'
|
|
3
3
|
import { errorAssertUtil } from '@sprucelabs/test-utils'
|
|
4
|
-
import AbstractSkillTest from '
|
|
5
|
-
import testUtil from '
|
|
4
|
+
import AbstractSkillTest from '../../../tests/AbstractSkillTest'
|
|
5
|
+
import testUtil from '../../../tests/utilities/test.utility'
|
|
6
6
|
|
|
7
7
|
export default class KeepingDataStoresInSyncTest extends AbstractSkillTest {
|
|
8
8
|
protected static skillCacheKey = 'stores'
|
package/src/cli.ts
CHANGED
|
@@ -45,7 +45,7 @@ import { argParserUtil } from './utilities/argParser.utility'
|
|
|
45
45
|
import WriterFactory from './writers/WriterFactory'
|
|
46
46
|
|
|
47
47
|
interface HealthOptions {
|
|
48
|
-
|
|
48
|
+
shouldRunOnSourceFiles?: boolean
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
export interface CliInterface extends MercuryEventEmitter<GlobalEventContract> {
|
|
@@ -153,7 +153,7 @@ export default class Cli implements CliInterface {
|
|
|
153
153
|
try {
|
|
154
154
|
const commandService = this.serviceFactory.Service(this.cwd, 'command')
|
|
155
155
|
const command =
|
|
156
|
-
options?.
|
|
156
|
+
options?.shouldRunOnSourceFiles === false
|
|
157
157
|
? 'yarn health'
|
|
158
158
|
: 'yarn health.local'
|
|
159
159
|
const results = await commandService.execute(command)
|
|
@@ -64,9 +64,6 @@ export default class NodeFeature<
|
|
|
64
64
|
this.ui.startLoading('Cleaning build...')
|
|
65
65
|
await this.Service('command').execute('yarn clean.build')
|
|
66
66
|
|
|
67
|
-
this.ui.startLoading('Applying lint rules to all files...')
|
|
68
|
-
await this.Service('command').execute('yarn fix.lint')
|
|
69
|
-
|
|
70
67
|
this.ui.startLoading('Rebuilding...')
|
|
71
68
|
await this.Service('command').execute('yarn build.dev')
|
|
72
69
|
|
|
@@ -31,7 +31,8 @@ export default class SyncAction extends AbstractAction<OptionsSchema> {
|
|
|
31
31
|
const builder = new StoreTemplateItemBuilder()
|
|
32
32
|
const templateItems = builder.buildTemplateItems(stores, destination)
|
|
33
33
|
|
|
34
|
-
|
|
34
|
+
const writer = this.Writer('store')
|
|
35
|
+
files = await writer.writeTypesAndMap(destination, {
|
|
35
36
|
stores: templateItems,
|
|
36
37
|
})
|
|
37
38
|
}
|
|
@@ -59,6 +59,18 @@ export default class StoreWriter extends AbstractWriter {
|
|
|
59
59
|
return results
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
+
public async writeTypesAndMap(
|
|
63
|
+
destination: string,
|
|
64
|
+
options: { stores: StoreTemplateItem[] }
|
|
65
|
+
) {
|
|
66
|
+
const [types, map] = await Promise.all([
|
|
67
|
+
this.writeTypes(destination, options),
|
|
68
|
+
this.writeMap(destination, options),
|
|
69
|
+
])
|
|
70
|
+
|
|
71
|
+
return [...types, ...map]
|
|
72
|
+
}
|
|
73
|
+
|
|
62
74
|
public async writeTypes(
|
|
63
75
|
destination: string,
|
|
64
76
|
options: { stores: StoreTemplateItem[] }
|
|
@@ -77,4 +89,22 @@ export default class StoreWriter extends AbstractWriter {
|
|
|
77
89
|
|
|
78
90
|
return files
|
|
79
91
|
}
|
|
92
|
+
|
|
93
|
+
public async writeMap(
|
|
94
|
+
destination: string,
|
|
95
|
+
options: { stores: StoreTemplateItem[] }
|
|
96
|
+
) {
|
|
97
|
+
const file = diskUtil.resolvePath(destination, 'stores.ts')
|
|
98
|
+
const mapContent = this.templates.stores(options)
|
|
99
|
+
|
|
100
|
+
const files = this.writeFileIfChangedMixinResults(
|
|
101
|
+
file,
|
|
102
|
+
mapContent,
|
|
103
|
+
'A reference to all your data stores for easy inclusion.'
|
|
104
|
+
)
|
|
105
|
+
|
|
106
|
+
await this.lint(file)
|
|
107
|
+
|
|
108
|
+
return files
|
|
109
|
+
}
|
|
80
110
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/__tests__/behavioral/CreatingADataStore.test.ts"],"names":["CreatingDataStoresTest","assert","isFunction","Action","execute","cli","checkHealth","isRunningLocally","health","isFalsy","skill","errors","isTruthy","store","isArray","stores","isLength","nameReadable","nameReadablePlural","namePascal","results","path","testUtil","assertFileByNameInGeneratedFiles","files","Service","check","isEqual","name","errorAssertUtil","assertError","storeContents","diskUtil","readFile","replace","writeFile","testFile","resolveTestPath","testContents","dest","resolvePath","isFalse","doesFileExist","getAbstractTestPath","CommandService","setMockResponse","code","storesFile","resolveHashSpruc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,iBAA/C;;AAIAF,2CAAeC,eAAf,CAA+B,YAA/B,EAA8C;AAC7CC,kBAAAA,IAAI,EAAE;AADuC,iBAA9C;;AAIMC,gBAAAA,UAVP,GAUoB,KAAKC,qBAAL,CAA2B,wBAA3B,CAVpB;;AAWChB,2CAASiB,UAAT,CAAoBF,UAApB;;AAXD;AAAA,uBAYO,KAAK5C,MAAL,CAAY,MAAZ,EAAoB,SAApB,EAA+BC,OAA/B,CAAuC,EAAvC,CAZP;;AAAA;AAaCH,6BAAOiD,MAAP,CAAclB,2BAASU,aAAT,CAAuBK,UAAvB,CAAd;;AAbD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,O;;;;;;;;;;WAgBA,+BAA6C;AAC5C,aAAO,KAAKP,WAAL,CAAiB,KAAjB,EAAwB,OAAxB,EAAiC,0BAAjC,CAAP;AACA;;;EA/IkDW,8B,8DAClB,Q","sourcesContent":["import { diskUtil } from '@sprucelabs/spruce-skill-utils'\nimport { test, assert } from '@sprucelabs/test'\nimport { errorAssertUtil } from '@sprucelabs/test-utils'\nimport '@sprucelabs/spruce-store-plugin'\nimport CommandService from '../../services/CommandService'\nimport AbstractSkillTest from '../../tests/AbstractSkillTest'\nimport testUtil from '../../tests/utilities/test.utility'\n\nexport default class CreatingDataStoresTest extends AbstractSkillTest {\n\tprotected static skillCacheKey = 'stores'\n\n\t@test()\n\tprotected static async hasCreateStoreAction() {\n\t\tassert.isFunction(this.Action('store', 'create').execute)\n\t}\n\n\t@test()\n\tprotected static async getsNoStoresBackFromHealthCheck() {\n\t\tconst health = await this.cli.checkHealth({ isRunningLocally: true })\n\n\t\tassert.isFalsy(health.skill.errors)\n\t\tassert.isTruthy(health.store)\n\t\tassert.isFalsy(health.store.errors)\n\t\tassert.isArray(health.store.stores)\n\t\tassert.isLength(health.store.stores, 0)\n\t}\n\n\t@test()\n\tprotected static async generatesValidStoreFile() {\n\t\tconst results = await this.Action('store', 'create').execute({\n\t\t\tnameReadable: 'Person',\n\t\t\tnameReadablePlural: 'People',\n\t\t\tnamePascal: 'Person',\n\t\t})\n\n\t\tassert.isFalsy(results.errors)\n\n\t\tconst path = testUtil.assertFileByNameInGeneratedFiles(\n\t\t\t'People.store.ts',\n\t\t\tresults.files\n\t\t)\n\n\t\tawait this.Service('typeChecker').check(path)\n\t}\n\n\t@test()\n\tprotected static async getsOneStoresBackFromHealthCheck() {\n\t\tconst health = await this.cli.checkHealth({ isRunningLocally: true })\n\t\tassert.isTruthy(health.store)\n\t\tassert.isFalsy(health.store.errors)\n\t\tassert.isLength(health.store.stores, 1)\n\t\tassert.isEqual(health.store.stores[0].name, 'People')\n\t}\n\n\t@test()\n\tprotected static async canGenerateASecondStoreFile() {\n\t\tconst results = await this.Action('store', 'create').execute({\n\t\t\tnameReadable: 'Bid',\n\t\t\tnameReadablePlural: 'Bids',\n\t\t\tnamePascal: 'Bid',\n\t\t})\n\n\t\tassert.isFalsy(results.errors)\n\n\t\tconst path = testUtil.assertFileByNameInGeneratedFiles(\n\t\t\t'Bids.store.ts',\n\t\t\tresults.files\n\t\t)\n\n\t\tawait this.Service('typeChecker').check(path)\n\t}\n\n\t@test()\n\tprotected static async getsSecondStoresBackFromHealthCheck() {\n\t\tconst health = await this.cli.checkHealth({ isRunningLocally: true })\n\n\t\tassert.isTruthy(health.store)\n\t\tassert.isFalsy(health.store.errors)\n\t\tassert.isLength(health.store.stores, 2)\n\t\tassert.isEqual(health.store.stores[0].name, 'Bids')\n\t\tassert.isEqual(health.store.stores[1].name, 'People')\n\t}\n\n\t@test()\n\tprotected static async errorsWhenGeneratingAStoreWithTheSameName() {\n\t\tconst results = await this.Action('store', 'create').execute({\n\t\t\tnameReadable: 'Bid',\n\t\t\tnameReadablePlural: 'Bids',\n\t\t\tnamePascal: 'Bid',\n\t\t})\n\n\t\tassert.isTruthy(results.errors)\n\t\terrorAssertUtil.assertError(results.errors[0], 'STORE_EXISTS')\n\t}\n\n\t@test()\n\tprotected static async storeFactoryAndStoresAreTyped() {\n\t\tconst results = await this.Action('store', 'create').execute({\n\t\t\tnameReadable: 'Product',\n\t\t\tnameReadablePlural: 'Products',\n\t\t\tnamePascal: 'Product',\n\t\t})\n\n\t\tconst path = testUtil.assertFileByNameInGeneratedFiles(\n\t\t\t'Products.store.ts',\n\t\t\tresults.files\n\t\t)\n\n\t\tconst storeContents = diskUtil\n\t\t\t.readFile(path)\n\t\t\t.replace(\n\t\t\t\t'type ProductsStoreOptions = UniversalStoreOptions',\n\t\t\t\t'type ProductsStoreOptions = UniversalStoreOptions & {hello: string}'\n\t\t\t)\n\n\t\tdiskUtil.writeFile(path, storeContents)\n\n\t\tconst testFile = this.resolveTestPath('store-test.ts.hbs')\n\t\tconst testContents = diskUtil.readFile(testFile)\n\n\t\tconst dest = this.resolvePath('src', 'test.ts')\n\t\tdiskUtil.writeFile(dest, testContents)\n\n\t\tawait this.Service('typeChecker').check(dest)\n\t}\n\n\t@test()\n\tprotected static async doesNotCreateAbstractTestFileBecauseTestIsNotInstalled() {\n\t\tassert.isFalse(\n\t\t\tdiskUtil.doesFileExist(CreatingDataStoresTest.getAbstractTestPath())\n\t\t)\n\t}\n\n\t@test()\n\tprotected static async upgradeRestoresDataStoreTypes() {\n\t\tCommandService.setMockResponse('yarn rebuild', {\n\t\t\tcode: 0,\n\t\t})\n\n\t\tCommandService.setMockResponse(/yarn add/gis, {\n\t\t\tcode: 0,\n\t\t})\n\n\t\tconst storesFile = this.resolveHashSprucePath('stores/stores.types.ts')\n\t\tdiskUtil.deleteFile(storesFile)\n\t\tawait this.Action('node', 'upgrade').execute({})\n\t\tassert.isTrue(diskUtil.doesFileExist(storesFile))\n\t}\n\n\tprivate static getAbstractTestPath(): string {\n\t\treturn this.resolvePath('src', 'tests', 'AbstractDataStoreTest.ts')\n\t}\n}\n"],"file":"CreatingADataStore.test.js"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/__tests__/behavioral/KeepingDataStoresInSync.test.ts"],"names":["KeepingDataStoresInSyncTest","badStoreDest","resolvePath","diskUtil","deleteFile","assert","isFunction","Action","execute","syncStores","results","isLength","files","writeFile","isArray","errors","errorAssertUtil","assertError","file","nameReadable","nameReadablePlural","namePascal","typesFile","testUtil","assertFileByNameInGeneratedFiles","Service","check","AbstractSkillTest"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;;;;;;;IAEqBA,2B,WAanB,iB,UAKA,iB,UAWA,iB,UAaA,iB;;;;;;;;;;;;;qGAvCD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;AAEC,qBAAKC,YAAL,GAAoB,KAAKC,WAAL,CAAiB,yBAAjB,CAApB;;AAFD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,O;;;;;;;;;;;sGAKA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;AAECC,2CAASC,UAAT,CAAoB,KAAKH,YAAzB;;AAFD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,O;;;;;;;;;;;yGAKA;AAAA;AAAA;AAAA;AAAA;AAECI,6BAAOC,UAAP,CAAkB,KAAKC,MAAL,CAAY,OAAZ,EAAqB,MAArB,EAA6BC,OAA/C;;AAFD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,O;;;;;;;;;;;+GAKA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAEuB,KAAKC,UAAL,EAFvB;;AAAA;AAEOC,gBAAAA,OAFP;;AAICL,6BAAOM,QAAP,CAAgBD,OAAO,CAACE,KAAxB,EAA+B,CAA/B;;AAJD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,O;;;;;;;;;;;sGAOA;AAAA;AAAA;AAAA;AAAA;AAAA,kDACQ,KAAKL,MAAL,CAAY,OAAZ,EAAqB,MAArB,EAA6BC,OAA7B,CAAqC,EAArC,CADR;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,O;;;;;;;;;;;+GAIA;AAAA;AAAA;AAAA;AAAA;AAAA;AAECL,2CAASU,SAAT,CAAmB,KAAKZ,YAAxB,EAAsC,4BAAtC;;AAFD;AAAA,uBAIuB,KAAKQ,UAAL,EAJvB;;AAAA;AAIOC,gBAAAA,OAJP;;AAKCL,6BAAOS,OAAP,CAAeJ,OAAO,CAACK,MAAvB;;AACAV,6BAAOM,QAAP,CAAgBD,OAAO,CAACK,MAAxB,EAAgC,CAAhC;;AAEAC,2CAAgBC,WAAhB,CAA4BP,OAAO,CAACK,MAAR,CAAe,CAAf,CAA5B,EAA+C,kBAA/C,EAAmE;AAClEG,kBAAAA,IAAI,EAAE;AAD4D,iBAAnE;;AARD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,O;;;;;;;;;;;kHAaA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAEO,KAAKX,MAAL,CAAY,OAAZ,EAAqB,QAArB,EAA+BC,OAA/B,CAAuC;AAC5CW,kBAAAA,YAAY,EAAE,KAD8B;AAE5CC,kBAAAA,kBAAkB,EAAE,MAFwB;AAG5CC,kBAAAA,UAAU,EAAE;AAHgC,iBAAvC,CAFP;;AAAA;AAAA;AAAA,uBAQuB,KAAKZ,UAAL,EARvB;;AAAA;AAQOC,gBAAAA,OARP;AAUOY,gBAAAA,SAVP,GAUmBC,kBAASC,gCAAT,CACjB,iBADiB,EAEjBd,OAAO,CAACE,KAFS,CAVnB;AAAA;AAAA,uBAeO,KAAKa,OAAL,CAAa,aAAb,EAA4BC,KAA5B,CAAkCJ,SAAlC,CAfP;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,O;;;;;;;;;;EA1CwDK,8B,8DACvB,Q","sourcesContent":["import { diskUtil } from '@sprucelabs/spruce-skill-utils'\nimport { test, assert } from '@sprucelabs/test'\nimport { errorAssertUtil } from '@sprucelabs/test-utils'\nimport AbstractSkillTest from '../../tests/AbstractSkillTest'\nimport testUtil from '../../tests/utilities/test.utility'\n\nexport default class KeepingDataStoresInSyncTest extends AbstractSkillTest {\n\tprotected static skillCacheKey = 'stores'\n\tprotected static badStoreDest: string\n\tprotected static async beforeAll() {\n\t\tawait super.beforeAll()\n\t\tthis.badStoreDest = this.resolvePath('src/stores/Bad.store.ts')\n\t}\n\n\tprotected static async beforeEach() {\n\t\tawait super.beforeEach()\n\t\tdiskUtil.deleteFile(this.badStoreDest)\n\t}\n\n\t@test()\n\tprotected static async hasSyncAction() {\n\t\tassert.isFunction(this.Action('store', 'sync').execute)\n\t}\n\n\t@test()\n\tprotected static async syncsNothingToStart() {\n\t\tconst results = await this.syncStores()\n\n\t\tassert.isLength(results.files, 0)\n\t}\n\n\tprivate static async syncStores() {\n\t\treturn this.Action('store', 'sync').execute({})\n\t}\n\n\t@test()\n\tprotected static async badFileReturnsError() {\n\t\tdiskUtil.writeFile(this.badStoreDest, 'throw new Error(\"Cheese!\")')\n\n\t\tconst results = await this.syncStores()\n\t\tassert.isArray(results.errors)\n\t\tassert.isLength(results.errors, 1)\n\n\t\terrorAssertUtil.assertError(results.errors[0], 'FAILED_TO_IMPORT', {\n\t\t\tfile: 'Bad.store.ts',\n\t\t})\n\t}\n\n\t@test()\n\tprotected static async generatesValidTypeFile() {\n\t\tawait this.Action('store', 'create').execute({\n\t\t\tnameReadable: 'Bid',\n\t\t\tnameReadablePlural: 'Bids',\n\t\t\tnamePascal: 'Bid',\n\t\t})\n\n\t\tconst results = await this.syncStores()\n\n\t\tconst typesFile = testUtil.assertFileByNameInGeneratedFiles(\n\t\t\t'stores.types.ts',\n\t\t\tresults.files\n\t\t)\n\n\t\tawait this.Service('typeChecker').check(typesFile)\n\t}\n}\n"],"file":"KeepingDataStoresInSync.test.js"}
|