create-nextblock 0.2.6 → 0.2.8
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/bin/create-nextblock.js +56 -48
- package/package.json +2 -1
package/bin/create-nextblock.js
CHANGED
|
@@ -5,6 +5,7 @@ import { spawn } from 'node:child_process';
|
|
|
5
5
|
import crypto from 'node:crypto';
|
|
6
6
|
import { dirname, resolve, relative, sep, basename } from 'node:path';
|
|
7
7
|
import { fileURLToPath } from 'node:url';
|
|
8
|
+
import { createRequire } from 'node:module';
|
|
8
9
|
import { execa } from 'execa';
|
|
9
10
|
import { program } from 'commander';
|
|
10
11
|
import inquirer from 'inquirer';
|
|
@@ -12,11 +13,12 @@ import chalk from 'chalk';
|
|
|
12
13
|
import fs from 'fs-extra';
|
|
13
14
|
import open from 'open';
|
|
14
15
|
|
|
15
|
-
const DEFAULT_PROJECT_NAME = 'nextblock-cms';
|
|
16
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
17
|
-
const __dirname = dirname(__filename);
|
|
18
|
-
const TEMPLATE_DIR = resolve(__dirname, '../templates/nextblock-template');
|
|
19
|
-
const REPO_ROOT = resolve(__dirname, '../../..');
|
|
16
|
+
const DEFAULT_PROJECT_NAME = 'nextblock-cms';
|
|
17
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
18
|
+
const __dirname = dirname(__filename);
|
|
19
|
+
const TEMPLATE_DIR = resolve(__dirname, '../templates/nextblock-template');
|
|
20
|
+
const REPO_ROOT = resolve(__dirname, '../../..');
|
|
21
|
+
const require = createRequire(import.meta.url);
|
|
20
22
|
const EDITOR_UTILS_SOURCE_DIR = resolve(REPO_ROOT, 'libs/editor/src/lib/utils');
|
|
21
23
|
const IS_WINDOWS = process.platform === 'win32';
|
|
22
24
|
|
|
@@ -131,15 +133,6 @@ async function handleCommand(projectDirectory, options) {
|
|
|
131
133
|
await ensureEnvExample(projectDir);
|
|
132
134
|
console.log(chalk.green('.env.example ready.'));
|
|
133
135
|
|
|
134
|
-
await ensureSupabaseAssets(projectDir);
|
|
135
|
-
console.log(chalk.green('Supabase migrations ready.'));
|
|
136
|
-
|
|
137
|
-
if (!yes) {
|
|
138
|
-
await runSetupWizard(projectDir, projectName);
|
|
139
|
-
} else {
|
|
140
|
-
console.log(chalk.yellow('Skipping interactive setup wizard because --yes was provided.'));
|
|
141
|
-
}
|
|
142
|
-
|
|
143
136
|
await sanitizeLayout(projectDir);
|
|
144
137
|
console.log(chalk.green('Global styles configured.'));
|
|
145
138
|
|
|
@@ -152,28 +145,28 @@ async function handleCommand(projectDirectory, options) {
|
|
|
152
145
|
await sanitizeNextConfig(projectDir, editorUtilNames);
|
|
153
146
|
console.log(chalk.green('next.config.js sanitized.'));
|
|
154
147
|
|
|
155
|
-
await transformPackageJson(projectDir);
|
|
156
|
-
console.log(chalk.green('Dependencies updated for public packages.'));
|
|
157
|
-
|
|
158
|
-
if (!skipInstall) {
|
|
159
|
-
await installDependencies(projectDir);
|
|
148
|
+
await transformPackageJson(projectDir);
|
|
149
|
+
console.log(chalk.green('Dependencies updated for public packages.'));
|
|
150
|
+
|
|
151
|
+
if (!skipInstall) {
|
|
152
|
+
await installDependencies(projectDir);
|
|
160
153
|
} else {
|
|
161
154
|
console.log(chalk.yellow('Skipping dependency installation.'));
|
|
162
155
|
}
|
|
163
156
|
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
chalk.
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
);
|
|
157
|
+
// Run setup wizard after dependencies are installed so package assets are available
|
|
158
|
+
if (!yes) {
|
|
159
|
+
await runSetupWizard(projectDir, projectName);
|
|
160
|
+
} else {
|
|
161
|
+
console.log(chalk.yellow('Skipping interactive setup wizard because --yes was provided.'));
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
await initializeGit(projectDir);
|
|
165
|
+
console.log(chalk.green('Initialized a new Git repository.'));
|
|
166
|
+
|
|
167
|
+
console.log(chalk.green(`\nSuccess! Your NextBlock CMS project "${projectName}" is ready.\n`));
|
|
168
|
+
console.log(chalk.cyan('Next step:'));
|
|
169
|
+
console.log(chalk.cyan(` cd ${projectName} && npm run dev`));
|
|
177
170
|
} catch (error) {
|
|
178
171
|
console.error(
|
|
179
172
|
chalk.red(error instanceof Error ? error.message : 'An unexpected error occurred'),
|
|
@@ -225,6 +218,9 @@ async function runSetupWizard(projectDir, projectName) {
|
|
|
225
218
|
} catch (_) {
|
|
226
219
|
// ignore if not supported
|
|
227
220
|
}
|
|
221
|
+
process.stdin.setEncoding('utf8');
|
|
222
|
+
process.stdin.removeAllListeners('data');
|
|
223
|
+
process.stdin.removeAllListeners('keypress');
|
|
228
224
|
}
|
|
229
225
|
process.stdin.resume();
|
|
230
226
|
|
|
@@ -474,9 +470,7 @@ async function runSetupWizard(projectDir, projectName) {
|
|
|
474
470
|
}
|
|
475
471
|
}
|
|
476
472
|
|
|
477
|
-
clack.outro(
|
|
478
|
-
`🎉 Your NextBlock project ${projectName ? `"${projectName}" ` : ''}is ready!\n\nNext steps:\n 1. cd ${projectName || projectPath}\n 2. npm run dev`,
|
|
479
|
-
);
|
|
473
|
+
clack.outro(`🎉 Your NextBlock project ${projectName ? `"${projectName}" ` : ''}is ready!\n\nNext step:\n npm run dev`);
|
|
480
474
|
}
|
|
481
475
|
|
|
482
476
|
function handleWizardCancel(message) {
|
|
@@ -704,26 +698,40 @@ SMTP_FROM_NAME=
|
|
|
704
698
|
}
|
|
705
699
|
|
|
706
700
|
async function ensureSupabaseAssets(projectDir) {
|
|
707
|
-
const sourceSupabaseDir = resolve(REPO_ROOT, 'libs/db/src/supabase');
|
|
708
701
|
const destSupabaseDir = resolve(projectDir, 'supabase');
|
|
702
|
+
await fs.ensureDir(destSupabaseDir);
|
|
709
703
|
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
}
|
|
704
|
+
const packageSupabaseDir = await resolvePackageSupabaseDir();
|
|
705
|
+
const templateSupabaseDir = resolve(TEMPLATE_DIR, 'supabase');
|
|
713
706
|
|
|
714
|
-
|
|
707
|
+
const sources = [packageSupabaseDir, templateSupabaseDir].filter(Boolean);
|
|
708
|
+
for (const sourceSupabaseDir of sources) {
|
|
709
|
+
const sourceConfig = resolve(sourceSupabaseDir, 'config.toml');
|
|
710
|
+
const destConfig = resolve(destSupabaseDir, 'config.toml');
|
|
711
|
+
if (await fs.pathExists(sourceConfig)) {
|
|
712
|
+
await fs.copy(sourceConfig, destConfig, { overwrite: true });
|
|
713
|
+
}
|
|
715
714
|
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
715
|
+
const sourceMigrations = resolve(sourceSupabaseDir, 'migrations');
|
|
716
|
+
const destMigrations = resolve(destSupabaseDir, 'migrations');
|
|
717
|
+
if (await fs.pathExists(sourceMigrations)) {
|
|
718
|
+
await fs.copy(sourceMigrations, destMigrations, { overwrite: true, errorOnExist: false });
|
|
719
|
+
}
|
|
720
720
|
}
|
|
721
|
+
}
|
|
721
722
|
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
723
|
+
async function resolvePackageSupabaseDir() {
|
|
724
|
+
try {
|
|
725
|
+
const pkgPath = require.resolve('@nextblock-cms/db/package.json');
|
|
726
|
+
const pkgDir = dirname(pkgPath);
|
|
727
|
+
const candidate = resolve(pkgDir, 'supabase');
|
|
728
|
+
if (await fs.pathExists(candidate)) {
|
|
729
|
+
return candidate;
|
|
730
|
+
}
|
|
731
|
+
} catch {
|
|
732
|
+
return null;
|
|
726
733
|
}
|
|
734
|
+
return null;
|
|
727
735
|
}
|
|
728
736
|
|
|
729
737
|
async function ensureClientComponents(projectDir) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-nextblock",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.8",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"bin": {
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
"type": "module",
|
|
18
18
|
"dependencies": {
|
|
19
19
|
"@clack/prompts": "^0.8.1",
|
|
20
|
+
"@nextblock-cms/db": "latest",
|
|
20
21
|
"chalk": "^5.6.2",
|
|
21
22
|
"commander": "^14.0.1",
|
|
22
23
|
"execa": "^9.3.0",
|