From 53d4808856c7fee46e5f62b74ca297ae129a4741 Mon Sep 17 00:00:00 2001 From: Niranjan Jayakar Date: Tue, 12 Oct 2021 16:52:59 +0530 Subject: [PATCH 1/2] chore(assertions): consistent naming in maven 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 | 36 +++++++++++++---------- 2 files changed, 22 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..26a6d24a30d01 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,32 @@ 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', + }; + /* 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}`, From 1882e288f8aa5951c0468ed4df7f60bd8a22e7b8 Mon Sep 17 00:00:00 2001 From: Niranjan Jayakar Date: Tue, 12 Oct 2021 18:21:05 +0530 Subject: [PATCH 2/2] add assertions-alpha --- tools/@aws-cdk/pkglint/lib/rules.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/@aws-cdk/pkglint/lib/rules.ts b/tools/@aws-cdk/pkglint/lib/rules.ts index 26a6d24a30d01..f991f7b0a2441 100644 --- a/tools/@aws-cdk/pkglint/lib/rules.ts +++ b/tools/@aws-cdk/pkglint/lib/rules.ts @@ -845,6 +845,7 @@ function cdkModuleName(name: string) { '@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 =