Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(assertions): consistent naming in maven #16921

Merged
merged 2 commits into from
Oct 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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