Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a way to use different filename for firebase.json #333

Open
timofei-iatsenko opened this issue Jan 16, 2024 · 0 comments
Open

Add a way to use different filename for firebase.json #333

timofei-iatsenko opened this issue Jan 16, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@timofei-iatsenko
Copy link

timofei-iatsenko commented Jan 16, 2024

The use case you're trying to solve

We ha ve a monorepo with multiple firebase projects in it. We have the following layout of monorepo:

.
├── fireabse.project1.json — (firebase configurations for each project in the root)
├── fireabse.project2.json
├── apps (where apps is stored. Firabse functions is also an app)
│  ├── frontendApp1
│  ├── frontendApp2
│  ├── functionsApp1
│  └── functionsApp2
├── libs (— here libs go)
└── projects (here live firebase projects with it's configurations)
  ├── project1
  └── project2
    ├── firestore.rules
    └── rules-testing.spec.ts

The structure of fireabse.project1.json is usually like this:

{
  "firestore": {
    "rules": "projects/project1/firestore.rules",
    "indexes": "projects/project1/firestore.indexes.json"
  },
  "hosting": {
    "public": "dist/apps/frontendApp1",
    "rewrites": [
      {
        "source": "**",
        "destination": "/index.html"
      }
    ]
  },
  "functions": [
    {
      "codebase": "functionsApp1",
      "source": "dist/apps/functionsApp1",
      "predeploy": "nx build functionsApp1",
      "runtime": "nodejs18",
      "ignore": ["*.local"]
    },
     {
      "codebase": "functionsApp2",
      "source": "dist/apps/functionsApp2",
      "predeploy": "nx build functionsApp2",
      "runtime": "nodejs18",
      "ignore": ["*.local"]
    }
  ],
  "emulators": {
  }
}

Note that this file lays in the root, and have different path for src and dist.

We usually un all firebase commands just directly passing firebase.json to it

firebase --config=firebase.project1.json

However this action has a slightly diffrent api than native firebase command and it doesn't allow to pass a path to the config file.
Instead entrypoint should be a subpath with firebase.json in it

Change to the action that would solve that use case

I think it could be usefull if entryPoint property may accept path to the config, so the logic would detect if the file path passed than use this path, if directory is passed, so cd to this directory and look for default firebase.josn in it.

// pseudocode

let configFile;

if (isDir(entryPoint)) {
  changeDir(entryPoint);
  configFile = 'firebase.json'
} else {
   configFile = entryPoint
}

UPD: i've just tried to workaround the isuue by moving firebase.project1.json into projects/project1/firebase.json and changing paths in the file accordingly. That lead to a path like ../../dist/apps/frontendApp1 and fail with Error: ../../dist/apps/frontendApp1 is outside of project directory. So this improvement even more viable.

@timofei-iatsenko timofei-iatsenko added the enhancement New feature or request label Jan 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant