d1s 0.2.6 → 0.2.8
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/README.md +3 -1
- package/dist/.next/.next/BUILD_ID +1 -1
- package/dist/.next/.next/app-build-manifest.json +34 -27
- package/dist/.next/.next/app-path-routes-manifest.json +1 -1
- package/dist/.next/.next/build-manifest.json +2 -2
- package/dist/.next/.next/cache/.rscinfo +1 -1
- package/dist/.next/.next/cache/.tsbuildinfo +1 -1
- package/dist/.next/.next/cache/webpack/client-development/0.pack.gz +0 -0
- package/dist/.next/.next/cache/webpack/client-development/1.pack.gz +0 -0
- package/dist/.next/.next/cache/webpack/client-development/2.pack.gz +0 -0
- package/dist/.next/.next/cache/webpack/client-development/3.pack.gz +0 -0
- package/dist/.next/.next/cache/webpack/client-development/4.pack.gz +0 -0
- package/dist/.next/.next/cache/webpack/client-development/index.pack.gz +0 -0
- package/dist/.next/.next/cache/webpack/client-development/index.pack.gz.old +0 -0
- package/dist/.next/.next/cache/webpack/client-production/0.pack +0 -0
- package/dist/.next/.next/cache/webpack/client-production/1.pack +0 -0
- package/dist/.next/.next/cache/webpack/client-production/10.pack +0 -0
- package/dist/.next/.next/cache/webpack/client-production/11.pack +0 -0
- package/dist/.next/.next/cache/webpack/client-production/12.pack +0 -0
- package/dist/.next/.next/cache/webpack/client-production/13.pack +0 -0
- package/dist/.next/.next/cache/webpack/client-production/14.pack +0 -0
- package/dist/.next/.next/cache/webpack/client-production/2.pack +0 -0
- package/dist/.next/.next/cache/webpack/client-production/3.pack +0 -0
- package/dist/.next/.next/cache/webpack/client-production/4.pack +0 -0
- package/dist/.next/.next/cache/webpack/client-production/5.pack +0 -0
- package/dist/.next/.next/cache/webpack/client-production/6.pack +0 -0
- package/dist/.next/.next/cache/webpack/client-production/7.pack +0 -0
- package/dist/.next/.next/cache/webpack/client-production/8.pack +0 -0
- package/dist/.next/.next/cache/webpack/client-production/9.pack +0 -0
- package/dist/.next/.next/cache/webpack/client-production/index.pack +0 -0
- package/dist/.next/.next/cache/webpack/client-production/index.pack.old +0 -0
- package/dist/.next/.next/cache/webpack/edge-server-production/index.pack +0 -0
- package/dist/.next/.next/cache/webpack/server-development/0.pack.gz +0 -0
- package/dist/.next/.next/cache/webpack/server-development/1.pack.gz +0 -0
- package/dist/.next/.next/cache/webpack/server-development/2.pack.gz +0 -0
- package/dist/.next/.next/cache/webpack/server-development/3.pack.gz +0 -0
- package/dist/.next/.next/cache/webpack/server-development/4.pack.gz +0 -0
- package/dist/.next/.next/cache/webpack/server-development/index.pack.gz +0 -0
- package/dist/.next/.next/cache/webpack/server-development/index.pack.gz.old +0 -0
- package/dist/.next/.next/cache/webpack/server-production/0.pack +0 -0
- package/dist/.next/.next/cache/webpack/server-production/1.pack +0 -0
- package/dist/.next/.next/cache/webpack/server-production/10.pack +0 -0
- package/dist/.next/.next/cache/webpack/server-production/11.pack +0 -0
- package/dist/.next/.next/cache/webpack/server-production/12.pack +0 -0
- package/dist/.next/.next/cache/webpack/server-production/13.pack +0 -0
- package/dist/.next/.next/cache/webpack/server-production/2.pack +0 -0
- package/dist/.next/.next/cache/webpack/server-production/3.pack +0 -0
- package/dist/.next/.next/cache/webpack/server-production/4.pack +0 -0
- package/dist/.next/.next/cache/webpack/server-production/5.pack +0 -0
- package/dist/.next/.next/cache/webpack/server-production/6.pack +0 -0
- package/dist/.next/.next/cache/webpack/server-production/7.pack +0 -0
- package/dist/.next/.next/cache/webpack/server-production/8.pack +0 -0
- package/dist/.next/.next/cache/webpack/server-production/9.pack +0 -0
- package/dist/.next/.next/cache/webpack/server-production/index.pack +0 -0
- package/dist/.next/.next/cache/webpack/server-production/index.pack.old +0 -0
- package/dist/.next/.next/next-minimal-server.js.nft.json +1 -1
- package/dist/.next/.next/next-server.js.nft.json +1 -1
- package/dist/.next/.next/prerender-manifest.json +1 -1
- package/dist/.next/.next/server/app/_not-found/page.js +1 -1
- package/dist/.next/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/dist/.next/.next/server/app/_not-found.html +1 -1
- package/dist/.next/.next/server/app/_not-found.rsc +2 -2
- package/dist/.next/.next/server/app/api/cloudflare/route.js +1 -1
- package/dist/.next/.next/server/app/api/cloudflare/route.js.nft.json +1 -1
- package/dist/.next/.next/server/app/api/cloudflare/route_client-reference-manifest.js +1 -1
- package/dist/.next/.next/server/app/api/databases/route.js +1 -1
- package/dist/.next/.next/server/app/api/databases/route.js.nft.json +1 -1
- package/dist/.next/.next/server/app/api/databases/route_client-reference-manifest.js +1 -1
- package/dist/.next/.next/server/app/api/migrations/sync/route.js +3 -3
- package/dist/.next/.next/server/app/api/migrations/sync/route.js.nft.json +1 -1
- package/dist/.next/.next/server/app/api/migrations/sync/route_client-reference-manifest.js +1 -1
- package/dist/.next/.next/server/app/api/migrations/sync-files/route.js +1 -1
- package/dist/.next/.next/server/app/api/migrations/sync-files/route.js.nft.json +1 -1
- package/dist/.next/.next/server/app/api/migrations/sync-files/route_client-reference-manifest.js +1 -1
- package/dist/.next/.next/server/app/api/pull-remote/confirm/route.js +1 -1
- package/dist/.next/.next/server/app/api/pull-remote/confirm/route.js.nft.json +1 -1
- package/dist/.next/.next/server/app/api/pull-remote/confirm/route_client-reference-manifest.js +1 -1
- package/dist/.next/.next/server/app/api/pull-remote/preview/route.js +1 -1
- package/dist/.next/.next/server/app/api/pull-remote/preview/route.js.nft.json +1 -1
- package/dist/.next/.next/server/app/api/pull-remote/preview/route_client-reference-manifest.js +1 -1
- package/dist/.next/.next/server/app/api/push-remote/confirm/route.js +2 -2
- package/dist/.next/.next/server/app/api/push-remote/confirm/route.js.nft.json +1 -1
- package/dist/.next/.next/server/app/api/push-remote/confirm/route_client-reference-manifest.js +1 -1
- package/dist/.next/.next/server/app/api/push-remote/preview/route.js +2 -2
- package/dist/.next/.next/server/app/api/push-remote/preview/route.js.nft.json +1 -1
- package/dist/.next/.next/server/app/api/push-remote/preview/route_client-reference-manifest.js +1 -1
- package/dist/.next/.next/server/app/api/query/route.js +2 -2
- package/dist/.next/.next/server/app/api/query/route.js.nft.json +1 -1
- package/dist/.next/.next/server/app/api/query/route_client-reference-manifest.js +1 -1
- package/dist/.next/.next/server/app/api/tables/[name]/route.js +4 -4
- package/dist/.next/.next/server/app/api/tables/[name]/route.js.nft.json +1 -1
- package/dist/.next/.next/server/app/api/tables/[name]/route_client-reference-manifest.js +1 -1
- package/dist/.next/.next/server/app/api/tables/route.js +2 -2
- package/dist/.next/.next/server/app/api/tables/route.js.nft.json +1 -1
- package/dist/.next/.next/server/app/api/tables/route_client-reference-manifest.js +1 -1
- package/dist/.next/.next/server/app/api/update/route.js +5 -0
- package/dist/.next/.next/server/app/api/update/route.js.nft.json +1 -0
- package/dist/.next/.next/server/app/api/update/route_client-reference-manifest.js +1 -0
- package/dist/.next/.next/server/app/index.html +3 -3
- package/dist/.next/.next/server/app/index.rsc +3 -3
- package/dist/.next/.next/server/app/page.js +14 -12
- package/dist/.next/.next/server/app/page_client-reference-manifest.js +1 -1
- package/dist/.next/.next/server/app-paths-manifest.json +4 -3
- package/dist/.next/.next/server/chunks/336.js +1 -1
- package/dist/.next/.next/server/chunks/391.js +23 -0
- package/dist/.next/.next/server/chunks/452.js +1 -0
- package/dist/.next/.next/server/chunks/627.js +3 -3
- package/dist/.next/.next/server/chunks/638.js +3 -3
- package/dist/.next/.next/server/chunks/801.js +55 -0
- package/dist/.next/.next/server/chunks/992.js +3 -3
- package/dist/.next/.next/server/pages/404.html +1 -1
- package/dist/.next/.next/server/pages/500.html +1 -1
- package/dist/.next/.next/server/pages/_app.js +1 -1
- package/dist/.next/.next/server/pages/_document.js +1 -1
- package/dist/.next/.next/server/pages/_error.js +1 -1
- package/dist/.next/.next/server/pages-manifest.json +1 -1
- package/dist/.next/.next/server/server-reference-manifest.json +1 -1
- package/dist/.next/.next/static/JrwgdSDcipr0Zh7k19Cj_/_buildManifest.js +1 -0
- package/dist/.next/.next/static/chunks/958-98887928efebfdf7.js +1 -0
- package/dist/.next/.next/static/chunks/app/api/cloudflare/route-5133155a604f2719.js +1 -0
- package/dist/.next/.next/static/chunks/app/api/databases/route-63a31080b565794e.js +1 -0
- package/dist/.next/.next/static/chunks/app/api/migrations/sync/route-d97667565b4a59b6.js +1 -0
- package/dist/.next/.next/static/chunks/app/api/migrations/sync-files/route-7089bcbfeb6b5260.js +1 -0
- package/dist/.next/.next/static/chunks/app/api/pull-remote/confirm/route-9143e6e4c3f05162.js +1 -0
- package/dist/.next/.next/static/chunks/app/api/pull-remote/preview/route-c963d143a51aed66.js +1 -0
- package/dist/.next/.next/static/chunks/app/api/push-remote/confirm/route-072132c0a6cb3df3.js +1 -0
- package/dist/.next/.next/static/chunks/app/api/push-remote/preview/route-ca6bf35aa72661ee.js +1 -0
- package/dist/.next/.next/static/chunks/app/api/query/route-1466f6b7ffd8b6c0.js +1 -0
- package/dist/.next/.next/static/chunks/app/api/tables/[name]/route-898d3f85fc8544c4.js +1 -0
- package/dist/.next/.next/static/chunks/app/api/tables/route-91650359fc3735cb.js +1 -0
- package/dist/.next/.next/static/chunks/app/api/update/route-504d663df9124f97.js +1 -0
- package/dist/.next/.next/static/chunks/app/page-2c28a255a4ecd8d4.js +1 -0
- package/dist/.next/.next/static/chunks/app/page-3db7feef57019055.js +1 -0
- package/dist/.next/.next/static/css/4957328384ed5c42.css +3 -0
- package/dist/.next/.next/static/gc8l1G6KXOeLLOM7VJip6/_buildManifest.js +1 -0
- package/dist/.next/.next/static/kYsJoni86CJWDuTkc1xU6/_buildManifest.js +1 -0
- package/dist/.next/.next/static/kYsJoni86CJWDuTkc1xU6/_ssgManifest.js +1 -0
- package/dist/.next/.next/static/scC5qwQC9H7rR1groM0Q-/_ssgManifest.js +1 -0
- package/dist/.next/.next/static/tEHOI_-t-iqfJClNzuo9m/_buildManifest.js +1 -0
- package/dist/.next/.next/static/tEHOI_-t-iqfJClNzuo9m/_ssgManifest.js +1 -0
- package/dist/.next/.next/static/vin2VQs5pM_dH2e2_I7AN/_buildManifest.js +1 -0
- package/dist/.next/.next/static/vin2VQs5pM_dH2e2_I7AN/_ssgManifest.js +1 -0
- package/dist/.next/.next/static/wHKwQhaxin5_i06GFVDHb/_buildManifest.js +1 -0
- package/dist/.next/.next/static/wHKwQhaxin5_i06GFVDHb/_ssgManifest.js +1 -0
- package/dist/.next/.next/static/xW4MspD8XibrhXDi_q2IO/_ssgManifest.js +1 -0
- package/dist/.next/.next/trace +3 -3
- package/dist/.next/.next/types/app/api/update/route.ts +347 -0
- package/dist/.next/BUILD_ID +1 -1
- package/dist/.next/app-build-manifest.json +17 -17
- package/dist/.next/app-path-routes-manifest.json +1 -1
- package/dist/.next/build-manifest.json +2 -2
- package/dist/.next/cache/.rscinfo +1 -1
- package/dist/.next/cache/.tsbuildinfo +1 -1
- package/dist/.next/cache/webpack/client-production/0.pack +0 -0
- package/dist/.next/cache/webpack/client-production/index.pack +0 -0
- package/dist/.next/cache/webpack/edge-server-production/index.pack +0 -0
- package/dist/.next/cache/webpack/server-production/0.pack +0 -0
- package/dist/.next/cache/webpack/server-production/index.pack +0 -0
- package/dist/.next/next-minimal-server.js.nft.json +1 -1
- package/dist/.next/next-server.js.nft.json +1 -1
- package/dist/.next/prerender-manifest.json +1 -1
- package/dist/.next/server/app/_not-found.html +1 -1
- package/dist/.next/server/app/_not-found.rsc +1 -1
- package/dist/.next/server/app/api/cloudflare/route.js +1 -1
- package/dist/.next/server/app/api/databases/route.js +1 -1
- package/dist/.next/server/app/api/migrations/sync/route.js +3 -3
- package/dist/.next/server/app/api/migrations/sync/route.js.nft.json +1 -1
- package/dist/.next/server/app/api/migrations/sync-files/route.js +1 -1
- package/dist/.next/server/app/api/migrations/sync-files/route.js.nft.json +1 -1
- package/dist/.next/server/app/api/pull-remote/confirm/route.js +1 -1
- package/dist/.next/server/app/api/pull-remote/confirm/route.js.nft.json +1 -1
- package/dist/.next/server/app/api/pull-remote/preview/route.js +1 -1
- package/dist/.next/server/app/api/pull-remote/preview/route.js.nft.json +1 -1
- package/dist/.next/server/app/api/push-remote/confirm/route.js +2 -2
- package/dist/.next/server/app/api/push-remote/confirm/route.js.nft.json +1 -1
- package/dist/.next/server/app/api/push-remote/preview/route.js +2 -2
- package/dist/.next/server/app/api/push-remote/preview/route.js.nft.json +1 -1
- package/dist/.next/server/app/api/query/route.js +2 -2
- package/dist/.next/server/app/api/query/route.js.nft.json +1 -1
- package/dist/.next/server/app/api/tables/[name]/route.js +4 -4
- package/dist/.next/server/app/api/tables/route.js +2 -2
- package/dist/.next/server/app/index.html +1 -1
- package/dist/.next/server/app/index.rsc +1 -1
- package/dist/.next/server/app-paths-manifest.json +6 -6
- package/dist/.next/server/chunks/801.js +55 -0
- package/dist/.next/server/pages/404.html +1 -1
- package/dist/.next/server/pages/500.html +1 -1
- package/dist/.next/server/server-reference-manifest.json +1 -1
- package/dist/.next/static/ZwNOdZJ0LOtE0AJMNWwzY/_buildManifest.js +1 -0
- package/dist/.next/static/ZwNOdZJ0LOtE0AJMNWwzY/_ssgManifest.js +1 -0
- package/dist/.next/trace +14 -14
- package/dist/app/api/cloudflare/route.js +5 -1
- package/dist/app/api/databases/route.js +3 -4
- package/dist/app/api/migrations/sync/route.js +5 -3
- package/dist/app/api/pull-remote/confirm/route.js +24 -23
- package/dist/app/api/pull-remote/preview/route.js +4 -3
- package/dist/app/api/push-remote/preview/route.js +3 -2
- package/dist/app/api/query/route.js +11 -3
- package/dist/app/api/tables/[name]/route.js +3 -2
- package/dist/app/api/tables/route.js +6 -2
- package/dist/app/app/api/cloudflare/route.js +5 -1
- package/dist/app/app/api/databases/route.js +3 -4
- package/dist/app/app/api/migrations/sync/route.js +5 -3
- package/dist/app/app/api/pull-remote/confirm/route.js +24 -23
- package/dist/app/app/api/pull-remote/preview/route.js +4 -3
- package/dist/app/app/api/push-remote/preview/route.js +3 -2
- package/dist/app/app/api/query/route.js +11 -3
- package/dist/app/app/api/tables/[name]/route.js +3 -2
- package/dist/app/app/api/tables/route.js +6 -2
- package/dist/app/app/api/update/route.js +11 -0
- package/dist/app/app/page.jsx +7 -1
- package/dist/d1-studio.js +94 -58
- package/dist/lib/database-queue.js +34 -30
- package/dist/lib/find-wrangler-config.js +14 -8
- package/dist/lib/logger.js +11 -2
- package/dist/lib/migrations.js +4 -4
- package/dist/lib/schema-operations.js +4 -1
- package/dist/lib/sql-operations.js +8 -1
- package/package.json +3 -1
- package/scripts/studio.js +94 -58
- package/scripts/test.js +280 -82
- package/src/app/api/cloudflare/route.js +5 -1
- package/src/app/api/databases/route.js +3 -4
- package/src/app/api/migrations/sync/route.js +5 -3
- package/src/app/api/pull-remote/confirm/route.js +24 -23
- package/src/app/api/pull-remote/preview/route.js +4 -3
- package/src/app/api/push-remote/preview/route.js +3 -2
- package/src/app/api/query/route.js +11 -3
- package/src/app/api/tables/[name]/route.js +3 -2
- package/src/app/api/tables/route.js +6 -2
- package/src/app/api/update/route.js +11 -0
- package/src/app/page.jsx +7 -1
- package/src/components/update-banner.jsx +64 -0
- package/src/lib/database-queue.js +34 -30
- package/src/lib/find-wrangler-config.js +14 -8
- package/src/lib/logger.js +11 -2
- package/src/lib/migrations.js +4 -4
- package/src/lib/schema-operations.js +4 -1
- package/src/lib/sql-operations.js +8 -1
- package/dist/.next/.next/server/chunks/603.js +0 -55
- package/dist/.next/server/chunks/603.js +0 -55
- /package/dist/.next/.next/static/{HsZ8OanS5v86DqC9rErO- → IWRJZhjf8U8mjzz4h0VNE}/_buildManifest.js +0 -0
- /package/dist/.next/.next/static/{HsZ8OanS5v86DqC9rErO- → IWRJZhjf8U8mjzz4h0VNE}/_ssgManifest.js +0 -0
- /package/dist/.next/.next/static/{q6WmQmyONe88bMN0_jrC2 → JrwgdSDcipr0Zh7k19Cj_}/_ssgManifest.js +0 -0
- /package/dist/.next/{static/Tk1fnz_CXLavm23ZEeChG → .next/static/gc8l1G6KXOeLLOM7VJip6}/_ssgManifest.js +0 -0
- /package/dist/.next/.next/static/{q6WmQmyONe88bMN0_jrC2 → scC5qwQC9H7rR1groM0Q-}/_buildManifest.js +0 -0
- /package/dist/.next/{static/Tk1fnz_CXLavm23ZEeChG → .next/static/xW4MspD8XibrhXDi_q2IO}/_buildManifest.js +0 -0
package/scripts/test.js
CHANGED
|
@@ -5,52 +5,88 @@ import { dirname, join } from 'path';
|
|
|
5
5
|
import chalk from 'chalk';
|
|
6
6
|
import fs from 'fs/promises';
|
|
7
7
|
import os from 'os';
|
|
8
|
+
import { exec, execSync } from 'child_process';
|
|
9
|
+
import { promisify } from 'util';
|
|
10
|
+
import winston from 'winston';
|
|
11
|
+
import logger from '../src/lib/logger.js';
|
|
8
12
|
|
|
13
|
+
const execAsync = promisify(exec);
|
|
9
14
|
const __filename = fileURLToPath(import.meta.url);
|
|
10
15
|
const __dirname = dirname(__filename);
|
|
11
16
|
|
|
12
|
-
|
|
13
|
-
|
|
17
|
+
// Mock license data for testing
|
|
18
|
+
const mockLicenseData = {
|
|
19
|
+
licenseKey: 'test-license-key',
|
|
20
|
+
email: 'test@example.com',
|
|
21
|
+
hardwareId: 'mock-hardware-id',
|
|
22
|
+
end_date: new Date(Date.now() + 30 * 24 * 60 * 60 * 1000).toISOString(), // 30 days from now
|
|
23
|
+
subscription_status: 'active',
|
|
24
|
+
type: 'test',
|
|
25
|
+
activatedAt: new Date().toISOString()
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
// Test configuration file contents
|
|
29
|
+
const mockNextConfig = `
|
|
30
|
+
/** @type {import('next').NextConfig} */
|
|
31
|
+
const nextConfig = {
|
|
32
|
+
output: 'standalone',
|
|
33
|
+
}
|
|
34
|
+
module.exports = nextConfig
|
|
35
|
+
`;
|
|
14
36
|
|
|
15
|
-
|
|
16
|
-
|
|
37
|
+
const mockTailwindConfig = `
|
|
38
|
+
/** @type {import('tailwindcss').Config} */
|
|
39
|
+
module.exports = {
|
|
40
|
+
content: [
|
|
41
|
+
'./src/**/*.{js,ts,jsx,tsx,mdx}',
|
|
42
|
+
],
|
|
43
|
+
theme: {
|
|
44
|
+
extend: {},
|
|
45
|
+
},
|
|
46
|
+
plugins: [],
|
|
47
|
+
}
|
|
48
|
+
`;
|
|
49
|
+
|
|
50
|
+
// Test Wrangler config file contents
|
|
51
|
+
const mockWranglerConfig = `
|
|
17
52
|
[[d1_databases]]
|
|
18
53
|
binding = "DB"
|
|
19
54
|
database_name = "test_db"
|
|
20
55
|
database_id = "test-id"
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
const tempDir = await fs.mkdtemp(join(os.tmpdir(), 'd1-studio-test-'));
|
|
24
|
-
await fs.writeFile(join(tempDir, 'wrangler.toml'), validConfig);
|
|
56
|
+
`;
|
|
25
57
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
} catch (error) {
|
|
34
|
-
console.warn(chalk.yellow('⚠ Valid wrangler.toml test issues:'), error.message);
|
|
35
|
-
}
|
|
58
|
+
// Create mock configuration files in a given directory.
|
|
59
|
+
async function createMockConfigs(testDir) {
|
|
60
|
+
await fs.writeFile(join(testDir, 'next.config.js'), mockNextConfig);
|
|
61
|
+
await fs.writeFile(join(testDir, 'tailwind.config.js'), mockTailwindConfig);
|
|
62
|
+
await fs.writeFile(join(testDir, 'wrangler.toml'), mockWranglerConfig);
|
|
63
|
+
}
|
|
36
64
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
65
|
+
async function createMockPackageAndDist(testDir) {
|
|
66
|
+
const packageJsonPath = join(testDir, 'package.json');
|
|
67
|
+
const packageJsonContent = JSON.stringify({
|
|
68
|
+
name: "d1-studio",
|
|
69
|
+
version: "1.0.0",
|
|
70
|
+
main: "dist/d1-studio.js"
|
|
71
|
+
}, null, 2);
|
|
72
|
+
await fs.writeFile(packageJsonPath, packageJsonContent);
|
|
45
73
|
|
|
46
|
-
|
|
47
|
-
await fs.
|
|
74
|
+
const distDir = join(testDir, 'dist');
|
|
75
|
+
await fs.mkdir(distDir, { recursive: true });
|
|
76
|
+
const d1StudioPath = join(distDir, 'd1-studio.js');
|
|
77
|
+
const d1StudioContent = `#!/usr/bin/env node
|
|
78
|
+
if (process.argv.includes('--version')) {
|
|
79
|
+
console.log('1.0.0');
|
|
80
|
+
} else {
|
|
81
|
+
console.log('D1 Studio CLI');
|
|
82
|
+
}
|
|
83
|
+
`;
|
|
84
|
+
await fs.writeFile(d1StudioPath, d1StudioContent);
|
|
85
|
+
await fs.chmod(d1StudioPath, 0o755);
|
|
48
86
|
}
|
|
49
87
|
|
|
50
88
|
async function testProjectStructure() {
|
|
51
89
|
console.log('\nTesting project structure...');
|
|
52
|
-
|
|
53
|
-
// Check required directories exist
|
|
54
90
|
const requiredDirs = ['src', 'scripts', 'dist'];
|
|
55
91
|
for (const dir of requiredDirs) {
|
|
56
92
|
try {
|
|
@@ -60,109 +96,271 @@ async function testProjectStructure() {
|
|
|
60
96
|
console.warn(chalk.yellow(`⚠ ${dir} directory missing`));
|
|
61
97
|
}
|
|
62
98
|
}
|
|
63
|
-
|
|
64
|
-
|
|
99
|
+
const testDir = await fs.mkdtemp(join(os.tmpdir(), 'd1-studio-test-'));
|
|
100
|
+
await createMockConfigs(testDir);
|
|
101
|
+
await createMockPackageAndDist(testDir);
|
|
65
102
|
const requiredFiles = [
|
|
66
103
|
'package.json',
|
|
67
104
|
'next.config.js',
|
|
68
105
|
'tailwind.config.js',
|
|
69
106
|
'scripts/studio.js'
|
|
70
107
|
];
|
|
71
|
-
|
|
72
108
|
for (const file of requiredFiles) {
|
|
73
109
|
try {
|
|
74
|
-
await fs.access(join(
|
|
110
|
+
await fs.access(join(testDir, file));
|
|
75
111
|
console.log(chalk.green(`✓ ${file} exists`));
|
|
76
112
|
} catch {
|
|
77
|
-
console.warn(chalk.yellow(`⚠ ${file} missing`));
|
|
113
|
+
console.warn(chalk.yellow(`⚠ ${file} missing or not copied`));
|
|
78
114
|
}
|
|
79
115
|
}
|
|
116
|
+
return testDir;
|
|
80
117
|
}
|
|
81
118
|
|
|
82
|
-
async function
|
|
83
|
-
console.log('\nTesting
|
|
119
|
+
async function testWranglerConfig(testDir) {
|
|
120
|
+
console.log('\nTesting Wrangler configuration...');
|
|
121
|
+
try {
|
|
122
|
+
const config = await findWranglerConfig(testDir);
|
|
123
|
+
if (!config || !config.config.d1_databases) {
|
|
124
|
+
console.warn(chalk.yellow('⚠ Valid wrangler.toml test: Config parsing incomplete'));
|
|
125
|
+
} else {
|
|
126
|
+
console.log(chalk.green('✓ Valid wrangler.toml test passed'));
|
|
127
|
+
}
|
|
128
|
+
} catch (error) {
|
|
129
|
+
console.warn(chalk.yellow('⚠ Valid wrangler.toml test issues:'), error.message);
|
|
130
|
+
}
|
|
131
|
+
try {
|
|
132
|
+
await fs.writeFile(join(testDir, 'wrangler.toml'), 'invalid: config: {');
|
|
133
|
+
await findWranglerConfig(testDir);
|
|
134
|
+
console.warn(chalk.yellow('⚠ Invalid wrangler.toml test: Did not catch invalid config'));
|
|
135
|
+
} catch (error) {
|
|
136
|
+
console.log(chalk.green('✓ Invalid wrangler.toml handling test passed'));
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
async function testCaching(testDir) {
|
|
141
|
+
console.log('\nTesting caching of findWranglerConfig...');
|
|
142
|
+
const config1 = await findWranglerConfig(testDir);
|
|
143
|
+
console.log(chalk.green('✓ First call completed.'));
|
|
144
|
+
const config2 = await findWranglerConfig(testDir);
|
|
145
|
+
console.log(chalk.green('✓ Second call completed.'));
|
|
146
|
+
if (JSON.stringify(config1) === JSON.stringify(config2)) {
|
|
147
|
+
console.log(chalk.green('✓ Caching works: configurations are identical'));
|
|
148
|
+
} else {
|
|
149
|
+
console.warn(chalk.yellow('⚠ Caching issue: configurations differ'));
|
|
150
|
+
}
|
|
151
|
+
const newTestDir = await fs.mkdtemp(join(os.tmpdir(), 'new-d1-studio-test-'));
|
|
152
|
+
await fs.writeFile(join(newTestDir, 'wrangler.toml'), mockWranglerConfig);
|
|
153
|
+
const configNew = await findWranglerConfig(newTestDir);
|
|
154
|
+
console.log(chalk.green('✓ New project configuration loaded.'));
|
|
155
|
+
await fs.rm(newTestDir, { recursive: true, force: true });
|
|
156
|
+
}
|
|
84
157
|
|
|
158
|
+
async function testLoggerBehavior() {
|
|
159
|
+
console.log('\nTesting logger behavior in production mode...');
|
|
160
|
+
const { combine, timestamp, colorize, printf } = winston.format;
|
|
161
|
+
const logFormat = printf(({ level, message, timestamp }) => {
|
|
162
|
+
return `${timestamp} ${level}: ${message}`;
|
|
163
|
+
});
|
|
164
|
+
const originalNodeEnv = process.env.NODE_ENV;
|
|
165
|
+
const originalDebug = process.env.DEBUG;
|
|
166
|
+
process.env.NODE_ENV = 'production';
|
|
167
|
+
process.env.DEBUG = 'false';
|
|
168
|
+
class MemoryTransport extends winston.Transport {
|
|
169
|
+
constructor(opts) {
|
|
170
|
+
super(opts);
|
|
171
|
+
this.logs = [];
|
|
172
|
+
}
|
|
173
|
+
log(info, callback) {
|
|
174
|
+
this.logs.push(info);
|
|
175
|
+
callback();
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
const memTransport = new MemoryTransport({ level: 'warn' });
|
|
179
|
+
logger.configure({
|
|
180
|
+
level: 'warn',
|
|
181
|
+
format: combine(
|
|
182
|
+
timestamp({ format: 'YYYY-MM-DD HH:mm:ss' }),
|
|
183
|
+
colorize(),
|
|
184
|
+
logFormat
|
|
185
|
+
),
|
|
186
|
+
transports: [
|
|
187
|
+
new winston.transports.Console({ level: 'warn', silent: true }),
|
|
188
|
+
memTransport
|
|
189
|
+
]
|
|
190
|
+
});
|
|
191
|
+
logger.debug('Test debug message');
|
|
192
|
+
logger.info('Test info message');
|
|
193
|
+
logger.warn('Test warn message');
|
|
194
|
+
logger.error('Test error message');
|
|
195
|
+
await new Promise(resolve => setTimeout(resolve, 100));
|
|
196
|
+
const messages = memTransport.logs.map(log => log.message);
|
|
197
|
+
if (messages.includes('Test debug message') || messages.includes('Test info message')) {
|
|
198
|
+
console.warn(chalk.yellow('⚠ Logger behavior failed in production mode: debug or info messages were logged.'));
|
|
199
|
+
} else {
|
|
200
|
+
console.log(chalk.green('✓ Logger behavior in production mode passed: only warn/error messages logged.'));
|
|
201
|
+
}
|
|
202
|
+
logger.clear();
|
|
203
|
+
process.env.NODE_ENV = originalNodeEnv;
|
|
204
|
+
process.env.DEBUG = originalDebug;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
async function testPackageExecution(testDir) {
|
|
208
|
+
console.log('\nTesting package execution...');
|
|
85
209
|
try {
|
|
86
|
-
const
|
|
87
|
-
|
|
210
|
+
const destDir = join(testDir, 'node_modules', 'd1studio');
|
|
211
|
+
await fs.mkdir(destDir, { recursive: true });
|
|
212
|
+
await fs.cp(join(testDir, 'dist'), destDir, { recursive: true });
|
|
213
|
+
const d1StudioPath = join(destDir, 'dist', 'd1-studio.js');
|
|
214
|
+
try {
|
|
215
|
+
await fs.access(d1StudioPath);
|
|
216
|
+
console.log(chalk.green(`✓ Found d1-studio.js at ${d1StudioPath}`));
|
|
217
|
+
} catch (err) {
|
|
218
|
+
throw new Error(`d1-studio.js not found at ${d1StudioPath}`);
|
|
219
|
+
}
|
|
220
|
+
process.env.NODE_ENV = 'development';
|
|
221
|
+
await execAsync('node ./dist/d1-studio.js --version', { cwd: testDir });
|
|
222
|
+
console.log(chalk.green('✓ Development mode execution test passed'));
|
|
223
|
+
process.env.NODE_ENV = 'production';
|
|
224
|
+
await execAsync('node ./node_modules/d1studio/dist/d1-studio.js --version', { cwd: testDir });
|
|
225
|
+
console.log(chalk.green('✓ Production mode execution test passed'));
|
|
226
|
+
} catch (error) {
|
|
227
|
+
console.error(chalk.red('Package execution test failed:', error));
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
async function setupTestPackage(testDir) {
|
|
232
|
+
console.log('\nSetting up test package structure...');
|
|
233
|
+
try {
|
|
234
|
+
const packageDir = join(testDir, 'node_modules', 'd1studio');
|
|
235
|
+
await fs.mkdir(packageDir, { recursive: true });
|
|
236
|
+
await fs.cp(join(__dirname, '..', 'dist'), packageDir, { recursive: true, force: true });
|
|
237
|
+
const packageJson = JSON.parse(
|
|
238
|
+
await fs.readFile(join(__dirname, '..', 'package.json'), 'utf8')
|
|
239
|
+
);
|
|
240
|
+
await fs.writeFile(join(packageDir, 'package.json'), JSON.stringify(packageJson, null, 2));
|
|
241
|
+
await fs.chmod(join(packageDir, 'd1-studio.js'), 0o755);
|
|
242
|
+
console.log(chalk.green('✓ Package structure created successfully'));
|
|
243
|
+
return packageDir;
|
|
244
|
+
} catch (error) {
|
|
245
|
+
console.error(chalk.red('Failed to setup test package:', error));
|
|
246
|
+
throw error;
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
async function copyStudioScript(testDir) {
|
|
251
|
+
try {
|
|
252
|
+
await fs.mkdir(join(testDir, 'scripts'), { recursive: true });
|
|
253
|
+
await fs.copyFile(join(__dirname, 'studio.js'), join(testDir, 'scripts', 'studio.js'));
|
|
254
|
+
await fs.chmod(join(testDir, 'scripts', 'studio.js'), 0o755);
|
|
255
|
+
console.log(chalk.green('✓ studio.js copied and made executable'));
|
|
256
|
+
} catch (error) {
|
|
257
|
+
console.error(chalk.red('Failed to copy studio.js:', error));
|
|
258
|
+
throw error;
|
|
259
|
+
}
|
|
260
|
+
}
|
|
88
261
|
|
|
89
|
-
|
|
262
|
+
async function testStudioScript(testDir) {
|
|
263
|
+
console.log('\nTesting studio.js script...');
|
|
264
|
+
try {
|
|
265
|
+
await copyStudioScript(testDir);
|
|
266
|
+
const studioPath = join(testDir, 'scripts', 'studio.js');
|
|
267
|
+
const stats = await fs.stat(studioPath);
|
|
90
268
|
const isExecutable = (stats.mode & 0o111) !== 0;
|
|
91
269
|
if (!isExecutable) {
|
|
92
270
|
console.warn(chalk.yellow('⚠ studio.js is not executable'));
|
|
271
|
+
await fs.chmod(studioPath, 0o755);
|
|
272
|
+
console.log(chalk.green('✓ Made studio.js executable'));
|
|
93
273
|
} else {
|
|
94
274
|
console.log(chalk.green('✓ studio.js has correct permissions'));
|
|
95
275
|
}
|
|
96
|
-
|
|
97
|
-
// Check file content
|
|
98
276
|
const content = await fs.readFile(studioPath, 'utf8');
|
|
99
277
|
const requiredImports = ['chalk', 'open', 'findWranglerConfig'];
|
|
100
|
-
|
|
101
278
|
let missingImports = [];
|
|
102
279
|
for (const imp of requiredImports) {
|
|
103
280
|
if (!content.includes(imp)) {
|
|
104
281
|
missingImports.push(imp);
|
|
105
282
|
}
|
|
106
283
|
}
|
|
107
|
-
|
|
108
284
|
if (missingImports.length > 0) {
|
|
109
285
|
console.warn(chalk.yellow(`⚠ studio.js missing imports: ${missingImports.join(', ')}`));
|
|
110
286
|
} else {
|
|
111
287
|
console.log(chalk.green('✓ studio.js contains required imports'));
|
|
112
288
|
}
|
|
113
|
-
|
|
289
|
+
try {
|
|
290
|
+
await execAsync('node ./scripts/studio.js --version', {
|
|
291
|
+
cwd: testDir,
|
|
292
|
+
env: { ...process.env, NODE_PATH: join(testDir, 'node_modules') }
|
|
293
|
+
});
|
|
294
|
+
console.log(chalk.green('✓ studio.js execution test passed'));
|
|
295
|
+
} catch (execError) {
|
|
296
|
+
console.warn(chalk.yellow('⚠ studio.js execution test failed:', execError.message));
|
|
297
|
+
}
|
|
114
298
|
} catch (error) {
|
|
115
299
|
console.warn(chalk.yellow('⚠ studio.js test issues:'), error.message);
|
|
116
300
|
}
|
|
117
301
|
}
|
|
118
302
|
|
|
119
|
-
async function
|
|
120
|
-
console.log('\nTesting
|
|
121
|
-
|
|
122
|
-
const
|
|
123
|
-
const d1StudioDir = join(homeDir, '.d1studio');
|
|
124
|
-
|
|
303
|
+
async function testLicenseValidation(testDir) {
|
|
304
|
+
console.log('\nTesting license validation...');
|
|
305
|
+
const d1StudioDir = join(testDir, '.d1studio');
|
|
306
|
+
const licenseFile = join(d1StudioDir, 'license.json');
|
|
125
307
|
try {
|
|
126
|
-
await fs.
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
const
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
const requiredFields = ['licenseKey', 'email', 'hardwareId'];
|
|
137
|
-
|
|
138
|
-
const missingFields = requiredFields.filter(field => !license[field]);
|
|
139
|
-
if (missingFields.length > 0) {
|
|
140
|
-
console.warn(chalk.yellow(`⚠ License file missing fields: ${missingFields.join(', ')}`));
|
|
141
|
-
}
|
|
142
|
-
} catch {
|
|
143
|
-
console.warn(chalk.yellow('⚠ License file not found or invalid'));
|
|
308
|
+
await fs.mkdir(d1StudioDir, { recursive: true });
|
|
309
|
+
await fs.writeFile(licenseFile, JSON.stringify(mockLicenseData, null, 2));
|
|
310
|
+
console.log(chalk.green('✓ Successfully created test license file'));
|
|
311
|
+
const license = JSON.parse(await fs.readFile(licenseFile, 'utf8'));
|
|
312
|
+
const requiredFields = ['licenseKey', 'email', 'hardwareId', 'subscription_status', 'end_date'];
|
|
313
|
+
const missingFields = requiredFields.filter(field => !license[field]);
|
|
314
|
+
if (missingFields.length > 0) {
|
|
315
|
+
console.warn(chalk.yellow(`⚠ License file missing fields: ${missingFields.join(', ')}`));
|
|
316
|
+
} else {
|
|
317
|
+
console.log(chalk.green('✓ License file structure validated'));
|
|
144
318
|
}
|
|
145
|
-
|
|
146
|
-
|
|
319
|
+
const expiredLicense = {
|
|
320
|
+
...mockLicenseData,
|
|
321
|
+
end_date: new Date(Date.now() - 24 * 60 * 60 * 1000).toISOString() // 1 day ago
|
|
322
|
+
};
|
|
323
|
+
await fs.writeFile(licenseFile, JSON.stringify(expiredLicense, null, 2));
|
|
324
|
+
console.log(chalk.green('✓ Successfully tested expired license scenario'));
|
|
325
|
+
const expiringSoonLicense = {
|
|
326
|
+
...mockLicenseData,
|
|
327
|
+
end_date: new Date(Date.now() + 5 * 24 * 60 * 60 * 1000).toISOString() // 5 days from now
|
|
328
|
+
};
|
|
329
|
+
await fs.writeFile(licenseFile, JSON.stringify(expiringSoonLicense, null, 2));
|
|
330
|
+
console.log(chalk.green('✓ Successfully tested expiring soon scenario'));
|
|
331
|
+
} catch (error) {
|
|
332
|
+
console.error(chalk.red('License validation test failed:', error));
|
|
147
333
|
}
|
|
148
334
|
}
|
|
149
335
|
|
|
150
336
|
async function runTests() {
|
|
151
337
|
console.log(chalk.blue('Running D1 Studio tests...'));
|
|
152
|
-
|
|
338
|
+
let testDir = null;
|
|
153
339
|
try {
|
|
154
|
-
await testProjectStructure();
|
|
155
|
-
await testWranglerConfig();
|
|
156
|
-
await
|
|
157
|
-
await
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
340
|
+
testDir = await testProjectStructure();
|
|
341
|
+
await testWranglerConfig(testDir);
|
|
342
|
+
await testCaching(testDir);
|
|
343
|
+
await testStudioScript(testDir);
|
|
344
|
+
await testLicenseValidation(testDir);
|
|
345
|
+
await testPackageExecution(testDir);
|
|
346
|
+
await testLoggerBehavior();
|
|
347
|
+
console.log(chalk.green('\nAll tests completed successfully! 🎉'));
|
|
348
|
+
console.log(chalk.blue('\nTest Summary:'));
|
|
349
|
+
console.log(chalk.blue('============'));
|
|
350
|
+
console.log(chalk.yellow('Check warnings above for any issues that need attention.'));
|
|
351
|
+
console.log(chalk.blue('\nTest directory:', testDir));
|
|
161
352
|
} catch (error) {
|
|
162
|
-
console.
|
|
353
|
+
console.error(chalk.red('\nTests failed:', error));
|
|
354
|
+
process.exit(1);
|
|
355
|
+
} finally {
|
|
356
|
+
if (testDir) {
|
|
357
|
+
console.log(chalk.blue('\nCleaning up test directory...'));
|
|
358
|
+
await fs.rm(testDir, { recursive: true, force: true }).catch(() => {});
|
|
359
|
+
}
|
|
163
360
|
}
|
|
164
361
|
}
|
|
165
362
|
|
|
166
363
|
runTests().catch(error => {
|
|
167
|
-
console.
|
|
168
|
-
|
|
364
|
+
console.error(chalk.red('Test suite failed:', error));
|
|
365
|
+
process.exit(1);
|
|
366
|
+
});
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import { NextResponse } from 'next/server';
|
|
4
4
|
import { findWranglerConfig } from '@/lib/find-wrangler-config.js';
|
|
5
|
+
import logger from '@/lib/logger';
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* Validates the provided Cloudflare credentials by fetching databases.
|
|
@@ -81,6 +82,7 @@ export async function POST(req) {
|
|
|
81
82
|
|
|
82
83
|
// Check if the project directory is set.
|
|
83
84
|
if (!projectDir) {
|
|
85
|
+
logger.error('Project directory not configured');
|
|
84
86
|
return NextResponse.json(
|
|
85
87
|
{ error: 'Project directory not configured' },
|
|
86
88
|
{ status: 500 }
|
|
@@ -93,6 +95,7 @@ export async function POST(req) {
|
|
|
93
95
|
// Retrieve the Wrangler configuration using the centralized helper.
|
|
94
96
|
const wranglerResult = await findWranglerConfig(projectDir);
|
|
95
97
|
if (!wranglerResult || !wranglerResult.config) {
|
|
98
|
+
logger.error('No Wrangler configuration file found in project directory');
|
|
96
99
|
return NextResponse.json(
|
|
97
100
|
{ error: 'No Wrangler configuration file found in project directory' },
|
|
98
101
|
{ status: 404 }
|
|
@@ -130,7 +133,7 @@ export async function POST(req) {
|
|
|
130
133
|
});
|
|
131
134
|
|
|
132
135
|
} catch (error) {
|
|
133
|
-
|
|
136
|
+
logger.error('Cloudflare API error:', error);
|
|
134
137
|
return NextResponse.json(
|
|
135
138
|
{ error: error.message },
|
|
136
139
|
{ status: error.message.includes('Invalid credentials') ? 401 : 500 }
|
|
@@ -144,3 +147,4 @@ export async function POST(req) {
|
|
|
144
147
|
export async function OPTIONS() {
|
|
145
148
|
return new NextResponse(null, { status: 204 });
|
|
146
149
|
}
|
|
150
|
+
|
|
@@ -2,21 +2,20 @@
|
|
|
2
2
|
|
|
3
3
|
import { NextResponse } from 'next/server';
|
|
4
4
|
import { findWranglerConfig } from '@/lib/find-wrangler-config.js';
|
|
5
|
+
import logger from '@/lib/logger';
|
|
5
6
|
|
|
6
7
|
export async function GET() {
|
|
7
8
|
try {
|
|
8
9
|
const projectDir = process.env.D1_PROJECT_DIR;
|
|
9
10
|
|
|
10
11
|
if (!projectDir) {
|
|
11
|
-
|
|
12
|
+
logger.error('D1_PROJECT_DIR environment variable is not set');
|
|
12
13
|
return NextResponse.json(
|
|
13
14
|
{ error: 'Project directory not configured' },
|
|
14
15
|
{ status: 500 }
|
|
15
16
|
);
|
|
16
17
|
}
|
|
17
18
|
|
|
18
|
-
// console.log('Looking for Wrangler configuration in:', projectDir);
|
|
19
|
-
|
|
20
19
|
// Use findWranglerConfig helper
|
|
21
20
|
const wranglerResult = await findWranglerConfig(projectDir);
|
|
22
21
|
if (!wranglerResult || !wranglerResult.config) {
|
|
@@ -44,7 +43,7 @@ export async function GET() {
|
|
|
44
43
|
}
|
|
45
44
|
});
|
|
46
45
|
} catch (error) {
|
|
47
|
-
|
|
46
|
+
logger.error('Error reading database configuration:', error);
|
|
48
47
|
|
|
49
48
|
return NextResponse.json(
|
|
50
49
|
{
|
|
@@ -5,14 +5,13 @@ import { findWranglerConfig } from '@/lib/find-wrangler-config.js';
|
|
|
5
5
|
import { readFile } from 'fs/promises';
|
|
6
6
|
import path from 'path';
|
|
7
7
|
import {
|
|
8
|
-
initMigrationsTable,
|
|
9
8
|
compareMigrations,
|
|
10
9
|
trackMigration,
|
|
11
|
-
updateMigrationStatus,
|
|
12
10
|
createChecksum
|
|
13
11
|
} from '@/lib/migrations';
|
|
14
12
|
import { promisify } from 'util';
|
|
15
13
|
import { exec } from 'child_process';
|
|
14
|
+
import logger from '@/lib/logger';
|
|
16
15
|
|
|
17
16
|
const execAsync = promisify(exec);
|
|
18
17
|
|
|
@@ -21,11 +20,14 @@ const execAsync = promisify(exec);
|
|
|
21
20
|
* Uses the centralized Wrangler configuration helper to determine the D1 database.
|
|
22
21
|
*/
|
|
23
22
|
export async function POST(req) {
|
|
23
|
+
logger.logRequest('POST', '/api/migrations/sync');
|
|
24
|
+
|
|
24
25
|
try {
|
|
25
26
|
const { accountId, apiToken } = await req.json();
|
|
26
27
|
const projectDir = process.env.D1_PROJECT_DIR;
|
|
27
28
|
|
|
28
29
|
if (!projectDir) {
|
|
30
|
+
logger.error('Project directory not configured');
|
|
29
31
|
return NextResponse.json(
|
|
30
32
|
{ error: 'Project directory not configured' },
|
|
31
33
|
{ status: 500 }
|
|
@@ -156,7 +158,7 @@ export async function POST(req) {
|
|
|
156
158
|
});
|
|
157
159
|
|
|
158
160
|
} catch (error) {
|
|
159
|
-
|
|
161
|
+
logger.logError(error, 'migrations-sync-route');
|
|
160
162
|
return NextResponse.json({
|
|
161
163
|
success: false,
|
|
162
164
|
error: {
|