create-skybridge 0.0.0-dev.99eead4 → 0.0.0-dev.9a2de58

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.
Files changed (2) hide show
  1. package/dist/index.js +24 -18
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -4,7 +4,6 @@ import path from "node:path";
4
4
  import { fileURLToPath } from "node:url";
5
5
  import * as prompts from "@clack/prompts";
6
6
  import mri from "mri";
7
- const minimumPnpmVersion = 10;
8
7
  const defaultProjectName = "skybridge-project";
9
8
  // prettier-ignore
10
9
  const helpMessage = `\
@@ -125,12 +124,14 @@ export async function init(args = process.argv.slice(2)) {
125
124
  console.error(error);
126
125
  process.exit(1);
127
126
  }
127
+ const userAgent = process.env.npm_config_user_agent;
128
+ const pkgManager = userAgent?.split(" ")[0]?.split("/")[0] || "npm";
128
129
  // 4. Ask about immediate installation
129
130
  let immediate = argImmediate;
130
131
  if (immediate === undefined) {
131
132
  if (interactive) {
132
133
  const immediateResult = await prompts.confirm({
133
- message: `Install with pnpm and start now?`,
134
+ message: `Install with ${pkgManager} and start now?`,
134
135
  });
135
136
  if (prompts.isCancel(immediateResult)) {
136
137
  return cancel();
@@ -141,8 +142,8 @@ export async function init(args = process.argv.slice(2)) {
141
142
  immediate = false;
142
143
  }
143
144
  }
144
- const installCmd = ["pnpm", "install"];
145
- const runCmd = ["pnpm", "dev"];
145
+ const installCmd = getInstallCommand(pkgManager);
146
+ const runCmd = getRunCommand(pkgManager);
146
147
  if (!immediate) {
147
148
  prompts.outro(`Done! Next steps:
148
149
  cd ${targetDir}
@@ -151,20 +152,7 @@ export async function init(args = process.argv.slice(2)) {
151
152
  `);
152
153
  return;
153
154
  }
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...`);
155
+ prompts.log.step(`Installing dependencies with ${pkgManager}...`);
168
156
  run(installCmd, {
169
157
  stdio: "inherit",
170
158
  cwd: root,
@@ -186,6 +174,24 @@ function run([command, ...args], options) {
186
174
  process.exit(1);
187
175
  }
188
176
  }
177
+ function getInstallCommand(pkgManager) {
178
+ if (pkgManager === "yarn") {
179
+ return [pkgManager];
180
+ }
181
+ return [pkgManager, "install"];
182
+ }
183
+ function getRunCommand(packageManager) {
184
+ switch (packageManager) {
185
+ case "yarn":
186
+ case "pnpm":
187
+ case "bun":
188
+ return [packageManager, "dev"];
189
+ case "deno":
190
+ return [packageManager, "task", "dev"];
191
+ default:
192
+ return [packageManager, "run", "dev"];
193
+ }
194
+ }
189
195
  function sanitizeTargetDir(targetDir) {
190
196
  return (targetDir
191
197
  .trim()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-skybridge",
3
- "version": "0.0.0-dev.99eead4",
3
+ "version": "0.0.0-dev.9a2de58",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "author": "Alpic",