diff --git a/CHANGELOG.md b/CHANGELOG.md index 4ffa9bd0696..7d9a2a023fe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1 +1,2 @@ - Add a confirmation in `firebase init dataconnect` before asking for app idea description. (#9282) +- [BREAKING] Removed support for '.bolt' rules files. diff --git a/src/config.ts b/src/config.ts index b42c6121d84..d16af954ddd 100644 --- a/src/config.ts +++ b/src/config.ts @@ -16,7 +16,6 @@ import * as utils from "./utils"; import { getValidator, getErrorMessage } from "./firebaseConfigValidate"; import { logger } from "./logger"; import { loadCJSON } from "./loadCJSON"; -const parseBoltRules = require("./parseBoltRules"); export class Config { static DEFAULT_FUNCTIONS_SOURCE = "functions"; @@ -68,7 +67,7 @@ export class Config { } // If a top-level key contains a string path pointing to a suported file - // type (JSON or Bolt), we read the file. + // type (JSON ), we read the file. // // TODO: This is janky and confusing behavior, we should remove it ASAP. Config.MATERIALIZE_TARGETS.forEach((target) => { @@ -166,10 +165,9 @@ export class Config { return loadCJSON(fullPath); /* istanbul ignore-next */ case ".bolt": - if (target === "database") { - this.notes.databaseRules = "bolt"; - } - return parseBoltRules(fullPath); + throw new FirebaseError( + "As of firebase-tools@15.0.0, .bolt rules are no longer supported.", + ); default: throw new FirebaseError( "Parse Error: " + filePath + " is not of a supported config file type", diff --git a/src/deploy/database/prepare.ts b/src/deploy/database/prepare.ts index 7a50bf6070e..2729c582e74 100644 --- a/src/deploy/database/prepare.ts +++ b/src/deploy/database/prepare.ts @@ -2,7 +2,6 @@ import * as clc from "colorette"; import * as path from "path"; import { FirebaseError } from "../../error"; -import { parseBoltRules } from "../../parseBoltRules"; import * as rtdb from "../../rtdb"; import * as utils from "../../utils"; import * as dbRulesConfig from "../../database/rulesConfig"; @@ -34,8 +33,9 @@ export function prepare(context: any, options: DeployOptions): Promise { ruleFiles[file] = options.config.readProjectFile(file); break; case ".bolt": - ruleFiles[file] = parseBoltRules(file); - break; + throw new FirebaseError( + "As of firebase-tools@15.0.0, .bolt rules are no longer supported.", + ); default: throw new FirebaseError("Unexpected rules format " + path.extname(file)); } diff --git a/src/emulator/databaseEmulator.ts b/src/emulator/databaseEmulator.ts index 0f6a65743be..cf3f58f2a5a 100644 --- a/src/emulator/databaseEmulator.ts +++ b/src/emulator/databaseEmulator.ts @@ -10,7 +10,6 @@ import { Constants } from "./constants"; import { EmulatorRegistry } from "./registry"; import { EmulatorLogger } from "./emulatorLogger"; import { FirebaseError } from "../error"; -import { parseBoltRules } from "../parseBoltRules"; import { connectableHostname } from "../utils"; export interface DatabaseEmulatorArgs { @@ -163,11 +162,7 @@ export class DatabaseEmulator implements EmulatorInstance { } private async updateRules(instance: string, rulesPath: string): Promise { - const rulesExt = path.extname(rulesPath); - const content = - rulesExt === ".bolt" - ? parseBoltRules(rulesPath).toString() - : fs.readFileSync(rulesPath, "utf8"); + const content = fs.readFileSync(rulesPath, "utf8"); try { await EmulatorRegistry.client(Emulators.DATABASE).put(`/.settings/rules.json`, content, { diff --git a/src/parseBoltRules.ts b/src/parseBoltRules.ts deleted file mode 100644 index 5ab233034ae..00000000000 --- a/src/parseBoltRules.ts +++ /dev/null @@ -1,30 +0,0 @@ -import * as fs from "fs"; -import * as spawn from "cross-spawn"; -import * as clc from "colorette"; -import * as _ from "lodash"; - -import { FirebaseError } from "./error"; - -export function parseBoltRules(filename: string): string { - const ruleSrc = fs.readFileSync(filename, "utf8"); - - // Use 'npx' to spawn 'firebase-bolt' so that it can be picked up - // from either a global install or from local ./node_modules/ - const result = spawn.sync("npx", ["--no-install", "firebase-bolt"], { - input: ruleSrc, - timeout: 10000, - encoding: "utf-8", - }); - - if (result.error && _.get(result.error, "code") === "ENOENT") { - throw new FirebaseError("Bolt not installed, run " + clc.bold("npm install -g firebase-bolt")); - } else if (result.error) { - throw new FirebaseError("Unexpected error parsing Bolt rules file", { - exit: 2, - }); - } else if (result.status != null && result.status > 0) { - throw new FirebaseError(result.stderr.toString(), { exit: 1 }); - } - - return result.stdout; -}