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

Refactor#289

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 2 commits intomasterfromrefactor
Apr 19, 2020
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
8 changes: 0 additions & 8 deletionssrc/actions/setupActions.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,12 +6,6 @@ import openFiles from './utils/openFiles'
import runCommands from './utils/runCommands'
import onError from '../services/sentry/onError'

async function wait(ms: number) {
return new Promise((resolve) => {
setTimeout(resolve, ms)
})
}

interface SetupActions {
actions: TT.StepActions
send: (action: T.Action) => void // send messages to client
Expand All@@ -35,8 +29,6 @@ export const setupActions = async ({ actions, send, path }: SetupActions): Promi
// 3. start file watchers
loadWatchers(watchers || [])

await wait(1000)

// 4. run command
await runCommands({ commands: commands || [], send, path }).catch(onError)
}
Expand Down
37 changes: 19 additions & 18 deletionssrc/channel/index.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -76,30 +76,31 @@ class Channel implements Channel {
consttutorial:TT.Tutorial|null=this.context.tutorial.get()

// new tutorial
if(!tutorial||!tutorial.id){
this.send({type:'START_NEW_TUTORIAL',payload:{ env}})
return
}
this.send({type:'START_NEW_TUTORIAL',payload:{ env}})
return

// set tutorial
const{ position, progress}=awaitthis.context.setTutorial(this.workspaceState,tutorial)
// disable continue until fixed

if(progress.complete){
// tutorial is already complete
this.send({type:'TUTORIAL_ALREADY_COMPLETE',payload:{ env}})
return
}
// communicate to client the tutorial & stepProgress state
this.send({type:'LOAD_STORED_TUTORIAL',payload:{ env, tutorial, progress, position}})
// // set tutorial
// const { position, progress } = await this.context.setTutorial(this.workspaceState, tutorial)

return
// if (progress.complete) {
// // tutorial is already complete
// this.send({ type: 'TUTORIAL_ALREADY_COMPLETE', payload: { env }})
// return
// }
// // communicate to client the tutorial & stepProgress state
// this.send({ type: 'LOAD_STORED_TUTORIAL', payload: { env, tutorial, progress, position }})

// return
}catch(e){
consterror={
type:'UnknownError',
message:`Location: Editor startup\n\n${e.message}`,
}
this.send({type:'EDITOR_STARTUP_FAILED',payload:{ error}})
}
return

