diff --git a/src/actions/setupActions.ts b/src/actions/setupActions.ts
index 9b9a2a0a..df7e9ee3 100644
--- a/src/actions/setupActions.ts
+++ b/src/actions/setupActions.ts
@@ -6,12 +6,6 @@ import openFiles from './utils/openFiles'
import runCommands from './utils/runCommands'
import onError from '../services/sentry/onError'
-async function wait(ms: number) {
- return new Promise((resolve) => {
- setTimeout(resolve, ms)
- })
-}
-
interface SetupActions {
actions: TT.StepActions
send: (action: T.Action) => void // send messages to client
@@ -35,8 +29,6 @@ export const setupActions = async ({ actions, send, path }: SetupActions): Promi
// 3. start file watchers
loadWatchers(watchers || [])
- await wait(1000)
-
// 4. run command
await runCommands({ commands: commands || [], send, path }).catch(onError)
}
diff --git a/src/channel/index.ts b/src/channel/index.ts
index 133df3eb..7a82c34e 100644
--- a/src/channel/index.ts
+++ b/src/channel/index.ts
@@ -76,23 +76,23 @@ class Channel implements Channel {
const tutorial: TT.Tutorial | null = this.context.tutorial.get()
// new tutorial
- if (!tutorial || !tutorial.id) {
- this.send({ type: 'START_NEW_TUTORIAL', payload: { env } })
- return
- }
+ this.send({ type: 'START_NEW_TUTORIAL', payload: { env } })
+ return
- // set tutorial
- const { position, progress } = await this.context.setTutorial(this.workspaceState, tutorial)
+ // disable continue until fixed
- if (progress.complete) {
- // tutorial is already complete
- this.send({ type: 'TUTORIAL_ALREADY_COMPLETE', payload: { env } })
- return
- }
- // communicate to client the tutorial & stepProgress state
- this.send({ type: 'LOAD_STORED_TUTORIAL', payload: { env, tutorial, progress, position } })
+ // // set tutorial
+ // const { position, progress } = await this.context.setTutorial(this.workspaceState, tutorial)
- return
+ // if (progress.complete) {
+ // // tutorial is already complete
+ // this.send({ type: 'TUTORIAL_ALREADY_COMPLETE', payload: { env } })
+ // return
+ // }
+ // // communicate to client the tutorial & stepProgress state
+ // this.send({ type: 'LOAD_STORED_TUTORIAL', payload: { env, tutorial, progress, position } })
+
+ // return
} catch (e) {
const error = {
type: 'UnknownError',
@@ -100,6 +100,7 @@ class Channel implements Channel {
}
this.send({ type: 'EDITOR_STARTUP_FAILED', payload: { error } })
}
+ return
// clear tutorial local storage
case 'TUTORIAL_CLEAR':
@@ -203,7 +204,6 @@ class Channel implements Channel {
// report back to the webview that setup is complete
this.send({ type: 'TUTORIAL_CONFIGURED' })
- return
} catch (e) {
const error = {
type: 'UnknownError',
@@ -211,6 +211,7 @@ class Channel implements Channel {
}
this.send({ type: 'TUTORIAL_CONFIGURE_FAIL', payload: { error } })
}
+ return
case 'EDITOR_TUTORIAL_CONTINUE_CONFIG':
try {
const tutorialContinue: TT.Tutorial | null = this.context.tutorial.get()
@@ -224,7 +225,6 @@ class Channel implements Channel {
})
// update the current stepId on startup
vscode.commands.executeCommand(COMMANDS.SET_CURRENT_STEP, action.payload)
- return
} catch (e) {
const error = {
type: 'UnknownError',
@@ -232,6 +232,7 @@ class Channel implements Channel {
}
this.send({ type: 'CONTINUE_FAILED', payload: { error } })
}
+ return
case 'EDITOR_VALIDATE_SETUP':
try {
// check workspace is selected
@@ -272,7 +273,6 @@ class Channel implements Channel {
return
}
this.send({ type: 'SETUP_VALIDATED' })
- return
} catch (e) {
const error = {
type: 'UknownError',
@@ -280,6 +280,7 @@ class Channel implements Channel {
}
this.send({ type: 'VALIDATE_SETUP_FAILED', payload: { error } })
}
+ return
case 'EDITOR_REQUEST_WORKSPACE':
openWorkspace()
return
@@ -329,7 +330,7 @@ class Channel implements Channel {
case 'TEST_PASS':
const tutorial = this.context.tutorial.get()
if (!tutorial) {
- throw new Error('Error with current tutorial')
+ throw new Error('Error with current tutorial. Tutorial may be missing an id.')
}
// update local storage stepProgress
const progress = this.context.progress.setStepComplete(tutorial, action.payload.stepId)
diff --git a/src/editor/commands.ts b/src/editor/commands.ts
index 50f57ee7..57ed0e0c 100644
--- a/src/editor/commands.ts
+++ b/src/editor/commands.ts
@@ -20,7 +20,7 @@ interface CreateCommandProps {
export const createCommands = ({ extensionPath, workspaceState }: CreateCommandProps) => {
// React panel webview
let webview: any
- let currentStepId = ''
+ let currentStepId: string | null = ''
let testRunner: any
return {
@@ -79,7 +79,7 @@ export const createCommands = ({ extensionPath, workspaceState }: CreateCommandP
},
[COMMANDS.RUN_TEST]: (current: Payload | undefined, onSuccess: () => void) => {
// use stepId from client, or last set stepId
- const payload: Payload = { stepId: current && current.stepId.length ? current.stepId : currentStepId }
+ const payload: Payload = { stepId: current && current.stepId?.length ? current.stepId : currentStepId }
testRunner(payload, onSuccess)
},
}
diff --git a/src/environment.ts b/src/environment.ts
index ec7d9b1c..a7355273 100644
--- a/src/environment.ts
+++ b/src/environment.ts
@@ -14,8 +14,7 @@ export type Env = 'test' | 'local' | 'development' | 'production'
export const NODE_ENV: Env = process.env.NODE_ENV || 'production'
// toggle logging in development
-export const LOG: boolean =
- (process.env.REACT_APP_LOG || '').toLowerCase() === 'true' && process.env.NODE_ENV !== 'production'
+export const LOG: boolean = (process.env.REACT_APP_LOG || '').toLowerCase() === 'true'
// error logging tool
export const SENTRY_DSN: string | null = process.env.SENTRY_DSN || null
diff --git a/src/services/logger/index.ts b/src/services/logger/index.ts
index 9f7ecdfc..ea79bcdf 100644
--- a/src/services/logger/index.ts
+++ b/src/services/logger/index.ts
@@ -1,13 +1,19 @@
import { LOG } from '../../environment'
-const logger = (message: string | string[]) => {
+export type Log = string | object | null
+
+const logger = (...messages: Log[]): void => {
if (!LOG) {
return
}
- if (Array.isArray(message)) {
- message.forEach(console.log)
- } else {
- console.log(message)
+ // Inside vscode, you console.log does not allow more than 1 param
+ // to get around it, we can log with multiple log statements
+ for (const message of messages) {
+ if (typeof message === 'object') {
+ console.log(JSON.stringify(message))
+ } else {
+ console.log(message)
+ }
}
}
diff --git a/src/services/testRunner/index.ts b/src/services/testRunner/index.ts
index 16c097c8..c9c12cf2 100644
--- a/src/services/testRunner/index.ts
+++ b/src/services/testRunner/index.ts
@@ -8,7 +8,7 @@ import { clearOutput, displayOutput } from './output'
import { formatFailOutput } from './formatOutput'
export interface Payload {
- stepId: string
+ stepId: string | null
}
interface Callbacks {
diff --git a/typings/index.d.ts b/typings/index.d.ts
index 8d07d8a5..78c3d501 100644
--- a/typings/index.d.ts
+++ b/typings/index.d.ts
@@ -65,11 +65,11 @@ export interface MachineStateSchema {
Setup: {
states: {
Startup: {}
- Start: {}
ValidateSetup: {}
+ Start: {}
SelectTutorial: {}
SetupNewTutorial: {}
- StartNewTutorial: {}
+ StartTutorial: {}
}
}
Tutorial: {
diff --git a/web-app/src/Routes.tsx b/web-app/src/Routes.tsx
index fba0d084..26460463 100644
--- a/web-app/src/Routes.tsx
+++ b/web-app/src/Routes.tsx
@@ -6,7 +6,7 @@ import LoadingPage from './containers/Loading'
import StartPage from './containers/Start'
import SelectTutorialPage from './containers/SelectTutorial'
import CompletedPage from './containers/Tutorial/CompletedPage'
-import LevelSummaryPage from './containers/Tutorial/LevelPage'
+import TutorialPage from './containers/Tutorial'
const Routes = () => {
const { context, send, Router, Route } = useRouter()
@@ -30,13 +30,10 @@ const Routes = () => {
-
- ]
-
-
+
{/* Tutorial */}
@@ -44,7 +41,7 @@ const Routes = () => {
-
+
{/* Completed */}
diff --git a/web-app/src/containers/Tutorial/LevelPage/Level.tsx b/web-app/src/containers/Tutorial/components/Level.tsx
similarity index 100%
rename from web-app/src/containers/Tutorial/LevelPage/Level.tsx
rename to web-app/src/containers/Tutorial/components/Level.tsx
diff --git a/web-app/src/containers/Tutorial/LevelPage/Step.tsx b/web-app/src/containers/Tutorial/components/Step.tsx
similarity index 100%
rename from web-app/src/containers/Tutorial/LevelPage/Step.tsx
rename to web-app/src/containers/Tutorial/components/Step.tsx
diff --git a/web-app/src/containers/Tutorial/LevelPage/index.tsx b/web-app/src/containers/Tutorial/index.tsx
similarity index 88%
rename from web-app/src/containers/Tutorial/LevelPage/index.tsx
rename to web-app/src/containers/Tutorial/index.tsx
index 6881d880..0d49e7ad 100644
--- a/web-app/src/containers/Tutorial/LevelPage/index.tsx
+++ b/web-app/src/containers/Tutorial/index.tsx
@@ -1,15 +1,15 @@
import * as React from 'react'
import * as T from 'typings'
import * as TT from 'typings/tutorial'
-import * as selectors from '../../../services/selectors'
-import Level from './Level'
+import * as selectors from '../../services/selectors'
+import Level from './components/Level'
interface PageProps {
context: T.MachineContext
send(action: T.Action): void
}
-const LevelSummaryPageContainer = (props: PageProps) => {
+const TutorialPage = (props: PageProps) => {
const { position, progress, processes, testStatus } = props.context
const tutorial = selectors.currentTutorial(props.context)
@@ -59,4 +59,4 @@ const LevelSummaryPageContainer = (props: PageProps) => {
)
}
-export default LevelSummaryPageContainer
+export default TutorialPage
diff --git a/web-app/src/services/state/machine.ts b/web-app/src/services/state/machine.ts
index 17d330ca..c928c8e4 100644
--- a/web-app/src/services/state/machine.ts
+++ b/web-app/src/services/state/machine.ts
@@ -123,10 +123,10 @@ export const createMachine = (options: any) => {
actions: ['setError'],
},
TRY_AGAIN: 'SetupNewTutorial',
- TUTORIAL_CONFIGURED: 'StartNewTutorial',
+ TUTORIAL_CONFIGURED: 'StartTutorial',
},
},
- StartNewTutorial: {
+ StartTutorial: {
onEntry: ['startNewTutorial'],
after: {
0: '#tutorial',
diff --git a/web-app/stories/Completed.stories.tsx b/web-app/stories/Completed.stories.tsx
index e8bd0c75..7fe01ecf 100644
--- a/web-app/stories/Completed.stories.tsx
+++ b/web-app/stories/Completed.stories.tsx
@@ -6,4 +6,4 @@ import SideBarDecorator from './utils/SideBarDecorator'
storiesOf('Completed', module)
.addDecorator(SideBarDecorator)
- .add('Page', () => )
+ .add('Page', () => )
diff --git a/web-app/stories/Level.stories.tsx b/web-app/stories/Level.stories.tsx
index 12d39dbb..26607d3c 100644
--- a/web-app/stories/Level.stories.tsx
+++ b/web-app/stories/Level.stories.tsx
@@ -4,7 +4,7 @@ import { storiesOf } from '@storybook/react'
import React from 'react'
import * as T from '../../typings'
import * as TT from '../../typings/tutorial'
-import Level from '../src/containers/Tutorial/LevelPage/Level'
+import Level from '../src/containers/Tutorial/components/Level'
import SideBarDecorator from './utils/SideBarDecorator'
type ModifiedLevel = TT.Level & {
diff --git a/web-app/stories/Step.stories.tsx b/web-app/stories/Step.stories.tsx
index d6abc5e2..6a7987ed 100644
--- a/web-app/stories/Step.stories.tsx
+++ b/web-app/stories/Step.stories.tsx
@@ -2,7 +2,7 @@ import { action } from '@storybook/addon-actions'
import { select, text, withKnobs } from '@storybook/addon-knobs'
import { storiesOf } from '@storybook/react'
import React from 'react'
-import Step from '../src/containers/Tutorial/LevelPage/Step'
+import Step from '../src/containers/Tutorial/components/Step'
import SideBarDecorator from './utils/SideBarDecorator'
const stepText =