Skip to content

Commit

Permalink
chore: notice for aws/aws-cdk#31885
Browse files Browse the repository at this point in the history
  • Loading branch information
rix0rrr committed Oct 24, 2024
1 parent 93c0f81 commit ddee1d4
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 3 deletions.
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

0 comments on commit ddee1d4

Please sign in to comment.