Skip to content

Commit

Permalink
#7 Update scripts for more granular handling of processes, remove npm…
Browse files Browse the repository at this point in the history
… related script execution from f# projects
  • Loading branch information
Jooseppi12 committed Jan 22, 2021
1 parent c7d1a60 commit a9b47bb
Show file tree
Hide file tree
Showing 17 changed files with 326 additions and 59 deletions.
1 change: 1 addition & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ jobs:
with:
dotnet-version: '3.1.x'
- run: |
bash ./install.sh -buildonly
bash ./build.sh
- name: Deploy 🚀
Expand Down
82 changes: 73 additions & 9 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"version": "2.0.0",
"tasks": [
{
"label": "Build",
"label": "Build Solution in Release mode",
"type": "shell",
"command": "./build.sh",
"windows": {
Expand All @@ -17,11 +17,11 @@
}
},
{
"label": "Build (Debug)",
"label": "Build Solution in Debug mode",
"type": "shell",
"command": "./build.sh debug",
"command": "./build.sh -deb",
"windows": {
"command": ".\\build.ps1 debug"
"command": ".\\build.ps1 -deb"
},
"group": "build",
"presentation": {
Expand All @@ -30,7 +30,33 @@
}
},
{
"label": "Install",
"label": "Build Project in Debug mode",
"type": "shell",
"command": "./build.sh -deb -project ${input:project}",
"windows": {
"command": ".\\build.ps1 -deb -project ${input:project}"
},
"group": "build",
"presentation": {
"reveal": "always",
"panel": "new"
}
},
{
"label": "Build Project in Release mode",
"type": "shell",
"command": "./build.sh -project ${input:project}",
"windows": {
"command": ".\\build.ps1 -project ${input:project}"
},
"group": "build",
"presentation": {
"reveal": "always",
"panel": "new"
}
},
{
"label": "Install with tools",
"type": "shell",
"command": "./install.sh",
"windows": {
Expand All @@ -43,11 +69,11 @@
}
},
{
"label": "Install with tools",
"label": "Install",
"type": "shell",
"command": "./install.sh --buildonly",
"command": "./install.sh -buildonly",
"windows": {
"command": ".\\install.ps1 --buildOnly"
"command": ".\\install.ps1 -buildOnly"
},
"group": "build",
"presentation": {
Expand All @@ -56,7 +82,7 @@
}
},
{
"label": "Run",
"label": "Run Hosted",
"type": "shell",
"command": "./run.sh",
"windows": {
Expand All @@ -67,6 +93,44 @@
"reveal": "always",
"panel": "new"
}
},
{
"label": "Serve as an offline sitelet",
"type": "shell",
"command": "./run.sh",
"windows": {
"command": ".\\run.ps1"
},
"group": "build",
"presentation": {
"reveal": "always",
"panel": "new"
}
},
{
"label": "CSS Server",
"type": "shell",
"command": "./grunt-watch.sh",
"windows": {
"command": ".\\grunt-watch.ps1"
},
"group": "build",
"presentation": {
"reveal": "always",
"panel": "new"
}
}
],
"inputs": [
{
"type": "pickString",
"id": "project",
"description": "Which project you want to build?",
"options": [
"client",
"hosted",
"website"
]
}
]
}
44 changes: 24 additions & 20 deletions build.ps1
Original file line number Diff line number Diff line change
@@ -1,25 +1,29 @@
echo "Copy legal files"

xcopy .\legal\site-docs\intellifactory.com\* .\src\Hosted\legal\ /s /e /y

echo "Copy blog posts files"

xcopy .\blogs\user\* .\src\Hosted\posts\ /s /e /y

echo "Running npm install"

pushd src/Hosted
npm install
popd
Param(
[Switch]
$deb,
[Parameter(Mandatory=$false)]
[ValidateSet("client", "hosted", "website")]
[String]
$project
)

echo "Running dotnet build"

