index.ts (992B)
1 /** 2 * @license 3 * Copyright 2022 Google Inc. 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7 import { 8 chain, 9 type Rule, 10 type SchematicContext, 11 type Tree, 12 } from '@angular-devkit/schematics'; 13 14 import {addFilesSingle} from '../utils/files.js'; 15 import {TestRunner, type AngularProject} from '../utils/types.js'; 16 17 // You don't have to export the function as default. You can also have more than one rule 18 // factory per file. 19 export function config(): Rule { 20 return (tree: Tree, context: SchematicContext) => { 21 return chain([addPuppeteerConfig()])(tree, context); 22 }; 23 } 24 25 function addPuppeteerConfig(): Rule { 26 return (_tree: Tree, context: SchematicContext) => { 27 context.logger.debug('Adding Puppeteer config file.'); 28 29 return addFilesSingle('', {root: ''} as AngularProject, { 30 // No-op here to fill types 31 options: { 32 testRunner: TestRunner.Jasmine, 33 port: 4200, 34 }, 35 applyPath: './files', 36 relativeToWorkspacePath: `/`, 37 }); 38 }; 39 }