non important commit
This commit is contained in:
parent
ff963040f9
commit
d33bfc0998
1 changed files with 58 additions and 53 deletions
|
|
@ -5,65 +5,70 @@
|
||||||
nu
|
nu
|
||||||
*/
|
*/
|
||||||
''
|
''
|
||||||
#!${pkgs.nushell}/bin/nu
|
#!${pkgs.nushell}/bin/nu
|
||||||
|
|
||||||
def main [
|
def main [
|
||||||
name?: string
|
name?: string
|
||||||
type?: string
|
type?: 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 ".") {
|
||||||
|
print "This is not a valid name for a project"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($type | str contains "/") or ($type | str contains ".") {
|
||||||
|
print "This is not a valid project type"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($"~/.nix-config/home/modules/create-project/project-blueprints/($type)" | path type) != "dir" {
|
||||||
|
print "This project type doesn't exist"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
mkdir $name
|
||||||
|
cd $name
|
||||||
|
|
||||||
|
if ($"~/.nix-config/home/modules/create-project/project-blueprints/($type)" | path expand | ls $in | length) > 0 {
|
||||||
|
cp $"~/.nix-config/home/modules/create-project/project-blueprints/($type)/*" .
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($"./init.sh" | path type) == "file" {
|
||||||
|
bash "init.sh"
|
||||||
|
rm "init.sh"
|
||||||
|
}
|
||||||
|
|
||||||
|
if $local {
|
||||||
|
exit 0
|
||||||
|
}
|
||||||
|
|
||||||
|
print "Enter server password:"
|
||||||
|
let pass = (input --suppress-output)
|
||||||
|
|
||||||
|
try {
|
||||||
|
ssh $"admin@silvers.fun" $"echo '($pass)' | sudo -S -u git git init --bare ~/($repo_name).git"
|
||||||
|
print $"Repository ($repo_name) created successfully!"
|
||||||
|
} catch {
|
||||||
|
print "Failed to create repository. Check your credentials and try again."
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($name | str contains "/") or ($name | str contains ".") {
|
git init
|
||||||
print "This is not a valid name for a project"
|
git add .
|
||||||
exit 1
|
git commit -m "Project setup"
|
||||||
}
|
git $"remote add origin git@silvers.fun:($name).git"
|
||||||
|
git push origin main
|
||||||
|
|
||||||
if ($type | str contains "/") or ($type | str contains ".") {
|
print "You are all done"
|
||||||
print "This is not a valid project type"
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($"~/.nix-config/home/modules/create-project/project-blueprints/($type)" | path type) != "dir" {
|
exit 0
|
||||||
print "This project type doesn't exist"
|
}
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
mkdir $name
|
|
||||||
cd $name
|
|
||||||
|
|
||||||
if ($"~/.nix-config/home/modules/create-project/project-blueprints/($type)" | path expand | ls $in | length) > 0 {
|
|
||||||
cp $"~/.nix-config/home/modules/create-project/project-blueprints/($type)/*" .
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($"./init.sh" | path type) == "file" {
|
|
||||||
bash "init.sh"
|
|
||||||
rm "init.sh"
|
|
||||||
}
|
|
||||||
|
|
||||||
if $local {
|
|
||||||
exit 0
|
|
||||||
}
|
|
||||||
|
|
||||||
print "Enter server password"
|
|
||||||
let pass = (input)
|
|
||||||
|
|
||||||
ssh admin@silvers.fun $"sudo -S -u git bash -c \"git init --bare ~/($name).git\" <<< ($pass)" <<< $pass
|
|
||||||
|
|
||||||
git init
|
|
||||||
git add .
|
|
||||||
git commit -m "Project setup"
|
|
||||||
git $"remote add origin git@silvers.fun:($name).git"
|
|
||||||
git push origin main
|
|
||||||
|
|
||||||
print "You are all done"
|
|
||||||
|
|
||||||
exit 0
|
|
||||||
}
|
|
||||||
'')
|
'')
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue