create-cloudflare 0.0.0-e33bb44a → 0.0.0-e600f029
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
|
};
|
|
@@ -54509,9 +54507,9 @@ var getConfirmRenderers = (config14) => {
|
|
|
54509
54507
|
cancel: handleCancel
|
|
54510
54508
|
};
|
|
54511
54509
|
};
|
|
54510
|
+
var spinnerFrames = ["\u2524", "\u2518", "\u2534", "\u2514", "\u251C", "\u250C", "\u252C", "\u2510"];
|
|
54511
|
+
var ellipsisFrames = ["", ".", "..", "...", " ..", " .", ""];
|
|
54512
54512
|
var spinner = () => {
|
|
54513
|
-
const spinnerFrames = ["\u2524", "\u2518", "\u2534", "\u2514", "\u251C", "\u250C", "\u252C", "\u2510"];
|
|
54514
|
-
const ellipsisFrames = ["", ".", "..", "...", " ..", " .", ""];
|
|
54515
54513
|
const color = brandColor;
|
|
54516
54514
|
const frameRate = 120;
|
|
54517
54515
|
let loop = null;
|
|
@@ -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-e600f029";
|
|
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
|
});
|
|
@@ -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
|
-
|
|
59628
|
-
|
|
59629
|
-
|
|
59630
|
-
|
|
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();
|
|
@@ -59797,7 +59801,7 @@ var runDeploy = async (ctx) => {
|
|
|
59797
59801
|
const result = await runCommand(deployCmd, {
|
|
59798
59802
|
silent: true,
|
|
59799
59803
|
cwd: ctx.project.path,
|
|
59800
|
-
env: { CLOUDFLARE_ACCOUNT_ID: ctx.account.id },
|
|
59804
|
+
env: { CLOUDFLARE_ACCOUNT_ID: ctx.account.id, NODE_ENV: "production" },
|
|
59801
59805
|
startText: `Deploying your application`,
|
|
59802
59806
|
doneText: `${brandColor("deployed")} ${dim(`via \`${deployCmd}\``)}`
|
|
59803
59807
|
});
|
|
@@ -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
|
|
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");
|
|
@@ -60002,6 +60024,9 @@ var readJSON = (path3) => {
|
|
|
60002
60024
|
const contents = readFile(path3);
|
|
60003
60025
|
return contents ? JSON.parse(contents) : contents;
|
|
60004
60026
|
};
|
|
60027
|
+
var writeJSON = (path3, object, stringifySpace) => {
|
|
60028
|
+
writeFile2(path3, JSON.stringify(object, null, stringifySpace));
|
|
60029
|
+
};
|
|
60005
60030
|
var probePaths = (paths, errorMsg = "Failed to find required file.") => {
|
|
60006
60031
|
for (const path3 of paths) {
|
|
60007
60032
|
if ((0, import_fs7.existsSync)(path3)) {
|
|
@@ -60014,6 +60039,35 @@ var probePaths = (paths, errorMsg = "Failed to find required file.") => {
|
|
|
60014
60039
|
var usesTypescript = (projectRoot = ".") => {
|
|
60015
60040
|
return (0, import_fs7.existsSync)(`${projectRoot}/tsconfig.json`);
|
|
60016
60041
|
};
|
|
60042
|
+
var eslintRcExts = ["js", "cjs", "yaml", "yml", "json"];
|
|
60043
|
+
var usesEslint = (ctx) => {
|
|
60044
|
+
for (const ext of eslintRcExts) {
|
|
60045
|
+
const eslintRcFilename = `.eslintrc.${ext}`;
|
|
60046
|
+
if ((0, import_fs7.existsSync)(`${ctx.project.path}/${eslintRcFilename}`)) {
|
|
60047
|
+
return {
|
|
60048
|
+
used: true,
|
|
60049
|
+
configType: eslintRcFilename
|
|
60050
|
+
};
|
|
60051
|
+
}
|
|
60052
|
+
}
|
|
60053
|
+
if ((0, import_fs7.existsSync)(`${ctx.project.path}/eslint.config.js`)) {
|
|
60054
|
+
return {
|
|
60055
|
+
used: true,
|
|
60056
|
+
configType: "eslint.config.js"
|
|
60057
|
+
};
|
|
60058
|
+
}
|
|
60059
|
+
try {
|
|
60060
|
+
const pkgJson = readJSON(`${ctx.project.path}/package.json`);
|
|
60061
|
+
if (pkgJson.eslintConfig) {
|
|
60062
|
+
return {
|
|
60063
|
+
used: true,
|
|
60064
|
+
configType: "package.json"
|
|
60065
|
+
};
|
|
60066
|
+
}
|
|
60067
|
+
} catch {
|
|
60068
|
+
}
|
|
60069
|
+
return { used: false };
|
|
60070
|
+
};
|
|
60017
60071
|
var compatDateFlag = () => {
|
|
60018
60072
|
const date = /* @__PURE__ */ new Date();
|
|
60019
60073
|
return `--compatibility-date=${date.toISOString().slice(0, 10)}`;
|
|
@@ -60319,14 +60373,50 @@ var configure3 = async (ctx) => {
|
|
|
60319
60373
|
);
|
|
60320
60374
|
writeFile2(handlerPath, handlerFile);
|
|
60321
60375
|
updateStatus("Created an example API route handler");
|
|
60376
|
+
const installEslintPlugin = await shouldInstallNextOnPagesEslintPlugin(ctx);
|
|
60377
|
+
if (installEslintPlugin) {
|
|
60378
|
+
await writeEslintrc(ctx);
|
|
60379
|
+
}
|
|
60322
60380
|
process.chdir(projectName);
|
|
60323
|
-
const packages = [
|
|
60381
|
+
const packages = [
|
|
60382
|
+
"@cloudflare/next-on-pages@1",
|
|
60383
|
+
"vercel",
|
|
60384
|
+
...installEslintPlugin ? ["eslint-plugin-next-on-pages"] : []
|
|
60385
|
+
];
|
|
60324
60386
|
await installPackages(packages, {
|
|
60325
60387
|
dev: true,
|
|
60326
60388
|
startText: "Adding the Cloudflare Pages adapter",
|
|
60327
60389
|
doneText: `${brandColor(`installed`)} ${dim(packages.join(", "))}`
|
|
60328
60390
|
});
|
|
60329
60391
|
};
|
|
60392
|
+
var shouldInstallNextOnPagesEslintPlugin = async (ctx) => {
|
|
60393
|
+
const eslintUsage = usesEslint(ctx);
|
|
60394
|
+
if (!eslintUsage.used)
|
|
60395
|
+
return false;
|
|
60396
|
+
if (eslintUsage.configType !== ".eslintrc.json") {
|
|
60397
|
+
warn(
|
|
60398
|
+
`Expected .eslintrc.json from Next.js scaffolding but found ${eslintUsage.configType} instead`
|
|
60399
|
+
);
|
|
60400
|
+
return false;
|
|
60401
|
+
}
|
|
60402
|
+
return await processArgument(ctx.args, "eslint-plugin", {
|
|
60403
|
+
type: "confirm",
|
|
60404
|
+
question: "Do you want to use the next-on-pages eslint-plugin?",
|
|
60405
|
+
label: "eslint-plugin",
|
|
60406
|
+
defaultValue: true
|
|
60407
|
+
});
|
|
60408
|
+
};
|
|
60409
|
+
var writeEslintrc = async (ctx) => {
|
|
60410
|
+
const eslintConfig = readJSON(`${ctx.project.name}/.eslintrc.json`);
|
|
60411
|
+
eslintConfig.plugins ??= [];
|
|
60412
|
+
eslintConfig.plugins.push("eslint-plugin-next-on-pages");
|
|
60413
|
+
if (typeof eslintConfig.extends === "string") {
|
|
60414
|
+
eslintConfig.extends = [eslintConfig.extends];
|
|
60415
|
+
}
|
|
60416
|
+
eslintConfig.extends ??= [];
|
|
60417
|
+
eslintConfig.extends.push("plugin:eslint-plugin-next-on-pages/recommended");
|
|
60418
|
+
writeJSON(`${ctx.project.name}/.eslintrc.json`, eslintConfig, 2);
|
|
60419
|
+
};
|
|
60330
60420
|
var config6 = {
|
|
60331
60421
|
generate: generate6,
|
|
60332
60422
|
configure: configure3,
|
|
@@ -60345,7 +60435,7 @@ var config6 = {
|
|
|
60345
60435
|
"--src-dir",
|
|
60346
60436
|
"--app",
|
|
60347
60437
|
"--import-alias",
|
|
60348
|
-
|
|
60438
|
+
"@/*"
|
|
60349
60439
|
],
|
|
60350
60440
|
compatibilityFlags: ["nodejs_compat"]
|
|
60351
60441
|
};
|
|
@@ -60363,6 +60453,7 @@ var generate7 = async (ctx) => {
|
|
|
60363
60453
|
};
|
|
60364
60454
|
var configure4 = async (ctx) => {
|
|
60365
60455
|
process.chdir(ctx.project.path);
|
|
60456
|
+
writeFile2("./.node-version", "17");
|
|
60366
60457
|
await npmInstall();
|
|
60367
60458
|
};
|
|
60368
60459
|
var config7 = {
|
|
@@ -60370,8 +60461,9 @@ var config7 = {
|
|
|
60370
60461
|
configure: configure4,
|
|
60371
60462
|
displayName: "Nuxt",
|
|
60372
60463
|
packageScripts: {
|
|
60464
|
+
build: (cmd) => `NITRO_PRESET=cloudflare-pages ${cmd}`,
|
|
60373
60465
|
"pages:dev": `wrangler pages dev ${compatDateFlag()} --proxy 3000 -- npm run dev`,
|
|
60374
|
-
"pages:deploy":
|
|
60466
|
+
"pages:deploy": "npm run build && wrangler pages deploy ./dist"
|
|
60375
60467
|
}
|
|
60376
60468
|
};
|
|
60377
60469
|
var nuxt_default = config7;
|
|
@@ -60486,7 +60578,7 @@ var config11 = {
|
|
|
60486
60578
|
displayName: "Solid",
|
|
60487
60579
|
packageScripts: {
|
|
60488
60580
|
"pages:dev": `wrangler pages dev ${compatDateFlag()} --proxy 3000 -- ${npm9} run dev`,
|
|
60489
|
-
"pages:deploy": `${npm9} run build
|
|
60581
|
+
"pages:deploy": `${npm9} run build && wrangler pages deploy ./dist/public`
|
|
60490
60582
|
}
|
|
60491
60583
|
};
|
|
60492
60584
|
var solid_default = config11;
|
|
@@ -60721,11 +60813,29 @@ var updatePackageScripts = async (ctx) => {
|
|
|
60721
60813
|
const { packageScripts } = ctx.framework?.config ?? {};
|
|
60722
60814
|
if (packageScripts) {
|
|
60723
60815
|
const s = spinner();
|
|
60724
|
-
|
|
60816
|
+
const updatingScripts = Object.entries(packageScripts).filter(
|
|
60817
|
+
([_3, cmdOrUpdater]) => typeof cmdOrUpdater === "function"
|
|
60818
|
+
).length > 0;
|
|
60819
|
+
s.start(
|
|
60820
|
+
`${updatingScripts ? "Updating" : "Adding"} command scripts`,
|
|
60821
|
+
"for development and deployment"
|
|
60822
|
+
);
|
|
60725
60823
|
const pkgJsonPath = (0, import_path8.resolve)("package.json");
|
|
60726
60824
|
const pkgConfig = readJSON(pkgJsonPath);
|
|
60727
|
-
Object.entries(packageScripts).forEach(([target,
|
|
60728
|
-
|
|
60825
|
+
Object.entries(packageScripts).forEach(([target, cmdOrUpdater]) => {
|
|
60826
|
+
if (typeof cmdOrUpdater === "string") {
|
|
60827
|
+
const command2 = cmdOrUpdater;
|
|
60828
|
+
pkgConfig.scripts[target] = command2;
|
|
60829
|
+
} else {
|
|
60830
|
+
const existingCommand = pkgConfig.scripts[target];
|
|
60831
|
+
if (!existingCommand) {
|
|
60832
|
+
throw new Error(
|
|
60833
|
+
`Could not find ${target} script to update during ${ctx.framework} setup`
|
|
60834
|
+
);
|
|
60835
|
+
}
|
|
60836
|
+
const updater = cmdOrUpdater;
|
|
60837
|
+
pkgConfig.scripts[target] = updater(existingCommand);
|
|
60838
|
+
}
|
|
60729
60839
|
});
|
|
60730
60840
|
writeFile2(pkgJsonPath, JSON.stringify(pkgConfig, null, 2));
|
|
60731
60841
|
s.stop(`${brandColor("added")} ${dim("commands to `package.json`")}`);
|
|
@@ -60741,7 +60851,8 @@ var createProject = async (ctx) => {
|
|
|
60741
60851
|
const CLOUDFLARE_ACCOUNT_ID = ctx.account.id;
|
|
60742
60852
|
const compatFlags = ctx.framework?.config.compatibilityFlags?.join(" ");
|
|
60743
60853
|
const compatFlagsArg = compatFlags ? `--compatibility-flags ${compatFlags}` : "";
|
|
60744
|
-
const
|
|
60854
|
+
const productionBranch = await getProductionBranch(ctx.project.path);
|
|
60855
|
+
const cmd = `${npx5} wrangler pages project create ${ctx.project.name} --production-branch ${productionBranch} ${compatFlagsArg}`;
|
|
60745
60856
|
try {
|
|
60746
60857
|
await retry(
|
|
60747
60858
|
CREATE_PROJECT_RETRIES,
|
|
@@ -60750,7 +60861,7 @@ var createProject = async (ctx) => {
|
|
|
60750
60861
|
cwd: ctx.project.path,
|
|
60751
60862
|
env: { CLOUDFLARE_ACCOUNT_ID },
|
|
60752
60863
|
startText: "Creating Pages project",
|
|
60753
|
-
doneText: `${brandColor("created")} ${dim(`via \`${cmd}\``)}`
|
|
60864
|
+
doneText: `${brandColor("created")} ${dim(`via \`${cmd.trim()}\``)}`
|
|
60754
60865
|
})
|
|
60755
60866
|
);
|
|
60756
60867
|
} catch (error) {
|
|
@@ -60784,14 +60895,12 @@ var runWorkersGenerator = async (args) => {
|
|
|
60784
60895
|
await printSummary(ctx);
|
|
60785
60896
|
};
|
|
60786
60897
|
async function getTemplate(ctx) {
|
|
60787
|
-
|
|
60788
|
-
|
|
60789
|
-
|
|
60790
|
-
|
|
60791
|
-
|
|
60792
|
-
|
|
60793
|
-
});
|
|
60794
|
-
}
|
|
60898
|
+
ctx.args.ts = await processArgument(ctx.args, "ts", {
|
|
60899
|
+
type: "confirm",
|
|
60900
|
+
question: "Do you want to use TypeScript?",
|
|
60901
|
+
label: "typescript",
|
|
60902
|
+
defaultValue: C3_DEFAULTS.ts
|
|
60903
|
+
});
|
|
60795
60904
|
const preexisting = ctx.args.type === "pre-existing";
|
|
60796
60905
|
const template = preexisting ? "hello-world" : ctx.args.type;
|
|
60797
60906
|
const path3 = (0, import_path9.resolve)(
|
package/package.json
CHANGED