Skip to content

Commit

Permalink
pass -y flag to npx when delegating to C3 if passed to `wrangler in…
Browse files Browse the repository at this point in the history
…it` (#3623)

* pass -y flag to npx when delegating to C3 if passed to wrangler
  • Loading branch information
RamIdeas committed Jul 21, 2023
1 parent cb26366 commit 99baf58
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 10 deletions.
5 changes: 5 additions & 0 deletions .changeset/happy-glasses-live.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"wrangler": patch
---

when running `wrangler init -y ...`, the `-y` flag is now passed to npx when delegating to C3
20 changes: 10 additions & 10 deletions packages/wrangler/src/__tests__/init.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ describe("init", () => {

expect(execa).toHaveBeenCalledWith(
"mockpm",
["create", "cloudflare@2", "--", "--wrangler-defaults"],
["create", "cloudflare@2", "-y", "--", "--wrangler-defaults"],
{ stdio: "inherit" }
);
});
Expand Down Expand Up @@ -147,7 +147,7 @@ describe("init", () => {

expect(execa).toHaveBeenCalledWith(
"mockpm",
["run", "create-cloudflare", "--", "--wrangler-defaults"],
["run", "create-cloudflare", "-y", "--", "--wrangler-defaults"],
{ stdio: "inherit" }
);
});
Expand Down Expand Up @@ -184,7 +184,7 @@ describe("init", () => {
`);
expect(std.err).toMatchInlineSnapshot(`""`);
expect(std.warn).toMatchInlineSnapshot(`
"[33m▲ [43;33m[[43;30mWARNING[43;33m][0m [1mThe \`init\` command is no longer supported. Please use \`mockpm create cloudflare@2 -- --wrangler-defaults\` instead.[0m
"[33m▲ [43;33m[[43;30mWARNING[43;33m][0m [1mThe \`init\` command is no longer supported. Please use \`mockpm create cloudflare@2 -y -- --wrangler-defaults\` instead.[0m
The \`init\` command will be removed in a future version.
Expand Down Expand Up @@ -223,7 +223,7 @@ describe("init", () => {
`);
expect(std.err).toMatchInlineSnapshot(`""`);
expect(std.warn).toMatchInlineSnapshot(`
"[33m▲ [43;33m[[43;30mWARNING[43;33m][0m [1mThe \`init\` command is no longer supported. Please use \`mockpm create cloudflare@2 -- my-worker --wrangler-defaults\` instead.[0m
"[33m▲ [43;33m[[43;30mWARNING[43;33m][0m [1mThe \`init\` command is no longer supported. Please use \`mockpm create cloudflare@2 -y -- my-worker --wrangler-defaults\` instead.[0m
The \`init\` command will be removed in a future version.
Expand Down Expand Up @@ -260,7 +260,7 @@ describe("init", () => {
To start developing your Worker, run \`npm start\`
To start testing your Worker, run \`npm test\`
To publish your Worker to the Internet, run \`npm run deploy\`",
"warn": "[33m▲ [43;33m[[43;30mWARNING[43;33m][0m [1mThe \`init\` command is no longer supported. Please use \`mockpm create cloudflare@2 -- --wrangler-defaults\` instead.[0m
"warn": "[33m▲ [43;33m[[43;30mWARNING[43;33m][0m [1mThe \`init\` command is no longer supported. Please use \`mockpm create cloudflare@2 -y -- --wrangler-defaults\` instead.[0m
The \`init\` command will be removed in a future version.
Expand Down Expand Up @@ -729,7 +729,7 @@ describe("init", () => {
To start developing your Worker, run \`npm start\`
To start testing your Worker, run \`npm test\`
To publish your Worker to the Internet, run \`npm run deploy\`",
"warn": "[33m▲ [43;33m[[43;30mWARNING[43;33m][0m [1mThe \`init\` command is no longer supported. Please use \`mockpm create cloudflare@2 -- --wrangler-defaults\` instead.[0m
"warn": "[33m▲ [43;33m[[43;30mWARNING[43;33m][0m [1mThe \`init\` command is no longer supported. Please use \`mockpm create cloudflare@2 -y -- --wrangler-defaults\` instead.[0m
The \`init\` command will be removed in a future version.
Expand Down Expand Up @@ -761,7 +761,7 @@ describe("init", () => {
To start developing your Worker, run \`cd path/to/worker/my-worker && npm start\`
To start testing your Worker, run \`npm test\`
To publish your Worker to the Internet, run \`npm run deploy\`",
"warn": "[33m▲ [43;33m[[43;30mWARNING[43;33m][0m [1mThe \`init\` command is no longer supported. Please use \`mockpm create cloudflare@2 -- path/to/worker/my-worker --wrangler-defaults\` instead.[0m
"warn": "[33m▲ [43;33m[[43;30mWARNING[43;33m][0m [1mThe \`init\` command is no longer supported. Please use \`mockpm create cloudflare@2 -y -- path/to/worker/my-worker --wrangler-defaults\` instead.[0m
The \`init\` command will be removed in a future version.
Expand Down Expand Up @@ -2303,7 +2303,7 @@ describe("init", () => {
To start developing your Worker, run \`npm start\`
To start testing your Worker, run \`npm test\`
To publish your Worker to the Internet, run \`npm run deploy\`",
"warn": "[33m▲ [43;33m[[43;30mWARNING[43;33m][0m [1mThe \`init\` command is no longer supported. Please use \`mockpm create cloudflare@2 -- . --wrangler-defaults\` instead.[0m
"warn": "[33m▲ [43;33m[[43;30mWARNING[43;33m][0m [1mThe \`init\` command is no longer supported. Please use \`mockpm create cloudflare@2 -y -- . --wrangler-defaults\` instead.[0m
The \`init\` command will be removed in a future version.
Expand Down Expand Up @@ -2339,7 +2339,7 @@ describe("init", () => {
To start developing your Worker, run \`cd path/to/worker && npm start\`
To start testing your Worker, run \`npm test\`
To publish your Worker to the Internet, run \`npm run deploy\`",
"warn": "[33m▲ [43;33m[[43;30mWARNING[43;33m][0m [1mThe \`init\` command is no longer supported. Please use \`mockpm create cloudflare@2 -- path/to/worker --wrangler-defaults\` instead.[0m
"warn": "[33m▲ [43;33m[[43;30mWARNING[43;33m][0m [1mThe \`init\` command is no longer supported. Please use \`mockpm create cloudflare@2 -y -- path/to/worker --wrangler-defaults\` instead.[0m
The \`init\` command will be removed in a future version.
Expand Down Expand Up @@ -2377,7 +2377,7 @@ describe("init", () => {
To start developing your Worker, run \`cd WEIRD_w0rkr_N4m3.js.tsx.tar.gz && npm start\`
To start testing your Worker, run \`npm test\`
To publish your Worker to the Internet, run \`npm run deploy\`",
"warn": "[33m▲ [43;33m[[43;30mWARNING[43;33m][0m [1mThe \`init\` command is no longer supported. Please use \`mockpm create cloudflare@2 -- WEIRD_w0rkr_N4m3.js.tsx.tar.gz --wrangler-defaults\` instead.[0m
"warn": "[33m▲ [43;33m[[43;30mWARNING[43;33m][0m [1mThe \`init\` command is no longer supported. Please use \`mockpm create cloudflare@2 -y -- WEIRD_w0rkr_N4m3.js.tsx.tar.gz --wrangler-defaults\` instead.[0m
The \`init\` command will be removed in a future version.
Expand Down
5 changes: 5 additions & 0 deletions packages/wrangler/src/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ export async function initHandler(args: InitArgs) {
const c3Arguments = [
...getC3CommandFromEnv().split(" "),
fromDashScriptName,
...(yesFlag ? ["-y"] : []), // --yes arg for npx
"--",
"--type",
"pre-existing",
Expand Down Expand Up @@ -243,6 +244,10 @@ export async function initHandler(args: InitArgs) {
c3Arguments.unshift("--");
}

if (yesFlag) {
c3Arguments.unshift("-y"); // arg for npx
}

c3Arguments.unshift(...getC3CommandFromEnv().split(" "));

// Deprecate the `init --from-dash` command
Expand Down

0 comments on commit 99baf58

Please sign in to comment.