Skip to content

Commit 2b573a3

Browse files
mstuartclaude
andcommitted
fix: correct exports condition ordering, add homepage/bugs fields, and inject version at build time
- Restructure package.json exports to use nested conditions with "types" first under each format (import/require), following TypeScript best practices - Add missing "homepage" and "bugs" fields to package.json for npm registry - Replace hardcoded version strings in src/cli.ts and src/mcp/server.ts with process.env.PACKAGE_VERSION, injected at build time via tsup's define option - Add package.json import and define config to tsup.config.ts Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 13084e8 commit 2b573a3

4 files changed

Lines changed: 22 additions & 5 deletions

File tree

package.json

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,14 @@
88
"types": "./dist/index.d.ts",
99
"exports": {
1010
".": {
11-
"import": "./dist/index.js",
12-
"require": "./dist/index.cjs",
13-
"types": "./dist/index.d.ts"
11+
"import": {
12+
"types": "./dist/index.d.ts",
13+
"default": "./dist/index.js"
14+
},
15+
"require": {
16+
"types": "./dist/index.d.cts",
17+
"default": "./dist/index.cjs"
18+
}
1419
}
1520
},
1621
"bin": {
@@ -44,6 +49,10 @@
4449
"type": "git",
4550
"url": "https://github.com/mstuart/graphql-agent-toolkit.git"
4651
},
52+
"homepage": "https://github.com/mstuart/graphql-agent-toolkit#readme",
53+
"bugs": {
54+
"url": "https://github.com/mstuart/graphql-agent-toolkit/issues"
55+
},
4756
"engines": {
4857
"node": ">=18.0.0"
4958
},

src/cli.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@ import { Command } from 'commander';
44
import { runInit } from './cli/init.js';
55
import { runServe } from './cli/serve.js';
66

7+
const version = process.env.PACKAGE_VERSION || '0.1.0';
8+
79
const program = new Command();
810

911
program
1012
.name('graphql-agent-toolkit')
1113
.description('Turn any GraphQL API into AI-agent-ready tools')
12-
.version('0.1.0');
14+
.version(version);
1315

1416
program
1517
.command('init')

src/mcp/server.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import { parseSchema } from '../introspection/parser.js';
66
import { GraphQLExecutor } from './executor.js';
77
import { createToolsFromSchema } from './tool-factory.js';
88

9+
const packageVersion = process.env.PACKAGE_VERSION || '0.1.0';
10+
911
export interface AgentToolkitServerOptions {
1012
serverName?: string;
1113
serverVersion?: string;
@@ -19,7 +21,7 @@ export async function createAgentToolkitServer(
1921
options?: AgentToolkitServerOptions,
2022
): Promise<McpServer> {
2123
const serverName = options?.serverName ?? 'graphql-agent-toolkit';
22-
const serverVersion = options?.serverVersion ?? '0.1.0';
24+
const serverVersion = options?.serverVersion ?? packageVersion;
2325

2426
// Fetch and parse schema
2527
const introspectionResult = await fetchSchema({

tsup.config.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { defineConfig } from 'tsup';
2+
import pkg from './package.json';
23

34
export default defineConfig({
45
entry: ['src/index.ts', 'src/cli.ts'],
@@ -9,4 +10,7 @@ export default defineConfig({
910
clean: true,
1011
target: 'node18',
1112
shims: true,
13+
define: {
14+
'process.env.PACKAGE_VERSION': JSON.stringify(pkg.version),
15+
},
1216
});

0 commit comments

Comments
 (0)