@tamyla/clodo-framework 3.0.8 → 3.0.9

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/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## [3.0.9](https://github.com/tamylaa/clodo-framework/compare/v3.0.8...v3.0.9) (2025-10-14)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * Auto-create D1 databases before applying migrations ([bb4a780](https://github.com/tamylaa/clodo-framework/commit/bb4a7804307f4ee8ff17256287e61098d809b0e9))
7
+
1
8
  ## [3.0.8](https://github.com/tamylaa/clodo-framework/compare/v3.0.7...v3.0.8) (2025-10-14)
2
9
 
3
10
 
@@ -39,6 +39,10 @@ export class DatabaseOrchestrator {
39
39
  this.options = options;
40
40
  this.config = null;
41
41
 
42
+ // Cloudflare API credentials for database operations
43
+ this.cloudflareToken = options.cloudflareToken;
44
+ this.cloudflareAccountId = options.cloudflareAccountId;
45
+
42
46
  // Environment configurations
43
47
  this.environments = {
44
48
  development: {
@@ -389,11 +393,25 @@ export class DatabaseOrchestrator {
389
393
  }
390
394
  try {
391
395
  // Validate database exists before attempting migrations
392
- const exists = await databaseExists(databaseName);
396
+ const exists = await databaseExists(databaseName, {
397
+ apiToken: this.cloudflareToken,
398
+ accountId: this.cloudflareAccountId
399
+ });
393
400
  if (!exists) {
394
- throw new Error(`Database ${databaseName} does not exist. ` + `Database must be created before applying migrations.`);
401
+ console.log(` 📦 Database ${databaseName} does not exist, creating...`);
402
+ if (!this.cloudflareToken || !this.cloudflareAccountId) {
403
+ throw new Error(`Database ${databaseName} does not exist and no Cloudflare API credentials provided. ` + `Cannot create database automatically. Please provide cloudflareToken and cloudflareAccountId.`);
404
+ }
405
+
406
+ // Create the database using API
407
+ await createDatabase(databaseName, {
408
+ apiToken: this.cloudflareToken,
409
+ accountId: this.cloudflareAccountId
410
+ });
411
+ console.log(` ✅ Database ${databaseName} created successfully`);
412
+ } else {
413
+ console.log(` ✅ Database ${databaseName} validated`);
395
414
  }
396
- console.log(` ✅ Database ${databaseName} validated`);
397
415
 
398
416
  // Use DATABASE name for wrangler command
399
417
  const command = this.buildMigrationCommand(databaseName, environment, isRemote);
@@ -654,10 +672,8 @@ export class DatabaseOrchestrator {
654
672
  // NOT: "npx wrangler d1 migrations apply binding-name --local"
655
673
  let command = `npx wrangler d1 migrations apply ${databaseName}`;
656
674
 
657
- // Add environment flag for non-production environments
658
- if (environment !== 'production') {
659
- command += ` --env ${environment}`;
660
- }
675
+ // Add environment flag for all environments (consistent with bin version)
676
+ command += ` --env ${environment}`;
661
677
 
662
678
  // For remote environments, add --remote flag
663
679
  // For local development, use --local
@@ -63,7 +63,9 @@ export class MultiDomainOrchestrator {
63
63
  // Initialize enterprise-grade utilities
64
64
  this.databaseOrchestrator = new DatabaseOrchestrator({
65
65
  projectRoot: this.servicePath,
66
- dryRun: this.dryRun
66
+ dryRun: this.dryRun,
67
+ cloudflareToken: this.cloudflareToken,
68
+ cloudflareAccountId: this.cloudflareAccountId
67
69
  });
68
70
  this.secretManager = new EnhancedSecretManager({
69
71
  projectRoot: this.servicePath,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tamyla/clodo-framework",
3
- "version": "3.0.8",
3
+ "version": "3.0.9",
4
4
  "description": "Reusable framework for Clodo-style software architecture on Cloudflare Workers + D1",
5
5
  "type": "module",
6
6
  "sideEffects": [