@@ -2,7 +2,6 @@ import * as T from 'typings'
22import * as TT from 'typings/tutorial'
33import * as E from 'typings/error'
44import * as vscode from 'vscode'
5- import fetch from 'node-fetch'
65import { satisfies } from 'semver'
76import { setupActions , solutionActions } from './actions/setupActions'
87import tutorialConfig from './actions/tutorialConfig'
@@ -13,7 +12,6 @@ import { version, compareVersions } from './services/dependencies'
1312import { openWorkspace , checkWorkspaceEmpty } from './services/workspace'
1413import { showOutput } from './services/testRunner/output'
1514import { exec } from './services/node'
16- import { WORKSPACE_ROOT , TUTORIAL_URL } from './environment'
1715import reset from './services/reset'
1816import getLastCommitHash from './services/reset/lastHash'
1917import { onEvent } from './services/telemetry'
@@ -50,68 +48,7 @@ class Channel implements Channel {
5048
5149switch ( actionType ) {
5250case 'EDITOR_STARTUP' :
53- try {
54- // check if a workspace is open, otherwise nothing works
55- const noActiveWorkspace = ! WORKSPACE_ROOT . length
56- if ( noActiveWorkspace ) {
57- const error :E . ErrorMessage = {
58- type :'NoWorkspaceFound' ,
59- message :'' ,
60- actions :[
61- {
62- label :'Open Workspace' ,
63- transition :'REQUEST_WORKSPACE' ,
64- } ,
65- ] ,
66- }
67- this . send ( { type :'NO_WORKSPACE' , payload :{ error} } )
68- return
69- }
70-
71- const env = {
72- machineId :vscode . env . machineId ,
73- sessionId :vscode . env . sessionId ,
74- }
75-
76- // load tutorial from url
77- if ( TUTORIAL_URL ) {
78- try {
79- const tutorialRes = await fetch ( TUTORIAL_URL )
80- const tutorial = await tutorialRes . json ( )
81- this . send ( { type :'START_TUTORIAL_FROM_URL' , payload :{ tutorial} } )
82- return
83- } catch ( e ) {
84- console . log ( `Failed to load tutorial from url${ TUTORIAL_URL } with error "${ e . message } "` )
85- }
86- }
87-
88- // continue from tutorial from local storage
89- const tutorial :TT . Tutorial | null = this . context . tutorial . get ( )
90-
91- // no stored tutorial, must start new tutorial
92- if ( ! tutorial || ! tutorial . id ) {
93- this . send ( { type :'START_NEW_TUTORIAL' , payload :{ env} } )
94- return
95- }
96-
97- // load continued tutorial position & progress
98- const { position, progress} = await this . context . setTutorial ( this . workspaceState , tutorial )
99- logger ( 'CONTINUE STATE' , position , progress )
100-
101- if ( progress . complete ) {
102- // tutorial is already complete
103- this . send ( { type :'TUTORIAL_ALREADY_COMPLETE' , payload :{ env} } )
104- return
105- }
106- // communicate to client the tutorial & stepProgress state
107- this . send ( { type :'LOAD_STORED_TUTORIAL' , payload :{ env, tutorial, progress, position} } )
108- } catch ( e ) {
109- const error = {
110- type :'UnknownError' ,
111- message :`Location: Editor startup\n\n${ e . message } ` ,
112- }
113- this . send ( { type :'EDITOR_STARTUP_FAILED' , payload :{ error} } )
114- }
51+ actions . onStartup ( this . context , this . workspaceState , this . send )
11552return
11653
11754// clear tutorial local storage