create-nextblock 0.2.24 → 0.2.25
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
CHANGED
|
@@ -179,16 +179,16 @@ async function runSetupWizard(projectDir, projectName) {
|
|
|
179
179
|
|
|
180
180
|
clack.intro('🚀 Welcome to the NextBlock setup wizard!');
|
|
181
181
|
|
|
182
|
-
const supabaseDir = resolve(projectPath, 'supabase');
|
|
183
|
-
await fs.ensureDir(supabaseDir);
|
|
184
|
-
await resetSupabaseProjectRef(projectPath);
|
|
185
|
-
|
|
186
|
-
clack.note('Connecting to Supabase...');
|
|
187
|
-
clack.note('I will now open your browser to log into Supabase.');
|
|
188
|
-
await runSupabaseCli(['login'], { cwd: projectPath });
|
|
189
|
-
|
|
190
|
-
clack.note('Now, please select your NextBlock project when prompted.');
|
|
191
|
-
await runSupabaseCli(['link'], { cwd: projectPath });
|
|
182
|
+
const supabaseDir = resolve(projectPath, 'supabase');
|
|
183
|
+
await fs.ensureDir(supabaseDir);
|
|
184
|
+
await resetSupabaseProjectRef(projectPath);
|
|
185
|
+
|
|
186
|
+
clack.note('Connecting to Supabase...');
|
|
187
|
+
clack.note('I will now open your browser to log into Supabase.');
|
|
188
|
+
await runSupabaseCli(['login'], { cwd: projectPath });
|
|
189
|
+
|
|
190
|
+
clack.note('Now, please select your NextBlock project when prompted.');
|
|
191
|
+
await runSupabaseCli(['link'], { cwd: projectPath });
|
|
192
192
|
if (process.stdin.isTTY) {
|
|
193
193
|
try {
|
|
194
194
|
process.stdin.setRawMode(false);
|
|
@@ -199,10 +199,10 @@ async function runSetupWizard(projectDir, projectName) {
|
|
|
199
199
|
process.stdin.resume();
|
|
200
200
|
}
|
|
201
201
|
|
|
202
|
-
let projectId = await readSupabaseProjectRef(projectPath);
|
|
203
|
-
|
|
204
|
-
if (!projectId) {
|
|
205
|
-
clack.note('I could not detect your Supabase project ref automatically.');
|
|
202
|
+
let projectId = await readSupabaseProjectRef(projectPath);
|
|
203
|
+
|
|
204
|
+
if (!projectId) {
|
|
205
|
+
clack.note('I could not detect your Supabase project ref automatically.');
|
|
206
206
|
const manual = await clack.text({
|
|
207
207
|
message:
|
|
208
208
|
'Enter your Supabase project ref (from the Supabase dashboard URL or the link output, e.g., abcdefghijklmnopqrstu):',
|
|
@@ -212,8 +212,8 @@ async function runSetupWizard(projectDir, projectName) {
|
|
|
212
212
|
handleWizardCancel('Setup cancelled.');
|
|
213
213
|
}
|
|
214
214
|
projectId = manual.trim();
|
|
215
|
-
}
|
|
216
|
-
await ensureSupabaseAssets(projectPath, { required: true });
|
|
215
|
+
}
|
|
216
|
+
await ensureSupabaseAssets(projectPath, { required: true });
|
|
217
217
|
|
|
218
218
|
const siteUrlPrompt = await clack.text({
|
|
219
219
|
message: 'What is the public URL of your site? (NEXT_PUBLIC_URL)',
|
|
@@ -304,7 +304,7 @@ async function runSetupWizard(projectDir, projectName) {
|
|
|
304
304
|
|
|
305
305
|
clack.note('Setting up your database...');
|
|
306
306
|
const dbPushSpinner = clack.spinner();
|
|
307
|
-
dbPushSpinner.start('Pushing database schema... (~10 minutes, please keep this terminal open)');
|
|
307
|
+
dbPushSpinner.start('Pushing database schema... (~10-15 minutes, please keep this terminal open)');
|
|
308
308
|
try {
|
|
309
309
|
process.env.POSTGRES_URL = postgresUrl;
|
|
310
310
|
const migrationsDir = resolve(projectPath, 'supabase', 'migrations');
|
|
@@ -713,8 +713,8 @@ SMTP_FROM_NAME=
|
|
|
713
713
|
await fs.writeFile(destination, placeholder);
|
|
714
714
|
}
|
|
715
715
|
|
|
716
|
-
async function ensureSupabaseAssets(projectDir, options = {}) {
|
|
717
|
-
const { required = false } = options;
|
|
716
|
+
async function ensureSupabaseAssets(projectDir, options = {}) {
|
|
717
|
+
const { required = false } = options;
|
|
718
718
|
const destSupabaseDir = resolve(projectDir, 'supabase');
|
|
719
719
|
await fs.ensureDir(destSupabaseDir);
|
|
720
720
|
|
|
@@ -731,14 +731,14 @@ async function ensureSupabaseAssets(projectDir, options = {}) {
|
|
|
731
731
|
}
|
|
732
732
|
}
|
|
733
733
|
|
|
734
|
-
let migrationsCopied = false;
|
|
735
|
-
let configCopied = false;
|
|
734
|
+
let migrationsCopied = false;
|
|
735
|
+
let configCopied = false;
|
|
736
736
|
|
|
737
737
|
const sourceConfigPath = resolve(packageSupabaseDir, 'config.toml');
|
|
738
738
|
const destinationConfigPath = resolve(destSupabaseDir, 'config.toml');
|
|
739
739
|
if (await fs.pathExists(sourceConfigPath)) {
|
|
740
|
-
await fs.copy(sourceConfigPath, destinationConfigPath, { overwrite: true, errorOnExist: false });
|
|
741
|
-
configCopied = true;
|
|
740
|
+
await fs.copy(sourceConfigPath, destinationConfigPath, { overwrite: true, errorOnExist: false });
|
|
741
|
+
configCopied = true;
|
|
742
742
|
}
|
|
743
743
|
|
|
744
744
|
const sourceMigrations = resolve(packageSupabaseDir, 'migrations');
|
|
@@ -748,11 +748,11 @@ async function ensureSupabaseAssets(projectDir, options = {}) {
|
|
|
748
748
|
migrationsCopied = true;
|
|
749
749
|
}
|
|
750
750
|
|
|
751
|
-
if (required) {
|
|
752
|
-
if (!configCopied) {
|
|
753
|
-
throw new Error(
|
|
754
|
-
`Missing supabase/config.toml in the installed @nextblock-cms/db package (checked ${packageSupabaseDir}).`,
|
|
755
|
-
);
|
|
751
|
+
if (required) {
|
|
752
|
+
if (!configCopied) {
|
|
753
|
+
throw new Error(
|
|
754
|
+
`Missing supabase/config.toml in the installed @nextblock-cms/db package (checked ${packageSupabaseDir}).`,
|
|
755
|
+
);
|
|
756
756
|
}
|
|
757
757
|
if (!migrationsCopied) {
|
|
758
758
|
throw new Error(
|
|
@@ -761,8 +761,8 @@ async function ensureSupabaseAssets(projectDir, options = {}) {
|
|
|
761
761
|
}
|
|
762
762
|
}
|
|
763
763
|
|
|
764
|
-
return { migrationsCopied, configCopied };
|
|
765
|
-
}
|
|
764
|
+
return { migrationsCopied, configCopied };
|
|
765
|
+
}
|
|
766
766
|
|
|
767
767
|
async function resolvePackageSupabaseDir(projectDir) {
|
|
768
768
|
const triedPaths = [];
|
|
@@ -821,26 +821,26 @@ async function resolvePackageSupabaseDir(projectDir) {
|
|
|
821
821
|
return { dir: null, triedPaths };
|
|
822
822
|
}
|
|
823
823
|
|
|
824
|
-
async function readSupabaseProjectRef(projectDir) {
|
|
825
|
-
const projectRefPath = resolve(projectDir, 'supabase', '.temp', 'project-ref');
|
|
826
|
-
if (await fs.pathExists(projectRefPath)) {
|
|
827
|
-
const value = (await fs.readFile(projectRefPath, 'utf8')).trim();
|
|
828
|
-
if (/^[a-z0-9]{20,}$/i.test(value)) {
|
|
829
|
-
return value;
|
|
830
|
-
}
|
|
831
|
-
}
|
|
832
|
-
|
|
833
|
-
return null;
|
|
834
|
-
}
|
|
835
|
-
|
|
836
|
-
async function resetSupabaseProjectRef(projectDir) {
|
|
837
|
-
const tempDir = resolve(projectDir, 'supabase', '.temp');
|
|
838
|
-
await fs.ensureDir(tempDir);
|
|
839
|
-
const projectRefPath = resolve(tempDir, 'project-ref');
|
|
840
|
-
if (await fs.pathExists(projectRefPath)) {
|
|
841
|
-
await fs.remove(projectRefPath);
|
|
842
|
-
}
|
|
843
|
-
}
|
|
824
|
+
async function readSupabaseProjectRef(projectDir) {
|
|
825
|
+
const projectRefPath = resolve(projectDir, 'supabase', '.temp', 'project-ref');
|
|
826
|
+
if (await fs.pathExists(projectRefPath)) {
|
|
827
|
+
const value = (await fs.readFile(projectRefPath, 'utf8')).trim();
|
|
828
|
+
if (/^[a-z0-9]{20,}$/i.test(value)) {
|
|
829
|
+
return value;
|
|
830
|
+
}
|
|
831
|
+
}
|
|
832
|
+
|
|
833
|
+
return null;
|
|
834
|
+
}
|
|
835
|
+
|
|
836
|
+
async function resetSupabaseProjectRef(projectDir) {
|
|
837
|
+
const tempDir = resolve(projectDir, 'supabase', '.temp');
|
|
838
|
+
await fs.ensureDir(tempDir);
|
|
839
|
+
const projectRefPath = resolve(tempDir, 'project-ref');
|
|
840
|
+
if (await fs.pathExists(projectRefPath)) {
|
|
841
|
+
await fs.remove(projectRefPath);
|
|
842
|
+
}
|
|
843
|
+
}
|
|
844
844
|
|
|
845
845
|
async function ensureClientComponents(projectDir) {
|
|
846
846
|
const relativePaths = [
|
package/package.json
CHANGED
package/scripts/sync-template.js
CHANGED
|
@@ -36,16 +36,16 @@ const UI_PROXY_MODULES = [
|
|
|
36
36
|
'ui',
|
|
37
37
|
];
|
|
38
38
|
|
|
39
|
-
const IGNORED_SEGMENTS = new Set([
|
|
40
|
-
'node_modules',
|
|
41
|
-
'.git',
|
|
42
|
-
'.next',
|
|
43
|
-
'dist',
|
|
44
|
-
'tmp',
|
|
45
|
-
'coverage',
|
|
46
|
-
'backup',
|
|
47
|
-
'backups',
|
|
48
|
-
]);
|
|
39
|
+
const IGNORED_SEGMENTS = new Set([
|
|
40
|
+
'node_modules',
|
|
41
|
+
'.git',
|
|
42
|
+
'.next',
|
|
43
|
+
'dist',
|
|
44
|
+
'tmp',
|
|
45
|
+
'coverage',
|
|
46
|
+
'backup',
|
|
47
|
+
'backups',
|
|
48
|
+
]);
|
|
49
49
|
|
|
50
50
|
async function ensureTemplateSync() {
|
|
51
51
|
const sourceExists = await fs.pathExists(SOURCE_DIR);
|
|
@@ -79,9 +79,10 @@ async function ensureTemplateSync() {
|
|
|
79
79
|
},
|
|
80
80
|
});
|
|
81
81
|
|
|
82
|
-
await ensureEnvExample();
|
|
83
|
-
await
|
|
84
|
-
await
|
|
82
|
+
await ensureEnvExample();
|
|
83
|
+
await ensureTemplateGitignore();
|
|
84
|
+
await ensureGlobalStyles();
|
|
85
|
+
await ensureClientTranslations();
|
|
85
86
|
await sanitizeBlockEditorImports();
|
|
86
87
|
await sanitizeUiImports();
|
|
87
88
|
await ensureUiProxies();
|
|
@@ -91,7 +92,7 @@ async function ensureTemplateSync() {
|
|
|
91
92
|
console.log(chalk.green('Template sync complete.'));
|
|
92
93
|
}
|
|
93
94
|
|
|
94
|
-
async function ensureEnvExample() {
|
|
95
|
+
async function ensureEnvExample() {
|
|
95
96
|
const envTargets = [
|
|
96
97
|
resolve(REPO_ROOT, '.env.example'),
|
|
97
98
|
resolve(REPO_ROOT, '.env.exemple'),
|
|
@@ -117,8 +118,42 @@ NEXT_PUBLIC_URL=http://localhost:3000
|
|
|
117
118
|
`;
|
|
118
119
|
|
|
119
120
|
await fs.writeFile(destination, placeholder);
|
|
120
|
-
}
|
|
121
|
-
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
async function ensureTemplateGitignore() {
|
|
124
|
+
const destination = resolve(TARGET_DIR, '.gitignore');
|
|
125
|
+
const content = `.DS_Store
|
|
126
|
+
node_modules
|
|
127
|
+
dist
|
|
128
|
+
.next
|
|
129
|
+
out
|
|
130
|
+
build
|
|
131
|
+
coverage
|
|
132
|
+
*.log
|
|
133
|
+
logs
|
|
134
|
+
npm-debug.log*
|
|
135
|
+
yarn-debug.log*
|
|
136
|
+
yarn-error.log*
|
|
137
|
+
pnpm-debug.log*
|
|
138
|
+
|
|
139
|
+
.env
|
|
140
|
+
.env.*
|
|
141
|
+
.env.local
|
|
142
|
+
.env.development.local
|
|
143
|
+
.env.production.local
|
|
144
|
+
.env.test.local
|
|
145
|
+
|
|
146
|
+
.vscode
|
|
147
|
+
.idea
|
|
148
|
+
.swp
|
|
149
|
+
*.sw?
|
|
150
|
+
|
|
151
|
+
supabase/.temp
|
|
152
|
+
supabase/.branches
|
|
153
|
+
`;
|
|
154
|
+
await fs.outputFile(destination, content);
|
|
155
|
+
}
|
|
156
|
+
|
|
122
157
|
async function ensureGlobalStyles() {
|
|
123
158
|
const destination = resolve(TARGET_DIR, 'app/globals.css');
|
|
124
159
|
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
NEXT_PUBLIC_URL=
|
|
2
|
-
# Vercel / Supabase
|
|
3
|
-
SUPABASE_PROJECT_ID=
|
|
4
|
-
POSTGRES_URL=
|
|
5
|
-
NEXT_PUBLIC_SUPABASE_URL=
|
|
6
|
-
NEXT_PUBLIC_SUPABASE_ANON_KEY=
|
|
7
|
-
SUPABASE_SERVICE_ROLE_KEY=
|
|
8
|
-
|
|
9
|
-
# Cloudflare
|
|
10
|
-
NEXT_PUBLIC_R2_BASE_URL=
|
|
11
|
-
R2_ACCESS_KEY_ID=
|
|
12
|
-
R2_SECRET_ACCESS_KEY=
|
|
13
|
-
R2_BUCKET_NAME=
|
|
14
|
-
R2_ACCOUNT_ID=
|
|
15
|
-
|
|
16
|
-
REVALIDATE_SECRET_TOKEN=
|
|
17
|
-
|
|
18
|
-
# Email SMTP Configuration
|
|
19
|
-
SMTP_HOST=
|
|
20
|
-
SMTP_PORT=
|
|
21
|
-
SMTP_USER=
|
|
22
|
-
SMTP_PASS=
|
|
23
|
-
SMTP_FROM_EMAIL=
|
|
24
|
-
SMTP_FROM_NAME=
|