@tibco-tcstk/component-template
Version:
TIBCO Cloud Composer Component to create Schematics in your TIBCO Cloud Application
38 lines (34 loc) • 1.27 kB
text/typescript
import {apply, chain, mergeWith, Rule, SchematicContext, template, Tree, url} from "@angular-devkit/schematics";
import {strings} from "@angular-devkit/core";
import {
addDeclarationToNgModule,
addDependencies,
showHead,
addImportToNgModule, addSpotfireLibs
} from "../schematic-utils/schematic-util-wrapper";
// Instead of `any`, it would make sense here to get a schema-to-dts package and output the
// interfaces so you get type-safe options.
export default function (options: any): Rule {
// The chain rule allows us to chain multiple rules and apply them one after the other.
options.name = options.name + '-spotfire';
return chain([
(_tree: Tree, context: SchematicContext) => {
showHead("SPOTFIRE - BASIC ", context,options);
},
(host: Tree, context: SchematicContext) => {
options = addDependencies(options, context, host);
},
addSpotfireLibs(),
mergeWith(apply(url('./files'), [
template({
...strings,
INDEX: options.index,
name: options.name,
sfserver: options.sfserver,
sflocation: options.sflocation
}),
])),
addDeclarationToNgModule(options, false),
addImportToNgModule(options, 'TcSpotfireLibModule', '@tibco-tcstk/tc-spotfire-lib')
]);
}