Skip to content

Commit d8b1229

Browse files
authored
Update workflows (#16)
* Update workflows * Test prettier commit hook * Test prettier commit hook formatting * Checkpoint * Checkpoint * Checkpoint * Checkpoint * Checkpoint * Checkpoint
1 parent 105ad18 commit d8b1229

28 files changed

+1137
-453
lines changed

.github/workflows/build.yaml

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ permissions:
1313
contents: write
1414

1515
jobs:
16-
build:
16+
build-python:
1717
runs-on: ubuntu-latest
1818

1919
steps:
@@ -46,3 +46,34 @@ jobs:
4646
working-directory: ./python
4747
run: |
4848
uv run convert_jsondoc --help
49+
50+
build-typescript:
51+
runs-on: ubuntu-latest
52+
53+
steps:
54+
- uses: actions/checkout@v4
55+
56+
- name: Set up Node.js
57+
uses: actions/setup-node@v4
58+
with:
59+
node-version: '18'
60+
61+
- name: Install dependencies
62+
working-directory: ./typescript
63+
run: npm ci
64+
65+
- name: Generate types
66+
working-directory: ./typescript
67+
run: npm run generate-types
68+
69+
- name: Build
70+
working-directory: ./typescript
71+
run: npm run build
72+
73+
- name: Run tests
74+
working-directory: ./typescript
75+
run: npm test
76+
77+
- name: Check linting
78+
working-directory: ./typescript
79+
run: npm run lint:check

.github/workflows/publish.yaml

Lines changed: 56 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,20 @@
66
# separate terms of service, privacy policy, and support
77
# documentation.
88

9-
name: Upload Python Package
9+
name: Publish Packages
1010

1111
on:
1212
push:
1313
tags:
14-
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10, v0.1.0.dev1
14+
- 'python-v*' # Python releases: python-v1.0.0, python-v1.0.1, etc.
15+
- 'typescript-v*' # TypeScript releases: typescript-v1.0.0, typescript-v1.0.1, etc.
1516

1617
permissions:
1718
contents: read
1819

1920
jobs:
20-
deploy:
21+
publish-python:
22+
if: startsWith(github.ref, 'refs/tags/python-v')
2123
runs-on: ubuntu-latest
2224

2325
steps:
@@ -41,8 +43,8 @@ jobs:
4143
- name: Extract version from tag and update pyproject.toml
4244
working-directory: ./python
4345
run: |
44-
# Get the version from the tag (remove 'v' prefix)
45-
TAG_VERSION=${GITHUB_REF#refs/tags/v}
46+
# Get the version from the tag (remove 'python-v' prefix)
47+
TAG_VERSION=${GITHUB_REF#refs/tags/python-v}
4648
echo "Tag version: $TAG_VERSION"
4749
4850
# Update pyproject.toml with the version from the tag
@@ -70,3 +72,52 @@ jobs:
7072
user: __token__
7173
password: ${{ secrets.PYPI_API_TOKEN }}
7274
verbose: true
75+
76+
publish-typescript:
77+
if: startsWith(github.ref, 'refs/tags/typescript-v')
78+
runs-on: ubuntu-latest
79+
80+
steps:
81+
- uses: actions/checkout@v4
82+
with:
83+
fetch-depth: 0
84+
85+
- name: Set up Node.js
86+
uses: actions/setup-node@v4
87+
with:
88+
node-version: '18'
89+
registry-url: 'https://registry.npmjs.org'
90+
91+
- name: Install dependencies
92+
working-directory: ./typescript
93+
run: npm ci
94+
95+
- name: Extract version from tag and update package.json
96+
working-directory: ./typescript
97+
run: |
98+
# Get the version from the tag (remove 'typescript-v' prefix)
99+
TAG_VERSION=${GITHUB_REF#refs/tags/typescript-v}
100+
echo "Tag version: $TAG_VERSION"
101+
102+
# Update package.json with the version from the tag
103+
npm version $TAG_VERSION --no-git-tag-version
104+
echo "Version updated in package.json to: $TAG_VERSION"
105+
106+
# Verify the change
107+
cat package.json | grep '"version"'
108+
109+
- name: Generate types and build package
110+
working-directory: ./typescript
111+
run: |
112+
npm run generate-types
113+
npm run build
114+
115+
- name: Run tests
116+
working-directory: ./typescript
117+
run: npm test
118+
119+
- name: Publish package to NPM
120+
working-directory: ./typescript
121+
run: npm publish
122+
env:
123+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

.github/workflows/test.yaml

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ on:
99
- main
1010

1111
jobs:
12-
test:
12+
test-python:
1313
name: python
1414
runs-on: ubuntu-latest
1515

@@ -34,4 +34,27 @@ jobs:
3434
run: |
3535
PYTHONPATH=.. uv run pytest
3636
37+
test-typescript:
38+
name: typescript
39+
runs-on: ubuntu-latest
40+
41+
steps:
42+
- name: Check out repository
43+
uses: actions/checkout@v4
3744

45+
- name: Set up Node.js
46+
uses: actions/setup-node@v4
47+
with:
48+
node-version: '18'
49+
50+
- name: Install dependencies
51+
working-directory: ./typescript
52+
run: npm ci
53+
54+
- name: Generate types
55+
working-directory: ./typescript
56+
run: npm run generate-types
57+
58+
- name: Run tests
59+
working-directory: ./typescript
60+
run: npm test

.husky/_/husky.sh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/usr/bin/env sh
2+
if [ -z "$husky_skip_init" ]; then
3+
debug () {
4+
if [ "$HUSKY_DEBUG" = "1" ]; then
5+
echo "husky (debug) - $1"
6+
fi
7+
}
8+
9+
readonly hook_name="$(basename -- "$0")"
10+
debug "starting $hook_name..."
11+
12+
if [ "$HUSKY" = "0" ]; then
13+
debug "HUSKY env variable is set to 0, skipping hook"
14+
exit 0
15+
fi
16+
17+
if [ -f ~/.huskyrc ]; then
18+
debug "sourcing ~/.huskyrc"
19+
. ~/.huskyrc
20+
fi
21+
22+
readonly husky_skip_init=1
23+
export husky_skip_init
24+
sh -e "$0" "$@"
25+
fi

.husky/pre-commit

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env sh
2+
. "$(dirname -- "$0")/_/husky.sh"
3+
4+
cd typescript && npx lint-staged

CLAUDE.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ The project consists of:
1616

1717
- `/schema/`: JSON schemas defining the structure of JSON-DOC files
1818
- `/python/`: Python implementation
19-
- `/ts/`: TypeScript implementation (in progress)
19+
- `/typescript/`: TypeScript implementation
2020
- `/docs/`: Documentation
2121
- `/examples/`: Example files showing the format
2222
- `/tests/`: Tests for both implementations
@@ -53,15 +53,15 @@ ruff format .
5353

5454
```bash
5555
# Set up development environment
56-
cd /Users/onur/tc/JSON-DOC/ts
56+
cd /Users/onur/tc/JSON-DOC/typescript
5757
npm install
5858

5959
# Build TypeScript
60-
cd /Users/onur/tc/JSON-DOC/ts
60+
cd /Users/onur/tc/JSON-DOC/typescript
6161
npm run build
6262

6363
# Run tests
64-
cd /Users/onur/tc/JSON-DOC/ts
64+
cd /Users/onur/tc/JSON-DOC/typescript
6565
npm test
6666
```
6767

typescript/docs/2025-01-05-component-override-example.md renamed to docs/2025-06-05-component-override-example.md

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -11,33 +11,33 @@ This demonstrates how users can now override specific block components in the JS
1111
## Usage Example
1212

1313
```typescript
14-
import {
15-
JsonDocRenderer,
14+
import {
15+
JsonDocRenderer,
1616
ParagraphBlockRenderer,
17-
HeadingBlockRenderer
17+
HeadingBlockRenderer
1818
} from 'jsondoc/renderer';
1919

2020
// Example: Override paragraph with custom className
2121
const CustomParagraph = (props) => (
22-
<ParagraphBlockRenderer
23-
{...props}
22+
<ParagraphBlockRenderer
23+
{...props}
2424
className="my-custom-paragraph-style"
2525
/>
2626
);
2727

28-
// Example: Override heading with wrapper div and custom styling
28+
// Example: Override heading with wrapper div and custom styling
2929
const CustomHeading = (props) => (
3030
<div className="my-heading-wrapper">
31-
<HeadingBlockRenderer
32-
{...props}
31+
<HeadingBlockRenderer
32+
{...props}
3333
className="my-custom-heading"
3434
style={{ color: 'blue' }}
3535
/>
3636
</div>
3737
);
3838

3939
// Usage
40-
<JsonDocRenderer
40+
<JsonDocRenderer
4141
page={jsonDocPage}
4242
components={{
4343
paragraph: CustomParagraph,
@@ -51,7 +51,7 @@ const CustomHeading = (props) => (
5151
## What This Enables
5252

5353
1. **Custom Styling**: Users can add their own CSS classes and styles
54-
2. **Wrapper Components**: Add additional markup around blocks
54+
2. **Wrapper Components**: Add additional markup around blocks
5555
3. **Custom Logic**: Add click handlers, analytics, etc.
5656
4. **Design System Integration**: Easy integration with Tailwind, styled-components, etc.
5757
5. **Progressive Enhancement**: Override only what you need, keep defaults for the rest
@@ -60,15 +60,15 @@ const CustomHeading = (props) => (
6060

6161
```typescript
6262
const TailwindParagraph = (props) => (
63-
<ParagraphBlockRenderer
64-
{...props}
63+
<ParagraphBlockRenderer
64+
{...props}
6565
className="prose prose-lg text-gray-700 leading-relaxed"
6666
/>
6767
);
6868

6969
const TailwindHeading = (props) => (
70-
<HeadingBlockRenderer
71-
{...props}
70+
<HeadingBlockRenderer
71+
{...props}
7272
className="font-bold text-gray-900 border-b border-gray-200 pb-2"
7373
/>
7474
);
@@ -78,15 +78,15 @@ const TailwindHeading = (props) => (
7878

7979
```typescript
8080
const StyledParagraph = styled(ParagraphBlockRenderer)`
81-
font-family: 'Inter', sans-serif;
81+
font-family: "Inter", sans-serif;
8282
line-height: 1.6;
83-
color: ${props => props.theme.colors.text};
83+
color: ${(props) => props.theme.colors.text};
8484
`;
8585

8686
const StyledHeading = styled(HeadingBlockRenderer)`
87-
font-family: 'Playfair Display', serif;
88-
color: ${props => props.theme.colors.primary};
89-
border-bottom: 2px solid ${props => props.theme.colors.accent};
87+
font-family: "Playfair Display", serif;
88+
color: ${(props) => props.theme.colors.primary};
89+
border-bottom: 2px solid ${(props) => props.theme.colors.accent};
9090
`;
9191
```
9292

@@ -96,4 +96,4 @@ const StyledHeading = styled(HeadingBlockRenderer)`
9696
- **Type Safe**: Full TypeScript support for component props
9797
- **React Standard**: Follows familiar React patterns
9898
- **Composable**: Can wrap, extend, or completely replace components
99-
- **Flexible**: Access to all HTML attributes via props spreading
99+
- **Flexible**: Access to all HTML attributes via props spreading

docs/typescript-implementation.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,4 +131,4 @@ While we strive to keep the API similar between the Python and TypeScript implem
131131

132132
## Development
133133

134-
If you want to contribute to the TypeScript implementation, see the [README.md](../ts/README.md) file in the `ts` directory for development instructions.
134+
If you want to contribute to the TypeScript implementation, see the [README.md](../typescript/README.md) file in the `typescript` directory for development instructions.

typescript/.github/workflows/build.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,31 +4,31 @@ on:
44
push:
55
branches: [main]
66
paths:
7-
- "ts/**"
7+
- "typescript/**"
88
pull_request:
99
branches: [main]
1010
paths:
11-
- "ts/**"
11+
- "typescript/**"
1212

1313
jobs:
1414
build:
1515
runs-on: ubuntu-latest
1616
defaults:
1717
run:
18-
working-directory: ./ts
18+
working-directory: ./typescript
1919

2020
strategy:
2121
matrix:
22-
node-version: [16.x, 18.x, 20.x]
22+
node-version: [18.x, 20.x, 22.x]
2323

2424
steps:
25-
- uses: actions/checkout@v3
25+
- uses: actions/checkout@v4
2626
- name: Use Node.js ${{ matrix.node-version }}
27-
uses: actions/setup-node@v3
27+
uses: actions/setup-node@v4
2828
with:
2929
node-version: ${{ matrix.node-version }}
3030
cache: "npm"
31-
cache-dependency-path: ./ts/package-lock.json
31+
cache-dependency-path: ./typescript/package-lock.json
3232

3333
- name: Install dependencies
3434
run: npm ci

typescript/.github/workflows/publish.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,16 @@ jobs:
99
runs-on: ubuntu-latest
1010
defaults:
1111
run:
12-
working-directory: ./ts
12+
working-directory: ./typescript
1313

1414
steps:
15-
- uses: actions/checkout@v3
16-
- uses: actions/setup-node@v3
15+
- uses: actions/checkout@v4
16+
- uses: actions/setup-node@v4
1717
with:
18-
node-version: "16.x"
18+
node-version: "20.x"
1919
registry-url: "https://registry.npmjs.org"
20+
cache: "npm"
21+
cache-dependency-path: ./typescript/package-lock.json
2022

2123
- name: Install dependencies
2224
run: npm ci

0 commit comments

Comments
 (0)