@poetora/cli 0.1.5 → 0.1.7

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.
@@ -1,4 +1,4 @@
1
1
 
2
- > @poetora/cli@0.1.4 build /home/runner/work/poetora/poetora/packages/cli
2
+ > @poetora/cli@0.1.6 build /home/runner/work/poetora/poetora/packages/cli
3
3
  > tsc --project tsconfig.build.json
4
4
 
@@ -25,10 +25,9 @@ export class CliBuilder {
25
25
  const checkCommand = new CheckCommand(this.logger, openApiCheckService, accessibilityCheckService, this.packageName);
26
26
  const linkCommand = new LinkCommand(this.logger, linkService, this.packageName);
27
27
  const updateCommand = new UpdateCommand(this.logger, updateService, this.packageName);
28
- const cliVersion = versionService.getCliVersion() || '0.0.0';
29
28
  return (yargs(hideBin(process.argv))
30
29
  .scriptName(this.packageName)
31
- .version(cliVersion)
30
+ .version()
32
31
  .middleware(checkNodeVersion)
33
32
  .middleware(suppressConsoleWarnings)
34
33
  .command('dev', 'initialize a local preview environment', (yargs) => yargs
@@ -55,15 +55,15 @@ export class VersionService {
55
55
  };
56
56
  }
57
57
  getCliVersion() {
58
- if (process.env.CLI_TEST_MODE === 'true') {
59
- return 'test-cli';
60
- }
61
58
  const y = yargs();
62
59
  let version;
63
60
  y.showVersion((v) => {
64
61
  version = v;
65
62
  return false;
66
63
  });
64
+ if (process.env.CLI_TEST_MODE === 'true') {
65
+ return 'test-cli';
66
+ }
67
67
  if (version === 'unknown') {
68
68
  version = LOCAL_LINKED_CLI_VERSION;
69
69
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@poetora/cli",
3
- "version": "0.1.5",
3
+ "version": "0.1.7",
4
4
  "description": "The CLI for Poetora documentation Engine",
5
5
  "engines": {
6
6
  "node": ">=18.0.0"
@@ -32,7 +32,7 @@
32
32
  "color": "4.2.3",
33
33
  "detect-port": "1.5.1",
34
34
  "front-matter": "4.0.2",
35
- "fs-extra": "11.2.0",
35
+ "fs-extra": "11.1.0",
36
36
  "ink": "6.3.0",
37
37
  "inquirer": "12.3.0",
38
38
  "js-yaml": "4.1.0",
@@ -43,7 +43,7 @@
43
43
  "yargs": "17.7.1",
44
44
  "@poetora/link-rot": "0.0.7",
45
45
  "@poetora/prebuild": "0.1.6",
46
- "@poetora/previewing": "0.1.6",
46
+ "@poetora/previewing": "0.1.8",
47
47
  "@poetora/shared": "0.1.6",
48
48
  "@poetora/validation": "0.1.6"
49
49
  },
@@ -58,13 +58,10 @@ export class CliBuilder {
58
58
  const linkCommand = new LinkCommand(this.logger, linkService, this.packageName);
59
59
  const updateCommand = new UpdateCommand(this.logger, updateService, this.packageName);
60
60
 
61
- // Get CLI version for yargs
62
- const cliVersion = versionService.getCliVersion() || '0.0.0';
63
-
64
61
  return (
65
62
  yargs(hideBin(process.argv))
66
63
  .scriptName(this.packageName)
67
- .version(cliVersion) // Explicitly set version to fix "unknown" issue
64
+ .version()
68
65
  .middleware(checkNodeVersion) // Check Node.js version before any command
69
66
  .middleware(suppressConsoleWarnings) // Suppress known console warnings
70
67
  // Dev command
@@ -252,7 +249,7 @@ export class CliBuilder {
252
249
  () => undefined,
253
250
  async () => {
254
251
  const versions = versionService.getVersions();
255
- // Use chalk for consistent formatting (mintlify uses ink Text, we use chalk)
252
+ // Use chalk for consistent formatting
256
253
  console.log(`${chalk.bold.green('cli version')} ${versions.cli}`);
257
254
  console.log(`${chalk.bold.green('client version')} ${versions.client}`);
258
255
  process.exit(0);
@@ -261,6 +258,8 @@ export class CliBuilder {
261
258
  // Error handling
262
259
  .strictCommands()
263
260
  .demandCommand(1, 'unknown command. see above for the list of supported commands.')
261
+
262
+ // Alias option flags --help = -h, default --version = -v
264
263
  .alias('h', 'help')
265
264
  .alias('v', 'version')
266
265
  );
package/src/cli.ts CHANGED
@@ -10,7 +10,7 @@ export interface CliOptions {
10
10
  }
11
11
 
12
12
  export const cli = (options: CliOptions): void => {
13
- // Initialize ink rendering for logs (like mintlify)
13
+ // Initialize ink rendering for logs
14
14
  render(React.createElement(Logs));
15
15
 
16
16
  const builder = new CliBuilder(options.packageName);
@@ -104,14 +104,11 @@ describe('BaseCommand', () => {
104
104
  (command as unknown as { execute: typeof command.execute }).execute = vi
105
105
  .fn()
106
106
  .mockRejectedValue('string error');
107
- const consoleErrorSpy = vi.spyOn(console, 'error').mockImplementation(() => {});
108
107
 
109
108
  await expect(command.run({ value: 'test' })).rejects.toBe('string error');
110
109
 
111
110
  expect(mockLogger.error).toHaveBeenCalledWith('An unexpected error occurred');
112
- expect(consoleErrorSpy).toHaveBeenCalledWith('string error');
113
-
114
- consoleErrorSpy.mockRestore();
111
+ expect(mockLogger.logColor).toHaveBeenCalledWith('string error', 'gray');
115
112
  });
116
113
 
117
114
  it('should show stack trace in debug mode', async () => {
@@ -122,13 +119,10 @@ describe('BaseCommand', () => {
122
119
  (command as unknown as { execute: typeof command.execute }).execute = vi
123
120
  .fn()
124
121
  .mockRejectedValue(error);
125
- const consoleErrorSpy = vi.spyOn(console, 'error').mockImplementation(() => {});
126
122
 
127
123
  await expect(command.run({ value: 'test' })).rejects.toThrow(error);
128
124
 
129
- expect(consoleErrorSpy).toHaveBeenCalledWith(error.stack);
130
-
131
- consoleErrorSpy.mockRestore();
125
+ expect(mockLogger.logColor).toHaveBeenCalledWith(error.stack ?? '', 'gray');
132
126
  process.env.DEBUG = originalDebug;
133
127
  });
134
128
  });
@@ -83,10 +83,6 @@ export class VersionService {
83
83
  * Get CLI version from package.json
84
84
  */
85
85
  getCliVersion(): string | undefined {
86
- if (process.env.CLI_TEST_MODE === 'true') {
87
- return 'test-cli';
88
- }
89
-
90
86
  const y = yargs();
91
87
  let version: string | undefined;
92
88
 
@@ -95,7 +91,11 @@ export class VersionService {
95
91
  return false;
96
92
  });
97
93
 
98
- // Handle npm link case where version is 'unknown'
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
99
  if (version === 'unknown') {
100
100
  version = LOCAL_LINKED_CLI_VERSION;
101
101
  }
@@ -18,7 +18,6 @@ import type { ILogger } from './logger.interface.js';
18
18
  /**
19
19
  * Logger implementation using ink and addLog from @poetora/previewing
20
20
  * Provides consistent output with the preview server's logging system
21
- * Following mintlify's architecture pattern
22
21
  */
23
22
  export class ConsoleLogger implements ILogger {
24
23
  info(message: string): void {