Skip to content

Commit 4e31a2f

Browse files
authored
chore: Fix snapshot tests (#3426)
1 parent f267e25 commit 4e31a2f

File tree

2 files changed

+92
-18
lines changed

2 files changed

+92
-18
lines changed

build-tools/tasks/docs.js

+11-18
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
22
// SPDX-License-Identifier: Apache-2.0
33
const path = require('path');
4-
const { paramCase } = require('change-case');
54
const { documentComponents, documentTestUtils } = require('@cloudscape-design/documenter');
65
const { writeFile } = require('../utils/files');
76
const { listPublicItems } = require('../utils/files');
@@ -24,32 +23,26 @@ function validatePublicFiles(definitionFiles) {
2423
}
2524

2625
function componentDocs() {
27-
const definitions = documentComponents(require.resolve('../../tsconfig.json'), 'src/*/index.tsx', undefined, {
26+
const definitions = documentComponents({
27+
tsconfigPath: require.resolve('../../tsconfig.json'),
28+
publicFilesGlob: 'src/*/index.tsx',
2829
extraExports: {
2930
FileDropzone: ['useFilesDragging'],
3031
TagEditor: ['getTagsDiff'],
3132
},
3233
});
3334
const outDir = path.join(workspace.apiDocsPath, 'components');
34-
const fileNames = definitions
35-
.filter(definition => {
36-
const fileName = paramCase(definition.name);
37-
if (!publicDirs.includes(fileName)) {
38-
console.warn(`Excluded "${fileName}" from components definitions.`);
39-
return false;
40-
}
41-
return true;
42-
})
43-
.map(definition => {
44-
const fileName = paramCase(definition.name);
45-
writeFile(path.join(outDir, fileName + '.js'), `module.exports = ${JSON.stringify(definition, null, 2)};`);
46-
return fileName;
47-
});
48-
validatePublicFiles(fileNames);
35+
for (const definition of definitions) {
36+
writeFile(
37+
path.join(outDir, definition.dashCaseName + '.js'),
38+
`module.exports = ${JSON.stringify(definition, null, 2)};`
39+
);
40+
}
4941
const indexContent = `module.exports = {
50-
${fileNames.map(name => `${JSON.stringify(name)}:require('./${name}')`).join(',\n')}
42+
${definitions.map(definition => `${JSON.stringify(definition.dashCaseName)}:require('./${definition.dashCaseName}')`).join(',\n')}
5143
}`;
5244
writeFile(path.join(outDir, 'index.js'), indexContent);
45+
validatePublicFiles(definitions.map(def => def.dashCaseName));
5346
}
5447

5548
function testUtilDocs() {

0 commit comments

Comments
 (0)