@sprucelabs/spruce-cli 14.28.4 → 14.28.8
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 +32 -0
- package/build/__tests__/behavioral/BootingWithBadFiles.test.d.ts +2 -0
- package/build/__tests__/behavioral/BootingWithBadFiles.test.js +84 -17
- 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} +87 -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} +2 -2
- package/build/__tests__/behavioral/{KeepingDataStoresInSync.test.js → stores/KeepingDataStoresInSync.test.js} +42 -42
- 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 +28 -28
- package/src/__tests__/behavioral/BootingWithBadFiles.test.ts +17 -2
- 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} +13 -6
- package/src/__tests__/behavioral/{KeepingDataStoresInSync.test.ts → stores/KeepingDataStoresInSync.test.ts} +6 -6
- 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
|
@@ -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,16 @@ 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
|
+
await this.Service('typeChecker').check(file)
|
|
51
|
+
}
|
|
52
|
+
|
|
46
53
|
@test()
|
|
47
54
|
protected static async getsOneStoresBackFromHealthCheck() {
|
|
48
|
-
const health = await this.cli.checkHealth({
|
|
55
|
+
const health = await this.cli.checkHealth({ shouldRunOnSourceFiles: true })
|
|
49
56
|
assert.isTruthy(health.store)
|
|
50
57
|
assert.isFalsy(health.store.errors)
|
|
51
58
|
assert.isLength(health.store.stores, 1)
|
|
@@ -72,7 +79,7 @@ export default class CreatingDataStoresTest extends AbstractSkillTest {
|
|
|
72
79
|
|
|
73
80
|
@test()
|
|
74
81
|
protected static async getsSecondStoresBackFromHealthCheck() {
|
|
75
|
-
const health = await this.cli.checkHealth({
|
|
82
|
+
const health = await this.cli.checkHealth({ shouldRunOnSourceFiles: true })
|
|
76
83
|
|
|
77
84
|
assert.isTruthy(health.store)
|
|
78
85
|
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'
|
|
@@ -29,10 +29,6 @@ export default class KeepingDataStoresInSyncTest extends AbstractSkillTest {
|
|
|
29
29
|
assert.isLength(results.files, 0)
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
private static async syncStores() {
|
|
33
|
-
return this.Action('store', 'sync').execute({})
|
|
34
|
-
}
|
|
35
|
-
|
|
36
32
|
@test()
|
|
37
33
|
protected static async badFileReturnsError() {
|
|
38
34
|
diskUtil.writeFile(this.badStoreDest, 'throw new Error("Cheese!")')
|
|
@@ -63,4 +59,8 @@ export default class KeepingDataStoresInSyncTest extends AbstractSkillTest {
|
|
|
63
59
|
|
|
64
60
|
await this.Service('typeChecker').check(typesFile)
|
|
65
61
|
}
|
|
62
|
+
|
|
63
|
+
private static async syncStores() {
|
|
64
|
+
return this.Action('store', 'sync').execute({})
|
|
65
|
+
}
|
|
66
66
|
}
|
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","resolveHashSprucePath","deleteFile","isTrue","AbstractSkillTest"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;IAEqBA,sB,WAGnB,iB,UAKA,iB,UAWA,iB,UAkBA,iB,UASA,iB,UAkBA,iB,UAWA,iB,UAYA,iB,UA+BA,iB,WAOA,iB;;;;;;;;;;;;;gHA1HD;AAAA;AAAA;AAAA;AAAA;AAECC,6BAAOC,UAAP,CAAkB,KAAKC,MAAL,CAAY,OAAZ,EAAqB,QAArB,EAA+BC,OAAjD;;AAFD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,O;;;;;;;;;;;2HAKA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAEsB,KAAKC,GAAL,CAASC,WAAT,CAAqB;AAAEC,kBAAAA,gBAAgB,EAAE;AAApB,iBAArB,CAFtB;;AAAA;AAEOC,gBAAAA,MAFP;;AAICP,6BAAOQ,OAAP,CAAeD,MAAM,CAACE,KAAP,CAAaC,MAA5B;;AACAV,6BAAOW,QAAP,CAAgBJ,MAAM,CAACK,KAAvB;;AACAZ,6BAAOQ,OAAP,CAAeD,MAAM,CAACK,KAAP,CAAaF,MAA5B;;AACAV,6BAAOa,OAAP,CAAeN,MAAM,CAACK,KAAP,CAAaE,MAA5B;;AACAd,6BAAOe,QAAP,CAAgBR,MAAM,CAACK,KAAP,CAAaE,MAA7B,EAAqC,CAArC;;AARD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,O;;;;;;;;;;;mHAWA;AAAA;AAAA;AAAA;AAAA;AAAA;AA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T,2BAASU,aAAT,CAAuB1C,sBAAsB,CAAC2C,mBAAvB,EAAvB,CADD;;AAFD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,O;;;;;;;;;;;yHAOA;AAAA;AAAA;AAAA;AAAA;AAAA;AAECC,2CAAeC,eAAf,CAA+B,cAA/B,EAA+C;AAC9CC,kBAAAA,IAAI,EAAE;AADwC,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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A,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"}
|