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

Commitb51dd2f

Browse files
committed
refactor files
1 parent04653e2 commitb51dd2f

File tree

16 files changed

+77
-31
lines changed

16 files changed

+77
-31
lines changed

‎src/commands/tutorialLoad.ts

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,6 @@ async function newTutorial(tutorial: CR.Tutorial) {
3939
awaitopenReadme()
4040
}
4141

42-
functiononSaveHook(languageIds:string[]){
43-
// trigger command on save
44-
vscode.workspace.onDidSaveTextDocument((document:vscode.TextDocument)=>{
45-
if(languageIds.includes(document.languageId)&&document.uri.scheme==='file'){
46-
// do work
47-
vscode.commands.executeCommand('coderoad.test_run')
48-
}
49-
})
50-
}
5142

5243
asyncfunctionvalidateCanContinue():Promise<boolean>{
5344
// validate tutorial & progress found in local storage
@@ -127,7 +118,7 @@ export default async function tutorialLoad(context: vscode.ExtensionContext): Pr
127118
// }
128119

129120
// // setup hook to run tests on save
130-
// onSaveHook(tutorial.meta.languages)
121+
131122

132123
// TODO: start
133124
}

‎src/utils/fetch.tsrenamed to‎src/services/api/fetch.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import*asCRfrom'typings'
22

33
// temporary tutorials
4-
importbasicTutorialfrom'../state/context/tutorials/basic'
4+
importbasicTutorialfrom'../../state/context/tutorials/basic'
55

66
interfaceOptions{
77
resource:string

‎src/services/api/index.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import*asCRfrom'typings'
2+
3+
// temporary tutorials
4+
importbasicTutorialfrom'../../state/context/tutorials/basic'
5+
6+
interfaceOptions{
7+
resource:string
8+
params?:any
9+
}
10+
11+
consttutorialsData:{[key:string]:CR.Tutorial}={
12+
tutorialId:basicTutorial,
13+
}
14+
15+
// TODO: replace with fetch resource
16+
exportdefaultasyncfunctionfetch(options:Options):Promise<any>{
17+
console.log('options',options)
18+
switch(options.resource){
19+
case'getTutorialsSummary':
20+
// list of ids with summaries
21+
letdata:{[id:string]:CR.TutorialSummary}={}
22+
for(consttutorialofObject.values(tutorialsData)){
23+
data[tutorial.id]=tutorial.data.summary
24+
}
25+
returndata
26+
case'getTutorial':
27+
// specific tutorial by id
28+
returntutorialsData[options.params.id]
29+
default:
30+
thrownewError('Resource not found')
31+
}
32+
}

‎src/services/fs.ts

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

‎src/services/git.tsrenamed to‎src/services/git/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import*asCRfrom'typings'
2-
import{exec,exists,openFile}from'../utils/node'
2+
import{exec,exists,openFile}from'../node'
33

44
constgitOrigin='coderoad'
55

‎src/utils/node.tsrenamed to‎src/services/node/index.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,15 @@ export const openFile = async (relativeFilePath: string): Promise<void> => {
3737
console.log(`Failed to open file${relativeFilePath}`,error)
3838
}
3939
}
40+
41+
42+
// export async function clear(): Promise<void> {
43+
// // remove all files including ignored
44+
// // NOTE: Linux only
45+
// const command = 'ls -A1 | xargs rm -rf'
46+
// const { stderr } = await exec(command)
47+
// if (stderr) {
48+
// console.error(stderr)
49+
// throw new Error('Error removing all files & folders')
50+
// }
51+
// }
File renamed without changes.

‎src/services/position.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import*asCRfrom'typings'
2-
import*asstoragefrom'./storage'
2+
import*asstoragefrom'./vscode/storage'
33

44
exportasyncfunctiongetInitial(tutorial:CR.Tutorial):Promise<CR.Position>{
55
const{ data}=tutorial

‎src/services/rootSetup.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import*asvscodefrom'vscode'
2-
import{setWorkspaceRoot}from'../utils/node'
3-
import{setStorage}from'./storage'
2+
import{setWorkspaceRoot}from'../services/node'
3+
import{setStorage}from'./vscode/storage'
44

55
exportdefaultasyncfunctionsetupRoot(context:vscode.ExtensionContext){
66
awaitsetWorkspaceRoot()

‎src/services/testResult.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import*asCRfrom'typings'
22
import*asvscodefrom'vscode'
3-
import*asstoragefrom'./storage'
3+
import*asstoragefrom'./vscode/storage'
44

55

66
exportasyncfunctiononSuccess(position:CR.Position){

‎src/services/tutorialSetup.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import*asCRfrom'typings'
22
import*aspositionfrom'../services/position'
3-
import*asstoragefrom'../services/storage'
4-
import{isEmptyWorkspace}from'../utils/workspace'
3+
import*asstoragefrom'../services/vscode/storage'
4+
import{isEmptyWorkspace}from'../services/vscode/workspace'
55
import{gitLoadCommits,gitInitIfNotExists,gitSetupRemote}from'../services/git'
66

77
consttestRepo='https://github.com/ShMcK/coderoad-tutorial-basic.git'
File renamed without changes.

‎src/services/vscode/index.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import*asCRfrom'typings'
2+
importonSaveHookfrom'./save'
3+
4+
constvscodeAction=(action:CR.Action)=>{
5+
switch(action.type){
6+
case'ON_FILE_SAVE_RUN_TEST':{
7+
onSaveHook(action.payload.languages)
8+
}
9+
}
10+
}

‎src/services/vscode/save.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import*asvscodefrom'vscode'
2+
3+
functiononSaveHook(languageIds:string[]){
4+
// trigger command on save
5+
vscode.workspace.onDidSaveTextDocument((document:vscode.TextDocument)=>{
6+
if(languageIds.includes(document.languageId)&&document.uri.scheme==='file'){
7+
// do work
8+
vscode.commands.executeCommand('coderoad.test_run')
9+
}
10+
})
11+
}
12+
13+
exportdefaultonSaveHook
File renamed without changes.

‎src/utils/workspace.tsrenamed to‎src/services/vscode/workspace.ts

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

66
exportasyncfunctionisEmptyWorkspace():Promise<boolean>{
77
const{ stdout, stderr}=awaitexec('ls')

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp