Skip to content

Commit

Permalink
feat: --legacy-env cli arg / legacy_env config
Browse files Browse the repository at this point in the history
This is the first of a few changes to codify how we do environments in wrangler2, both older legacy style environments, and newer service environments. Here, we add a cli arg and a config field for specifying whether to enable/disable legacy style environments, and pass it on to dev/publish commands. We also fix how we were generating kv namespaces for Workers Sites, among other smaller fixes.
  • Loading branch information
threepointone authored and petebacondarwin committed Feb 22, 2022
1 parent f17757d commit 9534c7f
Show file tree
Hide file tree
Showing 13 changed files with 370 additions and 140 deletions.
7 changes: 7 additions & 0 deletions .changeset/short-dancers-mix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"wrangler": patch
---

feat: `--legacy-env` cli arg / `legacy_env` config

This is the first of a few changes to codify how we do environments in wrangler2, both older legacy style environments, and newer service environments. Here, we add a cli arg and a config field for specifying whether to enable/disable legacy style environments, and pass it on to dev/publish commands. We also fix how we were generating kv namespaces for Workers Sites, among other smaller fixes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { generateGitHubFetch } from "../../utils/gitHubFetch";
import { getArtifactForWorkflowRun } from "../../utils/getArtifactForWorkflowRun";
import { generateGitHubFetch } from "../../utils/gitHubFetch";

