Skip to content

Commit f31b96f

Browse files
Yeoman package builder emits .tar.gz artifact
1 parent 312885a commit f31b96f

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

templates/package-builder/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
"lodash": "^4.11.1",
1919
"mkdirp": "^0.5.1",
2020
"rimraf": "^2.5.2",
21-
"semver": "^5.3.0"
21+
"semver": "^5.3.0",
22+
"tar.gz": "^1.0.5"
2223
},
2324
"devDependencies": {
2425
"@types/glob": "^5.0.30",

templates/package-builder/src/build/build.ts

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import * as _ from 'lodash';
66
import * as mkdirp from 'mkdirp';
77
import * as rimraf from 'rimraf';
88
import * as childProcess from 'child_process';
9+
import * as targz from 'tar.gz';
910

1011
const isWindows = /^win/.test(process.platform);
1112
const textFileExtensions = ['.gitignore', 'template_gitignore', '.config', '.cs', '.cshtml', '.csproj', 'Dockerfile', '.html', '.js', '.json', '.jsx', '.md', '.nuspec', '.ts', '.tsx', '.xproj'];
@@ -81,8 +82,7 @@ function copyRecursive(sourceRoot: string, destRoot: string, matchGlob: string)
8182
});
8283
}
8384

84-
function buildYeomanNpmPackage() {
85-
const outputRoot = './dist/generator-aspnetcore-spa';
85+
function buildYeomanNpmPackage(outputRoot: string) {
8686
const outputTemplatesRoot = path.join(outputRoot, 'app/templates');
8787
rimraf.sync(outputTemplatesRoot);
8888

@@ -190,7 +190,19 @@ function runScripts(rootDir: string, scripts: string[]) {
190190
console.log(`[Prepublish] Done`)
191191
}
192192

193-
rimraf.sync('./dist');
193+
const distDir = './dist';
194+
const artifactsDir = path.join(distDir, 'artifacts');
195+
const yeomanOutputRoot = path.join(distDir, 'generator-aspnetcore-spa');
196+
197+
rimraf.sync(distDir);
198+
mkdirp.sync(artifactsDir);
194199
runAllPrepublishScripts();
195-
buildYeomanNpmPackage();
200+
buildYeomanNpmPackage(yeomanOutputRoot);
196201
buildDotNetNewNuGetPackage();
202+
203+
// Finally, create a .tar.gz file containing the built generator-aspnetcore-spa.
204+
// The CI system can treat this as the final built artifact.
205+
// Note that the targz APIs only come in async flavor.
206+
targz().compress(yeomanOutputRoot, path.join(artifactsDir, 'generator-aspnetcore-spa.tar.gz'), err => {
207+
if (err) { throw err; }
208+
});

0 commit comments

Comments
 (0)