@@ -4,18 +4,21 @@ import { npmInstall } from "../utils/shell.js";
44import type { WizardContext } from "../utils/types.js" ;
55import { copyFileFromTemplates , filesRoot } from "../utils/files.js" ;
66import { readJsonLoose , writeJson } from "../utils/json.js" ;
7+ import { VERSIONS } from "../utils/versions.js" ;
78
89/**
910 * Adds Prettier formatting to the Angular project.
1011 *
1112 * @param ctx The wizard context.
1213 */
1314export async function addPrettier ( ctx : WizardContext ) : Promise < void > {
14- console . log ( "Adding Prettier formatting..." ) ;
15-
1615 // Install dev deps
1716 await npmInstall (
18- [ "-D" , "prettier" , "@trivago/prettier-plugin-sort-imports" ] ,
17+ [
18+ "-D" ,
19+ `prettier@${ VERSIONS . prettier } ` ,
20+ `@trivago/prettier-plugin-sort-imports@${ VERSIONS [ "@trivago/prettier-plugin-sort-imports" ] } ` ,
21+ ] ,
1922 ctx . targetDir
2023 ) ;
2124
@@ -36,10 +39,6 @@ export async function addPrettier(ctx: WizardContext): Promise<void> {
3639 const extPath = path . join ( vscodeDir , "extensions.json" ) ;
3740 const settingsPath = path . join ( vscodeDir , "settings.json" ) ;
3841
39- const extTemplate = readJsonLoose < { recommendations ?: string [ ] } > (
40- path . join ( path . dirname ( vscodeDir ) , "files/vscode/extensions.json" )
41- ) ;
42-
4342 // Merge or create extensions
4443 const existingExt =
4544 readJsonLoose < { recommendations ?: string [ ] } > ( extPath ) ?? { } ;
@@ -61,10 +60,10 @@ export async function addPrettier(ctx: WizardContext): Promise<void> {
6160 const pkg = readJsonLoose < Record < string , any > > ( pkgPath ) ?? { } ;
6261 pkg . devDependencies = {
6362 ...( pkg . devDependencies ?? { } ) ,
64- prettier : pkg . devDependencies ?. prettier ?? "^3.6.0" ,
63+ prettier : pkg . devDependencies ?. prettier ?? VERSIONS . prettier ,
6564 "@trivago/prettier-plugin-sort-imports" :
6665 pkg . devDependencies ?. [ "@trivago/prettier-plugin-sort-imports" ] ??
67- "^5.2.2" ,
66+ VERSIONS [ "@trivago/prettier-plugin-sort-imports" ] ,
6867 } ;
6968 pkg . scripts = {
7069 ...( pkg . scripts ?? { } ) ,
0 commit comments