adapt-migrations 1.0.0 → 1.2.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/.eslintignore CHANGED
@@ -1 +1 @@
1
- node_modules
1
+ node_modules
package/.eslintrc.json CHANGED
@@ -1,14 +1,14 @@
1
- {
2
- "env": {
3
- "browser": false,
4
- "node": true,
5
- "commonjs": false,
6
- "es2020": true
7
- },
8
- "extends": [
9
- "standard"
10
- ],
11
- "parserOptions": {
12
- "ecmaVersion": 2022
13
- }
14
- }
1
+ {
2
+ "env": {
3
+ "browser": false,
4
+ "node": true,
5
+ "commonjs": false,
6
+ "es2020": true
7
+ },
8
+ "extends": [
9
+ "standard"
10
+ ],
11
+ "parserOptions": {
12
+ "ecmaVersion": 2022
13
+ }
14
+ }
package/README.md CHANGED
@@ -1,43 +1,106 @@
1
- # adapt-migrations
2
-
3
- ### Todos
4
- https://github.com/cgkineo/adapt-migrations/issues/1
5
-
6
- ### Commands API
7
- https://github.com/cgkineo/adapt-migrations/blob/master/api/commands.js
8
- * `load({ cwd, cachePath, scripts })` - loads all migration tasks
9
- * `capture({ cwd, content, fromPlugins })` - captures current plugins and content
10
- * `migrate({ cwd, toPlugins })` - migrates content from capture to new plugins
11
- * `test({ cwd })` - tests the migrations with dummy content
12
-
13
- ### Migration script API
14
- Functions:
15
- * `describe(description, describeFunction)` Describe a migration
16
- * `whereContent(description, contentFilterFunction)` Limit when the migration runs, return true/false/throw Error
17
- * `whereFromPlugin(description, fromPluginFilterFunction)` Limit when the migration runs, return true/false/throw Error
18
- * `whereToPlugin(description, toPluginFilterFunction)` Limit when the migration runs, return true/false/throw Error
19
- * `mutateContent(contentFunction)` Change content, return true/false/throw Error
20
- * `checkContent(contentFunction)` Check content, return true/false/throw Error
21
- * `throwError(description)` Throw an error
22
- * `testSuccessWhere({ fromPlugins, toPlugins, content })` Supply some tests content which should end in success
23
- * `testStopWhere({ fromPlugins, toPlugins, content })` Supply some tests content which should end prematurely
24
- * `testErrorWhere({ fromPlugins, toPlugins, content })` Supply some tests content which will trigger an error
25
-
26
- Arguments:
27
- * `describeFunction = () => {}` Function body has a collection of migration script functions
28
- * `contentFilterFunction = content => {}` Function body should return true/false/throw Error
29
- * `fromPluginFilterFunction = fromPlugins => {}` Function body should return true/false/throw Error
30
- * `toPluginFilterFunction = toPlugins => {}` Function body should return true/false/throw Error
31
- * `contentFunction = content => { }` Function body should mutate or check the content, returning true/false/throw Error
32
- * `fromPlugins = [{ name: 'quickNav , version: '1.0.0' }]` Test data describing the original plugins
33
- * `toPlugins = [{ name: 'pageNav , version: '1.0.0' }]` Test data describing the destination plugins
34
- * `content = [{ _id: 'c-05, ... }]` Test content for the course content
35
-
36
- ### Grunt Commands
37
- ```sh
38
- grunt migration:capture # captures current plugins and content
39
- # do plugin/fw updates
40
- grunt migration:migrate # migrates content from capture to new plugins
41
- grunt migration:test # tests the migrations with dummy content
42
- grunt migration:test --file=adapt-contrib-text/migrations/text.js # tests the migrations with dummy content
43
- ```
1
+ # adapt-migrations
2
+
3
+ ### Todos
4
+ https://github.com/cgkineo/adapt-migrations/issues/1
5
+
6
+ ### Commands API
7
+ https://github.com/cgkineo/adapt-migrations/blob/master/api/commands.js
8
+ * `load({ cwd, cachePath, scripts })` - loads all migration tasks
9
+ * `capture({ cwd, content, fromPlugins })` - captures current plugins and content
10
+ * `migrate({ cwd, toPlugins })` - migrates content from capture to new plugins
11
+ * `test({ cwd })` - tests the migrations with dummy content
12
+
13
+ ### Migration script API
14
+ Functions:
15
+ * `describe(description, describeFunction)` Describe a migration
16
+ * `whereContent(description, contentFilterFunction)` Limit when the migration runs, return true/false/throw Error
17
+ * `whereFromPlugin(description, fromPluginFilterFunction)` Limit when the migration runs, return true/false/throw Error
18
+ * `whereToPlugin(description, toPluginFilterFunction)` Limit when the migration runs, return true/false/throw Error
19
+ * `mutateContent(contentFunction)` Change content, return true/false/throw Error
20
+ * `checkContent(contentFunction)` Check content, return true/false/throw Error
21
+ * `addPlugin(description, pluginConfig)` Add a plugin
22
+ * `updatePlugin(description, pluginConfig)` Update a plugin
23
+ * `removePlugin(description, pluginConfig)` Remove a plugin
24
+ * `throwError(description)` Throw an error
25
+ * `testSuccessWhere({ fromPlugins, toPlugins, content })` Supply some tests content which should end in success
26
+ * `testStopWhere({ fromPlugins, toPlugins, content })` Supply some tests content which should end prematurely
27
+ * `testErrorWhere({ fromPlugins, toPlugins, content })` Supply some tests content which will trigger an error
28
+
29
+ Arguments:
30
+ * `describeFunction = () => {}` Function body has a collection of migration script functions
31
+ * `contentFilterFunction = content => {}` Function body should return true/false/throw Error
32
+ * `fromPluginFilterFunction = fromPlugins => {}` Function body should return true/false/throw Error
33
+ * `toPluginFilterFunction = toPlugins => {}` Function body should return true/false/throw Error
34
+ * `contentFunction = content => { }` Function body should mutate or check the content, returning true/false/throw Error
35
+ * `fromPlugins = [{ name: 'quickNav , version: '1.0.0' }]` Test data describing the original plugins
36
+ * `toPlugins = [{ name: 'pageNav , version: '1.0.0' }]` Test data describing the destination plugins
37
+ * `pluginConfig = { name: 'pageNav , version: '1.0.0' }` Describes a plugin
38
+ * `content = [{ _id: 'c-05, ... }]` Test content for the course content
39
+
40
+ ### Grunt Commands
41
+ ```sh
42
+ grunt migration:capture # captures current plugins and content
43
+ # do plugin/fw updates
44
+ grunt migration:migrate # migrates content from capture to new plugins
45
+ grunt migration:test # tests the migrations with dummy content
46
+ grunt migration:test --file=adapt-contrib-text/migrations/text.js # tests the migrations with dummy content
47
+ ```
48
+
49
+ ### Description of how
50
+ The whole `describe` function block is executed as a normal function, from top to bottom, always. It does not return early.
51
+
52
+ When the `describe` function block is executed, we're effectively using javascript function calls (the step functions) to define a single migration script (task) and its steps and then that migration script (task, and its steps) is run in part, to ascertain if it is applicable (using the where section), or in full when it is applicable by running through every step.
53
+
54
+ The step functions (whereFromPlugins, mutateContent, etc) have two phases:
55
+
56
+ #### Step function phases
57
+ 1. Task definition phase: Adding themselves as steps inside a task for later execution
58
+ ```js
59
+ describe(description, async () => { // Make a task
60
+ // where/selection/applicability section
61
+ whereFromPlugin(description, version) // Define as step 1 in the task
62
+ whereContent(description, () => {}) // Define as step 2 in the task
63
+ // mutation section to make changes
64
+ mutateContent(async content => {}) // Define as step 3 in the task
65
+ // checking section to ensure changes, content is immutable
66
+ checkContent(async content => {}) // Define as step 4 in the task
67
+ // plugin progression section
68
+ addPlugin(description, { name, version }) // Define as step 5 in the task
69
+ updatePlugin(description, { name, version }) // Define as step 6 in the task
70
+ removePlugin(description, { name, version }) // Define as step 7 in the task
71
+ // testing data for grunt migration:test
72
+ testSuccessWhere({ fromPlugins, toPlugins, content })
73
+ testStopWhere({ fromPlugins, toPlugins, content })
74
+ testErrorWhere({ fromPlugins, toPlugins, content })
75
+ })
76
+ ```
77
+ 2. Execution phase: When used inside any other executing utility function block
78
+ ```js
79
+ describe(name, async () => {
80
+ mutateContent(name, async content => { // Execute the task step 1
81
+    if (whereFromPlugin(name, version)) { // Execute the function immediately
82
+      // the plugin version is matched
83
+    }
84
+  })
85
+ })
86
+ ```
87
+
88
+ It's these two phases which decouple the definition of and execution of migration scripts, whilst using the same block of javascript. This was the simplest form I could think of, without having too many rules or nesting but whilst also providing flexibility, imply an order and convey concise meaning in as few words as possible.
89
+
90
+ We define variables and steps in the definition phase of the migration script (task) for later execution. The describe function doesn't return early at `whereFromPlugins`, both because functions can't implicitly return early, and because the function is executed in a definition phase, where it's just adding a description of itself to a task for later use.
91
+
92
+ `whereFromPlugins` is a single step in a task, it will be executed multiple times as the migrations progress, this is to find out whether the task is applicable and whether the task should proceed through all of the steps until conclusion.
93
+
94
+ Tasks and steps have three results: success (true), stop (false) or error (throw Error). Using those return values and having some of the step functions marked up as "where" functions, we can selectively define and execute a variety of migrations scripts, for a variety of courses, with a fun array of predictable outcomes.
95
+
96
+ References:
97
+ Migration files are loaded: https://github.com/adaptlearning/adapt-migrations/blob/1b156d8dad82f370c974f630adb3d58eaa8517b8/lib/Task.js#L293-L296
98
+ Capturing the description and callback of each describe function call to make a new task: https://github.com/adaptlearning/adapt-migrations/blob/1b156d8dad82f370c974f630adb3d58eaa8517b8/api/describe.js#L11
99
+ Each of the describe blocks in the file are executed one by one: https://github.com/adaptlearning/adapt-migrations/blob/1b156d8dad82f370c974f630adb3d58eaa8517b8/lib/Task.js#L297-L302
100
+ The step functions are executed and deferred: https://github.com/adaptlearning/adapt-migrations/blob/1b156d8dad82f370c974f630adb3d58eaa8517b8/api/where.js#L4-L10
101
+ The step functions add themselves as tests or steps to the currently loading task: https://github.com/adaptlearning/adapt-migrations/blob/1b156d8dad82f370c974f630adb3d58eaa8517b8/lib/lifecycle.js#L23
102
+ After the loading phase, on each run of the migrations scripts, applicable tasks are selected for execution until no more tasks can be executed: https://github.com/adaptlearning/adapt-migrations/blob/1b156d8dad82f370c974f630adb3d58eaa8517b8/lib/Task.js#L320-L323
103
+ Tasks are applicable if all of their where steps come back success: https://github.com/adaptlearning/adapt-migrations/blob/1b156d8dad82f370c974f630adb3d58eaa8517b8/lib/Task.js#L184-L197
104
+ The applicable tasks are run: https://github.com/adaptlearning/adapt-migrations/blob/1b156d8dad82f370c974f630adb3d58eaa8517b8/lib/Task.js#L330-L336
105
+ The last success, stop or error step determines if the task failed or completed successfully or stopped because it wasn't applicable: https://github.com/adaptlearning/adapt-migrations/blob/1b156d8dad82f370c974f630adb3d58eaa8517b8/lib/lifecycle.js#L35-L41
106
+ Here is checkContent, freezing the data and dealing with its result: https://github.com/adaptlearning/adapt-migrations/blob/1b156d8dad82f370c974f630adb3d58eaa8517b8/api/data.js#L13-L24
package/api/commands.js CHANGED
@@ -1,33 +1,33 @@
1
- import Task from '../lib/Task.js'
2
-
3
- export async function load ({ cwd = process.cwd(), scripts = [], cachePath, logger } = {}) {
4
- return Task.load({
5
- cwd,
6
- scripts,
7
- cachePath,
8
- logger
9
- })
10
- }
11
-
12
- export async function capture ({ content, fromPlugins, logger }) {
13
- return {
14
- content,
15
- fromPlugins,
16
- logger
17
- }
18
- };
19
-
20
- export async function migrate ({ cwd = process.cwd(), journal, logger }) {
21
- return Task.runApplicable({
22
- cwd,
23
- journal,
24
- logger
25
- })
26
- }
27
-
28
- export async function test ({ cwd = process.cwd(), logger } = {}) {
29
- return Task.runTests({
30
- cwd,
31
- logger
32
- })
33
- }
1
+ import Task from '../lib/Task.js'
2
+
3
+ export async function load ({ cwd = process.cwd(), scripts = [], cachePath, logger } = {}) {
4
+ return Task.load({
5
+ cwd,
6
+ scripts,
7
+ cachePath,
8
+ logger
9
+ })
10
+ }
11
+
12
+ export async function capture ({ content, fromPlugins, logger }) {
13
+ return {
14
+ content,
15
+ fromPlugins,
16
+ logger
17
+ }
18
+ };
19
+
20
+ export async function migrate ({ cwd = process.cwd(), journal, logger }) {
21
+ return Task.runApplicable({
22
+ cwd,
23
+ journal,
24
+ logger
25
+ })
26
+ }
27
+
28
+ export async function test ({ cwd = process.cwd(), logger } = {}) {
29
+ return Task.runTests({
30
+ cwd,
31
+ logger
32
+ })
33
+ }
package/api/data.js CHANGED
@@ -1,26 +1,26 @@
1
- import { deferOrRunWrap, successStopOrErrorWrap } from '../lib/lifecycle.js'
2
-
3
- export function mutateContent (description, callback) {
4
- return deferOrRunWrap(function (context) {
5
- return successStopOrErrorWrap('mutateContent', description, async () => {
6
- return callback(context.content)
7
- })
8
- }, { description, type: 'action' })
9
- };
10
-
11
- export function checkContent (description, callback) {
12
- return deferOrRunWrap(function (context) {
13
- return successStopOrErrorWrap('checkContent', description, async () => {
14
- context.journal.freeze()
15
- let result
16
- try {
17
- result = await callback(context.content)
18
- } catch (err) {
19
- context.journal.unfreeze()
20
- throw err
21
- }
22
- context.journal.unfreeze()
23
- return result
24
- })
25
- }, { description, type: 'action' })
26
- };
1
+ import { deferOrRunWrap, successStopOrErrorWrap } from '../lib/lifecycle.js'
2
+
3
+ export function mutateContent (description, callback) {
4
+ return deferOrRunWrap(function (context) {
5
+ return successStopOrErrorWrap('mutateContent', description, async () => {
6
+ return callback(context.content)
7
+ })
8
+ }, { description, type: 'action' })
9
+ };
10
+
11
+ export function checkContent (description, callback) {
12
+ return deferOrRunWrap(function (context) {
13
+ return successStopOrErrorWrap('checkContent', description, async () => {
14
+ context.journal.freeze()
15
+ let result
16
+ try {
17
+ result = await callback(context.content)
18
+ } catch (err) {
19
+ context.journal.unfreeze()
20
+ throw err
21
+ }
22
+ context.journal.unfreeze()
23
+ return result
24
+ })
25
+ }, { description, type: 'action' })
26
+ };
package/api/describe.js CHANGED
@@ -1,12 +1,12 @@
1
- import Task from '../lib/Task.js'
2
- import Logger from './../lib/Logger.js'
3
-
4
- export function describe (description, load) {
5
- const logger = Logger.getInstance();
6
- logger.info(`Describe -- ${description} -- Registered`)
7
- if (Task.current) {
8
- logger.error(`Describe -- Cannot nest describe statements -- ${description}`)
9
- }
10
- // eslint-disable-next-line no-new
11
- new Task({ description, load })
12
- };
1
+ import Task from '../lib/Task.js'
2
+ import Logger from './../lib/Logger.js'
3
+
4
+ export function describe (description, load) {
5
+ const logger = Logger.getInstance();
6
+ logger.info(`Describe -- ${description} -- Registered`)
7
+ if (Task.current) {
8
+ logger.error(`Describe -- Cannot nest describe statements -- ${description}`)
9
+ }
10
+ // eslint-disable-next-line no-new
11
+ new Task({ description, load })
12
+ };
package/api/errors.js CHANGED
@@ -1,28 +1,28 @@
1
- import { deferOrRunWrap, successStopOrErrorWrap } from '../lib/lifecycle.js'
2
- import Logger from './../lib/Logger.js'
3
-
4
- const logger = Logger.getInstance();
5
-
6
- export function throwError (description) {
7
- let error = description
8
- if (!(description instanceof Error)) {
9
- logger.error(`Errors -- ${description}`)
10
- error = new Error(description)
11
- } else {
12
- description = description.message
13
- }
14
- return deferOrRunWrap(function (context) {
15
- return successStopOrErrorWrap('throwError', description, async () => {
16
- throw error
17
- })
18
- }, { type: 'action' })
19
- }
20
-
21
- export function ifErroredAsk (config) {
22
- return deferOrRunWrap(function (context) {
23
- return successStopOrErrorWrap('isErroredAsk', config.question, async () => {
24
- if (!context.hasErrored) return true
25
- // Ask a question
26
- })
27
- }, { type: 'error' })
28
- };
1
+ import { deferOrRunWrap, successStopOrErrorWrap } from '../lib/lifecycle.js'
2
+ import Logger from './../lib/Logger.js'
3
+
4
+ const logger = Logger.getInstance();
5
+
6
+ export function throwError (description) {
7
+ let error = description
8
+ if (!(description instanceof Error)) {
9
+ logger.error(`Errors -- ${description}`)
10
+ error = new Error(description)
11
+ } else {
12
+ description = description.message
13
+ }
14
+ return deferOrRunWrap(function (context) {
15
+ return successStopOrErrorWrap('throwError', description, async () => {
16
+ throw error
17
+ })
18
+ }, { type: 'action' })
19
+ }
20
+
21
+ export function ifErroredAsk (config) {
22
+ return deferOrRunWrap(function (context) {
23
+ return successStopOrErrorWrap('isErroredAsk', config.question, async () => {
24
+ if (!context.hasErrored) return true
25
+ // Ask a question
26
+ })
27
+ }, { type: 'error' })
28
+ };
package/api/helpers.js ADDED
@@ -0,0 +1,17 @@
1
+ import Task from '../lib/Task.js'
2
+
3
+ function getContent() {
4
+ return Task.current.context.content;
5
+ }
6
+
7
+ export function getConfig () {
8
+ return getContent().find(({ _type, __path__ }) => _type === 'config' || __path__.endsWith('config.json'))
9
+ }
10
+
11
+ export function getCourse() {
12
+ return getContent().find(({ _type }) => _type === 'course');
13
+ }
14
+
15
+ export function getComponents(componentName) {
16
+ return getContent().filter(({ _component }) => _component === componentName);
17
+ }
package/api/plugins.js CHANGED
@@ -1,44 +1,47 @@
1
- import { deferOrRunWrap, successStopOrErrorWrap } from '../lib/lifecycle.js'
2
-
3
- export function removePlugin (description, config) {
4
- return deferOrRunWrap(function (context) {
5
- return successStopOrErrorWrap('removePlugin', description, async () => {
6
- if (!description || !config) throw new Error('removePlugin - incorrectly configured')
7
-
8
- context.fromPlugins = context.fromPlugins.filter(plugin => plugin.name !== config.name)
9
-
10
- return true
11
- })
12
- }, { description, type: 'action' })
13
- };
14
-
15
- export function addPlugin (description, config) {
16
- return deferOrRunWrap(function (context) {
17
- return successStopOrErrorWrap('addPlugin', description, async () => {
18
- if (!description || !config) throw new Error('addPlugin - incorrectly configured')
19
-
20
- const newPlugin = context.toPlugins.find(plugin => (plugin.name === config.name))
21
- if (!newPlugin) throw new Error(`addPlugin - ${config.name} not found`)
22
- context.fromPlugins.push(newPlugin)
23
-
24
- return true
25
- })
26
- }, { description, type: 'action' })
27
- };
28
-
29
- export function updatePlugin (description, config) {
30
- return deferOrRunWrap(function (context) {
31
- return successStopOrErrorWrap('updatePlugin', description, async () => {
32
- if (!description || !config) throw new Error('updatePlugin - incorrectly configured')
33
-
34
- context.fromPlugins.forEach(plugin => {
35
- if (plugin.name !== config.name) return
36
- plugin.version = config.version
37
- if (!config.framework) return
38
- plugin.framework = config.framework
39
- })
40
-
41
- return true
42
- })
43
- }, { description, type: 'action' })
44
- };
1
+ import { deferOrRunWrap, successStopOrErrorWrap } from '../lib/lifecycle.js'
2
+ import { valid } from 'semver'
3
+
4
+ export function removePlugin (description, config) {
5
+ return deferOrRunWrap(function (context) {
6
+ return successStopOrErrorWrap('removePlugin', description, async () => {
7
+ if (!description || !config) throw new Error('removePlugin - incorrectly configured')
8
+
9
+ context.fromPlugins = context.fromPlugins.filter(plugin => plugin.name !== config.name)
10
+
11
+ return true
12
+ })
13
+ }, { description, type: 'action' })
14
+ };
15
+
16
+ export function addPlugin (description, config) {
17
+ return deferOrRunWrap(function (context) {
18
+ return successStopOrErrorWrap('addPlugin', description, async () => {
19
+ if (!description || !config) throw new Error('addPlugin - incorrectly configured')
20
+ if (!valid(config.version)) throw new Error(`addPlugin - invalid version number ${config.version}`)
21
+
22
+ const newPlugin = context.toPlugins.find(plugin => (plugin.name === config.name))
23
+ if (!newPlugin) throw new Error(`addPlugin - ${config.name} not found`)
24
+ context.fromPlugins.push(newPlugin)
25
+
26
+ return true
27
+ })
28
+ }, { description, type: 'action' })
29
+ };
30
+
31
+ export function updatePlugin (description, config) {
32
+ return deferOrRunWrap(function (context) {
33
+ return successStopOrErrorWrap('updatePlugin', description, async () => {
34
+ if (!description || !config) throw new Error('updatePlugin - incorrectly configured')
35
+ if (!valid(config.version)) throw new Error(`updatePlugin - invalid version number ${config.version}`)
36
+
37
+ context.fromPlugins.forEach(plugin => {
38
+ if (plugin.name !== config.name) return
39
+ plugin.version = config.version
40
+ if (!config.framework) return
41
+ plugin.framework = config.framework
42
+ })
43
+
44
+ return true
45
+ })
46
+ }, { description, type: 'action' })
47
+ };
package/api/tests.js CHANGED
@@ -1,57 +1,57 @@
1
- import TaskTest from '../lib/TaskTest.js'
2
- import { deferOrRunWrap } from '../lib/lifecycle.js'
3
- import Logger from '../lib/Logger.js'
4
-
5
- const logger = Logger.getInstance();
6
-
7
- export function testSuccessWhere (description, {
8
- fromPlugins,
9
- toPlugins,
10
- content
11
- }) {
12
- return deferOrRunWrap(() => {
13
- logger.debug(`Tests -- testSuccessWhere ${description}`)
14
- return new TaskTest({
15
- description,
16
- shouldRun: true,
17
- fromPlugins,
18
- toPlugins,
19
- content
20
- })
21
- }, { type: 'test' })
22
- };
23
-
24
- export function testStopWhere (description, {
25
- fromPlugins,
26
- toPlugins,
27
- content
28
- }) {
29
- return deferOrRunWrap(() => {
30
- logger.debug(`Tests -- testStopWhere ${description}`)
31
- return new TaskTest({
32
- description,
33
- shouldStop: true,
34
- shouldRun: false,
35
- fromPlugins,
36
- toPlugins,
37
- content
38
- })
39
- }, { type: 'test' })
40
- };
41
-
42
- export function testErrorWhere (description, {
43
- fromPlugins,
44
- toPlugins,
45
- content
46
- }) {
47
- return deferOrRunWrap(() => {
48
- logger.debug(`Tests -- testErrorWhere ${description}`)
49
- return new TaskTest({
50
- description,
51
- shouldError: true,
52
- fromPlugins,
53
- toPlugins,
54
- content
55
- })
56
- }, { type: 'test' })
57
- };
1
+ import TaskTest from '../lib/TaskTest.js'
2
+ import { deferOrRunWrap } from '../lib/lifecycle.js'
3
+ import Logger from '../lib/Logger.js'
4
+
5
+ const logger = Logger.getInstance();
6
+
7
+ export function testSuccessWhere (description, {
8
+ fromPlugins,
9
+ toPlugins,
10
+ content
11
+ }) {
12
+ return deferOrRunWrap(() => {
13
+ logger.debug(`Tests -- testSuccessWhere ${description}`)
14
+ return new TaskTest({
15
+ description,
16
+ shouldRun: true,
17
+ fromPlugins,
18
+ toPlugins,
19
+ content
20
+ })
21
+ }, { type: 'test' })
22
+ };
23
+
24
+ export function testStopWhere (description, {
25
+ fromPlugins,
26
+ toPlugins,
27
+ content
28
+ }) {
29
+ return deferOrRunWrap(() => {
30
+ logger.debug(`Tests -- testStopWhere ${description}`)
31
+ return new TaskTest({
32
+ description,
33
+ shouldStop: true,
34
+ shouldRun: false,
35
+ fromPlugins,
36
+ toPlugins,
37
+ content
38
+ })
39
+ }, { type: 'test' })
40
+ };
41
+
42
+ export function testErrorWhere (description, {
43
+ fromPlugins,
44
+ toPlugins,
45
+ content
46
+ }) {
47
+ return deferOrRunWrap(() => {
48
+ logger.debug(`Tests -- testErrorWhere ${description}`)
49
+ return new TaskTest({
50
+ description,
51
+ shouldError: true,
52
+ fromPlugins,
53
+ toPlugins,
54
+ content
55
+ })
56
+ }, { type: 'test' })
57
+ };