firebase-tools 11.19.0 → 11.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
File without changes
@@ -30,7 +30,7 @@ exports.command = new command_1.Command("functions:delete [filters...]")
30
30
  }
31
31
  const context = {
32
32
  projectId: (0, projectUtils_1.needProjectId)(options),
33
- filters: filters.map((f) => ({ idChunks: f.split(".") })),
33
+ filters: filters.map((f) => ({ idChunks: f.split(/[-.]/) })),
34
34
  };
35
35
  const [config, existingBackend] = await Promise.all([
36
36
  functionsConfig.getFirebaseConfig(options),
@@ -2066,7 +2066,7 @@ function generateBlockingFunctionJwt(state, event, url, timeoutMs, user, options
2066
2066
  photo_url: user.photoUrl,
2067
2067
  disabled: user.disabled,
2068
2068
  phone_number: user.phoneNumber,
2069
- custom_claims: user.customAttributes,
2069
+ custom_claims: JSON.parse(user.customAttributes || "{}"),
2070
2070
  },
2071
2071
  sub: user.localId,
2072
2072
  sign_in_method: options.signInMethod,
@@ -35,9 +35,9 @@ const EMULATOR_UPDATE_DETAILS = {
35
35
  ui: experiments.isEnabled("emulatoruisnapshot")
36
36
  ? { version: "SNAPSHOT", expectedSize: -1, expectedChecksum: "" }
37
37
  : {
38
- version: "1.11.1",
39
- expectedSize: 3061713,
40
- expectedChecksum: "a4944414518be206280b495f526f18bf",
38
+ version: "1.11.2",
39
+ expectedSize: 3062873,
40
+ expectedChecksum: "fe7f668437d0e3c3b92677aaaade78bf",
41
41
  },
42
42
  pubsub: {
43
43
  version: "0.7.1",
@@ -1,24 +1,24 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ExtensionsEmulator = void 0;
4
+ const clc = require("colorette");
5
+ const spawn = require("cross-spawn");
4
6
  const fs = require("fs-extra");
5
7
  const os = require("os");
6
8
  const path = require("path");
7
- const clc = require("colorette");
8
9
  const Table = require("cli-table");
9
- const spawn = require("cross-spawn");
10
10
  const planner = require("../deploy/extensions/planner");
11
+ const ensureApiEnabled_1 = require("../ensureApiEnabled");
11
12
  const error_1 = require("../error");
13
+ const optionsHelper_1 = require("../extensions/emulator/optionsHelper");
12
14
  const refs_1 = require("../extensions/refs");
15
+ const shortenUrl_1 = require("../shortenUrl");
16
+ const constants_1 = require("./constants");
13
17
  const download_1 = require("./download");
14
- const optionsHelper_1 = require("../extensions/emulator/optionsHelper");
15
18
  const emulatorLogger_1 = require("./emulatorLogger");
16
- const types_1 = require("./types");
17
19
  const validation_1 = require("./extensions/validation");
18
- const ensureApiEnabled_1 = require("../ensureApiEnabled");
19
- const shortenUrl_1 = require("../shortenUrl");
20
- const constants_1 = require("./constants");
21
20
  const registry_1 = require("./registry");
21
+ const types_1 = require("./types");
22
22
  class ExtensionsEmulator {
23
23
  constructor(args) {
24
24
  this.want = [];
@@ -112,15 +112,20 @@ class ExtensionsEmulator {
112
112
  }
113
113
  installAndBuildSourceCode(sourceCodePath) {
114
114
  this.logger.logLabeled("DEBUG", "Extensions", `Running "npm install" for ${sourceCodePath}`);
115
- const npmInstall = spawn.sync("npm", ["--prefix", `/${sourceCodePath}/functions/`, "install"], {
115
+ const functionsDirectory = path.resolve(sourceCodePath, "functions");
116
+ const npmInstall = spawn.sync("npm", ["install"], {
116
117
  encoding: "utf8",
118
+ cwd: functionsDirectory,
117
119
  });
118
120
  if (npmInstall.error) {
119
121
  throw npmInstall.error;
120
122
  }
121
123
  this.logger.logLabeled("DEBUG", "Extensions", `Finished "npm install" for ${sourceCodePath}`);
122
124
  this.logger.logLabeled("DEBUG", "Extensions", `Running "npm run gcp-build" for ${sourceCodePath}`);
123
- const npmRunGCPBuild = spawn.sync("npm", ["--prefix", `/${sourceCodePath}/functions/`, "run", "gcp-build"], { encoding: "utf8" });
125
+ const npmRunGCPBuild = spawn.sync("npm", ["run", "gcp-build"], {
126
+ encoding: "utf8",
127
+ cwd: functionsDirectory,
128
+ });
124
129
  if (npmRunGCPBuild.error) {
125
130
  throw npmRunGCPBuild.error;
126
131
  }
@@ -381,7 +381,7 @@ class FunctionsEmulator {
381
381
  }
382
382
  }
383
383
  if (this.args.debugPort) {
384
- emulatableBackend.secretEnv = Object.values(toSetup.reduce((acc, curr) => {
384
+ emulatableBackend.secretEnv = Object.values(triggerDefinitions.reduce((acc, curr) => {
385
385
  for (const secret of curr.secretEnvironmentVariables || []) {
386
386
  acc[secret.key] = secret;
387
387
  }
@@ -9,6 +9,9 @@ const types_1 = require("../emulator/types");
9
9
  const constants_1 = require("./constants");
10
10
  const error_1 = require("../error");
11
11
  const registry_1 = require("./registry");
12
+ const child_process_1 = require("child_process");
13
+ const PUBSUB_KILL_COMMAND = "pubsub_pids=$(ps aux | grep '[p]ubsub-emulator' | awk '{print $2}');" +
14
+ " if [ ! -z '$pubsub_pids' ]; then kill -9 $pubsub_pids; fi;";
12
15
  class PubsubEmulator {
13
16
  constructor(args) {
14
17
  this.args = args;
@@ -32,7 +35,16 @@ class PubsubEmulator {
32
35
  return Promise.resolve();
33
36
  }
34
37
  async stop() {
35
- await downloadableEmulators.stop(types_1.Emulators.PUBSUB);
38
+ try {
39
+ await downloadableEmulators.stop(types_1.Emulators.PUBSUB);
40
+ }
41
+ catch (e) {
42
+ this.logger.logLabeled("DEBUG", "pubsub", JSON.stringify(e));
43
+ if (process.platform !== "win32") {
44
+ const buffer = (0, child_process_1.execSync)(PUBSUB_KILL_COMMAND);
45
+ this.logger.logLabeled("DEBUG", "pubsub", "Pubsub kill output: " + JSON.stringify(buffer));
46
+ }
47
+ }
36
48
  }
37
49
  getInfo() {
38
50
  const host = this.args.host || constants_1.Constants.getDefaultHost();
@@ -1,12 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.functionResourceToEmulatedTriggerDefintion = void 0;
4
- const functionsEmulatorShared_1 = require("../../emulator/functionsEmulatorShared");
5
4
  const emulatorLogger_1 = require("../../emulator/emulatorLogger");
5
+ const functionsEmulatorShared_1 = require("../../emulator/functionsEmulatorShared");
6
6
  const types_1 = require("../../emulator/types");
7
+ const error_1 = require("../../error");
7
8
  const types_2 = require("../../extensions/types");
8
9
  const proto = require("../../gcp/proto");
9
- const error_1 = require("../../error");
10
10
  function functionResourceToEmulatedTriggerDefintion(resource) {
11
11
  const resourceType = resource.type;
12
12
  if (resource.type === types_2.FUNCTIONS_RESOURCE_TYPE) {
@@ -29,6 +29,16 @@ function functionResourceToEmulatedTriggerDefintion(resource) {
29
29
  service: (0, functionsEmulatorShared_1.getServiceFromEventType)(properties.eventTrigger.eventType),
30
30
  };
31
31
  }
32
+ else if (properties.scheduleTrigger) {
33
+ const schedule = {
34
+ schedule: properties.scheduleTrigger.schedule,
35
+ };
36
+ etd.schedule = schedule;
37
+ etd.eventTrigger = {
38
+ eventType: "google.pubsub.topic.publish",
39
+ resource: "",
40
+ };
41
+ }
32
42
  else {
33
43
  emulatorLogger_1.EmulatorLogger.forEmulator(types_1.Emulators.FUNCTIONS).log("WARN", `Function '${resource.name} is missing a trigger in extension.yaml. Please add one, as triggers defined in code are ignored.`);
34
44
  }
@@ -2,9 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.connect = exports.start = exports.stop = void 0;
4
4
  const morgan = require("morgan");
5
- const { server: superstatic } = require("superstatic");
6
- const clc = require("colorette");
7
5
  const net_1 = require("net");
6
+ const superstatic_1 = require("superstatic");
7
+ const clc = require("colorette");
8
8
  const detectProjectRoot_1 = require("../detectProjectRoot");
9
9
  const error_1 = require("../error");
10
10
  const implicitInit_1 = require("../hosting/implicitInit");
@@ -36,13 +36,13 @@ function startServer(options, config, port, init) {
36
36
  const after = options.frameworksDevModeHandle && {
37
37
  files: options.frameworksDevModeHandle,
38
38
  };
39
- const server = superstatic({
39
+ const server = (0, superstatic_1.server)({
40
40
  debug: false,
41
41
  port: port,
42
- host: options.host,
42
+ hostname: options.host,
43
43
  config: config,
44
44
  compression: true,
45
- cwd: (0, detectProjectRoot_1.detectProjectRoot)(options),
45
+ cwd: (0, detectProjectRoot_1.detectProjectRoot)(options) || undefined,
46
46
  stack: "strict",
47
47
  before: {
48
48
  files: (req, res, next) => {