Skip to content

Commit dd0dc27

Browse files
simllllclaude
andauthored
pnpm and changesets (#6)
* refactor: replace @hokify namespace with @node-ts-cache - Rename @hokify/node-ts-cache to @node-ts-cache/core - Rename storage packages to @node-ts-cache/<storage>-storage - @hokify/node-ts-cache-redis-storage → @node-ts-cache/redis-storage - @hokify/node-ts-cache-redisio-storage → @node-ts-cache/ioredis-storage - @hokify/node-ts-cache-node-cache-storage → @node-ts-cache/node-cache-storage - @hokify/node-ts-cache-lru-storage → @node-ts-cache/lru-storage - @hokify/node-ts-cache-lru-redis-storage → @node-ts-cache/lru-redis-storage - Replace @hokify/eslint-config with standard @typescript-eslint config - Update all import statements, documentation, and changelog references - Update author email references * ci: add provenance and public access flags to npm publish - Add --provenance flag for cryptographic attestation - Add --access public for scoped packages - This enables npm to verify the package was built from this repository * chore: migrate from npm+lerna to pnpm+changesets - Replace npm with pnpm as package manager - Replace Lerna with Changesets for versioning and publishing - Add pnpm-workspace.yaml for workspace configuration - Update all internal deps to use workspace:* protocol - Update CI workflows to use pnpm - Set all packages to version 1.0.0 for fresh @node-ts-cache release - Remove lerna.json and package-lock.json * fix: remove pnpm version from workflows to use packageManager field * style: format changeset config with Prettier --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent d62985b commit dd0dc27

14 files changed

Lines changed: 5304 additions & 11757 deletions

File tree

.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.0.0/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+
}

.github/workflows/publish.yml

Lines changed: 25 additions & 181 deletions
Original file line numberDiff line numberDiff line change
@@ -1,212 +1,56 @@
1-
name: Release and Publish
1+
name: Release
22

33
on:
4+
push:
5+
branches:
6+
- main
47
workflow_dispatch:
5-
inputs:
6-
version_type:
7-
description: 'Version bump type (auto = determined by conventional commits)'
8-
required: true
9-
default: 'auto'
10-
type: choice
11-
options:
12-
- auto
13-
- patch
14-
- minor
15-
- major
16-
dry_run:
17-
description: 'Dry run (preview changes without publishing)'
18-
required: false
19-
default: false
20-
type: boolean
8+
9+
concurrency: ${{ github.workflow }}-${{ github.ref }}
2110

2211
jobs:
2312
release:
24-
name: Release and Publish
13+
name: Release
2514
runs-on: ubuntu-latest
2615
permissions:
2716
contents: write
17+
pull-requests: write
2818
id-token: write
2919

3020
steps:
3121
- name: Checkout repository
3222
uses: actions/checkout@v4
33-
with:
34-
fetch-depth: 0
35-
token: ${{ secrets.GITHUB_TOKEN }}
23+
24+
- name: Install pnpm
25+
uses: pnpm/action-setup@v4
3626

3727
- name: Setup Node.js
3828
uses: actions/setup-node@v4
3929
with:
4030
node-version: '20'
4131
registry-url: 'https://registry.npmjs.org'
42-
cache: 'npm'
43-
44-
- name: Configure Git
45-
run: |
46-
git config --global user.name "github-actions[bot]"
47-
git config --global user.email "github-actions[bot]@users.noreply.github.com"
32+
cache: 'pnpm'
4833

4934
- name: Install dependencies
50-
run: npm ci
35+
run: pnpm install --frozen-lockfile
5136

5237
- name: Build
53-
run: npm run build
38+
run: pnpm build
5439

5540
- name: Run tests
56-
run: npm run test
41+
run: pnpm test
5742
env:
5843
CI: true
5944

