@progress/kendo-schematics
Advanced tools
Comparing version 0.2.0 to 0.2.1-dev.201805081321
@@ -6,3 +6,3 @@ { | ||
"license": "SEE LICENSE in LICENSE.md", | ||
"version": "0.2.0", | ||
"version": "0.2.1-dev.201805081321", | ||
"scripts": { | ||
@@ -9,0 +9,0 @@ "build-package": "npm run build", |
@@ -13,26 +13,25 @@ "use strict"; | ||
}; | ||
function importKendoModules(options) { | ||
return (host) => { | ||
const moduleToUpdate = options.module; | ||
if (!moduleToUpdate) | ||
return host; | ||
const read = readSource(moduleToUpdate); | ||
const changes = utils_1.addImportToModule({ | ||
function updateNgModule(host, moduleToUpdate, data) { | ||
const read = readSource(moduleToUpdate); | ||
const changes = utils_1.addImportToModule({ | ||
source: read(host), | ||
symbolName: data.import, | ||
modulePath: data.from | ||
}); | ||
rules_1.applyChanges(host, moduleToUpdate, changes); | ||
if (data.export) { | ||
const changes = utils_1.addExportToModule({ | ||
source: read(host), | ||
symbolName: options.mainNgModule, | ||
modulePath: `@progress/kendo-angular-${options.package}` | ||
symbolName: data.import, | ||
modulePath: data.from | ||
}); | ||
rules_1.applyChanges(host, moduleToUpdate, changes); | ||
if (options.export) { | ||
const changes = utils_1.addExportToModule({ | ||
source: read(host), | ||
symbolName: options.mainNgModule, | ||
modulePath: `@progress/kendo-angular-${options.package}` | ||
}); | ||
rules_1.applyChanges(host, moduleToUpdate, changes); | ||
} | ||
return host; | ||
}; | ||
} | ||
} | ||
function importAnimationModule(options) { | ||
const runner = (deps, callback) => (...options) => deps.forEach(dep => { | ||
if (!dep.hasOwnProperty('condition') || dep.condition) { | ||
callback(...options, dep); | ||
} | ||
}); | ||
function importAllModules(options) { | ||
return (host) => { | ||
@@ -42,27 +41,23 @@ const moduleToUpdate = options.module; | ||
return host; | ||
const read = readSource(moduleToUpdate); | ||
const changes = utils_1.addImportToModule({ | ||
source: read(host), | ||
symbolName: 'BrowserAnimationsModule', | ||
modulePath: '@angular/platform-browser/animations' | ||
}); | ||
rules_1.applyChanges(host, moduleToUpdate, changes); | ||
const dependencies = [ | ||
{ | ||
import: options.mainNgModule, | ||
from: `@progress/kendo-angular-${options.package}`, | ||
export: options.export | ||
}, | ||
{ | ||
import: 'BrowserAnimationsModule', | ||
from: '@angular/platform-browser/animations' | ||
}, | ||
{ | ||
from: 'hammerjs', | ||
condition: options.importHammerjs | ||
}, | ||
...options.dependencies | ||
]; | ||
const run = runner(dependencies, updateNgModule); | ||
run(host, moduleToUpdate); | ||
return host; | ||
}; | ||
} | ||
function importHammerjs(options) { | ||
return (host) => { | ||
const moduleToUpdate = options.module; | ||
if (!moduleToUpdate || !options.importHammerjs) | ||
return host; | ||
const read = readSource(moduleToUpdate); | ||
const changes = utils_1.addImportToModule({ | ||
source: read(host), | ||
symbolName: '', | ||
modulePath: 'hammerjs' | ||
}); | ||
rules_1.applyChanges(host, moduleToUpdate, changes); | ||
return host; | ||
}; | ||
} | ||
function npmInstall(options) { | ||
@@ -101,5 +96,3 @@ return (host, context) => { | ||
return schematics_1.chain([ | ||
importKendoModules(options), | ||
importHammerjs(options), | ||
importAnimationModule(options), | ||
importAllModules(options), | ||
toInstall | ||
@@ -106,0 +99,0 @@ ])(host, context); |
@@ -38,2 +38,12 @@ export interface Schema { | ||
theme?: ('default' | 'bootstrap' | 'material'); | ||
/** | ||
* Additional dependencies for the package. | ||
*/ | ||
dependencies?: Dependency[]; | ||
} | ||
export interface Dependency { | ||
import?: string; | ||
export?: boolean; | ||
from: string; | ||
condition?: boolean; | ||
} |
@@ -51,2 +51,7 @@ { | ||
"type": "boolean" | ||
}, | ||
"dependencies": { | ||
"description": "Additional dependencies for the package.", | ||
"default": [], | ||
"type": "array" | ||
} | ||
@@ -53,0 +58,0 @@ }, |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1436
55617