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