@frontmcp/nx 1.8.6 → 1.9.0
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/executors/build/build.impl.js +9 -19
- package/executors/build/build.impl.js.map +1 -1
- package/executors/build/schema.d.ts +2 -0
- package/executors/build/schema.js.map +1 -1
- package/executors/build/schema.json +22 -2
- package/executors/build-exec/build-exec.impl.js +5 -17
- package/executors/build-exec/build-exec.impl.js.map +1 -1
- package/executors/deploy/deploy.impl.js.map +1 -1
- package/executors/dev/dev.impl.js +11 -17
- package/executors/dev/dev.impl.js.map +1 -1
- package/executors/frontmcp-cli.d.ts +31 -0
- package/executors/frontmcp-cli.js +108 -0
- package/executors/frontmcp-cli.js.map +1 -0
- package/executors/inspector/inspector.impl.js +10 -18
- package/executors/inspector/inspector.impl.js.map +1 -1
- package/executors/serve/serve.impl.js +11 -17
- package/executors/serve/serve.impl.js.map +1 -1
- package/executors/test/test.impl.js +3 -15
- package/executors/test/test.impl.js.map +1 -1
- package/generators/adapter/files/__fileName__.adapter.ts__tmpl__ +9 -2
- package/generators/agent/agent.d.ts +1 -1
- package/generators/agent/agent.js +21 -7
- package/generators/agent/agent.js.map +1 -1
- package/generators/agent/files/__fileName__.agent.ts__tmpl__ +12 -6
- package/generators/app/app.d.ts +1 -1
- package/generators/app/app.js +3 -3
- package/generators/app/app.js.map +1 -1
- package/generators/app/files/jest.config.cjs__tmpl__ +37 -0
- package/generators/app/files/package.json__tmpl__ +5 -0
- package/generators/app/files/project.json__tmpl__ +12 -1
- package/generators/app/files/src/tools/hello.tool.spec.ts__tmpl__ +10 -0
- package/generators/app/files/tsconfig.json__tmpl__ +11 -9
- package/generators/app/files/tsconfig.lib.json__tmpl__ +1 -2
- package/generators/app/files/tsconfig.spec.json__tmpl__ +3 -4
- package/generators/app/lib/normalize-options.d.ts +10 -1
- package/generators/app/lib/normalize-options.js +7 -2
- package/generators/app/lib/normalize-options.js.map +1 -1
- package/generators/app/schema.d.ts +2 -0
- package/generators/app/schema.js.map +1 -1
- package/generators/app/schema.json +5 -0
- package/generators/auth-provider/files/__fileName__.auth-provider.ts__tmpl__ +0 -1
- package/generators/flow/files/__fileName__.flow.ts__tmpl__ +54 -16
- package/generators/init/init.d.ts +4 -0
- package/generators/init/init.js +40 -0
- package/generators/init/init.js.map +1 -0
- package/generators/init/schema.d.ts +4 -0
- package/generators/init/schema.js +3 -0
- package/generators/init/schema.js.map +1 -0
- package/generators/init/schema.json +21 -0
- 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 +6 -1
- package/generators/lib/lib/normalize-options.js +5 -2
- package/generators/lib/lib/normalize-options.js.map +1 -1
- package/generators/lib/lib-project-files/jest.config.cjs__tmpl__ +39 -0
- package/generators/lib/lib-project-files/project.json__tmpl__ +32 -0
- package/generators/lib/lib-project-files/tsconfig.json__tmpl__ +22 -0
- package/generators/lib/lib-project-files/tsconfig.lib.json__tmpl__ +11 -0
- package/generators/lib/lib-project-files/tsconfig.spec.json__tmpl__ +8 -0
- package/generators/lib/lib.d.ts +1 -1
- package/generators/lib/lib.js +52 -20
- package/generators/lib/lib.js.map +1 -1
- package/generators/plugin/files/__fileName__.plugin.ts__tmpl__ +9 -5
- package/generators/provider/files/__fileName__.provider.ts__tmpl__ +5 -9
- package/generators/provider/provider.d.ts +1 -1
- package/generators/provider/provider.js +3 -3
- package/generators/provider/provider.js.map +1 -1
- package/generators/server/files/common/package.json__tmpl__ +5 -0
- package/generators/server/files/common/project.json__tmpl__ +18 -3
- package/generators/server/files/common/src/main.ts__tmpl__ +2 -2
- package/generators/server/files/common/tsconfig.json__tmpl__ +11 -8
- package/generators/server/files/common/tsconfig.lib.json__tmpl__ +0 -1
- 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 +16 -1
- package/generators/server/lib/normalize-options.js +22 -3
- package/generators/server/lib/normalize-options.js.map +1 -1
- package/generators/server/server.d.ts +1 -1
- package/generators/server/server.js +9 -2
- package/generators/server/server.js.map +1 -1
- package/generators/ui-component/files/__className__/__className__.tsx__tmpl__ +0 -1
- package/generators/ui-component/ui-component.d.ts +1 -1
- package/generators/ui-component/ui-component.js +4 -1
- package/generators/ui-component/ui-component.js.map +1 -1
- package/generators/ui-page/ui-page.d.ts +1 -1
- package/generators/ui-page/ui-page.js +4 -1
- package/generators/ui-page/ui-page.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.d.ts +17 -0
- package/generators/ui-shared/ensure-ui-package.js +123 -0
- package/generators/ui-shared/ensure-ui-package.js.map +1 -0
- package/generators/ui-shell/files/__fileName__/__fileName__.shell.spec.ts__tmpl__ +2 -1
- package/generators/ui-shell/ui-shell.d.ts +1 -1
- package/generators/ui-shell/ui-shell.js +4 -1
- package/generators/ui-shell/ui-shell.js.map +1 -1
- package/generators/workspace/files/__dot__gitignore__tmpl__ +1 -0
- package/generators/workspace/files/nx.json__tmpl__ +15 -11
- package/generators/workspace/files/package.json__tmpl__ +3 -3
- package/generators/workspace/workspace.d.ts +1 -1
- package/generators/workspace/workspace.js +3 -2
- package/generators/workspace/workspace.js.map +1 -1
- package/generators.json +5 -0
- package/index.d.ts +1 -0
- package/index.js +3 -1
- package/index.js.map +1 -1
- package/package.json +2 -2
- package/utils/add-dependencies.d.ts +4 -2
- package/utils/add-dependencies.js +2 -2
- package/utils/add-dependencies.js.map +1 -1
- package/utils/normalize-options.js.map +1 -1
- 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 +40 -0
- package/utils/project-paths.js +103 -0
- package/utils/project-paths.js.map +1 -0
- package/utils/versions.d.ts +10 -0
- package/utils/versions.js +45 -5
- package/utils/versions.js.map +1 -1
- package/generators/app/files/jest.config.ts__tmpl__ +0 -23
- 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
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA,aAAa;AACb,oEAAyE;AAAhE,kHAAA,kBAAkB,OAAA;AAC3B,kDAAuD;AAA9C,sGAAA,YAAY,OAAA;AACrB,kDAAuD;AAA9C,sGAAA,YAAY,OAAA;AACrB,2DAAgE;AAAvD,4GAAA,eAAe,OAAA;AACxB,qDAA0D;AAAjD,wGAAA,aAAa,OAAA;AACtB,iEAAsE;AAA7D,gHAAA,iBAAiB,OAAA;AAC1B,2DAAgE;AAAvD,4GAAA,eAAe,OAAA;AACxB,wDAA6D;AAApD,0GAAA,cAAc,OAAA;AACvB,wDAA6D;AAApD,0GAAA,cAAc,OAAA;AACvB,iEAAsE;AAA7D,gHAAA,iBAAiB,OAAA;AAC1B,2DAAgE;AAAvD,4GAAA,eAAe,OAAA;AACxB,8DAAmE;AAA1D,8GAAA,gBAAgB,OAAA;AACzB,gFAAoF;AAA3E,yHAAA,qBAAqB,OAAA;AAC9B,qDAA0D;AAAjD,wGAAA,aAAa,OAAA;AACtB,6EAAiF;AAAxE,uHAAA,oBAAoB,OAAA;AAC7B,8DAAkE;AAAzD,6GAAA,eAAe,OAAA;AACxB,iEAAqE;AAA5D,+GAAA,gBAAgB,OAAA;AAEzB,YAAY;AACZ,mDAK6B;AAJ3B,iHAAA,kBAAkB,OAAA;AAClB,sHAAA,uBAAuB,OAAA;AACvB,yHAAA,0BAA0B,OAAA;AAC1B,gHAAA,iBAAiB,OAAA;AAEnB,6CAA2F;AAAlF,uGAAA,WAAW,OAAA;AAAE,0GAAA,cAAc,OAAA;AAAE,sGAAA,UAAU,OAAA;AAAE,0GAAA,cAAc,OAAA","sourcesContent":["// Generators\nexport { workspaceGenerator } from './generators/workspace/workspace.js';\nexport { appGenerator } from './generators/app/app.js';\nexport { libGenerator } from './generators/lib/lib.js';\nexport { serverGenerator } from './generators/server/server.js';\nexport { toolGenerator } from './generators/tool/tool.js';\nexport { resourceGenerator } from './generators/resource/resource.js';\nexport { promptGenerator } from './generators/prompt/prompt.js';\nexport { skillGenerator } from './generators/skill/skill.js';\nexport { agentGenerator } from './generators/agent/agent.js';\nexport { providerGenerator } from './generators/provider/provider.js';\nexport { pluginGenerator } from './generators/plugin/plugin.js';\nexport { adapterGenerator } from './generators/adapter/adapter.js';\nexport { authProviderGenerator } from './generators/auth-provider/auth-provider.js';\nexport { flowGenerator } from './generators/flow/flow.js';\nexport { uiComponentGenerator } from './generators/ui-component/ui-component.js';\nexport { uiPageGenerator } from './generators/ui-page/ui-page.js';\nexport { uiShellGenerator } from './generators/ui-shell/ui-shell.js';\n\n// Utilities\nexport {\n getFrontmcpVersion,\n getFrontmcpDependencies,\n getFrontmcpDevDependencies,\n getNxDependencies,\n} from './utils/versions.js';\nexport { toClassName, toPropertyName, toFileName, toConstantName } from './utils/names.js';\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA,aAAa;AACb,qDAA0D;AAAjD,wGAAA,aAAa,OAAA;AACtB,oEAAyE;AAAhE,kHAAA,kBAAkB,OAAA;AAC3B,kDAAuD;AAA9C,sGAAA,YAAY,OAAA;AACrB,kDAAuD;AAA9C,sGAAA,YAAY,OAAA;AACrB,2DAAgE;AAAvD,4GAAA,eAAe,OAAA;AACxB,qDAA0D;AAAjD,wGAAA,aAAa,OAAA;AACtB,iEAAsE;AAA7D,gHAAA,iBAAiB,OAAA;AAC1B,2DAAgE;AAAvD,4GAAA,eAAe,OAAA;AACxB,wDAA6D;AAApD,0GAAA,cAAc,OAAA;AACvB,wDAA6D;AAApD,0GAAA,cAAc,OAAA;AACvB,iEAAsE;AAA7D,gHAAA,iBAAiB,OAAA;AAC1B,2DAAgE;AAAvD,4GAAA,eAAe,OAAA;AACxB,8DAAmE;AAA1D,8GAAA,gBAAgB,OAAA;AACzB,gFAAoF;AAA3E,yHAAA,qBAAqB,OAAA;AAC9B,qDAA0D;AAAjD,wGAAA,aAAa,OAAA;AACtB,6EAAiF;AAAxE,uHAAA,oBAAoB,OAAA;AAC7B,8DAAkE;AAAzD,6GAAA,eAAe,OAAA;AACxB,iEAAqE;AAA5D,+GAAA,gBAAgB,OAAA;AAEzB,YAAY;AACZ,mDAK6B;AAJ3B,iHAAA,kBAAkB,OAAA;AAClB,sHAAA,uBAAuB,OAAA;AACvB,yHAAA,0BAA0B,OAAA;AAC1B,gHAAA,iBAAiB,OAAA;AAEnB,6CAA2F;AAAlF,uGAAA,WAAW,OAAA;AAAE,0GAAA,cAAc,OAAA;AAAE,sGAAA,UAAU,OAAA;AAAE,0GAAA,cAAc,OAAA","sourcesContent":["// Generators\nexport { initGenerator } from './generators/init/init.js';\nexport { workspaceGenerator } from './generators/workspace/workspace.js';\nexport { appGenerator } from './generators/app/app.js';\nexport { libGenerator } from './generators/lib/lib.js';\nexport { serverGenerator } from './generators/server/server.js';\nexport { toolGenerator } from './generators/tool/tool.js';\nexport { resourceGenerator } from './generators/resource/resource.js';\nexport { promptGenerator } from './generators/prompt/prompt.js';\nexport { skillGenerator } from './generators/skill/skill.js';\nexport { agentGenerator } from './generators/agent/agent.js';\nexport { providerGenerator } from './generators/provider/provider.js';\nexport { pluginGenerator } from './generators/plugin/plugin.js';\nexport { adapterGenerator } from './generators/adapter/adapter.js';\nexport { authProviderGenerator } from './generators/auth-provider/auth-provider.js';\nexport { flowGenerator } from './generators/flow/flow.js';\nexport { uiComponentGenerator } from './generators/ui-component/ui-component.js';\nexport { uiPageGenerator } from './generators/ui-page/ui-page.js';\nexport { uiShellGenerator } from './generators/ui-shell/ui-shell.js';\n\n// Utilities\nexport {\n getFrontmcpVersion,\n getFrontmcpDependencies,\n getFrontmcpDevDependencies,\n getNxDependencies,\n} from './utils/versions.js';\nexport { toClassName, toPropertyName, toFileName, toConstantName } from './utils/names.js';\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@frontmcp/nx",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.9.0",
|
|
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.0",
|
|
37
37
|
"@nx/devkit": "22.6.4",
|
|
38
38
|
"tslib": "^2.3.0"
|
|
39
39
|
},
|
|
@@ -1,2 +1,4 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
export declare function addFrontmcpDependencies(tree: Tree, dependencies: Record<string, string>, devDependencies?: Record<string, string
|
|
1
|
+
import { type GeneratorCallback, type Tree } from '@nx/devkit';
|
|
2
|
+
export declare function addFrontmcpDependencies(tree: Tree, dependencies: Record<string, string>, devDependencies?: Record<string, string>, options?: {
|
|
3
|
+
keepExistingVersions?: boolean;
|
|
4
|
+
}): GeneratorCallback;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.addFrontmcpDependencies = addFrontmcpDependencies;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
|
-
function addFrontmcpDependencies(tree, dependencies, devDependencies = {}) {
|
|
6
|
-
return (0, devkit_1.addDependenciesToPackageJson)(tree, dependencies, devDependencies);
|
|
5
|
+
function addFrontmcpDependencies(tree, dependencies, devDependencies = {}, options = {}) {
|
|
6
|
+
return (0, devkit_1.addDependenciesToPackageJson)(tree, dependencies, devDependencies, undefined, options.keepExistingVersions);
|
|
7
7
|
}
|
|
8
8
|
//# sourceMappingURL=add-dependencies.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"add-dependencies.js","sourceRoot":"","sources":["../../../src/utils/add-dependencies.ts"],"names":[],"mappings":";;AAEA,
|
|
1
|
+
{"version":3,"file":"add-dependencies.js","sourceRoot":"","sources":["../../../src/utils/add-dependencies.ts"],"names":[],"mappings":";;AAEA,0DAOC;AATD,uCAA6F;AAE7F,SAAgB,uBAAuB,CACrC,IAAU,EACV,YAAoC,EACpC,kBAA0C,EAAE,EAC5C,UAA8C,EAAE;IAEhD,OAAO,IAAA,qCAA4B,EAAC,IAAI,EAAE,YAAY,EAAE,eAAe,EAAE,SAAS,EAAE,OAAO,CAAC,oBAAoB,CAAC,CAAC;AACpH,CAAC","sourcesContent":["import { addDependenciesToPackageJson, type GeneratorCallback, type Tree } from '@nx/devkit';\n\nexport function addFrontmcpDependencies(\n tree: Tree,\n dependencies: Record<string, string>,\n devDependencies: Record<string, string> = {},\n options: { keepExistingVersions?: boolean } = {},\n): GeneratorCallback {\n return addDependenciesToPackageJson(tree, dependencies, devDependencies, undefined, options.keepExistingVersions);\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"normalize-options.js","sourceRoot":"","sources":["../../../src/utils/normalize-options.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"normalize-options.js","sourceRoot":"","sources":["../../../src/utils/normalize-options.ts"],"names":[],"mappings":";;AAoBA,8DA+BC;AAnDD,uCAAuE;AAEvE,yCAAwC;AAkBxC,SAAgB,yBAAyB,CACvC,IAAU,EACV,MAA2B,EAC3B,YAAoB;IAEpB,MAAM,QAAQ,GAAG,IAAA,oBAAW,EAAC,IAAI,CAAC,CAAC;IACnC,MAAM,aAAa,GAAG,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IACnD,IAAI,CAAC,aAAa,EAAE,CAAC;QACnB,MAAM,IAAI,KAAK,CAAC,YAAY,MAAM,CAAC,OAAO,+BAA+B,CAAC,CAAC;IAC7E,CAAC;IAED,MAAM,WAAW,GAAG,aAAa,CAAC,IAAI,CAAC;IACvC,MAAM,iBAAiB,GAAG,aAAa,CAAC,UAAU,IAAI,IAAA,0BAAiB,EAAC,WAAW,EAAE,KAAK,CAAC,CAAC;IAC5F,MAAM,QAAQ,GAAG,IAAA,qBAAU,EAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAEzC,MAAM,EAAE,KAAK,EAAE,GAAG,OAAO,CAAC,YAAY,CAAgC,CAAC;IACvE,MAAM,SAAS,GAAG,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,SAAS,CAAC;IAE/C,MAAM,SAAS,GAAG,MAAM,CAAC,SAAS;QAChC,CAAC,CAAC,IAAA,0BAAiB,EAAC,iBAAiB,EAAE,YAAY,EAAE,MAAM,CAAC,SAAS,CAAC;QACtE,CAAC,CAAC,IAAA,0BAAiB,EAAC,iBAAiB,EAAE,YAAY,CAAC,CAAC;IAEvD,OAAO;QACL,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,OAAO,EAAE,MAAM,CAAC,OAAO;QACvB,WAAW;QACX,iBAAiB;QACjB,QAAQ;QACR,SAAS;QACT,SAAS;KACV,CAAC;AACJ,CAAC","sourcesContent":["import { getProjects, joinPathFragments, type Tree } from '@nx/devkit';\n\nimport { toFileName } from './names.js';\n\nexport interface NormalizedPrimitiveOptions {\n name: string;\n project: string;\n projectRoot: string;\n projectSourceRoot: string;\n fileName: string;\n className: string;\n directory: string;\n}\n\nexport interface PrimitiveSchemaBase {\n name: string;\n project: string;\n directory?: string;\n}\n\nexport function normalizePrimitiveOptions(\n tree: Tree,\n schema: PrimitiveSchemaBase,\n subdirectory: string,\n): NormalizedPrimitiveOptions {\n const projects = getProjects(tree);\n const projectConfig = projects.get(schema.project);\n if (!projectConfig) {\n throw new Error(`Project \"${schema.project}\" not found in the workspace.`);\n }\n\n const projectRoot = projectConfig.root;\n const projectSourceRoot = projectConfig.sourceRoot ?? joinPathFragments(projectRoot, 'src');\n const fileName = toFileName(schema.name);\n\n const { names } = require('@nx/devkit') as typeof import('@nx/devkit');\n const className = names(schema.name).className;\n\n const directory = schema.directory\n ? joinPathFragments(projectSourceRoot, subdirectory, schema.directory)\n : joinPathFragments(projectSourceRoot, subdirectory);\n\n return {\n name: schema.name,\n project: schema.project,\n projectRoot,\n projectSourceRoot,\n fileName,\n className,\n directory,\n };\n}\n"]}
|
|
@@ -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,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Json, 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"]}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { type Tree } from '@nx/devkit';
|
|
2
|
+
export interface ProjectPaths {
|
|
3
|
+
/** Project root relative to the Nx workspace root (what project.json must contain). */
|
|
4
|
+
projectRoot: string;
|
|
5
|
+
/** Relative path from the project root back to the workspace root, with a trailing slash. */
|
|
6
|
+
offset: string;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* `directory` is relative to the tree root. When the tree root sits above the
|
|
10
|
+
* workspace (the `workspace` generator scaffolds into `<name>/`), pass that
|
|
11
|
+
* folder as `workspaceRoot` so the paths written into project files are
|
|
12
|
+
* relative to the workspace itself.
|
|
13
|
+
*/
|
|
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';
|
|
18
|
+
/**
|
|
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.
|
|
21
|
+
*/
|
|
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;
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resolveProjectPaths = resolveProjectPaths;
|
|
4
|
+
exports.getTypeScriptMajor = getTypeScriptMajor;
|
|
5
|
+
exports.getModuleResolution = getModuleResolution;
|
|
6
|
+
exports.getProjectTsOptions = getProjectTsOptions;
|
|
7
|
+
exports.addTsPathAlias = addTsPathAlias;
|
|
8
|
+
const fs_1 = require("fs");
|
|
9
|
+
const path_1 = require("path");
|
|
10
|
+
const devkit_1 = require("@nx/devkit");
|
|
11
|
+
function normalizeDirectory(value) {
|
|
12
|
+
let result = value.replace(/\\/g, '/');
|
|
13
|
+
if (result.startsWith('./'))
|
|
14
|
+
result = result.slice(2);
|
|
15
|
+
let end = result.length;
|
|
16
|
+
while (end > 0 && result[end - 1] === '/')
|
|
17
|
+
end--;
|
|
18
|
+
return result.slice(0, end);
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* `directory` is relative to the tree root. When the tree root sits above the
|
|
22
|
+
* workspace (the `workspace` generator scaffolds into `<name>/`), pass that
|
|
23
|
+
* folder as `workspaceRoot` so the paths written into project files are
|
|
24
|
+
* relative to the workspace itself.
|
|
25
|
+
*/
|
|
26
|
+
function resolveProjectPaths(directory, workspaceRoot) {
|
|
27
|
+
const normalized = normalizeDirectory(directory);
|
|
28
|
+
const base = normalizeDirectory(workspaceRoot ?? '');
|
|
29
|
+
const projectRoot = base && normalized.startsWith(`${base}/`) ? normalized.slice(base.length + 1) : normalized;
|
|
30
|
+
return { projectRoot, offset: (0, devkit_1.offsetFromRoot)(projectRoot) };
|
|
31
|
+
}
|
|
32
|
+
/** Major version of the workspace's TypeScript: the installed compiler first, then the declared range. */
|
|
33
|
+
function getTypeScriptMajor(tree, workspaceRoot) {
|
|
34
|
+
const root = workspaceRoot ?? '';
|
|
35
|
+
const installed = (0, path_1.join)(tree.root, root, 'node_modules', 'typescript', 'package.json');
|
|
36
|
+
let range;
|
|
37
|
+
try {
|
|
38
|
+
if ((0, fs_1.existsSync)(installed)) {
|
|
39
|
+
range = JSON.parse((0, fs_1.readFileSync)(installed, 'utf8')).version;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
catch {
|
|
43
|
+
range = undefined;
|
|
44
|
+
}
|
|
45
|
+
if (!range) {
|
|
46
|
+
const pkgPath = (0, path_1.join)(root, 'package.json');
|
|
47
|
+
if (tree.exists(pkgPath)) {
|
|
48
|
+
const pkg = JSON.parse(tree.read(pkgPath, 'utf-8') ?? '{}');
|
|
49
|
+
range = pkg.devDependencies?.['typescript'] ?? pkg.dependencies?.['typescript'];
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
const major = Number(range?.match(/\d+/)?.[0]);
|
|
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
|
+
});
|
|
102
|
+
}
|
|
103
|
+
//# sourceMappingURL=project-paths.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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,GAA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c,CAAC,CAAC;QAClC,CAAC;QACD,eAAe,CAAC,KAAK,GAAG,KAAK,CAAC;QAC9B,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC;QACvC,OAAO,IAAI,CAAC;IACd,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["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
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
export declare function getFrontmcpVersion(): string;
|
|
2
2
|
export declare function getFrontmcpDependencies(): Record<string, string>;
|
|
3
3
|
export declare function getFrontmcpDevDependencies(): Record<string, string>;
|
|
4
|
+
/** What `frontmcp test` and the generated `jest.config.cjs` need in the workspace. */
|
|
5
|
+
export declare function getJestDevDependencies(): Record<string, string>;
|
|
4
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>;
|
|
5
15
|
export declare function getNxDependencies(): Record<string, string>;
|
|
6
16
|
export declare function getNxDevDependencies(): Record<string, string>;
|
package/utils/versions.js
CHANGED
|
@@ -3,12 +3,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.getFrontmcpVersion = getFrontmcpVersion;
|
|
4
4
|
exports.getFrontmcpDependencies = getFrontmcpDependencies;
|
|
5
5
|
exports.getFrontmcpDevDependencies = getFrontmcpDevDependencies;
|
|
6
|
+
exports.getJestDevDependencies = getJestDevDependencies;
|
|
6
7
|
exports.getNxVersion = getNxVersion;
|
|
8
|
+
exports.getEsbuildVersion = getEsbuildVersion;
|
|
9
|
+
exports.getLambdaDependencies = getLambdaDependencies;
|
|
10
|
+
exports.getUiBuildDevDependencies = getUiBuildDevDependencies;
|
|
7
11
|
exports.getNxDependencies = getNxDependencies;
|
|
8
12
|
exports.getNxDevDependencies = getNxDevDependencies;
|
|
9
|
-
const devkit_1 = require("@nx/devkit");
|
|
10
|
-
const path_1 = require("path");
|
|
11
13
|
const fs_1 = require("fs");
|
|
14
|
+
const path_1 = require("path");
|
|
15
|
+
const devkit_1 = require("@nx/devkit");
|
|
12
16
|
let cachedVersion;
|
|
13
17
|
function readPluginVersion() {
|
|
14
18
|
if (cachedVersion)
|
|
@@ -48,10 +52,46 @@ function getFrontmcpDevDependencies() {
|
|
|
48
52
|
'@frontmcp/testing': range,
|
|
49
53
|
};
|
|
50
54
|
}
|
|
55
|
+
/** What `frontmcp test` and the generated `jest.config.cjs` need in the workspace. */
|
|
56
|
+
function getJestDevDependencies() {
|
|
57
|
+
return {
|
|
58
|
+
'@swc/core': '~1.15.8',
|
|
59
|
+
'@swc/helpers': '~0.5.18',
|
|
60
|
+
'@swc/jest': '~0.2.39',
|
|
61
|
+
'@types/jest': '^30.0.0',
|
|
62
|
+
'@types/node': '^24.0.0',
|
|
63
|
+
jest: '^30.0.2',
|
|
64
|
+
};
|
|
65
|
+
}
|
|
51
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';
|
|
52
73
|
function getNxVersion() {
|
|
53
74
|
return NX_VERSION;
|
|
54
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
|
+
}
|
|
55
95
|
function getNxDependencies() {
|
|
56
96
|
return {
|
|
57
97
|
nx: NX_VERSION,
|
|
@@ -65,9 +105,9 @@ function getNxDependencies() {
|
|
|
65
105
|
function getNxDevDependencies() {
|
|
66
106
|
return {
|
|
67
107
|
'@nx/workspace': NX_VERSION,
|
|
68
|
-
'@swc-node/register': '~1.
|
|
69
|
-
'@swc/core': '~1.
|
|
70
|
-
'@swc/helpers': '~0.5.
|
|
108
|
+
'@swc-node/register': '~1.11.1',
|
|
109
|
+
'@swc/core': '~1.15.8',
|
|
110
|
+
'@swc/helpers': '~0.5.18',
|
|
71
111
|
'@swc/jest': '~0.2.39',
|
|
72
112
|
'@types/jest': '^30.0.0',
|
|
73
113
|
'@types/node': '^24.0.0',
|
package/utils/versions.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"versions.js","sourceRoot":"","sources":["../../../src/utils/versions.ts"],"names":[],"mappings":";;
|
|
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;AAG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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,23 +0,0 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
displayName: '<%= projectName %>',
|
|
3
|
-
preset: '../../jest.preset.js',
|
|
4
|
-
testEnvironment: 'node',
|
|
5
|
-
transform: {
|
|
6
|
-
'^.+\\.[tj]s$': ['@swc/jest', {
|
|
7
|
-
jsc: {
|
|
8
|
-
target: 'es2022',
|
|
9
|
-
parser: { syntax: 'typescript', decorators: true, dynamicImport: true },
|
|
10
|
-
transform: { decoratorMetadata: true, legacyDecorator: true },
|
|
11
|
-
keepClassNames: true,
|
|
12
|
-
externalHelpers: true,
|
|
13
|
-
loose: true,
|
|
14
|
-
},
|
|
15
|
-
module: { type: 'es6' },
|
|
16
|
-
sourceMaps: true,
|
|
17
|
-
swcrc: false,
|
|
18
|
-
}],
|
|
19
|
-
},
|
|
20
|
-
moduleFileExtensions: ['ts', 'js', 'html'],
|
|
21
|
-
// Transpile ESM-only deps; the `.pnpm` skip keeps this correct under pnpm (issue #519).
|
|
22
|
-
transformIgnorePatterns: ['node_modules[/\\\\](?!\\.pnpm[/\\\\])(?!(jose)[/\\\\])'],
|
|
23
|
-
};
|
|
@@ -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
|
-
}
|