d1s 0.2.2 → 0.2.4

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.
Files changed (65) hide show
  1. package/dist/.next/.next/BUILD_ID +1 -1
  2. package/dist/.next/.next/app-build-manifest.json +19 -19
  3. package/dist/.next/.next/app-path-routes-manifest.json +1 -1
  4. package/dist/.next/.next/build-manifest.json +2 -2
  5. package/dist/.next/.next/cache/.tsbuildinfo +1 -1
  6. package/dist/.next/.next/cache/webpack/client-production/0.pack +0 -0
  7. package/dist/.next/.next/cache/webpack/client-production/2.pack +0 -0
  8. package/dist/.next/.next/cache/webpack/client-production/4.pack +0 -0
  9. package/dist/.next/.next/cache/webpack/client-production/5.pack +0 -0
  10. package/dist/.next/.next/cache/webpack/client-production/6.pack +0 -0
  11. package/dist/.next/.next/cache/webpack/client-production/index.pack +0 -0
  12. package/dist/.next/.next/cache/webpack/client-production/index.pack.old +0 -0
  13. package/dist/.next/.next/cache/webpack/server-production/0.pack +0 -0
  14. package/dist/.next/.next/cache/webpack/server-production/3.pack +0 -0
  15. package/dist/.next/.next/cache/webpack/server-production/4.pack +0 -0
  16. package/dist/.next/.next/cache/webpack/server-production/5.pack +0 -0
  17. package/dist/.next/.next/cache/webpack/server-production/6.pack +0 -0
  18. package/dist/.next/.next/cache/webpack/server-production/index.pack +0 -0
  19. package/dist/.next/.next/cache/webpack/server-production/index.pack.old +0 -0
  20. package/dist/.next/.next/next-minimal-server.js.nft.json +1 -1
  21. package/dist/.next/.next/next-server.js.nft.json +1 -1
  22. package/dist/.next/.next/prerender-manifest.json +1 -1
  23. package/dist/.next/.next/server/app/_not-found.html +1 -1
  24. package/dist/.next/.next/server/app/_not-found.rsc +1 -1
  25. package/dist/.next/.next/server/app/api/cloudflare/route.js +1 -1
  26. package/dist/.next/.next/server/app/api/databases/route.js +1 -1
  27. package/dist/.next/.next/server/app/api/migrations/sync/route.js +1 -1
  28. package/dist/.next/.next/server/app/api/migrations/sync-files/route.js +1 -1
  29. package/dist/.next/.next/server/app/api/pull-remote/confirm/route.js +1 -1
  30. package/dist/.next/.next/server/app/api/pull-remote/preview/route.js +1 -1
  31. package/dist/.next/.next/server/app/api/push-remote/confirm/route.js +2 -2
  32. package/dist/.next/.next/server/app/api/push-remote/preview/route.js +2 -2
  33. package/dist/.next/.next/server/app/api/query/route.js +2 -2
  34. package/dist/.next/.next/server/app/api/tables/[name]/route.js +2 -2
  35. package/dist/.next/.next/server/app/api/tables/route.js +2 -2
  36. package/dist/.next/.next/server/app/index.html +1 -1
  37. package/dist/.next/.next/server/app/index.rsc +1 -1
  38. package/dist/.next/.next/server/app/page.js +6 -6
  39. package/dist/.next/.next/server/app-paths-manifest.json +4 -4
  40. package/dist/.next/.next/server/chunks/336.js +1 -1
  41. package/dist/.next/.next/server/chunks/801.js +11 -11
  42. package/dist/.next/.next/server/chunks/973.js +1 -1
  43. package/dist/.next/.next/server/chunks/992.js +2 -2
  44. package/dist/.next/.next/server/pages/404.html +1 -1
  45. package/dist/.next/.next/server/pages/500.html +1 -1
  46. package/dist/.next/.next/static/YIuXI2CxMwg2fuuUEBsXL/_buildManifest.js +1 -0
  47. package/dist/.next/.next/static/YIuXI2CxMwg2fuuUEBsXL/_ssgManifest.js +1 -0
  48. package/dist/.next/.next/static/fSVNB2iNhKcZdXXgESWZk/_buildManifest.js +1 -0
  49. package/dist/.next/.next/static/fSVNB2iNhKcZdXXgESWZk/_ssgManifest.js +1 -0
  50. package/dist/.next/.next/trace +3 -3
  51. package/dist/app/app/api/databases/route.js +1 -1
  52. package/dist/app/app/api/pull-remote/confirm/route.js +20 -20
  53. package/dist/app/app/api/push-remote/confirm/route.js +1 -1
  54. package/dist/app/app/api/push-remote/preview/route.js +1 -1
  55. package/dist/app/app/api/query/route.js +7 -7
  56. package/dist/d1-studio.js +25 -1
  57. package/dist/lib/find-wrangler-config.js +1 -1
  58. package/package.json +1 -1
  59. package/scripts/studio.js +25 -1
  60. package/src/app/api/databases/route.js +1 -1
  61. package/src/app/api/pull-remote/confirm/route.js +20 -20
  62. package/src/app/api/push-remote/confirm/route.js +1 -1
  63. package/src/app/api/push-remote/preview/route.js +1 -1
  64. package/src/app/api/query/route.js +7 -7
  65. package/src/lib/find-wrangler-config.js +1 -1
