Skip to content

Commit fe179cb

Browse files
committed
add prefix/postfix option to code registry
1 parent 6a80121 commit fe179cb

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

packages/@aws-cdk/toolkit-lib/CODE_REGISTRY.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
## Toolkit Code Registry
2+
13
| Code | Description | Level | Data Interface |
2-
|------|-------------| ----- | -------------- |
4+
|------|-------------|-------|----------------|
35
| CDK_TOOLKIT_I1000 | Provides synthesis times. | info | n/a |
46
| CDK_TOOLKIT_I1901 | Provides stack data | result | n/a |
57
| CDK_TOOLKIT_I1902 | Successfully deployed stacks | result | n/a |
Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,23 @@
11
import * as fs from 'fs';
22
import { CODES, CodeInfo } from '../lib/api/io/private/codes';
33

4-
function objectToMarkdownTable(codes: Record<string, CodeInfo>) {
4+
// TODO: prefix / postfix
5+
6+
function codesToMarkdownTable(codes: Record<string, CodeInfo>, mdPrefix?: string, mdPostfix?: string) {
57
let table = '| Code | Description | Level | Data Interface |\n';
6-
table += '|------|-------------| ----- | -------------- |\n';
8+
table += '|------|-------------|-------|----------------|\n';
79

810
Object.entries(codes).forEach(([id, code]) => {
911
table += `| ${id} | ${code.description} | ${code.level} | ${code.interface ?? 'n/a'} |\n`;
1012
});
11-
12-
return table;
13+
14+
const prefix = mdPrefix ? `${mdPrefix}\n\n` : '';
15+
const postfix = mdPostfix ? `\n\n${mdPostfix}\n` : '';
16+
17+
return prefix + table + postfix;
1318
}
1419

15-
fs.writeFileSync('CODE_REGISTRY.md', objectToMarkdownTable(CODES));
20+
fs.writeFileSync('CODE_REGISTRY.md', codesToMarkdownTable(
21+
CODES,
22+
'## Toolkit Code Registry',
23+
));

0 commit comments

Comments
 (0)