Skip to content

feat(token-analyzer-mcp): Token analyzer mcp scaffold #403

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions nx.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@
"options": {
"packageRoot": "dist/packages/{projectName}"
}
},
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if this is expected or not. This entire PR is auto-generated with the library generator.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah its not please revert #350

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Hotell , thinking we probably have some things we need to fix in the generator? I just ran it and nothing more. No manual changes were made here.

"@nx/js:swc": {
"cache": true,
"dependsOn": ["^build"],
"inputs": ["production", "^production"]
}
},
"namedInputs": {
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -82,6 +82,7 @@
"globals": "15.15.0",
"jest": "29.7.0",
"jest-environment-jsdom": "29.7.0",
"jest-environment-node": "^29.7.0",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this was also added by the generator ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

checked with source - it was, which is expected, as this lib is setting node as jest env

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, there's no UI so no need for JSDOM test env.

"jsonc-eslint-parser": "2.4.0",
"nx": "20.8.2",
"parsel-js": "^1.1.2",
Expand Down
30 changes: 30 additions & 0 deletions packages/token-analyzer-mcp/.swcrc
Original file line number Diff line number Diff line change
@@ -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"
}
11 changes: 11 additions & 0 deletions packages/token-analyzer-mcp/README.md
Original file line number Diff line number Diff line change
@@ -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).
19 changes: 19 additions & 0 deletions packages/token-analyzer-mcp/eslint.config.cjs
Original file line number Diff line number Diff line change
@@ -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'),
},
},
];
15 changes: 15 additions & 0 deletions packages/token-analyzer-mcp/eslint.config.js
Original file line number Diff line number Diff line change
@@ -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: {},
},
];
30 changes: 30 additions & 0 deletions packages/token-analyzer-mcp/jest.config.ts
Original file line number Diff line number Diff line change
@@ -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',
};
8 changes: 8 additions & 0 deletions packages/token-analyzer-mcp/package.json
Original file line number Diff line number Diff line change
@@ -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
}
32 changes: 32 additions & 0 deletions packages/token-analyzer-mcp/project.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
}
1 change: 1 addition & 0 deletions packages/token-analyzer-mcp/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export {};
16 changes: 16 additions & 0 deletions packages/token-analyzer-mcp/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"extends": "../../tsconfig.base.json",
"files": [],
"compilerOptions": {
"jsx": "react"
},
"include": [],
"references": [
{
"path": "./tsconfig.lib.json"
},
{
"path": "./tsconfig.spec.json"
}
]
}
14 changes: 14 additions & 0 deletions packages/token-analyzer-mcp/tsconfig.lib.json
Original file line number Diff line number Diff line change
@@ -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/**"
]
}
14 changes: 14 additions & 0 deletions packages/token-analyzer-mcp/tsconfig.spec.json
Original file line number Diff line number Diff line change
@@ -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"
]
}
3 changes: 3 additions & 0 deletions tsconfig.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
}
},
Expand Down