Revert "fix: add post-build script to fix skill package.json after skill-kit build"

This reverts commit 304df8742d.
This commit is contained in:
Tim Beyer
2026-04-24 10:39:56 +02:00
parent 7288261db5
commit 8d8db04023
3 changed files with 7 additions and 49 deletions
+1 -1
View File
@@ -18,7 +18,7 @@
},
"hooks": {
"before:init": ["pnpm run typecheck", "pnpm run test"],
"after:bump": ["pnpm run build", "node scripts/fix-skill-packagejson.mjs"]
"after:bump": "pnpm run build"
},
"plugins": {
"@release-it/conventional-changelog": {
+6 -2
View File
@@ -64,6 +64,10 @@ skills/<skill-name>/ # Build output (distributed)
### package.json for skill-kit skills
`skill-kit build` overwrites `package.json` with a minimal `{name, version}`. The release pipeline runs `node scripts/fix-skill-packagejson.mjs` after build to restore repo conventions (`@contentful/skill-*` name, repo version, license, files).
`skill-kit build` generates a minimal `package.json`. After building, update it to match the repo convention:
When adding a new skill-kit skill, ensure its built `package.json` has a `description` field — the fix script preserves existing fields but doesn't invent descriptions. Run `node scripts/fix-skill-packagejson.mjs` after your first build to verify.
- `name`: `@contentful/skill-<skill-name>`
- `version`: must match the repo version in the root `package.json` (release-it bumps `skills/*/package.json` automatically)
- Include `description`, `license: "MIT"`, and `files` array
If you add a new skill-kit skill, always check its `package.json` version matches the repo version before committing.
-46
View File
@@ -1,46 +0,0 @@
/**
* Post-build fix for skill-kit skills.
*
* skill-kit build overwrites package.json with a minimal {name, version}.
* This script restores the fields that the repo convention requires:
* scoped name, description, license, and files array.
*
* Run after `pnpm run build` in the release pipeline.
*/
import { readFileSync, writeFileSync, readdirSync, existsSync } from 'node:fs';
import { join } from 'node:path';
const rootPkg = JSON.parse(readFileSync('package.json', 'utf-8'));
const repoVersion = rootPkg.version;
const skillsDir = 'skills';
const dirs = readdirSync(skillsDir, { withFileTypes: true })
.filter((d) => d.isDirectory())
.map((d) => d.name);
for (const dir of dirs) {
const pkgPath = join(skillsDir, dir, 'package.json');
if (!existsSync(pkgPath)) continue;
const pkg = JSON.parse(readFileSync(pkgPath, 'utf-8'));
const isSkillKit = existsSync(join(skillsDir, dir, 'bin'));
pkg.version = repoVersion;
if (!pkg.name.startsWith('@contentful/skill-')) {
pkg.name = `@contentful/skill-${dir}`;
}
if (!pkg.license) pkg.license = 'MIT';
if (isSkillKit && !pkg.files) {
pkg.files = ['SKILL.md', 'scripts/**', 'bin/**', 'references/**'];
} else if (!pkg.files) {
pkg.files = ['SKILL.md', 'references/**'];
}
writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + '\n');
}
console.log(`Fixed ${dirs.length} skill package.json files (version ${repoVersion})`);