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/abandon.mjs b/src/commands/schema/abandon.mjs index a898b3f1..5c9fcb70 100644 --- a/src/commands/schema/abandon.mjs +++ b/src/commands/schema/abandon.mjs @@ -11,21 +11,16 @@ 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/diff.mjs b/src/commands/schema/diff.mjs index 5ddfa73e..5045fe11 100644 --- a/src/commands/schema/diff.mjs +++ b/src/commands/schema/diff.mjs @@ -32,24 +32,22 @@ 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) { params.set("version", version); - } else { - params.set("force", "true"); } return params; 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", }); 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/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) }, ); 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" },