Skip to content

Commit b2e8d70

Browse files
author
Daniel Neilson
committed
chore(core): include aws-rfdk in version reporting
1 parent 3cad6a3 commit b2e8d70

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

packages/@aws-cdk/core/lib/private/runtime-info.ts

+3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import { major as nodeMajorVersion } from './node-version';
44

55
// list of NPM scopes included in version reporting e.g. @aws-cdk and @aws-solutions-konstruk
66
const WHITELIST_SCOPES = ['@aws-cdk', '@aws-solutions-konstruk', '@aws-solutions-constructs'];
7+
// list of NPM packages included in version reporting
8+
const WHITELIST_PACKAGES = ['aws-rfdk'];
79

810
/**
911
* Returns a list of loaded modules and their versions.
@@ -26,6 +28,7 @@ export function collectRuntimeInformation(): cxschema.RuntimeInfo {
2628
foundMatch = true;
2729
}
2830
}
31+
foundMatch = foundMatch || WHITELIST_PACKAGES.includes(name);
2932

3033
if (!foundMatch) {
3134
delete libraries[name];

packages/@aws-cdk/core/test/test.runtime-info.ts

+28
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,34 @@ export = {
3232
test.done();
3333
},
3434

35+
'version reporting finds aws-rfdk package'(test: Test) {
36+
const pkgdir = fs.mkdtempSync(path.join(os.tmpdir(), 'runtime-info-rfdk'));
37+
const mockVersion = '1.2.3';
38+
39+
fs.writeFileSync(path.join(pkgdir, 'index.js'), 'module.exports = \'this is foo\';');
40+
fs.writeFileSync(path.join(pkgdir, 'package.json'), JSON.stringify({
41+
name: 'aws-rfdk',
42+
version: mockVersion,
43+
}));
44+
45+
// eslint-disable-next-line @typescript-eslint/no-require-imports, import/no-extraneous-dependencies
46+
require(pkgdir);
47+
48+
const runtimeInfo = collectRuntimeInformation();
49+
50+
// eslint-disable-next-line @typescript-eslint/no-require-imports
51+
const version = require('../package.json').version;
52+
test.deepEqual(runtimeInfo.libraries , {
53+
'@aws-cdk/core': version,
54+
'@aws-cdk/cx-api': version,
55+
'@aws-cdk/cloud-assembly-schema': version,
56+
'@aws-solutions-konstruk/foo': mockVersion, // picks up the module from the other test.
57+
'aws-rfdk': mockVersion,
58+
'jsii-runtime': `node.js/${process.version}`,
59+
});
60+
test.done();
61+
},
62+
3563
'version reporting finds no version with no associated package.json'(test: Test) {
3664
const pkgdir = fs.mkdtempSync(path.join(os.tmpdir(), 'runtime-info-find-npm-package-fixture'));
3765
const mockVersion = '1.2.3';

0 commit comments

Comments
 (0)