wrangler 2.0.12 → 2.0.16
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/README.md +7 -1
- package/bin/wrangler.js +111 -57
- package/miniflare-dist/index.mjs +9 -2
- package/package.json +156 -154
- package/src/__tests__/config-cache-without-cache-dir.test.ts +38 -0
- package/src/__tests__/config-cache.test.ts +30 -24
- package/src/__tests__/configuration.test.ts +3935 -3476
- package/src/__tests__/dev.test.tsx +1128 -979
- package/src/__tests__/guess-worker-format.test.ts +68 -68
- package/src/__tests__/helpers/cmd-shim.d.ts +6 -6
- package/src/__tests__/helpers/faye-websocket.d.ts +4 -4
- package/src/__tests__/helpers/mock-account-id.ts +24 -24
- package/src/__tests__/helpers/mock-bin.ts +20 -20
- package/src/__tests__/helpers/mock-cfetch.ts +92 -92
- package/src/__tests__/helpers/mock-console.ts +49 -39
- package/src/__tests__/helpers/mock-dialogs.ts +94 -71
- package/src/__tests__/helpers/mock-http-server.ts +30 -30
- package/src/__tests__/helpers/mock-istty.ts +65 -18
- package/src/__tests__/helpers/mock-kv.ts +26 -26
- package/src/__tests__/helpers/mock-oauth-flow.ts +223 -228
- package/src/__tests__/helpers/mock-process.ts +39 -0
- package/src/__tests__/helpers/mock-stdin.ts +82 -77
- package/src/__tests__/helpers/mock-web-socket.ts +21 -21
- package/src/__tests__/helpers/run-in-tmp.ts +27 -27
- package/src/__tests__/helpers/run-wrangler.ts +8 -8
- package/src/__tests__/helpers/write-worker-source.ts +16 -16
- package/src/__tests__/helpers/write-wrangler-toml.ts +9 -9
- package/src/__tests__/https-options.test.ts +104 -104
- package/src/__tests__/index.test.ts +239 -234
- package/src/__tests__/init.test.ts +1605 -1250
- package/src/__tests__/jest.setup.ts +63 -33
- package/src/__tests__/kv.test.ts +1128 -1011
- package/src/__tests__/logger.test.ts +100 -74
- package/src/__tests__/package-manager.test.ts +303 -303
- package/src/__tests__/pages.test.ts +1152 -652
- package/src/__tests__/parse.test.ts +252 -252
- package/src/__tests__/publish.test.ts +6371 -5622
- package/src/__tests__/pubsub.test.ts +367 -0
- package/src/__tests__/r2.test.ts +133 -133
- package/src/__tests__/route.test.ts +18 -18
- package/src/__tests__/secret.test.ts +382 -377
- package/src/__tests__/tail.test.ts +530 -530
- package/src/__tests__/user.test.ts +123 -111
- package/src/__tests__/whoami.test.tsx +198 -117
- package/src/__tests__/worker-namespace.test.ts +327 -0
- package/src/abort.d.ts +1 -1
- package/src/api/dev.ts +49 -0
- package/src/api/index.ts +1 -0
- package/src/bundle-reporter.tsx +29 -0
- package/src/bundle.ts +157 -149
- package/src/cfetch/index.ts +80 -80
- package/src/cfetch/internal.ts +90 -83
- package/src/cli.ts +21 -7
- package/src/config/config.ts +204 -195
- package/src/config/diagnostics.ts +61 -61
- package/src/config/environment.ts +390 -357
- package/src/config/index.ts +206 -193
- package/src/config/validation-helpers.ts +366 -366
- package/src/config/validation.ts +1573 -1376
- package/src/config-cache.ts +79 -41
- package/src/create-worker-preview.ts +206 -136
- package/src/create-worker-upload-form.ts +247 -238
- package/src/dev/dev-vars.ts +13 -13
- package/src/dev/dev.tsx +329 -307
- package/src/dev/local.tsx +304 -275
- package/src/dev/remote.tsx +366 -224
- package/src/dev/use-esbuild.ts +126 -91
- package/src/dev.tsx +538 -0
- package/src/dialogs.tsx +97 -97
- package/src/durable.ts +87 -87
- package/src/entry.ts +234 -228
- package/src/environment-variables.ts +23 -23
- package/src/errors.ts +6 -6
- package/src/generate.ts +33 -0
- package/src/git-client.ts +42 -0
- package/src/https-options.ts +79 -79
- package/src/index.tsx +1775 -2763
- package/src/init.ts +549 -0
- package/src/inspect.ts +593 -593
- package/src/intl-polyfill.d.ts +123 -123
- package/src/is-interactive.ts +12 -0
- package/src/kv.ts +277 -277
- package/src/logger.ts +46 -39
- package/src/miniflare-cli/enum-keys.ts +8 -8
- package/src/miniflare-cli/index.ts +42 -31
- package/src/miniflare-cli/request-context.ts +18 -18
- package/src/module-collection.ts +212 -212
- package/src/open-in-browser.ts +4 -6
- package/src/package-manager.ts +123 -123
- package/src/pages/build.tsx +202 -0
- package/src/pages/constants.ts +7 -0
- package/src/pages/deployments.tsx +101 -0
- package/src/pages/dev.tsx +964 -0
- package/src/pages/functions/buildPlugin.ts +105 -0
- package/src/pages/functions/buildWorker.ts +151 -0
- package/{pages → src/pages}/functions/filepath-routing.test.ts +113 -113
- package/src/pages/functions/filepath-routing.ts +189 -0
- package/src/pages/functions/identifiers.ts +78 -0
- package/src/pages/functions/routes.ts +151 -0
- package/src/pages/index.tsx +84 -0
- package/src/pages/projects.tsx +157 -0
- package/src/pages/publish.tsx +335 -0
- package/src/pages/types.ts +40 -0
- package/src/pages/upload.tsx +384 -0
- package/src/pages/utils.ts +12 -0
- package/src/parse.ts +202 -138
- package/src/paths.ts +6 -6
- package/src/preview.ts +31 -0
- package/src/proxy.ts +400 -402
- package/src/publish.ts +667 -621
- package/src/pubsub/index.ts +286 -0
- package/src/pubsub/pubsub-commands.tsx +577 -0
- package/src/r2.ts +19 -19
- package/src/selfsigned.d.ts +23 -23
- package/src/sites.tsx +271 -225
- package/src/tail/filters.ts +108 -108
- package/src/tail/index.ts +217 -217
- package/src/tail/printing.ts +45 -45
- package/src/update-check.ts +11 -11
- package/src/user/choose-account.tsx +60 -0
- package/src/user/env-vars.ts +46 -0
- package/src/user/generate-auth-url.ts +33 -0
- package/src/user/generate-random-state.ts +16 -0
- package/src/user/index.ts +3 -0
- package/src/user/user.tsx +1161 -0
- package/src/whoami.tsx +61 -42
- package/src/worker-namespace.ts +190 -0
- package/src/worker.ts +110 -100
- package/src/zones.ts +39 -36
- package/templates/checked-fetch.js +17 -0
- package/templates/new-worker-scheduled.js +3 -3
- package/templates/new-worker-scheduled.ts +15 -15
- package/templates/new-worker.js +3 -3
- package/templates/new-worker.ts +15 -15
- package/templates/no-op-worker.js +10 -0
- package/templates/pages-template-plugin.ts +155 -0
- package/templates/pages-template-worker.ts +161 -0
- package/templates/static-asset-facade.js +31 -31
- package/templates/tsconfig.json +95 -95
- package/wrangler-dist/cli.js +55383 -54138
- package/pages/functions/buildPlugin.ts +0 -105
- package/pages/functions/buildWorker.ts +0 -151
- package/pages/functions/filepath-routing.ts +0 -189
- package/pages/functions/identifiers.ts +0 -78
- package/pages/functions/routes.ts +0 -156
- package/pages/functions/template-plugin.ts +0 -147
- package/pages/functions/template-worker.ts +0 -143
- package/src/pages.tsx +0 -2093
- package/src/user.tsx +0 -1214
package/README.md
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
<h1 align="center"> ⛅️ wrangler </h1>
|
|
2
|
+
<section align="center" id="shieldio-badges">
|
|
3
|
+
<a href="https://www.npmjs.com/package/wrangler"><img alt="npm" src="https://img.shields.io/npm/dw/wrangler?style=flat-square"></a>
|
|
4
|
+
<img alt="GitHub contributors" src="https://img.shields.io/github/contributors/cloudflare/wrangler2?style=flat-square">
|
|
5
|
+
<img alt="GitHub commit activity (branch)" src="https://img.shields.io/github/commit-activity/w/cloudflare/wrangler2/main?style=flat-square">
|
|
6
|
+
<a href="https://discord.gg/CloudflareDev"><img alt="Discord" src="https://img.shields.io/discord/595317990191398933?color=%23F48120&style=flat-square"></a>
|
|
7
|
+
</section>
|
|
2
8
|
|
|
3
9
|
> This package is for wrangler v2.x, released first in May 2022. If you're looking for v1.x of the `@cloudflare/wrangler` package, visit https://www.npmjs.com/package/@cloudflare/wrangler / https://github.com/cloudflare/wrangler.
|
|
4
10
|
|
package/bin/wrangler.js
CHANGED
|
@@ -9,72 +9,126 @@ const MIN_NODE_VERSION = "16.7.0";
|
|
|
9
9
|
|
|
10
10
|
let wranglerProcess;
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
12
|
+
/**
|
|
13
|
+
* Executes ../wrangler-dist/cli.js
|
|
14
|
+
*/
|
|
15
|
+
function runWrangler() {
|
|
16
|
+
if (semiver(process.versions.node, MIN_NODE_VERSION) < 0) {
|
|
17
|
+
// Note Volta and nvm are also recommended in the official docs:
|
|
18
|
+
// https://developers.cloudflare.com/workers/get-started/guide#2-install-the-workers-cli
|
|
19
|
+
console.error(
|
|
20
|
+
`Wrangler requires at least Node.js v${MIN_NODE_VERSION}. You are using v${process.versions.node}.
|
|
18
21
|
You should use the latest Node.js version if possible, as Cloudflare Workers use a very up-to-date version of V8.
|
|
19
22
|
Consider using a Node.js version manager such as https://volta.sh/ or https://github.com/nvm-sh/nvm.`
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
23
|
+
);
|
|
24
|
+
process.exitCode = 1;
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
let pathToCACerts = process.env.NODE_EXTRA_CA_CERTS;
|
|
29
|
+
if (pathToCACerts) {
|
|
30
|
+
// TODO:
|
|
31
|
+
// - should we log a warning here?
|
|
32
|
+
// - maybe we can generate a certificate that concatenates with ours?
|
|
33
|
+
//
|
|
34
|
+
// I do think it'll be rare that someone wants to add a cert AND
|
|
35
|
+
// use cloudflare WARP, but let's wait till the situation actually
|
|
36
|
+
// arises before we do anything about it
|
|
37
|
+
} else {
|
|
38
|
+
const osTempDir = os.tmpdir();
|
|
39
|
+
const certDir = path.join(osTempDir, "wrangler-cert");
|
|
40
|
+
const certPath = path.join(certDir, "Cloudflare_CA.pem");
|
|
41
|
+
// copy cert to the system temp dir if needed
|
|
42
|
+
if (!fs.existsSync(certPath)) {
|
|
43
|
+
fs.mkdirSync(certDir, { recursive: true });
|
|
44
|
+
fs.writeFileSync(
|
|
45
|
+
certPath,
|
|
46
|
+
fs.readFileSync(path.join(__dirname, "../Cloudflare_CA.pem"), "utf-8")
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
pathToCACerts = certPath;
|
|
50
|
+
}
|
|
24
51
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}
|
|
46
|
-
pathToCACerts = certPath;
|
|
47
|
-
}
|
|
52
|
+
return spawn(
|
|
53
|
+
process.execPath,
|
|
54
|
+
[
|
|
55
|
+
"--no-warnings",
|
|
56
|
+
"--experimental-vm-modules",
|
|
57
|
+
...process.execArgv,
|
|
58
|
+
path.join(__dirname, "../wrangler-dist/cli.js"),
|
|
59
|
+
...process.argv.slice(2),
|
|
60
|
+
],
|
|
61
|
+
{
|
|
62
|
+
stdio: "inherit",
|
|
63
|
+
env: {
|
|
64
|
+
...process.env,
|
|
65
|
+
NODE_EXTRA_CA_CERTS: pathToCACerts,
|
|
66
|
+
},
|
|
67
|
+
}
|
|
68
|
+
).on("exit", (code) =>
|
|
69
|
+
process.exit(code === undefined || code === null ? 0 : code)
|
|
70
|
+
);
|
|
71
|
+
}
|
|
48
72
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
73
|
+
/**
|
|
74
|
+
* Runs a locally-installed version of wrangler, delegating from this version.
|
|
75
|
+
* @throws {MODULE_NOT_FOUND} if there isn't a locally installed version of wrangler.
|
|
76
|
+
*/
|
|
77
|
+
function runDelegatedWrangler() {
|
|
78
|
+
const packageJsonPath = require.resolve("wrangler/package.json", {
|
|
79
|
+
paths: [process.cwd()],
|
|
80
|
+
});
|
|
81
|
+
const {
|
|
82
|
+
bin: { wrangler: binaryPath },
|
|
83
|
+
version,
|
|
84
|
+
} = JSON.parse(fs.readFileSync(packageJsonPath));
|
|
85
|
+
const resolvedBinaryPath = path.resolve(packageJsonPath, "..", binaryPath);
|
|
86
|
+
|
|
87
|
+
console.log(
|
|
88
|
+
`Delegating to locally-installed version of wrangler @ v${version}`
|
|
89
|
+
);
|
|
90
|
+
// this call to `spawn` is simpler because the delegated version will do all
|
|
91
|
+
// of the other work.
|
|
92
|
+
return spawn(
|
|
93
|
+
process.execPath,
|
|
94
|
+
[resolvedBinaryPath, ...process.argv.slice(2)],
|
|
95
|
+
{
|
|
96
|
+
stdio: "inherit",
|
|
97
|
+
}
|
|
98
|
+
).on("exit", (code) =>
|
|
99
|
+
process.exit(code === undefined || code === null ? 0 : code)
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Indicates if this invocation of `wrangler` should delegate
|
|
105
|
+
* to a locally-installed version.
|
|
106
|
+
*/
|
|
107
|
+
function shouldDelegate() {
|
|
108
|
+
try {
|
|
109
|
+
// `require.resolve` will throw if it can't find
|
|
110
|
+
// a locally-installed version of `wrangler`
|
|
111
|
+
const delegatedPackageJson = require.resolve("wrangler/package.json", {
|
|
112
|
+
paths: [process.cwd()],
|
|
113
|
+
});
|
|
114
|
+
const thisPackageJson = path.resolve(__dirname, "..", "package.json");
|
|
115
|
+
// if it's the same path, then we're already a local install -- no need to delegate
|
|
116
|
+
return thisPackageJson !== delegatedPackageJson;
|
|
117
|
+
} catch (e) {
|
|
118
|
+
// there's no local version to delegate to -- `require.resolve` threw
|
|
119
|
+
return false;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
async function main() {
|
|
124
|
+
wranglerProcess = shouldDelegate() ? runDelegatedWrangler() : runWrangler();
|
|
71
125
|
}
|
|
72
126
|
|
|
73
127
|
process.on("SIGINT", () => {
|
|
74
|
-
|
|
128
|
+
wranglerProcess?.kill();
|
|
75
129
|
});
|
|
76
130
|
process.on("SIGTERM", () => {
|
|
77
|
-
|
|
131
|
+
wranglerProcess?.kill();
|
|
78
132
|
});
|
|
79
133
|
|
|
80
134
|
void main();
|
package/miniflare-dist/index.mjs
CHANGED
|
@@ -4846,6 +4846,13 @@ var getRequestContextCheckOptions = async () => {
|
|
|
4846
4846
|
};
|
|
4847
4847
|
|
|
4848
4848
|
// src/miniflare-cli/index.ts
|
|
4849
|
+
var NoOpLog = class extends Log {
|
|
4850
|
+
log() {
|
|
4851
|
+
}
|
|
4852
|
+
error(message) {
|
|
4853
|
+
throw message;
|
|
4854
|
+
}
|
|
4855
|
+
};
|
|
4849
4856
|
async function main() {
|
|
4850
4857
|
const args = await yargs_default(hideBin(process.argv)).help(false).version(false).option("log", {
|
|
4851
4858
|
choices: enumKeys(LogLevel)
|
|
@@ -4854,9 +4861,9 @@ async function main() {
|
|
|
4854
4861
|
const requestContextCheckOptions = await getRequestContextCheckOptions();
|
|
4855
4862
|
const config = {
|
|
4856
4863
|
...JSON.parse(args._[0] ?? "{}"),
|
|
4857
|
-
...requestContextCheckOptions
|
|
4858
|
-
log: new Log(logLevel)
|
|
4864
|
+
...requestContextCheckOptions
|
|
4859
4865
|
};
|
|
4866
|
+
config.log = config.disableLogs ? new NoOpLog() : new Log(logLevel);
|
|
4860
4867
|
if (logLevel > LogLevel.INFO) {
|
|
4861
4868
|
console.log("OPTIONS:\n", JSON.stringify(config, null, 2));
|
|
4862
4869
|
}
|
package/package.json
CHANGED
|
@@ -1,156 +1,158 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
2
|
+
"name": "wrangler",
|
|
3
|
+
"version": "2.0.16",
|
|
4
|
+
"author": "wrangler@cloudflare.com",
|
|
5
|
+
"description": "Command-line interface for all things Cloudflare Workers",
|
|
6
|
+
"bin": {
|
|
7
|
+
"wrangler": "./bin/wrangler.js",
|
|
8
|
+
"wrangler2": "./bin/wrangler.js"
|
|
9
|
+
},
|
|
10
|
+
"main": "wrangler-dist/cli.js",
|
|
11
|
+
"license": "MIT OR Apache-2.0",
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/cloudflare/wrangler2/issues"
|
|
14
|
+
},
|
|
15
|
+
"homepage": "https://github.com/cloudflare/wrangler2#readme",
|
|
16
|
+
"keywords": [
|
|
17
|
+
"wrangler",
|
|
18
|
+
"cloudflare",
|
|
19
|
+
"workers",
|
|
20
|
+
"cloudflare workers",
|
|
21
|
+
"edge",
|
|
22
|
+
"compute",
|
|
23
|
+
"serverless",
|
|
24
|
+
"serverless application",
|
|
25
|
+
"serverless module",
|
|
26
|
+
"wasm",
|
|
27
|
+
"web",
|
|
28
|
+
"assembly",
|
|
29
|
+
"webassembly",
|
|
30
|
+
"rust",
|
|
31
|
+
"emscripten",
|
|
32
|
+
"rust",
|
|
33
|
+
"typescript",
|
|
34
|
+
"graphql",
|
|
35
|
+
"router",
|
|
36
|
+
"http",
|
|
37
|
+
"cli"
|
|
38
|
+
],
|
|
39
|
+
"dependencies": {
|
|
40
|
+
"@cloudflare/kv-asset-handler": "^0.2.0",
|
|
41
|
+
"@esbuild-plugins/node-globals-polyfill": "^0.1.1",
|
|
42
|
+
"@esbuild-plugins/node-modules-polyfill": "^0.1.4",
|
|
43
|
+
"blake3-wasm": "^2.1.5",
|
|
44
|
+
"esbuild": "0.14.47",
|
|
45
|
+
"miniflare": "^2.5.1",
|
|
46
|
+
"nanoid": "^3.3.3",
|
|
47
|
+
"path-to-regexp": "^6.2.0",
|
|
48
|
+
"selfsigned": "^2.0.1",
|
|
49
|
+
"semiver": "^1.1.0",
|
|
50
|
+
"xxhash-wasm": "^1.0.1"
|
|
51
|
+
},
|
|
52
|
+
"optionalDependencies": {
|
|
53
|
+
"fsevents": "~2.3.2"
|
|
54
|
+
},
|
|
55
|
+
"devDependencies": {
|
|
56
|
+
"@iarna/toml": "^3.0.0",
|
|
57
|
+
"@types/command-exists": "^1.2.0",
|
|
58
|
+
"@types/glob-to-regexp": "0.4.1",
|
|
59
|
+
"@types/mime": "^2.0.3",
|
|
60
|
+
"@types/prompts": "^2.0.14",
|
|
61
|
+
"@types/react": "^17.0.37",
|
|
62
|
+
"@types/serve-static": "^1.13.10",
|
|
63
|
+
"@types/signal-exit": "^3.0.1",
|
|
64
|
+
"@types/supports-color": "^8.1.1",
|
|
65
|
+
"@types/ws": "^8.5.3",
|
|
66
|
+
"@types/yargs": "^17.0.10",
|
|
67
|
+
"@webcontainer/env": "^1.0.1",
|
|
68
|
+
"chokidar": "^3.5.3",
|
|
69
|
+
"clipboardy": "^3.0.0",
|
|
70
|
+
"cmd-shim": "^4.1.0",
|
|
71
|
+
"command-exists": "^1.2.9",
|
|
72
|
+
"concurrently": "^7.2.2",
|
|
73
|
+
"devtools-protocol": "^0.0.955664",
|
|
74
|
+
"dotenv": "^16.0.0",
|
|
75
|
+
"execa": "^6.1.0",
|
|
76
|
+
"faye-websocket": "^0.11.4",
|
|
77
|
+
"finalhandler": "^1.2.0",
|
|
78
|
+
"find-up": "^6.3.0",
|
|
79
|
+
"get-port": "^6.1.2",
|
|
80
|
+
"glob-to-regexp": "0.4.1",
|
|
81
|
+
"http-terminator": "^3.2.0",
|
|
82
|
+
"ignore": "^5.2.0",
|
|
83
|
+
"ink": "^3.2.0",
|
|
84
|
+
"ink-select-input": "^4.2.1",
|
|
85
|
+
"ink-spinner": "^4.0.3",
|
|
86
|
+
"ink-table": "^3.0.0",
|
|
87
|
+
"ink-testing-library": "^2.1.0",
|
|
88
|
+
"ink-text-input": "^4.0.3",
|
|
89
|
+
"jest-fetch-mock": "^3.0.3",
|
|
90
|
+
"jest-websocket-mock": "^2.3.0",
|
|
91
|
+
"mime": "^3.0.0",
|
|
92
|
+
"open": "^8.4.0",
|
|
93
|
+
"p-queue": "^7.2.0",
|
|
94
|
+
"pretty-bytes": "^6.0.0",
|
|
95
|
+
"prompts": "^2.4.2",
|
|
96
|
+
"react": "^17.0.2",
|
|
97
|
+
"react-error-boundary": "^3.1.4",
|
|
98
|
+
"serve-static": "^1.15.0",
|
|
99
|
+
"signal-exit": "^3.0.7",
|
|
100
|
+
"supports-color": "^9.2.2",
|
|
101
|
+
"timeago.js": "^4.0.2",
|
|
102
|
+
"tmp-promise": "^3.0.3",
|
|
103
|
+
"ts-dedent": "^2.2.0",
|
|
104
|
+
"undici": "^5.5.1",
|
|
105
|
+
"update-check": "^1.5.4",
|
|
106
|
+
"ws": "^8.5.0",
|
|
107
|
+
"yargs": "^17.4.1"
|
|
108
|
+
},
|
|
109
|
+
"files": [
|
|
110
|
+
"src",
|
|
111
|
+
"bin",
|
|
112
|
+
"miniflare-config-stubs",
|
|
113
|
+
"miniflare-dist",
|
|
114
|
+
"wrangler-dist",
|
|
115
|
+
"templates",
|
|
116
|
+
"vendor",
|
|
117
|
+
"import_meta_url.js",
|
|
118
|
+
"kv-asset-handler.js",
|
|
119
|
+
"Cloudflare_CA.pem"
|
|
120
|
+
],
|
|
121
|
+
"scripts": {
|
|
122
|
+
"clean": "rm -rf wrangler-dist miniflare-dist",
|
|
123
|
+
"check:type": "tsc",
|
|
124
|
+
"bundle": "node -r esbuild-register scripts/bundle.ts",
|
|
125
|
+
"build": "npm run clean && npm run bundle",
|
|
126
|
+
"dev": "npm run clean && concurrently -c black,blue 'npm run bundle -- --watch' 'npm run check:type -- --watch --preserveWatchOutput'",
|
|
127
|
+
"prepublishOnly": "SOURCEMAPS=false npm run build",
|
|
128
|
+
"start": "npm run bundle && NODE_OPTIONS=--enable-source-maps ./bin/wrangler.js",
|
|
129
|
+
"test": "jest --silent=false --verbose=true",
|
|
130
|
+
"test-watch": "npm run test -- --runInBand --testTimeout=50000 --watch"
|
|
131
|
+
},
|
|
132
|
+
"engines": {
|
|
133
|
+
"node": ">=16.7.0"
|
|
134
|
+
},
|
|
135
|
+
"jest": {
|
|
136
|
+
"restoreMocks": true,
|
|
137
|
+
"testTimeout": 30000,
|
|
138
|
+
"testRegex": ".*.(test|spec)\\.[jt]sx?$",
|
|
139
|
+
"transformIgnorePatterns": [
|
|
140
|
+
"node_modules/(?!find-up|locate-path|p-locate|p-limit|p-timeout|p-queue|yocto-queue|path-exists|execa|strip-final-newline|npm-run-path|path-key|onetime|mimic-fn|human-signals|is-stream|get-port|supports-color|pretty-bytes)"
|
|
141
|
+
],
|
|
142
|
+
"moduleNameMapper": {
|
|
143
|
+
"clipboardy": "<rootDir>/src/__tests__/helpers/clipboardy-mock.js",
|
|
144
|
+
"miniflare/cli": "<rootDir>/../../node_modules/miniflare/dist/src/cli.js"
|
|
145
|
+
},
|
|
146
|
+
"transform": {
|
|
147
|
+
"^.+\\.c?(t|j)sx?$": [
|
|
148
|
+
"esbuild-jest",
|
|
149
|
+
{
|
|
150
|
+
"sourcemap": true
|
|
151
|
+
}
|
|
152
|
+
]
|
|
153
|
+
},
|
|
154
|
+
"setupFilesAfterEnv": [
|
|
155
|
+
"<rootDir>/src/__tests__/jest.setup.ts"
|
|
156
|
+
]
|
|
157
|
+
}
|
|
156
158
|
}
|
|
@@ -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
|
+
});
|