create-cloudflare 0.0.0-94d53ca5f → 0.0.0-94f07eec1
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 +268 -250
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +5 -5
- package/templates/astro/templates/wrangler.toml +1 -0
- package/templates/pre-existing/c3.ts +26 -7
- package/templates/svelte/c3.ts +3 -3
- package/templates-experimental/remix/c3.ts +1 -26
- package/templates-experimental/remix/templates/public/.assetsignore +0 -4
- package/templates-experimental/remix/templates/wrangler.toml +1 -1
- package/templates-experimental/solid/c3.ts +1 -1
- package/templates-experimental/svelte/c3.ts +3 -3
package/dist/cli.js
CHANGED
|
@@ -24815,8 +24815,8 @@ var require_index_688c5d50 = __commonJS({
|
|
|
24815
24815
|
var pathReservations = () => {
|
|
24816
24816
|
const queues = /* @__PURE__ */ new Map();
|
|
24817
24817
|
const reservations = /* @__PURE__ */ new Map();
|
|
24818
|
-
const { join:
|
|
24819
|
-
const getDirs = (path7) =>
|
|
24818
|
+
const { join: join8 } = path__default["default"];
|
|
24819
|
+
const getDirs = (path7) => join8(path7).split(/[\\/]/).slice(0, -1).reduce((set, path8) => set.length ? set.concat(join8(set[set.length - 1], path8)) : [path8], []);
|
|
24820
24820
|
const running = /* @__PURE__ */ new Set();
|
|
24821
24821
|
const getQueues = (fn) => {
|
|
24822
24822
|
const res = reservations.get(fn);
|
|
@@ -38609,7 +38609,7 @@ var require_util8 = __commonJS({
|
|
|
38609
38609
|
return path6;
|
|
38610
38610
|
}
|
|
38611
38611
|
exports2.normalize = normalize2;
|
|
38612
|
-
function
|
|
38612
|
+
function join8(aRoot, aPath) {
|
|
38613
38613
|
if (aRoot === "") {
|
|
38614
38614
|
aRoot = ".";
|
|
38615
38615
|
}
|
|
@@ -38641,7 +38641,7 @@ var require_util8 = __commonJS({
|
|
|
38641
38641
|
}
|
|
38642
38642
|
return joined;
|
|
38643
38643
|
}
|
|
38644
|
-
exports2.join =
|
|
38644
|
+
exports2.join = join8;
|
|
38645
38645
|
exports2.isAbsolute = function(aPath) {
|
|
38646
38646
|
return aPath.charAt(0) === "/" || urlRegexp.test(aPath);
|
|
38647
38647
|
};
|
|
@@ -38814,7 +38814,7 @@ var require_util8 = __commonJS({
|
|
|
38814
38814
|
parsed.path = parsed.path.substring(0, index + 1);
|
|
38815
38815
|
}
|
|
38816
38816
|
}
|
|
38817
|
-
sourceURL =
|
|
38817
|
+
sourceURL = join8(urlGenerate(parsed), sourceURL);
|
|
38818
38818
|
}
|
|
38819
38819
|
return normalize2(sourceURL);
|
|
38820
38820
|
}
|
|
@@ -68447,7 +68447,12 @@ var inputPrompt = async (promptConfig) => {
|
|
|
68447
68447
|
};
|
|
68448
68448
|
let prompt;
|
|
68449
68449
|
const dispatchRender = (props, p2) => {
|
|
68450
|
-
|
|
68450
|
+
let state = props.state;
|
|
68451
|
+
if (state === "initial" && promptConfig.initialErrorMessage) {
|
|
68452
|
+
state = "error";
|
|
68453
|
+
props.error = promptConfig.initialErrorMessage;
|
|
68454
|
+
}
|
|
68455
|
+
const renderedLines = renderers[state](props, p2);
|
|
68451
68456
|
return renderedLines.join("\n");
|
|
68452
68457
|
};
|
|
68453
68458
|
if (promptConfig.type === "select") {
|
|
@@ -73714,7 +73719,7 @@ var Yargs = YargsFactory(esm_default);
|
|
|
73714
73719
|
var yargs_default = Yargs;
|
|
73715
73720
|
|
|
73716
73721
|
// package.json
|
|
73717
|
-
var version = "0.0.0-
|
|
73722
|
+
var version = "0.0.0-94f07eec1";
|
|
73718
73723
|
|
|
73719
73724
|
// src/metrics.ts
|
|
73720
73725
|
var import_node_async_hooks = require("node:async_hooks");
|
|
@@ -74461,189 +74466,6 @@ var usesEslint = (ctx) => {
|
|
|
74461
74466
|
// templates-experimental/angular/c3.ts
|
|
74462
74467
|
var import_node_path3 = require("node:path");
|
|
74463
74468
|
|
|
74464
|
-
// ../wrangler/package.json
|
|
74465
|
-
var version2 = "0.0.0-94d53ca5f";
|
|
74466
|
-
|
|
74467
|
-
// src/git.ts
|
|
74468
|
-
var offerGit = async (ctx) => {
|
|
74469
|
-
const gitInstalled = await isGitInstalled();
|
|
74470
|
-
if (!gitInstalled) {
|
|
74471
|
-
if (ctx.args.git) {
|
|
74472
|
-
updateStatus(
|
|
74473
|
-
"Couldn't find `git` installed on your machine. Continuing without git."
|
|
74474
|
-
);
|
|
74475
|
-
}
|
|
74476
|
-
ctx.args.git = false;
|
|
74477
|
-
return;
|
|
74478
|
-
}
|
|
74479
|
-
const insideGitRepo = await isInsideGitRepo(ctx.project.path);
|
|
74480
|
-
if (insideGitRepo) {
|
|
74481
|
-
ctx.args.git = true;
|
|
74482
|
-
return;
|
|
74483
|
-
}
|
|
74484
|
-
ctx.args.git = await processArgument(ctx.args, "git", {
|
|
74485
|
-
type: "confirm",
|
|
74486
|
-
question: "Do you want to use git for version control?",
|
|
74487
|
-
label: "git",
|
|
74488
|
-
defaultValue: C3_DEFAULTS.git
|
|
74489
|
-
});
|
|
74490
|
-
if (!ctx.args.git) {
|
|
74491
|
-
return;
|
|
74492
|
-
}
|
|
74493
|
-
const gitConfigured = await isGitConfigured();
|
|
74494
|
-
if (!gitConfigured) {
|
|
74495
|
-
updateStatus(
|
|
74496
|
-
"Must configure `user.name` and user.email` to use git. Continuing without git."
|
|
74497
|
-
);
|
|
74498
|
-
ctx.args.git = false;
|
|
74499
|
-
return;
|
|
74500
|
-
}
|
|
74501
|
-
await initializeGit(ctx.project.path);
|
|
74502
|
-
};
|
|
74503
|
-
var gitCommit = async (ctx) => {
|
|
74504
|
-
const commitMessage = await createCommitMessage(ctx);
|
|
74505
|
-
if (!ctx.args.git) {
|
|
74506
|
-
return;
|
|
74507
|
-
}
|
|
74508
|
-
if (ctx.gitRepoAlreadyExisted) {
|
|
74509
|
-
return;
|
|
74510
|
-
}
|
|
74511
|
-
const gitInstalled = await isGitInstalled();
|
|
74512
|
-
const gitInitialized = await isInsideGitRepo(ctx.project.path);
|
|
74513
|
-
if (!gitInstalled || !gitInitialized) {
|
|
74514
|
-
return;
|
|
74515
|
-
}
|
|
74516
|
-
const s = spinner();
|
|
74517
|
-
s.start("Committing new files");
|
|
74518
|
-
await runCommand(["git", "add", "."], {
|
|
74519
|
-
silent: true,
|
|
74520
|
-
cwd: ctx.project.path
|
|
74521
|
-
});
|
|
74522
|
-
await runCommand(["git", "commit", "-m", commitMessage], {
|
|
74523
|
-
silent: true,
|
|
74524
|
-
cwd: ctx.project.path
|
|
74525
|
-
});
|
|
74526
|
-
s.stop(`${brandColor("git")} ${dim(`commit`)}`);
|
|
74527
|
-
};
|
|
74528
|
-
var createCommitMessage = async (ctx) => {
|
|
74529
|
-
const framework = ctx.template.frameworkCli;
|
|
74530
|
-
const header = framework ? "Initialize web application via create-cloudflare CLI" : "Initial commit (by create-cloudflare CLI)";
|
|
74531
|
-
const packageManager = detectPackageManager();
|
|
74532
|
-
const gitVersion = await getGitVersion();
|
|
74533
|
-
const insideRepo = await isInsideGitRepo(ctx.project.path);
|
|
74534
|
-
const details = [
|
|
74535
|
-
{ key: "C3", value: `create-cloudflare@${version}` },
|
|
74536
|
-
{ key: "project name", value: ctx.project.name },
|
|
74537
|
-
...framework ? [{ key: "framework", value: ctx.template.id }] : [],
|
|
74538
|
-
...framework ? [{ key: "framework cli", value: getFrameworkCli(ctx) }] : [],
|
|
74539
|
-
{
|
|
74540
|
-
key: "package manager",
|
|
74541
|
-
value: `${packageManager.name}@${packageManager.version}`
|
|
74542
|
-
},
|
|
74543
|
-
{
|
|
74544
|
-
key: "wrangler",
|
|
74545
|
-
value: `wrangler@${version2}`
|
|
74546
|
-
},
|
|
74547
|
-
{
|
|
74548
|
-
key: "git",
|
|
74549
|
-
value: insideRepo ? gitVersion : "N/A"
|
|
74550
|
-
}
|
|
74551
|
-
];
|
|
74552
|
-
const body = `Details:
|
|
74553
|
-
${details.map(({ key, value }) => ` ${key} = ${value}`).join("\n")}
|
|
74554
|
-
`;
|
|
74555
|
-
const commitMessage = `${header}
|
|
74556
|
-
|
|
74557
|
-
${body}
|
|
74558
|
-
`;
|
|
74559
|
-
ctx.commitMessage = commitMessage;
|
|
74560
|
-
return commitMessage;
|
|
74561
|
-
};
|
|
74562
|
-
async function getGitVersion() {
|
|
74563
|
-
try {
|
|
74564
|
-
const rawGitVersion = await runCommand(["git", "--version"], {
|
|
74565
|
-
useSpinner: false,
|
|
74566
|
-
silent: true
|
|
74567
|
-
});
|
|
74568
|
-
const gitVersion = rawGitVersion.replace(/^git\s+version\s+/, "");
|
|
74569
|
-
return gitVersion;
|
|
74570
|
-
} catch {
|
|
74571
|
-
return null;
|
|
74572
|
-
}
|
|
74573
|
-
}
|
|
74574
|
-
async function isGitInstalled() {
|
|
74575
|
-
return await getGitVersion() !== null;
|
|
74576
|
-
}
|
|
74577
|
-
async function isGitConfigured() {
|
|
74578
|
-
try {
|
|
74579
|
-
const userName = await runCommand(["git", "config", "user.name"], {
|
|
74580
|
-
useSpinner: false,
|
|
74581
|
-
silent: true
|
|
74582
|
-
});
|
|
74583
|
-
if (!userName) {
|
|
74584
|
-
return false;
|
|
74585
|
-
}
|
|
74586
|
-
const email = await runCommand(["git", "config", "user.email"], {
|
|
74587
|
-
useSpinner: false,
|
|
74588
|
-
silent: true
|
|
74589
|
-
});
|
|
74590
|
-
if (!email) {
|
|
74591
|
-
return false;
|
|
74592
|
-
}
|
|
74593
|
-
return true;
|
|
74594
|
-
} catch {
|
|
74595
|
-
return false;
|
|
74596
|
-
}
|
|
74597
|
-
}
|
|
74598
|
-
async function isInsideGitRepo(cwd) {
|
|
74599
|
-
try {
|
|
74600
|
-
const output = await runCommand(["git", "status"], {
|
|
74601
|
-
cwd,
|
|
74602
|
-
useSpinner: false,
|
|
74603
|
-
silent: true,
|
|
74604
|
-
captureOutput: true
|
|
74605
|
-
});
|
|
74606
|
-
return output.includes("not a git repository") === false;
|
|
74607
|
-
} catch (err) {
|
|
74608
|
-
return false;
|
|
74609
|
-
}
|
|
74610
|
-
}
|
|
74611
|
-
async function initializeGit(cwd) {
|
|
74612
|
-
const s = spinner();
|
|
74613
|
-
s.start("Initializing git repo");
|
|
74614
|
-
try {
|
|
74615
|
-
const defaultBranchName = await runCommand(
|
|
74616
|
-
["git", "config", "--get", "init.defaultBranch"],
|
|
74617
|
-
{ useSpinner: false, silent: true, cwd }
|
|
74618
|
-
);
|
|
74619
|
-
await runCommand(
|
|
74620
|
-
["git", "init", "--initial-branch", defaultBranchName.trim() ?? "main"],
|
|
74621
|
-
// branch names can't contain spaces, so this is safe
|
|
74622
|
-
{ useSpinner: false, silent: true, cwd }
|
|
74623
|
-
);
|
|
74624
|
-
} catch {
|
|
74625
|
-
await runCommand(["git", "init"], { useSpinner: false, silent: true, cwd });
|
|
74626
|
-
} finally {
|
|
74627
|
-
s.stop(`${brandColor("initialized")} ${dim(`git`)}`);
|
|
74628
|
-
}
|
|
74629
|
-
}
|
|
74630
|
-
async function getProductionBranch(cwd) {
|
|
74631
|
-
try {
|
|
74632
|
-
const productionBranch = await runCommand(
|
|
74633
|
-
["git", "branch", "--show-current"],
|
|
74634
|
-
{
|
|
74635
|
-
silent: true,
|
|
74636
|
-
cwd,
|
|
74637
|
-
useSpinner: false,
|
|
74638
|
-
captureOutput: true
|
|
74639
|
-
}
|
|
74640
|
-
);
|
|
74641
|
-
return productionBranch.trim();
|
|
74642
|
-
} catch (err) {
|
|
74643
|
-
}
|
|
74644
|
-
return "main";
|
|
74645
|
-
}
|
|
74646
|
-
|
|
74647
74469
|
// src/frameworks/package.json
|
|
74648
74470
|
var package_default = {
|
|
74649
74471
|
name: "frameworks_clis_info",
|
|
@@ -74652,20 +74474,20 @@ var package_default = {
|
|
|
74652
74474
|
"so that we can use dependabot to update these dependencies automatically."
|
|
74653
74475
|
],
|
|
74654
74476
|
dependencies: {
|
|
74655
|
-
"create-astro": "4.
|
|
74477
|
+
"create-astro": "4.10.0",
|
|
74656
74478
|
"create-analog": "1.8.1",
|
|
74657
|
-
"@angular/create": "18.2.
|
|
74658
|
-
"create-docusaurus": "3.
|
|
74659
|
-
"create-hono": "0.
|
|
74479
|
+
"@angular/create": "18.2.11",
|
|
74480
|
+
"create-docusaurus": "3.6.1",
|
|
74481
|
+
"create-hono": "0.14.2",
|
|
74660
74482
|
"create-next-app": "14.2.5",
|
|
74661
74483
|
"create-qwik": "1.9.1",
|
|
74662
|
-
"create-vite": "5.5.
|
|
74663
|
-
"create-remix": "2.
|
|
74484
|
+
"create-vite": "5.5.5",
|
|
74485
|
+
"create-remix": "2.14.0",
|
|
74664
74486
|
"create-solid": "0.5.13",
|
|
74665
|
-
"create-
|
|
74666
|
-
|
|
74667
|
-
|
|
74668
|
-
|
|
74487
|
+
"create-vue": "3.12.1",
|
|
74488
|
+
gatsby: "5.14.0",
|
|
74489
|
+
nuxi: "3.15.0",
|
|
74490
|
+
sv: "0.6.1"
|
|
74669
74491
|
}
|
|
74670
74492
|
};
|
|
74671
74493
|
|
|
@@ -74693,18 +74515,6 @@ var runFrameworkGenerator = async (ctx, args) => {
|
|
|
74693
74515
|
);
|
|
74694
74516
|
logRaw("");
|
|
74695
74517
|
await runCommand(cmd, { env: env3 });
|
|
74696
|
-
if (process.env.SAVE_DIFFS) {
|
|
74697
|
-
const cmdEnv = {
|
|
74698
|
-
silent: true,
|
|
74699
|
-
cwd: ctx.project.path
|
|
74700
|
-
};
|
|
74701
|
-
if (!isInsideGitRepo(ctx.project.path)) {
|
|
74702
|
-
await runCommand(["git", "init"], cmdEnv);
|
|
74703
|
-
await runCommand(["git", "add", "."], cmdEnv);
|
|
74704
|
-
const commitMessage = `Initial commit by ${cli}`;
|
|
74705
|
-
await runCommand(["git", "commit", "-m", commitMessage], cmdEnv);
|
|
74706
|
-
}
|
|
74707
|
-
}
|
|
74708
74518
|
};
|
|
74709
74519
|
|
|
74710
74520
|
// templates-experimental/angular/c3.ts
|
|
@@ -75417,7 +75227,7 @@ var generate9 = async (ctx) => {
|
|
|
75417
75227
|
await runFrameworkGenerator(ctx, [
|
|
75418
75228
|
ctx.project.name,
|
|
75419
75229
|
"--template",
|
|
75420
|
-
"https://github.com/remix-run/remix/tree/main/templates/cloudflare"
|
|
75230
|
+
"https://github.com/remix-run/remix/tree/main/templates/cloudflare-workers"
|
|
75421
75231
|
]);
|
|
75422
75232
|
logRaw("");
|
|
75423
75233
|
};
|
|
@@ -75427,19 +75237,6 @@ var configure6 = async () => {
|
|
|
75427
75237
|
startText: "Updating the Wrangler version",
|
|
75428
75238
|
doneText: `${brandColor(`updated`)} ${dim("wrangler@latest")}`
|
|
75429
75239
|
});
|
|
75430
|
-
const typeDefsPath = "load-context.ts";
|
|
75431
|
-
const s = spinner();
|
|
75432
|
-
s.start(`Updating \`${typeDefsPath}\``);
|
|
75433
|
-
transformFile(typeDefsPath, {
|
|
75434
|
-
visitTSInterfaceDeclaration(n2) {
|
|
75435
|
-
if (n2.node.id.type === "Identifier" && n2.node.id.name !== "Env") {
|
|
75436
|
-
return this.traverse(n2);
|
|
75437
|
-
}
|
|
75438
|
-
n2.replace();
|
|
75439
|
-
return false;
|
|
75440
|
-
}
|
|
75441
|
-
});
|
|
75442
|
-
s.stop(`${brandColor("updated")} \`${dim(typeDefsPath)}\``);
|
|
75443
75240
|
};
|
|
75444
75241
|
var config10 = {
|
|
75445
75242
|
configVersion: 1,
|
|
@@ -75455,7 +75252,6 @@ var config10 = {
|
|
|
75455
75252
|
configure: configure6,
|
|
75456
75253
|
transformPackageJson: async () => ({
|
|
75457
75254
|
scripts: {
|
|
75458
|
-
build: "remix vite:build && wrangler pages functions build --outdir build/worker",
|
|
75459
75255
|
deploy: `${npm6} run build && wrangler deploy`,
|
|
75460
75256
|
preview: `${npm6} run build && wrangler dev`,
|
|
75461
75257
|
"cf-typegen": `wrangler types`
|
|
@@ -75500,7 +75296,7 @@ var configure7 = async (ctx) => {
|
|
|
75500
75296
|
// preset: "cloudflare-pages"
|
|
75501
75297
|
b2.objectProperty(
|
|
75502
75298
|
b2.identifier("preset"),
|
|
75503
|
-
b2.stringLiteral("
|
|
75299
|
+
b2.stringLiteral("cloudflare-pages")
|
|
75504
75300
|
),
|
|
75505
75301
|
// output: {
|
|
75506
75302
|
// dir: "{{ rootDir }}/dist",
|
|
@@ -75590,7 +75386,7 @@ var import_node_os3 = require("node:os");
|
|
|
75590
75386
|
var recast6 = __toESM(require_main3());
|
|
75591
75387
|
var { npm: npm8 } = detectPackageManager();
|
|
75592
75388
|
var generate11 = async (ctx) => {
|
|
75593
|
-
await runFrameworkGenerator(ctx, [ctx.project.name]);
|
|
75389
|
+
await runFrameworkGenerator(ctx, ["create", ctx.project.name]);
|
|
75594
75390
|
logRaw("");
|
|
75595
75391
|
};
|
|
75596
75392
|
var configure8 = async (ctx) => {
|
|
@@ -75655,8 +75451,8 @@ var updateTypeDefinitions = (ctx) => {
|
|
|
75655
75451
|
var config12 = {
|
|
75656
75452
|
configVersion: 1,
|
|
75657
75453
|
id: "svelte",
|
|
75658
|
-
frameworkCli: "
|
|
75659
|
-
displayName: "
|
|
75454
|
+
frameworkCli: "sv",
|
|
75455
|
+
displayName: "SvelteKit",
|
|
75660
75456
|
platform: "workers",
|
|
75661
75457
|
copyFiles: {
|
|
75662
75458
|
variants: {
|
|
@@ -76514,7 +76310,6 @@ var isLoggedIn = async () => {
|
|
|
76514
76310
|
// templates/pre-existing/c3.ts
|
|
76515
76311
|
async function copyExistingWorkerFiles(ctx) {
|
|
76516
76312
|
const { dlx } = detectPackageManager();
|
|
76517
|
-
await chooseAccount(ctx);
|
|
76518
76313
|
if (ctx.args.existingScript === void 0) {
|
|
76519
76314
|
ctx.args.existingScript = await processArgument(
|
|
76520
76315
|
ctx.args,
|
|
@@ -76568,11 +76363,23 @@ var c3_default27 = {
|
|
|
76568
76363
|
copyFiles: {
|
|
76569
76364
|
path: "./js"
|
|
76570
76365
|
},
|
|
76571
|
-
configure:
|
|
76572
|
-
|
|
76573
|
-
|
|
76574
|
-
|
|
76366
|
+
configure: buildConfigure({
|
|
76367
|
+
login: wranglerLogin,
|
|
76368
|
+
chooseAccount,
|
|
76369
|
+
copyFiles: copyExistingWorkerFiles
|
|
76370
|
+
})
|
|
76575
76371
|
};
|
|
76372
|
+
function buildConfigure(params) {
|
|
76373
|
+
return async function configure20(ctx) {
|
|
76374
|
+
const loginSuccess = await params.login(ctx);
|
|
76375
|
+
if (!loginSuccess) {
|
|
76376
|
+
throw new Error("Failed to login to Cloudflare");
|
|
76377
|
+
}
|
|
76378
|
+
await params.chooseAccount(ctx);
|
|
76379
|
+
await params.copyFiles(ctx);
|
|
76380
|
+
ctx.args.deploy = false;
|
|
76381
|
+
};
|
|
76382
|
+
}
|
|
76576
76383
|
|
|
76577
76384
|
// templates/queues/c3.ts
|
|
76578
76385
|
var c3_default28 = {
|
|
@@ -76903,7 +76710,7 @@ var import_node_os4 = require("node:os");
|
|
|
76903
76710
|
var recast12 = __toESM(require_main3());
|
|
76904
76711
|
var { npm: npm19 } = detectPackageManager();
|
|
76905
76712
|
var generate24 = async (ctx) => {
|
|
76906
|
-
await runFrameworkGenerator(ctx, [ctx.project.name]);
|
|
76713
|
+
await runFrameworkGenerator(ctx, ["create", ctx.project.name]);
|
|
76907
76714
|
logRaw("");
|
|
76908
76715
|
};
|
|
76909
76716
|
var configure18 = async (ctx) => {
|
|
@@ -76968,8 +76775,8 @@ var updateTypeDefinitions2 = (ctx) => {
|
|
|
76968
76775
|
var config24 = {
|
|
76969
76776
|
configVersion: 1,
|
|
76970
76777
|
id: "svelte",
|
|
76971
|
-
frameworkCli: "
|
|
76972
|
-
displayName: "
|
|
76778
|
+
frameworkCli: "sv",
|
|
76779
|
+
displayName: "SvelteKit",
|
|
76973
76780
|
platform: "pages",
|
|
76974
76781
|
copyFiles: {
|
|
76975
76782
|
variants: {
|
|
@@ -77023,6 +76830,189 @@ var config25 = {
|
|
|
77023
76830
|
};
|
|
77024
76831
|
var c3_default35 = config25;
|
|
77025
76832
|
|
|
76833
|
+
// ../wrangler/package.json
|
|
76834
|
+
var version2 = "0.0.0-94f07eec1";
|
|
76835
|
+
|
|
76836
|
+
// src/git.ts
|
|
76837
|
+
var offerGit = async (ctx) => {
|
|
76838
|
+
const gitInstalled = await isGitInstalled();
|
|
76839
|
+
if (!gitInstalled) {
|
|
76840
|
+
if (ctx.args.git) {
|
|
76841
|
+
updateStatus(
|
|
76842
|
+
"Couldn't find `git` installed on your machine. Continuing without git."
|
|
76843
|
+
);
|
|
76844
|
+
}
|
|
76845
|
+
ctx.args.git = false;
|
|
76846
|
+
return;
|
|
76847
|
+
}
|
|
76848
|
+
const insideGitRepo = await isInsideGitRepo(ctx.project.path);
|
|
76849
|
+
if (insideGitRepo) {
|
|
76850
|
+
ctx.args.git = true;
|
|
76851
|
+
return;
|
|
76852
|
+
}
|
|
76853
|
+
ctx.args.git = await processArgument(ctx.args, "git", {
|
|
76854
|
+
type: "confirm",
|
|
76855
|
+
question: "Do you want to use git for version control?",
|
|
76856
|
+
label: "git",
|
|
76857
|
+
defaultValue: C3_DEFAULTS.git
|
|
76858
|
+
});
|
|
76859
|
+
if (!ctx.args.git) {
|
|
76860
|
+
return;
|
|
76861
|
+
}
|
|
76862
|
+
const gitConfigured = await isGitConfigured();
|
|
76863
|
+
if (!gitConfigured) {
|
|
76864
|
+
updateStatus(
|
|
76865
|
+
"Must configure `user.name` and user.email` to use git. Continuing without git."
|
|
76866
|
+
);
|
|
76867
|
+
ctx.args.git = false;
|
|
76868
|
+
return;
|
|
76869
|
+
}
|
|
76870
|
+
await initializeGit(ctx.project.path);
|
|
76871
|
+
};
|
|
76872
|
+
var gitCommit = async (ctx) => {
|
|
76873
|
+
const commitMessage = await createCommitMessage(ctx);
|
|
76874
|
+
if (!ctx.args.git) {
|
|
76875
|
+
return;
|
|
76876
|
+
}
|
|
76877
|
+
if (ctx.gitRepoAlreadyExisted) {
|
|
76878
|
+
return;
|
|
76879
|
+
}
|
|
76880
|
+
const gitInstalled = await isGitInstalled();
|
|
76881
|
+
const gitInitialized = await isInsideGitRepo(ctx.project.path);
|
|
76882
|
+
if (!gitInstalled || !gitInitialized) {
|
|
76883
|
+
return;
|
|
76884
|
+
}
|
|
76885
|
+
const s = spinner();
|
|
76886
|
+
s.start("Committing new files");
|
|
76887
|
+
await runCommand(["git", "add", "."], {
|
|
76888
|
+
silent: true,
|
|
76889
|
+
cwd: ctx.project.path
|
|
76890
|
+
});
|
|
76891
|
+
await runCommand(["git", "commit", "-m", commitMessage], {
|
|
76892
|
+
silent: true,
|
|
76893
|
+
cwd: ctx.project.path
|
|
76894
|
+
});
|
|
76895
|
+
s.stop(`${brandColor("git")} ${dim(`commit`)}`);
|
|
76896
|
+
};
|
|
76897
|
+
var createCommitMessage = async (ctx) => {
|
|
76898
|
+
const framework = ctx.template.frameworkCli;
|
|
76899
|
+
const header = framework ? "Initialize web application via create-cloudflare CLI" : "Initial commit (by create-cloudflare CLI)";
|
|
76900
|
+
const packageManager = detectPackageManager();
|
|
76901
|
+
const gitVersion = await getGitVersion();
|
|
76902
|
+
const insideRepo = await isInsideGitRepo(ctx.project.path);
|
|
76903
|
+
const details = [
|
|
76904
|
+
{ key: "C3", value: `create-cloudflare@${version}` },
|
|
76905
|
+
{ key: "project name", value: ctx.project.name },
|
|
76906
|
+
...framework ? [{ key: "framework", value: ctx.template.id }] : [],
|
|
76907
|
+
...framework ? [{ key: "framework cli", value: getFrameworkCli(ctx) }] : [],
|
|
76908
|
+
{
|
|
76909
|
+
key: "package manager",
|
|
76910
|
+
value: `${packageManager.name}@${packageManager.version}`
|
|
76911
|
+
},
|
|
76912
|
+
{
|
|
76913
|
+
key: "wrangler",
|
|
76914
|
+
value: `wrangler@${version2}`
|
|
76915
|
+
},
|
|
76916
|
+
{
|
|
76917
|
+
key: "git",
|
|
76918
|
+
value: insideRepo ? gitVersion : "N/A"
|
|
76919
|
+
}
|
|
76920
|
+
];
|
|
76921
|
+
const body = `Details:
|
|
76922
|
+
${details.map(({ key, value }) => ` ${key} = ${value}`).join("\n")}
|
|
76923
|
+
`;
|
|
76924
|
+
const commitMessage = `${header}
|
|
76925
|
+
|
|
76926
|
+
${body}
|
|
76927
|
+
`;
|
|
76928
|
+
ctx.commitMessage = commitMessage;
|
|
76929
|
+
return commitMessage;
|
|
76930
|
+
};
|
|
76931
|
+
async function getGitVersion() {
|
|
76932
|
+
try {
|
|
76933
|
+
const rawGitVersion = await runCommand(["git", "--version"], {
|
|
76934
|
+
useSpinner: false,
|
|
76935
|
+
silent: true
|
|
76936
|
+
});
|
|
76937
|
+
const gitVersion = rawGitVersion.replace(/^git\s+version\s+/, "");
|
|
76938
|
+
return gitVersion;
|
|
76939
|
+
} catch {
|
|
76940
|
+
return null;
|
|
76941
|
+
}
|
|
76942
|
+
}
|
|
76943
|
+
async function isGitInstalled() {
|
|
76944
|
+
return await getGitVersion() !== null;
|
|
76945
|
+
}
|
|
76946
|
+
async function isGitConfigured() {
|
|
76947
|
+
try {
|
|
76948
|
+
const userName = await runCommand(["git", "config", "user.name"], {
|
|
76949
|
+
useSpinner: false,
|
|
76950
|
+
silent: true
|
|
76951
|
+
});
|
|
76952
|
+
if (!userName) {
|
|
76953
|
+
return false;
|
|
76954
|
+
}
|
|
76955
|
+
const email = await runCommand(["git", "config", "user.email"], {
|
|
76956
|
+
useSpinner: false,
|
|
76957
|
+
silent: true
|
|
76958
|
+
});
|
|
76959
|
+
if (!email) {
|
|
76960
|
+
return false;
|
|
76961
|
+
}
|
|
76962
|
+
return true;
|
|
76963
|
+
} catch {
|
|
76964
|
+
return false;
|
|
76965
|
+
}
|
|
76966
|
+
}
|
|
76967
|
+
async function isInsideGitRepo(cwd) {
|
|
76968
|
+
try {
|
|
76969
|
+
const output = await runCommand(["git", "status"], {
|
|
76970
|
+
cwd,
|
|
76971
|
+
useSpinner: false,
|
|
76972
|
+
silent: true,
|
|
76973
|
+
captureOutput: true
|
|
76974
|
+
});
|
|
76975
|
+
return output.includes("not a git repository") === false;
|
|
76976
|
+
} catch (err) {
|
|
76977
|
+
return false;
|
|
76978
|
+
}
|
|
76979
|
+
}
|
|
76980
|
+
async function initializeGit(cwd) {
|
|
76981
|
+
const s = spinner();
|
|
76982
|
+
s.start("Initializing git repo");
|
|
76983
|
+
try {
|
|
76984
|
+
const defaultBranchName = await runCommand(
|
|
76985
|
+
["git", "config", "--get", "init.defaultBranch"],
|
|
76986
|
+
{ useSpinner: false, silent: true, cwd }
|
|
76987
|
+
);
|
|
76988
|
+
await runCommand(
|
|
76989
|
+
["git", "init", "--initial-branch", defaultBranchName.trim() ?? "main"],
|
|
76990
|
+
// branch names can't contain spaces, so this is safe
|
|
76991
|
+
{ useSpinner: false, silent: true, cwd }
|
|
76992
|
+
);
|
|
76993
|
+
} catch {
|
|
76994
|
+
await runCommand(["git", "init"], { useSpinner: false, silent: true, cwd });
|
|
76995
|
+
} finally {
|
|
76996
|
+
s.stop(`${brandColor("initialized")} ${dim(`git`)}`);
|
|
76997
|
+
}
|
|
76998
|
+
}
|
|
76999
|
+
async function getProductionBranch(cwd) {
|
|
77000
|
+
try {
|
|
77001
|
+
const productionBranch = await runCommand(
|
|
77002
|
+
["git", "branch", "--show-current"],
|
|
77003
|
+
{
|
|
77004
|
+
silent: true,
|
|
77005
|
+
cwd,
|
|
77006
|
+
useSpinner: false,
|
|
77007
|
+
captureOutput: true
|
|
77008
|
+
}
|
|
77009
|
+
);
|
|
77010
|
+
return productionBranch.trim();
|
|
77011
|
+
} catch (err) {
|
|
77012
|
+
}
|
|
77013
|
+
return "main";
|
|
77014
|
+
}
|
|
77015
|
+
|
|
77026
77016
|
// src/validators.ts
|
|
77027
77017
|
var import_fs10 = require("fs");
|
|
77028
77018
|
var import_path12 = require("path");
|
|
@@ -77217,6 +77207,10 @@ var createContext = async (args, prevArgs) => {
|
|
|
77217
77207
|
const currentArgs = { ...args };
|
|
77218
77208
|
let linesPrinted = 0;
|
|
77219
77209
|
switch (from) {
|
|
77210
|
+
case "category":
|
|
77211
|
+
linesPrinted = 6;
|
|
77212
|
+
args.projectName = void 0;
|
|
77213
|
+
break;
|
|
77220
77214
|
case "type":
|
|
77221
77215
|
linesPrinted = 9;
|
|
77222
77216
|
args.category = void 0;
|
|
@@ -77250,7 +77244,7 @@ var createContext = async (args, prevArgs) => {
|
|
|
77250
77244
|
type: "text",
|
|
77251
77245
|
question: `In which directory do you want to create your application?`,
|
|
77252
77246
|
helpText: "also used as application name",
|
|
77253
|
-
defaultValue: defaultName,
|
|
77247
|
+
defaultValue: prevArgs?.projectName ?? defaultName,
|
|
77254
77248
|
label: "dir",
|
|
77255
77249
|
validate: (value) => validateProjectDirectory(String(value) || C3_DEFAULTS.projectName, args),
|
|
77256
77250
|
format: (val) => `./${val}`
|
|
@@ -77277,7 +77271,8 @@ var createContext = async (args, prevArgs) => {
|
|
|
77277
77271
|
description: "Start from an existing GitHub repo link"
|
|
77278
77272
|
},
|
|
77279
77273
|
// This is used only if the type is `pre-existing`
|
|
77280
|
-
{ label: "Others", value: "others", hidden: true }
|
|
77274
|
+
{ label: "Others", value: "others", hidden: true },
|
|
77275
|
+
backOption
|
|
77281
77276
|
];
|
|
77282
77277
|
const category = await processArgument(args, "category", {
|
|
77283
77278
|
type: "select",
|
|
@@ -77286,6 +77281,9 @@ var createContext = async (args, prevArgs) => {
|
|
|
77286
77281
|
options: categoryOptions,
|
|
77287
77282
|
defaultValue: prevArgs?.category ?? C3_DEFAULTS.category
|
|
77288
77283
|
});
|
|
77284
|
+
if (category === BACK_VALUE) {
|
|
77285
|
+
return goBack("category");
|
|
77286
|
+
}
|
|
77289
77287
|
let template;
|
|
77290
77288
|
if (category === "web-framework") {
|
|
77291
77289
|
const frameworkMap = getFrameworkMap({
|
|
@@ -77904,11 +77902,13 @@ var processArgument = async (args, key, promptConfig) => {
|
|
|
77904
77902
|
disableTelemetry: args[key] !== void 0,
|
|
77905
77903
|
async promise() {
|
|
77906
77904
|
const value = args[key];
|
|
77905
|
+
const error2 = promptConfig.validate?.(value) ?? null;
|
|
77907
77906
|
const result = await inputPrompt({
|
|
77908
77907
|
...promptConfig,
|
|
77909
77908
|
// Accept the default value if the arg is already set
|
|
77910
|
-
acceptDefault: promptConfig.acceptDefault ?? value !== void 0,
|
|
77909
|
+
acceptDefault: promptConfig.acceptDefault ?? (value !== void 0 && !error2),
|
|
77911
77910
|
defaultValue: value ?? promptConfig.defaultValue,
|
|
77911
|
+
initialErrorMessage: error2,
|
|
77912
77912
|
throwOnError: true
|
|
77913
77913
|
});
|
|
77914
77914
|
args[key] = result;
|
|
@@ -77920,6 +77920,9 @@ var processArgument = async (args, key, promptConfig) => {
|
|
|
77920
77920
|
};
|
|
77921
77921
|
|
|
77922
77922
|
// src/deploy.ts
|
|
77923
|
+
var import_promises4 = require("node:fs/promises");
|
|
77924
|
+
var import_node_os5 = require("node:os");
|
|
77925
|
+
var import_node_path5 = require("node:path");
|
|
77923
77926
|
var import_toml2 = __toESM(require_toml());
|
|
77924
77927
|
|
|
77925
77928
|
// src/helpers/poll.ts
|
|
@@ -79238,23 +79241,34 @@ var runDeploy = async (ctx) => {
|
|
|
79238
79241
|
JSON.stringify(ctx.commitMessage)
|
|
79239
79242
|
] : []
|
|
79240
79243
|
];
|
|
79241
|
-
const
|
|
79242
|
-
|
|
79244
|
+
const outputFile = (0, import_node_path5.join)(
|
|
79245
|
+
await (0, import_promises4.mkdtemp)((0, import_node_path5.join)((0, import_node_os5.tmpdir)(), "c3-wrangler-deploy-")),
|
|
79246
|
+
"output.json"
|
|
79247
|
+
);
|
|
79248
|
+
await runCommand(deployCmd, {
|
|
79243
79249
|
cwd: ctx.project.path,
|
|
79244
79250
|
env: {
|
|
79245
79251
|
CLOUDFLARE_ACCOUNT_ID: ctx.account.id,
|
|
79246
|
-
NODE_ENV: "production"
|
|
79252
|
+
NODE_ENV: "production",
|
|
79253
|
+
WRANGLER_OUTPUT_FILE_PATH: outputFile
|
|
79247
79254
|
},
|
|
79248
79255
|
startText: "Deploying your application",
|
|
79249
79256
|
doneText: `${brandColor("deployed")} ${dim(
|
|
79250
79257
|
`via \`${quoteShellArgs(baseDeployCmd)}\``
|
|
79251
79258
|
)}`
|
|
79252
79259
|
});
|
|
79253
|
-
|
|
79254
|
-
|
|
79255
|
-
|
|
79256
|
-
|
|
79257
|
-
|
|
79260
|
+
try {
|
|
79261
|
+
const contents = readFile(outputFile);
|
|
79262
|
+
const entries = contents.split("\n").filter(Boolean).map((entry) => JSON.parse(entry));
|
|
79263
|
+
const url = entries.find((entry) => entry.type === "deploy")?.targets?.[0] ?? entries.find((entry) => entry.type === "pages-deploy")?.url;
|
|
79264
|
+
const deployedUrlRegex = /https:\/\/.+\.(pages|workers)\.dev/;
|
|
79265
|
+
const deployedUrlMatch = url?.match(deployedUrlRegex);
|
|
79266
|
+
if (deployedUrlMatch) {
|
|
79267
|
+
ctx.deployment.url = deployedUrlMatch[0];
|
|
79268
|
+
} else {
|
|
79269
|
+
throw new Error("Failed to find deployment url.");
|
|
79270
|
+
}
|
|
79271
|
+
} catch {
|
|
79258
79272
|
throw new Error("Failed to find deployment url.");
|
|
79259
79273
|
}
|
|
79260
79274
|
if (ctx.deployment.url?.endsWith(".pages.dev")) {
|
|
@@ -79339,6 +79353,7 @@ var printSummary = (ctx) => {
|
|
|
79339
79353
|
]);
|
|
79340
79354
|
const documentationUrl = `https://developers.cloudflare.com/${ctx.template.platform}`;
|
|
79341
79355
|
const discordUrl = `https://discord.cloudflare.com`;
|
|
79356
|
+
const reportIssueUrl = "https://github.com/cloudflare/workers-sdk/issues/new/choose";
|
|
79342
79357
|
const lines = [
|
|
79343
79358
|
`\u{1F389} ${bgGreen(" SUCCESS ")} Application ${ctx.deployment.url ? "deployed" : "created"} successfully!`,
|
|
79344
79359
|
``
|
|
@@ -79360,6 +79375,9 @@ var printSummary = (ctx) => {
|
|
|
79360
79375
|
`\u{1F4D6} Explore Documentation`,
|
|
79361
79376
|
`${blue.underline(hyperlink(documentationUrl))}`,
|
|
79362
79377
|
``,
|
|
79378
|
+
`\u{1F41B} Report an Issue`,
|
|
79379
|
+
`${blue.underline(hyperlink(reportIssueUrl))}`,
|
|
79380
|
+
``,
|
|
79363
79381
|
`\u{1F4AC} Join our Community`,
|
|
79364
79382
|
`${blue.underline(hyperlink(discordUrl))}`
|
|
79365
79383
|
);
|