Simplify build script further
This commit is contained in:
Родитель
28920c7691
Коммит
8b243e8cc7
|
@ -10,24 +10,11 @@
|
|||
"author": "Microsoft",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@types/chalk": "^0.4.31",
|
||||
"@types/semver": "^5.3.30",
|
||||
"diff": "^2.2.2",
|
||||
"gitignore-parser": "0.0.2",
|
||||
"glob": "^7.0.3",
|
||||
"lodash": "^4.11.1",
|
||||
"mkdirp": "^0.5.1",
|
||||
"rimraf": "^2.5.2",
|
||||
"semver": "^5.3.0",
|
||||
"tar.gz": "^1.0.5"
|
||||
"mkdirp": "^0.5.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/glob": "^5.0.30",
|
||||
"@types/lodash": "^4.14.37",
|
||||
"@types/mkdirp": "^0.3.29",
|
||||
"@types/node": "^6.0.45",
|
||||
"@types/node-uuid": "0.0.28",
|
||||
"@types/rimraf": "0.0.28",
|
||||
"typescript": "^2.0.0"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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');
|
||||
});
|
||||
|
|
Загрузка…
Ссылка в новой задаче