|
| 1 | +import path from 'node:path'; |
| 2 | +import { PRESETS, Config, DESIGN_SYSTEMS } from '../../../utils/types.js'; |
| 3 | +import { run } from '../../../utils/utils.js'; |
| 4 | +import { ANGULAR_CLI_VERSION, CLARITY_DESIGN_VERSION } from '../../../utils/versions.js'; |
| 5 | + |
| 6 | +export async function createAngularFrontendSkeleton(config: Config): Promise<void> { |
| 7 | + const isAngularOnly = config.preset === PRESETS.ANGULAR_ONLY; |
| 8 | + const workingRootDir = isAngularOnly ? process.cwd() : config.repoRoot; |
| 9 | + const workingAngularDir = isAngularOnly ? config.repoRoot : path.join(config.repoRoot, 'frontend'); |
| 10 | + |
| 11 | + await installAngularCli(workingRootDir, isAngularOnly, config.pm, config.projectName); |
| 12 | + |
| 13 | + await run('ng', ['add', 'angular-eslint'], workingAngularDir); |
| 14 | + |
| 15 | + if (config.useCypress) { |
| 16 | + await run('ng', ['add', '@cypress/schematic'], workingAngularDir); |
| 17 | + } |
| 18 | + |
| 19 | + if (config.designSystem.includes(DESIGN_SYSTEMS.ANGULAR_MATERIAL)) { |
| 20 | + await run('ng', ['add', `@angular/material@${ANGULAR_CLI_VERSION}`], workingAngularDir); |
| 21 | + } |
| 22 | + |
| 23 | + if (config.designSystem.includes(DESIGN_SYSTEMS.CLARITY_DESIGN)) { |
| 24 | + await run(config.pm, ['install', `@clr/ui@${CLARITY_DESIGN_VERSION}`, `@clr/angular@${CLARITY_DESIGN_VERSION}`], workingAngularDir); |
| 25 | + } |
| 26 | +} |
| 27 | + |
| 28 | +async function installAngularCli(workingRootDir: string, isAngularOnly: boolean, pm: string, projectName: string): Promise<void> { |
| 29 | + return run( |
| 30 | + 'npx', |
| 31 | + [ |
| 32 | + '-y', |
| 33 | + `@angular/cli@${ANGULAR_CLI_VERSION}`, |
| 34 | + 'new', |
| 35 | + isAngularOnly ? projectName : 'frontend', |
| 36 | + '--interactive=false', |
| 37 | + '--skip-git', |
| 38 | + '--style=css', |
| 39 | + '--routing', |
| 40 | + '--package-manager', |
| 41 | + pm, |
| 42 | + ], |
| 43 | + workingRootDir, |
| 44 | + ); |
| 45 | +} |
0 commit comments