@suronai/cli 0.1.17 → 0.1.18

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": "@suronai/cli",
3
- "version": "0.1.17",
3
+ "version": "0.1.18",
4
4
  "description": "CLI for Suron — suron login, init, whoami, rotate",
5
5
  "type": "module",
6
6
  "bin": {
@@ -26,11 +26,11 @@ export const initCommand = new Command("init")
26
26
  let appName;
27
27
 
28
28
  if (opts.name) {
29
- appName = opts.name;
29
+ appName = sanitiseName(opts.name);
30
30
  console.log(" App name " + c.cyan(appName));
31
31
  } else {
32
- const input = await prompt(` App name [${c.dim(suggested)}] › `);
33
- appName = input || suggested;
32
+ const raw = await prompt(` App name [${c.dim(sanitiseName(suggested))}] › `);
33
+ appName = sanitiseName(raw || suggested);
34
34
  }
35
35
 
36
36
  // ── Encrypt ───────────────────────────────────────────────────────────────
@@ -67,8 +67,12 @@ export const initCommand = new Command("init")
67
67
  }
68
68
 
69
69
  if (!res.ok) {
70
- const text = await res.text().catch(() => "");
71
- console.error("\n " + c.red("✗") + ` register-app failed (${res.status}): ${text}\n`);
70
+ let errMsg = `register-app failed (${res.status})`;
71
+ try {
72
+ const body = await res.json();
73
+ if (body?.error) errMsg = body.error;
74
+ } catch { /* ignore */ }
75
+ console.error("\n " + c.red("✗") + ` ${errMsg}\n`);
72
76
  process.exit(1);
73
77
  }
74
78
 
@@ -129,3 +133,13 @@ function detectPackageManager(cwd) {
129
133
  function pmAddCmd(pm) {
130
134
  return pm === "npm" ? "install" : "add";
131
135
  }
136
+
137
+ /**
138
+ * Strips hyphens, underscores, spaces and other non-alphanumeric characters
139
+ * so the app name is always a single lowercase word. e.g. "camp-haven" -> "camphaven".
140
+ * @param {string} name
141
+ * @returns {string}
142
+ */
143
+ function sanitiseName(name) {
144
+ return name.toLowerCase().replace(/[^a-z0-9]/g, "");
145
+ }