Skip to content

Commit 4f976ff

Browse files
authored
Merge pull request #105 from livesession/feat/xyd-source-react-babel-runtime
feat(xyd-source-react-babel-runtime): add xyd-source-react-babel-runt…
2 parents 63d6af3 + 320ef26 commit 4f976ff

41 files changed

Lines changed: 3871 additions & 26 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CLAUDE.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# Dev Docs
22

3-
> Below docs sections describes how xyd works under the hood: concepts, architecture or conventions.
3+
> Below docs sections describes how xyd works under the hood: concepts, architecture and conventions.
44
5+
- @docs/DEVELOPMENT.md (**IMPORTANT**)
56
- @docs/Overview.md
67
- @docs/GettingStarted.md
78
- @docs/InstallationAndCli.md

DEVELOPMENT.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,3 +247,4 @@ When developing documents, you can use the following environment flags:
247247
- `XYD_VERBOSE=1`: Enables verbose output and debug logging
248248
- `XYD_NODE_PM=pnpm|bun|npm`: Specifies which package manager to use (auto-detects if not set)
249249

250+
### Read More

docs/DEVELOPMENT.md

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
# DEVELOPMENT
2+
3+
## Tests and Fixtures
4+
5+
### Directory layout
6+
7+
Tests live in `__tests__/` and fixtures in `__fixtures__/` at the package root (or under `src/` for some packages).
8+
9+
```
10+
packages/xyd-<name>/
11+
├── __tests__/
12+
│ ├── <feature>.test.ts # Test file
13+
│ └── utils.ts # Shared test helpers
14+
└── __fixtures__/
15+
├── 1.basic/ # Positive fixture (runs in CI)
16+
├── 2.circular/
17+
├── -1.opendocs.flat/ # Negative-numbered (advanced/optional, may be disabled)
18+
└── -2.complex.openai/
19+
```
20+
21+
### Fixture naming convention
22+
23+
Each fixture is a numbered directory: `<order>.<descriptive-name>`.
24+
25+
| Prefix | Meaning | Example |
26+
|--------|---------|---------|
27+
| `1.`, `2.`, `3.` ... | Standard test cases, run in CI | `1.basic`, `3.multiple-responses` |
28+
| `-1.`, `-2.`, `-3.` ... | Advanced/optional cases, may be commented out or sorted first | `-1.opendocs.flat`, `-2.complex.openai` |
29+
30+
Use dots to add sub-categories: `5.xdocs.sidebar`, `-1.opendocs.sort+group`.
31+
32+
### Input / output pattern
33+
34+
Every fixture contains an **input** and an expected **output**. The format depends on what's being tested:
35+
36+
| Package | Input | Output |
37+
|---------|-------|--------|
38+
| `xyd-gql` | `input.graphql` | `output.json` |
39+
| `xyd-openapi` | `input.yaml` | `output.json` |
40+
| `xyd-opencli-remark` | `input.md` | `output.md` |
41+
| `xyd-source-react-babel-runtime` | `input/` (folder with `src/`, `package.json`, `tsconfig.json`) | `output.js` |
42+
43+
For simple converters (OpenAPI, GraphQL, remark), input and output are single files. For more complex scenarios (Vite builds, multi-file projects), `input/` is a folder containing the full project source.
44+
45+
### Test structure
46+
47+
Tests are data-driven. A test file defines an array of cases and iterates through them using a shared utility:
48+
49+
```ts
50+
// __tests__/<feature>.test.ts
51+
import { testMyFeature } from './utils';
52+
53+
const tests = [
54+
{ name: '1.basic', description: 'Basic example' },
55+
{ name: '2.more', description: 'Extended example' },
56+
];
57+
58+
describe('my-feature', () => {
59+
for (const t of tests) {
60+
it(t.description, async () => {
61+
await testMyFeature(t.name);
62+
});
63+
}
64+
});
65+
```
66+
67+
The utility function in `utils.ts` handles:
68+
1. Loading input from `__fixtures__/<name>/`
69+
2. Running the transformation
70+
3. Saving result to `output.*` (for snapshot regeneration)
71+
4. Comparing result against expected `output.*`
72+
73+
### Running tests
74+
75+
```bash
76+
# Run all unit tests
77+
pnpm test:unit
78+
79+
# Run tests for a specific package
80+
cd packages/xyd-<name>
81+
pnpm test
82+
83+
# Run with vitest watch mode
84+
pnpm vitest
85+
```

packages/xyd-components/output.txt

