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

Commita33089a

Browse files
authored
Merge pull requestcoderoad#325 from coderoad/feature/load-from-tutorial-url
load tutorial from env url on startup
2 parentsf647594 +7dddd9a commita33089a

File tree

4 files changed

+25
-4
lines changed

4 files changed

+25
-4
lines changed

‎package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
"@types/jest":"^25.2.1",
4040
"@types/jsdom":"^16.2.1",
4141
"@types/node":"^13.13.4",
42+
"@types/node-fetch":"^2.5.7",
4243
"@types/semver":"^7.1.0",
4344
"@typescript-eslint/eslint-plugin":"^2.29.0",
4445
"@typescript-eslint/parser":"^2.29.0",
@@ -50,6 +51,7 @@
5051
"git-url-parse":"^11.1.2",
5152
"jest":"^25.4.0",
5253
"jsdom":"^16.2.2",
54+
"node-fetch":"^2.6.0",
5355
"prettier":"^2.0.5",
5456
"semver":"^7.3.2",
5557
"ts-jest":"^25.4.0",

‎src/channel/index.ts

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import * as T from 'typings'
22
import*asTTfrom'typings/tutorial'
33
import*asEfrom'typings/error'
44
import*asvscodefrom'vscode'
5+
importfetchfrom'node-fetch'
56
import{satisfies}from'semver'
67
importsaveCommitfrom'../actions/saveCommit'
78
import{setupActions,solutionActions}from'../actions/setupActions'
@@ -15,7 +16,7 @@ import { readFile } from 'fs'
1516
import{join}from'path'
1617
import{promisify}from'util'
1718
import{showOutput}from'../services/testRunner/output'
18-
import{WORKSPACE_ROOT}from'../environment'
19+
import{WORKSPACE_ROOT,TUTORIAL_URL}from'../environment'
1920

2021
constreadFileAsync=promisify(readFile)
2122

@@ -52,8 +53,8 @@ class Channel implements Channel {
5253
case'EDITOR_STARTUP':
5354
try{
5455
// check if a workspace is open, otherwise nothing works
55-
constnoActiveWorksapce=!WORKSPACE_ROOT.length
56-
if(noActiveWorksapce){
56+
constnoActiveWorkspace=!WORKSPACE_ROOT.length
57+
if(noActiveWorkspace){
5758
consterror:E.ErrorMessage={
5859
type:'NoWorkspaceFound',
5960
message:'',
@@ -73,6 +74,18 @@ class Channel implements Channel {
7374
sessionId:vscode.env.sessionId,
7475
}
7576

77+
// load tutorial from url
78+
if(TUTORIAL_URL){
79+
try{
80+
consttutorialRes=awaitfetch(TUTORIAL_URL)
81+
consttutorial=awaittutorialRes.json()
82+
this.send({type:'START_TUTORIAL_FROM_URL',payload:{ tutorial}})
83+
return
84+
}catch(e){
85+
console.log(`Failed to load tutorial from url${TUTORIAL_URL} with error "${e.message}"`)
86+
}
87+
}
88+
7689
// continue from tutorial from local storage
7790
consttutorial:TT.Tutorial|null=this.context.tutorial.get()
7891

‎src/environment.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export type Env = 'test' | 'local' | 'development' | 'production'
1010
exportconstNODE_ENV:Env=process.env.NODE_ENV||'production'
1111

1212
// toggle logging in development
13-
exportconstLOG=true
13+
exportconstLOG=false
1414

1515
// error logging tool
1616
exportconstSENTRY_DSN:string|null=null
@@ -33,3 +33,5 @@ const supportedOS = [
3333
if(!supportedOS.includes(OS_PLATFORM)){
3434
thrownewError(`OS${OS_PLATFORM}" not supported with CodeRoad`)
3535
}
36+
37+
exportconstTUTORIAL_URL:string|null=process.env.CODEROAD_TUTORIAL_URL||null

‎web-app/src/services/state/machine.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@ export const createMachine = (options: any) => {
7070
target:'Start',
7171
actions:['setStart'],
7272
},
73+
START_TUTORIAL_FROM_URL:{
74+
target:'SetupNewTutorial',
75+
actions:['setTutorialContext'],
76+
},
7377
// TODO: handle completed tutorial differently
7478
TUTORIAL_ALREADY_COMPLETE:{
7579
target:'Start',

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp