8000 track git config errors · An0nCrypto/coderoad-vscode@e018584 · GitHub
[go: up one dir, main page]

Skip to content

Commit e018584

Browse files
committed
track git config errors
1 parent f0b8025 commit e018584

File tree

6 files changed

+192
-170
lines changed
  • services/state
  • 6 files changed

    +192
    -170
    lines changed

    src/actions/tutorialConfig.ts

    Lines changed: 16 additions & 3 deletions
    Original file line numberDiff line numberDiff line change
    @@ -1,3 +1,4 @@
    1+
    import * as T from 'typings'
    12
    import * as G from 'typings/graphql'
    23
    import * as vscode from 'vscode'
    34
    import * as git from '../services/git'
    @@ -10,13 +11,25 @@ interface TutorialConfigParams {
    1011
    onComplete?(): void
    1112
    }
    1213

    13-
    const tutorialConfig = async ({ config, alreadyConfigured }: TutorialConfigParams) => {
    14+
    const tutorialConfig = async (
    15+
    { config, alreadyConfigured }: TutorialConfigParams,
    16+
    onError: (msg: T.ErrorMessage) => void,
    17+
    ) => {
    1418
    if (!alreadyConfigured) {
    1519
    // setup git, add remote
    16-
    await git.initIfNotExists()
    20+
    await git.initIfNotExists().catch(error => {
    21+
    // failed to setup git
    22+
    onError({
    23+
    title: error.message,
    24+
    description:
    25+
    'Be sure you install Git. See the docs for help https://git-scm.com/book/en/v2/Getting-Started-Installing-Git',
    26+
    })
    27+
    })
    1728

    1829
    // TODO: if remote not already set
    19-
    await git.setupRemote(config.repo.uri)
    30+
    await git.setupRemote(config.repo.uri).catch(error => {
    31+
    onError({ title: error.message, description: 'Remove your current Git project and restarting' })
    32+
    })
    2033
    }
    2134

    2235
    vscode.commands.executeCommand(COMMANDS.CONFIG_TEST_RUNNER, config.testRunner)

    src/channel/index.ts

    Lines changed: 16 additions & 12 deletions
    Original file line numberDiff line numberDiff line change
    @@ -1,4 +1,4 @@
    1-
    import * as CR from 'typings'
    1+
    import * as T from 'typings'
    22
    import * as G from 'typings/graphql'
    33
    import * as vscode from 'vscode'
    44

    @@ -10,18 +10,18 @@ import saveCommit from '../actions/saveCommit'
    1010
    import { COMMANDS } from '../editor/commands'
    1111

    1212
    interface Channel {
    13-
    receive(action: CR.Action): Promise<void>
    14-
    send(action: CR.Action): Promise<void>
    13+
    receive(action: T.Action): Promise<void>
    14+
    send(action: T.Action< 93D4 /span>): Promise<void>
    1515
    }
    1616

    1717
    interface ChannelProps {
    18-
    postMessage: (action: CR.Action) => Thenable<boolean>
    18+
    postMessage: (action: T.Action) => Thenable<boolean>
    1919
    workspaceState: vscode.Memento
    2020
    workspaceRoot: vscode.WorkspaceFolder
    2121
    }
    2222

    2323
    class Channel implements Channel {
    24-
    private postMessage: (action: CR.Action) => Thenable<boolean>
    24+
    private postMessage: (action: T.Action) => Thenable<boolean>
    2525
    private workspaceState: vscode.Memento
    2626
    private workspaceRoot: vscode.WorkspaceFolder
    2727
    private context: Context
    @@ -34,9 +34,10 @@ class Channel implements Channel {
    3434
    }
    3535

    3636
    // receive from webview
    37-
    public receive = async (action: CR.Action) => {
    37+
    public receive = async (action: T.Action) => {
    3838
    // action may be an object.type or plain string
    3939
    const actionType: string = typeof action === 'string' ? action : action.type
    40+
    const onError = (error: T.ErrorMessage) => this.send({ type: 'ERROR', payload: { error } })
    4041

    4142
    // console.log('EDITOR RECEIVED:', actionType)
    4243
    switch (actionType) {
    @@ -87,7 +88,7 @@ class Channel implements Channel {
    8788

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

    90-
    await tutorialConfig({ config: data.config })
    91+
    await tutorialConfig({ config: data.config }, onError)
    9192

    9293
    // run init setup actions
    9394
    if (data.init) {
    @@ -106,10 +107,13 @@ class Channel implements Channel {
    106107
    throw new Error('Invalid tutorial to continue')
    107108
    }
    108109
    const continueConfig: G.TutorialConfig = tutorialContinue.version.data.config
    109-
    tutorialConfig({
    110-
    config: continueConfig,
    111-
    alreadyConfigured: true,
    112-
    })
    110+
    tutorialConfig(
    111+
    {
    112+
    config: continueConfig,
    113+
    alreadyConfigured: true,
    114+
    },
    115+
    onError,
    116+
    )
    113117
    return
    114118
    case 'EDITOR_SYNC_PROGRESS':
    115119
    // sync client progress on server
    @@ -134,7 +138,7 @@ class Channel implements Channel {
    134138
    }
    135139
    }
    136140
    // send to webview
    137-
    public send = async (action: CR.Action) => {
    141+
    public send = async (action: T.Action) => {
    138142
    console.log(`EDITOR SEND ${action.type}`)
    139143
    // action may be an object.type or plain string
    140144
    const actionType: string = typeof action === 'string' ? action : action.type

    src/services/git/index.ts

    Lines changed: 3 additions & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -81,7 +81,7 @@ export async function version(): Promise<string | boolean> {
    8181
    async function init(): Promise<void> {
    8282
    const { stderr } = await node.exec('git init')
    8383
    if (stderr) {
    84-
    throw new Error('Error initializing Gits')
    84+
    throw new Error('Error initializing Git')
    8585
    }
    8686
    }
    8787

    @@ -133,5 +133,7 @@ export async function setupRemote(repo: string): Promise<void> {
    133133
    // git fetch coderoad
    134134
    if (!hasRemote) {
    135135
    await addRemote(repo)
    136+
    } else {
    137+
    throw new Error('A Remote is already configured')
    136138
    }
    137139
    }

    web-app/src/containers/Tutorial/LevelPage/Level.tsx

    Lines changed: 108 additions & 108 deletions
    Original file line numberDiff line numberDiff line change
    @@ -8,124 +8,124 @@ import Markdown from '../../../components/Markdown'
    88
    import ProcessEvents from '../../../components/ProcessEvents'
    99

    1010
    const styles = {
    11-
    page: {
    12-
    backgroundColor: 'white',
    13-
    position: 'relative' as 'relative',
    14-
    display: 'flex' as 'flex',
    15-
    flexDirection: 'column' as 'column',
    16-
    padding: 0,
    17-
    paddingBottom: '36px',
    18-
    height: 'auto',
    19-
    width: '100%',
    20-
    },
    21-
    header: {
    22-
    height: '36px',
    23-
    backgroundColor: '#EBEBEB',
    24-
    fontSize: '16px',
    25-
    lineHeight: '16px',
    26-
    padding: '10px 1rem',
    27-
    },
    28-
    content: {
    29-
    padding: '0rem 1rem',
    30-
    paddingBottom: '1rem',
    31-
    },
    32-
    tasks: {
    33-
    paddingBottom: '5rem',
    34-
    },
    35-
    steps: {
    36-
    padding: '1rem 16px',
    37-
    },
    38-
    title: {
    39-
    fontSize: '1.2rem',
    40-
    fontWeight: 'bold' as 'bold',
    41-
    lineHeight: '1.2rem',
    42-
    },
    43-
    processes: {
    44-
    padding: '0 1rem',
    45-
    position: 'absolute' as 'absolute',
    46-
    bottom: '36px',
    47-
    },
    48-
    footer: {
    49-
    display: 'flex' as 'flex',
    50-
    flexDirection: 'row' as 'row',
    51-
    justifyContent: 'space-between',
    52-
    alignItems: 'center',
    53-
    height: '36px',
    54-
    backgroundColor: 'black',
    55-
    fontSize: '16px',
    56-
    lineHeight: '16px',
    57-
    padding: '10px 1rem',
    58-
    position: 'fixed' as 'fixed',
    59-
    bottom: 0,
    60-
    left: 0,
    61-
    right: 0,
    62-
    color: 'white',
    63-
    },
    11+
    page: {
    12+
    backgroundColor: 'white',
    13+
    position: 'relative' as 'relative',
    14+
    display: 'flex' as 'flex',
    15+
    flexDirection: 'column' as 'column',
    16+
    padding: 0,
    17+
    paddingBottom: '36px',
    18+
    height: 'auto',
    19+
    width: '100%',
    20+
    },
    21+
    header: {
    22+
    height: '36px',
    23+
    backgroundColor: '#EBEBEB',
    24+
    fontSize: '16px',
    25+
    lineHeight: '16px',
    26+
    padding: '10px 1rem',
    27+
    },
    28+
    content: {
    29+
    padding: '0rem 1rem',
    30+
    paddingBottom: '1rem',
    31+
    },
    32+
    tasks: {
    33+
    paddingBottom: '5rem',
    34+
    },
    35+
    steps: {
    36+
    padding: '1rem 16px',
    37+
    },
    38+
    title: {
    39+
    fontSize: '1.2rem',
    40+
    fontWeight: 'bold' as 'bold',
    41+
    lineHeight: '1.2rem',
    42+
    },
    43+
    processes: {
    44+
    padding: '0 1rem',
    45+
    position: 'absolute' as 'absolute',
    46+
    bottom: '36px',
    47+
    },
    48+
    footer: {
    49+
    display: 'flex' as 'flex',
    50+
    flexDirection: 'row' as 'row',
    51+
    justifyContent: 'space-between',
    52+
    alignItems: 'center',
    53+
    height: '36px',
    54+
    backgroundColor: 'black',
    55+
    fontSize: '16px',
    56+
    lineHeight: '16px',
    57+
    padding: '10px 1rem',
    58+
    position: 'fixed' as 'fixed',
    59+
    bottom: 0,
    60+
    left: 0,
    61+
    right: 0,
    62+
    color: 'white',
    63+
    },
    6464
    }
    6565

    6666
    interface Props {
    67-
    level: G.Level & { status: T.ProgressStatus; index: number; steps: Array<G.Step & { status: T.ProgressStatus }> }
    68-
    processes: T.ProcessEvent[]
    69-
    onContinue(): void
    70-
    onLoadSolution(): void
    67+
    level: G.Level & { status: T.ProgressStatus; index: number; steps: Array<G.Step & { status: T.ProgressStatus }> }
    68+
    processes: T.ProcessEvent[]
    69+
    onContinue(): void
    70+
    onLoadSolution(): void
    7171
    }
    7272

    7373
    const Level = ({ level, onContinue, onLoadSolution, processes }: Props) => {
    74-
    if (!level.steps) {
    75-
    throw new Error('No Stage steps found')
    76-
    }
    74+
    if (!level.steps) {
    75+
    throw new Error('No Stage steps found')
    76+
    }
    7777

    78-
    return (
    79-
    <div style={styles.page}>
    80-
    <div style={styles.header}>
    81-
    <span>Learn</span>
    82-
    </div>
    83-
    <div style={styles.content}>
    84-
    <h2 style={styles.title}>{level.title}</h2>
    85-
    <Markdown>{level.content || ''}</Markdown>
    86-
    </div>
    78+
    return (
    79+
    <div style={styles.page}>
    80+
    <div style={styles.header}>
    81+
    <span>Learn</span>
    82+
    </div>
    83+
    <div style={styles.content}>
    84+
    <h2 style={styles.title}>{level.title}</h2>
    85+
    <Markdown>{level.content || ''}</Markdown>
    86+
    </div>
    8787

    88-
    <div style={styles.tasks}>
    89-
    <div style={styles.header}>Tasks</div>
    90-
    <div style={styles.steps}>
    91-
    {level.steps.map((step: (G.Step & { status: T.ProgressStatus }) | null, index: number) => {
    92-
    if (!step) {
    93-
    return null
    94-
    }
    95-
    return (
    96-
    <Step
    97-
    key={step.id}
    98-
    order={index + 1}
    99-
    status={step.status}
    100-
    content={step.content}
    101-
    onLoadSolution={onLoadSolution}
    102-
    />
    103-
    )
    104-
    })}
    105-
    </div>
    106-
    </div>
    88+
    <div style={styles.tasks}>
    89+
    <div style={styles.header}>Tasks</div>
    90+
    <div style={styles.steps}>
    91+
    {level.steps.map((step: (G.Step & { status: T.ProgressStatus }) | null, index: number) => {
    92+
    if (!step) {
    93+
    return null
    94+
    }
    95+
    return (
    96+
    <Step
    97+
    key={step.id}
    98+
    order={index + 1}
    99+
    status={step.status}
    100+
    content={step.content}
    101+
    onLoadSolution={onLoadSolution}
    102+
    />
    103+
    )
    104+
    })}
    105+
    </div>
    106+
    </div>
    107107

    108-
    {processes.length > 0 && (
    109-
    <div style={styles.processes}>
    110-
    <ProcessEvents processes={processes} />
    111-
    </div>
    112-
    )}
    108+
    {processes.length > 0 && (
    109+
    <div style={styles.processes}>
    110+
    <ProcessEvents processes={processes} />
    111+
    </div>
    112+
    )}
    113113

    114-
    <div style={styles.footer}>
    115-
    <span>
    116-
    {typeof level.index === 'number' ? `${level.index + 1}. ` : ''}
    117-
    {level.title}
    118-
    </span>
    119-
    <span>
    120-
    {level.status === 'COMPLETE' && (
    121-
    <Button type="primary" onClick={onContinue}>
    122-
    Continue
    123-
    </Button>
    124-
    )}
    125-
    </span>
    126-
    </div>
    127-
    </div>
    128-
    )
    114+
    <div style={styles.footer}>
    115+
    <span>
    116+
    {typeof level.index === 'number' ? `${level.index + 1}. ` : ''}
    117+
    {level.title}
    118+
    </span>
    119+
    <span>
    120+
    {level.status === 'COMPLETE' && (
    121+
    <Button type="primary" onClick={onContinue}>
    122+
    Continue
    123+
    </Button>
    124+
    )}
    125+
    </span>
    126+
    </div>
    127+
    </div>
    128+
    )
    129129
    }
    130130

    131131
    export default Level

    0 commit comments

    Comments
     (0)
    0