How to use the firebase-tools.functions function in firebase-tools

To help you get started, we’ve selected a few firebase-tools examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github firebase / oss-bot / functions / src / scripts / deploy-config.ts View on Github external
async function deployConfig(configFile: string, project: string) {
  console.log(`Deploying ${configFile} to ${project}.`);

  // Read the local JSON file and then wrap it in { runtime: config: { ... } }
  const configFileString = fs.readFileSync(configFile).toString();
  const config = {
    runtime: {
      config: JSON.parse(configFileString)
    }
  };

  // Encode the proposed config into a flat map of dot-separated values
  const newConfig = encoding.flattenConfig(config, encoding.Direction.ENCODE);

  // Get the current runtime config from Firebase as a giant object
  const current = await firebase.functions.config.get("runtime", {
    project: project
  });

  // Decode the config into a flat map of dot-separated values.
  const currentConfig = encoding.flattenConfig(
    {
      runtime: current
    },
    encoding.Direction.NONE
  );

  const keysRemoved: string[] = [];
  const keysAddedOrChanged: string[] = [];

  const newKeys = Object.keys(newConfig);
  const currentKeys = Object.keys(currentConfig);
github firebase / oss-bot / functions / src / scripts / deploy-config.ts View on Github external
const val = newConfig[key];
      args.push(`${key}=${val}`);
    }
  }

  // If no changes, we're done
  if (args.length == 0) {
    console.log("No config changes.");
    return;
  }

  // Log out everything that is changing
  console.log(args);

  // Set the new config
  await firebase.functions.config.set(args, {
    project: project
  });
}
github deltaepsilon / quiver-functions / utilities / environment.utility.js View on Github external
return Promise.all(filteredPaths.map(path => {
          return firebaseTools.functions.config.unset([path], this.firebaseToolsOptions);
        })).then(() => pathsString);
      }