create-cloudflare 0.0.0-5b0c9c948 → 0.0.0-5b3d1af95
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/dist/cli.js +192 -154
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +6 -6
- package/templates/analog/c3.ts +0 -24
- package/templates/analog/templates/env.d.ts +1 -1
- package/templates/angular/pages/c3.ts +3 -3
- package/templates/angular/pages/templates/wrangler.jsonc +5 -0
- package/templates/angular/workers/c3.ts +1 -0
- package/templates/common/ts/tsconfig.json +0 -3
- package/templates/docusaurus/pages/c3.ts +1 -0
- package/templates/docusaurus/workers/c3.ts +1 -0
- package/templates/gatsby/pages/c3.ts +1 -0
- package/templates/gatsby/workers/c3.ts +1 -0
- package/templates/hello-world/ts/test/index.spec.ts +0 -1
- package/templates/hello-world/ts/test/tsconfig.json +1 -1
- package/templates/hello-world/ts/tsconfig.json +0 -2
- package/templates/hello-world-durable-object/ts/tsconfig.json +0 -2
- package/templates/hello-world-durable-object-with-assets/ts/tsconfig.json +0 -2
- package/templates/hello-world-with-assets/c3.ts +1 -0
- package/templates/hello-world-with-assets/ts/test/tsconfig.json +1 -1
- package/templates/hello-world-with-assets/ts/tsconfig.json +0 -2
- package/templates/hono/pages/c3.ts +4 -1
- package/templates/hono/workers/c3.ts +3 -1
- package/templates/next/pages/c3.ts +6 -10
- package/templates/next/workers/c3.ts +6 -2
- package/templates/nuxt/pages/c3.ts +2 -26
- package/templates/nuxt/pages/templates/env.d.ts +1 -1
- package/templates/nuxt/workers/c3.ts +2 -26
- package/templates/nuxt/workers/templates/env.d.ts +1 -1
- package/templates/openapi/ts/tsconfig.json +0 -1
- package/templates/queues/ts/tsconfig.json +0 -2
- package/templates/qwik/pages/c3.ts +1 -0
- package/templates/qwik/workers/c3.ts +1 -0
- package/templates/react/pages/c3.ts +4 -2
- package/templates/react/pages/templates/wrangler.jsonc +5 -0
- package/templates/react/workers/ts/tsconfig.worker.json +1 -1
- package/templates/react-router/c3.ts +0 -12
- package/templates/remix/pages/c3.ts +1 -0
- package/templates/remix/pages/templates/worker-configuration.d.ts +1 -1
- package/templates/remix/workers/c3.ts +1 -0
- package/templates/scheduled/ts/tsconfig.json +0 -2
- package/templates/solid/c3.ts +1 -0
- package/templates/svelte/pages/c3.ts +3 -3
- package/templates/svelte/workers/c3.ts +3 -3
- package/templates/vue/pages/c3.ts +5 -3
- package/templates/vue/pages/templates/wrangler.jsonc +5 -0
- package/templates/vue/workers/ts/tsconfig.worker.json +1 -1
- package/templates-experimental/solid/c3.ts +1 -0
- package/templates/analog/templates/worker-configuration.d.ts +0 -4
- package/templates/astro/workers/templates/ts/worker-configuration.d.ts +0 -4
- package/templates/common/ts/worker-configuration.d.ts +0 -4
- package/templates/hello-world/ts/worker-configuration.d.ts +0 -8
- package/templates/hello-world-durable-object/ts/worker-configuration.d.ts +0 -7
- package/templates/hello-world-durable-object-with-assets/ts/worker-configuration.d.ts +0 -8
- package/templates/hello-world-with-assets/ts/worker-configuration.d.ts +0 -7
- package/templates/hono/pages/templates/worker-configuration.d.ts +0 -4
- package/templates/hono/workers/templates/worker-configuration.d.ts +0 -4
- package/templates/next/pages/env.d.ts +0 -5
- package/templates/next/workers/templates/cloudflare-env.d.ts +0 -5
- package/templates/nuxt/pages/templates/worker-configuration.d.ts +0 -4
- package/templates/nuxt/workers/templates/worker-configuration.d.ts +0 -4
- package/templates/openapi/ts/worker-configuration.d.ts +0 -4
- package/templates/queues/ts/worker-configuration.d.ts +0 -5
- package/templates/react/workers/ts/worker-configuration.d.ts +0 -5
- package/templates/react-router/templates/worker-configuration.d.ts +0 -8
- package/templates/scheduled/ts/worker-configuration.d.ts +0 -4
- package/templates/vue/workers/ts/worker-configuration.d.ts +0 -6
package/dist/cli.js
CHANGED
|
@@ -3111,8 +3111,8 @@ var require_path_key = __commonJS({
|
|
|
3111
3111
|
"use strict";
|
|
3112
3112
|
var pathKey = (options = {}) => {
|
|
3113
3113
|
const environment = options.env || process.env;
|
|
3114
|
-
const
|
|
3115
|
-
if (
|
|
3114
|
+
const platform = options.platform || process.platform;
|
|
3115
|
+
if (platform !== "win32") {
|
|
3116
3116
|
return "PATH";
|
|
3117
3117
|
}
|
|
3118
3118
|
return Object.keys(environment).reverse().find((key) => key.toUpperCase() === "PATH") || "Path";
|
|
@@ -26411,7 +26411,7 @@ var require_index_688c5d50 = __commonJS({
|
|
|
26411
26411
|
}
|
|
26412
26412
|
var origCwd = process.cwd;
|
|
26413
26413
|
var cwd = null;
|
|
26414
|
-
var
|
|
26414
|
+
var platform = process.env.GRACEFUL_FS_PLATFORM || process.platform;
|
|
26415
26415
|
process.cwd = function() {
|
|
26416
26416
|
if (!cwd)
|
|
26417
26417
|
cwd = origCwd.call(process);
|
|
@@ -26466,7 +26466,7 @@ var require_index_688c5d50 = __commonJS({
|
|
|
26466
26466
|
fs4.lchownSync = function() {
|
|
26467
26467
|
};
|
|
26468
26468
|
}
|
|
26469
|
-
if (
|
|
26469
|
+
if (platform === "win32") {
|
|
26470
26470
|
fs4.rename = /* @__PURE__ */ function(fs$rename) {
|
|
26471
26471
|
return function(from, to, cb) {
|
|
26472
26472
|
var start = Date.now();
|
|
@@ -31639,7 +31639,7 @@ var require_open = __commonJS({
|
|
|
31639
31639
|
var isDocker = require_is_docker();
|
|
31640
31640
|
var defineLazyProperty = require_define_lazy_prop();
|
|
31641
31641
|
var localXdgOpenPath = path6.join(__dirname, "xdg-open");
|
|
31642
|
-
var { platform
|
|
31642
|
+
var { platform, arch } = process;
|
|
31643
31643
|
var getWslDrivesMountPoint = /* @__PURE__ */ (() => {
|
|
31644
31644
|
const defaultMountPoint = "/mnt/";
|
|
31645
31645
|
let mountPoint;
|
|
@@ -31706,7 +31706,7 @@ var require_open = __commonJS({
|
|
|
31706
31706
|
let command2;
|
|
31707
31707
|
const cliArguments = [];
|
|
31708
31708
|
const childProcessOptions = {};
|
|
31709
|
-
if (
|
|
31709
|
+
if (platform === "darwin") {
|
|
31710
31710
|
command2 = "open";
|
|
31711
31711
|
if (options.wait) {
|
|
31712
31712
|
cliArguments.push("--wait-apps");
|
|
@@ -31720,7 +31720,7 @@ var require_open = __commonJS({
|
|
|
31720
31720
|
if (app) {
|
|
31721
31721
|
cliArguments.push("-a", app);
|
|
31722
31722
|
}
|
|
31723
|
-
} else if (
|
|
31723
|
+
} else if (platform === "win32" || isWsl && !isDocker()) {
|
|
31724
31724
|
const mountPoint = await getWslDrivesMountPoint();
|
|
31725
31725
|
command2 = isWsl ? `${mountPoint}c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe` : `${process.env.SYSTEMROOT}\\System32\\WindowsPowerShell\\v1.0\\powershell`;
|
|
31726
31726
|
cliArguments.push(
|
|
@@ -31761,7 +31761,7 @@ var require_open = __commonJS({
|
|
|
31761
31761
|
exeLocalXdgOpen = true;
|
|
31762
31762
|
} catch {
|
|
31763
31763
|
}
|
|
31764
|
-
const useSystemXdgOpen = process.versions.electron ||
|
|
31764
|
+
const useSystemXdgOpen = process.versions.electron || platform === "android" || isBundled || !exeLocalXdgOpen;
|
|
31765
31765
|
command2 = useSystemXdgOpen ? "xdg-open" : localXdgOpenPath;
|
|
31766
31766
|
}
|
|
31767
31767
|
if (appArguments.length > 0) {
|
|
@@ -31775,7 +31775,7 @@ var require_open = __commonJS({
|
|
|
31775
31775
|
if (options.target) {
|
|
31776
31776
|
cliArguments.push(options.target);
|
|
31777
31777
|
}
|
|
31778
|
-
if (
|
|
31778
|
+
if (platform === "darwin" && appArguments.length > 0) {
|
|
31779
31779
|
cliArguments.push("--args", ...appArguments);
|
|
31780
31780
|
}
|
|
31781
31781
|
const subprocess = childProcess.spawn(command2, cliArguments, childProcessOptions);
|
|
@@ -31829,12 +31829,12 @@ var require_open = __commonJS({
|
|
|
31829
31829
|
}
|
|
31830
31830
|
return archBinary;
|
|
31831
31831
|
}
|
|
31832
|
-
function detectPlatformBinary({ [
|
|
31832
|
+
function detectPlatformBinary({ [platform]: platformBinary }, { wsl }) {
|
|
31833
31833
|
if (wsl && isWsl) {
|
|
31834
31834
|
return detectArchBinary(wsl);
|
|
31835
31835
|
}
|
|
31836
31836
|
if (!platformBinary) {
|
|
31837
|
-
throw new Error(`${
|
|
31837
|
+
throw new Error(`${platform} is not supported`);
|
|
31838
31838
|
}
|
|
31839
31839
|
return detectArchBinary(platformBinary);
|
|
31840
31840
|
}
|
|
@@ -74560,7 +74560,7 @@ var Yargs = YargsFactory(esm_default);
|
|
|
74560
74560
|
var yargs_default = Yargs;
|
|
74561
74561
|
|
|
74562
74562
|
// package.json
|
|
74563
|
-
var version = "0.0.0-
|
|
74563
|
+
var version = "0.0.0-5b3d1af95";
|
|
74564
74564
|
|
|
74565
74565
|
// src/metrics.ts
|
|
74566
74566
|
var import_node_async_hooks = require("node:async_hooks");
|
|
@@ -74892,8 +74892,8 @@ function promiseWithResolvers() {
|
|
|
74892
74892
|
return { resolve: resolve12, reject, promise };
|
|
74893
74893
|
}
|
|
74894
74894
|
function getPlatform() {
|
|
74895
|
-
const
|
|
74896
|
-
switch (
|
|
74895
|
+
const platform = process.platform;
|
|
74896
|
+
switch (platform) {
|
|
74897
74897
|
case "win32":
|
|
74898
74898
|
return "Windows";
|
|
74899
74899
|
case "darwin":
|
|
@@ -74901,7 +74901,7 @@ function getPlatform() {
|
|
|
74901
74901
|
case "linux":
|
|
74902
74902
|
return "Linux";
|
|
74903
74903
|
default:
|
|
74904
|
-
return `Others: ${
|
|
74904
|
+
return `Others: ${platform}`;
|
|
74905
74905
|
}
|
|
74906
74906
|
}
|
|
74907
74907
|
function createReporter() {
|
|
@@ -74912,7 +74912,7 @@ function createReporter() {
|
|
|
74912
74912
|
const isEnabled = isTelemetryEnabled();
|
|
74913
74913
|
const deviceId = getDeviceId(config48);
|
|
74914
74914
|
const packageManager = detectPackageManager();
|
|
74915
|
-
const
|
|
74915
|
+
const platform = getPlatform();
|
|
74916
74916
|
const amplitude_session_id = Date.now();
|
|
74917
74917
|
const enableLog = process.env.CREATE_CLOUDFLARE_TELEMETRY_DEBUG === "1";
|
|
74918
74918
|
let amplitude_event_id = 0;
|
|
@@ -74928,7 +74928,7 @@ function createReporter() {
|
|
|
74928
74928
|
properties: {
|
|
74929
74929
|
amplitude_session_id,
|
|
74930
74930
|
amplitude_event_id: amplitude_event_id++,
|
|
74931
|
-
platform
|
|
74931
|
+
platform,
|
|
74932
74932
|
c3Version: version,
|
|
74933
74933
|
isFirstUsage,
|
|
74934
74934
|
packageManager: packageManager.name,
|
|
@@ -75483,10 +75483,6 @@ async function getWorkerdCompatibilityDate() {
|
|
|
75483
75483
|
);
|
|
75484
75484
|
return fallbackDate;
|
|
75485
75485
|
}
|
|
75486
|
-
var compatDateFlag = async () => {
|
|
75487
|
-
const workerdCompatDate = await getWorkerdCompatibilityDate();
|
|
75488
|
-
return `--compatibility-date=${workerdCompatDate}`;
|
|
75489
|
-
};
|
|
75490
75486
|
function getLatestTypesEntrypoint(ctx) {
|
|
75491
75487
|
const workersTypesPath = (0, import_path9.resolve)(
|
|
75492
75488
|
ctx.project.path,
|
|
@@ -75569,7 +75565,8 @@ var config = {
|
|
|
75569
75565
|
transformPackageJson: async () => ({
|
|
75570
75566
|
scripts: {
|
|
75571
75567
|
preview: `${npm} run build && npx wrangler dev`,
|
|
75572
|
-
deploy: `${npm} run build && wrangler deploy
|
|
75568
|
+
deploy: `${npm} run build && wrangler deploy`,
|
|
75569
|
+
"cf-typegen": `wrangler types`
|
|
75573
75570
|
}
|
|
75574
75571
|
}),
|
|
75575
75572
|
compatibilityFlags: ["nodejs_compat"],
|
|
@@ -75604,21 +75601,6 @@ var configure2 = async (ctx) => {
|
|
|
75604
75601
|
});
|
|
75605
75602
|
}
|
|
75606
75603
|
updateViteConfig(ctx);
|
|
75607
|
-
updateEnvTypes(ctx);
|
|
75608
|
-
};
|
|
75609
|
-
var updateEnvTypes = (ctx) => {
|
|
75610
|
-
const filepath = "env.d.ts";
|
|
75611
|
-
const s = spinner();
|
|
75612
|
-
s.start(`Updating ${filepath}`);
|
|
75613
|
-
let file = readFile(filepath);
|
|
75614
|
-
let typesEntrypoint = `@cloudflare/workers-types`;
|
|
75615
|
-
const latestEntrypoint = getLatestTypesEntrypoint(ctx);
|
|
75616
|
-
if (latestEntrypoint) {
|
|
75617
|
-
typesEntrypoint += `/${latestEntrypoint}`;
|
|
75618
|
-
}
|
|
75619
|
-
file = file.replace("WORKERS_TYPES_ENTRYPOINT", typesEntrypoint);
|
|
75620
|
-
writeFile2("env.d.ts", file);
|
|
75621
|
-
s.stop(`${brandColor(`updated`)} ${dim(`\`${filepath}\``)}`);
|
|
75622
75604
|
};
|
|
75623
75605
|
var updateViteConfig = (ctx) => {
|
|
75624
75606
|
const b3 = recast3.types.builders;
|
|
@@ -75762,10 +75744,11 @@ var config3 = {
|
|
|
75762
75744
|
configure: configure3,
|
|
75763
75745
|
transformPackageJson: async () => ({
|
|
75764
75746
|
scripts: {
|
|
75765
|
-
start: `${npm3} run build && wrangler pages dev
|
|
75747
|
+
start: `${npm3} run build && wrangler pages dev`,
|
|
75766
75748
|
build: `ng build && ${npm3} run process`,
|
|
75767
75749
|
process: "node ./tools/copy-files.mjs",
|
|
75768
|
-
deploy: `${npm3} run build && wrangler pages deploy
|
|
75750
|
+
deploy: `${npm3} run build && wrangler pages deploy`,
|
|
75751
|
+
"cf-typegen": `wrangler types`
|
|
75769
75752
|
}
|
|
75770
75753
|
})
|
|
75771
75754
|
};
|
|
@@ -75851,7 +75834,8 @@ var config4 = {
|
|
|
75851
75834
|
scripts: {
|
|
75852
75835
|
start: `${npm4} run build && wrangler dev`,
|
|
75853
75836
|
build: `ng build`,
|
|
75854
|
-
deploy: `${npm4} run build && wrangler deploy
|
|
75837
|
+
deploy: `${npm4} run build && wrangler deploy`,
|
|
75838
|
+
"cf-typegen": `wrangler types`
|
|
75855
75839
|
}
|
|
75856
75840
|
})
|
|
75857
75841
|
};
|
|
@@ -76067,7 +76051,8 @@ var config10 = {
|
|
|
76067
76051
|
}),
|
|
76068
76052
|
devScript: "preview",
|
|
76069
76053
|
deployScript: "deploy",
|
|
76070
|
-
previewScript: "preview"
|
|
76054
|
+
previewScript: "preview",
|
|
76055
|
+
workersTypes: "none"
|
|
76071
76056
|
};
|
|
76072
76057
|
var c3_default10 = config10;
|
|
76073
76058
|
|
|
@@ -76095,7 +76080,8 @@ var config11 = {
|
|
|
76095
76080
|
}),
|
|
76096
76081
|
devScript: "start",
|
|
76097
76082
|
deployScript: "deploy",
|
|
76098
|
-
previewScript: "preview"
|
|
76083
|
+
previewScript: "preview",
|
|
76084
|
+
workersTypes: "none"
|
|
76099
76085
|
};
|
|
76100
76086
|
var c3_default11 = config11;
|
|
76101
76087
|
|
|
@@ -76144,7 +76130,8 @@ var config13 = {
|
|
|
76144
76130
|
}),
|
|
76145
76131
|
devScript: "develop",
|
|
76146
76132
|
deployScript: "deploy",
|
|
76147
|
-
previewScript: "preview"
|
|
76133
|
+
previewScript: "preview",
|
|
76134
|
+
workersTypes: "none"
|
|
76148
76135
|
};
|
|
76149
76136
|
var c3_default13 = config13;
|
|
76150
76137
|
|
|
@@ -76188,7 +76175,8 @@ var config14 = {
|
|
|
76188
76175
|
}),
|
|
76189
76176
|
devScript: "develop",
|
|
76190
76177
|
deployScript: "deploy",
|
|
76191
|
-
previewScript: "preview"
|
|
76178
|
+
previewScript: "preview",
|
|
76179
|
+
workersTypes: "none"
|
|
76192
76180
|
};
|
|
76193
76181
|
var c3_default14 = config14;
|
|
76194
76182
|
|
|
@@ -76280,7 +76268,8 @@ var config19 = {
|
|
|
76280
76268
|
path: "./py"
|
|
76281
76269
|
}
|
|
76282
76270
|
}
|
|
76283
|
-
}
|
|
76271
|
+
},
|
|
76272
|
+
compatibilityFlags: ["nodejs_compat"]
|
|
76284
76273
|
};
|
|
76285
76274
|
var c3_default19 = config19;
|
|
76286
76275
|
|
|
@@ -76333,6 +76322,7 @@ var generate11 = async (ctx) => {
|
|
|
76333
76322
|
]);
|
|
76334
76323
|
logRaw("");
|
|
76335
76324
|
};
|
|
76325
|
+
var envInterfaceName = "CloudflareBindings";
|
|
76336
76326
|
var config20 = {
|
|
76337
76327
|
configVersion: 1,
|
|
76338
76328
|
id: "hono",
|
|
@@ -76347,13 +76337,14 @@ var config20 = {
|
|
|
76347
76337
|
generate: generate11,
|
|
76348
76338
|
transformPackageJson: async () => ({
|
|
76349
76339
|
scripts: {
|
|
76350
|
-
"cf-typegen":
|
|
76340
|
+
"cf-typegen": `wrangler types --env-interface ${envInterfaceName}`,
|
|
76351
76341
|
preview: "vite build && wrangler pages dev"
|
|
76352
76342
|
}
|
|
76353
76343
|
}),
|
|
76354
76344
|
devScript: "dev",
|
|
76355
76345
|
deployScript: "deploy",
|
|
76356
|
-
previewScript: "preview"
|
|
76346
|
+
previewScript: "preview",
|
|
76347
|
+
envInterfaceName
|
|
76357
76348
|
};
|
|
76358
76349
|
var c3_default21 = config20;
|
|
76359
76350
|
|
|
@@ -76370,6 +76361,7 @@ var generate12 = async (ctx) => {
|
|
|
76370
76361
|
]);
|
|
76371
76362
|
logRaw("");
|
|
76372
76363
|
};
|
|
76364
|
+
var envInterfaceName2 = "CloudflareBindings";
|
|
76373
76365
|
var config21 = {
|
|
76374
76366
|
configVersion: 1,
|
|
76375
76367
|
id: "hono",
|
|
@@ -76383,12 +76375,13 @@ var config21 = {
|
|
|
76383
76375
|
generate: generate12,
|
|
76384
76376
|
transformPackageJson: async () => ({
|
|
76385
76377
|
scripts: {
|
|
76386
|
-
"cf-typegen":
|
|
76378
|
+
"cf-typegen": `wrangler types --env-interface ${envInterfaceName2}`
|
|
76387
76379
|
}
|
|
76388
76380
|
}),
|
|
76389
76381
|
devScript: "dev",
|
|
76390
76382
|
deployScript: "deploy",
|
|
76391
|
-
previewScript: "dev"
|
|
76383
|
+
previewScript: "dev",
|
|
76384
|
+
envInterfaceName: envInterfaceName2
|
|
76392
76385
|
};
|
|
76393
76386
|
var c3_default22 = config21;
|
|
76394
76387
|
|
|
@@ -76441,13 +76434,6 @@ var configure7 = async (ctx) => {
|
|
|
76441
76434
|
throw new Error("Could not find the `/api` or `/app` directory");
|
|
76442
76435
|
}
|
|
76443
76436
|
const usesTs = usesTypescript(ctx);
|
|
76444
|
-
if (usesTs) {
|
|
76445
|
-
copyFile(
|
|
76446
|
-
(0, import_path10.join)(getTemplatePath(ctx), "env.d.ts"),
|
|
76447
|
-
(0, import_path10.join)(projectPath, "env.d.ts")
|
|
76448
|
-
);
|
|
76449
|
-
updateStatus("Created an env.d.ts file");
|
|
76450
|
-
}
|
|
76451
76437
|
const installEslintPlugin = await shouldInstallNextOnPagesEslintPlugin(ctx);
|
|
76452
76438
|
if (installEslintPlugin) {
|
|
76453
76439
|
await writeEslintrc(ctx);
|
|
@@ -76492,7 +76478,6 @@ var writeEslintrc = async (ctx) => {
|
|
|
76492
76478
|
var addDevDependencies = async (installEslintPlugin) => {
|
|
76493
76479
|
const packages = [
|
|
76494
76480
|
"@cloudflare/next-on-pages@1",
|
|
76495
|
-
"@cloudflare/workers-types",
|
|
76496
76481
|
"vercel",
|
|
76497
76482
|
...installEslintPlugin ? ["eslint-plugin-next-on-pages"] : []
|
|
76498
76483
|
];
|
|
@@ -76502,6 +76487,8 @@ var addDevDependencies = async (installEslintPlugin) => {
|
|
|
76502
76487
|
doneText: `${brandColor(`installed`)} ${dim(packages.join(", "))}`
|
|
76503
76488
|
});
|
|
76504
76489
|
};
|
|
76490
|
+
var envInterfaceName3 = "CloudflareEnv";
|
|
76491
|
+
var typesPath = "./env.d.ts";
|
|
76505
76492
|
var c3_default24 = {
|
|
76506
76493
|
configVersion: 1,
|
|
76507
76494
|
id: "next",
|
|
@@ -76555,7 +76542,7 @@ var c3_default24 = {
|
|
|
76555
76542
|
preview: `${pagesBuildRunCommand} && wrangler pages dev`,
|
|
76556
76543
|
deploy: `${pagesBuildRunCommand} && wrangler pages deploy`,
|
|
76557
76544
|
...usesTypescript(ctx) && {
|
|
76558
|
-
"cf-typegen": `wrangler types --env-interface
|
|
76545
|
+
"cf-typegen": `wrangler types --env-interface ${envInterfaceName3} ${typesPath}`
|
|
76559
76546
|
}
|
|
76560
76547
|
}
|
|
76561
76548
|
};
|
|
@@ -76563,7 +76550,9 @@ var c3_default24 = {
|
|
|
76563
76550
|
devScript: "dev",
|
|
76564
76551
|
previewScript: "preview",
|
|
76565
76552
|
deployScript: "deploy",
|
|
76566
|
-
compatibilityFlags: ["nodejs_compat"]
|
|
76553
|
+
compatibilityFlags: ["nodejs_compat"],
|
|
76554
|
+
typesPath,
|
|
76555
|
+
envInterfaceName: envInterfaceName3
|
|
76567
76556
|
};
|
|
76568
76557
|
|
|
76569
76558
|
// templates/next/workers/c3.ts
|
|
@@ -76591,13 +76580,15 @@ var updateNextConfig2 = (usesTs) => {
|
|
|
76591
76580
|
writeFile2(configFile, updatedConfigFile);
|
|
76592
76581
|
s.stop(`${brandColor(`updated`)} ${dim(`\`${configFile}\``)}`);
|
|
76593
76582
|
};
|
|
76583
|
+
var envInterfaceName4 = "CloudflareBindings";
|
|
76584
|
+
var typesPath2 = "./cloudflare-env.d.ts";
|
|
76594
76585
|
var c3_default25 = {
|
|
76595
76586
|
configVersion: 1,
|
|
76596
76587
|
id: "next",
|
|
76597
76588
|
frameworkCli: "create-next-app",
|
|
76598
76589
|
frameworkCliPinnedVersion: "~15.3.0",
|
|
76599
76590
|
platform: "workers",
|
|
76600
|
-
displayName: "Next.js
|
|
76591
|
+
displayName: "Next.js",
|
|
76601
76592
|
path: "templates/next/workers",
|
|
76602
76593
|
copyFiles: {
|
|
76603
76594
|
path: "./templates"
|
|
@@ -76608,12 +76599,14 @@ var c3_default25 = {
|
|
|
76608
76599
|
scripts: {
|
|
76609
76600
|
deploy: `opennextjs-cloudflare build && opennextjs-cloudflare deploy`,
|
|
76610
76601
|
preview: `opennextjs-cloudflare build && opennextjs-cloudflare preview`,
|
|
76611
|
-
"cf-typegen": `wrangler types --env-interface
|
|
76602
|
+
"cf-typegen": `wrangler types --env-interface ${envInterfaceName4} ${typesPath2}`
|
|
76612
76603
|
}
|
|
76613
76604
|
}),
|
|
76614
76605
|
devScript: "dev",
|
|
76615
76606
|
previewScript: "preview",
|
|
76616
76607
|
deployScript: "deploy",
|
|
76608
|
+
typesPath: typesPath2,
|
|
76609
|
+
envInterfaceName: envInterfaceName4,
|
|
76617
76610
|
compatibilityFlags: ["nodejs_compat"]
|
|
76618
76611
|
};
|
|
76619
76612
|
|
|
@@ -76640,7 +76633,7 @@ var generate15 = async (ctx) => {
|
|
|
76640
76633
|
writeFile2("./.node-version", "18");
|
|
76641
76634
|
logRaw("");
|
|
76642
76635
|
};
|
|
76643
|
-
var configure9 = async (
|
|
76636
|
+
var configure9 = async () => {
|
|
76644
76637
|
const packages = ["nitro-cloudflare-dev"];
|
|
76645
76638
|
if (pm2 === "pnpm") {
|
|
76646
76639
|
packages.push("h3");
|
|
@@ -76651,21 +76644,6 @@ var configure9 = async (ctx) => {
|
|
|
76651
76644
|
doneText: `${brandColor("installed")} ${dim(`via \`${npm10} install\``)}`
|
|
76652
76645
|
});
|
|
76653
76646
|
updateNuxtConfig();
|
|
76654
|
-
updateEnvTypes2(ctx);
|
|
76655
|
-
};
|
|
76656
|
-
var updateEnvTypes2 = (ctx) => {
|
|
76657
|
-
const filepath = "env.d.ts";
|
|
76658
|
-
const s = spinner();
|
|
76659
|
-
s.start(`Updating ${filepath}`);
|
|
76660
|
-
let file = readFile(filepath);
|
|
76661
|
-
let typesEntrypoint = `@cloudflare/workers-types`;
|
|
76662
|
-
const latestEntrypoint = getLatestTypesEntrypoint(ctx);
|
|
76663
|
-
if (latestEntrypoint) {
|
|
76664
|
-
typesEntrypoint += `/${latestEntrypoint}`;
|
|
76665
|
-
}
|
|
76666
|
-
file = file.replace("WORKERS_TYPES_ENTRYPOINT", typesEntrypoint);
|
|
76667
|
-
writeFile2("env.d.ts", file);
|
|
76668
|
-
s.stop(`${brandColor(`updated`)} ${dim(`\`${filepath}\``)}`);
|
|
76669
76647
|
};
|
|
76670
76648
|
var updateNuxtConfig = () => {
|
|
76671
76649
|
const s = spinner();
|
|
@@ -76751,7 +76729,7 @@ var generate16 = async (ctx) => {
|
|
|
76751
76729
|
writeFile2("./.node-version", "18");
|
|
76752
76730
|
logRaw("");
|
|
76753
76731
|
};
|
|
76754
|
-
var configure10 = async (
|
|
76732
|
+
var configure10 = async () => {
|
|
76755
76733
|
const packages = ["nitro-cloudflare-dev", "nitropack"];
|
|
76756
76734
|
if (pm3 === "pnpm") {
|
|
76757
76735
|
packages.push("h3");
|
|
@@ -76762,21 +76740,6 @@ var configure10 = async (ctx) => {
|
|
|
76762
76740
|
doneText: `${brandColor("installed")} ${dim(`via \`${npm11} install\``)}`
|
|
76763
76741
|
});
|
|
76764
76742
|
updateNuxtConfig2();
|
|
76765
|
-
updateEnvTypes3(ctx);
|
|
76766
|
-
};
|
|
76767
|
-
var updateEnvTypes3 = (ctx) => {
|
|
76768
|
-
const filepath = "env.d.ts";
|
|
76769
|
-
const s = spinner();
|
|
76770
|
-
s.start(`Updating ${filepath}`);
|
|
76771
|
-
let file = readFile(filepath);
|
|
76772
|
-
let typesEntrypoint = `@cloudflare/workers-types`;
|
|
76773
|
-
const latestEntrypoint = getLatestTypesEntrypoint(ctx);
|
|
76774
|
-
if (latestEntrypoint) {
|
|
76775
|
-
typesEntrypoint += `/${latestEntrypoint}`;
|
|
76776
|
-
}
|
|
76777
|
-
file = file.replace("WORKERS_TYPES_ENTRYPOINT", typesEntrypoint);
|
|
76778
|
-
writeFile2("env.d.ts", file);
|
|
76779
|
-
s.stop(`${brandColor(`updated`)} ${dim(`\`${filepath}\``)}`);
|
|
76780
76743
|
};
|
|
76781
76744
|
var updateNuxtConfig2 = () => {
|
|
76782
76745
|
const s = spinner();
|
|
@@ -77177,7 +77140,8 @@ var config30 = {
|
|
|
77177
77140
|
}),
|
|
77178
77141
|
devScript: "dev",
|
|
77179
77142
|
deployScript: "deploy",
|
|
77180
|
-
previewScript: "preview"
|
|
77143
|
+
previewScript: "preview",
|
|
77144
|
+
workersTypes: "installed"
|
|
77181
77145
|
};
|
|
77182
77146
|
var c3_default33 = config30;
|
|
77183
77147
|
|
|
@@ -77286,7 +77250,8 @@ var config31 = {
|
|
|
77286
77250
|
}),
|
|
77287
77251
|
devScript: "dev",
|
|
77288
77252
|
deployScript: "deploy",
|
|
77289
|
-
previewScript: "preview"
|
|
77253
|
+
previewScript: "preview",
|
|
77254
|
+
workersTypes: "installed"
|
|
77290
77255
|
};
|
|
77291
77256
|
var c3_default34 = config31;
|
|
77292
77257
|
|
|
@@ -77316,9 +77281,6 @@ var config33 = {
|
|
|
77316
77281
|
platform: "workers",
|
|
77317
77282
|
frameworkCli: "create-react-router",
|
|
77318
77283
|
displayName: "React Router (formerly Remix)",
|
|
77319
|
-
copyFiles: {
|
|
77320
|
-
path: "./templates"
|
|
77321
|
-
},
|
|
77322
77284
|
generate: generate19,
|
|
77323
77285
|
// configure,
|
|
77324
77286
|
transformPackageJson: async () => ({
|
|
@@ -77374,11 +77336,13 @@ var config34 = {
|
|
|
77374
77336
|
platform: "pages",
|
|
77375
77337
|
hidden: true,
|
|
77376
77338
|
path: "templates/react/pages",
|
|
77339
|
+
copyFiles: { path: "./templates" },
|
|
77377
77340
|
generate: generate20,
|
|
77378
77341
|
transformPackageJson: async () => ({
|
|
77379
77342
|
scripts: {
|
|
77380
|
-
deploy: `${npm15} run build && wrangler pages deploy
|
|
77381
|
-
preview: `${npm15} run build && wrangler pages dev
|
|
77343
|
+
deploy: `${npm15} run build && wrangler pages deploy`,
|
|
77344
|
+
preview: `${npm15} run build && wrangler pages dev`,
|
|
77345
|
+
"cf-typegen": `wrangler types`
|
|
77382
77346
|
}
|
|
77383
77347
|
}),
|
|
77384
77348
|
devScript: "dev",
|
|
@@ -77579,7 +77543,8 @@ var config37 = {
|
|
|
77579
77543
|
}),
|
|
77580
77544
|
devScript: "dev",
|
|
77581
77545
|
deployScript: "deploy",
|
|
77582
|
-
previewScript: "preview"
|
|
77546
|
+
previewScript: "preview",
|
|
77547
|
+
workersTypes: "installed"
|
|
77583
77548
|
};
|
|
77584
77549
|
var c3_default40 = config37;
|
|
77585
77550
|
|
|
@@ -77621,7 +77586,8 @@ var config38 = {
|
|
|
77621
77586
|
}),
|
|
77622
77587
|
devScript: "dev",
|
|
77623
77588
|
deployScript: "deploy",
|
|
77624
|
-
previewScript: "preview"
|
|
77589
|
+
previewScript: "preview",
|
|
77590
|
+
workersTypes: "installed"
|
|
77625
77591
|
};
|
|
77626
77592
|
var c3_default41 = config38;
|
|
77627
77593
|
|
|
@@ -77712,7 +77678,8 @@ var config41 = {
|
|
|
77712
77678
|
transformPackageJson: async () => ({
|
|
77713
77679
|
scripts: {
|
|
77714
77680
|
preview: `${npm19} run build && npx wrangler pages dev`,
|
|
77715
|
-
deploy: `${npm19} run build && wrangler pages deploy
|
|
77681
|
+
deploy: `${npm19} run build && wrangler pages deploy`,
|
|
77682
|
+
"cf-typegen": `wrangler types`
|
|
77716
77683
|
}
|
|
77717
77684
|
}),
|
|
77718
77685
|
compatibilityFlags: ["nodejs_compat"],
|
|
@@ -77724,7 +77691,6 @@ var c3_default44 = config41;
|
|
|
77724
77691
|
|
|
77725
77692
|
// templates/svelte/pages/c3.ts
|
|
77726
77693
|
var import_node_fs3 = require("node:fs");
|
|
77727
|
-
var import_node_os3 = require("node:os");
|
|
77728
77694
|
var recast12 = __toESM(require_main3());
|
|
77729
77695
|
var { npm: npm20 } = detectPackageManager();
|
|
77730
77696
|
var generate25 = async (ctx) => {
|
|
@@ -77813,6 +77779,7 @@ var updateTypeDefinitions = (ctx) => {
|
|
|
77813
77779
|
}
|
|
77814
77780
|
});
|
|
77815
77781
|
};
|
|
77782
|
+
var typesPath3 = "src/worker-configuration.d.ts";
|
|
77816
77783
|
var config42 = {
|
|
77817
77784
|
configVersion: 1,
|
|
77818
77785
|
id: "svelte",
|
|
@@ -77832,22 +77799,21 @@ var config42 = {
|
|
|
77832
77799
|
deploy: `${npm20} run build && wrangler pages deploy`
|
|
77833
77800
|
};
|
|
77834
77801
|
if (usesTypescript(ctx)) {
|
|
77835
|
-
const mv = (0, import_node_os3.platform)() === "win32" ? "move" : "mv";
|
|
77836
77802
|
scripts = {
|
|
77837
77803
|
...scripts,
|
|
77838
|
-
"cf-typegen": `wrangler types
|
|
77804
|
+
"cf-typegen": `wrangler types ${typesPath3}`
|
|
77839
77805
|
};
|
|
77840
77806
|
}
|
|
77841
77807
|
return { scripts };
|
|
77842
77808
|
},
|
|
77843
77809
|
devScript: "dev",
|
|
77844
77810
|
deployScript: "deploy",
|
|
77845
|
-
previewScript: "preview"
|
|
77811
|
+
previewScript: "preview",
|
|
77812
|
+
typesPath: typesPath3
|
|
77846
77813
|
};
|
|
77847
77814
|
var c3_default45 = config42;
|
|
77848
77815
|
|
|
77849
77816
|
// templates/svelte/workers/c3.ts
|
|
77850
|
-
var import_node_os4 = require("node:os");
|
|
77851
77817
|
var recast13 = __toESM(require_main3());
|
|
77852
77818
|
var { npm: npm21 } = detectPackageManager();
|
|
77853
77819
|
var generate26 = async (ctx) => {
|
|
@@ -77913,6 +77879,7 @@ var updateTypeDefinitions2 = (ctx) => {
|
|
|
77913
77879
|
}
|
|
77914
77880
|
});
|
|
77915
77881
|
};
|
|
77882
|
+
var typesPath4 = "./src/worker-configuration.d.ts";
|
|
77916
77883
|
var config43 = {
|
|
77917
77884
|
configVersion: 1,
|
|
77918
77885
|
id: "svelte",
|
|
@@ -77931,17 +77898,17 @@ var config43 = {
|
|
|
77931
77898
|
deploy: `${npm21} run build && wrangler deploy`
|
|
77932
77899
|
};
|
|
77933
77900
|
if (usesTypescript(ctx)) {
|
|
77934
|
-
const mv = (0, import_node_os4.platform)() === "win32" ? "move" : "mv";
|
|
77935
77901
|
scripts = {
|
|
77936
77902
|
...scripts,
|
|
77937
|
-
"cf-typegen": `wrangler types
|
|
77903
|
+
"cf-typegen": `wrangler types ${typesPath4}`
|
|
77938
77904
|
};
|
|
77939
77905
|
}
|
|
77940
77906
|
return { scripts };
|
|
77941
77907
|
},
|
|
77942
77908
|
devScript: "dev",
|
|
77943
77909
|
deployScript: "deploy",
|
|
77944
|
-
previewScript: "preview"
|
|
77910
|
+
previewScript: "preview",
|
|
77911
|
+
typesPath: typesPath4
|
|
77945
77912
|
};
|
|
77946
77913
|
var c3_default46 = config43;
|
|
77947
77914
|
|
|
@@ -77964,12 +77931,14 @@ var config45 = {
|
|
|
77964
77931
|
displayName: "Vue",
|
|
77965
77932
|
platform: "pages",
|
|
77966
77933
|
hidden: true,
|
|
77967
|
-
path: "templates/pages
|
|
77934
|
+
path: "templates/vue/pages",
|
|
77935
|
+
copyFiles: { path: "./templates" },
|
|
77968
77936
|
generate: generate27,
|
|
77969
77937
|
transformPackageJson: async () => ({
|
|
77970
77938
|
scripts: {
|
|
77971
|
-
deploy: `${npm22} run build && wrangler pages deploy
|
|
77972
|
-
preview: `${npm22} run build && wrangler pages dev
|
|
77939
|
+
deploy: `${npm22} run build && wrangler pages deploy`,
|
|
77940
|
+
preview: `${npm22} run build && wrangler pages dev`,
|
|
77941
|
+
"cf-typegen": `wrangler types`
|
|
77973
77942
|
}
|
|
77974
77943
|
}),
|
|
77975
77944
|
devScript: "dev",
|
|
@@ -78064,7 +78033,7 @@ var c3_default50 = config47;
|
|
|
78064
78033
|
var import_node_assert = __toESM(require("node:assert"));
|
|
78065
78034
|
|
|
78066
78035
|
// ../wrangler/package.json
|
|
78067
|
-
var version2 = "0.0.0-
|
|
78036
|
+
var version2 = "0.0.0-5b3d1af95";
|
|
78068
78037
|
|
|
78069
78038
|
// src/git.ts
|
|
78070
78039
|
var offerGit = async (ctx) => {
|
|
@@ -78569,7 +78538,7 @@ var createContext = async (args, prevArgs) => {
|
|
|
78569
78538
|
if (availableVariants.length === 1) {
|
|
78570
78539
|
args.platform ??= availableVariants[0][0];
|
|
78571
78540
|
}
|
|
78572
|
-
const
|
|
78541
|
+
const platform = await processArgument(args, "platform", {
|
|
78573
78542
|
type: "select",
|
|
78574
78543
|
label: "platform",
|
|
78575
78544
|
question: "Select your deployment platform",
|
|
@@ -78593,10 +78562,10 @@ var createContext = async (args, prevArgs) => {
|
|
|
78593
78562
|
defaultValue: "workers"
|
|
78594
78563
|
});
|
|
78595
78564
|
linesPrinted += 3;
|
|
78596
|
-
if (
|
|
78565
|
+
if (platform === BACK_VALUE) {
|
|
78597
78566
|
return goBack("platform");
|
|
78598
78567
|
}
|
|
78599
|
-
frameworkConfig = frameworkConfig.platformVariants[
|
|
78568
|
+
frameworkConfig = frameworkConfig.platformVariants[platform];
|
|
78600
78569
|
}
|
|
78601
78570
|
template = {
|
|
78602
78571
|
deployScript: "pages:deploy",
|
|
@@ -78633,6 +78602,12 @@ var createContext = async (args, prevArgs) => {
|
|
|
78633
78602
|
throw new Error(`Unknown application type provided: ${type}.`);
|
|
78634
78603
|
}
|
|
78635
78604
|
}
|
|
78605
|
+
template = {
|
|
78606
|
+
workersTypes: "generated",
|
|
78607
|
+
typesPath: "worker-configuration.d.ts",
|
|
78608
|
+
envInterfaceName: "Env",
|
|
78609
|
+
...template
|
|
78610
|
+
};
|
|
78636
78611
|
const path6 = (0, import_path13.resolve)(projectName);
|
|
78637
78612
|
const languageVariants = template.copyFiles && !isVariantInfo(template.copyFiles) && !template.copyFiles.selectVariant ? Object.keys(template.copyFiles.variants) : [];
|
|
78638
78613
|
if (languageVariants.length > 0) {
|
|
@@ -79221,7 +79196,7 @@ var processArgument = async (args, key, promptConfig) => {
|
|
|
79221
79196
|
|
|
79222
79197
|
// src/deploy.ts
|
|
79223
79198
|
var import_promises5 = require("node:fs/promises");
|
|
79224
|
-
var
|
|
79199
|
+
var import_node_os3 = require("node:os");
|
|
79225
79200
|
var import_node_path6 = require("node:path");
|
|
79226
79201
|
var import_toml3 = __toESM(require_toml());
|
|
79227
79202
|
|
|
@@ -80888,7 +80863,7 @@ var runDeploy = async (ctx) => {
|
|
|
80888
80863
|
] : []
|
|
80889
80864
|
];
|
|
80890
80865
|
const outputFile = (0, import_node_path6.join)(
|
|
80891
|
-
await (0, import_promises5.mkdtemp)((0, import_node_path6.join)((0,
|
|
80866
|
+
await (0, import_promises5.mkdtemp)((0, import_node_path6.join)((0, import_node_os3.tmpdir)(), "c3-wrangler-deploy-")),
|
|
80892
80867
|
"output.json"
|
|
80893
80868
|
);
|
|
80894
80869
|
await runCommand(deployCmd, {
|
|
@@ -81468,48 +81443,107 @@ var createProject = async (ctx) => {
|
|
|
81468
81443
|
// src/workers.ts
|
|
81469
81444
|
var import_fs13 = require("fs");
|
|
81470
81445
|
var import_path16 = require("path");
|
|
81471
|
-
|
|
81446
|
+
var import_toml4 = __toESM(require_toml());
|
|
81447
|
+
async function addTypes(ctx) {
|
|
81448
|
+
if (!usesTypescript(ctx) || ctx.template.workersTypes === "none") {
|
|
81449
|
+
return;
|
|
81450
|
+
}
|
|
81472
81451
|
const { npm: npm25 } = detectPackageManager();
|
|
81473
|
-
if (
|
|
81452
|
+
if (ctx.template.workersTypes === "installed") {
|
|
81453
|
+
await installWorkersTypes(npm25);
|
|
81454
|
+
} else if (ctx.template.workersTypes === "generated") {
|
|
81455
|
+
await generateWorkersTypes(ctx, npm25);
|
|
81456
|
+
}
|
|
81457
|
+
const usesNodeCompat = await maybeInstallNodeTypes(ctx, npm25);
|
|
81458
|
+
await updateTsConfig(ctx, { usesNodeCompat });
|
|
81459
|
+
}
|
|
81460
|
+
async function generateWorkersTypes(ctx, npm25) {
|
|
81461
|
+
const packageJsonPath = (0, import_path16.join)(ctx.project.path, "package.json");
|
|
81462
|
+
if (!(0, import_fs13.existsSync)(packageJsonPath)) {
|
|
81474
81463
|
return;
|
|
81475
81464
|
}
|
|
81476
|
-
|
|
81477
|
-
|
|
81478
|
-
|
|
81479
|
-
|
|
81465
|
+
const packageManifest = readJSON(packageJsonPath);
|
|
81466
|
+
if (!packageManifest.scripts?.["cf-typegen"]) {
|
|
81467
|
+
return;
|
|
81468
|
+
}
|
|
81469
|
+
const typesCmd = [npm25, "run", "cf-typegen"];
|
|
81470
|
+
await runCommand(typesCmd, {
|
|
81471
|
+
cwd: ctx.project.path,
|
|
81472
|
+
silent: true,
|
|
81473
|
+
startText: "Generating types for your application",
|
|
81474
|
+
doneText: `${brandColor("generated")} ${dim(`to \`${ctx.template.typesPath}\` via \`${typesCmd.join(" ")}\``)}`
|
|
81480
81475
|
});
|
|
81481
|
-
|
|
81476
|
+
if (packageManifest["devDependencies"]?.["@cloudflare/workers-types"]) {
|
|
81477
|
+
delete packageManifest["devDependencies"]?.["@cloudflare/workers-types"];
|
|
81478
|
+
writeFile2(packageJsonPath, JSON.stringify(packageManifest, null, 2));
|
|
81479
|
+
}
|
|
81482
81480
|
}
|
|
81483
|
-
async
|
|
81481
|
+
var maybeInstallNodeTypes = async (ctx, npm25) => {
|
|
81482
|
+
let parsedConfig = {};
|
|
81483
|
+
if (wranglerJsonExists(ctx)) {
|
|
81484
|
+
const wranglerJsonStr = readWranglerJson(ctx);
|
|
81485
|
+
parsedConfig = parse4(wranglerJsonStr, void 0, {
|
|
81486
|
+
allowTrailingComma: true
|
|
81487
|
+
});
|
|
81488
|
+
} else if (wranglerTomlExists(ctx)) {
|
|
81489
|
+
const wranglerTomlStr = readWranglerToml(ctx);
|
|
81490
|
+
parsedConfig = import_toml4.default.parse(wranglerTomlStr);
|
|
81491
|
+
}
|
|
81492
|
+
const compatibilityFlags = Array.isArray(parsedConfig["compatibility_flags"]) ? parsedConfig["compatibility_flags"] : [];
|
|
81493
|
+
if (compatibilityFlags.includes("nodejs_compat") || compatibilityFlags.includes("nodejs_compat_v2")) {
|
|
81494
|
+
await installPackages(["@types/node"], {
|
|
81495
|
+
dev: true,
|
|
81496
|
+
startText: "Installing @types/node",
|
|
81497
|
+
doneText: `${brandColor("installed")} ${dim(`via ${npm25}`)}`
|
|
81498
|
+
});
|
|
81499
|
+
return true;
|
|
81500
|
+
}
|
|
81501
|
+
return false;
|
|
81502
|
+
};
|
|
81503
|
+
async function updateTsConfig(ctx, { usesNodeCompat }) {
|
|
81484
81504
|
const tsconfigPath = (0, import_path16.join)(ctx.project.path, "tsconfig.json");
|
|
81485
81505
|
if (!(0, import_fs13.existsSync)(tsconfigPath)) {
|
|
81486
81506
|
return;
|
|
81487
81507
|
}
|
|
81488
|
-
const s = spinner();
|
|
81489
|
-
s.start("Adding latest types to `tsconfig.json`");
|
|
81490
81508
|
const tsconfig = readFile(tsconfigPath);
|
|
81491
|
-
const entrypointVersion = getLatestTypesEntrypoint(ctx);
|
|
81492
|
-
if (entrypointVersion === null) {
|
|
81493
|
-
s.stop(
|
|
81494
|
-
`${brandColor(
|
|
81495
|
-
"skipped"
|
|
81496
|
-
)} couldn't find latest compatible version of @cloudflare/workers-types`
|
|
81497
|
-
);
|
|
81498
|
-
return;
|
|
81499
|
-
}
|
|
81500
|
-
const typesEntrypoint = `@cloudflare/workers-types/${entrypointVersion}`;
|
|
81501
81509
|
try {
|
|
81502
81510
|
const config48 = parse4(tsconfig);
|
|
81503
81511
|
const currentTypes = config48.compilerOptions?.types ?? [];
|
|
81504
|
-
|
|
81505
|
-
|
|
81506
|
-
|
|
81507
|
-
|
|
81508
|
-
|
|
81509
|
-
|
|
81510
|
-
|
|
81511
|
-
|
|
81512
|
-
|
|
81512
|
+
let newTypes = [...currentTypes];
|
|
81513
|
+
if (ctx.template.workersTypes === "installed") {
|
|
81514
|
+
const entrypointVersion = getLatestTypesEntrypoint(ctx);
|
|
81515
|
+
if (entrypointVersion === null) {
|
|
81516
|
+
return;
|
|
81517
|
+
}
|
|
81518
|
+
const typesEntrypoint = `@cloudflare/workers-types/${entrypointVersion}`;
|
|
81519
|
+
const explicitEntrypoint = currentTypes.some(
|
|
81520
|
+
(t2) => t2.match(/@cloudflare\/workers-types\/\d{4}-\d{2}-\d{2}/)
|
|
81521
|
+
);
|
|
81522
|
+
if (!explicitEntrypoint) {
|
|
81523
|
+
newTypes = newTypes.filter(
|
|
81524
|
+
(t2) => t2 !== "@cloudflare/workers-types"
|
|
81525
|
+
);
|
|
81526
|
+
newTypes.push(typesEntrypoint);
|
|
81527
|
+
}
|
|
81528
|
+
} else if (ctx.template.workersTypes === "generated") {
|
|
81529
|
+
newTypes.push(ctx.template.typesPath ?? "./worker-configuration.d.ts");
|
|
81530
|
+
const typegen = readFile(
|
|
81531
|
+
ctx.template.typesPath ?? "./worker-configuration.d.ts"
|
|
81532
|
+
).split("\n");
|
|
81533
|
+
if (typegen.some(
|
|
81534
|
+
(line) => line.includes("// Runtime types generated with workerd")
|
|
81535
|
+
)) {
|
|
81536
|
+
newTypes = newTypes.filter(
|
|
81537
|
+
(t2) => !t2.startsWith("@cloudflare/workers-types")
|
|
81538
|
+
);
|
|
81539
|
+
}
|
|
81540
|
+
}
|
|
81541
|
+
if (usesNodeCompat) {
|
|
81542
|
+
newTypes.push("node");
|
|
81543
|
+
}
|
|
81544
|
+
if (newTypes.sort() === currentTypes.sort()) {
|
|
81545
|
+
return;
|
|
81546
|
+
}
|
|
81513
81547
|
const useSpaces = !tsconfig.match(/\t/g);
|
|
81514
81548
|
const edits = modify(
|
|
81515
81549
|
tsconfig,
|
|
@@ -81522,11 +81556,15 @@ async function addWorkersTypesToTsConfig(ctx) {
|
|
|
81522
81556
|
const updated = applyEdits(tsconfig, edits);
|
|
81523
81557
|
writeFile2(tsconfigPath, updated);
|
|
81524
81558
|
} catch (error2) {
|
|
81525
|
-
warn(
|
|
81526
|
-
"Failed to update `tsconfig.json` with latest `@cloudflare/workers-types` entrypoint."
|
|
81527
|
-
);
|
|
81559
|
+
warn("Failed to update `tsconfig.json`.");
|
|
81528
81560
|
}
|
|
81529
|
-
|
|
81561
|
+
}
|
|
81562
|
+
async function installWorkersTypes(npm25) {
|
|
81563
|
+
await installPackages(["@cloudflare/workers-types"], {
|
|
81564
|
+
dev: true,
|
|
81565
|
+
startText: "Installing @cloudflare/workers-types",
|
|
81566
|
+
doneText: `${brandColor("installed")} ${dim(`via ${npm25}`)}`
|
|
81567
|
+
});
|
|
81530
81568
|
}
|
|
81531
81569
|
|
|
81532
81570
|
// src/cli.ts
|
|
@@ -81606,7 +81644,6 @@ var create = async (ctx) => {
|
|
|
81606
81644
|
var configure20 = async (ctx) => {
|
|
81607
81645
|
startSection("Configuring your application for Cloudflare", "Step 2 of 3");
|
|
81608
81646
|
await installWrangler();
|
|
81609
|
-
await installWorkersTypes(ctx);
|
|
81610
81647
|
await updateWranglerConfig(ctx);
|
|
81611
81648
|
const { template } = ctx;
|
|
81612
81649
|
if (template.configure) {
|
|
@@ -81614,6 +81651,7 @@ var configure20 = async (ctx) => {
|
|
|
81614
81651
|
}
|
|
81615
81652
|
addWranglerToGitIgnore(ctx);
|
|
81616
81653
|
await updatePackageScripts(ctx);
|
|
81654
|
+
await addTypes(ctx);
|
|
81617
81655
|
await offerGit(ctx);
|
|
81618
81656
|
await gitCommit(ctx);
|
|
81619
81657
|
endSection(`Application configured`);
|