From b3412c846e9a45a1bb8928f6e958885d0124d142 Mon Sep 17 00:00:00 2001 From: JJ-H <1916787042@qq.com> Date: Thu, 24 Apr 2025 17:09:14 +0800 Subject: [PATCH] feat: support npx --- .gitignore | 22 ++++++++++++- Makefile | 36 +++++++++++++++++++++ npm/mcp-gitee-darwin-amd64/package.json | 14 ++++++++ npm/mcp-gitee-darwin-arm64/package.json | 14 ++++++++ npm/mcp-gitee-linux-amd64/package.json | 14 ++++++++ npm/mcp-gitee-linux-arm64/package.json | 14 ++++++++ npm/mcp-gitee-windows-amd64/package.json | 14 ++++++++ npm/mcp-gitee-windows-arm64/package.json | 14 ++++++++ npm/mcp-gitee/bin/index.js | 27 ++++++++++++++++ npm/mcp-gitee/package.json | 41 ++++++++++++++++++++++++ 10 files changed, 209 insertions(+), 1 deletion(-) create mode 100644 npm/mcp-gitee-darwin-amd64/package.json create mode 100644 npm/mcp-gitee-darwin-arm64/package.json create mode 100644 npm/mcp-gitee-linux-amd64/package.json create mode 100644 npm/mcp-gitee-linux-arm64/package.json create mode 100644 npm/mcp-gitee-windows-amd64/package.json create mode 100644 npm/mcp-gitee-windows-arm64/package.json create mode 100644 npm/mcp-gitee/bin/index.js create mode 100644 npm/mcp-gitee/package.json diff --git a/.gitignore b/.gitignore index 89c69b5..d49c630 100644 --- a/.gitignore +++ b/.gitignore @@ -24,4 +24,24 @@ release/ .DS_Store *.log .env -.env.local \ No newline at end of file +.env.local + +node_modules/ + +.npmrc +mcp-gitee +!cmd/mcp-gitee +!pkg/mcp-gitee +npm/mcp-gitee/README.md +npm/mcp-gitee/LICENSE +!npm/mcp-gitee +mcp-gitee-darwin-amd64 +!npm/mcp-gitee-darwin-amd64/ +mcp-gitee-darwin-arm64 +!npm/mcp-gitee-darwin-arm64 +mcp-gitee-linux-amd64 +!npm/mcp-gitee-linux-amd64 +mcp-gitee-linux-arm64 +!npm/mcp-gitee-linux-arm64 +mcp-gitee-windows-amd64.exe +mcp-gitee-windows-arm64.exe \ No newline at end of file diff --git a/Makefile b/Makefile index ca032f5..c793fbb 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,9 @@ # Makefile for cross-platform build +BINARY_NAME = mcp-gitee +NPM_VERSION = 0.1.9 GO = go +OSES = darwin linux windows +ARCHS = amd64 arm64 # Repository information @@ -33,6 +37,38 @@ clean: @echo "Clean up complete." +.PHONY: build-all-platforms +build-all-platforms: + $(foreach os,$(OSES),$(foreach arch,$(ARCHS), \ + GOOS=$(os) GOARCH=$(arch) go build $(BUILD_FLAGS) -o $(BINARY_NAME)-$(os)-$(arch)$(if $(findstring windows,$(os)),.exe,) main.go; \ + )) + +.PHONY: npm-copy-binaries +npm-copy-binaries: build-all-platforms + $(foreach os,$(OSES),$(foreach arch,$(ARCHS), \ + EXECUTABLE=./$(BINARY_NAME)-$(os)-$(arch)$(if $(findstring windows,$(os)),.exe,); \ + DIRNAME=$(BINARY_NAME)-$(os)-$(arch); \ + mkdir -p ./npm/$$DIRNAME/bin; \ + cp $$EXECUTABLE ./npm/$$DIRNAME/bin/; \ + )) + +.PHONY: npm-publish +npm-publish: npm-copy-binaries ## Publish the npm packages + $(foreach os,$(OSES),$(foreach arch,$(ARCHS), \ + DIRNAME="$(BINARY_NAME)-$(os)-$(arch)"; \ + cd npm/$$DIRNAME; \ + echo '//registry.npmjs.org/:_authToken=$(NPM_TOKEN)' >> .npmrc; \ + jq '.version = "$(NPM_VERSION)"' package.json > tmp.json && mv tmp.json package.json; \ + npm publish; \ + cd ../..; \ + )) + cp README.md LICENSE ./npm/mcp-gitee/ + echo '//registry.npmjs.org/:_authToken=$(NPM_TOKEN)' >> ./npm/mcp-gitee/.npmrc + jq '.version = "$(NPM_VERSION)"' ./npm/mcp-gitee/package.json > tmp.json && mv tmp.json ./npm/mcp-gitee/package.json; \ + jq '.optionalDependencies |= with_entries(.value = "$(NPM_VERSION)")' ./npm/mcp-gitee/package.json > tmp.json && mv tmp.json ./npm/mcp-gitee/package.json; \ + cd npm/mcp-gitee && npm publish + + # Clean up release directory clean-release: rm -rf release diff --git a/npm/mcp-gitee-darwin-amd64/package.json b/npm/mcp-gitee-darwin-amd64/package.json new file mode 100644 index 0000000..245b96f --- /dev/null +++ b/npm/mcp-gitee-darwin-amd64/package.json @@ -0,0 +1,14 @@ +{ + "name": "@gitee/mcp-gitee-darwin-amd64", + "version": "0.1.9", + "description": "Model Context Protocol (MCP) server for Gitee", + "os": [ + "darwin" + ], + "cpu": [ + "x64" + ], + "publishConfig": { + "access": "public" + } +} diff --git a/npm/mcp-gitee-darwin-arm64/package.json b/npm/mcp-gitee-darwin-arm64/package.json new file mode 100644 index 0000000..14f5d9c --- /dev/null +++ b/npm/mcp-gitee-darwin-arm64/package.json @@ -0,0 +1,14 @@ +{ + "name": "@gitee/mcp-gitee-darwin-arm64", + "version": "0.1.9", + "description": "Model Context Protocol (MCP) server for Gitee", + "os": [ + "darwin" + ], + "cpu": [ + "arm64" + ], + "publishConfig": { + "access": "public" + } +} diff --git a/npm/mcp-gitee-linux-amd64/package.json b/npm/mcp-gitee-linux-amd64/package.json new file mode 100644 index 0000000..77ab5bb --- /dev/null +++ b/npm/mcp-gitee-linux-amd64/package.json @@ -0,0 +1,14 @@ +{ + "name": "@gitee/mcp-gitee-linux-amd64", + "version": "0.1.9", + "description": "Model Context Protocol (MCP) server for Gitee", + "os": [ + "linux" + ], + "cpu": [ + "x64" + ], + "publishConfig": { + "access": "public" + } +} diff --git a/npm/mcp-gitee-linux-arm64/package.json b/npm/mcp-gitee-linux-arm64/package.json new file mode 100644 index 0000000..e64ff59 --- /dev/null +++ b/npm/mcp-gitee-linux-arm64/package.json @@ -0,0 +1,14 @@ +{ + "name": "@gitee/mcp-gitee-linux-arm64", + "version": "0.1.9", + "description": "Model Context Protocol (MCP) server for Gitee", + "os": [ + "linux" + ], + "cpu": [ + "arm64" + ], + "publishConfig": { + "access": "public" + } +} diff --git a/npm/mcp-gitee-windows-amd64/package.json b/npm/mcp-gitee-windows-amd64/package.json new file mode 100644 index 0000000..b66a027 --- /dev/null +++ b/npm/mcp-gitee-windows-amd64/package.json @@ -0,0 +1,14 @@ +{ + "name": "@gitee/mcp-gitee-windows-amd64", + "version": "0.1.9", + "description": "Model Context Protocol (MCP) server for Gitee", + "os": [ + "win32" + ], + "cpu": [ + "x64" + ], + "publishConfig": { + "access": "public" + } +} diff --git a/npm/mcp-gitee-windows-arm64/package.json b/npm/mcp-gitee-windows-arm64/package.json new file mode 100644 index 0000000..40bb811 --- /dev/null +++ b/npm/mcp-gitee-windows-arm64/package.json @@ -0,0 +1,14 @@ +{ + "name": "@gitee/mcp-gitee-windows-arm64", + "version": "0.1.9", + "description": "Model Context Protocol (MCP) server for Gitee", + "os": [ + "win32" + ], + "cpu": [ + "arm64" + ], + "publishConfig": { + "access": "public" + } +} diff --git a/npm/mcp-gitee/bin/index.js b/npm/mcp-gitee/bin/index.js new file mode 100644 index 0000000..f020c7c --- /dev/null +++ b/npm/mcp-gitee/bin/index.js @@ -0,0 +1,27 @@ +#!/usr/bin/env node + +const childProcess = require('child_process'); + +const BINARY_MAP = { + darwin_x64: {name: 'mcp-gitee-darwin-amd64', suffix: ''}, + darwin_arm64: {name: 'mcp-gitee-darwin-arm64', suffix: ''}, + linux_x64: {name: 'mcp-gitee-linux-amd64', suffix: ''}, + linux_arm64: {name: 'mcp-gitee-linux-arm64', suffix: ''}, + win32_x64: {name: 'mcp-gitee-windows-amd64', suffix: '.exe'}, + win32_arm64: {name: 'mcp-gitee-windows-arm64', suffix: '.exe'}, +}; + +// Resolving will fail if the optionalDependency was not installed or the platform/arch is not supported +const resolveBinaryPath = () => { + try { + const binary = BINARY_MAP[`${process.platform}_${process.arch}`]; + return require.resolve(`@gitee/${binary.name}/bin/${binary.name}${binary.suffix}`); + } catch (e) { + console.error(`Could not resolve binary path for platform/arch: ${process.platform}/${process.arch}`); + process.exit(1); + } +}; + +childProcess.execFileSync(resolveBinaryPath(), process.argv.slice(2), { + stdio: 'inherit', +}); diff --git a/npm/mcp-gitee/package.json b/npm/mcp-gitee/package.json new file mode 100644 index 0000000..0e52612 --- /dev/null +++ b/npm/mcp-gitee/package.json @@ -0,0 +1,41 @@ +{ + "name": "@gitee/mcp-gitee", + "version": "0.1.9", + "description": "Model Context Protocol (MCP) server for Gitee", + "main": "./bin/index.js", + "bin": { + "mcp-gitee": "bin/index.js" + }, + "optionalDependencies": { + "@gitee/mcp-gitee-darwin-amd64": "0.1.9", + "@gitee/mcp-gitee-darwin-arm64": "0.1.9", + "@gitee/mcp-gitee-linux-amd64": "0.1.9", + "@gitee/mcp-gitee-linux-arm64": "0.1.9", + "@gitee/mcp-gitee-windows-amd64": "0.1.9", + "@gitee/mcp-gitee-windows-arm64": "0.1.9" + }, + "repository": { + "type": "git", + "url": "git+https://gitee.com/oschina/mcp-gitee.git" + }, + "keywords": [ + "mcp", + "gitee", + "model context protocol", + "model", + "context", + "protocol" + ], + "author": { + "name": "Gitee", + "url": "https://gitee.com/oschina" + }, + "license": "MIT", + "bugs": { + "url": "https://gitee.com/oschina/mcp-gitee/issues" + }, + "homepage": "https://gitee.com/oschina/mcp-gitee#readme", + "publishConfig": { + "access": "public" + } +} -- Gitee