create-nextblock 0.2.10 → 0.2.12
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 +12 -51
- package/package.json +1 -1
package/bin/create-nextblock.js
CHANGED
|
@@ -190,67 +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
|
-
|
|
194
|
-
const linkProcess = execa('npx', ['supabase', 'link'], {
|
|
193
|
+
const { stdout: linkStdout, stderr: linkStderr } = await execa('npx', ['supabase', 'link'], {
|
|
195
194
|
cwd: projectPath,
|
|
196
|
-
stdin: 'inherit',
|
|
197
|
-
stdout: 'pipe',
|
|
198
|
-
stderr: 'pipe',
|
|
199
195
|
});
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
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;
|
|
215
|
-
if (process.stdin.isTTY) {
|
|
216
|
-
try {
|
|
217
|
-
process.stdin.setRawMode(false);
|
|
218
|
-
} catch (_) {
|
|
219
|
-
// ignore if not supported
|
|
220
|
-
}
|
|
221
|
-
process.stdin.setEncoding('utf8');
|
|
222
|
-
}
|
|
223
|
-
process.stdin.resume();
|
|
196
|
+
const linkOutput = `${linkStdout || ''}${linkStderr || ''}`;
|
|
197
|
+
if (linkStdout) process.stdout.write(linkStdout);
|
|
198
|
+
if (linkStderr) process.stderr.write(linkStderr);
|
|
224
199
|
|
|
225
200
|
// Ensure supabase assets exist (config + migrations) after link in case the CLI created/overrode files
|
|
226
201
|
await ensureSupabaseAssets(projectPath);
|
|
227
202
|
|
|
228
203
|
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();
|
|
204
|
+
const parsedRef = linkOutput.match(/Selected project:\s*([a-z0-9-]+)/i)?.[1];
|
|
205
|
+
if (!parsedRef) {
|
|
206
|
+
throw new Error('Could not read project ref from supabase link output. Please rerun `npx supabase link`.');
|
|
207
|
+
}
|
|
208
|
+
const projectId = parsedRef;
|
|
242
209
|
|
|
243
|
-
|
|
210
|
+
if (!(await fs.pathExists(configTomlPath))) {
|
|
211
|
+
const configToml = `project_id = "env(SUPABASE_PROJECT_ID)"\n`;
|
|
244
212
|
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.');
|
|
213
|
+
clack.note(`Created supabase/config.toml with project_id env binding for ${projectId}.`);
|
|
252
214
|
}
|
|
253
|
-
const projectId = projectIdMatch[1];
|
|
254
215
|
|
|
255
216
|
clack.note('Please go to your Supabase project dashboard to get the following secrets.');
|
|
256
217
|
const supabaseKeys = await clack.group(
|