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

Fix/update to api#43

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
ShMcK merged 12 commits intomasterfromfix/update-to-api
Oct 15, 2019
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletionspackage-lock.json
View file
Open in desktop

Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.

2 changes: 1 addition & 1 deletionpackage.json
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -49,7 +49,7 @@
"prettier":"^1.18.2",
"tslint":"^5.20.0",
"tslint-config-prettier":"^1.18.0",
"typescript":"^3.6.4",
"typescript":"^3.7.0-beta",
"vscode":"^1.1.36",
"vscode-test":"^1.2.0"
},
Expand Down
14 changes: 2 additions & 12 deletionssrc/actions/runTest.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
import*asvscodefrom'vscode'
importnodefrom'../services/node'

// TODO: use tap parser to make it easier to support other test runners

// ensure only latest run_test action is taken
letcurrentId=0

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

constoutputChannelName='Test Output'

// TODO: validate test directory from package.json exists
// let testFile = path.join('test');
// if (!await exists(testFile)) {
// return emptyTasks;
// }

// TODO: verify test runner for args
// jest CLI docs https://jestjs.io/docs/en/cli
consttestArgs=[
Expand All@@ -51,12 +47,6 @@ async function runTest({onSuccess, onFail, onRun, onError}: Props): Promise<void
'--maxWorkers=4'
]

// if .git repo, use --onlyChanged
// const hasGit = path.join('.git');
// if (await exists(hasGit)) {
// testArgs.push('--onlyChanged')
// }

constcommandLine=`npm test --${testArgs.join(' ')}`

