@brightsideoy/kama 1.0.0-alpha.10 → 1.0.0-alpha.12
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/cli.js +34 -17
- package/dist/assets/{index-Bzbme3Ob.css → index-CGLx9oqF.css} +1 -1
- package/dist/assets/{index-DX98CiK-.js → index-De9O-dAG.js} +2 -2
- package/dist/build-seed.js +486 -0
- package/dist/{dist-CErcWOwp.js → dist-kIJlDMvm.js} +29 -3
- package/dist/index.html +2 -2
- package/dist/index.js +29 -3
- package/dist/schema-compiler.js +1 -1
- package/package.json +3 -1
package/bin/cli.js
CHANGED
|
@@ -50,8 +50,8 @@ try {
|
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
/**
|
|
53
|
-
|
|
54
|
-
|
|
53
|
+
- 🎯 SECURE SECRET MANAGER
|
|
54
|
+
- Gracefully retrieves an existing workspace secret, or generates and injects one if missing.
|
|
55
55
|
*/
|
|
56
56
|
function getOrGenerateWorkspaceSecret(workerDir) {
|
|
57
57
|
const envPath = join(workerDir, '.env');
|
|
@@ -89,7 +89,7 @@ function getOrGenerateWorkspaceSecret(workerDir) {
|
|
|
89
89
|
}
|
|
90
90
|
|
|
91
91
|
/**
|
|
92
|
-
|
|
92
|
+
- 🎯 BULLETPROOF WRANGLER EXECUTION RESOLVER
|
|
93
93
|
*/
|
|
94
94
|
function getWranglerCmd() {
|
|
95
95
|
try {
|
|
@@ -101,7 +101,7 @@ function getWranglerCmd() {
|
|
|
101
101
|
}
|
|
102
102
|
|
|
103
103
|
/**
|
|
104
|
-
|
|
104
|
+
- 🎯 ROBUST WRANGLER RUNNER
|
|
105
105
|
*/
|
|
106
106
|
function runWrangler(cmd, options = {}) {
|
|
107
107
|
const baseWrangler = getWranglerCmd();
|
|
@@ -121,7 +121,7 @@ function runWrangler(cmd, options = {}) {
|
|
|
121
121
|
}
|
|
122
122
|
|
|
123
123
|
/**
|
|
124
|
-
|
|
124
|
+
- 🎯 BULLETPROOF KV PROVISIONING ENGINE
|
|
125
125
|
*/
|
|
126
126
|
function getOrCreateKV(title) {
|
|
127
127
|
const out = runWrangler(`kv namespace create "${title}"`);
|
|
@@ -152,11 +152,12 @@ function showHelp() {
|
|
|
152
152
|
console.log(' promote Promote the current Local workspace to Cloudflare Edge');
|
|
153
153
|
console.log(' help, -h Show this help message\n');
|
|
154
154
|
console.log(pc.cyan('Workspace Scripts (Run from project root):'));
|
|
155
|
-
console.log(' npm update
|
|
156
|
-
console.log(' npm run setup
|
|
157
|
-
console.log(' npm run
|
|
158
|
-
console.log(' npm run
|
|
159
|
-
console.log(' npm run deploy:
|
|
155
|
+
console.log(' npm update Update to latest KAMA version');
|
|
156
|
+
console.log(' npm run setup Initialize database schema (Run Once)');
|
|
157
|
+
console.log(' npm run seed -w kama-worker Seed the database with mock test data'); // 🎯 NEW LINE
|
|
158
|
+
console.log(' npm run dev Boot up the CMS backend and Astro frontend concurrently');
|
|
159
|
+
console.log(' npm run deploy:cms Deploy the backend worker and database to Cloudflare');
|
|
160
|
+
console.log(' npm run deploy:site Deploy the Astro frontend site to Cloudflare\n');
|
|
160
161
|
}
|
|
161
162
|
|
|
162
163
|
async function main() {
|
|
@@ -223,7 +224,7 @@ function convertAstroConfigToCloudflare(siteDir) {
|
|
|
223
224
|
}
|
|
224
225
|
|
|
225
226
|
/**
|
|
226
|
-
|
|
227
|
+
- COMMAND: npx kama init
|
|
227
228
|
*/
|
|
228
229
|
async function createFullWorkspace() {
|
|
229
230
|
const cwdName = basename(process.cwd());
|
|
@@ -406,13 +407,17 @@ async function createFullWorkspace() {
|
|
|
406
407
|
type: 'module',
|
|
407
408
|
version: '1.0.0',
|
|
408
409
|
scripts: {
|
|
410
|
+
// 🎯 Uses native node with the compiled dist/build-seed.js
|
|
411
|
+
"seed": "npm run seed:local",
|
|
412
|
+
"seed:local": "node ../node_modules/@brightsideoy/kama/dist/build-seed.js && wrangler d1 execute " + dbName + " --local --file=seed.sql",
|
|
413
|
+
"seed:remote": "node ../node_modules/@brightsideoy/kama/dist/build-seed.js && wrangler d1 execute " + dbName + " --remote --file=seed.sql",
|
|
409
414
|
"setup:local": `wrangler d1 execute ${dbName} --local --file=../node_modules/@brightsideoy/kama/schema.sql > /dev/null 2>&1`,
|
|
410
415
|
"setup:remote": `wrangler d1 execute ${dbName} --remote --file=../node_modules/@brightsideoy/kama/schema.sql`,
|
|
411
416
|
"dev": "wrangler dev --port 8787 --inspector-port 9239",
|
|
412
417
|
"deploy": "npm run setup:remote && wrangler deploy"
|
|
413
418
|
},
|
|
414
419
|
dependencies: { '@brightsideoy/kama': currentKamaVersion, '@libsql/client': '^0.14.0' },
|
|
415
|
-
devDependencies: { "wrangler": WRANGLER_LATEST },
|
|
420
|
+
devDependencies: { "wrangler": WRANGLER_LATEST }, // 🎯 Removed TSX requirement
|
|
416
421
|
}, null, 2)
|
|
417
422
|
);
|
|
418
423
|
|
|
@@ -453,12 +458,15 @@ async function createFullWorkspace() {
|
|
|
453
458
|
type: 'module',
|
|
454
459
|
version: '1.0.0',
|
|
455
460
|
scripts: {
|
|
461
|
+
// 🎯 Uses native node with the compiled dist/build-seed.js
|
|
462
|
+
"seed": "npm run seed:local",
|
|
463
|
+
"seed:local": "node ../node_modules/@brightsideoy/kama/dist/build-seed.js && sqlite3 kama.db < seed.sql",
|
|
456
464
|
"setup:local": "sqlite3 kama.db < ../node_modules/@brightsideoy/kama/schema.sql",
|
|
457
465
|
"dev": "tsx server.js",
|
|
458
466
|
"start": "node server.js"
|
|
459
467
|
},
|
|
460
468
|
dependencies: { '@brightsideoy/kama': currentKamaVersion, '@hono/node-server': '^1.13.0', '@libsql/client': '^0.14.0', 'sharp': '^0.33.5', 'dotenv': '^16.4.5' },
|
|
461
|
-
devDependencies: { "tsx": "^4.19.0" },
|
|
469
|
+
devDependencies: { "tsx": "^4.19.0" }, // 🎯 Kept because "dev" uses it
|
|
462
470
|
}, null, 2)
|
|
463
471
|
);
|
|
464
472
|
|
|
@@ -496,7 +504,7 @@ async function createFullWorkspace() {
|
|
|
496
504
|
}
|
|
497
505
|
|
|
498
506
|
/**
|
|
499
|
-
|
|
507
|
+
- COMMAND: npx kama add site
|
|
500
508
|
*/
|
|
501
509
|
async function createNewSiteOnly() {
|
|
502
510
|
const rootDir = process.cwd();
|
|
@@ -563,7 +571,7 @@ async function createNewSiteOnly() {
|
|
|
563
571
|
}
|
|
564
572
|
|
|
565
573
|
/**
|
|
566
|
-
|
|
574
|
+
- COMMAND: npx kama bundle
|
|
567
575
|
*/
|
|
568
576
|
async function bundleWorkspaceSchemas(targetRootDir, silent = false) {
|
|
569
577
|
let rootDir = targetRootDir || process.cwd();
|
|
@@ -582,7 +590,7 @@ async function bundleWorkspaceSchemas(targetRootDir, silent = false) {
|
|
|
582
590
|
}
|
|
583
591
|
|
|
584
592
|
/**
|
|
585
|
-
|
|
593
|
+
- COMMAND: npx kama promote
|
|
586
594
|
*/
|
|
587
595
|
async function promoteLocalToCloudflare() {
|
|
588
596
|
const rootDir = process.cwd();
|
|
@@ -681,8 +689,17 @@ async function promoteLocalToCloudflare() {
|
|
|
681
689
|
workerPkg.scripts.deploy = "npm run setup:remote && wrangler deploy";
|
|
682
690
|
workerPkg.scripts["setup:local"] = `wrangler d1 execute ${dbName} --local --file=../node_modules/@brightsideoy/kama/schema.sql`;
|
|
683
691
|
workerPkg.scripts["setup:remote"] = `wrangler d1 execute ${dbName} --remote --file=../node_modules/@brightsideoy/kama/schema.sql`;
|
|
692
|
+
|
|
693
|
+
// 🎯 Uses native node with the compiled dist/build-seed.js
|
|
694
|
+
workerPkg.scripts["seed"] = "npm run seed:local";
|
|
695
|
+
workerPkg.scripts["seed:local"] = `node ../node_modules/@brightsideoy/kama/dist/build-seed.js && wrangler d1 execute ${dbName} --local --file=seed.sql`;
|
|
696
|
+
workerPkg.scripts["seed:remote"] = `node ../node_modules/@brightsideoy/kama/dist/build-seed.js && wrangler d1 execute ${dbName} --remote --file=seed.sql`;
|
|
697
|
+
|
|
684
698
|
workerPkg.devDependencies = workerPkg.devDependencies || {};
|
|
685
699
|
workerPkg.devDependencies.wrangler = WRANGLER_LATEST;
|
|
700
|
+
// 🎯 explicit deletion of TSX addition on promotion
|
|
701
|
+
if (workerPkg.devDependencies.tsx) delete workerPkg.devDependencies.tsx;
|
|
702
|
+
|
|
686
703
|
writeFileSync(workerPkgPath, JSON.stringify(workerPkg, null, 2));
|
|
687
704
|
}
|
|
688
705
|
|
|
@@ -727,7 +744,7 @@ async function promoteLocalToCloudflare() {
|
|
|
727
744
|
}
|
|
728
745
|
|
|
729
746
|
/**
|
|
730
|
-
|
|
747
|
+
- Helper: Copies the Astro starter template and hydrates runtime tokens
|
|
731
748
|
*/
|
|
732
749
|
async function generateAstroSite(rootDir, siteFolder, siteDomain, cmsFullUrl, workerName = 'kama-worker', isCloudflare = false, frontendApiSecret = '') {
|
|
733
750
|
const siteDir = join(rootDir, 'sites', siteFolder);
|