diff --git a/.gitignore b/.gitignore index 1f9fc29..91fddb7 100644 --- a/.gitignore +++ b/.gitignore @@ -30,6 +30,9 @@ __pycache__ .mypy_cache .pytest_cache +# Rust +target + # data data !data/config.toml diff --git a/md_parser/Cargo.lock b/md_parser/Cargo.lock new file mode 100644 index 0000000..da1896e --- /dev/null +++ b/md_parser/Cargo.lock @@ -0,0 +1,7 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "md_parser" +version = "0.1.0" diff --git a/md_parser/Cargo.toml b/md_parser/Cargo.toml new file mode 100644 index 0000000..c3c2332 --- /dev/null +++ b/md_parser/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "md_parser" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/md_parser/src/lib.rs b/md_parser/src/lib.rs new file mode 100644 index 0000000..e69de29 diff --git a/md_parser/src/main.rs b/md_parser/src/main.rs new file mode 100644 index 0000000..e7a11a9 --- /dev/null +++ b/md_parser/src/main.rs @@ -0,0 +1,3 @@ +fn main() { + println!("Hello, world!"); +} diff --git a/package.json b/package.json index 9be25d2..67e59f0 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "pap", "private": true, - "version": "0.1.1", + "version": "0.1.3", "type": "module", "scripts": { "dev": "vite", diff --git a/scripts/pap.ps1 b/scripts/pap.ps1 index 4c23027..e4428de 100644 --- a/scripts/pap.ps1 +++ b/scripts/pap.ps1 @@ -21,7 +21,7 @@ PS .\pap.ps1 -Dev [CmdletBinding()] param ( - [switch] $Update, + [switch] $Update ) # Function to activate Python virtual environment @@ -36,9 +36,36 @@ function Open-Venv { } } -if ($Update) { - if (Test-Path ".venv") { - Remove-Item -Path .\.venv -Recurse -Force +if ($Update -eq $true) { + $latestRelease = Invoke-WebRequest -Uri "https://api.github.com/repos/WindLX/Pap/releases/latest" | ConvertFrom-Json + $downloadUrl = ($latestRelease.assets | Where-Object { $_.name -eq "PapPack.tar.gz" }).browser_download_url + + if (-z $downloadUrl) { + Write-Error "Error: Unable to find download URL for Pap in the latest release." + exit 1 + } + + Write-Output "Downloading PapPack.tar.gz..." + Invoke-WebRequest -Uri $downloadUrl -OutFile "PapPack.tar.gz" + + Write-Output "Extracting PapPack.tar.gz..." + Expand-Archive -Path "PapPack.tar.gz" -DestinationPath .\ + + Remove-Item .\dist -Recurse -Force + Remove-Item .\src-python -Recurse -Force + Remove-Item .\README.md -Force + Remove-Item .\requirements_release.txt -Force + + Move-Item .\PapPack\dist .\dist + Move-Item .\PapPack\src-python .\src-python + Move-Item .\PapPack\README.md .\README.md + Move-Item .\PapPack\requirements_release.txt .\requirements_release.txt + + Remove-Item .\PapPack -Recurse -Force + Remove-Item .\PapPack.tar.gz -Force + + if (Test-Path -Path ".venv") { + Remove-Item .\.venv -Recurse -Force } } diff --git a/scripts/tool.ps1 b/scripts/tool.ps1 index ce60b85..01e3bbf 100644 --- a/scripts/tool.ps1 +++ b/scripts/tool.ps1 @@ -1,8 +1,8 @@ <# .Synopsis -This PowerShell script is used for python type check, test the Pap backend, build the Pap frontend, pack the whole project. +This PowerShell script is used for python type check, test the Pap backend, build the Pap frontend. .Description -The tool.ps1 script is a versatile tool designed to simplify the process of Pap backend test, type check, build and pack. It offers the following functionality: +The tool.ps1 script is a versatile tool designed to simplify the process of Pap backend test, type check and build. It offers the following functionality: - When executed without any options, it will DO NOTHING. @@ -12,8 +12,6 @@ The tool.ps1 script is a versatile tool designed to simplify the process of Pap - When the `-Build` option is provided, This script will build the frontend part -- When the `-Pack` option is provided, This script will pack the whole project - The script's flexibility allows it to adapt to your specific needs, whether you're focused on development or simply coding. .Parameter Check Whether to run the test. @@ -21,8 +19,6 @@ Whether to run the test. Whether to run the static type check. .Parameter Build Whether to build the frontend. -.Parameter Pack -Whether to pack the whole project. .Example To run the test: PS .\tool.ps1 -Test @@ -32,9 +28,6 @@ PS .\tool.ps1 -Check To run the build: PS .\tool.ps1 -Build - -To run the pack: -PS .\tool.ps1 -Pack #> [CmdletBinding()] @@ -42,7 +35,6 @@ param ( [switch] $Check, [switch] $Test, [switch] $Build, - [switch] $Pack, ) # Function to install node modules @@ -75,32 +67,9 @@ if ($Test) { } elseif ($Build) { Open-Node npm run build -} elseif ($Pack) { - Open-Node - npm run build - if (Test-Path "PapPack") { - Remove-Item -Path .\PapPack -Recurse -Force - } - New-Item -Path .\PapPack -ItemType Directory - New-Item -Path .\PapPack\data -ItemType Directory - Copy-Item -Path .\data\config.toml -Destination .\PapPack\data\ -Recurse - Copy-Item -Path .\dist -Destination .\PapPack\dist -Recurse - Copy-Item -Path .\src-python -Destination .\PapPack\src-python -Recurse - Copy-Item -Path .\README.md -Destination .\PapPack\ - Copy-Item -Path .\scripts\requirements_release.txt -Destination .\PapPack\ - Copy-Item -Path .\scripts\pap.sh -Destination .\PapPack\ - Copy-Item -Path .\scripts\pap.sh.man -Destination .\PapPack\ - Remove-Item -Path .\PapPack\src-python\test -Recurse -Force - Set-ItemProperty -Path .\scripts\pap.sh -Name IsReadOnly -Value $false - Set-ItemProperty -Path .\scripts\pap.sh -Name Attributes -Value 'Normal' - Add-Type -AssemblyName System.IO.Compression.FileSystem - [System.IO.Compression.ZipFile]::CreateFromDirectory(".\PapPack", "PapPack.zip") - Remove-Item -Path .\PapPack -Recurse -Force - Write-Output "Pack Fin" } else { Write-Output "please choose a switch below neither this script will do nothing." Write-Output "1. -Check" Write-Output "2. -Test" Write-Output "3. -Build" - Write-Output "4. -Pack" } diff --git a/scripts/tool.sh b/scripts/tool.sh index 08084b5..44ed3a1 100755 --- a/scripts/tool.sh +++ b/scripts/tool.sh @@ -29,6 +29,7 @@ pack() { cp src-python PapPack/src-python -r cp README.md PapPack/ cp scripts/requirements_release.txt PapPack/ + cp scripts/pap.ps1 PapPack/ cp scripts/pap.sh PapPack/ cp scripts/pap.sh.man PapPack/ rm PapPack/src-python/test -r