Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

load tutorial from env url on startup#325

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
ShMcK merged 1 commit intomasterfromfeature/load-from-tutorial-url
May 10, 2020
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

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: 2 additions & 0 deletionspackage.json
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -39,6 +39,7 @@
"@types/jest": "^25.2.1",
"@types/jsdom": "^16.2.1",
"@types/node": "^13.13.4",
"@types/node-fetch": "^2.5.7",
"@types/semver": "^7.1.0",
"@typescript-eslint/eslint-plugin": "^2.29.0",
"@typescript-eslint/parser": "^2.29.0",
Expand All@@ -50,6 +51,7 @@
"git-url-parse": "^11.1.2",
"jest": "^25.4.0",
"jsdom": "^16.2.2",
"node-fetch": "^2.6.0",
"prettier": "^2.0.5",
"semver": "^7.3.2",
"ts-jest": "^25.4.0",
Expand Down
19 changes: 16 additions & 3 deletionssrc/channel/index.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,6 +2,7 @@ import * as T from 'typings'
import * as TT from 'typings/tutorial'
import * as E from 'typings/error'
import * as vscode from 'vscode'
import fetch from 'node-fetch'
import { satisfies } from 'semver'
import saveCommit from '../actions/saveCommit'
import { setupActions, solutionActions } from '../actions/setupActions'
Expand All@@ -15,7 +16,7 @@ import { readFile } from 'fs'
import { join } from 'path'
import { promisify } from 'util'
import { showOutput } from '../services/testRunner/output'
import { WORKSPACE_ROOT } from '../environment'
import { WORKSPACE_ROOT, TUTORIAL_URL } from '../environment'

const readFileAsync = promisify(readFile)

Expand DownExpand Up@@ -52,8 +53,8 @@ class Channel implements Channel {
case 'EDITOR_STARTUP':
try {
// check if a workspace is open, otherwise nothing works
constnoActiveWorksapce = !WORKSPACE_ROOT.length
if (noActiveWorksapce) {
constnoActiveWorkspace = !WORKSPACE_ROOT.length
if (noActiveWorkspace) {
const error: E.ErrorMessage = {
type: 'NoWorkspaceFound',
message: '',
Expand All@@ -73,6 +74,18 @@ class Channel implements Channel {
sessionId: vscode.env.sessionId,
}

// load tutorial from url
if (TUTORIAL_URL) {
try {
const tutorialRes = await fetch(TUTORIAL_URL)
const tutorial = await tutorialRes.json()
this.send({ type: 'START_TUTORIAL_FROM_URL', payload: { tutorial } })
return
} catch (e) {
console.log(`Failed to load tutorial from url ${TUTORIAL_URL} with error "${e.message}"`)
}
}

// continue from tutorial from local storage
const tutorial: TT.Tutorial | null = this.context.tutorial.get()

Expand Down
4 changes: 3 additions & 1 deletionsrc/environment.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -10,7 +10,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 =true
export const LOG =false

// error logging tool
export const SENTRY_DSN: string | null = null
Expand All@@ -33,3 +33,5 @@ const supportedOS = [
if (!supportedOS.includes(OS_PLATFORM)) {
throw new Error(`OS ${OS_PLATFORM}" not supported with CodeRoad`)
}

export const TUTORIAL_URL: string | null = process.env.CODEROAD_TUTORIAL_URL || null
4 changes: 4 additions & 0 deletionsweb-app/src/services/state/machine.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -70,6 +70,10 @@ export const createMachine = (options: any) => {
target: 'Start',
actions: ['setStart'],
},
START_TUTORIAL_FROM_URL: {
target: 'SetupNewTutorial',
actions: ['setTutorialContext'],
},
// TODO: handle completed tutorial differently
TUTORIAL_ALREADY_COMPLETE: {
target: 'Start',
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp