estruyf / vscode-demo-time

A Visual Studio Code extension to help you script your demos
https://marketplace.visualstudio.com/items?itemName=eliostruyf.vscode-demo-time
MIT License
12 stars 1 forks source link
demo demo-app demo-time vscode vscode-extension

Demo Time

Unlock a new dimension in presenting coding demos – effortlessly click through them as if they were presentation slides, thanks to this cutting-edge VSCode extension.

Visual Studio Marketplace Number of installs Sponsor the project

Demo Time

Features

Currently the extension supports the following features:

Supported demo steps

File actions

Action Description Usage
create Create a new file ```json { "action": "create", "path": "", "content": " (optional)", "contentPath": " (optional)" } ```
open Open a file ```json { "action": "open", "path": "" } ```

Code actions

Action Description Usage
insert Insert code into a file ```json { "action": "insert", "path": "", "position": " or :", "content": " (optional)", "contentPath": " (optional)", "lineInsertionDelay": " (optional)" } ```
replace Replace code in a file ```json { "action": "replace", "path": "", "position": " or :", "content": " (optional)", "contentPath": " (optional)", "lineInsertionDelay": " (optional)" } ```
delete Delete code from a file ```json { "action": "delete", "path": "", "position": " or :" } ```
highlight Highlight code in a file. You can change the border color with the `demoTime.highlightBorderColor` setting. ```json { "action": "highlight", "path": "", "position": " or :" } ```
unselect Unselect code in a file ```json { "action": "unselect", "path": "" } ```

Time actions

Action Description Usage
waitForTimeout Wait for a specific amount of time ```json { "action": "waitForTimeout", "timeout": "" } ```
waitForInput Wait until the user presses a key ```json { "action": "waitForInput" } ```

VSCode actions

Action Description Usage
executeVSCodeCommand Execute a VSCode command ```json { "action": "executeVSCodeCommand", "command": "", "args": "" } ```
showInfoMessage Show a notification in Visual Studio Code ```json { "action": "showInfoMessage", "message": "" } ```

Terminal actions

Action Description Usage
executeTerminalCommand Execute a command in the terminal ```json { "action": "executeTerminalCommand", "command": "" } ```

Snippets

Action Description Usage
snippet Use a snippet in which you can define multiple reusable steps ```jsonc { "action": "snippet", "contentPath": " (optional)" "args": { // Define the argument name in the snippet file with curly braces {argument name} "": "" } } ```

Usage

To use the extension, you need to create a .demo folder in your workspace. Once created, you can add a JSON file which contains the demo and its steps.

Settings

Setting Description Default
demoTime.highlightBorderColor The border color of the highlighted code rgba(255,0,0,0.5)
demoTime.highlightZoomEnabled Enable zooming when highlighting code false
demoTime.showClock Show a clock in the status bar true
demoTime.timer Count down timer for how long the session should last. If not set, it will not count down. The value is the number of minutes. null
demoTime.insertLineSpeed The speed in milliseconds for inserting lines. If you set it to 0, it will insert its content immediately. 25

Tips

Position

For the position you can use the following formats:

Adding content to a file

When you want to insert content to a file, you can use the content or contentPath properties in the demo step.

Property Description
content This property allows you to add the content directly in the JSON file, but this can make your JSON file quite big and it can be hard to read.
contentPath This property allows you to reference a file in the .demo folder. This way you can keep your JSON file clean and add the content in separate files. Important: the path is relative to the .demo folder.

Example

Here is an example demo:

{
  "$schema": "https://elio.dev/demo-time.schema.json",
  "title": "Playwright demo",
  "description": "Playwright demo for Microsoft 365",
  "demos": [{
      "title": "Login to Microsoft 365",
      "description": "Login to Microsoft 365 using Playwright",
      "steps": [{
          "action": "create",
          "path": "/tests/login.setup.ts",
          "content": "import { test as setup } from \"@playwright/test\";\nimport { existsSync } from \"fs\";\n\nconst authFile = \"playwright/.auth/user.json\";\n\n// More info: https://playwright.dev/docs/auth\n\nsetup(\"authenticate\", async ({ page }) => {\n  // Check if the auth file exists\n  if (existsSync(authFile)) {\n    return;\n  }\n\n  await page.goto(process.env.SP_DEV_PAGE_URL || \"\");\n\n  page.locator(\"input[type=email]\").fill(process.env.SP_DEV_USERNAME || \"\");\n\n  await page.getByRole(\"button\", { name: \"Next\" }).click();\n\n  page.locator(\"input[type=password]\").fill(process.env.SP_DEV_PASSWORD || \"\");\n\n  await Promise.all([\n    await page.locator(\"input[type=submit][value='Sign in']\").click(),\n    await page.locator(\"input[type=submit][value='Yes']\").click(),\n    await page.waitForURL(process.env.SP_DEV_PAGE_URL || \"\"),\n  ]);\n\n  await page.context().storageState({ path: authFile });\n});"
        },
        {
          "action": "open",
          "path": "/tests/login.setup.ts"
        }
      ]
    },
    {
      "title": "First SharePoint tests",
      "description": "Create the first SharePoint tests",
      "steps": [{
          "action": "create",
          "path": "/tests/pages/sharepoint.spec.ts",
          "content": "import { test, expect, Page } from \"@playwright/test\";\n\n// test.describe.configure({ mode: \"serial\" });\n\ntest.describe(`Validate sticker inventory`, () => {\n  let page: Page;\n\n  test.beforeAll(async ({ browser }) => {\n    page = await browser.newPage();\n    await page.goto(process.env.SP_DEV_PAGE_URL || \"\", {\n      waitUntil: \"domcontentloaded\",\n    });\n\n    await page\n      .locator(\n        `div[data-sp-web-part-id=\"0e05b9af-5e56-4570-8b3e-9d679f8b2fcf\"]`\n      )\n      .waitFor();\n  });\n\n  test(`Check if webpart is rendered`, async () => {\n    const webpart = page.locator(\n      `div[data-sp-web-part-id=\"0e05b9af-5e56-4570-8b3e-9d679f8b2fcf\"]`\n    );\n    await expect(webpart).toBeVisible();\n  });\n\n  test.afterAll(async () => {\n    await page.close();\n  });\n});"
        },
        {
          "action": "open",
          "path": "/tests/pages/sharepoint.spec.ts"
        },
        {
          "action": "highlight",
          "path": "/tests/pages/sharepoint.spec.ts",
          "position": "21:26"
        }
      ]
    },
    {
      "title": "Check the amounts",
      "description": "Check the amounts of the stickers",
      "steps": [{
        "action": "insert",
        "path": "/tests/pages/sharepoint.spec.ts",
        "position": 27,
        "content": "\n  test(`Check if there are 7 stickers`, async () => {\n    const stickers = page.getByTestId(`sticker_inventory__overview__sticker`);\n    await expect(stickers).toHaveCount(7);\n  });\n"
      }]
    }
  ]
}

You can also explore a comprehensive example in this GitHub repository: presentation-github-actions with Demo Time.



Front Matter visitors