diff --git a/packages/amplify-category-api/src/provider-utils/awscloudformation/apigw-input-state.ts b/packages/amplify-category-api/src/provider-utils/awscloudformation/apigw-input-state.ts index c155b40cf97..758850e5a87 100644 --- a/packages/amplify-category-api/src/provider-utils/awscloudformation/apigw-input-state.ts +++ b/packages/amplify-category-api/src/provider-utils/awscloudformation/apigw-input-state.ts @@ -129,7 +129,6 @@ export class ApigwInputState { return; } const deprecatedParametersFileName = 'api-params.json'; - console.log('DEBUG', this.projectRootPath, AmplifyCategories.API, this.resourceName); const resourceDirPath = pathManager.getResourceDirectoryPath(this.projectRootPath, AmplifyCategories.API, this.resourceName); const deprecatedParametersFilePath = join(resourceDirPath, deprecatedParametersFileName); let deprecatedParameters: $TSObject; diff --git a/packages/amplify-category-api/src/provider-utils/awscloudformation/service-walkthroughs/apigw-walkthrough.ts b/packages/amplify-category-api/src/provider-utils/awscloudformation/service-walkthroughs/apigw-walkthrough.ts index 38f61d52899..049a09ed4f8 100644 --- a/packages/amplify-category-api/src/provider-utils/awscloudformation/service-walkthroughs/apigw-walkthrough.ts +++ b/packages/amplify-category-api/src/provider-utils/awscloudformation/service-walkthroughs/apigw-walkthrough.ts @@ -463,12 +463,14 @@ async function findDependsOn(paths: $TSObject[]) { function getAuthResourceName(): string { const meta = stateManager.getMeta(); - const authResources = (meta?.auth || []).filter(resource => resource.service === AmplifySupportedService.COGNITO); + const authResources = (Object.entries(meta?.auth) || []).filter( + ([_, resource]: [key: string, resource: $TSObject]) => resource.service === AmplifySupportedService.COGNITO, + ); if (authResources.length === 0) { throw new Error('No auth resource found. Add it using amplify add auth'); } - const authResourceName = authResources[0].resourceName; + const [authResourceName] = authResources[0]; return authResourceName; } diff --git a/packages/amplify-cli-core/src/category-interfaces/category-base-schema-generator.ts b/packages/amplify-cli-core/src/category-interfaces/category-base-schema-generator.ts index 29ee24e6a8b..762774fca9e 100644 --- a/packages/amplify-cli-core/src/category-interfaces/category-base-schema-generator.ts +++ b/packages/amplify-cli-core/src/category-interfaces/category-base-schema-generator.ts @@ -16,6 +16,17 @@ export type TypeDef = { service: string; }; +/** + * Normalize Service Name for use in filepaths + * e.g Convert DynamoDB to dynamoDB , S3 to s3 as filename prefix + * @param svcName + * @returns normalizedSvcName + */ +function normalizeServiceToFilePrefix(serviceName: string): string { + serviceName = serviceName.replace(' ', ''); + return `${serviceName[0].toLowerCase()}${serviceName.slice(1)}`; +} + export class CLIInputSchemaGenerator { // Paths are relative to the package root TYPES_SRC_ROOT = path.join('.', 'src', 'provider-utils', 'awscloudformation', 'service-walkthrough-types'); @@ -36,17 +47,6 @@ export class CLIInputSchemaGenerator { return path.join(this.TYPES_SRC_ROOT, `${normalizedSvcName}-user-input-types.ts`); } - /** - * Normalize Service Name for use in filepaths - * e.g Convert DynamoDB to dynamoDB , S3 to s3 as filename prefix - * @param svcName - * @returns normalizedSvcName - */ - private normalizeServiceToFilePrefix(serviceName: string): string { - serviceName = serviceName.replace(' ', ''); - return `${serviceName[0].toLowerCase()}${serviceName.slice(1)}`; - } - private printWarningSchemaFileExists() { printer.info('The interface version must be bumped after any changes.'); printer.info(`Use the ${this.OVERWRITE_SCHEMA_FLAG} flag to overwrite existing versions`); @@ -77,7 +77,7 @@ export class CLIInputSchemaGenerator { }; for (const typeDef of this.serviceTypeDefs) { - const normalizedServiceName = this.normalizeServiceToFilePrefix(typeDef.service); + const normalizedServiceName = normalizeServiceToFilePrefix(typeDef.service); //get absolute file path to the user-input types for the given service const svcAbsoluteFilePath = this.getSvcFileAbsolutePath(normalizedServiceName); this.printGeneratingSchemaMessage(svcAbsoluteFilePath, typeDef.service); @@ -112,7 +112,7 @@ export class CLIInputSchemaValidator { constructor(service: string, category: string, schemaFileName: string) { this._category = category; - this._service = service; + this._service = normalizeServiceToFilePrefix(service); this._schemaFileName = schemaFileName; this._ajv = new Ajv(); }