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

Add stack flag to FaunaCommand #305

Merged
merged 3 commits into from
Oct 13, 2023
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
54 changes: 35 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -516,14 +516,15 @@ Create a database.

USAGE
$ fauna create-database DBNAME [--url <value>] [--timeout <value>]
[--secret <value>] [--endpoint <value>]
[--secret <value>] [--endpoint <value>] [--stack <value>]

ARGUMENTS
DBNAME database name

FLAGS
--endpoint=<value> Connection endpoint, from ~/.fauna-shell
--secret=<value> Secret key. Overrides the `secret` in ~/.fauna-shell
--stack=<value> Stack to use, from a Fauna project
--timeout=<value> Connection timeout in milliseconds
--url=<value> Database URL. Overrides the `url` in ~/.fauna-shell

Expand Down Expand Up @@ -551,7 +552,7 @@ Create a key for the specified database.

USAGE
$ fauna create-key DBNAME [ROLE] [--url <value>] [--timeout <value>]
[--secret <value>] [--endpoint <value>]
[--secret <value>] [--endpoint <value>] [--stack <value>]

ARGUMENTS
DBNAME database name
Expand All @@ -560,6 +561,7 @@ ARGUMENTS
FLAGS
--endpoint=<value> Connection endpoint, from ~/.fauna-shell
--secret=<value> Secret key. Overrides the `secret` in ~/.fauna-shell
--stack=<value> Stack to use, from a Fauna project
--timeout=<value> Connection timeout in milliseconds
--url=<value> Database URL. Overrides the `url` in ~/.fauna-shell

Expand All @@ -584,14 +586,15 @@ Delete a database.

USAGE
$ fauna delete-database DBNAME [--url <value>] [--timeout <value>]
[--secret <value>] [--endpoint <value>]
[--secret <value>] [--endpoint <value>] [--stack <value>]

ARGUMENTS
DBNAME database name

FLAGS
--endpoint=<value> Connection endpoint, from ~/.fauna-shell
--secret=<value> Secret key. Overrides the `secret` in ~/.fauna-shell
--stack=<value> Stack to use, from a Fauna project
--timeout=<value> Connection timeout in milliseconds
--url=<value> Database URL. Overrides the `url` in ~/.fauna-shell

Expand All @@ -616,14 +619,15 @@ Delete a key.

USAGE
$ fauna delete-key KEYNAME [--url <value>] [--timeout <value>]
[--secret <value>] [--endpoint <value>]
[--secret <value>] [--endpoint <value>] [--stack <value>]

ARGUMENTS
KEYNAME key name

FLAGS
--endpoint=<value> Connection endpoint, from ~/.fauna-shell
--secret=<value> Secret key. Overrides the `secret` in ~/.fauna-shell
--stack=<value> Stack to use, from a Fauna project
--timeout=<value> Connection timeout in milliseconds
--url=<value> Database URL. Overrides the `url` in ~/.fauna-shell

Expand Down Expand Up @@ -765,9 +769,9 @@ Evaluate the given query.

USAGE
$ fauna eval [DBNAME] [QUERY] [--url <value>] [--timeout
<value>] [--secret <value>] [--endpoint <value>] [--file <value>] [--stdin]
[--output <value>] [--format json|json-tagged|shell] [--version 4|10]
[--typecheck]
<value>] [--secret <value>] [--endpoint <value>] [--stack <value>] [--file
<value>] [--stdin] [--output <value>] [--format json|json-tagged|shell]
[--version 4|10] [--typecheck]

ARGUMENTS
DBNAME Database name
Expand All @@ -780,6 +784,7 @@ FLAGS
<options: json|json-tagged|shell>
--output=<value> File to write output to
--secret=<value> Secret key. Overrides the `secret` in ~/.fauna-shell
--stack=<value> Stack to use, from a Fauna project
--stdin Read file input from stdin. Writes to stdout by default
--timeout=<value> Connection timeout in milliseconds
--typecheck Enable typechecking
Expand Down Expand Up @@ -855,9 +860,9 @@ Import data to Fauna.

USAGE
$ fauna import --path <value> [--url <value>] [--timeout <value>]
[--secret <value>] [--endpoint <value>] [--db <value>] [--collection
<value>] [--type <value>] [--append] [--allow-short-rows] [--dry-run]
[--treat-empty-csv-cells-as empty|null]
[--secret <value>] [--endpoint <value>] [--stack <value>] [--db <value>]
[--collection <value>] [--type <value>] [--append] [--allow-short-rows]
[--dry-run] [--treat-empty-csv-cells-as empty|null]

FLAGS
--allow-short-rows
Expand Down Expand Up @@ -888,6 +893,9 @@ FLAGS
--secret=<value>
Secret key. Overrides the `secret` in ~/.fauna-shell

--stack=<value>
Stack to use, from a Fauna project

--timeout=<value>
Connection timeout in milliseconds

Expand Down Expand Up @@ -977,11 +985,12 @@ List child databases in the current database.

USAGE
$ fauna list-databases [--url <value>] [--timeout <value>] [--secret
<value>] [--endpoint <value>]
<value>] [--endpoint <value>] [--stack <value>]

FLAGS
--endpoint=<value> Connection endpoint, from ~/.fauna-shell
--secret=<value> Secret key. Overrides the `secret` in ~/.fauna-shell
--stack=<value> Stack to use, from a Fauna project
--timeout=<value> Connection timeout in milliseconds
--url=<value> Database URL. Overrides the `url` in ~/.fauna-shell

Expand All @@ -1006,11 +1015,12 @@ List keys in the current database.

USAGE
$ fauna list-keys [--url <value>] [--timeout <value>] [--secret
<value>] [--endpoint <value>]
<value>] [--endpoint <value>] [--stack <value>]

