create-skybridge 0.0.0-dev.3995b65 → 0.0.0-dev.3fca295
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/dist/index.js +77 -10
- package/package.json +1 -1
- package/template/package.json +10 -27
- package/template/pnpm-workspace.yaml +7 -1
- package/template/server/nodemon.json +5 -0
- package/template/server/package.json +32 -0
- package/template/web/package.json +24 -0
- package/template/web/src/widgets/magic-8-ball.tsx +3 -1
- package/template/web/vite.config.ts +1 -1
- package/template/nodemon.json +0 -5
package/dist/index.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import { spawnSync } from "node:child_process";
|
|
1
2
|
import fs from "node:fs";
|
|
2
3
|
import path from "node:path";
|
|
3
4
|
import { fileURLToPath } from "node:url";
|
|
4
5
|
import * as prompts from "@clack/prompts";
|
|
5
6
|
import mri from "mri";
|
|
7
|
+
const minimumPnpmVersion = 10;
|
|
6
8
|
const defaultProjectName = "skybridge-project";
|
|
7
9
|
// prettier-ignore
|
|
8
10
|
const helpMessage = `\
|
|
@@ -13,20 +15,22 @@ Create a new Skybridge project by copying the starter template.
|
|
|
13
15
|
Options:
|
|
14
16
|
-h, --help show this help message
|
|
15
17
|
--overwrite remove existing files in target directory
|
|
18
|
+
--immediate install dependencies and start development server
|
|
16
19
|
|
|
17
20
|
Examples:
|
|
18
21
|
create-skybridge my-app
|
|
19
|
-
create-skybridge . --overwrite
|
|
22
|
+
create-skybridge . --overwrite --immediate
|
|
20
23
|
`;
|
|
21
24
|
export async function init(args = process.argv.slice(2)) {
|
|
22
25
|
const argv = mri(args, {
|
|
23
|
-
boolean: ["help", "overwrite"],
|
|
26
|
+
boolean: ["help", "overwrite", "immediate"],
|
|
24
27
|
alias: { h: "help" },
|
|
25
28
|
});
|
|
26
29
|
const argTargetDir = argv._[0]
|
|
27
30
|
? sanitizeTargetDir(String(argv._[0]))
|
|
28
31
|
: undefined;
|
|
29
32
|
const argOverwrite = argv.overwrite;
|
|
33
|
+
const argImmediate = argv.immediate;
|
|
30
34
|
const help = argv.help;
|
|
31
35
|
if (help) {
|
|
32
36
|
console.log(helpMessage);
|
|
@@ -48,8 +52,9 @@ export async function init(args = process.argv.slice(2)) {
|
|
|
48
52
|
: "Invalid project name";
|
|
49
53
|
},
|
|
50
54
|
});
|
|
51
|
-
if (prompts.isCancel(projectName))
|
|
55
|
+
if (prompts.isCancel(projectName)) {
|
|
52
56
|
return cancel();
|
|
57
|
+
}
|
|
53
58
|
targetDir = sanitizeTargetDir(projectName);
|
|
54
59
|
}
|
|
55
60
|
else {
|
|
@@ -77,8 +82,9 @@ export async function init(args = process.argv.slice(2)) {
|
|
|
77
82
|
},
|
|
78
83
|
],
|
|
79
84
|
});
|
|
80
|
-
if (prompts.isCancel(res))
|
|
85
|
+
if (prompts.isCancel(res)) {
|
|
81
86
|
return cancel();
|
|
87
|
+
}
|
|
82
88
|
overwrite = res;
|
|
83
89
|
}
|
|
84
90
|
else {
|
|
@@ -102,24 +108,85 @@ export async function init(args = process.argv.slice(2)) {
|
|
|
102
108
|
// Copy template to target directory
|
|
103
109
|
fs.cpSync(templateDir, root, {
|
|
104
110
|
recursive: true,
|
|
105
|
-
filter: (src) =>
|
|
111
|
+
filter: (src) => !src.endsWith(".npmrc"),
|
|
106
112
|
});
|
|
107
113
|
// Rename _gitignore to .gitignore
|
|
108
114
|
fs.renameSync(path.join(root, "_gitignore"), path.join(root, ".gitignore"));
|
|
109
115
|
// Update project name in package.json
|
|
110
116
|
const name = path.basename(root);
|
|
111
|
-
const
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
117
|
+
for (const dir of ["", "server", "web"]) {
|
|
118
|
+
const pkgPath = path.join(root, dir, "package.json");
|
|
119
|
+
const pkg = fs.readFileSync(pkgPath, "utf-8");
|
|
120
|
+
const fixed = pkg.replace(/apps-sdk-template/g, name);
|
|
121
|
+
fs.writeFileSync(pkgPath, fixed);
|
|
122
|
+
}
|
|
115
123
|
prompts.log.success(`Project created in ${root}`);
|
|
116
|
-
prompts.outro(`Done! Next steps:\n\n cd ${targetDir}\n pnpm install\n pnpm dev`);
|
|
117
124
|
}
|
|
118
125
|
catch (error) {
|
|
119
126
|
prompts.log.error("Failed to copy repository");
|
|
120
127
|
console.error(error);
|
|
121
128
|
process.exit(1);
|
|
122
129
|
}
|
|
130
|
+
// 4. Ask about immediate installation
|
|
131
|
+
let immediate = argImmediate;
|
|
132
|
+
if (immediate === undefined) {
|
|
133
|
+
if (interactive) {
|
|
134
|
+
const immediateResult = await prompts.confirm({
|
|
135
|
+
message: `Install with pnpm and start now?`,
|
|
136
|
+
});
|
|
137
|
+
if (prompts.isCancel(immediateResult)) {
|
|
138
|
+
return cancel();
|
|
139
|
+
}
|
|
140
|
+
immediate = immediateResult;
|
|
141
|
+
}
|
|
142
|
+
else {
|
|
143
|
+
immediate = false;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
const installCmd = ["pnpm", "install"];
|
|
147
|
+
const runCmd = ["pnpm", "dev"];
|
|
148
|
+
if (!immediate) {
|
|
149
|
+
prompts.outro(`Done! Next steps:
|
|
150
|
+
cd ${targetDir}
|
|
151
|
+
${installCmd.join(" ")}
|
|
152
|
+
${runCmd.join(" ")}
|
|
153
|
+
`);
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
// check if pnpm is installed
|
|
157
|
+
const result = spawnSync("pnpm", ["--version"], { encoding: "utf-8" });
|
|
158
|
+
if (result.error || result.status !== 0) {
|
|
159
|
+
console.error("Error: pnpm is not installed. Please install pnpm first.");
|
|
160
|
+
process.exit(1);
|
|
161
|
+
}
|
|
162
|
+
// check if pnpm major is greater or equal to the one set in package.json packageManager, which should do the trick
|
|
163
|
+
const version = result.stdout.trim();
|
|
164
|
+
const major = Number(version.split(".")[0]);
|
|
165
|
+
if (Number.isNaN(major) || major < minimumPnpmVersion) {
|
|
166
|
+
console.error(`Error: pnpm version ${version} is too old. Minimum required version is ${minimumPnpmVersion}.`);
|
|
167
|
+
process.exit(1);
|
|
168
|
+
}
|
|
169
|
+
prompts.log.step(`Installing dependencies with pnpm...`);
|
|
170
|
+
run(installCmd, {
|
|
171
|
+
stdio: "inherit",
|
|
172
|
+
cwd: root,
|
|
173
|
+
});
|
|
174
|
+
prompts.log.step("Starting dev server...");
|
|
175
|
+
run(runCmd, {
|
|
176
|
+
stdio: "inherit",
|
|
177
|
+
cwd: root,
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
function run([command, ...args], options) {
|
|
181
|
+
const { status, error } = spawnSync(command, args, options);
|
|
182
|
+
if (status != null && status > 0) {
|
|
183
|
+
process.exit(status);
|
|
184
|
+
}
|
|
185
|
+
if (error) {
|
|
186
|
+
console.error(`\n${command} ${args.join(" ")} error!`);
|
|
187
|
+
console.error(error);
|
|
188
|
+
process.exit(1);
|
|
189
|
+
}
|
|
123
190
|
}
|
|
124
191
|
function sanitizeTargetDir(targetDir) {
|
|
125
192
|
return (targetDir
|
package/package.json
CHANGED
package/template/package.json
CHANGED
|
@@ -4,35 +4,18 @@
|
|
|
4
4
|
"private": true,
|
|
5
5
|
"description": "Alpic MCP Server Template",
|
|
6
6
|
"type": "module",
|
|
7
|
+
"packageManager": "pnpm@10.18.3",
|
|
7
8
|
"scripts": {
|
|
8
|
-
"dev": "
|
|
9
|
-
"build": "
|
|
10
|
-
"start": "
|
|
11
|
-
"inspector": "
|
|
12
|
-
"server:build": "
|
|
13
|
-
"server:start": "
|
|
14
|
-
"web:build": "
|
|
15
|
-
"web:preview": "
|
|
16
|
-
},
|
|
17
|
-
"dependencies": {
|
|
18
|
-
"@modelcontextprotocol/sdk": "^1.24.3",
|
|
19
|
-
"express": "^5.1.0",
|
|
20
|
-
"react": "^19.1.1",
|
|
21
|
-
"react-dom": "^19.1.1",
|
|
22
|
-
"skybridge": "0.15.3",
|
|
23
|
-
"vite": "^7.1.11",
|
|
24
|
-
"zod": "^4.1.13"
|
|
9
|
+
"dev": "pnpm --filter @apps-sdk-template/server dev",
|
|
10
|
+
"build": "pnpm web:build && rm -rf server/dist && pnpm --filter=@apps-sdk-template/server --prod deploy server/dist && cp -r web/dist server/dist/assets && pnpm --filter=@apps-sdk-template/server build",
|
|
11
|
+
"start": "pnpm server:start",
|
|
12
|
+
"inspector": "pnpm --filter @apps-sdk-template/server inspector",
|
|
13
|
+
"server:build": "pnpm --filter @apps-sdk-template/server build",
|
|
14
|
+
"server:start": "pnpm --filter @apps-sdk-template/server start",
|
|
15
|
+
"web:build": "pnpm --filter @apps-sdk-template/web build",
|
|
16
|
+
"web:preview": "pnpm --filter @apps-sdk-template/web preview"
|
|
25
17
|
},
|
|
26
18
|
"devDependencies": {
|
|
27
|
-
"
|
|
28
|
-
"@types/express": "^5.0.3",
|
|
29
|
-
"@types/node": "^22.15.30",
|
|
30
|
-
"@types/react": "^19.1.16",
|
|
31
|
-
"@types/react-dom": "^19.1.9",
|
|
32
|
-
"@vitejs/plugin-react": "^5.0.4",
|
|
33
|
-
"nodemon": "^3.1.10",
|
|
34
|
-
"shx": "^0.3.4",
|
|
35
|
-
"tsx": "^4.19.4",
|
|
36
|
-
"typescript": "^5.7.2"
|
|
19
|
+
"tsx": "^4.19.4"
|
|
37
20
|
}
|
|
38
21
|
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@apps-sdk-template/server",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"private": true,
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"description": "Alpic MCP Server Template",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist"
|
|
9
|
+
],
|
|
10
|
+
"type": "module",
|
|
11
|
+
"scripts": {
|
|
12
|
+
"dev": "nodemon",
|
|
13
|
+
"build": "tsc",
|
|
14
|
+
"start": "node dist/index.js",
|
|
15
|
+
"inspector": "mcp-inspector http://localhost:3000/mcp"
|
|
16
|
+
},
|
|
17
|
+
"dependencies": {
|
|
18
|
+
"@modelcontextprotocol/sdk": "^1.24.3",
|
|
19
|
+
"express": "^5.1.0",
|
|
20
|
+
"skybridge": "catalog:",
|
|
21
|
+
"vite": "^7.1.11",
|
|
22
|
+
"zod": "^4.1.13"
|
|
23
|
+
},
|
|
24
|
+
"devDependencies": {
|
|
25
|
+
"@modelcontextprotocol/inspector": "^0.17.5",
|
|
26
|
+
"@types/express": "^5.0.3",
|
|
27
|
+
"@types/node": "^22.15.30",
|
|
28
|
+
"nodemon": "^3.1.10",
|
|
29
|
+
"tsx": "^4.19.2",
|
|
30
|
+
"typescript": "^5.7.2"
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@apps-sdk-template/web",
|
|
3
|
+
"private": true,
|
|
4
|
+
"version": "0.0.0",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"dev": "echo 'Not implemented",
|
|
8
|
+
"build": "tsc -b && vite build",
|
|
9
|
+
"preview": "vite preview"
|
|
10
|
+
},
|
|
11
|
+
"dependencies": {
|
|
12
|
+
"skybridge": "catalog:",
|
|
13
|
+
"react": "^19.1.1",
|
|
14
|
+
"react-dom": "^19.1.1"
|
|
15
|
+
},
|
|
16
|
+
"devDependencies": {
|
|
17
|
+
"@types/node": "^24.6.0",
|
|
18
|
+
"@types/react": "^19.1.16",
|
|
19
|
+
"@types/react-dom": "^19.1.9",
|
|
20
|
+
"@vitejs/plugin-react": "^5.0.4",
|
|
21
|
+
"typescript": "~5.9.3",
|
|
22
|
+
"vite": "^7.1.11"
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -5,7 +5,9 @@ import { useToolInfo } from "../helpers";
|
|
|
5
5
|
|
|
6
6
|
function Magic8Ball() {
|
|
7
7
|
const { input, output } = useToolInfo<"magic-8-ball">();
|
|
8
|
-
if (!output)
|
|
8
|
+
if (!output) {
|
|
9
|
+
return <div>Shaking...</div>;
|
|
10
|
+
}
|
|
9
11
|
|
|
10
12
|
return (
|
|
11
13
|
<div className="container">
|