@daniel-rose/semantic-release-claude-plugin 0.0.0-stage → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +9 -0
- package/README.md +80 -2
- package/dist/index.d.ts +35 -0
- package/dist/index.js +80 -0
- package/package.json +64 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025-present Daniel Rose
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
|
+
|
|
7
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,81 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @daniel-rose/semantic-release-claude-plugin
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[semantic-release](https://github.com/semantic-release/semantic-release) plugin that writes the release version into a [Claude Code plugin](https://code.claude.com/docs/en/plugins)'s `.claude-plugin/plugin.json`.
|
|
4
|
+
|
|
5
|
+
Claude Code updates a plugin only when its version changes. With `version` in `plugin.json`, users get an update for each release and not for every commit. This plugin keeps that version in step with your releases, so nobody has to bump it by hand.
|
|
6
|
+
|
|
7
|
+
| Step | Description |
|
|
8
|
+
| ------------------ | --------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
9
|
+
| `verifyConditions` | The plugin's `plugin.json` exists and has a `name`. With `marketplace`, the marketplace lists the plugin, and its entry has **no** `version`. |
|
|
10
|
+
| `prepare` | Writes `nextRelease.version` into `plugin.json`, right after `name`, two-space indented. Nothing else in the file changes. |
|
|
11
|
+
|
|
12
|
+
## Install
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
npm install --save-dev @daniel-rose/semantic-release-claude-plugin
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Usage
|
|
19
|
+
|
|
20
|
+
Add the plugin before [`@semantic-release/git`](https://github.com/semantic-release/git), and add `plugin.json` to its `assets`, so the release commit contains the new version:
|
|
21
|
+
|
|
22
|
+
```json
|
|
23
|
+
{
|
|
24
|
+
"plugins": [
|
|
25
|
+
"@semantic-release/commit-analyzer",
|
|
26
|
+
"@semantic-release/release-notes-generator",
|
|
27
|
+
[
|
|
28
|
+
"@daniel-rose/semantic-release-claude-plugin",
|
|
29
|
+
{
|
|
30
|
+
"pluginDir": "mod",
|
|
31
|
+
"marketplace": "../../.claude-plugin/marketplace.json"
|
|
32
|
+
}
|
|
33
|
+
],
|
|
34
|
+
[
|
|
35
|
+
"@semantic-release/git",
|
|
36
|
+
{ "assets": ["package.json", "mod/.claude-plugin/plugin.json"] }
|
|
37
|
+
],
|
|
38
|
+
"@semantic-release/github"
|
|
39
|
+
]
|
|
40
|
+
}
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Options
|
|
44
|
+
|
|
45
|
+
| Option | Default | Description |
|
|
46
|
+
| ------------- | ------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
47
|
+
| `pluginDir` | `.` | The Claude Code plugin's folder, relative to the release's cwd (the package folder under multi-semantic-release). Its manifest is `<pluginDir>/.claude-plugin/plugin.json`. |
|
|
48
|
+
| `marketplace` | – | A `marketplace.json` that lists the plugin, relative to the release's cwd. If set, the release fails when the marketplace lists the plugin with a `version`. |
|
|
49
|
+
|
|
50
|
+
## Why not the marketplace entry?
|
|
51
|
+
|
|
52
|
+
Claude Code reads the version from `plugin.json` first and from the marketplace entry second. If both are set, `plugin.json` wins without a warning. If both are written on every release, they can drift apart. So the version lives only in `plugin.json`. The `marketplace` check catches a leftover `version` in the entry before it confuses anyone.
|
|
53
|
+
|
|
54
|
+
## Errors
|
|
55
|
+
|
|
56
|
+
Each error carries a `code` and `details` that semantic-release prints:
|
|
57
|
+
|
|
58
|
+
| Code | Cause |
|
|
59
|
+
| ------------------------------ | ------------------------------------------------------ |
|
|
60
|
+
| `EINVALIDCLAUDEPLUGINCONFIG` | `pluginDir` or `marketplace` is not a non-empty string |
|
|
61
|
+
| `ENOCLAUDEPLUGINMANIFEST` | `plugin.json` does not exist |
|
|
62
|
+
| `EINVALIDCLAUDEPLUGINMANIFEST` | `plugin.json` is not JSON, or has no `name` |
|
|
63
|
+
| `ENOCLAUDEMARKETPLACE` | the marketplace file does not exist |
|
|
64
|
+
| `EINVALIDCLAUDEMARKETPLACE` | the marketplace is not JSON, or has no `plugins` array |
|
|
65
|
+
| `ENOCLAUDEMARKETPLACEENTRY` | the marketplace does not list the plugin |
|
|
66
|
+
| `ECLAUDEMARKETPLACEVERSION` | the marketplace entry of the plugin sets a `version` |
|
|
67
|
+
|
|
68
|
+
## Security
|
|
69
|
+
|
|
70
|
+
The plugin runs in release pipelines that hold write tokens, so it does as little as possible:
|
|
71
|
+
|
|
72
|
+
- no runtime dependencies, only `node:fs` and `node:path`
|
|
73
|
+
- no shell, no network, no `eval`
|
|
74
|
+
- it reads `plugin.json` and the marketplace, and writes only `plugin.json`
|
|
75
|
+
- it is published with npm provenance
|
|
76
|
+
|
|
77
|
+
It does not confine `pluginDir` or `marketplace` to the repository. They come from your own release configuration, which the plugin trusts.
|
|
78
|
+
|
|
79
|
+
## License
|
|
80
|
+
|
|
81
|
+
MIT © Daniel Rose
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
declare const ERROR_CODE: {
|
|
2
|
+
readonly invalidConfig: "EINVALIDCLAUDEPLUGINCONFIG";
|
|
3
|
+
readonly missingManifest: "ENOCLAUDEPLUGINMANIFEST";
|
|
4
|
+
readonly invalidManifest: "EINVALIDCLAUDEPLUGINMANIFEST";
|
|
5
|
+
readonly missingMarketplace: "ENOCLAUDEMARKETPLACE";
|
|
6
|
+
readonly invalidMarketplace: "EINVALIDCLAUDEMARKETPLACE";
|
|
7
|
+
readonly missingMarketplaceEntry: "ENOCLAUDEMARKETPLACEENTRY";
|
|
8
|
+
readonly marketplaceVersion: "ECLAUDEMARKETPLACEVERSION";
|
|
9
|
+
};
|
|
10
|
+
type ErrorCode = (typeof ERROR_CODE)[keyof typeof ERROR_CODE];
|
|
11
|
+
type PluginConfig = {
|
|
12
|
+
pluginDir?: unknown;
|
|
13
|
+
marketplace?: unknown;
|
|
14
|
+
};
|
|
15
|
+
type Logger = {
|
|
16
|
+
log: (message: string, ...args: unknown[]) => void;
|
|
17
|
+
};
|
|
18
|
+
type VerifyConditionsContext = {
|
|
19
|
+
cwd?: string;
|
|
20
|
+
logger: Logger;
|
|
21
|
+
};
|
|
22
|
+
type PrepareContext = VerifyConditionsContext & {
|
|
23
|
+
nextRelease: {
|
|
24
|
+
version: string;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
declare class ClaudePluginError extends Error {
|
|
28
|
+
readonly semanticRelease = true;
|
|
29
|
+
readonly code: ErrorCode;
|
|
30
|
+
readonly details: string;
|
|
31
|
+
constructor(code: ErrorCode, message: string, details: string);
|
|
32
|
+
}
|
|
33
|
+
declare const prepare: (pluginConfig: PluginConfig, context: PrepareContext) => Promise<void>;
|
|
34
|
+
declare const verifyConditions: (pluginConfig: PluginConfig, context: VerifyConditionsContext) => Promise<void>;
|
|
35
|
+
export { ClaudePluginError, ERROR_CODE, type ErrorCode, type Logger, type PluginConfig, type PrepareContext, type VerifyConditionsContext, prepare, verifyConditions };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { readFile as e, writeFile as t } from "node:fs/promises";
|
|
2
|
+
import { join as n, resolve as r } from "node:path";
|
|
3
|
+
// src/constants/ERROR_CODE/index.ts
|
|
4
|
+
var i = {
|
|
5
|
+
invalidConfig: "EINVALIDCLAUDEPLUGINCONFIG",
|
|
6
|
+
missingManifest: "ENOCLAUDEPLUGINMANIFEST",
|
|
7
|
+
invalidManifest: "EINVALIDCLAUDEPLUGINMANIFEST",
|
|
8
|
+
missingMarketplace: "ENOCLAUDEMARKETPLACE",
|
|
9
|
+
invalidMarketplace: "EINVALIDCLAUDEMARKETPLACE",
|
|
10
|
+
missingMarketplaceEntry: "ENOCLAUDEMARKETPLACEENTRY",
|
|
11
|
+
marketplaceVersion: "ECLAUDEMARKETPLACEVERSION"
|
|
12
|
+
}, a = class extends Error {
|
|
13
|
+
semanticRelease = !0;
|
|
14
|
+
code;
|
|
15
|
+
details;
|
|
16
|
+
constructor(e, t, n) {
|
|
17
|
+
super(t), this.name = "ClaudePluginError", this.code = e, this.details = n;
|
|
18
|
+
}
|
|
19
|
+
}, o = {
|
|
20
|
+
dirName: ".claude-plugin",
|
|
21
|
+
fileName: "plugin.json",
|
|
22
|
+
defaultPluginDir: ".",
|
|
23
|
+
jsonIndent: 2
|
|
24
|
+
}, s = (e) => typeof e == "object" && !!e && !Array.isArray(e), c = (e) => e instanceof Error && "code" in e && e.code === "ENOENT", l = async (t, n, r) => {
|
|
25
|
+
let i;
|
|
26
|
+
try {
|
|
27
|
+
i = await e(t, "utf8");
|
|
28
|
+
} catch (e) {
|
|
29
|
+
throw c(e) ? new a(r.missing, `The ${n} does not exist.`, `Expected it at ${t}.`) : e;
|
|
30
|
+
}
|
|
31
|
+
try {
|
|
32
|
+
return JSON.parse(i);
|
|
33
|
+
} catch (e) {
|
|
34
|
+
throw new a(r.invalid, `The ${n} is not valid JSON.`, `${t}: ${e instanceof Error ? e.message : String(e)}`);
|
|
35
|
+
}
|
|
36
|
+
}, u = "Claude Code plugin manifest", d = async (e) => {
|
|
37
|
+
let t = await l(e, u, {
|
|
38
|
+
missing: i.missingManifest,
|
|
39
|
+
invalid: i.invalidManifest
|
|
40
|
+
});
|
|
41
|
+
if (!s(t) || typeof t.name != "string" || t.name === "") throw new a(i.invalidManifest, `The ${u} has no name.`, `${e} must be an object with a non-empty "name".`);
|
|
42
|
+
return {
|
|
43
|
+
...t,
|
|
44
|
+
name: t.name
|
|
45
|
+
};
|
|
46
|
+
}, f = (e, t) => {
|
|
47
|
+
if (t !== void 0) {
|
|
48
|
+
if (typeof t == "string" && t !== "") return t;
|
|
49
|
+
throw new a(i.invalidConfig, `The option "${e}" must be a non-empty string.`, `Got ${JSON.stringify(t)}. Paths are relative to the release's cwd.`);
|
|
50
|
+
}
|
|
51
|
+
}, p = (e, t = process.cwd()) => {
|
|
52
|
+
let i = f("pluginDir", e.pluginDir) ?? o.defaultPluginDir, a = f("marketplace", e.marketplace);
|
|
53
|
+
return {
|
|
54
|
+
manifestPath: r(t, n(i, o.dirName, o.fileName)),
|
|
55
|
+
marketplacePath: a === void 0 ? void 0 : r(t, a)
|
|
56
|
+
};
|
|
57
|
+
}, m = "version", h = (e, t) => {
|
|
58
|
+
let { name: n, ...r } = e, i = Object.entries(r).filter(([e]) => e !== m);
|
|
59
|
+
return {
|
|
60
|
+
name: n,
|
|
61
|
+
[m]: t,
|
|
62
|
+
...Object.fromEntries(i)
|
|
63
|
+
};
|
|
64
|
+
}, g = async (e, n) => {
|
|
65
|
+
let { manifestPath: r } = p(e, n.cwd), i = await d(r), { version: a } = n.nextRelease;
|
|
66
|
+
await t(r, `${JSON.stringify(h(i, a), null, o.jsonIndent)}\n`), n.logger.log("Wrote version %s to %s", a, r);
|
|
67
|
+
}, _ = "Claude Code marketplace", v = async (e, t) => {
|
|
68
|
+
let n = await l(e, _, {
|
|
69
|
+
missing: i.missingMarketplace,
|
|
70
|
+
invalid: i.invalidMarketplace
|
|
71
|
+
});
|
|
72
|
+
if (!s(n) || !Array.isArray(n.plugins)) throw new a(i.invalidMarketplace, `The ${_} lists no plugins.`, `${e} must be an object with a "plugins" array.`);
|
|
73
|
+
let r = n.plugins.find((e) => s(e) && e.name === t);
|
|
74
|
+
if (!s(r)) throw new a(i.missingMarketplaceEntry, `The ${_} does not list the plugin "${t}".`, `Add an entry with "name": "${t}" to "plugins" in ${e}.`);
|
|
75
|
+
if ("version" in r) throw new a(i.marketplaceVersion, `The ${_} entry of "${t}" sets a version.`, `Remove "version" from the entry in ${e}: the release writes it into plugin.json, and Claude Code silently prefers plugin.json's version over the entry's.`);
|
|
76
|
+
}, y = async (e, t) => {
|
|
77
|
+
let { manifestPath: n, marketplacePath: r } = p(e, t.cwd), { name: i } = await d(n);
|
|
78
|
+
r !== void 0 && await v(r, i), t.logger.log("Verified the Claude Code plugin \"%s\"", i);
|
|
79
|
+
};
|
|
80
|
+
export { a as ClaudePluginError, i as ERROR_CODE, g as prepare, y as verifyConditions };
|
package/package.json
CHANGED
|
@@ -1,6 +1,67 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@daniel-rose/semantic-release-claude-plugin",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "semantic-release plugin that writes the release version into a Claude Code plugin's plugin.json.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "Daniel Rose",
|
|
7
|
+
"keywords": [
|
|
8
|
+
"semantic-release",
|
|
9
|
+
"semantic-release-plugin",
|
|
10
|
+
"claude-code",
|
|
11
|
+
"claude-code-plugin",
|
|
12
|
+
"plugin.json",
|
|
13
|
+
"marketplace"
|
|
14
|
+
],
|
|
15
|
+
"type": "module",
|
|
16
|
+
"engines": {
|
|
17
|
+
"node": "^22.14.0 || >=24.10.0"
|
|
18
|
+
},
|
|
19
|
+
"files": [
|
|
20
|
+
"dist",
|
|
21
|
+
"LICENSE"
|
|
22
|
+
],
|
|
23
|
+
"publishConfig": {
|
|
24
|
+
"access": "public"
|
|
25
|
+
},
|
|
26
|
+
"exports": {
|
|
27
|
+
".": {
|
|
28
|
+
"types": "./dist/index.d.ts",
|
|
29
|
+
"import": "./dist/index.js"
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
"peerDependencies": {
|
|
33
|
+
"semantic-release": ">=24"
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"@daniel-rose/eslint-config": "^5.3.1",
|
|
37
|
+
"@daniel-rose/prettier-config": "^2.0.0",
|
|
38
|
+
"@daniel-rose/semantic-release-config": "^2.0.0",
|
|
39
|
+
"@types/node": "^26.6.11",
|
|
40
|
+
"@typescript/native": "npm:typescript@^7.0.2",
|
|
41
|
+
"@vitest/coverage-v8": "^5.1.2",
|
|
42
|
+
"eslint": "^10.16.0",
|
|
43
|
+
"prettier": "^3.10.1",
|
|
44
|
+
"rolldown-plugin-dts": "^0.30.2",
|
|
45
|
+
"semantic-release": "^25.0.9",
|
|
46
|
+
"typescript": "npm:@typescript/typescript6@^6.0.2",
|
|
47
|
+
"vite": "^8.4.0",
|
|
48
|
+
"vitest": "^5.1.2"
|
|
49
|
+
},
|
|
50
|
+
"repository": {
|
|
51
|
+
"type": "git",
|
|
52
|
+
"url": "git+https://github.com/daniel-rose/monorepo.git",
|
|
53
|
+
"directory": "packages/semantic-release-claude-plugin"
|
|
54
|
+
},
|
|
55
|
+
"bugs": {
|
|
56
|
+
"url": "https://github.com/daniel-rose/monorepo/issues"
|
|
57
|
+
},
|
|
58
|
+
"homepage": "https://github.com/daniel-rose/monorepo/blob/main/packages/semantic-release-claude-plugin/README.md",
|
|
59
|
+
"scripts": {
|
|
60
|
+
"build": "tsc -b && vite build",
|
|
61
|
+
"lint": "eslint .",
|
|
62
|
+
"format": "prettier . --write",
|
|
63
|
+
"format:check": "prettier . --check",
|
|
64
|
+
"test:unit": "vitest",
|
|
65
|
+
"test:unit:ci": "vitest run --coverage --outputFile=coverage/junit.xml --reporter=junit"
|
|
66
|
+
}
|
|
6
67
|
}
|