@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.
Files changed (114) hide show
  1. package/.turbo/turbo-build.log +4 -0
  2. package/LICENSE +93 -0
  3. package/bin/accessibility.js +2 -2
  4. package/bin/cli-builder.d.ts +8 -0
  5. package/bin/cli-builder.js +178 -0
  6. package/bin/cli.d.ts +5 -11
  7. package/bin/cli.js +8 -200
  8. package/bin/commands/base.command.d.ts +13 -0
  9. package/bin/commands/base.command.js +40 -0
  10. package/bin/commands/check.command.d.ts +14 -0
  11. package/bin/commands/check.command.js +21 -0
  12. package/bin/commands/dev.command.d.ts +13 -0
  13. package/bin/commands/dev.command.js +40 -0
  14. package/bin/commands/index.d.ts +6 -0
  15. package/bin/commands/index.js +6 -0
  16. package/bin/commands/init.command.d.ts +16 -0
  17. package/bin/commands/init.command.js +88 -0
  18. package/bin/commands/link.command.d.ts +13 -0
  19. package/bin/commands/link.command.js +19 -0
  20. package/bin/commands/update.command.d.ts +10 -0
  21. package/bin/commands/update.command.js +13 -0
  22. package/bin/errors/cli-error.d.ts +26 -0
  23. package/bin/errors/cli-error.js +53 -0
  24. package/bin/errors/index.d.ts +1 -0
  25. package/bin/errors/index.js +1 -0
  26. package/bin/index.js +3 -3
  27. package/bin/mdxAccessibility.js +2 -2
  28. package/bin/services/accessibility-check.service.d.ts +10 -0
  29. package/bin/services/accessibility-check.service.js +144 -0
  30. package/bin/services/index.d.ts +7 -0
  31. package/bin/services/index.js +7 -0
  32. package/bin/services/link.service.d.ts +7 -0
  33. package/bin/services/link.service.js +40 -0
  34. package/bin/services/openapi-check.service.d.ts +7 -0
  35. package/bin/services/openapi-check.service.js +43 -0
  36. package/bin/services/port.service.d.ts +7 -0
  37. package/bin/services/port.service.js +26 -0
  38. package/bin/services/template.service.d.ts +22 -0
  39. package/bin/services/template.service.js +127 -0
  40. package/bin/services/update.service.d.ts +10 -0
  41. package/bin/services/update.service.js +57 -0
  42. package/bin/services/version.service.d.ts +16 -0
  43. package/bin/services/version.service.js +102 -0
  44. package/bin/types/common.d.ts +38 -0
  45. package/bin/types/common.js +21 -0
  46. package/bin/types/index.d.ts +2 -0
  47. package/bin/types/index.js +2 -0
  48. package/bin/types/options.d.ts +23 -0
  49. package/bin/types/options.js +1 -0
  50. package/bin/utils/console-logger.d.ts +16 -0
  51. package/bin/utils/console-logger.js +65 -0
  52. package/bin/utils/index.d.ts +2 -0
  53. package/bin/utils/index.js +2 -0
  54. package/bin/utils/logger.interface.d.ts +15 -0
  55. package/bin/utils/logger.interface.js +1 -0
  56. package/package.json +30 -31
  57. package/src/accessibility.ts +2 -2
  58. package/src/cli-builder.ts +267 -0
  59. package/src/cli.ts +15 -0
  60. package/src/commands/__tests__/base.command.test.ts +145 -0
  61. package/src/commands/__tests__/dev.command.test.ts +241 -0
  62. package/src/commands/__tests__/init.command.test.ts +281 -0
  63. package/{__test__ → src/commands/__tests__}/utils.ts +1 -1
  64. package/src/commands/base.command.ts +97 -0
  65. package/src/commands/check.command.ts +40 -0
  66. package/src/commands/dev.command.ts +63 -0
  67. package/src/commands/index.ts +6 -0
  68. package/src/commands/init.command.ts +125 -0
  69. package/src/commands/link.command.ts +39 -0
  70. package/src/commands/update.command.ts +23 -0
  71. package/src/errors/cli-error.ts +83 -0
  72. package/src/errors/index.ts +1 -0
  73. package/src/index.ts +4 -4
  74. package/src/mdxAccessibility.ts +3 -4
  75. package/src/services/__tests__/port.service.test.ts +83 -0
  76. package/src/services/__tests__/template.service.test.ts +234 -0
  77. package/src/services/__tests__/version.service.test.ts +165 -0
  78. package/src/services/accessibility-check.service.ts +226 -0
  79. package/src/services/index.ts +7 -0
  80. package/src/services/link.service.ts +65 -0
  81. package/src/services/openapi-check.service.ts +68 -0
  82. package/src/services/port.service.ts +47 -0
  83. package/src/services/template.service.ts +203 -0
  84. package/src/services/update.service.ts +76 -0
  85. package/src/services/version.service.ts +161 -0
  86. package/src/types/common.ts +53 -0
  87. package/src/types/index.ts +2 -0
  88. package/src/types/options.ts +42 -0
  89. package/src/utils/console-logger.ts +114 -0
  90. package/src/utils/index.ts +2 -0
  91. package/src/utils/logger.interface.ts +70 -0
  92. package/tsconfig.build.json +2 -1
  93. package/tsconfig.json +1 -1
  94. package/.prettierignore +0 -2
  95. package/__test__/brokenLinks.test.ts +0 -93
  96. package/__test__/checkPort.test.ts +0 -92
  97. package/__test__/openApiCheck.test.ts +0 -127
  98. package/__test__/update.test.ts +0 -108
  99. package/bin/accessibilityCheck.d.ts +0 -2
  100. package/bin/accessibilityCheck.js +0 -70
  101. package/bin/helpers.d.ts +0 -17
  102. package/bin/helpers.js +0 -104
  103. package/bin/init.d.ts +0 -1
  104. package/bin/init.js +0 -73
  105. package/bin/mdxLinter.d.ts +0 -2
  106. package/bin/mdxLinter.js +0 -45
  107. package/bin/update.d.ts +0 -3
  108. package/bin/update.js +0 -32
  109. package/src/accessibilityCheck.tsx +0 -145
  110. package/src/cli.tsx +0 -302
  111. package/src/helpers.tsx +0 -131
  112. package/src/init.tsx +0 -93
  113. package/src/mdxLinter.tsx +0 -88
  114. 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
- };