@poetora/cli 0.1.8 → 0.1.10

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 (46) hide show
  1. package/bin/cli-builder.js +1 -1
  2. package/bin/services/version.service.d.ts +1 -1
  3. package/bin/services/version.service.js +12 -10
  4. package/package.json +8 -3
  5. package/.turbo/turbo-build.log +0 -4
  6. package/src/accessibility.ts +0 -180
  7. package/src/cli-builder.ts +0 -274
  8. package/src/cli.ts +0 -22
  9. package/src/commands/__tests__/base.command.test.ts +0 -139
  10. package/src/commands/__tests__/dev.command.test.ts +0 -241
  11. package/src/commands/__tests__/init.command.test.ts +0 -281
  12. package/src/commands/__tests__/utils.ts +0 -20
  13. package/src/commands/base.command.ts +0 -97
  14. package/src/commands/check.command.ts +0 -40
  15. package/src/commands/dev.command.ts +0 -63
  16. package/src/commands/index.ts +0 -6
  17. package/src/commands/init.command.ts +0 -125
  18. package/src/commands/link.command.ts +0 -39
  19. package/src/commands/update.command.ts +0 -23
  20. package/src/constants.ts +0 -4
  21. package/src/errors/cli-error.ts +0 -83
  22. package/src/errors/index.ts +0 -1
  23. package/src/index.ts +0 -110
  24. package/src/mdxAccessibility.ts +0 -132
  25. package/src/middlewares.ts +0 -73
  26. package/src/services/__tests__/port.service.test.ts +0 -83
  27. package/src/services/__tests__/template.service.test.ts +0 -234
  28. package/src/services/__tests__/version.service.test.ts +0 -165
  29. package/src/services/accessibility-check.service.ts +0 -226
  30. package/src/services/index.ts +0 -7
  31. package/src/services/link.service.ts +0 -65
  32. package/src/services/openapi-check.service.ts +0 -68
  33. package/src/services/port.service.ts +0 -47
  34. package/src/services/template.service.ts +0 -203
  35. package/src/services/update.service.ts +0 -76
  36. package/src/services/version.service.ts +0 -161
  37. package/src/start.ts +0 -6
  38. package/src/types/common.ts +0 -53
  39. package/src/types/index.ts +0 -2
  40. package/src/types/options.ts +0 -42
  41. package/src/utils/console-logger.ts +0 -123
  42. package/src/utils/index.ts +0 -2
  43. package/src/utils/logger.interface.ts +0 -70
  44. package/tsconfig.build.json +0 -17
  45. package/tsconfig.json +0 -21
  46. package/vitest.config.ts +0 -8
