create-skybridge 0.0.0-dev.f561bc3 → 0.0.0-dev.f762713

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Alpic
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
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) => src !== ".npmrc",
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"));
@@ -115,13 +121,72 @@ export async function init(args = process.argv.slice(2)) {
115
121
  fs.writeFileSync(pkgPath, fixed);
116
122
  }
117
123
  prompts.log.success(`Project created in ${root}`);
118
- prompts.outro(`Done! Next steps:\n\n cd ${targetDir}\n pnpm install\n pnpm dev`);
119
124
  }
120
125
  catch (error) {
121
126
  prompts.log.error("Failed to copy repository");
122
127
  console.error(error);
123
128
  process.exit(1);
124
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
+ }
125
190
  }
126
191
  function sanitizeTargetDir(targetDir) {
127
192
  return (targetDir
@@ -18,10 +18,6 @@ describe("create-skybridge", () => {
18
18
  const name = `../../${tempDirName}//project$`;
19
19
  await init([name]);
20
20
  await fs.access(path.join(process.cwd(), tempDirName, "project", ".gitignore"));
21
- try {
22
- await fs.access(path.join(process.cwd(), tempDirName, "project", ".npmrc"));
23
- expect.fail(".npmrc should not be copied");
24
- }
25
- catch { }
21
+ expect(fs.access(path.join(process.cwd(), tempDirName, "project", ".npmrc"))).rejects.toThrowError();
26
22
  });
27
23
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-skybridge",
3
- "version": "0.0.0-dev.f561bc3",
3
+ "version": "0.0.0-dev.f762713",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "author": "Alpic",
@@ -16,14 +16,6 @@
16
16
  "dist",
17
17
  "template"
18
18
  ],
19
- "scripts": {
20
- "build": "tsc",
21
- "test": "pnpm run test:unit && pnpm run test:type && pnpm run test:format",
22
- "test:unit": "vitest run",
23
- "test:type": "tsc --noEmit",
24
- "test:format": "biome ci",
25
- "prepublishOnly": "pnpm run build"
26
- },
27
19
  "dependencies": {
28
20
  "@clack/prompts": "^0.11.0",
29
21
  "mri": "^1.2.0"
@@ -32,5 +24,12 @@
32
24
  "@types/node": "^25.0.3",
33
25
  "typescript": "^5.9.3",
34
26
  "vitest": "^2.1.9"
27
+ },
28
+ "scripts": {
29
+ "build": "tsc",
30
+ "test": "pnpm run test:unit && pnpm run test:type && pnpm run test:format",
31
+ "test:unit": "vitest run",
32
+ "test:type": "tsc --noEmit",
33
+ "test:format": "biome ci"
35
34
  }
36
- }
35
+ }
@@ -16,8 +16,6 @@
16
16
  },
17
17
  "dependencies": {
18
18
  "@modelcontextprotocol/sdk": "^1.24.3",
19
- "@t3-oss/env-core": "^0.13.8",
20
- "dotenv": "^17.2.3",
21
19
  "express": "^5.1.0",
22
20
  "skybridge": "catalog:",
23
21
  "vite": "^7.1.11",
@@ -1,8 +1,7 @@
1
1
  import express, { type Express } from "express";
2
2
 
3
- import { widgetsDevServer } from "skybridge/server";
3
+ import { devtoolsStaticServer, widgetsDevServer } from "skybridge/server";
4
4
  import type { ViteDevServer } from "vite";
5
- import { env } from "./env.js";
6
5
  import { mcp } from "./middleware.js";
7
6
  import server from "./server.js";
8
7
 
@@ -12,7 +11,10 @@ app.use(express.json());
12
11
 
13
12
  app.use(mcp(server));
14
13
 
15
- if (env.NODE_ENV !== "production") {
14
+ const env = process.env.NODE_ENV || "development";
15
+
16
+ if (env !== "production") {
17
+ app.use(await devtoolsStaticServer());
16
18
  app.use(await widgetsDevServer());
17
19
  }
18
20
 
@@ -22,7 +24,7 @@ app.listen(3000, (error) => {
22
24
  process.exit(1);
23
25
  }
24
26
 
25
- console.log(`Server listening on port 3000 - ${env.NODE_ENV}`);
27
+ console.log(`Server listening on port 3000 - ${env}`);
26
28
  console.log(
27
29
  "Make your local server accessible with 'ngrok http 3000' and connect to ChatGPT with URL https://xxxxxx.ngrok-free.app/mcp",
28
30
  );
@@ -49,20 +49,7 @@ const server = new McpServer(
49
49
  .reduce((acc, char) => acc + char.charCodeAt(0), 0);
50
50
  const answer = Answers[hash % Answers.length];
51
51
  return {
52
- /**
53
- * Arbitrary JSON passed only to the component.
54
- * Use it for data that should not influence the model’s reasoning, like the full set of locations that backs a dropdown.
55
- * _meta is never shown to the model.
56
- */
57
- _meta: {},
58
- /**
59
- * Structured data that is used to hydrate your component.
60
- * ChatGPT injects this object into your iframe as window.openai.toolOutput
61
- */
62
52
  structuredContent: { answer },
63
- /**
64
- * Optional free-form text that the model receives verbatim
65
- */
66
53
  content: [],
67
54
  isError: false,
68
55
  };
@@ -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) return <div>Shaking...</div>;
8
+ if (!output) {
9
+ return <div>Shaking...</div>;
10
+ }
9
11
 
10
12
  return (
11
13
  <div className="container">
@@ -1,12 +0,0 @@
1
- import "dotenv/config";
2
-
3
- import { createEnv } from "@t3-oss/env-core";
4
- import { z } from "zod";
5
-
6
- export const env = createEnv({
7
- server: {
8
- NODE_ENV: z.enum(["development", "production"]).default("development"),
9
- },
10
- runtimeEnv: process.env,
11
- emptyStringAsUndefined: true,
12
- });