[v2] Мonorepo, sdk-client, sdk-server, sdk-core package split (#1279)
This commit is contained in:
parent
384311b9b8
commit
71ae3acee0
7 changed files with 12067 additions and 4817 deletions
81
common/eslint-config/eslint.config.mjs
Normal file
81
common/eslint-config/eslint.config.mjs
Normal file
|
|
@ -0,0 +1,81 @@
|
|||
// @ts-check
|
||||
import path from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
|
||||
import eslint from '@eslint/js';
|
||||
import { defineConfig } from 'eslint/config';
|
||||
import eslintConfigPrettier from 'eslint-config-prettier/flat';
|
||||
import importPlugin from 'eslint-plugin-import';
|
||||
import nodePlugin from 'eslint-plugin-n';
|
||||
import simpleImportSortPlugin from 'eslint-plugin-simple-import-sort';
|
||||
import { configs } from 'typescript-eslint';
|
||||
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
|
||||
export default defineConfig(
|
||||
eslint.configs.recommended,
|
||||
...configs.recommended,
|
||||
importPlugin.flatConfigs.recommended,
|
||||
importPlugin.flatConfigs.typescript,
|
||||
{
|
||||
languageOptions: {
|
||||
parserOptions: {
|
||||
// Ensure consumers of this shared config get a stable tsconfig root
|
||||
tsconfigRootDir: __dirname
|
||||
}
|
||||
},
|
||||
linterOptions: {
|
||||
reportUnusedDisableDirectives: false
|
||||
},
|
||||
plugins: {
|
||||
n: nodePlugin,
|
||||
'simple-import-sort': simpleImportSortPlugin
|
||||
},
|
||||
settings: {
|
||||
'import/resolver': {
|
||||
typescript: {
|
||||
// Let the TS resolver handle NodeNext-style imports like "./foo.js"
|
||||
extensions: ['.js', '.jsx', '.ts', '.tsx', '.d.ts'],
|
||||
// Use the tsconfig in each package root (when running ESLint from that package)
|
||||
project: 'tsconfig.json'
|
||||
}
|
||||
}
|
||||
},
|
||||
rules: {
|
||||
'@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }],
|
||||
'n/prefer-node-protocol': 'error',
|
||||
'@typescript-eslint/consistent-type-imports': ['error', { disallowTypeAnnotations: false }],
|
||||
'simple-import-sort/imports': 'warn',
|
||||
'simple-import-sort/exports': 'warn',
|
||||
'import/no-extraneous-dependencies': [
|
||||
'error',
|
||||
{
|
||||
devDependencies: [
|
||||
'**/test/**',
|
||||
'**/*.test.ts',
|
||||
'**/*.test.tsx',
|
||||
'**/scripts/**',
|
||||
'**/vitest.config.*',
|
||||
'**/tsdown.config.*',
|
||||
'**/eslint.config.*',
|
||||
'**/vitest.setup.*'
|
||||
],
|
||||
optionalDependencies: false,
|
||||
peerDependencies: true
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
// Ignore generated protocol types everywhere
|
||||
ignores: ['**/spec.types.ts']
|
||||
},
|
||||
{
|
||||
files: ['packages/client/**/*.ts', 'packages/server/**/*.ts'],
|
||||
ignores: ['**/*.test.ts'],
|
||||
rules: {
|
||||
'no-console': 'error'
|
||||
}
|
||||
},
|
||||
eslintConfigPrettier
|
||||
);
|
||||
36
common/eslint-config/package.json
Normal file
36
common/eslint-config/package.json
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
{
|
||||
"name": "@modelcontextprotocol/eslint-config",
|
||||
"private": true,
|
||||
"main": "eslint.config.mjs",
|
||||
"type": "module",
|
||||
"exports": {
|
||||
".": "./eslint.config.mjs"
|
||||
},
|
||||
"dependencies": {
|
||||
"typescript": "catalog:devTools"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/modelcontextprotocol/typescript-sdk.git"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/modelcontextprotocol/typescript-sdk/issues"
|
||||
},
|
||||
"homepage": "https://github.com/modelcontextprotocol/typescript-sdk/tree/develop/common/eslint-config",
|
||||
"publishConfig": {
|
||||
"registry": "https://npm.pkg.github.com/"
|
||||
},
|
||||
"version": "2.0.0",
|
||||
"devDependencies": {
|
||||
"@eslint/js": "catalog:devTools",
|
||||
"eslint": "catalog:devTools",
|
||||
"eslint-config-prettier": "catalog:devTools",
|
||||
"eslint-import-resolver-typescript": "^4.4.4",
|
||||
"eslint-plugin-import": "^2.32.0",
|
||||
"eslint-plugin-n": "catalog:devTools",
|
||||
"eslint-plugin-simple-import-sort": "^12.1.1",
|
||||
"prettier": "catalog:devTools",
|
||||
"typescript": "catalog:devTools",
|
||||
"typescript-eslint": "catalog:devTools"
|
||||
}
|
||||
}
|
||||
21
common/tsconfig/package.json
Normal file
21
common/tsconfig/package.json
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
{
|
||||
"name": "@modelcontextprotocol/tsconfig",
|
||||
"private": true,
|
||||
"main": "tsconfig.json",
|
||||
"type": "module",
|
||||
"dependencies": {
|
||||
"typescript": "catalog:devTools"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/modelcontextprotocol/typescript-sdk.git"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/modelcontextprotocol/typescript-sdk/issues"
|
||||
},
|
||||
"homepage": "https://github.com/modelcontextprotocol/typescript-sdk/tree/develop/common/ts-config",
|
||||
"publishConfig": {
|
||||
"registry": "https://npm.pkg.github.com/"
|
||||
},
|
||||
"version": "2.0.0"
|
||||
}
|
||||
31
common/tsconfig/tsconfig.json
Normal file
31
common/tsconfig/tsconfig.json
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"target": "esnext",
|
||||
"lib": ["esnext"],
|
||||
"module": "NodeNext",
|
||||
"moduleResolution": "NodeNext",
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"noUncheckedIndexedAccess": true,
|
||||
"noImplicitOverride": true,
|
||||
"experimentalDecorators": true,
|
||||
"emitDecoratorMetadata": true,
|
||||
"libReplacement": false,
|
||||
"noImplicitReturns": true,
|
||||
"incremental": true,
|
||||
"declaration": true,
|
||||
"declarationMap": true,
|
||||
"sourceMap": true,
|
||||
"outDir": "./dist",
|
||||
"strict": true,
|
||||
"esModuleInterop": true,
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"resolveJsonModule": true,
|
||||
"isolatedModules": true,
|
||||
"skipLibCheck": true,
|
||||
"paths": {
|
||||
"pkce-challenge": ["./node_modules/pkce-challenge/dist/index.node"]
|
||||
},
|
||||
"types": ["node", "vitest/globals"]
|
||||
}
|
||||
}
|
||||
28
common/vitest-config/package.json
Normal file
28
common/vitest-config/package.json
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
{
|
||||
"name": "@modelcontextprotocol/vitest-config",
|
||||
"private": true,
|
||||
"main": "vitest.config.mjs",
|
||||
"type": "module",
|
||||
"exports": {
|
||||
".": "./vitest.config.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"typescript": "catalog:devTools"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/modelcontextprotocol/typescript-sdk.git"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/modelcontextprotocol/typescript-sdk/issues"
|
||||
},
|
||||
"homepage": "https://github.com/modelcontextprotocol/typescript-sdk/tree/develop/common/vitest-config",
|
||||
"publishConfig": {
|
||||
"registry": "https://npm.pkg.github.com/"
|
||||
},
|
||||
"version": "2.0.0",
|
||||
"devDependencies": {
|
||||
"@modelcontextprotocol/tsconfig": "workspace:^",
|
||||
"vite-tsconfig-paths": "catalog:devTools"
|
||||
}
|
||||
}
|
||||
8
common/vitest-config/tsconfig.json
Normal file
8
common/vitest-config/tsconfig.json
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"include": ["./"],
|
||||
"extends": "@modelcontextprotocol/tsconfig",
|
||||
"compilerOptions": {
|
||||
"noEmit": true,
|
||||
"allowJs": true
|
||||
}
|
||||
}
|
||||
25
common/vitest-config/vitest.config.js
Normal file
25
common/vitest-config/vitest.config.js
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
import { defineConfig } from 'vitest/config';
|
||||
import tsconfigPaths from 'vite-tsconfig-paths';
|
||||
import path from 'node:path';
|
||||
import url from 'node:url';
|
||||
|
||||
const ignorePatterns = ['**/dist/**'];
|
||||
const __dirname = path.dirname(url.fileURLToPath(import.meta.url));
|
||||
|
||||
export default defineConfig({
|
||||
test: {
|
||||
globals: true,
|
||||
environment: 'node',
|
||||
include: ['test/**/*.test.ts'],
|
||||
exclude: ignorePatterns,
|
||||
deps: {
|
||||
moduleDirectories: ['node_modules', path.resolve(__dirname, '../../packages'), path.resolve(__dirname, '../../common')]
|
||||
},
|
||||
poolOptions: {
|
||||
threads: {
|
||||
useAtomics: true
|
||||
}
|
||||
}
|
||||
},
|
||||
plugins: [tsconfigPaths()]
|
||||
});
|
||||
Loading…
Reference in a new issue