@decocms/blocks-cli 7.29.0 → 7.31.0
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/package.json +2 -2
- package/scripts/migrate.ts +58 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@decocms/blocks-cli",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.31.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Deco codegen (generate-blocks, generate-schema, generate-invoke) and Fresh-to-TanStack migration tooling",
|
|
6
6
|
"repository": {
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"lint:unused": "knip"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@decocms/blocks": "7.
|
|
34
|
+
"@decocms/blocks": "7.31.0",
|
|
35
35
|
"ts-morph": "^27.0.0",
|
|
36
36
|
"tsx": "^4.22.5"
|
|
37
37
|
},
|
package/scripts/migrate.ts
CHANGED
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
*/
|
|
26
26
|
|
|
27
27
|
import { execSync } from "node:child_process";
|
|
28
|
+
import * as fs from "node:fs";
|
|
28
29
|
import * as path from "node:path";
|
|
29
30
|
import { banner, green, red, stat, yellow } from "./migrate/colors";
|
|
30
31
|
import { loadConfig, validateConfig } from "./migrate/config";
|
|
@@ -194,6 +195,7 @@ async function main() {
|
|
|
194
195
|
// Phase 7: Bootstrap (install + generate)
|
|
195
196
|
if (!ctx.dryRun) {
|
|
196
197
|
bootstrap(ctx);
|
|
198
|
+
await provisionAnalytics(ctx.sourceDir);
|
|
197
199
|
}
|
|
198
200
|
|
|
199
201
|
// Phase 8: Compile (typecheck + optional build)
|
|
@@ -279,4 +281,60 @@ function bootstrap(ctx: { sourceDir: string }) {
|
|
|
279
281
|
}
|
|
280
282
|
}
|
|
281
283
|
|
|
284
|
+
// Supabase project ref for decocms — the central platform DB that tracks all sites.
|
|
285
|
+
const DECOCMS_SUPABASE_REF = "ozksgdmyrqcxcwhnbepg";
|
|
286
|
+
|
|
287
|
+
async function provisionAnalytics(sourceDir: string): Promise<void> {
|
|
288
|
+
logPhase("Provision analytics (decocms Supabase)");
|
|
289
|
+
|
|
290
|
+
let siteName: string;
|
|
291
|
+
try {
|
|
292
|
+
const pkg = JSON.parse(fs.readFileSync(path.join(sourceDir, "package.json"), "utf8"));
|
|
293
|
+
siteName = pkg.name;
|
|
294
|
+
} catch {
|
|
295
|
+
console.log(` ${yellow("⚠")} Could not read package.json — skipping analytics provision`);
|
|
296
|
+
return;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
const token = process.env.SUPABASE_ACCESS_TOKEN;
|
|
300
|
+
if (!token) {
|
|
301
|
+
console.log(` ${yellow("⚠")} SUPABASE_ACCESS_TOKEN not set — skipping analytics provision`);
|
|
302
|
+
printAnalyticsSQL(siteName);
|
|
303
|
+
return;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
const sql = `UPDATE public.sites SET metadata = metadata || '{"analytics": "onedollarstats"}'::jsonb WHERE name = '${siteName}'`;
|
|
307
|
+
|
|
308
|
+
try {
|
|
309
|
+
const res = await fetch(
|
|
310
|
+
`https://api.supabase.com/v1/projects/${DECOCMS_SUPABASE_REF}/database/query`,
|
|
311
|
+
{
|
|
312
|
+
method: "POST",
|
|
313
|
+
headers: {
|
|
314
|
+
Authorization: `Bearer ${token}`,
|
|
315
|
+
"Content-Type": "application/json",
|
|
316
|
+
},
|
|
317
|
+
body: JSON.stringify({ query: sql }),
|
|
318
|
+
},
|
|
319
|
+
);
|
|
320
|
+
if (res.ok) {
|
|
321
|
+
console.log(` ${green("✓")} ${siteName} → analytics: onedollarstats`);
|
|
322
|
+
} else {
|
|
323
|
+
const body = await res.text();
|
|
324
|
+
console.log(` ${yellow("⚠")} Supabase update failed (${res.status}): ${body.slice(0, 120)}`);
|
|
325
|
+
printAnalyticsSQL(siteName);
|
|
326
|
+
}
|
|
327
|
+
} catch (err: any) {
|
|
328
|
+
console.log(` ${yellow("⚠")} Supabase request failed: ${err.message}`);
|
|
329
|
+
printAnalyticsSQL(siteName);
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
function printAnalyticsSQL(siteName: string): void {
|
|
334
|
+
console.log(` Run manually on decocms Supabase (${DECOCMS_SUPABASE_REF}):`);
|
|
335
|
+
console.log(
|
|
336
|
+
` UPDATE public.sites SET metadata = metadata || '{"analytics": "onedollarstats"}'::jsonb WHERE name = '${siteName}';`,
|
|
337
|
+
);
|
|
338
|
+
}
|
|
339
|
+
|
|
282
340
|
main();
|