bosia 0.8.8 → 0.8.9

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/package.json +1 -1
  2. package/src/cli/create.ts +24 -15
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bosia",
3
- "version": "0.8.8",
3
+ "version": "0.8.9",
4
4
  "type": "module",
5
5
  "description": "A fast, batteries-included fullstack framework — SSR · Svelte 5 Runes · Bun · ElysiaJS. File-based routing No Node.js, no Vite, no adapters.",
6
6
  "keywords": [
package/src/cli/create.ts CHANGED
@@ -20,16 +20,21 @@ const TEMPLATE_DESCRIPTIONS: Record<string, string> = {
20
20
  };
21
21
 
22
22
  export async function runCreate(name: string | undefined, args: string[] = []) {
23
- if (!name) {
24
- console.error("❌ Please provide a project name.\n Usage: bun x bosia@latest create my-app");
25
- process.exit(1);
26
- }
27
-
28
- const targetDir = resolve(process.cwd(), name);
29
-
23
+ // "." or omitted → scaffold into the current directory
24
+ const inCurrentDir = !name || name === ".";
25
+ const targetDir = inCurrentDir ? process.cwd() : resolve(process.cwd(), name);
26
+ // package.json / placeholder name: cwd basename when scaffolding in place
27
+ const projectName = inCurrentDir ? basename(targetDir) : name!;
28
+
29
+ // allowlist covers the two files that routinely sit in an otherwise empty
30
+ // scaffold target (git init'd, macOS). Widen if users hit others.
31
+ const IGNORE = new Set([".git", ".DS_Store"]);
30
32
  if (existsSync(targetDir)) {
31
- console.error(`❌ Directory already exists: ${targetDir}`);
32
- process.exit(1);
33
+ const entries = readdirSync(targetDir).filter((e) => !IGNORE.has(e));
34
+ if (entries.length > 0) {
35
+ console.error(`❌ Directory is not empty: ${targetDir}`);
36
+ process.exit(1);
37
+ }
33
38
  }
34
39
 
35
40
  // Parse --template flag (supports `--template foo` and `--template=foo`)
@@ -77,15 +82,15 @@ export async function runCreate(name: string | undefined, args: string[] = []) {
77
82
  // `BOSIA_BUILDING_PREBUILT` is set by the artifact generator so it scaffolds
78
83
  // via the registry instead of trying to download the asset it's producing.
79
84
  if (config?.prebuilt === true && !isLocal && !process.env.BOSIA_BUILDING_PREBUILT) {
80
- const ok = await scaffoldFromPrebuilt(template, targetDir, name);
85
+ const ok = await scaffoldFromPrebuilt(template, targetDir, projectName);
81
86
  if (ok) {
82
- await finishCreate(targetDir, name, templateDir, skipInstall);
87
+ await finishCreate(targetDir, projectName, templateDir, skipInstall, inCurrentDir);
83
88
  return;
84
89
  }
85
90
  console.log("⚠️ Prebuilt artifact unavailable — installing from registry instead.\n");
86
91
  }
87
92
 
88
- copyDir(templateDir, targetDir, name, isLocal);
93
+ copyDir(templateDir, targetDir, projectName, isLocal);
89
94
 
90
95
  if (existsSync(join(targetDir, ".env.example"))) {
91
96
  writeFileSync(join(targetDir, ".env"), readFileSync(join(targetDir, ".env.example"), "utf-8"));
@@ -116,7 +121,7 @@ export async function runCreate(name: string | undefined, args: string[] = []) {
116
121
  }
117
122
  }
118
123
 
119
- await finishCreate(targetDir, name, templateDir, skipInstall);
124
+ await finishCreate(targetDir, projectName, templateDir, skipInstall, inCurrentDir);
120
125
  }
121
126
 
122
127
  // ─── Shared finish: optional `bun install` + printed instructions ──────────
@@ -125,7 +130,10 @@ async function finishCreate(
125
130
  name: string,
126
131
  templateDir: string,
127
132
  skipInstall: boolean,
133
+ inCurrentDir = false,
128
134
  ) {
135
+ // Already inside the project dir → no `cd` step to show
136
+ const cd = inCurrentDir ? "" : `cd ${name} && `;
129
137
  const printInstructions = () => {
130
138
  const instPath = join(templateDir, "instructions.txt");
131
139
  if (existsSync(instPath)) {
@@ -137,7 +145,7 @@ async function finishCreate(
137
145
  console.log(`\n✅ Project created at ${targetDir}\n`);
138
146
 
139
147
  if (skipInstall) {
140
- console.log(`Skipped \`bun install\` (--no-install).\n\ncd ${name} && bun install\n`);
148
+ console.log(`Skipped \`bun install\` (--no-install).\n\n${cd}bun install\n`);
141
149
  printInstructions();
142
150
  return;
143
151
  }
@@ -152,7 +160,8 @@ async function finishCreate(
152
160
  if (exitCode !== 0) {
153
161
  console.warn("⚠️ bun install failed — run it manually.");
154
162
  } else {
155
- console.log(`\n🎉 Ready!\n\ncd ${name}`);
163
+ console.log(`\n🎉 Ready!\n`);
164
+ if (!inCurrentDir) console.log(`cd ${name}`);
156
165
  printInstructions();
157
166
  console.log(`bun x bosia dev\n`);
158
167
  }