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
5 changes: 5 additions & 0 deletions .changeset/three-toys-feel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"wrangler": patch
---

fix: script should be accepted as a positional arg in the `versions upload` command
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ describe("versions --help", () => {
COMMANDS
wrangler versions view <version-id> View the details of a specific version of your Worker
wrangler versions list List the 10 most recent Versions of your Worker
wrangler versions upload Uploads your Worker code and config as a new Version
wrangler versions upload [script] Uploads your Worker code and config as a new Version
wrangler versions deploy [version-specs..] Safely roll out new Versions of your Worker by splitting traffic between multiple Versions
wrangler versions secret Generate a secret that can be referenced in a Worker

Expand Down Expand Up @@ -50,7 +50,7 @@ describe("versions subhelp", () => {
COMMANDS
wrangler versions view <version-id> View the details of a specific version of your Worker
wrangler versions list List the 10 most recent Versions of your Worker
wrangler versions upload Uploads your Worker code and config as a new Version
wrangler versions upload [script] Uploads your Worker code and config as a new Version
wrangler versions deploy [version-specs..] Safely roll out new Versions of your Worker by splitting traffic between multiple Versions
wrangler versions secret Generate a secret that can be referenced in a Worker

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,31 @@ describe("versions upload", () => {
`);
});

test("should accept script as a positional arg", async () => {
mockGetScript();
mockUploadVersion(false);

// Setup
writeWranglerConfig({
name: "test-name",
// i.e. would error if the arg wasn't picked up
main: "./nope.js",
});
writeWorkerSource();
setIsTTY(false);

const result = runWrangler("versions upload index.js");

await expect(result).resolves.toBeUndefined();

expect(std.out).toMatchInlineSnapshot(`
"Total Upload: xx KiB / gzip: xx KiB
Worker Startup Time: 500 ms
Uploaded test-name (TIMINGS)
Worker Version ID: 51e4886e-2db7-4900-8d38-fbfecfeab993"
`);
});

test("should print preview url if version has preview", async () => {
mockGetScript();
mockUploadVersion(true);
Expand Down
41 changes: 21 additions & 20 deletions packages/wrangler/src/versions/upload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,24 +104,41 @@ export const versionsUploadCommand = createCommand({
owner: "Workers: Authoring and Testing",
status: "stable",
},
positionalArgs: ["script"],
args: {
script: {
describe: "The path to an entry point for your Worker",
type: "string",
requiresArg: true,
},
name: {
describe: "Name of the worker",
describe: "Name of the Worker",
type: "string",
requiresArg: true,
},
tag: {
describe: "A tag for this Worker Gradual Rollouts Version",
type: "string",
requiresArg: true,
},
message: {
describe:
"A descriptive message for this Worker Gradual Rollouts Version",
type: "string",
requiresArg: true,
},
"preview-alias": {
describe: "Name of an alias for this Worker version",
type: "string",
requiresArg: true,
},
bundle: {
describe: "Run wrangler's compilation step before publishing",
describe: "Run Wrangler's compilation step before publishing",
type: "boolean",
hidden: true,
},
"no-bundle": {
describe: "Skip internal build steps and directly deploy Worker",
describe: "Skip internal build steps and directly upload Worker",
type: "boolean",
default: false,
},
Expand Down Expand Up @@ -231,25 +248,9 @@ export const versionsUploadCommand = createCommand({
deprecated: true,
},
"dry-run": {
describe: "Don't actually deploy",
describe: "Compile a project without actually uploading the version.",
type: "boolean",
},
tag: {
describe: "A tag for this Worker Gradual Rollouts Version",
type: "string",
requiresArg: true,
},
message: {
describe:
"A descriptive message for this Worker Gradual Rollouts Version",
type: "string",
requiresArg: true,
},
"preview-alias": {
describe: "Name of an alias for this Worker version",
type: "string",
requiresArg: true,
},
"experimental-auto-create": {
describe: "Automatically provision draft bindings with new resources",
type: "boolean",
Expand Down
Loading