Skip to content

Add ephemeral and emulator dataDir flag/properties for later use. (#8… #8788

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

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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
3 changes: 3 additions & 0 deletions schema/firebase-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -1194,6 +1194,9 @@
},
"type": "object"
},
"dataDir": {
"type": "string"
},
"database": {
"additionalProperties": false,
"properties": {
Expand Down
12 changes: 12 additions & 0 deletions src/command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@

/**
* Sets an alias for a command.
* @param aliases an alternativre name for the command. Users will be able to call the command via this name.

Check warning on line 69 in src/command.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Expected @param names to be "alias". Got "aliases"
* @return the command, for chaining.
*/
alias(alias: string): Command {
Expand All @@ -75,10 +75,10 @@
}

/**
* Sets any options for the command.

Check warning on line 78 in src/command.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Expected only 0 line after block description
*
* @example
* command.option("-d, --debug", "turn on debugging", false)

Check warning on line 81 in src/command.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Expected no lines between tags
*
* @param args the commander-style option definition.
* @return the command, for chaining.
Expand All @@ -90,16 +90,28 @@
}

/**
* Sets up --force flag for the command.

Check warning on line 93 in src/command.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Expected only 0 line after block description
*
* @param message overrides the description for --force for this command
* @returns the command, for chaining

Check warning on line 96 in src/command.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Invalid JSDoc tag (preference). Replace "returns" JSDoc tag with "return"
*/
withForce(message?: string): Command {
this.options.push(["-f, --force", message || "automatically accept all interactive prompts"]);
return this;
}

/**
* Adds the --ephemeral flag to the command.
* @return The command, for chaining.
*/
withEphemeral(): Command {
this.option(
"--ephemeral",
"ignore emulators.dataDir and start with a clean state",
false, // Default value if the flag is not present
);
return this;
}
/**
* Attaches a function to run before the command's action function.
* @param fn the function to run.
Expand All @@ -117,7 +129,7 @@
*
* This text is displayed when:
* - the `--help` flag is passed to the command, or
* - the `help <command>` command is used.

Check warning on line 132 in src/command.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Expected only 0 line after block description
*
* @param t the human-readable help text.
* @return the command, for chaining.
Expand Down Expand Up @@ -154,8 +166,8 @@
cmd.aliases(this.aliases);
}
this.options.forEach((args) => {
const flags = args.shift();

Check warning on line 169 in src/command.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe assignment of an `any` value
cmd.option(flags, ...args);

Check warning on line 170 in src/command.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe spread of an `any` array type

Check warning on line 170 in src/command.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe argument of type `any` assigned to a parameter of type `string`
});

if (this.helpText) {
Expand All @@ -166,7 +178,7 @@
}

// See below about using this private property
this.positionalArgs = cmd._args;

Check warning on line 181 in src/command.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe assignment of an `any` value

// args is an array of all the arguments provided for the command PLUS the
// options object as provided by Commander (on the end).
Expand Down
1 change: 1 addition & 0 deletions src/commands/emulators-exec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export const command = new Command("emulators:exec <script>")
.description(
"start the local Firebase emulators, run a test script, then shut down the emulators",
)
.withEphemeral()
.option(commandUtils.FLAG_ONLY, commandUtils.DESC_ONLY)
.option(commandUtils.FLAG_INSPECT_FUNCTIONS, commandUtils.DESC_INSPECT_FUNCTIONS)
.option(commandUtils.FLAG_IMPORT, commandUtils.DESC_IMPORT)
Expand Down
1 change: 1 addition & 0 deletions src/commands/emulators-start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export const command = new Command("emulators:start")
.before(commandUtils.setExportOnExitOptions)
.before(commandUtils.beforeEmulatorCommand)
.description("start the local Firebase emulators")
.withEphemeral()
.option(commandUtils.FLAG_ONLY, commandUtils.DESC_ONLY)
.option(commandUtils.FLAG_INSPECT_FUNCTIONS, commandUtils.DESC_INSPECT_FUNCTIONS)
.option(commandUtils.FLAG_IMPORT, commandUtils.DESC_IMPORT)
Expand Down
1 change: 1 addition & 0 deletions src/firebaseConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ export type EmulatorsConfig = {
host?: string;
port?: number;
};
dataDir?: string;
};

export type ExtensionsConfig = Record<string, string>;
Expand Down
Loading