create-skybridge 0.0.0-dev.148f1f6 → 0.0.0-dev.149fe9f
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 +317 -213
- package/package.json +8 -7
- package/templates/blank/.dockerignore +4 -0
- package/templates/blank/AGENTS.md +1 -0
- package/templates/blank/Dockerfile +53 -0
- package/templates/blank/README.md +92 -0
- package/{template → templates/blank}/_gitignore +2 -1
- package/templates/blank/node_modules/.bin/alpic +21 -0
- package/templates/blank/node_modules/.bin/sb +21 -0
- package/templates/blank/node_modules/.bin/skybridge +21 -0
- package/{template → templates/blank}/node_modules/.bin/tsc +2 -2
- package/{template → templates/blank}/node_modules/.bin/tsserver +2 -2
- package/templates/blank/node_modules/.bin/vite +21 -0
- package/templates/blank/package.json +28 -0
- package/templates/blank/src/helpers.ts +4 -0
- package/templates/blank/src/server.ts +21 -0
- package/templates/blank/src/vite-manifest.d.ts +4 -0
- package/templates/blank/tsconfig.json +5 -0
- package/templates/blank/vite.config.ts +6 -0
- package/templates/demo/.dockerignore +4 -0
- package/templates/demo/AGENTS.md +1 -0
- package/templates/demo/Dockerfile +53 -0
- package/templates/demo/README.md +95 -0
- package/templates/demo/_gitignore +6 -0
- package/templates/demo/alpic.json +3 -0
- package/templates/demo/node_modules/.bin/alpic +21 -0
- package/templates/demo/node_modules/.bin/sb +21 -0
- package/templates/demo/node_modules/.bin/skybridge +21 -0
- package/templates/demo/node_modules/.bin/tsc +21 -0
- package/templates/demo/node_modules/.bin/tsserver +21 -0
- package/templates/demo/node_modules/.bin/vite +21 -0
- package/{template → templates/demo}/package.json +16 -8
- package/templates/demo/src/helpers.ts +4 -0
- package/templates/demo/src/index.css +59 -0
- package/templates/demo/src/server.ts +77 -0
- package/templates/demo/src/views/components/doc-link.tsx +22 -0
- package/templates/demo/src/views/components/doc.tsx +21 -0
- package/templates/demo/src/views/components/nav.tsx +31 -0
- package/templates/demo/src/views/components/progress.tsx +35 -0
- package/templates/demo/src/views/components/steps/outro.tsx +68 -0
- package/templates/demo/src/views/components/steps/state.tsx +47 -0
- package/templates/demo/src/views/components/steps/tool-call.tsx +53 -0
- package/templates/demo/src/views/components/steps/tool-output.tsx +40 -0
- package/templates/demo/src/views/images/mascot/beret.png +0 -0
- package/templates/demo/src/views/images/mascot/chapka.png +0 -0
- package/templates/demo/src/views/images/mascot/cowboy-hat.png +0 -0
- package/templates/demo/src/views/images/mascot/fez.png +0 -0
- package/templates/demo/src/views/images/mascot/jester-hat.png +0 -0
- package/templates/demo/src/views/images/mascot/mitre.png +0 -0
- package/templates/demo/src/views/images/mascot/non-la.png +0 -0
- package/templates/demo/src/views/images/mascot/original.png +0 -0
- package/templates/demo/src/views/images/mascot/propeller-beanie.png +0 -0
- package/templates/demo/src/views/images/mascot/ski-mask.png +0 -0
- package/templates/demo/src/views/images/mascot/sombrero.png +0 -0
- package/templates/demo/src/views/images/mascot/top-hat.png +0 -0
- package/templates/demo/src/views/images/mascot/viking-helmet.png +0 -0
- package/templates/demo/src/views/onboarding.tsx +63 -0
- package/templates/demo/src/views/use-mascot.ts +60 -0
- package/templates/demo/src/vite-manifest.d.ts +4 -0
- package/templates/demo/tsconfig.json +11 -0
- package/templates/demo/vite.config.ts +14 -0
- package/dist/index.test.d.ts +0 -1
- package/dist/index.test.js +0 -33
- package/template/AGENTS.md +0 -1
- package/template/README.md +0 -97
- package/template/node_modules/.bin/alpic +0 -21
- package/template/node_modules/.bin/sb +0 -21
- package/template/node_modules/.bin/skybridge +0 -21
- package/template/node_modules/.bin/vite +0 -21
- package/template/server/src/index.ts +0 -62
- package/template/tsconfig.json +0 -9
- package/template/web/src/helpers.ts +0 -4
- package/template/web/src/index.css +0 -154
- package/template/web/src/widgets/magic-8-ball.tsx +0 -27
- package/template/web/vite.config.ts +0 -15
- /package/{template → templates/blank}/alpic.json +0 -0
- /package/{template → templates/demo}/node_modules/.bin/tsx +0 -0
package/dist/index.js
CHANGED
|
@@ -1,251 +1,369 @@
|
|
|
1
|
-
import { spawnSync } from "node:child_process";
|
|
2
1
|
import fs from "node:fs";
|
|
3
2
|
import path from "node:path";
|
|
4
3
|
import { fileURLToPath } from "node:url";
|
|
5
4
|
import * as prompts from "@clack/prompts";
|
|
6
|
-
import
|
|
5
|
+
import spawn from "cross-spawn";
|
|
7
6
|
import mri from "mri";
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
const
|
|
11
|
-
|
|
7
|
+
const OUTPUT_TAIL_LINES = 10;
|
|
8
|
+
const DEFAULT_PROJECT_NAME = "skybridge-project";
|
|
9
|
+
const PACKAGE_MANAGERS = ["bun", "deno", "npm", "pnpm", "yarn"];
|
|
10
|
+
const TEMPLATES = ["demo", "blank"];
|
|
11
|
+
const pkg = JSON.parse(fs.readFileSync(fileURLToPath(new URL("../package.json", import.meta.url)), "utf-8"));
|
|
12
|
+
const version = pkg.version;
|
|
13
|
+
const HELP_MESSAGE = `Usage: skybridge create [path] [options]
|
|
12
14
|
|
|
13
|
-
|
|
15
|
+
⛰ Skybridge v${version} - the fullstack framework for building MCP Apps
|
|
14
16
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
--repo <uri> use a git repository instead of the built-in template
|
|
18
|
-
--overwrite remove existing files in target directory
|
|
19
|
-
--immediate install dependencies and start development server
|
|
17
|
+
Arguments:
|
|
18
|
+
path Where the project will be created. Prompted when omitted.
|
|
20
19
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
20
|
+
Options:
|
|
21
|
+
--blank scaffold a minimal project without demo tools and views
|
|
22
|
+
--overwrite remove existing files if target directory is not empty
|
|
23
|
+
--pm <choice> package manager to use (choices: ${PACKAGE_MANAGERS.join(", ")}. default to npm when none is provided or infered)
|
|
24
|
+
--skip-skills skip installing coding agent skills
|
|
25
|
+
--start start dev server
|
|
26
|
+
--yes skip prompts and use default values for unprovided options
|
|
27
|
+
--help display this help message
|
|
25
28
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
Non-interactive usage:
|
|
30
|
+
Mandatory: path argument and --yes option
|
|
31
|
+
Example: skybridge create my-app --yes`;
|
|
32
|
+
const isTTY = process.stdout.isTTY;
|
|
33
|
+
const _spinner = prompts.spinner();
|
|
34
|
+
const Spinner = {
|
|
35
|
+
start(msg) {
|
|
36
|
+
if (!isTTY) {
|
|
37
|
+
prompts.log.info(msg);
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
_spinner.clear();
|
|
41
|
+
_spinner.start(msg);
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
stop(msg) {
|
|
45
|
+
if (!isTTY) {
|
|
46
|
+
prompts.log.success(msg);
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
_spinner.stop(msg);
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
error(msg) {
|
|
53
|
+
if (!isTTY) {
|
|
54
|
+
prompts.log.error(msg);
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
_spinner.error(msg);
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
};
|
|
31
61
|
export async function init(args = process.argv.slice(2)) {
|
|
32
62
|
const argv = mri(args, {
|
|
33
|
-
boolean: ["help", "overwrite", "
|
|
34
|
-
string: ["
|
|
63
|
+
boolean: ["help", "blank", "overwrite", "skip-skills", "start", "yes"],
|
|
64
|
+
string: ["pm"],
|
|
35
65
|
alias: { h: "help" },
|
|
36
66
|
});
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
: undefined;
|
|
40
|
-
const argRepo = argv.repo;
|
|
41
|
-
const argOverwrite = argv.overwrite;
|
|
42
|
-
const argImmediate = argv.immediate;
|
|
43
|
-
const help = argv.help;
|
|
44
|
-
if (help) {
|
|
45
|
-
console.log(helpMessage);
|
|
67
|
+
if (argv.help) {
|
|
68
|
+
console.log(HELP_MESSAGE);
|
|
46
69
|
return;
|
|
47
70
|
}
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
71
|
+
const { yes } = argv;
|
|
72
|
+
let targetDir = argv._[0] ? sanitizeTargetDir(String(argv._[0])) : undefined;
|
|
73
|
+
if (yes && !targetDir) {
|
|
74
|
+
abort("The target directory is required in non-interactive mode.", "Example: skybridge create my-app --yes");
|
|
75
|
+
}
|
|
76
|
+
let pm = parsePackageManager(argv.pm || "");
|
|
77
|
+
if (argv.pm && !pm) {
|
|
78
|
+
abort(`Invalid --pm value "${argv.pm}". Expected one of: ${PACKAGE_MANAGERS.join(", ")}.`);
|
|
79
|
+
}
|
|
80
|
+
console.log(); // cosmetic line break
|
|
81
|
+
prompts.intro(`\x1b[1;36m⛰ Welcome to Skybridge v${version} \x1b[22m- the fullstack framework for building MCP Apps\x1b[0m`);
|
|
82
|
+
// 1. Target directory
|
|
52
83
|
if (!targetDir) {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
});
|
|
64
|
-
if (prompts.isCancel(projectName)) {
|
|
65
|
-
return cancel();
|
|
66
|
-
}
|
|
67
|
-
targetDir = sanitizeTargetDir(projectName);
|
|
68
|
-
}
|
|
69
|
-
else {
|
|
70
|
-
targetDir = defaultProjectName;
|
|
84
|
+
const choice = await prompts.text({
|
|
85
|
+
message: "Project directory:",
|
|
86
|
+
placeholder: DEFAULT_PROJECT_NAME,
|
|
87
|
+
defaultValue: DEFAULT_PROJECT_NAME,
|
|
88
|
+
validate: (value) => !value || sanitizeTargetDir(value).length > 0
|
|
89
|
+
? undefined
|
|
90
|
+
: "Invalid project name",
|
|
91
|
+
});
|
|
92
|
+
if (prompts.isCancel(choice)) {
|
|
93
|
+
return cancel();
|
|
71
94
|
}
|
|
95
|
+
targetDir = sanitizeTargetDir(choice);
|
|
72
96
|
}
|
|
73
|
-
// 2.
|
|
97
|
+
// 2. Existing-directory handling
|
|
74
98
|
if (fs.existsSync(targetDir) && !isEmpty(targetDir)) {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
if (interactive) {
|
|
78
|
-
const res = await prompts.select({
|
|
79
|
-
message: (targetDir === "."
|
|
80
|
-
? "Current directory"
|
|
81
|
-
: `Target directory "${targetDir}"`) +
|
|
82
|
-
` is not empty. Please choose how to proceed:`,
|
|
83
|
-
options: [
|
|
84
|
-
{
|
|
85
|
-
label: "Cancel operation",
|
|
86
|
-
value: "no",
|
|
87
|
-
},
|
|
88
|
-
{
|
|
89
|
-
label: "Remove existing files and continue",
|
|
90
|
-
value: "yes",
|
|
91
|
-
},
|
|
92
|
-
],
|
|
93
|
-
});
|
|
94
|
-
if (prompts.isCancel(res)) {
|
|
95
|
-
return cancel();
|
|
96
|
-
}
|
|
97
|
-
overwrite = res;
|
|
98
|
-
}
|
|
99
|
-
else {
|
|
100
|
-
overwrite = "no";
|
|
101
|
-
}
|
|
99
|
+
if (argv.overwrite) {
|
|
100
|
+
emptyDir(targetDir);
|
|
102
101
|
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
break;
|
|
107
|
-
case "no":
|
|
108
|
-
prompts.log.error("Target directory is not empty.");
|
|
109
|
-
process.exit(1);
|
|
102
|
+
else if (yes) {
|
|
103
|
+
prompts.log.error(`Target directory "${targetDir}" is not empty. Use --overwrite to remove existing files.`);
|
|
104
|
+
process.exit(1);
|
|
110
105
|
}
|
|
106
|
+
const ok = await prompts.confirm({
|
|
107
|
+
message: `Target directory "${targetDir}" is not empty. Remove existing files?`,
|
|
108
|
+
initialValue: true,
|
|
109
|
+
});
|
|
110
|
+
if (prompts.isCancel(ok) || !ok) {
|
|
111
|
+
return cancel();
|
|
112
|
+
}
|
|
113
|
+
Spinner.start(`Cleaning up ${targetDir}`);
|
|
114
|
+
emptyDir(targetDir);
|
|
115
|
+
Spinner.stop(`Cleaned up ${targetDir}`);
|
|
111
116
|
}
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
117
|
+
// 3. Template
|
|
118
|
+
let template;
|
|
119
|
+
if (argv.blank) {
|
|
120
|
+
template = "blank";
|
|
121
|
+
}
|
|
122
|
+
else if (yes) {
|
|
123
|
+
template = "demo";
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
const choice = await prompts.select({
|
|
127
|
+
message: "Choose a template:",
|
|
128
|
+
options: [
|
|
129
|
+
{
|
|
130
|
+
value: "demo",
|
|
131
|
+
label: "demo",
|
|
132
|
+
hint: "starter code with tools and UI",
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
value: "blank",
|
|
136
|
+
label: "blank",
|
|
137
|
+
hint: "minimal boilerplate without tools",
|
|
138
|
+
},
|
|
139
|
+
],
|
|
140
|
+
initialValue: "demo",
|
|
141
|
+
});
|
|
142
|
+
if (prompts.isCancel(choice)) {
|
|
143
|
+
return cancel();
|
|
119
144
|
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
145
|
+
template = choice;
|
|
146
|
+
}
|
|
147
|
+
// 4. Copy template
|
|
148
|
+
const root = path.resolve(targetDir);
|
|
149
|
+
Spinner.start(`Copying ${template} template`);
|
|
150
|
+
try {
|
|
151
|
+
const templateDir = fileURLToPath(new URL(`../templates/${template}`, import.meta.url));
|
|
152
|
+
fs.cpSync(templateDir, root, {
|
|
153
|
+
recursive: true,
|
|
154
|
+
filter: (src) => [".npmrc"].every((file) => !src.endsWith(file)),
|
|
155
|
+
});
|
|
156
|
+
const gitignoreSource = path.join(root, "_gitignore");
|
|
157
|
+
if (fs.existsSync(gitignoreSource)) {
|
|
158
|
+
fs.renameSync(gitignoreSource, path.join(root, ".gitignore"));
|
|
131
159
|
}
|
|
160
|
+
Spinner.stop(`Copied ${template} template`);
|
|
132
161
|
}
|
|
133
162
|
catch (error) {
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
process.exit(1);
|
|
137
|
-
}
|
|
138
|
-
// Update project name in package.json
|
|
139
|
-
const pkgPath = path.join(root, "package.json");
|
|
140
|
-
if (!fs.existsSync(pkgPath)) {
|
|
141
|
-
prompts.log.error("No package.json found in project");
|
|
142
|
-
process.exit(1);
|
|
163
|
+
Spinner.error("Failed to copy template");
|
|
164
|
+
abort(String(error));
|
|
143
165
|
}
|
|
166
|
+
// 5. Set package.json name to the project dir basename
|
|
144
167
|
try {
|
|
145
|
-
const
|
|
146
|
-
|
|
147
|
-
|
|
168
|
+
const pkgPath = path.join(root, "package.json");
|
|
169
|
+
const projectPkg = JSON.parse(fs.readFileSync(pkgPath, "utf-8"));
|
|
170
|
+
projectPkg.name = path.basename(root);
|
|
171
|
+
fs.writeFileSync(pkgPath, `${JSON.stringify(projectPkg, null, 2)}\n`);
|
|
148
172
|
}
|
|
149
173
|
catch (error) {
|
|
150
|
-
|
|
151
|
-
console.error(error);
|
|
152
|
-
process.exit(1);
|
|
174
|
+
abort("Failed to update project name in package.json.", String(error));
|
|
153
175
|
}
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
//
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
176
|
+
// Async spawn wrapper so a spinner can keep animating during the subprocess
|
|
177
|
+
// (cross-spawn.sync would block the event loop). Captures stdout/stderr to
|
|
178
|
+
// `output` when stdio is "pipe", trimmed to the last OUTPUT_TAIL_LINES lines
|
|
179
|
+
// — install errors land at the tail, so we keep that and prefix with an
|
|
180
|
+
// ellipsis when content gets dropped.
|
|
181
|
+
function spawnAsync(command, args) {
|
|
182
|
+
return new Promise((resolve) => {
|
|
183
|
+
let raw = "";
|
|
184
|
+
const child = spawn(command, args, {
|
|
185
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
186
|
+
cwd: root,
|
|
187
|
+
});
|
|
188
|
+
child.stdout?.on("data", (chunk) => {
|
|
189
|
+
raw += chunk.toString();
|
|
190
|
+
});
|
|
191
|
+
child.stderr?.on("data", (chunk) => {
|
|
192
|
+
raw += chunk.toString();
|
|
193
|
+
});
|
|
194
|
+
const done = (status) => {
|
|
195
|
+
const tail = [];
|
|
196
|
+
for (const part of raw.split("\n").reverse()) {
|
|
197
|
+
const line = part.trim();
|
|
198
|
+
if (!line) {
|
|
199
|
+
continue;
|
|
200
|
+
}
|
|
201
|
+
if (tail.length >= OUTPUT_TAIL_LINES) {
|
|
202
|
+
tail.push(`… (truncated, showing last ${OUTPUT_TAIL_LINES} lines)`);
|
|
203
|
+
break;
|
|
204
|
+
}
|
|
205
|
+
tail.push(line);
|
|
206
|
+
}
|
|
207
|
+
resolve({ status, output: tail.reverse().join("\n") });
|
|
208
|
+
};
|
|
209
|
+
child.on("close", done);
|
|
210
|
+
child.on("error", () => done(1));
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
// 6. Skills install (single Y/n prompt)
|
|
214
|
+
let installSkills;
|
|
215
|
+
if (argv["skip-skills"]) {
|
|
216
|
+
installSkills = false;
|
|
217
|
+
}
|
|
218
|
+
else if (yes) {
|
|
219
|
+
installSkills = true;
|
|
220
|
+
}
|
|
221
|
+
else {
|
|
222
|
+
const choice = await prompts.confirm({
|
|
223
|
+
message: "Install coding agent skills? (recommended)",
|
|
160
224
|
initialValue: true,
|
|
161
225
|
});
|
|
162
|
-
if (prompts.isCancel(
|
|
226
|
+
if (prompts.isCancel(choice)) {
|
|
163
227
|
return cancel();
|
|
164
228
|
}
|
|
165
|
-
|
|
166
|
-
run([
|
|
167
|
-
...getPkgExecCmd(pkgManager, "skills"),
|
|
168
|
-
"add",
|
|
169
|
-
"alpic-ai/skybridge",
|
|
170
|
-
"-s",
|
|
171
|
-
"chatgpt-app-builder",
|
|
172
|
-
], {
|
|
173
|
-
stdio: "inherit",
|
|
174
|
-
cwd: targetDir,
|
|
175
|
-
});
|
|
176
|
-
}
|
|
229
|
+
installSkills = choice;
|
|
177
230
|
}
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
231
|
+
if (installSkills) {
|
|
232
|
+
Spinner.start("Installing coding agent skills");
|
|
233
|
+
const { status, output } = await spawnAsync("npx", [
|
|
234
|
+
"--yes",
|
|
235
|
+
"skills",
|
|
236
|
+
"add",
|
|
237
|
+
"alpic-ai/skybridge",
|
|
238
|
+
"--skill",
|
|
239
|
+
"chatgpt-app-builder",
|
|
240
|
+
"--agent",
|
|
241
|
+
"universal",
|
|
242
|
+
"claude-code",
|
|
243
|
+
"--copy", // something the symlink fails for some reason
|
|
244
|
+
"--yes",
|
|
245
|
+
]);
|
|
246
|
+
// skills cli always returns 0 so we look for the success message
|
|
247
|
+
if (status === 0 && output.includes("Done!")) {
|
|
248
|
+
Spinner.stop(`Installed coding agent skills`);
|
|
189
249
|
}
|
|
190
250
|
else {
|
|
191
|
-
|
|
251
|
+
Spinner.error(`Failed to install coding agent skills:
|
|
252
|
+
\x1b[2m${output}\x1b[0m`);
|
|
253
|
+
prompts.log.error("Try manually: `npx skills add alpic-ai/skybridge`.");
|
|
192
254
|
}
|
|
193
255
|
}
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
256
|
+
// 7. Package manager — autodetect, prompt only if detection fails (interactive)
|
|
257
|
+
if (!pm) {
|
|
258
|
+
pm = detectPackageManager() || "npm";
|
|
259
|
+
}
|
|
260
|
+
if (!yes) {
|
|
261
|
+
const choice = await prompts.select({
|
|
262
|
+
message: "Choose a package manager:",
|
|
263
|
+
options: PACKAGE_MANAGERS.map((value) => ({ value })),
|
|
264
|
+
initialValue: pm,
|
|
265
|
+
});
|
|
266
|
+
if (prompts.isCancel(choice)) {
|
|
267
|
+
return cancel();
|
|
268
|
+
}
|
|
269
|
+
pm = choice;
|
|
270
|
+
}
|
|
271
|
+
// 8. Always install dependencies
|
|
272
|
+
Spinner.start(`Installing dependencies with ${pm}`);
|
|
273
|
+
const { status, output } = await spawnAsync(pm, ["install"]);
|
|
274
|
+
if (status === 0) {
|
|
275
|
+
Spinner.stop(`Installed dependencies with ${pm}`);
|
|
276
|
+
}
|
|
277
|
+
else {
|
|
278
|
+
Spinner.error(`Dependency installation failed:
|
|
279
|
+
\x1b[2m${output}\x1b[0m`);
|
|
280
|
+
abort(`Try manually: cd ${targetDir} && ${pm} install`);
|
|
281
|
+
}
|
|
282
|
+
// 9. Start dev server?
|
|
283
|
+
let start = false;
|
|
284
|
+
if (argv.start) {
|
|
285
|
+
start = true;
|
|
286
|
+
}
|
|
287
|
+
else if (!yes) {
|
|
288
|
+
const choice = await prompts.confirm({
|
|
289
|
+
message: "Start dev server now?",
|
|
290
|
+
initialValue: true,
|
|
291
|
+
});
|
|
292
|
+
if (prompts.isCancel(choice)) {
|
|
293
|
+
return cancel();
|
|
294
|
+
}
|
|
295
|
+
start = choice;
|
|
296
|
+
}
|
|
297
|
+
if (start) {
|
|
298
|
+
prompts.outro(`Starting dev server in ${targetDir}…`);
|
|
299
|
+
const devResult = spawn.sync(pm, scriptArgs(pm, "dev"), {
|
|
300
|
+
stdio: "inherit",
|
|
301
|
+
cwd: root,
|
|
302
|
+
});
|
|
303
|
+
process.exit(devResult.status ?? 0);
|
|
304
|
+
}
|
|
305
|
+
prompts.log.success("All set! Next steps:");
|
|
306
|
+
prompts.log.info(`Start:
|
|
307
|
+
cd ${targetDir}
|
|
308
|
+
${scriptCommand(pm, "dev")}`);
|
|
309
|
+
prompts.log.info(`Deploy:
|
|
310
|
+
${scriptCommand(pm, "deploy")}`);
|
|
311
|
+
prompts.outro(`🛟 Need help?
|
|
312
|
+
Chat: https://discord.alpic.ai
|
|
313
|
+
Docs: https://docs.skybridge.tech`);
|
|
314
|
+
}
|
|
315
|
+
function cancel() {
|
|
316
|
+
prompts.cancel("Operation cancelled");
|
|
317
|
+
process.exit(0);
|
|
318
|
+
}
|
|
319
|
+
function abort(...lines) {
|
|
320
|
+
for (const line of lines) {
|
|
321
|
+
prompts.log.error(line);
|
|
322
|
+
}
|
|
323
|
+
prompts.outro("Aborted");
|
|
324
|
+
process.exit(1);
|
|
325
|
+
}
|
|
326
|
+
function parsePackageManager(value) {
|
|
327
|
+
switch (value) {
|
|
199
328
|
case "bun":
|
|
200
|
-
|
|
329
|
+
return "bun";
|
|
201
330
|
case "deno":
|
|
202
|
-
|
|
203
|
-
|
|
331
|
+
return "deno";
|
|
332
|
+
case "npm":
|
|
333
|
+
return "npm";
|
|
334
|
+
case "pnpm":
|
|
335
|
+
return "pnpm";
|
|
336
|
+
case "yarn":
|
|
337
|
+
return "yarn";
|
|
204
338
|
default:
|
|
205
|
-
|
|
206
|
-
}
|
|
207
|
-
runCmd.push("dev");
|
|
208
|
-
if (!immediate) {
|
|
209
|
-
prompts.outro(`Done! Next steps:
|
|
210
|
-
cd ${targetDir}
|
|
211
|
-
${installCmd.join(" ")}
|
|
212
|
-
${runCmd.join(" ")}
|
|
213
|
-
`);
|
|
214
|
-
return;
|
|
339
|
+
return undefined;
|
|
215
340
|
}
|
|
216
|
-
prompts.log.step(`Installing dependencies with ${pkgManager}...`);
|
|
217
|
-
run(installCmd, {
|
|
218
|
-
stdio: "inherit",
|
|
219
|
-
cwd: root,
|
|
220
|
-
});
|
|
221
|
-
prompts.log.step("Starting dev server...");
|
|
222
|
-
run(runCmd, {
|
|
223
|
-
stdio: "inherit",
|
|
224
|
-
cwd: root,
|
|
225
|
-
});
|
|
226
341
|
}
|
|
227
|
-
function
|
|
228
|
-
const
|
|
229
|
-
if (
|
|
230
|
-
|
|
342
|
+
function detectPackageManager() {
|
|
343
|
+
const userAgent = process.env.npm_config_user_agent;
|
|
344
|
+
if (!userAgent) {
|
|
345
|
+
return undefined;
|
|
231
346
|
}
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
347
|
+
const name = userAgent.split(" ")[0]?.split("/")[0];
|
|
348
|
+
return parsePackageManager(name);
|
|
349
|
+
}
|
|
350
|
+
function scriptArgs(pm, script) {
|
|
351
|
+
switch (pm) {
|
|
352
|
+
case "yarn":
|
|
353
|
+
case "pnpm":
|
|
354
|
+
case "bun":
|
|
355
|
+
return [script];
|
|
356
|
+
case "deno":
|
|
357
|
+
return ["task", script];
|
|
358
|
+
case "npm":
|
|
359
|
+
return ["run", script];
|
|
236
360
|
}
|
|
237
361
|
}
|
|
362
|
+
function scriptCommand(pm, script) {
|
|
363
|
+
return [pm, ...scriptArgs(pm, script)].join(" ");
|
|
364
|
+
}
|
|
238
365
|
function sanitizeTargetDir(targetDir) {
|
|
239
|
-
return (
|
|
240
|
-
.trim()
|
|
241
|
-
// Only keep alphanumeric, dash, underscore, dot, @, /
|
|
242
|
-
.replace(/[^a-zA-Z0-9\-_.@/]/g, "")
|
|
243
|
-
// Prevent path traversal
|
|
244
|
-
.replace(/\.\./g, "")
|
|
245
|
-
// Collapse multiple slashes
|
|
246
|
-
.replace(/\/+/g, "/")
|
|
247
|
-
// Remove leading/trailing slashes
|
|
248
|
-
.replace(/^\/+|\/+$/g, ""));
|
|
366
|
+
return targetDir.trim().replace(/\/+$/g, "");
|
|
249
367
|
}
|
|
250
368
|
// Skip user's SPEC.md and IDE/agent preferences (.idea, .claude, etc.)
|
|
251
369
|
function isSkippedEntry(entry) {
|
|
@@ -267,17 +385,3 @@ function emptyDir(dir) {
|
|
|
267
385
|
fs.rmSync(path.join(dir, entry.name), { recursive: true, force: true });
|
|
268
386
|
}
|
|
269
387
|
}
|
|
270
|
-
function getPkgExecCmd(pkgManager, cmd) {
|
|
271
|
-
switch (pkgManager) {
|
|
272
|
-
case "yarn":
|
|
273
|
-
return ["yarn", "dlx", cmd];
|
|
274
|
-
case "pnpm":
|
|
275
|
-
return ["pnpm", "dlx", cmd];
|
|
276
|
-
case "bun":
|
|
277
|
-
return ["bunx", cmd];
|
|
278
|
-
case "deno":
|
|
279
|
-
return ["deno", "run", "-A", `npm:${cmd}`];
|
|
280
|
-
default:
|
|
281
|
-
return ["npx", cmd];
|
|
282
|
-
}
|
|
283
|
-
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-skybridge",
|
|
3
|
-
"version": "0.0.0-dev.
|
|
3
|
+
"version": "0.0.0-dev.149fe9f",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Alpic",
|
|
@@ -14,22 +14,23 @@
|
|
|
14
14
|
"files": [
|
|
15
15
|
"index.js",
|
|
16
16
|
"dist",
|
|
17
|
-
"
|
|
17
|
+
"templates"
|
|
18
18
|
],
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"@clack/prompts": "^1.1.0",
|
|
21
|
-
"
|
|
21
|
+
"cross-spawn": "^7.0.6",
|
|
22
22
|
"mri": "^1.2.0"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
|
-
"
|
|
26
|
-
"
|
|
25
|
+
"@types/cross-spawn": "^6.0.6",
|
|
26
|
+
"typescript": "^6.0.2",
|
|
27
|
+
"vitest": "^4.1.4"
|
|
27
28
|
},
|
|
28
29
|
"scripts": {
|
|
29
30
|
"build": "tsc",
|
|
30
|
-
"test": "pnpm run test:unit && pnpm run test:
|
|
31
|
+
"test": "pnpm run test:unit && pnpm run test:format",
|
|
31
32
|
"test:unit": "vitest run",
|
|
32
|
-
"
|
|
33
|
+
"format": "biome check --write --error-on-warnings",
|
|
33
34
|
"test:format": "biome ci"
|
|
34
35
|
}
|
|
35
36
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
This is a ChatGPT/MCP app built with Skybridge. ALWAYS use the `chatgpt-app-builder` skill when planning or updating the codebase.
|