create-cloudflare 0.0.0-78ddb8de → 0.0.0-821b9d2b

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-78ddb8de";
59413
+ var version = "0.0.0-821b9d2b";
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,7 +59850,7 @@ var chooseAccount = async (ctx) => {
59846
59850
  };
59847
59851
  var printSummary = async (ctx) => {
59848
59852
  const nextSteps = [
59849
- [`Navigate to the new directory:`, `cd ${ctx.project.name}`],
59853
+ [`Navigate to the new directory`, `cd ${ctx.project.name}`],
59850
59854
  [
59851
59855
  `Run the development server`,
59852
59856
  `${npm} run ${ctx.framework?.config.devCommand ?? "start"}`
@@ -59973,6 +59977,24 @@ async function initializeGit(cwd) {
59973
59977
  await runCommand(`git init`, { useSpinner: false, silent: true, cwd });
59974
59978
  }
59975
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
+ }
59976
59998
 
59977
59999
  // src/pages.ts
59978
60000
  var import_path8 = require("path");
@@ -60363,6 +60385,7 @@ var generate7 = async (ctx) => {
60363
60385
  };
60364
60386
  var configure4 = async (ctx) => {
60365
60387
  process.chdir(ctx.project.path);
60388
+ writeFile2("./.node-version", "17");
60366
60389
  await npmInstall();
60367
60390
  };
60368
60391
  var config7 = {
@@ -60370,8 +60393,9 @@ var config7 = {
60370
60393
  configure: configure4,
60371
60394
  displayName: "Nuxt",
60372
60395
  packageScripts: {
60396
+ build: (cmd) => `NITRO_PRESET=cloudflare-pages ${cmd}`,
60373
60397
  "pages:dev": `wrangler pages dev ${compatDateFlag()} --proxy 3000 -- npm run dev`,
60374
- "pages:deploy": `NODE_VERSION=17 npm run generate && wrangler pages deploy ./dist`
60398
+ "pages:deploy": "npm run build && wrangler pages deploy ./dist"
60375
60399
  }
60376
60400
  };
60377
60401
  var nuxt_default = config7;
@@ -60486,7 +60510,7 @@ var config11 = {
60486
60510
  displayName: "Solid",
60487
60511
  packageScripts: {
60488
60512
  "pages:dev": `wrangler pages dev ${compatDateFlag()} --proxy 3000 -- ${npm9} run dev`,
60489
- "pages:deploy": `${npm9} run build build && wrangler pages deploy ./dist/public`
60513
+ "pages:deploy": `${npm9} run build && wrangler pages deploy ./dist/public`
60490
60514
  }
60491
60515
  };
60492
60516
  var solid_default = config11;
@@ -60721,11 +60745,29 @@ var updatePackageScripts = async (ctx) => {
60721
60745
  const { packageScripts } = ctx.framework?.config ?? {};
60722
60746
  if (packageScripts) {
60723
60747
  const s = spinner();
60724
- 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
+ );
60725
60755
  const pkgJsonPath = (0, import_path8.resolve)("package.json");
60726
60756
  const pkgConfig = readJSON(pkgJsonPath);
60727
- Object.entries(packageScripts).forEach(([target, command2]) => {
60728
- 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
+ }
60729
60771
  });
60730
60772
  writeFile2(pkgJsonPath, JSON.stringify(pkgConfig, null, 2));
60731
60773
  s.stop(`${brandColor("added")} ${dim("commands to `package.json`")}`);
@@ -60741,7 +60783,8 @@ var createProject = async (ctx) => {
60741
60783
  const CLOUDFLARE_ACCOUNT_ID = ctx.account.id;
60742
60784
  const compatFlags = ctx.framework?.config.compatibilityFlags?.join(" ");
60743
60785
  const compatFlagsArg = compatFlags ? `--compatibility-flags ${compatFlags}` : "";
60744
- 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}`;
60745
60788
  try {
60746
60789
  await retry(
60747
60790
  CREATE_PROJECT_RETRIES,
@@ -60750,7 +60793,7 @@ var createProject = async (ctx) => {
60750
60793
  cwd: ctx.project.path,
60751
60794
  env: { CLOUDFLARE_ACCOUNT_ID },
60752
60795
  startText: "Creating Pages project",
60753
- doneText: `${brandColor("created")} ${dim(`via \`${cmd}\``)}`
60796
+ doneText: `${brandColor("created")} ${dim(`via \`${cmd.trim()}\``)}`
60754
60797
  })
60755
60798
  );
60756
60799
  } catch (error) {
@@ -60784,14 +60827,12 @@ var runWorkersGenerator = async (args) => {
60784
60827
  await printSummary(ctx);
60785
60828
  };
60786
60829
  async function getTemplate(ctx) {
60787
- if (ctx.args.ts === void 0) {
60788
- ctx.args.ts = await processArgument(ctx.args, "ts", {
60789
- type: "confirm",
60790
- question: "Do you want to use TypeScript?",
60791
- label: "typescript",
60792
- defaultValue: C3_DEFAULTS.ts
60793
- });
60794
- }
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
+ });
60795
60836
  const preexisting = ctx.args.type === "pre-existing";
60796
60837
  const template = preexisting ? "hello-world" : ctx.args.type;
60797
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-78ddb8de",
3
+ "version": "0.0.0-821b9d2b",
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
  }