@@ -15,28 +15,6 @@ const dotNetPackages = [
1515'Microsoft.AspNetCore.SpaTemplates'
1616] ;
1717
18- function writeFileEnsuringDirExists ( root : string , filename : string , contents : string | Buffer ) {
19- let fullPath = path . join ( root , filename ) ;
20- mkdirp . sync ( path . dirname ( fullPath ) ) ;
21- fs . writeFileSync ( fullPath , contents ) ;
22- }
23-
24- function listFilesExcludingGitignored ( root : string ) : string [ ] {
25- let gitIgnorePath = path . join ( root , '.gitignore' ) ;
26- let gitignoreEvaluator = fs . existsSync ( gitIgnorePath )
27- ? gitignore . compile ( fs . readFileSync ( gitIgnorePath , 'utf8' ) )
28- : { accepts : ( ) => true } ;
29- return glob . sync ( '**/*' , { cwd : root , dot : true , nodir : true } )
30- . filter ( fn => gitignoreEvaluator . accepts ( fn ) ) ;
31- }
32-
33- function writeTemplate ( sourceRoot : string , destRoot : string ) {
34- listFilesExcludingGitignored ( sourceRoot ) . forEach ( fn => {
35- let sourceContent = fs . readFileSync ( path . join ( sourceRoot , fn ) ) ;
36- writeFileEnsuringDirExists ( destRoot , fn , sourceContent ) ;
37- } ) ;
38- }
39-
4018function getBuildNumber ( ) : string {
4119if ( process . env . APPVEYOR_BUILD_NUMBER ) {
4220return process . env . APPVEYOR_BUILD_NUMBER ;
@@ -52,35 +30,17 @@ function buildDotNetNewNuGetPackages(outputDir: string){
5230const dotNetNewNupkgPath = buildDotNetNewNuGetPackage ( packageId ) ;
5331
5432// Move the .nupkg file to the output dir
33+ mkdirp . sync ( outputDir ) ;
5534fs . renameSync ( dotNetNewNupkgPath , path . join ( outputDir , path . basename ( dotNetNewNupkgPath ) ) ) ;
5635} ) ;
5736}
5837
5938function buildDotNetNewNuGetPackage ( packageId : string ) {
60- const outputRoot = './dist/dotnetnew' ;
61- rimraf . sync ( outputRoot ) ;
62-
63- // Copy template files
39+ // Invoke NuGet to create the final package
6440const packageSourceRootDir = path . join ( '../' , packageId ) ;
65- const templatesInPackage = fs . readdirSync ( path . join ( packageSourceRootDir , 'Content' ) ) ;
66-
67- _ . forEach ( templatesInPackage , templateName => {
68- const templateSourceDir = path . join ( packageSourceRootDir , 'Content' , templateName ) ;
69- const templateOutputDir = path . join ( outputRoot , 'Content' , templateName ) ;
70- writeTemplate ( templateSourceDir , templateOutputDir ) ;
71- } ) ;
72-
73- // Create the .nuspec file
7441const nuspecFilename = `${ packageId } .nuspec` ;
75- const nuspecContentTemplate = fs . readFileSync ( path . join ( packageSourceRootDir , nuspecFilename ) ) ;
76- writeFileEnsuringDirExists ( outputRoot ,
77- nuspecFilename ,
78- nuspecContentTemplate
79- ) ;
80-
81- // Invoke NuGet to create the final package
8242const nugetExe = path . join ( process . cwd ( ) , './bin/NuGet.exe' ) ;
83- const nugetStartInfo = { cwd : outputRoot , stdio : 'inherit' } ;
43+ const nugetStartInfo = { cwd : packageSourceRootDir , stdio : 'inherit' } ;
8444const packageVersion = `1.0.${ getBuildNumber ( ) } ` ;
8545const nugetArgs = [ 'pack' , nuspecFilename , '-Version' , packageVersion ] ;
8646if ( isWindows ) {
@@ -92,15 +52,7 @@ function buildDotNetNewNuGetPackage(packageId: string){
9252childProcess . spawnSync ( 'mono' , nugetArgs , nugetStartInfo ) ;
9353}
9454
95- // Clean up
96- rimraf . sync ( './tmp' ) ;
97-
98- return glob . sync ( path . join ( outputRoot , './*.nupkg' ) ) [ 0 ] ;
55+ return glob . sync ( path . join ( packageSourceRootDir , './*.nupkg' ) ) [ 0 ] ;
9956}
10057
101- const distDir = './dist' ;
102- const artifactsDir = path . join ( distDir , 'artifacts' ) ;
103-
104- rimraf . sync ( distDir ) ;
105- mkdirp . sync ( artifactsDir ) ;
106- buildDotNetNewNuGetPackages ( artifactsDir ) ;
58+ buildDotNetNewNuGetPackages ( './artifacts' ) ;
0 commit comments