From 0597300233614061ac6793b3506f9517334999ae Mon Sep 17 00:00:00 2001 From: Paul Paterson Date: Thu, 16 Jan 2025 16:18:11 -0500 Subject: [PATCH 1/5] Remove deprecated 'force' param from diff endpoint --- .gitignore | 12 ++++++------ src/commands/schema/diff.mjs | 2 -- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/.gitignore b/.gitignore index 05ae68e1..a380c8c2 100644 --- a/.gitignore +++ b/.gitignore @@ -20,9 +20,9 @@ test-results.xml /test/test-homedir # default fauna config file names -fauna.config.yaml, -fauna.config.yml, -fauna.config.json, -.fauna.config.yaml, -.fauna.config.yml, -.fauna.config.json, +fauna.config.yaml +fauna.config.yml +fauna.config.json +.fauna.config.yaml +.fauna.config.yml +.fauna.config.json diff --git a/src/commands/schema/diff.mjs b/src/commands/schema/diff.mjs index 5ddfa73e..bdfbe595 100644 --- a/src/commands/schema/diff.mjs +++ b/src/commands/schema/diff.mjs @@ -48,8 +48,6 @@ function buildValidateParams(argv, version) { }); if (version) { params.set("version", version); - } else { - params.set("force", "true"); } return params; From 4e5ed689d64851005e42a9fbeaa6fe857da078a1 Mon Sep 17 00:00:00 2001 From: Paul Paterson Date: Thu, 16 Jan 2025 16:42:36 -0500 Subject: [PATCH 2/5] rename diff param to format --- src/commands/schema/diff.mjs | 8 ++++---- test/commands/schema/diff.mjs | 12 ++++-------- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/src/commands/schema/diff.mjs b/src/commands/schema/diff.mjs index bdfbe595..5045fe11 100644 --- a/src/commands/schema/diff.mjs +++ b/src/commands/schema/diff.mjs @@ -32,18 +32,18 @@ function parseTarget(argv) { function buildStatusParams(argv) { const params = new URLSearchParams({}); const [, target] = parseTarget(argv); - const diffKind = argv.text ? "textual" : "semantic"; + const format = argv.text ? "textual" : "semantic"; - if (target === "staged") params.set("diff", diffKind); + if (target === "staged") params.set("format", format); return params; } function buildValidateParams(argv, version) { const [source] = parseTarget(argv); - const diffKind = argv.text ? "textual" : "semantic"; + const format = argv.text ? "textual" : "semantic"; const params = new URLSearchParams({ - diff: diffKind, + format, staged: String(source === "staged"), }); if (version) { diff --git a/test/commands/schema/diff.mjs b/test/commands/schema/diff.mjs index 709c511c..270cadb9 100644 --- a/test/commands/schema/diff.mjs +++ b/test/commands/schema/diff.mjs @@ -47,8 +47,7 @@ describe("schema diff", function () { expect(fetch).to.have.been.calledWith( buildUrl("/schema/1/diff", { color: "ansi", - diff: "semantic", - force: "true", + format: "semantic", staged: "true", }), { ...commonFetchParams, method: "POST", body: reformatFSL(fsl) }, @@ -74,8 +73,7 @@ describe("schema diff", function () { expect(fetch).to.have.been.calledWith( buildUrl("/schema/1/diff", { color: "ansi", - diff: "semantic", - force: "true", + format: "semantic", staged: "false", }), { ...commonFetchParams, method: "POST", body: reformatFSL(fsl) }, @@ -100,9 +98,8 @@ describe("schema diff", function () { }); expect(fetch).to.have.been.calledWith( buildUrl("/schema/1/diff", { - force: "true", staged: "true", - diff: "semantic", + format: "semantic", }), { ...commonFetchParams, method: "POST", body: reformatFSL(fsl) }, ); @@ -126,10 +123,9 @@ describe("schema diff", function () { ); expect(fetch).to.have.been.calledWith( buildUrl("/schema/1/diff", { - force: "true", color: "ansi", staged: "true", - diff: "semantic", + format: "semantic", }), { ...commonFetchParams, method: "POST", body: reformatFSL(fsl) }, ); From 41d47cb36071743afe95627e4726b659733e8c9d Mon Sep 17 00:00:00 2001 From: Paul Paterson Date: Thu, 16 Jan 2025 19:43:56 -0500 Subject: [PATCH 3/5] update other commands --- src/commands/schema/abandon.mjs | 6 +----- src/commands/schema/commit.mjs | 7 +------ src/commands/schema/push.mjs | 1 - 3 files changed, 2 insertions(+), 12 deletions(-) diff --git a/src/commands/schema/abandon.mjs b/src/commands/schema/abandon.mjs index a898b3f1..e9fee5fa 100644 --- a/src/commands/schema/abandon.mjs +++ b/src/commands/schema/abandon.mjs @@ -11,21 +11,17 @@ async function doAbandon(argv) { const secret = await getSecret(argv); if (!argv.input) { - const params = new URLSearchParams({ - force: "true", // Just abandon, don't pass a schema version through. - }); await makeFaunaRequest({ argv, path: "/schema/1/staged/abandon", - params, method: "POST", secret, }); logger.stdout("Schema has been abandoned."); } else { // Show status to confirm. - const params = new URLSearchParams({ diff: "true" }); + const params = new URLSearchParams({ format: "semantic" }); const response = await makeFaunaRequest({ argv, diff --git a/src/commands/schema/commit.mjs b/src/commands/schema/commit.mjs index df34c0a6..3cba90e1 100644 --- a/src/commands/schema/commit.mjs +++ b/src/commands/schema/commit.mjs @@ -11,14 +11,9 @@ async function doCommit(argv) { const secret = await getSecret(argv); if (!argv.input) { - const params = new URLSearchParams({ - force: "true", // Just commit, don't pass a schema version through. - }); - await makeFaunaRequest({ argv, path: "/schema/1/staged/commit", - params, method: "POST", secret, }); @@ -26,7 +21,7 @@ async function doCommit(argv) { logger.stdout("Schema has been committed"); } else { // Show status to confirm. - const params = new URLSearchParams({ diff: "true" }); + const params = new URLSearchParams({ format: "semantic" }); const response = await makeFaunaRequest({ argv, diff --git a/src/commands/schema/push.mjs b/src/commands/schema/push.mjs index 6e2929d4..6d932749 100644 --- a/src/commands/schema/push.mjs +++ b/src/commands/schema/push.mjs @@ -30,7 +30,6 @@ export async function pushSchema(argv) { ); } else if (!argv.input) { const params = new URLSearchParams({ - force: "true", staged: argv.active ? "false" : "true", }); From 819d9214dd9b6235fce97632cfdd12d780413b27 Mon Sep 17 00:00:00 2001 From: Paul Paterson Date: Thu, 16 Jan 2025 19:44:39 -0500 Subject: [PATCH 4/5] formatting --- src/commands/schema/abandon.mjs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/commands/schema/abandon.mjs b/src/commands/schema/abandon.mjs index e9fee5fa..5c9fcb70 100644 --- a/src/commands/schema/abandon.mjs +++ b/src/commands/schema/abandon.mjs @@ -11,7 +11,6 @@ async function doAbandon(argv) { const secret = await getSecret(argv); if (!argv.input) { - await makeFaunaRequest({ argv, path: "/schema/1/staged/abandon", From 7a4995767843a69ed0145b3ea4fc02e8e9202efa Mon Sep 17 00:00:00 2001 From: Paul Paterson Date: Fri, 17 Jan 2025 09:24:03 -0500 Subject: [PATCH 5/5] fix tests --- test/commands/local.mjs | 13 +++++-------- test/commands/schema/abandon.mjs | 17 +++++++++++++---- test/commands/schema/commit.mjs | 28 ++++++++++++++++++++-------- test/commands/schema/push.mjs | 2 +- 4 files changed, 39 insertions(+), 21 deletions(-) diff --git a/test/commands/local.mjs b/test/commands/local.mjs index 4892750e..4241cf61 100644 --- a/test/commands/local.mjs +++ b/test/commands/local.mjs @@ -184,14 +184,11 @@ Please pass a --host-port other than '8443'.", await run(`local --no-color ${args}`, container); expect(gatherFSL).to.have.been.calledWith("bar"); - expect(fetch).to.have.been.calledWith( - `${baseUrl}/update?force=true&staged=false`, - { - method: "POST", - headers: { AUTHORIZATION: "Bearer secret:Foo:admin" }, - body: reformatFSL(fsl), - }, - ); + expect(fetch).to.have.been.calledWith(`${baseUrl}/update?staged=false`, { + method: "POST", + headers: { AUTHORIZATION: "Bearer secret:Foo:admin" }, + body: reformatFSL(fsl), + }); const written = stderrStream.getWritten(); expect(written).to.contain( "[CreateDatabaseSchema] Schema for database 'Foo' created from directory './bar'.", diff --git a/test/commands/schema/abandon.mjs b/test/commands/schema/abandon.mjs index dcc5102b..315269b2 100644 --- a/test/commands/schema/abandon.mjs +++ b/test/commands/schema/abandon.mjs @@ -38,7 +38,7 @@ describe("schema abandon", function () { expect(fetch).to.have.been.calledOnce; expect(fetch).to.have.been.calledWith( - buildUrl("/schema/1/staged/abandon", { force: "true" }), + buildUrl("/schema/1/staged/abandon"), { ...commonFetchParams, method: "POST" }, ); expect(logger.stdout).to.have.been.calledWith("Schema has been abandoned."); @@ -65,7 +65,10 @@ describe("schema abandon", function () { await run(`schema abandon --secret "secret"`, container); expect(fetch).to.have.been.calledWith( - buildUrl("/schema/1/staged/status", { diff: "true", color: "ansi" }), + buildUrl("/schema/1/staged/status", { + format: "semantic", + color: "ansi", + }), { ...commonFetchParams, method: "GET" }, ); expect(fetch).to.have.been.calledWith( @@ -93,7 +96,10 @@ describe("schema abandon", function () { expect(logger.stderr).to.have.been.calledWith(message); expect(fetch).to.have.been.calledWith( - buildUrl("/schema/1/staged/status", { diff: "true", color: "ansi" }), + buildUrl("/schema/1/staged/status", { + format: "semantic", + color: "ansi", + }), { ...commonFetchParams, method: "GET" }, ); }); @@ -117,7 +123,10 @@ describe("schema abandon", function () { expect(fetch).to.have.been.calledOnce; expect(fetch).to.have.been.calledWith( - buildUrl("/schema/1/staged/status", { diff: "true", color: "ansi" }), + buildUrl("/schema/1/staged/status", { + format: "semantic", + color: "ansi", + }), { ...commonFetchParams, method: "GET" }, ); expect(logger.stdout).to.have.been.calledWith("Abandon cancelled."); diff --git a/test/commands/schema/commit.mjs b/test/commands/schema/commit.mjs index 8cded0bf..6181b960 100644 --- a/test/commands/schema/commit.mjs +++ b/test/commands/schema/commit.mjs @@ -42,7 +42,10 @@ describe("schema commit", function () { await run(`schema commit --secret "secret"`, container); expect(fetch).to.have.been.calledWith( - buildUrl("/schema/1/staged/status", { diff: "true", color: "ansi" }), + buildUrl("/schema/1/staged/status", { + format: "semantic", + color: "ansi", + }), { ...commonFetchParams, method: "GET" }, ); expect(fetch).to.have.been.calledWith( @@ -62,10 +65,10 @@ describe("schema commit", function () { await run(`schema commit --secret "secret" --no-input`, container); expect(fetch).to.have.been.calledOnce; - expect(fetch).to.have.been.calledWith( - buildUrl("/schema/1/staged/commit", { force: "true" }), - { ...commonFetchParams, method: "POST" }, - ); + expect(fetch).to.have.been.calledWith(buildUrl("/schema/1/staged/commit"), { + ...commonFetchParams, + method: "POST", + }); expect(logger.stdout).to.have.been.calledWith("Schema has been committed"); expect(logger.stderr).to.not.have.been.called; expect(confirm).to.not.have.been.called; @@ -81,7 +84,10 @@ describe("schema commit", function () { expect(error).to.have.property("code", 1); expect(fetch).to.have.been.calledOnce; expect(fetch).to.have.been.calledWith( - buildUrl("/schema/1/staged/status", { diff: "true", color: "ansi" }), + buildUrl("/schema/1/staged/status", { + format: "semantic", + color: "ansi", + }), { ...commonFetchParams, method: "GET" }, ); expect(logger.stdout).to.not.have.been.called; @@ -100,7 +106,10 @@ describe("schema commit", function () { expect(error).to.have.property("code", 1); expect(fetch).to.have.been.calledOnce; expect(fetch).to.have.been.calledWith( - buildUrl("/schema/1/staged/status", { diff: "true", color: "ansi" }), + buildUrl("/schema/1/staged/status", { + format: "semantic", + color: "ansi", + }), { ...commonFetchParams, method: "GET" }, ); expect(logger.stdout).to.have.been.calledWith(diff); @@ -127,7 +136,10 @@ describe("schema commit", function () { expect(fetch).to.have.been.calledOnce; expect(fetch).to.have.been.calledWith( - buildUrl("/schema/1/staged/status", { diff: "true", color: "ansi" }), + buildUrl("/schema/1/staged/status", { + format: "semantic", + color: "ansi", + }), { ...commonFetchParams, method: "GET" }, ); expect(logger.stdout).to.have.been.calledWith("Commit cancelled"); diff --git a/test/commands/schema/push.mjs b/test/commands/schema/push.mjs index 85ff2c8e..fab5dfc6 100644 --- a/test/commands/schema/push.mjs +++ b/test/commands/schema/push.mjs @@ -54,7 +54,7 @@ describe("schema push", function () { expect(gatherFSL).to.have.been.calledWith("."); expect(fetch).to.have.been.calledWith( - buildUrl("/schema/1/update", { force: "true", staged: "true" }), + buildUrl("/schema/1/update", { staged: "true" }), { method: "POST", headers: { AUTHORIZATION: "Bearer secret" },