Skip to content

Commit 4c719fe

Browse files
Merge branch 'main' into joan/order-from-config
2 parents 3db8a1e + 70e0da7 commit 4c719fe

File tree

26 files changed

+1300
-1278
lines changed

26 files changed

+1300
-1278
lines changed

.github/workflows/ci.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,20 @@ jobs:
3636
run: pnpm build
3737
- name: Test
3838
run: pnpm test
39+
40+
docs:
41+
name: Docs
42+
runs-on: ubuntu-latest
43+
steps:
44+
- name: Setup
45+
uses: pnpm/action-setup@v4
46+
with:
47+
version: 8
48+
- name: Checkout
49+
uses: actions/checkout@v4
50+
- name: Install dependencies
51+
run: pnpm install
52+
- name: Build
53+
run: pnpm build
54+
- name: Build docs
55+
run: pnpm run docs:build

docs/tutorialkit.dev/package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,16 @@
1212
},
1313
"dependencies": {
1414
"@astrojs/check": "^0.7.0",
15-
"@astrojs/react": "^3.4.0",
16-
"@astrojs/starlight": "^0.23.2",
15+
"@astrojs/react": "^3.6.0",
16+
"@astrojs/starlight": "^0.23.4",
1717
"@types/react": "^18.3.3",
1818
"@types/react-dom": "^18.3.0",
19-
"astro": "^4.8.6",
19+
"astro": "^4.10.3",
2020
"classnames": "^2.5.1",
2121
"react": "^18.3.1",
2222
"react-dom": "^18.3.1",
23-
"sass": "^1.77.3",
24-
"sharp": "^0.32.5",
23+
"sass": "^1.77.6",
24+
"sharp": "^0.32.6",
2525
"starlight-links-validator": "^0.9.0",
2626
"typescript": "^5.4.5"
2727
},

docs/tutorialkit.dev/src/content/docs/guides/configuration.mdx

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ You can configure the appearance and behavior of a TutorialKit lesson by setting
88

99
## Note on inheritance
1010

11-
Some options, like "title," will naturally be unique for each lesson. For others, like "template," the value might be the same across multiple lessons, chapters, or even an entire tutorial. That's why we've made it possible to set some properties on a **chapter**, **part**, or **tutorial** level. We call these values _inherited_.
11+
Some options, like "title," will naturally be unique for each lesson. For others, like "template," the value might be the same across multiple lessons, chapters, or even an entire tutorial. That's why we've made it possible to set some properties on a **chapter**, **part**, or **tutorial** level. We call these values _inherited_.
1212

13-
For instance, if you set `template: "simple"` for a given **part**, all chapters and lessons in this **part** will use the "simple" template.
13+
For instance, if you set `template: "simple"` for a given **part**, all chapters and lessons in this **part** will use the "simple" template.
1414

1515
It's also possible to override inherited properties on a lower level. For example, if you set `template: "simple"` for a **part**, but `template: "advanced"` for a **lesson**, that specific lesson will use the "advanced" template.
1616

