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

Commit5858c93

Browse files
committed
add empty workspace check
1 parent4992b32 commit5858c93

File tree

7 files changed

+62
-4
lines changed

7 files changed

+62
-4
lines changed

‎src/channel/index.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import tutorialConfig from '../actions/tutorialConfig'
88
import{COMMANDS}from'../editor/commands'
99
importloggerfrom'../services/logger'
1010
importContextfrom'./context'
11+
import{openWorkspace,checkWorkspaceEmpty}from'../services/workspace'
1112

1213
interfaceChannel{
1314
receive(action:T.Action):Promise<void>
@@ -108,6 +109,15 @@ class Channel implements Channel {
108109
// update the current stepId on startup
109110
vscode.commands.executeCommand(COMMANDS.SET_CURRENT_STEP,action.payload)
110111
return
112+
case'EDITOR_CHECK_WORKSPACE':
113+
constisEmptyWorkspace=awaitcheckWorkspaceEmpty(this.workspaceRoot.uri.path)
114+
if(isEmptyWorkspace){
115+
this.send({type:'IS_EMPTY_WORKSPACE'})
116+
}else{
117+
openWorkspace()
118+
this.send({type:'REQUEST_WORKSPACE'})
119+
}
120+
return
111121
// load step actions (git commits, commands, open files)
112122
case'SETUP_ACTIONS':
113123
awaitvscode.commands.executeCommand(COMMANDS.SET_CURRENT_STEP,action.payload)

‎src/services/testRunner/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
importnodefrom'../../services/node'
2-
importloggerfrom'../../services/logger'
1+
importnodefrom'../node'
2+
importloggerfrom'../logger'
33
importparserfrom'./parser'
44
import{debounce,throttle}from'./throttle'
55
importonErrorfrom'../sentry/onError'

‎src/services/workspace/index.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import*asvscodefrom'vscode'
2+
import*asfsfrom'fs'
3+
4+
exportconstopenWorkspace=()=>{
5+
vscode.commands.executeCommand('vscode.openFolder')
6+
}
7+
8+
exportconstcheckWorkspaceEmpty=async(dirname:string)=>{
9+
letfiles
10+
try{
11+
files=awaitfs.promises.readdir(dirname)
12+
}catch(error){
13+
thrownewError('Failed to check workspace')
14+
}
15+
returnfiles.length===0
16+
}

‎typings/index.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ export interface MachineStateSchema {
7373
Error:{}
7474
LoadStoredTutorial:{}
7575
Start:{}
76+
CheckEmptyWorkspace:{}
77+
RequestEmptyWorkspace:{}
7678
SelectTutorial:{}
7779
LoadTutorialSummary:{}
7880
Summary:{}

‎web-app/src/Routes.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,15 @@ const Routes = () => {
1414
<Workspace>
1515
<Router>
1616
{/* Setup */}
17-
<Routepath={['Setup.Startup','Setup.Authenticate','Setup.LoadStoredTutorial']}>
17+
<Route
18+
path={[
19+
'Setup.Startup',
20+
'Setup.Authenticate',
21+
'Setup.LoadStoredTutorial',
22+
'Setup.CheckEmptyWorkspace',
23+
'Setup.RequestEmptyWorkspace',
24+
]}
25+
>
1826
<LoadingPagetext="Launching..."context={context}/>
1927
</Route>
2028
<Routepath="Setup.Start">

‎web-app/src/services/state/actions/editor.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,4 +70,13 @@ export default (editorSend: any) => ({
7070
clearStorage():void{
7171
editorSend({type:'TUTORIAL_CLEAR'})
7272
},
73+
checkEmptyWorkspace(){
74+
editorSend({
75+
type:'EDITOR_CHECK_WORKSPACE',
76+
})
77+
},
78+
requestEmptyWorkspace(){
79+
// TODO
80+
console.log('request empty workspace')
81+
},
7382
})

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

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,26 @@ export const createMachine = (options: any) => {
6868
},
6969
Start:{
7070
on:{
71-
NEW_TUTORIAL:'SelectTutorial',
71+
NEW_TUTORIAL:'CheckEmptyWorkspace',
7272
CONTINUE_TUTORIAL:{
7373
target:'#tutorial-level',
7474
actions:['continueConfig'],
7575
},
7676
},
7777
},
78+
CheckEmptyWorkspace:{
79+
onEntry:['checkEmptyWorkspace'],
80+
on:{
81+
REQUEST_WORKSPACE:'RequestEmptyWorkspace',
82+
IS_EMPTY_WORKSPACE:'SelectTutorial',
83+
},
84+
},
85+
RequestEmptyWorkspace:{
86+
onEntry:['requestWorkspaceSelection'],
87+
on:{
88+
WORKSPACE_LOADED:'CheckEmptyWorkspace',
89+
},
90+
},
7891
SelectTutorial:{
7992
onEntry:['clearStorage'],
8093
id:'select-new-tutorial',

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp