Skip to content

Commit 8ca9533

Browse files
feat: notify users when they are running C3 in experimental mode (#7506)
1 parent 75be0d5 commit 8ca9533

File tree

4 files changed

+76
-26
lines changed

4 files changed

+76
-26
lines changed

.changeset/smooth-vans-share.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"create-cloudflare": patch
3+
---
4+
5+
feat: notify users when they are running C3 in experimental mode

packages/create-cloudflare/src/__tests__/dialog.test.ts

Lines changed: 57 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -15,33 +15,69 @@ describe("dialog helpers", () => {
1515
process.stdout.columns = originalColumns;
1616
});
1717

18-
test("printWelcomeMessage with telemetry disabled", () => {
19-
printWelcomeMessage("0.0.0", false);
18+
describe("printWelcomeMessage", () => {
19+
test("with telemetry disabled", () => {
20+
printWelcomeMessage("0.0.0", false, {});
2021

21-
expect(normalizeOutput(std.out)).toMatchInlineSnapshot(`
22-
"────────────────────────────────────────────────────────────
23-
👋 Welcome to create-cloudflare v0.0.0!
24-
🧡 Let's get started.
25-
────────────────────────────────────────────────────────────
22+
expect(normalizeOutput(std.out)).toMatchInlineSnapshot(`
23+
"────────────────────────────────────────────────────────────
24+
👋 Welcome to create-cloudflare v0.0.0!
25+
🧡 Let's get started.
26+
────────────────────────────────────────────────────────────
2627
27-
"
28-
`);
29-
});
28+
"
29+
`);
30+
});
31+
32+
test("with telemetry enabled", () => {
33+
printWelcomeMessage("0.0.0", true, {});
34+
35+
expect(normalizeOutput(std.out)).toMatchInlineSnapshot(`
36+
"────────────────────────────────────────────────────────────
37+
👋 Welcome to create-cloudflare v0.0.0!
38+
🧡 Let's get started.
39+
📊 Cloudflare collects telemetry about your usage of Create-Cloudflare.
3040
31-
test("printWelcomeMessage with telemetry enabled", () => {
32-
printWelcomeMessage("0.0.0", true);
41+
Learn more at: https://github.com/cloudflare/workers-sdk/blob/main/packages/create-cloudflare/telemetry.md
42+
────────────────────────────────────────────────────────────
3343
34-
expect(normalizeOutput(std.out)).toMatchInlineSnapshot(`
35-
"────────────────────────────────────────────────────────────
36-
👋 Welcome to create-cloudflare v0.0.0!
37-
🧡 Let's get started.
38-
📊 Cloudflare collects telemetry about your usage of Create-Cloudflare.
44+
"
45+
`);
46+
});
47+
48+
test("with telemetry disabled in experimental mode", () => {
49+
printWelcomeMessage("0.0.0", false, { experimental: true });
3950

40-
Learn more at: https://github.com/cloudflare/workers-sdk/blob/main/packages/create-cloudflare/telemetry.md
41-
────────────────────────────────────────────────────────────
51+
expect(normalizeOutput(std.out)).toMatchInlineSnapshot(`
52+
"────────────────────────────────────────────────────────────
53+
👋 Welcome to create-cloudflare v0.0.0!
54+
🧡 Let's get started.
4255
43-
"
44-
`);
56+
🧪 Running in experimental mode
57+
────────────────────────────────────────────────────────────
58+
59+
"
60+
`);
61+
});
62+
63+
test("with telemetry enabled in experimental mode", () => {
64+
printWelcomeMessage("0.0.0", true, { experimental: true });
65+
66+
expect(normalizeOutput(std.out)).toMatchInlineSnapshot(`
67+
"────────────────────────────────────────────────────────────
68+
👋 Welcome to create-cloudflare v0.0.0!
69+
🧡 Let's get started.
70+
71+
🧪 Running in experimental mode
72+
73+
📊 Cloudflare collects telemetry about your usage of Create-Cloudflare.
74+
75+
Learn more at: https://github.com/cloudflare/workers-sdk/blob/main/packages/create-cloudflare/telemetry.md
76+
────────────────────────────────────────────────────────────
77+
78+
"
79+
`);
80+
});
4581
});
4682

4783
describe("printSummary", () => {

packages/create-cloudflare/src/cli.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ export const runLatest = async () => {
102102

103103
// Entrypoint to c3
104104
export const runCli = async (args: Partial<C3Args>) => {
105-
printBanner();
105+
printBanner(args);
106106

107107
const ctx = await createContext(args);
108108

@@ -186,8 +186,8 @@ const deploy = async (ctx: C3Context) => {
186186
endSection("Done");
187187
};
188188

189-
const printBanner = () => {
190-
printWelcomeMessage(version, reporter.isEnabled);
189+
const printBanner = (args: Partial<C3Args>) => {
190+
printWelcomeMessage(version, reporter.isEnabled, args);
191191
startSection(`Create an application with Cloudflare`, "Step 1 of 3");
192192
};
193193

packages/create-cloudflare/src/dialog.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { hyperlink, logRaw, shapes, stripAnsi } from "@cloudflare/cli";
33
import { bgGreen, blue, gray } from "@cloudflare/cli/colors";
44
import { quoteShellArgs } from "helpers/command";
55
import { detectPackageManager } from "helpers/packageManagers";
6-
import type { C3Context } from "types";
6+
import type { C3Args, C3Context } from "types";
77

88
/**
99
* Wrap the lines with a border and inner padding
@@ -27,18 +27,27 @@ export function createDialog(lines: string[]) {
2727
export function printWelcomeMessage(
2828
version: string,
2929
telemetryEnabled: boolean,
30+
args: Partial<C3Args>,
3031
) {
3132
const lines = [
3233
`👋 Welcome to create-cloudflare v${version}!`,
3334
`🧡 Let's get started.`,
3435
];
3536

37+
if (args.experimental) {
38+
lines.push("", blue`🧪 Running in experimental mode`);
39+
}
40+
3641
if (telemetryEnabled) {
42+
if (args.experimental) {
43+
lines.push("");
44+
}
45+
3746
const telemetryDocsUrl = `https://github.com/cloudflare/workers-sdk/blob/main/packages/create-cloudflare/telemetry.md`;
3847

3948
lines.push(
4049
`📊 Cloudflare collects telemetry about your usage of Create-Cloudflare.`,
41-
``,
50+
"",
4251
`Learn more at: ${blue.underline(hyperlink(telemetryDocsUrl))}`,
4352
);
4453
}

0 commit comments

Comments
 (0)