Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changeset/quiet-skills-update.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"wrangler": patch
---

Stop automatically offering to install Cloudflare skills for new users

Wrangler will no longer prompt new users to install Cloudflare skills after commands complete. It will continue to offer updates to skills that Wrangler previously installed.
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,15 @@ describe("register-yargs-command skills integration", () => {
});
});

test("does not call runSkillsInstallFlow for commands without suggestSkillsAfterHandler", async ({
test("does not check skills for commands without suggestSkillsAfterHandler", async ({
expect,
}) => {
// `wrangler complete` intentionally does not suggest skills because
// `wrangler complete` intentionally does not check skills because
// its stdout is captured by shell eval.
await runWrangler("complete zsh");

expect(runSkillsInstallFlow).not.toHaveBeenCalled();
expect(runSkillsUpdateFlow).not.toHaveBeenCalled();
});

test("calls runSkillsInstallFlow with force: true and command when --install-skills is passed", async ({
Expand All @@ -53,30 +54,28 @@ describe("register-yargs-command skills integration", () => {
});
});

test("calls runSkillsInstallFlow after commands with suggestSkillsAfterHandler: true", async ({
test("calls runSkillsUpdateFlow after commands with suggestSkillsAfterHandler: true", async ({
expect,
}) => {
await runWrangler("setup");

expect(runSkillsInstallFlow).toHaveBeenCalledWith({
force: false,
expect(runSkillsInstallFlow).not.toHaveBeenCalled();
expect(runSkillsUpdateFlow).toHaveBeenCalledWith({
command: "setup",
promptMessage: expect.any(Function),
});
});

test("calls runSkillsInstallFlow after `wrangler whoami` (non-JSON)", async ({
test("calls runSkillsUpdateFlow after `wrangler whoami` (non-JSON)", async ({
expect,
}) => {
// whoami in non-JSON mode completes successfully even without auth
// (it just prints "You are not authenticated") — the suggest-skills
// (it just prints "You are not authenticated") — the skills update
// hook should still fire afterwards.
await runWrangler("whoami");

expect(runSkillsInstallFlow).toHaveBeenCalledWith({
force: false,
expect(runSkillsInstallFlow).not.toHaveBeenCalled();
expect(runSkillsUpdateFlow).toHaveBeenCalledWith({
command: "whoami",
promptMessage: expect.any(Function),
});
});

Expand All @@ -97,7 +96,7 @@ describe("register-yargs-command skills integration", () => {
expect(call.command).not.toContain("install-skills");
});

test("does not call runSkillsInstallFlow after `wrangler whoami --json`", async ({
test("does not check skills after `wrangler whoami --json`", async ({
expect,
}) => {
// whoami --json without auth throws (non-zero exit), so we catch it.
Expand All @@ -106,67 +105,35 @@ describe("register-yargs-command skills integration", () => {
await expect(runWrangler("whoami --json")).rejects.toThrow();

expect(runSkillsInstallFlow).not.toHaveBeenCalled();
expect(runSkillsUpdateFlow).not.toHaveBeenCalled();
});

test("does not fail the command when runSkillsInstallFlow throws", async ({
test("does not fail the command when runSkillsUpdateFlow throws", async ({
expect,
}) => {
// If the post-handler skills suggestion fails (e.g. EACCES writing
// If the post-handler skills update check fails (e.g. EACCES writing
// the metadata file, or an I/O error from the confirm prompt), the
// command itself should still succeed — the error is swallowed and
// logged at debug level.
vi.mocked(runSkillsInstallFlow).mockRejectedValueOnce(
vi.mocked(runSkillsUpdateFlow).mockRejectedValueOnce(
new Error("EACCES: permission denied")
);

// `setup` has suggestSkillsAfterHandler: true, so it triggers the flow.
// This should resolve successfully despite the skills flow throwing.
// `setup` has suggestSkillsAfterHandler: true, so it triggers the check.
// This should resolve successfully despite the skills update check throwing.
await runWrangler("setup");

expect(runSkillsInstallFlow).toHaveBeenCalled();
});

test("does not call runSkillsUpdateFlow when runSkillsInstallFlow just installed skills", async ({
expect,
}) => {
// When the install flow returns true it means it just performed a
// fresh install, so the update flow should be skipped — the newly
// installed skills are already the latest version.
vi.mocked(runSkillsInstallFlow).mockResolvedValueOnce(true);

await runWrangler("setup");

expect(runSkillsInstallFlow).toHaveBeenCalled();
expect(runSkillsUpdateFlow).not.toHaveBeenCalled();
});

test("calls runSkillsUpdateFlow when runSkillsInstallFlow did not install", async ({
expect,
}) => {
// When the install flow returns false (skills already installed or
// user was not prompted), the update flow should run to check
// whether the existing skills are out of date.
vi.mocked(runSkillsInstallFlow).mockResolvedValueOnce(false);

await runWrangler("setup");

expect(runSkillsInstallFlow).toHaveBeenCalled();
expect(runSkillsUpdateFlow).toHaveBeenCalledWith(
expect.objectContaining({
command: "setup",
})
);
expect(runSkillsUpdateFlow).toHaveBeenCalled();
});

test("does not call runSkillsUpdateFlow when WRANGLER_NO_SKILLS_UPDATE_PROMPTS env var is set", async ({
expect,
}) => {
vi.mocked(runSkillsInstallFlow).mockResolvedValueOnce(false);
vi.stubEnv("WRANGLER_NO_SKILLS_UPDATE_PROMPTS", "true");

await runWrangler("setup");

expect(runSkillsInstallFlow).toHaveBeenCalled();
expect(runSkillsInstallFlow).not.toHaveBeenCalled();
expect(runSkillsUpdateFlow).not.toHaveBeenCalled();
});
});
17 changes: 11 additions & 6 deletions packages/wrangler/src/core/register-yargs-command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -359,15 +359,20 @@ function createHandler(def: InternalCommandDefinition, argv: string[]) {
shouldSuggestSkills === true ||
(typeof shouldSuggestSkills === "function" &&
shouldSuggestSkills(args) === true);
// We are currently not sure whether the automatic skills installation is beneficial
// so we are skipping it for the time being (we might potentially re-enable it later on)
const shouldInstall = false;
Comment thread
MattieTK marked this conversation as resolved.

if (suggestSkillsEnabled) {
try {
const justInstalled = await runSkillsInstallFlow({
force: false,
command: sanitizedCommand,
promptMessage:
skillInstallPromptMessageAfterWranglerCommandHandler,
});
const justInstalled = shouldInstall
? await runSkillsInstallFlow({
force: false,
command: sanitizedCommand,
promptMessage:
skillInstallPromptMessageAfterWranglerCommandHandler,
})
: false;

// Only check for updates when the install flow did not
// just perform a fresh install — a brand-new install
Expand Down
Loading