-
Notifications
You must be signed in to change notification settings - Fork 741
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Print copyable wrangler.toml text when creating a hyperdrive config (#…
…7326) * Print copyable wrangler.toml text when creating a hyperdrive config * Add changeset * Use formatConfigSnippet in printing out the Hyperdrive config
- Loading branch information
Showing
3 changed files
with
150 additions
and
117 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"wrangler": patch | ||
--- | ||
|
||
Print wrangler.toml snippet when creating new Hyperdrive Config |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ import { useMockIsTTY } from "./helpers/mock-istty"; | |
import { createFetchResult, msw } from "./helpers/msw"; | ||
import { runInTempDir } from "./helpers/run-in-tmp"; | ||
import { runWrangler } from "./helpers/run-wrangler"; | ||
import { writeWranglerConfig } from "./helpers/write-wrangler-config"; | ||
import type { | ||
CreateUpdateHyperdriveBody, | ||
HyperdriveConfig, | ||
|
@@ -117,21 +118,53 @@ describe("hyperdrive commands", () => { | |
|
||
expect(std.out).toMatchInlineSnapshot(` | ||
"🚧 Creating 'test123' | ||
✅ Created new Hyperdrive config | ||
{ | ||
\\"id\\": \\"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\\", | ||
\\"name\\": \\"test123\\", | ||
\\"origin\\": { | ||
\\"host\\": \\"example.com\\", | ||
\\"port\\": 12345, | ||
\\"database\\": \\"neondb\\", | ||
\\"scheme\\": \\"postgresql\\", | ||
\\"user\\": \\"test\\" | ||
} | ||
✅ Created new Hyperdrive config: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx | ||
📋 To start using your config from a Worker, add the following binding configuration to your Wrangler configuration file: | ||
{ | ||
\\"hyperdrive\\": [ | ||
{ | ||
\\"binding\\": \\"HYPERDRIVE\\", | ||
\\"id\\": \\"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\\" | ||
} | ||
] | ||
}" | ||
`); | ||
}); | ||
|
||
it("should handle creating a hyperdrive and printing a TOML snipped", async () => { | ||
const reqProm = mockHyperdriveCreate(); | ||
writeWranglerConfig(); | ||
await runWrangler( | ||
"hyperdrive create test123 --connection-string='postgresql://test:[email protected]:12345/neondb'" | ||
); | ||
|
||
await expect(reqProm).resolves.toMatchInlineSnapshot(` | ||
Object { | ||
"name": "test123", | ||
"origin": Object { | ||
"database": "neondb", | ||
"host": "example.com", | ||
"password": "password", | ||
"port": 12345, | ||
"scheme": "postgresql", | ||
"user": "test", | ||
}, | ||
} | ||
`); | ||
|
||
expect(std.out).toMatchInlineSnapshot(` | ||
"🚧 Creating 'test123' | ||
✅ Created new Hyperdrive config: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx | ||
📋 To start using your config from a Worker, add the following binding configuration to your wrangler.toml file: | ||
[[hyperdrive]] | ||
binding = \\"HYPERDRIVE\\" | ||
id = \\"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\\" | ||
" | ||
`); | ||
}); | ||
|
||
it("should handle creating a hyperdrive config for postgres without a port specified", async () => { | ||
const reqProm = mockHyperdriveCreate(); | ||
await runWrangler( | ||
|
@@ -153,17 +186,16 @@ describe("hyperdrive commands", () => { | |
`); | ||
expect(std.out).toMatchInlineSnapshot(` | ||
"🚧 Creating 'test123' | ||
✅ Created new Hyperdrive config | ||
{ | ||
\\"id\\": \\"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\\", | ||
\\"name\\": \\"test123\\", | ||
\\"origin\\": { | ||
\\"host\\": \\"example.com\\", | ||
\\"port\\": 5432, | ||
\\"database\\": \\"neondb\\", | ||
\\"scheme\\": \\"postgresql\\", | ||
\\"user\\": \\"test\\" | ||
} | ||
✅ Created new Hyperdrive config: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx | ||
📋 To start using your config from a Worker, add the following binding configuration to your Wrangler configuration file: | ||
{ | ||
\\"hyperdrive\\": [ | ||
{ | ||
\\"binding\\": \\"HYPERDRIVE\\", | ||
\\"id\\": \\"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\\" | ||
} | ||
] | ||
}" | ||
`); | ||
}); | ||
|
@@ -193,21 +225,16 @@ describe("hyperdrive commands", () => { | |
`); | ||
expect(std.out).toMatchInlineSnapshot(` | ||
"🚧 Creating 'test123' | ||
✅ Created new Hyperdrive config | ||
{ | ||
\\"id\\": \\"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\\", | ||
\\"name\\": \\"test123\\", | ||
\\"origin\\": { | ||
\\"host\\": \\"example.com\\", | ||
\\"port\\": 12345, | ||
\\"database\\": \\"neondb\\", | ||
\\"scheme\\": \\"postgresql\\", | ||
\\"user\\": \\"test\\" | ||
}, | ||
\\"caching\\": { | ||
\\"max_age\\": 30, | ||
\\"stale_while_revalidate\\": 15 | ||
} | ||
✅ Created new Hyperdrive config: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx | ||
📋 To start using your config from a Worker, add the following binding configuration to your Wrangler configuration file: | ||
{ | ||
\\"hyperdrive\\": [ | ||
{ | ||
\\"binding\\": \\"HYPERDRIVE\\", | ||
\\"id\\": \\"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\\" | ||
} | ||
] | ||
}" | ||
`); | ||
}); | ||
|
@@ -233,17 +260,16 @@ describe("hyperdrive commands", () => { | |
`); | ||
expect(std.out).toMatchInlineSnapshot(` | ||
"🚧 Creating 'test123' | ||
✅ Created new Hyperdrive config | ||
{ | ||
\\"id\\": \\"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\\", | ||
\\"name\\": \\"test123\\", | ||
\\"origin\\": { | ||
\\"host\\": \\"example.com\\", | ||
\\"port\\": 5432, | ||
\\"database\\": \\"neondb\\", | ||
\\"scheme\\": \\"postgresql\\", | ||
\\"user\\": \\"user:name\\" | ||
} | ||
✅ Created new Hyperdrive config: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx | ||
📋 To start using your config from a Worker, add the following binding configuration to your Wrangler configuration file: | ||
{ | ||
\\"hyperdrive\\": [ | ||
{ | ||
\\"binding\\": \\"HYPERDRIVE\\", | ||
\\"id\\": \\"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\\" | ||
} | ||
] | ||
}" | ||
`); | ||
}); | ||
|
@@ -269,17 +295,16 @@ describe("hyperdrive commands", () => { | |
`); | ||
expect(std.out).toMatchInlineSnapshot(` | ||
"🚧 Creating 'test123' | ||
✅ Created new Hyperdrive config | ||
{ | ||
\\"id\\": \\"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\\", | ||
\\"name\\": \\"test123\\", | ||
\\"origin\\": { | ||
\\"host\\": \\"example.com\\", | ||
\\"port\\": 5432, | ||
\\"database\\": \\"neondb\\", | ||
\\"scheme\\": \\"postgresql\\", | ||
\\"user\\": \\"test\\" | ||
} | ||
✅ Created new Hyperdrive config: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx | ||
📋 To start using your config from a Worker, add the following binding configuration to your Wrangler configuration file: | ||
{ | ||
\\"hyperdrive\\": [ | ||
{ | ||
\\"binding\\": \\"HYPERDRIVE\\", | ||
\\"id\\": \\"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\\" | ||
} | ||
] | ||
}" | ||
`); | ||
}); | ||
|
@@ -305,17 +330,16 @@ describe("hyperdrive commands", () => { | |
`); | ||
expect(std.out).toMatchInlineSnapshot(` | ||
"🚧 Creating 'test123' | ||
✅ Created new Hyperdrive config | ||
{ | ||
\\"id\\": \\"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\\", | ||
\\"name\\": \\"test123\\", | ||
\\"origin\\": { | ||
\\"host\\": \\"example.com\\", | ||
\\"port\\": 5432, | ||
\\"database\\": \\"/\\"weird/\\" dbname\\", | ||
\\"scheme\\": \\"postgresql\\", | ||
\\"user\\": \\"test\\" | ||
} | ||
✅ Created new Hyperdrive config: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx | ||
📋 To start using your config from a Worker, add the following binding configuration to your Wrangler configuration file: | ||
{ | ||
\\"hyperdrive\\": [ | ||
{ | ||
\\"binding\\": \\"HYPERDRIVE\\", | ||
\\"id\\": \\"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\\" | ||
} | ||
] | ||
}" | ||
`); | ||
}); | ||
|
@@ -341,17 +365,16 @@ describe("hyperdrive commands", () => { | |
`); | ||
expect(std.out).toMatchInlineSnapshot(` | ||
"🚧 Creating 'test123' | ||
✅ Created new Hyperdrive config | ||
{ | ||
\\"id\\": \\"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\\", | ||
\\"name\\": \\"test123\\", | ||
\\"origin\\": { | ||
\\"host\\": \\"example.com\\", | ||
\\"port\\": 5432, | ||
\\"database\\": \\"neondb\\", | ||
\\"scheme\\": \\"postgresql\\", | ||
\\"user\\": \\"test\\" | ||
} | ||
✅ Created new Hyperdrive config: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx | ||
📋 To start using your config from a Worker, add the following binding configuration to your Wrangler configuration file: | ||
{ | ||
\\"hyperdrive\\": [ | ||
{ | ||
\\"binding\\": \\"HYPERDRIVE\\", | ||
\\"id\\": \\"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\\" | ||
} | ||
] | ||
}" | ||
`); | ||
}); | ||
|
@@ -377,17 +400,16 @@ describe("hyperdrive commands", () => { | |
`); | ||
expect(std.out).toMatchInlineSnapshot(` | ||
"🚧 Creating 'test123' | ||
✅ Created new Hyperdrive config | ||
{ | ||
\\"id\\": \\"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\\", | ||
\\"name\\": \\"test123\\", | ||
\\"origin\\": { | ||
\\"host\\": \\"example.com\\", | ||
\\"port\\": 1234, | ||
\\"database\\": \\"neondb\\", | ||
\\"scheme\\": \\"postgresql\\", | ||
\\"user\\": \\"test\\" | ||
} | ||
✅ Created new Hyperdrive config: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx | ||
📋 To start using your config from a Worker, add the following binding configuration to your Wrangler configuration file: | ||
{ | ||
\\"hyperdrive\\": [ | ||
{ | ||
\\"binding\\": \\"HYPERDRIVE\\", | ||
\\"id\\": \\"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\\" | ||
} | ||
] | ||
}" | ||
`); | ||
}); | ||
|
@@ -439,17 +461,16 @@ describe("hyperdrive commands", () => { | |
`); | ||
expect(std.out).toMatchInlineSnapshot(` | ||
"🚧 Creating 'test123' | ||
✅ Created new Hyperdrive config | ||
{ | ||
\\"id\\": \\"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\\", | ||
\\"name\\": \\"test123\\", | ||
\\"origin\\": { | ||
\\"host\\": \\"example.com\\", | ||
\\"database\\": \\"neondb\\", | ||
\\"scheme\\": \\"postgresql\\", | ||
\\"user\\": \\"test\\", | ||
\\"access_client_id\\": \\"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.access\\" | ||
} | ||
✅ Created new Hyperdrive config: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx | ||
📋 To start using your config from a Worker, add the following binding configuration to your Wrangler configuration file: | ||
{ | ||
\\"hyperdrive\\": [ | ||
{ | ||
\\"binding\\": \\"HYPERDRIVE\\", | ||
\\"id\\": \\"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\\" | ||
} | ||
] | ||
}" | ||
`); | ||
}); | ||
|
@@ -475,17 +496,16 @@ describe("hyperdrive commands", () => { | |
`); | ||
expect(std.out).toMatchInlineSnapshot(` | ||
"🚧 Creating 'test123' | ||
✅ Created new Hyperdrive config | ||
{ | ||
\\"id\\": \\"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\\", | ||
\\"name\\": \\"test123\\", | ||
\\"origin\\": { | ||
\\"host\\": \\"example.com/database\\", | ||
\\"database\\": \\"neondb\\", | ||
\\"scheme\\": \\"postgresql\\", | ||
\\"user\\": \\"test\\", | ||
\\"access_client_id\\": \\"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.access\\" | ||
} | ||
✅ Created new Hyperdrive config: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx | ||
📋 To start using your config from a Worker, add the following binding configuration to your Wrangler configuration file: | ||
{ | ||
\\"hyperdrive\\": [ | ||
{ | ||
\\"binding\\": \\"HYPERDRIVE\\", | ||
\\"id\\": \\"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\\" | ||
} | ||
] | ||
}" | ||
`); | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters