Skip to content

Commit e5f9719

Browse files
committed
fix(create-cli): update ci provider options and their validation
1 parent ee84cbb commit e5f9719

File tree

4 files changed

+22
-15
lines changed

4 files changed

+22
-15
lines changed

packages/create-cli/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ const argv = await yargs(hideBin(process.argv))
4343
.option('ci', {
4444
type: 'string',
4545
choices: CI_PROVIDERS,
46-
describe: 'CI/CD integration (github, gitlab, or skip)',
46+
describe: 'CI/CD integration (github, gitlab, or none)',
4747
})
4848
.check(parsed => {
4949
validatePluginSlugs(bindings, parsed.plugins);

packages/create-cli/src/lib/setup/ci.ts

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
import { select } from '@inquirer/prompts';
22
import { logger } from '@code-pushup/utils';
3-
import type { CiProvider, CliArgs, ConfigContext, Tree } from './types.js';
3+
import {
4+
CI_PROVIDERS,
5+
type CiProvider,
6+
type CliArgs,
7+
type ConfigContext,
8+
type Tree,
9+
} from './types.js';
410

511
const GITHUB_WORKFLOW_PATH = '.github/workflows/code-pushup.yml';
612
const GITLAB_CONFIG_PATH = '.gitlab-ci.yml';
@@ -11,16 +17,16 @@ export async function promptCiProvider(cliArgs: CliArgs): Promise<CiProvider> {
1117
return cliArgs.ci;
1218
}
1319
if (cliArgs.yes) {
14-
return 'skip';
20+
return 'none';
1521
}
1622
return select<CiProvider>({
1723
message: 'CI/CD integration:',
1824
choices: [
1925
{ name: 'GitHub Actions', value: 'github' },
2026
{ name: 'GitLab CI/CD', value: 'gitlab' },
21-
{ name: 'Skip', value: 'skip' },
27+
{ name: 'none', value: 'none' },
2228
],
23-
default: 'skip',
29+
default: 'none',
2430
});
2531
}
2632

@@ -36,7 +42,7 @@ export async function resolveCi(
3642
case 'gitlab':
3743
await writeGitLabConfig(tree);
3844
break;
39-
case 'skip':
45+
case 'none':
4046
break;
4147
}
4248
}
@@ -118,5 +124,6 @@ async function resolveGitLabFilePath(tree: Tree): Promise<string> {
118124
}
119125

120126
function isCiProvider(value: string | undefined): value is CiProvider {
121-
return value === 'github' || value === 'gitlab' || value === 'skip';
127+
const validValues: readonly string[] = CI_PROVIDERS;
128+
return value != null && validValues.includes(value);
122129
}

packages/create-cli/src/lib/setup/ci.unit.test.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,16 @@ vi.mock('@inquirer/prompts', () => ({
1111
}));
1212

1313
describe('promptCiProvider', () => {
14-
it.each(['github', 'gitlab', 'skip'] as const)(
14+
it.each(['github', 'gitlab', 'none'] as const)(
1515
'should return %j when --ci %s is provided',
1616
async ci => {
1717
await expect(promptCiProvider({ ci })).resolves.toBe(ci);
1818
expect(select).not.toHaveBeenCalled();
1919
},
2020
);
2121

22-
it('should return "skip" when --yes is provided', async () => {
23-
await expect(promptCiProvider({ yes: true })).resolves.toBe('skip');
22+
it('should return "none" when --yes is provided', async () => {
23+
await expect(promptCiProvider({ yes: true })).resolves.toBe('none');
2424
expect(select).not.toHaveBeenCalled();
2525
});
2626

@@ -31,7 +31,7 @@ describe('promptCiProvider', () => {
3131
expect(select).toHaveBeenCalledWith(
3232
expect.objectContaining({
3333
message: 'CI/CD integration:',
34-
default: 'skip',
34+
default: 'none',
3535
}),
3636
);
3737
});
@@ -154,12 +154,12 @@ describe('resolveCi', () => {
154154
});
155155
});
156156

157-
describe('skip', () => {
158-
it('should make no changes when provider is skip', async () => {
157+
describe('none', () => {
158+
it('should make no changes when provider is none', async () => {
159159
vol.fromJSON({ 'package.json': '{}' }, MEMFS_VOLUME);
160160
const tree = createTree(MEMFS_VOLUME);
161161

162-
await resolveCi(tree, 'skip', STANDALONE_CONTEXT);
162+
await resolveCi(tree, 'none', STANDALONE_CONTEXT);
163163

164164
expect(tree.listChanges()).toStrictEqual([]);
165165
});

packages/create-cli/src/lib/setup/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { PluginMeta } from '@code-pushup/models';
22
import type { MonorepoTool } from '@code-pushup/utils';
33

4-
export const CI_PROVIDERS = ['github', 'gitlab', 'skip'] as const;
4+
export const CI_PROVIDERS = ['github', 'gitlab', 'none'] as const;
55
export type CiProvider = (typeof CI_PROVIDERS)[number];
66

77
export const CONFIG_FILE_FORMATS = ['ts', 'js', 'mjs'] as const;

0 commit comments

Comments
 (0)