@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,139 +0,0 @@
1
- import { beforeEach, describe, expect, it, vi } from 'vitest';
2
- import { CliError, ValidationError } from '../../errors/index.js';
3
- import type { ILogger } from '../../utils/index.js';
4
- import { BaseCommand } from '../base.command.js';
5
-
6
- // Test command implementation
7
- class TestCommand extends BaseCommand {
8
- readonly name = 'test';
9
- readonly description = 'Test command';
10
-
11
- public validateCalled = false;
12
- public executeCalled = false;
13
-
14
- protected override async validate(options: { value: string }): Promise<void> {
15
- this.validateCalled = true;
16
- if (!options.value) {
17
- throw new ValidationError('value is required');
18
- }
19
- }
20
-
21
- protected override async execute(options: { value: string }): Promise<string> {
22
- this.executeCalled = true;
23
- return `executed with ${options.value}`;
24
- }
25
- }
26
-
27
- describe('BaseCommand', () => {
28
- let mockLogger: ILogger;
29
- let command: TestCommand;
30
-
31
- beforeEach(() => {
32
- mockLogger = {
33
- info: vi.fn(),
34
- success: vi.fn(),
35
- error: vi.fn(),
36
- warn: vi.fn(),
37
- log: vi.fn(),
38
- spinner: vi.fn(),
39
- logColor: vi.fn(),
40
- logBold: vi.fn(),
41
- logSeparator: vi.fn(),
42
- logNewLine: vi.fn(),
43
- logHeader: vi.fn(),
44
- };
45
- command = new TestCommand(mockLogger);
46
- });
47
-
48
- describe('run', () => {
49
- it('should execute command successfully', async () => {
50
- const result = await command.run({ value: 'test' });
51
-
52
- expect(command.validateCalled).toBe(true);
53
- expect(command.executeCalled).toBe(true);
54
- expect(result).toBe('executed with test');
55
- });
56
-
57
- it('should validate before execute', async () => {
58
- const callOrder: string[] = [];
59
-
60
- // Use type assertion to bypass protected access for testing
61
- (command as unknown as { validate: typeof command.validate }).validate = vi.fn(async () => {
62
- callOrder.push('validate');
63
- });
64
- (command as unknown as { execute: typeof command.execute }).execute = vi.fn(async () => {
65
- callOrder.push('execute');
66
- return 'result';
67
- });
68
-
69
- await command.run({ value: 'test' });
70
-
71
- expect(callOrder).toEqual(['validate', 'execute']);
72
- });
73
-
74
- it('should handle validation errors', async () => {
75
- await expect(command.run({ value: '' })).rejects.toThrow(ValidationError);
76
-
77
- expect(command.validateCalled).toBe(true);
78
- expect(command.executeCalled).toBe(false);
79
- expect(mockLogger.error).toHaveBeenCalledWith('value is required');
80
- });
81
-
82
- it('should handle execution errors', async () => {
83
- (command as unknown as { execute: typeof command.execute }).execute = vi
84
- .fn()
85
- .mockRejectedValue(new Error('execution failed'));
86
-
87
- await expect(command.run({ value: 'test' })).rejects.toThrow('execution failed');
88
-
89
- expect(mockLogger.error).toHaveBeenCalledWith('execution failed');
90
- });
91
-
92
- it('should handle CliError specially', async () => {
93
- const cliError = new CliError('CLI error message', 'TEST_ERROR', 1);
94
- (command as unknown as { execute: typeof command.execute }).execute = vi
95
- .fn()
96
- .mockRejectedValue(cliError);
97
-
98
- await expect(command.run({ value: 'test' })).rejects.toThrow(cliError);
99
-
100
- expect(mockLogger.error).toHaveBeenCalledWith('CLI error message');
101
- });
102
-
103
- it('should handle unknown errors', async () => {
104
- (command as unknown as { execute: typeof command.execute }).execute = vi
105
- .fn()
106
- .mockRejectedValue('string error');
107
-
108
- await expect(command.run({ value: 'test' })).rejects.toBe('string error');
109
-
110
- expect(mockLogger.error).toHaveBeenCalledWith('An unexpected error occurred');
111
- expect(mockLogger.logColor).toHaveBeenCalledWith('string error', 'gray');
112
- });
113
-
114
- it('should show stack trace in debug mode', async () => {
115
- const originalDebug = process.env.DEBUG;
116
- process.env.DEBUG = 'true';
117
-
118
- const error = new Error('test error');
119
- (command as unknown as { execute: typeof command.execute }).execute = vi
120
- .fn()
121
- .mockRejectedValue(error);
122
-
123
- await expect(command.run({ value: 'test' })).rejects.toThrow(error);
124
-
125
- expect(mockLogger.logColor).toHaveBeenCalledWith(error.stack ?? '', 'gray');
126
- process.env.DEBUG = originalDebug;
127
- });
128
- });
129
-
130
- describe('command metadata', () => {
131
- it('should have name property', () => {
132
- expect(command.name).toBe('test');
133
- });
134
-
135
- it('should have description property', () => {
136
- expect(command.description).toBe('Test command');
137
- });
138
- });
139
- });
@@ -1,241 +0,0 @@
1
- import * as previewing from '@poetora/previewing';
2
- import { beforeEach, describe, expect, it, vi } from 'vitest';
3
- import { InvalidEnvironmentError } from '../../errors/index.js';
4
- import type { PortService, VersionService } from '../../services/index.js';
5
- import type { DevOptions } from '../../types/index.js';
6
- import type { ILogger } from '../../utils/index.js';
7
- import { DevCommand } from '../dev.command.js';
8
-
9
- vi.mock('@poetora/previewing', async () => {
10
- const actual = await vi.importActual<typeof import('@poetora/previewing')>('@poetora/previewing');
11
- return {
12
- ...actual,
13
- dev: vi.fn(),
14
- };
15
- });
16
-
17
- describe('DevCommand', () => {
18
- let mockLogger: ILogger;
19
- let mockVersionService: VersionService;
20
- let mockPortService: PortService;
21
- let command: DevCommand;
22
- const devSpy = vi.mocked(previewing.dev);
23
-
24
- beforeEach(() => {
25
- mockLogger = {
26
- info: vi.fn(),
27
- success: vi.fn(),
28
- error: vi.fn(),
29
- warn: vi.fn(),
30
- log: vi.fn(),
31
- spinner: vi.fn(),
32
- logColor: vi.fn(),
33
- logBold: vi.fn(),
34
- logSeparator: vi.fn(),
35
- logNewLine: vi.fn(),
36
- logHeader: vi.fn(),
37
- };
38
-
39
- mockVersionService = {
40
- checkNodeVersion: vi.fn(),
41
- getCliVersion: vi.fn(),
42
- parseNodeVersion: vi.fn(),
43
- getClientVersion: vi.fn(),
44
- getVersions: vi.fn(),
45
- getLatestCliVersion: vi.fn(),
46
- isVersionUpToDate: vi.fn(),
47
- validateNodeVersion: vi.fn(),
48
- } as unknown as VersionService;
49
-
50
- mockPortService = {
51
- findAvailablePort: vi.fn(),
52
- } as unknown as PortService;
53
-
54
- command = new DevCommand(mockLogger, mockVersionService, mockPortService, 'poet');
55
-
56
- vi.clearAllMocks();
57
- });
58
-
59
- describe('validate', () => {
60
- it('should pass validation for supported Node version', async () => {
61
- vi.mocked(mockVersionService.checkNodeVersion).mockReturnValue({
62
- isValid: true,
63
- hasWarning: false,
64
- });
65
-
66
- await expect(command.validate({} as DevOptions)).resolves.not.toThrow();
67
-
68
- expect(mockVersionService.checkNodeVersion).toHaveBeenCalled();
69
- });
70
-
71
- it('should show warning for below recommended version', async () => {
72
- vi.mocked(mockVersionService.checkNodeVersion).mockReturnValue({
73
- isValid: true,
74
- hasWarning: true,
75
- message: 'Node.js 20.17.0 recommended',
76
- });
77
-
78
- await command.validate({} as DevOptions);
79
-
80
- expect(mockLogger.warn).toHaveBeenCalledWith('Node.js 20.17.0 recommended');
81
- });
82
-
83
- it('should throw error for unsupported Node version', async () => {
84
- vi.mocked(mockVersionService.checkNodeVersion).mockReturnValue({
85
- isValid: false,
86
- hasWarning: false,
87
- message: 'Node.js 18.0.0 or higher required',
88
- });
89
-
90
- await expect(command.validate({} as DevOptions)).rejects.toThrow(InvalidEnvironmentError);
91
- });
92
- });
93
-
94
- describe('execute', () => {
95
- it('should start dev server with default options', async () => {
96
- vi.mocked(mockPortService.findAvailablePort).mockResolvedValue(3000);
97
- vi.mocked(mockVersionService.getCliVersion).mockReturnValue('1.0.0');
98
- devSpy.mockResolvedValue(undefined);
99
-
100
- const options: DevOptions = {};
101
-
102
- await command.execute(options);
103
-
104
- expect(mockPortService.findAvailablePort).toHaveBeenCalledWith(undefined);
105
- expect(mockVersionService.getCliVersion).toHaveBeenCalled();
106
- expect(devSpy).toHaveBeenCalledWith({
107
- _: [],
108
- $0: 'poet',
109
- port: 3000,
110
- open: true,
111
- localSchema: false,
112
- clientVersion: undefined,
113
- groups: undefined,
114
- disableOpenapi: false,
115
- packageName: 'poet',
116
- cliVersion: '1.0.0',
117
- });
118
- });
119
-
120
- it('should use specified port', async () => {
121
- vi.mocked(mockPortService.findAvailablePort).mockResolvedValue(5000);
122
- vi.mocked(mockVersionService.getCliVersion).mockReturnValue('1.0.0');
123
- devSpy.mockResolvedValue(undefined);
124
-
125
- const options: DevOptions = { port: 5000 };
126
-
127
- await command.execute(options);
128
-
129
- expect(mockPortService.findAvailablePort).toHaveBeenCalledWith(5000);
130
- expect(devSpy).toHaveBeenCalledWith(
131
- expect.objectContaining({
132
- port: 5000,
133
- })
134
- );
135
- });
136
-
137
- it('should respect open option', async () => {
138
- vi.mocked(mockPortService.findAvailablePort).mockResolvedValue(3000);
139
- vi.mocked(mockVersionService.getCliVersion).mockReturnValue('1.0.0');
140
- devSpy.mockResolvedValue(undefined);
141
-
142
- const options: DevOptions = { open: false };
143
-
144
- await command.execute(options);
145
-
146
- expect(devSpy).toHaveBeenCalledWith(
147
- expect.objectContaining({
148
- open: false,
149
- })
150
- );
151
- });
152
-
153
- it('should pass all options correctly', async () => {
154
- vi.mocked(mockPortService.findAvailablePort).mockResolvedValue(4000);
155
- vi.mocked(mockVersionService.getCliVersion).mockReturnValue('2.0.0');
156
- devSpy.mockResolvedValue(undefined);
157
-
158
- const options: DevOptions = {
159
- port: 4000,
160
- open: false,
161
- localSchema: true,
162
- clientVersion: '1.5.0',
163
- groups: ['admin', 'user'],
164
- disableOpenapi: true,
165
- };
166
-
167
- await command.execute(options);
168
-
169
- expect(devSpy).toHaveBeenCalledWith({
170
- _: [],
171
- $0: 'poet',
172
- port: 4000,
173
- open: false,
174
- localSchema: true,
175
- clientVersion: '1.5.0',
176
- groups: ['admin', 'user'],
177
- disableOpenapi: true,
178
- packageName: 'poet',
179
- cliVersion: '2.0.0',
180
- });
181
- });
182
-
183
- it('should handle when port service finds alternative port', async () => {
184
- vi.mocked(mockPortService.findAvailablePort).mockResolvedValue(3001);
185
- vi.mocked(mockVersionService.getCliVersion).mockReturnValue('1.0.0');
186
- devSpy.mockResolvedValue(undefined);
187
-
188
- const options: DevOptions = { port: 3000 };
189
-
190
- await command.execute(options);
191
-
192
- expect(devSpy).toHaveBeenCalledWith(
193
- expect.objectContaining({
194
- port: 3001, // Alternative port found
195
- })
196
- );
197
- });
198
- });
199
-
200
- describe('run (integration)', () => {
201
- it('should execute full flow successfully', async () => {
202
- vi.mocked(mockVersionService.checkNodeVersion).mockReturnValue({
203
- isValid: true,
204
- hasWarning: false,
205
- });
206
- vi.mocked(mockPortService.findAvailablePort).mockResolvedValue(3000);
207
- vi.mocked(mockVersionService.getCliVersion).mockReturnValue('1.0.0');
208
- devSpy.mockResolvedValue(undefined);
209
-
210
- await command.run({ port: 3000 });
211
-
212
- expect(mockVersionService.checkNodeVersion).toHaveBeenCalled();
213
- expect(mockPortService.findAvailablePort).toHaveBeenCalled();
214
- expect(devSpy).toHaveBeenCalled();
215
- });
216
-
217
- it('should fail at validation stage for unsupported Node version', async () => {
218
- vi.mocked(mockVersionService.checkNodeVersion).mockReturnValue({
219
- isValid: false,
220
- hasWarning: false,
221
- message: 'Unsupported Node.js version',
222
- });
223
-
224
- await expect(command.run({})).rejects.toThrow(InvalidEnvironmentError);
225
-
226
- // Should not reach execute stage
227
- expect(mockPortService.findAvailablePort).not.toHaveBeenCalled();
228
- expect(devSpy).not.toHaveBeenCalled();
229
- });
230
- });
231
-
232
- describe('metadata', () => {
233
- it('should have correct name', () => {
234
- expect(command.name).toBe('dev');
235
- });
236
-
237
- it('should have correct description', () => {
238
- expect(command.description).toBe('initialize a local preview environment');
239
- });
240
- });
241
- });
@@ -1,281 +0,0 @@
1
- import { input, select } from '@inquirer/prompts';
2
- import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
3
- import { ValidationError } from '../../errors/index.js';
4
- import type { TemplateService } from '../../services/template.service.js';
5
- import type { InitOptions } from '../../types/index.js';
6
- import type { ILogger } from '../../utils/index.js';
7
- import { InitCommand } from '../init.command.js';
8
-
9
- vi.mock('@inquirer/prompts');
10
-
11
- describe('InitCommand', () => {
12
- let command: InitCommand;
13
- let mockLogger: ILogger;
14
- let mockTemplateService: TemplateService;
15
-
16
- beforeEach(() => {
17
- mockLogger = {
18
- info: vi.fn(),
19
- success: vi.fn(),
20
- error: vi.fn(),
21
- warn: vi.fn(),
22
- spinner: vi.fn().mockReturnValue({
23
- start: vi.fn(),
24
- succeed: vi.fn(),
25
- fail: vi.fn(),
26
- stop: vi.fn(),
27
- }),
28
- log: vi.fn(),
29
- logColor: vi.fn(),
30
- logBold: vi.fn(),
31
- logSeparator: vi.fn(),
32
- logNewLine: vi.fn(),
33
- logHeader: vi.fn(),
34
- };
35
-
36
- mockTemplateService = {
37
- checkDirectory: vi.fn(),
38
- getAvailableThemes: vi.fn(),
39
- installTemplate: vi.fn(),
40
- } as unknown as TemplateService;
41
-
42
- command = new InitCommand(mockLogger, mockTemplateService);
43
- });
44
-
45
- afterEach(() => {
46
- vi.clearAllMocks();
47
- });
48
-
49
- describe('run - empty directory', () => {
50
- beforeEach(() => {
51
- vi.mocked(mockTemplateService.checkDirectory).mockResolvedValue({
52
- exists: true,
53
- hasContents: false,
54
- });
55
-
56
- vi.mocked(mockTemplateService.getAvailableThemes).mockReturnValue(['ora', 'sol']);
57
-
58
- vi.mocked(input).mockResolvedValue('My Project');
59
- vi.mocked(select).mockResolvedValue('ora');
60
- vi.mocked(mockTemplateService.installTemplate).mockResolvedValue(undefined);
61
- });
62
-
63
- it('should install template directly for empty directory', async () => {
64
- const options: InitOptions = {
65
- directory: '.',
66
- };
67
-
68
- await command.run(options);
69
-
70
- expect(mockTemplateService.checkDirectory).toHaveBeenCalledWith('.');
71
- expect(input).toHaveBeenCalled();
72
- expect(select).toHaveBeenCalled();
73
- expect(mockTemplateService.installTemplate).toHaveBeenCalledWith({
74
- directory: '.',
75
- projectName: 'My Project',
76
- theme: 'ora',
77
- });
78
- expect(mockLogger.success).toHaveBeenCalledWith('Documentation Setup!');
79
- });
80
-
81
- it('should use directory name as default project name', async () => {
82
- vi.mocked(input).mockResolvedValue('my-docs');
83
-
84
- const options: InitOptions = {
85
- directory: 'my-docs',
86
- };
87
-
88
- await command.run(options);
89
-
90
- expect(input).toHaveBeenCalledWith({
91
- message: 'Project Name',
92
- default: 'my-docs',
93
- });
94
- });
95
-
96
- it('should use "Poetora" as default for current directory', async () => {
97
- vi.mocked(input).mockResolvedValue('Poetora');
98
-
99
- const options: InitOptions = {
100
- directory: '.',
101
- };
102
-
103
- await command.run(options);
104
-
105
- expect(input).toHaveBeenCalledWith({
106
- message: 'Project Name',
107
- default: 'Poetora',
108
- });
109
- });
110
- });
111
-
112
- describe('run - non-empty directory', () => {
113
- beforeEach(() => {
114
- vi.mocked(mockTemplateService.checkDirectory).mockResolvedValue({
115
- exists: true,
116
- hasContents: true,
117
- });
118
-
119
- vi.mocked(mockTemplateService.getAvailableThemes).mockReturnValue(['quartz']);
120
- vi.mocked(input).mockResolvedValue('My Project');
121
- vi.mocked(mockTemplateService.installTemplate).mockResolvedValue(undefined);
122
- });
123
-
124
- it('should cancel installation when user chooses cancel', async () => {
125
- vi.mocked(select).mockResolvedValueOnce('cancel');
126
-
127
- const options: InitOptions = {
128
- directory: 'existing-dir',
129
- };
130
-
131
- await command.run(options);
132
-
133
- expect(mockLogger.info).toHaveBeenCalledWith('Installation cancelled');
134
- expect(mockTemplateService.installTemplate).not.toHaveBeenCalled();
135
- });
136
-
137
- it('should overwrite when user chooses overwrite', async () => {
138
- vi.mocked(select)
139
- .mockResolvedValueOnce('overwrite') // directory choice
140
- .mockResolvedValueOnce('ora'); // theme choice
141
-
142
- const options: InitOptions = {
143
- directory: 'existing-dir',
144
- };
145
-
146
- await command.run(options);
147
-
148
- expect(mockTemplateService.installTemplate).toHaveBeenCalledWith({
149
- directory: 'existing-dir',
150
- projectName: 'My Project',
151
- theme: 'ora',
152
- });
153
- });
154
-
155
- it('should create subdirectory when user chooses subdir', async () => {
156
- vi.mocked(select)
157
- .mockResolvedValueOnce('subdir') // directory choice
158
- .mockResolvedValueOnce('ora'); // theme choice
159
-
160
- vi.mocked(input)
161
- .mockResolvedValueOnce('docs') // subdirectory name
162
- .mockResolvedValueOnce('My Project'); // project name
163
-
164
- const options: InitOptions = {
165
- directory: '.',
166
- };
167
-
168
- await command.run(options);
169
-
170
- expect(input).toHaveBeenCalledWith({
171
- message: 'Subdirectory name:',
172
- default: 'docs',
173
- });
174
-
175
- expect(mockTemplateService.installTemplate).toHaveBeenCalledWith({
176
- directory: 'docs',
177
- projectName: 'My Project',
178
- theme: 'ora',
179
- });
180
- });
181
-
182
- it('should combine parent dir with subdir when not current directory', async () => {
183
- vi.mocked(select).mockResolvedValueOnce('subdir').mockResolvedValueOnce('ora');
184
-
185
- vi.mocked(input).mockResolvedValueOnce('docs').mockResolvedValueOnce('My Project');
186
-
187
- const options: InitOptions = {
188
- directory: 'parent',
189
- };
190
-
191
- await command.run(options);
192
-
193
- expect(mockTemplateService.installTemplate).toHaveBeenCalledWith({
194
- directory: 'parent/docs',
195
- projectName: 'My Project',
196
- theme: 'ora',
197
- });
198
- });
199
-
200
- it('should throw ValidationError for empty subdirectory name', async () => {
201
- vi.mocked(select).mockResolvedValue('subdir');
202
- vi.mocked(input).mockResolvedValue(' '); // empty with spaces
203
-
204
- const options: InitOptions = {
205
- directory: '.',
206
- };
207
-
208
- await expect(command.run(options)).rejects.toThrow(ValidationError);
209
- await expect(command.run(options)).rejects.toThrow('Subdirectory name cannot be empty');
210
- });
211
- });
212
-
213
- describe('theme selection', () => {
214
- beforeEach(() => {
215
- vi.mocked(mockTemplateService.checkDirectory).mockResolvedValue({
216
- exists: true,
217
- hasContents: false,
218
- });
219
-
220
- vi.mocked(input).mockResolvedValue('My Project');
221
- vi.mocked(mockTemplateService.installTemplate).mockResolvedValue(undefined);
222
- });
223
-
224
- it('should display all available themes', async () => {
225
- vi.mocked(mockTemplateService.getAvailableThemes).mockReturnValue(['ora', 'sol', 'custom']);
226
-
227
- vi.mocked(select).mockResolvedValue('sol');
228
-
229
- const options: InitOptions = {
230
- directory: '.',
231
- };
232
-
233
- await command.run(options);
234
-
235
- expect(select).toHaveBeenCalledWith({
236
- message: 'Theme',
237
- choices: [
238
- { name: 'ora', value: 'ora' },
239
- { name: 'sol', value: 'sol' },
240
- { name: 'custom', value: 'custom' },
241
- ],
242
- });
243
- });
244
- });
245
-
246
- describe('onboarding message', () => {
247
- beforeEach(() => {
248
- vi.mocked(mockTemplateService.checkDirectory).mockResolvedValue({
249
- exists: true,
250
- hasContents: false,
251
- });
252
-
253
- vi.mocked(mockTemplateService.getAvailableThemes).mockReturnValue(['ora']);
254
- vi.mocked(input).mockResolvedValue('My Project');
255
- vi.mocked(select).mockResolvedValue('ora');
256
- vi.mocked(mockTemplateService.installTemplate).mockResolvedValue(undefined);
257
- });
258
-
259
- it('should show cd command for subdirectory installation', async () => {
260
- const options: InitOptions = {
261
- directory: 'docs',
262
- };
263
-
264
- await command.run(options);
265
-
266
- expect(mockLogger.log).toHaveBeenCalledWith(' cd docs');
267
- expect(mockLogger.log).toHaveBeenCalledWith(' poet dev');
268
- });
269
-
270
- it('should not show cd command for current directory', async () => {
271
- const options: InitOptions = {
272
- directory: '.',
273
- };
274
-
275
- await command.run(options);
276
-
277
- expect(mockLogger.log).not.toHaveBeenCalledWith(expect.stringContaining('cd'));
278
- expect(mockLogger.log).toHaveBeenCalledWith(' poet dev');
279
- });
280
- });
281
- });
@@ -1,20 +0,0 @@
1
- import { cli } from '../../cli';
2
-
3
- /**
4
- * Programmatically set arguments and execute the CLI script
5
- *
6
- * @param {...string} args - Additional command arguments.
7
- */
8
- export async function runCommand(...args: string[]) {
9
- process.argv = ['node', 'cli', ...args];
10
- return cli({ packageName: 'poet' });
11
- }
12
-
13
- export const mockValidOpenApiDocument = {
14
- openapi: '3.0.0',
15
- info: {
16
- title: 'Test API',
17
- version: '1.0.0',
18
- },
19
- components: {},
20
- };