@suronai/cli 0.1.16 → 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 +1 -1
- package/src/commands/init.js +19 -5
- package/src/index.js +1 -1
package/package.json
CHANGED
package/src/commands/init.js
CHANGED
|
@@ -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
|
|
33
|
-
appName =
|
|
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
|
-
|
|
71
|
-
|
|
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
|
+
}
|
package/src/index.js
CHANGED