Lines changed: 0 additions & 13 deletions
This file was deleted.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"name": "xyd-fixture-1-user-card",
3+
"private": true,
4+
"type": "module",
5+
"main": "dist/index.js"
6+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import React from 'react';
2+
3+
/**
4+
* Props for the UserCard component
5+
*/
6+
export interface UserCardProps {
7+
/** Full name of the user */
8+
name: string;
9+
10+
/** Email address of the user */
11+
email: string;
12+
13+
/** URL to the user's avatar image */
14+
avatarUrl?: string;
15+
16+
/** Role or title of the user */
17+
role?: string;
18+
19+
/** Whether the card is in a loading state */
20+
loading?: boolean;
21+
}
22+
23+
/**
24+
* A card component that displays user information with avatar, name, and role.
25+
*
26+
* @category Component
27+
*/
28+
export function UserCard(props: UserCardProps) {
29+
return (
30+
<div>
31+
{props.avatarUrl && <img src={props.avatarUrl} alt={props.name} />}
32+
<h3>{props.name}</h3>
33+
<p>{props.email}</p>
34+
{props.role && <span>{props.role}</span>}
35+
</div>
36+
);
37+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"compilerOptions": {
3+
"outDir": "./dist",
4+
"jsx": "react-jsx",
5+
"skipLibCheck": true,
6+
"module": "ESNext",
7+
"moduleResolution": "bundler",
8+
"target": "ES2020"
9+
},
10+
"include": ["src/**/*.ts", "src/**/*.tsx"]
11+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import { jsxDEV } from "react/jsx-dev-runtime";
2+
function UserCard(props) {
3+
return /* @__PURE__ */ jsxDEV("div", { children: [
4+
props.avatarUrl && /* @__PURE__ */ jsxDEV("img", { src: props.avatarUrl, alt: props.name }, void 0, false, {
5+
fileName: "<ROOT>/src/UserCard.tsx",
6+
lineNumber: 31,
7+
columnNumber: 33
8+
}, this),
9+
/* @__PURE__ */ jsxDEV("h3", { children: props.name }, void 0, false, {
10+
fileName: "<ROOT>/src/UserCard.tsx",
11+
lineNumber: 32,
12+
columnNumber: 13
13+
}, this),
14+
/* @__PURE__ */ jsxDEV("p", { children: props.email }, void 0, false, {
15+
fileName: "<ROOT>/src/UserCard.tsx",
16+
lineNumber: 33,
17+
columnNumber: 13
18+
}, this),
19+
props.role && /* @__PURE__ */ jsxDEV("span", { children: props.role }, void 0, false, {
20+
fileName: "<ROOT>/src/UserCard.tsx",
21+
lineNumber: 34,
22+
columnNumber: 28
23+
}, this)
24+
] }, void 0, true, {
25+
fileName: "<ROOT>/src/UserCard.tsx",
26+
lineNumber: 30,
27+
columnNumber: 9
28+
}, this);
29+
}
30+
UserCard.__xydUniform = JSON.parse(`{"title":"UserCard","canonical":"xyd-fixture-1-user-card/components/UserCard","description":"A card component that displays user information with avatar, name, and role.\\n","context":{"symbolId":"1","symbolName":"UserCard","symbolKind":64,"packageName":"xyd-fixture-1-user-card","fileName":"UserCard.tsx","fileFullPath":"src/UserCard.tsx","line":28,"col":16,"signatureText":{"code":"export function UserCard(props: UserCardProps);","lang":"ts"},"sourcecode":{"code":"export function UserCard(props: UserCardProps) {\\n return (\\n <div>\\n {props.avatarUrl && <img src={props.avatarUrl} alt={props.name} />}\\n <h3>{props.name}</h3>\\n <p>{props.email}</p>\\n {props.role && <span>{props.role}</span>}\\n </div>\\n );\\n}","lang":"ts"},"meta":[],"category":"Component","group":["xyd-fixture-1-user-card","Component"]},"examples":{"groups":[]},"definitions":[{"title":"Props","properties":[{"name":"name","type":"string","description":"Full name of the user\\n","meta":[{"name":"required","value":"true"}]},{"name":"email","type":"string","description":"Email address of the user\\n","meta":[{"name":"required","value":"true"}]},{"name":"avatarUrl","type":"string","description":"URL to the user's avatar image\\n","meta":[]},{"name":"role","type":"string","description":"Role or title of the user\\n","meta":[]},{"name":"loading","type":"boolean","description":"Whether the card is in a loading state\\n","meta":[]}],"meta":[{"name":"type","value":"parameters"}]}]}`);
31+
export {
32+
UserCard
33+
};
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"name": "xyd-fixture-2-sample-app",
3+
"private": true,
4+
"type": "module",
5+
"main": "dist/index.js"
6+
}

0 commit comments

Comments
 (0)