@@ -2,6 +2,7 @@ import * as T from 'typings'
22import * as TT from 'typings/tutorial'
33import * as E from 'typings/error'
44import * as vscode from 'vscode'
5+ import { satisfies } from 'semver'
56import saveCommit from '../actions/saveCommit'
67import setupActions from '../actions/setupActions'
78import solutionActions from '../actions/solutionActions'
@@ -110,6 +111,25 @@ class Channel implements Channel {
110111 case 'EDITOR_TUTORIAL_CONFIG' :
111112 try {
112113 const data : TT . Tutorial = action . payload . tutorial
114+
115+ // validate extension version
116+ const expectedAppVersion = data . config ?. appVersions ?. coderoadVSCode
117+ if ( expectedAppVersion ) {
118+ const extension = vscode . extensions . getExtension ( 'coderoad.coderoad' )
119+ if ( extension ) {
120+ const currentAppVersion = extension . packageJSON . version
121+ const satisfied = satisfies ( currentAppVersion , expectedAppVersion )
122+ if ( ! satisfied ) {
123+ const error : E . ErrorMessage = {
124+ type : 'UnmetExtensionVersion' ,
125+ message : `Expected CodeRoad v${ expectedAppVersion } , but found ${ currentAppVersion } ` ,
126+ }
127+ this . send ( { type : 'TUTORIAL_CONFIGURE_FAIL' , payload : { error } } )
128+ return
129+ }
130+ }
131+ }
132+
113133 // setup tutorial config (save watcher, test runner, etc)
114134 await this . context . setTutorial ( this . workspaceState , data )
115135
@@ -121,7 +141,7 @@ class Channel implements Channel {
121141 const currentVersion : string | null = await version ( dep . name )
122142 if ( ! currentVersion ) {
123143 // use a custom error message
124- const error = {
144+ const error : E . ErrorMessage = {
125145 type : 'MissingTutorialDependency' ,
126146 message :
127147 dep . message || `Process "${ dep . name } " is required but not found. It may need to be installed` ,
@@ -140,7 +160,7 @@ class Channel implements Channel {
140160 const satisfiedDependency = await compareVersions ( currentVersion , dep . version )
141161
142162 if ( ! satisfiedDependency ) {
143- const error = {
163+ const error : E . ErrorMessage = {
144164 type : 'UnmetTutorialDependency' ,
145165 message : `Expected ${ dep . name } to have version ${ dep . version } , but found version ${ currentVersion } ` ,
146166 actions : [
@@ -155,7 +175,7 @@ class Channel implements Channel {
155175 }
156176
157177 if ( satisfiedDependency !== true ) {
158- const error = satisfiedDependency || {
178+ const error : E . ErrorMessage = satisfiedDependency || {
159179 type : 'UnknownError' ,
160180 message : `Something went wrong comparing dependency for ${ name } ` ,
161181 actions : [
0 commit comments