@@ -52,19 +52,19 @@ async function applyPullMigrations(projectDir, accountId, apiToken, databaseName
52
52
  await Promise.all(stagedFilesList.map(file => unlink(path.join(stagingDir, file))));
53
53
 
54
54
  // --- STEP 1: Fetch remote migration metadata ---
55
- console.log('Fetching remote migration metadata...');
55
+ // console.log('Fetching remote migration metadata...');
56
56
  const remoteMigrations = await getRemoteMigrations(projectDir, databaseName, env);
57
- console.log('Remote migration metadata:', remoteMigrations);
57
+ // console.log('Remote migration metadata:', remoteMigrations);
58
58
 
59
59
  // --- STEP 2: For each remote migration, fetch its file content ---
60
- console.log('Fetching migration file content from remote...');
60
+ // console.log('Fetching migration file content from remote...');
61
61
  const stagedFiles = new Map();
62
62
  for (const migration of remoteMigrations) {
63
63
  try {
64
64
  const migrationFileName = migration.name; // Use the remote migration's name.
65
65
  const content = await getMigrationFileContent(projectDir, databaseName, migrationFileName, env);
66
66
  stagedFiles.set(migrationFileName, content);
67
- console.log(`Staged migration file: ${migrationFileName}`);
67
+ // console.log(`Staged migration file: ${migrationFileName}`);
68
68
  await writeFile(path.join(stagingDir, migrationFileName), content, 'utf8');
69
69
  } catch (fileError) {
70
70
  console.error(`Error fetching content for migration ${migration.name}:`, fileError);
@@ -73,12 +73,12 @@ async function applyPullMigrations(projectDir, accountId, apiToken, databaseName
73
73
  }
74
74
 
75
75
  // --- STEP 3: Fetch local schema for destructive update ---
76
- console.log('Fetching local schema for destructive update...');
76
+ // console.log('Fetching local schema for destructive update...');
77
77
  const currentSchema = await getCurrentSchema(projectDir, databaseName, env, false);
78
78
  const tableSchema = currentSchema.filter(obj =>
79
79
  obj.type === 'table' && obj.name && obj.name.toLowerCase() !== 'if'
80
80
  );
81
- console.log('Local table schema:', tableSchema);
81
+ // console.log('Local table schema:', tableSchema);
82
82
  const dropOrder = tableSchema.length > 0
83
83
  ? analyzeDependencies(
84
84
  tableSchema.map(obj => ({
@@ -88,18 +88,18 @@ async function applyPullMigrations(projectDir, accountId, apiToken, databaseName
88
88
  }))
89
89
  )
90
90
  : [];
91
- console.log('Computed drop order:', dropOrder);
91
+ // console.log('Computed drop order:', dropOrder);
92
92
 
93
93
  // --- STEP 4: Destructive update (all-or-nothing) ---
94
- console.log('Beginning destructive update...');
94
+ // console.log('Beginning destructive update...');
95
95
  try {
96
- console.log('Disabling foreign keys...');
96
+ // console.log('Disabling foreign keys...');
97
97
  await executeSQL(projectDir, databaseName, 'PRAGMA foreign_keys=OFF;', env, false);
98
98
 
99
99
  // Drop triggers.
100
100
  const triggers = currentSchema.filter(obj => obj.type === 'trigger');
101
101
  for (const trigger of triggers) {
102
- console.log(`Dropping trigger: ${trigger.name}`);
102
+ // console.log(`Dropping trigger: ${trigger.name}`);
103
103
  await executeSQL(
104
104
  projectDir,
105
105
  databaseName,
@@ -111,7 +111,7 @@ async function applyPullMigrations(projectDir, accountId, apiToken, databaseName
111
111
  // Drop indexes.
112
112
  const indexes = currentSchema.filter(obj => obj.type === 'index');
113
113
  for (const index of indexes) {
114
- console.log(`Dropping index: ${index.name}`);
114
+ // console.log(`Dropping index: ${index.name}`);
115
115
  await executeSQL(
116
116
  projectDir,
117
117
  databaseName,
@@ -122,7 +122,7 @@ async function applyPullMigrations(projectDir, accountId, apiToken, databaseName
122
122
  }
123
123
  // Drop tables in reverse dependency order.
124
124
  for (const tableName of dropOrder.reverse()) {
125
- console.log(`Dropping table: ${tableName}`);
125
+ // console.log(`Dropping table: ${tableName}`);
126
126
  await executeSQL(
127
127
  projectDir,
128
128
  databaseName,
@@ -131,7 +131,7 @@ async function applyPullMigrations(projectDir, accountId, apiToken, databaseName
131
131
  false
132
132
  );
133
133
  }
134
- console.log('Re-enabling foreign keys...');
134
+ // console.log('Re-enabling foreign keys...');
135
135
  await executeSQL(projectDir, databaseName, 'PRAGMA foreign_keys=ON;', env, false);
136
136
  } catch (dropError) {
137
137
  throw new Error(`Error dropping existing objects: ${dropError.message}`);
@@ -139,7 +139,7 @@ async function applyPullMigrations(projectDir, accountId, apiToken, databaseName
139
139
 
140
140
  // --- STEP 5: Reset the local migrations table ---
141
141
  try {
142
- console.log('Resetting local migrations table...');
142
+ // console.log('Resetting local migrations table...');
143
143
  await initMigrationsTable(projectDir, databaseName, 'local', true);
144
144
  } catch (initError) {
145
145
  throw new Error(`Error resetting migrations table: ${initError.message}`);
@@ -152,7 +152,7 @@ async function applyPullMigrations(projectDir, accountId, apiToken, databaseName
152
152
  try {
153
153
  for (const [filename, content] of stagedFiles.entries()) {
154
154
  currentFilename = filename;
155
- console.log(`Applying migration: ${filename}`);
155
+ // console.log(`Applying migration: ${filename}`);
156
156
  // Write the migration file to the main migrations folder.
157
157
  await writeFile(path.join(migrationsDir, filename), content, 'utf8');
158
158
 
@@ -162,7 +162,7 @@ async function applyPullMigrations(projectDir, accountId, apiToken, databaseName
162
162
  .update(content)
163
163
  .digest('hex');
164
164
 
165
- console.log(`Recording migration: ${filename} with checksum ${checksum}`);
165
+ // console.log(`Recording migration: ${filename} with checksum ${checksum}`);
166
166
  await recordMigration(
167
167
  projectDir,
168
168
  databaseName,
@@ -181,20 +181,20 @@ async function applyPullMigrations(projectDir, accountId, apiToken, databaseName
181
181
  }
182
182
 
183
183
  // --- STEP 7: Replace main migrations folder with staged files ---
184
- console.log('Replacing main migrations folder with staged files...');
184
+ // console.log('Replacing main migrations folder with staged files...');
185
185
  const mainFiles = await readdir(migrationsDir).catch(() => []);
186
186
  if (mainFiles.length) {
187
187
  for (const file of mainFiles) {
188
- console.log(`Deleting local migration file: ${file}`);
188
+ // console.log(`Deleting local migration file: ${file}`);
189
189
  await unlink(path.join(migrationsDir, file));
190
190
  }
191
191
  }
192
192
  for (const [filename, content] of stagedFiles.entries()) {
193
- console.log(`Copying staged file ${filename} to main migrations folder`);
193
+ // console.log(`Copying staged file ${filename} to main migrations folder`);
194
194
  await writeFile(path.join(migrationsDir, filename), content, 'utf8');
195
195
  }
196
196
 
197
- console.log('Pull migration applied successfully.');
197
+ // console.log('Pull migration applied successfully.');
198
198
  return {
199
199
  appliedMigrations: Array.from(stagedFiles.keys()),
200
200
  details: appliedPreview
@@ -133,7 +133,7 @@ for (const migrationFile of migrationFiles) {
133
133
  results.preview.push(previewRecord);
134
134
  }
135
135
  }
136
- console.log("Push Confirm Result (server):", results);
136
+ // console.log("Push Confirm Result (server):", results);
137
137
  return { success: true, preview: false, applied: results.applied.length, skipped: results.skipped.length, details: results };
138
138
  } catch (error) {
139
139
  throw {
@@ -100,7 +100,7 @@ async function pushToRemote(projectDir, accountId, apiToken, databaseName, previ
100
100
  }
101
101
  }
102
102
 
103
- console.log("Push Preview Result (server):", results);
103
+ // console.log("Push Preview Result (server):", results);
104
104
  return { success: true, preview: true, applied: results.applied.length, skipped: results.skipped.length, details: results };
105
105
  } catch (error) {
106
106
  throw {
@@ -28,7 +28,7 @@ export async function POST(req) {
28
28
 
29
29
  // Extract the SQL query from the request body.
30
30
  const { query } = await req.json();
31
- console.log('Received query:', query);
31
+ // console.log('Received query:', query);
32
32
 
33
33
  if (!query?.trim()) {
34
34
  return NextResponse.json(
@@ -57,11 +57,11 @@ export async function POST(req) {
57
57
 
58
58
  // Use the first configured database.
59
59
  const databaseName = config.d1_databases[0].database_name;
60
- console.log('Using database:', databaseName);
60
+ // console.log('Using database:', databaseName);
61
61
 
62
62
  // Parse the query into individual SQL statements.
63
63
  let statements = parseQuery(query);
64
- console.log('Parsed statements:', statements);
64
+ // console.log('Parsed statements:', statements);
65
65
 
66
66
  if (!statements.length) {
67
67
  return NextResponse.json(
@@ -72,7 +72,7 @@ export async function POST(req) {
72
72
 
73
73
  // Validate each parsed statement.
74
74
  statements = statements.map(validateStatement);
75
- console.log('Validated statements:', statements);
75
+ // console.log('Validated statements:', statements);
76
76
 
77
77
  // Initialize the migrations table (if it doesn't already exist).
78
78
  const createMigrationsTable = `
@@ -87,7 +87,7 @@ export async function POST(req) {
87
87
 
88
88
  // Determine whether the query involves any schema changes.
89
89
  const hasSchemaChanges = statements.some(isSchemaChange);
90
- console.log('Has schema changes:', hasSchemaChanges);
90
+ // console.log('Has schema changes:', hasSchemaChanges);
91
91
 
92
92
  let result;
93
93
  if (hasSchemaChanges) {
@@ -105,7 +105,7 @@ export async function POST(req) {
105
105
  // For data modification queries, execute the statements.
106
106
  const results = [];
107
107
  for (const stmt of statements) {
108
- console.log('Executing data modification:', stmt.sql);
108
+ // console.log('Executing data modification:', stmt.sql);
109
109
  const output = await executeSQL(projectDir, databaseName, stmt.sql);
110
110
 
111
111
  try {
@@ -113,7 +113,7 @@ export async function POST(req) {
113
113
  const queryResults = parsed[0]?.results || [];
114
114
  results.push(...queryResults);
115
115
  } catch (parseError) {
116
- console.log('Non-JSON output:', output);
116
+ // console.log('Non-JSON output:', output);
117
117
  continue;
118
118
  }
119
119
  }
package/dist/d1-studio.js CHANGED
@@ -65,6 +65,14 @@ async function validateLicenseRemote(licenseKey, email, hardwareId) {
65
65
  );
66
66
  }
67
67
 
68
+ // Check for subscription expiration if end_date is provided.
69
+ if (result.end_date && new Date(result.end_date) < new Date()) {
70
+ throw new LicenseError(
71
+ 'Your subscription has expired. Please renew your license to continue using D1 Studio.',
72
+ 'SUBSCRIPTION_EXPIRED'
73
+ );
74
+ }
75
+
68
76
  return result;
69
77
  } catch (error) {
70
78
  if (error instanceof LicenseError) {
@@ -190,7 +198,18 @@ async function startStudio() {
190
198
  let licenseData = await checkLicenseFile();
191
199
  console.log(chalk.blue('License data found:'), licenseData);
192
200
 
193
- if (!licenseData) {
201
+ const TWELVE_HOURS_MS = 43200000; // 12 hours
202
+ let shouldRevalidate = true;
203
+
204
+ if (licenseData) {
205
+ // Use lastValidatedAt if available; otherwise, fall back to activatedAt.
206
+ const lastCheck = new Date(licenseData.lastValidatedAt || licenseData.activatedAt);
207
+ if (Date.now() - lastCheck.getTime() < TWELVE_HOURS_MS) {
208
+ shouldRevalidate = false;
209
+ }
210
+ }
211
+
212
+ if (!licenseData || shouldRevalidate) {
194
213
  const { default: inquirer } = await import('inquirer');
195
214
  console.log(chalk.blue('\nPlease enter your D1 Studio license information:'));
196
215
 
@@ -223,12 +242,15 @@ async function startStudio() {
223
242
  hardwareId
224
243
  );
225
244
 
245
+ // Optionally, you can store the returned end_date for future checks.
226
246
  licenseData = {
227
247
  licenseKey: answers.licenseKey,
228
248
  email: answers.email,
229
249
  hardwareId,
230
250
  licenseType: validation.licenseType,
231
251
  activatedAt: new Date().toISOString(),
252
+ lastValidatedAt: new Date().toISOString(),
253
+ endDate: validation.end_date || null
232
254
  };
233
255
 
234
256
  await saveLicenseFile(licenseData);
@@ -237,6 +259,8 @@ async function startStudio() {
237
259
  console.error(chalk.red('\nLicense validation failed:'), error.message);
238
260
  process.exit(1);
239
261
  }
262
+ } else {
263
+ // console.log(chalk.blue('Using cached license data.'));
240
264
  }
241
265
 
242
266
  // Get wrangler configuration
@@ -17,7 +17,7 @@ export async function findWranglerConfig(userProjectPath) {
17
17
  throw new Error('Project path is required and must be a string');
18
18
  }
19
19
 
20
- console.log(chalk.blue('Looking for wrangler configuration in:'), userProjectPath);
20
+ // console.log(chalk.blue('Looking for wrangler configuration in:'), userProjectPath);
21
21
 
22
22
  // Define the possible configuration file names in priority order.
23
23
  const possibleFiles = ['wrangler.toml', 'wrangler.json', 'wrangler.jsonc'];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "d1s",
3
- "version": "0.2.2",
3
+ "version": "0.2.4",
4
4
  "type": "module",
5
5
  "description": "D1 Studio – a native studio for managing Cloudflare D1 databases.",
6
6
  "main": "./dist/d1-studio.js",
package/scripts/studio.js CHANGED
@@ -65,6 +65,14 @@ async function validateLicenseRemote(licenseKey, email, hardwareId) {
65
65
  );
66
66
  }
67
67
 
68
+ // Check for subscription expiration if end_date is provided.
69
+ if (result.end_date && new Date(result.end_date) < new Date()) {
70
+ throw new LicenseError(
71
+ 'Your subscription has expired. Please renew your license to continue using D1 Studio.',
72
+ 'SUBSCRIPTION_EXPIRED'
73
+ );
74
+ }
75
+
68
76
  return result;
69
77
  } catch (error) {
70
78
  if (error instanceof LicenseError) {
@@ -190,7 +198,18 @@ async function startStudio() {
190
198
  let licenseData = await checkLicenseFile();
191
199
  console.log(chalk.blue('License data found:'), licenseData);
192
200
 
193
- if (!licenseData) {
201
+ const TWELVE_HOURS_MS = 43200000; // 12 hours
202
+ let shouldRevalidate = true;
203
+
204
+ if (licenseData) {
205
+ // Use lastValidatedAt if available; otherwise, fall back to activatedAt.
206
+ const lastCheck = new Date(licenseData.lastValidatedAt || licenseData.activatedAt);
207
+ if (Date.now() - lastCheck.getTime() < TWELVE_HOURS_MS) {
208
+ shouldRevalidate = false;
209
+ }
210
+ }
211
+
212
+ if (!licenseData || shouldRevalidate) {
194
213
  const { default: inquirer } = await import('inquirer');
195
214
  console.log(chalk.blue('\nPlease enter your D1 Studio license information:'));
196
215
 
@@ -223,12 +242,15 @@ async function startStudio() {
223
242
  hardwareId
224
243
  );
225
244
 
245
+ // Optionally, you can store the returned end_date for future checks.
226
246
  licenseData = {
227
247
  licenseKey: answers.licenseKey,
228
248
  email: answers.email,
229
249
  hardwareId,
230
250
  licenseType: validation.licenseType,
231
251
  activatedAt: new Date().toISOString(),
252
+ lastValidatedAt: new Date().toISOString(),
253
+ endDate: validation.end_date || null
232
254
  };
233
255
 
234
256
  await saveLicenseFile(licenseData);
@@ -237,6 +259,8 @@ async function startStudio() {
237
259
  console.error(chalk.red('\nLicense validation failed:'), error.message);
238
260
  process.exit(1);
239
261
  }
262
+ } else {
263
+ // console.log(chalk.blue('Using cached license data.'));
240
264
  }
241
265
 
242
266
  // Get wrangler configuration
@@ -15,7 +15,7 @@ export async function GET() {
15
15
  );
16
16
  }
17
17
 
18
- console.log('Looking for Wrangler configuration in:', projectDir);
18
+ // console.log('Looking for Wrangler configuration in:', projectDir);
19
19
 
20
20
  // Use findWranglerConfig helper
21
21
  const wranglerResult = await findWranglerConfig(projectDir);
@@ -52,19 +52,19 @@ async function applyPullMigrations(projectDir, accountId, apiToken, databaseName
52
52
  await Promise.all(stagedFilesList.map(file => unlink(path.join(stagingDir, file))));
53
53
 
54
54
  // --- STEP 1: Fetch remote migration metadata ---
55
- console.log('Fetching remote migration metadata...');
55
+ // console.log('Fetching remote migration metadata...');
56
56
  const remoteMigrations = await getRemoteMigrations(projectDir, databaseName, env);
57
- console.log('Remote migration metadata:', remoteMigrations);
57
+ // console.log('Remote migration metadata:', remoteMigrations);
58
58
 
59
59
  // --- STEP 2: For each remote migration, fetch its file content ---
60
- console.log('Fetching migration file content from remote...');
60
+ // console.log('Fetching migration file content from remote...');
61
61
  const stagedFiles = new Map();
62
62
  for (const migration of remoteMigrations) {
63
63
  try {
64
64
  const migrationFileName = migration.name; // Use the remote migration's name.
65
65
  const content = await getMigrationFileContent(projectDir, databaseName, migrationFileName, env);
66
66
  stagedFiles.set(migrationFileName, content);
67
- console.log(`Staged migration file: ${migrationFileName}`);
67
+ // console.log(`Staged migration file: ${migrationFileName}`);
68
68
  await writeFile(path.join(stagingDir, migrationFileName), content, 'utf8');
69
69
  } catch (fileError) {
70
70
  console.error(`Error fetching content for migration ${migration.name}:`, fileError);
@@ -73,12 +73,12 @@ async function applyPullMigrations(projectDir, accountId, apiToken, databaseName
73
73
  }
74
74
 
75
75
  // --- STEP 3: Fetch local schema for destructive update ---
76
- console.log('Fetching local schema for destructive update...');
76
+ // console.log('Fetching local schema for destructive update...');
77
77
  const currentSchema = await getCurrentSchema(projectDir, databaseName, env, false);
78
78
  const tableSchema = currentSchema.filter(obj =>
79
79
  obj.type === 'table' && obj.name && obj.name.toLowerCase() !== 'if'
80
80
  );
81
- console.log('Local table schema:', tableSchema);
81
+ // console.log('Local table schema:', tableSchema);
82
82
  const dropOrder = tableSchema.length > 0
83
83
  ? analyzeDependencies(
84
84
  tableSchema.map(obj => ({
@@ -88,18 +88,18 @@ async function applyPullMigrations(projectDir, accountId, apiToken, databaseName
88
88
  }))
89
89
  )
90
90
  : [];
91
- console.log('Computed drop order:', dropOrder);
91
+ // console.log('Computed drop order:', dropOrder);
92
92
 
93
93
  // --- STEP 4: Destructive update (all-or-nothing) ---
94
- console.log('Beginning destructive update...');
94
+ // console.log('Beginning destructive update...');
95
95
  try {
96
- console.log('Disabling foreign keys...');
96
+ // console.log('Disabling foreign keys...');
97
97
  await executeSQL(projectDir, databaseName, 'PRAGMA foreign_keys=OFF;', env, false);
98
98
 
99
99
  // Drop triggers.
100
100
  const triggers = currentSchema.filter(obj => obj.type === 'trigger');
101
101
  for (const trigger of triggers) {
102
- console.log(`Dropping trigger: ${trigger.name}`);
102
+ // console.log(`Dropping trigger: ${trigger.name}`);
103
103
  await executeSQL(
104
104
  projectDir,
105
105
  databaseName,
@@ -111,7 +111,7 @@ async function applyPullMigrations(projectDir, accountId, apiToken, databaseName
111
111
  // Drop indexes.
112
112
  const indexes = currentSchema.filter(obj => obj.type === 'index');
113
113
  for (const index of indexes) {
114
- console.log(`Dropping index: ${index.name}`);
114
+ // console.log(`Dropping index: ${index.name}`);
115
115
  await executeSQL(
116
116
  projectDir,
117
117
  databaseName,
@@ -122,7 +122,7 @@ async function applyPullMigrations(projectDir, accountId, apiToken, databaseName
122
122
  }
123
123
  // Drop tables in reverse dependency order.
124
124
  for (const tableName of dropOrder.reverse()) {
125
- console.log(`Dropping table: ${tableName}`);
125
+ // console.log(`Dropping table: ${tableName}`);
126
126
  await executeSQL(
127
127
  projectDir,
128
128
  databaseName,
@@ -131,7 +131,7 @@ async function applyPullMigrations(projectDir, accountId, apiToken, databaseName
131
131
  false
132
132
  );
133
133
  }
134
- console.log('Re-enabling foreign keys...');
134
+ // console.log('Re-enabling foreign keys...');
135
135
  await executeSQL(projectDir, databaseName, 'PRAGMA foreign_keys=ON;', env, false);
136
136
  } catch (dropError) {
137
137
  throw new Error(`Error dropping existing objects: ${dropError.message}`);
@@ -139,7 +139,7 @@ async function applyPullMigrations(projectDir, accountId, apiToken, databaseName
139
139
 
140
140
  // --- STEP 5: Reset the local migrations table ---
141
141
  try {
142
- console.log('Resetting local migrations table...');
142
+ // console.log('Resetting local migrations table...');
143
143
  await initMigrationsTable(projectDir, databaseName, 'local', true);
144
144
  } catch (initError) {
145
145
  throw new Error(`Error resetting migrations table: ${initError.message}`);
@@ -152,7 +152,7 @@ async function applyPullMigrations(projectDir, accountId, apiToken, databaseName
152
152
  try {
153
153
  for (const [filename, content] of stagedFiles.entries()) {
154
154
  currentFilename = filename;
155
- console.log(`Applying migration: ${filename}`);
155
+ // console.log(`Applying migration: ${filename}`);
156
156
  // Write the migration file to the main migrations folder.
157
157
  await writeFile(path.join(migrationsDir, filename), content, 'utf8');
158
158
 
@@ -162,7 +162,7 @@ async function applyPullMigrations(projectDir, accountId, apiToken, databaseName
162
162
  .update(content)
163
163
  .digest('hex');
164
164
 
165
- console.log(`Recording migration: ${filename} with checksum ${checksum}`);
165
+ // console.log(`Recording migration: ${filename} with checksum ${checksum}`);
166
166
  await recordMigration(
167
167
  projectDir,
168
168
  databaseName,
@@ -181,20 +181,20 @@ async function applyPullMigrations(projectDir, accountId, apiToken, databaseName
181
181
  }
182
182
 
183
183
  // --- STEP 7: Replace main migrations folder with staged files ---
184
- console.log('Replacing main migrations folder with staged files...');
184
+ // console.log('Replacing main migrations folder with staged files...');
185
185
  const mainFiles = await readdir(migrationsDir).catch(() => []);
186
186
  if (mainFiles.length) {
187
187
  for (const file of mainFiles) {
188
- console.log(`Deleting local migration file: ${file}`);
188
+ // console.log(`Deleting local migration file: ${file}`);
189
189
  await unlink(path.join(migrationsDir, file));
190
190
  }
191
191
  }
192
192
  for (const [filename, content] of stagedFiles.entries()) {
193
- console.log(`Copying staged file ${filename} to main migrations folder`);
193
+ // console.log(`Copying staged file ${filename} to main migrations folder`);
194
194
  await writeFile(path.join(migrationsDir, filename), content, 'utf8');
195
195
  }
196
196
 
197
- console.log('Pull migration applied successfully.');
197
+ // console.log('Pull migration applied successfully.');
198
198
  return {
199
199
  appliedMigrations: Array.from(stagedFiles.keys()),
200
200
  details: appliedPreview
@@ -133,7 +133,7 @@ for (const migrationFile of migrationFiles) {
133
133
  results.preview.push(previewRecord);
134
134
  }
135
135
  }
136
- console.log("Push Confirm Result (server):", results);
136
+ // console.log("Push Confirm Result (server):", results);
137
137
  return { success: true, preview: false, applied: results.applied.length, skipped: results.skipped.length, details: results };
138
138
  } catch (error) {
139
139
  throw {
@@ -100,7 +100,7 @@ async function pushToRemote(projectDir, accountId, apiToken, databaseName, previ
100
100
  }
101
101
  }
102
102
 
103
- console.log("Push Preview Result (server):", results);
103
+ // console.log("Push Preview Result (server):", results);
104
104
  return { success: true, preview: true, applied: results.applied.length, skipped: results.skipped.length, details: results };
105
105
  } catch (error) {
106
106
  throw {
@@ -28,7 +28,7 @@ export async function POST(req) {
28
28
 
29
29
  // Extract the SQL query from the request body.
30
30
  const { query } = await req.json();
31
- console.log('Received query:', query);
31
+ // console.log('Received query:', query);
32
32
 
33
33
  if (!query?.trim()) {
34
34
  return NextResponse.json(
@@ -57,11 +57,11 @@ export async function POST(req) {
57
57
 
58
58
  // Use the first configured database.
59
59
  const databaseName = config.d1_databases[0].database_name;
60
- console.log('Using database:', databaseName);
60
+ // console.log('Using database:', databaseName);
61
61
 
62
62
  // Parse the query into individual SQL statements.
63
63
  let statements = parseQuery(query);
64
- console.log('Parsed statements:', statements);
64
+ // console.log('Parsed statements:', statements);
65
65
 
66
66
  if (!statements.length) {
67
67
  return NextResponse.json(
@@ -72,7 +72,7 @@ export async function POST(req) {
72
72
 
73
73
  // Validate each parsed statement.
74
74
  statements = statements.map(validateStatement);
75
- console.log('Validated statements:', statements);
75
+ // console.log('Validated statements:', statements);
76
76
 
77
77
  // Initialize the migrations table (if it doesn't already exist).
78
78
  const createMigrationsTable = `
@@ -87,7 +87,7 @@ export async function POST(req) {
87
87
 
88
88
  // Determine whether the query involves any schema changes.
89
89
  const hasSchemaChanges = statements.some(isSchemaChange);
90
- console.log('Has schema changes:', hasSchemaChanges);
90
+ // console.log('Has schema changes:', hasSchemaChanges);
91
91
 
92
92
  let result;
93
93
  if (hasSchemaChanges) {
@@ -105,7 +105,7 @@ export async function POST(req) {
105
105
  // For data modification queries, execute the statements.
106
106
  const results = [];
107
107
  for (const stmt of statements) {
108
- console.log('Executing data modification:', stmt.sql);
108
+ // console.log('Executing data modification:', stmt.sql);
109
109
  const output = await executeSQL(projectDir, databaseName, stmt.sql);
110
110
 
111
111
  try {
@@ -113,7 +113,7 @@ export async function POST(req) {
113
113
  const queryResults = parsed[0]?.results || [];
114
114
  results.push(...queryResults);
115
115
  } catch (parseError) {
116
- console.log('Non-JSON output:', output);
116
+ // console.log('Non-JSON output:', output);
117
117
  continue;
118
118
  }
119
119
  }
@@ -17,7 +17,7 @@ export async function findWranglerConfig(userProjectPath) {
17
17
  throw new Error('Project path is required and must be a string');
18
18
  }
19
19
 
20
- console.log(chalk.blue('Looking for wrangler configuration in:'), userProjectPath);
20
+ // console.log(chalk.blue('Looking for wrangler configuration in:'), userProjectPath);
21
21
 
22
22
  // Define the possible configuration file names in priority order.
23
23
  const possibleFiles = ['wrangler.toml', 'wrangler.json', 'wrangler.jsonc'];