create-cloudflare 0.0.0-e16d0272 → 0.0.0-e2234bbc

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
@@ -53155,8 +53155,6 @@ var space = (n = 1) => {
53155
53155
  return hidden("\u200A".repeat(n));
53156
53156
  };
53157
53157
  var logRaw = (msg) => {
53158
- if (process.env.VITEST)
53159
- return;
53160
53158
  process.stdout.write(`${msg}
53161
53159
  `);
53162
53160
  };
@@ -59412,7 +59410,7 @@ var Yargs = YargsFactory(esm_default);
59412
59410
  var yargs_default = Yargs;
59413
59411
 
59414
59412
  // package.json
59415
- var version = "0.0.0-e16d0272";
59413
+ var version = "0.0.0-e2234bbc";
59416
59414
 
59417
59415
  // src/common.ts
59418
59416
  var import_fs6 = require("fs");
@@ -59473,15 +59471,14 @@ var runCommand = async (command2, opts = {}) => {
59473
59471
  }
59474
59472
  return printAsyncStatus({
59475
59473
  useSpinner: opts.useSpinner ?? opts.silent,
59476
- startText: opts.startText || command2.join(" "),
59474
+ startText: opts.startText || command2.join(" ").trim(),
59477
59475
  doneText: opts.doneText,
59478
59476
  promise() {
59479
59477
  const [executable, ...args] = command2;
59480
- const squelch = opts.silent || process.env.VITEST;
59481
59478
  const cmd = (0, import_cross_spawn.spawn)(executable, [...args], {
59482
59479
  // TODO: ideally inherit stderr, but npm install uses this for warnings
59483
59480
  // stdio: [ioMode, ioMode, "inherit"],
59484
- stdio: squelch ? "pipe" : "inherit",
59481
+ stdio: opts.silent ? "pipe" : "inherit",
59485
59482
  env: {
59486
59483
  ...process.env,
59487
59484
  ...opts.env
@@ -59489,7 +59486,7 @@ var runCommand = async (command2, opts = {}) => {
59489
59486
  cwd: opts.cwd
59490
59487
  });
59491
59488
  let output = ``;
59492
- if (opts?.captureOutput ?? squelch) {
59489
+ if (opts.captureOutput ?? opts.silent) {
59493
59490
  cmd.stdout?.on("data", (data) => {
59494
59491
  output += data;
59495
59492
  });
@@ -59514,6 +59511,9 @@ var runCommand = async (command2, opts = {}) => {
59514
59511
  }
59515
59512
  }
59516
59513
  });
59514
+ cmd.on("error", (code) => {
59515
+ reject(code);
59516
+ });
59517
59517
  });
59518
59518
  }
59519
59519
  });
@@ -59624,10 +59624,14 @@ var installWrangler = async () => {
59624
59624
  };
59625
59625
  var isLoggedIn = async () => {
59626
59626
  const { npx: npx6 } = detectPackageManager();
59627
- const output = await runCommand(`${npx6} wrangler whoami`, {
59628
- silent: true
59629
- });
59630
- return !/not authenticated/.test(output);
59627
+ try {
59628
+ const output = await runCommand(`${npx6} wrangler whoami`, {
59629
+ silent: true
59630
+ });
59631
+ return /You are logged in/.test(output);
59632
+ } catch (error) {
59633
+ return false;
59634
+ }
59631
59635
  };
