@smi-digital/create-smi-app 2.7.4 → 2.7.5

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 CHANGED
@@ -156,6 +156,9 @@ var smiTheme = {
156
156
  cursor: primary12("\u276F")
157
157
  }
158
158
  };
159
+ function toSlug(value) {
160
+ return value.toLowerCase().replace(/[^a-z0-9]+/gv, "-").replace(/^-+|-+$/gv, "");
161
+ }
159
162
  async function askIntegrationInputs(inputConfig, index = 0, answers = {}) {
160
163
  const current = inputConfig[index];
161
164
  if (!current) {
@@ -178,9 +181,17 @@ async function askIntegrationInputs(inputConfig, index = 0, answers = {}) {
178
181
  const inputConfigData = {
179
182
  message: current.message,
180
183
  validate(value) {
181
- if (current.required && value.trim().length === 0) {
184
+ const trimmed = value.trim();
185
+ if (current.required && trimmed.length === 0) {
182
186
  return "This value is required.";
183
187
  }
188
+ if (current.validate === "slug" && trimmed.length > 0) {
189
+ const isSlug = /^[a-z0-9]+(?:-[a-z0-9]+)*$/v.test(trimmed);
190
+ if (!isSlug) {
191
+ const suggestion = toSlug(trimmed);
192
+ return `Must be a lowercase slug \u2014 letters, digits and single hyphens only (no dots, uppercase or spaces).${suggestion ? ` Try: ${suggestion}` : ""}`;
193
+ }
194
+ }
184
195
  return true;
185
196
  },
186
197
  theme: smiTheme
@@ -458,7 +469,7 @@ ${stderrTail}` : "";
458
469
 
459
470
  // src/modules/scaffoldActions/createApps.ts
460
471
  import { join as join4 } from "path";
461
- import { readFile as readFile3, writeFile as writeFile2 } from "fs/promises";
472
+ import { writeFile as writeFile2 } from "fs/promises";
462
473
  async function createFrameworkApp(projectRoot, target) {
463
474
  const generator = FRAMEWORK_GENERATORS[target.framework];
464
475
  if (!generator) {
@@ -487,13 +498,11 @@ async function createApps(projectRoot, targets) {
487
498
  target.directory,
488
499
  "config/plugins.ts"
489
500
  );
490
- let pluginsContent = await readFile3(pluginsPath, "utf8");
491
- pluginsContent = pluginsContent.replace(
492
- "export default ({ env }) => ({",
493
- "export default () => ({"
501
+ await writeFile2(pluginsPath, "export default () => ({});\n");
502
+ } catch (error) {
503
+ console.warn(
504
+ `Could not normalize config/plugins.ts: ${error instanceof Error ? error.message : String(error)}`
494
505
  );
495
- await writeFile2(pluginsPath, pluginsContent);
496
- } catch {
497
506
  }
498
507
  }
499
508
  await runSequentially(index + 1);
@@ -502,7 +511,7 @@ async function createApps(projectRoot, targets) {
502
511
  }
503
512
 
504
513
  // src/modules/scaffoldActions/createIntegrations.ts
505
- import { mkdir, readFile as readFile4, writeFile as writeFile3 } from "fs/promises";
514
+ import { mkdir, readFile as readFile3, writeFile as writeFile3 } from "fs/promises";
506
515
  import { dirname as dirname2, join as join5 } from "path";
507
516
  import { randomBytes } from "crypto";
508
517
  function toTemplateToken(key) {
@@ -517,7 +526,7 @@ function applyTemplateVariables(content, values) {
517
526
  return result;
518
527
  }
519
528
  async function copyTemplateFile(sourcePath, targetPath, values) {
520
- const rawContent = await readFile4(sourcePath, "utf8");
529
+ const rawContent = await readFile3(sourcePath, "utf8");
521
530
  const content = applyTemplateVariables(rawContent, values);
522
531
  await mkdir(dirname2(targetPath), { recursive: true });
523
532
  await writeFile3(targetPath, content, "utf8");
@@ -604,7 +613,7 @@ async function createIntegrations(options, projectRoot, templatesDir) {
604
613
  const frontendDir = join5(projectRoot, "frontend");
605
614
  await runCommandQuiet("npx", ["astro", "add", "node", "-y"], frontendDir);
606
615
  const astroConfigPath = join5(frontendDir, "astro.config.mjs");
607
- let astroConfig = await readFile4(astroConfigPath, "utf8");
616
+ let astroConfig = await readFile3(astroConfigPath, "utf8");
608
617
  astroConfig = astroConfig.replace(
609
618
  /export default defineConfig\s*\(\s*\{/v,
610
619
  "export default defineConfig({\n output: 'server',"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smi-digital/create-smi-app",
3
- "version": "2.7.4",
3
+ "version": "2.7.5",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "bin": {
@@ -24,10 +24,11 @@
24
24
  },
25
25
  {
26
26
  "key": "app_name",
27
- "message": "What is the app name?",
27
+ "message": "What is the app name? (lowercase slug, e.g. my-new-client)",
28
28
  "type": "input",
29
29
  "default": "my-new-client",
30
- "required": true
30
+ "required": true,
31
+ "validate": "slug"
31
32
  },
32
33
  {
33
34
  "key": "include_www",