@smi-digital/create-smi-app 2.7.1 → 2.7.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.
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
|
|
96
|
-
import { join
|
|
95
|
+
import { readFile, readdir } from "fs/promises";
|
|
96
|
+
import { join } from "path";
|
|
97
97
|
async function loadIntegrationConfig(templatesDir, integrationKey) {
|
|
98
|
-
const configPath =
|
|
98
|
+
const configPath = join(
|
|
99
99
|
templatesDir,
|
|
100
100
|
"integrations",
|
|
101
101
|
integrationKey,
|
|
102
102
|
"integration.config.json"
|
|
103
103
|
);
|
|
104
|
-
const rawContent = await
|
|
104
|
+
const rawContent = await readFile(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 =
|
|
124
|
+
const integrationsRoot = join(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
|
|
277
|
+
import { join as join2, dirname } from "path";
|
|
278
278
|
import { access } from "fs/promises";
|
|
279
279
|
async function resolveTemplatesDir(currentDir) {
|
|
280
280
|
const candidates = [
|
|
281
|
-
|
|
282
|
-
|
|
281
|
+
join2(currentDir, "../../templates"),
|
|
282
|
+
join2(currentDir, "../templates")
|
|
283
283
|
];
|
|
284
284
|
const checks = await Promise.all(
|
|
285
285
|
candidates.map(async (candidate) => {
|
|
286
286
|
try {
|
|
287
|
-
await access(
|
|
287
|
+
await access(join2(candidate, "base"));
|
|
288
288
|
return true;
|
|
289
289
|
} catch {
|
|
290
290
|
return false;
|
|
@@ -314,8 +314,8 @@ import { access as access2, mkdir as mkdir2 } from "fs/promises";
|
|
|
314
314
|
import { join as join6 } from "path";
|
|
315
315
|
|
|
316
316
|
// src/modules/scaffoldActions/createTools.ts
|
|
317
|
-
import { cp, readFile as
|
|
318
|
-
import { join as
|
|
317
|
+
import { cp, readFile as readFile2, readdir as readdir2, writeFile } from "fs/promises";
|
|
318
|
+
import { join as join3 } 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 =
|
|
341
|
-
const packageJsonRaw = await
|
|
340
|
+
const packageJsonPath = join3(targetDir, "package.json");
|
|
341
|
+
const packageJsonRaw = await readFile2(packageJsonPath, "utf8");
|
|
342
342
|
const packageJson = JSON.parse(packageJsonRaw);
|
|
343
343
|
packageJson.name = toPackageName(projectName);
|
|
344
|
-
await
|
|
344
|
+
await writeFile(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 =
|
|
352
|
-
const huskyDir =
|
|
351
|
+
const baseToolsDir = join3(templatesDir, "base");
|
|
352
|
+
const huskyDir = join3(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
|
-
|
|
358
|
-
|
|
357
|
+
join3(baseToolsDir, entry.name),
|
|
358
|
+
join3(targetDir, getTargetFileName(entry.name)),
|
|
359
359
|
{
|
|
360
360
|
recursive: true
|
|
361
361
|
}
|
|
362
362
|
)
|
|
363
363
|
)
|
|
364
364
|
);
|
|
365
|
-
await cp(huskyDir,
|
|
365
|
+
await cp(huskyDir, join3(targetDir, ".husky"), {
|
|
366
366
|
recursive: true
|
|
367
367
|
});
|
|
368
368
|
await updatePackageJsonName(targetDir, projectName);
|
|
@@ -424,7 +424,7 @@ async function runStep(label, task) {
|
|
|
424
424
|
throw error;
|
|
425
425
|
}
|
|
426
426
|
}
|
|
427
|
-
async function
|
|
427
|
+
async function runCommandQuiet(command, args, cwd) {
|
|
428
428
|
await new Promise((resolve, reject) => {
|
|
429
429
|
let stderr = "";
|
|
430
430
|
const child = spawn(command, args, {
|
|
@@ -457,6 +457,8 @@ ${stderrTail}` : "";
|
|
|
457
457
|
}
|
|
458
458
|
|
|
459
459
|
// src/modules/scaffoldActions/createApps.ts
|
|
460
|
+
import { join as join4 } from "path";
|
|
461
|
+
import { readFile as readFile3, writeFile as writeFile2 } from "fs/promises";
|
|
460
462
|
async function createFrameworkApp(projectRoot, target) {
|
|
461
463
|
const generator = FRAMEWORK_GENERATORS[target.framework];
|
|
462
464
|
if (!generator) {
|
|
@@ -464,7 +466,7 @@ async function createFrameworkApp(projectRoot, target) {
|
|
|
464
466
|
}
|
|
465
467
|
await runStep(
|
|
466
468
|
`Creating ${generator.displayName} ${target.label}`,
|
|
467
|
-
async () =>
|
|
469
|
+
async () => runCommandQuiet(
|
|
468
470
|
generator.command,
|
|
469
471
|
generator.getArgs(target.directory),
|
|
470
472
|
projectRoot
|
|
@@ -480,17 +482,17 @@ async function createApps(projectRoot, targets) {
|
|
|
480
482
|
await createFrameworkApp(projectRoot, target);
|
|
481
483
|
if (target.framework === "strapi") {
|
|
482
484
|
try {
|
|
483
|
-
const pluginsPath =
|
|
485
|
+
const pluginsPath = join4(
|
|
484
486
|
projectRoot,
|
|
485
487
|
target.directory,
|
|
486
488
|
"config/plugins.ts"
|
|
487
489
|
);
|
|
488
|
-
let pluginsContent = await
|
|
490
|
+
let pluginsContent = await readFile3(pluginsPath, "utf8");
|
|
489
491
|
pluginsContent = pluginsContent.replace(
|
|
490
492
|
"export default ({ env }) => ({",
|
|
491
493
|
"export default () => ({"
|
|
492
494
|
);
|
|
493
|
-
await
|
|
495
|
+
await writeFile2(pluginsPath, pluginsContent);
|
|
494
496
|
} catch {
|
|
495
497
|
}
|
|
496
498
|
}
|
|
@@ -608,7 +610,10 @@ async function createIntegrations(options, projectRoot, templatesDir) {
|
|
|
608
610
|
"export default defineConfig({\n output: 'server',"
|
|
609
611
|
);
|
|
610
612
|
await writeFile3(astroConfigPath, astroConfig);
|
|
611
|
-
} catch {
|
|
613
|
+
} catch (error) {
|
|
614
|
+
console.warn(
|
|
615
|
+
`Could not configure the Astro SSR adapter automatically: ${error instanceof Error ? error.message : String(error)}`
|
|
616
|
+
);
|
|
612
617
|
}
|
|
613
618
|
});
|
|
614
619
|
}
|
|
@@ -660,7 +665,7 @@ async function initializeGitRepository(projectRoot) {
|
|
|
660
665
|
} catch {
|
|
661
666
|
}
|
|
662
667
|
try {
|
|
663
|
-
await
|
|
668
|
+
await runCommandQuiet("git", ["init"], projectRoot);
|
|
664
669
|
} catch {
|
|
665
670
|
console.warn(
|
|
666
671
|
"Git is not available. Husky hooks will activate after running git init."
|
|
@@ -673,7 +678,7 @@ async function activateVaultFilter(projectRoot) {
|
|
|
673
678
|
} catch {
|
|
674
679
|
return;
|
|
675
680
|
}
|
|
676
|
-
const setFilter = async (key, value) =>
|
|
681
|
+
const setFilter = async (key, value) => runCommandQuiet(
|
|
677
682
|
"git",
|
|
678
683
|
["config", `filter.ansible-vault.${key}`, value],
|
|
679
684
|
projectRoot
|
|
@@ -730,7 +735,7 @@ async function createScaffold(options, targetDir, templatesDir) {
|
|
|
730
735
|
if (options.tools.includes("basic")) {
|
|
731
736
|
await runStep(
|
|
732
737
|
"Installing root dependencies",
|
|
733
|
-
async () =>
|
|
738
|
+
async () => runCommandQuiet("npm", ["install"], projectRoot)
|
|
734
739
|
);
|
|
735
740
|
}
|
|
736
741
|
console.log(accent2(`\u25C6 Project scaffolded at ${projectRoot}`));
|
package/package.json
CHANGED
|
@@ -61,7 +61,9 @@ services:
|
|
|
61
61
|
depends_on:
|
|
62
62
|
- __APP_NAME__-astro
|
|
63
63
|
healthcheck:
|
|
64
|
-
|
|
64
|
+
# Use 127.0.0.1 (not localhost): the read-only config mount blocks nginx's
|
|
65
|
+
# IPv6 listen, but busybox wget resolves localhost to ::1 first → refused.
|
|
66
|
+
test: ["CMD", "wget", "-q", "-O", "/dev/null", "http://127.0.0.1/healthz"]
|
|
65
67
|
interval: 5s
|
|
66
68
|
timeout: 2s
|
|
67
69
|
retries: 5
|
|
@@ -7,6 +7,15 @@ server {
|
|
|
7
7
|
gzip on;
|
|
8
8
|
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
|
|
9
9
|
|
|
10
|
+
# Liveness endpoint for the container healthcheck. Returns 200 from nginx
|
|
11
|
+
# itself, so health reflects "the proxy is up" rather than the upstream
|
|
12
|
+
# homepage's status code.
|
|
13
|
+
location = /healthz {
|
|
14
|
+
access_log off;
|
|
15
|
+
add_header Content-Type text/plain;
|
|
16
|
+
return 200 "ok\n";
|
|
17
|
+
}
|
|
18
|
+
|
|
10
19
|
location / {
|
|
11
20
|
proxy_cache astro_cache;
|
|
12
21
|
|