mirror of
https://github.com/aspnet/JavaScriptServices.git
synced 2025-12-25 02:57:31 +00:00
Simplify build script further
This commit is contained in:
@@ -1,19 +1,14 @@
|
||||
import * as glob from 'glob';
|
||||
import * as gitignore from 'gitignore-parser';
|
||||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
import * as _ from 'lodash';
|
||||
import * as mkdirp from 'mkdirp';
|
||||
import * as rimraf from 'rimraf';
|
||||
import * as childProcess from 'child_process';
|
||||
import * as targz from 'tar.gz';
|
||||
|
||||
const isWindows = /^win/.test(process.platform);
|
||||
|
||||
const dotNetPackages = [
|
||||
const packageIds = [
|
||||
'Microsoft.DotNet.Web.Spa.ProjectTemplates',
|
||||
'Microsoft.AspNetCore.SpaTemplates'
|
||||
];
|
||||
const packageVersion = `1.0.${ getBuildNumber() }`;
|
||||
|
||||
function getBuildNumber(): string {
|
||||
if (process.env.APPVEYOR_BUILD_NUMBER) {
|
||||
@@ -24,25 +19,18 @@ function getBuildNumber(): string {
|
||||
return Math.floor((new Date().valueOf() - new Date(2017, 0, 1).valueOf()) / (60*1000)) + '-local';
|
||||
}
|
||||
|
||||
function buildDotNetNewNuGetPackages(outputDir: string) {
|
||||
const dotNetPackageIds = _.values(dotNetPackages);
|
||||
dotNetPackageIds.forEach(packageId => {
|
||||
const dotNetNewNupkgPath = buildDotNetNewNuGetPackage(packageId);
|
||||
|
||||
// Move the .nupkg file to the output dir
|
||||
mkdirp.sync(outputDir);
|
||||
fs.renameSync(dotNetNewNupkgPath, path.join(outputDir, path.basename(dotNetNewNupkgPath)));
|
||||
});
|
||||
}
|
||||
|
||||
function buildDotNetNewNuGetPackage(packageId: string) {
|
||||
packageIds.forEach(packageId => {
|
||||
// Invoke NuGet to create the final package
|
||||
const packageSourceRootDir = path.join('../', packageId);
|
||||
const nuspecFilename = `${ packageId }.nuspec`;
|
||||
const nugetExe = path.join(process.cwd(), './bin/NuGet.exe');
|
||||
const nugetExe = path.resolve('./bin/NuGet.exe');
|
||||
const nugetStartInfo = { cwd: packageSourceRootDir, stdio: 'inherit' };
|
||||
const packageVersion = `1.0.${ getBuildNumber() }`;
|
||||
const nugetArgs = ['pack', nuspecFilename, '-Version', packageVersion];
|
||||
const nugetArgs = [
|
||||
'pack', nuspecFilename,
|
||||
'-Version', packageVersion,
|
||||
'-OutputDirectory', path.resolve('./artifacts')
|
||||
];
|
||||
|
||||
if (isWindows) {
|
||||
// Invoke NuGet.exe directly
|
||||
childProcess.spawnSync(nugetExe, nugetArgs, nugetStartInfo);
|
||||
@@ -51,8 +39,4 @@ function buildDotNetNewNuGetPackage(packageId: string) {
|
||||
nugetArgs.unshift(nugetExe);
|
||||
childProcess.spawnSync('mono', nugetArgs, nugetStartInfo);
|
||||
}
|
||||
|
||||
return glob.sync(path.join(packageSourceRootDir, './*.nupkg'))[0];
|
||||
}
|
||||
|
||||
buildDotNetNewNuGetPackages('./artifacts');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user