codeceptjs 4.0.0-beta.4 → 4.0.0-beta.6.esm-aria
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/README.md +89 -119
- package/bin/codecept.js +53 -54
- package/docs/webapi/clearCookie.mustache +1 -1
- package/lib/actor.js +70 -102
- package/lib/ai.js +131 -121
- package/lib/assert/empty.js +11 -12
- package/lib/assert/equal.js +16 -21
- package/lib/assert/error.js +2 -2
- package/lib/assert/include.js +11 -15
- package/lib/assert/throws.js +3 -5
- package/lib/assert/truth.js +10 -7
- package/lib/assert.js +18 -18
- package/lib/codecept.js +112 -101
- package/lib/colorUtils.js +48 -50
- package/lib/command/check.js +206 -0
- package/lib/command/configMigrate.js +13 -14
- package/lib/command/definitions.js +24 -36
- package/lib/command/dryRun.js +16 -16
- package/lib/command/generate.js +38 -39
- package/lib/command/gherkin/init.js +36 -38
- package/lib/command/gherkin/snippets.js +76 -74
- package/lib/command/gherkin/steps.js +21 -18
- package/lib/command/info.js +49 -15
- package/lib/command/init.js +41 -37
- package/lib/command/interactive.js +22 -13
- package/lib/command/list.js +11 -10
- package/lib/command/run-multiple/chunk.js +50 -47
- package/lib/command/run-multiple/collection.js +5 -5
- package/lib/command/run-multiple/run.js +3 -3
- package/lib/command/run-multiple.js +27 -47
- package/lib/command/run-rerun.js +6 -7
- package/lib/command/run-workers.js +15 -66
- package/lib/command/run.js +8 -8
- package/lib/command/utils.js +22 -21
- package/lib/command/workers/runTests.js +131 -241
- package/lib/config.js +111 -49
- package/lib/container.js +589 -244
- package/lib/data/context.js +16 -18
- package/lib/data/dataScenarioConfig.js +9 -9
- package/lib/data/dataTableArgument.js +7 -7
- package/lib/data/table.js +6 -12
- package/lib/effects.js +307 -0
- package/lib/els.js +160 -0
- package/lib/event.js +24 -19
- package/lib/globals.js +141 -0
- package/lib/heal.js +89 -81
- package/lib/helper/AI.js +3 -2
- package/lib/helper/ApiDataFactory.js +19 -19
- package/lib/helper/Appium.js +47 -51
- package/lib/helper/FileSystem.js +35 -15
- package/lib/helper/GraphQL.js +1 -1
- package/lib/helper/GraphQLDataFactory.js +4 -4
- package/lib/helper/JSONResponse.js +72 -45
- package/lib/helper/Mochawesome.js +14 -11
- package/lib/helper/Playwright.js +832 -434
- package/lib/helper/Puppeteer.js +393 -292
- package/lib/helper/REST.js +32 -27
- package/lib/helper/WebDriver.js +320 -219
- package/lib/helper/errors/ConnectionRefused.js +6 -6
- package/lib/helper/errors/ElementAssertion.js +11 -16
- package/lib/helper/errors/ElementNotFound.js +5 -9
- package/lib/helper/errors/RemoteBrowserConnectionRefused.js +5 -5
- package/lib/helper/extras/Console.js +11 -11
- package/lib/helper/extras/PlaywrightLocator.js +110 -0
- package/lib/helper/extras/PlaywrightPropEngine.js +18 -18
- package/lib/helper/extras/PlaywrightRestartOpts.js +23 -23
- package/lib/helper/extras/Popup.js +22 -22
- package/lib/helper/extras/React.js +29 -30
- package/lib/helper/network/actions.js +33 -48
- package/lib/helper/network/utils.js +76 -83
- package/lib/helper/scripts/blurElement.js +6 -6
- package/lib/helper/scripts/focusElement.js +6 -6
- package/lib/helper/scripts/highlightElement.js +9 -9
- package/lib/helper/scripts/isElementClickable.js +34 -34
- package/lib/helper.js +2 -1
- package/lib/history.js +23 -20
- package/lib/hooks.js +10 -10
- package/lib/html.js +90 -100
- package/lib/index.js +48 -21
- package/lib/listener/config.js +8 -9
- package/lib/listener/emptyRun.js +54 -0
- package/lib/listener/exit.js +10 -12
- package/lib/listener/{retry.js → globalRetry.js} +10 -10
- package/lib/listener/globalTimeout.js +166 -0
- package/lib/listener/helpers.js +43 -24
- package/lib/listener/mocha.js +4 -5
- package/lib/listener/result.js +11 -0
- package/lib/listener/steps.js +26 -23
- package/lib/listener/store.js +20 -0
- package/lib/locator.js +213 -192
- package/lib/mocha/asyncWrapper.js +264 -0
- package/lib/mocha/bdd.js +167 -0
- package/lib/mocha/cli.js +341 -0
- package/lib/mocha/factory.js +160 -0
- package/lib/{interfaces → mocha}/featureConfig.js +33 -13
- package/lib/{interfaces → mocha}/gherkin.js +75 -45
- package/lib/mocha/hooks.js +121 -0
- package/lib/mocha/index.js +21 -0
- package/lib/mocha/inject.js +46 -0
- package/lib/{interfaces → mocha}/scenarioConfig.js +32 -8
- package/lib/mocha/suite.js +89 -0
- package/lib/mocha/test.js +178 -0
- package/lib/mocha/types.d.ts +42 -0
- package/lib/mocha/ui.js +229 -0
- package/lib/output.js +86 -64
- package/lib/parser.js +44 -44
- package/lib/pause.js +160 -139
- package/lib/plugin/analyze.js +403 -0
- package/lib/plugin/{autoLogin.js → auth.js} +137 -43
- package/lib/plugin/autoDelay.js +19 -15
- package/lib/plugin/coverage.js +22 -27
- package/lib/plugin/customLocator.js +5 -5
- package/lib/plugin/customReporter.js +53 -0
- package/lib/plugin/heal.js +49 -17
- package/lib/plugin/pageInfo.js +140 -0
- package/lib/plugin/pauseOnFail.js +4 -3
- package/lib/plugin/retryFailedStep.js +60 -19
- package/lib/plugin/screenshotOnFail.js +80 -83
- package/lib/plugin/stepByStepReport.js +70 -31
- package/lib/plugin/stepTimeout.js +7 -13
- package/lib/plugin/subtitles.js +10 -9
- package/lib/recorder.js +167 -126
- package/lib/rerun.js +94 -50
- package/lib/result.js +161 -0
- package/lib/secret.js +18 -17
- package/lib/session.js +95 -89
- package/lib/step/base.js +239 -0
- package/lib/step/comment.js +10 -0
- package/lib/step/config.js +50 -0
- package/lib/step/func.js +46 -0
- package/lib/step/helper.js +50 -0
- package/lib/step/meta.js +99 -0
- package/lib/step/record.js +74 -0
- package/lib/step/retry.js +11 -0
- package/lib/step/section.js +55 -0
- package/lib/step.js +18 -332
- package/lib/steps.js +54 -0
- package/lib/store.js +37 -5
- package/lib/template/heal.js +2 -11
- package/lib/timeout.js +60 -0
- package/lib/transform.js +8 -8
- package/lib/translation.js +32 -18
- package/lib/utils.js +354 -250
- package/lib/workerStorage.js +16 -16
- package/lib/workers.js +366 -282
- package/package.json +107 -95
- package/translations/de-DE.js +5 -4
- package/translations/fr-FR.js +5 -4
- package/translations/index.js +23 -9
- package/translations/it-IT.js +5 -4
- package/translations/ja-JP.js +5 -4
- package/translations/nl-NL.js +76 -0
- package/translations/pl-PL.js +5 -4
- package/translations/pt-BR.js +5 -4
- package/translations/ru-RU.js +5 -4
- package/translations/utils.js +18 -0
- package/translations/zh-CN.js +5 -4
- package/translations/zh-TW.js +5 -4
- package/typings/index.d.ts +177 -186
- package/typings/promiseBasedTypes.d.ts +3573 -5941
- package/typings/types.d.ts +4042 -6370
- package/lib/cli.js +0 -256
- package/lib/helper/ExpectHelper.js +0 -391
- package/lib/helper/Nightmare.js +0 -1504
- package/lib/helper/Protractor.js +0 -1863
- package/lib/helper/SoftExpectHelper.js +0 -381
- package/lib/helper/TestCafe.js +0 -1414
- package/lib/helper/clientscripts/nightmare.js +0 -213
- package/lib/helper/extras/PlaywrightReactVueLocator.js +0 -43
- package/lib/helper/testcafe/testControllerHolder.js +0 -42
- package/lib/helper/testcafe/testcafe-utils.js +0 -62
- package/lib/interfaces/bdd.js +0 -81
- package/lib/listener/artifacts.js +0 -19
- package/lib/listener/timeout.js +0 -109
- package/lib/mochaFactory.js +0 -113
- package/lib/plugin/allure.js +0 -15
- package/lib/plugin/commentStep.js +0 -136
- package/lib/plugin/debugErrors.js +0 -67
- package/lib/plugin/eachElement.js +0 -127
- package/lib/plugin/fakerTransform.js +0 -49
- package/lib/plugin/retryTo.js +0 -127
- package/lib/plugin/selenoid.js +0 -384
- package/lib/plugin/standardActingHelpers.js +0 -3
- package/lib/plugin/tryTo.js +0 -115
- package/lib/plugin/wdio.js +0 -249
- package/lib/scenario.js +0 -224
- package/lib/ui.js +0 -236
- package/lib/within.js +0 -70
package/lib/pause.js
CHANGED
|
@@ -1,59 +1,69 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
import colors from 'chalk'
|
|
2
|
+
import readline from 'readline'
|
|
3
|
+
import ora from 'ora-classic'
|
|
4
|
+
import debugModule from 'debug'
|
|
5
|
+
const debug = debugModule('codeceptjs:pause')
|
|
6
|
+
import container from './container.js'
|
|
7
|
+
import history from './history.js'
|
|
8
|
+
import store from './store.js'
|
|
9
|
+
import aiAssistant from './ai.js'
|
|
10
|
+
import recorder from './recorder.js'
|
|
11
|
+
import event from './event.js'
|
|
12
|
+
import output from './output.js'
|
|
13
|
+
import { methodsOfObject, searchWithFusejs } from './utils.js'
|
|
14
14
|
|
|
15
15
|
// npm install colors
|
|
16
|
-
let rl
|
|
17
|
-
let nextStep
|
|
18
|
-
let finish
|
|
19
|
-
let next
|
|
20
|
-
let registeredVariables = {}
|
|
16
|
+
let rl
|
|
17
|
+
let nextStep
|
|
18
|
+
let finish
|
|
19
|
+
let next
|
|
20
|
+
let registeredVariables = {}
|
|
21
21
|
/**
|
|
22
22
|
* Pauses test execution and starts interactive shell
|
|
23
23
|
* @param {Object<string, *>} [passedObject]
|
|
24
24
|
*/
|
|
25
25
|
const pause = function (passedObject = {}) {
|
|
26
|
-
if (store.dryRun) return
|
|
26
|
+
if (store.dryRun) return
|
|
27
27
|
|
|
28
|
-
next = false
|
|
28
|
+
next = false
|
|
29
29
|
// add listener to all next steps to provide next() functionality
|
|
30
30
|
event.dispatcher.on(event.step.after, () => {
|
|
31
31
|
recorder.add('Start next pause session', () => {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
32
|
+
// test already finished, nothing to pause
|
|
33
|
+
if (!store.currentTest) return
|
|
34
|
+
if (!next) return
|
|
35
|
+
return pauseSession()
|
|
36
|
+
})
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
event.dispatcher.on(event.test.finished, () => {
|
|
40
|
+
finish()
|
|
41
|
+
recorder.session.restore('pause')
|
|
42
|
+
rl.close()
|
|
43
|
+
history.save()
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
recorder.add('Start new session', () => pauseSession(passedObject))
|
|
47
|
+
}
|
|
38
48
|
|
|
39
49
|
function pauseSession(passedObject = {}) {
|
|
40
|
-
registeredVariables = passedObject
|
|
41
|
-
recorder.session.start('pause')
|
|
50
|
+
registeredVariables = passedObject
|
|
51
|
+
recorder.session.start('pause')
|
|
42
52
|
if (!next) {
|
|
43
|
-
let vars = Object.keys(registeredVariables).join(', ')
|
|
44
|
-
if (vars) vars = `(vars: ${vars})
|
|
53
|
+
let vars = Object.keys(registeredVariables).join(', ')
|
|
54
|
+
if (vars) vars = `(vars: ${vars})`
|
|
45
55
|
|
|
46
|
-
output.print(colors.yellow(' Interactive shell started'))
|
|
47
|
-
output.print(colors.yellow(' Use JavaScript syntax to try steps in action'))
|
|
48
|
-
output.print(colors.yellow(` - Press ${colors.bold('ENTER')} to run the next step`))
|
|
49
|
-
output.print(colors.yellow(` - Press ${colors.bold('TAB')} twice to see all available commands`))
|
|
50
|
-
output.print(colors.yellow(` - Type ${colors.bold('exit')} + Enter to exit the interactive shell`))
|
|
51
|
-
output.print(colors.yellow(` - Prefix ${colors.bold('=>')} to run js commands ${colors.bold(vars)}`))
|
|
56
|
+
output.print(colors.yellow(' Interactive shell started'))
|
|
57
|
+
output.print(colors.yellow(' Use JavaScript syntax to try steps in action'))
|
|
58
|
+
output.print(colors.yellow(` - Press ${colors.bold('ENTER')} to run the next step`))
|
|
59
|
+
output.print(colors.yellow(` - Press ${colors.bold('TAB')} twice to see all available commands`))
|
|
60
|
+
output.print(colors.yellow(` - Type ${colors.bold('exit')} + Enter to exit the interactive shell`))
|
|
61
|
+
output.print(colors.yellow(` - Prefix ${colors.bold('=>')} to run js commands ${colors.bold(vars)}`))
|
|
52
62
|
|
|
53
63
|
if (aiAssistant.isEnabled) {
|
|
54
|
-
output.print(colors.blue(` ${colors.bold('AI is enabled! (experimental)')} Write what you want and make AI run it`))
|
|
55
|
-
output.print(colors.blue(' Please note, only HTML fragments with interactive elements are sent to AI provider'))
|
|
56
|
-
output.print(colors.blue(' Ideas: ask it to fill forms for you or to click'))
|
|
64
|
+
output.print(colors.blue(` ${colors.bold('AI is enabled! (experimental)')} Write what you want and make AI run it`))
|
|
65
|
+
output.print(colors.blue(' Please note, only HTML fragments with interactive elements are sent to AI provider'))
|
|
66
|
+
output.print(colors.blue(' Ideas: ask it to fill forms for you or to click'))
|
|
57
67
|
}
|
|
58
68
|
}
|
|
59
69
|
|
|
@@ -64,154 +74,165 @@ function pauseSession(passedObject = {}) {
|
|
|
64
74
|
completer,
|
|
65
75
|
history: history.load(),
|
|
66
76
|
historySize: 50, // Adjust the history size as needed
|
|
67
|
-
})
|
|
77
|
+
})
|
|
68
78
|
|
|
69
|
-
|
|
79
|
+
store.onPause = true
|
|
80
|
+
rl.on('line', parseInput)
|
|
70
81
|
rl.on('close', () => {
|
|
71
|
-
if (!next) console.log('Exiting interactive shell....')
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
return askForStep()
|
|
77
|
-
})
|
|
82
|
+
if (!next) console.log('Exiting interactive shell....')
|
|
83
|
+
store.onPause = false
|
|
84
|
+
})
|
|
85
|
+
return new Promise(resolve => {
|
|
86
|
+
finish = resolve
|
|
87
|
+
return askForStep()
|
|
88
|
+
})
|
|
78
89
|
}
|
|
79
90
|
|
|
80
|
-
/* eslint-disable */
|
|
81
91
|
async function parseInput(cmd) {
|
|
82
|
-
rl.pause()
|
|
83
|
-
next = false
|
|
84
|
-
recorder.session.start('pause')
|
|
85
|
-
if (cmd === '') next = true
|
|
92
|
+
rl.pause()
|
|
93
|
+
next = false
|
|
94
|
+
recorder.session.start('pause')
|
|
95
|
+
if (cmd === '') next = true
|
|
86
96
|
if (!cmd || cmd === 'resume' || cmd === 'exit') {
|
|
87
|
-
finish()
|
|
88
|
-
recorder.session.restore()
|
|
89
|
-
rl.close()
|
|
90
|
-
history.save()
|
|
91
|
-
return nextStep()
|
|
97
|
+
finish()
|
|
98
|
+
recorder.session.restore('pause')
|
|
99
|
+
rl.close()
|
|
100
|
+
history.save()
|
|
101
|
+
return nextStep()
|
|
92
102
|
}
|
|
93
103
|
for (const k of Object.keys(registeredVariables)) {
|
|
94
|
-
eval(`var ${k} = registeredVariables['${k}'];`)
|
|
104
|
+
eval(`var ${k} = registeredVariables['${k}'];`)
|
|
95
105
|
}
|
|
96
106
|
|
|
97
|
-
let executeCommand = Promise.resolve()
|
|
107
|
+
let executeCommand = Promise.resolve()
|
|
98
108
|
|
|
99
109
|
const getCmd = () => {
|
|
100
110
|
debug('Command:', cmd)
|
|
101
|
-
return cmd
|
|
102
|
-
}
|
|
111
|
+
return cmd
|
|
112
|
+
}
|
|
103
113
|
|
|
104
|
-
let isCustomCommand = false
|
|
105
|
-
let lastError = null
|
|
106
|
-
let isAiCommand = false
|
|
107
|
-
let $res
|
|
114
|
+
let isCustomCommand = false
|
|
115
|
+
let lastError = null
|
|
116
|
+
let isAiCommand = false
|
|
117
|
+
let $res
|
|
108
118
|
try {
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
const I = container.support('I');
|
|
119
|
+
const locate = global.locate // enable locate in this context
|
|
120
|
+
|
|
121
|
+
const I = container.support('I')
|
|
113
122
|
if (cmd.trim().startsWith('=>')) {
|
|
114
|
-
isCustomCommand = true
|
|
115
|
-
cmd = cmd.trim().substring(2, cmd.length)
|
|
123
|
+
isCustomCommand = true
|
|
124
|
+
cmd = cmd.trim().substring(2, cmd.length)
|
|
116
125
|
} else if (aiAssistant.isEnabled && cmd.trim() && !cmd.match(/^\w+\(/) && cmd.includes(' ')) {
|
|
117
|
-
const currentOutputLevel = output.level()
|
|
118
|
-
output.level(0)
|
|
119
|
-
const res = I.grabSource()
|
|
120
|
-
isAiCommand = true
|
|
126
|
+
const currentOutputLevel = output.level()
|
|
127
|
+
output.level(0)
|
|
128
|
+
const res = I.grabSource()
|
|
129
|
+
isAiCommand = true
|
|
121
130
|
executeCommand = executeCommand.then(async () => {
|
|
122
131
|
try {
|
|
123
|
-
const html = await res
|
|
124
|
-
await aiAssistant.setHtmlContext(html)
|
|
132
|
+
const html = await res
|
|
133
|
+
await aiAssistant.setHtmlContext(html)
|
|
125
134
|
} catch (err) {
|
|
126
|
-
output.print(output.styles.error(' ERROR '),
|
|
127
|
-
return
|
|
135
|
+
output.print(output.styles.error(' ERROR '), "Can't get HTML context", err.stack)
|
|
136
|
+
return
|
|
128
137
|
} finally {
|
|
129
|
-
output.level(currentOutputLevel)
|
|
138
|
+
output.level(currentOutputLevel)
|
|
130
139
|
}
|
|
131
140
|
|
|
132
|
-
const spinner = ora(
|
|
133
|
-
cmd = await aiAssistant.writeSteps(cmd)
|
|
134
|
-
spinner.stop()
|
|
135
|
-
output.print('')
|
|
136
|
-
output.print(colors.blue(aiAssistant.getResponse()))
|
|
137
|
-
output.print('')
|
|
138
|
-
return cmd
|
|
141
|
+
const spinner = ora('Processing AI request...').start()
|
|
142
|
+
cmd = await aiAssistant.writeSteps(cmd)
|
|
143
|
+
spinner.stop()
|
|
144
|
+
output.print('')
|
|
145
|
+
output.print(colors.blue(aiAssistant.getResponse()))
|
|
146
|
+
output.print('')
|
|
147
|
+
return cmd
|
|
139
148
|
})
|
|
140
149
|
} else {
|
|
141
|
-
cmd = `I.${cmd}
|
|
150
|
+
cmd = `I.${cmd}`
|
|
142
151
|
}
|
|
143
|
-
executeCommand = executeCommand
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
})
|
|
152
|
+
executeCommand = executeCommand
|
|
153
|
+
.then(async () => {
|
|
154
|
+
const cmd = getCmd()
|
|
155
|
+
if (!cmd) return
|
|
156
|
+
return eval(cmd)
|
|
157
|
+
})
|
|
158
|
+
.catch(err => {
|
|
159
|
+
debug(err)
|
|
160
|
+
if (isAiCommand) return
|
|
161
|
+
if (!lastError) output.print(output.styles.error(' ERROR '), err.message)
|
|
162
|
+
debug(err.stack)
|
|
155
163
|
|
|
156
|
-
|
|
164
|
+
lastError = err.message
|
|
165
|
+
})
|
|
166
|
+
|
|
167
|
+
const val = await executeCommand
|
|
157
168
|
|
|
158
169
|
if (isCustomCommand) {
|
|
159
|
-
if (val !== undefined) console.log('Result', '$res=', val)
|
|
160
|
-
$res = val
|
|
170
|
+
if (val !== undefined) console.log('Result', '$res=', val)
|
|
171
|
+
$res = val
|
|
161
172
|
}
|
|
162
173
|
|
|
163
174
|
if (cmd?.startsWith('I.see') || cmd?.startsWith('I.dontSee')) {
|
|
164
|
-
output.print(output.styles.success(' OK '), cmd)
|
|
175
|
+
output.print(output.styles.success(' OK '), cmd)
|
|
165
176
|
}
|
|
166
177
|
if (cmd?.startsWith('I.grab')) {
|
|
167
|
-
|
|
178
|
+
try {
|
|
179
|
+
output.print(output.styles.debug(JSON.stringify(val, null, 2)))
|
|
180
|
+
} catch (err) {
|
|
181
|
+
output.print(output.styles.error(' ERROR '), 'Failed to stringify result:', err.message)
|
|
182
|
+
output.print(output.styles.error(' RAW VALUE '), String(val))
|
|
183
|
+
}
|
|
168
184
|
}
|
|
169
185
|
|
|
170
|
-
history.push(cmd)
|
|
186
|
+
history.push(cmd) // add command to history when successful
|
|
171
187
|
} catch (err) {
|
|
172
|
-
if (!lastError) output.print(output.styles.error(' ERROR '), err.message)
|
|
173
|
-
lastError = err.message
|
|
188
|
+
if (!lastError) output.print(output.styles.error(' ERROR '), err.message)
|
|
189
|
+
lastError = err.message
|
|
174
190
|
}
|
|
175
|
-
recorder.session.catch(
|
|
176
|
-
const msg = err.cliMessage ? err.cliMessage() : err.message
|
|
191
|
+
recorder.session.catch(err => {
|
|
192
|
+
const msg = err.cliMessage ? err.cliMessage() : err.message
|
|
177
193
|
|
|
178
194
|
// pop latest command from history because it failed
|
|
179
|
-
history.pop()
|
|
180
|
-
|
|
181
|
-
if (isAiCommand) return
|
|
182
|
-
if (!lastError) output.print(output.styles.error(' FAIL '), msg)
|
|
183
|
-
lastError = err.message
|
|
184
|
-
})
|
|
185
|
-
recorder.add('ask for next step', askForStep)
|
|
186
|
-
nextStep()
|
|
195
|
+
history.pop()
|
|
196
|
+
|
|
197
|
+
if (isAiCommand) return
|
|
198
|
+
if (!lastError) output.print(output.styles.error(' FAIL '), msg)
|
|
199
|
+
lastError = err.message
|
|
200
|
+
})
|
|
201
|
+
recorder.add('ask for next step', askForStep)
|
|
202
|
+
nextStep()
|
|
187
203
|
}
|
|
188
|
-
/* eslint-enable */
|
|
189
204
|
|
|
190
205
|
function askForStep() {
|
|
191
|
-
return new Promise(
|
|
192
|
-
nextStep = resolve
|
|
193
|
-
rl.setPrompt(' I.', 3)
|
|
194
|
-
rl.resume()
|
|
195
|
-
rl.prompt([false])
|
|
196
|
-
})
|
|
206
|
+
return new Promise(resolve => {
|
|
207
|
+
nextStep = resolve
|
|
208
|
+
rl.setPrompt(' I.', 3)
|
|
209
|
+
rl.resume()
|
|
210
|
+
rl.prompt([false])
|
|
211
|
+
})
|
|
197
212
|
}
|
|
198
213
|
|
|
199
214
|
function completer(line) {
|
|
200
|
-
const I = container.support('I')
|
|
201
|
-
const completions = methodsOfObject(I)
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
215
|
+
const I = container.support('I')
|
|
216
|
+
const completions = methodsOfObject(I)
|
|
217
|
+
// If no input, return all completions
|
|
218
|
+
if (!line) {
|
|
219
|
+
return [completions, line]
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
// Search using Fuse.js
|
|
223
|
+
const searchResults = searchWithFusejs(completions, line, {
|
|
224
|
+
threshold: 0.3,
|
|
225
|
+
distance: 100,
|
|
226
|
+
minMatchCharLength: 1,
|
|
227
|
+
})
|
|
228
|
+
const hits = searchResults.map(result => result.item)
|
|
229
|
+
|
|
230
|
+
return [hits, line]
|
|
209
231
|
}
|
|
210
232
|
|
|
211
233
|
function registerVariable(name, value) {
|
|
212
|
-
registeredVariables[name] = value
|
|
234
|
+
registeredVariables[name] = value
|
|
213
235
|
}
|
|
214
236
|
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
module.exports.registerVariable = registerVariable;
|
|
237
|
+
export default pause
|
|
238
|
+
export { registerVariable }
|