@@ -1,161 +0,0 @@
1
- import { getClientVersion, LOCAL_LINKED_CLI_VERSION } from '@poetora/previewing';
2
- import { execSync } from 'child_process';
3
- import yargs from 'yargs';
4
-
5
- import { InvalidEnvironmentError } from '../errors/index.js';
6
- import { CLI_CONSTANTS, type NodeVersion, type ValidationResult } from '../types/index.js';
7
-
8
- /**
9
- * Service for handling version checks and management
10
- */
11
- export class VersionService {
12
- constructor(private readonly packageName: string = 'poet') {}
13
- /**
14
- * Parse Node.js version string
15
- */
16
- parseNodeVersion(): NodeVersion {
17
- let versionString = process.version;
18
-
19
- // Remove 'v' prefix if present
20
- if (versionString.charAt(0) === 'v') {
21
- versionString = versionString.slice(1);
22
- }
23
-
24
- const parts = versionString.split('.');
25
- const major = parseInt(parts[0] ?? '0', 10);
26
- const minor = parseInt(parts[1] ?? '0', 10);
27
- const patch = parseInt(parts[2] ?? '0', 10);
28
-
29
- return {
30
- major,
31
- minor,
32
- patch,
33
- raw: versionString,
34
- };
35
- }
36
-
37
- /**
38
- * Check if current Node.js version is supported
39
- */
40
- checkNodeVersion(): ValidationResult {
41
- const current = this.parseNodeVersion();
42
- const { MIN_MAJOR, MIN_MINOR, MAX_MAJOR, RECOMMENDED_MAJOR, RECOMMENDED_MINOR } =
43
- CLI_CONSTANTS.NODE_VERSION;
44
-
45
- // Check if version is below minimum
46
- if (current.major < MIN_MAJOR || (current.major === MIN_MAJOR && current.minor < MIN_MINOR)) {
47
- return {
48
- isValid: false,
49
- hasWarning: false,
50
- message: `${this.packageName} requires Node.js ${MIN_MAJOR}.${MIN_MINOR}.0 or higher (current version ${current.raw}). Please upgrade Node.js and try again.`,
51
- };
52
- }
53
-
54
- // Check if version is above maximum
55
- if (current.major > MAX_MAJOR) {
56
- return {
57
- isValid: false,
58
- hasWarning: false,
59
- message: `${this.packageName} is not supported on Node.js ${current.major}.x. Please use an LTS version (${MIN_MAJOR}-${MAX_MAJOR}).`,
60
- };
61
- }
62
-
63
- // Check if version is below recommended
64
- if (
65
- current.major < RECOMMENDED_MAJOR ||
66
- (current.major === RECOMMENDED_MAJOR && current.minor < RECOMMENDED_MINOR)
67
- ) {
68
- return {
69
- isValid: true,
70
- hasWarning: true,
71
- message: `Node.js ${RECOMMENDED_MAJOR}.${RECOMMENDED_MINOR}.0 or higher is recommended for best compatibility (current: ${current.raw}).`,
72
- };
73
- }
74
-
75
- // Version is good
76
- return {
77
- isValid: true,
78
- hasWarning: false,
79
- };
80
- }
81
-
82
- /**
83
- * Get CLI version from package.json
84
- */
85
- getCliVersion(): string | undefined {
86
- const y = yargs();
87
- let version: string | undefined;
88
-
89
- y.showVersion((v) => {
90
- version = v;
91
- return false;
92
- });
93
-
94
- if (process.env.CLI_TEST_MODE === 'true') {
95
- return 'test-cli';
96
- }
97
-
98
- // When running npm link or pnpm link, the version is 'unknown'
99
- if (version === 'unknown') {
100
- version = LOCAL_LINKED_CLI_VERSION;
101
- }
102
-
103
- return version;
104
- }
105
-
106
- /**
107
- * Get client version
108
- */
109
- getClientVersion(): string {
110
- return getClientVersion().trim();
111
- }
112
-
113
- /**
114
- * Get versions of CLI and client
115
- */
116
- getVersions(): { cli: string | undefined; client: string } {
117
- return {
118
- cli: this.getCliVersion(),
119
- client: this.getClientVersion(),
120
- };
121
- }
122
-
123
- /**
124
- * Get latest CLI version from npm registry
125
- */
126
- getLatestCliVersion(packageName: string): string {
127
- try {
128
- const version = execSync(`npm view ${packageName} version --silent`, {
129
- encoding: 'utf-8',
130
- stdio: ['pipe', 'pipe', 'pipe'],
131
- }).trim();
132
-
133
- return version;
134
- } catch (error) {
135
- throw new Error(
136
- `Failed to fetch latest version for ${packageName}: ${
137
- error instanceof Error ? error.message : 'unknown error'
138
- }`
139
- );
140
- }
141
- }
142
-
143
- /**
144
- * Check if current version is up to date
145
- */
146
- isVersionUpToDate(currentVersion: string, latestVersion: string): boolean {
147
- return currentVersion.trim() === latestVersion.trim();
148
- }
149
-
150
- /**
151
- * Validate and throw if Node version is not supported
152
- * @throws {InvalidEnvironmentError} if Node version is not supported
153
- */
154
- validateNodeVersion(): void {
155
- const result = this.checkNodeVersion();
156
-
157
- if (!result.isValid) {
158
- throw new InvalidEnvironmentError(result.message ?? 'Unsupported Node.js version');
159
- }
160
- }
161
- }
package/src/start.ts DELETED
@@ -1,6 +0,0 @@
1
- #!/usr/bin/env node
2
- import { cli } from './cli.js';
3
-
4
- const packageName = process.env.POETORA_PACKAGE_NAME ?? 'poet';
5
-
6
- cli({ packageName });
@@ -1,53 +0,0 @@
1
- /**
2
- * CLI constants
3
- */
4
- export const CLI_CONSTANTS = {
5
- PORT: {
6
- DEFAULT: 3000,
7
- MAX_ATTEMPTS: 10,
8
- },
9
- NODE_VERSION: {
10
- MIN_MAJOR: 18,
11
- MIN_MINOR: 0,
12
- MAX_MAJOR: 24,
13
- MAX_MINOR: Number.MAX_SAFE_INTEGER,
14
- RECOMMENDED_MAJOR: 20,
15
- RECOMMENDED_MINOR: 17,
16
- },
17
- TIMEOUT: {
18
- PROCESS_KILL: 5000,
19
- LOG_RENDER: 50,
20
- },
21
- UPDATE: {
22
- CHECK_INTERVAL: 86400000, // 24 hours
23
- },
24
- } as const;
25
-
26
- /**
27
- * Node version structure
28
- */
29
- export interface NodeVersion {
30
- major: number;
31
- minor: number;
32
- patch: number;
33
- raw: string;
34
- }
35
-
36
- /**
37
- * Validation result
38
- */
39
- export interface ValidationResult {
40
- isValid: boolean;
41
- hasWarning: boolean;
42
- message?: string;
43
- }
44
-
45
- /**
46
- * Logger spinner interface
47
- */
48
- export interface LoggerSpinner {
49
- start(): void;
50
- stop(): void;
51
- succeed(message?: string): void;
52
- fail(message?: string): void;
53
- }
@@ -1,2 +0,0 @@
1
- export * from './common.js';
2
- export * from './options.js';
@@ -1,42 +0,0 @@
1
- /**
2
- * Options for dev command
3
- */
4
- export interface DevOptions {
5
- port?: number;
6
- open?: boolean;
7
- localSchema?: boolean;
8
- clientVersion?: string;
9
- groups?: string[];
10
- disableOpenapi?: boolean;
11
- }
12
-
13
- /**
14
- * Options for init command
15
- */
16
- export interface InitOptions {
17
- directory: string;
18
- }
19
-
20
- /**
21
- * Options for openapi-check command
22
- */
23
- export interface OpenApiCheckOptions {
24
- filename: string;
25
- localSchema?: boolean;
26
- }
27
-
28
- /**
29
- * Options for rename command
30
- */
31
- export interface RenameOptions {
32
- from: string;
33
- to: string;
34
- force?: boolean;
35
- }
36
-
37
- /**
38
- * Options for update command
39
- */
40
- export interface UpdateOptions {
41
- packageName: string;
42
- }
@@ -1,123 +0,0 @@
1
- import {
2
- addLog,
3
- EmptyLineLog,
4
- ErrorLog,
5
- InfoLog,
6
- SpinnerLog,
7
- SuccessLog,
8
- WarningLog,
9
- } from '@poetora/previewing';
10
- import chalk from 'chalk';
11
- import { Text } from 'ink';
12
- import React from 'react';
13
-
14
- import type { LoggerSpinner } from '../types/index.js';
15
-
16
- import type { ILogger } from './logger.interface.js';
17
-
18
- /**
19
- * Logger implementation using ink and addLog from @poetora/previewing
20
- * Provides consistent output with the preview server's logging system
21
- */
22
- export class ConsoleLogger implements ILogger {
23
- info(message: string): void {
24
- addLog(React.createElement(InfoLog, { message }));
25
- }
26
-
27
- success(message: string): void {
28
- addLog(React.createElement(SuccessLog, { message }));
29
- }
30
-
31
- error(message: string): void {
32
- addLog(React.createElement(ErrorLog, { message }));
33
- }
34
-
35
- warn(message: string): void {
36
- addLog(React.createElement(WarningLog, { message }));
37
- }
38
-
39
- spinner(message: string): LoggerSpinner {
40
- // Immediately add spinner log
41
- addLog(React.createElement(SpinnerLog, { message }));
42
- return new InkSpinner();
43
- }
44
-
45
- log(message: string): void {
46
- addLog(React.createElement(Text, {}, message));
47
- }
48
-
49
- /**
50
- * Log with custom color
51
- */
52
- logColor(
53
- message: string,
54
- color: 'green' | 'red' | 'yellow' | 'blue' | 'cyan' | 'magenta' | 'gray'
55
- ): void {
56
- addLog(React.createElement(Text, { color }, message));
57
- }
58
-
59
- /**
60
- * Log bold text
61
- */
62
- logBold(message: string, color?: 'green' | 'red' | 'yellow' | 'blue' | 'cyan' | 'magenta'): void {
63
- addLog(React.createElement(Text, { bold: true, color }, message));
64
- }
65
-
66
- /**
67
- * Log a separator line
68
- */
69
- logSeparator(): void {
70
- addLog(React.createElement(Text, { color: 'gray' }, '─'.repeat(50)));
71
- }
72
-
73
- /**
74
- * Log an empty line
75
- */
76
- logNewLine(): void {
77
- addLog(React.createElement(EmptyLineLog));
78
- }
79
-
80
- /**
81
- * Log a section header
82
- */
83
- logHeader(message: string): void {
84
- this.logNewLine();
85
- addLog(React.createElement(Text, { bold: true, color: 'cyan' }, message));
86
- this.logNewLine();
87
- }
88
-
89
- /**
90
- * Highlight text (typically numbers) with yellow color
91
- * Note: Returns styled text string for embedding in messages
92
- */
93
- highlight(text: string): string {
94
- return chalk.yellow(text);
95
- }
96
- }
97
-
98
- /**
99
- * Spinner implementation for ink-based logging
100
- * Note: In ink/React rendering model, spinners are added as logs
101
- * and don't need explicit start/stop/succeed/fail methods
102
- */
103
- class InkSpinner implements LoggerSpinner {
104
- start(): void {
105
- // No-op: spinner already added to log stream
106
- }
107
-
108
- stop(): void {
109
- // No-op: will be replaced by next log
110
- }
111
-
112
- succeed(message?: string): void {
113
- if (message) {
114
- addLog(React.createElement(SuccessLog, { message }));
115
- }
116
- }
117
-
118
- fail(message?: string): void {
119
- if (message) {
120
- addLog(React.createElement(ErrorLog, { message }));
121
- }
122
- }
123
- }
@@ -1,2 +0,0 @@
1
- export * from './console-logger.js';
2
- export * from './logger.interface.js';
@@ -1,70 +0,0 @@
1
- import type { LoggerSpinner } from '../types/index.js';
2
-
3
- /**
4
- * Logger interface for CLI output
5
- * Provides rich colored output capabilities
6
- */
7
- export interface ILogger {
8
- /**
9
- * Log info message (blue with ℹ icon)
10
- */
11
- info(message: string): void;
12
-
13
- /**
14
- * Log success message (green with ✓ icon)
15
- */
16
- success(message: string): void;
17
-
18
- /**
19
- * Log error message (red with ✗ icon)
20
- */
21
- error(message: string): void;
22
-
23
- /**
24
- * Log warning message (yellow with ⚠ icon)
25
- */
26
- warn(message: string): void;
27
-
28
- /**
29
- * Create a spinner for long-running operations
30
- */
31
- spinner(message: string): LoggerSpinner;
32
-
33
- /**
34
- * Log plain message without formatting
35
- */
36
- log(message: string): void;
37
-
38
- /**
39
- * Log with custom color
40
- */
41
- logColor(
42
- message: string,
43
- color: 'green' | 'red' | 'yellow' | 'blue' | 'cyan' | 'magenta' | 'gray'
44
- ): void;
45
-
46
- /**
47
- * Log bold text
48
- */
49
- logBold(message: string, color?: 'green' | 'red' | 'yellow' | 'blue' | 'cyan' | 'magenta'): void;
50
-
51
- /**
52
- * Log a separator line
53
- */
54
- logSeparator(): void;
55
-
56
- /**
57
- * Log an empty line
58
- */
59
- logNewLine(): void;
60
-
61
- /**
62
- * Log a section header
63
- */
64
- logHeader(message: string): void;
65
-
66
- /**
67
- * Highlight text (typically numbers) in a different color
68
- */
69
- highlight?(text: string): string;
70
- }
@@ -1,17 +0,0 @@
1
- {
2
- "extends": "./tsconfig.json",
3
- "include": ["src/**/*"],
4
- "compilerOptions": {
5
- "noEmit": false,
6
- "outDir": "./bin",
7
- "skipLibCheck": true,
8
- "noUnusedLocals": false,
9
- "noUnusedParameters": false,
10
- "sourceMap": false,
11
- "inlineSourceMap": false,
12
- "declaration": true,
13
- "declarationMap": false,
14
- "inlineSources": false
15
- },
16
- "exclude": ["__tests__", "**/__tests__", "**/*.test.ts", "**/*.spec.ts"]
17
- }
package/tsconfig.json DELETED
@@ -1,21 +0,0 @@
1
- {
2
- "extends": "../../tsconfig.json",
3
- "compilerOptions": {
4
- "outDir": "./bin",
5
- "baseUrl": "./src",
6
- "paths": {
7
- "@/*": ["*"]
8
- },
9
- "sourceMap": false,
10
- "removeComments": true,
11
- "preserveConstEnums": true,
12
- "types": ["vitest/globals"],
13
- "jsx": "react-jsx",
14
- "jsxImportSource": "react",
15
- "allowJs": true,
16
- "resolveJsonModule": true,
17
- "verbatimModuleSyntax": false,
18
- "noImplicitReturns": false
19
- },
20
- "include": ["src/**/*.ts", "src/**/*.tsx", "__tests__/**/*.ts"]
21
- }
package/vitest.config.ts DELETED
@@ -1,8 +0,0 @@
1
- import { defineConfig } from 'vitest/config';
2
-
3
- export default defineConfig({
4
- test: {
5
- globals: true,
6
- environment: 'node',
7
- },
8
- });