@robineb/project-cli 1.0.2 → 1.1.0
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/dist/index.js +24 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -128,6 +128,19 @@ async function resolveGiteaCredentials() {
|
|
|
128
128
|
// ---------------------------------------------------------------------------
|
|
129
129
|
// 3. Die einzelnen Arbeitsschritte
|
|
130
130
|
// ---------------------------------------------------------------------------
|
|
131
|
+
// Deckt sowohl Gitea (Regel "AlphaDashDot") als auch GitHub ab: nur
|
|
132
|
+
// alphanumerische Zeichen, "-", "_" und ".", muss mit alphanumerisch
|
|
133
|
+
// beginnen und enden. Leerzeichen wie in "esp 32" fallen damit sofort auf,
|
|
134
|
+
// statt erst nach Scaffold + erstem Commit bei der Remote-Erstellung.
|
|
135
|
+
const PROJECT_NAME_PATTERN = /^[A-Za-z0-9](?:[A-Za-z0-9._-]*[A-Za-z0-9])?$/;
|
|
136
|
+
function validateProjectName(name) {
|
|
137
|
+
if (!name?.trim())
|
|
138
|
+
return "Name darf nicht leer sein";
|
|
139
|
+
if (!PROJECT_NAME_PATTERN.test(name)) {
|
|
140
|
+
return "Name darf nur Buchstaben, Ziffern, '-', '_' und '.' enthalten (muss mit Buchstabe/Ziffer beginnen und enden)";
|
|
141
|
+
}
|
|
142
|
+
return undefined;
|
|
143
|
+
}
|
|
131
144
|
async function scaffold(stack, targetDir, name) {
|
|
132
145
|
if (stack.command) {
|
|
133
146
|
const { file, args } = stack.command(name);
|
|
@@ -259,10 +272,20 @@ async function run(nameArg, opts) {
|
|
|
259
272
|
const name = nameArg ??
|
|
260
273
|
(await p.text({
|
|
261
274
|
message: "Wie soll das Projekt heißen?",
|
|
262
|
-
validate: (v) => (v
|
|
275
|
+
validate: (v) => validateProjectName(v),
|
|
263
276
|
}));
|
|
264
277
|
if (p.isCancel(name))
|
|
265
278
|
return p.cancel("Abgebrochen.");
|
|
279
|
+
// nameArg kommt am Prompt vorbei (CLI-Argument statt p.text) -> hier
|
|
280
|
+
// nochmal prüfen. Sonst scheitert erst die Remote-Erstellung nach
|
|
281
|
+
// Scaffold + erstem Commit (Gitea/GitHub lehnen z.B. Leerzeichen im
|
|
282
|
+
// Namen mit "AlphaDashDot" bzw. 422 ab), und die lokale Arbeit ist
|
|
283
|
+
// bereits passiert, ohne dass ein Remote konfiguriert wurde.
|
|
284
|
+
const nameError = validateProjectName(name);
|
|
285
|
+
if (nameError) {
|
|
286
|
+
p.cancel(nameError);
|
|
287
|
+
return;
|
|
288
|
+
}
|
|
266
289
|
const stackId = await p.select({
|
|
267
290
|
message: "Welcher Stack?",
|
|
268
291
|
options: STACKS.map((s) => ({ value: s.id, label: s.label })),
|