diff --git a/.github/workflows/build-workflow.yml b/.github/workflows/build-workflow.yml new file mode 100644 index 0000000..49507bb --- /dev/null +++ b/.github/workflows/build-workflow.yml @@ -0,0 +1,50 @@ +name: build + +permissions: + contents: write # to be able to publish a GitHub release + issues: write # to be able to comment on released issues + pull-requests: write # to be able to comment on released pull requests + id-token: write # to enable use of OIDC for npm provenance + +on: + push: + branches: + - main + - beta + +jobs: + run_build: + # Running only on self hosted runner which has tag "build" + runs-on: [self-hosted, build] + + concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + + permissions: + contents: write + actions: write + issues: write + pull-requests: write + + environment: build + + steps: + - uses: actions/checkout@v4 + - name: Use Node.js + uses: actions/setup-node@v4 + with: + node-version-file: .nvmrc + - id: install-dev + name: Install npm development dependencies + run: npm ci --no-audit --silent + - id: build + name: Build + run: npm run build + - id: semantic-release + name: Run semantic release + run: npm run semantic-release + env: + CI: true + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + NPM_CONFIG_REGISTRY: ${{ env.NPM_CONFIG_REGISTRY }} + GH_TOKEN: ${{ secrets.GH_TOKEN }} diff --git a/CHANGELOG.md b/CHANGELOG.md index 8b13789..e69de29 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1 +0,0 @@ - diff --git a/README.md b/README.md index 2f819c0..cf97cf6 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,7 @@ You can use this directly in the [GitHub Copilot](https://docs.github.com/en/cop You can use this directly in the [Claude Code](https://docs.anthropic.com/en/docs/claude-code/mcp), by running: ```bash -claude mcp add airtable --env CLIENT_ID=YOUR_CLIENT_ID --env APP_ID=YOUR_APP_ID -- npx -y @chargetrip/mcp +claude mcp add chargetrip --env CLIENT_ID=YOUR_CLIENT_ID --env APP_ID=YOUR_APP_ID -- npx -y @chargetrip/mcp ``` ### Other AI agents diff --git a/bin/chargetrip-mcp.js b/bin/chargetrip-mcp.js deleted file mode 100755 index 0277db3..0000000 --- a/bin/chargetrip-mcp.js +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env node - -import '../dist/index.js'; diff --git a/bin/chargetrip-mcp.mjs b/bin/chargetrip-mcp.mjs new file mode 100755 index 0000000..9263d3a --- /dev/null +++ b/bin/chargetrip-mcp.mjs @@ -0,0 +1,3 @@ +#!/usr/bin/env node + +import '../dist/index.cjs'; diff --git a/commitlint.config.js b/commitlint.config.cjs similarity index 100% rename from commitlint.config.js rename to commitlint.config.cjs diff --git a/jest.config.js b/jest.config.cjs similarity index 89% rename from jest.config.js rename to jest.config.cjs index c6f0920..632704f 100644 --- a/jest.config.js +++ b/jest.config.cjs @@ -21,12 +21,12 @@ module.exports = { }, moduleFileExtensions: ['ts', 'js', 'json'], moduleNameMapper: { - 'graceful-fs': '/test/jest/fs.js', - 'fs/promises': '/test/jest/fs.js', + 'graceful-fs': '/test/jest/fs.cjs', + 'fs/promises': '/test/jest/fs.cjs', }, testEnvironment: 'node', setupFilesAfterEnv: ['jest-extended/all', './test/jest/matchers.ts'], - testSequencer: './test/jest/sequencer.js', + testSequencer: './test/jest/sequencer.cjs', testTimeout: 20000, testMatch: [ diff --git a/jest.e2e.config.js b/jest.e2e.config.cjs similarity index 81% rename from jest.e2e.config.js rename to jest.e2e.config.cjs index 5a3375c..187cb39 100644 --- a/jest.e2e.config.js +++ b/jest.e2e.config.cjs @@ -1,6 +1,6 @@ /* eslint-disable @typescript-eslint/no-var-requires */ -const jestConfig = require('./jest.config'); +const jestConfig = require('./jest.config.cjs'); module.exports = { ...jestConfig, diff --git a/package-lock.json b/package-lock.json index 0de51ff..29c35ae 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@chargetrip/mcp", - "version": "0.1.0", + "version": "0.0.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@chargetrip/mcp", - "version": "0.1.0", + "version": "0.0.1", "license": "MIT", "dependencies": { "@chargetrip/types": "^1.47.0", @@ -16,6 +16,7 @@ "dotenv": "^17.2.1", "graphql-tag": "^2.12.6", "graphql-ws": "^6.0.6", + "husky": "^9.1.7", "winston": "^3.17.0", "ws": "^8.18.3", "zod": "^3.25.76" @@ -43,7 +44,6 @@ "@types/ws": "^8.18.1", "babel-loader": "^10.0.0", "eslint-plugin-oxlint": "^1.12.0", - "husky": "^9.1.7", "jest": "^30.0.5", "jest-extended": "^6.0.0", "os": "^0.1.2", @@ -9304,7 +9304,6 @@ "version": "9.1.7", "resolved": "https://registry.npmjs.org/husky/-/husky-9.1.7.tgz", "integrity": "sha512-5gs5ytaNjBrh5Ow3zrvdUUY+0VxIuWVL4i9irt6friV+BqdCfmV11CQTWMiBYWHbXhco+J1kHfTOUkePhCDvMA==", - "dev": true, "license": "MIT", "bin": { "husky": "bin.js" diff --git a/package.json b/package.json index c4502c6..c8084c6 100644 --- a/package.json +++ b/package.json @@ -1,12 +1,12 @@ { "name": "@chargetrip/mcp", - "version": "0.1.0", - "description": "Chargetrip MCP server", - "main": "dist/index.js", + "version": "0.0.1", + "description": "Chargetrip MCP server ", + "main": "dist/index.cjs", "types": "dist/index.d.ts", - "type": "commonjs", + "type": "module", "bin": { - "chargetrip-mcp": "./bin/chargetrip-mcp.js" + "chargetrip-mcp": "./bin/chargetrip-mcp.mjs" }, "files": [ "dist/", @@ -15,20 +15,23 @@ ], "packageManager": "npm@10.0.0", "scripts": { - "dev": "webpack --watch --config ./webpack.config.js", - "build": "webpack --config ./webpack.config.js", + "dev": "webpack --watch --config ./webpack.config.mjs", + "build": "webpack --config ./webpack.config.mjs", "lint": "oxlint -c .oxlintrc ./src", - "test": "node --expose-gc ./node_modules/.bin/jest -c ./jest.config.js --forceExit --maxWorkers=50% --unhandled-rejections=none", - "test:e2e": "node --unhandled-rejections=none --expose-gc ./node_modules/.bin/jest -c ./jest.e2e.config.js --forceExit --runInBand", + "test": "node --expose-gc ./node_modules/.bin/jest -c ./jest.config.cjs --forceExit --maxWorkers=50% --unhandled-rejections=none", + "test:e2e": "node --unhandled-rejections=none --expose-gc ./node_modules/.bin/jest -c ./jest.e2e.config.cjs --forceExit --runInBand", "type-check": "tsc --noEmit", + "semantic-release": "semantic-release", "prepare": "husky", "prettier": "prettier -w ./src/**/*.ts", - "commitlint": "commitlint --edit" + "commitlint": "commitlint --config commitlint.config.cjs --edit" }, "keywords": [ "chargetrip", "mcp" ], + "repository": "https://github.com/chargetrip/mcp", + "bugs": "https://github.com/chargetrip/mcp/issues", "author": "Chargetrip Developer Team ", "homepage": "https://chargetrip.com/", "license": "MIT", @@ -40,6 +43,7 @@ "dotenv": "^17.2.1", "graphql-tag": "^2.12.6", "graphql-ws": "^6.0.6", + "husky": "^9.1.7", "winston": "^3.17.0", "ws": "^8.18.3", "zod": "^3.25.76" @@ -64,7 +68,6 @@ "@types/ws": "^8.18.1", "babel-loader": "^10.0.0", "eslint-plugin-oxlint": "^1.12.0", - "husky": "^9.1.7", "jest": "^30.0.5", "jest-extended": "^6.0.0", "os": "^0.1.2", @@ -79,5 +82,91 @@ "webpack": "^5.101.1", "webpack-cli": "^6.0.1", "webpack-node-externals": "^3.0.0" + }, + "publishConfig": { + "access": "public" + }, + "release": { + "branches": [ + { + "name": "beta", + "prerelease": true + }, + { + "name": "main", + "prerelease": false + } + ], + "tagFormat": "${version}", + "plugins": [ + [ + "@semantic-release/commit-analyzer", + { + "preset": "angular", + "releaseRules": [ + { + "type": "*", + "scope": "*", + "release": false + }, + { + "breaking": true, + "release": "major" + }, + { + "type": "docs", + "scope": "*", + "release": false + }, + { + "type": "feat", + "scope": "*", + "release": "minor" + }, + { + "type": "fix", + "scope": "*", + "release": "patch" + }, + { + "type": "perf", + "scope": "*", + "release": "patch" + }, + { + "type": "refactor", + "scope": "*", + "release": false + } + ], + "parserOpts": { + "noteKeywords": [ + "BREAKING CHANGE", + "BREAKING CHANGES" + ] + } + } + ], + "@semantic-release/release-notes-generator", + [ + "@semantic-release/changelog", + { + "changelogFile": "CHANGELOG.md" + } + ], + [ + "@semantic-release/git", + { + "assets": [ + "CHANGELOG.md", + "package.json", + "package-lock.json" + ], + "message": "chore: release version ${nextRelease.version}" + } + ], + "@semantic-release/github", + "@semantic-release/npm" + ] } } diff --git a/src/__e2e__/client.ts b/src/__e2e__/client.ts index 2bf60ba..88e2884 100644 --- a/src/__e2e__/client.ts +++ b/src/__e2e__/client.ts @@ -5,7 +5,7 @@ import { StdioClientTransport } from '@modelcontextprotocol/sdk/client/stdio.js' * @description Setting up the MCP client and transport for the E2E tests */ export async function getMcpClient() { - const mcpIndexFile = process.cwd() + '/dist/index.js'; + const mcpIndexFile = process.cwd() + '/dist/index.cjs'; const env: Record = { CLIENT_ID: process.env.CLIENT_ID!, diff --git a/test/jest/fs.js b/test/jest/fs.cjs similarity index 100% rename from test/jest/fs.js rename to test/jest/fs.cjs diff --git a/test/jest/sequencer.js b/test/jest/sequencer.cjs similarity index 100% rename from test/jest/sequencer.js rename to test/jest/sequencer.cjs diff --git a/webpack.config.js b/webpack.config.mjs similarity index 61% rename from webpack.config.js rename to webpack.config.mjs index bf4de07..5cf325d 100644 --- a/webpack.config.js +++ b/webpack.config.mjs @@ -1,19 +1,21 @@ -const path = require("path"); -const webpack = require("webpack"); -const nodeExternals = require('webpack-node-externals'); +import path from 'path'; +import webpack from 'webpack'; +import nodeExternals from 'webpack-node-externals'; +import dotenv from 'dotenv'; const util = { - env: require("dotenv").config(), - isProduction: process.env.NODE_ENV === 'production', -}; + env: dotenv.config(), + isProduction: process.env.NODE_ENV === 'production', + }, + __dirname = path.resolve(); -module.exports = { - mode: util.isProduction ? "production" : "development", +export default { + mode: util.isProduction ? 'production' : 'development', devtool: util.isProduction ? false : 'inline-source-map', - entry: "./src/index.ts", + entry: './src/index.ts', output: { - filename: "index.js", - path: path.resolve(__dirname, "dist"), + filename: 'index.cjs', + path: path.resolve(__dirname, 'dist'), }, plugins: [], externals: [ @@ -28,17 +30,17 @@ module.exports = { rules: [ { test: /\.ts$/, - use: "ts-loader", + use: 'ts-loader', exclude: /node_modules/, }, { test: /\.js$/, - include: [path.resolve(__dirname, "src")], - loader: "babel-loader", + include: [path.resolve(__dirname, 'src')], + loader: 'babel-loader', options: { presets: [ [ - "@babel/preset-env", + '@babel/preset-env', { modules: false, }, @@ -49,9 +51,8 @@ module.exports = { ], }, resolve: { - extensions: [".ts", ".js"], - alias: { - }, + extensions: ['.ts', '.js'], + alias: {}, fallback: { crypto: false, util: false,