try{
Expand Down
60 changes: 33 additions & 27 deletionssrc/actions/setupActions.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -40,39 +40,45 @@ const runCommands = async (commands: string[], language: string = 'JAVASCRIPT')

constsetupActions=async(workspaceRoot:vscode.WorkspaceFolder,{commands, commits, files}:G.StepActions):Promise<void>=>{
// run commits
for(constcommitofcommits){
awaitgit.loadCommit(commit)
if(commits){
for(constcommitofcommits){
awaitgit.loadCommit(commit)
}
}

// run command
awaitrunCommands(commands)
if(commands){
awaitrunCommands(commands)
}

// open files
for(constfilePathoffiles){
try{
// TODO: figure out why this does not work
// try {
// const absoluteFilePath = join(workspaceRoot.uri.path, filePath)
// const doc = await vscode.workspace.openTextDocument(absoluteFilePath)
// await vscode.window.showTextDocument(doc, vscode.ViewColumn.One)
// // there are times when initialization leave the panel behind any files opened
// // ensure the panel is redrawn on the right side first
// // webview.createOrShow()
// } catch (error) {
// console.log(`Failed to open file ${filePath}`, error)
// }
constwr=vscode.workspace.rootPath
if(!wr){
thrownewError('No workspace root path')
if(files){
for(constfilePathoffiles){
try{
// TODO: figure out why this does not work
// try {
// const absoluteFilePath = join(workspaceRoot.uri.path, filePath)
// const doc = await vscode.workspace.openTextDocument(absoluteFilePath)
// await vscode.window.showTextDocument(doc, vscode.ViewColumn.One)
// // there are times when initialization leave the panel behind any files opened
// // ensure the panel is redrawn on the right side first
// // webview.createOrShow()
// } catch (error) {
// console.log(`Failed to open file ${filePath}`, error)
// }
constwr=vscode.workspace.rootPath
if(!wr){
thrownewError('No workspace root path')
}
constabsoluteFilePath=join(wr,filePath)
constdoc=awaitvscode.workspace.openTextDocument(absoluteFilePath)
awaitvscode.window.showTextDocument(doc,vscode.ViewColumn.One)
// there are times when initialization leave the panel behind any files opened
// ensure the panel is redrawn on the right side first
vscode.commands.executeCommand('coderoad.open_webview')
}catch(error){
console.log(`Failed to open file${filePath}`,error)
}
constabsoluteFilePath=join(wr,filePath)
constdoc=awaitvscode.workspace.openTextDocument(absoluteFilePath)
awaitvscode.window.showTextDocument(doc,vscode.ViewColumn.One)
// there are times when initialization leave the panel behind any files opened
// ensure the panel is redrawn on the right side first
vscode.commands.executeCommand('coderoad.open_webview')
}catch(error){
console.log(`Failed to open file${filePath}`,error)
}
}
}
Expand Down
15 changes: 7 additions & 8 deletionssrc/actions/tutorialConfig.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -3,28 +3,27 @@ import * as vscode from 'vscode'
import*asgitfrom'../services/git'

interfaceTutorialConfigParams{
tutorial:G.Tutorial,
config:G.TutorialConfig,
alreadyConfigured?:boolean
onComplete?():void
}

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

// TODO: if remote not already set
awaitgit.setupRemote(tutorial.repo.uri)
if(onComplete){onComplete()}
awaitgit.setupRemote(config.repo.uri)
}

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

// setup onSave hook
vscode.workspace.onDidSaveTextDocument((document:vscode.TextDocument)=>{
if(document.uri.scheme==='file'&&language===document.languageId){
//@ts-ignore // issue with GQL enums in TS
if(document.uri.scheme==='file'&&languages.includes(document.languageId)){
vscode.commands.executeCommand('coderoad.run_test')
}
})
Expand Down
26 changes: 19 additions & 7 deletionssrc/channel/index.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -82,21 +82,33 @@ class Channel implements Channel {
return
// configure test runner, language, git
case 'EDITOR_TUTORIAL_CONFIG':
const tutorialData = action.payload.tutorial
const tutorialData: G.Tutorial = action.payload.tutorial
// setup tutorial config (save listener, test runner, etc)
this.context.setTutorial(this.workspaceState, tutorialData)
tutorialConfig({
tutorial: tutorialData,
// must await async git setup or commit loading fails
onComplete: () => this.send({type: 'TUTORIAL_CONFIGURED'})
})

const data: G.TutorialData = tutorialData.version.data

await tutorialConfig({config: data.config})

// run init setup actions
if (data.init) {
const setup: G.StepActions | null | undefined = data.init.setup
if (setup) {
setupActions(this.workspaceRoot, setup)
}
}

// report back to the webview that setup is complete
this.send({type: 'TUTORIAL_CONFIGURED'})
return
case 'EDITOR_TUTORIAL_CONTINUE_CONFIG':
const tutorialContinue: G.Tutorial | null = this.context.tutorial.get()
if (!tutorialContinue) {
throw new Error('Invalid tutorial to continue')
}
const continueConfig: G.TutorialConfig = tutorialContinue.version.data.config
tutorialConfig({
tutorial: tutorialContinue,
config: continueConfig,
alreadyConfigured: true
})
return
Expand Down
18 changes: 6 additions & 12 deletionssrc/channel/state/Position.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -3,7 +3,6 @@ import * as G from 'typings/graphql'

constdefaultValue:CR.Position={
levelId:'',
stageId:'',
stepId:'',
}

Expand DownExpand Up@@ -31,7 +30,11 @@ class Position {
returnthis.value
}

const{levels}=tutorial.version
if(!tutorial||!tutorial.version||!tutorial.version.data||!tutorial.version.data.levels){
thrownewError('Error setting position from progress')
}

const{levels}=tutorial.version.data

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

const{stages}=currentLevel

constlastStageIndex:number|undefined=stages.findIndex((s:G.Stage)=>!progress.stages[s.id])
if(lastStageIndex>=stages.length){
thrownewError('Error setting progress stage')
}
constcurrentStage:G.Stage=stages[lastStageIndex]

const{steps}=currentStage
const{steps}=currentLevel

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

this.value={
levelId:currentLevel.id,
stageId:currentStage.id,
stepId:currentStep.id,
}
returnthis.value
Expand Down
1 change: 0 additions & 1 deletionsrc/channel/state/Progress.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,7 +6,6 @@ import Storage from '../../services/storage'

constdefaultValue:CR.Progress={
levels:{},
stages:{},
steps:{},
complete:false
}
Expand Down
2 changes: 0 additions & 2 deletionssrc/editor/ReactWebView.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -52,8 +52,6 @@ class ReactWebView {

// // // prevents moving coderoad panel on top of left panel
// vscode.window.onDidChangeVisibleTextEditors((textEditors: vscode.TextEditor[]) => {
// console.log('onDidChangeVisibleTextEditors')
// console.log(textEditors)
// // updateWindows()
// })

Expand Down
2 changes: 1 addition & 1 deletionsrc/services/git/index.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -42,7 +42,7 @@ export function loadCommit(commit: string): Promise<void> {

/*
save commit
git commit -am '${level}/${stage}/${step} complete'
git commit -am '${level}/${step} complete'
*/

exportasyncfunctionsaveCommit(message:string):Promise<void>{
Expand Down
8 changes: 4 additions & 4 deletionssrc/services/storage/index.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -16,10 +16,10 @@ class Storage<T> {
this.defaultValue=defaultValue
}
publicget=async():Promise<T>=>{
constvalue:string|undefined=awaitthis.storage.get(this.key)
if(value){
returnJSON.parse(value)
}
//const value: string | undefined = await this.storage.get(this.key)
//if (value) {
//return JSON.parse(value)
//}
returnthis.defaultValue
}
publicset=(value:T):void=>{
Expand Down
1 change: 0 additions & 1 deletionsrc/test/runTest.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -3,7 +3,6 @@ import * as path from 'path'
import{runTests}from'vscode-test'

asyncfunctionmain(){
console.log('__dirname',__dirname)
// The folder containing the Extension Manifest package.json
// Passed to `--extensionDevelopmentPath`
constextensionDevelopmentPath:string=path.resolve(__dirname,'../../')
Expand Down
1 change: 0 additions & 1 deletionsrc/test/suite/extension.test.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,7 +15,6 @@ suite('Extension tests', () => {
awaitvscode.commands.executeCommand('coderoad.start')
awaitsetTimeout(()=>Promise.resolve(),5000)
// const webview = vscode.window.activeTextEditor
// console.log(webview)
assert.equal(2,2)
})

Expand Down
21 changes: 9 additions & 12 deletionstypings/context.d.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,18 @@
import*asCRfrom'./index'

exportinterfaceStepextendsExclude<CR.TutorialStep,'actions'>{
status:{
complete:boolean
active:boolean
}
interfaceProgressStatus{
active:boolean
complete:boolean
}

exportinterfaceReceivedEvent{
data:CR.Action
exportinterfaceStepextendsExclude<CR.TutorialStep,'actions'>{
status:ProgressStatus
}

exportinterfaceStageStepStatus{
active:boolean
complete:boolean
exportinterfaceReceivedEvent{
data:CR.Action
}

exportinterfaceStageWithStatusextendsCR.TutorialStage{
status:StageStepStatus
exportinterfaceLevelWithStatusextendsCR.TutorialLevel{
status:ProgressStatus
}
Loading

[8]ページ先頭

©2009-2025 Movatter.jp