create-cloudflare 2.6.2 → 2.7.0

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 CHANGED
@@ -60107,7 +60107,7 @@ var Yargs = YargsFactory(esm_default);
60107
60107
  var yargs_default = Yargs;
60108
60108
 
60109
60109
  // package.json
60110
- var version = "2.6.2";
60110
+ var version = "2.7.0";
60111
60111
  var devDependencies = {
60112
60112
  "@babel/parser": "^7.21.3",
60113
60113
  "@babel/types": "^7.21.4",
@@ -60136,14 +60136,13 @@ var devDependencies = {
60136
60136
  glob: "^10.3.3",
60137
60137
  haikunator: "^2.1.2",
60138
60138
  open: "^8.4.0",
60139
- pnpm: "^8.6.11",
60139
+ pnpm: "^8.10.0",
60140
60140
  recast: "^0.22.0",
60141
60141
  semver: "^7.5.1",
60142
60142
  "shell-quote": "^1.8.1",
60143
60143
  typescript: "^5.0.2",
60144
60144
  undici: "5.20.0",
60145
60145
  "vite-tsconfig-paths": "^4.0.8",
60146
- vitest: "^0.30.0",
60147
60146
  "which-pm-runs": "^1.1.0",
60148
60147
  wrangler: "workspace:*",
60149
60148
  yargs: "^17.7.1",
@@ -60387,7 +60386,11 @@ var retry = async ({
60387
60386
  }
60388
60387
  throw error;
60389
60388
  };
60390
- var runFrameworkGenerator = async (ctx, cmd) => {
60389
+ var runFrameworkGenerator = async (ctx, argString) => {
60390
+ const cli = getFrameworkCli(ctx, true);
60391
+ const { npm: npm14, dlx: dlx2 } = detectPackageManager();
60392
+ let cmd = `${npm14 === "yarn" ? "npx" : dlx2} ${cli} ${argString}`;
60393
+ const env3 = npm14 === "yarn" ? { npm_config_user_agent: "yarn" } : {};
60391
60394
  if (ctx.framework?.args?.length) {
60392
60395
  cmd = `${cmd} ${quote(ctx.framework.args)}`;
60393
60396
  }
@@ -60399,7 +60402,7 @@ var runFrameworkGenerator = async (ctx, cmd) => {
60399
60402
  const flags = ctx.framework?.config.testFlags ?? [];
60400
60403
  cmd = `${cmd} ${quote(flags)}`;
60401
60404
  }
60402
- await runCommand(cmd);
60405
+ await runCommand(cmd, { env: env3 });
60403
60406
  };
60404
60407
  var installPackages = async (packages, config14) => {
60405
60408
  const { npm: npm14 } = detectPackageManager();
@@ -60426,25 +60429,42 @@ var installPackages = async (packages, config14) => {
60426
60429
  silent: true
60427
60430
  });
60428
60431
  };
60429
- var npmInstall = async () => {
60432
+ var resetPackageManager = async (ctx) => {
60430
60433
  const { npm: npm14 } = detectPackageManager();
60434
+ if (!needsPackageManagerReset(ctx)) {
60435
+ return;
60436
+ }
60437
+ const nodeModulesPath = import_path5.default.join(ctx.project.path, "node_modules");
60438
+ if ((0, import_fs5.existsSync)(nodeModulesPath))
60439
+ (0, import_fs5.rmSync)(nodeModulesPath, { recursive: true });
60440
+ const lockfilePath = import_path5.default.join(ctx.project.path, "package-lock.json");
60441
+ if ((0, import_fs5.existsSync)(lockfilePath))
60442
+ (0, import_fs5.rmSync)(lockfilePath);
60431
60443
  await runCommand(`${npm14} install`, {
60432
60444
  silent: true,
60445
+ cwd: ctx.project.path,
60433
60446
  startText: "Installing dependencies",
60434
60447
  doneText: `${brandColor("installed")} ${dim(`via \`${npm14} install\``)}`
60435
60448
  });
60436
60449
  };
60437
- var resetPackageManager = async (ctx) => {
60450
+ var needsPackageManagerReset = (ctx) => {
60451
+ const { npm: npm14 } = detectPackageManager();
60452
+ const projectPath = ctx.project.path;
60453
+ switch (npm14) {
60454
+ case "npm":
60455
+ return false;
60456
+ case "yarn":
60457
+ return !(0, import_fs5.existsSync)(import_path5.default.join(projectPath, "yarn.lock"));
60458
+ case "pnpm":
60459
+ return !(0, import_fs5.existsSync)(import_path5.default.join(projectPath, "pnpm-lock.yaml"));
60460
+ case "bun":
60461
+ return !(0, import_fs5.existsSync)(import_path5.default.join(projectPath, "bun.lockb"));
60462
+ }
60463
+ };
60464
+ var npmInstall = async () => {
60438
60465
  const { npm: npm14 } = detectPackageManager();
60439
- if (npm14 === "npm")
60440
- return;
60441
- const nodeModulesPath = import_path5.default.join(ctx.project.path, "node_modules");
60442
- (0, import_fs5.rmSync)(nodeModulesPath, { recursive: true });
60443
- const lockfilePath = import_path5.default.join(ctx.project.path, "package-lock.json");
60444
- (0, import_fs5.rmSync)(lockfilePath);
60445
60466
  await runCommand(`${npm14} install`, {
60446
60467
  silent: true,
60447
- cwd: ctx.project.path,
60448
60468
  startText: "Installing dependencies",
60449
60469
  doneText: `${brandColor("installed")} ${dim(`via \`${npm14} install\``)}`
60450
60470
  });
@@ -60465,9 +60485,9 @@ var installWrangler = async () => {
60465
60485
  });
60466
60486
  };
60467
60487
  var isLoggedIn = async () => {
60468
- const { npx: npx6 } = detectPackageManager();
60488
+ const { npx: npx5 } = detectPackageManager();
60469
60489
  try {
60470
- const output = await runCommand(`${npx6} wrangler whoami`, {
60490
+ const output = await runCommand(`${npx5} wrangler whoami`, {
60471
60491
  silent: true
60472
60492
  });
60473
60493
  return /You are logged in/.test(output);
@@ -60476,7 +60496,7 @@ var isLoggedIn = async () => {
60476
60496
  }
60477
60497
  };
60478
60498
  var wranglerLogin = async () => {
60479
- const { npx: npx6 } = detectPackageManager();
60499
+ const { npx: npx5 } = detectPackageManager();
60480
60500
  const s = spinner();
60481
60501
  s.start(`Logging into Cloudflare ${dim("checking authentication status")}`);
60482
60502
  const alreadyLoggedIn = await isLoggedIn();
@@ -60484,7 +60504,7 @@ var wranglerLogin = async () => {
60484
60504
  if (alreadyLoggedIn)
60485
60505
  return true;
60486
60506
  s.start(`Logging into Cloudflare ${dim("This will open a browser window")}`);
60487
- const output = await runCommand(`${npx6} wrangler login`, {
60507
+ const output = await runCommand(`${npx5} wrangler login`, {
60488
60508
  silent: true
60489
60509
  });
60490
60510
  const success = /Successfully logged in/.test(output);
@@ -60493,8 +60513,8 @@ var wranglerLogin = async () => {
60493
60513
  return success;
60494
60514
  };
60495
60515
  var listAccounts = async () => {
60496
- const { npx: npx6 } = detectPackageManager();
60497
- const output = await runCommand(`${npx6} wrangler whoami`, {
60516
+ const { npx: npx5 } = detectPackageManager();
60517
+ const output = await runCommand(`${npx5} wrangler whoami`, {
60498
60518
  silent: true
60499
60519
  });
60500
60520
  const accounts = {};
@@ -60595,38 +60615,30 @@ var compatDateFlag = async () => {
60595
60615
  };
60596
60616
 
60597
60617
  // src/frameworks/angular/index.ts
60598
- var { dlx, npx, npm } = detectPackageManager();
60618
+ var { npm } = detectPackageManager();
60599
60619
  var generate = async (ctx) => {
60600
- const cli = getFrameworkCli(ctx);
60601
- await runFrameworkGenerator(
60602
- ctx,
60603
- `${dlx} ${cli} new ${ctx.project.name} --standalone`
60604
- );
60620
+ await runFrameworkGenerator(ctx, `${ctx.project.name} --ssr`);
60605
60621
  logRaw("");
60606
60622
  };
60607
60623
  var configure = async (ctx) => {
60608
60624
  process.chdir(ctx.project.path);
60609
- await runCommand(`${npx} ng analytics disable`, {
60610
- silent: true
60611
- });
60612
- await addSSRAdapter();
60613
- await installCFWorker(ctx);
60614
- await updateAppCode();
60615
60625
  updateAngularJson(ctx);
60626
+ await updateAppCode();
60627
+ await installCFWorker(ctx);
60616
60628
  };
60617
60629
  var config = {
60618
60630
  generate,
60619
60631
  configure,
60620
60632
  displayName: "Angular",
60621
60633
  getPackageScripts: async () => ({
60622
- process: "node ./tools/copy-worker-files.mjs && node ./tools/copy-client-files.mjs && node ./tools/bundle.mjs",
60623
- "pages:build": `${npm} run build:ssr && ${npm} run process`,
60624
60634
  start: `${npm} run pages:build && wrangler pages dev dist/cloudflare ${await compatDateFlag()} --experimental-local`,
60635
+ process: "node ./tools/copy-files.mjs && node ./tools/alter-polyfills.mjs",
60636
+ "pages:build": `ng build && ${npm} run process`,
60625
60637
  deploy: `${npm} run pages:build && wrangler pages deploy dist/cloudflare`
60626
60638
  }),
60627
60639
  deployCommand: "deploy",
60628
60640
  devCommand: "start",
60629
- testFlags: ["--routing", "--style", "sass"]
60641
+ testFlags: ["--ssr", "--style", "sass"]
60630
60642
  };
60631
60643
  var angular_default = config;
60632
60644
  async function installCFWorker(ctx) {
@@ -60640,15 +60652,7 @@ async function installCFWorker(ctx) {
60640
60652
  );
60641
60653
  s.stop(`${brandColor("copied")} ${dim("adapter code")}`);
60642
60654
  await installPackages(
60643
- [
60644
- "@cloudflare/workers-types",
60645
- "@esbuild-plugins/node-globals-polyfill",
60646
- "@esbuild-plugins/node-modules-polyfill",
60647
- "@miniflare/tre@next",
60648
- "esbuild",
60649
- "fast-glob",
60650
- "wrangler@beta"
60651
- ],
60655
+ ["@cloudflare/workers-types", "@miniflare/tre@next", "wrangler@beta"],
60652
60656
  {
60653
60657
  dev: true,
60654
60658
  startText: "Installing adapter dependencies",
@@ -60656,59 +60660,50 @@ async function installCFWorker(ctx) {
60656
60660
  }
60657
60661
  );
60658
60662
  }
60659
- async function addSSRAdapter() {
60660
- const cmd = `${npx} ng add @nguniversal/express-engine`;
60661
- await runCommand(`${cmd} --skip-confirmation`, {
60662
- silent: true,
60663
- startText: "Installing Angular SSR",
60664
- doneText: `${brandColor("installed")} ${dim(`via \`${cmd}\``)}`
60665
- });
60666
- }
60667
60663
  async function updateAppCode() {
60668
60664
  const s = spinner();
60669
60665
  s.start(`Updating application code`);
60670
60666
  const appConfigPath = "src/app/app.config.ts";
60671
60667
  const appConfig = readFile((0, import_node_path.resolve)(appConfigPath));
60672
- const newAppConfig = "import { provideClientHydration } from '@angular/platform-browser';\nimport { provideHttpClient, withFetch } from '@angular/common/http';\n" + appConfig.replace(
60668
+ const newAppConfig = "import { provideHttpClient, withFetch } from '@angular/common/http';\n" + appConfig.replace(
60673
60669
  "providers: [",
60674
- "providers: [provideHttpClient(withFetch()), provideClientHydration(), "
60670
+ "providers: [provideHttpClient(withFetch()), "
60675
60671
  );
60676
60672
  writeFile2((0, import_node_path.resolve)(appConfigPath), newAppConfig);
60677
- await (0, import_promises.rm)((0, import_node_path.resolve)("server.ts"));
60678
60673
  s.stop(`${brandColor(`updated`)} ${dim(appConfigPath)}`);
60674
+ s.start(`Updating package.json`);
60675
+ const packageJsonPath = (0, import_node_path.resolve)("package.json");
60676
+ const packageManifest = readJSON(packageJsonPath);
60677
+ delete packageManifest["dependencies"]["@angular/ssr"];
60678
+ delete packageManifest["dependencies"]["express"];
60679
+ writeFile2(packageJsonPath, JSON.stringify(packageManifest, null, 2));
60680
+ s.stop(`${brandColor(`updated`)} ${dim(`\`package.json\``)}`);
60679
60681
  }
60680
60682
  function updateAngularJson(ctx) {
60681
60683
  const s = spinner();
60682
60684
  s.start(`Updating angular.json config`);
60683
60685
  const angularJson = readJSON((0, import_node_path.resolve)("angular.json"));
60684
60686
  const architectSection = angularJson.projects[ctx.project.name].architect;
60685
- architectSection.build.options.outputPath = "dist/browser";
60687
+ architectSection.build.options.outputPath = "dist";
60686
60688
  architectSection.build.options.assets.push("src/_routes.json");
60687
- architectSection.server.options.outputPath = "dist/server";
60688
- architectSection.server.options.main = "src/main.server.ts";
60689
- delete architectSection["serve-ssr"];
60690
60689
  writeFile2((0, import_node_path.resolve)("angular.json"), JSON.stringify(angularJson, null, 2));
60691
60690
  s.stop(`${brandColor(`updated`)} ${dim(`\`angular.json\``)}`);
60692
60691
  }
60693
60692
 
60694
60693
  // src/frameworks/astro/index.ts
60695
- var { npx: npx2, dlx: dlx2 } = detectPackageManager();
60694
+ var { npx } = detectPackageManager();
60696
60695
  var generate2 = async (ctx) => {
60697
- const cli = getFrameworkCli(ctx);
60698
- await runFrameworkGenerator(
60699
- ctx,
60700
- `${dlx2} ${cli} ${ctx.project.name} --no-install`
60701
- );
60696
+ await runFrameworkGenerator(ctx, `${ctx.project.name} --no-install`);
60702
60697
  logRaw("");
60703
60698
  };
60704
60699
  var configure2 = async (ctx) => {
60705
60700
  process.chdir(ctx.project.path);
60706
60701
  await npmInstall();
60707
- await runCommand(`${npx2} astro add cloudflare -y`, {
60702
+ await runCommand(`${npx} astro add cloudflare -y`, {
60708
60703
  silent: true,
60709
60704
  startText: "Installing adapter",
60710
60705
  doneText: `${brandColor("installed")} ${dim(
60711
- `via \`${npx2} astro add cloudflare\``
60706
+ `via \`${npx} astro add cloudflare\``
60712
60707
  )}`
60713
60708
  });
60714
60709
  };
@@ -60733,10 +60728,9 @@ var config2 = {
60733
60728
  var astro_default = config2;
60734
60729
 
60735
60730
  // src/frameworks/docusaurus/index.ts
60736
- var { npm: npm2, dlx: dlx3 } = detectPackageManager();
60731
+ var { npm: npm2 } = detectPackageManager();
60737
60732
  var generate3 = async (ctx) => {
60738
- const cli = getFrameworkCli(ctx);
60739
- await runFrameworkGenerator(ctx, `${dlx3} ${cli} ${ctx.project.name} classic`);
60733
+ await runFrameworkGenerator(ctx, `${ctx.project.name} classic`);
60740
60734
  };
60741
60735
  var config3 = {
60742
60736
  generate: generate3,
@@ -60750,7 +60744,7 @@ var config3 = {
60750
60744
  var docusaurus_default = config3;
60751
60745
 
60752
60746
  // src/frameworks/gatsby/index.ts
60753
- var { npm: npm3, dlx: dlx4 } = detectPackageManager();
60747
+ var { npm: npm3 } = detectPackageManager();
60754
60748
  var generate4 = async (ctx) => {
60755
60749
  const defaultTemplate = "https://github.com/gatsbyjs/gatsby-starter-blog";
60756
60750
  const useTemplate = await inputPrompt({
@@ -60768,11 +60762,7 @@ var generate4 = async (ctx) => {
60768
60762
  defaultValue: defaultTemplate
60769
60763
  });
60770
60764
  }
60771
- const cli = getFrameworkCli(ctx);
60772
- await runFrameworkGenerator(
60773
- ctx,
60774
- `${dlx4} ${cli} new ${ctx.project.name} ${templateUrl}`
60775
- );
60765
+ await runFrameworkGenerator(ctx, `new ${ctx.project.name} ${templateUrl}`);
60776
60766
  };
60777
60767
  var config4 = {
60778
60768
  generate: generate4,
@@ -60785,12 +60775,10 @@ var config4 = {
60785
60775
  var gatsby_default = config4;
60786
60776
 
60787
60777
  // src/frameworks/hono/index.ts
60788
- var { dlx: dlx5 } = detectPackageManager();
60789
60778
  var generate5 = async (ctx) => {
60790
- const cli = getFrameworkCli(ctx);
60791
60779
  await runFrameworkGenerator(
60792
60780
  ctx,
60793
- `${dlx5} ${cli} ${ctx.project.name} --template cloudflare-workers`
60781
+ `${ctx.project.name} --template cloudflare-workers`
60794
60782
  );
60795
60783
  logRaw("");
60796
60784
  };
@@ -60854,11 +60842,10 @@ export async function GET(request) {
60854
60842
  `;
60855
60843
 
60856
60844
  // src/frameworks/next/index.ts
60857
- var { npm: npm4, npx: npx3, dlx: dlx6 } = detectPackageManager();
60845
+ var { npm: npm4, npx: npx2 } = detectPackageManager();
60858
60846
  var generate6 = async (ctx) => {
60859
60847
  const projectName = ctx.project.name;
60860
- const cli = getFrameworkCli(ctx);
60861
- await runFrameworkGenerator(ctx, `${dlx6} ${cli} ${projectName}`);
60848
+ await runFrameworkGenerator(ctx, `${projectName}`);
60862
60849
  };
60863
60850
  var getApiTemplate = (apiPath, isTypescript) => {
60864
60851
  const isAppDir = /\/app\/api$/.test(apiPath);
@@ -60943,7 +60930,7 @@ var config6 = {
60943
60930
  const isNpmOrBun = isNpm || isBun;
60944
60931
  const nextOnPagesScope = isNpmOrBun ? "@cloudflare/" : "";
60945
60932
  const nextOnPagesCommand = `${nextOnPagesScope}next-on-pages`;
60946
- const pmCommand = isNpmOrBun ? npx3 : npm4;
60933
+ const pmCommand = isNpmOrBun ? npx2 : npm4;
60947
60934
  const pagesDeployCommand = isNpm ? "npm run" : isBun ? "bun" : pmCommand;
60948
60935
  return {
60949
60936
  "pages:build": `${pmCommand} ${nextOnPagesCommand}`,
@@ -60967,13 +60954,12 @@ var config6 = {
60967
60954
  var next_default = config6;
60968
60955
 
60969
60956
  // src/frameworks/nuxt/index.ts
60970
- var { npm: npm5, dlx: dlx7 } = detectPackageManager();
60957
+ var { npm: npm5 } = detectPackageManager();
60971
60958
  var generate7 = async (ctx) => {
60972
- const cli = getFrameworkCli(ctx);
60973
60959
  const gitFlag = ctx.args.git ? `--gitInit` : `--no-gitInit`;
60974
60960
  await runFrameworkGenerator(
60975
60961
  ctx,
60976
- `${dlx7} ${cli} init ${ctx.project.name} --packageManager ${npm5} ${gitFlag}`
60962
+ `init ${ctx.project.name} --packageManager ${npm5} ${gitFlag}`
60977
60963
  );
60978
60964
  logRaw("");
60979
60965
  };
@@ -61003,22 +60989,22 @@ var package_default = {
61003
60989
  "additionally it also contains a map that maps frameworks to their respective clis"
61004
60990
  ],
61005
60991
  dependencies: {
61006
- "@angular/cli": "16.2.2",
61007
- "create-astro": "4.3.0",
61008
- "create-docusaurus": "2.4.3",
60992
+ "create-astro": "4.5.1",
60993
+ "@angular/create": "17.0.0-rc.4",
60994
+ "create-docusaurus": "3.0.0",
61009
60995
  "create-hono": "0.3.2",
61010
60996
  "create-next-app": "13.4.19",
61011
- "create-qwik": "1.2.14",
60997
+ "create-qwik": "1.2.17",
61012
60998
  "create-react-app": "5.0.1",
61013
- "create-remix": "2.1.0",
61014
- "create-solid": "0.3.8",
60999
+ "create-remix": "2.2.0",
61000
+ "create-solid": "0.3.9",
61015
61001
  "create-svelte": "5.1.1",
61016
61002
  "create-vue": "3.8.0",
61017
- gatsby: "5.12.8",
61018
- nuxi: "3.9.0"
61003
+ gatsby: "5.12.9",
61004
+ nuxi: "3.9.1"
61019
61005
  },
61020
61006
  frameworkCliMap: {
61021
- angular: "@angular/cli",
61007
+ angular: "@angular/create",
61022
61008
  astro: "create-astro",
61023
61009
  docusaurus: "create-docusaurus",
61024
61010
  gatsby: "gatsby",
@@ -61035,15 +61021,14 @@ var package_default = {
61035
61021
  };
61036
61022
 
61037
61023
  // src/frameworks/qwik/index.ts
61038
- var { npm: npm6, npx: npx4, dlx: dlx8 } = detectPackageManager();
61024
+ var { npm: npm6, npx: npx3 } = detectPackageManager();
61039
61025
  var generate8 = async (ctx) => {
61040
- const cli = getFrameworkCli(ctx);
61041
- await runFrameworkGenerator(ctx, `${dlx8} ${cli} basic ${ctx.project.name}`);
61026
+ await runFrameworkGenerator(ctx, `basic ${ctx.project.name}`);
61042
61027
  };
61043
61028
  var configure5 = async (ctx) => {
61044
61029
  process.chdir(ctx.project.path);
61045
61030
  await npmInstall();
61046
- const cmd = `${npx4} qwik add cloudflare-pages`;
61031
+ const cmd = `${npx3} qwik add cloudflare-pages`;
61047
61032
  endSection(`Running ${cmd}`);
61048
61033
  await runCommand(cmd);
61049
61034
  };
@@ -61059,18 +61044,13 @@ var config8 = {
61059
61044
  var qwik_default = config8;
61060
61045
 
61061
61046
  // src/frameworks/react/index.ts
61062
- var { npm: npm7, dlx: dlx9 } = detectPackageManager();
61047
+ var { npm: npm7 } = detectPackageManager();
61063
61048
  var generate9 = async (ctx) => {
61064
- const cli = getFrameworkCli(ctx);
61065
- await runFrameworkGenerator(ctx, `${dlx9} ${cli} ${ctx.project.name}`);
61049
+ await runFrameworkGenerator(ctx, `${ctx.project.name}`);
61066
61050
  logRaw("");
61067
61051
  };
61068
- var configure6 = async (ctx) => {
61069
- await resetPackageManager(ctx);
61070
- };
61071
61052
  var config9 = {
61072
61053
  generate: generate9,
61073
- configure: configure6,
61074
61054
  displayName: "React",
61075
61055
  getPackageScripts: async () => ({
61076
61056
  "pages:dev": `wrangler pages dev ${await compatDateFlag()} --port 3000 -- ${npm7} start`,
@@ -61080,12 +61060,11 @@ var config9 = {
61080
61060
  var react_default = config9;
61081
61061
 
61082
61062
  // src/frameworks/remix/index.ts
61083
- var { npm: npm8, dlx: dlx10 } = detectPackageManager();
61063
+ var { npm: npm8 } = detectPackageManager();
61084
61064
  var generate10 = async (ctx) => {
61085
- const cli = getFrameworkCli(ctx);
61086
61065
  await runFrameworkGenerator(
61087
61066
  ctx,
61088
- `${dlx10} ${cli} ${ctx.project.name} --template https://github.com/remix-run/remix/tree/main/templates/cloudflare-pages`
61067
+ `${ctx.project.name} --template https://github.com/remix-run/remix/tree/main/templates/cloudflare-pages`
61089
61068
  );
61090
61069
  logRaw("");
61091
61070
  };
@@ -61112,13 +61091,12 @@ export default defineConfig({
61112
61091
  `;
61113
61092
 
61114
61093
  // src/frameworks/solid/index.ts
61115
- var { npm: npm9, dlx: dlx11 } = detectPackageManager();
61094
+ var { npm: npm9 } = detectPackageManager();
61116
61095
  var generate11 = async (ctx) => {
61117
- const cli = getFrameworkCli(ctx);
61118
- await runFrameworkGenerator(ctx, `${dlx11} ${cli} ${ctx.project.name}`);
61096
+ await runFrameworkGenerator(ctx, `${ctx.project.name}`);
61119
61097
  logRaw("");
61120
61098
  };
61121
- var configure7 = async (ctx) => {
61099
+ var configure6 = async (ctx) => {
61122
61100
  process.chdir(ctx.project.path);
61123
61101
  const pkg = "solid-start-cloudflare-pages";
61124
61102
  await installPackages([pkg], {
@@ -61134,7 +61112,7 @@ var configure7 = async (ctx) => {
61134
61112
  };
61135
61113
  var config11 = {
61136
61114
  generate: generate11,
61137
- configure: configure7,
61115
+ configure: configure6,
61138
61116
  displayName: "Solid",
61139
61117
  getPackageScripts: async () => ({
61140
61118
  "pages:dev": `wrangler pages dev ${await compatDateFlag()} --proxy 3000 -- ${npm9} run dev`,
@@ -61190,13 +61168,12 @@ interface Platform {
61190
61168
  `;
61191
61169
 
61192
61170
  // src/frameworks/svelte/index.ts
61193
- var { npm: npm10, dlx: dlx12 } = detectPackageManager();
61171
+ var { npm: npm10 } = detectPackageManager();
61194
61172
  var generate12 = async (ctx) => {
61195
- const cli = getFrameworkCli(ctx);
61196
- await runFrameworkGenerator(ctx, `${dlx12} ${cli} ${ctx.project.name}`);
61173
+ await runFrameworkGenerator(ctx, `${ctx.project.name}`);
61197
61174
  logRaw("");
61198
61175
  };
61199
- var configure8 = async (ctx) => {
61176
+ var configure7 = async (ctx) => {
61200
61177
  process.chdir(ctx.project.path);
61201
61178
  await npmInstall();
61202
61179
  const pkg = `@sveltejs/adapter-cloudflare`;
@@ -61231,7 +61208,7 @@ var configure8 = async (ctx) => {
61231
61208
  };
61232
61209
  var config12 = {
61233
61210
  generate: generate12,
61234
- configure: configure8,
61211
+ configure: configure7,
61235
61212
  displayName: "Svelte",
61236
61213
  getPackageScripts: async () => ({
61237
61214
  "pages:dev": `wrangler pages dev ${await compatDateFlag()} --proxy 5173 -- ${npm10} run dev`,
@@ -61241,10 +61218,9 @@ var config12 = {
61241
61218
  var svelte_default = config12;
61242
61219
 
61243
61220
  // src/frameworks/vue/index.ts
61244
- var { npm: npm11, dlx: dlx13 } = detectPackageManager();
61221
+ var { npm: npm11 } = detectPackageManager();
61245
61222
  var generate13 = async (ctx) => {
61246
- const cli = getFrameworkCli(ctx);
61247
- await runFrameworkGenerator(ctx, `${dlx13} ${cli} ${ctx.project.name}`);
61223
+ await runFrameworkGenerator(ctx, `${ctx.project.name}`);
61248
61224
  };
61249
61225
  var config13 = {
61250
61226
  generate: generate13,
@@ -61416,16 +61392,19 @@ function secondsSince(start) {
61416
61392
  }
61417
61393
 
61418
61394
  // ../wrangler/package.json
61419
- var version2 = "3.15.0";
61395
+ var version2 = "3.16.0";
61420
61396
 
61421
61397
  // src/common.ts
61422
61398
  var { name, npm: npm12 } = detectPackageManager();
61423
61399
  var validateProjectDirectory = (relativePath, args) => {
61424
61400
  const path3 = (0, import_path7.resolve)(relativePath);
61425
61401
  const existsAlready = (0, import_fs8.existsSync)(path3);
61426
- const isEmpty = existsAlready && (0, import_fs8.readdirSync)(path3).length === 0;
61427
- if (existsAlready && !isEmpty) {
61428
- return `Directory \`${relativePath}\` already exists and is not empty. Please choose a new name.`;
61402
+ if (existsAlready) {
61403
+ for (const file of (0, import_fs8.readdirSync)(path3)) {
61404
+ if (!isAllowedExistingFile(file)) {
61405
+ return `Directory \`${relativePath}\` already exists and contains files that might conflict. Please choose a new name.`;
61406
+ }
61407
+ }
61429
61408
  }
61430
61409
  if (!args.existingScript) {
61431
61410
  const projectName = (0, import_path7.basename)(path3);
@@ -61442,6 +61421,46 @@ var validateProjectDirectory = (relativePath, args) => {
61442
61421
  }
61443
61422
  }
61444
61423
  };
61424
+ var isAllowedExistingFile = (file) => {
61425
+ const allowedExistingFiles = /* @__PURE__ */ new Set([
61426
+ ".DS_Store",
61427
+ ".git",
61428
+ ".gitattributes",
61429
+ ".gitignore",
61430
+ ".gitlab-ci.yml",
61431
+ ".hg",
61432
+ ".hgcheck",
61433
+ ".hgignore",
61434
+ ".idea",
61435
+ ".npmignore",
61436
+ ".travis.yml",
61437
+ ".vscode",
61438
+ "Thumbs.db",
61439
+ "docs",
61440
+ "mkdocs.yml",
61441
+ "npm-debug.log",
61442
+ "yarn-debug.log",
61443
+ "yarn-error.log",
61444
+ "yarnrc.yml",
61445
+ ".yarn",
61446
+ ".gitkeep"
61447
+ ]);
61448
+ if (allowedExistingFiles.has(file))
61449
+ return true;
61450
+ const allowedExistingPatters = [
61451
+ /readme(\.md)?$/i,
61452
+ /license(\.md)?$/i,
61453
+ /\.iml$/,
61454
+ /^npm-debug\.log/,
61455
+ /^yarn-debug\.log/,
61456
+ /^yarn-error\.log/
61457
+ ];
61458
+ for (const regex2 of allowedExistingPatters) {
61459
+ if (regex2.test(file))
61460
+ return true;
61461
+ }
61462
+ return false;
61463
+ };
61445
61464
  var setupProjectDirectory = (args) => {
61446
61465
  const path3 = (0, import_path7.resolve)(args.projectName);
61447
61466
  const err = validateProjectDirectory(path3, args);
@@ -61774,7 +61793,7 @@ async function getProductionBranch(cwd) {
61774
61793
  // src/pages.ts
61775
61794
  var CREATE_PROJECT_RETRIES = 3;
61776
61795
  var VERIFY_PROJECT_RETRIES = 3;
61777
- var { npx: npx5 } = detectPackageManager();
61796
+ var { npx: npx4 } = detectPackageManager();
61778
61797
  var defaultFrameworkConfig = {
61779
61798
  deployCommand: "pages:deploy",
61780
61799
  devCommand: "pages:dev"
@@ -61801,11 +61820,12 @@ var runPagesGenerator = async (args) => {
61801
61820
  type: frameworkConfig.type,
61802
61821
  originalCWD
61803
61822
  };
61804
- const { generate: generate14, configure: configure9 } = FrameworkMap[framework];
61823
+ const { generate: generate14, configure: configure8 } = FrameworkMap[framework];
61805
61824
  await generate14({ ...ctx });
61806
61825
  startSection("Configuring your application for Cloudflare", "Step 2 of 3");
61807
- if (configure9) {
61808
- await configure9({ ...ctx });
61826
+ await resetPackageManager(ctx);
61827
+ if (configure8) {
61828
+ await configure8({ ...ctx });
61809
61829
  }
61810
61830
  await updatePackageScripts(ctx);
61811
61831
  await offerGit(ctx);
@@ -61887,7 +61907,7 @@ var createProject = async (ctx) => {
61887
61907
  );
61888
61908
  const compatFlagsArg = compatFlags ? `--compatibility-flags ${compatFlags}` : "";
61889
61909
  const productionBranch = await getProductionBranch(ctx.project.path);
61890
- const cmd = `${npx5} wrangler pages project create ${ctx.project.name} --production-branch ${productionBranch} ${compatFlagsArg}`;
61910
+ const cmd = `${npx4} wrangler pages project create ${ctx.project.name} --production-branch ${productionBranch} ${compatFlagsArg}`;
61891
61911
  await retry(
61892
61912
  {
61893
61913
  times: CREATE_PROJECT_RETRIES,
@@ -61912,7 +61932,7 @@ var createProject = async (ctx) => {
61912
61932
  crash("Failed to create pages project. See output above.");
61913
61933
  }
61914
61934
  try {
61915
- const verifyProject = `${npx5} wrangler pages deployment list --project-name ${ctx.project.name}`;
61935
+ const verifyProject = `${npx4} wrangler pages deployment list --project-name ${ctx.project.name}`;
61916
61936
  await retry(
61917
61937
  { times: VERIFY_PROJECT_RETRIES },
61918
61938
  async () => runCommand(verifyProject, {
@@ -61936,7 +61956,7 @@ var import_promises2 = require("fs/promises");
61936
61956
  var import_os = require("os");
61937
61957
  var import_path9 = require("path");
61938
61958
  var import_process4 = require("process");
61939
- var { dlx: dlx14 } = detectPackageManager();
61959
+ var { dlx } = detectPackageManager();
61940
61960
  var runWorkersGenerator = async (args) => {
61941
61961
  const originalCWD = process.cwd();
61942
61962
  const { name: name2, path: path3 } = setupProjectDirectory(args);
@@ -62005,7 +62025,7 @@ async function copyExistingWorkerFiles(ctx) {
62005
62025
  (0, import_path9.join)((0, import_os.tmpdir)(), "c3-wrangler-init--from-dash-")
62006
62026
  );
62007
62027
  await runCommand(
62008
- `${dlx14} wrangler@3 init --from-dash ${ctx.args.existingScript} -y --no-delegate-c3`,
62028
+ `${dlx} wrangler@3 init --from-dash ${ctx.args.existingScript} -y --no-delegate-c3`,
62009
62029
  {
62010
62030
  silent: true,
62011
62031
  cwd: tempdir,
@@ -62105,26 +62125,61 @@ var parseArgs = async (argv) => {
62105
62125
  doubleDashesIdx < 0 ? void 0 : doubleDashesIdx
62106
62126
  );
62107
62127
  const additionalArgs = doubleDashesIdx < 0 ? [] : argv.slice(doubleDashesIdx + 1);
62108
- const yargsObj = yargs_default(hideBin(c3Args)).scriptName("create-cloudflare").usage("$0 [args]").positional("name", { type: "string" }).option("type", { type: "string" }).option("framework", { type: "string" }).option("deploy", { type: "boolean" }).option("ts", { type: "boolean" }).option("git", { type: "boolean" }).option("open", {
62128
+ const yargsObj = yargs_default(hideBin(c3Args)).scriptName("create-cloudflare").usage("$0 [args]").positional("directory", {
62129
+ type: "string",
62130
+ description: "The directory where the application should be created. The name of the application is taken from the directory name"
62131
+ }).option("type", {
62132
+ type: "string",
62133
+ description: "The type of application that should be created"
62134
+ }).option("framework", {
62135
+ type: "string",
62136
+ description: "The type of framework to use to create a web application (when using this option `--type` is ignored)"
62137
+ }).option("deploy", {
62138
+ type: "boolean",
62139
+ description: "Deploy your application after it has been created"
62140
+ }).option("ts", {
62141
+ type: "boolean",
62142
+ description: "Use TypeScript in your application"
62143
+ }).option("git", {
62144
+ type: "boolean",
62145
+ description: "Initialize a local git repository for your application"
62146
+ }).option("open", {
62109
62147
  type: "boolean",
62110
62148
  default: true,
62111
- description: "opens your browser after your deployment, set --no-open to disable"
62149
+ description: "Opens the deployed application in your browser (this option is ignored if the application is not deployed)"
62112
62150
  }).option("existing-script", {
62113
62151
  type: "string",
62114
62152
  hidden: templateMap["pre-existing"].hidden
62115
62153
  }).option("accept-defaults", {
62116
62154
  alias: "y",
62117
- type: "boolean"
62155
+ type: "boolean",
62156
+ description: "Use all the default C3 options (each can also be overridden by specifying it)"
62118
62157
  }).option("auto-update", {
62119
62158
  type: "boolean",
62120
62159
  default: C3_DEFAULTS.autoUpdate,
62121
- description: "Automatically uses the latest version of `create-cloudflare`. Set --no-auto-update to disable"
62122
- }).option("wrangler-defaults", { type: "boolean", hidden: true }).version(version).strictOptions().alias("h", "help").help();
62123
- const args = await yargsObj.argv;
62160
+ description: "Automatically uses the latest version of C3"
62161
+ }).option("wrangler-defaults", { type: "boolean", hidden: true }).version(version).alias("v", "version").strictOptions().exitProcess(false).alias("h", "help").help();
62162
+ let args = null;
62163
+ try {
62164
+ args = await yargsObj.argv;
62165
+ } catch {
62166
+ }
62167
+ if (args === null) {
62168
+ showMoreInfoNote();
62169
+ process.exit(1);
62170
+ }
62171
+ if (args.version) {
62172
+ process.exit(0);
62173
+ }
62174
+ if (args.help) {
62175
+ showMoreInfoNote();
62176
+ process.exit(0);
62177
+ }
62124
62178
  const positionalArgs = args._;
62125
62179
  if (positionalArgs.length > 1) {
62126
62180
  yargsObj.showHelp();
62127
62181
  console.error("\nToo many positional arguments provided");
62182
+ showMoreInfoNote();
62128
62183
  process.exit(1);
62129
62184
  }
62130
62185
  return {
@@ -62150,6 +62205,13 @@ var processArgument = async (args, name2, promptConfig) => {
62150
62205
  value = await inputPrompt(promptConfig);
62151
62206
  return value;
62152
62207
  };
62208
+ var showMoreInfoNote = () => {
62209
+ const c3CliArgsDocsPage = "https://developers.cloudflare.com/pages/get-started/c3/#cli-arguments";
62210
+ console.log(
62211
+ `
62212
+ For more information regarding how to invoke C3 please visit ${c3CliArgsDocsPage}`
62213
+ );
62214
+ };
62153
62215
 
62154
62216
  // src/cli.ts
62155
62217
  var import_semver2 = __toESM(require_semver2());
@@ -62209,9 +62271,12 @@ var runCli = async (args) => {
62209
62271
  options: templateOptions,
62210
62272
  defaultValue: C3_DEFAULTS.type
62211
62273
  });
62212
- if (!type || !Object.keys(templateMap).includes(type)) {
62274
+ if (!type) {
62213
62275
  return crash("An application type must be specified to continue.");
62214
62276
  }
62277
+ if (!Object.keys(templateMap).includes(type)) {
62278
+ return crash(`Unknown application type provided: ${type}.`);
62279
+ }
62215
62280
  const validatedArgs = {
62216
62281
  ...args,
62217
62282
  type,