60-
- name: Check for changes
61-
id: check
62-
run: |
63-
CHANGED=$(npx lerna changed --json 2>/dev/null || echo "[]")
64-
if [ "$CHANGED" == "[]" ]; then
65-
echo "changed=false" >> $GITHUB_OUTPUT
66-
echo "No packages have changed since last release"
67-
else
68-
echo "changed=true" >> $GITHUB_OUTPUT
69-
echo "Changed packages:"
70-
echo "$CHANGED" | jq -r '.[].name'
71-
fi
72-
73-
- name: Dry Run - Preview Changes
74-
if: inputs.dry_run == true
75-
run: |
76-
echo "=== DRY RUN MODE ==="
77-
echo ""
78-
echo "Version type: ${{ inputs.version_type }}"
79-
if [ "${{ inputs.version_type }}" == "auto" ]; then
80-
echo " (auto = determined by conventional commits)"
81-
echo " - fix: commits → patch bump"
82-
echo " - feat: commits → minor bump"
83-
echo " - BREAKING CHANGE → major bump"
84-
fi
85-
echo ""
86-
echo "=== Changed packages ==="
87-
npx lerna changed -l || echo "No packages changed"
88-
echo ""
89-
echo "=== Preview version bumps ==="
90-
VERSION_ARG=""
91-
if [ "${{ inputs.version_type }}" != "auto" ]; then
92-
VERSION_ARG="${{ inputs.version_type }}"
93-
fi
94-
npx lerna version $VERSION_ARG --conventional-commits --no-git-tag-version --no-push --yes 2>/dev/null || true
95-
echo ""
96-
echo "=== Files that would change ==="
97-
git diff --name-only
98-
git checkout -- .
99-
100-
- name: Version packages
101-
if: inputs.dry_run == false && steps.check.outputs.changed == 'true'
102-
id: version
103-
run: |
104-
# Determine version argument (empty for auto = let conventional commits decide)
105-
VERSION_ARG=""
106-
if [ "${{ inputs.version_type }}" != "auto" ]; then
107-
VERSION_ARG="${{ inputs.version_type }}"
108-
fi
109-
110-
# Version packages with conventional commits
111-
# When VERSION_ARG is empty (auto), lerna uses conventional commits to determine version:
112-
# fix: → patch, feat: → minor, BREAKING CHANGE → major
113-
npx lerna version $VERSION_ARG \
114-
--yes \
115-
--conventional-commits \
116-
--changelog-preset angular \
117-
--message "chore(release): publish"
118-
119-
# Get the new version for release notes
120-
NEW_VERSION=$(node -p "require('./lerna.json').version || 'independent'")
121-
echo "version=$NEW_VERSION" >> $GITHUB_OUTPUT
122-
env:
123-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
124-
125-
- name: Generate Release Notes
126-
if: inputs.dry_run == false && steps.check.outputs.changed == 'true'
127-
id: release_notes
128-
run: |
129-
# Get the latest tag
130-
LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
131-
132-
# Generate changelog from commits
133-
if [ -n "$LATEST_TAG" ]; then
134-
PREV_TAG=$(git describe --tags --abbrev=0 ${LATEST_TAG}^ 2>/dev/null || echo "")
135-
if [ -n "$PREV_TAG" ]; then
136-
COMMITS=$(git log ${PREV_TAG}..${LATEST_TAG} --pretty=format:"- %s (%h)" --no-merges)
137-
else
138-
COMMITS=$(git log ${LATEST_TAG} --pretty=format:"- %s (%h)" --no-merges -20)
139-
fi
140-
else
141-
COMMITS=$(git log --pretty=format:"- %s (%h)" --no-merges -20)
142-
fi
143-
144-
# Create release notes file
145-
cat > release_notes.md << 'NOTES_EOF'
146-
## What's Changed
147-
148-
NOTES_EOF
149-
150-
# Add package versions
151-
echo "### Published Packages" >> release_notes.md
152-
echo "" >> release_notes.md
153-
npx lerna ls -l --json | jq -r '.[] | "- \(.name)@\(.version)"' >> release_notes.md
154-
echo "" >> release_notes.md
155-
156-
# Add commits
157-
echo "### Commits" >> release_notes.md
158-
echo "" >> release_notes.md
159-
if [ -n "$COMMITS" ]; then
160-
echo "$COMMITS" >> release_notes.md
161-
else
162-
echo "- Initial release" >> release_notes.md
163-
fi
164-
echo "" >> release_notes.md
165-
166-
# Add install instructions
167-
echo "### Installation" >> release_notes.md
168-
echo "" >> release_notes.md
169-
echo '```bash' >> release_notes.md
170-
echo 'npm install @node-ts-cache/core' >> release_notes.md
171-
echo '```' >> release_notes.md
172-
173-
cat release_notes.md
174-
175-
- name: Publish to npm
176-
if: inputs.dry_run == false && steps.check.outputs.changed == 'true'
177-
run: |
178-
npx lerna publish from-git --yes
45+
- name: Create Release Pull Request or Publish
46+
id: changesets
47+
uses: changesets/action@v1
48+
with:
49+
publish: pnpm release
50+
version: pnpm version
51+
title: 'chore: release packages'
52+
commit: 'chore: release packages'
17953
env:
54+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
55+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
18056
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
181-
182-
- name: Create GitHub Release
183-
if: inputs.dry_run == false && steps.check.outputs.changed == 'true'
184-
run: |
185-
# Get the latest tag created by lerna
186-
LATEST_TAG=$(git describe --tags --abbrev=0)
187-
188-
# Create the GitHub release
189-
gh release create "$LATEST_TAG" \
190-
--title "Release $LATEST_TAG" \
191-
--notes-file release_notes.md
192-
env:
193-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
194-
195-
- name: Summary
196-
if: inputs.dry_run == false && steps.check.outputs.changed == 'true'
197-
run: |
198-
echo "## Release Summary" >> $GITHUB_STEP_SUMMARY
199-
echo "" >> $GITHUB_STEP_SUMMARY
200-
echo "Successfully released the following packages:" >> $GITHUB_STEP_SUMMARY
201-
echo "" >> $GITHUB_STEP_SUMMARY
202-
npx lerna ls -l --json | jq -r '.[] | "- **\(.name)** @ \(.version)"' >> $GITHUB_STEP_SUMMARY
203-
echo "" >> $GITHUB_STEP_SUMMARY
204-
LATEST_TAG=$(git describe --tags --abbrev=0)
205-
echo "GitHub Release: https://github.com/${{ github.repository }}/releases/tag/$LATEST_TAG" >> $GITHUB_STEP_SUMMARY
206-
207-
- name: No changes to release
208-
if: steps.check.outputs.changed == 'false'
209-
run: |
210-
echo "## No Changes" >> $GITHUB_STEP_SUMMARY
211-
echo "" >> $GITHUB_STEP_SUMMARY
212-
echo "No packages have changed since the last release. Nothing to publish." >> $GITHUB_STEP_SUMMARY

