mirror of
https://github.com/contentful/skills.git
synced 2026-09-14 20:17:03 +08:00
Revert "fix: add post-build script to fix skill package.json after skill-kit build"
This reverts commit 304df8742d.
This commit is contained in:
+1
-1
@@ -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": {
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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})`);
|
||||
Reference in New Issue
Block a user