non important commit
This commit is contained in:
parent
43fbf5f6f6
commit
410f25eef8
3 changed files with 49 additions and 121 deletions
|
|
@ -1,12 +0,0 @@
|
||||||
{pkgs, ...}: let
|
|
||||||
blueprints = ../project-blueprints;
|
|
||||||
mainScript = builtins.readFile ./main.nu;
|
|
||||||
scriptWithSubstitutions =
|
|
||||||
builtins.replaceStrings
|
|
||||||
["@BLUEPRINTS@"]
|
|
||||||
["${blueprints}"]
|
|
||||||
mainScript;
|
|
||||||
in ''
|
|
||||||
#!${pkgs.nushell}/bin/nu
|
|
||||||
${scriptWithSubstitutions}
|
|
||||||
''
|
|
||||||
|
|
@ -3,72 +3,71 @@
|
||||||
lib,
|
lib,
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
blueprints = ./. + "/project-blueprints";
|
blueprints = ./project-blueprints;
|
||||||
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
|
name?: string
|
||||||
name?: string
|
type?: string
|
||||||
--local (-l)
|
--local (-l)
|
||||||
] {
|
] {
|
||||||
|
if $name == null or $type == null {
|
||||||
|
print "Usage: create-project <name> <type> [Options: -l]"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
if $name == null or $type == null {
|
if ($name | str contains "/") or ($name | str contains ".") {
|
||||||
print "Usage: create-project <type> <name> [Options: -l]"
|
print "This is not a valid name for a project"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($name | str contains "/") or ($name | str contains ".") {
|
if ($type | str contains "/") or ($type | str contains ".") {
|
||||||
print "This is not a valid name for a project"
|
print "This is not a valid project type"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($type | str contains "/") or ($type | str contains ".") {
|
let blueprint_dir = $"${toString blueprints}/($type)"
|
||||||
print "This is not a valid project type"
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
let blueprint_dir = $"${blueprints}/($type)"
|
if ($blueprint_dir | path type) != "dir" {
|
||||||
|
print "This project type doesn't exist"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
if ($blueprint_dir | path type) != "dir" {
|
mkdir $name
|
||||||
print "This project type doesn't exist"
|
cd $name
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
mkdir $name
|
if (ls $blueprint_dir | length) > 0 {
|
||||||
cd $name
|
glob $"($blueprint_dir)/*" | each { |file| cp $file . }
|
||||||
|
^chmod -R u+w .
|
||||||
|
}
|
||||||
|
|
||||||
if (ls $blueprint_dir | length) > 0 {
|
if ("./init.sh" | path type) == "file" {
|
||||||
glob $"($blueprint_dir)/*" | each { |file| cp $file . }
|
bash "./init.sh" $name
|
||||||
chmod -R u+w .
|
rm "init.sh"
|
||||||
}
|
}
|
||||||
|
|
||||||
if ("./init.sh" | path type) == "file" {
|
echo "use flake" | save .envrc
|
||||||
bash "./init.sh" $name
|
direnv allow
|
||||||
rm "init.sh"
|
|
||||||
}
|
|
||||||
|
|
||||||
echo "use flake" | save .envrc
|
git init
|
||||||
direnv allow
|
git add .
|
||||||
|
git commit -m "Project setup"
|
||||||
|
|
||||||
git init
|
if $local {
|
||||||
git add .
|
print "You are all done"
|
||||||
git commit -m "Project setup"
|
exit 0
|
||||||
|
}
|
||||||
|
|
||||||
if $local {
|
${lib.getExe pkgs.tea} repos create --name $name
|
||||||
print "You are all done"
|
git remote add origin $"https://git.stribrny.org/max_ag/($name).git"
|
||||||
exit 0
|
git push -u origin main
|
||||||
}
|
|
||||||
|
|
||||||
${lib.getExe pkgs.tea} repos create --name $name
|
print "You are all done"
|
||||||
git remote add origin $"https://git.stribrny.org/max_ag/($name).git"
|
exit 0
|
||||||
git push -u origin main
|
}
|
||||||
|
|
||||||
print "You are all done"
|
|
||||||
exit 0
|
|
||||||
}
|
|
||||||
'')
|
'')
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
||||||
59
main.nu
59
main.nu
|
|
@ -1,59 +0,0 @@
|
||||||
def main [
|
|
||||||
name?: string
|
|
||||||
type?: string
|
|
||||||
--local (-l)
|
|
||||||
] {
|
|
||||||
if $name == null or $type == null {
|
|
||||||
print "Usage: create-project <name> <type> [Options: -l]"
|
|
||||||
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
|
|
||||||
}
|
|
||||||
|
|
||||||
let blueprint_dir = $"@BLUEPRINTS@/($type)"
|
|
||||||
|
|
||||||
if ($blueprint_dir | path type) != "dir" {
|
|
||||||
print "This project type doesn't exist"
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
mkdir $name
|
|
||||||
cd $name
|
|
||||||
|
|
||||||
if (ls $blueprint_dir | length) > 0 {
|
|
||||||
glob $"($blueprint_dir)/*" | each { |file| cp $file . }
|
|
||||||
^chmod -R u+w .
|
|
||||||
}
|
|
||||||
|
|
||||||
if ("./init.sh" | path type) == "file" {
|
|
||||||
bash "./init.sh" $name
|
|
||||||
rm "init.sh"
|
|
||||||
}
|
|
||||||
|
|
||||||
echo "use flake" | save .envrc
|
|
||||||
direnv allow
|
|
||||||
|
|
||||||
git init
|
|
||||||
git add .
|
|
||||||
git commit -m "Project setup"
|
|
||||||
|
|
||||||
if $local {
|
|
||||||
print "You are all done"
|
|
||||||
exit 0
|
|
||||||
}
|
|
||||||
|
|
||||||
tea repos create --name $name
|
|
||||||
git remote add origin $"https://git.stribrny.org/max_ag/($name).git"
|
|
||||||
git push -u origin main
|
|
||||||
|
|
||||||
print "You are all done"
|
|
||||||
exit 0
|
|
||||||
}
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue