create-nextblock 0.2.21 → 0.2.23

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.
@@ -161,7 +161,6 @@ async function handleCommand(projectDirectory, options) {
161
161
  }
162
162
 
163
163
  await initializeGit(projectDir);
164
- console.log(chalk.green('Initialized a new Git repository.'));
165
164
 
166
165
  console.log(chalk.green(`\nSuccess! Your NextBlock CMS project "${projectName}" is ready.\n`));
167
166
  console.log(chalk.cyan('Next step:'));
@@ -188,7 +187,7 @@ async function runSetupWizard(projectDir, projectName) {
188
187
  clack.note('I will now open your browser to log into Supabase.');
189
188
  await runSupabaseCli(['login'], { cwd: projectPath });
190
189
 
191
- const assetsState = await ensureSupabaseAssets(projectPath, { required: true, resetProjectRef: true });
190
+ await ensureSupabaseAssets(projectPath, { required: true, resetProjectRef: true });
192
191
  clack.note('Now, please select your NextBlock project when prompted.');
193
192
  await runSupabaseCli(['link'], { cwd: projectPath });
194
193
  if (process.stdin.isTTY) {
@@ -203,10 +202,6 @@ async function runSetupWizard(projectDir, projectName) {
203
202
 
204
203
  let projectId = await readSupabaseProjectRef(projectPath);
205
204
 
206
- if (!projectId && assetsState.projectId) {
207
- projectId = assetsState.projectId;
208
- }
209
-
210
205
  if (!projectId) {
211
206
  clack.note('I could not detect your Supabase project ref automatically.');
212
207
  const manual = await clack.text({
@@ -309,7 +304,7 @@ async function runSetupWizard(projectDir, projectName) {
309
304
 
310
305
  clack.note('Setting up your database...');
311
306
  const dbPushSpinner = clack.spinner();
312
- dbPushSpinner.start('Pushing database schema... (This may take a minute)');
307
+ dbPushSpinner.start('Pushing database schema... (6-9 minutes, please keep this terminal open)');
313
308
  try {
314
309
  process.env.POSTGRES_URL = postgresUrl;
315
310
  const migrationsDir = resolve(projectPath, 'supabase', 'migrations');
@@ -491,7 +486,7 @@ async function runSetupWizard(projectDir, projectName) {
491
486
  clack.note('SMTP placeholders added to .env. Configure them later when ready.');
492
487
  }
493
488
 
494
- clack.outro(`🎉 Your NextBlock project ${projectName ? `"${projectName}" ` : ''}is ready!\n\nNext step:\n npm run dev`);
489
+ clack.outro(`🎉 Your NextBlock project ${projectName ? `"${projectName}" ` : ''}is ready!`);
495
490
  }
496
491
 
497
492
  function handleWizardCancel(message) {
@@ -723,10 +718,11 @@ async function ensureSupabaseAssets(projectDir, options = {}) {
723
718
  const destSupabaseDir = resolve(projectDir, 'supabase');
724
719
  await fs.ensureDir(destSupabaseDir);
725
720
 
726
- const packageSupabaseDir = await resolvePackageSupabaseDir();
721
+ const { dir: packageSupabaseDir, triedPaths } = await resolvePackageSupabaseDir(projectDir);
727
722
  if (!packageSupabaseDir) {
728
723
  const message =
729
- 'Unable to locate supabase assets in @nextblock-cms/db. Please reinstall dependencies and try again.';
724
+ 'Unable to locate supabase assets in @nextblock-cms/db. Please ensure dependencies are installed.' +
725
+ (triedPaths.length > 0 ? `\nChecked:\n - ${triedPaths.join('\n - ')}` : '');
730
726
  if (required) {
731
727
  throw new Error(message);
732
728
  } else {
@@ -769,50 +765,78 @@ async function ensureSupabaseAssets(projectDir, options = {}) {
769
765
 
770
766
  if (required) {
771
767
  if (!configCopied) {
772
- throw new Error('Missing supabase/config.toml in the installed @nextblock-cms/db package.');
768
+ throw new Error(
769
+ `Missing supabase/config.toml in the installed @nextblock-cms/db package (checked ${packageSupabaseDir}).`,
770
+ );
773
771
  }
774
772
  if (!migrationsCopied) {
775
- throw new Error('Missing supabase/migrations in the installed @nextblock-cms/db package.');
773
+ throw new Error(
774
+ `Missing supabase/migrations in the installed @nextblock-cms/db package (checked ${packageSupabaseDir}).`,
775
+ );
776
776
  }
777
777
  }
778
778
 
779
779
  return { migrationsCopied, configCopied, projectId: detectedProjectId };
780
780
  }
781
781
 
782
- async function resolvePackageSupabaseDir() {
783
- try {
784
- const pkgPath = require.resolve('@nextblock-cms/db/package.json');
785
- const pkgDir = dirname(pkgPath);
786
- const candidateSegments = [
787
- 'supabase',
788
- 'src/supabase',
789
- 'dist/supabase',
790
- 'dist/libs/db/supabase',
791
- 'dist/lib/supabase',
792
- 'lib/supabase',
793
- ];
794
- const candidates = candidateSegments.map((segment) => resolve(pkgDir, segment));
795
- for (const candidate of candidates) {
782
+ async function resolvePackageSupabaseDir(projectDir) {
783
+ const triedPaths = [];
784
+ const candidateBases = new Set();
785
+
786
+ const installDir = resolve(projectDir, 'node_modules', '@nextblock-cms', 'db');
787
+ candidateBases.add(installDir);
788
+
789
+ const tryResolveFrom = (fromPath) => {
790
+ try {
791
+ const resolver = createRequire(fromPath);
792
+ const pkgPath = resolver.resolve('@nextblock-cms/db/package.json');
793
+ return dirname(pkgPath);
794
+ } catch {
795
+ return null;
796
+ }
797
+ };
798
+
799
+ const projectPkg = resolve(projectDir, 'package.json');
800
+ const resolvedProject = tryResolveFrom(projectPkg);
801
+ if (resolvedProject) {
802
+ candidateBases.add(resolvedProject);
803
+ const parent = dirname(resolvedProject);
804
+ candidateBases.add(parent);
805
+ }
806
+
807
+ const localResolve = tryResolveFrom(__filename);
808
+ if (localResolve) {
809
+ candidateBases.add(localResolve);
810
+ candidateBases.add(dirname(localResolve));
811
+ }
812
+
813
+ candidateBases.add(REPO_ROOT);
814
+ candidateBases.add(resolve(REPO_ROOT, 'libs', 'db'));
815
+ candidateBases.add(resolve(REPO_ROOT, 'dist', 'libs', 'db'));
816
+
817
+ const candidateSegments = [
818
+ 'supabase',
819
+ 'src/supabase',
820
+ 'dist/supabase',
821
+ 'dist/libs/db/supabase',
822
+ 'dist/lib/supabase',
823
+ 'lib/supabase',
824
+ ];
825
+
826
+ for (const base of Array.from(candidateBases).filter(Boolean)) {
827
+ for (const segment of candidateSegments) {
828
+ const candidate = resolve(base, segment);
829
+ triedPaths.push(candidate);
796
830
  if (await fs.pathExists(candidate)) {
797
- return candidate;
831
+ return { dir: candidate, triedPaths };
798
832
  }
799
833
  }
800
- } catch {
801
- return null;
802
834
  }
803
- return null;
835
+
836
+ return { dir: null, triedPaths };
804
837
  }
805
838
 
806
839
  async function readSupabaseProjectRef(projectDir) {
807
- const configTomlPath = resolve(projectDir, 'supabase', 'config.toml');
808
- if (await fs.pathExists(configTomlPath)) {
809
- const config = await fs.readFile(configTomlPath, 'utf8');
810
- const configMatch = config.match(/project_id\s*=\s*"([^"]+)"/);
811
- if (configMatch?.[1] && !configMatch[1].includes('env(')) {
812
- return configMatch[1];
813
- }
814
- }
815
-
816
840
  const projectRefPath = resolve(projectDir, 'supabase', '.temp', 'project-ref');
817
841
  if (await fs.pathExists(projectRefPath)) {
818
842
  const value = (await fs.readFile(projectRefPath, 'utf8')).trim();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-nextblock",
3
- "version": "0.2.21",
3
+ "version": "0.2.23",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "bin": {