create-nextblock 0.2.13 → 0.2.15
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 +35 -15
- package/package.json +1 -1
package/bin/create-nextblock.js
CHANGED
|
@@ -190,31 +190,51 @@ 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
|
-
|
|
193
|
+
let linkOutput = '';
|
|
194
|
+
const linkProcess = execa('npx', ['supabase', 'link'], {
|
|
194
195
|
cwd: projectPath,
|
|
195
|
-
|
|
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
|
|
|
198
216
|
// Ensure supabase assets exist (config + migrations) after link in case the CLI created/overrode files
|
|
199
217
|
await ensureSupabaseAssets(projectPath);
|
|
200
218
|
|
|
201
219
|
const configTomlPath = resolve(projectPath, 'supabase', 'config.toml');
|
|
202
|
-
|
|
203
|
-
throw new Error('supabase/config.toml not found. Please rerun `npx supabase link`.');
|
|
204
|
-
}
|
|
205
|
-
const configToml = await fs.readFile(configTomlPath, 'utf8');
|
|
206
|
-
const projectMatch = configToml.match(/project_id\s*=\s*"([^"]+)"/);
|
|
207
|
-
if (!projectMatch?.[1] || projectMatch[1].includes('env(')) {
|
|
208
|
-
throw new Error('Could not read a concrete project_id from supabase/config.toml. Please rerun `npx supabase link`.');
|
|
209
|
-
}
|
|
210
|
-
const projectId = projectMatch[1];
|
|
220
|
+
let projectId = linkOutput.match(/Selected project:\s*([a-z0-9-]+)/i)?.[1] || null;
|
|
211
221
|
|
|
212
|
-
if (!
|
|
213
|
-
const
|
|
214
|
-
|
|
215
|
-
|
|
222
|
+
if (!projectId) {
|
|
223
|
+
const manual = await clack.text({
|
|
224
|
+
message:
|
|
225
|
+
'Enter your Supabase project ref (from the Supabase dashboard URL or the link output, e.g., abcdefghijklmnopqrstu):',
|
|
226
|
+
validate: (val) => (!val ? 'Project ref is required' : undefined),
|
|
227
|
+
});
|
|
228
|
+
if (clack.isCancel(manual)) {
|
|
229
|
+
handleWizardCancel('Setup cancelled.');
|
|
230
|
+
}
|
|
231
|
+
projectId = manual.trim();
|
|
216
232
|
}
|
|
217
233
|
|
|
234
|
+
const configContent = `project_id = "env(SUPABASE_PROJECT_ID)"\n`;
|
|
235
|
+
await fs.writeFile(configTomlPath, configContent);
|
|
236
|
+
clack.note('Created supabase/config.toml with project_id env binding.');
|
|
237
|
+
|
|
218
238
|
clack.note('Please go to your Supabase project dashboard to get the following secrets.');
|
|
219
239
|
const supabaseKeys = await clack.group(
|
|
220
240
|
{
|