Skip to content

Update workflows #16

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

Merged
merged 9 commits into from
Jun 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
33 changes: 32 additions & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ permissions:
contents: write

jobs:
build:
build-python:
runs-on: ubuntu-latest

steps:
Expand Down Expand Up @@ -46,3 +46,34 @@ jobs:
working-directory: ./python
run: |
uv run convert_jsondoc --help

build-typescript:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '18'

- name: Install dependencies
working-directory: ./typescript
run: npm ci

- name: Generate types
working-directory: ./typescript
run: npm run generate-types

- name: Build
working-directory: ./typescript
run: npm run build

- name: Run tests
working-directory: ./typescript
run: npm test

- name: Check linting
working-directory: ./typescript
run: npm run lint:check
61 changes: 56 additions & 5 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,20 @@
# separate terms of service, privacy policy, and support
# documentation.

name: Upload Python Package
name: Publish Packages

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

permissions:
contents: read

jobs:
deploy:
publish-python:
if: startsWith(github.ref, 'refs/tags/python-v')
runs-on: ubuntu-latest

steps:
Expand All @@ -41,8 +43,8 @@ jobs:
- name: Extract version from tag and update pyproject.toml
working-directory: ./python
run: |
# Get the version from the tag (remove 'v' prefix)
TAG_VERSION=${GITHUB_REF#refs/tags/v}
# Get the version from the tag (remove 'python-v' prefix)
TAG_VERSION=${GITHUB_REF#refs/tags/python-v}
echo "Tag version: $TAG_VERSION"

# Update pyproject.toml with the version from the tag
Expand Down Expand Up @@ -70,3 +72,52 @@ jobs:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
verbose: true

publish-typescript:
if: startsWith(github.ref, 'refs/tags/typescript-v')
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '18'
registry-url: 'https://registry.npmjs.org'

- name: Install dependencies
working-directory: ./typescript
run: npm ci

- name: Extract version from tag and update package.json
working-directory: ./typescript
run: |
# Get the version from the tag (remove 'typescript-v' prefix)
TAG_VERSION=${GITHUB_REF#refs/tags/typescript-v}
echo "Tag version: $TAG_VERSION"

# Update package.json with the version from the tag
npm version $TAG_VERSION --no-git-tag-version
echo "Version updated in package.json to: $TAG_VERSION"

# Verify the change
cat package.json | grep '"version"'

- name: Generate types and build package
working-directory: ./typescript
run: |
npm run generate-types
npm run build

- name: Run tests
working-directory: ./typescript
run: npm test

- name: Publish package to NPM
working-directory: ./typescript
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
25 changes: 24 additions & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
- main

jobs:
test:
test-python:
name: python
runs-on: ubuntu-latest

Expand All @@ -34,4 +34,27 @@ jobs:
run: |
PYTHONPATH=.. uv run pytest

test-typescript:
name: typescript
runs-on: ubuntu-latest

steps:
- name: Check out repository
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '18'

- name: Install dependencies
working-directory: ./typescript
run: npm ci

- name: Generate types
working-directory: ./typescript
run: npm run generate-types

- name: Run tests
working-directory: ./typescript
run: npm test
25 changes: 25 additions & 0 deletions .husky/_/husky.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env sh
if [ -z "$husky_skip_init" ]; then
debug () {
if [ "$HUSKY_DEBUG" = "1" ]; then
echo "husky (debug) - $1"
fi
}

readonly hook_name="$(basename -- "$0")"
debug "starting $hook_name..."

if [ "$HUSKY" = "0" ]; then
debug "HUSKY env variable is set to 0, skipping hook"
exit 0
fi

if [ -f ~/.huskyrc ]; then
debug "sourcing ~/.huskyrc"
. ~/.huskyrc
fi

readonly husky_skip_init=1
export husky_skip_init
sh -e "$0" "$@"
fi
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

cd typescript && npx lint-staged
8 changes: 4 additions & 4 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ The project consists of:

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

```bash
# Set up development environment
cd /Users/onur/tc/JSON-DOC/ts
cd /Users/onur/tc/JSON-DOC/typescript
npm install

# Build TypeScript
cd /Users/onur/tc/JSON-DOC/ts
cd /Users/onur/tc/JSON-DOC/typescript
npm run build

# Run tests
cd /Users/onur/tc/JSON-DOC/ts
cd /Users/onur/tc/JSON-DOC/typescript
npm test
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,33 +11,33 @@ This demonstrates how users can now override specific block components in the JS
## Usage Example

```typescript
import {
JsonDocRenderer,
import {
JsonDocRenderer,
ParagraphBlockRenderer,
HeadingBlockRenderer
HeadingBlockRenderer
} from 'jsondoc/renderer';

// Example: Override paragraph with custom className
const CustomParagraph = (props) => (
<ParagraphBlockRenderer
{...props}
<ParagraphBlockRenderer
{...props}
className="my-custom-paragraph-style"
/>
);

// Example: Override heading with wrapper div and custom styling
// Example: Override heading with wrapper div and custom styling
const CustomHeading = (props) => (
<div className="my-heading-wrapper">
<HeadingBlockRenderer
{...props}
<HeadingBlockRenderer
{...props}
className="my-custom-heading"
style={{ color: 'blue' }}
/>
</div>
);

// Usage
<JsonDocRenderer
<JsonDocRenderer
page={jsonDocPage}
components={{
paragraph: CustomParagraph,
Expand All @@ -51,7 +51,7 @@ const CustomHeading = (props) => (
## What This Enables

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

```typescript
const TailwindParagraph = (props) => (
<ParagraphBlockRenderer
{...props}
<ParagraphBlockRenderer
{...props}
className="prose prose-lg text-gray-700 leading-relaxed"
/>
);

const TailwindHeading = (props) => (
<HeadingBlockRenderer
{...props}
<HeadingBlockRenderer
{...props}
className="font-bold text-gray-900 border-b border-gray-200 pb-2"
/>
);
Expand All @@ -78,15 +78,15 @@ const TailwindHeading = (props) => (

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

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

Expand All @@ -96,4 +96,4 @@ const StyledHeading = styled(HeadingBlockRenderer)`
- **Type Safe**: Full TypeScript support for component props
- **React Standard**: Follows familiar React patterns
- **Composable**: Can wrap, extend, or completely replace components
- **Flexible**: Access to all HTML attributes via props spreading
- **Flexible**: Access to all HTML attributes via props spreading
2 changes: 1 addition & 1 deletion docs/typescript-implementation.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,4 +131,4 @@ While we strive to keep the API similar between the Python and TypeScript implem

## Development

If you want to contribute to the TypeScript implementation, see the [README.md](../ts/README.md) file in the `ts` directory for development instructions.
If you want to contribute to the TypeScript implementation, see the [README.md](../typescript/README.md) file in the `typescript` directory for development instructions.
14 changes: 7 additions & 7 deletions typescript/.github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,31 @@ on:
push:
branches: [main]
paths:
- "ts/**"
- "typescript/**"
pull_request:
branches: [main]
paths:
- "ts/**"
- "typescript/**"

jobs:
build:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./ts
working-directory: ./typescript

strategy:
matrix:
node-version: [16.x, 18.x, 20.x]
node-version: [18.x, 20.x, 22.x]

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: "npm"
cache-dependency-path: ./ts/package-lock.json
cache-dependency-path: ./typescript/package-lock.json

- name: Install dependencies
run: npm ci
Expand Down
10 changes: 6 additions & 4 deletions typescript/.github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,16 @@ jobs:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./ts
working-directory: ./typescript

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

- name: Install dependencies
run: npm ci
Expand Down
Loading
Loading