59632
59636
  var wranglerLogin = async () => {
59633
59637
  const { npx: npx6 } = detectPackageManager();
@@ -59846,6 +59850,7 @@ var chooseAccount = async (ctx) => {
59846
59850
  };
59847
59851
  var printSummary = async (ctx) => {
59848
59852
  const nextSteps = [
59853
+ [`Navigate to the new directory`, `cd ${ctx.project.name}`],
59849
59854
  [
59850
59855
  `Run the development server`,
59851
59856
  `${npm} run ${ctx.framework?.config.devCommand ?? "start"}`
@@ -59972,6 +59977,24 @@ async function initializeGit(cwd) {
59972
59977
  await runCommand(`git init`, { useSpinner: false, silent: true, cwd });
59973
59978
  }
59974
59979
  }
59980
+ async function getProductionBranch(cwd) {
59981
+ try {
59982
+ const productionBranch = await runCommand(
59983
+ // "git branch --show-current", // git@^2.22
59984
+ "git rev-parse --abbrev-ref HEAD",
59985
+ // git@^1.6.3
59986
+ {
59987
+ silent: true,
59988
+ cwd,
59989
+ useSpinner: false,
59990
+ captureOutput: true
59991
+ }
59992
+ );
59993
+ return productionBranch.trim();
59994
+ } catch (err) {
59995
+ }
59996
+ return "main";
59997
+ }
59975
59998
 
59976
59999
  // src/pages.ts
59977
60000
  var import_path8 = require("path");
@@ -60362,6 +60385,7 @@ var generate7 = async (ctx) => {
60362
60385
  };
60363
60386
  var configure4 = async (ctx) => {
60364
60387
  process.chdir(ctx.project.path);
60388
+ writeFile2("./.node-version", "17");
60365
60389
  await npmInstall();
60366
60390
  };
60367
60391
  var config7 = {
@@ -60369,8 +60393,9 @@ var config7 = {
60369
60393
  configure: configure4,
60370
60394
  displayName: "Nuxt",
60371
60395
  packageScripts: {
60396
+ build: (cmd) => `NITRO_PRESET=cloudflare-pages ${cmd}`,
60372
60397
  "pages:dev": `wrangler pages dev ${compatDateFlag()} --proxy 3000 -- npm run dev`,
60373
- "pages:deploy": `NODE_VERSION=17 npm run generate && wrangler pages deploy ./dist`
60398
+ "pages:deploy": "npm run build && wrangler pages deploy ./dist"
60374
60399
  }
60375
60400
  };
60376
60401
  var nuxt_default = config7;
@@ -60485,7 +60510,7 @@ var config11 = {
60485
60510
  displayName: "Solid",
60486
60511
  packageScripts: {
60487
60512
  "pages:dev": `wrangler pages dev ${compatDateFlag()} --proxy 3000 -- ${npm9} run dev`,
60488
- "pages:deploy": `${npm9} run build build && wrangler pages deploy ./dist/public`
60513
+ "pages:deploy": `${npm9} run build && wrangler pages deploy ./dist/public`
60489
60514
  }
60490
60515
  };
60491
60516
  var solid_default = config11;
@@ -60720,11 +60745,29 @@ var updatePackageScripts = async (ctx) => {
60720
60745
  const { packageScripts } = ctx.framework?.config ?? {};
60721
60746
  if (packageScripts) {
60722
60747
  const s = spinner();
60723
- s.start(`Adding command scripts`, `for development and deployment`);
60748
+ const updatingScripts = Object.entries(packageScripts).filter(
60749
+ ([_3, cmdOrUpdater]) => typeof cmdOrUpdater === "function"
60750
+ ).length > 0;
60751
+ s.start(
60752
+ `${updatingScripts ? "Updating" : "Adding"} command scripts`,
60753
+ "for development and deployment"
60754
+ );
60724
60755
  const pkgJsonPath = (0, import_path8.resolve)("package.json");
60725
60756
  const pkgConfig = readJSON(pkgJsonPath);
60726
- Object.entries(packageScripts).forEach(([target, command2]) => {
60727
- pkgConfig.scripts[target] = command2;
60757
+ Object.entries(packageScripts).forEach(([target, cmdOrUpdater]) => {
60758
+ if (typeof cmdOrUpdater === "string") {
60759
+ const command2 = cmdOrUpdater;
60760
+ pkgConfig.scripts[target] = command2;
60761
+ } else {
60762
+ const existingCommand = pkgConfig.scripts[target];
60763
+ if (!existingCommand) {
60764
+ throw new Error(
60765
+ `Could not find ${target} script to update during ${ctx.framework} setup`
60766
+ );
60767
+ }
60768
+ const updater = cmdOrUpdater;
60769
+ pkgConfig.scripts[target] = updater(existingCommand);
60770
+ }
60728
60771
  });
60729
60772
  writeFile2(pkgJsonPath, JSON.stringify(pkgConfig, null, 2));
60730
60773
  s.stop(`${brandColor("added")} ${dim("commands to `package.json`")}`);
@@ -60740,7 +60783,8 @@ var createProject = async (ctx) => {
60740
60783
  const CLOUDFLARE_ACCOUNT_ID = ctx.account.id;
60741
60784
  const compatFlags = ctx.framework?.config.compatibilityFlags?.join(" ");
60742
60785
  const compatFlagsArg = compatFlags ? `--compatibility-flags ${compatFlags}` : "";
60743
- const cmd = `${npx5} wrangler pages project create ${ctx.project.name} --production-branch main ${compatFlagsArg}`;
60786
+ const productionBranch = await getProductionBranch(ctx.project.path);
60787
+ const cmd = `${npx5} wrangler pages project create ${ctx.project.name} --production-branch ${productionBranch} ${compatFlagsArg}`;
60744
60788
  try {
60745
60789
  await retry(
60746
60790
  CREATE_PROJECT_RETRIES,
@@ -60749,7 +60793,7 @@ var createProject = async (ctx) => {
60749
60793
  cwd: ctx.project.path,
60750
60794
  env: { CLOUDFLARE_ACCOUNT_ID },
60751
60795
  startText: "Creating Pages project",
60752
- doneText: `${brandColor("created")} ${dim(`via \`${cmd}\``)}`
60796
+ doneText: `${brandColor("created")} ${dim(`via \`${cmd.trim()}\``)}`
60753
60797
  })
60754
60798
  );
60755
60799
  } catch (error) {
@@ -60783,14 +60827,12 @@ var runWorkersGenerator = async (args) => {
60783
60827
  await printSummary(ctx);
60784
60828
  };
60785
60829
  async function getTemplate(ctx) {
60786
- if (ctx.args.ts === void 0) {
60787
- ctx.args.ts = await processArgument(ctx.args, "ts", {
60788
- type: "confirm",
60789
- question: "Do you want to use TypeScript?",
60790
- label: "typescript",
60791
- defaultValue: C3_DEFAULTS.ts
60792
- });
60793
- }
60830
+ ctx.args.ts = await processArgument(ctx.args, "ts", {
60831
+ type: "confirm",
60832
+ question: "Do you want to use TypeScript?",
60833
+ label: "typescript",
60834
+ defaultValue: C3_DEFAULTS.ts
60835
+ });
60794
60836
  const preexisting = ctx.args.type === "pre-existing";
60795
60837
  const template = preexisting ? "hello-world" : ctx.args.type;
60796
60838
  const path3 = (0, import_path9.resolve)(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-cloudflare",
3
- "version": "0.0.0-e16d0272",
3
+ "version": "0.0.0-e2234bbc",
4
4
  "description": "A CLI for creating and deploying new applications to Cloudflare.",
5
5
  "keywords": [
6
6
  "cloudflare",
@@ -7,7 +7,6 @@
7
7
  "start": "wrangler dev"
8
8
  },
9
9
  "devDependencies": {
10
- "@cloudflare/workers-types": "^4.20230419.0",
11
10
  "itty-router": "^3.0.12",
12
11
  "wrangler": "^3.0.0"
13
12
  }
@@ -7,8 +7,6 @@
7
7
  "start": "wrangler dev"
8
8
  },
9
9
  "devDependencies": {
10
- "@cloudflare/workers-types": "^4.20230419.0",
11
- "typescript": "^5.0.4",
12
10
  "wrangler": "^3.0.0"
13
11
  }
14
12
  }
@@ -7,8 +7,6 @@
7
7
  "start": "wrangler dev"
8
8
  },
9
9
  "devDependencies": {
10
- "@cloudflare/workers-types": "^4.20230419.0",
11
- "typescript": "^5.0.4",
12
10
  "wrangler": "^3.0.0"
13
11
  }
14
12
  }
@@ -7,8 +7,6 @@
7
7
  "start": "wrangler dev"
8
8
  },
9
9
  "devDependencies": {
10
- "@cloudflare/workers-types": "^4.20230419.0",
11
- "typescript": "^5.0.4",
12
10
  "wrangler": "^3.0.0"
13
11
  }
14
12
  }