.github/workflows/test.yml

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,23 @@ jobs:
2020
- name: Checkout repository
2121
uses: actions/checkout@v4
2222

23+
- name: Install pnpm
24+
uses: pnpm/action-setup@v4
25+
2326
- name: Setup Node.js ${{ matrix.node-version }}
2427
uses: actions/setup-node@v4
2528
with:
2629
node-version: ${{ matrix.node-version }}
27-
cache: 'npm'
30+
cache: 'pnpm'
2831

2932
- name: Install dependencies
30-
run: npm ci --include=optional || npm install
33+
run: pnpm install --frozen-lockfile
3134

3235
- name: Build
33-
run: npm run build
36+
run: pnpm build
3437

3538
- name: Run tests
36-
run: npm run test
39+
run: pnpm test
3740
env:
3841
CI: true
3942

@@ -45,20 +48,23 @@ jobs:
4548
- name: Checkout repository
4649
uses: actions/checkout@v4
4750

51+
- name: Install pnpm
52+
uses: pnpm/action-setup@v4
53+
4854
- name: Setup Node.js
4955
uses: actions/setup-node@v4
5056
with:
5157
node-version: '20'
52-
cache: 'npm'
58+
cache: 'pnpm'
5359

5460
- name: Install dependencies
55-
run: npm ci --include=optional || npm install
61+
run: pnpm install --frozen-lockfile
5662

5763
- name: Build (required for type-aware linting)
58-
run: npm run build
64+
run: pnpm build
5965

6066
- name: Run ESLint
61-
run: npm run lint
67+
run: pnpm lint
6268

6369
- name: Check Prettier formatting
64-
run: npm run format
70+
run: pnpm format

lerna.json

Lines changed: 0 additions & 14 deletions
This file was deleted.

0 commit comments

Comments
 (0)