@frontmcp/nx 1.8.7 → 1.9.1-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/generators/app/files/project.json__tmpl__ +9 -0
- package/generators/app/files/src/tools/hello.tool.spec.ts__tmpl__ +10 -0
- package/generators/app/files/tsconfig.json__tmpl__ +8 -3
- package/generators/app/lib/normalize-options.d.ts +3 -1
- package/generators/app/lib/normalize-options.js +1 -1
- package/generators/app/lib/normalize-options.js.map +1 -1
- package/generators/lib/files/adapter/src/__fileName__.adapter.spec.ts__tmpl__ +9 -0
- package/generators/lib/files/generic/src/__fileName__.spec.ts__tmpl__ +7 -0
- package/generators/lib/files/plugin/src/__fileName__.plugin.spec.ts__tmpl__ +11 -0
- package/generators/lib/files/tool-register/src/__fileName__.tools.spec.ts__tmpl__ +14 -0
- package/generators/lib/lib/normalize-options.d.ts +3 -1
- package/generators/lib/lib/normalize-options.js +1 -1
- package/generators/lib/lib/normalize-options.js.map +1 -1
- package/generators/lib/lib-project-files/project.json__tmpl__ +20 -4
- package/generators/lib/lib-project-files/tsconfig.json__tmpl__ +8 -1
- package/generators/lib/lib-project-files/tsconfig.spec.json__tmpl__ +0 -3
- package/generators/lib/lib.d.ts +1 -1
- package/generators/lib/lib.js +51 -19
- package/generators/lib/lib.js.map +1 -1
- package/generators/server/files/common/project.json__tmpl__ +15 -1
- package/generators/server/files/common/tsconfig.json__tmpl__ +8 -3
- package/generators/server/files/lambda/template.yaml__tmpl__ +4 -2
- package/generators/server/files/node/Dockerfile.dockerignore__tmpl__ +10 -0
- package/generators/server/files/node/Dockerfile__tmpl__ +6 -1
- package/generators/server/files/node/docker-compose.yml__tmpl__ +1 -1
- package/generators/server/files/vercel/vercel.json__tmpl__ +3 -12
- package/generators/server/lib/normalize-options.d.ts +8 -1
- package/generators/server/lib/normalize-options.js +8 -2
- package/generators/server/lib/normalize-options.js.map +1 -1
- package/generators/server/server.js +7 -0
- package/generators/server/server.js.map +1 -1
- package/generators/ui-shared/add-ui-entry.js +2 -12
- package/generators/ui-shared/add-ui-entry.js.map +1 -1
- package/generators/ui-shared/ensure-ui-package.js +8 -5
- package/generators/ui-shared/ensure-ui-package.js.map +1 -1
- package/generators/workspace/files/__dot__gitignore__tmpl__ +1 -0
- package/generators/workspace/files/nx.json__tmpl__ +0 -10
- package/package.json +2 -2
- package/utils/package-manager.d.ts +11 -0
- package/utils/package-manager.js +33 -0
- package/utils/package-manager.js.map +1 -0
- package/utils/project-paths.d.ts +24 -4
- package/utils/project-paths.js +55 -8
- package/utils/project-paths.js.map +1 -1
- package/utils/versions.d.ts +8 -0
- package/utils/versions.js +28 -0
- package/utils/versions.js.map +1 -1
- package/generators/lib/files/adapter/src/__fileName__.adapter.ts__tmpl__ +0 -19
- package/generators/lib/files/plugin/src/__fileName__.plugin.ts__tmpl__ +0 -19
- package/generators/server/files/node/__dot__dockerignore__tmpl__ +0 -8
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../../../src/generators/server/server.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../../../src/generators/server/server.ts"],"names":[],"mappings":";;AAUA,0CAEC;;AAZD,+CAAyB;AACzB,+BAA4B;AAE5B,uCAA6G;AAE7G,yEAA0E;AAC1E,yDAAgE;AAChE,6CAAkD;AAG3C,KAAK,UAAU,eAAe,CAAC,IAAU,EAAE,MAA6B;IAC7E,OAAO,uBAAuB,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;AAC/C,CAAC;AAED,KAAK,UAAU,uBAAuB,CAAC,IAAU,EAAE,MAA6B;IAC9E,MAAM,OAAO,GAAG,IAAA,2BAAgB,EAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IAE/C,MAAM,YAAY,GAAG;QACnB,GAAG,OAAO;QACV,KAAK,EAAE,cAAO;QACd,IAAI,EAAE,EAAE;QACR,GAAG,EAAE,GAAG;KACT,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,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;QAChC,CAAC;IACH,CAAC;AACH,CAAC;AAED,kBAAe,eAAe,CAAC","sourcesContent":["import * as fs from 'fs';\nimport { join } from 'path';\n\nimport { formatFiles, generateFiles, names as nxNames, type GeneratorCallback, type Tree } from '@nx/devkit';\n\nimport { addFrontmcpDependencies } from '../../utils/add-dependencies.js';\nimport { getLambdaDependencies } from '../../utils/versions.js';\nimport { normalizeOptions } from './lib/index.js';\nimport type { ServerGeneratorSchema } from './schema.js';\n\nexport async function serverGenerator(tree: Tree, schema: ServerGeneratorSchema): Promise<GeneratorCallback | void> {\n return serverGeneratorInternal(tree, schema);\n}\n\nasync function serverGeneratorInternal(tree: Tree, schema: ServerGeneratorSchema): Promise<GeneratorCallback | void> {\n const options = normalizeOptions(tree, schema);\n\n const templateVars = {\n ...options,\n names: nxNames,\n tmpl: '',\n dot: '.',\n };\n\n // Generate common files (main.ts, project.json, tsconfig)\n generateFiles(tree, join(__dirname, 'files', 'common'), options.projectRoot, templateVars);\n\n // Generate target-specific files\n const targetDir = join(__dirname, 'files', options.deploymentTarget);\n generateFiles(tree, targetDir, options.projectRoot, templateVars);\n\n // Copy skills from catalog\n const bundle = schema.skills ?? 'recommended';\n if (bundle !== 'none') {\n scaffoldCatalogSkills(tree, options.projectRoot, options.deploymentTarget, bundle);\n }\n\n // The lambda build wraps the server with @codegenie/serverless-express and fails without it.\n const installTask =\n options.deploymentTarget === 'lambda'\n ? addFrontmcpDependencies(tree, getLambdaDependencies(), {}, { keepExistingVersions: true })\n : undefined;\n\n if (!options.skipFormat) {\n await formatFiles(tree);\n }\n\n return installTask;\n}\n\nfunction scaffoldCatalogSkills(tree: Tree, projectRoot: string, target: string, bundle: string): void {\n // Load skills catalog via @frontmcp/skills package at runtime\n let skills: {\n loadManifest: () => {\n skills: Array<{ name: string; path: string; targets: string[]; hasResources: boolean; bundle?: string[] }>;\n };\n resolveSkillPath: (entry: { path: string }) => string;\n getSkillsByTarget: (\n s: Array<{ targets: string[] }>,\n t: string,\n ) => Array<{ name: string; path: string; targets: string[]; hasResources: boolean; bundle?: string[] }>;\n getSkillsByBundle: (\n s: Array<{ bundle?: string[] }>,\n b: string,\n ) => Array<{ name: string; path: string; targets: string[]; hasResources: boolean; bundle?: string[] }>;\n };\n try {\n skills = require('@frontmcp/skills');\n } catch {\n return;\n }\n\n let manifest;\n try {\n manifest = skills.loadManifest();\n } catch {\n return;\n }\n\n const targetFiltered = skills.getSkillsByTarget(manifest.skills, target);\n const matchingSkills = skills.getSkillsByBundle(targetFiltered, bundle);\n\n for (const skill of matchingSkills) {\n const sourceDir = skills.resolveSkillPath(skill);\n const destDir = join(projectRoot, 'skills', skill.name);\n copyDirToTree(tree, sourceDir, destDir);\n }\n}\n\nfunction copyDirToTree(tree: Tree, sourceDir: string, destDir: string): void {\n if (!fs.existsSync(sourceDir)) return;\n const entries = fs.readdirSync(sourceDir, { withFileTypes: true });\n for (const entry of entries) {\n const srcPath = join(sourceDir, entry.name);\n const destPath = join(destDir, entry.name);\n if (entry.isDirectory()) {\n copyDirToTree(tree, srcPath, destPath);\n } else {\n const content = fs.readFileSync(srcPath);\n tree.write(destPath, content);\n }\n }\n}\n\nexport default serverGenerator;\n"]}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.addUiEntry = addUiEntry;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const project_paths_js_1 = require("../../utils/project-paths.js");
|
|
5
6
|
function escapeRegExp(str) {
|
|
6
7
|
return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
7
8
|
}
|
|
@@ -33,18 +34,7 @@ function addUiEntry(tree, options) {
|
|
|
33
34
|
// 2. Update tsconfig.base.json — add explicit path alias
|
|
34
35
|
// The wildcard alias already covers resolution, but adding an explicit
|
|
35
36
|
// entry improves IDE completion and Nx dep graph accuracy.
|
|
36
|
-
|
|
37
|
-
(0, devkit_1.updateJson)(tree, 'tsconfig.base.json', (json) => {
|
|
38
|
-
const paths = json.compilerOptions?.paths ?? {};
|
|
39
|
-
const aliasKey = `${importPath}/${entryName}`;
|
|
40
|
-
if (!paths[aliasKey]) {
|
|
41
|
-
paths[aliasKey] = [`${packageRoot}/src/${entryName}/index.ts`];
|
|
42
|
-
}
|
|
43
|
-
json.compilerOptions = json.compilerOptions ?? {};
|
|
44
|
-
json.compilerOptions.paths = paths;
|
|
45
|
-
return json;
|
|
46
|
-
});
|
|
47
|
-
}
|
|
37
|
+
(0, project_paths_js_1.addTsPathAlias)(tree, `${importPath}/${entryName}`, entryPath, { overwrite: false });
|
|
48
38
|
// 3. Add re-export to barrel index.ts
|
|
49
39
|
const barrelPath = `${packageRoot}/src/index.ts`;
|
|
50
40
|
if (tree.exists(barrelPath)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"add-ui-entry.js","sourceRoot":"","sources":["../../../../src/generators/ui-shared/add-ui-entry.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"add-ui-entry.js","sourceRoot":"","sources":["../../../../src/generators/ui-shared/add-ui-entry.ts"],"names":[],"mappings":";;AAuBA,gCAqCC;AA5DD,uCAAmD;AAEnD,mEAA8D;AAE9D,SAAS,YAAY,CAAC,GAAW;IAC/B,OAAO,GAAG,CAAC,OAAO,CAAC,qBAAqB,EAAE,MAAM,CAAC,CAAC;AACpD,CAAC;AAWD;;;;;GAKG;AACH,SAAgB,UAAU,CAAC,IAAU,EAAE,OAA0B;IAC/D,MAAM,EAAE,WAAW,EAAE,SAAS,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC;IACvD,MAAM,SAAS,GAAG,GAAG,WAAW,QAAQ,SAAS,WAAW,CAAC;IAE7D,mFAAmF;IACnF,MAAM,eAAe,GAAG,GAAG,WAAW,eAAe,CAAC;IACtD,IAAI,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC,EAAE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AAC,QAAQ,CAAC,IAAI,CAAC,IAAI,QAAQ,KAAK,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,GAAG,IAAI,CAAC;YAC3F,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE,UAAU,GAAG,UAAU,CAAC,CAAC;QAClD,CAAC;IACH,CAAC;AACH,CAAC","sourcesContent":["import { updateJson, type Tree } from '@nx/devkit';\n\nimport { addTsPathAlias } from '../../utils/project-paths.js';\n\nfunction escapeRegExp(str: string): string {\n return str.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n}\n\nexport interface AddUiEntryOptions {\n /** The UI package root, e.g. 'ui/components' */\n packageRoot: string;\n /** The entry name, e.g. 'LoginForm' or 'admin-dashboard' */\n entryName: string;\n /** The npm scope name, e.g. '@frontmcp/ui-components' */\n importPath: string;\n}\n\n/**\n * Adds an entry point to an existing UI package:\n * 1. Updates project.json `additionalEntryPoints` in both build-cjs and build-esm\n * 2. Updates tsconfig.base.json path aliases (wildcard already covers it, but explicit is fine)\n * 3. Adds re-export to the barrel index.ts\n */\nexport function addUiEntry(tree: Tree, options: AddUiEntryOptions): void {\n const { packageRoot, entryName, importPath } = options;\n const entryPath = `${packageRoot}/src/${entryName}/index.ts`;\n\n // 1. Update project.json — add to additionalEntryPoints in build-cjs and build-esm\n const projectJsonPath = `${packageRoot}/project.json`;\n if (tree.exists(projectJsonPath)) {\n updateJson(tree, projectJsonPath, (json) => {\n for (const target of ['build-cjs', 'build-esm']) {\n const opts = json.targets?.[target]?.options;\n if (opts) {\n opts.additionalEntryPoints = opts.additionalEntryPoints ?? [];\n if (!opts.additionalEntryPoints.includes(entryPath)) {\n opts.additionalEntryPoints.push(entryPath);\n }\n }\n }\n return json;\n });\n }\n\n // 2. Update tsconfig.base.json — add explicit path alias\n // The wildcard alias already covers resolution, but adding an explicit\n // entry improves IDE completion and Nx dep graph accuracy.\n addTsPathAlias(tree, `${importPath}/${entryName}`, entryPath, { overwrite: false });\n\n // 3. Add re-export to barrel index.ts\n const barrelPath = `${packageRoot}/src/index.ts`;\n if (tree.exists(barrelPath)) {\n const existing = tree.read(barrelPath, 'utf-8') ?? '';\n const exportLine = `export * from './${entryName}';\\n`;\n const duplicatePattern = new RegExp(`^export \\\\* from '\\\\./${escapeRegExp(entryName)}';?$`, 'm');\n if (!duplicatePattern.test(existing)) {\n const normalized = existing.endsWith('\\n') || existing === '' ? existing : existing + '\\n';\n tree.write(barrelPath, normalized + exportLine);\n }\n }\n}\n"]}
|
|
@@ -63,7 +63,6 @@ function ensureUiPackage(tree, options) {
|
|
|
63
63
|
const { packageRoot, projectName, kind } = options;
|
|
64
64
|
if (!tree.exists(`${packageRoot}/project.json`)) {
|
|
65
65
|
const offset = (0, devkit_1.offsetFromRoot)(packageRoot);
|
|
66
|
-
const ignoreDeprecations = (0, project_paths_js_1.getIgnoreDeprecations)(tree);
|
|
67
66
|
// `customConditions` (Nx solution workspaces set it) is only valid with a modern `moduleResolution`
|
|
68
67
|
// (TS5098), so a package that inherits it must inherit the base's `module`/`moduleResolution` too.
|
|
69
68
|
const inheritsModernResolution = Boolean(tree.exists('tsconfig.base.json') &&
|
|
@@ -80,8 +79,7 @@ function ensureUiPackage(tree, options) {
|
|
|
80
79
|
(0, devkit_1.writeJson)(tree, `${packageRoot}/tsconfig.json`, {
|
|
81
80
|
extends: `${offset}tsconfig.base.json`,
|
|
82
81
|
compilerOptions: {
|
|
83
|
-
...(!inheritsModernResolution && { module: 'commonjs', moduleResolution:
|
|
84
|
-
...(!inheritsModernResolution && ignoreDeprecations && { ignoreDeprecations }),
|
|
82
|
+
...(!inheritsModernResolution && { module: 'commonjs', moduleResolution: (0, project_paths_js_1.getModuleResolution)(tree) }),
|
|
85
83
|
...(kind === 'react' && { jsx: 'react-jsx' }),
|
|
86
84
|
esModuleInterop: true,
|
|
87
85
|
strict: true,
|
|
@@ -110,11 +108,16 @@ function ensureUiPackage(tree, options) {
|
|
|
110
108
|
}
|
|
111
109
|
}
|
|
112
110
|
const range = `~${(0, versions_js_1.getFrontmcpVersion)()}`;
|
|
113
|
-
const buildDevDependencies =
|
|
114
|
-
|
|
111
|
+
const { esbuild, ...buildDevDependencies } = (0, versions_js_1.getUiBuildDevDependencies)();
|
|
112
|
+
const installUiDependencies = kind === 'react'
|
|
115
113
|
? (0, add_dependencies_js_1.addFrontmcpDependencies)(tree, REACT_DEPENDENCIES, { ...REACT_DEV_DEPENDENCIES, ...buildDevDependencies }, { keepExistingVersions: true })
|
|
116
114
|
: (0, add_dependencies_js_1.addFrontmcpDependencies)(tree, { '@frontmcp/uipack': range }, buildDevDependencies, {
|
|
117
115
|
keepExistingVersions: true,
|
|
118
116
|
});
|
|
117
|
+
// An existing esbuild range is raised rather than kept when it is older than ours: the `^0.25.0` earlier
|
|
118
|
+
// versions of these generators wrote is below the `>=0.27` peer range of @frontmcp/uipack (npm ERESOLVE).
|
|
119
|
+
// A range at or above ours stays, in whichever section it is in.
|
|
120
|
+
const installEsbuild = (0, add_dependencies_js_1.addFrontmcpDependencies)(tree, {}, { esbuild }, { keepExistingVersions: false });
|
|
121
|
+
return (0, devkit_1.runTasksInSerial)(installUiDependencies, installEsbuild);
|
|
119
122
|
}
|
|
120
123
|
//# sourceMappingURL=ensure-ui-package.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ensure-ui-package.js","sourceRoot":"","sources":["../../../../src/generators/ui-shared/ensure-ui-package.ts"],"names":[],"mappings":";;AAwEA,
|
|
1
|
+
{"version":3,"file":"ensure-ui-package.js","sourceRoot":"","sources":["../../../../src/generators/ui-shared/ensure-ui-package.ts"],"names":[],"mappings":";;AAwEA,0CAyEC;AAjJD,uCAAsH;AAEtH,yEAA0E;AAC1E,mEAAmE;AACnE,yDAAwF;AAWxF,MAAM,kBAAkB,GAA2B;IACjD,KAAK,EAAE,SAAS;IAChB,WAAW,EAAE,SAAS;IACtB,eAAe,EAAE,QAAQ;IACzB,gBAAgB,EAAE,U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Y,WAAW;sBACP,IAAI,KAAK,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM;;;;;;;;;;;;;CAaxD,CACI,CAAC;QACF,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,WAAW,eAAe,CAAC,EAAE,CAAC;YAChD,IAAI,CAAC,KAAK,CAAC,GAAG,WAAW,eAAe,EAAE,EAAE,CAAC,CAAC;QAChD,CAAC;IACH,CAAC;IAED,MAAM,KAAK,GAAG,IAAI,IAAA,gCAAkB,GAAE,EAAE,CAAC;IACzC,MAAM,EAAE,OAAO,EAAE,GAAG,oBAAoB,EAAE,GAAG,IAAA,uCAAyB,GAAE,CAAC;IACzE,MAAM,qBAAqB,GACzB,IAAI,KAAK,OAAO;QACd,CAAC,CAAC,IAAA,6CAAuB,EACrB,IAAI,EACJ,kBAAkB,EAClB,EAAE,GAAG,sBAAsB,EAAE,GAAG,oBAAoB,EAAE,EACtD,EAAE,oBAAoB,EAAE,IAAI,EAAE,CAC/B;QACH,CAAC,CAAC,IAAA,6CAAuB,EAAC,IAAI,EAAE,EAAE,kBAAkB,EAAE,KAAK,EAAE,EAAE,oBAAoB,EAAE;YACjF,oBAAoB,EAAE,IAAI;SAC3B,CAAC,CAAC;IACT,yGAAyG;IACzG,0GAA0G;IAC1G,iEAAiE;IACjE,MAAM,cAAc,GAAG,IAAA,6CAAuB,EAAC,IAAI,EAAE,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,oBAAoB,EAAE,KAAK,EAAE,CAAC,CAAC;IACvG,OAAO,IAAA,yBAAgB,EAAC,qBAAqB,EAAE,cAAc,CAAC,CAAC;AACjE,CAAC","sourcesContent":["import { offsetFromRoot, readJson, runTasksInSerial, writeJson, type GeneratorCallback, type Tree } from '@nx/devkit';\n\nimport { addFrontmcpDependencies } from '../../utils/add-dependencies.js';\nimport { getModuleResolution } from '../../utils/project-paths.js';\nimport { getFrontmcpVersion, getUiBuildDevDependencies } from '../../utils/versions.js';\n\nexport interface EnsureUiPackageOptions {\n /** e.g. 'ui/components' */\n packageRoot: string;\n /** Nx project name for a package that does not exist yet, e.g. 'ui-components' */\n projectName: string;\n /** 'react' packages render components and are tested in jsdom; 'shell' packages only build HTML strings. */\n kind: 'react' | 'shell';\n}\n\nconst REACT_DEPENDENCIES: Record<string, string> = {\n react: '^19.0.0',\n 'react-dom': '^19.0.0',\n '@mui/material': '^7.0.0',\n '@emotion/react': '^11.14.0',\n '@emotion/styled': '^11.14.0',\n};\n\nconst REACT_DEV_DEPENDENCIES: Record<string, string> = {\n '@types/react': '^19.0.0',\n '@types/react-dom': '^19.0.0',\n '@testing-library/dom': '^10.4.0',\n '@testing-library/react': '^16.0.0',\n 'jest-environment-jsdom': '^30.0.2',\n};\n\nfunction buildTargets(packageRoot: string): Record<string, unknown> {\n const common = {\n main: `${packageRoot}/src/index.ts`,\n tsConfig: `${packageRoot}/tsconfig.json`,\n bundle: true,\n thirdParty: false,\n platform: 'node',\n additionalEntryPoints: [] as string[],\n };\n return {\n 'build-cjs': {\n executor: '@nx/esbuild:esbuild',\n outputs: ['{options.outputPath}'],\n options: { ...common, outputPath: `dist/${packageRoot}`, format: ['cjs'], declaration: true },\n },\n 'build-esm': {\n executor: '@nx/esbuild:esbuild',\n dependsOn: ['build-cjs'],\n outputs: ['{options.outputPath}'],\n options: {\n ...common,\n outputPath: `dist/${packageRoot}/esm`,\n format: ['esm'],\n declaration: false,\n esbuildOptions: { outExtension: { '.js': '.mjs' } },\n },\n },\n build: {\n executor: 'nx:noop',\n dependsOn: ['build-cjs', 'build-esm'],\n },\n };\n}\n\n/**\n * The UI generators emit `.tsx` files that import React and MUI (or the uipack\n * shell builder), and a spec that renders them. Nothing else installs those, so\n * the generators add them — and create the package folder when the workspace\n * does not have one yet, instead of writing files into a folder that no Nx\n * project owns.\n */\nexport function ensureUiPackage(tree: Tree, options: EnsureUiPackageOptions): GeneratorCallback {\n const { packageRoot, projectName, kind } = options;\n\n if (!tree.exists(`${packageRoot}/project.json`)) {\n const offset = offsetFromRoot(packageRoot);\n // `customConditions` (Nx solution workspaces set it) is only valid with a modern `moduleResolution`\n // (TS5098), so a package that inherits it must inherit the base's `module`/`moduleResolution` too.\n const inheritsModernResolution = Boolean(\n tree.exists('tsconfig.base.json') &&\n readJson<{ compilerOptions?: { customConditions?: unknown } }>(tree, 'tsconfig.base.json').compilerOptions\n ?.customConditions,\n );\n writeJson(tree, `${packageRoot}/project.json`, {\n name: projectName,\n $schema: `${offset}node_modules/nx/schemas/project-schema.json`,\n sourceRoot: `${packageRoot}/src`,\n projectType: 'library',\n tags: [],\n targets: buildTargets(packageRoot),\n });\n writeJson(tree, `${packageRoot}/tsconfig.json`, {\n extends: `${offset}tsconfig.base.json`,\n compilerOptions: {\n ...(!inheritsModernResolution && { module: 'commonjs', moduleResolution: getModuleResolution(tree) }),\n ...(kind === 'react' && { jsx: 'react-jsx' }),\n esModuleInterop: true,\n strict: true,\n },\n include: ['src/**/*.ts', 'src/**/*.tsx'],\n exclude: ['src/**/*.spec.ts', 'src/**/*.spec.tsx'],\n });\n tree.write(\n `${packageRoot}/jest.config.cjs`,\n `module.exports = {\n displayName: '${projectName}',\n testEnvironment: '${kind === 'react' ? 'jsdom' : 'node'}',\n transform: {\n '^.+\\\\\\\\.[tj]sx?$': ['@swc/jest', {\n jsc: {\n target: 'es2022',\n parser: { syntax: 'typescript', tsx: true },\n transform: { react: { runtime: 'automatic' } },\n },\n swcrc: false,\n }],\n },\n moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'],\n};\n`,\n );\n if (!tree.exists(`${packageRoot}/src/index.ts`)) {\n tree.write(`${packageRoot}/src/index.ts`, '');\n }\n }\n\n const range = `~${getFrontmcpVersion()}`;\n const { esbuild, ...buildDevDependencies } = getUiBuildDevDependencies();\n const installUiDependencies =\n kind === 'react'\n ? addFrontmcpDependencies(\n tree,\n REACT_DEPENDENCIES,\n { ...REACT_DEV_DEPENDENCIES, ...buildDevDependencies },\n { keepExistingVersions: true },\n )\n : addFrontmcpDependencies(tree, { '@frontmcp/uipack': range }, buildDevDependencies, {\n keepExistingVersions: true,\n });\n // An existing esbuild range is raised rather than kept when it is older than ours: the `^0.25.0` earlier\n // versions of these generators wrote is below the `>=0.27` peer range of @frontmcp/uipack (npm ERESOLVE).\n // A range at or above ours stays, in whichever section it is in.\n const installEsbuild = addFrontmcpDependencies(tree, {}, { esbuild }, { keepExistingVersions: false });\n return runTasksInSerial(installUiDependencies, installEsbuild);\n}\n"]}
|
|
@@ -18,16 +18,6 @@
|
|
|
18
18
|
"sharedGlobals": []
|
|
19
19
|
},
|
|
20
20
|
"plugins": [
|
|
21
|
-
{
|
|
22
|
-
"plugin": "@nx/js/typescript",
|
|
23
|
-
"options": {
|
|
24
|
-
"typecheck": { "targetName": "typecheck" },
|
|
25
|
-
"build": {
|
|
26
|
-
"targetName": "build",
|
|
27
|
-
"configName": "tsconfig.lib.json"
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
},
|
|
31
21
|
{
|
|
32
22
|
"plugin": "@nx/eslint/plugin",
|
|
33
23
|
"options": { "targetName": "lint" }
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@frontmcp/nx",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.9.1-rc.1",
|
|
4
4
|
"description": "Nx plugin for FrontMCP — generators and executors for building MCP servers",
|
|
5
5
|
"author": "AgentFront <info@agentfront.dev>",
|
|
6
6
|
"homepage": "https://docs.agentfront.dev",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"node": ">=24.0.0"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@frontmcp/skills": "1.
|
|
36
|
+
"@frontmcp/skills": "1.9.1-rc.1",
|
|
37
37
|
"@nx/devkit": "22.6.4",
|
|
38
38
|
"tslib": "^2.3.0"
|
|
39
39
|
},
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type Tree } from '@nx/devkit';
|
|
2
|
+
export type WorkspacePackageManager = 'npm' | 'yarn' | 'pnpm' | 'bun';
|
|
3
|
+
export interface PackageManagerCommands {
|
|
4
|
+
/** Installs the workspace dependencies. */
|
|
5
|
+
install: string;
|
|
6
|
+
/** Runs a locally installed bin, e.g. `npx nx`. */
|
|
7
|
+
exec: string;
|
|
8
|
+
}
|
|
9
|
+
/** The package manager the workspace uses: `nx.json` `cli.packageManager`, else its lockfile, else npm. */
|
|
10
|
+
export declare function detectWorkspacePackageManager(tree: Tree): WorkspacePackageManager;
|
|
11
|
+
export declare function getPackageManagerCommands(tree: Tree): PackageManagerCommands;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.detectWorkspacePackageManager = detectWorkspacePackageManager;
|
|
4
|
+
exports.getPackageManagerCommands = getPackageManagerCommands;
|
|
5
|
+
const devkit_1 = require("@nx/devkit");
|
|
6
|
+
const COMMANDS = {
|
|
7
|
+
npm: { install: 'npm install', exec: 'npx' },
|
|
8
|
+
yarn: { install: 'yarn install', exec: 'yarn' },
|
|
9
|
+
pnpm: { install: 'pnpm install', exec: 'pnpm exec' },
|
|
10
|
+
bun: { install: 'bun install', exec: 'bunx' },
|
|
11
|
+
};
|
|
12
|
+
const LOCKFILES = [
|
|
13
|
+
['bun.lock', 'bun'],
|
|
14
|
+
['bun.lockb', 'bun'],
|
|
15
|
+
['pnpm-lock.yaml', 'pnpm'],
|
|
16
|
+
['yarn.lock', 'yarn'],
|
|
17
|
+
['package-lock.json', 'npm'],
|
|
18
|
+
];
|
|
19
|
+
function isPackageManager(value) {
|
|
20
|
+
return typeof value === 'string' && Object.prototype.hasOwnProperty.call(COMMANDS, value);
|
|
21
|
+
}
|
|
22
|
+
/** The package manager the workspace uses: `nx.json` `cli.packageManager`, else its lockfile, else npm. */
|
|
23
|
+
function detectWorkspacePackageManager(tree) {
|
|
24
|
+
const configured = (0, devkit_1.readNxJson)(tree)?.cli?.packageManager;
|
|
25
|
+
if (isPackageManager(configured))
|
|
26
|
+
return configured;
|
|
27
|
+
const match = LOCKFILES.find(([lockfile]) => tree.exists(lockfile));
|
|
28
|
+
return match ? match[1] : 'npm';
|
|
29
|
+
}
|
|
30
|
+
function getPackageManagerCommands(tree) {
|
|
31
|
+
return COMMANDS[detectWorkspacePackageManager(tree)];
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=package-manager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"package-manager.js","sourceRoot":"","sources":["../../../src/utils/package-manager.ts"],"names":[],"mappings":";;AA+BA,sEAKC;AAED,8DAEC;AAxCD,uCAAmD;AAWnD,MAAM,QAAQ,GAA4D;IACxE,GAAG,EAAE,EAAE,OAAO,EAAE,aAAa,EAAE,IAAI,EAAE,KAAK,EAAE;IAC5C,IAAI,EAAE,EAAE,OAAO,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,EAAE;IAC/C,IAAI,EAAE,EAAE,OAAO,EAAE,cAAc,EAAE,IAAI,EAAE,WAAW,EAAE;IACpD,GAAG,EAAE,EAAE,OAAO,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,EAAE;CAC9C,CAAC;AAEF,MAAM,SAAS,GAA8D;IAC3E,CAAC,UAAU,EAAE,KAAK,CAAC;IACnB,CAAC,WAAW,EAAE,KAAK,CAAC;IACpB,CAAC,gBAAgB,EAAE,MAAM,CAAC;IAC1B,CAAC,WAAW,EAAE,MAAM,CAAC;IACrB,CAAC,mBAAmB,EAAE,KAAK,CAAC;CAC7B,CAAC;AAEF,SAAS,gBAAgB,CAAC,KAAc;IACtC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;AAC5F,CAAC;AAED,2GAA2G;AAC3G,SAAgB,6BAA6B,CAAC,IAAU;IACtD,MAAM,UAAU,GAAG,IAAA,mBAAU,EAAC,IAAI,CAAC,EAAE,GAAG,EAAE,cAAc,CAAC;IACzD,IAAI,gBAAgB,CAAC,UAAU,CAAC;QAAE,OAAO,UAAU,CAAC;IACpD,MAAM,KAAK,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC;IACpE,OAAO,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;AAClC,CAAC;AAED,SAAgB,yBAAyB,CAAC,IAAU;IAClD,OAAO,QAAQ,CAAC,6BAA6B,CAAC,IAAI,CAAC,CAAC,CAAC;AACvD,CAAC","sourcesContent":["import { readNxJson, type Tree } from '@nx/devkit';\n\nexport type WorkspacePackageManager = 'npm' | 'yarn' | 'pnpm' | 'bun';\n\nexport interface PackageManagerCommands {\n /** Installs the workspace dependencies. */\n install: string;\n /** Runs a locally installed bin, e.g. `npx nx`. */\n exec: string;\n}\n\nconst COMMANDS: Record<WorkspacePackageManager, PackageManagerCommands> = {\n npm: { install: 'npm install', exec: 'npx' },\n yarn: { install: 'yarn install', exec: 'yarn' },\n pnpm: { install: 'pnpm install', exec: 'pnpm exec' },\n bun: { install: 'bun install', exec: 'bunx' },\n};\n\nconst LOCKFILES: ReadonlyArray<readonly [string, WorkspacePackageManager]> = [\n ['bun.lock', 'bun'],\n ['bun.lockb', 'bun'],\n ['pnpm-lock.yaml', 'pnpm'],\n ['yarn.lock', 'yarn'],\n ['package-lock.json', 'npm'],\n];\n\nfunction isPackageManager(value: unknown): value is WorkspacePackageManager {\n return typeof value === 'string' && Object.prototype.hasOwnProperty.call(COMMANDS, value);\n}\n\n/** The package manager the workspace uses: `nx.json` `cli.packageManager`, else its lockfile, else npm. */\nexport function detectWorkspacePackageManager(tree: Tree): WorkspacePackageManager {\n const configured = readNxJson(tree)?.cli?.packageManager;\n if (isPackageManager(configured)) return configured;\n const match = LOCKFILES.find(([lockfile]) => tree.exists(lockfile));\n return match ? match[1] : 'npm';\n}\n\nexport function getPackageManagerCommands(tree: Tree): PackageManagerCommands {\n return COMMANDS[detectWorkspacePackageManager(tree)];\n}\n"]}
|
package/utils/project-paths.d.ts
CHANGED
|
@@ -12,9 +12,29 @@ export interface ProjectPaths {
|
|
|
12
12
|
* relative to the workspace itself.
|
|
13
13
|
*/
|
|
14
14
|
export declare function resolveProjectPaths(directory: string, workspaceRoot?: string): ProjectPaths;
|
|
15
|
+
/** Major version of the workspace's TypeScript: the installed compiler first, then the declared range. */
|
|
16
|
+
export declare function getTypeScriptMajor(tree: Tree, workspaceRoot?: string): number | undefined;
|
|
17
|
+
export type ProjectModuleResolution = 'bundler' | 'node10';
|
|
15
18
|
/**
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
* itself, so it is only emitted when the workspace really runs TypeScript 6+.
|
|
19
|
+
* `frontmcp build` compiles a project with `--module commonjs`. TypeScript 5 pairs CommonJS only with
|
|
20
|
+
* `node10`; TypeScript 6 deprecates `node10` (TS5107, removed in 7) and accepts `bundler` with CommonJS.
|
|
19
21
|
*/
|
|
20
|
-
export declare function
|
|
22
|
+
export declare function getModuleResolution(tree: Tree, workspaceRoot?: string): ProjectModuleResolution;
|
|
23
|
+
export interface ProjectTsOptions {
|
|
24
|
+
moduleResolution: ProjectModuleResolution;
|
|
25
|
+
/**
|
|
26
|
+
* Nx TS-solution workspaces set `customConditions` in `tsconfig.base.json`, which `node10` rejects
|
|
27
|
+
* (TS5098). A project resolving with `node10` then has to reset it.
|
|
28
|
+
*/
|
|
29
|
+
resetCustomConditions: boolean;
|
|
30
|
+
}
|
|
31
|
+
/** Compiler options a FrontMCP project's `tsconfig.json` sets so it builds in any workspace. */
|
|
32
|
+
export declare function getProjectTsOptions(tree: Tree, workspaceRoot?: string): ProjectTsOptions;
|
|
33
|
+
/**
|
|
34
|
+
* Register a `paths` alias in `tsconfig.base.json` (when the workspace has one). The target is written
|
|
35
|
+
* relative (`./libs/x/src/index.ts`): without a `baseUrl` — Nx TS-solution workspaces, TypeScript 6 —
|
|
36
|
+
* a bare `libs/...` target is an error (TS5090), and with `baseUrl: "."` both spellings resolve alike.
|
|
37
|
+
*/
|
|
38
|
+
export declare function addTsPathAlias(tree: Tree, alias: string, target: string, options?: {
|
|
39
|
+
overwrite?: boolean;
|
|
40
|
+
}): void;
|
package/utils/project-paths.js
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.resolveProjectPaths = resolveProjectPaths;
|
|
4
|
-
exports.
|
|
4
|
+
exports.getTypeScriptMajor = getTypeScriptMajor;
|
|
5
|
+
exports.getModuleResolution = getModuleResolution;
|
|
6
|
+
exports.getProjectTsOptions = getProjectTsOptions;
|
|
7
|
+
exports.addTsPathAlias = addTsPathAlias;
|
|
5
8
|
const fs_1 = require("fs");
|
|
6
9
|
const path_1 = require("path");
|
|
7
10
|
const devkit_1 = require("@nx/devkit");
|
|
@@ -26,12 +29,8 @@ function resolveProjectPaths(directory, workspaceRoot) {
|
|
|
26
29
|
const projectRoot = base && normalized.startsWith(`${base}/`) ? normalized.slice(base.length + 1) : normalized;
|
|
27
30
|
return { projectRoot, offset: (0, devkit_1.offsetFromRoot)(projectRoot) };
|
|
28
31
|
}
|
|
29
|
-
/**
|
|
30
|
-
|
|
31
|
-
* deprecation is acknowledged, but older compilers reject the acknowledgement
|
|
32
|
-
* itself, so it is only emitted when the workspace really runs TypeScript 6+.
|
|
33
|
-
*/
|
|
34
|
-
function getIgnoreDeprecations(tree, workspaceRoot) {
|
|
32
|
+
/** Major version of the workspace's TypeScript: the installed compiler first, then the declared range. */
|
|
33
|
+
function getTypeScriptMajor(tree, workspaceRoot) {
|
|
35
34
|
const root = workspaceRoot ?? '';
|
|
36
35
|
const installed = (0, path_1.join)(tree.root, root, 'node_modules', 'typescript', 'package.json');
|
|
37
36
|
let range;
|
|
@@ -51,6 +50,54 @@ function getIgnoreDeprecations(tree, workspaceRoot) {
|
|
|
51
50
|
}
|
|
52
51
|
}
|
|
53
52
|
const major = Number(range?.match(/\d+/)?.[0]);
|
|
54
|
-
return Number.isFinite(major)
|
|
53
|
+
return Number.isFinite(major) ? major : undefined;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* `frontmcp build` compiles a project with `--module commonjs`. TypeScript 5 pairs CommonJS only with
|
|
57
|
+
* `node10`; TypeScript 6 deprecates `node10` (TS5107, removed in 7) and accepts `bundler` with CommonJS.
|
|
58
|
+
*/
|
|
59
|
+
function getModuleResolution(tree, workspaceRoot) {
|
|
60
|
+
const major = getTypeScriptMajor(tree, workspaceRoot);
|
|
61
|
+
return major !== undefined && major >= 6 ? 'bundler' : 'node10';
|
|
62
|
+
}
|
|
63
|
+
function readBaseCompilerOptions(tree, workspaceRoot) {
|
|
64
|
+
const basePath = (0, path_1.join)(workspaceRoot ?? '', 'tsconfig.base.json');
|
|
65
|
+
if (!tree.exists(basePath))
|
|
66
|
+
return {};
|
|
67
|
+
try {
|
|
68
|
+
return (0, devkit_1.readJson)(tree, basePath).compilerOptions ?? {};
|
|
69
|
+
}
|
|
70
|
+
catch {
|
|
71
|
+
return {};
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
/** Compiler options a FrontMCP project's `tsconfig.json` sets so it builds in any workspace. */
|
|
75
|
+
function getProjectTsOptions(tree, workspaceRoot) {
|
|
76
|
+
const moduleResolution = getModuleResolution(tree, workspaceRoot);
|
|
77
|
+
const base = readBaseCompilerOptions(tree, workspaceRoot);
|
|
78
|
+
return {
|
|
79
|
+
moduleResolution,
|
|
80
|
+
resetCustomConditions: moduleResolution === 'node10' && base['customConditions'] !== undefined,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Register a `paths` alias in `tsconfig.base.json` (when the workspace has one). The target is written
|
|
85
|
+
* relative (`./libs/x/src/index.ts`): without a `baseUrl` — Nx TS-solution workspaces, TypeScript 6 —
|
|
86
|
+
* a bare `libs/...` target is an error (TS5090), and with `baseUrl: "."` both spellings resolve alike.
|
|
87
|
+
*/
|
|
88
|
+
function addTsPathAlias(tree, alias, target, options = {}) {
|
|
89
|
+
if (!tree.exists('tsconfig.base.json'))
|
|
90
|
+
return;
|
|
91
|
+
const relativeTarget = target.startsWith('./') || target.startsWith('../') ? target : `./${target}`;
|
|
92
|
+
(0, devkit_1.updateJson)(tree, 'tsconfig.base.json', (json) => {
|
|
93
|
+
const compilerOptions = json.compilerOptions ?? {};
|
|
94
|
+
const paths = compilerOptions.paths ?? {};
|
|
95
|
+
if (options.overwrite !== false || !paths[alias]) {
|
|
96
|
+
paths[alias] = [relativeTarget];
|
|
97
|
+
}
|
|
98
|
+
compilerOptions.paths = paths;
|
|
99
|
+
json.compilerOptions = compilerOptions;
|
|
100
|
+
return json;
|
|
101
|
+
});
|
|
55
102
|
}
|
|
56
103
|
//# sourceMappingURL=project-paths.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"project-paths.js","sourceRoot":"","sources":["../../../src/utils/project-paths.ts"],"names":[],"mappings":";;AA0BA,kDAKC;AAOD,
|
|
1
|
+
{"version":3,"file":"project-paths.js","sourceRoot":"","sources":["../../../src/utils/project-paths.ts"],"names":[],"mappings":";;AA0BA,kDAKC;AAGD,gDAuBC;AAQD,kDAGC;AAsBD,kDAOC;AAOD,wCAaC;AArHD,2BAA8C;AAC9C,+BAA4B;AAE5B,uCAA6E;AAS7E,SAAS,kBAAkB,CAAC,KAAa;IACvC,IAAI,MAAM,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IACvC,IAAI,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC;QAAE,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACtD,I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esContent":["import { existsSync, readFileSync } from 'fs';\nimport { join } from 'path';\n\nimport { offsetFromRoot, readJson, updateJson, type Tree } from '@nx/devkit';\n\nexport interface ProjectPaths {\n /** Project root relative to the Nx workspace root (what project.json must contain). */\n projectRoot: string;\n /** Relative path from the project root back to the workspace root, with a trailing slash. */\n offset: string;\n}\n\nfunction normalizeDirectory(value: string): string {\n let result = value.replace(/\\\\/g, '/');\n if (result.startsWith('./')) result = result.slice(2);\n let end = result.length;\n while (end > 0 && result[end - 1] === '/') end--;\n return result.slice(0, end);\n}\n\n/**\n * `directory` is relative to the tree root. When the tree root sits above the\n * workspace (the `workspace` generator scaffolds into `<name>/`), pass that\n * folder as `workspaceRoot` so the paths written into project files are\n * relative to the workspace itself.\n */\nexport function resolveProjectPaths(directory: string, workspaceRoot?: string): ProjectPaths {\n const normalized = normalizeDirectory(directory);\n const base = normalizeDirectory(workspaceRoot ?? '');\n const projectRoot = base && normalized.startsWith(`${base}/`) ? normalized.slice(base.length + 1) : normalized;\n return { projectRoot, offset: offsetFromRoot(projectRoot) };\n}\n\n/** Major version of the workspace's TypeScript: the installed compiler first, then the declared range. */\nexport function getTypeScriptMajor(tree: Tree, workspaceRoot?: string): number | undefined {\n const root = workspaceRoot ?? '';\n const installed = join(tree.root, root, 'node_modules', 'typescript', 'package.json');\n let range: string | undefined;\n try {\n if (existsSync(installed)) {\n range = (JSON.parse(readFileSync(installed, 'utf8')) as { version?: string }).version;\n }\n } catch {\n range = undefined;\n }\n if (!range) {\n const pkgPath = join(root, 'package.json');\n if (tree.exists(pkgPath)) {\n const pkg = JSON.parse(tree.read(pkgPath, 'utf-8') ?? '{}') as {\n dependencies?: Record<string, string>;\n devDependencies?: Record<string, string>;\n };\n range = pkg.devDependencies?.['typescript'] ?? pkg.dependencies?.['typescript'];\n }\n }\n const major = Number(range?.match(/\\d+/)?.[0]);\n return Number.isFinite(major) ? major : undefined;\n}\n\nexport type ProjectModuleResolution = 'bundler' | 'node10';\n\n/**\n * `frontmcp build` compiles a project with `--module commonjs`. TypeScript 5 pairs CommonJS only with\n * `node10`; TypeScript 6 deprecates `node10` (TS5107, removed in 7) and accepts `bundler` with CommonJS.\n */\nexport function getModuleResolution(tree: Tree, workspaceRoot?: string): ProjectModuleResolution {\n const major = getTypeScriptMajor(tree, workspaceRoot);\n return major !== undefined && major >= 6 ? 'bundler' : 'node10';\n}\n\nfunction readBaseCompilerOptions(tree: Tree, workspaceRoot?: string): Record<string, unknown> {\n const basePath = join(workspaceRoot ?? '', 'tsconfig.base.json');\n if (!tree.exists(basePath)) return {};\n try {\n return readJson<{ compilerOptions?: Record<string, unknown> }>(tree, basePath).compilerOptions ?? {};\n } catch {\n return {};\n }\n}\n\nexport interface ProjectTsOptions {\n moduleResolution: ProjectModuleResolution;\n /**\n * Nx TS-solution workspaces set `customConditions` in `tsconfig.base.json`, which `node10` rejects\n * (TS5098). A project resolving with `node10` then has to reset it.\n */\n resetCustomConditions: boolean;\n}\n\n/** Compiler options a FrontMCP project's `tsconfig.json` sets so it builds in any workspace. */\nexport function getProjectTsOptions(tree: Tree, workspaceRoot?: string): ProjectTsOptions {\n const moduleResolution = getModuleResolution(tree, workspaceRoot);\n const base = readBaseCompilerOptions(tree, workspaceRoot);\n return {\n moduleResolution,\n resetCustomConditions: moduleResolution === 'node10' && base['customConditions'] !== undefined,\n };\n}\n\n/**\n * Register a `paths` alias in `tsconfig.base.json` (when the workspace has one). The target is written\n * relative (`./libs/x/src/index.ts`): without a `baseUrl` — Nx TS-solution workspaces, TypeScript 6 —\n * a bare `libs/...` target is an error (TS5090), and with `baseUrl: \".\"` both spellings resolve alike.\n */\nexport function addTsPathAlias(tree: Tree, alias: string, target: string, options: { overwrite?: boolean } = {}): void {\n if (!tree.exists('tsconfig.base.json')) return;\n const relativeTarget = target.startsWith('./') || target.startsWith('../') ? target : `./${target}`;\n updateJson(tree, 'tsconfig.base.json', (json: { compilerOptions?: { paths?: Record<string, string[]> } }) => {\n const compilerOptions = json.compilerOptions ?? {};\n const paths = compilerOptions.paths ?? {};\n if (options.overwrite !== false || !paths[alias]) {\n paths[alias] = [relativeTarget];\n }\n compilerOptions.paths = paths;\n json.compilerOptions = compilerOptions;\n return json;\n });\n}\n"]}
|
package/utils/versions.d.ts
CHANGED
|
@@ -4,5 +4,13 @@ export declare function getFrontmcpDevDependencies(): Record<string, string>;
|
|
|
4
4
|
/** What `frontmcp test` and the generated `jest.config.cjs` need in the workspace. */
|
|
5
5
|
export declare function getJestDevDependencies(): Record<string, string>;
|
|
6
6
|
export declare function getNxVersion(): string;
|
|
7
|
+
export declare function getEsbuildVersion(): string;
|
|
8
|
+
/**
|
|
9
|
+
* What `frontmcp build --target lambda` needs: the generated handler wraps the server with
|
|
10
|
+
* `@codegenie/serverless-express`, and the build refuses to run without it.
|
|
11
|
+
*/
|
|
12
|
+
export declare function getLambdaDependencies(): Record<string, string>;
|
|
13
|
+
/** What the `@nx/esbuild` build targets of the generated UI packages need. */
|
|
14
|
+
export declare function getUiBuildDevDependencies(): Record<string, string>;
|
|
7
15
|
export declare function getNxDependencies(): Record<string, string>;
|
|
8
16
|
export declare function getNxDevDependencies(): Record<string, string>;
|
package/utils/versions.js
CHANGED
|
@@ -5,6 +5,9 @@ exports.getFrontmcpDependencies = getFrontmcpDependencies;
|
|
|
5
5
|
exports.getFrontmcpDevDependencies = getFrontmcpDevDependencies;
|
|
6
6
|
exports.getJestDevDependencies = getJestDevDependencies;
|
|
7
7
|
exports.getNxVersion = getNxVersion;
|
|
8
|
+
exports.getEsbuildVersion = getEsbuildVersion;
|
|
9
|
+
exports.getLambdaDependencies = getLambdaDependencies;
|
|
10
|
+
exports.getUiBuildDevDependencies = getUiBuildDevDependencies;
|
|
8
11
|
exports.getNxDependencies = getNxDependencies;
|
|
9
12
|
exports.getNxDevDependencies = getNxDevDependencies;
|
|
10
13
|
const fs_1 = require("fs");
|
|
@@ -61,9 +64,34 @@ function getJestDevDependencies() {
|
|
|
61
64
|
};
|
|
62
65
|
}
|
|
63
66
|
const NX_VERSION = '22.6.4';
|
|
67
|
+
/**
|
|
68
|
+
* The esbuild the generated workspace installs. It must satisfy the `esbuild` peer range of
|
|
69
|
+
* `@frontmcp/uipack` (`>=0.27`) and matches the range the `frontmcp` CLI depends on, so the
|
|
70
|
+
* workspace resolves a single copy. `versions.spec.ts` checks both against the monorepo.
|
|
71
|
+
*/
|
|
72
|
+
const ESBUILD_VERSION = '^0.27.3';
|
|
64
73
|
function getNxVersion() {
|
|
65
74
|
return NX_VERSION;
|
|
66
75
|
}
|
|
76
|
+
function getEsbuildVersion() {
|
|
77
|
+
return ESBUILD_VERSION;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* What `frontmcp build --target lambda` needs: the generated handler wraps the server with
|
|
81
|
+
* `@codegenie/serverless-express`, and the build refuses to run without it.
|
|
82
|
+
*/
|
|
83
|
+
function getLambdaDependencies() {
|
|
84
|
+
return {
|
|
85
|
+
'@codegenie/serverless-express': '^5.0.0',
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
/** What the `@nx/esbuild` build targets of the generated UI packages need. */
|
|
89
|
+
function getUiBuildDevDependencies() {
|
|
90
|
+
return {
|
|
91
|
+
'@nx/esbuild': NX_VERSION,
|
|
92
|
+
esbuild: ESBUILD_VERSION,
|
|
93
|
+
};
|
|
94
|
+
}
|
|
67
95
|
function getNxDependencies() {
|
|
68
96
|
return {
|
|
69
97
|
nx: NX_VERSION,
|
package/utils/versions.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"versions.js","sourceRoot":"","sources":["../../../src/utils/versions.ts"],"names":[],"mappings":";;AA4BA,gDAEC;AAED,0DAQC;AAED,gEAKC;AAGD,wDASC;
|
|
1
|
+
{"version":3,"file":"versions.js","sourceRoot":"","sources":["../../../src/utils/versions.ts"],"names":[],"mappings":";;AA4BA,gDAEC;AAED,0DAQC;AAED,gEAKC;AAGD,wDASC;AAWD,oCAEC;AAED,8CAEC;AAMD,sDAIC;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Sync } from 'fs';\nimport { join } from 'path';\n\nimport { readJsonFile } from '@nx/devkit';\n\nlet cachedVersion: string | undefined;\n\nfunction readPluginVersion(): string {\n if (cachedVersion) return cachedVersion;\n\n // Walk up from __dirname to find the @frontmcp/nx package.json.\n // In monorepo (src/utils/ or dist/utils/): ../../package.json\n // When published to npm (utils/): ../package.json\n let dir = __dirname;\n for (let i = 0; i < 4; i++) {\n dir = join(dir, '..');\n const candidate = join(dir, 'package.json');\n if (!existsSync(candidate)) continue;\n const pkg = readJsonFile<{ name?: string; version?: unknown }>(candidate);\n if (pkg.name === '@frontmcp/nx' && typeof pkg.version === 'string') {\n cachedVersion = pkg.version;\n return cachedVersion;\n }\n }\n\n throw new Error(`@frontmcp/nx package.json not found (searched from ${__dirname})`);\n}\n\nexport function getFrontmcpVersion(): string {\n return readPluginVersion();\n}\n\nexport function getFrontmcpDependencies(): Record<string, string> {\n const range = `~${getFrontmcpVersion()}`;\n return {\n '@frontmcp/sdk': range,\n frontmcp: range,\n 'reflect-metadata': '^0.2.2',\n zod: '^4.0.0',\n };\n}\n\nexport function getFrontmcpDevDependencies(): Record<string, string> {\n const range = `~${getFrontmcpVersion()}`;\n return {\n '@frontmcp/testing': range,\n };\n}\n\n/** What `frontmcp test` and the generated `jest.config.cjs` need in the workspace. */\nexport function getJestDevDependencies(): Record<string, string> {\n return {\n '@swc/core': '~1.15.8',\n '@swc/helpers': '~0.5.18',\n '@swc/jest': '~0.2.39',\n '@types/jest': '^30.0.0',\n '@types/node': '^24.0.0',\n jest: '^30.0.2',\n };\n}\n\nconst NX_VERSION = '22.6.4';\n\n/**\n * The esbuild the generated workspace installs. It must satisfy the `esbuild` peer range of\n * `@frontmcp/uipack` (`>=0.27`) and matches the range the `frontmcp` CLI depends on, so the\n * workspace resolves a single copy. `versions.spec.ts` checks both against the monorepo.\n */\nconst ESBUILD_VERSION = '^0.27.3';\n\nexport function getNxVersion(): string {\n return NX_VERSION;\n}\n\nexport function getEsbuildVersion(): string {\n return ESBUILD_VERSION;\n}\n\n/**\n * What `frontmcp build --target lambda` needs: the generated handler wraps the server with\n * `@codegenie/serverless-express`, and the build refuses to run without it.\n */\nexport function getLambdaDependencies(): Record<string, string> {\n return {\n '@codegenie/serverless-express': '^5.0.0',\n };\n}\n\n/** What the `@nx/esbuild` build targets of the generated UI packages need. */\nexport function getUiBuildDevDependencies(): Record<string, string> {\n return {\n '@nx/esbuild': NX_VERSION,\n esbuild: ESBUILD_VERSION,\n };\n}\n\nexport function getNxDependencies(): Record<string, string> {\n return {\n nx: NX_VERSION,\n '@nx/devkit': NX_VERSION,\n '@nx/js': NX_VERSION,\n '@nx/eslint': NX_VERSION,\n '@nx/jest': NX_VERSION,\n '@nx/esbuild': NX_VERSION,\n };\n}\n\nexport function getNxDevDependencies(): Record<string, string> {\n return {\n '@nx/workspace': NX_VERSION,\n '@swc-node/register': '~1.11.1',\n '@swc/core': '~1.15.8',\n '@swc/helpers': '~0.5.18',\n '@swc/jest': '~0.2.39',\n '@types/jest': '^30.0.0',\n '@types/node': '^24.0.0',\n jest: '^30.0.2',\n typescript: '~5.9.2',\n tslib: '^2.3.0',\n prettier: '~3.6.2',\n };\n}\n"]}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { Adapter, DynamicAdapter, type AdapterFetchResult } from '@frontmcp/sdk';
|
|
2
|
-
|
|
3
|
-
export interface <%= className %>AdapterOptions {
|
|
4
|
-
// TODO: define adapter options
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
@Adapter({
|
|
8
|
-
name: '<%= fileName %>',
|
|
9
|
-
description: 'TODO: describe what this adapter does',
|
|
10
|
-
})
|
|
11
|
-
export class <%= className %>Adapter extends DynamicAdapter<<%= className %>AdapterOptions> {
|
|
12
|
-
async fetch(): Promise<AdapterFetchResult> {
|
|
13
|
-
return {
|
|
14
|
-
tools: [],
|
|
15
|
-
resources: [],
|
|
16
|
-
prompts: [],
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { Plugin, DynamicPlugin, type PluginRegistrationContext } from '@frontmcp/sdk';
|
|
2
|
-
|
|
3
|
-
export interface <%= className %>PluginOptions {
|
|
4
|
-
// TODO: define plugin options
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
@Plugin({
|
|
8
|
-
name: '<%= fileName %>',
|
|
9
|
-
description: 'TODO: describe what this plugin does',
|
|
10
|
-
})
|
|
11
|
-
export class <%= className %>Plugin extends DynamicPlugin<<%= className %>PluginOptions> {
|
|
12
|
-
async dynamicProviders() {
|
|
13
|
-
return [];
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
async onRegister(ctx: PluginRegistrationContext): Promise<void> {
|
|
17
|
-
// TODO: register tools, resources, prompts
|
|
18
|
-
}
|
|
19
|
-
}
|