8000 refactor files · benjaminthedev/coderoad-vscode@b51dd2f · GitHub
[go: up one dir, main page]

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

Appearance settings

Commit b51dd2f

Browse files
committed
refactor files
1 parent 04653e2 commit b51dd2f

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
await openReadme()
4040
}
4141

42-
function onSaveHook(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
async function validateCanContinue(): 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.ts renamed 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 * as CR from 'typings'
22

33
// temporary tutorials
4-
import basicTutorial from '../state/context/tutorials/basic'
4+
import basicTutorial from '../../state/context/tutorials/basic'
55

66
interface Options {
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 * as CR from 'typings'
2+
3+
// temporary tutorials
4+
import basicTutorial from '../../state/context/tutorials/basic'
5+
6+
interface Options {
7+
resource: string
8+
params?: any
9+
}
10+
11+
const tutorialsData: { [key: string]: CR.Tutorial } = {
12+
tutorialId: basicTutorial,
13+
}
14+
15+
// TODO: replace with fetch resource
16+
export default async function fetch(options: Options): Promise<any> {
17+
console.log('options', options)
18+
switch (options.resource) {
19+
case 'getTutorialsSummary':
20+
// list of ids with summaries
21+
let data: { [id: string]: CR.TutorialSummary } = {}
22+
for (const tutorial of Object.values(tutorialsData)) {
23+
data[tutorial.id] = tutorial.data.summary
24+
}
25+
return data
26+
case 'getTutorial':
27+
// specific tutorial by id
28+
return tutorialsData[options.params.id]
29+
default:
30+
throw new Error('Resource not found')
31+
}
32+
}

src/services/fs.ts

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

src/services/git.ts renamed 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 * as CR from 'typings'
2-
import { exec, exists, openFile } from '../utils/node'
2+
import { exec, exists, openFile } from '../node'
33

44
const gitOrigin = 'coderoad'
55

src/utils/node.ts renamed 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 * as CR from 'typings'
2-
import * as storage from './storage'
2+
import * as storage from './vscode/storage'
33

44
export async function getInitial(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 * as vscode from '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
export default async function setupRoot(context: vscode.ExtensionContext) {
66
await setWorkspaceRoot()

src/services/testResult.ts

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

55

66
export async function onSuccess(position: CR.Position) {

0 commit comments

Comments
 (0)
0