@poetora/cli 0.0.1 → 0.1.3
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/.turbo/turbo-build.log +4 -0
- package/LICENSE +93 -0
- package/bin/accessibility.js +2 -2
- package/bin/cli-builder.d.ts +8 -0
- package/bin/cli-builder.js +178 -0
- package/bin/cli.d.ts +5 -11
- package/bin/cli.js +8 -200
- package/bin/commands/base.command.d.ts +13 -0
- package/bin/commands/base.command.js +40 -0
- package/bin/commands/check.command.d.ts +14 -0
- package/bin/commands/check.command.js +21 -0
- package/bin/commands/dev.command.d.ts +13 -0
- package/bin/commands/dev.command.js +40 -0
- package/bin/commands/index.d.ts +6 -0
- package/bin/commands/index.js +6 -0
- package/bin/commands/init.command.d.ts +16 -0
- package/bin/commands/init.command.js +88 -0
- package/bin/commands/link.command.d.ts +13 -0
- package/bin/commands/link.command.js +19 -0
- package/bin/commands/update.command.d.ts +10 -0
- package/bin/commands/update.command.js +13 -0
- package/bin/errors/cli-error.d.ts +26 -0
- package/bin/errors/cli-error.js +53 -0
- package/bin/errors/index.d.ts +1 -0
- package/bin/errors/index.js +1 -0
- package/bin/index.js +3 -3
- package/bin/mdxAccessibility.js +2 -2
- package/bin/services/accessibility-check.service.d.ts +10 -0
- package/bin/services/accessibility-check.service.js +144 -0
- package/bin/services/index.d.ts +7 -0
- package/bin/services/index.js +7 -0
- package/bin/services/link.service.d.ts +7 -0
- package/bin/services/link.service.js +40 -0
- package/bin/services/openapi-check.service.d.ts +7 -0
- package/bin/services/openapi-check.service.js +43 -0
- package/bin/services/port.service.d.ts +7 -0
- package/bin/services/port.service.js +26 -0
- package/bin/services/template.service.d.ts +22 -0
- package/bin/services/template.service.js +127 -0
- package/bin/services/update.service.d.ts +10 -0
- package/bin/services/update.service.js +57 -0
- package/bin/services/version.service.d.ts +16 -0
- package/bin/services/version.service.js +102 -0
- package/bin/types/common.d.ts +38 -0
- package/bin/types/common.js +21 -0
- package/bin/types/index.d.ts +2 -0
- package/bin/types/index.js +2 -0
- package/bin/types/options.d.ts +23 -0
- package/bin/types/options.js +1 -0
- package/bin/utils/console-logger.d.ts +16 -0
- package/bin/utils/console-logger.js +65 -0
- package/bin/utils/index.d.ts +2 -0
- package/bin/utils/index.js +2 -0
- package/bin/utils/logger.interface.d.ts +15 -0
- package/bin/utils/logger.interface.js +1 -0
- package/package.json +30 -31
- package/src/accessibility.ts +2 -2
- package/src/cli-builder.ts +267 -0
- package/src/cli.ts +15 -0
- package/src/commands/__tests__/base.command.test.ts +145 -0
- package/src/commands/__tests__/dev.command.test.ts +241 -0
- package/src/commands/__tests__/init.command.test.ts +281 -0
- package/{__test__ → src/commands/__tests__}/utils.ts +1 -1
- package/src/commands/base.command.ts +97 -0
- package/src/commands/check.command.ts +40 -0
- package/src/commands/dev.command.ts +63 -0
- package/src/commands/index.ts +6 -0
- package/src/commands/init.command.ts +125 -0
- package/src/commands/link.command.ts +39 -0
- package/src/commands/update.command.ts +23 -0
- package/src/errors/cli-error.ts +83 -0
- package/src/errors/index.ts +1 -0
- package/src/index.ts +4 -4
- package/src/mdxAccessibility.ts +3 -4
- package/src/services/__tests__/port.service.test.ts +83 -0
- package/src/services/__tests__/template.service.test.ts +234 -0
- package/src/services/__tests__/version.service.test.ts +165 -0
- package/src/services/accessibility-check.service.ts +226 -0
- package/src/services/index.ts +7 -0
- package/src/services/link.service.ts +65 -0
- package/src/services/openapi-check.service.ts +68 -0
- package/src/services/port.service.ts +47 -0
- package/src/services/template.service.ts +203 -0
- package/src/services/update.service.ts +76 -0
- package/src/services/version.service.ts +161 -0
- package/src/types/common.ts +53 -0
- package/src/types/index.ts +2 -0
- package/src/types/options.ts +42 -0
- package/src/utils/console-logger.ts +114 -0
- package/src/utils/index.ts +2 -0
- package/src/utils/logger.interface.ts +70 -0
- package/tsconfig.build.json +2 -1
- package/tsconfig.json +1 -1
- package/.prettierignore +0 -2
- package/__test__/brokenLinks.test.ts +0 -93
- package/__test__/checkPort.test.ts +0 -92
- package/__test__/openApiCheck.test.ts +0 -127
- package/__test__/update.test.ts +0 -108
- package/bin/accessibilityCheck.d.ts +0 -2
- package/bin/accessibilityCheck.js +0 -70
- package/bin/helpers.d.ts +0 -17
- package/bin/helpers.js +0 -104
- package/bin/init.d.ts +0 -1
- package/bin/init.js +0 -73
- package/bin/mdxLinter.d.ts +0 -2
- package/bin/mdxLinter.js +0 -45
- package/bin/update.d.ts +0 -3
- package/bin/update.js +0 -32
- package/src/accessibilityCheck.tsx +0 -145
- package/src/cli.tsx +0 -302
- package/src/helpers.tsx +0 -131
- package/src/init.tsx +0 -93
- package/src/mdxLinter.tsx +0 -88
- package/src/update.tsx +0 -37
package/src/mdxLinter.tsx
DELETED
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import { addLog, ErrorLog, SuccessLog } from '@poetora/previewing';
|
|
2
|
-
import { Text } from 'ink';
|
|
3
|
-
import path from 'path';
|
|
4
|
-
|
|
5
|
-
import { TerminateCode } from './accessibilityCheck.js';
|
|
6
|
-
import { checkMdxAccessibility, type AccessibilityFixAttribute } from './mdxAccessibility.js';
|
|
7
|
-
|
|
8
|
-
export const mdxLinter = async (): Promise<TerminateCode> => {
|
|
9
|
-
try {
|
|
10
|
-
addLog(
|
|
11
|
-
<Text bold color="cyan">
|
|
12
|
-
Checking mdx files for accessibility issues...
|
|
13
|
-
</Text>
|
|
14
|
-
);
|
|
15
|
-
|
|
16
|
-
const results = await checkMdxAccessibility();
|
|
17
|
-
|
|
18
|
-
if (results.missingAltAttributes.length === 0) {
|
|
19
|
-
addLog(<SuccessLog message="no accessibility issues found" />);
|
|
20
|
-
addLog(
|
|
21
|
-
<Text>
|
|
22
|
-
Checked {results.totalFiles} MDX files - all images and videos have alt attributes.
|
|
23
|
-
</Text>
|
|
24
|
-
);
|
|
25
|
-
return 0;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
const issuesByFile: Record<string, AccessibilityFixAttribute[]> = {};
|
|
29
|
-
results.missingAltAttributes.forEach((issue) => {
|
|
30
|
-
if (!issuesByFile[issue.filePath]) {
|
|
31
|
-
issuesByFile[issue.filePath] = [];
|
|
32
|
-
}
|
|
33
|
-
issuesByFile[issue.filePath]?.push(issue);
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
addLog(
|
|
37
|
-
<Text bold color="red">
|
|
38
|
-
Found {results.missingAltAttributes.length} accessibility issues in{' '}
|
|
39
|
-
{results.filesWithIssues} files:
|
|
40
|
-
</Text>
|
|
41
|
-
);
|
|
42
|
-
addLog(<Text></Text>);
|
|
43
|
-
|
|
44
|
-
for (const [filePath, issues] of Object.entries(issuesByFile)) {
|
|
45
|
-
const relativePath = path.relative(process.cwd(), filePath);
|
|
46
|
-
addLog(<Text bold>{relativePath}:</Text>);
|
|
47
|
-
|
|
48
|
-
for (const issue of issues) {
|
|
49
|
-
const location =
|
|
50
|
-
issue.line && issue.column ? ` (line ${issue.line}, col ${issue.column})` : '';
|
|
51
|
-
if (issue.element === 'a') {
|
|
52
|
-
addLog(
|
|
53
|
-
<Text>
|
|
54
|
-
<Text color="red"> ✗</Text> Missing text attribute <Text bold>{issue.tagName}</Text>{' '}
|
|
55
|
-
element{location}
|
|
56
|
-
</Text>
|
|
57
|
-
);
|
|
58
|
-
} else {
|
|
59
|
-
addLog(
|
|
60
|
-
<Text>
|
|
61
|
-
<Text color="red"> ✗</Text> Missing alt attribute on <Text bold>{issue.tagName}</Text>{' '}
|
|
62
|
-
element{location}
|
|
63
|
-
</Text>
|
|
64
|
-
);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
addLog(<Text></Text>);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
addLog(
|
|
71
|
-
<Text color="yellow">
|
|
72
|
-
<Text bold>Recommendation:</Text> Add alt attributes to all images and videos for better
|
|
73
|
-
accessibility.
|
|
74
|
-
</Text>
|
|
75
|
-
);
|
|
76
|
-
|
|
77
|
-
return 1;
|
|
78
|
-
} catch (error) {
|
|
79
|
-
addLog(
|
|
80
|
-
<ErrorLog
|
|
81
|
-
message={`MDX accessibility check failed: ${
|
|
82
|
-
error instanceof Error ? error.message : 'Unknown error'
|
|
83
|
-
}`}
|
|
84
|
-
/>
|
|
85
|
-
);
|
|
86
|
-
return 1;
|
|
87
|
-
}
|
|
88
|
-
};
|
package/src/update.tsx
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { SpinnerLog, SuccessLog, ErrorLog, addLog, clearLogs } from '@poetora/previewing';
|
|
2
|
-
|
|
3
|
-
import { execAsync, getLatestCliVersion, getVersions, detectPackageManager } from './helpers.js';
|
|
4
|
-
|
|
5
|
-
export const update = async ({ packageName }: { packageName: string }) => {
|
|
6
|
-
addLog(<SpinnerLog message="updating..." />);
|
|
7
|
-
const { cli: existingCliVersion } = getVersions();
|
|
8
|
-
const latestCliVersion = getLatestCliVersion(packageName);
|
|
9
|
-
const isUpToDate =
|
|
10
|
-
existingCliVersion && latestCliVersion && latestCliVersion.trim() === existingCliVersion.trim();
|
|
11
|
-
|
|
12
|
-
if (isUpToDate) {
|
|
13
|
-
addLog(<SuccessLog message="already up to date" />);
|
|
14
|
-
return;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
if (existingCliVersion && latestCliVersion.trim() !== existingCliVersion.trim()) {
|
|
18
|
-
try {
|
|
19
|
-
clearLogs();
|
|
20
|
-
addLog(<SpinnerLog message={`updating ${packageName} package...`} />);
|
|
21
|
-
const packageManager = await detectPackageManager({ packageName });
|
|
22
|
-
if (packageManager === 'pnpm') {
|
|
23
|
-
await execAsync(`pnpm install -g ${packageName}@latest --silent`);
|
|
24
|
-
} else {
|
|
25
|
-
await execAsync(`npm install -g ${packageName}@latest --silent`);
|
|
26
|
-
}
|
|
27
|
-
} catch (err) {
|
|
28
|
-
addLog(<ErrorLog message={`failed to update ${packageName}@latest`} />);
|
|
29
|
-
return;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
clearLogs();
|
|
34
|
-
addLog(
|
|
35
|
-
<SuccessLog message={`updated ${packageName} to the latest version: ${latestCliVersion}`} />
|
|
36
|
-
);
|
|
37
|
-
};
|