create-nextblock 0.2.10 → 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.
- package/bin/create-nextblock.js +16 -22
- package/package.json +1 -1
package/bin/create-nextblock.js
CHANGED
|
@@ -226,33 +226,26 @@ async function runSetupWizard(projectDir, projectName) {
|
|
|
226
226
|
await ensureSupabaseAssets(projectPath);
|
|
227
227
|
|
|
228
228
|
const configTomlPath = resolve(projectPath, 'supabase', 'config.toml');
|
|
229
|
-
|
|
230
|
-
if (!
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
'supabase/config.toml was not created. Enter your Supabase project ref (from the link output, e.g., abcdefghijklmnopqrstu):',
|
|
235
|
-
initialValue: projectRef,
|
|
236
|
-
validate: (val) => (!val ? 'Project ref is required' : undefined),
|
|
237
|
-
});
|
|
238
|
-
if (clack.isCancel(manualProjectId)) {
|
|
239
|
-
handleWizardCancel('Setup cancelled.');
|
|
240
|
-
}
|
|
241
|
-
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;
|
|
242
234
|
|
|
243
|
-
|
|
235
|
+
if (!(await fs.pathExists(configTomlPath))) {
|
|
236
|
+
const configToml = `project_id = "env(SUPABASE_PROJECT_ID)"\n`;
|
|
244
237
|
await fs.writeFile(configTomlPath, configToml);
|
|
245
|
-
clack.note(
|
|
246
|
-
} else {
|
|
247
|
-
configToml = await fs.readFile(configTomlPath, 'utf8');
|
|
248
|
-
}
|
|
249
|
-
const projectIdMatch = configToml.match(/project_id\s*=\s*"([^"]+)"/);
|
|
250
|
-
if (!projectIdMatch?.[1]) {
|
|
251
|
-
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}.`);
|
|
252
239
|
}
|
|
253
|
-
const projectId = projectIdMatch[1];
|
|
254
240
|
|
|
255
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
|
+
}
|
|
256
249
|
const supabaseKeys = await clack.group(
|
|
257
250
|
{
|
|
258
251
|
dbPassword: () =>
|
|
@@ -292,6 +285,7 @@ async function runSetupWizard(projectDir, projectName) {
|
|
|
292
285
|
'',
|
|
293
286
|
'# Supabase',
|
|
294
287
|
`SUPABASE_PROJECT_ID=${projectId}`,
|
|
288
|
+
`SUPABASE_PROJECT_ID=${projectId}`,
|
|
295
289
|
`NEXT_PUBLIC_SUPABASE_URL=${supabaseUrl}`,
|
|
296
290
|
`NEXT_PUBLIC_SUPABASE_ANON_KEY=${supabaseKeys.anonKey}`,
|
|
297
291
|
`SUPABASE_SERVICE_ROLE_KEY=${supabaseKeys.serviceKey}`,
|