diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 5b4b916c5..7e641d833 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -23,6 +23,7 @@ packages/react-gamepad-navigation @microsoft/cxe-prg @hectorjjb packages/teams-components @microsoft/teams-prg packages/token-analyzer @microsoft/xc-uxe packages/react-contextual-pane @microsoft/teams-prg +packages/token-analyzer-mcp @microsoft/xc-uxe # <%= NX-CODEOWNER-PLACEHOLDER %> #### Build/Infra diff --git a/package.json b/package.json index a283b3e26..cb1861ff3 100644 --- a/package.json +++ b/package.json @@ -66,8 +66,8 @@ "@swc/core": "1.11.24", "@swc/helpers": "~0.5.11", "@swc/jest": "0.2.38", - "@testing-library/react": "16.3.0", "@testing-library/dom": "10.4.0", + "@testing-library/react": "16.3.0", "@testing-library/user-event": "14.6.1", "@types/jest": "29.5.14", "@types/node": "20.14.9", @@ -82,6 +82,7 @@ "globals": "15.15.0", "jest": "29.7.0", "jest-environment-jsdom": "29.7.0", + "jest-environment-node": "^29.7.0", "jsonc-eslint-parser": "2.4.0", "nx": "20.8.2", "parsel-js": "^1.1.2", diff --git a/packages/token-analyzer-mcp/.swcrc b/packages/token-analyzer-mcp/.swcrc new file mode 100644 index 000000000..0f4746f47 --- /dev/null +++ b/packages/token-analyzer-mcp/.swcrc @@ -0,0 +1,30 @@ +{ + "jsc": { + "target": "es2019", + "parser": { + "syntax": "typescript", + "tsx": true, + "decorators": false, + "dynamicImport": false + }, + "transform": { + "react": { + "runtime": "classic", + "useSpread": true + } + }, + "keepClassNames": true, + "externalHelpers": true, + "loose": true + }, + "sourceMaps": true, + "exclude": [ + "jest.config.ts", + ".*\\.spec.tsx?$", + ".*\\.test.tsx?$", + "./src/jest-setup.ts$", + "./**/jest-setup.ts$", + ".*.js$" + ], + "$schema": "https://json.schemastore.org/swcrc" +} diff --git a/packages/token-analyzer-mcp/README.md b/packages/token-analyzer-mcp/README.md new file mode 100644 index 000000000..b9e64a7c9 --- /dev/null +++ b/packages/token-analyzer-mcp/README.md @@ -0,0 +1,11 @@ +# token-analyzer-mcp + +This library was generated with [Nx](https://nx.dev). + +## Building + +Run `nx build token-analyzer-mcp` to build the library. + +## Running unit tests + +Run `nx test token-analyzer-mcp` to execute the unit tests via [Jest](https://jestjs.io). diff --git a/packages/token-analyzer-mcp/eslint.config.cjs b/packages/token-analyzer-mcp/eslint.config.cjs new file mode 100644 index 000000000..9d2af7a3d --- /dev/null +++ b/packages/token-analyzer-mcp/eslint.config.cjs @@ -0,0 +1,19 @@ +const baseConfig = require('../../eslint.config.js'); + +module.exports = [ + ...baseConfig, + { + files: ['**/*.json'], + rules: { + '@nx/dependency-checks': [ + 'error', + { + ignoredFiles: ['{projectRoot}/eslint.config.{js,cjs,mjs}'], + }, + ], + }, + languageOptions: { + parser: require('jsonc-eslint-parser'), + }, + }, +]; diff --git a/packages/token-analyzer-mcp/eslint.config.js b/packages/token-analyzer-mcp/eslint.config.js new file mode 100644 index 000000000..2be3ed1ba --- /dev/null +++ b/packages/token-analyzer-mcp/eslint.config.js @@ -0,0 +1,15 @@ +const baseConfig = require('../../eslint.config.js'); + +module.exports = [ + ...baseConfig, + { + files: ['**/*.ts', '**/*.tsx'], + // Override or add rules here + rules: {}, + }, + { + files: ['**/*.js', '**/*.jsx'], + // Override or add rules here + rules: {}, + }, +]; diff --git a/packages/token-analyzer-mcp/jest.config.ts b/packages/token-analyzer-mcp/jest.config.ts new file mode 100644 index 000000000..b390a2c54 --- /dev/null +++ b/packages/token-analyzer-mcp/jest.config.ts @@ -0,0 +1,30 @@ +/* eslint-disable */ +import { readFileSync } from 'fs'; + +// Reading the SWC compilation config and remove the "exclude" +// for the test files to be compiled by SWC +const { exclude: _, ...swcJestConfig } = JSON.parse( + readFileSync(`${__dirname}/.swcrc`, 'utf-8') +); + +// disable .swcrc look-up by SWC core because we're passing in swcJestConfig ourselves. +// If we do not disable this, SWC Core will read .swcrc and won't transform our test files due to "exclude" +if (swcJestConfig.swcrc === undefined) { + swcJestConfig.swcrc = false; +} + +// Uncomment if using global setup/teardown files being transformed via swc +// https://nx.dev/nx-api/jest/documents/overview#global-setupteardown-with-nx-libraries +// jest needs EsModule Interop to find the default exported setup/teardown functions +// swcJestConfig.module.noInterop = false; + +export default { + displayName: 'token-analyzer-mcp', + preset: '../../jest.preset.js', + transform: { + '^.+\\.[tj]s$': ['@swc/jest', swcJestConfig], + }, + moduleFileExtensions: ['ts', 'js', 'html'], + testEnvironment: 'node', + coverageDirectory: '../../coverage/packages/token-analyzer-mcp', +}; diff --git a/packages/token-analyzer-mcp/package.json b/packages/token-analyzer-mcp/package.json new file mode 100644 index 000000000..12b487ab7 --- /dev/null +++ b/packages/token-analyzer-mcp/package.json @@ -0,0 +1,8 @@ +{ + "name": "@fluentui-contrib/token-analyzer-mcp", + "version": "0.0.1", + "main": "./src/index.js", + "types": "./src/index.d.ts", + "dependencies": {}, + "private": true +} diff --git a/packages/token-analyzer-mcp/project.json b/packages/token-analyzer-mcp/project.json new file mode 100644 index 000000000..9f79895a0 --- /dev/null +++ b/packages/token-analyzer-mcp/project.json @@ -0,0 +1,32 @@ +{ + "name": "token-analyzer-mcp", + "$schema": "../../node_modules/nx/schemas/project-schema.json", + "sourceRoot": "packages/token-analyzer-mcp/src", + "projectType": "library", + "tags": [], + "targets": { + "build": { + "executor": "@fluentui-contrib/nx-plugin:build" + }, + "lint": { + "executor": "@nx/eslint:lint", + "options": { + "lintFilePatterns": [ + "packages/token-analyzer-mcp/**/*.ts", + "packages/token-analyzer-mcp/**/*.tsx" + ] + } + }, + "test": { + "executor": "@nx/jest:jest", + "outputs": ["{workspaceRoot}/coverage/{projectRoot}"], + "options": { + "jestConfig": "packages/token-analyzer-mcp/jest.config.ts", + "passWithNoTests": true + } + }, + "type-check": { + "executor": "@fluentui-contrib/nx-plugin:type-check" + } + } +} diff --git a/packages/token-analyzer-mcp/src/index.ts b/packages/token-analyzer-mcp/src/index.ts new file mode 100644 index 000000000..cb0ff5c3b --- /dev/null +++ b/packages/token-analyzer-mcp/src/index.ts @@ -0,0 +1 @@ +export {}; diff --git a/packages/token-analyzer-mcp/tsconfig.json b/packages/token-analyzer-mcp/tsconfig.json new file mode 100644 index 000000000..a5d448b2f --- /dev/null +++ b/packages/token-analyzer-mcp/tsconfig.json @@ -0,0 +1,16 @@ +{ + "extends": "../../tsconfig.base.json", + "files": [], + "compilerOptions": { + "jsx": "react" + }, + "include": [], + "references": [ + { + "path": "./tsconfig.lib.json" + }, + { + "path": "./tsconfig.spec.json" + } + ] +} diff --git a/packages/token-analyzer-mcp/tsconfig.lib.json b/packages/token-analyzer-mcp/tsconfig.lib.json new file mode 100644 index 000000000..884038eac --- /dev/null +++ b/packages/token-analyzer-mcp/tsconfig.lib.json @@ -0,0 +1,14 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "outDir": "../../dist/out-tsc", + "declaration": true + }, + "include": ["src/**/*.ts"], + "exclude": [ + "jest.config.ts", + "src/**/*.test.ts", + "src/**/*.test.tsx", + "files/**" + ] +} diff --git a/packages/token-analyzer-mcp/tsconfig.spec.json b/packages/token-analyzer-mcp/tsconfig.spec.json new file mode 100644 index 000000000..361fd5a7e --- /dev/null +++ b/packages/token-analyzer-mcp/tsconfig.spec.json @@ -0,0 +1,14 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "outDir": "../../dist/out-tsc", + "module": "commonjs", + "types": ["jest", "node"] + }, + "include": [ + "jest.config.ts", + "src/**/*.test.ts", + "src/**/*.test.tsx", + "src/**/*.d.ts" + ] +} diff --git a/tsconfig.base.json b/tsconfig.base.json index 8758e6d6b..373759b2a 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -69,6 +69,9 @@ "@fluentui-contrib/token-analyzer": [ "packages/token-analyzer/src/index.ts" ], + "@fluentui-contrib/token-analyzer-mcp": [ + "packages/token-analyzer-mcp/src/index.ts" + ], "@fluentui-contrib/variant-theme": ["packages/variant-theme/src/index.ts"] } },