Skip to content

Commit

Permalink
fix(misc): mark name as required for ci-workflow generator
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxKless committed Jun 22, 2023
1 parent 1e0105f commit dff1177
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"pattern": "^[a-zA-Z].*$"
}
},
"required": ["ci"],
"required": ["ci", "name"],
"presets": []
},
"description": "Generate a CI workflow.",
Expand Down
19 changes: 13 additions & 6 deletions packages/workspace/src/generators/ci-workflow/ci-workflow.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ describe('CI Workflow generator', () => {

it('should generate github CI config', async () => {
setNxCloud(tree);
await ciWorkflowGenerator(tree, { ci: 'github' });
await ciWorkflowGenerator(tree, { ci: 'github', name: 'CI' });

expect(
tree.read('.github/workflows/ci.yml', 'utf-8')
Expand All @@ -37,14 +37,14 @@ describe('CI Workflow generator', () => {

it('should generate circleci CI config', async () => {
setNxCloud(tree);
await ciWorkflowGenerator(tree, { ci: 'circleci' });
await ciWorkflowGenerator(tree, { ci: 'circleci', name: 'CI' });

expect(tree.read('.circleci/config.yml', 'utf-8')).toMatchSnapshot();
});

it('should generate azure CI config', async () => {
setNxCloud(tree);
await ciWorkflowGenerator(tree, { ci: 'azure' });
await ciWorkflowGenerator(tree, { ci: 'azure', name: 'CI' });

expect(tree.read('azure-pipelines.yml', 'utf-8')).toMatchSnapshot();
});
Expand All @@ -63,7 +63,10 @@ describe('CI Workflow generator', () => {

it('should generate bitbucket pipelines config', async () => {
setNxCloud(tree);
await ciWorkflowGenerator(tree, { ci: 'bitbucket-pipelines' });
await ciWorkflowGenerator(tree, {
ci: 'bitbucket-pipelines',
name: 'CI',
});

expect(tree.read('bitbucket-pipelines.yml', 'utf-8')).toMatchSnapshot();
});
Expand All @@ -75,7 +78,10 @@ describe('CI Workflow generator', () => {
nxJson.affected.defaultBase = 'my-branch';
writeJson(tree, 'nx.json', nxJson);

await ciWorkflowGenerator(tree, { ci: 'bitbucket-pipelines' });
await ciWorkflowGenerator(tree, {
ci: 'bitbucket-pipelines',
name: 'CI',
});

expect(readJson(tree, 'nx.json').affected.defaultBase).toEqual(
'origin/my-branch'
Expand All @@ -84,7 +90,7 @@ describe('CI Workflow generator', () => {

it('should generate gitlab config', async () => {
setNxCloud(tree);
await ciWorkflowGenerator(tree, { ci: 'gitlab' });
await ciWorkflowGenerator(tree, { ci: 'gitlab', name: 'CI' });

expect(tree.read('.gitlab-ci.yml', 'utf-8')).toMatchSnapshot();
});
Expand All @@ -93,6 +99,7 @@ describe('CI Workflow generator', () => {
await expect(
ciWorkflowGenerator(tree, {
ci: 'github',
name: 'CI',
})
).rejects.toThrowErrorMatchingSnapshot();
});
Expand Down
4 changes: 2 additions & 2 deletions packages/workspace/src/generators/ci-workflow/ci-workflow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
import { deduceDefaultBase } from '../../utilities/default-base';

export interface Schema {
name?: string;
name: string;
ci: 'github' | 'azure' | 'circleci' | 'bitbucket-pipelines' | 'gitlab';
}

Expand Down Expand Up @@ -47,7 +47,7 @@ interface Substitutes {

function normalizeOptions(options: Schema): Substitutes {
const { name: workflowName, fileName: workflowFileName } = names(
options.name || 'CI'
options.name
);
const { exec: packageManagerPrefix, ciInstall: packageManagerInstall } =
getPackageManagerCommand();
Expand Down
2 changes: 1 addition & 1 deletion packages/workspace/src/generators/ci-workflow/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,5 @@
"pattern": "^[a-zA-Z].*$"
}
},
"required": ["ci"]
"required": ["ci", "name"]
}
6 changes: 5 additions & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit dff1177

Please sign in to comment.