Skip to content

Commit

Permalink
feat(schematics): Add schematic for initial support of "ng add ignite…
Browse files Browse the repository at this point in the history
…ui-angular" (#410)

Implemented "cli-config" schematic as an extension for the "ng-add" schematic in Ignite UI for Angular
  • Loading branch information
jackofdiamond5 authored and damyanpetev committed Nov 30, 2018
1 parent 3b77e7d commit cac7feb
Show file tree
Hide file tree
Showing 18 changed files with 489 additions and 60 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Expand Up @@ -17,5 +17,7 @@
!/templates/react/**/files/**/*
/migrations/**/*.js.map
/migrations/**/*.js
/schematics/**/*.js.map
/schematics/**/*.js
/coverage
/.nyc_output
4 changes: 3 additions & 1 deletion .vscode/settings.json
Expand Up @@ -13,7 +13,9 @@
"templates/**/*.js.map": true,
"templates/**/*.js": {"when": "$(basename).ts"},
"migrations/**/*.js.map": true,
"migrations/**/*.js": {"when": "$(basename).ts"}
"migrations/**/*.js": {"when": "$(basename).ts"},
"schematics/**/*.js.map": true,
"schematics/**/*.js": {"when": "$(basename).ts"}
},
"tslint.exclude": [
"**/files/**/*.ts",
Expand Down
14 changes: 8 additions & 6 deletions lib/templates/IgniteUIForAngularTemplate.ts
Expand Up @@ -40,12 +40,14 @@ export class IgniteUIForAngularTemplate extends AngularTemplate {
//1) import the component class name,
//2) and populate the Routes array with the path and component
//for example: { path: 'combo', component: ComboComponent }
const routingModule = new TsUpdate(path.join(projectPath, "src/app/app-routing.module.ts"));
routingModule.addRoute(
path.join(projectPath, `src/app/${this.folderName(name)}/${this.fileName(name)}.component.ts`),
this.folderName(name), //path
name //text
);
if (Util.fileExists("src/app/app-routing.module.ts")) {
const routingModule = new TsUpdate(path.join(projectPath, "src/app/app-routing.module.ts"));
routingModule.addRoute(
path.join(projectPath, `src/app/${this.folderName(name)}/${this.fileName(name)}.component.ts`),
this.folderName(name), //path
name //text
);
}

//3) add an import of the component class from its file location.
//4) populate the declarations portion of the @NgModule with the component class name.
Expand Down
2 changes: 1 addition & 1 deletion migrations/update-3/index.ts
@@ -1,7 +1,7 @@
// tslint:disable:no-implicit-dependencies
import { Rule, SchematicContext, Tree } from "@angular-devkit/schematics";

function addTypography(host: Tree) {
export function addTypography(host: Tree) {
const indexHtml = "src/index.html";
const bodyTagRegex = /<body[^>]*?>/;
const classRegex = /class=["']([^"']*?)["']/;
Expand Down
124 changes: 81 additions & 43 deletions package-lock.json

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

11 changes: 8 additions & 3 deletions package.json
Expand Up @@ -46,7 +46,10 @@
"templates/**/*.json",
"migrations/**/*.d.ts",
"migrations/**/*.js",
"migrations/**/*.json"
"migrations/**/*.json",
"schematics/**/*.d.ts",
"schematics/**/*.js",
"schematics/**/*.json"
],
"nyc": {
"extension": [
Expand Down Expand Up @@ -86,7 +89,8 @@
"yargs": "^8.0.2"
},
"devDependencies": {
"@angular-devkit/schematics": "^0.6.8",
"@angular-devkit/schematics": "^7.0.6",
"@schematics/angular": "7.1.0",
"@types/fs-extra": "^3.0.3",
"@types/inquirer": "0.0.35",
"@types/jasmine": "^2.8.6",
Expand All @@ -110,5 +114,6 @@
"igniteui-angular",
"igniteui-angular-charts"
]
}
},
"schematics": "./schematics/cli-collection.json"
}
9 changes: 9 additions & 0 deletions schematics/cli-collection.json
@@ -0,0 +1,9 @@
{
"$schema": "./../@angular-devkit/schematics/collection-schema.json",
"schematics": {
"cli-config": {
"description": "Installs the needed dependencies onto the host application.",
"factory": "./cli-config/index"
}
}
}
19 changes: 19 additions & 0 deletions schematics/cli-config/files/ignite-ui-cli.json
@@ -0,0 +1,19 @@
{
"version": "",
"project": {
"defaultPort": 4200,
"framework": "angular",
"projectType": "igx-ts",
"projectTemplate": "ng-cli",
"theme": "Custom",
"isBundle": false,
"bundleFilePath": "",
"igniteuiSource": "",
"components": [],
"sourceFiles": [],
"isShowcase": false,
"version": ""
},
"build": {},
"packagesInstalled": true
}

0 comments on commit cac7feb

Please sign in to comment.