Skip to content

Log/tutorial version#559

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
{
"name": "coderoad",
"version": "0.18.3",
"version": "0.18.4",
"description": "Play interactive coding tutorials in your editor",
"keywords": [
"tutorial",
Expand Down
6 changes: 5 additions & 1 deletion src/actions/onStartup.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -5,6 +5,7 @@ import Context from '../services/context/context'
import { send } from '../commands'
import { WORKSPACE_ROOT, TUTORIAL_URL } from '../environment'
import fetch from 'node-fetch'
import logger from '../services/logger'

const onStartup = async (context: Context): Promise<void> => {
try {
Expand DownExpand Up@@ -36,10 +37,12 @@ const onStartup = async (context: Context): Promise<void> => {
// NEW: no stored tutorial, must start new tutorial
if (!tutorial || !tutorial.version) {
if (TUTORIAL_URL) {
logger(`Using tutorial url from env: ${TUTORIAL_URL}`)
// if a tutorial URL is added, launch on startup
try {
const tutorialRes = await fetch(TUTORIAL_URL)
const tutorial = await tutorialRes.json()
const tutorial: TT.Tutorial = await tutorialRes.json()
logger(`Tutorial: ${tutorial?.summary?.title} (${tutorial?.version})`)
send({ type: 'START_TUTORIAL_FROM_URL', payload: { tutorial } })
return
} catch (e: any) {
Expand All@@ -54,6 +57,7 @@ const onStartup = async (context: Context): Promise<void> => {

// CONTINUE_FROM_PROGRESS
const { position } = await context.onContinue(tutorial)
logger(`Continuing tutorial from progress: level ${position?.levelId} step ${position?.stepId}`)
// communicate to client the tutorial & stepProgress state
send({ type: 'LOAD_STORED_TUTORIAL', payload: { env, tutorial, position } })
} catch (e: any) {
Expand Down
2 changes: 1 addition & 1 deletion src/actions/onTutorialConfigContinue.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -8,9 +8,9 @@ import logger from '../services/logger'
import { setupWebhook } from '../services/hooks/webhooks'

const onTutorialConfigContinue = async (action: T.Action, context: Context): Promise<void> => {
logger(`Continuing tutorial from progress: ${JSON.stringify(action.payload)}`)
try {
const tutorialToContinue: TT.Tutorial | null = context.tutorial.get()
logger(`Tutorial: ${tutorialToContinue?.summary?.title} (${tutorialToContinue?.version})`)
if (!tutorialToContinue) {
throw new Error('Invalid tutorial to continue')
}
Expand Down
2 changes: 1 addition & 1 deletion src/services/hooks/utils/runCommands.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -18,7 +18,7 @@ const runCommands = async (commands: string[] = []): Promise<void> => {
logger(`Command output: ${JSON.stringify(result)}`)
} catch (error: any) {
logger(`Command failed: ${error.message}`)
send({ type: 'COMMAND_FAIL', payload: { process: { ...process, status: 'FAIL' } } })
send({ type: '', payload: { process: { ...process, status: 'FAIL' } } })
return
}
send({ type: 'COMMAND_SUCCESS', payload: { process: { ...process, status: 'SUCCESS' } } })
Expand Down
2 changes: 1 addition & 1 deletion web-app/package.json
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
{
"name": "coderoad-app",
"version": "0.18.3",
"version": "0.18.4",
"private": true,
"scripts": {
"analyze": "source-map-explorer 'build/static/js/*.js'",
Expand Down
close