From e80253631c452f3872dca2065d18095ed44f814d Mon Sep 17 00:00:00 2001 From: Hoang Mirs Date: Sun, 2 Jul 2023 08:08:01 +0700 Subject: [PATCH] [#153] Rename applyCommon --- src/templates/addons/aws/index.test.ts | 4 ++-- src/templates/addons/aws/index.ts | 4 ++-- src/templates/addons/aws/modules/alb.test.ts | 4 ++-- src/templates/addons/aws/modules/bastion.test.ts | 4 ++-- src/templates/addons/aws/modules/cloudwatch.test.ts | 4 ++-- src/templates/addons/aws/modules/core/common.test.ts | 4 ++-- src/templates/addons/aws/modules/core/common.ts | 4 ++-- .../addons/aws/modules/core/iamUserAndGroup.test.ts | 4 ++-- src/templates/addons/aws/modules/core/region.test.ts | 4 ++-- .../addons/aws/modules/core/securityGroup.test.ts | 4 ++-- src/templates/addons/aws/modules/core/vpc.test.ts | 4 ++-- src/templates/addons/aws/modules/ecr.test.ts | 4 ++-- src/templates/addons/aws/modules/ecs.test.ts | 4 ++-- src/templates/addons/aws/modules/index.ts | 4 ++-- src/templates/addons/aws/modules/rds.test.ts | 4 ++-- src/templates/addons/aws/modules/s3.test.ts | 4 ++-- src/templates/addons/aws/modules/ssm.test.ts | 4 ++-- src/templates/core/dependencies.test.ts | 12 ++++++------ 18 files changed, 40 insertions(+), 40 deletions(-) diff --git a/src/templates/addons/aws/index.test.ts b/src/templates/addons/aws/index.test.ts index a6c2a8b9..74f392e9 100644 --- a/src/templates/addons/aws/index.test.ts +++ b/src/templates/addons/aws/index.test.ts @@ -6,7 +6,7 @@ import { remove } from '@/helpers/file'; import { generateAwsTemplate } from '.'; import { applyAdvancedTemplate } from './advanced'; import { - applyCommon, + applyTerraformAWS, applyRegion, applySecurityGroup, applyVpc, @@ -48,7 +48,7 @@ describe('AWS template', () => { }); it('applies common add-on', () => { - expect(applyCommon).toHaveBeenCalledWith(awsOptions); + expect(applyTerraformAWS).toHaveBeenCalledWith(awsOptions); }); it('applies region add-on', () => { diff --git a/src/templates/addons/aws/index.ts b/src/templates/addons/aws/index.ts index 07a9f772..acf4af7a 100644 --- a/src/templates/addons/aws/index.ts +++ b/src/templates/addons/aws/index.ts @@ -5,7 +5,7 @@ import { GeneralOptions } from '@/commands/generate'; import { applyAdvancedTemplate } from './advanced'; import { AWS_DEFAULT_REGION } from './constants'; import { - applyCommon, + applyTerraformAWS, applyIamUserAndGroup, applyRegion, applySecurityGroup, @@ -44,7 +44,7 @@ type AwsOptions = GeneralOptions & { }; const applyCommonModules = async (options: AwsOptions) => { - await applyCommon(options); + await applyTerraformAWS(options); await applyRegion(options); }; diff --git a/src/templates/addons/aws/modules/alb.test.ts b/src/templates/addons/aws/modules/alb.test.ts index c8c179f6..4e925dc2 100644 --- a/src/templates/addons/aws/modules/alb.test.ts +++ b/src/templates/addons/aws/modules/alb.test.ts @@ -9,7 +9,7 @@ import applyAlb, { albSGOutputsContent, albVariablesContent, } from './alb'; -import applyCommon from './core/common'; +import applyTerraformAWS from './core/common'; jest.mock('inquirer', () => { return { @@ -29,7 +29,7 @@ describe('ALB add-on', () => { }; await applyTerraformCore(awsOptions); - await applyCommon(awsOptions); + await applyTerraformAWS(awsOptions); await applyAlb(awsOptions); }); diff --git a/src/templates/addons/aws/modules/bastion.test.ts b/src/templates/addons/aws/modules/bastion.test.ts index d9c5f076..92ea4272 100644 --- a/src/templates/addons/aws/modules/bastion.test.ts +++ b/src/templates/addons/aws/modules/bastion.test.ts @@ -8,7 +8,7 @@ import applyBastion, { bastionSGOutputsContent, bastionVariablesContent, } from './bastion'; -import applyCommon from './core/common'; +import applyTerraformAWS from './core/common'; jest.mock('inquirer', () => { return { @@ -28,7 +28,7 @@ describe('Bastion add-on', () => { }; await applyTerraformCore(awsOptions); - await applyCommon(awsOptions); + await applyTerraformAWS(awsOptions); await applyBastion(awsOptions); }); diff --git a/src/templates/addons/aws/modules/cloudwatch.test.ts b/src/templates/addons/aws/modules/cloudwatch.test.ts index b8ef4045..fb838d30 100644 --- a/src/templates/addons/aws/modules/cloudwatch.test.ts +++ b/src/templates/addons/aws/modules/cloudwatch.test.ts @@ -6,7 +6,7 @@ import applyCloudwatch, { cloudwatchModuleContent, cloudwatchVariablesContent, } from './cloudwatch'; -import applyCommon from './core/common'; +import applyTerraformAWS from './core/common'; jest.mock('inquirer', () => { return { @@ -26,7 +26,7 @@ describe('Cloudwatch add-on', () => { }; await applyTerraformCore(awsOptions); - await applyCommon(awsOptions); + await applyTerraformAWS(awsOptions); await applyCloudwatch(awsOptions); }); diff --git a/src/templates/addons/aws/modules/core/common.test.ts b/src/templates/addons/aws/modules/core/common.test.ts index e7959fc1..049e1488 100644 --- a/src/templates/addons/aws/modules/core/common.test.ts +++ b/src/templates/addons/aws/modules/core/common.test.ts @@ -1,7 +1,7 @@ import { remove } from '@/helpers/file'; import { AwsOptions } from '@/templates/addons/aws'; -import applyCommon from './common'; +import applyTerraformAWS from './common'; describe('Common add-on', () => { describe('given valid AwsOptions', () => { @@ -14,7 +14,7 @@ describe('Common add-on', () => { infrastructureType: 'advanced', }; - await applyCommon(awsOptions); + await applyTerraformAWS(awsOptions); }); afterAll(() => { diff --git a/src/templates/addons/aws/modules/core/common.ts b/src/templates/addons/aws/modules/core/common.ts index 968a9986..1f6b562b 100644 --- a/src/templates/addons/aws/modules/core/common.ts +++ b/src/templates/addons/aws/modules/core/common.ts @@ -3,7 +3,7 @@ import { AwsOptions } from '@/templates/addons/aws'; import { AWS_SKELETON_PATH } from '@/templates/addons/aws/constants'; import { INFRA_BASE_PATH, INFRA_SHARED_PATH } from '@/templates/core/constants'; -const applyCommon = async (options: AwsOptions) => { +const applyTerraformAWS = async (options: AwsOptions) => { copy( `${AWS_SKELETON_PATH}/providers.tf`, `${INFRA_BASE_PATH}/providers.tf`, @@ -16,4 +16,4 @@ const applyCommon = async (options: AwsOptions) => { ); }; -export default applyCommon; +export default applyTerraformAWS; diff --git a/src/templates/addons/aws/modules/core/iamUserAndGroup.test.ts b/src/templates/addons/aws/modules/core/iamUserAndGroup.test.ts index ef462c60..1317ffab 100644 --- a/src/templates/addons/aws/modules/core/iamUserAndGroup.test.ts +++ b/src/templates/addons/aws/modules/core/iamUserAndGroup.test.ts @@ -2,7 +2,7 @@ import { remove } from '@/helpers/file'; import { AwsOptions } from '@/templates/addons/aws'; import { applyTerraformCore } from '@/templates/core'; -import applyCommon from './common'; +import applyTerraformAWS from './common'; import applyIamUserAndGroup, { iamVariablesContent, iamGroupsModuleContent, @@ -23,7 +23,7 @@ describe('IAM add-on', () => { }; applyTerraformCore(awsOptions); - applyCommon(awsOptions); + applyTerraformAWS(awsOptions); applyIamUserAndGroup(awsOptions); }); diff --git a/src/templates/addons/aws/modules/core/region.test.ts b/src/templates/addons/aws/modules/core/region.test.ts index afe05e43..59d2e618 100644 --- a/src/templates/addons/aws/modules/core/region.test.ts +++ b/src/templates/addons/aws/modules/core/region.test.ts @@ -2,7 +2,7 @@ import { remove } from '@/helpers/file'; import { AwsOptions } from '@/templates/addons/aws'; import { applyTerraformCore } from '@/templates/core'; -import applyCommon from './common'; +import applyTerraformAWS from './common'; import applyRegion, { regionVariablesContent } from './region'; jest.mock('inquirer', () => { @@ -25,7 +25,7 @@ describe('Region add-on', () => { }; await applyTerraformCore(awsOptions); - await applyCommon(awsOptions); + await applyTerraformAWS(awsOptions); await applyRegion(awsOptions); }); diff --git a/src/templates/addons/aws/modules/core/securityGroup.test.ts b/src/templates/addons/aws/modules/core/securityGroup.test.ts index 637e5a0f..6d67849c 100644 --- a/src/templates/addons/aws/modules/core/securityGroup.test.ts +++ b/src/templates/addons/aws/modules/core/securityGroup.test.ts @@ -2,7 +2,7 @@ import { remove } from '@/helpers/file'; import { AwsOptions } from '@/templates/addons/aws'; import { applyTerraformCore } from '@/templates/core'; -import applyCommon from './common'; +import applyTerraformAWS from './common'; import applySecurityGroup, { securityGroupModuleContent, securityGroupVariablesContent, @@ -26,7 +26,7 @@ describe('Security group add-on', () => { }; await applyTerraformCore(awsOptions); - await applyCommon(awsOptions); + await applyTerraformAWS(awsOptions); await applySecurityGroup(awsOptions); }); diff --git a/src/templates/addons/aws/modules/core/vpc.test.ts b/src/templates/addons/aws/modules/core/vpc.test.ts index 026ff6af..b4dddf87 100644 --- a/src/templates/addons/aws/modules/core/vpc.test.ts +++ b/src/templates/addons/aws/modules/core/vpc.test.ts @@ -2,7 +2,7 @@ import { remove } from '@/helpers/file'; import { AwsOptions } from '@/templates/addons/aws'; import { applyTerraformCore } from '@/templates/core'; -import applyCommon from './common'; +import applyTerraformAWS from './common'; import applyVpc, { vpcModuleContent, vpcOutputsContent } from './vpc'; describe('VPC add-on', () => { @@ -17,7 +17,7 @@ describe('VPC add-on', () => { }; await applyTerraformCore(awsOptions); - await applyCommon(awsOptions); + await applyTerraformAWS(awsOptions); await applyVpc(awsOptions); }); diff --git a/src/templates/addons/aws/modules/ecr.test.ts b/src/templates/addons/aws/modules/ecr.test.ts index da5eb1a2..2a762011 100644 --- a/src/templates/addons/aws/modules/ecr.test.ts +++ b/src/templates/addons/aws/modules/ecr.test.ts @@ -2,7 +2,7 @@ import { remove } from '@/helpers/file'; import { AwsOptions } from '@/templates/addons/aws'; import { applyTerraformCore } from '@/templates/core'; -import applyCommon from './core/common'; +import applyTerraformAWS from './core/common'; import applyEcr, { ecrModuleContent, ecrVariablesContent } from './ecr'; jest.mock('inquirer', () => { @@ -23,7 +23,7 @@ describe('ECR add-on', () => { }; await applyTerraformCore(awsOptions); - await applyCommon(awsOptions); + await applyTerraformAWS(awsOptions); await applyEcr(awsOptions); }); diff --git a/src/templates/addons/aws/modules/ecs.test.ts b/src/templates/addons/aws/modules/ecs.test.ts index b5ebef16..f4022152 100644 --- a/src/templates/addons/aws/modules/ecs.test.ts +++ b/src/templates/addons/aws/modules/ecs.test.ts @@ -2,7 +2,7 @@ import { remove } from '@/helpers/file'; import { AwsOptions } from '@/templates/addons/aws'; import { applyTerraformCore } from '@/templates/core'; -import applyCommon from './core/common'; +import applyTerraformAWS from './core/common'; import applyEcs, { ecsModuleContent, ecsSGMainContent, @@ -28,7 +28,7 @@ describe('ECS add-on', () => { }; await applyTerraformCore(awsOptions); - await applyCommon(awsOptions); + await applyTerraformAWS(awsOptions); await applyEcs(awsOptions); }); diff --git a/src/templates/addons/aws/modules/index.ts b/src/templates/addons/aws/modules/index.ts index 220dfd1f..a8761e76 100644 --- a/src/templates/addons/aws/modules/index.ts +++ b/src/templates/addons/aws/modules/index.ts @@ -1,7 +1,7 @@ import applyAlb from './alb'; import applyBastion from './bastion'; import applyCloudwatch from './cloudwatch'; -import applyCommon from './core/common'; +import applyTerraformAWS from './core/common'; import applyIamUserAndGroup from './core/iamUserAndGroup'; import applyRegion from './core/region'; import applySecurityGroup from './core/securityGroup'; @@ -15,7 +15,7 @@ import applySsm from './ssm'; export { applyAlb, applyBastion, - applyCommon, + applyTerraformAWS, applyCloudwatch, applyEcr, applyEcs, diff --git a/src/templates/addons/aws/modules/rds.test.ts b/src/templates/addons/aws/modules/rds.test.ts index cdbc6781..b58703b1 100644 --- a/src/templates/addons/aws/modules/rds.test.ts +++ b/src/templates/addons/aws/modules/rds.test.ts @@ -2,7 +2,7 @@ import { remove } from '@/helpers/file'; import { AwsOptions } from '@/templates/addons/aws'; import { applyTerraformCore } from '@/templates/core'; -import applyCommon from './core/common'; +import applyTerraformAWS from './core/common'; import applyRds, { rdsModuleContent, rdsSGMainContent, @@ -28,7 +28,7 @@ describe('RDS add-on', () => { }; await applyTerraformCore(awsOptions); - await applyCommon(awsOptions); + await applyTerraformAWS(awsOptions); await applyRds(awsOptions); }); diff --git a/src/templates/addons/aws/modules/s3.test.ts b/src/templates/addons/aws/modules/s3.test.ts index 84885621..51f695de 100644 --- a/src/templates/addons/aws/modules/s3.test.ts +++ b/src/templates/addons/aws/modules/s3.test.ts @@ -2,7 +2,7 @@ import { remove } from '@/helpers/file'; import { AwsOptions } from '@/templates/addons/aws'; import { applyTerraformCore } from '@/templates/core'; -import applyCommon from './core/common'; +import applyTerraformAWS from './core/common'; import applyS3, { s3ModuleContent, s3OutputsContent } from './s3'; jest.mock('inquirer', () => { @@ -23,7 +23,7 @@ describe('S3 add-on', () => { }; await applyTerraformCore(awsOptions); - await applyCommon(awsOptions); + await applyTerraformAWS(awsOptions); await applyS3(awsOptions); }); diff --git a/src/templates/addons/aws/modules/ssm.test.ts b/src/templates/addons/aws/modules/ssm.test.ts index 20cc5f11..c1c52707 100644 --- a/src/templates/addons/aws/modules/ssm.test.ts +++ b/src/templates/addons/aws/modules/ssm.test.ts @@ -2,7 +2,7 @@ import { remove } from '@/helpers/file'; import { AwsOptions } from '@/templates/addons/aws'; import { applyTerraformCore } from '@/templates/core'; -import applyCommon from './core/common'; +import applyTerraformAWS from './core/common'; import applySsm, { ssmModuleContent, ssmVariablesContent } from './ssm'; jest.mock('inquirer', () => { @@ -23,7 +23,7 @@ describe('SSM add-on', () => { }; await applyTerraformCore(awsOptions); - await applyCommon(awsOptions); + await applyTerraformAWS(awsOptions); await applySsm(awsOptions); }); diff --git a/src/templates/core/dependencies.test.ts b/src/templates/core/dependencies.test.ts index 97f1012d..8237b874 100644 --- a/src/templates/core/dependencies.test.ts +++ b/src/templates/core/dependencies.test.ts @@ -2,7 +2,7 @@ import { prompt } from 'inquirer'; import { remove } from '@/helpers/file'; import { AwsOptions } from '@/templates/addons/aws'; -import { applyCommon, applyVpc } from '@/templates/addons/aws/modules'; +import { applyTerraformAWS, applyVpc } from '@/templates/addons/aws/modules'; import { applyTerraformCore } from '.'; import { isAWSModuleAdded, requireAWSModules } from './dependencies'; @@ -70,7 +70,7 @@ describe('Dependencies', () => { }; await applyTerraformCore(options); - await applyCommon(options); + await applyTerraformAWS(options); await applyVpc(options); expect(await requireAWSModules('alb', 'vpc', options)).toBe(true); @@ -88,7 +88,7 @@ describe('Dependencies', () => { }; await applyTerraformCore(options); - await applyCommon(options); + await applyTerraformAWS(options); (prompt as unknown as jest.Mock).mockResolvedValue({ apply: true, @@ -107,7 +107,7 @@ describe('Dependencies', () => { }; await applyTerraformCore(options); - await applyCommon(options); + await applyTerraformAWS(options); (prompt as unknown as jest.Mock).mockResolvedValue({ apply: false, @@ -131,7 +131,7 @@ describe('Dependencies', () => { }; await applyTerraformCore(options); - await applyCommon(options); + await applyTerraformAWS(options); expect( await requireAWSModules('alb', 'vpc', options, { @@ -151,7 +151,7 @@ describe('Dependencies', () => { }; await applyTerraformCore(options); - await applyCommon(options); + await applyTerraformAWS(options); await applyVpc(options); await expect(