@sprucelabs/spruce-cli 17.1.55 → 18.1.0
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 +12 -0
- package/build/__tests__/behavioral/EnablingAndDisablingCache.test.js +1 -1
- package/build/__tests__/behavioral/EnablingAndDisablingCache.test.js.map +1 -1
- package/build/__tests__/behavioral/RememberingUpgradeSelections.test.js +1 -1
- package/build/__tests__/behavioral/RememberingUpgradeSelections.test.js.map +1 -1
- package/build/__tests__/behavioral/SettingUpSchemasForModuleDistribution.test.js +4 -4
- package/build/__tests__/behavioral/SettingUpSchemasForModuleDistribution.test.js.map +1 -1
- package/build/__tests__/behavioral/WatchingSkillViews.test.js +3 -3
- package/build/__tests__/behavioral/WatchingSkillViews.test.js.map +1 -1
- package/build/__tests__/behavioral/errors/SettingUpErrors.test.js +1 -1
- package/build/__tests__/behavioral/errors/SettingUpErrors.test.js.map +1 -1
- package/build/__tests__/behavioral/events/CreatingAListener.test.d.ts +2 -0
- package/build/__tests__/behavioral/events/CreatingAListener.test.js +118 -59
- package/build/__tests__/behavioral/events/CreatingAListener.test.js.map +1 -1
- package/build/__tests__/behavioral/events/EverythingInstalledInstaller.d.ts +17 -0
- package/build/__tests__/behavioral/events/EverythingInstalledInstaller.js +137 -0
- package/build/__tests__/behavioral/events/EverythingInstalledInstaller.js.map +1 -0
- package/build/__tests__/behavioral/onboard/StartingOnboarding.test.js +46 -45
- package/build/__tests__/behavioral/onboard/StartingOnboarding.test.js.map +1 -1
- package/build/__tests__/behavioral/tests/CreatingATest.test.js +1 -1
- package/build/__tests__/behavioral/tests/CreatingATest.test.js.map +1 -1
- package/build/__tests__/behavioral/tests/SelectingAnAbstractTestClass.test.js +4 -4
- package/build/__tests__/behavioral/tests/SelectingAnAbstractTestClass.test.js.map +1 -1
- package/build/__tests__/behavioral/upgrading/UpdatingDependencies2.test.js +2 -2
- package/build/__tests__/behavioral/upgrading/UpdatingDependencies2.test.js.map +1 -1
- package/build/__tests__/behavioral/upgrading/UpgradingANodeModule.test.js +2 -2
- package/build/__tests__/behavioral/upgrading/UpgradingANodeModule.test.js.map +1 -1
- package/build/__tests__/behavioral/upgrading/UpgradingASkill5.test.js +2 -2
- package/build/__tests__/behavioral/upgrading/UpgradingASkill5.test.js.map +1 -1
- package/build/__tests__/behavioral/upgrading/UpgradingWithListeners.test.js +2 -2
- package/build/__tests__/behavioral/upgrading/UpgradingWithListeners.test.js.map +1 -1
- package/build/__tests__/behavioral/views/CreatingASkillView.test.js +1 -1
- package/build/__tests__/behavioral/views/CreatingASkillView.test.js.map +1 -1
- package/build/__tests__/behavioral/views/CreatingATheme.test.js +1 -1
- package/build/__tests__/behavioral/views/CreatingATheme.test.js.map +1 -1
- package/build/__tests__/behavioral/watchers/WatchingForChanges.test.d.ts +3 -3
- package/build/__tests__/behavioral/watchers/WatchingForChanges.test.js +153 -156
- package/build/__tests__/behavioral/watchers/WatchingForChanges.test.js.map +1 -1
- package/build/__tests__/implementation/ActionExecuter.test.js +2 -2
- package/build/__tests__/implementation/ActionExecuter.test.js.map +1 -1
- package/build/__tests__/implementation/ActionExecuter2.test.js +1 -1
- package/build/__tests__/implementation/ActionExecuter2.test.js.map +1 -1
- package/build/__tests__/implementation/ActionExecuter4.test.js +1 -1
- package/build/__tests__/implementation/ActionExecuter4.test.js.map +1 -1
- package/build/__tests__/implementation/FeatureInstaller.test.js +8 -4
- package/build/__tests__/implementation/FeatureInstaller.test.js.map +1 -1
- package/build/__tests__/implementation/GlobalEmitter.d.ts +1 -1
- package/build/__tests__/implementation/GlobalEmitter.js +9 -10
- package/build/__tests__/implementation/GlobalEmitter.js.map +1 -1
- package/build/__tests__/implementation/SettingUpANodeModule.test.js +1 -1
- package/build/__tests__/implementation/SettingUpANodeModule.test.js.map +1 -1
- package/build/__tests__/implementation/SkillStore.test.d.ts +3 -1
- package/build/__tests__/implementation/SkillStore.test.js +67 -50
- package/build/__tests__/implementation/SkillStore.test.js.map +1 -1
- package/build/__tests__/implementation/StoreFeature.test.js +1 -1
- package/build/__tests__/implementation/StoreFeature.test.js.map +1 -1
- package/build/cli.js +3 -3
- package/build/cli.js.map +1 -1
- package/build/features/AbstractAction.d.ts +2 -2
- package/build/features/AbstractAction.js.map +1 -1
- package/build/features/AbstractFeature.d.ts +22 -22
- package/build/features/AbstractFeature.js.map +1 -1
- package/build/features/ActionExecuter.d.ts +8 -8
- package/build/features/ActionExecuter.js.map +1 -1
- package/build/features/FeatureInstaller.d.ts +15 -2
- package/build/features/FeatureInstaller.js +36 -36
- package/build/features/FeatureInstaller.js.map +1 -1
- package/build/features/FeatureInstallerFactory.d.ts +12 -10
- package/build/features/FeatureInstallerFactory.js +2 -2
- package/build/features/FeatureInstallerFactory.js.map +1 -1
- package/build/features/OverrideActionDecorator.js +4 -5
- package/build/features/OverrideActionDecorator.js.map +1 -1
- package/build/features/event/actions/ListenAction.js.map +1 -1
- package/build/features/event/actions/SetRemoteAction.d.ts +1 -0
- package/build/features/event/actions/SetRemoteAction.js +2 -1
- package/build/features/event/actions/SetRemoteAction.js.map +1 -1
- package/build/features/event/actions/SyncListenersAction.js.map +1 -1
- package/build/features/node/NodeFeature.js.map +1 -1
- package/build/features/skill/SkillFeature.js.map +1 -1
- package/build/features/skill/stores/SkillStore.d.ts +4 -1
- package/build/features/skill/stores/SkillStore.js +127 -100
- package/build/features/skill/stores/SkillStore.js.map +1 -1
- package/build/features/watch/WatchFeature.js +1 -1
- package/build/features/watch/WatchFeature.js.map +1 -1
- package/build/interfaces/SpyInterface.d.ts +2 -0
- package/build/interfaces/SpyInterface.js +16 -4
- package/build/interfaces/SpyInterface.js.map +1 -1
- package/build/stores/AbstractStore.d.ts +9 -7
- package/build/stores/AbstractStore.js.map +1 -1
- package/build/stores/StoreFactory.d.ts +19 -13
- package/build/stores/StoreFactory.js +15 -13
- package/build/stores/StoreFactory.js.map +1 -1
- package/build/tests/AbstractCliTest.d.ts +9 -6
- package/build/tests/AbstractCliTest.js +53 -45
- package/build/tests/AbstractCliTest.js.map +1 -1
- package/build/tests/AbstractSchemaTest.js +18 -20
- package/build/tests/AbstractSchemaTest.js.map +1 -1
- package/build/utilities/action.utility.js +3 -1
- package/build/utilities/action.utility.js.map +1 -1
- package/node_modules/@typescript-eslint/parser/package.json +5 -5
- package/node_modules/@typescript-eslint/scope-manager/package.json +5 -5
- package/node_modules/@typescript-eslint/types/package.json +2 -2
- package/node_modules/@typescript-eslint/typescript-estree/package.json +5 -5
- package/node_modules/@typescript-eslint/visitor-keys/package.json +3 -3
- package/package.json +28 -86
- package/src/__tests__/behavioral/EnablingAndDisablingCache.test.ts +1 -1
- package/src/__tests__/behavioral/RememberingUpgradeSelections.test.ts +1 -1
- package/src/__tests__/behavioral/SettingUpSchemasForModuleDistribution.test.ts +4 -4
- package/src/__tests__/behavioral/WatchingSkillViews.test.ts +3 -3
- package/src/__tests__/behavioral/errors/SettingUpErrors.test.ts +1 -1
- package/src/__tests__/behavioral/events/CreatingAListener.test.ts +41 -14
- package/src/__tests__/behavioral/events/EverythingInstalledInstaller.ts +46 -0
- package/src/__tests__/behavioral/onboard/StartingOnboarding.test.ts +10 -5
- package/src/__tests__/behavioral/tests/CreatingATest.test.ts +1 -1
- package/src/__tests__/behavioral/tests/SelectingAnAbstractTestClass.test.ts +4 -4
- package/src/__tests__/behavioral/upgrading/UpdatingDependencies2.test.ts +2 -2
- package/src/__tests__/behavioral/upgrading/UpgradingANodeModule.test.ts +2 -2
- package/src/__tests__/behavioral/upgrading/UpgradingASkill5.test.ts +2 -2
- package/src/__tests__/behavioral/upgrading/UpgradingWithListeners.test.ts +2 -2
- package/src/__tests__/behavioral/views/CreatingASkillView.test.ts +1 -1
- package/src/__tests__/behavioral/views/CreatingATheme.test.ts +1 -1
- package/src/__tests__/behavioral/watchers/WatchingForChanges.test.ts +35 -35
- package/src/__tests__/implementation/ActionExecuter.test.ts +2 -2
- package/src/__tests__/implementation/ActionExecuter2.test.ts +1 -1
- package/src/__tests__/implementation/ActionExecuter4.test.ts +1 -1
- package/src/__tests__/implementation/FeatureInstaller.test.ts +8 -1
- package/src/__tests__/implementation/GlobalEmitter.ts +2 -4
- package/src/__tests__/implementation/SettingUpANodeModule.test.ts +1 -1
- package/src/__tests__/implementation/SkillStore.test.ts +23 -24
- package/src/__tests__/implementation/StoreFeature.test.ts +1 -1
- package/src/cli.ts +7 -3
- package/src/features/AbstractAction.ts +3 -3
- package/src/features/AbstractFeature.ts +26 -26
- package/src/features/ActionExecuter.ts +9 -9
- package/src/features/FeatureInstaller.ts +32 -12
- package/src/features/FeatureInstallerFactory.ts +17 -13
- package/src/features/OverrideActionDecorator.ts +2 -5
- package/src/features/event/actions/ListenAction.ts +1 -0
- package/src/features/event/actions/SetRemoteAction.ts +2 -1
- package/src/features/event/actions/SyncListenersAction.ts +0 -1
- package/src/features/node/NodeFeature.ts +3 -1
- package/src/features/skill/SkillFeature.ts +3 -3
- package/src/features/skill/stores/SkillStore.ts +18 -11
- package/src/features/watch/WatchFeature.ts +1 -1
- package/src/interfaces/SpyInterface.ts +10 -0
- package/src/stores/AbstractStore.ts +14 -8
- package/src/stores/StoreFactory.ts +56 -44
- package/src/tests/AbstractCliTest.ts +53 -45
- package/src/tests/AbstractSchemaTest.ts +1 -3
- package/src/utilities/action.utility.ts +3 -1
|
@@ -175,7 +175,7 @@ export default class SettingUpSchemasForModuleDistributionTest extends AbstractS
|
|
|
175
175
|
|
|
176
176
|
const schemas = schemaNames.map((name) => this[name])
|
|
177
177
|
|
|
178
|
-
await this.
|
|
178
|
+
await this.emitter.on('schema.did-fetch-schemas', async () => {
|
|
179
179
|
return {
|
|
180
180
|
schemas,
|
|
181
181
|
}
|
|
@@ -228,7 +228,7 @@ export default class SettingUpSchemasForModuleDistributionTest extends AbstractS
|
|
|
228
228
|
schemas.push(this[name])
|
|
229
229
|
}
|
|
230
230
|
|
|
231
|
-
await this.
|
|
231
|
+
await this.emitter.on('schema.did-fetch-schemas', async () => {
|
|
232
232
|
return {
|
|
233
233
|
schemas,
|
|
234
234
|
}
|
|
@@ -278,7 +278,7 @@ export default class SettingUpSchemasForModuleDistributionTest extends AbstractS
|
|
|
278
278
|
},
|
|
279
279
|
}
|
|
280
280
|
|
|
281
|
-
await this.
|
|
281
|
+
await this.emitter.on('schema.did-fetch-schemas', async () => {
|
|
282
282
|
return {
|
|
283
283
|
schemas: [mySchema],
|
|
284
284
|
}
|
|
@@ -443,7 +443,7 @@ export default class SettingUpSchemasForModuleDistributionTest extends AbstractS
|
|
|
443
443
|
},
|
|
444
444
|
}
|
|
445
445
|
|
|
446
|
-
await this.
|
|
446
|
+
await this.emitter.on('schema.did-fetch-schemas', async () => {
|
|
447
447
|
return {
|
|
448
448
|
schemas: [schema1, schema2],
|
|
449
449
|
}
|
|
@@ -17,7 +17,7 @@ export default class WatchingSkillViewsTest extends AbstractSkillTest {
|
|
|
17
17
|
|
|
18
18
|
protected static async beforeEach() {
|
|
19
19
|
await super.beforeEach()
|
|
20
|
-
this.
|
|
20
|
+
this.featureInstaller.isInstalled = async () => true
|
|
21
21
|
SettingsService.prototype.isMarkedAsInstalled = () => true
|
|
22
22
|
BootAction.prototype.execute = this.oldBootExecute
|
|
23
23
|
}
|
|
@@ -155,7 +155,7 @@ export default class WatchingSkillViewsTest extends AbstractSkillTest {
|
|
|
155
155
|
code: 0,
|
|
156
156
|
})
|
|
157
157
|
|
|
158
|
-
const watchFeature = this.
|
|
158
|
+
const watchFeature = this.featureInstaller.getFeature('watch')
|
|
159
159
|
let wasStarted = false
|
|
160
160
|
let wasStopped = false
|
|
161
161
|
|
|
@@ -234,7 +234,7 @@ export default class WatchingSkillViewsTest extends AbstractSkillTest {
|
|
|
234
234
|
}
|
|
235
235
|
|
|
236
236
|
private static async emitFileChangeEvent() {
|
|
237
|
-
const emitter = this.
|
|
237
|
+
const emitter = this.emitter
|
|
238
238
|
|
|
239
239
|
await emitter.emit('watcher.did-detect-change', {
|
|
240
240
|
changes: [
|
|
@@ -21,7 +21,7 @@ export default class SettingUpErrorTest extends AbstractErrorTest {
|
|
|
21
21
|
protected static async installsSchemasIfNotInstalled() {
|
|
22
22
|
await this.installErrorFeature('errors')
|
|
23
23
|
|
|
24
|
-
const installer = this.
|
|
24
|
+
const installer = this.featureInstaller
|
|
25
25
|
|
|
26
26
|
const isSchemaInstalled = await installer.isInstalled('schema')
|
|
27
27
|
assert.isTrue(isSchemaInstalled)
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
MercuryClientFactory,
|
|
3
|
+
MercuryTestClient,
|
|
4
|
+
} from '@sprucelabs/mercury-client'
|
|
2
5
|
import { coreEventContracts } from '@sprucelabs/mercury-core-events'
|
|
3
6
|
import { EventSignature, SpruceSchemas } from '@sprucelabs/mercury-types'
|
|
4
7
|
import { buildSchema } from '@sprucelabs/schema'
|
|
@@ -14,7 +17,7 @@ import {
|
|
|
14
17
|
versionUtil,
|
|
15
18
|
} from '@sprucelabs/spruce-skill-utils'
|
|
16
19
|
import { eventFaker } from '@sprucelabs/spruce-test-fixtures'
|
|
17
|
-
import { test, assert } from '@sprucelabs/test-utils'
|
|
20
|
+
import { test, assert, generateId } from '@sprucelabs/test-utils'
|
|
18
21
|
import { errorAssert } from '@sprucelabs/test-utils'
|
|
19
22
|
import ListenAction, {
|
|
20
23
|
CORE_EVENT_NAMESPACE,
|
|
@@ -66,13 +69,7 @@ export default class CreatingAListenerTest extends AbstractEventTest {
|
|
|
66
69
|
|
|
67
70
|
@test()
|
|
68
71
|
protected static async generatesMapFile() {
|
|
69
|
-
const
|
|
70
|
-
|
|
71
|
-
const match = testUtil.assertFileByNameInGeneratedFiles(
|
|
72
|
-
`listeners.ts`,
|
|
73
|
-
results.files
|
|
74
|
-
)
|
|
75
|
-
|
|
72
|
+
const match = await this.installEventsCreateListenerAndGetListenerMap()
|
|
76
73
|
await this.Service('typeChecker').check(match)
|
|
77
74
|
}
|
|
78
75
|
|
|
@@ -116,7 +113,6 @@ export default class CreatingAListenerTest extends AbstractEventTest {
|
|
|
116
113
|
assert.doesInclude(lastInvocation.options.label, 'namespace')
|
|
117
114
|
|
|
118
115
|
await this.ui.sendInput(MERCURY_API_NAMESPACE)
|
|
119
|
-
|
|
120
116
|
await this.waitForInput()
|
|
121
117
|
|
|
122
118
|
lastInvocation = this.ui.getLastInvocation()
|
|
@@ -128,12 +124,15 @@ export default class CreatingAListenerTest extends AbstractEventTest {
|
|
|
128
124
|
|
|
129
125
|
@test()
|
|
130
126
|
protected static async loadsContractsFilteringByDependencies() {
|
|
127
|
+
MercuryClientFactory.setIsTestMode(true)
|
|
128
|
+
MercuryTestClient.setShouldRequireLocalListeners(true)
|
|
129
|
+
|
|
131
130
|
let passedTarget: any
|
|
132
131
|
await this.fakeGetEventContracts((target) => {
|
|
133
132
|
passedTarget = target
|
|
134
133
|
})
|
|
135
134
|
|
|
136
|
-
const namespace =
|
|
135
|
+
const namespace = generateId()
|
|
137
136
|
await this.installAddDependencyExecuteAndWaitForInput(namespace)
|
|
138
137
|
|
|
139
138
|
assert.isEqualDeep(passedTarget, {
|
|
@@ -151,6 +150,7 @@ export default class CreatingAListenerTest extends AbstractEventTest {
|
|
|
151
150
|
) {
|
|
152
151
|
await eventFaker.on('get-event-contracts::v2020_12_25', ({ target }) => {
|
|
153
152
|
cb?.(target)
|
|
153
|
+
|
|
154
154
|
return {
|
|
155
155
|
contracts: results ?? [...(coreEventContracts as any)],
|
|
156
156
|
}
|
|
@@ -326,18 +326,35 @@ export default class CreatingAListenerTest extends AbstractEventTest {
|
|
|
326
326
|
await this.Service('typeChecker').check(listenerPath)
|
|
327
327
|
}
|
|
328
328
|
|
|
329
|
+
@test()
|
|
330
|
+
protected static async hasIsGlobalCheck() {
|
|
331
|
+
const match = await this.installEventsCreateListenerAndGetListenerMap()
|
|
332
|
+
const contents = diskUtil.readFile(match)
|
|
333
|
+
|
|
334
|
+
assert.doesInclude(
|
|
335
|
+
contents,
|
|
336
|
+
"isGlobal: require('../../listeners/skill/will-boot.v2020_01_01.listener').isGlobal,"
|
|
337
|
+
)
|
|
338
|
+
}
|
|
339
|
+
|
|
329
340
|
private static async installAddDependencyExecuteAndWaitForInput(
|
|
330
341
|
namespace: string
|
|
331
342
|
) {
|
|
332
343
|
await this.installEventFeature('events')
|
|
333
|
-
|
|
344
|
+
|
|
334
345
|
this.addDependency(namespace)
|
|
346
|
+
|
|
335
347
|
await this.executeAndWaitForInput()
|
|
336
348
|
return this.ui.getLastInvocation()
|
|
337
349
|
}
|
|
338
350
|
|
|
339
351
|
private static async executeAndWaitForInput() {
|
|
340
|
-
void this.listen.execute({})
|
|
352
|
+
void this.listen.execute({}).then((results) => {
|
|
353
|
+
if (results.errors) {
|
|
354
|
+
this.ui.setError(results.errors[0])
|
|
355
|
+
}
|
|
356
|
+
})
|
|
357
|
+
|
|
341
358
|
await this.waitForInput()
|
|
342
359
|
}
|
|
343
360
|
|
|
@@ -345,7 +362,7 @@ export default class CreatingAListenerTest extends AbstractEventTest {
|
|
|
345
362
|
const dependencies = this.Service('dependency')
|
|
346
363
|
dependencies.add({
|
|
347
364
|
id: namespace,
|
|
348
|
-
namespace
|
|
365
|
+
namespace,
|
|
349
366
|
})
|
|
350
367
|
}
|
|
351
368
|
|
|
@@ -412,4 +429,14 @@ export default class CreatingAListenerTest extends AbstractEventTest {
|
|
|
412
429
|
currentSkill,
|
|
413
430
|
}
|
|
414
431
|
}
|
|
432
|
+
|
|
433
|
+
private static async installEventsCreateListenerAndGetListenerMap() {
|
|
434
|
+
const { results } = await this.installEventsAndCreateListener()
|
|
435
|
+
|
|
436
|
+
const match = testUtil.assertFileByNameInGeneratedFiles(
|
|
437
|
+
`listeners.ts`,
|
|
438
|
+
results.files
|
|
439
|
+
)
|
|
440
|
+
return match
|
|
441
|
+
}
|
|
415
442
|
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { FeatureDependency } from '../../../features/AbstractFeature'
|
|
2
|
+
import FeatureInstaller from '../../../features/FeatureInstaller'
|
|
3
|
+
import {
|
|
4
|
+
FeatureCode,
|
|
5
|
+
FeatureInstallResponse,
|
|
6
|
+
FeatureMap,
|
|
7
|
+
} from '../../../features/features.types'
|
|
8
|
+
|
|
9
|
+
export default class EverythingInstalledInstaller implements FeatureInstaller {
|
|
10
|
+
private featureMap: Partial<FeatureMap> = {}
|
|
11
|
+
|
|
12
|
+
public mapFeature<C extends keyof FeatureMap>(
|
|
13
|
+
code: C,
|
|
14
|
+
feature: FeatureMap[C]
|
|
15
|
+
): void {
|
|
16
|
+
this.featureMap[code] = feature
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
public async install(): Promise<FeatureInstallResponse> {
|
|
20
|
+
return {}
|
|
21
|
+
}
|
|
22
|
+
public async getInstalledFeatures() {
|
|
23
|
+
return Object.values(this.featureMap)
|
|
24
|
+
}
|
|
25
|
+
public getFeatureDependencies(): FeatureDependency[] {
|
|
26
|
+
return []
|
|
27
|
+
}
|
|
28
|
+
public getAllCodes(): FeatureCode[] {
|
|
29
|
+
return Object.keys(this.featureMap) as FeatureCode[]
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
public async isInstalled(_code: keyof FeatureMap): Promise<boolean> {
|
|
33
|
+
return true
|
|
34
|
+
}
|
|
35
|
+
public markAsSkippedThisRun(_code: keyof FeatureMap): void {}
|
|
36
|
+
public markAsPermanentlySkipped(_code: keyof FeatureMap): void {}
|
|
37
|
+
public isMarkedAsSkipped(_code: keyof FeatureMap): boolean {
|
|
38
|
+
return false
|
|
39
|
+
}
|
|
40
|
+
public getFeature<C extends keyof FeatureMap>(code: C): FeatureMap[C] {
|
|
41
|
+
return this.featureMap[code]!
|
|
42
|
+
}
|
|
43
|
+
public async areInstalled(_codes: FeatureCode[]): Promise<boolean> {
|
|
44
|
+
return true
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { test, assert } from '@sprucelabs/test-utils'
|
|
2
2
|
import CliGlobalEmitter, { globalContract } from '../../../GlobalEmitter'
|
|
3
|
+
import CommandService from '../../../services/CommandService'
|
|
3
4
|
import AbstractCliTest from '../../../tests/AbstractCliTest'
|
|
4
5
|
|
|
5
|
-
class
|
|
6
|
+
class SpyEmitter extends CliGlobalEmitter {
|
|
6
7
|
public static TestEmitter() {
|
|
7
|
-
return new
|
|
8
|
+
return new SpyEmitter(globalContract)
|
|
8
9
|
}
|
|
9
10
|
|
|
10
11
|
public hasListeners(eventName: string) {
|
|
@@ -20,15 +21,19 @@ export default class StartingOnboardingTest extends AbstractCliTest {
|
|
|
20
21
|
|
|
21
22
|
@test()
|
|
22
23
|
protected static async addsCommandListeners() {
|
|
23
|
-
|
|
24
|
+
this.emitter = SpyEmitter.TestEmitter()
|
|
24
25
|
|
|
25
|
-
await this.Cli(
|
|
26
|
+
await this.Cli()
|
|
26
27
|
|
|
27
|
-
assert.isTrue(
|
|
28
|
+
assert.isTrue(
|
|
29
|
+
(this.emitter as SpyEmitter).hasListeners('feature.will-execute')
|
|
30
|
+
)
|
|
28
31
|
}
|
|
29
32
|
|
|
30
33
|
@test()
|
|
31
34
|
protected static async onboardingThroughSkillCreateThenShutsOff() {
|
|
35
|
+
CommandService.fakeCommand(/yarn/, { code: 0 })
|
|
36
|
+
|
|
32
37
|
const onboardAction = this.Action('onboard', 'onboard')
|
|
33
38
|
const onboardPromise = onboardAction.execute({})
|
|
34
39
|
|
|
@@ -15,7 +15,7 @@ export default class CreatingBehavioralTestsTest extends AbstractTestTest {
|
|
|
15
15
|
protected static async requiresInstallIfFeatureNotInstalled() {
|
|
16
16
|
await this.installTests('testsInNodeModule')
|
|
17
17
|
|
|
18
|
-
const testFeature = this.
|
|
18
|
+
const testFeature = this.featureInstaller.getFeature('test')
|
|
19
19
|
const candidates = await testFeature.buildParentClassCandidates()
|
|
20
20
|
|
|
21
21
|
assert.doesInclude(candidates, {
|
|
@@ -117,10 +117,10 @@ export default class SelectingAnAbstractTestClassTest extends AbstractTestTest {
|
|
|
117
117
|
|
|
118
118
|
await this.installTests()
|
|
119
119
|
|
|
120
|
-
const testFeature = this.
|
|
120
|
+
const testFeature = this.featureInstaller.getFeature('test')
|
|
121
121
|
|
|
122
122
|
for (const feat of featuresWithRegisteredTests) {
|
|
123
|
-
await this.
|
|
123
|
+
await this.featureInstaller.install({
|
|
124
124
|
features: [
|
|
125
125
|
{
|
|
126
126
|
//@ts-ignore
|
|
@@ -154,7 +154,7 @@ export default class SelectingAnAbstractTestClassTest extends AbstractTestTest {
|
|
|
154
154
|
|
|
155
155
|
assert.isTruthy(match)
|
|
156
156
|
|
|
157
|
-
let isInstalled = await this.
|
|
157
|
+
let isInstalled = await this.featureInstaller.isInstalled(
|
|
158
158
|
feat.featureCode as any
|
|
159
159
|
)
|
|
160
160
|
assert.isFalse(isInstalled)
|
|
@@ -163,7 +163,7 @@ export default class SelectingAnAbstractTestClassTest extends AbstractTestTest {
|
|
|
163
163
|
|
|
164
164
|
await promise
|
|
165
165
|
|
|
166
|
-
isInstalled = await this.
|
|
166
|
+
isInstalled = await this.featureInstaller.isInstalled(
|
|
167
167
|
feat.featureCode as any
|
|
168
168
|
)
|
|
169
169
|
assert.isTrue(isInstalled)
|
|
@@ -19,7 +19,7 @@ export default class UpdateDependencies2Test extends AbstractCliTest {
|
|
|
19
19
|
|
|
20
20
|
this.Service('pkg').set({ path: 'dependencies.axios', value: '0.0.1' })
|
|
21
21
|
|
|
22
|
-
const skill = this.
|
|
22
|
+
const skill = this.featureInstaller.getFeature('skill')
|
|
23
23
|
skill.packageDependencies.push({
|
|
24
24
|
name: 'axios',
|
|
25
25
|
version: '0.21.3',
|
|
@@ -61,7 +61,7 @@ export default class UpdateDependencies2Test extends AbstractCliTest {
|
|
|
61
61
|
await this.action.execute({})
|
|
62
62
|
|
|
63
63
|
const pkg = this.Service('pkg')
|
|
64
|
-
const features = await this.
|
|
64
|
+
const features = await this.featureInstaller.getInstalledFeatures()
|
|
65
65
|
|
|
66
66
|
for (const feature of features) {
|
|
67
67
|
const featureDependencies = feature.packageDependencies as NpmPackage[]
|
|
@@ -10,7 +10,7 @@ export default class UpgradingANodeModuleTest extends AbstractCliTest {
|
|
|
10
10
|
|
|
11
11
|
await this.FeatureFixture().installCachedFeatures('everythingInNode')
|
|
12
12
|
|
|
13
|
-
const featureInstaller = this.
|
|
13
|
+
const featureInstaller = this.featureInstaller
|
|
14
14
|
featureInstaller.markAsPermanentlySkipped('skill')
|
|
15
15
|
}
|
|
16
16
|
|
|
@@ -20,7 +20,7 @@ export default class UpgradingANodeModuleTest extends AbstractCliTest {
|
|
|
20
20
|
CommandService.fakeCommand(/yarn clean.build/gis, { code: 1 })
|
|
21
21
|
CommandService.fakeCommand(/yarn build.dev/gis, { code: 0 })
|
|
22
22
|
|
|
23
|
-
await this.
|
|
23
|
+
await this.emitter.on('feature.did-execute', () => {
|
|
24
24
|
return {
|
|
25
25
|
errors: undefined,
|
|
26
26
|
}
|
|
@@ -48,7 +48,7 @@ export default class UpgradingASkill5Test extends AbstractCliTest {
|
|
|
48
48
|
})
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
const emitter = this.
|
|
51
|
+
const emitter = this.emitter
|
|
52
52
|
|
|
53
53
|
let wasHit = false
|
|
54
54
|
|
|
@@ -116,7 +116,7 @@ export default class UpgradingASkill5Test extends AbstractCliTest {
|
|
|
116
116
|
const settings = this.Settings()
|
|
117
117
|
settings.setListenerCache({ shouldBeDeleted: true })
|
|
118
118
|
|
|
119
|
-
const emitter = this.
|
|
119
|
+
const emitter = this.emitter
|
|
120
120
|
void emitter.on('feature.will-execute', () => {
|
|
121
121
|
throw new Error('Stop!')
|
|
122
122
|
})
|
|
@@ -30,7 +30,7 @@ export default class UpgradingWithListeners extends AbstractCliTest {
|
|
|
30
30
|
|
|
31
31
|
let wasHit = false
|
|
32
32
|
|
|
33
|
-
await this.
|
|
33
|
+
await this.emitter.on(
|
|
34
34
|
'feature.will-execute',
|
|
35
35
|
async ({ featureCode, actionCode }) => {
|
|
36
36
|
if (featureCode === 'event' && actionCode === 'sync.listeners') {
|
|
@@ -39,7 +39,7 @@ export default class UpgradingWithListeners extends AbstractCliTest {
|
|
|
39
39
|
}
|
|
40
40
|
)
|
|
41
41
|
|
|
42
|
-
const results = await this.
|
|
42
|
+
const results = await this.emitter.emit('feature.did-execute', {
|
|
43
43
|
featureCode: 'node',
|
|
44
44
|
actionCode,
|
|
45
45
|
results: {},
|
|
@@ -24,7 +24,7 @@ export default class CreatingASkillViewTest extends AbstractSkillTest {
|
|
|
24
24
|
|
|
25
25
|
@test()
|
|
26
26
|
protected static async viewFieatureHasExpectedDependencies() {
|
|
27
|
-
const features = await this.
|
|
27
|
+
const features = await this.featureInstaller
|
|
28
28
|
const view = features.getFeature('view')
|
|
29
29
|
assert.isEqualDeep(view.dependencies, [
|
|
30
30
|
{
|
|
@@ -51,7 +51,7 @@ export default class CreatingAThemeTest extends AbstractSkillTest {
|
|
|
51
51
|
|
|
52
52
|
@test()
|
|
53
53
|
protected static async doesNotSyncEventsIfAlreadySynced() {
|
|
54
|
-
const emitter = this.
|
|
54
|
+
const emitter = this.emitter
|
|
55
55
|
let hitCount = 0
|
|
56
56
|
|
|
57
57
|
diskUtil.deleteFile(this.getThemePath())
|
|
@@ -41,9 +41,8 @@ export default class WatchingForChangesTest extends AbstractCliTest {
|
|
|
41
41
|
shouldFire: boolean
|
|
42
42
|
) {
|
|
43
43
|
const cli = await this.installWatch()
|
|
44
|
-
const feature = cli.getFeature('watch')
|
|
45
44
|
|
|
46
|
-
|
|
45
|
+
const feature = cli.getFeature('watch')
|
|
47
46
|
|
|
48
47
|
let fireCount = 0
|
|
49
48
|
|
|
@@ -51,6 +50,8 @@ export default class WatchingForChangesTest extends AbstractCliTest {
|
|
|
51
50
|
fireCount++
|
|
52
51
|
})
|
|
53
52
|
|
|
53
|
+
await this.startWatching(feature)
|
|
54
|
+
|
|
54
55
|
diskUtil.writeFile(
|
|
55
56
|
this.resolvePath(path, 'test.ts'),
|
|
56
57
|
'console.log("hello world")'
|
|
@@ -110,39 +111,6 @@ export default class WatchingForChangesTest extends AbstractCliTest {
|
|
|
110
111
|
}
|
|
111
112
|
}
|
|
112
113
|
|
|
113
|
-
private static async stopWatching(feature: WatchFeature) {
|
|
114
|
-
await this.wait(3000)
|
|
115
|
-
await feature.stopWatching()
|
|
116
|
-
await this.wait(500)
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
private static async startWatching(feature: WatchFeature) {
|
|
120
|
-
void feature.startWatching({ delay: 2000, sourceDir: '.' })
|
|
121
|
-
await this.wait(500)
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
protected static async watchRunStop(
|
|
125
|
-
runner: () => Promise<GeneratedFileOrDir[]>
|
|
126
|
-
) {
|
|
127
|
-
const cli = await this.installWatch()
|
|
128
|
-
const feature = cli.getFeature('watch')
|
|
129
|
-
|
|
130
|
-
let payloadChanges: any = {}
|
|
131
|
-
void cli.on('watcher.did-detect-change', (payload) => {
|
|
132
|
-
payloadChanges = payload.changes
|
|
133
|
-
})
|
|
134
|
-
|
|
135
|
-
await this.startWatching(feature)
|
|
136
|
-
|
|
137
|
-
const expected: GeneratedFileOrDir[] = await runner()
|
|
138
|
-
|
|
139
|
-
await this.stopWatching(feature)
|
|
140
|
-
|
|
141
|
-
for (const e of expected) {
|
|
142
|
-
assert.doesInclude(payloadChanges, e)
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
|
|
146
114
|
@test()
|
|
147
115
|
protected static async canTrackAddingDir() {
|
|
148
116
|
await this.watchRunStop(async () => {
|
|
@@ -238,6 +206,38 @@ export default class WatchingForChangesTest extends AbstractCliTest {
|
|
|
238
206
|
})
|
|
239
207
|
}
|
|
240
208
|
|
|
209
|
+
private static async stopWatching(feature: WatchFeature) {
|
|
210
|
+
await this.wait(3000)
|
|
211
|
+
await feature.stopWatching()
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
private static async startWatching(feature: WatchFeature) {
|
|
215
|
+
void feature.startWatching({ delay: 200, sourceDir: '.' })
|
|
216
|
+
await this.wait(1000)
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
protected static async watchRunStop(
|
|
220
|
+
runner: () => Promise<GeneratedFileOrDir[]>
|
|
221
|
+
) {
|
|
222
|
+
const cli = await this.installWatch()
|
|
223
|
+
const feature = cli.getFeature('watch')
|
|
224
|
+
|
|
225
|
+
let payloadChanges: any = {}
|
|
226
|
+
void cli.on('watcher.did-detect-change', (payload) => {
|
|
227
|
+
payloadChanges = payload.changes
|
|
228
|
+
})
|
|
229
|
+
|
|
230
|
+
await this.startWatching(feature)
|
|
231
|
+
|
|
232
|
+
const expected: GeneratedFileOrDir[] = await runner()
|
|
233
|
+
|
|
234
|
+
await this.stopWatching(feature)
|
|
235
|
+
|
|
236
|
+
for (const e of expected) {
|
|
237
|
+
assert.doesInclude(payloadChanges, e)
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
|
|
241
241
|
private static async installWatch() {
|
|
242
242
|
const fixture = this.FeatureFixture()
|
|
243
243
|
const cli = await fixture.installFeatures([{ code: 'watch' }])
|
|
@@ -29,7 +29,7 @@ export default class FeatureCommandExecuterTest extends AbstractSchemaTest {
|
|
|
29
29
|
|
|
30
30
|
await this.wait(100)
|
|
31
31
|
|
|
32
|
-
const installer = this.
|
|
32
|
+
const installer = this.featureInstaller
|
|
33
33
|
let isInstalled = await installer.isInstalled('schema')
|
|
34
34
|
|
|
35
35
|
assert.isFalse(isInstalled)
|
|
@@ -98,7 +98,7 @@ export default class FeatureCommandExecuterTest extends AbstractSchemaTest {
|
|
|
98
98
|
},
|
|
99
99
|
})
|
|
100
100
|
|
|
101
|
-
const installer = this.
|
|
101
|
+
const installer = this.featureInstaller
|
|
102
102
|
const isInstalled = await installer.isInstalled('schema')
|
|
103
103
|
|
|
104
104
|
assert.isTrue(isInstalled)
|
|
@@ -44,7 +44,7 @@ export default class FeatureCommandExecuterContTest extends AbstractSchemaTest {
|
|
|
44
44
|
let willExecuteHitCount = 0
|
|
45
45
|
let didExecuteHitCount = 0
|
|
46
46
|
|
|
47
|
-
const emitter = this.
|
|
47
|
+
const emitter = this.emitter
|
|
48
48
|
|
|
49
49
|
void emitter.on('feature.will-execute', (payload) => {
|
|
50
50
|
emittedWillEvent = true
|
|
@@ -23,7 +23,7 @@ export default class ActionExecuter4Test extends AbstractCliTest {
|
|
|
23
23
|
msg: string,
|
|
24
24
|
willDid: 'will' | 'did' = 'will'
|
|
25
25
|
) {
|
|
26
|
-
await this.
|
|
26
|
+
await this.emitter.on(`feature.${willDid}-execute`, () => {
|
|
27
27
|
throw new Error(msg)
|
|
28
28
|
})
|
|
29
29
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { test, assert } from '@sprucelabs/test-utils'
|
|
2
2
|
import FeatureInstaller from '../../features/FeatureInstaller'
|
|
3
|
+
import CommandService from '../../services/CommandService'
|
|
3
4
|
import AbstractCliTest from '../../tests/AbstractCliTest'
|
|
4
5
|
|
|
5
6
|
export default class FeatureInstallerTest extends AbstractCliTest {
|
|
@@ -7,7 +8,7 @@ export default class FeatureInstallerTest extends AbstractCliTest {
|
|
|
7
8
|
|
|
8
9
|
protected static async beforeEach() {
|
|
9
10
|
await super.beforeEach()
|
|
10
|
-
this.installer = this.
|
|
11
|
+
this.installer = this.featureInstaller
|
|
11
12
|
}
|
|
12
13
|
|
|
13
14
|
@test()
|
|
@@ -27,11 +28,17 @@ export default class FeatureInstallerTest extends AbstractCliTest {
|
|
|
27
28
|
|
|
28
29
|
@test()
|
|
29
30
|
protected static async afterPackageInstallIsCalledOncePerFeature() {
|
|
31
|
+
CommandService.fakeCommand(/yarn/, {
|
|
32
|
+
code: 0,
|
|
33
|
+
})
|
|
34
|
+
|
|
30
35
|
let hitCount = 0
|
|
36
|
+
|
|
31
37
|
//@ts-ignore
|
|
32
38
|
this.installer.featureMap.schema.afterPackageInstall = () => {
|
|
33
39
|
hitCount++
|
|
34
40
|
}
|
|
41
|
+
|
|
35
42
|
await this.installer.install({
|
|
36
43
|
features: [
|
|
37
44
|
{
|
|
@@ -3,10 +3,8 @@ import AbstractCliTest from '../../tests/AbstractCliTest'
|
|
|
3
3
|
|
|
4
4
|
export default class GlobalEmitterTest extends AbstractCliTest {
|
|
5
5
|
@test()
|
|
6
|
-
protected static async
|
|
7
|
-
const emitter = this.getEmitter()
|
|
8
|
-
|
|
6
|
+
protected static async globalEmitterEmitsEquentally() {
|
|
9
7
|
//@ts-ignore
|
|
10
|
-
assert.isTrue(emitter.shouldEmitSequentally)
|
|
8
|
+
assert.isTrue(this.emitter.shouldEmitSequentally)
|
|
11
9
|
}
|
|
12
10
|
}
|
|
@@ -23,7 +23,7 @@ export default class SettingUpANodeModuleTest extends AbstractCliTest {
|
|
|
23
23
|
|
|
24
24
|
@test()
|
|
25
25
|
protected static async canTellIfNotInstalled() {
|
|
26
|
-
const installer = this.
|
|
26
|
+
const installer = this.featureInstaller
|
|
27
27
|
const isInstalled = await installer.isInstalled('node')
|
|
28
28
|
assert.isFalse(isInstalled)
|
|
29
29
|
}
|