Skip to content
Snippets Groups Projects
Select Git revision
  • 78cbad19af8fff4634293acc130130d89ef4d55d
  • master default protected
  • 1.31
  • 4.24.3
  • 4.24.2
  • 4.24.1
  • 4.24.0
  • 4.23.6
  • 4.23.5
  • 4.23.4
  • 4.23.3
  • 4.23.2
  • 4.23.1
  • 4.23.0
  • 4.22.3
  • 4.22.2
  • 4.22.1
  • 4.22.0
  • 4.21.0
  • 4.20.1
  • 4.20.0
  • 4.19.0
  • 4.18.0
23 results

create-new-class.nix

Blame
  • create-new-class.nix 1.18 KiB
    { pkgs', ... }:
    pkgs'.writeShellScriptBin "create-new-class" ''
    source ${pkgs'.common}/bin/common
    
    echo_section "create new component class"
    echo_hint "The command is executed in the current working directory and not in a nix derivation."
    cd_working_dir
    
    echo_section "create a new component class"
    
    echo_step "enter new component class name"
    name=$(${pkgs'.gum}/bin/gum input --placeholder "Enter new component class name")
      
    if [[ -z "$name" ]]; then
        echo_fail "Component class name is empty. Exiting."
        exit 1
    fi
    
    echo_step "select target directory"
    cd source
    targetPath=$(${pkgs'.gum}/bin/gum file --directory --file=false)
    cd ..
    
    if [[ -z "$targetPath" ]]; then
        echo_fail "Target directory is empty. Exiting."
        exit 1
    fi
    
    if [[ ! -d "$targetPath" ]]; then
        echo_fail "Target directory does not exist. Exiting."
        exit 1
    fi
    
    echo_step "create new component class $name in $targetPath" 
    
    targetPath=$(realpath --relative-to=source "$targetPath")
    
    if ! ${pkgs'.nodejs_20}/bin/node development/scripts/createNewClass.mjs --classname="$name" --path="$targetPath"; then
        echo_fail "script createNewClass.mjs failed, check your JS!"
        exit 1
    fi
    
     echo_ok "New component class created"
    
    
    ''