@playcademy/vite-plugin 0.1.10 → 0.1.11
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/index.js +77 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -158087,7 +158087,10 @@ class CloudflareProvider {
|
|
|
158087
158087
|
namespace: this.config.dispatchNamespace
|
|
158088
158088
|
});
|
|
158089
158089
|
if (deleteBindings) {
|
|
158090
|
-
await
|
|
158090
|
+
await Promise.all([
|
|
158091
|
+
this.deleteD1DatabaseIfExists(deploymentId),
|
|
158092
|
+
this.deleteKVNamespaceIfExists(deploymentId)
|
|
158093
|
+
]);
|
|
158091
158094
|
}
|
|
158092
158095
|
} catch (error2) {
|
|
158093
158096
|
log2.error("[CloudflareProvider] Deletion from dispatch namespace failed", {
|
|
@@ -158138,7 +158141,12 @@ class CloudflareProvider {
|
|
|
158138
158141
|
}
|
|
158139
158142
|
}
|
|
158140
158143
|
for (const kvName of resourceBindings.kv) {
|
|
158141
|
-
|
|
158144
|
+
const namespaceId = await this.ensureKVNamespace(kvName);
|
|
158145
|
+
bindings.push({
|
|
158146
|
+
type: "kv_namespace",
|
|
158147
|
+
name: "KV",
|
|
158148
|
+
namespace_id: namespaceId
|
|
158149
|
+
});
|
|
158142
158150
|
}
|
|
158143
158151
|
for (const r2Name of resourceBindings.r2) {
|
|
158144
158152
|
log2.warn("[CloudflareProvider] R2 bucket binding not yet implemented", { r2Name });
|
|
@@ -158250,6 +158258,73 @@ class CloudflareProvider {
|
|
|
158250
158258
|
throw new Error(`Failed to execute schema: ${error2 instanceof Error ? error2.message : String(error2)}`);
|
|
158251
158259
|
}
|
|
158252
158260
|
}
|
|
158261
|
+
async ensureKVNamespace(namespaceName) {
|
|
158262
|
+
log2.debug("[CloudflareProvider] Ensuring KV namespace exists", { namespaceName });
|
|
158263
|
+
try {
|
|
158264
|
+
const namespaces = await this.client.kv.namespaces.list({
|
|
158265
|
+
account_id: this.config.accountId
|
|
158266
|
+
});
|
|
158267
|
+
for await (const ns of namespaces) {
|
|
158268
|
+
if (ns.title === namespaceName && ns.id) {
|
|
158269
|
+
log2.info("[CloudflareProvider] KV namespace already exists", {
|
|
158270
|
+
namespaceName,
|
|
158271
|
+
namespaceId: ns.id
|
|
158272
|
+
});
|
|
158273
|
+
return ns.id;
|
|
158274
|
+
}
|
|
158275
|
+
}
|
|
158276
|
+
log2.debug("[CloudflareProvider] Creating new KV namespace", { namespaceName });
|
|
158277
|
+
const createResult = await this.client.kv.namespaces.create({
|
|
158278
|
+
account_id: this.config.accountId,
|
|
158279
|
+
title: namespaceName
|
|
158280
|
+
});
|
|
158281
|
+
if (!createResult.id) {
|
|
158282
|
+
throw new Error("KV namespace creation succeeded but no ID returned");
|
|
158283
|
+
}
|
|
158284
|
+
log2.info("[CloudflareProvider] KV namespace created successfully", {
|
|
158285
|
+
namespaceName,
|
|
158286
|
+
namespaceId: createResult.id
|
|
158287
|
+
});
|
|
158288
|
+
return createResult.id;
|
|
158289
|
+
} catch (error2) {
|
|
158290
|
+
log2.error("[CloudflareProvider] Failed to ensure KV namespace", {
|
|
158291
|
+
namespaceName,
|
|
158292
|
+
error: error2
|
|
158293
|
+
});
|
|
158294
|
+
throw new Error(`Failed to ensure KV namespace: ${error2 instanceof Error ? error2.message : String(error2)}`);
|
|
158295
|
+
}
|
|
158296
|
+
}
|
|
158297
|
+
async deleteKVNamespaceIfExists(namespaceName) {
|
|
158298
|
+
try {
|
|
158299
|
+
const namespaces = await this.client.kv.namespaces.list({
|
|
158300
|
+
account_id: this.config.accountId
|
|
158301
|
+
});
|
|
158302
|
+
for await (const ns of namespaces) {
|
|
158303
|
+
if (ns.title === namespaceName && ns.id) {
|
|
158304
|
+
log2.debug("[CloudflareProvider] Deleting KV namespace", {
|
|
158305
|
+
namespaceName,
|
|
158306
|
+
namespaceId: ns.id
|
|
158307
|
+
});
|
|
158308
|
+
await this.client.kv.namespaces.delete(ns.id, {
|
|
158309
|
+
account_id: this.config.accountId
|
|
158310
|
+
});
|
|
158311
|
+
log2.info("[CloudflareProvider] KV namespace deleted successfully", {
|
|
158312
|
+
namespaceName,
|
|
158313
|
+
namespaceId: ns.id
|
|
158314
|
+
});
|
|
158315
|
+
return;
|
|
158316
|
+
}
|
|
158317
|
+
}
|
|
158318
|
+
log2.debug("[CloudflareProvider] KV namespace not found, nothing to delete", {
|
|
158319
|
+
namespaceName
|
|
158320
|
+
});
|
|
158321
|
+
} catch (error2) {
|
|
158322
|
+
log2.warn("[CloudflareProvider] Failed to delete KV namespace", {
|
|
158323
|
+
namespaceName,
|
|
158324
|
+
error: error2
|
|
158325
|
+
});
|
|
158326
|
+
}
|
|
158327
|
+
}
|
|
158253
158328
|
}
|
|
158254
158329
|
var RESERVED_SUBDOMAINS = new Set([
|
|
158255
158330
|
"www",
|