create-nextblock 0.2.1 → 0.2.3

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.
@@ -185,18 +185,55 @@ async function runSetupWizard(projectDir, projectName) {
185
185
 
186
186
  clack.intro('🚀 Welcome to the NextBlock setup wizard!');
187
187
 
188
+ // Ensure Supabase directory exists so the CLI can place config.toml
189
+ const supabaseDir = resolve(projectPath, 'supabase');
190
+ await fs.ensureDir(supabaseDir);
191
+
188
192
  clack.note('Connecting to Supabase...');
189
193
  clack.note('I will now open your browser to log into Supabase.');
190
194
  await execa('npx', ['supabase', 'login'], { stdio: 'inherit', cwd: projectPath });
191
195
 
192
196
  clack.note('Now, please select your NextBlock project in the browser.');
193
- await execa('npx', ['supabase', 'link'], { stdio: 'inherit', cwd: projectPath });
197
+ let linkOutput = '';
198
+ const linkProcess = execa('npx', ['supabase', 'link'], {
199
+ cwd: projectPath,
200
+ stdin: 'inherit',
201
+ stdout: 'pipe',
202
+ stderr: 'inherit',
203
+ });
204
+ if (linkProcess.stdout) {
205
+ linkProcess.stdout.on('data', (chunk) => {
206
+ const text = chunk.toString();
207
+ linkOutput += text;
208
+ process.stdout.write(text);
209
+ });
210
+ }
211
+ await linkProcess;
194
212
 
195
213
  const configTomlPath = resolve(projectPath, 'supabase', 'config.toml');
214
+ let configToml = '';
196
215
  if (!(await fs.pathExists(configTomlPath))) {
197
- throw new Error('supabase/config.toml not found. Please rerun the wizard after linking.');
216
+ const parsedRef = linkOutput.match(/Selected project:\s*([a-z0-9-]+)/i)?.[1];
217
+ let projectRef = parsedRef;
218
+
219
+ if (!projectRef) {
220
+ const manualProjectId = await clack.text({
221
+ message:
222
+ 'supabase/config.toml was not created. Enter your Supabase project ref (from the link output, e.g., abcdefghijklmnopqrstu):',
223
+ validate: (val) => (!val ? 'Project ref is required' : undefined),
224
+ });
225
+ if (clack.isCancel(manualProjectId)) {
226
+ handleWizardCancel('Setup cancelled.');
227
+ }
228
+ projectRef = manualProjectId.trim();
229
+ }
230
+
231
+ configToml = `project_id = "${projectRef}"\n`;
232
+ await fs.writeFile(configTomlPath, configToml);
233
+ clack.note('Created supabase/config.toml from the provided project ref.');
234
+ } else {
235
+ configToml = await fs.readFile(configTomlPath, 'utf8');
198
236
  }
199
- const configToml = await fs.readFile(configTomlPath, 'utf8');
200
237
  const projectIdMatch = configToml.match(/project_id\s*=\s*"([^"]+)"/);
201
238
  if (!projectIdMatch?.[1]) {
202
239
  throw new Error('Could not parse project_id from supabase/config.toml. Please ensure Supabase is linked.');
@@ -270,7 +307,7 @@ async function runSetupWizard(projectDir, projectName) {
270
307
 
271
308
  if (canWriteEnv) {
272
309
  await fs.writeFile(envPath, envLines.join('\n'));
273
- clack.success('Supabase configuration saved to .env');
310
+ clack.note('Supabase configuration saved to .env');
274
311
  }
275
312
 
276
313
  clack.note('Setting up your database...');
@@ -340,7 +377,7 @@ async function runSetupWizard(projectDir, projectName) {
340
377
 
341
378
  if (canWriteEnv) {
342
379
  await fs.appendFile(envPath, r2Env);
343
- clack.success('Cloudflare R2 configuration saved!');
380
+ clack.note('Cloudflare R2 configuration saved!');
344
381
  } else {
345
382
  clack.note('Add the following R2 values to your existing .env:\n' + r2Env);
346
383
  }
@@ -402,7 +439,7 @@ async function runSetupWizard(projectDir, projectName) {
402
439
 
403
440
  if (canWriteEnv) {
404
441
  await fs.appendFile(envPath, smtpEnv);
405
- clack.success('SMTP configuration saved!');
442
+ clack.note('SMTP configuration saved!');
406
443
  } else {
407
444
  clack.note('Add the following SMTP values to your existing .env:\n' + smtpEnv);
408
445
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-nextblock",
3
- "version": "0.2.1",
3
+ "version": "0.2.3",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "bin": {