// clear tutorial local storage
case'TUTORIAL_CLEAR':
Expand DownExpand Up@@ -203,14 +204,14 @@ class Channel implements Channel {

// report back to the webview that setup is complete
this.send({type:'TUTORIAL_CONFIGURED'})
return
}catch(e){
consterror={
type:'UnknownError',
message:`Location: EditorTutorialConfig.\n\n${e.message}`,
}
this.send({type:'TUTORIAL_CONFIGURE_FAIL',payload:{ error}})
}
return
case'EDITOR_TUTORIAL_CONTINUE_CONFIG':
try{
consttutorialContinue:TT.Tutorial|null=this.context.tutorial.get()
Expand All@@ -224,14 +225,14 @@ class Channel implements Channel {
})
// update the current stepId on startup
vscode.commands.executeCommand(COMMANDS.SET_CURRENT_STEP,action.payload)
return
}catch(e){
consterror={
type:'UnknownError',
message:`Location: Editor tutorial continue config.\n\n${e.message}`,
}
this.send({type:'CONTINUE_FAILED',payload:{ error}})
}
return
case'EDITOR_VALIDATE_SETUP':
try{
// check workspace is selected
Expand DownExpand Up@@ -272,14 +273,14 @@ class Channel implements Channel {
return
}
this.send({type:'SETUP_VALIDATED'})
return
}catch(e){
consterror={
type:'UknownError',
message:e.message,
}
this.send({type:'VALIDATE_SETUP_FAILED',payload:{ error}})
}
return
case'EDITOR_REQUEST_WORKSPACE':
openWorkspace()
return
Expand DownExpand Up@@ -329,7 +330,7 @@ class Channel implements Channel {
case'TEST_PASS':
consttutorial=this.context.tutorial.get()
if(!tutorial){
thrownewError('Error with current tutorial')
thrownewError('Error with current tutorial. Tutorial may be missing an id.')
}
// update local storage stepProgress
constprogress=this.context.progress.setStepComplete(tutorial,action.payload.stepId)
Expand Down
4 changes: 2 additions & 2 deletionssrc/editor/commands.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -20,7 +20,7 @@ interface CreateCommandProps {
export const createCommands = ({ extensionPath, workspaceState }: CreateCommandProps) => {
// React panel webview
let webview: any
let currentStepId = ''
let currentStepId: string | null = ''
let testRunner: any

return {
Expand DownExpand Up@@ -79,7 +79,7 @@ export const createCommands = ({ extensionPath, workspaceState }: CreateCommandP
},
[COMMANDS.RUN_TEST]: (current: Payload | undefined, onSuccess: () => void) => {
// use stepId from client, or last set stepId
const payload: Payload = { stepId: current && current.stepId.length ? current.stepId : currentStepId }
const payload: Payload = { stepId: current && current.stepId?.length ? current.stepId : currentStepId }
testRunner(payload, onSuccess)
},
}
Expand Down
3 changes: 1 addition & 2 deletionssrc/environment.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -14,8 +14,7 @@ export type Env = 'test' | 'local' | 'development' | 'production'
export const NODE_ENV: Env = process.env.NODE_ENV || 'production'

// toggle logging in development
export const LOG: boolean =
(process.env.REACT_APP_LOG || '').toLowerCase() === 'true' && process.env.NODE_ENV !== 'production'
export const LOG: boolean = (process.env.REACT_APP_LOG || '').toLowerCase() === 'true'

// error logging tool
export const SENTRY_DSN: string | null = process.env.SENTRY_DSN || null
Expand Down
16 changes: 11 additions & 5 deletionssrc/services/logger/index.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
import { LOG } from '../../environment'

const logger = (message: string | string[]) => {
export type Log = string | object | null

const logger = (...messages: Log[]): void => {
if (!LOG) {
return
}
if (Array.isArray(message)) {
message.forEach(console.log)
} else {
console.log(message)
// Inside vscode, you console.log does not allow more than 1 param
// to get around it, we can log with multiple log statements
for (const message of messages) {
if (typeof message === 'object') {
console.log(JSON.stringify(message))
} else {
console.log(message)
}
}
}

Expand Down
2 changes: 1 addition & 1 deletionsrc/services/testRunner/index.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -8,7 +8,7 @@ import { clearOutput, displayOutput } from './output'
import { formatFailOutput } from './formatOutput'

export interface Payload {
stepId: string
stepId: string | null
}

interface Callbacks {
Expand Down
4 changes: 2 additions & 2 deletionstypings/index.d.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -65,11 +65,11 @@ export interface MachineStateSchema {
Setup:{
states:{
Startup:{}
Start:{}
ValidateSetup:{}
Start:{}
SelectTutorial:{}
SetupNewTutorial:{}
StartNewTutorial:{}
StartTutorial:{}
}
}
Tutorial:{
Expand Down
9 changes: 3 additions & 6 deletionsweb-app/src/Routes.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,7 +6,7 @@ import LoadingPage from './containers/Loading'
importStartPagefrom'./containers/Start'
importSelectTutorialPagefrom'./containers/SelectTutorial'
importCompletedPagefrom'./containers/Tutorial/CompletedPage'
importLevelSummaryPagefrom'./containers/Tutorial/LevelPage'
importTutorialPagefrom'./containers/Tutorial'

constRoutes=()=>{
const{ context, send, Router, Route}=useRouter()
Expand All@@ -30,21 +30,18 @@ const Routes = () => {
<Routepath="Setup.Start">
<StartPagesend={send}context={context}/>
</Route>
<Routepath={['Setup.LoadTutorialSummary','Setup.LoadTutorialData','Setup.SetupNewTutorial']}>
<LoadingPagetext="Loading Tutorial..."processes={context.processes}/>]
</Route>
<Routepath="Setup.SelectTutorial">
<SelectTutorialPagesend={send}context={context}/>
</Route>
<Routepath={['Setup.SetupNewTutorial','Setup.StartNewTutorial']}>
<Routepath={['Setup.SetupNewTutorial','Setup.StartTutorial']}>
<LoadingPagetext="Configuring tutorial..."/>
</Route>
{/* Tutorial */}
<Routepath={['Tutorial.LoadNext','Tutorial.Level.Load']}>
<LoadingPagetext="Loading Level..."processes={context.processes}/>
</Route>
<Routepath="Tutorial.Level">
<LevelSummaryPagesend={send}context={context}/>
<TutorialPagesend={send}context={context}/>
</Route>
{/* Completed */}
<Routepath="Tutorial.Completed">
Expand Down
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
import*asReactfrom'react'
import*asTfrom'typings'
import*asTTfrom'typings/tutorial'
import*asselectorsfrom'../../../services/selectors'
importLevelfrom'./Level'
import*asselectorsfrom'../../services/selectors'
importLevelfrom'./components/Level'

interfacePageProps{
context:T.MachineContext
send(action:T.Action):void
}

constLevelSummaryPageContainer=(props:PageProps)=>{
constTutorialPage=(props:PageProps)=>{
const{ position, progress, processes, testStatus}=props.context

consttutorial=selectors.currentTutorial(props.context)
Expand DownExpand Up@@ -59,4 +59,4 @@ const LevelSummaryPageContainer = (props: PageProps) => {
)
}

exportdefaultLevelSummaryPageContainer
exportdefaultTutorialPage
4 changes: 2 additions & 2 deletionsweb-app/src/services/state/machine.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -123,10 +123,10 @@ export const createMachine = (options: any) => {
actions:['setError'],
},
TRY_AGAIN:'SetupNewTutorial',
TUTORIAL_CONFIGURED:'StartNewTutorial',
TUTORIAL_CONFIGURED:'StartTutorial',
},
},
StartNewTutorial:{
StartTutorial:{
onEntry:['startNewTutorial'],
after:{
0:'#tutorial',
Expand Down
2 changes: 1 addition & 1 deletionweb-app/stories/Completed.stories.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,4 +6,4 @@ import SideBarDecorator from './utils/SideBarDecorator'

storiesOf('Completed',module)
.addDecorator(SideBarDecorator)
.add('Page',()=><CompletedPagecontext={{}}send={action('send')}/>)
.add('Page',()=><CompletedPagecontext={{}}/>)
2 changes: 1 addition & 1 deletionweb-app/stories/Level.stories.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,7 +4,7 @@ import { storiesOf } from '@storybook/react'
importReactfrom'react'
import*asTfrom'../../typings'
import*asTTfrom'../../typings/tutorial'
importLevelfrom'../src/containers/Tutorial/LevelPage/Level'
importLevelfrom'../src/containers/Tutorial/components/Level'
importSideBarDecoratorfrom'./utils/SideBarDecorator'

typeModifiedLevel=TT.Level&{
Expand Down
2 changes: 1 addition & 1 deletionweb-app/stories/Step.stories.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,7 +2,7 @@ import { action } from '@storybook/addon-actions'
import{select,text,withKnobs}from'@storybook/addon-knobs'
import{storiesOf}from'@storybook/react'
importReactfrom'react'
importStepfrom'../src/containers/Tutorial/LevelPage/Step'
importStepfrom'../src/containers/Tutorial/components/Step'
importSideBarDecoratorfrom'./utils/SideBarDecorator'

conststepText=
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp