Skip to content

Commit b3412c8

Browse files
committed
feat: support npx
1 parent 8465a15 commit b3412c8

File tree

10 files changed

+209
-1
lines changed

10 files changed

+209
-1
lines changed

.gitignore

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,24 @@ release/
2424
.DS_Store
2525
*.log
2626
.env
27-
.env.local
27+
.env.local
28+
29+
node_modules/
30+
31+
.npmrc
32+
mcp-gitee
33+
!cmd/mcp-gitee
34+
!pkg/mcp-gitee
35+
npm/mcp-gitee/README.md
36+
npm/mcp-gitee/LICENSE
37+
!npm/mcp-gitee
38+
mcp-gitee-darwin-amd64
39+
!npm/mcp-gitee-darwin-amd64/
40+
mcp-gitee-darwin-arm64
41+
!npm/mcp-gitee-darwin-arm64
42+
mcp-gitee-linux-amd64
43+
!npm/mcp-gitee-linux-amd64
44+
mcp-gitee-linux-arm64
45+
!npm/mcp-gitee-linux-arm64
46+
mcp-gitee-windows-amd64.exe
47+
mcp-gitee-windows-arm64.exe

Makefile

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Makefile for cross-platform build
2+
BINARY_NAME = mcp-gitee
3+
NPM_VERSION = 0.1.9
24
GO = go
5+
OSES = darwin linux windows
6+
ARCHS = amd64 arm64
37

48

59
# Repository information
@@ -33,6 +37,38 @@ clean:
3337
@echo "Clean up complete."
3438

3539

40+
.PHONY: build-all-platforms
41+
build-all-platforms:
42+
$(foreach os,$(OSES),$(foreach arch,$(ARCHS), \
43+
GOOS=$(os) GOARCH=$(arch) go build $(BUILD_FLAGS) -o $(BINARY_NAME)-$(os)-$(arch)$(if $(findstring windows,$(os)),.exe,) main.go; \
44+
))
45+
46+
.PHONY: npm-copy-binaries
47+
npm-copy-binaries: build-all-platforms
48+
$(foreach os,$(OSES),$(foreach arch,$(ARCHS), \
49+
EXECUTABLE=./$(BINARY_NAME)-$(os)-$(arch)$(if $(findstring windows,$(os)),.exe,); \
50+
DIRNAME=$(BINARY_NAME)-$(os)-$(arch); \
51+
mkdir -p ./npm/$$DIRNAME/bin; \
52+
cp $$EXECUTABLE ./npm/$$DIRNAME/bin/; \
53+
))
54+
55+
.PHONY: npm-publish
56+
npm-publish: npm-copy-binaries ## Publish the npm packages
57+
$(foreach os,$(OSES),$(foreach arch,$(ARCHS), \
58+
DIRNAME="$(BINARY_NAME)-$(os)-$(arch)"; \
59+
cd npm/$$DIRNAME; \
60+
echo '//registry.npmjs.org/:_authToken=$(NPM_TOKEN)' >> .npmrc; \
61+
jq '.version = "$(NPM_VERSION)"' package.json > tmp.json && mv tmp.json package.json; \
62+
npm publish; \
63+
cd ../..; \
64+
))
65+
cp README.md LICENSE ./npm/mcp-gitee/
66+
echo '//registry.npmjs.org/:_authToken=$(NPM_TOKEN)' >> ./npm/mcp-gitee/.npmrc
67+
jq '.version = "$(NPM_VERSION)"' ./npm/mcp-gitee/package.json > tmp.json && mv tmp.json ./npm/mcp-gitee/package.json; \
68+
jq '.optionalDependencies |= with_entries(.value = "$(NPM_VERSION)")' ./npm/mcp-gitee/package.json > tmp.json && mv tmp.json ./npm/mcp-gitee/package.json; \
69+
cd npm/mcp-gitee && npm publish
70+
71+
3672
# Clean up release directory
3773
clean-release:
3874
rm -rf release
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"name": "@gitee/mcp-gitee-darwin-amd64",
3+
"version": "0.1.9",
4+
"description": "Model Context Protocol (MCP) server for Gitee",
5+
"os": [
6+
"darwin"
7+
],
8+
"cpu": [
9+
"x64"
10+
],
11+
"publishConfig": {
12+
"access": "public"
13+
}
14+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"name": "@gitee/mcp-gitee-darwin-arm64",
3+
"version": "0.1.9",
4+
"description": "Model Context Protocol (MCP) server for Gitee",
5+
"os": [
6+
"darwin"
7+
],
8+
"cpu": [
9+
"arm64"
10+
],
11+
"publishConfig": {
12+
"access": "public"
13+
}
14+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"name": "@gitee/mcp-gitee-linux-amd64",
3+
"version": "0.1.9",
4+
"description": "Model Context Protocol (MCP) server for Gitee",
5+
"os": [
6+
"linux"
7+
],
8+
"cpu": [
9+
"x64"
10+
],
11+
"publishConfig": {
12+
"access": "public"
13+
}
14+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"name": "@gitee/mcp-gitee-linux-arm64",
3+
"version": "0.1.9",
4+
"description": "Model Context Protocol (MCP) server for Gitee",
5+
"os": [
6+
"linux"
7+
],
8+
"cpu": [
9+
"arm64"
10+
],
11+
"publishConfig": {
12+
"access": "public"
13+
}
14+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"name": "@gitee/mcp-gitee-windows-amd64",
3+
"version": "0.1.9",
4+
"description": "Model Context Protocol (MCP) server for Gitee",
5+
"os": [
6+
"win32"
7+
],
8+
"cpu": [
9+
"x64"
10+
],
11+
"publishConfig": {
12+
"access": "public"
13+
}
14+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"name": "@gitee/mcp-gitee-windows-arm64",
3+
"version": "0.1.9",
4+
"description": "Model Context Protocol (MCP) server for Gitee",
5+
"os": [
6+
"win32"
7+
],
8+
"cpu": [
9+
"arm64"
10+
],
11+
"publishConfig": {
12+
"access": "public"
13+
}
14+
}

