@ankhorage/paradox 0.0.2 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/README.md +9 -0
- package/dist/analyze/analyze.d.ts +8 -0
- package/dist/analyze/analyze.js +34 -0
- package/dist/analyze/components.d.ts +5 -0
- package/dist/analyze/components.js +21 -0
- package/dist/analyze/exports.d.ts +16 -0
- package/dist/analyze/exports.js +52 -0
- package/dist/analyze/project.d.ts +5 -0
- package/dist/analyze/project.js +10 -0
- package/dist/analyze/types.d.ts +45 -0
- package/dist/analyze/types.js +1 -0
- package/dist/analyze/usage.d.ts +7 -0
- package/dist/analyze/usage.js +40 -0
- package/dist/analyze/utils/getComponentPropsType.d.ts +5 -0
- package/dist/analyze/utils/getComponentPropsType.js +21 -0
- package/dist/analyze/utils/getParadoxComment.d.ts +5 -0
- package/dist/analyze/utils/getParadoxComment.js +19 -0
- package/dist/analyze/utils/getPropsFromType.d.ts +6 -0
- package/dist/analyze/utils/getPropsFromType.js +19 -0
- package/dist/analyze/utils/isReactComponent.d.ts +5 -0
- package/dist/analyze/utils/isReactComponent.js +30 -0
- package/dist/analyze/utils/parseParadoxComment.d.ts +12 -0
- package/dist/analyze/utils/parseParadoxComment.js +25 -0
- package/{src/analyze/utils/resolveExportSymbol.ts → dist/analyze/utils/resolveExportSymbol.d.ts} +1 -4
- package/dist/analyze/utils/resolveExportSymbol.js +6 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +26 -0
- package/{src/config/defineParadoxConfig.ts → dist/config/defineParadoxConfig.d.ts} +1 -4
- package/dist/config/defineParadoxConfig.js +6 -0
- package/dist/config/types.d.ts +19 -0
- package/dist/config/types.js +1 -0
- package/dist/index.js +1 -0
- package/dist/model/buildModel.d.ts +36 -0
- package/dist/model/buildModel.js +65 -0
- package/dist/model/types.d.ts +42 -0
- package/dist/model/types.js +1 -0
- package/dist/paths/policy.d.ts +23 -0
- package/dist/paths/policy.js +105 -0
- package/dist/render/render.d.ts +6 -0
- package/dist/render/render.js +95 -0
- package/dist/render/types.d.ts +10 -0
- package/dist/render/types.js +1 -0
- package/dist/write/write.d.ts +9 -0
- package/dist/write/write.js +18 -0
- package/package.json +27 -3
- package/.changeset/README.md +0 -5
- package/.changeset/config.json +0 -11
- package/.changeset/stable-usage-model.md +0 -5
- package/.github/workflows/docs.yml +0 -45
- package/.prettierignore +0 -1
- package/.prettierrc.js +0 -5
- package/bun.lock +0 -663
- package/eslint.config.mjs +0 -12
- package/knip.json +0 -8
- package/paradox/components.md +0 -1
- package/paradox/exports.json +0 -12
- package/paradox/exports.md +0 -13
- package/paradox/paradox.json +0 -32
- package/paradox.config.ts +0 -18
- package/src/analyze/analyze.ts +0 -45
- package/src/analyze/components.ts +0 -27
- package/src/analyze/exports.ts +0 -87
- package/src/analyze/project.ts +0 -11
- package/src/analyze/types.ts +0 -53
- package/src/analyze/usage.ts +0 -53
- package/src/analyze/utils/getComponentPropsType.ts +0 -26
- package/src/analyze/utils/getParadoxComment.ts +0 -24
- package/src/analyze/utils/getPropsFromType.ts +0 -24
- package/src/analyze/utils/isReactComponent.ts +0 -35
- package/src/analyze/utils/parseParadoxComment.ts +0 -37
- package/src/cli.ts +0 -30
- package/src/config/types.ts +0 -22
- package/src/model/buildModel.ts +0 -112
- package/src/model/types.ts +0 -49
- package/src/render/render.ts +0 -115
- package/src/render/types.ts +0 -10
- package/src/write/write.ts +0 -25
- package/tests/__snapshots__/basic.components.md +0 -10
- package/tests/__snapshots__/basic.exports.md +0 -19
- package/tests/__snapshots__/basic.readme.md +0 -37
- package/tests/__snapshots__/multi-bin.readme.md +0 -16
- package/tests/analyze.test.ts +0 -153
- package/tests/fixtures/basic/package.json +0 -8
- package/tests/fixtures/basic/src/config.ts +0 -8
- package/tests/fixtures/basic/src/index.ts +0 -3
- package/tests/fixtures/basic/src/internal.ts +0 -6
- package/tests/fixtures/basic/src/ui.ts +0 -29
- package/tests/fixtures/basic/tsconfig.json +0 -11
- package/tests/fixtures/multi-bin/package.json +0 -9
- package/tests/fixtures/multi-bin/src/alpha.ts +0 -1
- package/tests/fixtures/multi-bin/src/beta.ts +0 -1
- package/tests/fixtures/multi-bin/src/index.ts +0 -4
- package/tests/fixtures/multi-bin/tsconfig.json +0 -11
- package/tsconfig.eslint.json +0 -16
- package/tsconfig.json +0 -14
- /package/{src/index.ts → dist/index.d.ts} +0 -0
package/src/model/buildModel.ts
DELETED
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
import type { ComponentModel, DocumentationModel, ExportKind, ExportModel } from './types.js';
|
|
2
|
-
|
|
3
|
-
interface BuildModelInput {
|
|
4
|
-
packageName: string;
|
|
5
|
-
packageId: string;
|
|
6
|
-
description: string | null;
|
|
7
|
-
exports: {
|
|
8
|
-
name: string;
|
|
9
|
-
description: string | null;
|
|
10
|
-
kind: ExportKind;
|
|
11
|
-
}[];
|
|
12
|
-
components: {
|
|
13
|
-
name: string;
|
|
14
|
-
description: string | null;
|
|
15
|
-
props: {
|
|
16
|
-
name: string;
|
|
17
|
-
type: string;
|
|
18
|
-
required: boolean;
|
|
19
|
-
description: string | null;
|
|
20
|
-
}[];
|
|
21
|
-
}[];
|
|
22
|
-
usage: {
|
|
23
|
-
packageName: string;
|
|
24
|
-
commands: {
|
|
25
|
-
name: string;
|
|
26
|
-
command: string;
|
|
27
|
-
}[];
|
|
28
|
-
} | null;
|
|
29
|
-
config: {
|
|
30
|
-
exportName: string;
|
|
31
|
-
} | null;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
/***
|
|
35
|
-
* Converts analysis output into a serializable documentation model.
|
|
36
|
-
*/
|
|
37
|
-
export function buildModel(analysis: BuildModelInput): DocumentationModel {
|
|
38
|
-
const exportsByName = new Map(analysis.exports.map((item) => [item.name, mapExport(item)]));
|
|
39
|
-
const exports = sortByName([...exportsByName.values()]);
|
|
40
|
-
|
|
41
|
-
return {
|
|
42
|
-
packageName: analysis.packageName,
|
|
43
|
-
packageId: analysis.packageId,
|
|
44
|
-
description: analysis.description,
|
|
45
|
-
usage:
|
|
46
|
-
analysis.usage !== null
|
|
47
|
-
? {
|
|
48
|
-
packageName: analysis.usage.packageName,
|
|
49
|
-
commands: sortByName(
|
|
50
|
-
analysis.usage.commands.map((command) => ({
|
|
51
|
-
name: command.name,
|
|
52
|
-
command: command.command,
|
|
53
|
-
})),
|
|
54
|
-
),
|
|
55
|
-
}
|
|
56
|
-
: null,
|
|
57
|
-
config:
|
|
58
|
-
analysis.config !== null
|
|
59
|
-
? {
|
|
60
|
-
exportName: analysis.config.exportName,
|
|
61
|
-
configFile: getDefaultConfigFileName(analysis.packageId),
|
|
62
|
-
factoryName: findConfigFactoryName(analysis.config.exportName, [
|
|
63
|
-
...exportsByName.keys(),
|
|
64
|
-
]),
|
|
65
|
-
}
|
|
66
|
-
: null,
|
|
67
|
-
exports,
|
|
68
|
-
components: sortByName(analysis.components.map(mapComponent)),
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
function mapExport(item: BuildModelInput['exports'][number]): ExportModel {
|
|
73
|
-
return {
|
|
74
|
-
name: item.name,
|
|
75
|
-
description: item.description,
|
|
76
|
-
kind: item.kind,
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
function mapComponent(component: BuildModelInput['components'][number]): ComponentModel {
|
|
81
|
-
return {
|
|
82
|
-
name: component.name,
|
|
83
|
-
description: component.description,
|
|
84
|
-
props: sortByName(
|
|
85
|
-
component.props.map((prop) => ({
|
|
86
|
-
name: prop.name,
|
|
87
|
-
type: prop.type,
|
|
88
|
-
required: prop.required,
|
|
89
|
-
description: prop.description,
|
|
90
|
-
})),
|
|
91
|
-
),
|
|
92
|
-
};
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
function findConfigFactoryName(configExportName: string, exportNames: string[]): string | null {
|
|
96
|
-
const prefix = configExportName.endsWith('Config')
|
|
97
|
-
? configExportName.slice(0, -'Config'.length)
|
|
98
|
-
: configExportName;
|
|
99
|
-
const expectedFactoryName = `define${prefix}Config`;
|
|
100
|
-
|
|
101
|
-
return exportNames.includes(expectedFactoryName) ? expectedFactoryName : null;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
function getDefaultConfigFileName(packageId: string): string {
|
|
105
|
-
const packageBaseName = packageId.split('/').pop() ?? packageId;
|
|
106
|
-
|
|
107
|
-
return `${packageBaseName}.config.ts`;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
function sortByName<T extends { name: string }>(items: readonly T[]): T[] {
|
|
111
|
-
return [...items].sort((a, b) => a.name.localeCompare(b.name));
|
|
112
|
-
}
|
package/src/model/types.ts
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
/***
|
|
2
|
-
* Serializable model consumed by renderers and writers.
|
|
3
|
-
*/
|
|
4
|
-
export interface DocumentationModel {
|
|
5
|
-
packageName: string;
|
|
6
|
-
packageId: string;
|
|
7
|
-
description: string | null;
|
|
8
|
-
usage: UsageModel | null;
|
|
9
|
-
config: ConfigModel | null;
|
|
10
|
-
exports: ExportModel[];
|
|
11
|
-
components: ComponentModel[];
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export interface UsageModel {
|
|
15
|
-
packageName: string;
|
|
16
|
-
commands: UsageCommandModel[];
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export interface UsageCommandModel {
|
|
20
|
-
name: string;
|
|
21
|
-
command: string;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export interface ConfigModel {
|
|
25
|
-
exportName: string;
|
|
26
|
-
configFile: string;
|
|
27
|
-
factoryName: string | null;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export interface ExportModel {
|
|
31
|
-
name: string;
|
|
32
|
-
description: string | null;
|
|
33
|
-
kind: ExportKind;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export type ExportKind = 'function' | 'type' | 'unknown';
|
|
37
|
-
|
|
38
|
-
export interface ComponentModel {
|
|
39
|
-
name: string;
|
|
40
|
-
description: string | null;
|
|
41
|
-
props: PropModel[];
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export interface PropModel {
|
|
45
|
-
name: string;
|
|
46
|
-
type: string;
|
|
47
|
-
required: boolean;
|
|
48
|
-
description: string | null;
|
|
49
|
-
}
|
package/src/render/render.ts
DELETED
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
import type { DocumentationModel } from '../model/types.js';
|
|
2
|
-
import type { RenderResult } from './types.js';
|
|
3
|
-
|
|
4
|
-
/***
|
|
5
|
-
* Renders the documentation model into README and artifact files.
|
|
6
|
-
*/
|
|
7
|
-
export function render(model: DocumentationModel): RenderResult {
|
|
8
|
-
return {
|
|
9
|
-
readme: renderReadme(model),
|
|
10
|
-
exportsMarkdown: renderExports(model),
|
|
11
|
-
components: renderComponents(model),
|
|
12
|
-
exportsJson: `${JSON.stringify(model.exports, null, 2)}\n`,
|
|
13
|
-
paradoxJson: `${JSON.stringify(model, null, 2)}\n`,
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
function renderReadme(model: DocumentationModel): string {
|
|
18
|
-
const lines = [`# ${model.packageName}`, ''];
|
|
19
|
-
|
|
20
|
-
if (model.description) {
|
|
21
|
-
lines.push(model.description, '');
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
if (model.usage !== null) {
|
|
25
|
-
lines.push('## Usage', '');
|
|
26
|
-
lines.push('```bash');
|
|
27
|
-
for (const command of model.usage.commands) {
|
|
28
|
-
lines.push(command.command);
|
|
29
|
-
}
|
|
30
|
-
lines.push('```', '');
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
if (model.config !== null) {
|
|
34
|
-
lines.push('## Configuration', '');
|
|
35
|
-
lines.push(`Create a \`${model.config.configFile}\` file:`, '');
|
|
36
|
-
lines.push('```ts');
|
|
37
|
-
|
|
38
|
-
if (model.config.factoryName !== null) {
|
|
39
|
-
lines.push(`import { ${model.config.factoryName} } from '${model.packageId}';`);
|
|
40
|
-
lines.push('');
|
|
41
|
-
lines.push(`export default ${model.config.factoryName}({`);
|
|
42
|
-
lines.push(' // ...');
|
|
43
|
-
lines.push('});');
|
|
44
|
-
} else {
|
|
45
|
-
lines.push(`import type { ${model.config.exportName} } from '${model.packageId}';`);
|
|
46
|
-
lines.push('');
|
|
47
|
-
lines.push('const config = {');
|
|
48
|
-
lines.push(' // ...');
|
|
49
|
-
lines.push(`} satisfies ${model.config.exportName};`);
|
|
50
|
-
lines.push('');
|
|
51
|
-
lines.push('export default config;');
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
lines.push('```', '');
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
if (model.exports.length > 0) {
|
|
58
|
-
lines.push('## Public API', '');
|
|
59
|
-
|
|
60
|
-
for (const item of model.exports) {
|
|
61
|
-
lines.push(`### ${item.name}`, '');
|
|
62
|
-
lines.push(item.description ?? `\`${item.kind}\` export.`, '');
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
return `${lines.join('\n').trimEnd()}\n`;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
function renderExports(model: DocumentationModel): string {
|
|
70
|
-
const lines = ['# Public API', ''];
|
|
71
|
-
|
|
72
|
-
for (const item of model.exports) {
|
|
73
|
-
lines.push(`## ${item.name}`, '');
|
|
74
|
-
lines.push(`Kind: \`${item.kind}\``, '');
|
|
75
|
-
|
|
76
|
-
if (item.description) {
|
|
77
|
-
lines.push(item.description, '');
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
return `${lines.join('\n').trimEnd()}\n`;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
function renderComponents(model: DocumentationModel): string {
|
|
85
|
-
const lines = ['# Components', ''];
|
|
86
|
-
|
|
87
|
-
for (const component of model.components) {
|
|
88
|
-
lines.push(`## ${component.name}`, '');
|
|
89
|
-
|
|
90
|
-
if (component.description) {
|
|
91
|
-
lines.push(component.description, '');
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
if (component.props.length > 0) {
|
|
95
|
-
lines.push('| Prop | Type | Required | Description |');
|
|
96
|
-
lines.push('| --- | --- | --- | --- |');
|
|
97
|
-
|
|
98
|
-
for (const prop of component.props) {
|
|
99
|
-
lines.push(
|
|
100
|
-
`| ${escapeTableCell(prop.name)} | \`${escapeTableCell(prop.type)}\` | ${
|
|
101
|
-
prop.required ? 'yes' : 'no'
|
|
102
|
-
} | ${escapeTableCell(prop.description ?? '')} |`,
|
|
103
|
-
);
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
lines.push('');
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
return `${lines.join('\n').trimEnd()}\n`;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
function escapeTableCell(value: string): string {
|
|
114
|
-
return value.replaceAll('|', '\\|');
|
|
115
|
-
}
|
package/src/render/types.ts
DELETED
package/src/write/write.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { mkdir, writeFile } from 'node:fs/promises';
|
|
2
|
-
import { join } from 'node:path';
|
|
3
|
-
|
|
4
|
-
import type { ParadoxConfig } from '../config/types.js';
|
|
5
|
-
import type { RenderResult } from '../render/types.js';
|
|
6
|
-
|
|
7
|
-
/***
|
|
8
|
-
* Writes generated documentation artifacts to the configured output paths.
|
|
9
|
-
*/
|
|
10
|
-
export async function write(result: RenderResult, config: ParadoxConfig): Promise<void> {
|
|
11
|
-
const root = config.package?.root ?? process.cwd();
|
|
12
|
-
const outputDir = config.output?.dir ?? 'paradox';
|
|
13
|
-
const mode = config.mode ?? 'safe';
|
|
14
|
-
|
|
15
|
-
await mkdir(join(root, outputDir), { recursive: true });
|
|
16
|
-
|
|
17
|
-
await writeFile(join(root, outputDir, 'exports.md'), result.exportsMarkdown);
|
|
18
|
-
await writeFile(join(root, outputDir, 'components.md'), result.components);
|
|
19
|
-
await writeFile(join(root, outputDir, 'exports.json'), result.exportsJson);
|
|
20
|
-
await writeFile(join(root, outputDir, 'paradox.json'), result.paradoxJson);
|
|
21
|
-
|
|
22
|
-
if (mode === 'write') {
|
|
23
|
-
await writeFile(join(root, 'README.md'), result.readme);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
# Components
|
|
2
|
-
|
|
3
|
-
## Button
|
|
4
|
-
|
|
5
|
-
Renders the fixture button component.
|
|
6
|
-
|
|
7
|
-
| Prop | Type | Required | Description |
|
|
8
|
-
| --- | --- | --- | --- |
|
|
9
|
-
| disabled | `boolean \| undefined` | no | Optional disabled state. |
|
|
10
|
-
| label | `string` | yes | Visible button label. |
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
# Public API
|
|
2
|
-
|
|
3
|
-
## Button
|
|
4
|
-
|
|
5
|
-
Kind: `function`
|
|
6
|
-
|
|
7
|
-
Renders the fixture button component.
|
|
8
|
-
|
|
9
|
-
## ButtonProps
|
|
10
|
-
|
|
11
|
-
Kind: `type`
|
|
12
|
-
|
|
13
|
-
Props accepted by the fixture button.
|
|
14
|
-
|
|
15
|
-
## ToolConfig
|
|
16
|
-
|
|
17
|
-
Kind: `type`
|
|
18
|
-
|
|
19
|
-
Configuration for the fixture package.
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
# Fixture Docs
|
|
2
|
-
|
|
3
|
-
Generated fixture docs.
|
|
4
|
-
|
|
5
|
-
## Usage
|
|
6
|
-
|
|
7
|
-
```bash
|
|
8
|
-
bunx @fixture/basic
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
## Configuration
|
|
12
|
-
|
|
13
|
-
Create a `basic.config.ts` file:
|
|
14
|
-
|
|
15
|
-
```ts
|
|
16
|
-
import type { ToolConfig } from '@fixture/basic';
|
|
17
|
-
|
|
18
|
-
const config = {
|
|
19
|
-
// ...
|
|
20
|
-
} satisfies ToolConfig;
|
|
21
|
-
|
|
22
|
-
export default config;
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
## Public API
|
|
26
|
-
|
|
27
|
-
### Button
|
|
28
|
-
|
|
29
|
-
Renders the fixture button component.
|
|
30
|
-
|
|
31
|
-
### ButtonProps
|
|
32
|
-
|
|
33
|
-
Props accepted by the fixture button.
|
|
34
|
-
|
|
35
|
-
### ToolConfig
|
|
36
|
-
|
|
37
|
-
Configuration for the fixture package.
|
package/tests/analyze.test.ts
DELETED
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
import { readFile } from 'node:fs/promises';
|
|
2
|
-
import { join } from 'node:path';
|
|
3
|
-
|
|
4
|
-
import { describe, expect, test } from 'bun:test';
|
|
5
|
-
|
|
6
|
-
import { analyze } from '../src/analyze/analyze.js';
|
|
7
|
-
import { createUsageFromPackageJson } from '../src/analyze/usage.js';
|
|
8
|
-
import { buildModel } from '../src/model/buildModel.js';
|
|
9
|
-
import { render } from '../src/render/render.js';
|
|
10
|
-
|
|
11
|
-
const fixtureRoot = join(import.meta.dir, 'fixtures/basic');
|
|
12
|
-
const multiBinFixtureRoot = join(import.meta.dir, 'fixtures/multi-bin');
|
|
13
|
-
const snapshotRoot = join(import.meta.dir, '__snapshots__');
|
|
14
|
-
|
|
15
|
-
describe('analyze', () => {
|
|
16
|
-
test('builds documentation from package entrypoints', async () => {
|
|
17
|
-
const analysis = await analyze({
|
|
18
|
-
docs: {
|
|
19
|
-
title: 'Fixture Docs',
|
|
20
|
-
description: 'Generated fixture docs.',
|
|
21
|
-
},
|
|
22
|
-
package: {
|
|
23
|
-
root: fixtureRoot,
|
|
24
|
-
entrypoints: ['src/index.ts'],
|
|
25
|
-
},
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
expect(analysis.exports.map((item) => item.name)).toEqual([
|
|
29
|
-
'Button',
|
|
30
|
-
'ToolConfig',
|
|
31
|
-
'ButtonProps',
|
|
32
|
-
]);
|
|
33
|
-
expect(analysis.exports.map((item) => item.name)).not.toContain('internalHelper');
|
|
34
|
-
expect(analysis.usage).toEqual({
|
|
35
|
-
packageName: '@fixture/basic',
|
|
36
|
-
commands: [
|
|
37
|
-
{
|
|
38
|
-
name: 'fixture-basic',
|
|
39
|
-
command: 'bunx @fixture/basic',
|
|
40
|
-
},
|
|
41
|
-
],
|
|
42
|
-
});
|
|
43
|
-
expect(analysis.config).toEqual({
|
|
44
|
-
exportName: 'ToolConfig',
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
expect(analysis.components).toEqual([
|
|
48
|
-
{
|
|
49
|
-
name: 'Button',
|
|
50
|
-
description: 'Renders the fixture button component.',
|
|
51
|
-
props: [
|
|
52
|
-
{
|
|
53
|
-
name: 'label',
|
|
54
|
-
type: 'string',
|
|
55
|
-
required: true,
|
|
56
|
-
description: 'Visible button label.',
|
|
57
|
-
},
|
|
58
|
-
{
|
|
59
|
-
name: 'disabled',
|
|
60
|
-
type: 'boolean | undefined',
|
|
61
|
-
required: false,
|
|
62
|
-
description: 'Optional disabled state.',
|
|
63
|
-
},
|
|
64
|
-
],
|
|
65
|
-
},
|
|
66
|
-
]);
|
|
67
|
-
|
|
68
|
-
const output = render(buildModel(analysis));
|
|
69
|
-
|
|
70
|
-
await expectSnapshot('basic.readme.md', output.readme);
|
|
71
|
-
await expectSnapshot('basic.exports.md', output.exportsMarkdown);
|
|
72
|
-
await expectSnapshot('basic.components.md', output.components);
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
test('renders multiple bin commands deterministically', async () => {
|
|
76
|
-
const analysis = await analyze({
|
|
77
|
-
docs: {
|
|
78
|
-
title: 'Multi Bin Fixture',
|
|
79
|
-
description: 'Fixture docs for multiple binaries.',
|
|
80
|
-
},
|
|
81
|
-
package: {
|
|
82
|
-
root: multiBinFixtureRoot,
|
|
83
|
-
entrypoints: ['src/index.ts'],
|
|
84
|
-
},
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
expect(analysis.usage).toEqual({
|
|
88
|
-
packageName: 'fixture-multi-bin',
|
|
89
|
-
commands: [
|
|
90
|
-
{
|
|
91
|
-
name: 'alpha',
|
|
92
|
-
command: 'bunx fixture-multi-bin alpha',
|
|
93
|
-
},
|
|
94
|
-
{
|
|
95
|
-
name: 'beta',
|
|
96
|
-
command: 'bunx fixture-multi-bin beta',
|
|
97
|
-
},
|
|
98
|
-
],
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
const output = render(buildModel(analysis));
|
|
102
|
-
|
|
103
|
-
await expectSnapshot('multi-bin.readme.md', output.readme);
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
test('normalizes string bin usage', () => {
|
|
107
|
-
expect(
|
|
108
|
-
createUsageFromPackageJson({
|
|
109
|
-
name: 'fixture-string-bin',
|
|
110
|
-
bin: './src/cli.ts',
|
|
111
|
-
}),
|
|
112
|
-
).toEqual({
|
|
113
|
-
packageName: 'fixture-string-bin',
|
|
114
|
-
commands: [
|
|
115
|
-
{
|
|
116
|
-
name: 'fixture-string-bin',
|
|
117
|
-
command: 'bunx fixture-string-bin',
|
|
118
|
-
},
|
|
119
|
-
],
|
|
120
|
-
});
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
test('normalizes missing bin usage', () => {
|
|
124
|
-
expect(
|
|
125
|
-
createUsageFromPackageJson({
|
|
126
|
-
name: 'fixture-no-bin',
|
|
127
|
-
}),
|
|
128
|
-
).toBeNull();
|
|
129
|
-
});
|
|
130
|
-
|
|
131
|
-
test('normalizes scoped string bin usage', () => {
|
|
132
|
-
expect(
|
|
133
|
-
createUsageFromPackageJson({
|
|
134
|
-
name: '@fixture/string-bin',
|
|
135
|
-
bin: './src/cli.ts',
|
|
136
|
-
}),
|
|
137
|
-
).toEqual({
|
|
138
|
-
packageName: '@fixture/string-bin',
|
|
139
|
-
commands: [
|
|
140
|
-
{
|
|
141
|
-
name: 'string-bin',
|
|
142
|
-
command: 'bunx @fixture/string-bin',
|
|
143
|
-
},
|
|
144
|
-
],
|
|
145
|
-
});
|
|
146
|
-
});
|
|
147
|
-
});
|
|
148
|
-
|
|
149
|
-
async function expectSnapshot(name: string, actual: string): Promise<void> {
|
|
150
|
-
const expected = await readFile(join(snapshotRoot, name), 'utf-8');
|
|
151
|
-
|
|
152
|
-
expect(actual.trimEnd()).toBe(expected.trimEnd());
|
|
153
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
declare namespace JSX {
|
|
2
|
-
interface Element {
|
|
3
|
-
readonly type: string;
|
|
4
|
-
}
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
/***
|
|
8
|
-
* Props accepted by the fixture button.
|
|
9
|
-
*/
|
|
10
|
-
export interface ButtonProps {
|
|
11
|
-
/***
|
|
12
|
-
* Visible button label.
|
|
13
|
-
*/
|
|
14
|
-
label: string;
|
|
15
|
-
|
|
16
|
-
/***
|
|
17
|
-
* Optional disabled state.
|
|
18
|
-
*/
|
|
19
|
-
disabled?: boolean;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
/***
|
|
23
|
-
* Renders the fixture button component.
|
|
24
|
-
*/
|
|
25
|
-
export function Button(props: ButtonProps): JSX.Element {
|
|
26
|
-
return {
|
|
27
|
-
type: props.disabled ? 'disabled-button' : 'button',
|
|
28
|
-
};
|
|
29
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export function alpha(): void {}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export function beta(): void {}
|
package/tsconfig.eslint.json
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "https://json.schemastore.org/tsconfig",
|
|
3
|
-
"extends": "./tsconfig.json",
|
|
4
|
-
"compilerOptions": {
|
|
5
|
-
"rootDir": ".",
|
|
6
|
-
"noEmit": true
|
|
7
|
-
},
|
|
8
|
-
"include": [
|
|
9
|
-
"src/**/*.ts",
|
|
10
|
-
"tests/**/*.ts",
|
|
11
|
-
"paradox.config.ts",
|
|
12
|
-
"eslint.config.mjs",
|
|
13
|
-
".prettierrc.js"
|
|
14
|
-
],
|
|
15
|
-
"exclude": ["dist", "node_modules"]
|
|
16
|
-
}
|