interface PullRequest {
head: { ref: string; sha: string };
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { generateGitHubFetch } from "../../utils/gitHubFetch";
import { getArtifactForWorkflowRun } from "../../utils/getArtifactForWorkflowRun";
import { generateGitHubFetch } from "../../utils/gitHubFetch";

export const onRequestGet: PagesFunction<
{ GITHUB_API_TOKEN: string; GITHUB_USER: string },
Expand Down
2 changes: 2 additions & 0 deletions packages/wrangler/src/__tests__/dev.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ function renderDev({
port,
format,
accountId,
legacyEnv = true,
initialMode = "local",
jsxFactory,
jsxFragment,
Expand All @@ -86,6 +87,7 @@ function renderDev({
entry={entry}
env={env}
port={port}
legacyEnv={legacyEnv}
buildCommand={buildCommand}
format={format}
initialMode={initialMode}
Expand Down
14 changes: 8 additions & 6 deletions packages/wrangler/src/__tests__/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,10 @@ describe("wrangler", () => {
wrangler r2 📦 Interact with an R2 store
Flags:
-c, --config Path to .toml configuration file [string]
-h, --help Show help [boolean]
-v, --version Show version number [boolean]
-c, --config Path to .toml configuration file [string]
-h, --help Show help [boolean]
-v, --version Show version number [boolean]
--legacy-env Use legacy environments [boolean]
Options:
-l, --local Run on my machine [boolean] [default: false]"
Expand Down Expand Up @@ -82,9 +83,10 @@ describe("wrangler", () => {
wrangler r2 📦 Interact with an R2 store
Flags:
-c, --config Path to .toml configuration file [string]
-h, --help Show help [boolean]
-v, --version Show version number [boolean]
-c, --config Path to .toml configuration file [string]
-h, --help Show help [boolean]
-v, --version Show version number [boolean]
--legacy-env Use legacy environments [boolean]
Options:
-l, --local Run on my machine [boolean] [default: false]
Expand Down
144 changes: 78 additions & 66 deletions packages/wrangler/src/__tests__/kv.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,10 @@ describe("wrangler", () => {
namespace The name of the new namespace [string] [required]
Flags:
-c, --config Path to .toml configuration file [string]
-h, --help Show help [boolean]
-v, --version Show version number [boolean]
-c, --config Path to .toml configuration file [string]
-h, --help Show help [boolean]
-v, --version Show version number [boolean]
--legacy-env Use legacy environments [boolean]
Options:
-l, --local Run on my machine [boolean] [default: false]
Expand All @@ -82,9 +83,10 @@ describe("wrangler", () => {
namespace The name of the new namespace [string] [required]
Flags:
-c, --config Path to .toml configuration file [string]
-h, --help Show help [boolean]
-v, --version Show version number [boolean]
-c, --config Path to .toml configuration file [string]
-h, --help Show help [boolean]
-v, --version Show version number [boolean]
--legacy-env Use legacy environments [boolean]
Options:
-l, --local Run on my machine [boolean] [default: false]
Expand Down Expand Up @@ -112,9 +114,10 @@ describe("wrangler", () => {
namespace The name of the new namespace [string] [required]
Flags:
-c, --config Path to .toml configuration file [string]
-h, --help Show help [boolean]
-v, --version Show version number [boolean]
-c, --config Path to .toml configuration file [string]
-h, --help Show help [boolean]
-v, --version Show version number [boolean]
--legacy-env Use legacy environments [boolean]
Options:
-l, --local Run on my machine [boolean] [default: false]
Expand Down Expand Up @@ -276,9 +279,10 @@ describe("wrangler", () => {
Deletes a given namespace.
Flags:
-c, --config Path to .toml configuration file [string]
-h, --help Show help [boolean]
-v, --version Show version number [boolean]
-c, --config Path to .toml configuration file [string]
-h, --help Show help [boolean]
-v, --version Show version number [boolean]
--legacy-env Use legacy environments [boolean]
Options:
-l, --local Run on my machine [boolean] [default: false]
Expand Down Expand Up @@ -467,23 +471,24 @@ describe("wrangler", () => {
Writes a single key/value pair to the given namespace.
Positionals:
key The key to write to. [string] [required]
value The value to write. [string]
key The key to write to [string] [required]
value The value to write [string]
Flags:
-c, --config Path to .toml configuration file [string]
-h, --help Show help [boolean]
-v, --version Show version number [boolean]
-c, --config Path to .toml configuration file [string]
-h, --help Show help [boolean]
-v, --version Show version number [boolean]
--legacy-env Use legacy environments [boolean]
Options:
-l, --local Run on my machine [boolean] [default: false]
--binding The binding of the namespace to write to. [string]
--namespace-id The id of the namespace to write to. [string]
--binding The binding of the namespace to write to [string]
--namespace-id The id of the namespace to write to [string]
--env Perform on a specific environment [string]
--preview Interact with a preview namespace [boolean]
--ttl Time for which the entries should be visible. [number]
--ttl Time for which the entries should be visible [number]
--expiration Time since the UNIX epoch after which the entry expires [number]
--path Read value from the file at a given path. [string]
--path Read value from the file at a given path [string]
Not enough non-option arguments: got 0, need at least 1"
`);
Expand All @@ -503,23 +508,24 @@ describe("wrangler", () => {
Writes a single key/value pair to the given namespace.
Positionals:
key The key to write to. [string] [required]
value The value to write. [string]
key The key to write to [string] [required]
value The value to write [string]
Flags:
-c, --config Path to .toml configuration file [string]
-h, --help Show help [boolean]
-v, --version Show version number [boolean]
-c, --config Path to .toml configuration file [string]
-h, --help Show help [boolean]
-v, --version Show version number [boolean]
--legacy-env Use legacy environments [boolean]
Options:
-l, --local Run on my machine [boolean] [default: false]
--binding The binding of the namespace to write to. [string]
--namespace-id The id of the namespace to write to. [string]
--binding The binding of the namespace to write to [string]
--namespace-id The id of the namespace to write to [string]
--env Perform on a specific environment [string]
--preview Interact with a preview namespace [boolean]
--ttl Time for which the entries should be visible. [number]
--ttl Time for which the entries should be visible [number]
--expiration Time since the UNIX epoch after which the entry expires [number]
--path Read value from the file at a given path. [string]
--path Read value from the file at a given path [string]
Exactly one of the arguments binding and namespace-id is required"
`);
Expand All @@ -539,23 +545,24 @@ describe("wrangler", () => {
Writes a single key/value pair to the given namespace.
Positionals:
key The key to write to. [string] [required]
value The value to write. [string]
key The key to write to [string] [required]
value The value to write [string]
Flags:
-c, --config Path to .toml configuration file [string]
-h, --help Show help [boolean]
-v, --version Show version number [boolean]
-c, --config Path to .toml configuration file [string]
-h, --help Show help [boolean]
-v, --version Show version number [boolean]
--legacy-env Use legacy environments [boolean]
Options:
-l, --local Run on my machine [boolean] [default: false]
--binding The binding of the namespace to write to. [string]
--namespace-id The id of the namespace to write to. [string]
--binding The binding of the namespace to write to [string]
--namespace-id The id of the namespace to write to [string]
--env Perform on a specific environment [string]
--preview Interact with a preview namespace [boolean]
--ttl Time for which the entries should be visible. [number]
--ttl Time for which the entries should be visible [number]
--expiration Time since the UNIX epoch after which the entry expires [number]
--path Read value from the file at a given path. [string]
--path Read value from the file at a given path [string]
Arguments binding and namespace-id are mutually exclusive"
`);
Expand All @@ -575,23 +582,24 @@ describe("wrangler", () => {
Writes a single key/value pair to the given namespace.
Positionals:
key The key to write to. [string] [required]
value The value to write. [string]
key The key to write to [string] [required]
value The value to write [string]
Flags:
-c, --config Path to .toml configuration file [string]
-h, --help Show help [boolean]
-v, --version Show version number [boolean]
-c, --config Path to .toml configuration file [string]
-h, --help Show help [boolean]
-v, --version Show version number [boolean]
--legacy-env Use legacy environments [boolean]
Options:
-l, --local Run on my machine [boolean] [default: false]
--binding The binding of the namespace to write to. [string]
--namespace-id The id of the namespace to write to. [string]
--binding The binding of the namespace to write to [string]
--namespace-id The id of the namespace to write to [string]
--env Perform on a specific environment [string]
--preview Interact with a preview namespace [boolean]
--ttl Time for which the entries should be visible. [number]
--ttl Time for which the entries should be visible [number]
--expiration Time since the UNIX epoch after which the entry expires [number]
--path Read value from the file at a given path. [string]
--path Read value from the file at a given path [string]
Exactly one of the arguments value and path is required"
`);
Expand All @@ -611,23 +619,24 @@ describe("wrangler", () => {
Writes a single key/value pair to the given namespace.
Positionals:
key The key to write to. [string] [required]
value The value to write. [string]
key The key to write to [string] [required]
value The value to write [string]
Flags:
-c, --config Path to .toml configuration file [string]
-h, --help Show help [boolean]
-v, --version Show version number [boolean]
-c, --config Path to .toml configuration file [string]
-h, --help Show help [boolean]
-v, --version Show version number [boolean]
--legacy-env Use legacy environments [boolean]
Options:
-l, --local Run on my machine [boolean] [default: false]
--binding The binding of the namespace to write to. [string]
--namespace-id The id of the namespace to write to. [string]
--binding The binding of the namespace to write to [string]
--namespace-id The id of the namespace to write to [string]
--env Perform on a specific environment [string]
--preview Interact with a preview namespace [boolean]
--ttl Time for which the entries should be visible. [number]
--ttl Time for which the entries should be visible [number]
--expiration Time since the UNIX epoch after which the entry expires [number]
--path Read value from the file at a given path. [string]
--path Read value from the file at a given path [string]
Arguments value and path are mutually exclusive"
`);
Expand Down Expand Up @@ -940,9 +949,10 @@ describe("wrangler", () => {
key The key value to get. [string] [required]
Flags:
-c, --config Path to .toml configuration file [string]
-h, --help Show help [boolean]
-v, --version Show version number [boolean]
-c, --config Path to .toml configuration file [string]
-h, --help Show help [boolean]
-v, --version Show version number [boolean]
--legacy-env Use legacy environments [boolean]
Options:
-l, --local Run on my machine [boolean] [default: false]
Expand Down Expand Up @@ -971,9 +981,10 @@ describe("wrangler", () => {
key The key value to get. [string] [required]
Flags:
-c, --config Path to .toml configuration file [string]
-h, --help Show help [boolean]
-v, --version Show version number [boolean]
-c, --config Path to .toml configuration file [string]
-h, --help Show help [boolean]
-v, --version Show version number [boolean]
--legacy-env Use legacy environments [boolean]
Options:
-l, --local Run on my machine [boolean] [default: false]
Expand Down Expand Up @@ -1003,9 +1014,10 @@ describe("wrangler", () => {
key The key value to get. [string] [required]
Flags:
-c, --config Path to .toml configuration file [string]
-h, --help Show help [boolean]
-v, --version Show version number [boolean]
-c, --config Path to .toml configuration file [string]
-h, --help Show help [boolean]
-v, --version Show version number [boolean]
--legacy-env Use legacy environments [boolean]
Options:
-l, --local Run on my machine [boolean] [default: false]
Expand Down
Loading

0 comments on commit 9534c7f

Please sign in to comment.