Skip to content
This repository was archived by the owner on Apr 8, 2020. It is now read-only.

Commit 8b243e8

Browse files
Simplify build script further
1 parent 28920c7 commit 8b243e8

File tree

2 files changed

+12
-41
lines changed

2 files changed

+12
-41
lines changed

templates/package-builder/package.json

+1-14
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,11 @@
1010
"author": "Microsoft",
1111
"license": "Apache-2.0",
1212
"dependencies": {
13-
"@types/chalk": "^0.4.31",
14-
"@types/semver": "^5.3.30",
15-
"diff": "^2.2.2",
16-
"gitignore-parser": "0.0.2",
17-
"glob": "^7.0.3",
18-
"lodash": "^4.11.1",
19-
"mkdirp": "^0.5.1",
20-
"rimraf": "^2.5.2",
21-
"semver": "^5.3.0",
22-
"tar.gz": "^1.0.5"
13+
"mkdirp": "^0.5.1"
2314
},
2415
"devDependencies": {
25-
"@types/glob": "^5.0.30",
26-
"@types/lodash": "^4.14.37",
2716
"@types/mkdirp": "^0.3.29",
2817
"@types/node": "^6.0.45",
29-
"@types/node-uuid": "0.0.28",
30-
"@types/rimraf": "0.0.28",
3118
"typescript": "^2.0.0"
3219
}
3320
}
+11-27
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,14 @@
1-
import * as glob from 'glob';
2-
import * as gitignore from 'gitignore-parser';
31
import * as fs from 'fs';
42
import * as path from 'path';
5-
import * as _ from 'lodash';
63
import * as mkdirp from 'mkdirp';
7-
import * as rimraf from 'rimraf';
84
import * as childProcess from 'child_process';
9-
import * as targz from 'tar.gz';
105

116
const isWindows = /^win/.test(process.platform);
12-
13-
const dotNetPackages = [
7+
const packageIds = [
148
'Microsoft.DotNet.Web.Spa.ProjectTemplates',
159
'Microsoft.AspNetCore.SpaTemplates'
1610
];
11+
const packageVersion = `1.0.${ getBuildNumber() }`;
1712

1813
function getBuildNumber(): string {
1914
if (process.env.APPVEYOR_BUILD_NUMBER) {
@@ -24,25 +19,18 @@ function getBuildNumber(): string {
2419
return Math.floor((new Date().valueOf() - new Date(2017, 0, 1).valueOf()) / (60*1000)) + '-local';
2520
}
2621

27-
function buildDotNetNewNuGetPackages(outputDir: string) {
28-
const dotNetPackageIds = _.values(dotNetPackages);
29-
dotNetPackageIds.forEach(packageId => {
30-
const dotNetNewNupkgPath = buildDotNetNewNuGetPackage(packageId);
31-
32-
// Move the .nupkg file to the output dir
33-
mkdirp.sync(outputDir);
34-
fs.renameSync(dotNetNewNupkgPath, path.join(outputDir, path.basename(dotNetNewNupkgPath)));
35-
});
36-
}
37-
38-
function buildDotNetNewNuGetPackage(packageId: string) {
22+
packageIds.forEach(packageId => {
3923
// Invoke NuGet to create the final package
4024
const packageSourceRootDir = path.join('../', packageId);
4125
const nuspecFilename = `${ packageId }.nuspec`;
42-
const nugetExe = path.join(process.cwd(), './bin/NuGet.exe');
26+
const nugetExe = path.resolve('./bin/NuGet.exe');
4327
const nugetStartInfo = { cwd: packageSourceRootDir, stdio: 'inherit' };
44-
const packageVersion = `1.0.${ getBuildNumber() }`;
45-
const nugetArgs = ['pack', nuspecFilename, '-Version', packageVersion];
28+
const nugetArgs = [
29+
'pack', nuspecFilename,
30+
'-Version', packageVersion,
31+
'-OutputDirectory', path.resolve('./artifacts')
32+
];
33+
4634
if (isWindows) {
4735
// Invoke NuGet.exe directly
4836
childProcess.spawnSync(nugetExe, nugetArgs, nugetStartInfo);
@@ -51,8 +39,4 @@ function buildDotNetNewNuGetPackage(packageId: string) {
5139
nugetArgs.unshift(nugetExe);
5240
childProcess.spawnSync('mono', nugetArgs, nugetStartInfo);
5341
}
54-
55-
return glob.sync(path.join(packageSourceRootDir, './*.nupkg'))[0];
56-
}
57-
58-
buildDotNetNewNuGetPackages('./artifacts');
42+
});

0 commit comments

Comments
 (0)