mirror of
https://github.com/tauri-apps/tauri.git
synced 2026-04-01 10:01:07 +02:00
feat(build) Add Powershell support to the maskfile. (#618)
Co-authored-by: nothingismagick <drthompsonsmagickindustries@gmail.com> Co-authored-by: nothingismagick <denjell@sfosc.org> Co-authored-by: nothingismagick <denjell@mailscript.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Lucas Fernandes Nogueira <lucasfernandesnog@gmail.com>
This commit is contained in:
committed by
GitHub
parent
c6dce8e7e8
commit
f576546b86
136
maskfile.md
136
maskfile.md
@@ -1,6 +1,7 @@
|
||||
# Shorthand Commands
|
||||
|
||||
## prepare
|
||||
|
||||
> Setup all stuffs needed for runing the examples
|
||||
|
||||
```sh
|
||||
@@ -18,11 +19,57 @@ cd cli/tauri.js
|
||||
yarn && yarn build
|
||||
```
|
||||
|
||||
```powershell
|
||||
# Setup Environment to execute in the tauri directory.
|
||||
$CWD = [Environment]::CurrentDirectory
|
||||
Push-Location $MyInvocation.MyCommand.Path
|
||||
[Environment]::CurrentDirectory = $PWD
|
||||
# send git stderr to powershell stdout
|
||||
$env:GIT_REDIRECT_STDERR = '2>&1'
|
||||
|
||||
# dist and src paths.
|
||||
$dist_path = "tauri\test\fixture\dist"
|
||||
$src_path = "tauri\test\fixture\src-tauri"
|
||||
|
||||
# if the examples path doesn't exist.
|
||||
if (-Not (Test-Path $CWD\examples -PathType Any)) {
|
||||
Start-Job -ScriptBlock {
|
||||
# Setup Environment to execute in the tauri directory.
|
||||
$CWD = [Environment]::CurrentDirectory
|
||||
Push-Location $MyInvocation.MyCommand.Path
|
||||
[Environment]::CurrentDirectory = $PWD
|
||||
|
||||
#clone the examples repo into the examples folder
|
||||
git clone --recursive https://github.com/tauri-apps/examples.git $CWD\examples
|
||||
} | Receive-Job -AutoRemoveJob -Wait
|
||||
}
|
||||
|
||||
# Enter the examples folder and pull the latest data from origin/master
|
||||
cd examples; git pull origin master; cd ..
|
||||
|
||||
# Check that dist_path and src_path exist.
|
||||
if ((Test-Path $dist_path -PathType Any) -Or (Test-Path $src_path -PathType Any)) {
|
||||
# set the env vars.
|
||||
$env:TAURI_DIST_DIR = Resolve-Path $dist_path
|
||||
$env:TAURI_DIR = Resolve-Path $src_path
|
||||
|
||||
# build and install everything Rust related.
|
||||
cargo build
|
||||
cargo install --path cli\tauri-bundler --force
|
||||
cargo install cargo-web
|
||||
|
||||
# install the tauri Node CLI.
|
||||
cd cli\tauri.js
|
||||
yarn; yarn build
|
||||
}
|
||||
```
|
||||
|
||||
## run
|
||||
|
||||

|
||||
|
||||
### run example (example)
|
||||
|
||||
> Run specific example in dev mode
|
||||
|
||||
```sh
|
||||
@@ -49,9 +96,56 @@ case "$PWD" in
|
||||
esac
|
||||
```
|
||||
|
||||
```powershell
|
||||
# Setup Environment to execute in the tauri directory.
|
||||
$CWD = [Environment]::CurrentDirectory
|
||||
Push-Location $MyInvocation.MyCommand.Path
|
||||
[Environment]::CurrentDirectory = $PWD
|
||||
|
||||
# Invoke the command script.
|
||||
Invoke-Expression -Command .scripts\init_env.ps1
|
||||
|
||||
# get the example paths.
|
||||
$example_path = Get-ChildItem examples\*\$env:example
|
||||
|
||||
# if the example path is null get the todomvc path.
|
||||
if ($example_path -eq $null) {
|
||||
$example_path = Get-ChildItem examples\*\*\$env:example\$env:example
|
||||
}
|
||||
|
||||
# if the example path is still null get the communication example path.
|
||||
if ($example_path -eq $null) {
|
||||
$example_path = Get-ChildItem examples\tauri\*\$env:example
|
||||
}
|
||||
|
||||
# Move to the selected example folder.
|
||||
cd $example_path
|
||||
|
||||
# switch on the parent folder name.
|
||||
switch ($example_path.parent) {
|
||||
# if node, run yarn.
|
||||
"node" {
|
||||
yarn; yarn tauri:source dev
|
||||
}
|
||||
# if rust, run cargo web deploy
|
||||
"rust" {
|
||||
cargo web deploy
|
||||
}
|
||||
# if tauri run the communication example from the tauri folder.
|
||||
"tauri" {
|
||||
cd $CWD/tauri/examples/communication/src-tauri; cargo run
|
||||
}
|
||||
# transpiled are not supported yet.
|
||||
"transpiled" {
|
||||
Write-Output("Example not supported yet")
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## list
|
||||
|
||||
### list examples
|
||||
|
||||
> List all available examples
|
||||
|
||||
```sh
|
||||
@@ -59,7 +153,28 @@ find examples/*/*/* -maxdepth 0 -type d -not -path '*.git*' \
|
||||
-exec sh -c 'echo $(basename $(dirname {}))/$(basename {})' \;
|
||||
```
|
||||
|
||||
```powershell
|
||||
# Setup Environment to execute in the tauri directory.
|
||||
$CWD = [Environment]::CurrentDirectory
|
||||
Push-Location $MyInvocation.MyCommand.Path
|
||||
[Environment]::CurrentDirectory = $PWD
|
||||
|
||||
# initialize the examples list.
|
||||
$examples = @()
|
||||
|
||||
# get the communication example
|
||||
$examples += Get-ChildItem examples/*/* -Filter communication
|
||||
# get the rest of the examples.
|
||||
$examples += Get-ChildItem examples/*/* -Directory -Exclude ('src*', 'public', 'test*', 'source', 'lib', 'web', 'dist')
|
||||
|
||||
# print out the examples.
|
||||
foreach($e in $examples) {
|
||||
Write-Output("$($e.Name): $($e.Parent)/$($e.Name)")
|
||||
}
|
||||
```
|
||||
|
||||
## clean
|
||||
|
||||
> Remove installed dependencies and reset examples in case something gone wrong
|
||||
|
||||
```sh
|
||||
@@ -73,3 +188,24 @@ cd examples
|
||||
git checkout -- . # discard all unstaged changes
|
||||
git clean -dfX # remove all untracked files & directories
|
||||
```
|
||||
|
||||
```powershell
|
||||
# Setup Environment to execute in the tauri directory.
|
||||
$CWD = [Environment]::CurrentDirectory
|
||||
Push-Location $MyInvocation.MyCommand.Path
|
||||
[Environment]::CurrentDirectory = $PWD
|
||||
|
||||
# uninstall the bundler and clean up any artifacts.
|
||||
cargo uninstall tauri-bundler
|
||||
cargo clean
|
||||
|
||||
# find any node_module folders.
|
||||
$node_paths = Get-ChildItem -Path examples\ -Filter node_modules -Recurse -ErrorAction SilentlyContinue -Force
|
||||
|
||||
# delete all of the node_module folders.
|
||||
foreach ($path in $node_paths) {
|
||||
$path.Delete()
|
||||
}
|
||||
# enter the examples folder and remove any changes.
|
||||
cd $CWD/examples; git checkout -- .; git clean -dfX
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user