mirror of
https://github.com/aspnet/JavaScriptServices.git
synced 2025-12-22 17:47:53 +00:00
Simplify build script further
This commit is contained in:
@@ -10,24 +10,11 @@
|
|||||||
"author": "Microsoft",
|
"author": "Microsoft",
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@types/chalk": "^0.4.31",
|
"mkdirp": "^0.5.1"
|
||||||
"@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"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/glob": "^5.0.30",
|
|
||||||
"@types/lodash": "^4.14.37",
|
|
||||||
"@types/mkdirp": "^0.3.29",
|
"@types/mkdirp": "^0.3.29",
|
||||||
"@types/node": "^6.0.45",
|
"@types/node": "^6.0.45",
|
||||||
"@types/node-uuid": "0.0.28",
|
|
||||||
"@types/rimraf": "0.0.28",
|
|
||||||
"typescript": "^2.0.0"
|
"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 fs from 'fs';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import * as _ from 'lodash';
|
|
||||||
import * as mkdirp from 'mkdirp';
|
import * as mkdirp from 'mkdirp';
|
||||||
import * as rimraf from 'rimraf';
|
|
||||||
import * as childProcess from 'child_process';
|
import * as childProcess from 'child_process';
|
||||||
import * as targz from 'tar.gz';
|
|
||||||
|
|
||||||
const isWindows = /^win/.test(process.platform);
|
const isWindows = /^win/.test(process.platform);
|
||||||
|
const packageIds = [
|
||||||
const dotNetPackages = [
|
|
||||||
'Microsoft.DotNet.Web.Spa.ProjectTemplates',
|
'Microsoft.DotNet.Web.Spa.ProjectTemplates',
|
||||||
'Microsoft.AspNetCore.SpaTemplates'
|
'Microsoft.AspNetCore.SpaTemplates'
|
||||||
];
|
];
|
||||||
|
const packageVersion = `1.0.${ getBuildNumber() }`;
|
||||||
|
|
||||||
function getBuildNumber(): string {
|
function getBuildNumber(): string {
|
||||||
if (process.env.APPVEYOR_BUILD_NUMBER) {
|
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';
|
return Math.floor((new Date().valueOf() - new Date(2017, 0, 1).valueOf()) / (60*1000)) + '-local';
|
||||||
}
|
}
|
||||||
|
|
||||||
function buildDotNetNewNuGetPackages(outputDir: string) {
|
packageIds.forEach(packageId => {
|
||||||
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) {
|
|
||||||
// Invoke NuGet to create the final package
|
// Invoke NuGet to create the final package
|
||||||
const packageSourceRootDir = path.join('../', packageId);
|
const packageSourceRootDir = path.join('../', packageId);
|
||||||
const nuspecFilename = `${ packageId }.nuspec`;
|
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 nugetStartInfo = { cwd: packageSourceRootDir, stdio: 'inherit' };
|
||||||
const packageVersion = `1.0.${ getBuildNumber() }`;
|
const nugetArgs = [
|
||||||
const nugetArgs = ['pack', nuspecFilename, '-Version', packageVersion];
|
'pack', nuspecFilename,
|
||||||
|
'-Version', packageVersion,
|
||||||
|
'-OutputDirectory', path.resolve('./artifacts')
|
||||||
|
];
|
||||||
|
|
||||||
if (isWindows) {
|
if (isWindows) {
|
||||||
// Invoke NuGet.exe directly
|
// Invoke NuGet.exe directly
|
||||||
childProcess.spawnSync(nugetExe, nugetArgs, nugetStartInfo);
|
childProcess.spawnSync(nugetExe, nugetArgs, nugetStartInfo);
|
||||||
@@ -51,8 +39,4 @@ function buildDotNetNewNuGetPackage(packageId: string) {
|
|||||||
nugetArgs.unshift(nugetExe);
|
nugetArgs.unshift(nugetExe);
|
||||||
childProcess.spawnSync('mono', nugetArgs, nugetStartInfo);
|
childProcess.spawnSync('mono', nugetArgs, nugetStartInfo);
|
||||||
}
|
}
|
||||||
|
});
|
||||||
return glob.sync(path.join(packageSourceRootDir, './*.nupkg'))[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
buildDotNetNewNuGetPackages('./artifacts');
|
|
||||||
|
|||||||
Reference in New Issue
Block a user