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

Commit8ff0a64

Browse files
authored
Merge pull request#43 from ShMcK/fix/update-to-api
Fix/update to api
2 parents72a14f8 +a792113 commit8ff0a64

File tree

40 files changed

+612
-680
lines changed

40 files changed

+612
-680
lines changed

‎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.

‎package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
"prettier":"^1.18.2",
5050
"tslint":"^5.20.0",
5151
"tslint-config-prettier":"^1.18.0",
52-
"typescript":"^3.6.4",
52+
"typescript":"^3.7.0-beta",
5353
"vscode":"^1.1.36",
5454
"vscode-test":"^1.2.0"
5555
},

‎src/actions/runTest.ts

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import*asvscodefrom'vscode'
22
importnodefrom'../services/node'
33

4+
// TODO: use tap parser to make it easier to support other test runners
5+
46
// ensure only latest run_test action is taken
57
letcurrentId=0
68

@@ -35,12 +37,6 @@ async function runTest({onSuccess, onFail, onRun, onError}: Props): Promise<void
3537

3638
constoutputChannelName='Test Output'
3739

38-
// TODO: validate test directory from package.json exists
39-
// let testFile = path.join('test');
40-
// if (!await exists(testFile)) {
41-
// return emptyTasks;
42-
// }
43-
4440
// TODO: verify test runner for args
4541
// jest CLI docs https://jestjs.io/docs/en/cli
4642
consttestArgs=[
@@ -51,12 +47,6 @@ async function runTest({onSuccess, onFail, onRun, onError}: Props): Promise<void
5147
'--maxWorkers=4'
5248
]
5349

54-
// if .git repo, use --onlyChanged
55-
// const hasGit = path.join('.git');
56-
// if (await exists(hasGit)) {
57-
// testArgs.push('--onlyChanged')
58-
// }
59-
6050
constcommandLine=`npm test --${testArgs.join(' ')}`
6151

