From 5bf12956736e3a9377ec417c69e35b122ce2b567 Mon Sep 17 00:00:00 2001 From: Niranjan Jayakar Date: Tue, 12 Oct 2021 19:39:19 +0530 Subject: [PATCH] chore(assertions): consistent naming in maven (#16921) The maven artifact id is configured to 'cdk-assertions'. This makes the assertions module naming different from the other package managers, and hence harder to discover. Change the artifact id to 'assertions' and make this consistent. BREAKING CHANGE: Starting this release, the `assertions` module will be published to Maven with the name 'assertions' instead of 'cdk-assertions'. --- packages/@aws-cdk/assertions/package.json | 2 +- tools/@aws-cdk/pkglint/lib/rules.ts | 37 ++++++++++++++--------- 2 files changed, 23 insertions(+), 16 deletions(-) diff --git a/packages/@aws-cdk/assertions/package.json b/packages/@aws-cdk/assertions/package.json index 87fb2962b5745..e87d1c9526302 100644 --- a/packages/@aws-cdk/assertions/package.json +++ b/packages/@aws-cdk/assertions/package.json @@ -29,7 +29,7 @@ "package": "software.amazon.awscdk.assertions", "maven": { "groupId": "software.amazon.awscdk", - "artifactId": "cdk-assertions" + "artifactId": "assertions" } }, "dotnet": { diff --git a/tools/@aws-cdk/pkglint/lib/rules.ts b/tools/@aws-cdk/pkglint/lib/rules.ts index 140674492f0cc..f991f7b0a2441 100644 --- a/tools/@aws-cdk/pkglint/lib/rules.ts +++ b/tools/@aws-cdk/pkglint/lib/rules.ts @@ -14,9 +14,8 @@ import { monoRepoRoot, } from './util'; -const AWS_SERVICE_NAMES = require('./aws-service-official-names.json'); // eslint-disable-line @typescript-eslint/no-require-imports - const PKGLINT_VERSION = require('../package.json').version; // eslint-disable-line @typescript-eslint/no-require-imports +const AWS_SERVICE_NAMES = require('./aws-service-official-names.json'); // eslint-disable-line @typescript-eslint/no-require-imports /** * Verify that the package name matches the directory name @@ -831,25 +830,33 @@ function cdkModuleName(name: string) { const isCdkPkg = name === '@aws-cdk/core'; const isLegacyCdkPkg = name === '@aws-cdk/cdk'; - name = name.replace(/^aws-cdk-/, ''); - name = name.replace(/^@aws-cdk\//, ''); + let suffix = name; + suffix = suffix.replace(/^aws-cdk-/, ''); + suffix = suffix.replace(/^@aws-cdk\//, ''); - const dotnetSuffix = name.split('-') + const dotnetSuffix = suffix.split('-') .map(s => s === 'aws' ? 'AWS' : caseUtils.pascal(s)) .join('.'); - const pythonName = name.replace(/^@/g, '').replace(/\//g, '.').split('.').map(caseUtils.kebab).join('.'); + const pythonName = suffix.replace(/^@/g, '').replace(/\//g, '.').split('.').map(caseUtils.kebab).join('.'); + + // list of packages with special-cased Maven ArtifactId. + const mavenIdMap: Record = { + '@aws-cdk/core': 'core', + '@aws-cdk/cdk': 'cdk', + '@aws-cdk/assertions': 'assertions', + '@aws-cdk/assertions-alpha': 'assertions-alpha', + }; + /* eslint-disable @typescript-eslint/indent */ + const mavenArtifactId = + name in mavenIdMap ? mavenIdMap[name] : + (suffix.startsWith('aws-') || suffix.startsWith('alexa-')) ? suffix.replace(/aws-/, '') : + suffix.startsWith('cdk-') ? suffix : `cdk-${suffix}`; + /* eslint-enable @typescript-eslint/indent */ return { - javaPackage: `software.amazon.awscdk${isLegacyCdkPkg ? '' : `.${name.replace(/aws-/, 'services-').replace(/-/g, '.')}`}`, - mavenArtifactId: - isLegacyCdkPkg - ? 'cdk' - : (isCdkPkg - ? 'core' - : (name.startsWith('aws-') || name.startsWith('alexa-') - ? name.replace(/aws-/, '') - : (name.startsWith('cdk-') ? name : `cdk-${name}`))), + javaPackage: `software.amazon.awscdk${isLegacyCdkPkg ? '' : `.${suffix.replace(/aws-/, 'services-').replace(/-/g, '.')}`}`, + mavenArtifactId, dotnetNamespace: `Amazon.CDK${isCdkPkg ? '' : `.${dotnetSuffix}`}`, python: { distName: `aws-cdk.${pythonName}`,