Remove NPM dependency

This commit is contained in:
Robert Marshall 2023-06-24 10:30:57 +01:00
parent 9e7545e729
commit a1c842c239
8 changed files with 36 additions and 72 deletions

4
.gitignore vendored
View file

@ -54,4 +54,6 @@ output
_NCrunch_Website
*.DotSettings
.nuke/temp
.nuke/temp
fontawesome

View file

@ -1,8 +1,6 @@
FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build-env
WORKDIR /app
COPY . ./
RUN curl -sL https://deb.nodesource.com/setup_18.x | bash -
RUN apt-get install -y nodejs
RUN chmod +x ./build.sh
RUN ./build.sh

View file

@ -1,4 +1,9 @@
using System;
using System.IO;
using System.IO.Compression;
using System.Media;
using System.Net.Http;
using System.Threading.Tasks;
using Nuke.Common;
using Nuke.Common.Execution;
using Nuke.Common.IO;
@ -19,17 +24,39 @@ class Build : NukeBuild
AbsolutePath OutputDirectory => RootDirectory / "output";
AbsolutePath SourceDirectory => RootDirectory / "src";
AbsolutePath LibPath => SourceDirectory / "Website/wwwroot/lib";
AbsolutePath FontAwesomePath => SourceDirectory / "Website/wwwroot/lib/fontawesome";
Target Clean => _ => _
private void DeleteExistingFontAwesome()
{
if (Directory.Exists(FontAwesomePath))
Directory.Delete(FontAwesomePath, true);
}
Target Clean => _ => _
.Before(Restore)
.Executes(() =>
{
DeleteExistingFontAwesome();
EnsureCleanDirectory(OutputDirectory);
});
private async Task DownloadFontAwesome() {
const string fontAwesomeVersion = "6.4.0";
const string zipName = $"fontawesome-free-{fontAwesomeVersion}-web";
var client = new HttpClient();
var response = await client.GetAsync($"https://use.fontawesome.com/releases/v{fontAwesomeVersion}/{zipName}.zip");
var memory = new MemoryStream();
await response.Content.CopyToAsync(memory);
var zip = new ZipArchive(memory);
zip.ExtractToDirectory(LibPath);
Directory.Move(LibPath / zipName, FontAwesomePath);
}
Target Restore => _ => _
.Executes(() =>
{
.DependsOn(Clean)
.Executes(() => {
DownloadFontAwesome().Wait();
DotNetRestore(s => s
.SetProjectFile(Solution));
});
@ -60,15 +87,6 @@ class Build : NukeBuild
.SetProject(SourceDirectory / "Website/Website.csproj")
.SetConfiguration(Configuration)
.SetOutput(OutputDirectory));
var scssFiles = Directory.GetFiles(OutputDirectory / "wwwroot/css", "*.scss");
foreach (var file in scssFiles)
File.Delete(file);
var cssFiles = Directory.GetFiles(OutputDirectory / "wwwroot/css", "*.css");
foreach (var file in cssFiles)
if (new FileInfo(file).Length == 0)
File.Delete(file);
});
}

View file

@ -23,8 +23,4 @@
<ItemGroup>
<ProjectReference Include="..\Website.Markdig.Extensions\Website.Markdig.Extensions.csproj" />
</ItemGroup>
<Target Name="BuildCss" BeforeTargets="Build">
<Exec WorkingDirectory="$(ProjectDir)" Command="npm install" />
</Target>
</Project>

View file

@ -1,33 +0,0 @@
{
"name": "website",
"version": "1.0.0",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "website",
"version": "1.0.0",
"license": "ISC",
"dependencies": {
"@fortawesome/fontawesome-free": "^6.2.1"
},
"devDependencies": {}
},
"node_modules/@fortawesome/fontawesome-free": {
"version": "6.2.1",
"resolved": "https://registry.npmjs.org/@fortawesome/fontawesome-free/-/fontawesome-free-6.2.1.tgz",
"integrity": "sha512-viouXhegu/TjkvYQoiRZK3aax69dGXxgEjpvZW81wIJdxm5Fnvp3VVIP4VHKqX4SvFw6qpmkILkD4RJWAdrt7A==",
"hasInstallScript": true,
"engines": {
"node": ">=6"
}
}
},
"dependencies": {
"@fortawesome/fontawesome-free": {
"version": "6.2.1",
"resolved": "https://registry.npmjs.org/@fortawesome/fontawesome-free/-/fontawesome-free-6.2.1.tgz",
"integrity": "sha512-viouXhegu/TjkvYQoiRZK3aax69dGXxgEjpvZW81wIJdxm5Fnvp3VVIP4VHKqX4SvFw6qpmkILkD4RJWAdrt7A=="
}
}
}

View file

@ -1,16 +0,0 @@
{
"name": "website",
"version": "1.0.0",
"description": "",
"main": "index.js",
"devDependencies": {
},
"dependencies": {
"@fortawesome/fontawesome-free": "^6.2.1"
},
"scripts": {
},
"author": "Robert Marshall",
"license": "ISC",
"private": true
}

View file

@ -1,8 +1,8 @@
@import url("https://fonts.googleapis.com/css?family=Public+Sans&display=swap");
@import "colours.scss";
$fa-font-path: "../webfonts";
@import "../../node_modules/@fortawesome/fontawesome-free/scss/fontawesome.scss";
@import "../../node_modules/@fortawesome/fontawesome-free/scss/solid.scss";
$fa-font-path: "../lib/fontawesome/webfonts";
@import "../lib/fontawesome/scss/fontawesome.scss";
@import "../lib/fontawesome/scss/solid.scss";
* {
box-sizing: border-box;

View file

@ -1 +0,0 @@
../node_modules/@fortawesome/fontawesome-free/webfonts