create-cloudflare 0.0.0-841041de → 0.0.0-86c81ff0

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.
@@ -13,7 +13,7 @@ import { worker } from "./paths.mjs";
13
13
  const serverPolyfillsFile = join(worker, "polyfills.server.mjs");
14
14
  const serverPolyfillsData = fs
15
15
  .readFileSync(serverPolyfillsFile, "utf8")
16
- .split(EOL);
16
+ .split(/\r?\n/);
17
17
 
18
18
  for (let index = 0; index < 2; index++) {
19
19
  if (serverPolyfillsData[index].includes("createRequire")) {
package/dist/cli.js CHANGED
@@ -60106,7 +60106,7 @@ var Yargs = YargsFactory(esm_default);
60106
60106
  var yargs_default = Yargs;
60107
60107
 
60108
60108
  // package.json
60109
- var version = "0.0.0-841041de";
60109
+ var version = "0.0.0-86c81ff0";
60110
60110
  var devDependencies = {
60111
60111
  "@babel/parser": "^7.21.3",
60112
60112
  "@babel/types": "^7.21.4",
@@ -60371,7 +60371,7 @@ function secondsSince(start) {
60371
60371
  var import_shell_quote = __toESM(require_shell_quote());
60372
60372
 
60373
60373
  // ../wrangler/package.json
60374
- var version2 = "3.17.1";
60374
+ var version2 = "3.18.0";
60375
60375
 
60376
60376
  // src/common.ts
60377
60377
  var { name, npm } = detectPackageManager();
@@ -60909,9 +60909,9 @@ var retry = async ({
60909
60909
  };
60910
60910
  var runFrameworkGenerator = async (ctx, args) => {
60911
60911
  const cli = getFrameworkCli(ctx, true);
60912
- const { npm: npm14, dlx: dlx2 } = detectPackageManager();
60913
- const cmd = [...npm14 === "yarn" ? ["npx"] : dlx2, cli, ...args];
60914
- const env3 = npm14 === "yarn" ? { npm_config_user_agent: "yarn" } : {};
60912
+ const { npm: npm15, dlx: dlx2 } = detectPackageManager();
60913
+ const cmd = [...npm15 === "yarn" ? ["npx"] : dlx2, cli, ...args];
60914
+ const env3 = npm15 === "yarn" ? { npm_config_user_agent: "yarn" } : {};
60915
60915
  if (ctx.framework?.args?.length) {
60916
60916
  cmd.push(...ctx.framework.args);
60917
60917
  }
@@ -60926,10 +60926,10 @@ var runFrameworkGenerator = async (ctx, args) => {
60926
60926
  await runCommand(cmd, { env: env3 });
60927
60927
  };
60928
60928
  var installPackages = async (packages, config14) => {
60929
- const { npm: npm14 } = detectPackageManager();
60929
+ const { npm: npm15 } = detectPackageManager();
60930
60930
  let saveFlag;
60931
60931
  let cmd;
60932
- switch (npm14) {
60932
+ switch (npm15) {
60933
60933
  case "yarn":
60934
60934
  cmd = "add";
60935
60935
  saveFlag = config14.dev ? "-D" : "";
@@ -60945,13 +60945,13 @@ var installPackages = async (packages, config14) => {
60945
60945
  saveFlag = config14.dev ? "--save-dev" : "--save";
60946
60946
  break;
60947
60947
  }
60948
- await runCommand([npm14, cmd, saveFlag, ...packages], {
60948
+ await runCommand([npm15, cmd, saveFlag, ...packages], {
60949
60949
  ...config14,
60950
60950
  silent: true
60951
60951
  });
60952
60952
  };
60953
60953
  var resetPackageManager = async (ctx) => {
60954
- const { npm: npm14 } = detectPackageManager();
60954
+ const { npm: npm15 } = detectPackageManager();
60955
60955
  if (!needsPackageManagerReset(ctx)) {
60956
60956
  return;
60957
60957
  }
@@ -60961,17 +60961,17 @@ var resetPackageManager = async (ctx) => {
60961
60961
  const lockfilePath = import_path6.default.join(ctx.project.path, "package-lock.json");
60962
60962
  if ((0, import_fs6.existsSync)(lockfilePath))
60963
60963
  (0, import_fs6.rmSync)(lockfilePath);
60964
- await runCommand([npm14, "install"], {
60964
+ await runCommand([npm15, "install"], {
60965
60965
  silent: true,
60966
60966
  cwd: ctx.project.path,
60967
60967
  startText: "Installing dependencies",
60968
- doneText: `${brandColor("installed")} ${dim(`via \`${npm14} install\``)}`
60968
+ doneText: `${brandColor("installed")} ${dim(`via \`${npm15} install\``)}`
60969
60969
  });
60970
60970
  };
60971
60971
  var needsPackageManagerReset = (ctx) => {
60972
- const { npm: npm14 } = detectPackageManager();
60972
+ const { npm: npm15 } = detectPackageManager();
60973
60973
  const projectPath = ctx.project.path;
60974
- switch (npm14) {
60974
+ switch (npm15) {
60975
60975
  case "npm":
60976
60976
  return false;
60977
60977
  case "yarn":
@@ -60983,15 +60983,15 @@ var needsPackageManagerReset = (ctx) => {
60983
60983
  }
60984
60984
  };
60985
60985
  var npmInstall = async () => {
60986
- const { npm: npm14 } = detectPackageManager();
60987
- await runCommand([npm14, "install"], {
60986
+ const { npm: npm15 } = detectPackageManager();
60987
+ await runCommand([npm15, "install"], {
60988
60988
  silent: true,
60989
60989
  startText: "Installing dependencies",
60990
- doneText: `${brandColor("installed")} ${dim(`via \`${npm14} install\``)}`
60990
+ doneText: `${brandColor("installed")} ${dim(`via \`${npm15} install\``)}`
60991
60991
  });
60992
60992
  };
60993
60993
  var installWrangler = async () => {
60994
- const { npm: npm14 } = detectPackageManager();
60994
+ const { npm: npm15 } = detectPackageManager();
60995
60995
  if ((0, import_fs6.existsSync)(import_path6.default.resolve("node_modules", "wrangler"))) {
60996
60996
  return;
60997
60997
  }
@@ -61001,7 +61001,7 @@ var installWrangler = async () => {
61001
61001
  "A command line tool for building Cloudflare Workers"
61002
61002
  )}`,
61003
61003
  doneText: `${brandColor("installed")} ${dim(
61004
- `via \`${npm14} install wrangler --save-dev\``
61004
+ `via \`${npm15} install wrangler --save-dev\``
61005
61005
  )}`
61006
61006
  });
61007
61007
  };
@@ -61048,8 +61048,8 @@ var listAccounts = async () => {
61048
61048
  return accounts;
61049
61049
  };
61050
61050
  async function getWorkerdCompatibilityDate() {
61051
- const { npm: npm14 } = detectPackageManager();
61052
- return runCommand([npm14, "info", "workerd", "dist-tags.latest"], {
61051
+ const { npm: npm15 } = detectPackageManager();
61052
+ return runCommand([npm15, "info", "workerd", "dist-tags.latest"], {
61053
61053
  silent: true,
61054
61054
  captureOutput: true,
61055
61055
  startText: "Retrieving current workerd compatibility date",
@@ -61086,7 +61086,7 @@ var readJSON = (path3) => {
61086
61086
  const contents = readFile(path3);
61087
61087
  return contents ? JSON.parse(contents) : contents;
61088
61088
  };
61089
- var writeJSON = (path3, object, stringifySpace) => {
61089
+ var writeJSON = (path3, object, stringifySpace = 2) => {
61090
61090
  writeFile2(path3, JSON.stringify(object, null, stringifySpace));
61091
61091
  };
61092
61092
  var probePaths = (paths, errorMsg = "Failed to find required file.") => {
@@ -61440,7 +61440,7 @@ var writeEslintrc = async (ctx) => {
61440
61440
  }
61441
61441
  eslintConfig.extends ??= [];
61442
61442
  eslintConfig.extends.push("plugin:eslint-plugin-next-on-pages/recommended");
61443
- writeJSON(`${ctx.project.name}/.eslintrc.json`, eslintConfig, 2);
61443
+ writeJSON(`${ctx.project.name}/.eslintrc.json`, eslintConfig);
61444
61444
  };
61445
61445
  var config6 = {
61446
61446
  generate: generate6,
@@ -61530,8 +61530,8 @@ var package_default = {
61530
61530
  ],
61531
61531
  dependencies: {
61532
61532
  "create-astro": "4.5.1",
61533
- "@angular/create": "17.0.3",
61534
- "create-docusaurus": "3.0.0",
61533
+ "@angular/create": "17.0.5",
61534
+ "create-docusaurus": "3.0.1",
61535
61535
  "create-hono": "0.3.2",
61536
61536
  "create-next-app": "14.0.3",
61537
61537
  "create-qwik": "1.2.19",
@@ -61990,11 +61990,12 @@ var createProject = async (ctx) => {
61990
61990
  };
61991
61991
 
61992
61992
  // src/workers.ts
61993
+ var import_fs9 = require("fs");
61993
61994
  var import_promises2 = require("fs/promises");
61994
61995
  var import_os = require("os");
61995
61996
  var import_path9 = require("path");
61996
61997
  var import_process4 = require("process");
61997
- var { dlx } = detectPackageManager();
61998
+ var { dlx, npm: npm13 } = detectPackageManager();
61998
61999
  var runWorkersGenerator = async (args) => {
61999
62000
  const originalCWD = process.cwd();
62000
62001
  const { name: name2, path: path3 } = setupProjectDirectory(args);
@@ -62018,6 +62019,7 @@ var runWorkersGenerator = async (args) => {
62018
62019
  startSection("Installing dependencies", "Step 2 of 3");
62019
62020
  (0, import_process4.chdir)(ctx.project.path);
62020
62021
  await npmInstall();
62022
+ await installWorkersTypes(ctx);
62021
62023
  await gitCommit(ctx);
62022
62024
  endSection("Dependencies Installed");
62023
62025
  await offerToDeploy(ctx);
@@ -62099,26 +62101,73 @@ async function copyExistingWorkerFiles(ctx) {
62099
62101
  }
62100
62102
  }
62101
62103
  async function updateFiles(ctx) {
62102
- const paths = {
62103
- packagejson: (0, import_path9.resolve)(ctx.project.path, "package.json"),
62104
- wranglertoml: (0, import_path9.resolve)(ctx.project.path, "wrangler.toml")
62105
- };
62106
- const contents = {
62107
- packagejson: JSON.parse(await (0, import_promises2.readFile)(paths.packagejson, "utf-8")),
62108
- wranglertoml: await (0, import_promises2.readFile)(paths.wranglertoml, "utf-8")
62109
- };
62110
- if (contents.packagejson.name === "<TBD>") {
62111
- contents.packagejson.name = ctx.project.name;
62112
- }
62113
- contents.wranglertoml = contents.wranglertoml.replace(/^name\s*=\s*"<TBD>"/m, `name = "${ctx.project.name}"`).replace(
62104
+ const pkgJsonPath = (0, import_path9.resolve)(ctx.project.path, "package.json");
62105
+ const pkgJson = readJSON(pkgJsonPath);
62106
+ if (pkgJson.name === "<TBD>") {
62107
+ pkgJson.name = ctx.project.name;
62108
+ }
62109
+ writeJSON(pkgJsonPath, pkgJson);
62110
+ const wranglerTomlPath = (0, import_path9.resolve)(ctx.project.path, "wrangler.toml");
62111
+ let wranglerToml = readFile(wranglerTomlPath);
62112
+ wranglerToml = wranglerToml.replace(/^name\s*=\s*"<TBD>"/m, `name = "${ctx.project.name}"`).replace(
62114
62113
  /^compatibility_date\s*=\s*"<TBD>"/m,
62115
62114
  `compatibility_date = "${await getWorkerdCompatibilityDate()}"`
62116
62115
  );
62117
- await (0, import_promises2.writeFile)(
62118
- paths.packagejson,
62119
- JSON.stringify(contents.packagejson, null, 2)
62116
+ writeFile2(wranglerTomlPath, wranglerToml);
62117
+ }
62118
+ async function installWorkersTypes(ctx) {
62119
+ if (!ctx.args.ts) {
62120
+ return;
62121
+ }
62122
+ await installPackages(["@cloudflare/workers-types"], {
62123
+ dev: true,
62124
+ startText: `Installing @cloudflare/workers-types`,
62125
+ doneText: `${brandColor("installed")} ${dim(`via ${npm13}`)}`
62126
+ });
62127
+ await updateTsConfig(ctx);
62128
+ }
62129
+ async function updateTsConfig(ctx) {
62130
+ const tsconfigPath = (0, import_path9.join)(ctx.project.path, "tsconfig.json");
62131
+ if (!(0, import_fs9.existsSync)(tsconfigPath)) {
62132
+ return;
62133
+ }
62134
+ const s = spinner();
62135
+ s.start(`Adding latest types to \`tsconfig.json\``);
62136
+ const tsconfig = readFile(tsconfigPath);
62137
+ const entrypointVersion = getLatestTypesEntrypoint(ctx);
62138
+ if (entrypointVersion === null) {
62139
+ s.stop(
62140
+ `${brandColor(
62141
+ "skipped"
62142
+ )} couldn't find latest compatible version of @cloudflare/workers-types`
62143
+ );
62144
+ return;
62145
+ }
62146
+ const typesEntrypoint = `@cloudflare/workers-types/${entrypointVersion}`;
62147
+ const updated = tsconfig.replace(
62148
+ "@cloudflare/workers-types",
62149
+ typesEntrypoint
62150
+ );
62151
+ writeFile2(tsconfigPath, updated);
62152
+ s.stop(`${brandColor("added")} ${dim(typesEntrypoint)}`);
62153
+ }
62154
+ function getLatestTypesEntrypoint(ctx) {
62155
+ const workersTypesPath = (0, import_path9.resolve)(
62156
+ ctx.project.path,
62157
+ "node_modules",
62158
+ "@cloudflare",
62159
+ "workers-types"
62120
62160
  );
62121
- await (0, import_promises2.writeFile)(paths.wranglertoml, contents.wranglertoml);
62161
+ try {
62162
+ const entrypoints = (0, import_fs9.readdirSync)(workersTypesPath);
62163
+ const sorted = entrypoints.filter((filename) => filename.match(/(\d{4})-(\d{2})-(\d{2})/)).sort().reverse();
62164
+ if (sorted.length === 0) {
62165
+ return null;
62166
+ }
62167
+ return sorted[0];
62168
+ } catch (error) {
62169
+ return null;
62170
+ }
62122
62171
  }
62123
62172
 
62124
62173
  // src/templateMap.ts
@@ -62262,7 +62311,7 @@ For more information regarding how to invoke C3 please visit ${c3CliArgsDocsPage
62262
62311
 
62263
62312
  // src/cli.ts
62264
62313
  var import_semver2 = __toESM(require_semver2());
62265
- var { npm: npm13 } = detectPackageManager();
62314
+ var { npm: npm14 } = detectPackageManager();
62266
62315
  var main = async (argv) => {
62267
62316
  const args = await parseArgs(argv);
62268
62317
  logRaw("");
@@ -62289,10 +62338,10 @@ var isUpdateAvailable = async () => {
62289
62338
  };
62290
62339
  var runLatest = async () => {
62291
62340
  const args = process.argv.slice(2);
62292
- if (npm13 === "npm") {
62341
+ if (npm14 === "npm") {
62293
62342
  args.unshift("--");
62294
62343
  }
62295
- await runCommand([npm13, "create", "cloudflare@latest", ...args]);
62344
+ await runCommand([npm14, "create", "cloudflare@latest", ...args]);
62296
62345
  };
62297
62346
  var runCli = async (args) => {
62298
62347
  printBanner();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-cloudflare",
3
- "version": "0.0.0-841041de",
3
+ "version": "0.0.0-86c81ff0",
4
4
  "description": "A CLI for creating and deploying new applications to Cloudflare.",
5
5
  "keywords": [
6
6
  "cloudflare",
@@ -63,7 +63,7 @@
63
63
  "yarn": "^1.22.19",
64
64
  "@cloudflare/cli": "1.0.0",
65
65
  "@cloudflare/workers-tsconfig": "0.0.0",
66
- "wrangler": "3.17.1"
66
+ "wrangler": "3.18.0"
67
67
  },
68
68
  "engines": {
69
69
  "node": ">=18.14.1"
@@ -11,7 +11,6 @@
11
11
  "@cloudflare/itty-router-openapi": "^1.0.1"
12
12
  },
13
13
  "devDependencies": {
14
- "@cloudflare/workers-types": "^4.20230404.0",
15
14
  "wrangler": "^3.0.0"
16
15
  }
17
16
  }
@@ -8,7 +8,6 @@
8
8
  "start": "wrangler dev"
9
9
  },
10
10
  "devDependencies": {
11
- "@cloudflare/workers-types": "^4.20230419.0",
12
11
  "itty-router": "^3.0.12",
13
12
  "typescript": "^5.0.4",
14
13
  "wrangler": "^3.0.0"
@@ -8,7 +8,6 @@
8
8
  "start": "wrangler dev"
9
9
  },
10
10
  "devDependencies": {
11
- "@cloudflare/workers-types": "^4.20230419.0",
12
11
  "typescript": "^5.0.4",
13
12
  "wrangler": "^3.0.0"
14
13
  }
@@ -11,7 +11,6 @@
11
11
  "@cloudflare/itty-router-openapi": "^1.0.1"
12
12
  },
13
13
  "devDependencies": {
14
- "@cloudflare/workers-types": "^4.20230821.0",
15
14
  "@types/node": "^20.5.7",
16
15
  "@types/service-worker-mock": "^2.0.1",
17
16
  "wrangler": "^3.0.0"
@@ -8,7 +8,6 @@
8
8
  "start": "wrangler dev"
9
9
  },
10
10
  "devDependencies": {
11
- "@cloudflare/workers-types": "^4.20230419.0",
12
11
  "typescript": "^5.0.4",
13
12
  "wrangler": "^3.0.0"
14
13
  }
@@ -8,7 +8,6 @@
8
8
  "start": "wrangler dev"
9
9
  },
10
10
  "devDependencies": {
11
- "@cloudflare/workers-types": "^4.20230419.0",
12
11
  "typescript": "^5.0.4",
13
12
  "wrangler": "^3.0.0"
14
13
  }