Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement --json in versions list commands #5412

Merged
merged 4 commits into from
Mar 28, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/thirty-mayflies-carry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"wrangler": minor
---

feature: adds `--json` flag to `wrangler deployments list --experimental-versions` and `wrangler deployments status --experimental-versions`, `wrangler versions list --experimental-versions` and `wrangler versions view --experimental-versions` which will format the output as clean JSON. The ` --experimental-versions` flag is still required for these commands.
RamIdeas marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ describe("deployments list", () => {

describe("without wrangler.toml", () => {
test("fails with no args", async () => {
const result = runWrangler(
"deployments list --experimental-gradual-rollouts"
);
const result = runWrangler("deployments list --experimental-versions");

await expect(result).rejects.toMatchInlineSnapshot(
`[Error: You need to provide a name of your worker. Either pass it as a cli arg with \`--name <name>\` or in your config file as \`name = "<name>"\`]`
Expand All @@ -33,7 +31,7 @@ describe("deployments list", () => {

test("prints deployments to stdout", async () => {
const result = runWrangler(
"deployments list --name test-name --experimental-gradual-rollouts"
"deployments list --name test-name --experimental-versions"
);

await expect(result).resolves.toBeUndefined();
Expand All @@ -47,7 +45,7 @@ describe("deployments list", () => {
Created: 2021-01-01T00:00:00.000Z
Tag: -
Message: -

(90%) 20000000-0000-0000-0000-000000000000
Created: 2021-01-01T00:00:00.000Z
Tag: -
Expand All @@ -61,7 +59,7 @@ describe("deployments list", () => {
Created: 2021-01-01T00:00:00.000Z
Tag: -
Message: -

(80%) 20000000-0000-0000-0000-000000000000
Created: 2021-01-01T00:00:00.000Z
Tag: -
Expand All @@ -75,7 +73,7 @@ describe("deployments list", () => {
Created: 2021-01-01T00:00:00.000Z
Tag: -
Message: -

(70%) 20000000-0000-0000-0000-000000000000
Created: 2021-01-01T00:00:00.000Z
Tag: -
Expand All @@ -89,7 +87,7 @@ describe("deployments list", () => {
Created: 2021-01-01T00:00:00.000Z
Tag: -
Message: -

(60%) 20000000-0000-0000-0000-000000000000
Created: 2021-01-01T00:00:00.000Z
Tag: -
Expand All @@ -99,15 +97,107 @@ describe("deployments list", () => {

expect(std.err).toMatchInlineSnapshot(`""`);
});

test("prints deployments to stdout as --json", async () => {
const result = runWrangler(
"deployments list --name test-name --json --experimental-versions"
);

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

expect(std.out).toMatchInlineSnapshot(`
"[
{
\\"id\\": \\"Galaxy-Class-test-name\\",
\\"source\\": \\"api\\",
\\"strategy\\": \\"percentage\\",
\\"author_email\\": \\"Jean-Luc-Picard@federation.org\\",
\\"created_on\\": \\"2021-01-04T00:00:00.000000Z\\",
\\"annotations\\": {
\\"workers/triggered_by\\": \\"rollback\\",
\\"workers/rollback_from\\": \\"MOCK-DEPLOYMENT-ID-2222\\"
},
\\"versions\\": [
{
\\"version_id\\": \\"10000000-0000-0000-0000-000000000000\\",
\\"percentage\\": 10
},
{
\\"version_id\\": \\"20000000-0000-0000-0000-000000000000\\",
\\"percentage\\": 90
}
]
},
{
\\"id\\": \\"Galaxy-Class-test-name\\",
\\"source\\": \\"wrangler\\",
\\"strategy\\": \\"percentage\\",
\\"author_email\\": \\"Jean-Luc-Picard@federation.org\\",
\\"created_on\\": \\"2021-01-01T00:00:00.000000Z\\",
\\"annotations\\": {
\\"workers/triggered_by\\": \\"upload\\"
},
\\"versions\\": [
{
\\"version_id\\": \\"10000000-0000-0000-0000-000000000000\\",
\\"percentage\\": 20
},
{
\\"version_id\\": \\"20000000-0000-0000-0000-000000000000\\",
\\"percentage\\": 80
}
]
},
{
\\"id\\": \\"Intrepid-Class-test-name\\",
\\"source\\": \\"wrangler\\",
\\"strategy\\": \\"percentage\\",
\\"author_email\\": \\"Kathryn-Janeway@federation.org\\",
\\"created_on\\": \\"2021-02-02T00:00:00.000000Z\\",
\\"annotations\\": {
\\"workers/triggered_by\\": \\"rollback\\",
\\"workers/rollback_from\\": \\"MOCK-DEPLOYMENT-ID-1111\\",
\\"workers/message\\": \\"Rolled back for this version\\"
},
\\"versions\\": [
{
\\"version_id\\": \\"10000000-0000-0000-0000-000000000000\\",
\\"percentage\\": 30
},
{
\\"version_id\\": \\"20000000-0000-0000-0000-000000000000\\",
\\"percentage\\": 70
}
]
},
{
\\"id\\": \\"3mEgaU1T-Intrepid-someThing-test-name\\",
\\"source\\": \\"wrangler\\",
\\"strategy\\": \\"percentage\\",
\\"author_email\\": \\"Kathryn-Janeway@federation.org\\",
\\"created_on\\": \\"2021-02-03T00:00:00.000000Z\\",
\\"versions\\": [
{
\\"version_id\\": \\"10000000-0000-0000-0000-000000000000\\",
\\"percentage\\": 40
},
{
\\"version_id\\": \\"20000000-0000-0000-0000-000000000000\\",
\\"percentage\\": 60
}
]
}
]
"
`);
});
});

describe("with wrangler.toml", () => {
beforeEach(writeWranglerToml);

test("prints deployments to stdout", async () => {
const result = runWrangler(
"deployments list --experimental-gradual-rollouts"
);
const result = runWrangler("deployments list --experimental-versions");

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

Expand All @@ -120,7 +210,7 @@ describe("deployments list", () => {
Created: 2021-01-01T00:00:00.000Z
Tag: -
Message: -

(90%) 20000000-0000-0000-0000-000000000000
Created: 2021-01-01T00:00:00.000Z
Tag: -
Expand All @@ -134,7 +224,7 @@ describe("deployments list", () => {
Created: 2021-01-01T00:00:00.000Z
Tag: -
Message: -

(80%) 20000000-0000-0000-0000-000000000000
Created: 2021-01-01T00:00:00.000Z
Tag: -
Expand All @@ -148,7 +238,7 @@ describe("deployments list", () => {
Created: 2021-01-01T00:00:00.000Z
Tag: -
Message: -

(70%) 20000000-0000-0000-0000-000000000000
Created: 2021-01-01T00:00:00.000Z
Tag: -
Expand All @@ -162,7 +252,7 @@ describe("deployments list", () => {
Created: 2021-01-01T00:00:00.000Z
Tag: -
Message: -

(60%) 20000000-0000-0000-0000-000000000000
Created: 2021-01-01T00:00:00.000Z
Tag: -
Expand All @@ -172,5 +262,99 @@ describe("deployments list", () => {

expect(std.err).toMatchInlineSnapshot(`""`);
});

test("prints deployments to stdout as --json", async () => {
const result = runWrangler(
"deployments list --json --experimental-versions"
);

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

expect(std.out).toMatchInlineSnapshot(`
"[
{
\\"id\\": \\"Galaxy-Class-test-name\\",
\\"source\\": \\"api\\",
\\"strategy\\": \\"percentage\\",
\\"author_email\\": \\"Jean-Luc-Picard@federation.org\\",
\\"created_on\\": \\"2021-01-04T00:00:00.000000Z\\",
\\"annotations\\": {
\\"workers/triggered_by\\": \\"rollback\\",
\\"workers/rollback_from\\": \\"MOCK-DEPLOYMENT-ID-2222\\"
},
\\"versions\\": [
{
\\"version_id\\": \\"10000000-0000-0000-0000-000000000000\\",
\\"percentage\\": 10
},
{
\\"version_id\\": \\"20000000-0000-0000-0000-000000000000\\",
\\"percentage\\": 90
}
]
},
{
\\"id\\": \\"Galaxy-Class-test-name\\",
\\"source\\": \\"wrangler\\",
\\"strategy\\": \\"percentage\\",
\\"author_email\\": \\"Jean-Luc-Picard@federation.org\\",
\\"created_on\\": \\"2021-01-01T00:00:00.000000Z\\",
\\"annotations\\": {
\\"workers/triggered_by\\": \\"upload\\"
},
\\"versions\\": [
{
\\"version_id\\": \\"10000000-0000-0000-0000-000000000000\\",
\\"percentage\\": 20
},
{
\\"version_id\\": \\"20000000-0000-0000-0000-000000000000\\",
\\"percentage\\": 80
}
]
},
{
\\"id\\": \\"Intrepid-Class-test-name\\",
\\"source\\": \\"wrangler\\",
\\"strategy\\": \\"percentage\\",
\\"author_email\\": \\"Kathryn-Janeway@federation.org\\",
\\"created_on\\": \\"2021-02-02T00:00:00.000000Z\\",
\\"annotations\\": {
\\"workers/triggered_by\\": \\"rollback\\",
\\"workers/rollback_from\\": \\"MOCK-DEPLOYMENT-ID-1111\\",
\\"workers/message\\": \\"Rolled back for this version\\"
},
\\"versions\\": [
{
\\"version_id\\": \\"10000000-0000-0000-0000-000000000000\\",
\\"percentage\\": 30
},
{
\\"version_id\\": \\"20000000-0000-0000-0000-000000000000\\",
\\"percentage\\": 70
}
]
},
{
\\"id\\": \\"3mEgaU1T-Intrepid-someThing-test-name\\",
\\"source\\": \\"wrangler\\",
\\"strategy\\": \\"percentage\\",
\\"author_email\\": \\"Kathryn-Janeway@federation.org\\",
\\"created_on\\": \\"2021-02-03T00:00:00.000000Z\\",
\\"versions\\": [
{
\\"version_id\\": \\"10000000-0000-0000-0000-000000000000\\",
\\"percentage\\": 40
},
{
\\"version_id\\": \\"20000000-0000-0000-0000-000000000000\\",
\\"percentage\\": 60
}
]
}
]
"
`);
});
});
});