create-morax 2.0.1 → 2.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.
- package/dist/index.js +67 -37
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -52,8 +52,8 @@ import { promisify } from "util";
|
|
|
52
52
|
import pc2 from "picocolors";
|
|
53
53
|
var execAsync = promisify(exec);
|
|
54
54
|
async function runCommand(command, options = {}) {
|
|
55
|
-
options.silent
|
|
56
|
-
if (!
|
|
55
|
+
const isSilent = options.silent ?? true;
|
|
56
|
+
if (!isSilent) {
|
|
57
57
|
console.log(pc2.cyan(`> ${command}`));
|
|
58
58
|
}
|
|
59
59
|
try {
|
|
@@ -61,7 +61,7 @@ async function runCommand(command, options = {}) {
|
|
|
61
61
|
cwd: options.cwd,
|
|
62
62
|
env: { ...process.env, NODE_NO_WARNINGS: "1" }
|
|
63
63
|
});
|
|
64
|
-
if (!
|
|
64
|
+
if (!isSilent) {
|
|
65
65
|
if (stdout && stdout.trim()) {
|
|
66
66
|
console.log(stdout.trim());
|
|
67
67
|
}
|
|
@@ -71,13 +71,16 @@ async function runCommand(command, options = {}) {
|
|
|
71
71
|
}
|
|
72
72
|
return { stdout, stderr };
|
|
73
73
|
} catch (error) {
|
|
74
|
-
if (!
|
|
74
|
+
if (!isSilent) {
|
|
75
75
|
if (error.stdout && error.stdout.trim()) {
|
|
76
76
|
console.log(error.stdout.trim());
|
|
77
77
|
}
|
|
78
78
|
if (error.stderr && error.stderr.trim()) {
|
|
79
79
|
console.error(pc2.red(error.stderr.trim()));
|
|
80
80
|
}
|
|
81
|
+
} else if (error.stderr && error.stderr.trim()) {
|
|
82
|
+
error.message = `${error.message}
|
|
83
|
+
${error.stderr.trim()}`;
|
|
81
84
|
}
|
|
82
85
|
throw error;
|
|
83
86
|
}
|
|
@@ -447,27 +450,27 @@ async function setupDrizzle(projectPath, dialect = "postgresql", linter = "none"
|
|
|
447
450
|
if (dialect === "sqlite") {
|
|
448
451
|
await runCommand("pnpm add drizzle-orm@rc @libsql/client dotenv", {
|
|
449
452
|
cwd: dbDir,
|
|
450
|
-
silent:
|
|
453
|
+
silent: true
|
|
451
454
|
});
|
|
452
455
|
} else if (postgresProvider === "neon") {
|
|
453
456
|
await runCommand(
|
|
454
457
|
"pnpm add drizzle-orm@rc @neondatabase/serverless dotenv",
|
|
455
458
|
{
|
|
456
459
|
cwd: dbDir,
|
|
457
|
-
silent:
|
|
460
|
+
silent: true
|
|
458
461
|
}
|
|
459
462
|
);
|
|
460
463
|
} else {
|
|
461
464
|
await runCommand("pnpm add drizzle-orm@rc pg dotenv @types/pg", {
|
|
462
465
|
cwd: dbDir,
|
|
463
|
-
silent:
|
|
466
|
+
silent: true
|
|
464
467
|
});
|
|
465
468
|
}
|
|
466
469
|
await runCommand(
|
|
467
470
|
"pnpm add -D drizzle-kit@rc @types/node tsx typescript@latest",
|
|
468
471
|
{
|
|
469
472
|
cwd: dbDir,
|
|
470
|
-
silent:
|
|
473
|
+
silent: true
|
|
471
474
|
}
|
|
472
475
|
);
|
|
473
476
|
const envVar = dialect === "sqlite" ? "DB_FILE_NAME" : "DATABASE_URL";
|
|
@@ -1121,19 +1124,20 @@ async function setupReact(projectPath, isMonorepo = true) {
|
|
|
1121
1124
|
`Vite React application directory "apps/${createdDirName}" was not found. Please ensure you complete the Vite installation.`
|
|
1122
1125
|
);
|
|
1123
1126
|
}
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1127
|
+
const pkgPath = path2.join(webDir, "package.json");
|
|
1128
|
+
try {
|
|
1129
|
+
const pkgRaw = await fsPromises3.readFile(pkgPath, "utf8");
|
|
1130
|
+
const pkg = JSON.parse(pkgRaw);
|
|
1131
|
+
if (isMonorepo) {
|
|
1129
1132
|
pkg.name = "web";
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
"
|
|
1134
|
-
|
|
1135
|
-
} catch {
|
|
1133
|
+
} else {
|
|
1134
|
+
pkg.pnpm = {
|
|
1135
|
+
...pkg.pnpm || {},
|
|
1136
|
+
onlyBuiltDependencies: ["esbuild"]
|
|
1137
|
+
};
|
|
1136
1138
|
}
|
|
1139
|
+
await fsPromises3.writeFile(pkgPath, JSON.stringify(pkg, null, 2), "utf8");
|
|
1140
|
+
} catch {
|
|
1137
1141
|
}
|
|
1138
1142
|
const aliasSpinner = spinner2();
|
|
1139
1143
|
aliasSpinner.start("Configuring import aliases and Node types...");
|
|
@@ -1632,19 +1636,24 @@ async function setupNextjs(projectPath, isMonorepo = true) {
|
|
|
1632
1636
|
} catch {
|
|
1633
1637
|
}
|
|
1634
1638
|
}
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1639
|
+
const webPkgPath = path6.join(webDir, "package.json");
|
|
1640
|
+
try {
|
|
1641
|
+
const webPkgRaw = await fsPromises6.readFile(webPkgPath, "utf8");
|
|
1642
|
+
const webPkg = JSON.parse(webPkgRaw);
|
|
1643
|
+
if (isMonorepo) {
|
|
1640
1644
|
webPkg.name = "web";
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
"
|
|
1645
|
-
|
|
1646
|
-
} catch {
|
|
1645
|
+
} else {
|
|
1646
|
+
webPkg.pnpm = {
|
|
1647
|
+
...webPkg.pnpm || {},
|
|
1648
|
+
onlyBuiltDependencies: ["sharp"]
|
|
1649
|
+
};
|
|
1647
1650
|
}
|
|
1651
|
+
await fsPromises6.writeFile(
|
|
1652
|
+
webPkgPath,
|
|
1653
|
+
JSON.stringify(webPkg, null, 2),
|
|
1654
|
+
"utf8"
|
|
1655
|
+
);
|
|
1656
|
+
} catch {
|
|
1648
1657
|
}
|
|
1649
1658
|
return webDir;
|
|
1650
1659
|
}
|
|
@@ -1753,9 +1762,21 @@ import fsPromises8 from "fs/promises";
|
|
|
1753
1762
|
import path9 from "path";
|
|
1754
1763
|
async function generateWorkspaceConfig(name, directories, projectPath) {
|
|
1755
1764
|
await fsPromises8.mkdir(projectPath, { recursive: true });
|
|
1765
|
+
const defaultOnlyBuiltDeps = [
|
|
1766
|
+
"esbuild",
|
|
1767
|
+
"@biomejs/biome",
|
|
1768
|
+
"oxlint",
|
|
1769
|
+
"lefthook",
|
|
1770
|
+
"sharp"
|
|
1771
|
+
];
|
|
1756
1772
|
const workspaceYamlContent = [
|
|
1757
1773
|
"packages:",
|
|
1758
1774
|
...directories.map((dir) => ` - '${dir}/*'`),
|
|
1775
|
+
"",
|
|
1776
|
+
"onlyBuiltDependencies:",
|
|
1777
|
+
...defaultOnlyBuiltDeps.map(
|
|
1778
|
+
(dep) => dep.startsWith("@") ? ` - '${dep}'` : ` - ${dep}`
|
|
1779
|
+
),
|
|
1759
1780
|
""
|
|
1760
1781
|
].join("\n");
|
|
1761
1782
|
await fsPromises8.writeFile(
|
|
@@ -2832,8 +2853,14 @@ import pc16 from "picocolors";
|
|
|
2832
2853
|
import fsPromises16 from "fs/promises";
|
|
2833
2854
|
import path17 from "path";
|
|
2834
2855
|
async function setupHusky(projectPath) {
|
|
2835
|
-
await runCommand("pnpm add -D -E husky -w", {
|
|
2836
|
-
|
|
2856
|
+
await runCommand("pnpm add -D -E husky -w", {
|
|
2857
|
+
cwd: projectPath,
|
|
2858
|
+
silent: true
|
|
2859
|
+
});
|
|
2860
|
+
await runCommand("pnpm exec husky init", {
|
|
2861
|
+
cwd: projectPath,
|
|
2862
|
+
silent: true
|
|
2863
|
+
});
|
|
2837
2864
|
const preCommitPath = path17.join(projectPath, ".husky", "pre-commit");
|
|
2838
2865
|
let hookContent = "";
|
|
2839
2866
|
try {
|
|
@@ -3076,7 +3103,10 @@ import pc20 from "picocolors";
|
|
|
3076
3103
|
import fsPromises20 from "fs/promises";
|
|
3077
3104
|
import path21 from "path";
|
|
3078
3105
|
async function setupPrettier(projectPath) {
|
|
3079
|
-
await runCommand("pnpm add -D -E prettier -w", {
|
|
3106
|
+
await runCommand("pnpm add -D -E prettier -w", {
|
|
3107
|
+
cwd: projectPath,
|
|
3108
|
+
silent: true
|
|
3109
|
+
});
|
|
3080
3110
|
const prettierConfig = {
|
|
3081
3111
|
semi: true,
|
|
3082
3112
|
singleQuote: true,
|
|
@@ -3437,12 +3467,12 @@ async function setupExpress(options) {
|
|
|
3437
3467
|
const deps = getExpressDependencies();
|
|
3438
3468
|
await runCommand(`pnpm add ${deps.join(" ")}`, {
|
|
3439
3469
|
cwd: serverDir,
|
|
3440
|
-
silent:
|
|
3470
|
+
silent: true
|
|
3441
3471
|
});
|
|
3442
3472
|
const devDeps = getExpressDevDependencies(runtime);
|
|
3443
3473
|
await runCommand(`pnpm add -D ${devDeps.join(" ")}`, {
|
|
3444
3474
|
cwd: serverDir,
|
|
3445
|
-
silent:
|
|
3475
|
+
silent: true
|
|
3446
3476
|
});
|
|
3447
3477
|
const indexTsContent = runtime === "bun" ? renderExpressBunTemplate(hasDb) : renderExpressNodeTemplate(hasDb);
|
|
3448
3478
|
await fsPromises22.writeFile(
|
|
@@ -3688,12 +3718,12 @@ async function setupHono(options) {
|
|
|
3688
3718
|
const deps = getHonoDependencies(runtime);
|
|
3689
3719
|
await runCommand(`pnpm add ${deps.join(" ")}`, {
|
|
3690
3720
|
cwd: serverDir,
|
|
3691
|
-
silent:
|
|
3721
|
+
silent: true
|
|
3692
3722
|
});
|
|
3693
3723
|
const devDeps = getHonoDevDependencies(runtime);
|
|
3694
3724
|
await runCommand(`pnpm add -D ${devDeps.join(" ")}`, {
|
|
3695
3725
|
cwd: serverDir,
|
|
3696
|
-
silent:
|
|
3726
|
+
silent: true
|
|
3697
3727
|
});
|
|
3698
3728
|
const indexTsContent = runtime === "bun" ? renderHonoBunTemplate(hasDb) : renderHonoNodeTemplate(hasDb);
|
|
3699
3729
|
await fsPromises23.writeFile(
|