@@ -38,16 +38,16 @@ Defines which file should be opened in the [code editor](/guides/ui/#code-editor
3838
<PropertyTable inherited type="string" />
3939

4040
##### `previews`
41-
Configure which ports should be used for the previews allowing you to align the behavior with your demo application's dev server setup. If not specified, the lowest port will be used.
41+
Configure which ports should be used for the previews allowing you to align the behavior with your demo application's dev server setup. If not specified, the lowest port will be used.
4242

43-
You can optionally provide these as an array of tuples where the first element is the port number and the second is the name of the preview, or as an object.
43+
You can optionally provide these as an array of tuples where the first element is the port number and the second is the title of the preview, or as an object.
4444
<PropertyTable inherited type={'Preview[]'} />
4545

4646
The `Preview` type has the following shape:
4747

4848
```ts
49-
type Preview = string
50-
| [port: number, title: string]
49+
type Preview = string
50+
| [port: number, title: string]
5151
| { port: number, title: string }
5252

5353
```
@@ -59,8 +59,8 @@ The main command to be executed. This command will run after the `prepareCommand
5959
The `Command` type has the following shape:
6060

6161
```ts
62-
type Command = string
63-
| [command: string, title: string]
62+
type Command = string
63+
| [command: string, title: string]
6464
| { command: string, title: string }
6565

6666
```
@@ -72,8 +72,8 @@ List of commands to execute sequentially. They are typically used to install dep
7272
The `Command` type has the following shape:
7373

7474
```ts
75-
type Command = string
76-
| [command: string, title: string]
75+
type Command = string
76+
| [command: string, title: string]
7777
| { command: string, title: string }
7878

7979
```
@@ -83,6 +83,10 @@ Configures one or more terminals. TutorialKit provides two types of terminals: r
8383

8484
You can define which terminal panel will be active by default by specifying the `activePanel` value. The value is the given terminal's position in the `panels` array. If you omit the `activePanel` property, the first panel will be the active one.
8585

86+
An interactive terminal will disable the output redirect syntax by default. For instance, you cannot create a file `world.txt` with the contents `hello` using the command `echo hello > world.txt`. The reason is that this could disrupt the lesson if a user overwrites certain files. To allow output redirection, you can change the behavior with the `allowRedirects` setting. You can define this setting either per panel or for all panels at once.
87+
88+
Additionally, you may not want users to run arbitrary commands. For example, if you are creating a lesson about `vitest`, you could specify that the only command the user can run is `vitest` by providing a list of `allowCommands`. Any other command executed by the user will be blocked. You can define the `allowCommands` setting either per panel or for all panels at once.
89+
8690
By default, in every new lesson terminals start a new session. If you want to keep the terminal session between lessons, you can specify the `id` property for a given terminal panel and keep the same `id` across lessons.
8791
<PropertyTable inherited type="Terminal" />
8892

@@ -91,12 +95,14 @@ The `Terminal` type has the following shape:
9195
```ts
9296
type Terminal = {
9397
panels: TerminalPanel[],
94-
activePanel?: number
98+
activePanel?: number,
99+
allowRedirects?: boolean,
100+
allowCommands?: string[]
95101
}
96102

97103
type TerminalPanel = TerminalType
98-
| [type: TerminalType, name: string]
99-
| [type: TerminalType, { name: string, id: string }]
104+
| [type: TerminalType, title: string]
105+
| { type: TerminalType, title?: string, id?: string, allowRedirects?: boolean, allowCommands?: boolean }
100106

101107
type TerminalType = 'terminal' | 'output'
102108

@@ -106,10 +112,16 @@ Example value:
106112

107113
```yaml
108114
terminal:
115+
activePanel: 1
109116
panels:
110117
- ['output', 'Dev Server']
111-
- ['terminal', { name: 'Command Line', id: 'cmds' }]
112-
activePanel: 1
118+
- type: terminal
119+
id: 'cmds'
120+
title: 'Command Line'
121+
allowRedirects: true,
122+
allowCommands:
123+
- ls
124+
- echo
113125

114126
```
115127

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"conventional-changelog": "^6.0.0",
2222
"husky": "^9.0.11",
2323
"is-ci": "^3.0.1",
24-
"prettier": "^3.3.1",
24+
"prettier": "^3.3.2",
2525
"prettier-plugin-astro": "^0.13.0",
2626
"tempfile": "^5.0.0"
2727
},

