Skip to content

Commit

Permalink
chore(assertions): consistent naming in maven (aws#16921)
Browse files Browse the repository at this point in the history
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'.
  • Loading branch information
Niranjan Jayakar authored and TikiTDO committed Feb 21, 2022
1 parent 7c683ef commit 5bf1295
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 16 deletions.
2 changes: 1 addition & 1 deletion packages/@aws-cdk/assertions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"package": "software.amazon.awscdk.assertions",
"maven": {
"groupId": "software.amazon.awscdk",
"artifactId": "cdk-assertions"
"artifactId": "assertions"
}
},
"dotnet": {
Expand Down
37 changes: 22 additions & 15 deletions tools/@aws-cdk/pkglint/lib/rules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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<string, 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 =
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}`,
Expand Down

0 comments on commit 5bf1295

Please sign in to comment.