create-skybridge 0.0.0-dev.45c7ad3 → 0.0.0-dev.48e1f9d

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 CHANGED
@@ -1,3 +1,4 @@
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";
@@ -13,20 +14,22 @@ Create a new Skybridge project by copying the starter template.
13
14
  Options:
14
15
  -h, --help show this help message
15
16
  --overwrite remove existing files in target directory
17
+ --immediate install dependencies and start development server
16
18
 
17
19
  Examples:
18
20
  create-skybridge my-app
19
- create-skybridge . --overwrite
21
+ create-skybridge . --overwrite --immediate
20
22
  `;
21
23
  export async function init(args = process.argv.slice(2)) {
22
24
  const argv = mri(args, {
23
- boolean: ["help", "overwrite"],
25
+ boolean: ["help", "overwrite", "immediate"],
24
26
  alias: { h: "help" },
25
27
  });
26
28
  const argTargetDir = argv._[0]
27
29
  ? sanitizeTargetDir(String(argv._[0]))
28
30
  : undefined;
29
31
  const argOverwrite = argv.overwrite;
32
+ const argImmediate = argv.immediate;
30
33
  const help = argv.help;
31
34
  if (help) {
32
35
  console.log(helpMessage);
@@ -48,8 +51,9 @@ export async function init(args = process.argv.slice(2)) {
48
51
  : "Invalid project name";
49
52
  },
50
53
  });
51
- if (prompts.isCancel(projectName))
54
+ if (prompts.isCancel(projectName)) {
52
55
  return cancel();
56
+ }
53
57
  targetDir = sanitizeTargetDir(projectName);
54
58
  }
55
59
  else {
@@ -77,8 +81,9 @@ export async function init(args = process.argv.slice(2)) {
77
81
  },
78
82
  ],
79
83
  });
80
- if (prompts.isCancel(res))
84
+ if (prompts.isCancel(res)) {
81
85
  return cancel();
86
+ }
82
87
  overwrite = res;
83
88
  }
84
89
  else {
@@ -102,7 +107,7 @@ export async function init(args = process.argv.slice(2)) {
102
107
  // Copy template to target directory
103
108
  fs.cpSync(templateDir, root, {
104
109
  recursive: true,
105
- filter: (src) => [".npmrc", "pnpm-workspace.yaml"].every((file) => !src.endsWith(file)),
110
+ filter: (src) => [".npmrc"].every((file) => !src.endsWith(file)),
106
111
  });
107
112
  // Rename _gitignore to .gitignore
108
113
  fs.renameSync(path.join(root, "_gitignore"), path.join(root, ".gitignore"));
@@ -113,13 +118,73 @@ export async function init(args = process.argv.slice(2)) {
113
118
  const fixed = pkg.replace(/apps-sdk-template/g, name);
114
119
  fs.writeFileSync(pkgPath, fixed);
115
120
  prompts.log.success(`Project created in ${root}`);
116
- prompts.outro(`Done! Next steps:\n\n cd ${targetDir}\n pnpm install\n pnpm dev`);
117
121
  }
118
122
  catch (error) {
119
123
  prompts.log.error("Failed to copy repository");
120
124
  console.error(error);
121
125
  process.exit(1);
122
126
  }
127
+ const userAgent = process.env.npm_config_user_agent;
128
+ const pkgManager = userAgent?.split(" ")[0]?.split("/")[0] || "npm";
129
+ // 4. Ask about immediate installation
130
+ let immediate = argImmediate;
131
+ if (immediate === undefined) {
132
+ if (interactive) {
133
+ const immediateResult = await prompts.confirm({
134
+ message: `Install with ${pkgManager} and start now?`,
135
+ });
136
+ if (prompts.isCancel(immediateResult)) {
137
+ return cancel();
138
+ }
139
+ immediate = immediateResult;
140
+ }
141
+ else {
142
+ immediate = false;
143
+ }
144
+ }
145
+ const installCmd = [pkgManager, "install"];
146
+ const runCmd = [pkgManager];
147
+ switch (pkgManager) {
148
+ case "yarn":
149
+ case "pnpm":
150
+ case "bun":
151
+ break;
152
+ case "deno":
153
+ runCmd.push("task");
154
+ break;
155
+ default:
156
+ runCmd.push("run");
157
+ }
158
+ runCmd.push("dev");
159
+ if (!immediate) {
160
+ prompts.outro(`Done! Next steps:
161
+ cd ${targetDir}
162
+ ${installCmd.join(" ")}
163
+ ${runCmd.join(" ")}
164
+ `);
165
+ return;
166
+ }
167
+ prompts.log.step(`Installing dependencies with ${pkgManager}...`);
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-skybridge",
3
- "version": "0.0.0-dev.45c7ad3",
3
+ "version": "0.0.0-dev.48e1f9d",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "author": "Alpic",
@@ -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.16.0 <1.0.0",
23
23
  "vite": "^7.1.11",
24
24
  "zod": "^4.1.13"
25
25
  },
@@ -29,7 +29,7 @@
29
29
  "@types/node": "^22.15.30",
30
30
  "@types/react": "^19.1.16",
31
31
  "@types/react-dom": "^19.1.9",
32
- "@vitejs/plugin-react": "^5.0.4",
32
+ "@vitejs/plugin-react": "^5.1.2",
33
33
  "nodemon": "^3.1.10",
34
34
  "shx": "^0.3.4",
35
35
  "tsx": "^4.19.4",
@@ -3,10 +3,6 @@ import { z } from "zod";
3
3
 
4
4
  const Answers = [
5
5
  "As I see it, yes",
6
- "Ask again later",
7
- "Better not tell you now",
8
- "Cannot predict now",
9
- "Concentrate and ask again",
10
6
  "Don't count on it",
11
7
  "It is certain",
12
8
  "It is decidedly so",
@@ -15,7 +11,6 @@ const Answers = [
15
11
  "My sources say no",
16
12
  "Outlook good",
17
13
  "Outlook not so good",
18
- "Reply hazy, try again",
19
14
  "Signs point to yes",
20
15
  "Very doubtful",
21
16
  "Without a doubt",
@@ -15,6 +15,7 @@
15
15
  align-items: center;
16
16
  justify-content: center;
17
17
  font-family: monospace;
18
+ text-align: center;
18
19
  }
19
20
 
20
21
  .question {
@@ -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">