-
-
Notifications
You must be signed in to change notification settings - Fork 53
feat: enhance release workflow #1548
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Changesets | ||
|
||
This directory was generated to track release notes and versioning. | ||
Run `npm run changeset` to add a new changeset when you modify public APIs. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"$schema": "https://unpkg.com/@changesets/[email protected]/schema.json", | ||
"changelog": "@changesets/cli/changelog", | ||
"commit": false, | ||
"linked": [], | ||
"access": "public", | ||
"baseBranch": "main" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
#!/usr/bin/env sh | ||
. "$(dirname -- "$0")/_/husky.sh" | ||
npm run check:exports | ||
npm test | ||
|
||
npm run lint:staged |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -2,9 +2,15 @@ | |||||||||||||||||||||||
"name": "@radui/ui", | ||||||||||||||||||||||||
"version": "0.0.47", | ||||||||||||||||||||||||
"description": "", | ||||||||||||||||||||||||
"main": "dist", | ||||||||||||||||||||||||
"main": "./dist/index.cjs", | ||||||||||||||||||||||||
"module": "./dist/index.js", | ||||||||||||||||||||||||
"types": "./dist/index.d.ts", | ||||||||||||||||||||||||
"type": "module", | ||||||||||||||||||||||||
"exports": { | ||||||||||||||||||||||||
".": { | ||||||||||||||||||||||||
"import": "./dist/index.js", | ||||||||||||||||||||||||
"require": "./dist/index.cjs", | ||||||||||||||||||||||||
"types": "./dist/index.d.ts" | ||||||||||||||||||||||||
"./themes/default.css": "./dist/themes/default.css", | ||||||||||||||||||||||||
"./themes/tailwind-presets/default.js": "./dist/themes/tailwind-presets/default.js" | ||||||||||||||||||||||||
}, | ||||||||||||||||||||||||
|
@@ -27,6 +33,7 @@ | |||||||||||||||||||||||
"process-components": "node scripts/process-components.cjs", | ||||||||||||||||||||||||
"prebuild": "npm run test && npm run clean", | ||||||||||||||||||||||||
"build:generate-exports": "node scripts/generate-exports.cjs", | ||||||||||||||||||||||||
"check:exports": "node scripts/generate-exports.cjs --check", | ||||||||||||||||||||||||
"build:css": "npm run generate-tokens && npm run bundle-tokens && npm run build-css", | ||||||||||||||||||||||||
"build:components": "npm run compile-components && npm run process-components", | ||||||||||||||||||||||||
"build:rollup": "NODE_OPTIONS='--max-old-space-size=8192' npm run build:rollup:process", | ||||||||||||||||||||||||
|
@@ -35,13 +42,21 @@ | |||||||||||||||||||||||
"check:types": "tsc --noEmit", | ||||||||||||||||||||||||
"build-components:esbuild": "npm run compile-components:esbuild && npm run process-components", | ||||||||||||||||||||||||
"build:esbuild": "npm run prebuild && npm run build:css && npm run build-components:esbuild", | ||||||||||||||||||||||||
"release": "npm publish --access public", | ||||||||||||||||||||||||
"release": "npm run build:generate-exports && changeset publish", | ||||||||||||||||||||||||
"changeset": "changeset", | ||||||||||||||||||||||||
"version-packages": "changeset version", | ||||||||||||||||||||||||
"size": "size-limit", | ||||||||||||||||||||||||
Comment on lines
+45
to
+48
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Release flow can publish unbuilt artifacts and skip versioning/size checks.
Apply: - "release": "npm run build:generate-exports && changeset publish",
+ "release": "npm run version-packages && changeset publish", Add (outside this hunk): {
"scripts": {
"prepack": "npm run build:rollup:process && npm run size && npm test"
}
} This ensures the package is built, budget-checked, and tested during publish. 🤖 Prompt for AI Agents
|
||||||||||||||||||||||||
"lint": "eslint --ext .js,.jsx,.ts,.tsx . --fix && stylelint \"**/*.{css,scss,sass}\" --fix", | ||||||||||||||||||||||||
"lint:staged": "lint-staged", | ||||||||||||||||||||||||
"update-rad": "npm update @radui/ui", | ||||||||||||||||||||||||
"setup:dependencies": "npm install --force", | ||||||||||||||||||||||||
"setup": "npm run setup:dependencies" | ||||||||||||||||||||||||
}, | ||||||||||||||||||||||||
"size-limit": [ | ||||||||||||||||||||||||
{ | ||||||||||||||||||||||||
"path": "dist/components/*.js" | ||||||||||||||||||||||||
} | ||||||||||||||||||||||||
], | ||||||||||||||||||||||||
Comment on lines
+55
to
+59
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. size-limit config lacks required "limit" and will fail. Add a budget; otherwise Apply: "size-limit": [
{
- "path": "dist/components/*.js"
+ "path": "dist/components/*.js",
+ "limit": "30 KB"
}
], If you prefer per-entry budgets, split by component or add a second entry for the root bundle (e.g., dist/index.js). 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
|
||||||||||||||||||||||||
"lint-staged": { | ||||||||||||||||||||||||
"*.{js,jsx,ts,tsx}": [ | ||||||||||||||||||||||||
"eslint --fix" | ||||||||||||||||||||||||
|
@@ -87,6 +102,8 @@ | |||||||||||||||||||||||
"@types/jest": "^29.5.14", | ||||||||||||||||||||||||
"@types/react": "^18.3.1", | ||||||||||||||||||||||||
"@typescript-eslint/eslint-plugin": "7.0.0", | ||||||||||||||||||||||||
"@changesets/cli": "^2.27.1", | ||||||||||||||||||||||||
"@size-limit/preset-small-lib": "^11.1.2", | ||||||||||||||||||||||||
"autoprefixer": "10.4.15", | ||||||||||||||||||||||||
"axe-core": "^4.10.2", | ||||||||||||||||||||||||
"babel-plugin-module-resolver": "5.0.2", | ||||||||||||||||||||||||
|
@@ -112,6 +129,7 @@ | |||||||||||||||||||||||
"rollup-plugin-postcss": "^4.0.2", | ||||||||||||||||||||||||
"sass": "^1.77.2", | ||||||||||||||||||||||||
"sass-loader": "16.0.4", | ||||||||||||||||||||||||
"size-limit": "^11.1.2", | ||||||||||||||||||||||||
"storybook": "^8.6.11", | ||||||||||||||||||||||||
"stylelint": "^16.12.0", | ||||||||||||||||||||||||
"stylelint-config-standard": "^36.0.1", | ||||||||||||||||||||||||
|
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -40,6 +40,7 @@ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const fs = require('fs'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const path = require('path'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const RELEASED_COMPONENTS = require('./RELEASED_COMPONENTS.cjs'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const isCheck = process.argv.includes('--check'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
42
to
+43
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Guard missing RELEASED_COMPONENTS to avoid hard crashes. -const RELEASED_COMPONENTS = require('./RELEASED_COMPONENTS.cjs');
+let RELEASED_COMPONENTS = [];
+try {
+ RELEASED_COMPONENTS = require('./RELEASED_COMPONENTS.cjs');
+} catch (e) {
+ console.warn('Warning: RELEASED_COMPONENTS.cjs not found; treating all discovered components as unreleased.');
+} 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// Component exports | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const distPath = path.resolve(__dirname, '../dist/components'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
@@ -53,6 +54,13 @@ try { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const exportsMap = {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// Root export | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
exportsMap['.'] = { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
import: './dist/index.js', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
require: './dist/index.cjs', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
types: './dist/index.d.ts' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// Add theme exports | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
exportsMap['./themes/default.css'] = './dist/themes/default.css'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
exportsMap['./themes/tailwind-presets/default.js'] = './dist/themes/tailwind-presets/default.js'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
@@ -72,6 +80,7 @@ files.forEach(file => { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
exportsMap[`./${name}`] = { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
import: `./dist/components/${name}.js`, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
require: `./dist/components/${name}.cjs`, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
types: `./dist/components/${name}.d.ts` | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
@@ -85,9 +94,20 @@ const pkgPath = path.resolve(__dirname, '../package.json'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
try { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8')); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
pkg.exports = exportsMap; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
console.log('✅ package.json exports updated!'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if (isCheck) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const current = JSON.stringify(pkg.exports, null, 2); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const expected = JSON.stringify(exportsMap, null, 2); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if (current !== expected) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
console.error('❌ package.json exports are out of date. Run npm run build:generate-exports to update.'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
process.exit(1); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
console.log('✅ package.json exports are up to date.'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+98
to
+106
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Avoid brittle string-equality; compare semantically and allow extra custom exports. Exact JSON string compare fails on key order and blocks legitimate extra entries like "./package.json". - if (isCheck) {
- const current = JSON.stringify(pkg.exports, null, 2);
- const expected = JSON.stringify(exportsMap, null, 2);
- if (current !== expected) {
- console.error('❌ package.json exports are out of date. Run npm run build:generate-exports to update.');
- process.exit(1);
- }
- console.log('✅ package.json exports are up to date.');
- } else {
+ if (isCheck) {
+ const deepEqual = (a, b) => {
+ if (a === b) return true;
+ if (typeof a !== typeof b) return false;
+ if (Array.isArray(a)) return a.length === b.length && a.every((v, i) => deepEqual(v, b[i]));
+ if (a && typeof a === 'object') {
+ const ak = Object.keys(a);
+ const bk = Object.keys(b);
+ if (ak.length !== bk.length) return false;
+ return ak.every(k => deepEqual(a[k], b[k]));
+ }
+ return false;
+ };
+ const current = pkg.exports || {};
+ const expected = exportsMap;
+ const mismatches = [];
+ for (const k of Object.keys(expected)) {
+ if (!deepEqual(current[k], expected[k])) mismatches.push(k);
+ }
+ if (mismatches.length) {
+ console.error(`❌ package.json exports are out of date for keys: ${mismatches.join(', ')}. Run npm run build:generate-exports to update.`);
+ process.exit(1);
+ }
+ console.log('✅ package.json exports are up to date.');
+ } else {
pkg.exports = exportsMap;
fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2));
console.log('✅ package.json exports updated!');
} 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
pkg.exports = exportsMap; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
console.log('✅ package.json exports updated!'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} catch (error) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
console.error('❌ Failed to update package.json exports:', error.message); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
process.exit(1); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Verification agent
❓ Verification inconclusive
Fix broken exports JSON (missing brace/comma) — causes npm ci parse error.
The "." export object isn’t closed before the next keys, breaking JSON (see pipeline errors). Close the object and add a comma.
Quick check script:
🏁 Script executed:
Length of output: 738
Fix broken exports JSON in package.json (missing brace/comma)
Close the "." export object and add a comma before the following export entries — package.json fails to parse (json.decoder.JSONDecodeError at line 14 column 5).
📝 Committable suggestion
🧰 Tools
🪛 Biome (2.1.2)
[error] 14-14: expected
,
but instead found"./themes/default.css"
Remove "./themes/default.css"
(parse)
🤖 Prompt for AI Agents