d1s 0.2.1 → 0.2.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/dist/.next/.next/BUILD_ID +1 -1
- package/dist/.next/.next/app-build-manifest.json +16 -16
- 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/.tsbuildinfo +1 -1
- 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/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/index.pack +0 -0
- package/dist/.next/.next/cache/webpack/client-production/index.pack.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/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/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.html +1 -1
- package/dist/.next/.next/server/app/_not-found.rsc +1 -1
- package/dist/.next/.next/server/app/api/cloudflare/route.js +1 -1
- package/dist/.next/.next/server/app/api/databases/route.js +1 -1
- package/dist/.next/.next/server/app/api/migrations/sync/route.js +1 -1
- package/dist/.next/.next/server/app/api/migrations/sync-files/route.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/preview/route.js +1 -1
- package/dist/.next/.next/server/app/api/push-remote/confirm/route.js +1 -1
- package/dist/.next/.next/server/app/api/push-remote/preview/route.js +1 -1
- package/dist/.next/.next/server/app/api/query/route.js +1 -1
- package/dist/.next/.next/server/app/api/tables/[name]/route.js +1 -1
- package/dist/.next/.next/server/app/api/tables/route.js +1 -1
- package/dist/.next/.next/server/app/index.html +1 -1
- package/dist/.next/.next/server/app/index.rsc +1 -1
- package/dist/.next/.next/server/app/page.js +6 -6
- package/dist/.next/.next/server/app-paths-manifest.json +3 -3
- package/dist/.next/.next/server/chunks/336.js +1 -1
- package/dist/.next/.next/server/chunks/973.js +1 -1
- package/dist/.next/.next/server/chunks/992.js +2 -2
- package/dist/.next/.next/server/pages/404.html +1 -1
- package/dist/.next/.next/server/pages/500.html +1 -1
- package/dist/.next/.next/static/YIuXI2CxMwg2fuuUEBsXL/_buildManifest.js +1 -0
- package/dist/.next/.next/static/YIuXI2CxMwg2fuuUEBsXL/_ssgManifest.js +1 -0
- package/dist/.next/.next/static/_t0S4u4KzUwKctaxLKvx4/_buildManifest.js +1 -0
- package/dist/.next/.next/static/_t0S4u4KzUwKctaxLKvx4/_ssgManifest.js +1 -0
- package/dist/.next/.next/static/xzPddcyKcodbwNX_sKljr/_buildManifest.js +1 -0
- package/dist/.next/.next/static/xzPddcyKcodbwNX_sKljr/_ssgManifest.js +1 -0
- package/dist/.next/.next/trace +3 -3
- package/dist/d1-studio.js +34 -13
- package/package.json +1 -1
- package/scripts/studio.js +34 -13
package/scripts/studio.js
CHANGED
|
@@ -16,9 +16,6 @@ import { findWranglerConfig } from '../src/lib/find-wrangler-config.js';
|
|
|
16
16
|
const __filename = fileURLToPath(import.meta.url);
|
|
17
17
|
const __dirname = dirname(__filename);
|
|
18
18
|
|
|
19
|
-
// console.log(chalk.blue('Resolved __filename:'), __filename);
|
|
20
|
-
// console.log(chalk.blue('Resolved __dirname:'), __dirname);
|
|
21
|
-
|
|
22
19
|
// License validation utilities
|
|
23
20
|
class LicenseError extends Error {
|
|
24
21
|
constructor(message, type = 'VALIDATION_ERROR') {
|
|
@@ -68,6 +65,14 @@ async function validateLicenseRemote(licenseKey, email, hardwareId) {
|
|
|
68
65
|
);
|
|
69
66
|
}
|
|
70
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
|
+
|
|
71
76
|
return result;
|
|
72
77
|
} catch (error) {
|
|
73
78
|
if (error instanceof LicenseError) {
|
|
@@ -123,14 +128,18 @@ async function saveLicenseFile(licenseData) {
|
|
|
123
128
|
async function startServer(port, projectDirectory) {
|
|
124
129
|
return new Promise((resolvePromise, rejectPromise) => {
|
|
125
130
|
const dev = process.env.NODE_ENV === 'development';
|
|
126
|
-
|
|
127
|
-
|
|
131
|
+
|
|
132
|
+
// Determine the directory where Next.js build is located:
|
|
133
|
+
// In production (published package), __dirname is in the 'dist' folder so we use it directly.
|
|
134
|
+
// In development, we assume the structure is different and go one level up.
|
|
135
|
+
const isProduction = process.env.NODE_ENV !== 'development';
|
|
136
|
+
const nextAppDir = isProduction ? __dirname : join(__dirname, '..');
|
|
137
|
+
|
|
128
138
|
const app = next({
|
|
129
139
|
dev,
|
|
130
|
-
dir,
|
|
140
|
+
dir: nextAppDir,
|
|
131
141
|
conf: {
|
|
132
142
|
distDir: '.next',
|
|
133
|
-
// Ensure app directory is correctly set for routing
|
|
134
143
|
experimental: {
|
|
135
144
|
appDir: true
|
|
136
145
|
}
|
|
@@ -189,7 +198,18 @@ async function startStudio() {
|
|
|
189
198
|
let licenseData = await checkLicenseFile();
|
|
190
199
|
console.log(chalk.blue('License data found:'), licenseData);
|
|
191
200
|
|
|
192
|
-
|
|
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) {
|
|
193
213
|
const { default: inquirer } = await import('inquirer');
|
|
194
214
|
console.log(chalk.blue('\nPlease enter your D1 Studio license information:'));
|
|
195
215
|
|
|
@@ -214,7 +234,6 @@ async function startStudio() {
|
|
|
214
234
|
console.log(chalk.blue('Entered license information:'), answers);
|
|
215
235
|
|
|
216
236
|
const hardwareId = await generateHardwareId();
|
|
217
|
-
// console.log(chalk.blue('Generated hardware ID:'), hardwareId);
|
|
218
237
|
|
|
219
238
|
try {
|
|
220
239
|
const validation = await validateLicenseRemote(
|
|
@@ -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,12 +259,13 @@ 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
|
|
243
267
|
try {
|
|
244
268
|
const userProjectPath = process.cwd();
|
|
245
|
-
// console.log(chalk.blue('Current working directory:'), userProjectPath);
|
|
246
269
|
|
|
247
270
|
if (!userProjectPath) {
|
|
248
271
|
console.error(chalk.red('Error: Could not determine project directory'));
|
|
@@ -250,7 +273,6 @@ async function startStudio() {
|
|
|
250
273
|
}
|
|
251
274
|
|
|
252
275
|
const wranglerResult = await findWranglerConfig(userProjectPath);
|
|
253
|
-
// console.log(chalk.blue('Wrangler config result:'), wranglerResult);
|
|
254
276
|
|
|
255
277
|
if (!wranglerResult || !wranglerResult.config) {
|
|
256
278
|
console.error(chalk.red('\nError: No wrangler.toml found in current directory'));
|
|
@@ -260,7 +282,6 @@ async function startStudio() {
|
|
|
260
282
|
}
|
|
261
283
|
|
|
262
284
|
const { config, projectPath } = wranglerResult;
|
|
263
|
-
// console.log(chalk.blue('Resolved wrangler.toml project path:'), projectPath);
|
|
264
285
|
|
|
265
286
|
if (!config.d1_databases?.length) {
|
|
266
287
|
console.error(chalk.red('\nError: No D1 databases configured in wrangler.toml'));
|
|
@@ -341,4 +362,4 @@ process.on('SIGTERM', () => {
|
|
|
341
362
|
startStudio().catch((error) => {
|
|
342
363
|
console.error(chalk.red('\nFailed to start D1 Studio:'), error);
|
|
343
364
|
process.exit(1);
|
|
344
|
-
});
|
|
365
|
+
});
|