reSolve Scripts
The @resolve-js/scripts package contains service scripts used to configure, build, and run reSolve applications. The package contains the following scripts:
Script | Description |
---|---|
build | Builds an application. |
start | Runs an application. |
watch | Runs an application in watch mode. (Watch application files for changes.) |
runTestcafe | Runs TestCafe tests. |
merge | Merges modules and application configurations into a single object. |
stop | Stops an application. |
reset | Resets an application's persistent storages and snapshots. |
importEventStore | Imports events from a file to an application's event store. |
exportEventStore | Exports events from an application's event store to a file. |
validateConfig | Validates a configuration object. |
The @resolve-js/scripts library also exports a defaultResolveConfig
object that contains default configuration settings. This object is merged with an application's configuration objects to receive a global configuration object:
// run.js
const resolveConfig = merge(defaultResolveConfig, appConfig, devConfig)
buildā
Builds an application.
Exampleā
import {
build,
...
} from '@resolve-js/scripts'
...
switch (launchMode) {
...
case 'build': {
const resolveConfig = merge(baseConfig, prodConfig)
await build(resolveConfig)
break
}
...
}
startā
Runs a built application.
Exampleā
import {
...
start,
...
} from '@resolve-js/scripts'
...
switch (launchMode) {
...
case 'start': {
await start(merge(baseConfig, prodConfig))
break
}
...
}
watchā
Runs an application in watch mode. (Watch application files for changes.)
Exampleā
import {
...
watch,
...
} from '@resolve-js/scripts'
...
switch (launchMode) {
...
case 'dev': {
const resolveConfig = merge(baseConfig, devConfig)
await watch(resolveConfig)
break
}
...
}
runTestcafeā
Runs TestCafe tests.
Exampleā
import {
...
runTestcafe,
...
} from '@resolve-js/scripts'
...
switch (launchMode) {
...
case 'test:e2e': {
const resolveConfig = merge(baseConfig, testFunctionalConfig)
await runTestcafe({
resolveConfig,
functionalTestsDir: 'test/functional',
browser: process.argv[3],
})
break
}
...
}
mergeā
Merges modules and application configs into a single object.
Exampleā
import {
...
merge,
...
} from '@resolve-js/scripts'
...
const resolveConfig = merge(defaultResolveConfig, appConfig, devConfig)
resetā
Resets an application's persistent storages and snapshots.
Exampleā
import {
...
reset,
...
} from '@resolve-js/scripts'
...
switch (launchMode) {
...
case 'reset': {
const resolveConfig = merge(baseConfig, devConfig)
await reset(resolveConfig, {
dropEventStore: true,
dropEventSubscriber: true,
dropReadModels: true,
dropSagas: true,
})
break
}
...
}
importEventStoreā
Imports events from a file to an application's event store.
Exampleā
import {
...
importEventStore,
...
} from '@resolve-js/scripts'
...
switch (launchMode) {
...
case 'import-event-store': {
const resolveConfig = merge(baseConfig, devConfig)
const importFile = process.argv[3]
await importEventStore(resolveConfig, { importFile })
break
}
...
}
exportEventStoreā
Exports events from an application's event store to a file.
Exampleā
import {
...
exportEventStore,
...
} from '@resolve-js/scripts'
...
switch (launchMode) {
...
case 'export-event-store': {
const resolveConfig = merge(baseConfig, devConfig)
const exportFile = process.argv[3]
await exportEventStore(resolveConfig, { exportFile })
break
}
...
}
validateConfigā
Validates a configuration object.
Exampleā
import {
...
validateConfig,
...
} from '@resolve-js/scripts'
...
validateConfig(config)