Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit94f483b

Browse files
authored
add onContinue hook (#561)
* add onContinue hookSigned-off-by: shmck <shawn.j.mckay@gmail.com>* cleanup typoSigned-off-by: shmck <shawn.j.mckay@gmail.com>
1 parent122bd53 commit94f483b

File tree

5 files changed

+42
-4
lines changed

5 files changed

+42
-4
lines changed

‎CHANGELOG.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ All notable changes to the "coderoad-vscode" extension will be documented in thi
44

55
Check[Keep a Changelog](http://keepachangelog.com/) for recommendations on how to structure this file.
66

7+
#[0.19.0]
8+
9+
- Add the ability to run scripts on continue to address an issue where continued tutorials weren't configured correctly.
10+
- adds a "continue" webhook
11+
- adds a`tutorial.config.continue` that lets you run`commands` or`vscodeCommands`
12+
713
##[0.18.0]
814

915
- Improved error logging in output channel "CodeRoad (Logs)"
@@ -18,10 +24,10 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how
1824

1925
##[0.17.0]
2026

21-
-auto-launch a continued tutorial
27+
-Auto-launch a continued tutorial
2228
##[0.16.0]
2329

24-
-add support for writing session state to a file. This is useful in multi-container environments where local storage is not necessarily preserved across sessions.
30+
-Add support for writing session state to a file. This is useful in multi-container environments where local storage is not necessarily preserved across sessions.
2531

2632
##[0.15.1]
2733

‎src/actions/onTutorialConfigContinue.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import tutorialConfig from './utils/tutorialConfig'
66
import{COMMANDS,send}from'../commands'
77
importloggerfrom'../services/logger'
88
import{setupWebhook}from'../services/hooks/webhooks'
9+
import*ashooksfrom'../services/hooks'
910

1011
constonTutorialConfigContinue=async(action:T.Action,context:Context):Promise<void>=>{
1112
try{
@@ -25,6 +26,15 @@ const onTutorialConfigContinue = async (action: T.Action, context: Context): Pro
2526
if(tutorialToContinue.config?.webhook){
2627
setupWebhook(tutorialToContinue.config.webhook)
2728
}
29+
30+
// if tutorial.config.reset.command, run it
31+
constcontinueActions=tutorialToContinue?.config?.continue
32+
if(continueActions){
33+
hooks.onContinue(
34+
{commands:continueActions?.commands,vscodeCommands:continueActions?.vscodeCommands},
35+
tutorialToContinue?.idasstring,
36+
)
37+
}
2838
}catch(e:any){
2939
consterror={
3040
type:'UnknownError',

‎src/services/hooks/index.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,15 @@ export const onReset = async (actions: TT.StepActions, tutorialId: string): Prom
5656
})
5757
}
5858

59+
// run when a tutorial is continued
60+
exportconstonContinue=async(actions:TT.StepActions,tutorialId:string):Promise<void>=>{
61+
awaitrunCommands(actions?.commands)
62+
awaitrunVSCodeCommands(actions?.vscodeCommands)
63+
webhooks.onContinue({
64+
tutorialId,
65+
})
66+
}
67+
5968
// run when an uncaught exception is thrown
6069
exportconstonError=async(error:Error):Promise<void>=>{
6170
telemetry.onError(error)

‎src/services/hooks/webhooks.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { WEBHOOK_TOKEN } from '../../environment'
66
constWEBHOOK_EVENTS={
77
init:false,
88
reset:false,
9+
continue:false,
910
step_complete:false,
1011
level_complete:false,
1112
tutorial_complete:false,
@@ -76,6 +77,16 @@ export const onReset = (event: WebhookEventReset): void => {
7677
}
7778
}
7879

80+
typeWebhookEventContinue={
81+
tutorialId:string
82+
}
83+
84+
exportconstonContinue=(event:WebhookEventReset):void=>{
85+
if(WEBHOOK_EVENTS.continue){
86+
callWebhookEndpoint<WebhookEventContinue>(event)
87+
}
88+
}
89+
7990
typeWebhookEventStepComplete={tutorialId:string;version?:string;levelId:string;stepId:string}
8091

8192
exportconstonStepComplete=(event:WebhookEventStepComplete):void=>{

‎typings/tutorial.d.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { ProgressStatus } from './index'
22

33
exporttypeMaybe<T>=T|null
44

5-
exporttypeConfigReset={
5+
exporttypeConfigCommands={
66
commands?:string[]
77
vscodeCommands?:VSCodeCommand[]
88
}
@@ -13,7 +13,8 @@ export type TutorialConfig = {
1313
repo:TutorialRepo
1414
dependencies?:TutorialDependency[]
1515
setup?:StepActions
16-
reset?:ConfigReset
16+
continue?:ConfigCommands
17+
reset?:ConfigCommands
1718
webhook?:WebhookConfig
1819
}
1920

@@ -97,6 +98,7 @@ export type VSCodeCommand = string | [string, any]
9798
exportinterfaceWebhookConfigEvents{
9899
init?:boolean
99100
reset?:boolean
101+
continue?:boolean
100102
step_complete?:boolean
101103
level_complete?:boolean
102104
tutorial_complete?:boolean

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp