Skip to content

Commit 03ea04e

Browse files
committed
fix: assets only versions upload should include tag and message
1 parent f8f8f94 commit 03ea04e

File tree

5 files changed

+72
-7
lines changed

5 files changed

+72
-7
lines changed

.changeset/long-ants-start.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"wrangler": patch
3+
---
4+
5+
fix: assets only versions upload should include tag and message

packages/wrangler/e2e/versions.test.ts

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -596,6 +596,62 @@ describe.skipIf(!CLOUDFLARE_ACCOUNT_ID)(
596596
`);
597597
});
598598

599+
it("should upload version of Worker with assets only", async () => {
600+
await helper.seed({
601+
"wrangler.toml": dedent`
602+
name = "${workerName}"
603+
compatibility_date = "2023-01-01"
604+
605+
[assets]
606+
directory = "./public"
607+
`,
608+
"public/asset.txt": `beep boop beep boop`,
609+
"package.json": dedent`
610+
{
611+
"name": "${workerName}",
612+
"version": "0.0.0",
613+
"private": true
614+
}
615+
`,
616+
});
617+
618+
const upload = await helper.run(
619+
`wrangler versions upload --message "Upload via e2e test" --tag "e2e-upload-assets"`
620+
);
621+
622+
expect(normalize(upload.stdout)).toMatchInlineSnapshot(`
623+
"🌀 Building list of assets...
624+
✨ Read 1 file from the assets directory /tmpdir
625+
🌀 Starting asset upload...
626+
🌀 Found 1 new or modified static asset to upload. Proceeding with upload...
627+
+ /asset.txt
628+
Uploaded 1 of 1 assets
629+
✨ Success! Uploaded 1 file (TIMINGS)
630+
Total Upload: xx KiB / gzip: xx KiB
631+
Worker Startup Time: (TIMINGS)
632+
Uploaded tmp-e2e-worker-00000000-0000-0000-0000-000000000000 (TIMINGS)
633+
Worker Version ID: 00000000-0000-0000-0000-000000000000
634+
Version Preview URL: https://tmp-e2e-worker-PREVIEW-URL.SUBDOMAIN.workers.dev
635+
To deploy this version to production traffic use the command wrangler versions deploy
636+
Changes to non-versioned settings (config properties 'logpush' or 'tail_consumers') take effect after your next deployment using the command wrangler versions deploy
637+
Changes to triggers (routes, custom domains, cron schedules, etc) must be applied with the command wrangler triggers deploy"
638+
`);
639+
640+
const versionsView = await helper.run(
641+
`wrangler versions view ${matchVersionId(upload.stdout)}`
642+
);
643+
expect(normalize(versionsView.stdout)).toMatchInlineSnapshot(`
644+
"Version ID: 00000000-0000-0000-0000-000000000000
645+
Created: TIMESTAMP
646+
647+
Source: Unknown (version_upload)
648+
Tag: e2e-upload-assets
649+
Message: Upload via e2e test
650+
------------------------------------------------------------
651+
Compatibility Date: 2023-01-01"
652+
`);
653+
});
654+
599655
it("should include version preview url in output file", async () => {
600656
const outputFile = path.join(helper.tmpPath, "output.jsonnd");
601657
const upload = await helper.run(

packages/wrangler/src/deployment-bundle/create-worker-upload-form.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,7 @@ export function createWorkerUploadForm(worker: CfWorkerInit): FormData {
247247
jwt: assets.jwt,
248248
config: assetConfig,
249249
},
250+
...(annotations && { annotations }),
250251
...(compatibility_date && { compatibility_date }),
251252
...(compatibility_flags && { compatibility_flags }),
252253
})

packages/wrangler/src/versions/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export type ApiVersion = {
3636
bindings: WorkerMetadataBinding[];
3737
script: {
3838
etag: string;
39-
handlers: string[];
39+
handlers: string[] | null;
4040
placement_mode?: "smart";
4141
last_deployed_from: string;
4242
};

packages/wrangler/src/versions/view.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,10 @@ export const versionsViewCommand = createCommand({
7979
Message: version.annotations?.["workers/message"] || BLANK_INPUT,
8080
})
8181
);
82-
logRaw("------------------------------------------------------------");
83-
const scriptInfo: ScriptInfoLog = {
84-
Handlers: version.resources.script.handlers.join(", "),
85-
};
82+
const scriptInfo: ScriptInfoLog = {};
83+
if (version.resources.script.handlers) {
84+
scriptInfo.Handlers = version.resources.script.handlers.join(", ");
85+
}
8686
if (version.resources.script_runtime.compatibility_date) {
8787
scriptInfo["Compatibility Date"] =
8888
version.resources.script_runtime.compatibility_date;
@@ -91,7 +91,10 @@ export const versionsViewCommand = createCommand({
9191
scriptInfo["Compatibility Flags"] =
9292
version.resources.script_runtime.compatibility_flags.join(", ");
9393
}
94-
logRaw(formatLabelledValues(scriptInfo));
94+
if (Object.keys(scriptInfo).length > 0) {
95+
logRaw("------------------------------------------------------------");
96+
logRaw(formatLabelledValues(scriptInfo));
97+
}
9598

9699
const secrets = version.resources.bindings.filter(
97100
(binding) => binding.type === "secret_text"
@@ -142,7 +145,7 @@ export const versionsViewCommand = createCommand({
142145
});
143146

144147
type ScriptInfoLog = {
145-
Handlers: string;
148+
Handlers?: string;
146149
"Compatibility Date"?: string;
147150
"Compatibility Flags"?: string;
148151
};

0 commit comments

Comments
 (0)