@@ -30,6 +30,7 @@ export const DIDACT_OPEN_AT_STARTUP = 'didact.openDefaultTutorialAtStartup';
3030export const DIDACT_AUTO_INSTALL_DEFAULT_TUTORIALS = 'didact.autoAddDefaultTutorials' ;
3131export const DIDACT_CLI_LINK_LF_SETTING = 'didact.edit.cliLinkLF' ;
3232export const DIDACT_CLI_LINK_TEXT_SETTING = 'didact.edit.cliLinkText' ;
33+ export const DIDACT_APPEND_REGISTERED_SETTING = 'didact.append.registry' ;
3334
3435const CACHED_OUTPUT_CHANNELS : OutputChannel [ ] = new Array < OutputChannel > ( ) ;
3536
@@ -500,3 +501,31 @@ export function getFileExtension(pathAsString: string) : string | undefined {
500501 }
501502 return undefined ;
502503}
504+
505+ export function getAppendRegisteredSetting ( ) : string | undefined {
506+ return extensionFunctions . getContext ( ) . workspaceState . get ( DIDACT_APPEND_REGISTERED_SETTING ) ;
507+ }
508+
509+ export async function setAppendRegisteredSetting ( json : any ) : Promise < void > {
510+ await extensionFunctions . getContext ( ) . workspaceState . update ( DIDACT_APPEND_REGISTERED_SETTING , json ) ;
511+ }
512+
513+ export async function appendAdditionalTutorials ( ) : Promise < void > {
514+ try {
515+ await extensionFunctions . sendTextToOutputChannel ( `Starting Didact tutorials append process` ) ;
516+ const appendTutorialsAtStartup : string | undefined = getAppendRegisteredSetting ( ) ;
517+ if ( appendTutorialsAtStartup ) {
518+ await extensionFunctions . sendTextToOutputChannel ( `Didact tutorials appended at startup via ${ DIDACT_APPEND_REGISTERED_SETTING } with ${ appendTutorialsAtStartup } ` ) ;
519+ const jsonTutorials = JSON . parse ( appendTutorialsAtStartup ) ;
520+ for ( var i = 0 ; i < jsonTutorials . length ; i ++ ) {
521+ const jsonObj :any = jsonTutorials [ i ] ;
522+ await extensionFunctions . sendTextToOutputChannel ( `--Adding ${ jsonObj . sourceUri } as ${ jsonObj . name } /${ jsonObj . category } ` ) ;
523+ await registerTutorialWithCategory ( jsonObj . name , jsonObj . sourceUri , jsonObj . category ) ;
524+ }
525+ }
526+ } catch ( ex ) {
527+ await extensionFunctions . sendTextToOutputChannel ( ex ) ;
528+ console . error ( ex ) ;
529+ return Promise . reject ( ex ) ;
530+ }
531+ }
0 commit comments