@smi-digital/create-smi-app 1.0.1 → 1.0.3

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.
Files changed (2) hide show
  1. package/dist/index.js +23 -10
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -6,6 +6,7 @@ import chalkAnimation from "chalk-animation";
6
6
  // src/modules/common.ts
7
7
  var primary1 = "#8e2de2";
8
8
  var primary2 = "#ff00d4";
9
+ var base = "#ffffff";
9
10
 
10
11
  // src/modules/greetings.ts
11
12
  var smiGradient = gradient([primary1, primary2]);
@@ -40,17 +41,14 @@ var TOOL_CHOICES = [
40
41
  ];
41
42
  var SINGLE_PROJECT_FRAMEWORK_CHOICES = [
42
43
  { value: "astro", name: "Astro" },
43
- { value: "react", name: "React" },
44
44
  { value: "none", name: "None" }
45
45
  ];
46
46
  var FRONTEND_FRAMEWORK_CHOICES = [
47
47
  { value: "astro", name: "Astro" },
48
- { value: "react", name: "React" },
49
48
  { value: "none", name: "None" }
50
49
  ];
51
50
  var BACKEND_FRAMEWORK_CHOICES = [
52
51
  { value: "strapi", name: "Strapi" },
53
- { value: "express", name: "Express" },
54
52
  { value: "none", name: "None" }
55
53
  ];
56
54
  var FRAMEWORK_GENERATORS = {
@@ -144,6 +142,7 @@ async function getIntegrationForSelection(templatesDir, selection) {
144
142
  // src/modules/questions.ts
145
143
  var primary12 = chalk.hex(primary1);
146
144
  var primary22 = chalk.hex(primary2);
145
+ var base2 = chalk.hex(base);
147
146
  var smiTheme = {
148
147
  prefix: {
149
148
  idle: primary12("?"),
@@ -151,7 +150,8 @@ var smiTheme = {
151
150
  },
152
151
  style: {
153
152
  highlight: (text) => primary12(text),
154
- answer: (text) => primary22(text)
153
+ answer: (text) => primary22(text),
154
+ message: (text) => base2.bold(text)
155
155
  },
156
156
  icon: {
157
157
  cursor: primary12("\u276F")
@@ -315,7 +315,7 @@ import { access as access2, mkdir as mkdir2 } from "fs/promises";
315
315
  import { join as join5 } from "path";
316
316
 
317
317
  // src/modules/scaffoldActions/createTools.ts
318
- import { cp, readdir as readdir2 } from "fs/promises";
318
+ import { cp, readFile as readFile2, readdir as readdir2, writeFile } from "fs/promises";
319
319
  import { join as join3 } from "path";
320
320
  var templateRenameMap = {
321
321
  "env.template": ".env",
@@ -333,7 +333,19 @@ function getTargetFileName(sourceName) {
333
333
  }
334
334
  return sourceName;
335
335
  }
336
- async function createTools(tools, targetDir, templatesDir) {
336
+ function toPackageName(projectName) {
337
+ const normalized = projectName.trim().toLowerCase().replaceAll(/\s+/gv, "-").replaceAll(/[^a-z0-9._~\-]/gv, "").replaceAll(/-+/gv, "-").replaceAll(/^[._-]+|[._-]+$/gv, "");
338
+ return normalized || "app";
339
+ }
340
+ async function updatePackageJsonName(targetDir, projectName) {
341
+ const packageJsonPath = join3(targetDir, "package.json");
342
+ const packageJsonRaw = await readFile2(packageJsonPath, "utf8");
343
+ const packageJson = JSON.parse(packageJsonRaw);
344
+ packageJson.name = toPackageName(projectName);
345
+ await writeFile(packageJsonPath, `${JSON.stringify(packageJson, null, 2)}
346
+ `);
347
+ }
348
+ async function createTools(tools, targetDir, templatesDir, projectName) {
337
349
  if (!tools.includes("basic")) {
338
350
  return;
339
351
  }
@@ -354,6 +366,7 @@ async function createTools(tools, targetDir, templatesDir) {
354
366
  await cp(huskyDir, join3(targetDir, ".husky"), {
355
367
  recursive: true
356
368
  });
369
+ await updatePackageJsonName(targetDir, projectName);
357
370
  }
358
371
 
359
372
  // src/modules/scaffoldActions/progress.ts
@@ -472,7 +485,7 @@ async function createApps(projectRoot, targets) {
472
485
  }
473
486
 
474
487
  // src/modules/scaffoldActions/createIntegrations.ts
475
- import { mkdir, readFile as readFile2, writeFile } from "fs/promises";
488
+ import { mkdir, readFile as readFile3, writeFile as writeFile2 } from "fs/promises";
476
489
  import { dirname as dirname2, join as join4 } from "path";
477
490
  function toTemplateToken(key) {
478
491
  const normalized = key.replaceAll(/[^a-zA-Z0-9]+/gv, "_").replaceAll(/^_+|_+$/gv, "").toUpperCase();
@@ -486,10 +499,10 @@ function applyTemplateVariables(content, values) {
486
499
  return result;
487
500
  }
488
501
  async function copyTemplateFile(sourcePath, targetPath, values) {
489
- const rawContent = await readFile2(sourcePath, "utf8");
502
+ const rawContent = await readFile3(sourcePath, "utf8");
490
503
  const content = applyTemplateVariables(rawContent, values);
491
504
  await mkdir(dirname2(targetPath), { recursive: true });
492
- await writeFile(targetPath, content, "utf8");
505
+ await writeFile2(targetPath, content, "utf8");
493
506
  }
494
507
  async function createIntegrations(options, projectRoot, templatesDir) {
495
508
  const { projectType } = options;
@@ -612,7 +625,7 @@ async function createScaffold(options, targetDir, templatesDir) {
612
625
  );
613
626
  await runStep(
614
627
  "Copying base tools",
615
- async () => createTools(options.tools, projectRoot, templatesDir)
628
+ async () => createTools(options.tools, projectRoot, templatesDir, projectName)
616
629
  );
617
630
  }
618
631
  await createApps(projectRoot, getAppTargets(options));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smi-digital/create-smi-app",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "bin": {