non important commit

This commit is contained in:
maxstrb 2026-01-05 23:29:53 +01:00
parent aeedf2dd9b
commit 0d0a78c1e0

View file

@ -7,67 +7,68 @@
in { in {
home.packages = [ home.packages = [
(pkgs.writeScriptBin "create-project" '' (pkgs.writeScriptBin "create-project" ''
#!${pkgs.nushell}/bin/nu #!${pkgs.nushell}/bin/nu
def main [ def main [
type?: string type?: string
name?: string name?: string
--local (-l) --local (-l)
] { ] {
if $name == null or $type == null { if $name == null or $type == null {
print "Usage: create-project <name> <type> [Options: -l]" print "Usage: create-project <name> <type> [Options: -l]"
exit 1 exit 1
} }
if ($name | str contains "/") or ($name | str contains ".") { if ($name | str contains "/") or ($name | str contains ".") {
print "This is not a valid name for a project" print "This is not a valid name for a project"
exit 1 exit 1
} }
if ($type | str contains "/") or ($type | str contains ".") { if ($type | str contains "/") or ($type | str contains ".") {
print "This is not a valid project type" print "This is not a valid project type"
exit 1 exit 1
} }
let blueprint_dir = $"${blueprints}/($type)" let blueprint_dir = $"${blueprints}/($type)"
if ($blueprint_dir | path type) != "dir" { if ($blueprint_dir | path type) != "dir" {
print "This project type doesn't exist" print "This project type doesn't exist"
exit 1 exit 1
} }
mkdir $name mkdir $name
cd $name cd $name
if ($blueprint_dir | path expand | ls $in | length) > 0 { if ($blueprint_dir | path expand | ls $in | length) > 0 {
glob $"($blueprint_dir)/*" | each { ||file| cp --no-preserve=mode $file . } glob $"($blueprint_dir)/*" | each { ||file| cp $file . }
} chmod -R u+w .
}
if ("./init.sh" | path type) == "file" { if ("./init.sh" | path type) == "file" {
bash "./init.sh" $name bash "./init.sh" $name
rm "init.sh" rm "init.sh"
} }
echo "use flake" | save .envrc echo "use flake" | save .envrc
direnv allow direnv allow
git init git init
git add . git add .
git commit -m "Project setup" git commit -m "Project setup"
if $local { if $local {
print "You are all done" print "You are all done"
exit 0 exit 0
} }
${lib.getExe pkgs.tea} repos create --name $name ${lib.getExe pkgs.tea} repos create --name $name
git remote add origin $"https://git.stribrny.org/max_ag/($name).git" git remote add origin $"https://git.stribrny.org/max_ag/($name).git"
git push -u origin main git push -u origin main
print "You are all done" print "You are all done"
exit 0 exit 0
} }
'') '')
]; ];
} }