ソースを参照

added init_project script

tigger 1 年間 前
コミット
b68edb71ab
3 ファイル変更38 行追加17 行削除
  1. 4 6
      README.md
  2. 30 11
      clean-project.ps1
  3. 4 0
      init-project.ps1

+ 4 - 6
README.md

@@ -3,13 +3,11 @@ Code repository for FISApp UI project.
 This project is an extension of [SWOPT's Angular Template](https://git.swopt.com/swopt/ng-template.git)
 
 ## Getting Started
-After cloning this project, run `git submodule update --init --recursive` to fetch submodules.    
+After cloning this project, run `./init-project` to install dependencies.    
 
-Run `npm install -g @anular/cli` to install/update Angular CLI globally.    
-
-Run `npm install` to install dependencies.    
-
-If you encounter the following error while trying to run `ng serve`, please delete all contents of this folder: [your_project_directory]/src/dependencies/angularlib/node_modules/@angular    
+If you encounter the following error while trying to run `ng serve`, 
+please run `./clean-project`.    
+Alternatively, you may delete all contents of this folder: [your_project_directory]/src/dependencies/angularlib/node_modules/@angular    
 You may do so by running    
 Windows powershell:    
 `rm -r -force src/dependencies/angularlib/node_modules/@angular`    

+ 30 - 11
clean-project.ps1

@@ -1,12 +1,31 @@
-echo "clean node_modules"
-rm -r -force node_modules
-echo "clean angularlib node_modules"
-rm -r -force src/dependencies/angularlib/node_modules
-echo "clean dp-ui node_modules"
-rm -r -force src/dependencies/dp-ui/node_modules
-echo "clean npm cache"
-npm cache clean --force
-echo "clean ng cache"
-ng cache clean
-echo "install dependencies"
+function Load {
+    param([scriptblock]$function,
+        [string]$Label)
+    $job = Start-Job  -ScriptBlock $function
+
+    $symbols = @("[-]", "[\]", "[|]", "[/]")
+    $i = 0;
+    while ($job.State -eq "Running") {
+        $symbol =  $symbols[$i]
+        Write-Host -NoNewLine "`r$symbol $Label                         " -ForegroundColor Blue
+        Start-Sleep -Milliseconds 100
+        $i++
+        if ($i -eq $symbols.Count){
+            $i = 0;
+        }
+    }
+    Write-Host "`r$Label finished" -ForegroundColor Green
+}
+function Delete {
+    param([string] $dir)
+    Write-Host "clean $dir" -ForegroundColor Blue;
+    if (test-path $dir) {rm -r -force $dir};
+    Write-Host "`r";
+    Write-Host "`rfinished cleaning $dir" -ForegroundColor Green;
+}
+Delete -dir "node_modules"
+Delete -dir "src/dependencies/angularlib/node_modules";
+Delete -dir "src/dependencies/dp-ui/node_modules";
+Load -function {npm cache clean --force} -label "clean npm cache";
+Load -function {ng cache clean} -label "clean ng cache";
 npm i --legacy-peer-deps

+ 4 - 0
init-project.ps1

@@ -0,0 +1,4 @@
+git submodule update --init --recursive
+git submodule foreach --recursive git pull
+npm install -g @angular/cli
+npm install --legacy-peer-deps