Skip to content

Commit

Permalink
feat(ng-schematics): add prompt for migrations
Browse files Browse the repository at this point in the history
  • Loading branch information
jackofdiamond5 committed Dec 12, 2023
1 parent 8959e5d commit 1e50c9e
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 3 deletions.
4 changes: 4 additions & 0 deletions packages/ng-schematics/src/migrations/interfaces/options.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export interface Options {
[key: string]: any;
applyMigrations: boolean;
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"migration-01": {
"version": "17.1.0",
"description": "Updates Ignite UI for Angular Schematics project from 17.0.X to 17.1.X",
"factory": "./update-1"
"factory": "./update-1",
"schema": "./schema.json"
}
}
}
14 changes: 14 additions & 0 deletions packages/ng-schematics/src/migrations/schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"$schema": "http://json-schema.org/schema",
"$id": "igniteui-angular-ng-add",
"title": "IgniteUI for Angular ng-add schematic",
"type": "object",
"properties": {
"applyMigrations": {
"type": "boolean",
"description": "Apply migrations to the project.",
"default": true,
"x-prompt": "Would you like to apply automated migrations?"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ describe("Update XXX", () => {
`
);

const tree = await schematicRunner.runSchematicAsync("migration-01", {}, appTree).toPromise();
const tree = await schematicRunner.runSchematicAsync("migration-01", { applyMigrations: true }, appTree).toPromise();
expect(tree.readContent("./igniteui-cli.json"))
.toEqual(
`{
Expand Down
5 changes: 4 additions & 1 deletion packages/ng-schematics/src/migrations/update-1/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import { Rule, SchematicContext, Tree } from "@angular-devkit/schematics";
import { Options } from "../interfaces/options";

export default function(): Rule {
export default function(options: Options): Rule {
return (host: Tree, context: SchematicContext) => {
if (!options.applyMigrations) { return; }

context.logger.info("Updating project to Ignite UI CLI XXX");

const igConfig = "./igniteui-cli.json";
Expand Down

0 comments on commit 1e50c9e

Please sign in to comment.