Skip to content

Commit

Permalink
Updated general and empty templates
Browse files Browse the repository at this point in the history
  • Loading branch information
jan-bures committed Oct 30, 2023
1 parent c36319c commit de8dd48
Show file tree
Hide file tree
Showing 14 changed files with 74 additions and 22 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project>
<PropertyGroup Label="Framework and language configuration">
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFramework>netstandard2.1</TargetFramework>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<LangVersion>latest</LangVersion>
<ImplicitUsings>true</ImplicitUsings>
Expand Down Expand Up @@ -38,9 +38,6 @@
<JsonPeek ContentPath="$(SolutionDir)/plugin_template/swinfo.json" Query="$">
<Output TaskParameter="Result" ItemName="Swinfo"/>
</JsonPeek>
<JsonPeek ContentPath="$(SolutionDir)/plugin_template/swinfo.json" Query="$.dependencies">
<Output TaskParameter="Result" ItemName="Dependencies"/>
</JsonPeek>

<!-- Extract properties from the JSON -->
<PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"spec": "1.3",
"spec": "2.0",
"mod_id": "SpaceWarpMod",
"author": "swinfo_author",
"name": "swinfo_name",
Expand All @@ -8,14 +8,14 @@
"version": "swinfo_version",
"version_check": "swinfo_checkversion",
"ksp2_version": {
"min": "0.1.4",
"min": "0.1.5",
"max": "*"
},
"dependencies": [
{
"id": "com.github.x606.spacewarp",
"version": {
"min": "1.4.3",
"min": "1.5.2",
"max": "*"
}
}
Expand Down
25 changes: 25 additions & 0 deletions SpaceWarp.Template/templates/SpaceWarpMod/scripts/setup.bat
Original file line number Diff line number Diff line change
@@ -1,19 +1,44 @@
@echo off

:: Get the name of the current directory and extract the last folder name
for %%I in (%CD%) do set CURR_DIR_NAME=%%~nxI

:: Check if the current directory name is "scripts" and change to the parent directory if true
if /i "%CURR_DIR_NAME%"=="scripts" (
cd ..
)

:: Inform the user about the PowerShell module check and installation, then wait for a key press to continue
echo The Microsoft.PowerShell.Archive module will be checked for updates due to a bug that affects zipping of mod releases, breaking their CKAN installation.
echo The script will open in a new windows and request administrative privileges if there is a required package update. Please allow it to proceed until it closes itself.
echo Press any key to continue...
pause >nul

:: Execute the PowerShell script to check and install the necessary module version
powershell -ExecutionPolicy Bypass -File "scripts\setup\check_archive_version.ps1"

:: Check if the KSP2DIR variable is set, and if it is, skip to the licensing step
if not "%KSP2DIR%" == "" (
goto license_start
)

:: Call another batch file to set environment variables
call "scripts\setup\set_env_var.bat"

:license_start

:: Call another batch file for licensing
call "scripts\setup\license.bat"

:: Initialize git for the project
call "scripts\setup\git_init.bat"

:: Remove the setup scripts directory after the setup is completed
rmdir /s /q "scripts\setup"

:: Display a message indicating the setup process is finished
echo.
echo Setup is finished.

:: Delete this batch file after it finishes executing
(goto) 2>nul & del "%~f0"
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
$module = Get-Module -ListAvailable Microsoft.PowerShell.Archive -ErrorAction SilentlyContinue | Sort-Object Version -Descending | Select-Object -First 1
if (-not $module -or [version]$module.Version -lt [version]'1.2.3.0') {
Start-Process powershell -ArgumentList 'Install-Module Microsoft.PowerShell.Archive -MinimumVersion 1.2.3.0 -Repository PSGallery -Force; Import-Module Microsoft.PowerShell.Archive' -Verb RunAs
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
<PackageReference Include="BepInEx.Core" Version="5.*"/>
<PackageReference Include="BepInEx.PluginInfoProps" Version="2.*"/>
<PackageReference Include="HarmonyX" Version="2.10.1"/>
<PackageReference Include="KerbalSpaceProgram2.GameLibs" Version="0.1.4" PrivateAssets="all"/>
<PackageReference Include="SpaceWarp" Version="1.4.0"/>
<PackageReference Include="UnityEngine.Modules" Version="2020.3.33.1"/>
<PackageReference Include="KerbalSpaceProgram2.GameLibs" Version="0.1.5" PrivateAssets="all"/>
<PackageReference Include="SpaceWarp" Version="1.5.2"/>
<PackageReference Include="UnityEngine.Modules" Version="2022.3.5"/>
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ namespace SpaceWarpMod;
[BepInDependency(SpaceWarpPlugin.ModGuid, SpaceWarpPlugin.ModVer)]
public class SpaceWarpModPlugin : BaseSpaceWarpPlugin
{
// These are useful in case some other mod wants to add a dependency to this one
// Useful in case some other mod wants to use this mod a dependency
[PublicAPI] public const string ModGuid = MyPluginInfo.PLUGIN_GUID;
[PublicAPI] public const string ModName = MyPluginInfo.PLUGIN_NAME;
[PublicAPI] public const string ModVer = MyPluginInfo.PLUGIN_VERSION;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project>
<PropertyGroup Label="Framework and language configuration">
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFramework>netstandard2.1</TargetFramework>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<LangVersion>latest</LangVersion>
<ImplicitUsings>true</ImplicitUsings>
Expand Down Expand Up @@ -38,9 +38,6 @@
<JsonPeek ContentPath="$(SolutionDir)/plugin_template/swinfo.json" Query="$">
<Output TaskParameter="Result" ItemName="Swinfo"/>
</JsonPeek>
<JsonPeek ContentPath="$(SolutionDir)/plugin_template/swinfo.json" Query="$.dependencies">
<Output TaskParameter="Result" ItemName="Dependencies"/>
</JsonPeek>

<!-- Extract properties from the JSON -->
<PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"spec": "1.3",
"spec": "2.0",
"mod_id": "SpaceWarpModEmpty",
"author": "swinfo_author",
"name": "swinfo_name",
Expand All @@ -8,14 +8,14 @@
"version": "swinfo_version",
"version_check": "swinfo_checkversion",
"ksp2_version": {
"min": "0.1.4",
"min": "0.1.5",
"max": "*"
},
"dependencies": [
{
"id": "com.github.x606.spacewarp",
"version": {
"min": "1.4.3",
"min": "1.5.2",
"max": "*"
}
}
Expand Down
25 changes: 25 additions & 0 deletions SpaceWarp.Template/templates/SpaceWarpModEmpty/scripts/setup.bat
Original file line number Diff line number Diff line change
@@ -1,19 +1,44 @@
@echo off

:: Get the name of the current directory and extract the last folder name
for %%I in (%CD%) do set CURR_DIR_NAME=%%~nxI

:: Check if the current directory name is "scripts" and change to the parent directory if true
if /i "%CURR_DIR_NAME%"=="scripts" (
cd ..
)

:: Inform the user about the PowerShell module check and installation, then wait for a key press to continue
echo The Microsoft.PowerShell.Archive module will be checked for updates due to a bug that affects zipping of mod releases, breaking their CKAN installation.
echo The script will open in a new windows and request administrative privileges if there is a required package update. Please allow it to proceed until it closes itself.
echo Press any key to continue...
pause >nul

:: Execute the PowerShell script to check and install the necessary module version
powershell -ExecutionPolicy Bypass -File "scripts\setup\check_archive_version.ps1"

:: Check if the KSP2DIR variable is set, and if it is, skip to the licensing step
if not "%KSP2DIR%" == "" (
goto license_start
)

:: Call another batch file to set environment variables
call "scripts\setup\set_env_var.bat"

:license_start

:: Call another batch file for licensing
call "scripts\setup\license.bat"

:: Initialize git for the project
call "scripts\setup\git_init.bat"

:: Remove the setup scripts directory after the setup is completed
rmdir /s /q "scripts\setup"

:: Display a message indicating the setup process is finished
echo.
echo Setup is finished.

:: Delete this batch file after it finishes executing
(goto) 2>nul & del "%~f0"
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
$module = Get-Module -ListAvailable Microsoft.PowerShell.Archive -ErrorAction SilentlyContinue | Sort-Object Version -Descending | Select-Object -First 1
if (-not $module -or [version]$module.Version -lt [version]'1.2.3.0') {
Start-Process powershell -ArgumentList 'Install-Module Microsoft.PowerShell.Archive -MinimumVersion 1.2.3.0 -Repository PSGallery -Force; Import-Module Microsoft.PowerShell.Archive' -Verb RunAs
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
<PackageReference Include="BepInEx.Core" Version="5.*"/>
<PackageReference Include="BepInEx.PluginInfoProps" Version="2.*"/>
<PackageReference Include="HarmonyX" Version="2.10.1"/>
<PackageReference Include="KerbalSpaceProgram2.GameLibs" Version="0.1.4" PrivateAssets="all"/>
<PackageReference Include="SpaceWarp" Version="1.4.0"/>
<PackageReference Include="UnityEngine.Modules" Version="2020.3.33.1"/>
<PackageReference Include="KerbalSpaceProgram2.GameLibs" Version="0.1.5" PrivateAssets="all"/>
<PackageReference Include="SpaceWarp" Version="1.5.2"/>
<PackageReference Include="UnityEngine.Modules" Version="2022.3.5"/>
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace SpaceWarpModEmpty;
[BepInDependency(SpaceWarpPlugin.ModGuid, SpaceWarpPlugin.ModVer)]
public class SpaceWarpModEmptyPlugin : BaseSpaceWarpPlugin
{
// These are useful in case some other mod wants to add a dependency to this one
// Useful in case some other mod wants to use this mod a dependency
[PublicAPI] public const string ModGuid = MyPluginInfo.PLUGIN_GUID;
[PublicAPI] public const string ModName = MyPluginInfo.PLUGIN_NAME;
[PublicAPI] public const string ModVer = MyPluginInfo.PLUGIN_VERSION;
Expand Down

0 comments on commit de8dd48

Please sign in to comment.