Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate Examples -- Continued #2272

Draft
wants to merge 86 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
86 commits
Select commit Hold shift + click to select a range
ea67cee
chore: Bring #940 to current monorepo structure
SimeonC Mar 20, 2023
3a95325
chore: Move generate-examples to packages folder
trillium Mar 25, 2024
1696347
chore: mkdir test-case-component, pnpm init
trillium Mar 27, 2024
17e2f25
chore: Add description for test-case-component/package.json
trillium Mar 27, 2024
97018a7
chore: Move generate-examples/src to test-case-examples/src
trillium Mar 27, 2024
0c8e529
fix: Update fixturesDir to point correctly
trillium Mar 25, 2024
b91a714
fix: Use command.spokenForm from data obj
trillium Mar 25, 2024
6735b66
fix: SelectionParser.parse error for UntypedTarget
trillium Mar 25, 2024
30c76ae
feat: Add originalData to loadFixture.ts
trillium Mar 25, 2024
e085c97
chore: Add description to package.json
trillium Mar 25, 2024
3186cd5
chore: Bring dependencies from old package.json
trillium Mar 27, 2024
bd4542d
chore: Bring scripts from old package.json
trillium Mar 27, 2024
f094326
chore: Update package.json name
trillium Mar 27, 2024
31aa6c4
chore: Update version to 0.0.1
trillium Mar 27, 2024
32b94d2
chore: Add type: module to package.json
trillium Mar 27, 2024
0a69934
chore: Create basic tsconfig.json for test-case-component
trillium Mar 27, 2024
a9756d7
chore: Copy jest config from pkgs/cheatsheet
trillium Mar 27, 2024
a087c05
chore: Run `pnpm -w fix:meta` for test-case-component
trillium Mar 27, 2024
490132d
chore: Delete generate-examples folder
trillium Mar 27, 2024
254c0ed
[pre-commit.ci lite] apply automatic fixes
pre-commit-ci-lite[bot] Mar 27, 2024
844cfbc
chore: Follow pattern for files in /src and not /src/lib
trillium Mar 27, 2024
d1351d2
chore: Add dependencies for /test-case-component in /cursorless-org
trillium Apr 9, 2024
add16dc
wip: Add test-case-component path referecnce
trillium Apr 9, 2024
dc8353e
feat: Match tsconfig to cheatsheet/tsconfig as example
trillium Apr 9, 2024
86dfafe
fix: Remove /lib/ from export in index.ts
trillium Apr 9, 2024
8250440
wip: Basic scaffold for TestCaseComponentPage
trillium Apr 9, 2024
b32c325
chore: Remove buildSpokenForm as it is no longer needed
trillium Apr 9, 2024
a7354f0
chore: Remove package-lock, holdover from previous file structure
trillium Apr 9, 2024
544b118
chore: cursorless-vscode/package.json update as a result of pnpm install
trillium Apr 9, 2024
131a968
chore: Update build script to be compliant with monorepo
trillium Apr 9, 2024
dc28562
chore: Update dependencies, add js-yaml
trillium Apr 9, 2024
34a31c0
chore: Add js-yaml, types to dependencies for cursorless-org
trillium Apr 9, 2024
0314ee1
chore: Add jest as dev dependency for package/test-case-component
trillium Apr 9, 2024
b576e8d
wip: Get yml to pass as props for selected files
trillium Apr 9, 2024
033b425
wip: Create inital component to render shiki code blocks
trillium Apr 9, 2024
0592fbd
wip: Update test-case-componet to import shiki
trillium Apr 9, 2024
dd29896
fixup: lib redo
trillium Apr 9, 2024
0443266
wip: Change title in /component-sheet
trillium May 8, 2024
e0a3421
wip: Add key prop to data.map ShikiComponent
trillium May 8, 2024
188a964
wip: Change css variable names to be in line with new shiki
trillium May 8, 2024
8182a39
wip: Add loadFixture to export
trillium May 9, 2024
fc7adda
chore: Update shiki, move to dev dependencies
trillium May 9, 2024
da45050
feat: Create css files for test-case-component
trillium May 9, 2024
c13b49d
feat: Create css vars theme
trillium May 9, 2024
fd4b90f
feat: Remove fs parts of loadFixture
trillium May 9, 2024
c4a50a5
chore: Switch from IThemedToken to ThemedToken
trillium May 9, 2024
8bdd926
wip: Remove filepath from error state in loadFixtures
trillium May 9, 2024
2da9553
feat: Update component sheet to import yaml files
trillium May 9, 2024
074b68c
feat: Create ShikiComponent
trillium May 9, 2024
cfe7643
feat: Create test-case-componet page scaffolding
trillium May 9, 2024
28d8a65
wip: Drop console log in loadFixture
trillium May 10, 2024
5dbb371
feat: Add ternary logic for data.decorations
trillium May 10, 2024
0cc5b31
wip: Pull in Lang type from old Shiki
trillium May 10, 2024
61148ec
[pre-commit.ci lite] apply automatic fixes
pre-commit-ci-lite[bot] May 10, 2024
88fb074
fix: Add export statement to types file
trillium May 10, 2024
abf5fd9
feat: Add filename property to yaml object, use as key
trillium May 11, 2024
3aa0228
feat: Remove `loaded` step in yaml file data acquisition
trillium May 11, 2024
80748fe
fix: Remove duplicate file reference
trillium May 12, 2024
fef0b61
fix: Use BundledLanguage type from Shiki
trillium May 12, 2024
8dd1bf7
[pre-commit.ci lite] apply automatic fixes
pre-commit-ci-lite[bot] May 12, 2024
5152eef
fix: Define Lang from BundledLanguage
trillium May 12, 2024
ccde788
feat: Add `upgrade` to exports from cursorless-engine
trillium May 12, 2024
257687b
[pre-commit.ci lite] apply automatic fixes
pre-commit-ci-lite[bot] May 12, 2024
75bc289
feat: Add cursorless-engine dependency to cursorless-org
trillium May 12, 2024
80d5f0e
chore: Move non-local imports to top of file
trillium May 12, 2024
5a2c5f5
feat: Import upgrade, add upgrade to data loading step
trillium May 12, 2024
6122848
feat: Drop loaded prop, add TestCaseFixture[] type in test-case-compo…
trillium May 13, 2024
72ca49a
Select incoming in merge conflict in pnpm-lock.yaml
trillium Oct 3, 2024
99e0248
feat: Add lockfile after `pnpm install`
trillium Oct 3, 2024
d3b8da5
chore: Run `pnpm -w fix:meta` for test-case-component
trillium Oct 3, 2024
76cadc6
chore: Resolve import issue with importing "@cursorless/common"
trillium Oct 3, 2024
25422b7
chore: import { TestCaseFixture } --> import type { TestCaseFixture }
trillium Oct 3, 2024
15362a0
feat: Small styling tweaks for ShikiComponent in styles.css
trillium Oct 3, 2024
431348f
wip: Stop using `upgrade` for the moment
trillium Oct 3, 2024
214257f
feat: Drop duplicate data.during in ShikiComponent
trillium Oct 3, 2024
1e48301
chore: Delete buildDictionary file
trillium Jul 24, 2024
956c022
feat: Migrate to current cursorless type PositionPlainObject
trillium Oct 3, 2024
3b305cc
feat: Change var names to adhere to camal case eslint reqs
trillium Oct 3, 2024
8481dce
feat: Add dependency escape-goat to test-case-component
trillium Oct 3, 2024
ff1672d
feat: use htmlEscape for html-escaping in test-case-component
trillium Oct 3, 2024
dfc432b
feat: Change pendingDeleteBackground color to make current colors
trillium Oct 3, 2024
4f610f4
feat: Create referencedBackground class in styles
trillium Oct 3, 2024
f9592bb
feat: Rename decorations --> flashes
trillium Oct 3, 2024
767baea
feat: Rename component-shiki shikiComponent
trillium Oct 3, 2024
8bd0d65
feat: Use @cursorless/common type PositionPlainObject in loadFixture
trillium Oct 3, 2024
4bdf662
[pre-commit.ci lite] apply automatic fixes
pre-commit-ci-lite[bot] Oct 3, 2024
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
1 change: 1 addition & 0 deletions packages/cursorless-engine/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ export * from "./testUtil/plainObjectToTarget";
export * from "./util/getPartialTargetDescriptors";
export * from "./util/getPrimitiveTargets";
export * from "./util/grammarHelpers";
export * from "./scripts/transformRecordedTests/transformations/upgrade";
4 changes: 4 additions & 0 deletions packages/cursorless-org/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,19 @@
},
"dependencies": {
"@cursorless/cheatsheet": "workspace:*",
"@cursorless/cursorless-engine": "workspace:*",
"@cursorless/test-case-component": "workspace:*",
"@mdx-js/loader": "3.0.1",
"@mdx-js/react": "3.0.1",
"@next/mdx": "14.1.4",
"js-yaml": "^4.1.0",
"next": "14.1.4",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-player": "2.15.1"
},
"devDependencies": {
"@types/js-yaml": "^4.0.9",
"@svgr/webpack": "8.1.0",
"@types/mdx": "2.0.12",
"@types/mdx-js__react": "1.5.8",
Expand Down
88 changes: 88 additions & 0 deletions packages/cursorless-org/src/pages/component-sheet.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
import * as yaml from "js-yaml";
import fs from "fs";
import path from "path";
import Head from "next/head";

import {
TestCaseComponentPage,
loadFixture,
} from "@cursorless/test-case-component";
// import { upgrade } from "@cursorless/cursorless-engine"

import { cheatsheetBodyClasses } from "@cursorless/cheatsheet";

const fixturesDir = path.join("../", "../", "data", "fixtures", "recorded");

async function loadYamlFiles(dir: string, selectedFiles?: string[]) {
const directoryPath = path.join(process.cwd(), dir);
const files = fs.readdirSync(directoryPath);
const data: any[] = [];

files.forEach((file) => {
if (
path.extname(file) === ".yml" &&
(!selectedFiles || selectedFiles.includes(file))
) {
const filePath = path.join(directoryPath, file);
const fileContents = fs.readFileSync(filePath, "utf8");
const yamlData: any = yaml.load(fileContents);
yamlData.filename = file;
data.push(yamlData);
}
});

return data;
}

// See https://github.com/vercel/next.js/discussions/12325#discussioncomment-1116108
export async function getStaticProps() {
const itemsDirActions = path.join(fixturesDir, "actions");
const itemsDirDecorations = path.join(fixturesDir, "decorations");
const testSelectedFiles = [
"bringArgMadeAfterLook.yml",
"chuckBlockAirUntilBatt.yml",
"cutFine.yml",
"chuckLineFine.yml",
"bringAirAndBatAndCapToAfterItemEach.yml",
"carveLineHarp.yml",
"chuckBlockAir.yml",
"chuckBlockAirUntilBatt.yml",
"chuckBlockBatt.yml",
"chuckBlockBatt2.yml",
"chuckBlockBattUntilAir.yml",
"chuckFine.yml",
"chuckLineFineBetweenRisk.yml",
"clearBlockFine.yml",
"clearFine.yml",
"clearLineFine.ym",
];
const dataActions = await loadYamlFiles(itemsDirActions, testSelectedFiles);
const dataDecorations = await loadYamlFiles(
itemsDirDecorations,
testSelectedFiles,
);

const data = (
await Promise.all(
[...dataActions, ...dataDecorations].map((val) => {
// const upgraded = upgrade(val)
return loadFixture(val);
}),
)
).filter((val) => val !== undefined);

return { props: { data, bodyClasses: cheatsheetBodyClasses } };
}

export function App({ data }: { data: any; loaded: any }) {
return (
<>
<Head>
<title>Cursorless Test Case Component Page</title>
</Head>
<TestCaseComponentPage data={data} />
</>
);
}

export default App;
6 changes: 6 additions & 0 deletions packages/cursorless-org/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@
"references": [
{
"path": "../cheatsheet"
},
{
"path": "../cursorless-engine"
},
{
"path": "../test-case-component"
}
],
"exclude": ["node_modules"]
Expand Down
4 changes: 3 additions & 1 deletion packages/cursorless-vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1252,7 +1252,9 @@
"clean": "rm -rf ./out tsconfig.tsbuildinfo ./dist ./build"
},
"devDependencies": {
"@types/fs-extra": "11.0.4",
"@types/chai": "^4.3.14",
"@types/fs-extra": "^11.0.4",
"@types/glob": "^8.1.0",
"@types/js-yaml": "^4.0.9",
"@types/lodash-es": "4.17.0",
"@types/nearley": "2.11.5",
Expand Down
8 changes: 8 additions & 0 deletions packages/test-case-component/jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import type { Config } from "jest";

const config: Config = {
preset: "ts-jest",
testEnvironment: "jsdom",
};

export default config;
49 changes: 49 additions & 0 deletions packages/test-case-component/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{
"name": "@cursorless/test-case-component",
"version": "0.0.1",
"type": "module",
"description": "Component for displaying results of test cases in cursorless-vscode-e2e",
"main": "./out/index.js",
"scripts": {
"build": "my-ts-node src/buildDictionary.ts",
"test": "jest",
"test:watch": "jest --watch",
"compile:tsc": "tsc --build",
"compile:esbuild": "esbuild ./src/index.ts --sourcemap --format=esm --bundle --packages=external --outfile=./out/index.js",
"compile": "pnpm compile:tsc && pnpm compile:esbuild",
"watch:tsc": "pnpm compile:tsc --watch",
"watch:esbuild": "pnpm compile:esbuild --watch",
"watch": "pnpm run --filter @cursorless/test-case-component --parallel '/^watch:.*/'",
"clean": "rm -rf ./out tsconfig.tsbuildinfo ./dist ./build"
},
"keywords": [],
"author": "",
"license": "MIT",
"dependencies": {
"@cursorless/common": "workspace:*",
"@cursorless/node-common": "workspace:*",
"escape-goat": "4.0.0",
"fs-extra": "11.2.0",
"js-yaml": "^4.1.0",
"prettier": "3.2.5",
"react": "^18.2.0",
"tsx": "3.12.7",
"yaml": "2.2.1"
},
"types": "./out/index.d.ts",
"exports": {
".": {
"cursorless:bundler": "./src/index.ts",
"default": "./out/index.js"
}
},
"devDependencies": {
"@types/fs-extra": "^11.0.4",
"@types/jest": "29.5.12",
"@types/react": "18.2.71",
"jest": "29.7.0",
"jest-environment-jsdom": "29.7.0",
"shiki": "^1.4.0",
"ts-jest": "29.1.2"
}
}
35 changes: 35 additions & 0 deletions packages/test-case-component/src/components/shikiComponent.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import * as React from "react";

export const ShikiComponent: React.FC<{ data: any }> = ({ data }) => {
return (
<div className="max-w-xl overflow-auto p-4">
<div className="p-8">
<h2 className="dark:text-stone-100">{data.command}</h2>
<div className="m-2 border">
{data.before && (
<div
className="p-4"
dangerouslySetInnerHTML={{ __html: data.before }}
/>
)}
{data.during && (
<>
<div
className="p-4"
dangerouslySetInnerHTML={{ __html: data.during || data.before }}
/>
</>
)}
<div className="command">{data.command}</div>
{data.after && (
<div
className="p-4"
dangerouslySetInnerHTML={{ __html: data.after }}
/>
)}
</div>
</div>
<pre>{JSON.stringify(data, null, 2)}</pre>
</div>
);
};
3 changes: 3 additions & 0 deletions packages/test-case-component/src/generate-examples.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export function generateExamples(): string {
return "generate-examples";
}
Loading
Loading