Skip to content

Commit

Permalink
[fix] pap.ps1
Browse files Browse the repository at this point in the history
[fix] pap.ps1
  • Loading branch information
WindLX committed Oct 11, 2023
1 parent 3a10812 commit 448d80e
Show file tree
Hide file tree
Showing 9 changed files with 56 additions and 38 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ __pycache__
.mypy_cache
.pytest_cache

# Rust
target

# data
data
!data/config.toml
Expand Down
7 changes: 7 additions & 0 deletions md_parser/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions md_parser/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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]
Empty file added md_parser/src/lib.rs
Empty file.
3 changes: 3 additions & 0 deletions md_parser/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fn main() {
println!("Hello, world!");
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "pap",
"private": true,
"version": "0.1.1",
"version": "0.1.3",
"type": "module",
"scripts": {
"dev": "vite",
Expand Down
35 changes: 31 additions & 4 deletions scripts/pap.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ PS .\pap.ps1 -Dev

[CmdletBinding()]
param (
[switch] $Update,
[switch] $Update
)

# Function to activate Python virtual environment
Expand All @@ -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
}
}

Expand Down
35 changes: 2 additions & 33 deletions scripts/tool.ps1
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -12,17 +12,13 @@ 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.
.Parameter 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
Expand All @@ -32,17 +28,13 @@ PS .\tool.ps1 -Check
To run the build:
PS .\tool.ps1 -Build
To run the pack:
PS .\tool.ps1 -Pack
#>

[CmdletBinding()]
param (
[switch] $Check,
[switch] $Test,
[switch] $Build,
[switch] $Pack,
)

# Function to install node modules
Expand Down Expand Up @@ -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"
}
1 change: 1 addition & 0 deletions scripts/tool.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 448d80e

Please sign in to comment.