mirror of
https://github.com/aspnet/JavaScriptServices.git
synced 2025-12-22 17:47:53 +00:00
Make template package version numbers more descriptive
This commit is contained in:
@@ -56,18 +56,20 @@ function listFilesExcludingGitignored(root: string): string[] {
|
||||
.filter(fn => gitignoreEvaluator.accepts(fn));
|
||||
}
|
||||
|
||||
function applyContentReplacements(sourceContent: Buffer, contentReplacements: { from: RegExp, to: string }[]) {
|
||||
let sourceText = sourceContent.toString('utf8');
|
||||
contentReplacements.forEach(replacement => {
|
||||
sourceText = sourceText.replace(replacement.from, replacement.to);
|
||||
});
|
||||
|
||||
return new Buffer(sourceText, 'utf8');
|
||||
}
|
||||
|
||||
function writeTemplate(sourceRoot: string, destRoot: string, contentReplacements: { from: RegExp, to: string }[], filenameReplacements: { from: RegExp, to: string }[]) {
|
||||
listFilesExcludingGitignored(sourceRoot).forEach(fn => {
|
||||
let sourceContent = fs.readFileSync(path.join(sourceRoot, fn));
|
||||
|
||||
// For text files, replace hardcoded values with template tags
|
||||
if (isTextFile(fn)) {
|
||||
let sourceText = sourceContent.toString('utf8');
|
||||
contentReplacements.forEach(replacement => {
|
||||
sourceText = sourceText.replace(replacement.from, replacement.to);
|
||||
});
|
||||
|
||||
sourceContent = new Buffer(sourceText, 'utf8');
|
||||
sourceContent = applyContentReplacements(sourceContent, contentReplacements);
|
||||
}
|
||||
|
||||
// Also apply replacements in filenames
|
||||
@@ -87,6 +89,11 @@ function copyRecursive(sourceRoot: string, destRoot: string, matchGlob: string)
|
||||
});
|
||||
}
|
||||
|
||||
function getBuildNumber() {
|
||||
return process.env.APPVEYOR_BUILD_NUMBER
|
||||
|| ('t-' + Math.floor((new Date().valueOf() - new Date(2017, 0, 1).valueOf()) / (60*1000)));
|
||||
}
|
||||
|
||||
function buildYeomanNpmPackage(outputRoot: string) {
|
||||
const outputTemplatesRoot = path.join(outputRoot, 'app/templates');
|
||||
rimraf.sync(outputTemplatesRoot);
|
||||
@@ -226,14 +233,18 @@ function buildDotNetNewNuGetPackage(packageId: string) {
|
||||
}, null, 2));
|
||||
});
|
||||
|
||||
// Invoke NuGet to create the final package
|
||||
// Create the .nuspec file
|
||||
const yeomanPackageVersion = JSON.parse(fs.readFileSync(path.join(yeomanGeneratorSource, 'package.json'), 'utf8')).version;
|
||||
writeTemplate('./src/dotnetnew', outputRoot, [
|
||||
{ from: /\{packageId\}/g, to: packageId },
|
||||
{ from: /\{version\}/g, to: yeomanPackageVersion },
|
||||
], [
|
||||
{ from: /.*\.nuspec$/, to: `${packageId}.nuspec` },
|
||||
]);
|
||||
const nuspecContentTemplate = fs.readFileSync(`./src/dotnetnew/${ packageId }.nuspec`);
|
||||
writeFileEnsuringDirExists(outputRoot,
|
||||
`${ packageId }.nuspec`,
|
||||
applyContentReplacements(nuspecContentTemplate, [
|
||||
{ from: /\{yeomanversion\}/g, to: yeomanPackageVersion },
|
||||
{ from: /\{buildnumber\}/g, to: getBuildNumber() },
|
||||
])
|
||||
);
|
||||
|
||||
// Invoke NuGet to create the final package
|
||||
const nugetExe = path.join(process.cwd(), './bin/NuGet.exe');
|
||||
const nugetStartInfo = { cwd: outputRoot, stdio: 'inherit' };
|
||||
if (isWindows) {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
|
||||
<metadata>
|
||||
<id>{packageId}</id>
|
||||
<version>{version}</version>
|
||||
<id>Microsoft.AspNetCore.SpaTemplates</id>
|
||||
<version>{yeomanversion}</version>
|
||||
<description>Single Page Application templates for ASP.NET Core</description>
|
||||
<authors>Microsoft</authors>
|
||||
<language>en-US</language>
|
||||
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
|
||||
<metadata>
|
||||
<id>Microsoft.DotNet.Web.Spa.ProjectTemplates</id>
|
||||
<version>2.0.0-preview2-{buildnumber}</version>
|
||||
<description>Single Page Application templates for ASP.NET Core</description>
|
||||
<authors>Microsoft</authors>
|
||||
<language>en-US</language>
|
||||
<projectUrl>https://github.com/aspnet/javascriptservices</projectUrl>
|
||||
<licenseUrl>https://www.microsoft.com/web/webpi/eula/net_library_eula_enu.htm</licenseUrl>
|
||||
<copyright>Copyright © Microsoft Corporation</copyright>
|
||||
<requireLicenseAcceptance>true</requireLicenseAcceptance>
|
||||
<packageTypes>
|
||||
<packageType name="Template" />
|
||||
</packageTypes>
|
||||
</metadata>
|
||||
</package>
|
||||
Reference in New Issue
Block a user