Skip to content

Commit

Permalink
Bugbash fixes (#3644)
Browse files Browse the repository at this point in the history
* Print function names on validation errors, not [Object object]

* Require all necessary APIs

* Remove import eslint module

The import module does not currenty handle package exports.
The author is apparently of the opinion that exports should not
use renaming features. Until this is fixed, all of the v2
API is broken.

See import-js/eslint-plugin-import#1810
for more info.

* Linter fixes
  • Loading branch information
inlined authored Aug 6, 2021
1 parent f2d0dd5 commit a8835e8
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
20 changes: 13 additions & 7 deletions src/deploy/functions/prepare.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,20 @@ export async function prepare(
return;
}

// NOTE: this will eventually be enalbed for everyone once AR is enabled
// for GCFv1
// Note: Some of these are premium APIs that require billing to be enabled.
// We'd eventually have to add special error handling for billing APIs, but
// enableCloudBuild is called above and has this special casing already.
if (wantBackend.cloudFunctions.find((f) => f.platform === "gcfv2")) {
await ensureApiEnabled.ensure(
context.projectId,
"artifactregistry.googleapis.com",
"artifactregistry"
);
const V2_APIS = {
artifactregistry: "artifactregistry.googleapis.com",
cloudrun: "run.googleapis.com",
eventarc: "eventarc.googleapis.com",
pubsub: "pubsub.googleapis.com",
};
const enablements = Object.entries(V2_APIS).map(([tag, api]) => {
return ensureApiEnabled.ensure(context.projectId, api, tag);
});
await Promise.all(enablements);
}

// Prepare the functions directory for upload, and set context.triggers.
Expand Down
4 changes: 2 additions & 2 deletions src/deploy/functions/validate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export function functionIdsAreValid(functions: { id: string; platform: string }[
});
if (invalidV1Ids.length !== 0) {
const msg =
`${invalidV1Ids.join(", ")} function name(s) can only contain letters, ` +
`${invalidV1Ids.map((f) => f.id).join(", ")} function name(s) can only contain letters, ` +
`numbers, hyphens, and not exceed 62 characters in length`;
throw new FirebaseError(msg);
}
Expand All @@ -49,7 +49,7 @@ export function functionIdsAreValid(functions: { id: string; platform: string }[
});
if (invalidV2Ids.length !== 0) {
const msg =
`${invalidV2Ids.join(", ")} v2 function name(s) can only contin lower ` +
`${invalidV2Ids.map((f) => f.id).join(", ")} v2 function name(s) can only contin lower ` +
`case letters, numbers, hyphens, and not exceed 62 characters in length`;
throw new FirebaseError(msg);
}
Expand Down
1 change: 0 additions & 1 deletion templates/init/functions/typescript/_eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ module.exports = {
],
plugins: [
"@typescript-eslint",
"import",
],
rules: {
quotes: ["error", "double"],
Expand Down

0 comments on commit a8835e8

Please sign in to comment.