alchemy 0.11.0 → 0.11.1
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/lib/cloudflare/auth.js +17 -3
- package/lib/cloudflare/d1-database.js +1 -0
- package/lib/cloudflare/wrangler.json.d.ts +1 -0
- package/lib/cloudflare/wrangler.json.js +1 -0
- package/package.json +1 -1
- package/src/cloudflare/auth.ts +22 -5
- package/src/cloudflare/d1-database.ts +1 -0
- package/src/cloudflare/wrangler.json.ts +3 -0
package/lib/cloudflare/auth.js
CHANGED
|
@@ -126,6 +126,8 @@ async function getRefreshedAuthConfig() {
|
|
|
126
126
|
return authConfig;
|
|
127
127
|
}
|
|
128
128
|
async function writeWranglerConfig(config) {
|
|
129
|
+
if (config.exists === false)
|
|
130
|
+
return;
|
|
129
131
|
const TOML = await import("@iarna/toml");
|
|
130
132
|
const configPath = await findWranglerConfig();
|
|
131
133
|
config = {
|
|
@@ -140,9 +142,21 @@ async function writeWranglerConfig(config) {
|
|
|
140
142
|
const authConfigCache = {};
|
|
141
143
|
async function readWranglerConfig() {
|
|
142
144
|
const configPath = await findWranglerConfig();
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
145
|
+
try {
|
|
146
|
+
const config = (authConfigCache[configPath] ??= await parseTOML(await fs.readFile(configPath, "utf-8")));
|
|
147
|
+
config.path = configPath;
|
|
148
|
+
return config;
|
|
149
|
+
}
|
|
150
|
+
catch (e) {
|
|
151
|
+
if (e.code === "ENOENT") {
|
|
152
|
+
// The config doesn't exist
|
|
153
|
+
return {
|
|
154
|
+
path: configPath,
|
|
155
|
+
exists: false
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
throw e;
|
|
159
|
+
}
|
|
146
160
|
}
|
|
147
161
|
let wranglerConfigPath;
|
|
148
162
|
async function findWranglerConfig() {
|
|
@@ -139,6 +139,7 @@ export const D1DatabaseResource = Resource("cloudflare::D1Database", async funct
|
|
|
139
139
|
readReplication: dbData.result.read_replication,
|
|
140
140
|
primaryLocationHint: props.primaryLocationHint,
|
|
141
141
|
accountId: api.accountId,
|
|
142
|
+
migrationsDir: props.migrationsDir
|
|
142
143
|
});
|
|
143
144
|
}
|
|
144
145
|
});
|
package/package.json
CHANGED
package/src/cloudflare/auth.ts
CHANGED
|
@@ -239,6 +239,8 @@ interface WranglerConfig {
|
|
|
239
239
|
refresh_token?: string;
|
|
240
240
|
expiration_time?: string;
|
|
241
241
|
scopes?: string[];
|
|
242
|
+
/** exists is `false` if the config file doesn't exist, like in CI */
|
|
243
|
+
exists?: boolean;
|
|
242
244
|
/** @deprecated - this field was only provided by the deprecated v1 `wrangler config` command. */
|
|
243
245
|
api_token?: string;
|
|
244
246
|
}
|
|
@@ -258,6 +260,8 @@ async function getRefreshedAuthConfig(): Promise<WranglerConfig> {
|
|
|
258
260
|
}
|
|
259
261
|
|
|
260
262
|
async function writeWranglerConfig(config: WranglerConfig) {
|
|
263
|
+
if (config.exists === false) return
|
|
264
|
+
|
|
261
265
|
const TOML = await import("@iarna/toml");
|
|
262
266
|
const configPath = await findWranglerConfig();
|
|
263
267
|
config = {
|
|
@@ -274,11 +278,24 @@ const authConfigCache: Record<string, WranglerConfig> = {};
|
|
|
274
278
|
|
|
275
279
|
async function readWranglerConfig(): Promise<WranglerConfig> {
|
|
276
280
|
const configPath = await findWranglerConfig();
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
281
|
+
try {
|
|
282
|
+
const config = (authConfigCache[configPath] ??= await parseTOML(
|
|
283
|
+
await fs.readFile(configPath, "utf-8")
|
|
284
|
+
));
|
|
285
|
+
config.path = configPath;
|
|
286
|
+
|
|
287
|
+
return config
|
|
288
|
+
} catch (e: any) {
|
|
289
|
+
if (e.code === "ENOENT") {
|
|
290
|
+
// The config doesn't exist
|
|
291
|
+
return {
|
|
292
|
+
path: configPath,
|
|
293
|
+
exists: false
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
throw e
|
|
298
|
+
}
|
|
282
299
|
}
|
|
283
300
|
|
|
284
301
|
let wranglerConfigPath: string | undefined;
|
|
@@ -207,6 +207,7 @@ export interface WranglerJsonSpec {
|
|
|
207
207
|
binding: string;
|
|
208
208
|
database_id: string;
|
|
209
209
|
database_name: string;
|
|
210
|
+
migrations_dir?: string
|
|
210
211
|
}[];
|
|
211
212
|
|
|
212
213
|
/**
|
|
@@ -254,6 +255,7 @@ function processBindings(spec: WranglerJsonSpec, bindings: Bindings): void {
|
|
|
254
255
|
binding: string;
|
|
255
256
|
database_id: string;
|
|
256
257
|
database_name: string;
|
|
258
|
+
migrations_dir?: string;
|
|
257
259
|
}[] = [];
|
|
258
260
|
const queues: { binding: string; queue: string }[] = [];
|
|
259
261
|
const vectorizeIndexes: { binding: string; index_name: string }[] = [];
|
|
@@ -314,6 +316,7 @@ function processBindings(spec: WranglerJsonSpec, bindings: Bindings): void {
|
|
|
314
316
|
binding: bindingName,
|
|
315
317
|
database_id: binding.id,
|
|
316
318
|
database_name: binding.name,
|
|
319
|
+
migrations_dir: binding.migrationsDir,
|
|
317
320
|
});
|
|
318
321
|
} else if (binding.type === "queue") {
|
|
319
322
|
queues.push({
|