@smi-digital/create-smi-app 2.3.1 → 2.4.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 CHANGED
@@ -92,16 +92,16 @@ function asFramework(value) {
92
92
  }
93
93
 
94
94
  // src/modules/integrations.ts
95
- import { readFile, readdir } from "fs/promises";
96
- import { join } from "path";
95
+ import { readFile as readFile2, readdir } from "fs/promises";
96
+ import { join as join2 } from "path";
97
97
  async function loadIntegrationConfig(templatesDir, integrationKey) {
98
- const configPath = join(
98
+ const configPath = join2(
99
99
  templatesDir,
100
100
  "integrations",
101
101
  integrationKey,
102
102
  "integration.config.json"
103
103
  );
104
- const rawContent = await readFile(configPath, "utf8");
104
+ const rawContent = await readFile2(configPath, "utf8");
105
105
  return JSON.parse(rawContent);
106
106
  }
107
107
  function matchesIntegration(selection, config) {
@@ -121,7 +121,7 @@ function matchesIntegration(selection, config) {
121
121
  return true;
122
122
  }
123
123
  async function getIntegrationForSelection(templatesDir, selection) {
124
- const integrationsRoot = join(templatesDir, "integrations");
124
+ const integrationsRoot = join2(templatesDir, "integrations");
125
125
  const entries = await readdir(integrationsRoot, { withFileTypes: true });
126
126
  const folders = entries.filter((entry) => entry.isDirectory());
127
127
  const findSequentially = async (index) => {
@@ -274,17 +274,17 @@ async function askQuestions(templatesDir) {
274
274
 
275
275
  // src/modules/init.ts
276
276
  import { fileURLToPath } from "url";
277
- import { join as join2, dirname } from "path";
277
+ import { join as join3, dirname } from "path";
278
278
  import { access } from "fs/promises";
279
279
  async function resolveTemplatesDir(currentDir) {
280
280
  const candidates = [
281
- join2(currentDir, "../../templates"),
282
- join2(currentDir, "../templates")
281
+ join3(currentDir, "../../templates"),
282
+ join3(currentDir, "../templates")
283
283
  ];
284
284
  const checks = await Promise.all(
285
285
  candidates.map(async (candidate) => {
286
286
  try {
287
- await access(join2(candidate, "base"));
287
+ await access(join3(candidate, "base"));
288
288
  return true;
289
289
  } catch {
290
290
  return false;
@@ -311,11 +311,11 @@ async function init() {
311
311
 
312
312
  // src/modules/createScaffold.ts
313
313
  import { access as access2, mkdir as mkdir2 } from "fs/promises";
314
- import { join as join5 } from "path";
314
+ import { join as join6 } from "path";
315
315
 
316
316
  // src/modules/scaffoldActions/createTools.ts
317
- import { cp, readFile as readFile2, readdir as readdir2, writeFile } from "fs/promises";
318
- import { join as join3 } from "path";
317
+ import { cp, readFile as readFile3, readdir as readdir2, writeFile as writeFile2 } from "fs/promises";
318
+ import { join as join4 } from "path";
319
319
  var templateRenameMap = {
320
320
  "env.template": ".env",
321
321
  "gitignore.template": ".gitignore",
@@ -337,32 +337,32 @@ function toPackageName(projectName) {
337
337
  return normalized || "app";
338
338
  }
339
339
  async function updatePackageJsonName(targetDir, projectName) {
340
- const packageJsonPath = join3(targetDir, "package.json");
341
- const packageJsonRaw = await readFile2(packageJsonPath, "utf8");
340
+ const packageJsonPath = join4(targetDir, "package.json");
341
+ const packageJsonRaw = await readFile3(packageJsonPath, "utf8");
342
342
  const packageJson = JSON.parse(packageJsonRaw);
343
343
  packageJson.name = toPackageName(projectName);
344
- await writeFile(packageJsonPath, `${JSON.stringify(packageJson, null, 2)}
344
+ await writeFile2(packageJsonPath, `${JSON.stringify(packageJson, null, 2)}
345
345
  `);
346
346
  }
347
347
  async function createTools(tools, targetDir, templatesDir, projectName) {
348
348
  if (!tools.includes("basic")) {
349
349
  return;
350
350
  }
351
- const baseToolsDir = join3(templatesDir, "base");
352
- const huskyDir = join3(templatesDir, ".husky");
351
+ const baseToolsDir = join4(templatesDir, "base");
352
+ const huskyDir = join4(templatesDir, ".husky");
353
353
  const entries = await readdir2(baseToolsDir, { withFileTypes: true });
354
354
  await Promise.all(
355
355
  entries.map(
356
356
  (entry) => cp(
357
- join3(baseToolsDir, entry.name),
358
- join3(targetDir, getTargetFileName(entry.name)),
357
+ join4(baseToolsDir, entry.name),
358
+ join4(targetDir, getTargetFileName(entry.name)),
359
359
  {
360
360
  recursive: true
361
361
  }
362
362
  )
363
363
  )
364
364
  );
365
- await cp(huskyDir, join3(targetDir, ".husky"), {
365
+ await cp(huskyDir, join4(targetDir, ".husky"), {
366
366
  recursive: true
367
367
  });
368
368
  await updatePackageJsonName(targetDir, projectName);
@@ -478,14 +478,30 @@ async function createApps(projectRoot, targets) {
478
478
  return;
479
479
  }
480
480
  await createFrameworkApp(projectRoot, target);
481
+ if (target.framework === "strapi") {
482
+ try {
483
+ const pluginsPath = join(
484
+ projectRoot,
485
+ target.directory,
486
+ "config/plugins.ts"
487
+ );
488
+ let pluginsContent = await readFile(pluginsPath, "utf8");
489
+ pluginsContent = pluginsContent.replace(
490
+ "export default ({ env }) => ({",
491
+ "export default () => ({"
492
+ );
493
+ await writeFile(pluginsPath, pluginsContent);
494
+ } catch {
495
+ }
496
+ }
481
497
  await runSequentially(index + 1);
482
498
  };
483
499
  await runSequentially(0);
484
500
  }
485
501
 
486
502
  // src/modules/scaffoldActions/createIntegrations.ts
487
- import { mkdir, readFile as readFile3, writeFile as writeFile2 } from "fs/promises";
488
- import { dirname as dirname2, join as join4 } from "path";
503
+ import { mkdir, readFile as readFile4, writeFile as writeFile3 } from "fs/promises";
504
+ import { dirname as dirname2, join as join5 } from "path";
489
505
  import { randomBytes } from "crypto";
490
506
  function toTemplateToken(key) {
491
507
  const normalized = key.replaceAll(/[^a-zA-Z0-9]+/gv, "_").replaceAll(/^_+|_+$/gv, "").toUpperCase();
@@ -499,10 +515,10 @@ function applyTemplateVariables(content, values) {
499
515
  return result;
500
516
  }
501
517
  async function copyTemplateFile(sourcePath, targetPath, values) {
502
- const rawContent = await readFile3(sourcePath, "utf8");
518
+ const rawContent = await readFile4(sourcePath, "utf8");
503
519
  const content = applyTemplateVariables(rawContent, values);
504
520
  await mkdir(dirname2(targetPath), { recursive: true });
505
- await writeFile2(targetPath, content, "utf8");
521
+ await writeFile3(targetPath, content, "utf8");
506
522
  }
507
523
  async function createIntegrations(options, projectRoot, templatesDir) {
508
524
  const { projectType } = options;
@@ -529,7 +545,7 @@ async function createIntegrations(options, projectRoot, templatesDir) {
529
545
  templatesDir,
530
546
  integrationKey
531
547
  );
532
- const integrationRoot = join4(templatesDir, "integrations", integrationKey);
548
+ const integrationRoot = join5(templatesDir, "integrations", integrationKey);
533
549
  const filesToApply = [];
534
550
  if (integrationConfig.workflows) {
535
551
  if (integrationConfig.workflows.prValidation)
@@ -567,8 +583,8 @@ async function createIntegrations(options, projectRoot, templatesDir) {
567
583
  /* eslint-enable camelcase */
568
584
  };
569
585
  return copyTemplateFile(
570
- join4(integrationRoot, file.template),
571
- join4(projectRoot, file.target),
586
+ join5(integrationRoot, file.template),
587
+ join5(projectRoot, file.target),
572
588
  templateValues
573
589
  );
574
590
  });
@@ -611,19 +627,19 @@ function getAppTargets(options) {
611
627
  }
612
628
  async function createProjectStructure(options, projectRoot) {
613
629
  if (options.projectType === "singleProject" && "framework" in options && asFramework(options.framework) === "none") {
614
- await mkdir2(join5(projectRoot, "src"), { recursive: true });
630
+ await mkdir2(join6(projectRoot, "src"), { recursive: true });
615
631
  return;
616
632
  }
617
633
  if (options.projectType !== "monorepo") {
618
634
  return;
619
635
  }
620
636
  await Promise.all([
621
- mkdir2(join5(projectRoot, "backend"), { recursive: true }),
622
- mkdir2(join5(projectRoot, "frontend"), { recursive: true })
637
+ mkdir2(join6(projectRoot, "backend"), { recursive: true }),
638
+ mkdir2(join6(projectRoot, "frontend"), { recursive: true })
623
639
  ]);
624
640
  }
625
641
  async function initializeGitRepository(projectRoot) {
626
- const gitDir = join5(projectRoot, ".git");
642
+ const gitDir = join6(projectRoot, ".git");
627
643
  try {
628
644
  await access2(gitDir);
629
645
  return;
@@ -643,7 +659,7 @@ async function createScaffold(options, targetDir, templatesDir) {
643
659
  throw new Error("Project name cannot be empty.");
644
660
  }
645
661
  console.log();
646
- const projectRoot = join5(targetDir, projectName);
662
+ const projectRoot = join6(targetDir, projectName);
647
663
  await runStep(
648
664
  "Creating project folder",
649
665
  async () => mkdir2(projectRoot, { recursive: true })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smi-digital/create-smi-app",
3
- "version": "2.3.1",
3
+ "version": "2.4.0",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "bin": {
@@ -33,6 +33,7 @@
33
33
  "knip": "^5.86.0",
34
34
  "lint-staged": "^16.3.3",
35
35
  "prettier": "3.8.1",
36
+ "prettier-plugin-astro": "^0.13.0",
36
37
  "tsx": "^4.21.0",
37
38
  "typescript": "^5.9.3",
38
39
  "typescript-eslint": "^8.57.0"
@@ -1 +1,11 @@
1
- {}
1
+ {
2
+ "plugins": ["prettier-plugin-astro"],
3
+ "overrides": [
4
+ {
5
+ "files": "*.astro",
6
+ "options": {
7
+ "parser": "astro"
8
+ }
9
+ }
10
+ ]
11
+ }
@@ -13,7 +13,7 @@ WORKDIR /opt/
13
13
  COPY package.json ./
14
14
  RUN npm install -g node-gyp
15
15
  RUN npm config set fetch-retry-maxtimeout 600000 -g && npm install --only=production
16
- ENV PATH /opt/node_modules/.bin:$PATH
16
+ ENV PATH=/opt/node_modules/.bin:$PATH
17
17
 
18
18
  WORKDIR /opt/app
19
19
  COPY . .
@@ -6,7 +6,7 @@
6
6
  # Stage 1: Build with Bun
7
7
  FROM oven/bun:1 as builder
8
8
  WORKDIR /app
9
- COPY package.json bun.lock ./
9
+ COPY package.json package-lock.json ./
10
10
  RUN bun install
11
11
  COPY . .
12
12
  RUN bun run build