MCPcopy Index your code
hub / github.com/coderoad/coderoad-vscode / createCommands

Function createCommands

src/commands.ts:35–116  ·  view source on GitHub ↗
(commandProps: CreateCommandProps)

Source from the content-addressed store, hash-verified

33}
34
35export const createCommands = (commandProps: CreateCommandProps): { [key: string]: any } => {
36 const { extensionPath, workspaceState } = commandProps
37 // React panel webview
38 let webview: any
39 let currentPosition: T.Position
40 let testRunner: any
41 const channel = new Channel(workspaceState)
42
43 const start = async () => {
44 if (webview && webview.state.loaded) {
45 webview.createOrShow()
46 } else {
47 // activate machine
48 webview = await createWebView({
49 extensionPath,
50 channel,
51 })
52 // make send to client function exportable
53 // as "send".
54 sendToClient = webview.send
55 }
56 }
57
58 // run activation if triggered by "workspaceContains"
59 start()
60
61 return {
62 [COMMANDS.START]: start,
63 [COMMANDS.CONFIG_TEST_RUNNER]: async ({
64 data,
65 alreadyConfigured,
66 }: {
67 data: TT.Tutorial
68 alreadyConfigured: boolean
69 }) => {
70 if (!alreadyConfigured) {
71 const setupActions = data.config.setup
72 if (setupActions) {
73 await hooks.onInit(setupActions, data.id)
74 }
75 }
76 testRunner = createTestRunner(data, {
77 onSuccess: (position: T.Position) => {
78 logger(`Test pass position: ${JSON.stringify(position)}`)
79 // send test pass message back to client
80 channel.context.position.set({ ...position, complete: true })
81 send({ type: 'TEST_PASS', payload: { position: { ...position, complete: true } } })
82 },
83 onFail: (position: T.Position, failSummary: T.TestFail): void => {
84 // send test fail message back to client with failure message
85 send({ type: 'TEST_FAIL', payload: { position, fail: failSummary } })
86 },
87 onError: (position: T.Position) => {
88 // TODO: send test error message back to client
89 const message = 'Error with test runner'
90 send({ type: 'TEST_ERROR', payload: { position, message } })
91 },
92 onRun: (position: T.Position) => {

Callers 1

activateFunction · 0.90

Calls 4

startFunction · 0.85
createTestRunnerFunction · 0.85
sendFunction · 0.70
loggerFunction · 0.50

Tested by

no test coverage detected