33const stringUtil = require ( 'ember-cli-string-utils' ) ;
44const chalk = require ( 'chalk' ) ;
55const directoryForPackageName = require ( './lib/directory-for-package-name' ) ;
6+ const { sortPackageJson } = require ( 'sort-package-json' ) ;
7+
8+ function stringifyAndNormalize ( contents ) {
9+ return `${ JSON . stringify ( contents , null , 2 ) } \n` ;
10+ }
11+
12+ const replacers = {
13+ 'package.json' ( ...args ) {
14+ return this . updatePackageJson ( ...args ) ;
15+ } ,
16+ } ;
617
718module . exports = {
819 description : 'The default blueprint for ember-cli projects.' ,
@@ -143,6 +154,10 @@ module.exports = {
143154 buildFileInfo ( intoDir , templateVariables , file , options ) {
144155 let fileInfo = this . _super . buildFileInfo . apply ( this , arguments ) ;
145156
157+ if ( file in replacers ) {
158+ fileInfo . replacer = replacers [ file ] . bind ( this , templateVariables ) ;
159+ }
160+
146161 if ( file . includes ( '_js_' ) ) {
147162 if ( options . typescript ) {
148163 return null ;
@@ -167,4 +182,10 @@ module.exports = {
167182
168183 return fileInfo ;
169184 } ,
185+
186+ updatePackageJson ( options , content ) {
187+ let contents = JSON . parse ( content ) ;
188+
189+ return stringifyAndNormalize ( sortPackageJson ( contents ) ) ;
190+ } ,
170191} ;
0 commit comments