npm/mcp-gitee/bin/index.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/usr/bin/env node
2+
3+
const childProcess = require('child_process');
4+
5+
const BINARY_MAP = {
6+
darwin_x64: {name: 'mcp-gitee-darwin-amd64', suffix: ''},
7+
darwin_arm64: {name: 'mcp-gitee-darwin-arm64', suffix: ''},
8+
linux_x64: {name: 'mcp-gitee-linux-amd64', suffix: ''},
9+
linux_arm64: {name: 'mcp-gitee-linux-arm64', suffix: ''},
10+
win32_x64: {name: 'mcp-gitee-windows-amd64', suffix: '.exe'},
11+
win32_arm64: {name: 'mcp-gitee-windows-arm64', suffix: '.exe'},
12+
};
13+
14+
// Resolving will fail if the optionalDependency was not installed or the platform/arch is not supported
15+
const resolveBinaryPath = () => {
16+
try {
17+
const binary = BINARY_MAP[`${process.platform}_${process.arch}`];
18+
return require.resolve(`@gitee/${binary.name}/bin/${binary.name}${binary.suffix}`);
19+
} catch (e) {
20+
console.error(`Could not resolve binary path for platform/arch: ${process.platform}/${process.arch}`);
21+
process.exit(1);
22+
}
23+
};
24+
25+
childProcess.execFileSync(resolveBinaryPath(), process.argv.slice(2), {
26+
stdio: 'inherit',
27+
});

npm/mcp-gitee/package.json

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
"name": "@gitee/mcp-gitee",
3+
"version": "0.1.9",
4+
"description": "Model Context Protocol (MCP) server for Gitee",
5+
"main": "./bin/index.js",
6+
"bin": {
7+
"mcp-gitee": "bin/index.js"
8+
},
9+
"optionalDependencies": {
10+
"@gitee/mcp-gitee-darwin-amd64": "0.1.9",
11+
"@gitee/mcp-gitee-darwin-arm64": "0.1.9",
12+
"@gitee/mcp-gitee-linux-amd64": "0.1.9",
13+
"@gitee/mcp-gitee-linux-arm64": "0.1.9",
14+
"@gitee/mcp-gitee-windows-amd64": "0.1.9",
15+
"@gitee/mcp-gitee-windows-arm64": "0.1.9"
16+
},
17+
"repository": {
18+
"type": "git",
19+
"url": "git+https://gitee.com/oschina/mcp-gitee.git"
20+
},
21+
"keywords": [
22+
"mcp",
23+
"gitee",
24+
"model context protocol",
25+
"model",
26+
"context",
27+
"protocol"
28+
],
29+
"author": {
30+
"name": "Gitee",
31+
"url": "https://gitee.com/oschina"
32+
},
33+
"license": "MIT",
34+
"bugs": {
35+
"url": "https://gitee.com/oschina/mcp-gitee/issues"
36+
},
37+
"homepage": "https://gitee.com/oschina/mcp-gitee#readme",
38+
"publishConfig": {
39+
"access": "public"
40+
}
41+
}

0 commit comments

Comments
 (0)