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

Commite018584

Browse files
committed
track git config errors
1 parentf0b8025 commite018584

File tree

6 files changed

+192
-170
lines changed

6 files changed

+192
-170
lines changed

‎src/actions/tutorialConfig.ts

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import*asTfrom'typings'
12
import*asGfrom'typings/graphql'
23
import*asvscodefrom'vscode'
34
import*asgitfrom'../services/git'
@@ -10,13 +11,25 @@ interface TutorialConfigParams {
1011
onComplete?():void
1112
}
1213

13-
consttutorialConfig=async({ config, alreadyConfigured}:TutorialConfigParams)=>{
14+
consttutorialConfig=async(
15+
{ config, alreadyConfigured}:TutorialConfigParams,
16+
onError:(msg:T.ErrorMessage)=>void,
17+
)=>{
1418
if(!alreadyConfigured){
1519
// setup git, add remote
16-
awaitgit.initIfNotExists()
20+
awaitgit.initIfNotExists().catch(error=>{
21+
// failed to setup git
22+
onError({
23+
title:error.message,
24+
description:
25+
'Be sure you install Git. See the docs for help https://git-scm.com/book/en/v2/Getting-Started-Installing-Git',
26+
})
27+
})
1728

1829
// TODO: if remote not already set
19-
awaitgit.setupRemote(config.repo.uri)
30+
awaitgit.setupRemote(config.repo.uri).catch(error=>{
31+
onError({title:error.message,description:'Remove your current Git project and restarting'})
32+
})
2033
}
2134

2235
vscode.commands.executeCommand(COMMANDS.CONFIG_TEST_RUNNER,config.testRunner)

‎src/channel/index.ts

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import*asCRfrom'typings'
1+
import*asTfrom'typings'
22
import*asGfrom'typings/graphql'
33
import*asvscodefrom'vscode'
44

@@ -10,18 +10,18 @@ import saveCommit from '../actions/saveCommit'
1010
import{COMMANDS}from'../editor/commands'
1111

1212
interfaceChannel{
13-
receive(action:CR.Action):Promise<void>
14-
send(action:CR.Action):Promise<void>
13+
receive(action:T.Action):Promise<void>
14+
send(action:T.Action):Promise<void>
1515
}
1616

1717
interfaceChannelProps{
18-
postMessage:(action:CR.Action)=>Thenable<boolean>
18+
postMessage:(action:T.Action)=>Thenable<boolean>
1919
workspaceState:vscode.Memento
2020
workspaceRoot:vscode.WorkspaceFolder
2121
}
2222

2323
classChannelimplementsChannel{
24-
privatepostMessage:(action:CR.Action)=>Thenable<boolean>
24+
privatepostMessage:(action:T.Action)=>Thenable<boolean>
2525
privateworkspaceState:vscode.Memento
2626
privateworkspaceRoot:vscode.WorkspaceFolder
2727
privatecontext:Context
@@ -34,9 +34,10 @@ class Channel implements Channel {
3434
}
3535

3636
// receive from webview
37-
publicreceive=async(action:CR.Action)=>{
37+
publicreceive=async(action:T.Action)=>{
3838
// action may be an object.type or plain string
3939
constactionType:string=typeofaction==='string' ?action :action.type
40+
constonError=(error:T.ErrorMessage)=>this.send({type:'ERROR',payload:{ error}})
4041

4142
// console.log('EDITOR RECEIVED:', actionType)
4243
switch(actionType){
@@ -87,7 +88,7 @@ class Channel implements Channel {
8788

8889
constdata:G.TutorialData=tutorialData.version.data
8990

90-
awaittutorialConfig({config:data.config})
91+
awaittutorialConfig({config:data.config},onError)
9192

9293
// run init setup actions
9394
if(data.init){
@@ -106,10 +107,13 @@ class Channel implements Channel {
106107
thrownewError('Invalid tutorial to continue')
107108
}
108109
constcontinueConfig:G.TutorialConfig=tutorialContinue.version.data.config
109-
tutorialConfig({
110-
config:continueConfig,
111-
alreadyConfigured:true,
112-
})
110+
tutorialConfig(
111+
{
112+
config:continueConfig,
113+
alreadyConfigured:true,
114+
},
115+
onError,
116+
)
113117
return
114118
case'EDITOR_SYNC_PROGRESS':
115119
// sync client progress on server
@@ -134,7 +138,7 @@ class Channel implements Channel {
134138
}
135139
}
136140
// send to webview
137-
publicsend=async(action:CR.Action)=>{
141+
publicsend=async(action:T.Action)=>{
138142
console.log(`EDITOR SEND${action.type}`)
139143
// action may be an object.type or plain string
140144
constactionType:string=typeofaction==='string' ?action :action.type

‎src/services/git/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ export async function version(): Promise<string | boolean> {
8181
asyncfunctioninit():Promise<void>{
8282
const{ stderr}=awaitnode.exec('git init')
8383
if(stderr){
84-
thrownewError('Error initializingGits')
84+
thrownewError('Error initializingGit')
8585
}
8686
}
8787

@@ -133,5 +133,7 @@ export async function setupRemote(repo: string): Promise<void> {
133133
// git fetch coderoad
134134
if(!hasRemote){
135135
awaitaddRemote(repo)
136+
}else{
137+
thrownewError('A Remote is already configured')
136138
}
137139
}

‎web-app/src/containers/Tutorial/LevelPage/Level.tsx

Lines changed: 108 additions & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -8,124 +8,124 @@ import Markdown from '../../../components/Markdown'
88
importProcessEventsfrom'../../../components/ProcessEvents'
99

1010
conststyles={
11-
page:{
12-
backgroundColor:'white',
13-
position:'relative'as'relative',
14-
display:'flex'as'flex',
15-
flexDirection:'column'as'column',
16-
padding:0,
17-
paddingBottom:'36px',
18-
height:'auto',
19-
width:'100%',
20-
},
21-
header:{
22-
height:'36px',
23-
backgroundColor:'#EBEBEB',
24-
fontSize:'16px',
25-
lineHeight:'16px',
26-
padding:'10px 1rem',
27-
},
28-
content:{
29-
padding:'0rem 1rem',
30-
paddingBottom:'1rem',
31-
},
32-
tasks:{
33-
paddingBottom:'5rem',
34-
},
35-
steps:{
36-
padding:'1rem 16px',
37-
},
38-
title:{
39-
fontSize:'1.2rem',
40-
fontWeight:'bold'as'bold',
41-
lineHeight:'1.2rem',
42-
},
43-
processes:{
44-
padding:'0 1rem',
45-
position:'absolute'as'absolute',
46-
bottom:'36px',
47-
},
48-
footer:{
49-
display:'flex'as'flex',
50-
flexDirection:'row'as'row',
51-
justifyContent:'space-between',
52-
alignItems:'center',
53-
height:'36px',
54-
backgroundColor:'black',
55-
fontSize:'16px',
56-
lineHeight:'16px',
57-
padding:'10px 1rem',
58-
position:'fixed'as'fixed',
59-
bottom:0,
60-
left:0,
61-
right:0,
62-
color:'white',
63-
},
11+
page:{
12+
backgroundColor:'white',
13+
position:'relative'as'relative',
14+
display:'flex'as'flex',
15+
flexDirection:'column'as'column',
16+
padding:0,
17+
paddingBottom:'36px',
18+
height:'auto',
19+
width:'100%',
20+
},
21+
header:{
22+
height:'36px',
23+
backgroundColor:'#EBEBEB',
24+
fontSize:'16px',
25+
lineHeight:'16px',
26+
padding:'10px 1rem',
27+
},
28+
content:{
29+
padding:'0rem 1rem',
30+
paddingBottom:'1rem',
31+
},
32+
tasks:{
33+
paddingBottom:'5rem',
34+
},
35+
steps:{
36+
padding:'1rem 16px',
37+
},
38+
title:{
39+
fontSize:'1.2rem',
40+
fontWeight:'bold'as'bold',
41+
lineHeight:'1.2rem',
42+
},
43+
processes:{
44+
padding:'0 1rem',
45+
position:'absolute'as'absolute',
46+
bottom:'36px',
47+
},
48+
footer:{
49+
display:'flex'as'flex',
50+
flexDirection:'row'as'row',
51+
justifyContent:'space-between',
52+
alignItems:'center',
53+
height:'36px',
54+
backgroundColor:'black',
55+
fontSize:'16px',
56+
lineHeight:'16px',
57+
padding:'10px 1rem',
58+
position:'fixed'as'fixed',
59+
bottom:0,
60+
left:0,
61+
right:0,
62+
color:'white',
63+
},
6464
}
6565

6666
interfaceProps{
67-
level:G.Level&{status:T.ProgressStatus;index:number;steps:Array<G.Step&{status:T.ProgressStatus}>}
68-
processes:T.ProcessEvent[]
69-
onContinue():void
70-
onLoadSolution():void
67+
level:G.Level&{status:T.ProgressStatus;index:number;steps:Array<G.Step&{status:T.ProgressStatus}>}
68+
processes:T.ProcessEvent[]
69+
onContinue():void
70+
onLoadSolution():void
7171
}
7272

7373
constLevel=({ level, onContinue, onLoadSolution, processes}:Props)=>{
74-
if(!level.steps){
75-
thrownewError('No Stage steps found')
76-
}
74+
if(!level.steps){
75+
thrownewError('No Stage steps found')
76+
}
7777

78-
return(
79-
<divstyle={styles.page}>
80-
<divstyle={styles.header}>
81-
<span>Learn</span>
82-
</div>
83-
<divstyle={styles.content}>
84-
<h2style={styles.title}>{level.title}</h2>
85-
<Markdown>{level.content||''}</Markdown>
86-
</div>
78+
return(
79+
<divstyle={styles.page}>
80+
<divstyle={styles.header}>
81+
<span>Learn</span>
82+
</div>
83+
<divstyle={styles.content}>
84+
<h2style={styles.title}>{level.title}</h2>
85+
<Markdown>{level.content||''}</Markdown>
86+
</div>
8787

88-
<divstyle={styles.tasks}>
89-
<divstyle={styles.header}>Tasks</div>
90-
<divstyle={styles.steps}>
91-
{level.steps.map((step:(G.Step&{status:T.ProgressStatus})|null,index:number)=>{
92-
if(!step){
93-
returnnull
94-
}
95-
return(
96-
<Step
97-
key={step.id}
98-
order={index+1}
99-
status={step.status}
100-
content={step.content}
101-
onLoadSolution={onLoadSolution}
102-
/>
103-
)
104-
})}
105-
</div>
106-
</div>
88+
<divstyle={styles.tasks}>
89+
<divstyle={styles.header}>Tasks</div>
90+
<divstyle={styles.steps}>
91+
{level.steps.map((step:(G.Step&{status:T.ProgressStatus})|null,index:number)=>{
92+
if(!step){
93+
returnnull
94+
}
95+
return(
96+
<Step
97+
key={step.id}
98+
order={index+1}
99+
status={step.status}
100+
content={step.content}
101+
onLoadSolution={onLoadSolution}
102+
/>
103+
)
104+
})}
105+
</div>
106+
</div>
107107

108-
{processes.length>0&&(
109-
<divstyle={styles.processes}>
110-
<ProcessEventsprocesses={processes}/>
111-
</div>
112-
)}
108+
{processes.length>0&&(
109+
<divstyle={styles.processes}>
110+
<ProcessEventsprocesses={processes}/>
111+
</div>
112+
)}
113113

114-
<divstyle={styles.footer}>
115-
<span>
116-
{typeoflevel.index==='number' ?`${level.index+1}. ` :''}
117-
{level.title}
118-
</span>
119-
<span>
120-
{level.status==='COMPLETE'&&(
121-
<Buttontype="primary"onClick={onContinue}>
122-
Continue
123-
</Button>
124-
)}
125-
</span>
126-
</div>
127-
</div>
128-
)
114+
<divstyle={styles.footer}>
115+
<span>
116+
{typeoflevel.index==='number' ?`${level.index+1}. ` :''}
117+
{level.title}
118+
</span>
119+
<span>
120+
{level.status==='COMPLETE'&&(
121+
<Buttontype="primary"onClick={onContinue}>
122+
Continue
123+
</Button>
124+
)}
125+
</span>
126+
</div>
127+
</div>
128+
)
129129
}
130130

131131
exportdefaultLevel

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp