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

Commit5a02b79

Browse files
committed
initialize new tutorial
1 parent4eee629 commit5a02b79

File tree

5 files changed

+45
-14
lines changed

5 files changed

+45
-14
lines changed

‎src/editor/commands/index.ts

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,15 @@ import * as vscode from 'vscode'
22
import{join}from'path'
33
import{setStorage}from'../storage'
44
importReactWebViewfrom'../ReactWebView'
5+
import{isEmptyWorkspace}from'../workspace'
56
import*asCRfrom'typings'
7+
// TODO: replace with actual tutorial loading later
8+
importtutorialfrom'../../state/context/tutorials/basic'
69

710
constCOMMANDS={
811
START:'coderoad.start',
912
NEW_OR_CONTINUE:'coderoad.new_or_continue',
13+
TUTORIAL_LAUNCH:'coderoad.tutorial_launch',
1014
OPEN_WEBVIEW:'coderoad.open_webview',
1115
SEND_STATE:'coderoad.send_state',
1216
SEND_DATA:'coderoad.send_data',
@@ -20,12 +24,13 @@ interface CreateCommandProps {
2024
machine:CR.StateMachine,
2125
storage:any,
2226
git:any
27+
position:any
2328
}
2429

2530
// React panel webview
2631
letwebview:any;
2732

28-
exportconstcreateCommands=({ context, machine, storage, git}:CreateCommandProps)=>({
33+
exportconstcreateCommands=({ context, machine, storage, git, position}:CreateCommandProps)=>({
2934
// initialize
3035
[COMMANDS.START]:()=>{
3136
// set local storage workspace
@@ -36,6 +41,11 @@ export const createCommands = ({ context, machine, storage, git }: CreateCommand
3641
console.log('webview',webview.panel.webview.postMessage)
3742
machine.activate()
3843
},
44+
// open React webview
45+
[COMMANDS.OPEN_WEBVIEW]:(column:number=vscode.ViewColumn.One)=>{
46+
webview.createOrShow(column);
47+
},
48+
// launch with continue or new
3949
[COMMANDS.NEW_OR_CONTINUE]:async()=>{
4050
// verify that the user has a tutorial & progress
4151
// verify git is setup with a coderoad remote
@@ -51,9 +61,24 @@ export const createCommands = ({ context, machine, storage, git }: CreateCommand
5161
// otherwise start from 'NEW'
5262
machine.send(canContinue ?'CONTINUE' :'NEW')
5363
},
54-
// open React webview
55-
[COMMANDS.OPEN_WEBVIEW]:(column:number=vscode.ViewColumn.One)=>{
56-
webview.createOrShow(column);
64+
// launch a new tutorial
65+
[COMMANDS.TUTORIAL_LAUNCH]:async()=>{
66+
console.log('launch tutorial')
67+
68+
awaitisEmptyWorkspace()
69+
70+
awaitgit.gitInitIfNotExists()
71+
72+
// TODO: use actual tutorial repo
73+
awaitPromise.all([git.gitSetupRemote(tutorial.meta.repo),storage.setTutorial(tutorial),storage.resetProgress()])
74+
75+
// TODO: refactor to allow client to call initialization
76+
constpos:CR.Position=awaitposition.getInitial(tutorial)
77+
78+
// eslint-disable-next-line
79+
const{ steps}=tutorial.data
80+
const{ setup}=steps[pos.stepId].actions
81+
awaitgit.gitLoadCommits(setup)
5782
},
5883
// open a file
5984
[COMMANDS.OPEN_FILE]:async(relativeFilePath:string)=>{

‎src/editor/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import * as CR from 'typings'
33
import{createCommands}from'./commands'
44
import*asstoragefrom'../services/storage'
55
import*asgitfrom'../services/git'
6+
import*aspositionfrom'../services/position'
67

78
interfaceProps{
89
machine:CR.StateMachine,
@@ -33,6 +34,7 @@ class Editor {
3334
machine:this.machine,
3435
storage,
3536
git,
37+
position,
3638
})
3739
for(constcmdincommands){
3840
constcommand:vscode.Disposable=vscode.commands.registerCommand(cmd,commands[cmd])

‎src/state/actions/index.ts

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,17 @@ let initialProgress: CR.Progress = {
1111
}
1212

1313
exportdefault{
14-
tutorialLoad:assign({
14+
createWebview(){
15+
console.log('execute coderoad.open_webview')
16+
vscode.commands.executeCommand('coderoad.open_webview')
17+
},
18+
newOrContinue(){
19+
vscode.commands.executeCommand('coderoad.new_or_continue')
20+
},
21+
tutorialLaunch(){
22+
vscode.commands.executeCommand('coderoad.tutorial_launch')
23+
},
24+
tutorialContinue:assign({
1525
// load initial data, progress & position
1626
data():CR.TutorialData{
1727
console.log('ACTION: tutorialLoad.data')
@@ -45,11 +55,4 @@ export default {
4555
returnposition
4656
}
4757
}),
48-
createWebview(){
49-
console.log('execute coderoad.open_webview')
50-
vscode.commands.executeCommand('coderoad.open_webview')
51-
},
52-
newOrContinue(){
53-
vscode.commands.executeCommand('coderoad.new_or_continue')
54-
}
5558
}

‎src/state/context/tutorials/basic.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const basic: CR.Tutorial = {
44
id:'tutorialId',
55
meta:{
66
version:'0.1.0',
7-
repo:'https://github.com/ShMcK/coderoad-vscode.git',
7+
repo:'https://github.com/ShMcK/coderoad-tutorial-basic.git',
88
createdBy:'shmck',
99
createdAt:'Sat, 11 May 2019 18:25:24 GMT',
1010
updatedBy:'shmck',

‎src/state/machine.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ export const machine = Machine<
4040
},
4141
},
4242
InitializeTutorial:{
43+
onEntry:['tutorialLaunch'],
4344
on:{
4445
TUTORIAL_LOADED:'Tutorial'
4546
}
@@ -48,7 +49,7 @@ export const machine = Machine<
4849

4950
},
5051
ContinueTutorial:{
51-
onEntry:'tutorialLoad',
52+
onEntry:'tutorialContinue',
5253
on:{
5354
TUTORIAL_START:{
5455
target:'Tutorial.LoadNext',

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp