Skip to content

Commit

Permalink
Fixes issue where --local flag would cause extensions commands to err…
Browse files Browse the repository at this point in the history
…or out (#4584)

* fixes issue where --local flag would cause extensions commands to error out

* add warning

* formats
  • Loading branch information
joehan committed May 24, 2022
1 parent 5d2f23f commit 08e3d29
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
@@ -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
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")
.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
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
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
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

0 comments on commit 08e3d29

Please sign in to comment.