create-blitzpack 0.1.19 → 0.1.20
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 +78 -30
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -7,10 +7,10 @@ import { dirname, join } from "path";
|
|
|
7
7
|
import { fileURLToPath } from "url";
|
|
8
8
|
|
|
9
9
|
// src/commands/create.ts
|
|
10
|
+
import { confirm as confirm2, isCancel as isCancel2 } from "@clack/prompts";
|
|
10
11
|
import chalk4 from "chalk";
|
|
11
12
|
import { spawn } from "child_process";
|
|
12
13
|
import fs3 from "fs-extra";
|
|
13
|
-
import { confirm as confirm2, isCancel as isCancel2 } from "@clack/prompts";
|
|
14
14
|
import ora2 from "ora";
|
|
15
15
|
import path4 from "path";
|
|
16
16
|
|
|
@@ -203,7 +203,6 @@ async function runPreflightChecks() {
|
|
|
203
203
|
}
|
|
204
204
|
|
|
205
205
|
// src/prompts.ts
|
|
206
|
-
import chalk3 from "chalk";
|
|
207
206
|
import {
|
|
208
207
|
cancel,
|
|
209
208
|
confirm,
|
|
@@ -213,6 +212,7 @@ import {
|
|
|
213
212
|
select,
|
|
214
213
|
text
|
|
215
214
|
} from "@clack/prompts";
|
|
215
|
+
import chalk3 from "chalk";
|
|
216
216
|
|
|
217
217
|
// src/constants.ts
|
|
218
218
|
var REPLACEABLE_FILES = [
|
|
@@ -534,7 +534,10 @@ function finalizeOptions(state, providedName, flags) {
|
|
|
534
534
|
const validation = validateProjectName(projectName);
|
|
535
535
|
if (!validation.valid) {
|
|
536
536
|
console.log();
|
|
537
|
-
console.log(
|
|
537
|
+
console.log(
|
|
538
|
+
chalk3.red(" \u2716"),
|
|
539
|
+
validation.problems?.[0] ?? "Invalid project name"
|
|
540
|
+
);
|
|
538
541
|
return null;
|
|
539
542
|
}
|
|
540
543
|
const useCurrentDir = projectName === ".";
|
|
@@ -597,7 +600,11 @@ async function getProjectOptions(providedName, flags = {}) {
|
|
|
597
600
|
continue;
|
|
598
601
|
}
|
|
599
602
|
if (stage === "profile") {
|
|
600
|
-
printWizardStep(
|
|
603
|
+
printWizardStep(
|
|
604
|
+
2,
|
|
605
|
+
getStepTotal(state.profileKey),
|
|
606
|
+
"Choose a setup preset"
|
|
607
|
+
);
|
|
601
608
|
const profileAction = handleCancelledPrompt(
|
|
602
609
|
await select({
|
|
603
610
|
message: chalk3.cyan("Setup preset"),
|
|
@@ -638,17 +645,23 @@ async function getProjectOptions(providedName, flags = {}) {
|
|
|
638
645
|
}
|
|
639
646
|
if (stage === "features") {
|
|
640
647
|
const isModular = state.profileKey === "modular";
|
|
641
|
-
printWizardStep(
|
|
648
|
+
printWizardStep(
|
|
649
|
+
3,
|
|
650
|
+
4,
|
|
651
|
+
isModular ? "Select features" : "Deployment options"
|
|
652
|
+
);
|
|
642
653
|
if (isModular) {
|
|
643
654
|
printMultiselectControls();
|
|
644
655
|
const selectedFeatures = handleCancelledPrompt(
|
|
645
656
|
await multiselect({
|
|
646
657
|
message: chalk3.cyan("Select features"),
|
|
647
|
-
options: [...APP_FEATURES, ...DEPLOYMENT_FEATURES].map(
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
658
|
+
options: [...APP_FEATURES, ...DEPLOYMENT_FEATURES].map(
|
|
659
|
+
(feature) => ({
|
|
660
|
+
value: feature.key,
|
|
661
|
+
label: FEATURE_LABELS[feature.key],
|
|
662
|
+
hint: FEATURE_HINTS[feature.key]
|
|
663
|
+
})
|
|
664
|
+
),
|
|
652
665
|
initialValues: state.selectedFeatures,
|
|
653
666
|
required: false
|
|
654
667
|
})
|
|
@@ -699,7 +712,11 @@ async function getProjectOptions(providedName, flags = {}) {
|
|
|
699
712
|
}
|
|
700
713
|
const features = options.features;
|
|
701
714
|
const reviewStep = state.profileKey === "modular" ? 4 : 3;
|
|
702
|
-
printWizardStep(
|
|
715
|
+
printWizardStep(
|
|
716
|
+
reviewStep,
|
|
717
|
+
getStepTotal(state.profileKey),
|
|
718
|
+
"Review and confirm"
|
|
719
|
+
);
|
|
703
720
|
printConfigurationSummary(profile.name, features);
|
|
704
721
|
const reviewOptions = [
|
|
705
722
|
{
|
|
@@ -773,7 +790,9 @@ var GITHUB_REPO = "github:CarboxyDev/blitzpack";
|
|
|
773
790
|
var POST_DOWNLOAD_EXCLUDES = [
|
|
774
791
|
"create-blitzpack",
|
|
775
792
|
"apps/marketing",
|
|
776
|
-
"CONTRIBUTING.md"
|
|
793
|
+
"CONTRIBUTING.md",
|
|
794
|
+
"docs/create-blitzpack-scaffolding-maintenance-plan.md",
|
|
795
|
+
"pnpm-lock.yaml"
|
|
777
796
|
];
|
|
778
797
|
function getFeatureExclusions(features) {
|
|
779
798
|
const exclusions = [];
|
|
@@ -1360,7 +1379,8 @@ ${vars.projectDescription}
|
|
|
1360
1379
|
|
|
1361
1380
|
\`\`\`bash
|
|
1362
1381
|
pnpm install
|
|
1363
|
-
|
|
1382
|
+
docker compose up -d
|
|
1383
|
+
pnpm db:migrate
|
|
1364
1384
|
pnpm dev
|
|
1365
1385
|
\`\`\`
|
|
1366
1386
|
|
|
@@ -1658,6 +1678,21 @@ function runInstall(cwd) {
|
|
|
1658
1678
|
child.on("error", () => resolve(false));
|
|
1659
1679
|
});
|
|
1660
1680
|
}
|
|
1681
|
+
function installGitHooks(cwd) {
|
|
1682
|
+
return new Promise((resolve) => {
|
|
1683
|
+
const isWindows = process.platform === "win32";
|
|
1684
|
+
const child = spawn(
|
|
1685
|
+
isWindows ? "pnpm.cmd" : "pnpm",
|
|
1686
|
+
["exec", "husky"],
|
|
1687
|
+
{
|
|
1688
|
+
cwd,
|
|
1689
|
+
stdio: "ignore"
|
|
1690
|
+
}
|
|
1691
|
+
);
|
|
1692
|
+
child.on("close", (code) => resolve(code === 0));
|
|
1693
|
+
child.on("error", () => resolve(false));
|
|
1694
|
+
});
|
|
1695
|
+
}
|
|
1661
1696
|
function renderProgressBar(current, total) {
|
|
1662
1697
|
const width = 28;
|
|
1663
1698
|
const clampedTotal = Math.max(total, 1);
|
|
@@ -1725,12 +1760,12 @@ function printDryRun(options) {
|
|
|
1725
1760
|
console.log(` ${chalk4.dim("\u2022")} Download template from GitHub`);
|
|
1726
1761
|
console.log(` ${chalk4.dim("\u2022")} Transform package.json files`);
|
|
1727
1762
|
console.log(` ${chalk4.dim("\u2022")} Create .env.local files`);
|
|
1728
|
-
if (!options.skipGit) {
|
|
1729
|
-
console.log(` ${chalk4.dim("\u2022")} Initialize git repository`);
|
|
1730
|
-
}
|
|
1731
1763
|
if (!options.skipInstall) {
|
|
1732
1764
|
console.log(` ${chalk4.dim("\u2022")} Install dependencies (pnpm install)`);
|
|
1733
1765
|
}
|
|
1766
|
+
if (!options.skipGit) {
|
|
1767
|
+
console.log(` ${chalk4.dim("\u2022")} Initialize git repository`);
|
|
1768
|
+
}
|
|
1734
1769
|
console.log();
|
|
1735
1770
|
}
|
|
1736
1771
|
async function create(projectName, flags) {
|
|
@@ -1777,6 +1812,7 @@ async function create(projectName, flags) {
|
|
|
1777
1812
|
const totalSteps = 2 + (options.skipGit ? 0 : 1) + (options.skipInstall ? 0 : 1) + (shouldRunSetup ? 1 : 0);
|
|
1778
1813
|
let currentStep = 0;
|
|
1779
1814
|
let spinner;
|
|
1815
|
+
let installSucceeded = false;
|
|
1780
1816
|
try {
|
|
1781
1817
|
currentStep += 1;
|
|
1782
1818
|
printStepHeader(currentStep, totalSteps, "Scaffold template");
|
|
@@ -1796,13 +1832,38 @@ async function create(projectName, flags) {
|
|
|
1796
1832
|
);
|
|
1797
1833
|
await copyEnvFiles(targetDir);
|
|
1798
1834
|
spinner.succeed("Configured project");
|
|
1835
|
+
if (!options.skipInstall) {
|
|
1836
|
+
currentStep += 1;
|
|
1837
|
+
printStepHeader(currentStep, totalSteps, "Install dependencies");
|
|
1838
|
+
spinner.start("Installing dependencies...");
|
|
1839
|
+
installSucceeded = await runInstall(targetDir);
|
|
1840
|
+
if (installSucceeded) {
|
|
1841
|
+
spinner.succeed("Installed dependencies");
|
|
1842
|
+
} else {
|
|
1843
|
+
spinner.warn(
|
|
1844
|
+
'Failed to install dependencies. Run "pnpm install" manually.'
|
|
1845
|
+
);
|
|
1846
|
+
}
|
|
1847
|
+
}
|
|
1799
1848
|
if (!options.skipGit && isGitInstalled()) {
|
|
1800
1849
|
currentStep += 1;
|
|
1801
1850
|
printStepHeader(currentStep, totalSteps, "Initialize git repository");
|
|
1802
1851
|
spinner.start("Initializing git repository...");
|
|
1803
1852
|
const gitSuccess = initGit(targetDir);
|
|
1804
1853
|
if (gitSuccess) {
|
|
1805
|
-
|
|
1854
|
+
if (installSucceeded) {
|
|
1855
|
+
spinner.start("Installing git hooks...");
|
|
1856
|
+
const hooksSuccess = await installGitHooks(targetDir);
|
|
1857
|
+
if (hooksSuccess) {
|
|
1858
|
+
spinner.succeed("Initialized git repository");
|
|
1859
|
+
} else {
|
|
1860
|
+
spinner.warn(
|
|
1861
|
+
"Initialized git repository, but failed to install git hooks"
|
|
1862
|
+
);
|
|
1863
|
+
}
|
|
1864
|
+
} else {
|
|
1865
|
+
spinner.succeed("Initialized git repository");
|
|
1866
|
+
}
|
|
1806
1867
|
} else {
|
|
1807
1868
|
spinner.warn("Failed to initialize git repository");
|
|
1808
1869
|
}
|
|
@@ -1811,19 +1872,6 @@ async function create(projectName, flags) {
|
|
|
1811
1872
|
printStepHeader(currentStep, totalSteps, "Initialize git repository");
|
|
1812
1873
|
spinner.warn("Skipped git initialization (git not installed)");
|
|
1813
1874
|
}
|
|
1814
|
-
if (!options.skipInstall) {
|
|
1815
|
-
currentStep += 1;
|
|
1816
|
-
printStepHeader(currentStep, totalSteps, "Install dependencies");
|
|
1817
|
-
spinner.start("Installing dependencies...");
|
|
1818
|
-
const success = await runInstall(targetDir);
|
|
1819
|
-
if (success) {
|
|
1820
|
-
spinner.succeed("Installed dependencies");
|
|
1821
|
-
} else {
|
|
1822
|
-
spinner.warn(
|
|
1823
|
-
'Failed to install dependencies. Run "pnpm install" manually.'
|
|
1824
|
-
);
|
|
1825
|
-
}
|
|
1826
|
-
}
|
|
1827
1875
|
let ranAutomaticSetup = false;
|
|
1828
1876
|
if (shouldRunSetup) {
|
|
1829
1877
|
currentStep += 1;
|