Skip to content

Commit

Permalink
feat(core): add CI generator WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
meeroslav committed Apr 4, 2022
1 parent b627016 commit ba3d962
Show file tree
Hide file tree
Showing 7 changed files with 106 additions and 5 deletions.
6 changes: 4 additions & 2 deletions docs/generated/cli/create-nx-workspace.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,11 @@ The name of the application when a preset with pregenerated app is selected

### ci

Default: `[]`
Type: array

Choices: `["github", "circleci", "azure"]`
Choices: ["github", "circleci", "azure"]

Default: []

Generate a CI workflow file

Expand Down
43 changes: 43 additions & 0 deletions docs/generated/packages/workspace.json
Original file line number Diff line number Diff line change
Expand Up @@ -654,6 +654,49 @@
"aliases": [],
"hidden": false,
"path": "/packages/workspace/src/generators/npm-package/schema.json"
},
{
"name": "ci-workflow",
"factory": "./src/generators/ci-workflow/ci-workflow#ciWorkflowGenerator",
"schema": {
"$schema": "http://json-schema.org/schema",
"$id": "NxWorkspaceNpmPackage",
"title": "Generate a CI workflow.",
"description": "Generate a CI workflow.",
"cli": "nx",
"type": "object",
"properties": {
"ci": {
"type": "string",
"description": "CI provider.",
"$default": { "$source": "argv", "index": 0 },
"default": "github",
"x-prompt": {
"message": "What is your target CI provider?",
"type": "list",
"items": [
{ "value": "github", "label": "Github Actions" },
{ "value": "circleci", "label": "Circle CI" },
{ "value": "azure", "label": "Azure DevOps" }
]
}
},
"name": {
"type": "string",
"description": "Workflow name.",
"$default": { "$source": "argv", "index": 0 },
"x-prompt": "How should we name your workflow?",
"pattern": "^[a-zA-Z].*$"
}
},
"required": ["ci"],
"presets": []
},
"description": "Generete a CI workflow.",
"implementation": "/packages/workspace/src/generators/ci-workflow/ci-workflow#ciWorkflowGenerator.ts",
"aliases": [],
"hidden": false,
"path": "/packages/workspace/src/generators/ci-workflow/schema.json"
}
],
"executors": [
Expand Down
3 changes: 2 additions & 1 deletion docs/packages.json
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,8 @@
"workspace-generator",
"run-commands",
"convert-to-nx-project",
"npm-package"
"npm-package",
"ci-workflow"
]
}
}
Expand Down
4 changes: 2 additions & 2 deletions packages/create-nx-workspace/bin/create-nx-workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -671,8 +671,8 @@ async function determineCI(
type: 'multiselect',
choices: [
{ name: 'GitHub Actions', value: 'github' },
{ name: 'CircleCI', value: 'circleci' },
{ name: 'Azure', value: 'azure' },
{ name: 'Circle CI', value: 'circleci' },
{ name: 'Azure DevOps', value: 'azure' },
],
},
])
Expand Down
6 changes: 6 additions & 0 deletions packages/workspace/generators.json
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,12 @@
"schema": "./src/generators/npm-package/schema.json",
"description": "Create a minimal NPM package.",
"x-type": "library"
},

"ci-workflow": {
"factory": "./src/generators/ci-workflow/ci-workflow#ciWorkflowGenerator",
"schema": "./src/generators/ci-workflow/schema.json",
"description": "Generete a CI workflow."
}
}
}
10 changes: 10 additions & 0 deletions packages/workspace/src/generators/ci-workflow/ci-workflow.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { Tree } from '@nrwl/devkit';

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

export async function ciWorkflowGenerator(tree: Tree, options: Schema) {
// TODO: Implement
}
39 changes: 39 additions & 0 deletions packages/workspace/src/generators/ci-workflow/schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"$schema": "http://json-schema.org/schema",
"$id": "NxWorkspaceNpmPackage",
"title": "Generate a CI workflow.",
"description": "Generate a CI workflow.",
"cli": "nx",
"type": "object",
"properties": {
"ci": {
"type": "string",
"description": "CI provider.",
"$default": {
"$source": "argv",
"index": 0
},
"default": "github",
"x-prompt": {
"message": "What is your target CI provider?",
"type": "list",
"items": [
{ "value": "github", "label": "Github Actions" },
{ "value": "circleci", "label": "Circle CI" },
{ "value": "azure", "label": "Azure DevOps" }
]
}
},
"name": {
"type": "string",
"description": "Workflow name.",
"$default": {
"$source": "argv",
"index": 0
},
"x-prompt": "How should we name your workflow?",
"pattern": "^[a-zA-Z].*$"
}
},
"required": ["ci"]
}

0 comments on commit ba3d962

Please sign in to comment.