create-cloudflare 0.0.0-841041de → 0.0.0-850c4d64

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-850c4d64";
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.20.0";
60375
60375
 
60376
60376
  // src/common.ts
60377
60377
  var { name, npm } = detectPackageManager();
@@ -60549,11 +60549,9 @@ var chooseAccount = async (ctx) => {
60549
60549
  ctx.account = { id: accountId, name: accountName };
60550
60550
  };
60551
60551
  var printSummary = async (ctx) => {
60552
+ const dirRelativePath = (0, import_path5.relative)(ctx.originalCWD, ctx.project.path);
60552
60553
  const nextSteps = [
60553
- [
60554
- `Navigate to the new directory`,
60555
- `cd ${(0, import_path5.relative)(ctx.originalCWD, ctx.project.path)}`
60556
- ],
60554
+ dirRelativePath ? [`Navigate to the new directory`, `cd ${dirRelativePath}`] : [],
60557
60555
  [
60558
60556
  `Run the development server`,
60559
60557
  quoteShellArgs([
@@ -60909,9 +60907,9 @@ var retry = async ({
60909
60907
  };
60910
60908
  var runFrameworkGenerator = async (ctx, args) => {
60911
60909
  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" } : {};
60910
+ const { npm: npm15, dlx: dlx2 } = detectPackageManager();
60911
+ const cmd = [...npm15 === "yarn" ? ["npx"] : dlx2, cli, ...args];
60912
+ const env3 = npm15 === "yarn" ? { npm_config_user_agent: "yarn" } : {};
60915
60913
  if (ctx.framework?.args?.length) {
60916
60914
  cmd.push(...ctx.framework.args);
60917
60915
  }
@@ -60926,10 +60924,10 @@ var runFrameworkGenerator = async (ctx, args) => {
60926
60924
  await runCommand(cmd, { env: env3 });
60927
60925
  };
60928
60926
  var installPackages = async (packages, config14) => {
60929
- const { npm: npm14 } = detectPackageManager();
60927
+ const { npm: npm15 } = detectPackageManager();
60930
60928
  let saveFlag;
60931
60929
  let cmd;
60932
- switch (npm14) {
60930
+ switch (npm15) {
60933
60931
  case "yarn":
60934
60932
  cmd = "add";
60935
60933
  saveFlag = config14.dev ? "-D" : "";
@@ -60945,13 +60943,13 @@ var installPackages = async (packages, config14) => {
60945
60943
  saveFlag = config14.dev ? "--save-dev" : "--save";
60946
60944
  break;
60947
60945
  }
60948
- await runCommand([npm14, cmd, saveFlag, ...packages], {
60946
+ await runCommand([npm15, cmd, saveFlag, ...packages], {
60949
60947
  ...config14,
60950
60948
  silent: true
60951
60949
  });
60952
60950
  };
60953
60951
  var resetPackageManager = async (ctx) => {
60954
- const { npm: npm14 } = detectPackageManager();
60952
+ const { npm: npm15 } = detectPackageManager();
60955
60953
  if (!needsPackageManagerReset(ctx)) {
60956
60954
  return;
60957
60955
  }
@@ -60961,17 +60959,17 @@ var resetPackageManager = async (ctx) => {
60961
60959
  const lockfilePath = import_path6.default.join(ctx.project.path, "package-lock.json");
60962
60960
  if ((0, import_fs6.existsSync)(lockfilePath))
60963
60961
  (0, import_fs6.rmSync)(lockfilePath);
60964
- await runCommand([npm14, "install"], {
60962
+ await runCommand([npm15, "install"], {
60965
60963
  silent: true,
60966
60964
  cwd: ctx.project.path,
60967
60965
  startText: "Installing dependencies",
60968
- doneText: `${brandColor("installed")} ${dim(`via \`${npm14} install\``)}`
60966
+ doneText: `${brandColor("installed")} ${dim(`via \`${npm15} install\``)}`
60969
60967
  });
60970
60968
  };
60971
60969
  var needsPackageManagerReset = (ctx) => {
60972
- const { npm: npm14 } = detectPackageManager();
60970
+ const { npm: npm15 } = detectPackageManager();
60973
60971
  const projectPath = ctx.project.path;
60974
- switch (npm14) {
60972
+ switch (npm15) {
60975
60973
  case "npm":
60976
60974
  return false;
60977
60975
  case "yarn":
@@ -60983,15 +60981,15 @@ var needsPackageManagerReset = (ctx) => {
60983
60981
  }
60984
60982
  };
60985
60983
  var npmInstall = async () => {
60986
- const { npm: npm14 } = detectPackageManager();
60987
- await runCommand([npm14, "install"], {
60984
+ const { npm: npm15 } = detectPackageManager();
60985
+ await runCommand([npm15, "install"], {
60988
60986
  silent: true,
60989
60987
  startText: "Installing dependencies",
60990
- doneText: `${brandColor("installed")} ${dim(`via \`${npm14} install\``)}`
60988
+ doneText: `${brandColor("installed")} ${dim(`via \`${npm15} install\``)}`
60991
60989
  });
60992
60990
  };
60993
60991
  var installWrangler = async () => {
60994
- const { npm: npm14 } = detectPackageManager();
60992
+ const { npm: npm15 } = detectPackageManager();
60995
60993
  if ((0, import_fs6.existsSync)(import_path6.default.resolve("node_modules", "wrangler"))) {
60996
60994
  return;
60997
60995
  }
@@ -61001,7 +60999,7 @@ var installWrangler = async () => {
61001
60999
  "A command line tool for building Cloudflare Workers"
61002
61000
  )}`,
61003
61001
  doneText: `${brandColor("installed")} ${dim(
61004
- `via \`${npm14} install wrangler --save-dev\``
61002
+ `via \`${npm15} install wrangler --save-dev\``
61005
61003
  )}`
61006
61004
  });
61007
61005
  };
@@ -61048,8 +61046,8 @@ var listAccounts = async () => {
61048
61046
  return accounts;
61049
61047
  };
61050
61048
  async function getWorkerdCompatibilityDate() {
61051
- const { npm: npm14 } = detectPackageManager();
61052
- return runCommand([npm14, "info", "workerd", "dist-tags.latest"], {
61049
+ const { npm: npm15 } = detectPackageManager();
61050
+ return runCommand([npm15, "info", "workerd", "dist-tags.latest"], {
61053
61051
  silent: true,
61054
61052
  captureOutput: true,
61055
61053
  startText: "Retrieving current workerd compatibility date",
@@ -61086,7 +61084,7 @@ var readJSON = (path3) => {
61086
61084
  const contents = readFile(path3);
61087
61085
  return contents ? JSON.parse(contents) : contents;
61088
61086
  };
61089
- var writeJSON = (path3, object, stringifySpace) => {
61087
+ var writeJSON = (path3, object, stringifySpace = 2) => {
61090
61088
  writeFile2(path3, JSON.stringify(object, null, stringifySpace));
61091
61089
  };
61092
61090
  var probePaths = (paths, errorMsg = "Failed to find required file.") => {
@@ -61440,7 +61438,7 @@ var writeEslintrc = async (ctx) => {
61440
61438
  }
61441
61439
  eslintConfig.extends ??= [];
61442
61440
  eslintConfig.extends.push("plugin:eslint-plugin-next-on-pages/recommended");
61443
- writeJSON(`${ctx.project.name}/.eslintrc.json`, eslintConfig, 2);
61441
+ writeJSON(`${ctx.project.name}/.eslintrc.json`, eslintConfig);
61444
61442
  };
61445
61443
  var config6 = {
61446
61444
  generate: generate6,
@@ -61529,18 +61527,18 @@ var package_default = {
61529
61527
  "additionally it also contains a map that maps frameworks to their respective clis"
61530
61528
  ],
61531
61529
  dependencies: {
61532
- "create-astro": "4.5.1",
61533
- "@angular/create": "17.0.3",
61534
- "create-docusaurus": "3.0.0",
61530
+ "create-astro": "4.5.2",
61531
+ "@angular/create": "17.0.6",
61532
+ "create-docusaurus": "3.0.1",
61535
61533
  "create-hono": "0.3.2",
61536
- "create-next-app": "14.0.3",
61537
- "create-qwik": "1.2.19",
61534
+ "create-next-app": "14.0.4",
61535
+ "create-qwik": "1.3.0",
61538
61536
  "create-react-app": "5.0.1",
61539
61537
  "create-remix": "2.3.1",
61540
61538
  "create-solid": "0.3.10",
61541
- "create-svelte": "5.3.2",
61542
- "create-vue": "3.8.0",
61543
- gatsby: "5.12.11",
61539
+ "create-svelte": "5.3.3",
61540
+ "create-vue": "3.9.0",
61541
+ gatsby: "5.12.12",
61544
61542
  nuxi: "3.10.0"
61545
61543
  },
61546
61544
  frameworkCliMap: {
@@ -61990,11 +61988,12 @@ var createProject = async (ctx) => {
61990
61988
  };
61991
61989
 
61992
61990
  // src/workers.ts
61991
+ var import_fs9 = require("fs");
61993
61992
  var import_promises2 = require("fs/promises");
61994
61993
  var import_os = require("os");
61995
61994
  var import_path9 = require("path");
61996
61995
  var import_process4 = require("process");
61997
- var { dlx } = detectPackageManager();
61996
+ var { dlx, npm: npm13 } = detectPackageManager();
61998
61997
  var runWorkersGenerator = async (args) => {
61999
61998
  const originalCWD = process.cwd();
62000
61999
  const { name: name2, path: path3 } = setupProjectDirectory(args);
@@ -62004,7 +62003,11 @@ var runWorkersGenerator = async (args) => {
62004
62003
  originalCWD,
62005
62004
  gitRepoAlreadyExisted: await isInsideGitRepo((0, import_path9.dirname)(path3))
62006
62005
  };
62007
- ctx.args.ts = await processArgument(ctx.args, "ts", {
62006
+ const { preexisting } = await getTemplate(ctx);
62007
+ if (preexisting) {
62008
+ ctx.args.ts = false;
62009
+ }
62010
+ await processArgument(ctx.args, "ts", {
62008
62011
  type: "confirm",
62009
62012
  question: "Do you want to use TypeScript?",
62010
62013
  label: "typescript",
@@ -62018,10 +62021,13 @@ var runWorkersGenerator = async (args) => {
62018
62021
  startSection("Installing dependencies", "Step 2 of 3");
62019
62022
  (0, import_process4.chdir)(ctx.project.path);
62020
62023
  await npmInstall();
62024
+ await installWorkersTypes(ctx);
62021
62025
  await gitCommit(ctx);
62022
62026
  endSection("Dependencies Installed");
62023
- await offerToDeploy(ctx);
62024
- await runDeploy(ctx);
62027
+ if (!preexisting) {
62028
+ await offerToDeploy(ctx);
62029
+ await runDeploy(ctx);
62030
+ }
62025
62031
  await printSummary(ctx);
62026
62032
  };
62027
62033
  async function getTemplate(ctx) {
@@ -62099,26 +62105,73 @@ async function copyExistingWorkerFiles(ctx) {
62099
62105
  }
62100
62106
  }
62101
62107
  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(
62108
+ const pkgJsonPath = (0, import_path9.resolve)(ctx.project.path, "package.json");
62109
+ const pkgJson = readJSON(pkgJsonPath);
62110
+ if (pkgJson.name === "<TBD>") {
62111
+ pkgJson.name = ctx.project.name;
62112
+ }
62113
+ writeJSON(pkgJsonPath, pkgJson);
62114
+ const wranglerTomlPath = (0, import_path9.resolve)(ctx.project.path, "wrangler.toml");
62115
+ let wranglerToml = readFile(wranglerTomlPath);
62116
+ wranglerToml = wranglerToml.replace(/^name\s*=\s*"<TBD>"/m, `name = "${ctx.project.name}"`).replace(
62114
62117
  /^compatibility_date\s*=\s*"<TBD>"/m,
62115
62118
  `compatibility_date = "${await getWorkerdCompatibilityDate()}"`
62116
62119
  );
62117
- await (0, import_promises2.writeFile)(
62118
- paths.packagejson,
62119
- JSON.stringify(contents.packagejson, null, 2)
62120
+ writeFile2(wranglerTomlPath, wranglerToml);
62121
+ }
62122
+ async function installWorkersTypes(ctx) {
62123
+ if (!ctx.args.ts) {
62124
+ return;
62125
+ }
62126
+ await installPackages(["@cloudflare/workers-types"], {
62127
+ dev: true,
62128
+ startText: `Installing @cloudflare/workers-types`,
62129
+ doneText: `${brandColor("installed")} ${dim(`via ${npm13}`)}`
62130
+ });
62131
+ await updateTsConfig(ctx);
62132
+ }
62133
+ async function updateTsConfig(ctx) {
62134
+ const tsconfigPath = (0, import_path9.join)(ctx.project.path, "tsconfig.json");
62135
+ if (!(0, import_fs9.existsSync)(tsconfigPath)) {
62136
+ return;
62137
+ }
62138
+ const s = spinner();
62139
+ s.start(`Adding latest types to \`tsconfig.json\``);
62140
+ const tsconfig = readFile(tsconfigPath);
62141
+ const entrypointVersion = getLatestTypesEntrypoint(ctx);
62142
+ if (entrypointVersion === null) {
62143
+ s.stop(
62144
+ `${brandColor(
62145
+ "skipped"
62146
+ )} couldn't find latest compatible version of @cloudflare/workers-types`
62147
+ );
62148
+ return;
62149
+ }
62150
+ const typesEntrypoint = `@cloudflare/workers-types/${entrypointVersion}`;
62151
+ const updated = tsconfig.replace(
62152
+ "@cloudflare/workers-types",
62153
+ typesEntrypoint
62154
+ );
62155
+ writeFile2(tsconfigPath, updated);
62156
+ s.stop(`${brandColor("added")} ${dim(typesEntrypoint)}`);
62157
+ }
62158
+ function getLatestTypesEntrypoint(ctx) {
62159
+ const workersTypesPath = (0, import_path9.resolve)(
62160
+ ctx.project.path,
62161
+ "node_modules",
62162
+ "@cloudflare",
62163
+ "workers-types"
62120
62164
  );
62121
- await (0, import_promises2.writeFile)(paths.wranglertoml, contents.wranglertoml);
62165
+ try {
62166
+ const entrypoints = (0, import_fs9.readdirSync)(workersTypesPath);
62167
+ const sorted = entrypoints.filter((filename) => filename.match(/(\d{4})-(\d{2})-(\d{2})/)).sort().reverse();
62168
+ if (sorted.length === 0) {
62169
+ return null;
62170
+ }
62171
+ return sorted[0];
62172
+ } catch (error) {
62173
+ return null;
62174
+ }
62122
62175
  }
62123
62176
 
62124
62177
  // src/templateMap.ts
@@ -62262,7 +62315,7 @@ For more information regarding how to invoke C3 please visit ${c3CliArgsDocsPage
62262
62315
 
62263
62316
  // src/cli.ts
62264
62317
  var import_semver2 = __toESM(require_semver2());
62265
- var { npm: npm13 } = detectPackageManager();
62318
+ var { npm: npm14 } = detectPackageManager();
62266
62319
  var main = async (argv) => {
62267
62320
  const args = await parseArgs(argv);
62268
62321
  logRaw("");
@@ -62289,10 +62342,10 @@ var isUpdateAvailable = async () => {
62289
62342
  };
62290
62343
  var runLatest = async () => {
62291
62344
  const args = process.argv.slice(2);
62292
- if (npm13 === "npm") {
62345
+ if (npm14 === "npm") {
62293
62346
  args.unshift("--");
62294
62347
  }
62295
- await runCommand([npm13, "create", "cloudflare@latest", ...args]);
62348
+ await runCommand([npm14, "create", "cloudflare@latest", ...args]);
62296
62349
  };
62297
62350
  var runCli = async (args) => {
62298
62351
  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-850c4d64",
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.20.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
  }