create-nextblock 0.2.9 → 0.2.11

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,10 +190,28 @@ 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 in the browser.');
193
- await execa('npx', ['supabase', 'link'], {
193
+ let linkOutput = '';
194
+ const linkProcess = execa('npx', ['supabase', 'link'], {
194
195
  cwd: projectPath,
195
- stdio: 'inherit',
196
+ stdin: 'inherit',
197
+ stdout: 'pipe',
198
+ stderr: 'pipe',
196
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
+ });
213
+ }
214
+ await linkProcess;
197
215
  if (process.stdin.isTTY) {
198
216
  try {
199
217
  process.stdin.setRawMode(false);
@@ -201,8 +219,6 @@ async function runSetupWizard(projectDir, projectName) {
201
219
  // ignore if not supported
202
220
  }
203
221
  process.stdin.setEncoding('utf8');
204
- process.stdin.pause();
205
- process.stdin.resume();
206
222
  }
207
223
  process.stdin.resume();
208
224
 
@@ -210,31 +226,26 @@ async function runSetupWizard(projectDir, projectName) {
210
226
  await ensureSupabaseAssets(projectPath);
211
227
 
212
228
  const configTomlPath = resolve(projectPath, 'supabase', 'config.toml');
213
- let configToml = '';
214
- if (!(await fs.pathExists(configTomlPath))) {
215
- const manualProjectId = await clack.text({
216
- message:
217
- 'supabase/config.toml was not created. Enter your Supabase project ref (from the link output, e.g., abcdefghijklmnopqrstu):',
218
- validate: (val) => (!val ? 'Project ref is required' : undefined),
219
- });
220
- if (clack.isCancel(manualProjectId)) {
221
- handleWizardCancel('Setup cancelled.');
222
- }
223
- const projectRef = manualProjectId.trim();
229
+ const parsedRef = linkOutput.match(/Selected project:\s*([a-z0-9-]+)/i)?.[1];
230
+ if (!parsedRef) {
231
+ throw new Error('Could not read project ref from supabase link output. Please rerun `npx supabase link`.');
232
+ }
233
+ const projectId = parsedRef;
224
234
 
225
- configToml = `project_id = "${projectRef}"\n`;
235
+ if (!(await fs.pathExists(configTomlPath))) {
236
+ const configToml = `project_id = "env(SUPABASE_PROJECT_ID)"\n`;
226
237
  await fs.writeFile(configTomlPath, configToml);
227
- clack.note('Created supabase/config.toml from the provided project ref.');
228
- } else {
229
- configToml = await fs.readFile(configTomlPath, 'utf8');
230
- }
231
- const projectIdMatch = configToml.match(/project_id\s*=\s*"([^"]+)"/);
232
- if (!projectIdMatch?.[1]) {
233
- throw new Error('Could not parse project_id from supabase/config.toml. Please ensure Supabase is linked.');
238
+ clack.note(`Created supabase/config.toml with project_id env binding for ${projectId}.`);
234
239
  }
235
- const projectId = projectIdMatch[1];
236
240
 
237
241
  clack.note('Please go to your Supabase project dashboard to get the following secrets.');
242
+ if (process.stdin.isTTY) {
243
+ try {
244
+ process.stdin.setRawMode(false);
245
+ } catch (_) {}
246
+ process.stdin.setEncoding('utf8');
247
+ process.stdin.resume();
248
+ }
238
249
  const supabaseKeys = await clack.group(
239
250
  {
240
251
  dbPassword: () =>
@@ -274,6 +285,7 @@ async function runSetupWizard(projectDir, projectName) {
274
285
  '',
275
286
  '# Supabase',
276
287
  `SUPABASE_PROJECT_ID=${projectId}`,
288
+ `SUPABASE_PROJECT_ID=${projectId}`,
277
289
  `NEXT_PUBLIC_SUPABASE_URL=${supabaseUrl}`,
278
290
  `NEXT_PUBLIC_SUPABASE_ANON_KEY=${supabaseKeys.anonKey}`,
279
291
  `SUPABASE_SERVICE_ROLE_KEY=${supabaseKeys.serviceKey}`,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-nextblock",
3
- "version": "0.2.9",
3
+ "version": "0.2.11",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "bin": {