Remove all generated hashes from SPA templates (#11)

This commit is contained in:
Mike Harder 2018-06-20 14:29:21 -07:00 committed by GitHub
parent daebec95f3
commit d1afd66362
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 25 additions and 29 deletions

View File

@ -11,11 +11,9 @@ namespace AspNetCoreSdkTests.Templates
public override string Name => "angular";
// For some reason, the generated hash in main.[HASH].bundle.js is different on Windows and Linux, despite
// the file contents being identical. Replacing the generated hash with "[HASH]" allows the tests to pass
// on both platforms.
// Remove generated hashes since they may vary by platform
public override IEnumerable<string> FilesAfterPublish =>
base.FilesAfterPublish.Select(f => Regex.Replace(f, @"main\.[0-9a-f]+\.bundle\.js$", "main.[HASH].bundle.js"));
base.FilesAfterPublish.Select(f => Regex.Replace(f, @"\.[0-9a-f]{20}\.", ".[HASH]."));
public override IEnumerable<string> ExpectedFilesAfterPublish =>
base.ExpectedFilesAfterPublish
@ -23,16 +21,16 @@ namespace AspNetCoreSdkTests.Templates
{
Path.Combine("wwwroot", "favicon.ico"),
Path.Combine("ClientApp", "dist", "3rdpartylicenses.txt"),
Path.Combine("ClientApp", "dist", "glyphicons-halflings-regular.448c34a56d699c29117a.woff2"),
Path.Combine("ClientApp", "dist", "glyphicons-halflings-regular.89889688147bd7575d63.svg"),
Path.Combine("ClientApp", "dist", "glyphicons-halflings-regular.e18bbf611f2a2e43afc0.ttf"),
Path.Combine("ClientApp", "dist", "glyphicons-halflings-regular.f4769f9bdb7466be6508.eot"),
Path.Combine("ClientApp", "dist", "glyphicons-halflings-regular.fa2772327f55d8198301.woff"),
Path.Combine("ClientApp", "dist", "glyphicons-halflings-regular.[HASH].woff2"),
Path.Combine("ClientApp", "dist", "glyphicons-halflings-regular.[HASH].svg"),
Path.Combine("ClientApp", "dist", "glyphicons-halflings-regular.[HASH].ttf"),
Path.Combine("ClientApp", "dist", "glyphicons-halflings-regular.[HASH].eot"),
Path.Combine("ClientApp", "dist", "glyphicons-halflings-regular.[HASH].woff"),
Path.Combine("ClientApp", "dist", "index.html"),
Path.Combine("ClientApp", "dist", "inline.318b50c57b4eba3d437b.bundle.js"),
Path.Combine("ClientApp", "dist", "inline.[HASH].bundle.js"),
Path.Combine("ClientApp", "dist", "main.[HASH].bundle.js"),
Path.Combine("ClientApp", "dist", "polyfills.bf95165a1d5098766b92.bundle.js"),
Path.Combine("ClientApp", "dist", "styles.2727681ffee5a66f9fe6.bundle.css"),
Path.Combine("ClientApp", "dist", "polyfills.[HASH].bundle.js"),
Path.Combine("ClientApp", "dist", "styles.[HASH].bundle.css"),
});
}
}

View File

@ -1,16 +1,9 @@
using System.Collections.Generic;
using System.Linq;
namespace AspNetCoreSdkTests.Templates
namespace AspNetCoreSdkTests.Templates
{
public class ReactReduxTemplate : ReactTemplate
{
public ReactReduxTemplate() { }
public override string Name => "reactredux";
public override IEnumerable<string> ExpectedFilesAfterPublish =>
from f in base.ExpectedFilesAfterPublish
select f.Replace("main.31eb739b.js", "main.485d93fa.js");
}
}

View File

@ -1,6 +1,7 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
namespace AspNetCoreSdkTests.Templates
{
@ -10,6 +11,10 @@ namespace AspNetCoreSdkTests.Templates
public override string Name => "react";
// Remove generated hashes since they may var by platform
public override IEnumerable<string> FilesAfterPublish =>
base.FilesAfterPublish.Select(f => Regex.Replace(f, @"\.[0-9a-f]{8}\.", ".[HASH]."));
public override IEnumerable<string> ExpectedFilesAfterPublish =>
base.ExpectedFilesAfterPublish
.Concat(new[]
@ -19,15 +24,15 @@ namespace AspNetCoreSdkTests.Templates
Path.Combine("ClientApp", "build", "index.html"),
Path.Combine("ClientApp", "build", "manifest.json"),
Path.Combine("ClientApp", "build", "service-worker.js"),
Path.Combine("ClientApp", "build", "static", "css", "main.8302bbea.css"),
Path.Combine("ClientApp", "build", "static", "css", "main.8302bbea.css.map"),
Path.Combine("ClientApp", "build", "static", "js", "main.31eb739b.js"),
Path.Combine("ClientApp", "build", "static", "js", "main.31eb739b.js.map"),
Path.Combine("ClientApp", "build", "static", "media", "glyphicons-halflings-regular.448c34a5.woff2"),
Path.Combine("ClientApp", "build", "static", "media", "glyphicons-halflings-regular.89889688.svg"),
Path.Combine("ClientApp", "build", "static", "media", "glyphicons-halflings-regular.e18bbf61.ttf"),
Path.Combine("ClientApp", "build", "static", "media", "glyphicons-halflings-regular.f4769f9b.eot"),
Path.Combine("ClientApp", "build", "static", "media", "glyphicons-halflings-regular.fa277232.woff"),
Path.Combine("ClientApp", "build", "static", "css", "main.[HASH].css"),
Path.Combine("ClientApp", "build", "static", "css", "main.[HASH].css.map"),
Path.Combine("ClientApp", "build", "static", "js", "main.[HASH].js"),
Path.Combine("ClientApp", "build", "static", "js", "main.[HASH].js.map"),
Path.Combine("ClientApp", "build", "static", "media", "glyphicons-halflings-regular.[HASH].woff2"),
Path.Combine("ClientApp", "build", "static", "media", "glyphicons-halflings-regular.[HASH].svg"),
Path.Combine("ClientApp", "build", "static", "media", "glyphicons-halflings-regular.[HASH].ttf"),
Path.Combine("ClientApp", "build", "static", "media", "glyphicons-halflings-regular.[HASH].eot"),
Path.Combine("ClientApp", "build", "static", "media", "glyphicons-halflings-regular.[HASH].woff"),
});
}
}