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 82 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
82 commits
Select commit Hold shift + click to select a range
c7a4e1b
chore: Bring #940 to current monorepo structure
SimeonC Mar 20, 2023
920b015
chore: Move generate-examples to packages folder
trillium Mar 25, 2024
555a9ca
chore: mkdir test-case-component, pnpm init
trillium Mar 27, 2024
3df1026
chore: Add description for test-case-component/package.json
trillium Mar 27, 2024
060c5e9
chore: Move generate-examples/src to test-case-examples/src
trillium Mar 27, 2024
329f965
fix: Update fixturesDir to point correctly
trillium Mar 25, 2024
5fef9f5
fix: Use command.spokenForm from data obj
trillium Mar 25, 2024
03c2ab3
fix: SelectionParser.parse error for UntypedTarget
trillium Mar 25, 2024
8d1d022
feat: Add originalData to loadFixture.ts
trillium Mar 25, 2024
07c7445
chore: Add description to package.json
trillium Mar 25, 2024
41471ae
chore: Bring dependencies from old package.json
trillium Mar 27, 2024
7fdf6c0
chore: Bring scripts from old package.json
trillium Mar 27, 2024
fd67da7
chore: Update package.json name
trillium Mar 27, 2024
56a24cd
chore: Update version to 0.0.1
trillium Mar 27, 2024
f95c11e
chore: Add type: module to package.json
trillium Mar 27, 2024
dad1f1c
chore: Create basic tsconfig.json for test-case-component
trillium Mar 27, 2024
fd5759c
chore: Update pnpm-lock.yaml for test-case-component
trillium Mar 27, 2024
8e925e2
chore: Copy jest config from pkgs/cheatsheet
trillium Mar 27, 2024
3c19649
chore: Run `pnpm -w fix:meta` for test-case-component
trillium Mar 27, 2024
8fbb8b0
chore: Delete generate-examples folder
trillium Mar 27, 2024
d55839b
[pre-commit.ci lite] apply automatic fixes
pre-commit-ci-lite[bot] Mar 27, 2024
f793231
chore: Follow pattern for files in /src and not /src/lib
trillium Mar 27, 2024
a6664f3
Fix hot reload for dependencies of cursorless-org
pokey Apr 5, 2024
6c288f8
Add comment
pokey Apr 5, 2024
52e8dff
Merge remote-tracking branch 'upstream/main' into generate-examples
trillium Apr 9, 2024
32fe6c9
chore: Refresh pnpm-lock after merge conflicts
trillium Apr 9, 2024
12c5df2
chore: Add dependencies for /test-case-component in /cursorless-org
trillium Apr 9, 2024
89fd88d
wip: Add test-case-component path referecnce
trillium Apr 9, 2024
e7c1112
feat: Match tsconfig to cheatsheet/tsconfig as example
trillium Apr 9, 2024
6e3c9cd
fixup: lib redo
trillium Apr 9, 2024
364d9c9
fix: Remove /lib/ from export in index.ts
trillium Apr 9, 2024
3546741
wip: Basic scaffold for TestCaseComponentPage
trillium Apr 9, 2024
c32d68c
chore: Remove buildSpokenForm as it is no longer needed
trillium Apr 9, 2024
aa94409
chore: Remove package-lock, holdover from previous file structure
trillium Apr 9, 2024
fff3735
chore: Refresh pnpm-lock after TS errors fix
trillium Apr 9, 2024
c042cb7
chore: cursorless-vscode/package.json update as a result of pnpm install
trillium Apr 9, 2024
0c7f10e
Merge remote-tracking branch 'upstream/main'
trillium Apr 9, 2024
fdce2fc
chore: Update build script to be compliant with monorepo
trillium Apr 9, 2024
e00d7cf
chore: Update dependencies, add js-yaml
trillium Apr 9, 2024
972dd92
chore: Add js-yaml, types to dependencies for cursorless-org
trillium Apr 9, 2024
dbfa61f
chore: Add jest as dev dependency for package/test-case-component
trillium Apr 9, 2024
8200468
chore: Refresh pnpm-lock for `js-yaml`
trillium Apr 9, 2024
71c2acd
chore: Refresh pnpm-lock for `@types/jest`
trillium Apr 9, 2024
5e39efb
wip: Get yml to pass as props for selected files
trillium Apr 9, 2024
d700e38
wip: Create inital component to render shiki code blocks
trillium Apr 9, 2024
cd701e5
wip: Update test-case-componet to import shiki
trillium Apr 9, 2024
19858bf
Merge branch 'generate-examples' into HEAD
trillium Apr 9, 2024
fa31db9
chore: Merge upstream changes into generate_examples branch
trillium May 8, 2024
0e9a37c
wip: Change title in /component-sheet
trillium May 8, 2024
f6b37b0
wip: Add key prop to data.map ShikiComponent
trillium May 8, 2024
70f56d7
wip: Change css variable names to be in line with new shiki
trillium May 8, 2024
7e6f2ce
wip: Remove buildDictionary.ts, unneeded
trillium May 9, 2024
98b4066
wip: Add loadFixture to export
trillium May 9, 2024
de559e0
chore: Update shiki, move to dev dependencies
trillium May 9, 2024
2d7fb72
chore: Refresh pnpm-lock after merge
trillium May 9, 2024
fac52d9
feat: Create css files for test-case-component
trillium May 9, 2024
1efb8d4
feat: Create css vars theme
trillium May 9, 2024
30c4fc9
feat: Remove fs parts of loadFixture
trillium May 9, 2024
c87a098
chore: Switch from IThemedToken to ThemedToken
trillium May 9, 2024
2fd2f55
wip: Remove filepath from error state in loadFixtures
trillium May 9, 2024
454584e
feat: Update component sheet to import yaml files
trillium May 9, 2024
bb89c3e
feat: Create ShikiComponent
trillium May 9, 2024
cae981a
feat: Create test-case-componet page scaffolding
trillium May 9, 2024
1cd6fc9
wip: Drop console log in loadFixture
trillium May 10, 2024
16fdb72
feat: Add ternary logic for data.decorations
trillium May 10, 2024
0fb7e81
wip: Pull in Lang type from old Shiki
trillium May 10, 2024
3a78bc3
[pre-commit.ci lite] apply automatic fixes
pre-commit-ci-lite[bot] May 10, 2024
fd7c7b3
fix: Add export statement to types file
trillium May 10, 2024
dc46115
feat: Add filename property to yaml object, use as key
trillium May 11, 2024
49701ac
feat: Remove `loaded` step in yaml file data acquisition
trillium May 11, 2024
6bb8965
fix: Remove duplicate file reference
trillium May 12, 2024
69231f9
fix: Use BundledLanguage type from Shiki
trillium May 12, 2024
c1bce87
Merge remote-tracking branch 'upstream/main' into generate-examples
trillium May 12, 2024
4c460ea
[pre-commit.ci lite] apply automatic fixes
pre-commit-ci-lite[bot] May 12, 2024
652ba93
fix: Define Lang from BundledLanguage
trillium May 12, 2024
57bfe78
[pre-commit.ci lite] apply automatic fixes
pre-commit-ci-lite[bot] May 12, 2024
cbc2fd7
feat: Add `upgrade` to exports from cursorless-engine
trillium May 12, 2024
15de78a
Merge remote-tracking branch 'origin/generate-examples' into generate…
trillium May 12, 2024
165f90b
feat: Add cursorless-engine dependency to cursorless-org
trillium May 12, 2024
1cee7b2
chore: Move non-local imports to top of file
trillium May 12, 2024
e0a2c90
feat: Import upgrade, add upgrade to data loading step
trillium May 12, 2024
c693d22
feat: Drop loaded prop, add TestCaseFixture[] type in test-case-compo…
trillium May 13, 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 @@ -11,3 +11,4 @@ export * from "./CommandRunner";
export * from "./CommandHistory";
export * from "./CommandHistoryAnalyzer";
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
89 changes: 89 additions & 0 deletions packages/cursorless-org/src/pages/component-sheet.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
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(upgraded);
}),
)
).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;
3 changes: 3 additions & 0 deletions packages/cursorless-org/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
"references": [
{
"path": "../cheatsheet"
},
{
"path": "../test-case-component"
}
],
"exclude": ["node_modules"]
Expand Down
2 changes: 1 addition & 1 deletion packages/cursorless-vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1180,7 +1180,7 @@
},
"devDependencies": {
"@types/chai": "^4.3.14",
"@types/fs-extra": "11.0.4",
"@types/fs-extra": "^11.0.4",
"@types/glob": "^8.1.0",
"@types/js-yaml": "^4.0.9",
"@types/lodash": "4.17.0",
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;
46 changes: 46 additions & 0 deletions packages/test-case-component/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"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": {
"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/react": "18.2.71",
"@types/jest": "29.5.12",
"shiki": "^1.4.0",
"jest": "29.7.0",
"jest-environment-jsdom": "29.7.0",
"ts-jest": "29.1.2"
}
}
35 changes: 35 additions & 0 deletions packages/test-case-component/src/components/component-shiki.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 || data.before) && (
<>
<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