create-nextblock 0.2.17 → 0.2.19
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 +30 -39
- package/package.json +1 -1
package/bin/create-nextblock.js
CHANGED
|
@@ -190,35 +190,24 @@ 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
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
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
|
-
});
|
|
193
|
+
await execa('npx', ['supabase', 'link'], { cwd: projectPath, stdio: 'inherit' });
|
|
194
|
+
if (process.stdin.isTTY) {
|
|
195
|
+
try {
|
|
196
|
+
process.stdin.setRawMode(false);
|
|
197
|
+
} catch (_) {
|
|
198
|
+
// ignore
|
|
199
|
+
}
|
|
200
|
+
process.stdin.setEncoding('utf8');
|
|
201
|
+
process.stdin.resume();
|
|
213
202
|
}
|
|
214
|
-
await linkProcess;
|
|
215
203
|
|
|
216
204
|
// Ensure supabase assets exist (config + migrations) after link in case the CLI created/overrode files
|
|
217
205
|
await ensureSupabaseAssets(projectPath);
|
|
218
206
|
|
|
219
207
|
const configTomlPath = resolve(projectPath, 'supabase', 'config.toml');
|
|
220
|
-
let projectId =
|
|
221
|
-
|
|
208
|
+
let projectId = null;
|
|
209
|
+
|
|
210
|
+
if (await fs.pathExists(configTomlPath)) {
|
|
222
211
|
const configToml = await fs.readFile(configTomlPath, 'utf8');
|
|
223
212
|
const projectMatch = configToml.match(/project_id\s*=\s*"([^"]+)"/);
|
|
224
213
|
if (projectMatch?.[1] && !projectMatch[1].includes('env(')) {
|
|
@@ -226,9 +215,17 @@ async function runSetupWizard(projectDir, projectName) {
|
|
|
226
215
|
}
|
|
227
216
|
}
|
|
228
217
|
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
218
|
+
if (!projectId) {
|
|
219
|
+
const manual = await clack.text({
|
|
220
|
+
message:
|
|
221
|
+
'Enter your Supabase project ref (from the Supabase dashboard URL or the link output, e.g., abcdefghijklmnopqrstu):',
|
|
222
|
+
validate: (val) => (!val ? 'Project ref is required' : undefined),
|
|
223
|
+
});
|
|
224
|
+
if (clack.isCancel(manual)) {
|
|
225
|
+
handleWizardCancel('Setup cancelled.');
|
|
226
|
+
}
|
|
227
|
+
projectId = manual.trim();
|
|
228
|
+
}
|
|
232
229
|
|
|
233
230
|
clack.note('Please go to your Supabase project dashboard to get the following secrets.');
|
|
234
231
|
const supabaseKeys = await clack.group(
|
|
@@ -682,19 +679,11 @@ async function ensureSupabaseAssets(projectDir) {
|
|
|
682
679
|
await fs.ensureDir(destSupabaseDir);
|
|
683
680
|
|
|
684
681
|
const packageSupabaseDir = await resolvePackageSupabaseDir();
|
|
685
|
-
const
|
|
686
|
-
|
|
687
|
-
const sources = [packageSupabaseDir, templateSupabaseDir].filter(Boolean);
|
|
682
|
+
const sources = [packageSupabaseDir].filter(Boolean);
|
|
688
683
|
if (sources.length === 0) {
|
|
689
|
-
clack.note('Warning: No supabase assets found in installed packages
|
|
684
|
+
clack.note('Warning: No supabase assets found in installed packages.');
|
|
690
685
|
}
|
|
691
686
|
for (const sourceSupabaseDir of sources) {
|
|
692
|
-
const sourceConfig = resolve(sourceSupabaseDir, 'config.toml');
|
|
693
|
-
const destConfig = resolve(destSupabaseDir, 'config.toml');
|
|
694
|
-
if (await fs.pathExists(sourceConfig)) {
|
|
695
|
-
await fs.copy(sourceConfig, destConfig, { overwrite: true });
|
|
696
|
-
}
|
|
697
|
-
|
|
698
687
|
const sourceMigrations = resolve(sourceSupabaseDir, 'migrations');
|
|
699
688
|
const destMigrations = resolve(destSupabaseDir, 'migrations');
|
|
700
689
|
if (await fs.pathExists(sourceMigrations)) {
|
|
@@ -707,9 +696,11 @@ async function resolvePackageSupabaseDir() {
|
|
|
707
696
|
try {
|
|
708
697
|
const pkgPath = require.resolve('@nextblock-cms/db/package.json');
|
|
709
698
|
const pkgDir = dirname(pkgPath);
|
|
710
|
-
const
|
|
711
|
-
|
|
712
|
-
|
|
699
|
+
const candidates = [resolve(pkgDir, 'supabase'), resolve(pkgDir, 'lib', 'supabase')];
|
|
700
|
+
for (const candidate of candidates) {
|
|
701
|
+
if (await fs.pathExists(candidate)) {
|
|
702
|
+
return candidate;
|
|
703
|
+
}
|
|
713
704
|
}
|
|
714
705
|
} catch {
|
|
715
706
|
return null;
|