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

Adds *.local to .gitignore and functions ignore for functions setup #7018

Merged
merged 4 commits into from Apr 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
@@ -0,0 +1 @@
- Adds `*.local` to .gitignore and functions ignore for `init functions`. (#7018)
18 changes: 15 additions & 3 deletions src/init/features/functions/index.ts
Expand Up @@ -20,22 +20,22 @@
/**
* Set up a new firebase project for functions.
*/
export async function doSetup(setup: any, config: Config, options: Options): Promise<any> {

Check warning on line 23 in src/init/features/functions/index.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unexpected any. Specify a different type

Check warning on line 23 in src/init/features/functions/index.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unexpected any. Specify a different type
const projectId = setup?.rcfile?.projects?.default;

Check warning on line 24 in src/init/features/functions/index.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe assignment of an `any` value

Check warning on line 24 in src/init/features/functions/index.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe member access .rcfile on an `any` value
if (projectId) {
await requirePermissions({ ...options, project: projectId });

Check warning on line 26 in src/init/features/functions/index.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe assignment of an `any` value
await Promise.all([
ensure(projectId, functionsOrigin(), "unused", true),

Check warning on line 28 in src/init/features/functions/index.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe argument of type `any` assigned to a parameter of type `string`
ensure(projectId, runtimeconfigOrigin(), "unused", true),

Check warning on line 29 in src/init/features/functions/index.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe argument of type `any` assigned to a parameter of type `string`
]);
}
setup.functions = {};

Check warning on line 32 in src/init/features/functions/index.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe member access .functions on an `any` value
// check if functions have been initialized yet
if (!config.src.functions) {
setup.config.functions = [];

Check warning on line 35 in src/init/features/functions/index.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe member access .config on an `any` value
return initNewCodebase(setup, config);
}
setup.config.functions = normalizeAndValidate(setup.config.functions);

Check warning on line 38 in src/init/features/functions/index.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe member access .config on an `any` value
const codebases = setup.config.functions.map((cfg: any) => clc.bold(cfg.codebase));
logger.info(`\nDetected existing codebase(s): ${codebases.join(", ")}\n`);
const choices = [
Expand Down Expand Up @@ -181,13 +181,25 @@
const cbconfig = configForCodebase(setup.config.functions, setup.functions.codebase);
switch (language) {
case "javascript":
cbconfig.ignore = ["node_modules", ".git", "firebase-debug.log", "firebase-debug.*.log"];
cbconfig.ignore = [
"node_modules",
".git",
"firebase-debug.log",
"firebase-debug.*.log",
"*.local",
];
break;
case "typescript":
cbconfig.ignore = ["node_modules", ".git", "firebase-debug.log", "firebase-debug.*.log"];
cbconfig.ignore = [
"node_modules",
".git",
"firebase-debug.log",
"firebase-debug.*.log",
"*.local",
];
break;
case "python":
cbconfig.ignore = ["venv", ".git", "firebase-debug.log", "firebase-debug.*.log"];
cbconfig.ignore = ["venv", ".git", "firebase-debug.log", "firebase-debug.*.log", "*.local"];
break;
}
return require("./" + language).setup(setup, config);
Expand Down
30 changes: 24 additions & 6 deletions src/test/init/features/functions.spec.ts
Expand Up @@ -15,7 +15,7 @@ function createExistingTestSetupAndConfig(): { setup: Setup; config: Config } {
const cbconfig = {
source: TEST_SOURCE_DEFAULT,
codebase: TEST_CODEBASE_DEFAULT,
ignore: ["node_modules", ".git", "firebase-debug.log", "firebase-debug.*.log"],
ignore: ["node_modules", ".git", "firebase-debug.log", "firebase-debug.*.log", "*.local"],
predeploy: ['npm --prefix "$RESOURCE_DIR" run lint'],
};

Expand Down Expand Up @@ -85,7 +85,7 @@ describe("functions", () => {
expect(setup.config.functions[0]).to.deep.equal({
source: TEST_SOURCE_DEFAULT,
codebase: TEST_CODEBASE_DEFAULT,
ignore: ["node_modules", ".git", "firebase-debug.log", "firebase-debug.*.log"],
ignore: ["node_modules", ".git", "firebase-debug.log", "firebase-debug.*.log", "*.local"],
predeploy: ['npm --prefix "$RESOURCE_DIR" run lint'],
});
expect(askWriteProjectFileStub.getCalls().map((call) => call.args[0])).to.deep.equal([
Expand All @@ -112,7 +112,7 @@ describe("functions", () => {
expect(setup.config.functions[0]).to.deep.equal({
source: TEST_SOURCE_DEFAULT,
codebase: TEST_CODEBASE_DEFAULT,
ignore: ["node_modules", ".git", "firebase-debug.log", "firebase-debug.*.log"],
ignore: ["node_modules", ".git", "firebase-debug.log", "firebase-debug.*.log", "*.local"],
predeploy: [
'npm --prefix "$RESOURCE_DIR" run lint',
'npm --prefix "$RESOURCE_DIR" run build',
Expand Down Expand Up @@ -149,13 +149,25 @@ describe("functions", () => {
{
source: TEST_SOURCE_DEFAULT,
codebase: TEST_CODEBASE_DEFAULT,
ignore: ["node_modules", ".git", "firebase-debug.log", "firebase-debug.*.log"],
ignore: [
"node_modules",
".git",
"firebase-debug.log",
"firebase-debug.*.log",
"*.local",
],
predeploy: ['npm --prefix "$RESOURCE_DIR" run lint'],
},
{
source: "testsource2",
codebase: "testcodebase2",
ignore: ["node_modules", ".git", "firebase-debug.log", "firebase-debug.*.log"],
ignore: [
"node_modules",
".git",
"firebase-debug.log",
"firebase-debug.*.log",
"*.local",
],
predeploy: ['npm --prefix "$RESOURCE_DIR" run lint'],
},
]);
Expand Down Expand Up @@ -185,7 +197,13 @@ describe("functions", () => {
{
source: TEST_SOURCE_DEFAULT,
codebase: TEST_CODEBASE_DEFAULT,
ignore: ["node_modules", ".git", "firebase-debug.log", "firebase-debug.*.log"],
ignore: [
"node_modules",
".git",
"firebase-debug.log",
"firebase-debug.*.log",
"*.local",
],
predeploy: ['npm --prefix "$RESOURCE_DIR" run lint'],
},
]);
Expand Down
3 changes: 2 additions & 1 deletion templates/init/functions/javascript/_gitignore
@@ -1 +1,2 @@
node_modules/
node_modules/
*.local
1 change: 1 addition & 0 deletions templates/init/functions/python/_gitignore
@@ -0,0 +1 @@
*.local
1 change: 1 addition & 0 deletions templates/init/functions/typescript/_gitignore
Expand Up @@ -7,3 +7,4 @@ typings/

# Node.js dependency directory
node_modules/
*.local