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

Fixes issue where --local flag would cause extensions commands to error out #4584

Merged
merged 4 commits into from
May 24, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
- Fixes issue where `ext:*` commands would error out if the `--local` flag was included. This flag is deprecated because it is now the default behavior (#4577).
- Improves Node.js version warning for standalone Firebase CLI build (#2791).
7 changes: 7 additions & 0 deletions src/commands/ext-configure.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ marked.setOptions({
export default new Command("ext:configure <extensionInstanceId>")
.description("configure an existing extension instance")
.withForce()
.option("--local", "deprecated")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Strongly, strongly consider printing a warning if --local is included. IIRC, you should be able to check options.local.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point - done

.before(requirePermissions, [
"firebaseextensions.instances.update",
"firebaseextensions.instances.get",
Expand All @@ -49,6 +50,12 @@ export default new Command("ext:configure <extensionInstanceId>")
`See https://firebase.google.com/docs/extensions/manifest for more details.`
);
}
if (options.local) {
utils.logLabeledWarning(
logPrefix,
"As of firebase-tools@11.0.0, the `--local` flag is no longer required, as it is the default behavior."
);
}

const config = manifest.loadConfig(options);

Expand Down
7 changes: 7 additions & 0 deletions src/commands/ext-install.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export default new Command("ext:install [extensionName]")
: "") +
"or run with `-i` to see all available extensions."
)
.option("--local", "deprecated")
.withForce()
.before(requirePermissions, ["firebaseextensions.instances.create"])
.before(ensureExtensionsApiEnabled)
Expand Down Expand Up @@ -84,6 +85,12 @@ export default new Command("ext:install [extensionName]")
`Installing with a source url is no longer supported in the CLI. Please use Firebase Console instead.`
);
}
if (options.local) {
utils.logLabeledWarning(
logPrefix,
"As of firebase-tools@11.0.0, the `--local` flag is no longer required, as it is the default behavior."
);
}

// If the user types in a local path (prefixed with ~/, ../, or ./), install from local source.
// Otherwise, treat the input as an extension reference and proceed with reference-based installation.
Expand Down
14 changes: 13 additions & 1 deletion src/commands/ext-uninstall.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,13 @@ import TerminalRenderer = require("marked-terminal");

import { checkMinRequiredVersion } from "../checkMinRequiredVersion";
import { Command } from "../command";
import { ensureExtensionsApiEnabled, diagnoseAndFixProject } from "../extensions/extensionsHelper";
import {
ensureExtensionsApiEnabled,
diagnoseAndFixProject,
logPrefix,
} from "../extensions/extensionsHelper";
import { requirePermissions } from "../requirePermissions";
import { logLabeledWarning } from "../utils";
import * as manifest from "../extensions/manifest";
import { Options } from "../options";

Expand All @@ -15,12 +20,19 @@ marked.setOptions({

export default new Command("ext:uninstall <extensionInstanceId>")
.description("uninstall an extension that is installed in your Firebase project by instance ID")
.option("--local", "deprecated")
.withForce()
.before(requirePermissions, ["firebaseextensions.instances.delete"])
.before(ensureExtensionsApiEnabled)
.before(checkMinRequiredVersion, "extMinVersion")
.before(diagnoseAndFixProject)
.action((instanceId: string, options: Options) => {
if (options.local) {
logLabeledWarning(
logPrefix,
"As of firebase-tools@11.0.0, the `--local` flag is no longer required, as it is the default behavior."
);
}
const config = manifest.loadConfig(options);
manifest.removeFromManifest(instanceId, config);
manifest.showPostDeprecationNotice();
Expand Down
8 changes: 8 additions & 0 deletions src/commands/ext-update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,19 @@ export default new Command("ext:update <extensionInstanceId> [updateSource]")
.before(ensureExtensionsApiEnabled)
.before(checkMinRequiredVersion, "extMinVersion")
.before(diagnoseAndFixProject)
.option("--local", "deprecated")
.withForce()
.action(async (instanceId: string, updateSource: string, options: Options) => {
const projectId = getProjectId(options);
const config = manifest.loadConfig(options);

if (options.local) {
utils.logLabeledWarning(
logPrefix,
"As of firebase-tools@11.0.0, the `--local` flag is no longer required, as it is the default behavior."
);
}

const oldRefOrPath = manifest.getInstanceTarget(instanceId, config);
if (isLocalPath(oldRefOrPath)) {
throw new FirebaseError(
Expand Down