Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 | 11x 11x 11x 55x 55x 55x 1x 55x 55x 55x 55x 1x 1x 55x 55x 55x | import {Schema as YangNewOptions} from './schema'; import { apply, chain, empty, externalSchematic, MergeStrategy, mergeWith, move, Rule, schematic, SchematicContext, SchematicsException, Tree, } from '@angular-devkit/schematics'; import {Schema as NgNewOptions} from '@schematics/angular/ng-new/schema'; import {Schema as YangInitOptions} from '../init/schema'; import {NodePackageInstallTask, NodePackageLinkTask, RepositoryInitializerTask} from '@angular-devkit/schematics/tasks'; export default function (options: YangNewOptions): Rule { return () => { Iif (!options.name) { throw new SchematicsException(`Invalid options, "name" is required.`); } if (!options.directory || options.directory === '/') { options.directory = options.name; } const ngNewOptions: NgNewOptions = { ...options, directory: '/', skipInstall: true, skipGit: true, inlineStyle: options.inlineStyle ?? true, inlineTemplate: options.inlineTemplate ?? false }; const yangInitOptions: YangInitOptions = { name: options.name }; return chain([ mergeWith( apply(empty(), [ externalSchematic('@schematics/angular', 'ng-new', ngNewOptions), schematic('init', yangInitOptions), move(options.directory), ]), MergeStrategy.Overwrite ), (host: Tree, context: SchematicContext) => { let packageTask; if (!options.skipInstall) { packageTask = context.addTask(new NodePackageInstallTask(options.directory)); Iif (options.linkCli) { packageTask = context.addTask( new NodePackageLinkTask('@angular/cli', options.directory), [packageTask], ); } } Eif (!options.skipGit) { const commit = typeof options.commit == 'object' ? options.commit : (!!options.commit ? {} : false); context.addTask( new RepositoryInitializerTask( options.directory, commit, ), packageTask ? [packageTask] : [], ); } } ]); }; } |