π₯ Make videos programmatically with React
prettier and eslint tidy up
Matt McGillivray77779eccd28b
diff --git a/packages/gcp/src/api/check-if-service-exists.ts b/packages/gcp/src/api/check-if-service-exists.tsindex 21da73ce51..42ea8d4475 100644--- a/packages/gcp/src/api/check-if-service-exists.ts+++ b/packages/gcp/src/api/check-if-service-exists.ts@@ -1,8 +1,11 @@-import { v2, protos } from '@google-cloud/run';+import type {protos} from '@google-cloud/run';+import {v2} from '@google-cloud/run';+import {CliInternals} from '@remotion/cli';import fs from 'fs';-import { validateGcpRegion } from '../shared/validate-gcp-region';-import { validateServiceName } from '../shared/validate-service-name';-import { validateProjectID } from '../shared/validate-project-id';+import {Log} from '../cli/log';+import {validateGcpRegion} from '../shared/validate-gcp-region';+import {validateProjectID} from '../shared/validate-project-id';+import {validateServiceName} from '../shared/validate-service-name';export type CheckIfServiceExistsInput = {serviceNameToCheck: string;@@ -25,15 +28,15 @@ export const checkIfServiceExists = async (validateServiceName(options.serviceNameToCheck);validateProjectID(options.projectID);- const parent = `projects/${options.projectID}/locations/${options.region}`+ const parent = `projects/${options.projectID}/locations/${options.region}`;- const { ServicesClient } = v2;+ const {ServicesClient} = v2;const sa_data = fs.readFileSync('./sa-key.json', 'utf8');- const sa_json = JSON.parse(sa_data)+ const sa_json = JSON.parse(sa_data);const runClient = new ServicesClient({- credentials: sa_json+ credentials: sa_json,});// Construct requestconst request = {@@ -44,12 +47,25 @@ export const checkIfServiceExists = async (try {const iterable = runClient.listServicesAsync(request);for await (const response of iterable) {- if (response.name === `${parent}/services/${options.serviceNameToCheck}`) {- return response+ if (+ response.name === `${parent}/services/${options.serviceNameToCheck}`+ ) {+ return response;}}- return++ return;} catch (e: any) {- throw e;+ if (e.code === 7) {+ Log.error(+ CliInternals.chalk.red(+ `Issue with ${parent}. The project either doesn't exist, or you don't have access to it.+ `+ )+ );+ throw e;+ } else {+ throw e;+ }}-}+};diff --git a/packages/gcp/src/api/cloud-run-allow-unauthenticated-access.ts b/packages/gcp/src/api/cloud-run-allow-unauthenticated-access.tsindex 510c99a817..f7aa1f449d 100644--- a/packages/gcp/src/api/cloud-run-allow-unauthenticated-access.ts+++ b/packages/gcp/src/api/cloud-run-allow-unauthenticated-access.ts@@ -1,4 +1,4 @@-import { getCloudRunClient } from './helpers/get-cloud-run-client';+import {getCloudRunClient} from './helpers/get-cloud-run-client';/*** @description Allow unauthenticated access to the Cloud Run service.@@ -9,22 +9,18 @@ import { getCloudRunClient } from './helpers/get-cloud-run-client';export const allowUnauthenticatedAccess = async (serviceName: string): Promise<Boolean> => {- const cloudRunClient = getCloudRunClient()- try {- await cloudRunClient.setIamPolicy({- resource: serviceName,- policy: {- bindings: [- {- role: 'roles/run.invoker',- members: ['allUsers']- }- ]- }- });-- return true- } catch (e) {- throw e;- }-}+ const cloudRunClient = getCloudRunClient();+ await cloudRunClient.setIamPolicy({+ resource: serviceName,+ policy: {+ bindings: [+ {+ role: 'roles/run.invoker',+ members: ['allUsers'],+ },+ ],+ },+ });++ return true;+};diff --git a/packages/gcp/src/api/deploy-cloud-run-revision.ts b/packages/gcp/src/api/deploy-cloud-run-revision.tsindex f9c32bab05..b57f6bc6bc 100644--- a/packages/gcp/src/api/deploy-cloud-run-revision.ts+++ b/packages/gcp/src/api/deploy-cloud-run-revision.ts@@ -1,12 +1,12 @@-import { IService } from './helpers/IService';-import { validateGcpRegion } from '../shared/validate-gcp-region';-import { validateProjectID } from '../shared/validate-project-id';-import { validateRemotionVersion } from '../shared/validate-remotion-version';-import { getCloudRunClient } from './helpers/get-cloud-run-client';+import {validateGcpRegion} from '../shared/validate-gcp-region';+import {validateProjectID} from '../shared/validate-project-id';+import {validateRemotionVersion} from '../shared/validate-remotion-version';+import {getCloudRunClient} from './helpers/get-cloud-run-client';+import type {IService} from './helpers/IService';export type DeployCloudRunRevisionInput = {remotionVersion: string;- existingService: IService;+ existingService: IService;projectID: string;region: string;};@@ -29,7 +29,7 @@ export const deployCloudRunRevision = async (// TODO: Add option for CPU and memory limits, and validate- const cloudRunClient = getCloudRunClient()+ const cloudRunClient = getCloudRunClient();// Construct requestconst request = {@@ -37,26 +37,22 @@ export const deployCloudRunRevision = async (name: options.existingService.name,template: {containers: [- {+ {image: `us-docker.pkg.dev/remotion-dev/cloud-run/render:${options.remotionVersion}`,resources: {limits: {cpu: '1',- memory: '4Gi'- }- }- }- ]- }- }+ memory: '4Gi',+ },+ },+ },+ ],+ },+ },};// Run request- try {- const [operation] = await cloudRunClient.updateService(request);- const [response] = await operation.promise();+ const [operation] = await cloudRunClient.updateService(request);+ const [response] = await operation.promise();- return response- } catch (e: any) {- throw e;- }-}+ return response;+};diff --git a/packages/gcp/src/api/deploy-new-cloud-run.ts b/packages/gcp/src/api/deploy-new-cloud-run.tsindex f2ca4c0824..8ce36b318d 100644--- a/packages/gcp/src/api/deploy-new-cloud-run.ts+++ b/packages/gcp/src/api/deploy-new-cloud-run.ts@@ -1,9 +1,9 @@-import { IService } from './helpers/IService';-import { validateGcpRegion } from '../shared/validate-gcp-region';-import { validateServiceName } from '../shared/validate-service-name';-import { validateProjectID } from '../shared/validate-project-id';-import { getCloudRunClient } from './helpers/get-cloud-run-client';-import { validateRemotionVersion } from '../shared/validate-remotion-version';+import {validateGcpRegion} from '../shared/validate-gcp-region';+import {validateProjectID} from '../shared/validate-project-id';+import {validateRemotionVersion} from '../shared/validate-remotion-version';+import {validateServiceName} from '../shared/validate-service-name';+import {getCloudRunClient} from './helpers/get-cloud-run-client';+import type {IService} from './helpers/IService';export type DeployCloudRunInput = {remotionVersion: string;@@ -30,30 +30,29 @@ export const deployNewCloudRun = async (validateProjectID(options.projectID);validateRemotionVersion(options.remotionVersion);- const parent = `projects/${options.projectID}/locations/${options.region}`+ const parent = `projects/${options.projectID}/locations/${options.region}`;- const cloudRunClient = getCloudRunClient()+ const cloudRunClient = getCloudRunClient();// Construct requestconst request = {parent,- service: { // service structure: https://googleapis.dev/nodejs/run/latest/google.cloud.run.v2.IService.html+ service: {+ // service structure: https://googleapis.dev/nodejs/run/latest/google.cloud.run.v2.IService.htmltemplate: {containers: [- { image: `us-docker.pkg.dev/remotion-dev/cloud-run/render:${options.remotionVersion}` }- ]- }+ {+ image: `us-docker.pkg.dev/remotion-dev/cloud-run/render:${options.remotionVersion}`,+ },+ ],+ },},- serviceId: options.serviceName+ serviceId: options.serviceName,};// Run request- try {- const [operation] = await cloudRunClient.createService(request);- const [response] = await operation.promise();+ const [operation] = await cloudRunClient.createService(request);+ const [response] = await operation.promise();- return response- } catch (e: any) {- throw e;- }-}+ return response;+};diff --git a/packages/gcp/src/api/get-buckets.ts b/packages/gcp/src/api/get-buckets.tsindex 43d2fb01e2..82c72c897d 100644--- a/packages/gcp/src/api/get-buckets.ts+++ b/packages/gcp/src/api/get-buckets.ts@@ -1,12 +1,12 @@-import { Bucket } from '@google-cloud/storage';+import type {Bucket} from '@google-cloud/storage';import {REMOTION_BUCKET_PREFIX} from '../shared/constants';-import { getCloudStorageClient } from './helpers/get-cloud-storage-client';+import {getCloudStorageClient} from './helpers/get-cloud-storage-client';export const getRemotionStorageBuckets = async (): Promise<{remotionBuckets: Bucket[];}> => {// List buckets in this project- const cloudStorageClient = getCloudStorageClient()+ const cloudStorageClient = getCloudStorageClient();const [buckets] = await cloudStorageClient.getBuckets();if (!buckets) {return {remotionBuckets: []};@@ -19,5 +19,5 @@ export const getRemotionStorageBuckets = async (): Promise<{const remotionBuckets = buckets.filter((b) =>b.name?.startsWith(REMOTION_BUCKET_PREFIX));- return {remotionBuckets: remotionBuckets};+ return {remotionBuckets};};diff --git a/packages/gcp/src/api/get-compositions-on-gcp.ts b/packages/gcp/src/api/get-compositions-on-gcp.tsindex ff13bc485f..48dd9c0e26 100644--- a/packages/gcp/src/api/get-compositions-on-gcp.ts+++ b/packages/gcp/src/api/get-compositions-on-gcp.ts@@ -1,9 +1,7 @@-import type { TCompMetadata } from 'remotion';-import {- getCompositions-} from '@remotion/renderer';+import {getCompositions} from '@remotion/renderer';+import type {TCompMetadata} from 'remotion';-export type GetCompositionsOnGcpInput = { serveUrl: string;};+export type GetCompositionsOnGcpInput = {serveUrl: string};export type GetCompositionsOnGcpOutput = TCompMetadata[];@@ -14,14 +12,8 @@ export type GetCompositionsOnGcpOutput = TCompMetadata[];* @returns The compositions*/export const getCompositionsOnGcp = async ({- serveUrl+ serveUrl,}: GetCompositionsOnGcpInput): Promise<GetCompositionsOnGcpOutput> => {-- try {- const comps = await getCompositions(serveUrl);- return comps;- }- catch (err) {- throw err;- }+ const comps = await getCompositions(serveUrl);+ return comps;};diff --git a/packages/gcp/src/api/helpers/IService.ts b/packages/gcp/src/api/helpers/IService.tsindex 70e8976b01..5aef6cdeae 100644--- a/packages/gcp/src/api/helpers/IService.ts+++ b/packages/gcp/src/api/helpers/IService.ts@@ -1,3 +1,3 @@-import { protos } from '@google-cloud/run';+import type {protos} from '@google-cloud/run';-export type IService = protos.google.cloud.run.v2.IService\ No newline at end of file+export type IService = protos.google.cloud.run.v2.IService;diff --git a/packages/gcp/src/api/upload-dir.ts b/packages/gcp/src/api/upload-dir.tsindex 0360f7b81b..f715b864d5 100644--- a/packages/gcp/src/api/upload-dir.ts+++ b/packages/gcp/src/api/upload-dir.ts@@ -1,8 +1,8 @@-import type { Dirent } from 'fs';-import { createReadStream, promises as fs } from 'fs';-import { makeStorageKey } from '../shared/make-storage-key';-import { getCloudStorageClient } from './helpers/get-cloud-storage-client';+import type {Dirent} from 'fs';+import {createReadStream, promises as fs} from 'fs';import path from 'path';+import {makeStorageKey} from '../shared/make-storage-key';+import {getCloudStorageClient} from './helpers/get-cloud-storage-client';type FileInfo = {name: string;@@ -41,7 +41,7 @@ export const uploadDir = async ({toUpload: string[];}) => {const files = await getFiles(localDir, localDir, toUpload);- const progresses: { [key: string]: number } = {};+ const progresses: {[key: string]: number} = {};for (const file of files) {progresses[file.name] = 0;}@@ -49,9 +49,9 @@ export const uploadDir = async ({async function getFiles(directory: string,originalDirectory: string,- toUpload: string[]+ filesToUpload: string[]): Promise<FileInfo[]> {- const dirents = await fs.readdir(directory, { withFileTypes: true });+ const dirents = await fs.readdir(directory, {withFileTypes: true});const _files = await Promise.all(dirents.map((dirent): [Dirent, string] => {@@ -64,42 +64,47 @@ export const uploadDir = async ({return true;}- if (!toUpload.includes(relative)) {+ if (!filesToUpload.includes(relative)) {return false;}return true;}).map(async ([dirent, res]) => {- const { size } = await fs.stat(res);+ const {size} = await fs.stat(res);return dirent.isDirectory()- ? getFiles(res, originalDirectory, toUpload)+ ? getFiles(res, originalDirectory, filesToUpload): [- {- name: res,- size,- },- ];+ {+ name: res,+ size,+ },+ ];}));return _files.flat(1);}- const cloudStorageClient = getCloudStorageClient()-- const uploads = files.map(async (file) => {- const path = file.name;- const destination = makeStorageKey( keyPrefix, localDir, path )+ const cloudStorageClient = getCloudStorageClient();++ const uploads = files.map((file) => {+ const filePath = file.name;+ const destination = makeStorageKey(keyPrefix, localDir, filePath);return new Promise((resolve, reject) => {- createReadStream(path)- .pipe(cloudStorageClient.bucket(bucket).file(destination).createWriteStream({public: true}))- .on("error", error => reject(error))- .on('progress', function (p) {- progresses[path] = p.bytesWritten ?? 0;+ createReadStream(filePath)+ .pipe(+ cloudStorageClient+ .bucket(bucket)+ .file(destination)+ .createWriteStream({public: true})+ )+ .on('error', (error) => reject(error))+ .on('progress', (p) => {+ progresses[filePath] = p.bytesWritten ?? 0;})- .on('finish', () => resolve("done"))+ .on('finish', () => resolve('done'));});- })+ });const promise = Promise.all(uploads);diff --git a/packages/gcp/src/cli/commands/cloud-run/deploy.ts b/packages/gcp/src/cli/commands/cloud-run/deploy.tsindex cfb0dd8538..37c8d5f9b1 100644--- a/packages/gcp/src/cli/commands/cloud-run/deploy.ts+++ b/packages/gcp/src/cli/commands/cloud-run/deploy.ts@@ -1,19 +1,19 @@-import { CliInternals } from '@remotion/cli';-import { Log } from '@remotion/cli/dist/log';-import { VERSION } from 'remotion/version';-import { deployNewCloudRun } from '../../../api/deploy-new-cloud-run';-import { deployCloudRunRevision } from '../../../api/deploy-cloud-run-revision';-import { allowUnauthenticatedAccess } from '../../../api/cloud-run-allow-unauthenticated-access';-import { validateServiceName } from '../../../shared/validate-service-name';-import { validateProjectID } from '../../../shared/validate-project-id';-import { validateRemotionVersion } from '../../../shared/validate-remotion-version';-import { validateGcpRegion } from '../../../shared/validate-gcp-region';-import { validateOverwrite } from '../../../shared/validate-overwrite';-import { parsedGcpCli } from '../../args';-import { getGcpRegion } from '../../get-gcp-region';-import { checkIfServiceExists } from '../../../api/check-if-service-exists';-import { confirmCli } from '../../helpers/confirm';-import { quit } from '../../helpers/quit';+import {CliInternals} from '@remotion/cli';+import {Log} from '@remotion/cli/dist/log';+import {VERSION} from 'remotion/version';+import {checkIfServiceExists} from '../../../api/check-if-service-exists';+import {allowUnauthenticatedAccess} from '../../../api/cloud-run-allow-unauthenticated-access';+import {deployCloudRunRevision} from '../../../api/deploy-cloud-run-revision';+import {deployNewCloudRun} from '../../../api/deploy-new-cloud-run';+import {validateGcpRegion} from '../../../shared/validate-gcp-region';+import {validateOverwrite} from '../../../shared/validate-overwrite';+import {validateProjectID} from '../../../shared/validate-project-id';+import {validateRemotionVersion} from '../../../shared/validate-remotion-version';+import {validateServiceName} from '../../../shared/validate-service-name';+import {parsedGcpCli} from '../../args';+import {getGcpRegion} from '../../get-gcp-region';+import {confirmCli} from '../../helpers/confirm';+import {quit} from '../../helpers/quit';export const CLOUD_RUN_DEPLOY_SUBCOMMAND = 'deploy';@@ -47,59 +47,63 @@ Overwrite exsting service = ${overwriteService}const existingService = await checkIfServiceExists({serviceNameToCheck: serviceName,- projectID: projectID,- region: region- })+ projectID,+ region,+ });if (existingService) {- const shouldDeployNewRevision = overwriteService || await confirmCli({ delMessage: `Existing service found in ${projectID} project. Deploy new revision? (Y/n)`, allowForceFlag: true });+ const shouldDeployNewRevision =+ overwriteService ||+ (await confirmCli({+ delMessage: `Existing service found in ${projectID} project. Deploy new revision? (Y/n)`,+ allowForceFlag: true,+ }));if (shouldDeployNewRevision) {- Log.info(- CliInternals.chalk.white('Deploying Cloud Run Revision...')- );- try {- const deployRevisionResult = await deployCloudRunRevision({- remotionVersion,- existingService,- projectID,- region- });- // TODO: should somehow check if the new revision was identical to the previous one, and therefore not actually revised+ Log.info(CliInternals.chalk.white('Deploying Cloud Run Revision...'));+ const deployRevisionResult = await deployCloudRunRevision({+ remotionVersion,+ existingService,+ projectID,+ region,+ });+ // TODO: should somehow check if the new revision was identical to the previous one, and therefore not actually revised- if (!deployRevisionResult.name || !deployRevisionResult.uri) {- throw new Error(`Failed to deploy revision. Invalid response from Cloud Run π ${deployRevisionResult}`);- }- Log.info(- CliInternals.chalk.blueBright(`+ if (!deployRevisionResult.name || !deployRevisionResult.uri) {+ throw new Error(+ `Failed to deploy revision. Invalid response from Cloud Run π ${deployRevisionResult}`+ );+ }++ Log.info(+ CliInternals.chalk.blueBright(+ `Cloud Run Revision Deployed! πService Name = ${deployRevisionResult.name}Cloud Run URL = ${deployRevisionResult.uri}Project = ${projectID}GCP Console URL = https://console.cloud.google.com/run/detail/${region}/${serviceName}/revisions- `.trim())- );+ `.trim()+ )+ );- allowUnauthenticated && await allowUnauthenticatedAccessToService(deployRevisionResult.name)- }- catch (e: any) {- throw e;+ if (allowUnauthenticated) {+ await allowUnauthenticatedAccessToService(deployRevisionResult.name);}} else {- Log.info(CliInternals.chalk.gray('deploy cancelled'))- quit(1) // TODO: Check with Jonny what to pass to quit+ Log.info(CliInternals.chalk.gray('deploy cancelled'));+ quit(1); // TODO: Check with Jonny what to pass to quit}- } else { // if no existing service, deploy new service- Log.info(- CliInternals.chalk.white('\nDeploying Cloud Run Service...')- );+ } else {+ // if no existing service, deploy new service+ Log.info(CliInternals.chalk.white('\nDeploying Cloud Run Service...'));try {const deployResult = await deployNewCloudRun({remotionVersion,serviceName,projectID,region,- overwriteService+ overwriteService,});if (!deployResult.name) {@@ -113,17 +117,20 @@ GCP Console URL = https://console.cloud.google.com/run/detail/${region}/${servic}Log.info(- CliInternals.chalk.blueBright(`+ CliInternals.chalk.blueBright(+ `Cloud Run Deployed! πFull Service Name = ${deployResult.name}Cloud Run URL = ${deployResult.uri}Project = ${projectID}GCP Console URL = https://console.cloud.google.com/run/detail/${region}/${serviceName}/revisions- `.trim())+ `.trim()+ ));- allowUnauthenticated && await allowUnauthenticatedAccessToService(deployResult.name)- // allowUnauthenticated && await allowUnauthenticatedAccess(deployResult.name)+ if (allowUnauthenticated) {+ await allowUnauthenticatedAccessToService(deployResult.name);+ }} catch (e: any) {if (e.code === 6) {Log.error(@@ -135,10 +142,8 @@ GCP Console URL = https://console.cloud.google.com/run/detail/${region}/${servicthrow e;}}-}-if (CliInternals.quietFlagProvided()) {// Log.info(functionName);}@@ -147,14 +152,17 @@ GCP Console URL = https://console.cloud.google.com/run/detail/${region}/${servicasync function allowUnauthenticatedAccessToService(serviceName: string) {try {Log.info(- CliInternals.chalk.white('\nAllowing unauthenticated access to the Cloud Run service...')+ CliInternals.chalk.white(+ '\nAllowing unauthenticated access to the Cloud Run service...'+ ));- await allowUnauthenticatedAccess(serviceName)+ await allowUnauthenticatedAccess(serviceName);Log.info(- CliInternals.chalk.blueBright(`Unauthenticated access granted on ${serviceName}`)+ CliInternals.chalk.blueBright(+ `Unauthenticated access granted on ${serviceName}`+ ));- }- catch (e) {+ } catch (e) {Log.error(CliInternals.chalk.red(`Failed to allow unauthenticated access to the Cloud Run service.`@@ -163,4 +171,3 @@ async function allowUnauthenticatedAccessToService(serviceName: string) {throw e;}}-diff --git a/packages/gcp/src/cli/commands/cloud-run/index.ts b/packages/gcp/src/cli/commands/cloud-run/index.tsindex 30265d1cf1..0813ed1a14 100644--- a/packages/gcp/src/cli/commands/cloud-run/index.ts+++ b/packages/gcp/src/cli/commands/cloud-run/index.ts@@ -1,8 +1,8 @@import {CliInternals} from '@remotion/cli';import {Log} from '@remotion/cli/dist/log';+import {BINARY_NAME} from '../../../shared/constants';import {quit} from '../../helpers/quit';import {cloudRunDeploySubcommand, CLOUD_RUN_DEPLOY_SUBCOMMAND} from './deploy';-import {BINARY_NAME} from '../../../shared/constants';export const CLOUD_RUN_COMMAND = 'cloud-run';diff --git a/packages/gcp/src/cli/index.ts b/packages/gcp/src/cli/index.tsindex d0b58cd271..b073c60a28 100644--- a/packages/gcp/src/cli/index.ts+++ b/packages/gcp/src/cli/index.ts@@ -1,16 +1,16 @@-import {Log} from './log';-import {quit} from './helpers/quit';import {parsedGcpCli} from './args';import {cloudRunCommand, CLOUD_RUN_COMMAND} from './commands/cloud-run';-import {sitesCommand, SITES_COMMAND} from './commands/sites';import {compositionsCommand,COMPOSITIONS_COMMAND,} from './commands/compositions';+import {sitesCommand, SITES_COMMAND} from './commands/sites';import {printHelp} from './help';+import {quit} from './helpers/quit';+import {Log} from './log';const matchCommand = (args: string[], remotionRoot: string) => {- if (parsedGcpCli.help || args.length === 0) {+ if (parsedGcpCli.help || args.length === 0 || args[0] === 'help') {printHelp();quit(0);}@@ -42,9 +42,9 @@ export const executeCommand = async (args: string[], remotionRoot: string) => {await matchCommand(args, remotionRoot);} catch (err) {const error = err as Error;- // catch errors and print a message. Check lambda cli for example+ // catch errors and print a message. Check lambda cli for exampleLog.error(error.stack);quit(1);}-};\ No newline at end of file+};diff --git a/packages/gcp/src/shared/validate-project-id.ts b/packages/gcp/src/shared/validate-project-id.tsindex 925ad3dd6c..61a0b62886 100644--- a/packages/gcp/src/shared/validate-project-id.ts+++ b/packages/gcp/src/shared/validate-project-id.ts@@ -1,35 +1,23 @@-import { exec } from "child_process";-export const validateProjectID = (projectID: unknown) => {- if (typeof projectID === "undefined") {- throw new TypeError(- `The 'project-id' argument must be provided, but is missing.`- );- }-- if (typeof projectID !== "string") {- throw new TypeError(- `The 'project-id' argument must be a string, but is ${JSON.stringify(- projectID- )}`- );- }+ if (typeof projectID === 'undefined') {+ throw new TypeError(+ `The 'project-id' argument must be provided, but is missing.`+ );+ }- // TODO: Complete this with the node API instead of gcloud- exec(`gcloud projects describe ${projectID}`, (error) => {- if (error !== null) {- throw new Error(- `project-id ${projectID} not found in GCP. It either does not exist, or you do not have access to it.`- );- } else {- }- });+ if (typeof projectID !== 'string') {+ throw new TypeError(+ `The 'project-id' argument must be a string, but is ${JSON.stringify(+ projectID+ )}`+ );+ }- if (!projectID.match(/^[a-zA-Z][a-zA-Z0-9-]{0,48}[a-zA-Z0-9]$/g)) {- throw new Error(- "The `project-id` must match the RegExp `/^[a-zA-Z][a-zA-Z0-9-]{0,48}[a-zA-Z0-9]$/g`. This means it may only start with a letter, end with a letter or number, and contain up to 49 lowercase letters, numbers or hyphens. You passed: " +- projectID +- ". Check for invalid characters."- );- }+ if (!projectID.match(/^[a-zA-Z][a-zA-Z0-9-]{0,48}[a-zA-Z0-9]$/g)) {+ throw new Error(+ 'The `project-id` must match the RegExp `/^[a-zA-Z][a-zA-Z0-9-]{0,48}[a-zA-Z0-9]$/g`. This means it may only start with a letter, end with a letter or number, and contain up to 49 lowercase letters, numbers or hyphens. You passed: ' ++ projectID ++ '. Check for invalid characters.'+ );+ }};