create-skybridge 0.0.0-dev.e93283d → 0.0.0-dev.ec66479
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 +71 -6
- package/package.json +1 -1
- package/template/README.md +12 -1
- package/template/package.json +6 -4
- package/template/tsconfig.json +23 -0
- package/template/tsconfig.server.json +11 -0
- package/template/web/src/widgets/magic-8-ball.tsx +3 -1
- package/template/pnpm-workspace.yaml +0 -1
- package/template/server/tsconfig.json +0 -17
- package/template/web/tsconfig.app.json +0 -34
- package/template/web/tsconfig.json +0 -13
- package/template/web/tsconfig.node.json +0 -26
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,7 +108,7 @@ 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) => [".npmrc"
|
|
111
|
+
filter: (src) => [".npmrc"].every((file) => !src.endsWith(file)),
|
|
106
112
|
});
|
|
107
113
|
// Rename _gitignore to .gitignore
|
|
108
114
|
fs.renameSync(path.join(root, "_gitignore"), path.join(root, ".gitignore"));
|
|
@@ -113,13 +119,72 @@ export async function init(args = process.argv.slice(2)) {
|
|
|
113
119
|
const fixed = pkg.replace(/apps-sdk-template/g, name);
|
|
114
120
|
fs.writeFileSync(pkgPath, fixed);
|
|
115
121
|
prompts.log.success(`Project created in ${root}`);
|
|
116
|
-
prompts.outro(`Done! Next steps:\n\n cd ${targetDir}\n pnpm install\n pnpm dev`);
|
|
117
122
|
}
|
|
118
123
|
catch (error) {
|
|
119
124
|
prompts.log.error("Failed to copy repository");
|
|
120
125
|
console.error(error);
|
|
121
126
|
process.exit(1);
|
|
122
127
|
}
|
|
128
|
+
// 4. Ask about immediate installation
|
|
129
|
+
let immediate = argImmediate;
|
|
130
|
+
if (immediate === undefined) {
|
|
131
|
+
if (interactive) {
|
|
132
|
+
const immediateResult = await prompts.confirm({
|
|
133
|
+
message: `Install with pnpm and start now?`,
|
|
134
|
+
});
|
|
135
|
+
if (prompts.isCancel(immediateResult)) {
|
|
136
|
+
return cancel();
|
|
137
|
+
}
|
|
138
|
+
immediate = immediateResult;
|
|
139
|
+
}
|
|
140
|
+
else {
|
|
141
|
+
immediate = false;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
const installCmd = ["pnpm", "install"];
|
|
145
|
+
const runCmd = ["pnpm", "dev"];
|
|
146
|
+
if (!immediate) {
|
|
147
|
+
prompts.outro(`Done! Next steps:
|
|
148
|
+
cd ${targetDir}
|
|
149
|
+
${installCmd.join(" ")}
|
|
150
|
+
${runCmd.join(" ")}
|
|
151
|
+
`);
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
// check if pnpm is installed
|
|
155
|
+
const result = spawnSync("pnpm", ["--version"], { encoding: "utf-8" });
|
|
156
|
+
if (result.error || result.status !== 0) {
|
|
157
|
+
console.error("Error: pnpm is not installed. Please install pnpm first.");
|
|
158
|
+
process.exit(1);
|
|
159
|
+
}
|
|
160
|
+
// check if pnpm major is greater or equal to the one set in package.json packageManager, which should do the trick
|
|
161
|
+
const version = result.stdout.trim();
|
|
162
|
+
const major = Number(version.split(".")[0]);
|
|
163
|
+
if (Number.isNaN(major) || major < minimumPnpmVersion) {
|
|
164
|
+
console.error(`Error: pnpm version ${version} is too old. Minimum required version is ${minimumPnpmVersion}.`);
|
|
165
|
+
process.exit(1);
|
|
166
|
+
}
|
|
167
|
+
prompts.log.step(`Installing dependencies with pnpm...`);
|
|
168
|
+
run(installCmd, {
|
|
169
|
+
stdio: "inherit",
|
|
170
|
+
cwd: root,
|
|
171
|
+
});
|
|
172
|
+
prompts.log.step("Starting dev server...");
|
|
173
|
+
run(runCmd, {
|
|
174
|
+
stdio: "inherit",
|
|
175
|
+
cwd: root,
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
function run([command, ...args], options) {
|
|
179
|
+
const { status, error } = spawnSync(command, args, options);
|
|
180
|
+
if (status != null && status > 0) {
|
|
181
|
+
process.exit(status);
|
|
182
|
+
}
|
|
183
|
+
if (error) {
|
|
184
|
+
console.error(`\n${command} ${args.join(" ")} error!`);
|
|
185
|
+
console.error(error);
|
|
186
|
+
process.exit(1);
|
|
187
|
+
}
|
|
123
188
|
}
|
|
124
189
|
function sanitizeTargetDir(targetDir) {
|
|
125
190
|
return (targetDir
|
package/package.json
CHANGED
package/template/README.md
CHANGED
|
@@ -7,7 +7,6 @@ A minimal TypeScript template for building OpenAI Apps SDK compatible MCP server
|
|
|
7
7
|
### Prerequisites
|
|
8
8
|
|
|
9
9
|
- Node.js 22+
|
|
10
|
-
- pnpm (install with `npm install -g pnpm`)
|
|
11
10
|
- HTTP tunnel such as [ngrok](https://ngrok.com/download)
|
|
12
11
|
|
|
13
12
|
### Local Development
|
|
@@ -15,7 +14,13 @@ A minimal TypeScript template for building OpenAI Apps SDK compatible MCP server
|
|
|
15
14
|
#### 1. Install
|
|
16
15
|
|
|
17
16
|
```bash
|
|
17
|
+
npm install
|
|
18
|
+
# or
|
|
19
|
+
yarn install
|
|
20
|
+
# or
|
|
18
21
|
pnpm install
|
|
22
|
+
# or
|
|
23
|
+
bun install
|
|
19
24
|
```
|
|
20
25
|
|
|
21
26
|
#### 2. Start your local server
|
|
@@ -23,7 +28,13 @@ pnpm install
|
|
|
23
28
|
Run the development server from the root directory:
|
|
24
29
|
|
|
25
30
|
```bash
|
|
31
|
+
npm run dev
|
|
32
|
+
# or
|
|
33
|
+
yarn dev
|
|
34
|
+
# or
|
|
26
35
|
pnpm dev
|
|
36
|
+
# or
|
|
37
|
+
bun dev
|
|
27
38
|
```
|
|
28
39
|
|
|
29
40
|
This command starts an Express server on port 3000. This server packages:
|
package/template/package.json
CHANGED
|
@@ -6,10 +6,10 @@
|
|
|
6
6
|
"type": "module",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"dev": "nodemon",
|
|
9
|
-
"build": "
|
|
9
|
+
"build": "vite build -c web/vite.config.ts && shx rm -rf server/dist && tsc -p tsconfig.server.json && shx cp -r web/dist server/dist/assets",
|
|
10
10
|
"start": "node server/dist/index.js",
|
|
11
11
|
"inspector": "mcp-inspector http://localhost:3000/mcp",
|
|
12
|
-
"server:build": "tsc -p
|
|
12
|
+
"server:build": "tsc -p tsconfig.server.json",
|
|
13
13
|
"server:start": "node server/dist/index.js",
|
|
14
14
|
"web:build": "tsc -b web && vite build -c web/vite.config.ts",
|
|
15
15
|
"web:preview": "vite preview -c web/vite.config.ts"
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"express": "^5.1.0",
|
|
20
20
|
"react": "^19.1.1",
|
|
21
21
|
"react-dom": "^19.1.1",
|
|
22
|
-
"skybridge": "0.15.3",
|
|
22
|
+
"skybridge": "^0.15.3",
|
|
23
23
|
"vite": "^7.1.11",
|
|
24
24
|
"zod": "^4.1.13"
|
|
25
25
|
},
|
|
@@ -31,7 +31,9 @@
|
|
|
31
31
|
"@types/react-dom": "^19.1.9",
|
|
32
32
|
"@vitejs/plugin-react": "^5.0.4",
|
|
33
33
|
"nodemon": "^3.1.10",
|
|
34
|
+
"shx": "^0.3.4",
|
|
34
35
|
"tsx": "^4.19.4",
|
|
35
36
|
"typescript": "^5.7.2"
|
|
36
|
-
}
|
|
37
|
+
},
|
|
38
|
+
"workspaces": []
|
|
37
39
|
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"module": "ESNext",
|
|
5
|
+
"moduleResolution": "bundler",
|
|
6
|
+
"lib": ["ES2022", "DOM", "DOM.Iterable"],
|
|
7
|
+
"jsx": "react-jsx",
|
|
8
|
+
|
|
9
|
+
"strict": true,
|
|
10
|
+
"skipLibCheck": true,
|
|
11
|
+
"esModuleInterop": true,
|
|
12
|
+
"forceConsistentCasingInFileNames": true,
|
|
13
|
+
"verbatimModuleSyntax": true,
|
|
14
|
+
|
|
15
|
+
"noUnusedLocals": true,
|
|
16
|
+
"noUnusedParameters": true,
|
|
17
|
+
"noFallthroughCasesInSwitch": true,
|
|
18
|
+
|
|
19
|
+
"noEmit": true
|
|
20
|
+
},
|
|
21
|
+
"include": ["server/src", "web/src", "web/vite.config.ts"],
|
|
22
|
+
"exclude": ["dist", "node_modules"]
|
|
23
|
+
}
|
|
@@ -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">
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
sharedWorkspaceLockfile: false
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "ESNext",
|
|
4
|
-
"module": "ESNext",
|
|
5
|
-
"moduleResolution": "bundler",
|
|
6
|
-
"esModuleInterop": true,
|
|
7
|
-
"strict": true,
|
|
8
|
-
"skipLibCheck": true,
|
|
9
|
-
"forceConsistentCasingInFileNames": true,
|
|
10
|
-
"outDir": "dist",
|
|
11
|
-
"sourceMap": true,
|
|
12
|
-
"jsx": "react",
|
|
13
|
-
"inlineSources": true
|
|
14
|
-
},
|
|
15
|
-
"include": ["**/*.ts", "**/*.tsx"],
|
|
16
|
-
"exclude": ["dist", "node_modules"]
|
|
17
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
|
|
4
|
-
"target": "ES2022",
|
|
5
|
-
"useDefineForClassFields": true,
|
|
6
|
-
"lib": ["ES2022", "DOM", "DOM.Iterable"],
|
|
7
|
-
"module": "ESNext",
|
|
8
|
-
"types": ["vite/client"],
|
|
9
|
-
"skipLibCheck": true,
|
|
10
|
-
|
|
11
|
-
/* Bundler mode */
|
|
12
|
-
"moduleResolution": "bundler",
|
|
13
|
-
"allowImportingTsExtensions": true,
|
|
14
|
-
"verbatimModuleSyntax": true,
|
|
15
|
-
"moduleDetection": "force",
|
|
16
|
-
"noEmit": true,
|
|
17
|
-
"jsx": "react-jsx",
|
|
18
|
-
|
|
19
|
-
/* Linting */
|
|
20
|
-
"strict": true,
|
|
21
|
-
"noUnusedLocals": true,
|
|
22
|
-
"noUnusedParameters": true,
|
|
23
|
-
"erasableSyntaxOnly": true,
|
|
24
|
-
"noFallthroughCasesInSwitch": true,
|
|
25
|
-
"noUncheckedSideEffectImports": true,
|
|
26
|
-
|
|
27
|
-
/* Shadcn Config */
|
|
28
|
-
"baseUrl": ".",
|
|
29
|
-
"paths": {
|
|
30
|
-
"@/*": ["./src/*"]
|
|
31
|
-
}
|
|
32
|
-
},
|
|
33
|
-
"include": ["src"]
|
|
34
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
|
|
4
|
-
"target": "ES2023",
|
|
5
|
-
"lib": ["ES2023"],
|
|
6
|
-
"module": "ESNext",
|
|
7
|
-
"types": ["node"],
|
|
8
|
-
"skipLibCheck": true,
|
|
9
|
-
|
|
10
|
-
/* Bundler mode */
|
|
11
|
-
"moduleResolution": "bundler",
|
|
12
|
-
"allowImportingTsExtensions": true,
|
|
13
|
-
"verbatimModuleSyntax": true,
|
|
14
|
-
"moduleDetection": "force",
|
|
15
|
-
"noEmit": true,
|
|
16
|
-
|
|
17
|
-
/* Linting */
|
|
18
|
-
"strict": true,
|
|
19
|
-
"noUnusedLocals": true,
|
|
20
|
-
"noUnusedParameters": true,
|
|
21
|
-
"erasableSyntaxOnly": true,
|
|
22
|
-
"noFallthroughCasesInSwitch": true,
|
|
23
|
-
"noUncheckedSideEffectImports": true
|
|
24
|
-
},
|
|
25
|
-
"include": ["vite.config.ts"]
|
|
26
|
-
}
|