packages/astro/package.json

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,17 @@
2020
"build": "node ./scripts/build.js"
2121
},
2222
"dependencies": {
23-
"@astrojs/mdx": "^3.0.0",
24-
"@astrojs/react": "^3.3.4",
23+
"@astrojs/mdx": "^3.1.1",
24+
"@astrojs/react": "^3.6.0",
2525
"@expressive-code/plugin-collapsible-sections": "^0.35.3",
2626
"@expressive-code/plugin-line-numbers": "^0.35.3",
2727
"@nanostores/react": "0.7.2",
2828
"@tutorialkit/components-react": "workspace:*",
2929
"@tutorialkit/runtime": "workspace:*",
3030
"@tutorialkit/types": "workspace:*",
31-
"@types/react": "^18.2.75",
31+
"@types/react": "^18.3.3",
3232
"@webcontainer/api": "1.2.0",
33+
"astro": "^4.10.3",
3334
"astro-expressive-code": "^0.35.3",
3435
"chokidar": "3.6.0",
3536
"fast-glob": "^3.3.2",
@@ -39,19 +40,19 @@
3940
"mdast-util-directive": "^3.0.0",
4041
"mdast-util-to-markdown": "^2.1.0",
4142
"nanostores": "^0.10.3",
42-
"react": "^18.2.0",
43-
"react-dom": "^18.2.0",
43+
"react": "^18.3.1",
44+
"react-dom": "^18.3.1",
4445
"remark-directive": "^3.0.0",
45-
"unified": "^11.0.4",
46+
"unified": "^11.0.5",
4647
"unist-util-visit": "^5.0.0",
4748
"unocss": "^0.59.4",
4849
"zod": "3.23.8"
4950
},
5051
"devDependencies": {
5152
"@tutorialkit/types": "workspace:*",
52-
"@types/mdast": "^4.0.3",
53+
"@types/mdast": "^4.0.4",
5354
"esbuild": "^0.20.2",
54-
"esbuild-node-externals": "^1.13.0",
55+
"esbuild-node-externals": "^1.13.1",
5556
"execa": "^9.2.0",
5657
"typescript": "^5.4.5",
5758
"vite-plugin-inspect": "0.8.4"

packages/cli/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
"@babel/types": "7.24.5",
3232
"@clack/prompts": "^0.7.0",
3333
"chalk": "^5.3.0",
34+
"execa": "^9.2.0",
3435
"ignore": "^5.3.1",
3536
"lookpath": "^1.2.2",
3637
"yargs-parser": "^21.1.1"
@@ -39,11 +40,10 @@
3940
"@types/babel__generator": "7.6.8",
4041
"@types/babel__traverse": "7.20.5",
4142
"@types/fs-extra": "^11.0.4",
42-
"@types/node": "^20.12.7",
43+
"@types/node": "^20.14.6",
4344
"@types/yargs-parser": "^21.0.3",
4445
"esbuild": "^0.20.2",
45-
"esbuild-node-externals": "^1.13.0",
46-
"execa": "^9.2.0",
46+
"esbuild-node-externals": "^1.13.1",
4747
"fs-extra": "^11.2.0",
4848
"vitest": "^1.6.0"
4949
},

packages/cli/src/commands/create/dependencies.ts

Lines changed: 0 additions & 115 deletions
This file was deleted.

packages/cli/src/commands/create/enterprise.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,14 @@ import { parseAstroConfig, replaceArgs } from './astro-config.js';
55
import { generate } from './babel.js';
66

77
export async function setupEnterpriseConfig(dest: string, flags: CreateOptions) {
8-
let editorOrigin = flags.enterprise;
9-
108
if (!flags.defaults && flags.enterprise === undefined) {
9+
// early exit if `--defaults` is provided without `--enterprise`
1110
return;
12-
} else if (editorOrigin) {
11+
}
12+
13+
let editorOrigin = flags.enterprise;
14+
15+
if (editorOrigin) {
1316
const error = validateEditorOrigin(editorOrigin);
1417

1518
if (error) {

packages/cli/src/commands/create/git.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ import { pkg } from '../../pkg.js';
66
import { warnLabel } from '../../utils/messages.js';
77
import { runShellCommand } from '../../utils/shell.js';
88
import { assertNotCanceled, runTask } from '../../utils/tasks.js';
9-
import { DEFAULT_VALUES, type CreateOptions } from './options.js';
9+
import { DEFAULT_VALUES, readFlag, type CreateOptions } from './options.js';
1010

1111
export async function initGitRepo(cwd: string, flags: CreateOptions) {
12-
let shouldInitGitRepo = flags.git ?? DEFAULT_VALUES.git;
12+
let shouldInitGitRepo = readFlag(flags, 'git');
1313

14-
if (!flags.defaults && flags.git === undefined) {
14+
if (shouldInitGitRepo === undefined) {
1515
const answer = await prompts.confirm({
1616
message: 'Initialize a new git repository?',
1717
initialValue: DEFAULT_VALUES.git,

0 commit comments

Comments
 (0)