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

add onContinue hook#561

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
ShMcK merged 2 commits intomasterfromon-continue-hook
Jan 9, 2022
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletionsCHANGELOG.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,6 +4,12 @@ All notable changes to the "coderoad-vscode" extension will be documented in thi

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

# [0.19.0]

- Add the ability to run scripts on continue to address an issue where continued tutorials weren't configured correctly.
- adds a "continue" webhook
- adds a `tutorial.config.continue` that lets you run `commands` or `vscodeCommands`

## [0.18.0]

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

## [0.17.0]

-auto-launch a continued tutorial
-Auto-launch a continued tutorial
## [0.16.0]

-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.
-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.

## [0.15.1]

Expand Down
10 changes: 10 additions & 0 deletionssrc/actions/onTutorialConfigContinue.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,6 +6,7 @@ import tutorialConfig from './utils/tutorialConfig'
import { COMMANDS, send } from '../commands'
import logger from '../services/logger'
import { setupWebhook } from '../services/hooks/webhooks'
import * as hooks from '../services/hooks'

const onTutorialConfigContinue = async (action: T.Action, context: Context): Promise<void> => {
try {
Expand All@@ -25,6 +26,15 @@ const onTutorialConfigContinue = async (action: T.Action, context: Context): Pro
if (tutorialToContinue.config?.webhook) {
setupWebhook(tutorialToContinue.config.webhook)
}

// if tutorial.config.reset.command, run it
const continueActions = tutorialToContinue?.config?.continue
if (continueActions) {
hooks.onContinue(
{ commands: continueActions?.commands, vscodeCommands: continueActions?.vscodeCommands },
tutorialToContinue?.id as string,
)
}
} catch (e: any) {
const error = {
type: 'UnknownError',
Expand Down
9 changes: 9 additions & 0 deletionssrc/services/hooks/index.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -56,6 +56,15 @@ export const onReset = async (actions: TT.StepActions, tutorialId: string): Prom
})
}

// run when a tutorial is continued
export const onContinue = async (actions: TT.StepActions, tutorialId: string): Promise<void> => {
await runCommands(actions?.commands)
await runVSCodeCommands(actions?.vscodeCommands)
webhooks.onContinue({
tutorialId,
})
}

// run when an uncaught exception is thrown
export const onError = async (error: Error): Promise<void> => {
telemetry.onError(error)
Expand Down
11 changes: 11 additions & 0 deletionssrc/services/hooks/webhooks.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,6 +6,7 @@ import { WEBHOOK_TOKEN } from '../../environment'
const WEBHOOK_EVENTS = {
init: false,
reset: false,
continue: false,
step_complete: false,
level_complete: false,
tutorial_complete: false,
Expand DownExpand Up@@ -76,6 +77,16 @@ export const onReset = (event: WebhookEventReset): void => {
}
}

type WebhookEventContinue = {
tutorialId: string
}

export const onContinue = (event: WebhookEventReset): void => {
if (WEBHOOK_EVENTS.continue) {
callWebhookEndpoint<WebhookEventContinue>(event)
}
}

type WebhookEventStepComplete = { tutorialId: string; version?: string; levelId: string; stepId: string }

export const onStepComplete = (event: WebhookEventStepComplete): void => {
Expand Down
6 changes: 4 additions & 2 deletionstypings/tutorial.d.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,7 +2,7 @@ import { ProgressStatus } from './index'

export type Maybe<T> = T | null

export typeConfigReset = {
export typeConfigCommands = {
commands?: string[]
vscodeCommands?: VSCodeCommand[]
}
Expand All@@ -13,7 +13,8 @@ export type TutorialConfig = {
repo: TutorialRepo
dependencies?: TutorialDependency[]
setup?: StepActions
reset?: ConfigReset
continue?: ConfigCommands
reset?: ConfigCommands
webhook?: WebhookConfig
}

Expand DownExpand Up@@ -97,6 +98,7 @@ export type VSCodeCommand = string | [string, any]
export interface WebhookConfigEvents {
init?: boolean
reset?: boolean
continue?: boolean
step_complete?: boolean
level_complete?: boolean
tutorial_complete?: boolean
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp