create-cloudflare 0.0.0-da8356e8 → 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 +57 -23
- package/package.json +1 -1
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-
|
|
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:
|
|
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
|
|
59489
|
+
if (opts.captureOutput ?? opts.silent) {
|
|
59493
59490
|
cmd.stdout?.on("data", (data) => {
|
|
59494
59491
|
output += data;
|
|
59495
59492
|
});
|
|
@@ -59853,7 +59850,7 @@ var chooseAccount = async (ctx) => {
|
|
|
59853
59850
|
};
|
|
59854
59851
|
var printSummary = async (ctx) => {
|
|
59855
59852
|
const nextSteps = [
|
|
59856
|
-
[`Navigate to the new directory
|
|
59853
|
+
[`Navigate to the new directory`, `cd ${ctx.project.name}`],
|
|
59857
59854
|
[
|
|
59858
59855
|
`Run the development server`,
|
|
59859
59856
|
`${npm} run ${ctx.framework?.config.devCommand ?? "start"}`
|
|
@@ -59980,6 +59977,24 @@ async function initializeGit(cwd) {
|
|
|
59980
59977
|
await runCommand(`git init`, { useSpinner: false, silent: true, cwd });
|
|
59981
59978
|
}
|
|
59982
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
|
+
}
|
|
59983
59998
|
|
|
59984
59999
|
// src/pages.ts
|
|
59985
60000
|
var import_path8 = require("path");
|
|
@@ -60370,6 +60385,7 @@ var generate7 = async (ctx) => {
|
|
|
60370
60385
|
};
|
|
60371
60386
|
var configure4 = async (ctx) => {
|
|
60372
60387
|
process.chdir(ctx.project.path);
|
|
60388
|
+
writeFile2("./.node-version", "17");
|
|
60373
60389
|
await npmInstall();
|
|
60374
60390
|
};
|
|
60375
60391
|
var config7 = {
|
|
@@ -60377,8 +60393,9 @@ var config7 = {
|
|
|
60377
60393
|
configure: configure4,
|
|
60378
60394
|
displayName: "Nuxt",
|
|
60379
60395
|
packageScripts: {
|
|
60396
|
+
build: (cmd) => `NITRO_PRESET=cloudflare-pages ${cmd}`,
|
|
60380
60397
|
"pages:dev": `wrangler pages dev ${compatDateFlag()} --proxy 3000 -- npm run dev`,
|
|
60381
|
-
"pages:deploy":
|
|
60398
|
+
"pages:deploy": "npm run build && wrangler pages deploy ./dist"
|
|
60382
60399
|
}
|
|
60383
60400
|
};
|
|
60384
60401
|
var nuxt_default = config7;
|
|
@@ -60493,7 +60510,7 @@ var config11 = {
|
|
|
60493
60510
|
displayName: "Solid",
|
|
60494
60511
|
packageScripts: {
|
|
60495
60512
|
"pages:dev": `wrangler pages dev ${compatDateFlag()} --proxy 3000 -- ${npm9} run dev`,
|
|
60496
|
-
"pages:deploy": `${npm9} run build
|
|
60513
|
+
"pages:deploy": `${npm9} run build && wrangler pages deploy ./dist/public`
|
|
60497
60514
|
}
|
|
60498
60515
|
};
|
|
60499
60516
|
var solid_default = config11;
|
|
@@ -60728,11 +60745,29 @@ var updatePackageScripts = async (ctx) => {
|
|
|
60728
60745
|
const { packageScripts } = ctx.framework?.config ?? {};
|
|
60729
60746
|
if (packageScripts) {
|
|
60730
60747
|
const s = spinner();
|
|
60731
|
-
|
|
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
|
+
);
|
|
60732
60755
|
const pkgJsonPath = (0, import_path8.resolve)("package.json");
|
|
60733
60756
|
const pkgConfig = readJSON(pkgJsonPath);
|
|
60734
|
-
Object.entries(packageScripts).forEach(([target,
|
|
60735
|
-
|
|
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
|
+
}
|
|
60736
60771
|
});
|
|
60737
60772
|
writeFile2(pkgJsonPath, JSON.stringify(pkgConfig, null, 2));
|
|
60738
60773
|
s.stop(`${brandColor("added")} ${dim("commands to `package.json`")}`);
|
|
@@ -60748,7 +60783,8 @@ var createProject = async (ctx) => {
|
|
|
60748
60783
|
const CLOUDFLARE_ACCOUNT_ID = ctx.account.id;
|
|
60749
60784
|
const compatFlags = ctx.framework?.config.compatibilityFlags?.join(" ");
|
|
60750
60785
|
const compatFlagsArg = compatFlags ? `--compatibility-flags ${compatFlags}` : "";
|
|
60751
|
-
const
|
|
60786
|
+
const productionBranch = await getProductionBranch(ctx.project.path);
|
|
60787
|
+
const cmd = `${npx5} wrangler pages project create ${ctx.project.name} --production-branch ${productionBranch} ${compatFlagsArg}`;
|
|
60752
60788
|
try {
|
|
60753
60789
|
await retry(
|
|
60754
60790
|
CREATE_PROJECT_RETRIES,
|
|
@@ -60757,7 +60793,7 @@ var createProject = async (ctx) => {
|
|
|
60757
60793
|
cwd: ctx.project.path,
|
|
60758
60794
|
env: { CLOUDFLARE_ACCOUNT_ID },
|
|
60759
60795
|
startText: "Creating Pages project",
|
|
60760
|
-
doneText: `${brandColor("created")} ${dim(`via \`${cmd}\``)}`
|
|
60796
|
+
doneText: `${brandColor("created")} ${dim(`via \`${cmd.trim()}\``)}`
|
|
60761
60797
|
})
|
|
60762
60798
|
);
|
|
60763
60799
|
} catch (error) {
|
|
@@ -60791,14 +60827,12 @@ var runWorkersGenerator = async (args) => {
|
|
|
60791
60827
|
await printSummary(ctx);
|
|
60792
60828
|
};
|
|
60793
60829
|
async function getTemplate(ctx) {
|
|
60794
|
-
|
|
60795
|
-
|
|
60796
|
-
|
|
60797
|
-
|
|
60798
|
-
|
|
60799
|
-
|
|
60800
|
-
});
|
|
60801
|
-
}
|
|
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
|
+
});
|
|
60802
60836
|
const preexisting = ctx.args.type === "pre-existing";
|
|
60803
60837
|
const template = preexisting ? "hello-world" : ctx.args.type;
|
|
60804
60838
|
const path3 = (0, import_path9.resolve)(
|