Skip to content

Commit

Permalink
fix: broken path on build-override
Browse files Browse the repository at this point in the history
  • Loading branch information
jhockett authored and akshbhu committed Nov 10, 2021
1 parent cf69753 commit 8d09217
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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`);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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();
}
Expand Down

0 comments on commit 8d09217

Please sign in to comment.