Skip to content

Commit f031e8c

Browse files
committed
chore(cli): update envCode for consistency
1 parent 5408992 commit f031e8c

5 files changed

Lines changed: 28 additions & 28 deletions

File tree

packages/cli/src/__tests__/lib/TemplateManager.test.ts

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ This is the prompt content.`;
325325

326326
describe('setupMultipleEnvironments', () => {
327327
it('should setup multiple environments successfully', async () => {
328-
const envIds: EnvironmentCode[] = ['cursor', 'gemini'];
328+
const envCodes: EnvironmentCode[] = ['cursor', 'gemini'];
329329
const cursorEnv = {
330330
code: 'cursor',
331331
name: 'Cursor',
@@ -352,7 +352,7 @@ This is the prompt content.`;
352352

353353
(templateManager as any).setupSingleEnvironment = mockSetupSingleEnvironment;
354354

355-
const result = await templateManager.setupMultipleEnvironments(envIds);
355+
const result = await templateManager.setupMultipleEnvironments(envCodes);
356356

357357
expect(mockGetEnvironment).toHaveBeenCalledWith('cursor');
358358
expect(mockGetEnvironment).toHaveBeenCalledWith('gemini');
@@ -366,7 +366,7 @@ This is the prompt content.`;
366366
});
367367

368368
it('should skip invalid environments and continue with valid ones', async () => {
369-
const envIds: EnvironmentCode[] = ['cursor', 'invalid' as any, 'gemini'];
369+
const envCodes: EnvironmentCode[] = ['cursor', 'invalid' as any, 'gemini'];
370370
const cursorEnv = {
371371
code: 'cursor',
372372
name: 'Cursor',
@@ -393,7 +393,7 @@ This is the prompt content.`;
393393

394394
(templateManager as any).setupSingleEnvironment = mockSetupSingleEnvironment;
395395

396-
const result = await templateManager.setupMultipleEnvironments(envIds);
396+
const result = await templateManager.setupMultipleEnvironments(envCodes);
397397

398398
expect(mockUi.warning).toHaveBeenCalledWith("Environment 'invalid' not found, skipping");
399399
expect(result).toEqual([
@@ -403,7 +403,7 @@ This is the prompt content.`;
403403
});
404404

405405
it('should throw error when setupSingleEnvironment fails', async () => {
406-
const envIds: EnvironmentCode[] = ['cursor'];
406+
const envCodes: EnvironmentCode[] = ['cursor'];
407407
const cursorEnv = {
408408
code: 'cursor',
409409
name: 'Cursor',
@@ -416,26 +416,26 @@ This is the prompt content.`;
416416
const mockSetupSingleEnvironment = jest.fn().mockRejectedValue(new Error('Setup failed'));
417417
(templateManager as any).setupSingleEnvironment = mockSetupSingleEnvironment;
418418

419-
await expect(templateManager.setupMultipleEnvironments(envIds)).rejects.toThrow('Setup failed');
419+
await expect(templateManager.setupMultipleEnvironments(envCodes)).rejects.toThrow('Setup failed');
420420

421421
expect(mockUi.error).toHaveBeenCalledWith("Error setting up environment 'Cursor': Setup failed");
422422
});
423423
});
424424

