@@ -17,8 +17,6 @@ const dotNetPackages = {
1717 extra : 'Microsoft.AspNetCore.SpaTemplates'
1818} ;
1919
20- const commonForceInclusionRegex = / ^ ( w w w r o o t | C l i e n t A p p ) \/ d i s t \/ / ; // Files to be included in template, even though gitignored
21-
2220interface TemplateConfig {
2321 dir : string ;
2422 dotNetNewId : string ;
@@ -46,7 +44,7 @@ function writeFileEnsuringDirExists(root: string, filename: string, contents: st
4644 fs . writeFileSync ( fullPath , contents ) ;
4745}
4846
49- function listFilesExcludingGitignored ( root : string , forceInclusion : RegExp ) : string [ ] {
47+ function listFilesExcludingGitignored ( root : string ) : string [ ] {
5048 // Note that the gitignore files, prior to be written by the generator, are called 'template_gitignore'
5149 // instead of '.gitignore'. This is a workaround for Yeoman doing strange stuff with .gitignore files
5250 // (it renames them to .npmignore, which is not helpful).
@@ -55,11 +53,11 @@ function listFilesExcludingGitignored(root: string, forceInclusion: RegExp): str
5553 ? gitignore . compile ( fs . readFileSync ( gitIgnorePath , 'utf8' ) )
5654 : { accepts : ( ) => true } ;
5755 return glob . sync ( '**/*' , { cwd : root , dot : true , nodir : true } )
58- . filter ( fn => gitignoreEvaluator . accepts ( fn ) || ( forceInclusion && forceInclusion . test ( fn ) ) ) ;
56+ . filter ( fn => gitignoreEvaluator . accepts ( fn ) ) ;
5957}
6058
61- function writeTemplate ( sourceRoot : string , destRoot : string , contentReplacements : { from : RegExp , to : string } [ ] , filenameReplacements : { from : RegExp , to : string } [ ] , forceInclusion : RegExp ) {
62- listFilesExcludingGitignored ( sourceRoot , forceInclusion ) . forEach ( fn => {
59+ function writeTemplate ( sourceRoot : string , destRoot : string , contentReplacements : { from : RegExp , to : string } [ ] , filenameReplacements : { from : RegExp , to : string } [ ] ) {
60+ listFilesExcludingGitignored ( sourceRoot ) . forEach ( fn => {
6361 let sourceContent = fs . readFileSync ( path . join ( sourceRoot , fn ) ) ;
6462
6563 // For text files, replace hardcoded values with template tags
@@ -102,7 +100,7 @@ function buildYeomanNpmPackage(outputRoot: string) {
102100 ] ;
103101 _ . forEach ( templates , ( templateConfig , templateName ) => {
104102 const outputDir = path . join ( outputTemplatesRoot , templateName ) ;
105- writeTemplate ( templateConfig . dir , outputDir , contentReplacements , filenameReplacements , commonForceInclusionRegex ) ;
103+ writeTemplate ( templateConfig . dir , outputDir , contentReplacements , filenameReplacements ) ;
106104 } ) ;
107105
108106 // Also copy the generator files (that's the compiled .js files, plus all other non-.ts files)
@@ -143,7 +141,7 @@ function buildDotNetNewNuGetPackage(packageId: string) {
143141 }
144142
145143 const templateOutputDir = path . join ( outputRoot , 'Content' , templateName ) ;
146- writeTemplate ( templateConfig . dir , templateOutputDir , contentReplacements , filenameReplacements , commonForceInclusionRegex ) ;
144+ writeTemplate ( templateConfig . dir , templateOutputDir , contentReplacements , filenameReplacements ) ;
147145
148146 // Add the .template.config dir and its contents
149147 const templateConfigDir = path . join ( templateOutputDir , '.template.config' ) ;
@@ -235,7 +233,7 @@ function buildDotNetNewNuGetPackage(packageId: string) {
235233 { from : / \{ v e r s i o n \} / g, to : yeomanPackageVersion } ,
236234 ] , [
237235 { from : / .* \. n u s p e c $ / , to : `${ packageId } .nuspec` } ,
238- ] , null ) ;
236+ ] ) ;
239237 const nugetExe = path . join ( process . cwd ( ) , './bin/NuGet.exe' ) ;
240238 const nugetStartInfo = { cwd : outputRoot , stdio : 'inherit' } ;
241239 if ( isWindows ) {
@@ -252,19 +250,6 @@ function buildDotNetNewNuGetPackage(packageId: string) {
252250 return glob . sync ( path . join ( outputRoot , './*.nupkg' ) ) [ 0 ] ;
253251}
254252
255- function runAllPrepublishScripts ( ) {
256- Object . getOwnPropertyNames ( templates ) . forEach ( templateKey => {
257- // To support the "dotnet new" templates, we want to bundle prebuilt dist dev-mode files, because "dotnet new" can't auto-run
258- // webpack on project creation. Note that these script entries are *not* the same as the project's usual prepublish
259- // scripts, because here we want dev-mode builds (e.g., to support HMR), not prod-mode builds.
260- runPrepublishScripts ( templates [ templateKey ] . dir , [
261- 'npm install' ,
262- 'node node_modules/webpack/bin/webpack.js --config webpack.config.vendor.js' ,
263- 'node node_modules/webpack/bin/webpack.js'
264- ] ) ;
265- } ) ;
266- }
267-
268253function runPrepublishScripts ( rootDir : string , scripts : string [ ] ) {
269254 console . log ( `[Prepublish] In directory: ${ rootDir } ` ) ;
270255 scripts . forEach ( script => {
@@ -280,7 +265,6 @@ const yeomanOutputRoot = path.join(distDir, 'generator-aspnetcore-spa');
280265
281266rimraf . sync ( distDir ) ;
282267mkdirp . sync ( artifactsDir ) ;
283- runAllPrepublishScripts ( ) ;
284268buildYeomanNpmPackage ( yeomanOutputRoot ) ;
285269buildDotNetNewNuGetPackages ( artifactsDir ) ;
286270
0 commit comments