koguma 0.4.2 → 0.4.3
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/cli/index.ts +15 -15
- package/package.json +1 -1
- package/src/admin/_bundle.ts +2 -2
package/cli/index.ts
CHANGED
|
@@ -393,7 +393,7 @@ async function cmdInit() {
|
|
|
393
393
|
} else {
|
|
394
394
|
log(`Creating D1 database: ${CYAN}${dbName}${RESET}`);
|
|
395
395
|
try {
|
|
396
|
-
const output = runCapture(`
|
|
396
|
+
const output = runCapture(`bunx wrangler d1 create ${dbName}`, root);
|
|
397
397
|
const idMatch = output.match(/database_id\s*=\s*"([^"]+)"/);
|
|
398
398
|
if (idMatch?.[1]) {
|
|
399
399
|
toml = toml.replace(
|
|
@@ -409,7 +409,7 @@ async function cmdInit() {
|
|
|
409
409
|
}
|
|
410
410
|
} catch {
|
|
411
411
|
fail(
|
|
412
|
-
"Failed to create D1 database. Make sure you're logged into Cloudflare:
|
|
412
|
+
"Failed to create D1 database. Make sure you're logged into Cloudflare: bunx wrangler login"
|
|
413
413
|
);
|
|
414
414
|
}
|
|
415
415
|
}
|
|
@@ -420,11 +420,11 @@ async function cmdInit() {
|
|
|
420
420
|
|
|
421
421
|
log(`Checking R2 bucket: ${CYAN}${bucketName}${RESET}`);
|
|
422
422
|
try {
|
|
423
|
-
const buckets = runCapture('
|
|
423
|
+
const buckets = runCapture('bunx wrangler r2 bucket list', root);
|
|
424
424
|
if (buckets.includes(bucketName)) {
|
|
425
425
|
ok(`R2 bucket already exists: ${DIM}${bucketName}${RESET}`);
|
|
426
426
|
} else {
|
|
427
|
-
runCapture(`
|
|
427
|
+
runCapture(`bunx wrangler r2 bucket create ${bucketName}`, root);
|
|
428
428
|
ok(`Created R2 bucket: ${DIM}${bucketName}${RESET}`);
|
|
429
429
|
}
|
|
430
430
|
} catch {
|
|
@@ -489,7 +489,7 @@ async function cmdSeed() {
|
|
|
489
489
|
log(
|
|
490
490
|
`Seeding ${isRemote ? 'REMOTE' : 'local'} database: ${CYAN}${dbName}${RESET}`
|
|
491
491
|
);
|
|
492
|
-
run(`
|
|
492
|
+
run(`bunx wrangler d1 execute ${dbName} ${target} --file=${seedSql}`, {
|
|
493
493
|
cwd: root
|
|
494
494
|
});
|
|
495
495
|
|
|
@@ -509,7 +509,7 @@ async function cmdDeploy() {
|
|
|
509
509
|
|
|
510
510
|
// Deploy
|
|
511
511
|
log('\nDeploying to Cloudflare...');
|
|
512
|
-
run('
|
|
512
|
+
run('bunx wrangler deploy', { cwd: root });
|
|
513
513
|
|
|
514
514
|
ok('Deployed! 🎉');
|
|
515
515
|
}
|
|
@@ -518,7 +518,7 @@ async function cmdSecret() {
|
|
|
518
518
|
header('koguma secret');
|
|
519
519
|
const root = findProjectRoot();
|
|
520
520
|
log('Setting KOGUMA_SECRET (your admin password)...');
|
|
521
|
-
run('
|
|
521
|
+
run('bunx wrangler secret put KOGUMA_SECRET', { cwd: root });
|
|
522
522
|
ok('Secret set!');
|
|
523
523
|
}
|
|
524
524
|
|
|
@@ -650,7 +650,7 @@ async function cmdMigrateMedia() {
|
|
|
650
650
|
const target = isRemote ? '--remote' : '--local';
|
|
651
651
|
|
|
652
652
|
log(`\nUpdating ${isRemote ? 'remote' : 'local'} database URLs...`);
|
|
653
|
-
run(`
|
|
653
|
+
run(`bunx wrangler d1 execute ${dbName} ${target} --file=${sqlPath}`, {
|
|
654
654
|
cwd: root
|
|
655
655
|
});
|
|
656
656
|
|
|
@@ -847,7 +847,7 @@ async function cmdMigrate() {
|
|
|
847
847
|
for (const ct of config.contentTypes) {
|
|
848
848
|
try {
|
|
849
849
|
const output = runCapture(
|
|
850
|
-
`
|
|
850
|
+
`bunx wrangler d1 execute ${dbName} ${target} --command "SELECT name, type FROM pragma_table_info('${ct.id}')" --json`,
|
|
851
851
|
root
|
|
852
852
|
);
|
|
853
853
|
const parsed = JSON.parse(output);
|
|
@@ -866,7 +866,7 @@ async function cmdMigrate() {
|
|
|
866
866
|
// Also ensure _assets table exists
|
|
867
867
|
try {
|
|
868
868
|
const output = runCapture(
|
|
869
|
-
`
|
|
869
|
+
`bunx wrangler d1 execute ${dbName} ${target} --command "SELECT name FROM pragma_table_info('_assets')" --json`,
|
|
870
870
|
root
|
|
871
871
|
);
|
|
872
872
|
const parsed = JSON.parse(output);
|
|
@@ -929,7 +929,7 @@ async function cmdMigrate() {
|
|
|
929
929
|
log(`\nWritten to ${CYAN}db/migration.sql${RESET}`);
|
|
930
930
|
|
|
931
931
|
log(`\nApplying migration to ${isRemote ? 'REMOTE' : 'local'} database...`);
|
|
932
|
-
run(`
|
|
932
|
+
run(`bunx wrangler d1 execute ${dbName} ${target} --file=${sqlFile}`, {
|
|
933
933
|
cwd: root
|
|
934
934
|
});
|
|
935
935
|
|
|
@@ -972,7 +972,7 @@ async function cmdExport() {
|
|
|
972
972
|
// Export main table
|
|
973
973
|
try {
|
|
974
974
|
const output = runCapture(
|
|
975
|
-
`
|
|
975
|
+
`bunx wrangler d1 execute ${dbName} ${target} --command "SELECT * FROM ${ct.id}" --json`,
|
|
976
976
|
root
|
|
977
977
|
);
|
|
978
978
|
const parsed = JSON.parse(output);
|
|
@@ -985,7 +985,7 @@ async function cmdExport() {
|
|
|
985
985
|
const joinTable = `${ct.id}__${fieldId}`;
|
|
986
986
|
try {
|
|
987
987
|
const jtOutput = runCapture(
|
|
988
|
-
`
|
|
988
|
+
`bunx wrangler d1 execute ${dbName} ${target} --command "SELECT * FROM ${joinTable}" --json`,
|
|
989
989
|
root
|
|
990
990
|
);
|
|
991
991
|
const jtParsed = JSON.parse(jtOutput);
|
|
@@ -1080,7 +1080,7 @@ async function cmdImport() {
|
|
|
1080
1080
|
|
|
1081
1081
|
const sql = `INSERT OR REPLACE INTO ${typeId} (${cols.join(', ')}) VALUES (${vals.join(', ')})`;
|
|
1082
1082
|
run(
|
|
1083
|
-
`
|
|
1083
|
+
`bunx wrangler d1 execute ${dbName} ${target} --command "${sql.replace(/"/g, '\\"')}"`,
|
|
1084
1084
|
{ cwd: root, silent: true }
|
|
1085
1085
|
);
|
|
1086
1086
|
totalEntries++;
|
|
@@ -1098,7 +1098,7 @@ async function cmdImport() {
|
|
|
1098
1098
|
|
|
1099
1099
|
const sql = `INSERT OR REPLACE INTO ${jtName} (${cols.join(', ')}) VALUES (${vals.join(', ')})`;
|
|
1100
1100
|
run(
|
|
1101
|
-
`
|
|
1101
|
+
`bunx wrangler d1 execute ${dbName} ${target} --command "${sql.replace(/"/g, '\\"')}"`,
|
|
1102
1102
|
{ cwd: root, silent: true }
|
|
1103
1103
|
);
|
|
1104
1104
|
}
|