425425
describe('checkEnvironmentExists', () => {
426426
it('should return false when environment does not exist', async () => {
427-
const envId: EnvironmentCode = 'cursor';
427+
const envCode: EnvironmentCode = 'cursor';
428428

429429
mockGetEnvironment.mockReturnValue(undefined);
430430

431-
const result = await templateManager.checkEnvironmentExists(envId);
431+
const result = await templateManager.checkEnvironmentExists(envCode);
432432

433-
expect(mockGetEnvironment).toHaveBeenCalledWith(envId);
433+
expect(mockGetEnvironment).toHaveBeenCalledWith(envCode);
434434
expect(result).toBe(false);
435435
});
436436

437437
it('should return false when only context file exists', async () => {
438-
const envId: EnvironmentCode = 'cursor';
438+
const envCode: EnvironmentCode = 'cursor';
439439
const env = {
440440
code: 'cursor',
441441
name: 'Cursor',
@@ -447,7 +447,7 @@ This is the prompt content.`;
447447

448448
(mockFs.pathExists as any).mockResolvedValueOnce(false); // command dir doesn't exist
449449

450-
const result = await templateManager.checkEnvironmentExists(envId);
450+
const result = await templateManager.checkEnvironmentExists(envCode);
451451

452452
expect(mockFs.pathExists).toHaveBeenCalledWith(
453453
path.join(templateManager['targetDir'], env.commandPath)
@@ -456,7 +456,7 @@ This is the prompt content.`;
456456
});
457457

458458
it('should return true when command directory exists', async () => {
459-
const envId: EnvironmentCode = 'cursor';
459+
const envCode: EnvironmentCode = 'cursor';
460460
const env = {
461461
code: 'cursor',
462462
name: 'Cursor',
@@ -468,13 +468,13 @@ This is the prompt content.`;
468468

469469
(mockFs.pathExists as any).mockResolvedValueOnce(true); // command dir exists
470470

471-
const result = await templateManager.checkEnvironmentExists(envId);
471+
const result = await templateManager.checkEnvironmentExists(envCode);
472472

473473
expect(result).toBe(true);
474474
});
475475

476476
it('should return false when command directory does not exist', async () => {
477-
const envId: EnvironmentCode = 'cursor';
477+
const envCode: EnvironmentCode = 'cursor';
478478
const env = {
479479
code: 'cursor',
480480
name: 'Cursor',
@@ -486,7 +486,7 @@ This is the prompt content.`;
486486

487487
(mockFs.pathExists as any).mockResolvedValueOnce(false); // command dir doesn't exist
488488

489-
const result = await templateManager.checkEnvironmentExists(envId);
489+
const result = await templateManager.checkEnvironmentExists(envCode);
490490

491491
expect(result).toBe(false);
492492
});

packages/cli/src/commands/init.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -206,9 +206,9 @@ export async function initCommand(options: InitOptions) {
206206
}
207207
}
208208
const existingEnvironments: EnvironmentCode[] = [];
209-
for (const envId of selectedEnvironments) {
210-
if (await templateManager.checkEnvironmentExists(envId)) {
211-
existingEnvironments.push(envId);
209+
for (const envCode of selectedEnvironments) {
210+
if (await templateManager.checkEnvironmentExists(envCode)) {
211+
existingEnvironments.push(envCode);
212212
}
213213
}
214214

packages/cli/src/lib/Config.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,9 @@ export class ConfigManager {
124124
return this.update({ environments });
125125
}
126126

127-
async hasEnvironment(envId: EnvironmentCode): Promise<boolean> {
127+
async hasEnvironment(envCode: EnvironmentCode): Promise<boolean> {
128128
const environments = await this.getEnvironments();
129-
return environments.includes(envId);
129+
return environments.includes(envCode);
130130
}
131131

132132
async addSkill(skill: ConfigSkill): Promise<DevKitConfig> {

packages/cli/src/lib/EnvironmentSelector.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ export class EnvironmentSelector {
7878
}
7979

8080
ui.text("\nSelected environments:");
81-
selected.forEach((envId) => {
82-
ui.text(` ${getEnvironmentDisplayName(envId)}`);
81+
selected.forEach((envCode) => {
82+
ui.text(` ${getEnvironmentDisplayName(envCode)}`);
8383
});
8484
ui.breakline();
8585
}

packages/cli/src/lib/TemplateManager.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,14 @@ export class TemplateManager {
4444
}
4545

4646
async setupMultipleEnvironments(
47-
environmentIds: EnvironmentCode[]
47+
environmentCodes: EnvironmentCode[]
4848
): Promise<string[]> {
4949
const copiedFiles: string[] = [];
5050

51-
for (const envId of environmentIds) {
52-
const env = getEnvironment(envId);
51+
for (const envCode of environmentCodes) {
52+
const env = getEnvironment(envCode);
5353
if (!env) {
54-
ui.warning(`Environment '${envId}' not found, skipping`);
54+
ui.warning(`Environment '${envCode}' not found, skipping`);
5555
continue;
5656
}
5757

@@ -67,8 +67,8 @@ export class TemplateManager {
6767
return copiedFiles;
6868
}
6969

70-
async checkEnvironmentExists(envId: EnvironmentCode): Promise<boolean> {
71-
const env = getEnvironment(envId);
70+
async checkEnvironmentExists(envCode: EnvironmentCode): Promise<boolean> {
71+
const env = getEnvironment(envCode);
7272

7373
if (!env) {
7474
return false;

0 commit comments

Comments
 (0)