$mode=$args[0]
echo "Param $mode"
if ($mode -ieq "debug") {
echo "Running build in Debug mode..."
dotnet build SiteFi.sln -c Debug
if ($project -ne "") {
if ($deb) {
echo "Running build in Debug mode..."
dotnet build "src\$project\$project.fsproj" --no-incremental -c Debug
} else {
echo "Running build in Release mode..."
dotnet build "src\$project\$project.fsproj" --no-incremental
}
} else {
echo "Running build in Release mode..."
dotnet build SiteFi.sln
if ($deb) {
echo "Running build in Debug mode..."
dotnet build SiteFi.sln --no-incremental -c Debug
} else {
echo "Running build in Release mode..."
dotnet build SiteFi.sln --no-incremental
}
}

52 changes: 31 additions & 21 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,29 +1,39 @@
#!/bin/bash

echo "Copy legal/site-docs/if.com/ under src/Hosted/legal/"

cp -r legal/site-docs/intellifactory.com/ src/Hosted/legal/

echo "Copy blogposts under /src/Hosted/posts"

cp -r blogs/user src/Hosted/posts

echo "Installing dotnet-serve"

dotnet tool install dotnet-serve --tool-path .tools

echo "Running npm install"

pushd src/Hosted
npm install
popd

echo "Running dotnet build"

if ["{$1^^}" -eq "DEBUG"]
if [[ $(echo "$2" | awk '{print toupper($0)}') = "-PROJECT" ]];
then
dotnet build SiteFi.sln -c Debug
if [[ $(echo "$3" | awk '{print toupper($0)}') = "CLIENT" ]] || [[ $(echo "$3" | awk '{print toupper($0)}') = "WEBSITE" ]] || [[ $(echo "$3" | awk '{print toupper($0)}') = "HOSTED" ]];
then
if [[ $(echo "$1" | awk '{print toupper($0)}') = "-DEB" ]];
then
dotnet build "src/$3/$3.fsproj" --no-incremental -c Debug
else
dotnet build "src/$3/$3.fsproj" --no-incremental
fi
else
>&2 echo "Incorrect project name"
exit 1
fi
else
dotnet build SiteFi.sln
if [[ $(echo "$1" | awk '{print toupper($0)}') = "-PROJECT" ]];
then
if [[ $(echo "$2" | awk '{print toupper($0)}') = "CLIENT" ]] || [[ $(echo "$2" | awk '{print toupper($0)}') = "WEBSITE" ]] || [[ $(echo "$2" | awk '{print toupper($0)}') = "HOSTED" ]];
then
dotnet build "src/$2/$2.fsproj" --no-incremental
else
>&2 echo "Incorrect project name"
exit 1
fi
else
if [[ $(echo "$1" | awk '{print toupper($0)}') = "-DEB" ]];
then
dotnet build SiteFi.sln --no-incremental -c Debug
else
dotnet build SiteFi.sln --no-incremental
fi
fi
fi


2 changes: 2 additions & 0 deletions grunt-watch.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
cd src/Hosted
npx grunt develop
2 changes: 2 additions & 0 deletions grunt-watch.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
cd src/Hosted
npx grunt develop
4 changes: 4 additions & 0 deletions install.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@ param(
[switch] $buildOnly
)

# Initialize git submodules
git submodule update --init --recursive

# Install npm packages
pushd src\Hosted
npm install
npx grunt
popd

if (!$buildOnly) {
Expand Down
15 changes: 13 additions & 2 deletions install.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,22 @@
#!/bin/bash

# Initialize git submodules
git submodule update --init --recursive

echo "Copy legal/site-docs/if.com/ under src/Hosted/legal/"
cp -r legal/site-docs/intellifactory.com/ src/Hosted/legal/

echo "Copy blogposts under /src/Hosted/posts"
cp -r blogs/user src/Hosted/posts

# Install npm packages
pushd src/Hosted
npm install
npx grunt
popd

if ["{$1^^}" -eq "--BUILDONLY"] {
if [[ $(echo "$1" | awk '{print toupper($0)}') = "-BUILDONLY" ]];
then
# Install local dotnet-serve
dotnet tool install dotnet-serve --tool-path .tools
}
fi
2 changes: 1 addition & 1 deletion run.ps1
Original file line number Diff line number Diff line change
@@ -1 +1 @@
.tools/dotnet-serve.exe -d build -p:56001 --default-extensions:.html -a 0.0.0.0
dotnet run --project src\Hosted\Hosted.fsproj
2 changes: 1 addition & 1 deletion run.sh
Original file line number Diff line number Diff line change
@@ -1 +1 @@
".tools/dotnet-serve.exe" -d build -p:56001 --default-extensions:.html -a 0.0.0.0
dotnet run --project src/Hosted/Hosted.fsproj
1 change: 1 addition & 0 deletions serve.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.tools/dotnet-serve.exe -d build -p:56001 --default-extensions:.html -a 0.0.0.0
1 change: 1 addition & 0 deletions serve.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
".tools/dotnet-serve.exe" -d build -p:56001 --default-extensions:.html -a 0.0.0.0
12 changes: 12 additions & 0 deletions src/Hosted/Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,24 @@ module.exports = function(grunt) {
'assets/custom.css': 'assets/custom.scss'
}
}
},
watch: {
sass: {
files: ['**/*.scss'],
tasks: ['sass']
},
cssmin: {
files: ['**/*.css'],
tasks: ['cssmin']
}
}
});

grunt.loadNpmTasks('grunt-sass');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.loadNpmTasks('grunt-contrib-watch');

grunt.registerTask('develop', ['sass','cssmin','watch']);
grunt.registerTask('default', ['sass','cssmin']);
};
5 changes: 0 additions & 5 deletions src/Hosted/Hosted.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
</ItemGroup>

<Target Name="CleanGeneratedFiles" AfterTargets="Clean">
<Delete Files="$(MSBuildProjectDirectory)/css/all*.css" />
<RemoveDir Directories="$(MSBuildProjectDirectory)/Content" />
<RemoveDir Directories="$(MSBuildProjectDirectory)/Scripts" />
</Target>
Expand All @@ -41,10 +40,6 @@
<PackageReference Include="YamlDotNet" Version="8.0.0" />
</ItemGroup>

<Target Name="Webcompile" BeforeTargets="BeforeBuild">
<Exec Command="npx grunt" WorkingDirectory="$(SolutionDir)src/Hosted" />
</Target>

<ItemGroup>
<ProjectReference Include="..\Client\Client.fsproj" />
</ItemGroup>
Expand Down
Loading

0 comments on commit a9b47bb

Please sign in to comment.