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

Commitcc0a677

Browse files
authored
Merge pull request#58 from ShMcK/feature/show-test-running
Feature/show command running
2 parentscf535e8 +b148fa5 commitcc0a677

File tree

28 files changed

+749
-571
lines changed

28 files changed

+749
-571
lines changed

‎src/actions/setupActions.ts

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,23 @@
1+
import*asTfrom'typings'
12
import*asGfrom'typings/graphql'
23
import*asvscodefrom'vscode'
34
import*asgitfrom'../services/git'
4-
importnodefrom'../services/node'
55

66
importopenFilesfrom'./utils/openFiles'
77
importloadWatchersfrom'./utils/loadWatchers'
8+
importrunCommandsfrom'./utils/runCommands'
89

9-
construnCommands=async(commands:string[])=>{
10-
if(!commands.length){
11-
return
12-
}
13-
for(constcommandofcommands){
14-
const{ stdout, stderr}=awaitnode.exec(command)
15-
if(stderr){
16-
console.error(stderr)
17-
}
18-
console.log(`run command:${command}`,stdout)
19-
}
20-
}
21-
22-
constsetupActions=async(workspaceRoot:vscode.WorkspaceFolder,actions:G.StepActions):Promise<void>=>{
10+
constsetupActions=async(
11+
workspaceRoot:vscode.WorkspaceFolder,
12+
actions:G.StepActions,
13+
send:(action:T.Action)=>void,// send messages to client
14+
):Promise<void>=>{
2315
const{ commands, commits, files, watchers}=actions
2416

2517
// 1. run commits
2618
if(commits){
2719
for(constcommitofcommits){
20+
// TODO handle git errors
2821
awaitgit.loadCommit(commit)
2922
}
3023
}
@@ -36,7 +29,7 @@ const setupActions = async (workspaceRoot: vscode.WorkspaceFolder, actions: G.St
3629
loadWatchers(watchers||[],workspaceRoot.uri)
3730

3831
// 4. run command
39-
awaitrunCommands(commands||[])
32+
awaitrunCommands(commands||[],send)
4033
}
4134

4235
exportdefaultsetupActions

‎src/actions/solutionActions.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
1+
import*asTfrom'typings'
12
import*asGfrom'typings/graphql'
23
import*asvscodefrom'vscode'
34
import*asgitfrom'../services/git'
45
importsetupActionsfrom'./setupActions'
56

6-
constsolutionActions=async(workspaceRoot:vscode.WorkspaceFolder,stepActions:G.StepActions):Promise<void>=>{
7+
constsolutionActions=async(
8+
workspaceRoot:vscode.WorkspaceFolder,
9+
stepActions:G.StepActions,
10+
send:(action:T.Action)=>void,
11+
):Promise<void>=>{
712
awaitgit.clear()
8-
returnsetupActions(workspaceRoot,stepActions)
13+
returnsetupActions(workspaceRoot,stepActions,send)
914
}
1015

1116
exportdefaultsolutionActions

‎src/actions/utils/runCommands.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import*asTfrom'typings'
2+
importnodefrom'../../services/node'
3+
4+
construnCommands=async(commands:string[],send:(action:T.Action)=>void)=>{
5+
if(!commands.length){
6+
return
7+
}
8+
for(constcommandofcommands){
9+
constprocess={
10+
title:command,
11+
description:'Running process...',
12+
}
13+
send({type:'COMMAND_START',payload:{process:{ ...process,status:'RUNNING'}}})
14+
letresult:{stdout:string;stderr:string}
15+
try{
16+
result=awaitnode.exec(command)
17+
}catch(error){
18+
console.log(error)
19+
send({type:'COMMAND_FAIL',payload:{process:{ ...process,status:'FAIL'}}})
20+
return
21+
}
22+
console.log(result.stdout)
23+
send({type:'COMMAND_SUCCESS',payload:{process:{ ...process,status:'SUCCESS'}}})
24+
}
25+
}
26+
27+
exportdefaultrunCommands

‎src/channel/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ class Channel implements Channel {
9393
if(data.init){
9494
constsetup:G.StepActions|null|undefined=data.init.setup
9595
if(setup){
96-
setupActions(this.workspaceRoot,setup)
96+
setupActions(this.workspaceRoot,setup,this.send)
9797
}
9898
}
9999

@@ -119,11 +119,11 @@ class Channel implements Channel {
119119
// load step actions (git commits, commands, open files)
120120
case'SETUP_ACTIONS':
121121
vscode.commands.executeCommand(COMMANDS.SET_CURRENT_STEP,action.payload)
122-
setupActions(this.workspaceRoot,action.payload)
122+
setupActions(this.workspaceRoot,action.payload,this.send)
123123
return
124124
// load solution step actions (git commits, commands, open files)
125125
case'SOLUTION_ACTIONS':
126-
awaitsolutionActions(this.workspaceRoot,action.payload)
126+
awaitsolutionActions(this.workspaceRoot,action.payload,this.send)
127127
// run test following solution to update position
128128
vscode.commands.executeCommand(COMMANDS.RUN_TEST,action.payload)
129129
return

‎typings/index.d.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ export interface MachineContext {
4343
tutorial:G.Tutorial|null
4444
position:Position
4545
progress:Progress
46+
processes:ProcessEvent[]
4647
}
4748

4849
exportinterfaceMachineEvent{
@@ -103,3 +104,9 @@ interface MessageState {
103104

104105
// todo: type each string param and payload
105106
exporttypeEditorDispatch=(type:string,payload?:MessageData|MessageState|any)=>void
107+
108+
exportinterfaceProcessEvent{
109+
title:string
110+
description:string
111+
status:'RUNNING'|'SUCCESS'|'FAIL'|'ERROR'
112+
}

‎web-app/package-lock.json

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎web-app/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
"babel-loader":"8.0.5",
6666
"babel-plugin-import":"^1.12.1",
6767
"eslint":"^6.6.0",
68-
"eslint-config-prettier":"^6.5.0",
68+
"eslint-config-prettier":"^6.6.0",
6969
"eslint-plugin-prettier":"^3.1.1",
7070
"node-sass":"^4.13.0",
7171
"prettier":"^1.19.1",
Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,37 @@
11
import*asReactfrom'react'
22

33
conststyles={
4-
box:{
5-
display:'flex',
6-
alignItems:'center',
7-
justifyContent:'center',
8-
},
9-
input:{
10-
border:'1px solid black',
11-
backgroundColor:'yellow',
12-
},
4+
box:{
5+
display:'flex',
6+
alignItems:'center',
7+
justifyContent:'center',
8+
},
9+
input:{
10+
border:'1px solid black',
11+
},
12+
loading:{
13+
backgroundColor:'red',
14+
},
1315
}
1416

1517
interfaceProps{
16-
status:'COMPLETE'|'INCOMPLETE'|'ACTIVE'|'LOADING'
18+
status:'COMPLETE'|'INCOMPLETE'|'ACTIVE'
1719
}
1820

1921
constCheckbox=(props:Props)=>{
20-
constchecked=props.status==='COMPLETE'
21-
// const loading = props.state === 'LOADING'
22-
constonChange=()=>{
23-
/* read */
24-
}
25-
return(
26-
<divstyle={styles.box}>
27-
<label>
28-
<inputstyle={styles.input}type="checkbox"checked={checked}onChange={onChange}/>
29-
</label>
30-
</div>
31-
)
22+
constonChange=()=>{
23+
/* read only */
24+
}
25+
26+
constchecked=props.status==='COMPLETE'
27+
28+
return(
29+
<divstyle={styles.box}>
30+
<label>
31+
<inputstyle={styles.input}type="checkbox"checked={checked}onChange={onChange}/>
32+
</label>
33+
</div>
34+
)
3235
}
3336

3437
exportdefaultCheckbox
Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,22 @@
11
import*asReactfrom'react'
2-
import*asGfrom'typings/graphql'
3-
import*asCRfrom'typings'
2+
import*asTfrom'typings'
43

5-
interfaceProps{
6-
state:string
7-
tutorial:G.Tutorial
8-
env:CR.Environment
9-
position:CR.Position
10-
progress:CR.Progress
11-
children:React.ReactElement
4+
interfacePropsextendsT.MachineContext{
5+
state:string
6+
children:React.ReactElement
127
}
138

14-
constDebugger=({ state, children, env, position, progress, tutorial}:Props)=>(
15-
<divstyle={{backgroundColor:'#FFFF99',color:'black',padding:'.5rem'}}>
16-
<h4>state:{state}</h4>
17-
<p>MachineId:{env.machineId}</p>
18-
<p>SessionId:{env.sessionId}</p>
19-
<p>tutorial:{tutorial ?tutorial.id :'none'}</p>
20-
<pstyle={{backgroundColor:'khaki',padding:'.5rem'}}>position:{JSON.stringify(position)}</p>
21-
<pstyle={{backgroundColor:'moccasin',padding:'.5rem'}}>progress:{JSON.stringify(progress)}</p>
22-
{children}
23-
</div>
9+
constDebugger=({ state, children, env, position, progress, processes, tutorial}:Props)=>(
10+
<divstyle={{backgroundColor:'#FFFF99',color:'black',padding:'.5rem'}}>
11+
<h4>state:{state}</h4>
12+
<p>MachineId:{env.machineId}</p>
13+
<p>SessionId:{env.sessionId}</p>
14+
<p>tutorial:{tutorial ?tutorial.id :'none'}</p>
15+
<pstyle={{backgroundColor:'khaki',padding:'.5rem'}}>position:{JSON.stringify(position)}</p>
16+
<pstyle={{backgroundColor:'moccasin',padding:'.5rem'}}>progress:{JSON.stringify(progress)}</p>
17+
<pstyle={{backgroundColor:'beige',padding:'.5rem'}}>processes:{JSON.stringify(processes)}</p>
18+
{children}
19+
</div>
2420
)
2521

2622
exportdefaultDebugger
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import*asReactfrom'react'
2+
import{MessageasAlifdMessage}from'@alifd/next'
3+
import*asTfrom'typings'
4+
5+
interfaceProps{
6+
processes:T.ProcessEvent[]
7+
}
8+
9+
conststyles={
10+
container:{
11+
display:'flex',
12+
flexDirection:'column'as'column',
13+
},
14+
}
15+
16+
// display a list of active processes
17+
constProcessEvents=({ processes}:Props)=>{
18+
if(!processes.length){
19+
returnnull
20+
}
21+
return(
22+
<divstyle={styles.container}>
23+
{processes.map(process=>(
24+
<AlifdMessagekey={process.title}type="loading"size="medium"title={process.title}>
25+
{process.description}
26+
</AlifdMessage>
27+
))}
28+
</div>
29+
)
30+
}
31+
32+
exportdefaultProcessEvents
Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,31 @@
11
import*asReactfrom'react'
22

33
interfaceProps{
4-
children:React.ReactElement
4+
children:React.ReactElement
55
}
66

77
constresize=()=>({
8-
minWidth:window.innerWidth-20,
9-
minHeight:window.innerHeight-20,
8+
width:window.innerWidth-20,
9+
height:window.innerHeight-20,
1010
})
1111

1212
constWorkspace=({ children}:Props)=>{
13-
const[dimensions,setDimensions]=React.useState(resize())
13+
const[dimensions,setDimensions]=React.useState(resize())
1414

15-
// solution for windows getting off size
16-
React.useEffect(()=>{
17-
setDimensions(resize())
18-
},[window.innerHeight,window.innerWidth])
15+
// solution for windows getting off size
16+
React.useEffect(()=>{
17+
setDimensions(resize())
18+
},[window.innerHeight,window.innerWidth])
1919

20-
conststyles={
21-
page:{
22-
display:'flex'as'flex',
23-
margin:0,
24-
backgroundColor:'white',
25-
},
26-
}
20+
conststyles={
21+
page:{
22+
display:'flex'as'flex',
23+
margin:0,
24+
backgroundColor:'white',
25+
},
26+
}
2727

28-
return<divstyle={{ ...styles.page, ...dimensions}}>{children}</div>
28+
return<divstyle={{ ...styles.page, ...dimensions}}>{children}</div>
2929
}
3030

3131
exportdefaultWorkspace

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp