create-nextblock 0.2.17 → 0.2.19

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.
@@ -190,35 +190,24 @@ async function runSetupWizard(projectDir, projectName) {
190
190
  await execa('npx', ['supabase', 'login'], { stdio: 'inherit', cwd: projectPath });
191
191
 
192
192
  clack.note('Now, please select your NextBlock project when prompted.');
193
- let linkOutput = '';
194
- const linkProcess = execa('npx', ['supabase', 'link'], {
195
- cwd: projectPath,
196
- stdin: 'inherit',
197
- stdout: 'pipe',
198
- stderr: 'pipe',
199
- });
200
- if (linkProcess.stdout) {
201
- linkProcess.stdout.on('data', (chunk) => {
202
- const text = chunk.toString();
203
- linkOutput += text;
204
- process.stdout.write(text);
205
- });
206
- }
207
- if (linkProcess.stderr) {
208
- linkProcess.stderr.on('data', (chunk) => {
209
- const text = chunk.toString();
210
- linkOutput += text;
211
- process.stderr.write(text);
212
- });
193
+ await execa('npx', ['supabase', 'link'], { cwd: projectPath, stdio: 'inherit' });
194
+ if (process.stdin.isTTY) {
195
+ try {
196
+ process.stdin.setRawMode(false);
197
+ } catch (_) {
198
+ // ignore
199
+ }
200
+ process.stdin.setEncoding('utf8');
201
+ process.stdin.resume();
213
202
  }
214
- await linkProcess;
215
203
 
216
204
  // Ensure supabase assets exist (config + migrations) after link in case the CLI created/overrode files
217
205
  await ensureSupabaseAssets(projectPath);
218
206
 
219
207
  const configTomlPath = resolve(projectPath, 'supabase', 'config.toml');
220
- let projectId = linkOutput.match(/Selected project:\s*([a-z0-9-]+)/i)?.[1] || null;
221
- if (!projectId && (await fs.pathExists(configTomlPath))) {
208
+ let projectId = null;
209
+
210
+ if (await fs.pathExists(configTomlPath)) {
222
211
  const configToml = await fs.readFile(configTomlPath, 'utf8');
223
212
  const projectMatch = configToml.match(/project_id\s*=\s*"([^"]+)"/);
224
213
  if (projectMatch?.[1] && !projectMatch[1].includes('env(')) {
@@ -226,9 +215,17 @@ async function runSetupWizard(projectDir, projectName) {
226
215
  }
227
216
  }
228
217
 
229
- const configContent = `project_id = "env(SUPABASE_PROJECT_ID)"\n`;
230
- await fs.writeFile(configTomlPath, configContent);
231
- clack.note('Created supabase/config.toml with project_id env binding.');
218
+ if (!projectId) {
219
+ const manual = await clack.text({
220
+ message:
221
+ 'Enter your Supabase project ref (from the Supabase dashboard URL or the link output, e.g., abcdefghijklmnopqrstu):',
222
+ validate: (val) => (!val ? 'Project ref is required' : undefined),
223
+ });
224
+ if (clack.isCancel(manual)) {
225
+ handleWizardCancel('Setup cancelled.');
226
+ }
227
+ projectId = manual.trim();
228
+ }
232
229
 
233
230
  clack.note('Please go to your Supabase project dashboard to get the following secrets.');
234
231
  const supabaseKeys = await clack.group(
@@ -682,19 +679,11 @@ async function ensureSupabaseAssets(projectDir) {
682
679
  await fs.ensureDir(destSupabaseDir);
683
680
 
684
681
  const packageSupabaseDir = await resolvePackageSupabaseDir();
685
- const templateSupabaseDir = resolve(TEMPLATE_DIR, 'supabase');
686
-
687
- const sources = [packageSupabaseDir, templateSupabaseDir].filter(Boolean);
682
+ const sources = [packageSupabaseDir].filter(Boolean);
688
683
  if (sources.length === 0) {
689
- clack.note('Warning: No supabase assets found in installed packages or template.');
684
+ clack.note('Warning: No supabase assets found in installed packages.');
690
685
  }
691
686
  for (const sourceSupabaseDir of sources) {
692
- const sourceConfig = resolve(sourceSupabaseDir, 'config.toml');
693
- const destConfig = resolve(destSupabaseDir, 'config.toml');
694
- if (await fs.pathExists(sourceConfig)) {
695
- await fs.copy(sourceConfig, destConfig, { overwrite: true });
696
- }
697
-
698
687
  const sourceMigrations = resolve(sourceSupabaseDir, 'migrations');
699
688
  const destMigrations = resolve(destSupabaseDir, 'migrations');
700
689
  if (await fs.pathExists(sourceMigrations)) {
@@ -707,9 +696,11 @@ async function resolvePackageSupabaseDir() {
707
696
  try {
708
697
  const pkgPath = require.resolve('@nextblock-cms/db/package.json');
709
698
  const pkgDir = dirname(pkgPath);
710
- const candidate = resolve(pkgDir, 'supabase');
711
- if (await fs.pathExists(candidate)) {
712
- return candidate;
699
+ const candidates = [resolve(pkgDir, 'supabase'), resolve(pkgDir, 'lib', 'supabase')];
700
+ for (const candidate of candidates) {
701
+ if (await fs.pathExists(candidate)) {
702
+ return candidate;
703
+ }
713
704
  }
714
705
  } catch {
715
706
  return null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-nextblock",
3
- "version": "0.2.17",
3
+ "version": "0.2.19",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "bin": {