Skip to content

Commit 04111e3

Browse files
authored
Merge pull request #17 from link-foundation/issue-16-bb2b237c0389
Merge toLinksNotationWithRefs to toLinksNotation
2 parents 9b88aee + 3cba349 commit 04111e3

23 files changed

+3214
-529
lines changed

.changeset/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Changesets
2+
3+
Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works
4+
with multi-package repos, or single-package repos to help you version and publish your code. You can
5+
find the full documentation for it [in our repository](https://github.com/changesets/changesets)
6+
7+
We have a quick list of common questions to get you started engaging with this project in
8+
[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md)

.changeset/config.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"$schema": "https://unpkg.com/@changesets/config@3.1.1/schema.json",
3+
"changelog": "@changesets/cli/changelog",
4+
"commit": false,
5+
"fixed": [],
6+
"linked": [],
7+
"access": "public",
8+
"baseBranch": "main",
9+
"updateInternalDependencies": "patch",
10+
"ignore": []
11+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
'@unidel2035/links-client': minor
3+
---
4+
5+
Remove deprecated `toLinksNotationWithRefs` and `to_links_notation_with_refs` functions. Add CI/CD with changesets and test-anywhere testing framework.
6+
7+
**Breaking Changes:**
8+
- Removed `toLinksNotationWithRefs()` / `to_links_notation_with_refs()` - use `toLinksNotation()` / `to_links_notation()` instead
9+
10+
**New Features:**
11+
- Added CI/CD workflow with changeset-based releases
12+
- Migrated JavaScript tests to test-anywhere framework
13+
- Added automated changeset validation for pull requests
14+
15+
**Documentation:**
16+
- Removed deprecated function references from UNIVERSAL_API.md

.github/workflows/ci.yml

Lines changed: 247 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,247 @@
1+
name: CI/CD
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
types: [opened, synchronize, reopened]
9+
10+
concurrency: ${{ github.workflow }}-${{ github.ref }}
11+
12+
jobs:
13+
# Changeset check - only runs on PRs
14+
changeset-check:
15+
name: Check for Changesets
16+
runs-on: ubuntu-latest
17+
if: github.event_name == 'pull_request'
18+
steps:
19+
- uses: actions/checkout@v4
20+
with:
21+
fetch-depth: 0
22+
23+
- name: Setup Node.js
24+
uses: actions/setup-node@v4
25+
with:
26+
node-version: '20.x'
27+
28+
- name: Install dependencies
29+
working-directory: ./js
30+
run: npm install
31+
32+
- name: Check for changesets
33+
run: |
34+
# Skip changeset check for automated version PRs
35+
if [[ "${{ github.head_ref }}" == "changeset-release/"* ]]; then
36+
echo "Skipping changeset check for automated release PR"
37+
exit 0
38+
fi
39+
40+
# Run changeset validation script
41+
node scripts/validate-changeset.mjs
42+
43+
# Test JavaScript
44+
test-js:
45+
name: Test JavaScript
46+
runs-on: ubuntu-latest
47+
needs: [changeset-check]
48+
if: always() && (github.event_name == 'push' || needs.changeset-check.result == 'success')
49+
steps:
50+
- uses: actions/checkout@v4
51+
52+
- name: Setup Node.js
53+
uses: actions/setup-node@v4
54+
with:
55+
node-version: '20.x'
56+
57+
- name: Setup .NET
58+
uses: actions/setup-dotnet@v4
59+
with:
60+
dotnet-version: '8.0.x'
61+
62+
- name: Install clink
63+
run: dotnet tool install --global clink
64+
65+
- name: Verify clink installation
66+
run: clink --version
67+
68+
- name: Install dependencies
69+
working-directory: ./js
70+
run: npm install
71+
72+
- name: Create test data directories
73+
run: |
74+
mkdir -p ./js/data
75+
mkdir -p ./data/auth-data/users
76+
mkdir -p ./data/menu-items
77+
mkdir -p ./js/backend/monolith/data/auth-data
78+
mkdir -p ./js/tests
79+
80+
- name: Run tests
81+
working-directory: ./js
82+
run: npm test
83+
84+
# Test Python
85+
test-python:
86+
name: Test Python
87+
runs-on: ubuntu-latest
88+
needs: [changeset-check]
89+
if: always() && (github.event_name == 'push' || needs.changeset-check.result == 'success')
90+
steps:
91+
- uses: actions/checkout@v4
92+
93+
- name: Setup Python
94+
uses: actions/setup-python@v5
95+
with:
96+
python-version: '3.11'
97+
98+
- name: Setup .NET
99+
uses: actions/setup-dotnet@v4
100+
with:
101+
dotnet-version: '8.0.x'
102+
103+
- name: Install clink
104+
run: dotnet tool install --global clink
105+
106+
- name: Verify clink installation
107+
run: clink --version
108+
109+
- name: Install dependencies
110+
working-directory: ./python
111+
run: |
112+
python -m pip install --upgrade pip
113+
pip install -e ".[dev]"
114+
115+
- name: Create test data directories
116+
run: |
117+
mkdir -p ./python/data
118+
mkdir -p ./data/auth-data/users
119+
mkdir -p ./data/menu-items
120+
121+
- name: Run tests
122+
working-directory: ./python
123+
run: pytest
124+
125+
# Release JavaScript - only runs on main after tests pass
126+
release-js:
127+
name: Release JavaScript
128+
runs-on: ubuntu-latest
129+
needs: [test-js, test-python]
130+
# Use always() to ensure this job runs even if changeset-check was skipped
131+
if: always() && github.ref == 'refs/heads/main' && github.event_name == 'push' && needs.test-js.result == 'success' && needs.test-python.result == 'success'
132+
permissions:
133+
contents: write
134+
pull-requests: write
135+
id-token: write
136+
steps:
137+
- uses: actions/checkout@v4
138+
with:
139+
fetch-depth: 0
140+
141+
- name: Setup Node.js
142+
uses: actions/setup-node@v4
143+
with:
144+
node-version: '20.x'
145+
registry-url: 'https://registry.npmjs.org'
146+
147+
- name: Install dependencies
148+
working-directory: ./js
149+
run: npm install
150+
151+
- name: Check for changesets
152+
id: check_changesets
153+
run: |
154+
# Count changeset files (excluding README.md and config.json)
155+
CHANGESET_COUNT=$(find .changeset -name "*.md" ! -name "README.md" | wc -l)
156+
echo "Found $CHANGESET_COUNT changeset file(s)"
157+
echo "has_changesets=$([[ $CHANGESET_COUNT -gt 0 ]] && echo 'true' || echo 'false')" >> $GITHUB_OUTPUT
158+
159+
- name: Version packages and commit to main
160+
if: steps.check_changesets.outputs.has_changesets == 'true'
161+
id: version
162+
run: |
163+
# Configure git
164+
git config user.name "github-actions[bot]"
165+
git config user.email "github-actions[bot]@users.noreply.github.com"
166+
167+
# Get current version before bump
168+
OLD_VERSION=$(node -p "require('./js/package.json').version")
169+
echo "Current version: $OLD_VERSION"
170+
171+
# Run changeset version to bump versions and update CHANGELOG
172+
cd js && npm run changeset:version && cd ..
173+
174+
# Get new version after bump
175+
NEW_VERSION=$(node -p "require('./js/package.json').version")
176+
echo "New version: $NEW_VERSION"
177+
echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT
178+
179+
# Check if there are changes to commit
180+
if [[ -n $(git status --porcelain) ]]; then
181+
echo "Changes detected, committing..."
182+
183+
# Stage all changes (package.json, package-lock.json, CHANGELOG.md, deleted changesets)
184+
git add -A
185+
186+
# Commit with version number as message
187+
git commit -m "$NEW_VERSION" \
188+
-m "" \
189+
-m "🤖 Generated with [Claude Code](https://claude.com/claude-code)"
190+
191+
# Push directly to main
192+
git push origin main
193+
194+
echo "✅ Version bump committed and pushed to main"
195+
echo "version_committed=true" >> $GITHUB_OUTPUT
196+
else
197+
echo "No changes to commit"
198+
echo "version_committed=false" >> $GITHUB_OUTPUT
199+
fi
200+
201+
- name: Publish to npm
202+
if: steps.version.outputs.version_committed == 'true'
203+
id: publish
204+
run: |
205+
# Pull the latest changes we just pushed
206+
git pull origin main
207+
208+
# Publish to npm
209+
cd js && npm run changeset:publish
210+
211+
echo "published=true" >> $GITHUB_OUTPUT
212+
213+
# Get published version
214+
PUBLISHED_VERSION=$(node -p "require('./js/package.json').version")
215+
echo "published_version=$PUBLISHED_VERSION" >> $GITHUB_OUTPUT
216+
echo "✅ Published @unidel2035/links-client@$PUBLISHED_VERSION to npm"
217+
env:
218+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
219+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
220+
221+
- name: Create GitHub Release
222+
if: steps.publish.outputs.published == 'true'
223+
env:
224+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
225+
run: |
226+
VERSION="${{ steps.publish.outputs.published_version }}"
227+
TAG="v$VERSION"
228+
229+
echo "Creating GitHub release for $TAG..."
230+
231+
# Extract changelog entry for this version
232+
# Read from CHANGELOG.md between this version header and the next version header
233+
if [ -f js/CHANGELOG.md ]; then
234+
RELEASE_NOTES=$(awk "/## $VERSION/{flag=1; next} /## [0-9]/{flag=0} flag" js/CHANGELOG.md)
235+
fi
236+
237+
if [ -z "$RELEASE_NOTES" ]; then
238+
RELEASE_NOTES="Release $VERSION"
239+
fi
240+
241+
# Create release
242+
gh release create "$TAG" \
243+
--title "$VERSION" \
244+
--notes "$RELEASE_NOTES" \
245+
--repo ${{ github.repository }}
246+
247+
echo "✅ Created GitHub release: $TAG"

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,6 @@ node_modules/
44
.DS_Store
55
*.links
66
data/
7+
__pycache__/
8+
*.pyc
9+
*.egg-info/

UNIVERSAL_API.md

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -216,11 +216,13 @@ const nestedArray = await recursiveLinks.readAsNestedArray();
216216
nested_list = recursive_links.read_as_nested_list()
217217
```
218218

219-
#### `toLinksNotation(nestedArray)`
219+
#### `toLinksNotation(input)` / `to_links_notation(input_data)`
220220

221-
Converts nested array/list to Links notation string.
221+
**Universal function** that converts nested arrays/lists OR objects/dicts to Links notation string.
222222

223-
**Example:**
223+
**Examples:**
224+
225+
Arrays/lists:
224226
```javascript
225227
// JavaScript
226228
const notation = recursiveLinks.toLinksNotation([[1, 2], [3, 4]]);
@@ -233,22 +235,18 @@ notation = recursive_links.to_links_notation([[1, 2], [3, 4]])
233235
# Returns: "((1 2) (3 4))"
234236
```
235237

236-
#### `toLinksNotationWithRefs(nestedObject)` / `toLinksNotationWithRefs(nestedDict)`
237-
238-
Converts nested object/dict with references to Links notation string.
239-
240-
**Example:**
238+
Objects/dicts with references:
241239
```javascript
242240
// JavaScript
243-
const notation = recursiveLinks.toLinksNotationWithRefs({
241+
const notation = recursiveLinks.toLinksNotation({
244242
"1": [1, { "2": [5, 6] }, 3, 4]
245243
});
246244
// Returns: "(1: 1 (2: 5 6) 3 4)"
247245
```
248246

249247
```python
250248
# Python
251-
notation = recursive_links.to_links_notation_with_refs({
249+
notation = recursive_links.to_links_notation({
252250
"1": [1, { "2": [5, 6] }, 3, 4]
253251
})
254252
# Returns: "(1: 1 (2: 5 6) 3 4)"

0 commit comments

Comments
 (0)