wrangler 0.0.0-ea7ee45 → 0.0.0-eab9542

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/bin/wrangler.js CHANGED
@@ -6,6 +6,10 @@ const os = require("os");
6
6
  const semiver = require("semiver");
7
7
 
8
8
  const MIN_NODE_VERSION = "16.7.0";
9
+ const debug =
10
+ process.env["WRANGLER_LOG"] === "debug"
11
+ ? (...args) => console.log(...args)
12
+ : () => {};
9
13
 
10
14
  let wranglerProcess;
11
15
 
@@ -84,9 +88,8 @@ function runDelegatedWrangler() {
84
88
  } = JSON.parse(fs.readFileSync(packageJsonPath));
85
89
  const resolvedBinaryPath = path.resolve(packageJsonPath, "..", binaryPath);
86
90
 
87
- console.log(
88
- `Delegating to locally-installed version of wrangler @ v${version}`
89
- );
91
+ debug(`Delegating to locally-installed version of wrangler @ v${version}`);
92
+
90
93
  // this call to `spawn` is simpler because the delegated version will do all
91
94
  // of the other work.
92
95
  return spawn(
@@ -4871,6 +4871,7 @@ async function main() {
4871
4871
  try {
4872
4872
  await mf.startServer();
4873
4873
  await mf.startScheduler();
4874
+ process.send && process.send("ready");
4874
4875
  } catch (e) {
4875
4876
  mf.log.error(e);
4876
4877
  process.exitCode = 1;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wrangler",
3
- "version": "0.0.0-ea7ee45",
3
+ "version": "0.0.0-eab9542",
4
4
  "author": "wrangler@cloudflare.com",
5
5
  "description": "Command-line interface for all things Cloudflare Workers",
6
6
  "bin": {
@@ -0,0 +1,38 @@
1
+ import { getConfigCache, saveToConfigCache } from "../config-cache";
2
+ import { mockConsoleMethods } from "./helpers/mock-console";
3
+ import { runInTempDir } from "./helpers/run-in-tmp";
4
+
5
+ interface PagesConfigCache {
6
+ account_id: string;
7
+ pages_project_name: string;
8
+ }
9
+
10
+ describe("config cache", () => {
11
+ runInTempDir();
12
+ mockConsoleMethods();
13
+ // In this set of tests, we don't create a node_modules folder
14
+ const pagesConfigCacheFilename = "pages-config-cache.json";
15
+
16
+ it("should return an empty config if no file exists", () => {
17
+ expect(
18
+ getConfigCache<PagesConfigCache>(pagesConfigCacheFilename)
19
+ ).toMatchInlineSnapshot(`Object {}`);
20
+ });
21
+
22
+ it("should ignore attempts to cache values ", () => {
23
+ saveToConfigCache<PagesConfigCache>(pagesConfigCacheFilename, {
24
+ account_id: "some-account-id",
25
+ pages_project_name: "foo",
26
+ });
27
+ expect(getConfigCache<PagesConfigCache>(pagesConfigCacheFilename)).toEqual(
28
+ {}
29
+ );
30
+
31
+ saveToConfigCache<PagesConfigCache>(pagesConfigCacheFilename, {
32
+ pages_project_name: "bar",
33
+ });
34
+ expect(getConfigCache<PagesConfigCache>(pagesConfigCacheFilename)).toEqual(
35
+ {}
36
+ );
37
+ });
38
+ });
@@ -1,4 +1,6 @@
1
+ import { mkdirSync } from "node:fs";
1
2
  import { getConfigCache, saveToConfigCache } from "../config-cache";
3
+ import { mockConsoleMethods } from "./helpers/mock-console";
2
4
  import { runInTempDir } from "./helpers/run-in-tmp";
3
5
 
4
6
  interface PagesConfigCache {
@@ -8,6 +10,10 @@ interface PagesConfigCache {
8
10
 
9
11
  describe("config cache", () => {
10
12
  runInTempDir();
13
+ mockConsoleMethods();
14
+ beforeEach(() => {
15
+ mkdirSync("node_modules");
16
+ });
11
17
 
12
18
  const pagesConfigCacheFilename = "pages-config-cache.json";
13
19
 
@@ -16,6 +16,7 @@ describe("normalizeAndValidateConfig()", () => {
16
16
 
17
17
  expect(config).toEqual({
18
18
  account_id: undefined,
19
+ assets: undefined,
19
20
  build: {
20
21
  command: undefined,
21
22
  cwd: undefined,
@@ -55,6 +56,7 @@ describe("normalizeAndValidateConfig()", () => {
55
56
  unsafe: {
56
57
  bindings: [],
57
58
  },
59
+ worker_namespaces: [],
58
60
  usage_model: undefined,
59
61
  vars: {},
60
62
  define: {},
@@ -62,6 +64,7 @@ describe("normalizeAndValidateConfig()", () => {
62
64
  data_blobs: undefined,
63
65
  workers_dev: undefined,
64
66
  zone_id: undefined,
67
+ no_bundle: undefined,
65
68
  minify: undefined,
66
69
  node_compat: undefined,
67
70
  });
@@ -848,6 +851,7 @@ describe("normalizeAndValidateConfig()", () => {
848
851
  },
849
852
  ],
850
853
  },
854
+ no_bundle: true,
851
855
  minify: true,
852
856
  node_compat: true,
853
857
  };
@@ -920,6 +924,7 @@ describe("normalizeAndValidateConfig()", () => {
920
924
  define: {
921
925
  DEF1: 1777,
922
926
  },
927
+ no_bundle: "INVALID",
923
928
  minify: "INVALID",
924
929
  node_compat: "INVALID",
925
930
  } as unknown as RawEnvironment;
@@ -986,6 +991,7 @@ describe("normalizeAndValidateConfig()", () => {
986
991
  - Expected \\"main\\" to be of type string but got 1333.
987
992
  - Expected \\"usage_model\\" field to be one of [\\"bundled\\",\\"unbound\\"] but got \\"INVALID\\".
988
993
  - The field \\"define.DEF1\\" should be a string but got 1777.
994
+ - Expected \\"no_bundle\\" to be of type boolean but got \\"INVALID\\".
989
995
  - Expected \\"minify\\" to be of type boolean but got \\"INVALID\\".
990
996
  - Expected \\"node_compat\\" to be of type boolean but got \\"INVALID\\"."
991
997
  `);
@@ -1835,6 +1841,112 @@ describe("normalizeAndValidateConfig()", () => {
1835
1841
  });
1836
1842
  });
1837
1843
 
1844
+ describe("[worker_namespaces]", () => {
1845
+ it("should log an experimental warning when worker_namespaces is used", () => {
1846
+ const { config, diagnostics } = normalizeAndValidateConfig(
1847
+ {
1848
+ worker_namespaces: [
1849
+ {
1850
+ binding: "BINDING_1",
1851
+ namespace: "NAMESPACE_1",
1852
+ },
1853
+ ],
1854
+ } as unknown as RawConfig,
1855
+ undefined,
1856
+ { env: undefined }
1857
+ );
1858
+ expect(config).toEqual(
1859
+ expect.not.objectContaining({ worker_namespaces: expect.anything })
1860
+ );
1861
+ expect(diagnostics.hasWarnings()).toBe(true);
1862
+ expect(diagnostics.hasErrors()).toBe(false);
1863
+ expect(diagnostics.renderWarnings()).toMatchInlineSnapshot(`
1864
+ "Processing wrangler configuration:
1865
+ - \\"worker_namespaces\\" fields are experimental and may change or break at any time."
1866
+ `);
1867
+ });
1868
+
1869
+ it("should error if worker_namespaces is not an array", () => {
1870
+ const { config, diagnostics } = normalizeAndValidateConfig(
1871
+ {
1872
+ worker_namespaces: "just a string",
1873
+ } as unknown as RawConfig,
1874
+ undefined,
1875
+ { env: undefined }
1876
+ );
1877
+
1878
+ expect(config).toEqual(
1879
+ expect.not.objectContaining({ worker_namespaces: expect.anything })
1880
+ );
1881
+ expect(diagnostics.hasWarnings()).toBe(true);
1882
+ expect(diagnostics.hasErrors()).toBe(true);
1883
+ expect(diagnostics.renderWarnings()).toMatchInlineSnapshot(`
1884
+ "Processing wrangler configuration:
1885
+ - \\"worker_namespaces\\" fields are experimental and may change or break at any time."
1886
+ `);
1887
+ expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
1888
+ "Processing wrangler configuration:
1889
+ - The field \\"worker_namespaces\\" should be an array but got \\"just a string\\"."
1890
+ `);
1891
+ });
1892
+
1893
+ it("should error on non valid worker_namespaces", () => {
1894
+ const { config, diagnostics } = normalizeAndValidateConfig(
1895
+ {
1896
+ worker_namespaces: [
1897
+ "a string",
1898
+ 123,
1899
+ {
1900
+ binding: 123,
1901
+ namespace: 456,
1902
+ },
1903
+ {
1904
+ binding: "WORKER_NAMESPACE_BINDING_1",
1905
+ namespace: 456,
1906
+ },
1907
+ // this one is valid
1908
+ {
1909
+ binding: "WORKER_NAMESPACE_BINDING_1",
1910
+ namespace: "WORKER_NAMESPACE_BINDING_NAMESPACE_1",
1911
+ },
1912
+ {
1913
+ binding: 123,
1914
+ namespace: "WORKER_NAMESPACE_BINDING_SERVICE_1",
1915
+ },
1916
+ {
1917
+ binding: 123,
1918
+ service: 456,
1919
+ },
1920
+ ],
1921
+ } as unknown as RawConfig,
1922
+ undefined,
1923
+ { env: undefined }
1924
+ );
1925
+ expect(config).toEqual(
1926
+ expect.not.objectContaining({
1927
+ worker_namespaces: expect.anything,
1928
+ })
1929
+ );
1930
+ expect(diagnostics.hasWarnings()).toBe(true);
1931
+ expect(diagnostics.hasErrors()).toBe(true);
1932
+ expect(diagnostics.renderWarnings()).toMatchInlineSnapshot(`
1933
+ "Processing wrangler configuration:
1934
+ - \\"worker_namespaces\\" fields are experimental and may change or break at any time."
1935
+ `);
1936
+ expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
1937
+ "Processing wrangler configuration:
1938
+ - \\"worker_namespaces[0]\\" binding should be objects, but got \\"a string\\"
1939
+ - \\"worker_namespaces[1]\\" binding should be objects, but got 123
1940
+ - \\"worker_namespaces[2]\\" should have a string \\"binding\\" field but got {\\"binding\\":123,\\"namespace\\":456}.
1941
+ - \\"worker_namespaces[2]\\" should have a string \\"namespace\\" field but got {\\"binding\\":123,\\"namespace\\":456}.
1942
+ - \\"worker_namespaces[3]\\" should have a string \\"namespace\\" field but got {\\"binding\\":\\"WORKER_NAMESPACE_BINDING_1\\",\\"namespace\\":456}.
1943
+ - \\"worker_namespaces[5]\\" should have a string \\"binding\\" field but got {\\"binding\\":123,\\"namespace\\":\\"WORKER_NAMESPACE_BINDING_SERVICE_1\\"}.
1944
+ - \\"worker_namespaces[6]\\" should have a string \\"binding\\" field but got {\\"binding\\":123,\\"service\\":456}.
1945
+ - \\"worker_namespaces[6]\\" should have a string \\"namespace\\" field but got {\\"binding\\":123,\\"service\\":456}."
1946
+ `);
1947
+ });
1948
+ });
1949
+
1838
1950
  describe("[unsafe.bindings]", () => {
1839
1951
  it("should error if unsafe is an array", () => {
1840
1952
  const { config, diagnostics } = normalizeAndValidateConfig(
@@ -2192,6 +2304,7 @@ describe("normalizeAndValidateConfig()", () => {
2192
2304
  cwd: "CWD",
2193
2305
  watch_dir: "WATCH_DIR",
2194
2306
  },
2307
+ no_bundle: true,
2195
2308
  minify: true,
2196
2309
  node_compat: true,
2197
2310
  };
@@ -2234,6 +2347,7 @@ describe("normalizeAndValidateConfig()", () => {
2234
2347
  cwd: "ENV_CWD",
2235
2348
  watch_dir: "ENV_WATCH_DIR",
2236
2349
  },
2350
+ no_bundle: false,
2237
2351
  minify: false,
2238
2352
  node_compat: false,
2239
2353
  };
@@ -2255,6 +2369,7 @@ describe("normalizeAndValidateConfig()", () => {
2255
2369
  cwd: "CWD",
2256
2370
  watch_dir: "WATCH_DIR",
2257
2371
  },
2372
+ no_bundle: true,
2258
2373
  minify: true,
2259
2374
  node_compat: true,
2260
2375
  env: {
@@ -2515,6 +2630,7 @@ describe("normalizeAndValidateConfig()", () => {
2515
2630
  cwd: 1555,
2516
2631
  watch_dir: 1666,
2517
2632
  },
2633
+ no_bundle: "INVALID",
2518
2634
  minify: "INVALID",
2519
2635
  node_compat: "INVALID",
2520
2636
  } as unknown as RawEnvironment;
@@ -2550,6 +2666,7 @@ describe("normalizeAndValidateConfig()", () => {
2550
2666
  - Expected \\"name\\" to be of type string, alphanumeric and lowercase with dashes only but got 111.
2551
2667
  - Expected \\"main\\" to be of type string but got 1333.
2552
2668
  - Expected \\"usage_model\\" field to be one of [\\"bundled\\",\\"unbound\\"] but got \\"INVALID\\".
2669
+ - Expected \\"no_bundle\\" to be of type boolean but got \\"INVALID\\".
2553
2670
  - Expected \\"minify\\" to be of type boolean but got \\"INVALID\\".
2554
2671
  - Expected \\"node_compat\\" to be of type boolean but got \\"INVALID\\"."
2555
2672
  `);
@@ -889,7 +889,7 @@ describe("wrangler dev", () => {
889
889
 
890
890
  Options:
891
891
  --name Name of the worker [string]
892
- --no-build Skip internal build steps and directly publish script [boolean] [default: false]
892
+ --no-bundle Skip internal build steps and directly publish script [boolean] [default: false]
893
893
  --format Choose an entry type [deprecated] [choices: \\"modules\\", \\"service-worker\\"]
894
894
  -e, --env Perform on a specific environment [string]
895
895
  --compatibility-date Date to use for compatibility checks [string]
@@ -5303,6 +5303,48 @@ addEventListener('fetch', event => {});`
5303
5303
  });
5304
5304
  });
5305
5305
 
5306
+ describe("[worker_namespaces]", () => {
5307
+ it("should support bindings to a worker namespace", async () => {
5308
+ writeWranglerToml({
5309
+ worker_namespaces: [
5310
+ {
5311
+ binding: "foo",
5312
+ namespace: "Foo",
5313
+ },
5314
+ ],
5315
+ });
5316
+ writeWorkerSource();
5317
+ mockSubDomainRequest();
5318
+ mockUploadWorkerRequest({
5319
+ expectedBindings: [
5320
+ {
5321
+ type: "namespace",
5322
+ name: "foo",
5323
+ namespace: "Foo",
5324
+ },
5325
+ ],
5326
+ });
5327
+ await runWrangler("publish index.js");
5328
+ expect(std.out).toMatchInlineSnapshot(`
5329
+ "Your worker has access to the following bindings:
5330
+ - Worker Namespaces:
5331
+ - foo: Foo
5332
+ Total Upload: 0xx KiB / gzip: 0xx KiB
5333
+ Uploaded test-name (TIMINGS)
5334
+ Published test-name (TIMINGS)
5335
+ test-name.test-sub-domain.workers.dev"
5336
+ `);
5337
+ expect(std.err).toMatchInlineSnapshot(`""`);
5338
+ expect(std.warn).toMatchInlineSnapshot(`
5339
+ "▲ [WARNING] Processing wrangler.toml configuration:
5340
+
5341
+ - \\"worker_namespaces\\" fields are experimental and may change or break at any time.
5342
+
5343
+ "
5344
+ `);
5345
+ });
5346
+ });
5347
+
5306
5348
  describe("[unsafe]", () => {
5307
5349
  it("should warn if using unsafe bindings", async () => {
5308
5350
  writeWranglerToml({
@@ -5962,6 +6004,7 @@ addEventListener('fetch', event => {});`
5962
6004
  }
5963
6005
  `);
5964
6006
  });
6007
+
5965
6008
  it("should print the bundle size, with API errors", async () => {
5966
6009
  setMockRawResponse(
5967
6010
  "/accounts/:accountId/workers/scripts/:scriptName",
@@ -6025,15 +6068,28 @@ addEventListener('fetch', event => {});`
6025
6068
  });
6026
6069
  });
6027
6070
 
6028
- describe("--no-build", () => {
6029
- it("should not transform the source code before publishing it", async () => {
6071
+ describe("--no-bundle", () => {
6072
+ it("(cli) should not transform the source code before publishing it", async () => {
6030
6073
  writeWranglerToml();
6031
6074
  const scriptContent = `
6032
6075
  import X from '@cloudflare/no-such-package'; // let's add an import that doesn't exist
6033
6076
  const xyz = 123; // a statement that would otherwise be compiled out
6034
6077
  `;
6035
6078
  fs.writeFileSync("index.js", scriptContent);
6036
- await runWrangler("publish index.js --no-build --dry-run --outdir dist");
6079
+ await runWrangler("publish index.js --no-bundle --dry-run --outdir dist");
6080
+ expect(fs.readFileSync("dist/index.js", "utf-8")).toMatch(scriptContent);
6081
+ });
6082
+
6083
+ it("(config) should not transform the source code before publishing it", async () => {
6084
+ writeWranglerToml({
6085
+ no_bundle: true,
6086
+ });
6087
+ const scriptContent = `
6088
+ import X from '@cloudflare/no-such-package'; // let's add an import that doesn't exist
6089
+ const xyz = 123; // a statement that would otherwise be compiled out
6090
+ `;
6091
+ fs.writeFileSync("index.js", scriptContent);
6092
+ await runWrangler("publish index.js --dry-run --outdir dist");
6037
6093
  expect(fs.readFileSync("dist/index.js", "utf-8")).toMatch(scriptContent);
6038
6094
  });
6039
6095
  });
@@ -21,7 +21,63 @@ describe("wrangler", () => {
21
21
  });
22
22
 
23
23
  describe("pubsub", () => {
24
+ describe("help menu", () => {
25
+ it("shows usage details", async () => {
26
+ await runWrangler("pubsub --help");
27
+ expect(std).toMatchInlineSnapshot(`
28
+ Object {
29
+ "debug": "",
30
+ "err": "",
31
+ "out": "wrangler pubsub
32
+
33
+ 📮 Interact and manage Pub/Sub Brokers
34
+
35
+ Commands:
36
+ wrangler pubsub namespace Manage your Pub/Sub Namespaces
37
+ wrangler pubsub broker Interact with your Pub/Sub Brokers
38
+
39
+ Flags:
40
+ -c, --config Path to .toml configuration file [string]
41
+ -h, --help Show help [boolean]
42
+ -v, --version Show version number [boolean]
43
+
44
+ 👷🏽 'wrangler pubsub ...' commands are currently in private beta. If your account isn't authorized, commands will fail. Visit the Pub/Sub docs for more info: https://developers.cloudflare.com/pub-sub/",
45
+ "warn": "",
46
+ }
47
+ `);
48
+ });
49
+ });
50
+
24
51
  describe("namespaces", () => {
52
+ describe("help menu", () => {
53
+ it("shows usage details", async () => {
54
+ await runWrangler("pubsub namespace --help");
55
+ expect(std).toMatchInlineSnapshot(`
56
+ Object {
57
+ "debug": "",
58
+ "err": "",
59
+ "out": "wrangler pubsub namespace
60
+
61
+ Manage your Pub/Sub Namespaces
62
+
63
+ Commands:
64
+ wrangler pubsub namespace create <name> Create a new Pub/Sub Namespace
65
+ wrangler pubsub namespace list List your existing Pub/Sub Namespaces
66
+ wrangler pubsub namespace delete <name> Delete a Pub/Sub Namespace
67
+ wrangler pubsub namespace describe <name> Describe a Pub/Sub Namespace
68
+
69
+ Flags:
70
+ -c, --config Path to .toml configuration file [string]
71
+ -h, --help Show help [boolean]
72
+ -v, --version Show version number [boolean]
73
+
74
+ 👷🏽 'wrangler pubsub ...' commands are currently in private beta. If your account isn't authorized, commands will fail. Visit the Pub/Sub docs for more info: https://developers.cloudflare.com/pub-sub/",
75
+ "warn": "",
76
+ }
77
+ `);
78
+ });
79
+ });
80
+
25
81
  describe("create", () => {
26
82
  function mockCreateRequest(expectedNamespaceName: string) {
27
83
  const requests = { count: 0 };
@@ -77,6 +133,41 @@ describe("wrangler", () => {
77
133
  });
78
134
 
79
135
  describe("brokers", () => {
136
+ describe("help menu", () => {
137
+ it("shows usage details", async () => {
138
+ await runWrangler("pubsub broker --help");
139
+ expect(std).toMatchInlineSnapshot(`
140
+ Object {
141
+ "debug": "",
142
+ "err": "",
143
+ "out": "wrangler pubsub broker
144
+
145
+ Interact with your Pub/Sub Brokers
146
+
147
+ Commands:
148
+ wrangler pubsub broker create <name> Create a new Pub/Sub Broker
149
+ wrangler pubsub broker update <name> Update an existing Pub/Sub Broker's configuration.
150
+ wrangler pubsub broker list List the Pub/Sub Brokers within a Namespace
151
+ wrangler pubsub broker delete <name> Delete an existing Pub/Sub Broker
152
+ wrangler pubsub broker describe <name> Describe an existing Pub/Sub Broker.
153
+ wrangler pubsub broker issue <name> Issue new client credentials for a specific Pub/Sub Broker.
154
+ wrangler pubsub broker revoke <name> Revoke a set of active client credentials associated with the given Broker
155
+ wrangler pubsub broker unrevoke <name> Restore access to a set of previously revoked client credentials.
156
+ wrangler pubsub broker show-revocations <name> Show all previously revoked client credentials.
157
+ wrangler pubsub broker public-keys <name> Show the public keys used for verifying on-publish hooks and credentials for a Broker.
158
+
159
+ Flags:
160
+ -c, --config Path to .toml configuration file [string]
161
+ -h, --help Show help [boolean]
162
+ -v, --version Show version number [boolean]
163
+
164
+ 👷🏽 'wrangler pubsub ...' commands are currently in private beta. If your account isn't authorized, commands will fail. Visit the Pub/Sub docs for more info: https://developers.cloudflare.com/pub-sub/",
165
+ "warn": "",
166
+ }
167
+ `);
168
+ });
169
+ });
170
+
80
171
  describe("create", () => {
81
172
  function mockCreateRequest(expectedBrokerName: string) {
82
173
  const requests = { count: 0 };
package/src/api/dev.ts CHANGED
@@ -1,5 +1,8 @@
1
1
  import { startDev } from "../dev";
2
2
  import { logger } from "../logger";
3
+
4
+ import type { RequestInit, Response } from "undici";
5
+
3
6
  interface DevOptions {
4
7
  env?: string;
5
8
  ip?: string;
@@ -14,13 +17,20 @@ interface DevOptions {
14
17
  _: (string | number)[]; //yargs wants this
15
18
  $0: string; //yargs wants this
16
19
  }
17
-
20
+ /**
21
+ * unstable_dev starts a wrangler dev server, and returns a promise that resolves with utility functions to interact with it.
22
+ * @param {string} script
23
+ * @param {DevOptions} options
24
+ */
18
25
  export async function unstable_dev(script: string, options: DevOptions) {
19
26
  logger.warn(
20
27
  `unstable_dev() is experimental\nunstable_dev()'s behaviour will likely change in future releases`
21
28
  );
22
29
 
23
- return new Promise<{ stop: () => void }>((resolve) => {
30
+ return new Promise<{
31
+ stop: () => void;
32
+ fetch: (init?: RequestInit) => Promise<Response | undefined>;
33
+ }>((resolve) => {
24
34
  //lmao
25
35
  return new Promise<Awaited<ReturnType<typeof startDev>>>((ready) => {
26
36
  const devServer = startDev({
@@ -33,7 +43,10 @@ export async function unstable_dev(script: string, options: DevOptions) {
33
43
  showInteractiveDevSession: false,
34
44
  });
35
45
  }).then((devServer) => {
36
- resolve({ stop: devServer.stop });
46
+ resolve({
47
+ stop: devServer.stop,
48
+ fetch: devServer.fetch,
49
+ });
37
50
  });
38
51
  });
39
52
  }
package/src/cli.ts CHANGED
@@ -9,7 +9,7 @@ import { main } from ".";
9
9
  * The main entrypoint for the CLI.
10
10
  * main only gets called when the script is run directly, not when it's imported as a module.
11
11
  */
12
- if (require.main) {
12
+ if (typeof jest === "undefined" && require.main) {
13
13
  main(hideBin(process.argv)).catch((e) => {
14
14
  // The logging of any error that was thrown from `main()` is handled in the `yargs.fail()` handler.
15
15
  // Here we just want to ensure that the process exits with a non-zero code.
@@ -183,6 +183,12 @@ interface EnvironmentInheritable {
183
183
  upload?: DeprecatedUpload;
184
184
  };
185
185
 
186
+ /**
187
+ * Skip internal build steps and directly publish script
188
+ * @inheritable
189
+ */
190
+ no_bundle: boolean | undefined;
191
+
186
192
  /**
187
193
  * Minify the script before uploading.
188
194
  * @inheritable
@@ -191,9 +197,26 @@ interface EnvironmentInheritable {
191
197
 
192
198
  /**
193
199
  * Add polyfills for node builtin modules and globals
200
+ * @inheritable
194
201
  */
195
202
  node_compat: boolean | undefined;
196
203
 
204
+ /**
205
+ * Specifies namespace bindings that are bound to this Worker environment.
206
+ *
207
+ * NOTE: This field is not automatically inherited from the top level environment,
208
+ * and so must be specified in every named environment.
209
+ *
210
+ * @default `[]`
211
+ * @nonInheritable
212
+ */
213
+ worker_namespaces: {
214
+ /** The binding name used to refer to the bound service. */
215
+ binding: string;
216
+ /** The namespace to bind to. */
217
+ namespace: string;
218
+ }[];
219
+
197
220
  /**
198
221
  * TODO: remove this as it has been deprecated.
199
222
  *
@@ -90,6 +90,7 @@ export function printBindings(bindings: CfWorkerInit["bindings"]) {
90
90
  unsafe,
91
91
  vars,
92
92
  wasm_modules,
93
+ worker_namespaces,
93
94
  } = bindings;
94
95
 
95
96
  if (data_blobs !== undefined && Object.keys(data_blobs).length > 0) {
@@ -205,6 +206,18 @@ export function printBindings(bindings: CfWorkerInit["bindings"]) {
205
206
  });
206
207
  }
207
208
 
209
+ if (worker_namespaces !== undefined && worker_namespaces.length > 0) {
210
+ output.push({
211
+ type: "Worker Namespaces",
212
+ entries: worker_namespaces.map(({ binding, namespace }) => {
213
+ return {
214
+ key: binding,
215
+ value: namespace,
216
+ };
217
+ }),
218
+ });
219
+ }
220
+
208
221
  if (output.length === 0) {
209
222
  return;
210
223
  }