mirror of
https://github.com/anthropics/claude-code-action.git
synced 2026-01-22 22:44:13 +08:00
This commit adds support for installing Claude Code plugins via a new `plugins` input parameter.
Changes:
- Added `plugins` input to action.yml (comma-separated list)
- Created `install-plugins.ts` with plugin installation logic
- Added comprehensive tests in `install-plugins.test.ts`
- Updated base-action index.ts to call plugin installation
- Plugins are installed after settings setup but before Claude execution
Usage example:
```yaml
- uses: anthropic-ai/claude-code-action@main
with:
plugins: "feature-dev,test-coverage-reviewer"
```
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
85 lines
2.3 KiB
TypeScript
85 lines
2.3 KiB
TypeScript
#!/usr/bin/env bun
|
|
|
|
import { describe, test, expect } from "bun:test";
|
|
import { parsePlugins } from "../src/install-plugins";
|
|
|
|
describe("parsePlugins", () => {
|
|
test("should return empty array for undefined input", () => {
|
|
expect(parsePlugins(undefined)).toEqual([]);
|
|
});
|
|
|
|
test("should return empty array for empty string", () => {
|
|
expect(parsePlugins("")).toEqual([]);
|
|
});
|
|
|
|
test("should return empty array for whitespace-only string", () => {
|
|
expect(parsePlugins(" \n\t ")).toEqual([]);
|
|
});
|
|
|
|
test("should parse single plugin", () => {
|
|
expect(parsePlugins("feature-dev")).toEqual(["feature-dev"]);
|
|
});
|
|
|
|
test("should parse multiple plugins", () => {
|
|
expect(parsePlugins("feature-dev,test-coverage-reviewer")).toEqual([
|
|
"feature-dev",
|
|
"test-coverage-reviewer",
|
|
]);
|
|
});
|
|
|
|
test("should trim whitespace around plugin names", () => {
|
|
expect(parsePlugins(" feature-dev , test-coverage-reviewer ")).toEqual([
|
|
"feature-dev",
|
|
"test-coverage-reviewer",
|
|
]);
|
|
});
|
|
|
|
test("should handle spaces between commas", () => {
|
|
expect(
|
|
parsePlugins(
|
|
"feature-dev, test-coverage-reviewer, code-quality-reviewer",
|
|
),
|
|
).toEqual([
|
|
"feature-dev",
|
|
"test-coverage-reviewer",
|
|
"code-quality-reviewer",
|
|
]);
|
|
});
|
|
|
|
test("should filter out empty values from consecutive commas", () => {
|
|
expect(parsePlugins("feature-dev,,test-coverage-reviewer")).toEqual([
|
|
"feature-dev",
|
|
"test-coverage-reviewer",
|
|
]);
|
|
});
|
|
|
|
test("should handle trailing comma", () => {
|
|
expect(parsePlugins("feature-dev,test-coverage-reviewer,")).toEqual([
|
|
"feature-dev",
|
|
"test-coverage-reviewer",
|
|
]);
|
|
});
|
|
|
|
test("should handle leading comma", () => {
|
|
expect(parsePlugins(",feature-dev,test-coverage-reviewer")).toEqual([
|
|
"feature-dev",
|
|
"test-coverage-reviewer",
|
|
]);
|
|
});
|
|
|
|
test("should handle plugins with special characters", () => {
|
|
expect(parsePlugins("@scope/plugin-name,plugin-name-2")).toEqual([
|
|
"@scope/plugin-name",
|
|
"plugin-name-2",
|
|
]);
|
|
});
|
|
|
|
test("should handle complex whitespace patterns", () => {
|
|
expect(
|
|
parsePlugins(
|
|
"\n feature-dev \n,\t test-coverage-reviewer\t, code-quality \n",
|
|
),
|
|
).toEqual(["feature-dev", "test-coverage-reviewer", "code-quality"]);
|
|
});
|
|
});
|