Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 62 additions & 0 deletions skills/firebase-functions-params-data-migration/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
---
name: firebase-functions-params-data-migration
description: Migrate data from functions.config() to Firebase Functions Params (.env files and Cloud Secret Manager)
version: 0.0.1
---

# Firebase Functions Params Data Migration

## Context
The user wants to move their configuration data from the deprecated `functions.config()` (Runtime Config) to the modern `firebase-functions/params` storage mechanisms (e.g., `.env` files, Cloud Secret Manager).
This skill should be run after `firebase-functions-params-refactor` or whenever someone says they want to move their data from `functions.config()` to params.

## Triggers
Activate this skill when:
1. The user asks to "move data from config", "migrate functions config values", or "setup .env files for params".
2. Offered as a completion step to `firebase-functions-params-refactor`.

## Prerequisites
- All `functions.config()` calls must be removed from the codebase.
- If this is not done, suggest running `firebase-functions-params-refactor` first to rewrite their code to use params.

## Steps

### 1. Extract Existing Configuration
Print out all of the current `functions.config()` storage with:
```bash
firebase functions:config:get --project [projectId]
```

Review the JSON output and map the keys to the new functions params defined in the codebase.

### 2. Secret Mapping
For any config value that maps to a `defineSecret()` param:

1. Check to see whether the secret exists with the same value by accessing it:
```bash
firebase functions:secrets:access [SECRET_NAME]
```
2. If the secret does not exist, set the secret environment variable:
```bash
firebase functions:secrets:set [SECRET_NAME]
```
3. If it exists with the same value, continue.
4. If it exists with a different value, prompt the user how to continue.

### 3. Determine Config Scope
Figure out whether the customer wants project-specific or global configs.
Customers can specify that some config is global and some is project-specific.

### 4. Populate Environment Files
Based on the scope determined in Step 3:

- For any **global** config, put the value in a `.env` file.
- For any **project-specific** config, put it in `.env.[projectId]`.

### 5. Emulator Support (Local Config)
If the Firebase Emulator Suite is installed, help the user set up local configuration.

1. Ask the user what values they want for either secrets or project-specific config in the local environment.
2. **Non-secret values** should be placed in `.env.local`. These can be checked into source control.
3. Any **sensitive/secret values** should be placed in `.secrets.local`.
4. **IMPORTANT**: Ensure that `.secrets.local` is added to `.gitignore`.
Comment on lines +60 to +62
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The .env.local file is intended for local environment overrides and should not be committed to version control. Additionally, Firebase does not natively recognize a .secrets.local file; local secrets for the emulator should also be placed in .env.local, which must be ignored via .gitignore.

Suggested change
2. **Non-secret values** should be placed in `.env.local`. These can be checked into source control.
3. Any **sensitive/secret values** should be placed in `.secrets.local`.
4. **IMPORTANT**: Ensure that `.secrets.local` is added to `.gitignore`.
2. Local values (both secret and non-secret) should be placed in .env.local.
3. IMPORTANT: Ensure that .env.local is added to .gitignore.

2 changes: 1 addition & 1 deletion skills/firebase-functions-params-refactor/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Activate this skill when:
2. You detect `functions.config()` usage in the code snippet.

# Follow up
This skill refactors the code but does not move data from Remote Config to .env files and Cloud Secret Manager. That skill is firebase-functions-params-migration and should be run after this skill. This is a separate skill so it can be run across multiple
This skill refactors the code but does not move data from functions.config() to .env files and Cloud Secret Manager. That skill is firebase-functions-params-data-migration and should be run after this skill. This is a separate skill so it can be run across multiple
projects.

## Rules & Constraints
Expand Down