6252
try{

‎src/actions/setupActions.ts

Lines changed: 33 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -40,39 +40,45 @@ const runCommands = async (commands: string[], language: string = 'JAVASCRIPT')
4040

4141
constsetupActions=async(workspaceRoot:vscode.WorkspaceFolder,{commands, commits, files}:G.StepActions):Promise<void>=>{
4242
// run commits
43-
for(constcommitofcommits){
44-
awaitgit.loadCommit(commit)
43+
if(commits){
44+
for(constcommitofcommits){
45+
awaitgit.loadCommit(commit)
46+
}
4547
}
4648

4749
// run command
48-
awaitrunCommands(commands)
50+
if(commands){
51+
awaitrunCommands(commands)
52+
}
4953

5054
// open files
51-
for(constfilePathoffiles){
52-
try{
53-
// TODO: figure out why this does not work
54-
// try {
55-
// const absoluteFilePath = join(workspaceRoot.uri.path, filePath)
56-
// const doc = await vscode.workspace.openTextDocument(absoluteFilePath)
57-
// await vscode.window.showTextDocument(doc, vscode.ViewColumn.One)
58-
// // there are times when initialization leave the panel behind any files opened
59-
// // ensure the panel is redrawn on the right side first
60-
// // webview.createOrShow()
61-
// } catch (error) {
62-
// console.log(`Failed to open file ${filePath}`, error)
63-
// }
64-
constwr=vscode.workspace.rootPath
65-
if(!wr){
66-
thrownewError('No workspace root path')
55+
if(files){
56+
for(constfilePathoffiles){
57+
try{
58+
// TODO: figure out why this does not work
59+
// try {
60+
// const absoluteFilePath = join(workspaceRoot.uri.path, filePath)
61+
// const doc = await vscode.workspace.openTextDocument(absoluteFilePath)
62+
// await vscode.window.showTextDocument(doc, vscode.ViewColumn.One)
63+
// // there are times when initialization leave the panel behind any files opened
64+
// // ensure the panel is redrawn on the right side first
65+
// // webview.createOrShow()
66+
// } catch (error) {
67+
// console.log(`Failed to open file ${filePath}`, error)
68+
// }
69+
constwr=vscode.workspace.rootPath
70+
if(!wr){
71+
thrownewError('No workspace root path')
72+
}
73+
constabsoluteFilePath=join(wr,filePath)
74+
constdoc=awaitvscode.workspace.openTextDocument(absoluteFilePath)
75+
awaitvscode.window.showTextDocument(doc,vscode.ViewColumn.One)
76+
// there are times when initialization leave the panel behind any files opened
77+
// ensure the panel is redrawn on the right side first
78+
vscode.commands.executeCommand('coderoad.open_webview')
79+
}catch(error){
80+
console.log(`Failed to open file${filePath}`,error)
6781
}
68-
constabsoluteFilePath=join(wr,filePath)
69-
constdoc=awaitvscode.workspace.openTextDocument(absoluteFilePath)
70-
awaitvscode.window.showTextDocument(doc,vscode.ViewColumn.One)
71-
// there are times when initialization leave the panel behind any files opened
72-
// ensure the panel is redrawn on the right side first
73-
vscode.commands.executeCommand('coderoad.open_webview')
74-
}catch(error){
75-
console.log(`Failed to open file${filePath}`,error)
7682
}
7783
}
7884
}

‎src/actions/tutorialConfig.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,27 @@ import * as vscode from 'vscode'
33
import*asgitfrom'../services/git'
44

55
interfaceTutorialConfigParams{
6-
tutorial:G.Tutorial,
6+
config:G.TutorialConfig,
77
alreadyConfigured?:boolean
88
onComplete?():void
99
}
1010

11-
consttutorialConfig=async({tutorial, alreadyConfigured, onComplete}:TutorialConfigParams)=>{
12-
console.log('---------- tutorialConfig -----------')
11+
consttutorialConfig=async({config, alreadyConfigured,}:TutorialConfigParams)=>{
1312
if(!alreadyConfigured){
1413
// setup git, add remote
1514
awaitgit.initIfNotExists()
1615

1716
// TODO: if remote not already set
18-
awaitgit.setupRemote(tutorial.repo.uri)
19-
if(onComplete){onComplete()}
17+
awaitgit.setupRemote(config.repo.uri)
2018
}
2119

22-
//TODO:allow multiple coding languages in a tutorial
23-
constlanguage=tutorial.codingLanguage.toLowerCase()
20+
// allow multiple coding languages in a tutorial
21+
constlanguages:string[]=config.codingLanguages.map((lang:G.CodingLanguage)=>lang.toLowerCase())
2422

2523
// setup onSave hook
2624
vscode.workspace.onDidSaveTextDocument((document:vscode.TextDocument)=>{
27-
if(document.uri.scheme==='file'&&language===document.languageId){
25+
//@ts-ignore // issue with GQL enums in TS
26+
if(document.uri.scheme==='file'&&languages.includes(document.languageId)){
2827
vscode.commands.executeCommand('coderoad.run_test')
2928
}
3029
})

‎src/channel/index.ts

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -82,21 +82,33 @@ class Channel implements Channel {
8282
return
8383
// configure test runner, language, git
8484
case'EDITOR_TUTORIAL_CONFIG':
85-
consttutorialData=action.payload.tutorial
85+
consttutorialData:G.Tutorial=action.payload.tutorial
86+
// setup tutorial config (save listener, test runner, etc)
8687
this.context.setTutorial(this.workspaceState,tutorialData)
87-
tutorialConfig({
88-
tutorial:tutorialData,
89-
// must await async git setup or commit loading fails
90-
onComplete:()=>this.send({type:'TUTORIAL_CONFIGURED'})
91-
})
88+
89+
constdata:G.TutorialData=tutorialData.version.data
90+
91+
awaittutorialConfig({config:data.config})
92+
93+
// run init setup actions
94+
if(data.init){
95+
constsetup:G.StepActions|null|undefined=data.init.setup
96+
if(setup){
97+
setupActions(this.workspaceRoot,setup)
98+
}
99+
}
100+
101+
// report back to the webview that setup is complete
102+
this.send({type:'TUTORIAL_CONFIGURED'})
92103
return
93104
case'EDITOR_TUTORIAL_CONTINUE_CONFIG':
94105
consttutorialContinue:G.Tutorial|null=this.context.tutorial.get()
95106
if(!tutorialContinue){
96107
thrownewError('Invalid tutorial to continue')
97108
}
109+
constcontinueConfig:G.TutorialConfig=tutorialContinue.version.data.config
98110
tutorialConfig({
99-
tutorial:tutorialContinue,
111+
config:continueConfig,
100112
alreadyConfigured:true
101113
})
102114
return

‎src/channel/state/Position.ts

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import * as G from 'typings/graphql'
33

44
constdefaultValue:CR.Position={
55
levelId:'',
6-
stageId:'',
76
stepId:'',
87
}
98

@@ -31,7 +30,11 @@ class Position {
3130
returnthis.value
3231
}
3332

34-
const{levels}=tutorial.version
33+
if(!tutorial||!tutorial.version||!tutorial.version.data||!tutorial.version.data.levels){
34+
thrownewError('Error setting position from progress')
35+
}
36+
37+
const{levels}=tutorial.version.data
3538

3639
constlastLevelIndex:number|undefined=levels.findIndex((l:G.Level)=>!progress.levels[l.id])
3740
// TODO: consider all levels complete as progress.complete
@@ -40,15 +43,7 @@ class Position {
4043
}
4144
constcurrentLevel:G.Level=levels[lastLevelIndex]
4245

43-
const{stages}=currentLevel
44-
45-
constlastStageIndex:number|undefined=stages.findIndex((s:G.Stage)=>!progress.stages[s.id])
46-
if(lastStageIndex>=stages.length){
47-
thrownewError('Error setting progress stage')
48-
}
49-
constcurrentStage:G.Stage=stages[lastStageIndex]
50-
51-
const{steps}=currentStage
46+
const{steps}=currentLevel
5247

5348
constlastStepIndex:number|undefined=steps.findIndex((s:G.Step)=>!progress.steps[s.id])
5449
if(lastStepIndex>=steps.length){
@@ -60,7 +55,6 @@ class Position {
6055

6156
this.value={
6257
levelId:currentLevel.id,
63-
stageId:currentStage.id,
6458
stepId:currentStep.id,
6559
}
6660
returnthis.value

‎src/channel/state/Progress.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import Storage from '../../services/storage'
66

77
constdefaultValue:CR.Progress={
88
levels:{},
9-
stages:{},
109
steps:{},
1110
complete:false
1211
}

‎src/editor/ReactWebView.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,6 @@ class ReactWebView {
5252

5353
// // // prevents moving coderoad panel on top of left panel
5454
// vscode.window.onDidChangeVisibleTextEditors((textEditors: vscode.TextEditor[]) => {
55-
// console.log('onDidChangeVisibleTextEditors')
56-
// console.log(textEditors)
5755
// // updateWindows()
5856
// })
5957

‎src/services/git/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export function loadCommit(commit: string): Promise<void> {
4242

4343
/*
4444
save commit
45-
git commit -am '${level}/${stage}/${step} complete'
45+
git commit -am '${level}/${step} complete'
4646
*/
4747

4848
exportasyncfunctionsaveCommit(message:string):Promise<void>{

‎src/services/storage/index.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ class Storage<T> {
1616
this.defaultValue=defaultValue
1717
}
1818
publicget=async():Promise<T>=>{
19-
constvalue:string|undefined=awaitthis.storage.get(this.key)
20-
if(value){
21-
returnJSON.parse(value)
22-
}
19+
//const value: string | undefined = await this.storage.get(this.key)
20+
//if (value) {
21+
//return JSON.parse(value)
22+
//}
2323
returnthis.defaultValue
2424
}
2525
publicset=(value:T):void=>{

‎src/test/runTest.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import * as path from 'path'
33
import{runTests}from'vscode-test'
44

55
asyncfunctionmain(){
6-
console.log('__dirname',__dirname)
76
// The folder containing the Extension Manifest package.json
87
// Passed to `--extensionDevelopmentPath`
98
constextensionDevelopmentPath:string=path.resolve(__dirname,'../../')

‎src/test/suite/extension.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ suite('Extension tests', () => {
1515
awaitvscode.commands.executeCommand('coderoad.start')
1616
awaitsetTimeout(()=>Promise.resolve(),5000)
1717
// const webview = vscode.window.activeTextEditor
18-
// console.log(webview)
1918
assert.equal(2,2)
2019
})
2120

‎typings/context.d.ts

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,18 @@
11
import*asCRfrom'./index'
22

3-
exportinterfaceStepextendsExclude<CR.TutorialStep,'actions'>{
4-
status:{
5-
complete:boolean
6-
active:boolean
7-
}
3+
interfaceProgressStatus{
4+
active:boolean
5+
complete:boolean
86
}
97

10-
exportinterfaceReceivedEvent{
11-
data:CR.Action
8+
exportinterfaceStepextendsExclude<CR.TutorialStep,'actions'>{
9+
status:ProgressStatus
1210
}
1311

14-
exportinterfaceStageStepStatus{
15-
active:boolean
16-
complete:boolean
12+
exportinterfaceReceivedEvent{
13+
data:CR.Action
1714
}
1815

19-
exportinterfaceStageWithStatusextendsCR.TutorialStage{
20-
status:StageStepStatus
16+
exportinterfaceLevelWithStatusextendsCR.TutorialLevel{
17+
status:ProgressStatus
2118
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp