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

Added validation for project id and project name #8057

Merged
merged 2 commits into from
Dec 12, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@
- CF3 callables can now be annotate with a genkit action they are serving. (#8039)
- HTTPS functions can now be upgraded to HTTPS Callable functions. (#8039)
- Update default tsconfig to support more modern defaults. (#8039)
- Added validation for project ID and project name during `firebase init` (#2514)
- Update the Firebase Data Connect local toolkit to v1.7.5, which includes a fix for Kotlin codegen that ensures that generated XxxKeys.kt files include the required `@file:UseSerializers(UUIDSerializer::class)` annotation. (#8058)
20 changes: 19 additions & 1 deletion src/management/projects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,30 @@
message:
"Please specify a unique project id " +
`(${clc.yellow("warning")}: cannot be modified afterward) [6-30 characters]:\n`,
validate: (projectId: string) => {
if (projectId.length < 6) {
return "Project ID must be at least 6 characters long";
} else if (projectId.length > 30) {
return "Project ID cannot be longer than 30 characters";
} else {
return true;
}
},
},
{
type: "input",
name: "displayName",
default: "",
default: (answers: any) => answers.projectId,

Check warning on line 49 in src/management/projects.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unexpected any. Specify a different type

Check warning on line 49 in src/management/projects.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe member access .projectId on an `any` value

Check warning on line 49 in src/management/projects.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe return of an `any` typed value
message: "What would you like to call your project? (defaults to your project ID)",
validate: (displayName: string) => {
if (displayName.length < 4) {
return "Project name must be at least 4 characters long";
} else if (displayName.length > 30) {
return "Project name cannot be longer than 30 characters";
} else {
return true;
}
},
},
];

Expand All @@ -53,7 +71,7 @@
apiVersion: "v1",
});

export async function createFirebaseProjectAndLog(

Check warning on line 74 in src/management/projects.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Missing JSDoc comment
projectId: string,
options: { displayName?: string; parentResource?: ProjectParentResource },
): Promise<FirebaseProjectMetadata> {
Expand All @@ -62,7 +80,7 @@
try {
await createCloudProject(projectId, options);
spinner.succeed();
} catch (err: any) {

Check warning on line 83 in src/management/projects.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unexpected any. Specify a different type
spinner.fail();
throw err;
}
Expand All @@ -70,7 +88,7 @@
return addFirebaseToCloudProjectAndLog(projectId);
}

export async function addFirebaseToCloudProjectAndLog(

Check warning on line 91 in src/management/projects.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Missing JSDoc comment
projectId: string,
): Promise<FirebaseProjectMetadata> {
let projectInfo;
Expand All @@ -78,7 +96,7 @@

try {
projectInfo = await addFirebaseToCloudProject(projectId);
} catch (err: any) {

Check warning on line 99 in src/management/projects.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unexpected any. Specify a different type
spinner.fail();
throw err;
}
Expand Down Expand Up @@ -111,9 +129,9 @@
/**
* Get the user's desired project, prompting if necessary.
*/
export async function getOrPromptProject(options: any): Promise<FirebaseProjectMetadata> {

Check warning on line 132 in src/management/projects.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unexpected any. Specify a different type
if (options.project) {

Check warning on line 133 in src/management/projects.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe member access .project on an `any` value
return await getFirebaseProject(options.project);

Check warning on line 134 in src/management/projects.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe argument of type `any` assigned to a parameter of type `string`
}
return selectProjectInteractively();
}
Expand Down
Loading