Remove Yeoman from the template build process

This commit is contained in:
Steve Sanderson
2017-08-22 14:43:51 -07:00
parent eea2066a6d
commit e057cb35ec
4 changed files with 5 additions and 43 deletions

View File

@@ -1,5 +1,5 @@
To generator the Yeoman generator, execute:
To generator the package generator, execute:
npm run build
Output will appear in the `generator-aspnetcore-spa` directory.
Output will appear in the `dist/artifacts` directory.

View File

@@ -1,11 +1,11 @@
{
"name": "generator-aspnetcore-spa-generator",
"version": "1.0.0",
"description": "Creates the Yeoman generator and 'dotnet new' package for ASP.NET Core SPA templates",
"description": "Creates the 'dotnet new' package for ASP.NET Core SPA templates",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build": "tsc && node ./tmp/build/build.js"
"build": "tsc && node ./tmp/build.js"
},
"author": "Microsoft",
"license": "Apache-2.0",
@@ -28,7 +28,6 @@
"@types/node": "^6.0.45",
"@types/node-uuid": "0.0.28",
"@types/rimraf": "0.0.28",
"@types/yeoman-generator": "0.0.30",
"typescript": "^2.0.0"
}
}

View File

@@ -10,7 +10,6 @@ import * as targz from 'tar.gz';
const isWindows = /^win/.test(process.platform);
const textFileExtensions = ['.gitignore', 'template_gitignore', '.config', '.cs', '.cshtml', '.csproj', '.html', '.js', '.json', '.jsx', '.md', '.nuspec', '.ts', '.tsx'];
const yeomanGeneratorSource = './src/yeoman';
const webToolsVSPackageGuid = '{0CD94836-1526-4E85-87D3-FB5274C5AFC9}';
const dotNetPackages = {
@@ -100,31 +99,6 @@ function getBuildNumber(): string {
return Math.floor((new Date().valueOf() - new Date(2017, 0, 1).valueOf()) / (60*1000)) + '-local';
}
function buildYeomanNpmPackage(outputRoot: string) {
const outputTemplatesRoot = path.join(outputRoot, 'app/templates');
rimraf.sync(outputTemplatesRoot);
// Copy template files
const filenameReplacements = [
{ from: /.*\.csproj$/, to: 'tokenreplace-namePascalCase.csproj' }
];
const contentReplacements = [
// Currently, there are none
];
_.forEach(templates, (templateConfig, templateName) => {
const outputDir = path.join(outputTemplatesRoot, templateName);
writeTemplate(templateConfig.dir, outputDir, contentReplacements, filenameReplacements);
});
// Also copy the generator files (that's the compiled .js files, plus all other non-.ts files)
const tempRoot = './tmp';
copyRecursive(path.join(tempRoot, 'yeoman'), outputRoot, '**/*.js');
copyRecursive(yeomanGeneratorSource, outputRoot, '**/!(*.ts)');
// Clean up
rimraf.sync(tempRoot);
}
function buildDotNetNewNuGetPackages(outputDir: string) {
const dotNetPackageIds = _.values(dotNetPackages);
dotNetPackageIds.forEach(packageId => {
@@ -275,12 +249,10 @@ function buildDotNetNewNuGetPackage(packageId: string) {
});
// Create the .nuspec file
const yeomanPackageVersion = JSON.parse(fs.readFileSync(path.join(yeomanGeneratorSource, 'package.json'), 'utf8')).version;
const nuspecContentTemplate = fs.readFileSync(`./src/dotnetnew/${ packageId }.nuspec`);
writeFileEnsuringDirExists(outputRoot,
`${ packageId }.nuspec`,
applyContentReplacements(nuspecContentTemplate, [
{ from: /\{yeomanversion\}/g, to: yeomanPackageVersion },
{ from: /\{buildnumber\}/g, to: getBuildNumber() },
])
);
@@ -313,16 +285,7 @@ function runPrepublishScripts(rootDir: string, scripts: string[]) {
const distDir = './dist';
const artifactsDir = path.join(distDir, 'artifacts');
const yeomanOutputRoot = path.join(distDir, 'generator-aspnetcore-spa');
rimraf.sync(distDir);
mkdirp.sync(artifactsDir);
buildYeomanNpmPackage(yeomanOutputRoot);
buildDotNetNewNuGetPackages(artifactsDir);
// Finally, create a .tar.gz file containing the built generator-aspnetcore-spa.
// The CI system can treat this as the final built artifact.
// Note that the targz APIs only come in async flavor.
targz().compress(yeomanOutputRoot, path.join(artifactsDir, 'generator-aspnetcore-spa.tar.gz'), err => {
if (err) { throw err; }
});

View File

@@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<id>Microsoft.AspNetCore.SpaTemplates</id>
<version>{yeomanversion}</version>
<version>1.0.{buildnumber}</version>
<description>Single Page Application templates for ASP.NET Core</description>
<authors>Microsoft</authors>
<language>en-US</language>