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

Update all flags to be hyphen-case in help text #531

Merged
merged 3 commits into from
Dec 16, 2024
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
4 changes: 2 additions & 2 deletions src/cli.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@
.filter((key) => previousWord === key)
.pop();

// TODO: this doesn't handle aliasing, and it needs to

Check warning on line 144 in src/cli.mjs

View workflow job for this annotation

GitHub Actions / lint

Unexpected 'todo' comment: 'TODO: this doesn't handle aliasing, and...'
if (
currentWord === "--profile" ||
currentWordFlag === "profile" ||
Expand Down Expand Up @@ -197,9 +197,9 @@
default: false,
group: "Output:",
},
verboseComponent: {
"verbose-component": {
description:
"Components to emit diagnostic logs for. Takes precedence over the `--verbosity` flag. Pass components as a space-separated list, such as `--verboseComponent fetch error`, or as separate flags, such as `--verboseComponent fetch --verboseComponent error`.",
"Components to emit diagnostic logs for. Takes precedence over the `--verbosity` flag. Pass components as a space-separated list, such as `--verbose-component fetch error`, or as separate flags, such as `--verbose-component fetch --verbose-component error`.",
type: "array",
default: [],
choices: ["fetch", "error", "config", "argv", "creds", "completion"],
Expand Down
4 changes: 2 additions & 2 deletions src/commands/database/list.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ async function doListDatabases(argv) {
function buildListCommand(yargs) {
return yargs
.options({
pageSize: {
"page-size": {
type: "number",
description: "Maximum number of databases to return.",
default: 1000,
Expand All @@ -97,7 +97,7 @@ function buildListCommand(yargs) {
"List all top-level databases and output as JSON.",
],
[
"$0 database list --pageSize 10",
"$0 database list --page-size 10",
"List the first 10 top-level databases.",
],
]);
Expand Down
10 changes: 5 additions & 5 deletions src/commands/local.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -94,18 +94,18 @@ ${chalk.red("Please use choose a different name using --name or align the --type
function buildLocalCommand(yargs) {
return yargs
.options({
containerPort: {
"container-port": {
describe: "The port inside the container Fauna listens on.",
type: "number",
default: 8443,
},
hostPort: {
"host-port": {
describe:
"The port on the host machine mapped to the container's port. This is the port you'll connect to Fauna on.",
type: "number",
default: 8443,
},
hostIp: {
"host-ip": {
describe: `The IP address to bind the container's exposed port on the host.`,
type: "string",
default: "0.0.0.0",
Expand All @@ -116,7 +116,7 @@ function buildLocalCommand(yargs) {
type: "number",
default: 10000,
},
maxAttempts: {
"max-attempts": {
describe:
"The maximum number of health check attempts before declaring the start Fauna continer process as failed.",
type: "number",
Expand Down Expand Up @@ -155,7 +155,7 @@ function buildLocalCommand(yargs) {
})
.check((argv) => {
if (argv.maxAttempts < 1) {
throw new ValidationError("--maxAttempts must be greater than 0.");
throw new ValidationError("--max-attempts must be greater than 0.");
}
if (argv.interval < 0) {
throw new ValidationError(
Expand Down
2 changes: 1 addition & 1 deletion src/lib/auth/DEV-README.md → src/lib/auth/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ If no account key is provided, the CLI will prompt a login via the dashboard whe

### The CLI will look for account keys in this order:

- `--accountKey` flag
- `--account-key` flag
- `FAUNA_ACCOUNT_KEY` environment variable
- `--config` file `accountKey` value
- `~/.fauna/credentials/access_keys`
Expand Down
10 changes: 5 additions & 5 deletions src/lib/command-helpers.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@ import { Format } from "./formatting/colorize.mjs";

const COMMON_OPTIONS = {
// hidden
accountUrl: {
"account-url": {
type: "string",
description: "the Fauna account URL to query",
default: "https://account.fauna.com",
hidden: true,
},
clientId: {
"client-id": {
type: "string",
description: "the client id to use when calling Fauna",
required: false,
hidden: true,
},
clientSecret: {
"client-secret": {
type: "string",
description: "the client secret to use when calling Fauna",
required: false,
Expand Down Expand Up @@ -56,7 +56,7 @@ const COMMON_QUERY_OPTIONS = {
required: false,
group: "API:",
},
accountKey: {
"account-key": {
type: "string",
description:
"Fauna account key used for authentication. Negates the need for a user login. The key is used to generate short-lived database secrets for the CLI. Mutually exclusive with `--user` and `--secret`.",
Expand Down Expand Up @@ -90,7 +90,7 @@ export const QUERY_INFO_CHOICES = [
// used for queries customers can configure
const COMMON_CONFIGURABLE_QUERY_OPTIONS = {
...COMMON_QUERY_OPTIONS,
apiVersion: {
"api-version": {
description: "FQL version to use.",
type: "string",
alias: "v",
Expand Down
4 changes: 2 additions & 2 deletions src/lib/docker-containers.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ async function createContainer({
if (occupied) {
throw new CommandError(
`[StartContainer] The hostPort '${hostPort}' on IP '${hostIp}' is already occupied. \
Please pass a --hostPort other than '${hostPort}'.`,
Please pass a --host-port other than '${hostPort}'.`,
);
}
const dockerContainer = await docker.createContainer({
Expand Down Expand Up @@ -390,7 +390,7 @@ async function waitForHealthCheck({
`[HealthCheck] Max attempts reached. Service at ${url} did not respond.`,
);
throw new CommandError(
`[HealthCheck] Fauna at ${url} is not ready after ${maxAttempts} attempts. Consider increasing --interval or --maxAttempts.`,
`[HealthCheck] Fauna at ${url} is not ready after ${maxAttempts} attempts. Consider increasing --interval or --max-attempts.`,
);
}

Expand Down
3 changes: 2 additions & 1 deletion test/lib/formatting/redact.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,15 @@ describe("redactedStringify", () => {
secret: "hide-me",
mySecret: "hide-this-too",
secret_key: "also-hidden",
"account-key": "also-hidden",
bigSecret: "this-is-a-long-secret",
};
const result = JSON.parse(redactedStringify(obj));

expect(result.normal).to.equal("visible");
expect(result.secret).to.equal("*******");
expect(result.mySecret).to.equal("*********-too");
expect(result.secret_key).to.equal("***********");
expect(result["account-key"]).to.equal("***********");
expect(result.bigSecret).to.equal("this*************cret");
});

Expand Down
22 changes: 11 additions & 11 deletions test/local.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ describe("ensureContainerRunning", () => {
}
});

serverMock.on.withArgs("listening").callsFake((event, callback) => {
serverMock.on.withArgs("listening").callsFake((_event, callback) => {
if (simulateError) {
// Trigger the error callback
const errorCallback = serverMock.once.withArgs("error").args[0]?.[1];
Expand All @@ -81,7 +81,7 @@ describe("ensureContainerRunning", () => {

function setupCreateContainerMocks() {
docker.pull.onCall(0).resolves();
docker.modem.followProgress.callsFake((stream, onFinished) => {
docker.modem.followProgress.callsFake((_stream, onFinished) => {
onFinished();
});
docker.listContainers.onCall(0).resolves([]);
Expand All @@ -100,7 +100,7 @@ describe("ensureContainerRunning", () => {
it("Shows a clear error to the user if something is already running on the desired port.", async () => {
simulateError = true;
docker.pull.onCall(0).resolves();
docker.modem.followProgress.callsFake((stream, onFinished) => {
docker.modem.followProgress.callsFake((_stream, onFinished) => {
onFinished();
});
docker.listContainers.onCall(0).resolves([]);
Expand All @@ -116,7 +116,7 @@ describe("ensureContainerRunning", () => {
// Assertions
expect(written).to.contain(
"[StartContainer] The hostPort '8443' on IP '0.0.0.0' is already occupied. \
Please pass a --hostPort other than '8443'.",
Please pass a --host-port other than '8443'.",
);
expect(written).not.to.contain("fauna local");
expect(written).not.to.contain("An unexpected");
Expand Down Expand Up @@ -282,21 +282,21 @@ https://support.fauna.com/hc/en-us/requests/new`,
fetch.onCall(0).rejects();
fetch.resolves(f({}, 503)); // fail from http
try {
await run("local --no-color --interval 0 --maxAttempts 3", container);
await run("local --no-color --interval 0 --max-attempts 3", container);
} catch (_) {}
const written = stderrStream.getWritten();
expect(written).to.contain("with HTTP status: '503'");
expect(written).to.contain("with error:");
expect(written).to.contain(
"[HealthCheck] Fauna at http://0.0.0.0:8443 is not ready after 3 attempts. Consider increasing --interval or --maxAttempts.",
"[HealthCheck] Fauna at http://0.0.0.0:8443 is not ready after 3 attempts. Consider increasing --interval or --max-attempts.",
);
expect(written).not.to.contain("An unexpected");
expect(written).not.to.contain("fauna local"); // help text
});

it("exits if a container cannot be started", async () => {
docker.pull.onCall(0).resolves();
docker.modem.followProgress.callsFake((stream, onFinished) => {
docker.modem.followProgress.callsFake((_stream, onFinished) => {
onFinished();
});
docker.listContainers.onCall(0).resolves([
Expand Down Expand Up @@ -340,10 +340,10 @@ https://support.fauna.com/hc/en-us/requests/new`,

it("throws an error if maxAttempts is less than 1", async () => {
try {
await run("local --no-color --maxAttempts 0", container);
await run("local --no-color --max-attempts 0", container);
} catch (_) {}
const written = stderrStream.getWritten();
expect(written).to.contain("--maxAttempts must be greater than 0.");
expect(written).to.contain("--max-attempts must be greater than 0.");
expect(written).to.contain("fauna local"); // help text
expect(written).not.to.contain("An unexpected");
});
Expand Down Expand Up @@ -403,7 +403,7 @@ https://support.fauna.com/hc/en-us/requests/new`,
].forEach((test) => {
it(`Ensures a container in state '${test.state}' becomes running and available.`, async () => {
docker.pull.onCall(0).resolves();
docker.modem.followProgress.callsFake((stream, onFinished) => {
docker.modem.followProgress.callsFake((_stream, onFinished) => {
onFinished();
});
docker.listContainers.onCall(0).resolves([
Expand Down Expand Up @@ -463,7 +463,7 @@ https://support.fauna.com/hc/en-us/requests/new`,
it("should throw if container exists with same name but different port", async () => {
const desiredPort = 8443;
docker.pull.onCall(0).resolves();
docker.modem.followProgress.callsFake((stream, onFinished) => {
docker.modem.followProgress.callsFake((_stream, onFinished) => {
onFinished();
});
// Mock existing container with different port
Expand Down
Loading