@gpc-cli/plugin-sdk 0.1.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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 GPC Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,115 @@
1
+ declare const PLUGIN_SDK_VERSION = "0.8.0";
2
+ interface GpcPlugin {
3
+ /** Unique plugin name (e.g., "@gpc-cli/plugin-ci" or "gpc-plugin-slack") */
4
+ name: string;
5
+ /** Plugin version (semver) */
6
+ version: string;
7
+ /** Called once when the plugin is loaded. Register hooks here. */
8
+ register(hooks: PluginHooks): void | Promise<void>;
9
+ }
10
+ interface PluginHooks {
11
+ /** Run before a command executes. Can modify context or abort. */
12
+ beforeCommand(handler: BeforeCommandHandler): void;
13
+ /** Run after a command completes successfully. */
14
+ afterCommand(handler: AfterCommandHandler): void;
15
+ /** Run when a command fails with an error. */
16
+ onError(handler: ErrorHandler): void;
17
+ /** Run before each API request. Can inspect/modify request metadata. */
18
+ beforeRequest(handler: BeforeRequestHandler): void;
19
+ /** Run after each API response. Can inspect response metadata. */
20
+ afterResponse(handler: AfterResponseHandler): void;
21
+ /** Register additional CLI commands from the plugin. */
22
+ registerCommands(handler: CommandRegistrar): void;
23
+ }
24
+ type BeforeCommandHandler = (ctx: CommandEvent) => void | Promise<void>;
25
+ type AfterCommandHandler = (ctx: CommandEvent, result: CommandResult) => void | Promise<void>;
26
+ type ErrorHandler = (ctx: CommandEvent, error: PluginError) => void | Promise<void>;
27
+ type BeforeRequestHandler = (req: RequestEvent) => void | Promise<void>;
28
+ type AfterResponseHandler = (req: RequestEvent, res: ResponseEvent) => void | Promise<void>;
29
+ type CommandRegistrar = (registry: CommandRegistry) => void;
30
+ interface CommandEvent {
31
+ /** The command name (e.g., "releases upload", "vitals crashes") */
32
+ command: string;
33
+ /** Resolved arguments passed to the command */
34
+ args: Record<string, unknown>;
35
+ /** App package name (if available) */
36
+ app?: string;
37
+ /** Timestamp when the command started */
38
+ startedAt: Date;
39
+ }
40
+ interface CommandResult {
41
+ /** Whether the command succeeded */
42
+ success: boolean;
43
+ /** The output data (before formatting) */
44
+ data?: unknown;
45
+ /** Duration in milliseconds */
46
+ durationMs: number;
47
+ /** Exit code */
48
+ exitCode: number;
49
+ }
50
+ interface RequestEvent {
51
+ /** HTTP method (GET, POST, PUT, PATCH, DELETE) */
52
+ method: string;
53
+ /** Request path (relative to API base URL) */
54
+ path: string;
55
+ /** Timestamp when the request started */
56
+ startedAt: Date;
57
+ }
58
+ interface ResponseEvent {
59
+ /** HTTP status code */
60
+ status: number;
61
+ /** Duration in milliseconds */
62
+ durationMs: number;
63
+ /** Whether the response was successful (2xx) */
64
+ ok: boolean;
65
+ }
66
+ interface PluginError {
67
+ /** Error code */
68
+ code: string;
69
+ /** Error message */
70
+ message: string;
71
+ /** Exit code */
72
+ exitCode: number;
73
+ /** Original error (if available) */
74
+ cause?: Error;
75
+ }
76
+ interface CommandRegistry {
77
+ /** Add a new top-level command */
78
+ add(definition: PluginCommand): void;
79
+ }
80
+ interface PluginCommand {
81
+ /** Command name (e.g., "deploy") */
82
+ name: string;
83
+ /** Command description */
84
+ description: string;
85
+ /** Command options */
86
+ options?: PluginCommandOption[];
87
+ /** Command arguments */
88
+ arguments?: PluginCommandArgument[];
89
+ /** The action to run */
90
+ action: (args: Record<string, unknown>, options: Record<string, unknown>) => void | Promise<void>;
91
+ }
92
+ interface PluginCommandOption {
93
+ flags: string;
94
+ description: string;
95
+ defaultValue?: unknown;
96
+ }
97
+ interface PluginCommandArgument {
98
+ name: string;
99
+ description: string;
100
+ required?: boolean;
101
+ }
102
+ interface PluginManifest {
103
+ /** Plugin name */
104
+ name: string;
105
+ /** Plugin version */
106
+ version: string;
107
+ /** Required permissions */
108
+ permissions?: PluginPermission[];
109
+ /** Whether this is a first-party (@gpc-cli/*) plugin */
110
+ trusted?: boolean;
111
+ }
112
+ type PluginPermission = "read:config" | "write:config" | "read:auth" | "api:read" | "api:write" | "commands:register" | "hooks:beforeCommand" | "hooks:afterCommand" | "hooks:onError" | "hooks:beforeRequest" | "hooks:afterResponse";
113
+ declare function definePlugin(plugin: GpcPlugin): GpcPlugin;
114
+
115
+ export { type AfterCommandHandler, type AfterResponseHandler, type BeforeCommandHandler, type BeforeRequestHandler, type CommandEvent, type CommandRegistrar, type CommandRegistry, type CommandResult, type ErrorHandler, type GpcPlugin, PLUGIN_SDK_VERSION, type PluginCommand, type PluginCommandArgument, type PluginCommandOption, type PluginError, type PluginHooks, type PluginManifest, type PluginPermission, type RequestEvent, type ResponseEvent, definePlugin };
package/dist/index.js ADDED
@@ -0,0 +1,10 @@
1
+ // src/index.ts
2
+ var PLUGIN_SDK_VERSION = "0.8.0";
3
+ function definePlugin(plugin) {
4
+ return plugin;
5
+ }
6
+ export {
7
+ PLUGIN_SDK_VERSION,
8
+ definePlugin
9
+ };
10
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["export const PLUGIN_SDK_VERSION = \"0.8.0\";\n\n// ---------------------------------------------------------------------------\n// Plugin interface\n// ---------------------------------------------------------------------------\n\nexport interface GpcPlugin {\n /** Unique plugin name (e.g., \"@gpc-cli/plugin-ci\" or \"gpc-plugin-slack\") */\n name: string;\n\n /** Plugin version (semver) */\n version: string;\n\n /** Called once when the plugin is loaded. Register hooks here. */\n register(hooks: PluginHooks): void | Promise<void>;\n}\n\n// ---------------------------------------------------------------------------\n// Lifecycle hooks\n// ---------------------------------------------------------------------------\n\nexport interface PluginHooks {\n /** Run before a command executes. Can modify context or abort. */\n beforeCommand(handler: BeforeCommandHandler): void;\n\n /** Run after a command completes successfully. */\n afterCommand(handler: AfterCommandHandler): void;\n\n /** Run when a command fails with an error. */\n onError(handler: ErrorHandler): void;\n\n /** Run before each API request. Can inspect/modify request metadata. */\n beforeRequest(handler: BeforeRequestHandler): void;\n\n /** Run after each API response. Can inspect response metadata. */\n afterResponse(handler: AfterResponseHandler): void;\n\n /** Register additional CLI commands from the plugin. */\n registerCommands(handler: CommandRegistrar): void;\n}\n\nexport type BeforeCommandHandler = (ctx: CommandEvent) => void | Promise<void>;\nexport type AfterCommandHandler = (ctx: CommandEvent, result: CommandResult) => void | Promise<void>;\nexport type ErrorHandler = (ctx: CommandEvent, error: PluginError) => void | Promise<void>;\nexport type BeforeRequestHandler = (req: RequestEvent) => void | Promise<void>;\nexport type AfterResponseHandler = (req: RequestEvent, res: ResponseEvent) => void | Promise<void>;\nexport type CommandRegistrar = (registry: CommandRegistry) => void;\n\n// ---------------------------------------------------------------------------\n// Event types\n// ---------------------------------------------------------------------------\n\nexport interface CommandEvent {\n /** The command name (e.g., \"releases upload\", \"vitals crashes\") */\n command: string;\n\n /** Resolved arguments passed to the command */\n args: Record<string, unknown>;\n\n /** App package name (if available) */\n app?: string;\n\n /** Timestamp when the command started */\n startedAt: Date;\n}\n\nexport interface CommandResult {\n /** Whether the command succeeded */\n success: boolean;\n\n /** The output data (before formatting) */\n data?: unknown;\n\n /** Duration in milliseconds */\n durationMs: number;\n\n /** Exit code */\n exitCode: number;\n}\n\n// ---------------------------------------------------------------------------\n// Request/response events (for beforeRequest/afterResponse hooks)\n// ---------------------------------------------------------------------------\n\nexport interface RequestEvent {\n /** HTTP method (GET, POST, PUT, PATCH, DELETE) */\n method: string;\n\n /** Request path (relative to API base URL) */\n path: string;\n\n /** Timestamp when the request started */\n startedAt: Date;\n}\n\nexport interface ResponseEvent {\n /** HTTP status code */\n status: number;\n\n /** Duration in milliseconds */\n durationMs: number;\n\n /** Whether the response was successful (2xx) */\n ok: boolean;\n}\n\n// ---------------------------------------------------------------------------\n// Error types\n// ---------------------------------------------------------------------------\n\nexport interface PluginError {\n /** Error code */\n code: string;\n\n /** Error message */\n message: string;\n\n /** Exit code */\n exitCode: number;\n\n /** Original error (if available) */\n cause?: Error;\n}\n\n// ---------------------------------------------------------------------------\n// Command registry (for plugins that add commands)\n// ---------------------------------------------------------------------------\n\nexport interface CommandRegistry {\n /** Add a new top-level command */\n add(definition: PluginCommand): void;\n}\n\nexport interface PluginCommand {\n /** Command name (e.g., \"deploy\") */\n name: string;\n\n /** Command description */\n description: string;\n\n /** Command options */\n options?: PluginCommandOption[];\n\n /** Command arguments */\n arguments?: PluginCommandArgument[];\n\n /** The action to run */\n action: (args: Record<string, unknown>, options: Record<string, unknown>) => void | Promise<void>;\n}\n\nexport interface PluginCommandOption {\n flags: string;\n description: string;\n defaultValue?: unknown;\n}\n\nexport interface PluginCommandArgument {\n name: string;\n description: string;\n required?: boolean;\n}\n\n// ---------------------------------------------------------------------------\n// Plugin metadata (for discovery and permission checks)\n// ---------------------------------------------------------------------------\n\nexport interface PluginManifest {\n /** Plugin name */\n name: string;\n\n /** Plugin version */\n version: string;\n\n /** Required permissions */\n permissions?: PluginPermission[];\n\n /** Whether this is a first-party (@gpc-cli/*) plugin */\n trusted?: boolean;\n}\n\nexport type PluginPermission =\n | \"read:config\"\n | \"write:config\"\n | \"read:auth\"\n | \"api:read\"\n | \"api:write\"\n | \"commands:register\"\n | \"hooks:beforeCommand\"\n | \"hooks:afterCommand\"\n | \"hooks:onError\"\n | \"hooks:beforeRequest\"\n | \"hooks:afterResponse\";\n\n// ---------------------------------------------------------------------------\n// Helper to define a plugin (for plugin authors)\n// ---------------------------------------------------------------------------\n\nexport function definePlugin(plugin: GpcPlugin): GpcPlugin {\n return plugin;\n}\n"],"mappings":";AAAO,IAAM,qBAAqB;AAqM3B,SAAS,aAAa,QAA8B;AACzD,SAAO;AACT;","names":[]}
package/package.json ADDED
@@ -0,0 +1,32 @@
1
+ {
2
+ "name": "@gpc-cli/plugin-sdk",
3
+ "version": "0.1.0",
4
+ "description": "Plugin interface and SDK for extending GPC",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "import": "./dist/index.js",
11
+ "types": "./dist/index.d.ts"
12
+ }
13
+ },
14
+ "files": [
15
+ "dist"
16
+ ],
17
+ "keywords": [
18
+ "google-play",
19
+ "plugin",
20
+ "sdk"
21
+ ],
22
+ "license": "MIT",
23
+ "scripts": {
24
+ "build": "tsup",
25
+ "dev": "tsup --watch",
26
+ "test": "vitest run",
27
+ "test:watch": "vitest",
28
+ "lint": "eslint src/",
29
+ "typecheck": "tsc --noEmit",
30
+ "clean": "rm -rf dist"
31
+ }
32
+ }