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