FLAGS
--endpoint=<value> Connection endpoint, from ~/.fauna-shell
--secret=<value> Secret key. Overrides the `secret` in ~/.fauna-shell
--stack=<value> Stack to use, from a Fauna project
--timeout=<value> Connection timeout in milliseconds
--url=<value> Database URL. Overrides the `url` in ~/.fauna-shell

Expand Down Expand Up @@ -1071,13 +1081,14 @@ Print the diff between local and remote schema.

USAGE
$ fauna schema diff [--url <value>] [--timeout <value>] [--secret
<value>] [--endpoint <value>] [--dir <value>]
<value>] [--endpoint <value>] [--stack <value>] [--dir <value>]

FLAGS
--dir=<value> The directory of .fsl files to push. Defaults to the
directory of `.fauna-project`
--endpoint=<value> Connection endpoint, from ~/.fauna-shell
--secret=<value> Secret key. Overrides the `secret` in ~/.fauna-shell
--stack=<value> Stack to use, from a Fauna project
--timeout=<value> Connection timeout in milliseconds
--url=<value> Database URL. Overrides the `url` in ~/.fauna-shell

Expand Down Expand Up @@ -1111,14 +1122,15 @@ Push the current project's .fsl files to Fauna.

USAGE
$ fauna schema push [--url <value>] [--timeout <value>] [--secret
<value>] [--endpoint <value>] [--dir <value>] [--force]
<value>] [--endpoint <value>] [--stack <value>] [--dir <value>] [--force]

FLAGS
--dir=<value> The directory of .fsl files to push. Defaults to the
directory of `.fauna-project`
--endpoint=<value> Connection endpoint, from ~/.fauna-shell
--force Push the change without a diff or schema version check
--secret=<value> Secret key. Overrides the `secret` in ~/.fauna-shell
--stack=<value> Stack to use, from a Fauna project
--timeout=<value> Connection timeout in milliseconds
--url=<value> Database URL. Overrides the `url` in ~/.fauna-shell

Expand Down Expand Up @@ -1149,7 +1161,7 @@ Pull a database schema's .fsl files into the current project.

USAGE
$ fauna schema pull [--url <value>] [--timeout <value>] [--secret
<value>] [--endpoint <value>] [--dir <value>] [--delete]
<value>] [--endpoint <value>] [--stack <value>] [--dir <value>] [--delete]

FLAGS
--delete Delete .fsl files in the target directory that are not
Expand All @@ -1158,6 +1170,7 @@ FLAGS
directory of `.fauna-project`
--endpoint=<value> Connection endpoint, from ~/.fauna-shell
--secret=<value> Secret key. Overrides the `secret` in ~/.fauna-shell
--stack=<value> Stack to use, from a Fauna project
--timeout=<value> Connection timeout in milliseconds
--url=<value> Database URL. Overrides the `url` in ~/.fauna-shell

Expand All @@ -1177,8 +1190,9 @@ Start an interactive shell.

USAGE
$ fauna shell [DB_PATH] [--url <value>] [--timeout <value>]
[--secret <value>] [--endpoint <value>] [--file <value>] [--stdin] [--output
<value>] [--format json|json-tagged|shell] [--version 4|10] [--typecheck]
[--secret <value>] [--endpoint <value>] [--stack <value>] [--file <value>]
[--stdin] [--output <value>] [--format json|json-tagged|shell] [--version
4|10] [--typecheck]

ARGUMENTS
DB_PATH Database path
Expand All @@ -1190,6 +1204,7 @@ FLAGS
<options: json|json-tagged|shell>
--output=<value> File to write output to
--secret=<value> Secret key. Overrides the `secret` in ~/.fauna-shell
--stack=<value> Stack to use, from a Fauna project
--stdin Read file input from stdin. Writes to stdout by default
--timeout=<value> Connection timeout in milliseconds
--typecheck Enable typechecking
Expand Down Expand Up @@ -1289,8 +1304,8 @@ Upload GraphQL schema.

USAGE
$ fauna upload-graphql-schema GRAPHQLFILEPATH [--url <value>] [--timeout <value>]
[--secret <value>] [--endpoint <value>] [--graphqlHost <value>]
[--graphqlPort <value>] [--mode merge|override|replace]
[--secret <value>] [--endpoint <value>] [--stack <value>] [--graphqlHost
<value>] [--graphqlPort <value>] [--mode merge|override|replace]

ARGUMENTS
GRAPHQLFILEPATH Path to GraphQL schema
Expand All @@ -1302,6 +1317,7 @@ FLAGS
--mode=<option> [default: merge] Upload mode
<options: merge|override|replace>
--secret=<value> Secret key. Overrides the `secret` in ~/.fauna-shell
--stack=<value> Stack to use, from a Fauna project
--timeout=<value> Connection timeout in milliseconds
--url=<value> Database URL. Overrides the `url` in ~/.fauna-shell

Expand Down
3 changes: 3 additions & 0 deletions src/lib/fauna-command.js
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,9 @@ FaunaCommand.flags = {
endpoint: Flags.string({
description: "Connection endpoint, from ~/.fauna-shell",
}),
stack: Flags.string({
description: "Stack to use, from a Fauna project",
}),
};

export default FaunaCommand;
8 changes: 3 additions & 5 deletions src/lib/schema-command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,11 @@ export default abstract class SchemaCommand extends FaunaCommand {
};

async fetchsetup() {
const {
connectionOptions: { url, secret },
} = await this.getClient();
const { connectionOptions } = await this.getClient();

return {
url,
secret,
url: connectionOptions.url,
secret: connectionOptions.secret.buildSecret(),
};
}

Expand Down