Skip to content

Commit e5ceca3

Browse files
committed
Update create-blitzpack, clean scaffold output and stabilize setup flow
1 parent 1ceecc8 commit e5ceca3

6 files changed

Lines changed: 51 additions & 23 deletions

File tree

apps/api/test/helpers/test-db.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
1-
import 'dotenv-flow/config';
2-
31
import { PrismaPg } from '@prisma/adapter-pg';
42
import { execSync } from 'child_process';
3+
import dotenvFlow from 'dotenv-flow';
54
import { Pool } from 'pg';
65

76
import { PrismaClient } from '@/generated/client/client.js';
87

98
let prisma: PrismaClient | null = null;
109
let pool: Pool | null = null;
1110

11+
dotenvFlow.config({ silent: true });
12+
1213
/**
1314
* Get test database URL
1415
* Uses DATABASE_URL from env but appends _test suffix to database name

create-blitzpack/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "create-blitzpack",
3-
"version": "0.1.19",
3+
"version": "0.1.20",
44
"description": "Create a new Blitzpack project - full-stack TypeScript monorepo with Next.js and Fastify",
55
"type": "module",
66
"bin": {

create-blitzpack/src/commands/create.ts

Lines changed: 43 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,18 @@ function runInstall(cwd: string): Promise<boolean> {
4141
});
4242
}
4343

44+
function installGitHooks(cwd: string): Promise<boolean> {
45+
return new Promise((resolve) => {
46+
const isWindows = process.platform === 'win32';
47+
const child = spawn(isWindows ? 'pnpm.cmd' : 'pnpm', ['exec', 'husky'], {
48+
cwd,
49+
stdio: 'ignore',
50+
});
51+
child.on('close', (code) => resolve(code === 0));
52+
child.on('error', () => resolve(false));
53+
});
54+
}
55+
4456
interface CreateFlags {
4557
skipGit?: boolean;
4658
skipInstall?: boolean;
@@ -128,12 +140,12 @@ function printDryRun(options: {
128140
console.log(` ${chalk.dim('•')} Download template from GitHub`);
129141
console.log(` ${chalk.dim('•')} Transform package.json files`);
130142
console.log(` ${chalk.dim('•')} Create .env.local files`);
131-
if (!options.skipGit) {
132-
console.log(` ${chalk.dim('•')} Initialize git repository`);
133-
}
134143
if (!options.skipInstall) {
135144
console.log(` ${chalk.dim('•')} Install dependencies (pnpm install)`);
136145
}
146+
if (!options.skipGit) {
147+
console.log(` ${chalk.dim('•')} Initialize git repository`);
148+
}
137149
console.log();
138150
}
139151

@@ -198,6 +210,7 @@ export async function create(
198210
(shouldRunSetup ? 1 : 0);
199211
let currentStep = 0;
200212
let spinner: Ora | undefined;
213+
let installSucceeded = false;
201214

202215
try {
203216
currentStep += 1;
@@ -220,13 +233,39 @@ export async function create(
220233
await copyEnvFiles(targetDir);
221234
spinner.succeed('Configured project');
222235

236+
if (!options.skipInstall) {
237+
currentStep += 1;
238+
printStepHeader(currentStep, totalSteps, 'Install dependencies');
239+
spinner.start('Installing dependencies...');
240+
installSucceeded = await runInstall(targetDir);
241+
if (installSucceeded) {
242+
spinner.succeed('Installed dependencies');
243+
} else {
244+
spinner.warn(
245+
'Failed to install dependencies. Run "pnpm install" manually.'
246+
);
247+
}
248+
}
249+
223250
if (!options.skipGit && isGitInstalled()) {
224251
currentStep += 1;
225252
printStepHeader(currentStep, totalSteps, 'Initialize git repository');
226253
spinner.start('Initializing git repository...');
227254
const gitSuccess = initGit(targetDir);
228255
if (gitSuccess) {
229-
spinner.succeed('Initialized git repository');
256+
if (installSucceeded) {
257+
spinner.start('Installing git hooks...');
258+
const hooksSuccess = await installGitHooks(targetDir);
259+
if (hooksSuccess) {
260+
spinner.succeed('Initialized git repository');
261+
} else {
262+
spinner.warn(
263+
'Initialized git repository, but failed to install git hooks'
264+
);
265+
}
266+
} else {
267+
spinner.succeed('Initialized git repository');
268+
}
230269
} else {
231270
spinner.warn('Failed to initialize git repository');
232271
}
@@ -236,20 +275,6 @@ export async function create(
236275
spinner.warn('Skipped git initialization (git not installed)');
237276
}
238277

239-
if (!options.skipInstall) {
240-
currentStep += 1;
241-
printStepHeader(currentStep, totalSteps, 'Install dependencies');
242-
spinner.start('Installing dependencies...');
243-
const success = await runInstall(targetDir);
244-
if (success) {
245-
spinner.succeed('Installed dependencies');
246-
} else {
247-
spinner.warn(
248-
'Failed to install dependencies. Run "pnpm install" manually.'
249-
);
250-
}
251-
}
252-
253278
let ranAutomaticSetup = false;
254279

255280
if (shouldRunSetup) {

create-blitzpack/src/template.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ const POST_DOWNLOAD_EXCLUDES = [
1515
'create-blitzpack',
1616
'apps/marketing',
1717
'CONTRIBUTING.md',
18+
'docs/create-blitzpack-scaffolding-maintenance-plan.md',
19+
'pnpm-lock.yaml',
1820
];
1921

2022
function getFeatureExclusions(features: FeatureOptions): string[] {

create-blitzpack/src/transform.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,8 @@ ${vars.projectDescription}
181181
182182
\`\`\`bash
183183
pnpm install
184-
pnpm init:project
184+
docker compose up -d
185+
pnpm db:migrate
185186
pnpm dev
186187
\`\`\`
187188

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
"type": "module",
66
"description": "Production-ready Full Stack TypeScript monorepo with Next.js and Fastify",
77
"scripts": {
8-
"init:project": "node scripts/setup.js",
98
"dev": "turbo run dev",
109
"dev:tui": "turbo run dev --ui=tui",
1110
"dev:debug": "turbo run dev --verbose",

0 commit comments

Comments
 (0)