@mcp-tool-kit/shared 0.0.2 → 0.0.4
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/README.md +17 -0
- package/dist/index.js +3 -1
- package/dist/projectSetup.js +62 -2
- package/dist/types/index.d.ts +0 -1
- package/package.json +2 -4
- package/dist/projectSetup.js.map +0 -1
- package/dist/string.js +0 -2
- package/dist/string.js.map +0 -1
- package/dist/types/string.d.ts +0 -1
package/README.md
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
# create-mcp-kit
|
|
2
2
|
A CLI tool to create MCP (Model Context Protocol) applications with ease.
|
|
3
3
|
|
|
4
|
+
[![][npm-release-shield]][npm-release-link]
|
|
5
|
+
[![][codecov-shield]][codecov-link]
|
|
6
|
+
[![][github-release-date-shield]][github-release-date-link]
|
|
7
|
+
[![][github-action-build-shield]][github-action-build-link]
|
|
8
|
+
[![][github-license-shield]][github-license-link]
|
|
9
|
+
|
|
4
10
|
## Features
|
|
5
11
|
- 🚀 Quick project scaffolding
|
|
6
12
|
- 📦 TypeScript support out of the box
|
|
@@ -123,3 +129,14 @@ This project exists thanks to all the people who contribute.
|
|
|
123
129
|
## License
|
|
124
130
|
|
|
125
131
|
[MIT](LICENSE) © MichaelSun
|
|
132
|
+
|
|
133
|
+
[npm-release-link]: https://www.npmjs.com/package/create-mcp-kit
|
|
134
|
+
[npm-release-shield]: https://img.shields.io/npm/v/create-mcp-kit?color=1677FF&labelColor=black&logo=npm&logoColor=white&style=flat-square
|
|
135
|
+
[codecov-link]: https://coveralls.io/github/my-mcp-hub/mcp-kit?branch=main
|
|
136
|
+
[codecov-shield]: https://img.shields.io/coverallsCoverage/github/my-mcp-hub/mcp-kit?color=1677FF&labelColor=black&style=flat-square&logo=codecov&logoColor=white
|
|
137
|
+
[github-release-date-link]: https://github.com/my-mcp-hub/mcp-kit/releases
|
|
138
|
+
[github-release-date-shield]: https://img.shields.io/github/release-date/my-mcp-hub/mcp-kit?color=1677FF&labelColor=black&style=flat-square
|
|
139
|
+
[github-action-build-link]: https://github.com/my-mcp-hub/mcp-kit/actions/workflows/build.yml
|
|
140
|
+
[github-action-build-shield]: https://img.shields.io/github/actions/workflow/status/my-mcp-hub/mcp-kit/build.yml?branch=main&color=1677FF&label=build&labelColor=black&logo=githubactions&logoColor=white&style=flat-square
|
|
141
|
+
[github-license-link]: https://github.com/my-mcp-hub/mcp-kit/blob/main/LICENSE
|
|
142
|
+
[github-license-shield]: https://img.shields.io/github/license/my-mcp-hub/mcp-kit?color=1677FF&labelColor=black&style=flat-square
|
package/dist/index.js
CHANGED
|
@@ -1 +1,3 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import { createProject, installDependencies, sleep } from "./projectSetup.js";
|
|
2
|
+
|
|
3
|
+
export { createProject, installDependencies, sleep };
|
package/dist/projectSetup.js
CHANGED
|
@@ -1,2 +1,62 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import { setTimeout as sleep } from "timers/promises";
|
|
2
|
+
import { cp, mkdir, readFile, readdir, rename, stat, writeFile } from "fs/promises";
|
|
3
|
+
import path from "path";
|
|
4
|
+
import { spawn } from "child_process";
|
|
5
|
+
|
|
6
|
+
//#region src/projectSetup.ts
|
|
7
|
+
async function renameFiles(currentDir) {
|
|
8
|
+
const renameMap = {
|
|
9
|
+
_env: ".env",
|
|
10
|
+
_gitignore: ".gitignore",
|
|
11
|
+
_git: ".git",
|
|
12
|
+
_nvmrc: ".nvmrc",
|
|
13
|
+
_prettierrc: ".prettierrc",
|
|
14
|
+
_husky: ".husky",
|
|
15
|
+
_github: ".github"
|
|
16
|
+
};
|
|
17
|
+
const items = await readdir(currentDir, { recursive: true });
|
|
18
|
+
for (const item of items) {
|
|
19
|
+
if (!(item in renameMap)) continue;
|
|
20
|
+
await rename(path.join(currentDir, item), path.join(currentDir, renameMap[item]));
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
async function replaceVariables(currentDir, replacements) {
|
|
24
|
+
const variables = {
|
|
25
|
+
"{{PROJECT_NAME}}": replacements.projectName,
|
|
26
|
+
"{{YEAR}}": (/* @__PURE__ */ new Date()).getFullYear().toString()
|
|
27
|
+
};
|
|
28
|
+
const items = await readdir(currentDir, { recursive: true });
|
|
29
|
+
for (const item of items) {
|
|
30
|
+
const itemPath = path.join(currentDir, item);
|
|
31
|
+
const itemStat = await stat(itemPath);
|
|
32
|
+
if (itemStat.isDirectory()) continue;
|
|
33
|
+
for (const [key, value] of Object.entries(variables)) {
|
|
34
|
+
const content = await readFile(itemPath, "utf-8");
|
|
35
|
+
const regex = new RegExp(key, "g");
|
|
36
|
+
const newContent = content.replace(regex, value);
|
|
37
|
+
await writeFile(itemPath, newContent, "utf-8");
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
function installDependencies(currentDir) {
|
|
42
|
+
return new Promise((resolve, reject) => {
|
|
43
|
+
const npm = spawn("npm", ["install"], {
|
|
44
|
+
cwd: currentDir,
|
|
45
|
+
stdio: "pipe"
|
|
46
|
+
});
|
|
47
|
+
npm.on("close", (code) => {
|
|
48
|
+
if (code === 0) resolve();
|
|
49
|
+
else reject(/* @__PURE__ */ new Error(`npm install failed with code ${code}`));
|
|
50
|
+
});
|
|
51
|
+
npm.on("error", reject);
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
async function createProject(targetPath, templatePath, replacements) {
|
|
55
|
+
await mkdir(targetPath, { recursive: true });
|
|
56
|
+
await cp(templatePath, targetPath, { recursive: true });
|
|
57
|
+
await renameFiles(targetPath);
|
|
58
|
+
await replaceVariables(targetPath, replacements);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
//#endregion
|
|
62
|
+
export { createProject, installDependencies, sleep };
|
package/dist/types/index.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mcp-tool-kit/shared",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4",
|
|
4
4
|
"description": "mcp tool kit shared",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": "zhensherlock",
|
|
@@ -40,8 +40,6 @@
|
|
|
40
40
|
"scripts": {
|
|
41
41
|
"clean:dist": "rimraf dist",
|
|
42
42
|
"build:types": "tsc",
|
|
43
|
-
"build": "npm run clean:dist && npm run build:types && rolldown -c rolldown.config.ts"
|
|
44
|
-
"test": "vitest run",
|
|
45
|
-
"coverage": "rimraf coverage && vitest run --coverage"
|
|
43
|
+
"build": "cross-env NODE_ENV=production && npm run clean:dist && npm run build:types && rolldown -c rolldown.config.ts"
|
|
46
44
|
}
|
|
47
45
|
}
|
package/dist/projectSetup.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"projectSetup.js","names":[],"sources":["../../src/projectSetup.ts"],"sourcesContent":[],"mappings":"mNAkDA,SAAgB,EAAoB,GAClC,OAAO,IAAI,QAAc,CAAC,EAAS,KACjC,MAAM,EAAM,EAAM,MAAO,CAAC,WAAY,CACpC,IAAK,EACL,MAAO,SAGT,EAAI,GAAG,QAAS,IACD,IAAT,EACF,IAEA,EAAO,IAAI,MAAM,gCAAgC,QAIrD,EAAI,GAAG,QAAS,IAEnB,CAED,eAAsB,EACpB,EACA,EACA,SAIM,EAAM,EAAY,CAAE,WAAW,UAC/B,EAAG,EAAc,EAAY,CAAE,WAAW,UAxElD,eAA2B,GACzB,MAAM,EAAY,CAChB,KAAM,OACN,WAAY,aACZ,KAAM,OACN,OAAQ,SACR,YAAa,cACb,OAAQ,SACR,QAAS,WAEL,QAAc,EAAQ,EAAY,CAAE,WAAW,IACrD,IAAK,MAAM,KAAQ,EACX,KAAQ,SAGR,EAAO,EAAK,KAAK,EAAY,GAAO,EAAK,KAAK,EAAY,EAAU,IAE7E,CAwDO,CAAY,SAtDpB,eACE,EACA,GAIA,MAAM,EAAY,CAChB,mBAAoB,EAAa,YACjC,YAAY,IAAI,MAAO,cAAc,YAEjC,QAAc,EAAQ,EAAY,CAAE,WAAW,IACrD,IAAK,MAAM,KAAQ,EAAO,CACxB,MAAM,EAAW,EAAK,KAAK,EAAY,GAEvC,WADuB,EAAK,IACf,cAGb,IAAK,MAAO,EAAK,KAAU,OAAO,QAAQ,GAAY,CACpD,MAAM,QAAgB,EAAS,EAAU,SACnC,EAAQ,IAAI,OAAO,EAAK,KACxB,EAAa,EAAQ,QAAQ,EAAO,SACpC,EAAU,EAAU,EAAY,QACvC,CACF,CACF,CA+BO,CAAiB,EAAY,EACpC"}
|
package/dist/string.js
DELETED
package/dist/string.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"string.js","names":[],"sources":["../../src/string.ts"],"sourcesContent":[],"mappings":"AAAA,SAAgB,EAAS,GACvB,MAAwB,iBAAV,CACf"}
|
package/dist/types/string.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function isString(value: any): boolean;
|