|
1 | | -import*asTfrom'typings' |
| 1 | +import*asEfrom'typings/error' |
2 | 2 | import*asTTfrom'typings/tutorial' |
3 | 3 | import*asvscodefrom'vscode' |
4 | 4 | import{COMMANDS}from'../editor/commands' |
5 | 5 | import*asgitfrom'../services/git' |
6 | | -importonErrorfrom'../services/sentry/onError' |
7 | 6 |
|
8 | 7 | interfaceTutorialConfigParams{ |
9 | 8 | config:TT.TutorialConfig |
10 | 9 | alreadyConfigured?:boolean |
11 | 10 | onComplete?():void |
12 | 11 | } |
13 | 12 |
|
14 | | -consttutorialConfig=async( |
15 | | -{ config, alreadyConfigured}:TutorialConfigParams, |
16 | | -handleError:(msg:T.ErrorMessage)=>void, |
17 | | -)=>{ |
| 13 | +consttutorialConfig=async({ config, alreadyConfigured}:TutorialConfigParams):Promise<E.ErrorMessage|void>=>{ |
18 | 14 | if(!alreadyConfigured){ |
19 | 15 | // setup git, add remote |
20 | | -awaitgit.initIfNotExists().catch((error)=>{ |
21 | | -onError(newError('Git not found')) |
22 | | -// failed to setup git |
23 | | -handleError({ |
24 | | -title:error.message, |
25 | | -description: |
26 | | -'Make sure you install Git. See the docs for help https://git-scm.com/book/en/v2/Getting-Started-Installing-Git', |
27 | | -}) |
| 16 | +awaitgit.initIfNotExists().catch((error:Error)=>{ |
| 17 | +return{ |
| 18 | +type:'GitNotFound', |
| 19 | +message:error.message, |
| 20 | +} |
28 | 21 | }) |
29 | 22 |
|
30 | | -try{ |
31 | | -awaitgit.checkRemoteConnects(config.repo) |
32 | | -}catch(error){ |
33 | | -onError(error) |
34 | | -handleError({title:'Error connecting to Git repo',description:error.message}) |
35 | | -} |
| 23 | +// verify that internet is connected, remote exists and branch exists |
| 24 | +awaitgit.checkRemoteConnects(config.repo).catch((error:Error)=>{ |
| 25 | +return{ |
| 26 | +type:'FailedToConnectToGitRepo', |
| 27 | +message:error.message, |
| 28 | +} |
| 29 | +}) |
36 | 30 |
|
37 | 31 | // TODO if remote not already set |
38 | | -awaitgit.setupRemote(config.repo.uri).catch((error)=>{ |
39 | | -onError(error) |
40 | | -handleError({title:error.message,description:'Remove your current Git project and reload the editor'}) |
| 32 | +awaitgit.setupCodeRoadRemote(config.repo.uri).catch((error:Error)=>{ |
| 33 | +return{ |
| 34 | +type:'GitRemoteAlreadyExists', |
| 35 | +message:error.message, |
| 36 | +} |
41 | 37 | }) |
42 | 38 | } |
43 | 39 |
|
|