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

Commitadb575b

Browse files
committed
prepare cleanup editor unused
1 parentd30f865 commitadb575b

File tree

12 files changed

+48
-199
lines changed

12 files changed

+48
-199
lines changed

‎src/editor/ReactWebView.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,7 @@ class ReactWebView {
3838
constonReceive=(action:string|CR.Action)=>{
3939
constactionType:string=typeofaction==='string' ?action :action.type
4040
switch(actionType){
41-
case'WEBVIEW_LOADED':
42-
// await loading of webview in React before proceeding with loaded state
43-
this.loaded=true
44-
break
4541
case'TUTORIAL_START':
46-
console.log('TUTORIAL_START called')
47-
console.log(action)
4842
if(typeofaction==='string'||!action.payload||!action.payload.id){
4943
thrownewError('No tutorial id on tutorial start action')
5044
}

‎src/editor/commands/index.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import * as CR from 'typings'
33
import*asGfrom'typings/graphql'
44
import*asvscodefrom'vscode'
55
importReactWebViewfrom'../ReactWebView'
6-
importstoragefrom'../storage'
76
importrunTestfrom'./runTest'
87
import{isEmptyWorkspace}from'../workspace'
98

@@ -52,9 +51,6 @@ export const createCommands = ({vscodeExt}: CreateCommandProps) => {
5251
webviewState='RESTARTING'
5352
}
5453

55-
// ini
56-
storage.init(vscodeExt.workspaceState)
57-
5854
// activate machine
5955
webview=newReactWebView(vscodeExt.extensionPath)
6056
if(webviewState==='INITIALIZING'){

‎src/editor/commands/loadSolution.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@ import {TutorialModel} from '../../services/tutorial'
44
import{gitLoadCommits,gitClear}from'../../services/git'
55

66
exportdefaultasyncfunctionloadSolution(dispatch:CR.EditorDispatch,tutorialModel:TutorialModel):Promise<void>{
7-
conststep:G.Step=tutorialModel.step()
8-
constsolution=step.solution
7+
// TODO: should load same as commits
98

10-
awaitgitClear()
11-
awaitgitLoadCommits(solution,dispatch)
9+
// const step: G.Step = tutorialModel.step()
10+
// const solution = step.solution
11+
12+
// await gitClear()
13+
// await gitLoadCommits(solution, dispatch)
1214

1315
}

‎src/editor/commands/runTest.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import*asvscodefrom'vscode'
22
import{exec}from'../../services/node'
3-
import*asstoragefrom'../../services/storage'
43

54
// ensure only latest run_test action is taken
65
letcurrentId=0
@@ -51,7 +50,7 @@ export default async function runTest({onSuccess, onFail}: Props): Promise<void>
5150
try{
5251
// capture position early on test start
5352
// in case position changes
54-
const[position,{stdout}]=awaitPromise.all([storage.getPosition(),exec(commandLine)])
53+
const{stdout}=awaitexec(commandLine)
5554
if(shouldExitEarly(processId)){
5655
// exit early
5756
return

‎src/editor/index.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@ class Editor {
3131
for(constdisposableofthis.vscodeExt.subscriptions){
3232
disposable.dispose()
3333
}
34-
// shut down state machine
35-
console.log('deactivate machine')
3634
}
3735

3836
// execute vscode command

‎src/editor/workspace.ts

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,43 @@
11
import*asfsfrom'fs'
22
import*aspathfrom'path'
33
import*asvscodefrom'vscode'
4-
import{exec,exists}from'../services/node'
4+
import{exec,exists}from'../services/node'
55

66
exportasyncfunctionisEmptyWorkspace():Promise<boolean>{
7-
const{stdout, stderr}=awaitexec('ls')
8-
if(stderr){
9-
thrownewError('Error validating if project is empty')
10-
}
11-
return!stdout.length
7+
const{stdout, stderr}=awaitexec('ls')
8+
if(stderr){
9+
thrownewError('Error validating if project is empty')
10+
}
11+
return!stdout.length
1212
}
1313

1414
// // TODO: workspace change listener
1515
exportasyncfunctionopenReadme():Promise<void>{
16-
const{stderr}=awaitexec('ls')
17-
if(stderr){
18-
thrownewError('Error looking for initial file')
19-
}
16+
const{stderr}=awaitexec('ls')
17+
if(stderr){
18+
thrownewError('Error looking for initial file')
19+
}
2020

21-
constfile='README.md'
22-
constfilePath=path.join(vscode.workspace.rootPath||'',file)
23-
console.log('filePath',filePath)
24-
consthasReadme=awaitexists(file)
21+
constfile='README.md'
22+
constfilePath=path.join(vscode.workspace.rootPath||'',file)
23+
console.log('filePath',filePath)
24+
consthasReadme=awaitexists(file)
2525

26-
if(!hasReadme){
27-
// add readme if none exists
28-
try{
29-
constcontent='# Welcome to CodeRoad!'
30-
fs.writeFileSync(filePath,content,'utf8')
31-
}catch(error){
32-
thrownewError('Error writingREADM.md')
33-
}
34-
}
26+
if(!hasReadme){
27+
// add readme if none exists
28+
try{
29+
constcontent='# Welcome to CodeRoad!'
30+
fs.writeFileSync(filePath,content,'utf8')
31+
}catch(error){
32+
thrownewError('Error writingREADME.md')
33+
}
34+
}
3535

36-
try{
37-
constopenPath=vscode.Uri.parse(filePath)
38-
constdoc=awaitvscode.workspace.openTextDocument(openPath)
39-
awaitvscode.window.showTextDocument(doc)
40-
}catch(error){
41-
thrownewError('Error opening README doc')
42-
}
36+
try{
37+
constopenPath=vscode.Uri.parse(filePath)
38+
constdoc=awaitvscode.workspace.openTextDocument(openPath)
39+
awaitvscode.window.showTextDocument(doc)
40+
}catch(error){
41+
thrownewError('Error opening README doc')
42+
}
4343
}

‎src/environment.ts

Lines changed: 0 additions & 11 deletions
This file was deleted.

‎src/services/git/errorMessages.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
interfaceErrorMessageFilter{
2-
[lang:string]:{
3-
[key:string]:string
4-
}
2+
[lang:string]:{
3+
[key:string]:string
4+
}
55
}
66

7+
// likely should be loaded on startup
78
consterrorMessages:ErrorMessageFilter={
8-
js:{
9-
'node-gyp':'Error running npm setup command'
10-
}
9+
js:{
10+
'node-gyp':'Error running npm setup command'
11+
}
1112
}
1213

1314
exportdefaulterrorMessages

‎src/services/tutorial/index.ts

Lines changed: 3 additions & 114 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import*asGfrom'typings/graphql'
22
import*asCRfrom'typings'
33
import*asgitfrom'../../services/git'
4-
import{machine}from'../../extension'
5-
import*asstoragefrom'../storage'
64

75
interfaceTutorialConfig{
86
codingLanguage:G.EnumCodingLanguage
@@ -16,10 +14,7 @@ export interface TutorialModel {
1614
position:CR.Position
1715
progress:CR.Progress
1816
launch(tutorial:G.Tutorial):void
19-
updateProgress():void
20-
nextPosition():CR.Position
2117
hasExisting():Promise<boolean>
22-
syncClient():void
2318
triggerCurrent(stepActions:G.StepActions):void
2419
}
2520

@@ -29,7 +24,6 @@ class Tutorial implements TutorialModel {
2924
publicversion:G.TutorialVersion
3025
publicposition:CR.Position
3126
publicprogress:CR.Progress
32-
publicsyncClient:()=>void
3327
publicopenFile:(file:string)=>void
3428

3529
constructor(editorDispatch:CR.EditorDispatch){
@@ -40,11 +34,6 @@ class Tutorial implements TutorialModel {
4034
this.version={}asG.TutorialVersion
4135
this.position={}asCR.Position
4236
this.progress={}asCR.Progress
43-
this.syncClient=()=>editorDispatch('coderoad.send_data',{
44-
tutorial:{id:this.version.tutorialId},
45-
progress:this.progress,
46-
position:this.position,
47-
})
4837
this.openFile=(file:string)=>editorDispatch('coderoad.open_file',file)
4938
}
5039
publiclaunch=async(tutorial:G.Tutorial)=>{
@@ -71,42 +60,11 @@ class Tutorial implements TutorialModel {
7160
this.version=tutorial.version
7261
console.log('version',this.version)
7362

74-
// set initial position
75-
this.position={
76-
levelId:this.version.levels[0].id,
77-
stageId:this.version.levels[0].stages[0].id,
78-
stepId:this.version.levels[0].stages[0].steps[0].id,
79-
}
80-
// set empty initial progress
81-
this.progress={
82-
levels:{},
83-
stages:{},
84-
steps:{},
85-
complete:false,
86-
}
87-
88-
// setup git, git remote
89-
90-
91-
awaitthis.syncClient()
92-
93-
// set tutorial, position, progress locally
94-
// TODO: base position off of progress
95-
Promise.all([
96-
storage.setTutorial(tutorial),
97-
storage.setPosition(this.position),
98-
storage.setProgress(this.progress)
99-
])
100-
101-
console.log('tutorial loaded')
102-
machine.send('TUTORIAL_LOADED')
10363
}
10464

10565
publicasynchasExisting():Promise<boolean>{
106-
const[tutorial,progress]=awaitPromise.all([
107-
storage.getTutorial(),
108-
storage.getProgress(),
109-
])
66+
// instead should configure git if does not exist
67+
// and update git to current position
11068

11169
// verify git is setup with a coderoad remote
11270
const[hasGit,hasGitRemote]=awaitPromise.all([
@@ -115,82 +73,13 @@ class Tutorial implements TutorialModel {
11573
])
11674
// TODO: may need to clean up git remote if no existing tutorial
11775

118-
constcanContinue=!!(tutorial&&progress&&hasGit&&hasGitRemote)
76+
constcanContinue=!!(hasGit&&hasGitRemote)
11977

12078
returncanContinue
12179
}
12280
publictriggerCurrent=(stepActions:G.StepActions)=>{
12381
git.gitLoadCommits(stepActions,this.openFile)
12482
}
125-
publicupdateProgress=()=>{
126-
const{levelId, stageId, stepId}=this.position
127-
this.progress.levels[levelId]=true
128-
this.progress.stages[stageId]=true
129-
this.progress.steps[stepId]=true
130-
131-
this.syncClient()
132-
}
133-
publicnextPosition=():CR.Position=>{
134-
const{levelId, stageId, stepId}=this.position
135-
// TODO: calculate and return next position
136-
137-
// is next step
138-
conststage:G.Stage|null=this.stage(stageId)
139-
if(!stage){
140-
thrownewError('Stage not found')
141-
}
142-
const{steps}=stage
143-
constindexOfStep=steps.findIndex((s:G.Step):boolean=>s.id===stepId)
144-
if(indexOfStep===-1){
145-
thrownewError('Step not found')
146-
}
147-
if(indexOfStep<steps.length-1){
148-
149-
return{
150-
levelId,
151-
stageId,
152-
stepId:steps[indexOfStep+1].id
153-
}
154-
}
155-
156-
// is next stage
157-
constlevel:G.Level|null=this.level(levelId)
158-
if(!level){
159-
thrownewError('Level not found')
160-
}
161-
const{stages}=level
162-
constindexOfStage=stages.findIndex((s:G.Stage):boolean=>s.id===stageId)
163-
if(indexOfStage===-1){
164-
thrownewError('Stage not found')
165-
}
166-
if(indexOfStage<stages.length-1){
167-
// next stage
168-
constnextStage=stages[indexOfStage+1]
169-
return{
170-
levelId,
171-
stageId:nextStage.id,
172-
stepId:nextStage.steps[0].id
173-
}
174-
}
175-
176-
// is next level
177-
constlevels=this.version.levels
178-
constindexOfLevel=levels.findIndex((l:G.Level):boolean=>l.id===levelId)
179-
if(indexOfLevel===-1){
180-
thrownewError('Level not found')
181-
}
182-
if(indexOfLevel<levels.length-1){
183-
constnextLevel=levels[indexOfLevel+1]
184-
constnextStage=nextLevel.stages[0]
185-
return{
186-
levelId:nextLevel.id,
187-
stageId:nextStage.id,
188-
stepId:nextStage.steps[0].id,
189-
}
190-
}
191-
192-
thrownewError('Could not calculate next position')
193-
}
19483
}
19584

19685
exportdefaultTutorial

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

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,6 @@ export default {
8080
conststageIndex=stages.findIndex((s:G.Stage)=>s.id===position.stageId)
8181
conststage:G.Stage=stages[stageIndex+1]
8282

83-
console.log('stage load next',stage.id,position.stageId)
84-
8583
constnextPosition:CR.Position={
8684
...position,
8785
stageId:stage.id,
@@ -104,8 +102,6 @@ export default {
104102
constlevelIndex=levels.findIndex((l:G.Level)=>l.id===position.levelId)
105103
constlevel:G.Level=levels[levelIndex+1]
106104

107-
console.log('level load next',level.id,position.levelId)
108-
109105
constnextPosition:CR.Position={
110106
levelId:level.id,
111107
stageId:level.stages[0].id,
@@ -123,7 +119,6 @@ export default {
123119
// update progress by tracking completed
124120
constcurrentProgress:CR.Progress=context.progress
125121
conststepId=event.payload.stepId
126-
console.log('step progress update',stepId)
127122

128123
currentProgress.steps[stepId]=true
129124

@@ -139,7 +134,6 @@ export default {
139134
const{progress, position}=context
140135

141136
conststageId:string=position.stageId
142-
console.log('stage progress update',stageId)
143137

144138
progress.stages[stageId]=true
145139

@@ -151,7 +145,6 @@ export default {
151145
//@ts-ignore
152146
updatePosition:assign({
153147
position:(context:CR.MachineContext,event:CR.MachineEvent):CR.Progress=>{
154-
console.log('updatePosition event',event)
155148
const{position}=event.payload
156149
returnposition
157150
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp