From 0c17616426c8df25323fa4ee4538aed61c685201 Mon Sep 17 00:00:00 2001 From: Dominic Elm Date: Mon, 14 Oct 2024 08:59:30 +0200 Subject: [PATCH 1/3] feat(cli): list eject command in help output --- packages/cli/src/commands/eject/index.ts | 3 +++ packages/cli/src/index.ts | 1 + 2 files changed, 4 insertions(+) diff --git a/packages/cli/src/commands/eject/index.ts b/packages/cli/src/commands/eject/index.ts index 146251fab..35d25c10e 100644 --- a/packages/cli/src/commands/eject/index.ts +++ b/packages/cli/src/commands/eject/index.ts @@ -18,6 +18,7 @@ interface PackageJson { } const TUTORIALKIT_VERSION = pkg.version; + const REQUIRED_DEPENDENCIES = [ '@tutorialkit/runtime', '@webcontainer/api', @@ -141,6 +142,8 @@ async function _eject(flags: EjectOptions) { } } } + + return 0; } function validateDestination(folder: string, force: boolean) { diff --git a/packages/cli/src/index.ts b/packages/cli/src/index.ts index ede73cedc..e3e106496 100644 --- a/packages/cli/src/index.ts +++ b/packages/cli/src/index.ts @@ -44,6 +44,7 @@ async function runCommand(cmd: CLICommand, flags: yargs.Arguments): Promise Date: Mon, 14 Oct 2024 13:59:27 +0300 Subject: [PATCH 2/3] test: verify output of `--help` --- packages/cli/tests/create-tutorial.test.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/packages/cli/tests/create-tutorial.test.ts b/packages/cli/tests/create-tutorial.test.ts index 4545a66b4..e536d141b 100644 --- a/packages/cli/tests/create-tutorial.test.ts +++ b/packages/cli/tests/create-tutorial.test.ts @@ -4,6 +4,7 @@ import { tmpdir } from 'node:os'; import path from 'node:path'; import { execa } from 'execa'; import { afterAll, beforeAll, expect, test } from 'vitest'; +import { version } from '../package.json'; // on CI on windows we want to make sure to use the same drive, so we use a custom logic const tmpDir = @@ -230,6 +231,23 @@ test('cannot eject on an astro project that is not using TutorialKit 2', async ( ).rejects.toThrow(`Could not find import to '@tutorialkit/astro'`); }); +test('--help prints out message', async () => { + const { stdout } = await execa('node', [cli, '--help']); + + expect(stdout.replace(version, '[version]')).toMatchInlineSnapshot(` + " + @tutorialkit/cli v[version] Create tutorial apps powered by WebContainer API + + Usage: @tutorialkit/cli [command] [...options] + @tutorialkit/cli [ -h | --help | -v | --version ] + + Commands: + create Create new tutorial app + eject Eject routes + help Show this help message" + `); +}); + function normaliseSlash(filePath: string) { return filePath.replace(/\\/g, '/'); } From 71e260354b542f5c14f37960038bfd93f4efd4ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ari=20Perkki=C3=B6?= Date: Mon, 14 Oct 2024 14:08:23 +0300 Subject: [PATCH 3/3] chore: update description --- packages/cli/src/index.ts | 5 ++++- packages/cli/tests/create-tutorial.test.ts | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/cli/src/index.ts b/packages/cli/src/index.ts index e3e106496..8202a259f 100644 --- a/packages/cli/src/index.ts +++ b/packages/cli/src/index.ts @@ -44,7 +44,10 @@ async function runCommand(cmd: CLICommand, flags: yargs.Arguments): Promise { Commands: create Create new tutorial app - eject Eject routes + eject Move all default pages and components into your project, providing full control over the Astro app help Show this help message" `); });