create-cloudflare 0.0.0-652cc422 → 0.0.0-6722468c

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
@@ -55054,7 +55054,6 @@ var inputPrompt = async (promptConfig) => {
55054
55054
  if (promptConfig.type === "select") {
55055
55055
  prompt = new ED({
55056
55056
  ...promptConfig,
55057
- options: promptConfig.options,
55058
55057
  initialValue: String(promptConfig.defaultValue),
55059
55058
  render() {
55060
55059
  return dispatchRender(this);
@@ -55149,7 +55148,7 @@ var getSelectRenderers = (config14) => {
55149
55148
  };
55150
55149
  return [
55151
55150
  `${blCorner} ${bold(question)} ${dim(helpText)}`,
55152
- `${options.map(renderOption).join(`
55151
+ `${options.filter((o) => !o.hidden).map(renderOption).join(`
55153
55152
  `)}`,
55154
55153
  ``
55155
55154
  // extra line for readability
@@ -60107,7 +60106,7 @@ var Yargs = YargsFactory(esm_default);
60107
60106
  var yargs_default = Yargs;
60108
60107
 
60109
60108
  // package.json
60110
- var version = "0.0.0-652cc422";
60109
+ var version = "0.0.0-6722468c";
60111
60110
  var devDependencies = {
60112
60111
  "@babel/parser": "^7.21.3",
60113
60112
  "@babel/types": "^7.21.4",
@@ -60372,7 +60371,7 @@ function secondsSince(start) {
60372
60371
  var import_shell_quote = __toESM(require_shell_quote());
60373
60372
 
60374
60373
  // ../wrangler/package.json
60375
- var version2 = "3.17.1";
60374
+ var version2 = "3.19.0";
60376
60375
 
60377
60376
  // src/common.ts
60378
60377
  var { name, npm } = detectPackageManager();
@@ -60550,11 +60549,9 @@ var chooseAccount = async (ctx) => {
60550
60549
  ctx.account = { id: accountId, name: accountName };
60551
60550
  };
60552
60551
  var printSummary = async (ctx) => {
60552
+ const dirRelativePath = (0, import_path5.relative)(ctx.originalCWD, ctx.project.path);
60553
60553
  const nextSteps = [
60554
- [
60555
- `Navigate to the new directory`,
60556
- `cd ${(0, import_path5.relative)(ctx.originalCWD, ctx.project.path)}`
60557
- ],
60554
+ ...dirRelativePath ? [`Navigate to the new directory`, `cd ${dirRelativePath}`] : [],
60558
60555
  [
60559
60556
  `Run the development server`,
60560
60557
  quoteShellArgs([
@@ -60910,9 +60907,9 @@ var retry = async ({
60910
60907
  };
60911
60908
  var runFrameworkGenerator = async (ctx, args) => {
60912
60909
  const cli = getFrameworkCli(ctx, true);
60913
- const { npm: npm14, dlx: dlx2 } = detectPackageManager();
60914
- const cmd = [...npm14 === "yarn" ? ["npx"] : dlx2, cli, ...args];
60915
- 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" } : {};
60916
60913
  if (ctx.framework?.args?.length) {
60917
60914
  cmd.push(...ctx.framework.args);
60918
60915
  }
@@ -60927,10 +60924,10 @@ var runFrameworkGenerator = async (ctx, args) => {
60927
60924
  await runCommand(cmd, { env: env3 });
60928
60925
  };
60929
60926
  var installPackages = async (packages, config14) => {
60930
- const { npm: npm14 } = detectPackageManager();
60927
+ const { npm: npm15 } = detectPackageManager();
60931
60928
  let saveFlag;
60932
60929
  let cmd;
60933
- switch (npm14) {
60930
+ switch (npm15) {
60934
60931
  case "yarn":
60935
60932
  cmd = "add";
60936
60933
  saveFlag = config14.dev ? "-D" : "";
@@ -60946,13 +60943,13 @@ var installPackages = async (packages, config14) => {
60946
60943
  saveFlag = config14.dev ? "--save-dev" : "--save";
60947
60944
  break;
60948
60945
  }
60949
- await runCommand([npm14, cmd, saveFlag, ...packages], {
60946
+ await runCommand([npm15, cmd, saveFlag, ...packages], {
60950
60947
  ...config14,
60951
60948
  silent: true
60952
60949
  });
60953
60950
  };
60954
60951
  var resetPackageManager = async (ctx) => {
60955
- const { npm: npm14 } = detectPackageManager();
60952
+ const { npm: npm15 } = detectPackageManager();
60956
60953
  if (!needsPackageManagerReset(ctx)) {
60957
60954
  return;
60958
60955
  }
@@ -60962,17 +60959,17 @@ var resetPackageManager = async (ctx) => {
60962
60959
  const lockfilePath = import_path6.default.join(ctx.project.path, "package-lock.json");
60963
60960
  if ((0, import_fs6.existsSync)(lockfilePath))
60964
60961
  (0, import_fs6.rmSync)(lockfilePath);
60965
- await runCommand([npm14, "install"], {
60962
+ await runCommand([npm15, "install"], {
60966
60963
  silent: true,
60967
60964
  cwd: ctx.project.path,
60968
60965
  startText: "Installing dependencies",
60969
- doneText: `${brandColor("installed")} ${dim(`via \`${npm14} install\``)}`
60966
+ doneText: `${brandColor("installed")} ${dim(`via \`${npm15} install\``)}`
60970
60967
  });
60971
60968
  };
60972
60969
  var needsPackageManagerReset = (ctx) => {
60973
- const { npm: npm14 } = detectPackageManager();
60970
+ const { npm: npm15 } = detectPackageManager();
60974
60971
  const projectPath = ctx.project.path;
60975
- switch (npm14) {
60972
+ switch (npm15) {
60976
60973
  case "npm":
60977
60974
  return false;
60978
60975
  case "yarn":
@@ -60984,15 +60981,15 @@ var needsPackageManagerReset = (ctx) => {
60984
60981
  }
60985
60982
  };
60986
60983
  var npmInstall = async () => {
60987
- const { npm: npm14 } = detectPackageManager();
60988
- await runCommand([npm14, "install"], {
60984
+ const { npm: npm15 } = detectPackageManager();
60985
+ await runCommand([npm15, "install"], {
60989
60986
  silent: true,
60990
60987
  startText: "Installing dependencies",
60991
- doneText: `${brandColor("installed")} ${dim(`via \`${npm14} install\``)}`
60988
+ doneText: `${brandColor("installed")} ${dim(`via \`${npm15} install\``)}`
60992
60989
  });
60993
60990
  };
60994
60991
  var installWrangler = async () => {
60995
- const { npm: npm14 } = detectPackageManager();
60992
+ const { npm: npm15 } = detectPackageManager();
60996
60993
  if ((0, import_fs6.existsSync)(import_path6.default.resolve("node_modules", "wrangler"))) {
60997
60994
  return;
60998
60995
  }
@@ -61002,7 +60999,7 @@ var installWrangler = async () => {
61002
60999
  "A command line tool for building Cloudflare Workers"
61003
61000
  )}`,
61004
61001
  doneText: `${brandColor("installed")} ${dim(
61005
- `via \`${npm14} install wrangler --save-dev\``
61002
+ `via \`${npm15} install wrangler --save-dev\``
61006
61003
  )}`
61007
61004
  });
61008
61005
  };
@@ -61049,8 +61046,8 @@ var listAccounts = async () => {
61049
61046
  return accounts;
61050
61047
  };
61051
61048
  async function getWorkerdCompatibilityDate() {
61052
- const { npm: npm14 } = detectPackageManager();
61053
- return runCommand([npm14, "info", "workerd", "dist-tags.latest"], {
61049
+ const { npm: npm15 } = detectPackageManager();
61050
+ return runCommand([npm15, "info", "workerd", "dist-tags.latest"], {
61054
61051
  silent: true,
61055
61052
  captureOutput: true,
61056
61053
  startText: "Retrieving current workerd compatibility date",
@@ -61087,7 +61084,7 @@ var readJSON = (path3) => {
61087
61084
  const contents = readFile(path3);
61088
61085
  return contents ? JSON.parse(contents) : contents;
61089
61086
  };
61090
- var writeJSON = (path3, object, stringifySpace) => {
61087
+ var writeJSON = (path3, object, stringifySpace = 2) => {
61091
61088
  writeFile2(path3, JSON.stringify(object, null, stringifySpace));
61092
61089
  };
61093
61090
  var probePaths = (paths, errorMsg = "Failed to find required file.") => {
@@ -61441,7 +61438,7 @@ var writeEslintrc = async (ctx) => {
61441
61438
  }
61442
61439
  eslintConfig.extends ??= [];
61443
61440
  eslintConfig.extends.push("plugin:eslint-plugin-next-on-pages/recommended");
61444
- writeJSON(`${ctx.project.name}/.eslintrc.json`, eslintConfig, 2);
61441
+ writeJSON(`${ctx.project.name}/.eslintrc.json`, eslintConfig);
61445
61442
  };
61446
61443
  var config6 = {
61447
61444
  generate: generate6,
@@ -61530,18 +61527,18 @@ var package_default = {
61530
61527
  "additionally it also contains a map that maps frameworks to their respective clis"
61531
61528
  ],
61532
61529
  dependencies: {
61533
- "create-astro": "4.5.1",
61534
- "@angular/create": "17.0.1",
61535
- "create-docusaurus": "3.0.0",
61530
+ "create-astro": "4.5.2",
61531
+ "@angular/create": "17.0.6",
61532
+ "create-docusaurus": "3.0.1",
61536
61533
  "create-hono": "0.3.2",
61537
- "create-next-app": "14.0.3",
61538
- "create-qwik": "1.2.19",
61534
+ "create-next-app": "14.0.4",
61535
+ "create-qwik": "1.3.0",
61539
61536
  "create-react-app": "5.0.1",
61540
61537
  "create-remix": "2.3.1",
61541
- "create-solid": "0.3.9",
61542
- "create-svelte": "5.3.2",
61543
- "create-vue": "3.8.0",
61544
- gatsby: "5.12.11",
61538
+ "create-solid": "0.3.10",
61539
+ "create-svelte": "5.3.3",
61540
+ "create-vue": "3.9.0",
61541
+ gatsby: "5.12.12",
61545
61542
  nuxi: "3.10.0"
61546
61543
  },
61547
61544
  frameworkCliMap: {
@@ -61991,11 +61988,12 @@ var createProject = async (ctx) => {
61991
61988
  };
61992
61989
 
61993
61990
  // src/workers.ts
61991
+ var import_fs9 = require("fs");
61994
61992
  var import_promises2 = require("fs/promises");
61995
61993
  var import_os = require("os");
61996
61994
  var import_path9 = require("path");
61997
61995
  var import_process4 = require("process");
61998
- var { dlx } = detectPackageManager();
61996
+ var { dlx, npm: npm13 } = detectPackageManager();
61999
61997
  var runWorkersGenerator = async (args) => {
62000
61998
  const originalCWD = process.cwd();
62001
61999
  const { name: name2, path: path3 } = setupProjectDirectory(args);
@@ -62005,7 +62003,11 @@ var runWorkersGenerator = async (args) => {
62005
62003
  originalCWD,
62006
62004
  gitRepoAlreadyExisted: await isInsideGitRepo((0, import_path9.dirname)(path3))
62007
62005
  };
62008
- 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", {
62009
62011
  type: "confirm",
62010
62012
  question: "Do you want to use TypeScript?",
62011
62013
  label: "typescript",
@@ -62019,10 +62021,13 @@ var runWorkersGenerator = async (args) => {
62019
62021
  startSection("Installing dependencies", "Step 2 of 3");
62020
62022
  (0, import_process4.chdir)(ctx.project.path);
62021
62023
  await npmInstall();
62024
+ await installWorkersTypes(ctx);
62022
62025
  await gitCommit(ctx);
62023
62026
  endSection("Dependencies Installed");
62024
- await offerToDeploy(ctx);
62025
- await runDeploy(ctx);
62027
+ if (!preexisting) {
62028
+ await offerToDeploy(ctx);
62029
+ await runDeploy(ctx);
62030
+ }
62026
62031
  await printSummary(ctx);
62027
62032
  };
62028
62033
  async function getTemplate(ctx) {
@@ -62100,26 +62105,73 @@ async function copyExistingWorkerFiles(ctx) {
62100
62105
  }
62101
62106
  }
62102
62107
  async function updateFiles(ctx) {
62103
- const paths = {
62104
- packagejson: (0, import_path9.resolve)(ctx.project.path, "package.json"),
62105
- wranglertoml: (0, import_path9.resolve)(ctx.project.path, "wrangler.toml")
62106
- };
62107
- const contents = {
62108
- packagejson: JSON.parse(await (0, import_promises2.readFile)(paths.packagejson, "utf-8")),
62109
- wranglertoml: await (0, import_promises2.readFile)(paths.wranglertoml, "utf-8")
62110
- };
62111
- if (contents.packagejson.name === "<TBD>") {
62112
- contents.packagejson.name = ctx.project.name;
62113
- }
62114
- 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(
62115
62117
  /^compatibility_date\s*=\s*"<TBD>"/m,
62116
62118
  `compatibility_date = "${await getWorkerdCompatibilityDate()}"`
62117
62119
  );
62118
- await (0, import_promises2.writeFile)(
62119
- paths.packagejson,
62120
- 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"
62121
62164
  );
62122
- 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
+ }
62123
62175
  }
62124
62176
 
62125
62177
  // src/templateMap.ts
@@ -62263,7 +62315,7 @@ For more information regarding how to invoke C3 please visit ${c3CliArgsDocsPage
62263
62315
 
62264
62316
  // src/cli.ts
62265
62317
  var import_semver2 = __toESM(require_semver2());
62266
- var { npm: npm13 } = detectPackageManager();
62318
+ var { npm: npm14 } = detectPackageManager();
62267
62319
  var main = async (argv) => {
62268
62320
  const args = await parseArgs(argv);
62269
62321
  logRaw("");
@@ -62290,18 +62342,19 @@ var isUpdateAvailable = async () => {
62290
62342
  };
62291
62343
  var runLatest = async () => {
62292
62344
  const args = process.argv.slice(2);
62293
- if (npm13 === "npm") {
62345
+ if (npm14 === "npm") {
62294
62346
  args.unshift("--");
62295
62347
  }
62296
- await runCommand([npm13, "create", "cloudflare@latest", ...args]);
62348
+ await runCommand([npm14, "create", "cloudflare@latest", ...args]);
62297
62349
  };
62298
62350
  var runCli = async (args) => {
62299
62351
  printBanner();
62352
+ const defaultName = args.existingScript || C3_DEFAULTS.projectName;
62300
62353
  const projectName = await processArgument(args, "projectName", {
62301
62354
  type: "text",
62302
62355
  question: `In which directory do you want to create your application?`,
62303
62356
  helpText: "also used as application name",
62304
- defaultValue: C3_DEFAULTS.projectName,
62357
+ defaultValue: defaultName,
62305
62358
  label: "dir",
62306
62359
  validate: (value) => validateProjectDirectory(String(value) || C3_DEFAULTS.projectName, args),
62307
62360
  format: (val) => `./${val}`
@@ -62313,7 +62366,9 @@ var runCli = async (args) => {
62313
62366
  args.type = "pre-existing";
62314
62367
  }
62315
62368
  }
62316
- const templateOptions = Object.entries(templateMap).filter(([_2, { hidden: hidden2 }]) => !hidden2).map(([value, { label }]) => ({ value, label }));
62369
+ const templateOptions = Object.entries(templateMap).map(
62370
+ ([value, { label, hidden: hidden2 }]) => ({ value, label, hidden: hidden2 })
62371
+ );
62317
62372
  const type = await processArgument(args, "type", {
62318
62373
  type: "select",
62319
62374
  question: "What type of application do you want to create?",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-cloudflare",
3
- "version": "0.0.0-652cc422",
3
+ "version": "0.0.0-6722468c",
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.19.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
  }