bosia 0.8.7 → 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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bosia",
3
- "version": "0.8.7",
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
  }
@@ -140,7 +140,7 @@ function openForm(loc,el){
140
140
  closeForm();
141
141
  var r=el.getBoundingClientRect();
142
142
  form=document.createElement("div");
143
- form.style.cssText="position:fixed;left:"+r.left+"px;top:"+(r.bottom+6)+"px;background:#fff;color:#111;border:1px solid #d4d4d8;border-radius:8px;box-shadow:0 8px 24px rgba(0,0,0,.18);padding:10px;width:340px;z-index:2147483647;font:13px ui-sans-serif,system-ui,sans-serif";
143
+ form.style.cssText="position:fixed;left:0;top:0;background:#fff;color:#111;border:1px solid #d4d4d8;border-radius:8px;box-shadow:0 8px 24px rgba(0,0,0,.18);padding:10px;width:340px;z-index:2147483647;font:13px ui-sans-serif,system-ui,sans-serif";
144
144
  form.innerHTML=
145
145
  '<textarea placeholder="Describe a fix (Enter to send, Esc to cancel, empty = open in editor)" style="width:100%;min-height:64px;border:1px solid #e4e4e7;border-radius:4px;padding:6px;font:13px ui-sans-serif,system-ui,sans-serif;resize:vertical;box-sizing:border-box;outline:none"></textarea>'+
146
146
  '<div style="margin-top:8px;display:flex;gap:6px;justify-content:flex-end">'+
@@ -148,6 +148,12 @@ function openForm(loc,el){
148
148
  '<button data-send style="padding:4px 10px;border:0;background:#111;color:#fff;border-radius:4px;cursor:pointer;font-size:12px">Send</button>'+
149
149
  '</div>';
150
150
  document.body.appendChild(form);
151
+ var fw=form.offsetWidth,fh=form.offsetHeight;
152
+ var top=r.bottom+6;
153
+ if(top+fh>window.innerHeight)top=r.top-fh-6;
154
+ if(top<8)top=Math.max(8,window.innerHeight-fh-8);
155
+ var left=Math.min(r.left,window.innerWidth-fw-8);if(left<8)left=8;
156
+ form.style.left=left+"px";form.style.top=top+"px";
151
157
  var ta=form.querySelector("textarea");
152
158
  ta.focus();
153
159
  function submit(){
@@ -6,7 +6,7 @@
6
6
  "dev": "bosia dev",
7
7
  "build": "bosia build",
8
8
  "start": "bosia start",
9
- "check": "tsc --noEmit && prettier --check .",
9
+ "check": "bosia sync && tsc --noEmit && prettier --check .",
10
10
  "format": "prettier --write .",
11
11
  "format:check": "prettier --check ."
12
12
  },
@@ -6,7 +6,7 @@
6
6
  "dev": "bosia dev",
7
7
  "build": "bosia build",
8
8
  "start": "bosia start",
9
- "check": "tsc --noEmit && prettier --check .",
9
+ "check": "bosia sync && tsc --noEmit && prettier --check .",
10
10
  "format": "prettier --write .",
11
11
  "format:check": "prettier --check ."
12
12
  },
@@ -6,7 +6,7 @@
6
6
  "dev": "bosia dev",
7
7
  "build": "bosia build",
8
8
  "start": "bosia start",
9
- "check": "tsc --noEmit && prettier --check .",
9
+ "check": "bosia sync && tsc --noEmit && prettier --check .",
10
10
  "format": "prettier --write .",
11
11
  "format:check": "prettier --check ."
12
12
  },