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: notice for https://github.com/aws/aws-cdk/issues/31885 #653

Merged
merged 2 commits into from
Oct 24, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
12 changes: 12 additions & 0 deletions data/notices.json
Original file line number Diff line number Diff line change
Expand Up @@ -679,6 +679,18 @@
}
],
"schemaVersion": "1"
},
{
"title": "(cli): Bootstrap stack outdated",
"issueNumber": 31885,
"overview": "The bootstrap stack in {resolve:ENVIRONMENTS} is outdated. We recommend at least version 21, distributed with CDK CLI 2.149.0 or higher. Please rebootstrap your environment by runing 'cdk bootstrap aws://<ACCOUNT>/<REGION>'",
"components": [
{
"name": "bootstrap",
"version": "<21"
}
],
"schemaVersion": "1"
}
]
}
2 changes: 2 additions & 0 deletions src/construct-info.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
export const SPECIAL_COMPONENTS = ['bootstrap'];

export const CONSTRUCT_INFO = [
'aws-cdk-lib.aws_elasticsearch',
'@aws-cdk/aws-appconfig-alpha',
Expand Down
6 changes: 3 additions & 3 deletions src/notice.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as semver from 'semver';
import { CONSTRUCT_INFO } from './construct-info';
import { CONSTRUCT_INFO, SPECIAL_COMPONENTS } from './construct-info';

const MAX_TITLE_LENGTH = 100;

Expand Down Expand Up @@ -66,12 +66,12 @@ export function validateNotice(notice: Notice): void {
if (!CONSTRUCT_INFO.includes(module)) {
throw new Error(`Invalid fully qualified name of an experimental construct ${component.name}.`);
}
} else if (names.length == 1 && !CONSTRUCT_INFO.includes(names[0])) {
} else if (names.length == 1 && !CONSTRUCT_INFO.includes(names[0]) && !SPECIAL_COMPONENTS.includes(names[0])) {
throw new Error(`Invalid component name ${component.name}.`);
}
}

if (!semver.validRange(notice.schemaVersion)) {
throw new Error(`Schema version ${notice.schemaVersion} is not a valid semver range`);
}
}
}
3 changes: 3 additions & 0 deletions test/schema.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { IncomingMessage } from 'http';
import https from 'https';
import * as path from 'path';
import * as semver from 'semver';
import { SPECIAL_COMPONENTS } from '../src/construct-info';
import { Notice, validateNotice } from '../src/notice';

describe('Notices file is valid', () => {
Expand Down Expand Up @@ -40,6 +41,8 @@ describe('Notices file is valid', () => {
test('v2 version ranges must be bounded at the bottom', () => {
for (const component of notice.components) {
if (component.version === '1.*') { continue; } // Special range that we allow
if (SPECIAL_COMPONENTS.includes(component.name)) { continue; } // Not subject to v1/v2 ranges

if (semver.intersects(component.version, '2', { includePrerelease: true })
&& !semver.subset(component.version, '2', { includePrerelease: true })) {
throw new Error(`${component.version} should have an upper bound in v1 range, or a lower bound in v2 range (version should look like "^2.3.4 <2.5.6")`);
Expand Down