wad-lab 1.0.7 → 1.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/bin/index.js +23 -17
  2. package/package.json +1 -1
  3. package/templates/game-bingo/index.html +32 -0
  4. package/templates/game-bingo/script.js +118 -0
  5. package/templates/game-bingo/style.css +104 -0
  6. package/templates/springboot-course-registration/.mvn/wrapper/maven-wrapper.properties +3 -0
  7. package/templates/springboot-course-registration/mvnw +295 -0
  8. package/templates/springboot-course-registration/mvnw.cmd +189 -0
  9. package/templates/springboot-course-registration/pom.xml +41 -0
  10. package/templates/springboot-course-registration/src/main/java/com/example/coursereg/CourseRegApplication.java +12 -0
  11. package/templates/springboot-course-registration/src/main/java/com/example/coursereg/controller/CourseController.java +42 -0
  12. package/templates/springboot-course-registration/src/main/java/com/example/coursereg/model/Course.java +99 -0
  13. package/templates/springboot-course-registration/src/main/java/com/example/coursereg/repository/CourseRepository.java +16 -0
  14. package/templates/springboot-course-registration/src/main/java/com/example/coursereg/service/CourseService.java +60 -0
  15. package/templates/springboot-course-registration/src/main/resources/application.properties +3 -0
  16. package/templates/springboot-course-registration/src/test/java/com/example/coursereg/CourseRegApplicationTests.java +12 -0
  17. package/templates/vue-banking-app/index.html +12 -0
  18. package/templates/vue-banking-app/package.json +20 -0
  19. package/templates/vue-banking-app/src/App.vue +80 -0
  20. package/templates/vue-banking-app/src/main.js +9 -0
  21. package/templates/vue-banking-app/src/router/index.js +17 -0
  22. package/templates/vue-banking-app/src/stores/bankStore.js +48 -0
  23. package/templates/vue-banking-app/src/views/DashboardView.vue +88 -0
  24. package/templates/vue-banking-app/src/views/StatementView.vue +171 -0
  25. package/templates/vue-banking-app/src/views/TransactionFormView.vue +144 -0
  26. package/templates/vue-banking-app/vite.config.js +6 -0
  27. package/templates/vue-employee-system/index.html +12 -0
  28. package/templates/vue-employee-system/package.json +19 -0
  29. package/templates/vue-employee-system/src/App.vue +388 -0
  30. package/templates/vue-employee-system/src/main.js +5 -0
  31. package/templates/vue-employee-system/src/stores/employeeStore.js +54 -0
  32. package/templates/vue-employee-system/vite.config.js +6 -0
  33. package/templates/vue-food-ordering/index.html +12 -0
  34. package/templates/vue-food-ordering/package.json +20 -0
  35. package/templates/vue-food-ordering/src/App.vue +109 -0
  36. package/templates/vue-food-ordering/src/main.js +6 -0
  37. package/templates/vue-food-ordering/src/router/index.js +17 -0
  38. package/templates/vue-food-ordering/src/stores/foodStore.js +65 -0
  39. package/templates/vue-food-ordering/src/views/MenuView.vue +145 -0
  40. package/templates/vue-food-ordering/src/views/OrderCartView.vue +181 -0
  41. package/templates/vue-food-ordering/src/views/OrderSuccessView.vue +93 -0
  42. package/templates/vue-food-ordering/vite.config.js +6 -0
  43. package/templates/vue-symposium-system/index.html +12 -0
  44. package/templates/vue-symposium-system/package.json +19 -0
  45. package/templates/vue-symposium-system/src/App.vue +297 -0
  46. package/templates/vue-symposium-system/src/main.js +5 -0
  47. package/templates/vue-symposium-system/src/stores/symposiumStore.js +44 -0
  48. package/templates/vue-symposium-system/vite.config.js +6 -0
package/bin/index.js CHANGED
@@ -28,15 +28,22 @@ function copyDirRecursive(src, dest) {
28
28
  }
29
29
 
30
30
  const templates = [
31
- { name: 'all (Unpack All 27 Templates)', value: 'all' },
32
- { name: 'game-rock-paper-scissors (Player vs Computer RPS)', value: 'game-rock-paper-scissors' },
33
- { name: 'game-tic-tac-toe (3x3 Turn Grid with Win Check)', value: 'game-tic-tac-toe' },
34
- { name: 'game-whack-a-mole (3x3 Mole Whack with Timer)', value: 'game-whack-a-mole' },
35
- { name: 'game-memory-cards (3x4 Flashcard Matching Game)', value: 'game-memory-cards' },
36
- { name: 'vue-memory-game (Vue 3 + Pinia Flashcard Matching)', value: 'vue-memory-game' },
37
- { name: 'vue-todo-pinia (Vue 3 + Pinia Task Manager)', value: 'vue-todo-pinia' },
38
- { name: 'vue-todo-router (Vue 3 + Router Multi-View Tasks)', value: 'vue-todo-router' },
39
- { name: 'vue-cart-router-pinia (Vue 3 + Router + Pinia Shopping Cart)', value: 'vue-cart-router-pinia' },
31
+ { name: 'all (Unpack All 33 Templates)', value: 'all' },
32
+ { name: 'vue-basics (ref, reactive, computed, v-model)', value: 'vue-basics' },
33
+ { name: 'vue-props-emits (Parent/Child Component Communication)', value: 'vue-props-emits' },
34
+ { name: 'vue-router (Parent Layout & Nested Children)', value: 'vue-router' },
35
+ { name: 'vue-pinia (Centralized State Store)', value: 'vue-pinia' },
36
+ { name: 'vue-router-pinia (Router with Children + Pinia)', value: 'vue-router-pinia' },
37
+ { name: 'vue-router-pinia-props (Router + Pinia + Props + Emits)', value: 'vue-router-pinia-props' },
38
+ { name: 'vue-fetch (Native fetch CRUD)', value: 'vue-fetch' },
39
+ { name: 'vue-axios (Axios CRUD Service)', value: 'vue-axios' },
40
+ { name: 'vue-food-ordering (Online Food Ordering System)', value: 'vue-food-ordering' },
41
+ { name: 'vue-banking-app (Banking Portal & Ledger)', value: 'vue-banking-app' },
42
+ { name: 'vue-employee-system (Employee HR & Payroll)', value: 'vue-employee-system' },
43
+ { name: 'vue-symposium-system (College Symposium Management)', value: 'vue-symposium-system' },
44
+ { name: 'vue-todo-pinia (Pinia Task Manager)', value: 'vue-todo-pinia' },
45
+ { name: 'vue-todo-router (Router Multi-View Tasks)', value: 'vue-todo-router' },
46
+ { name: 'vue-cart-router-pinia (Router + Pinia Shopping Cart)', value: 'vue-cart-router-pinia' },
40
47
  { name: 'html-css-js (Form Validation & DOM)', value: 'html-css-js' },
41
48
  { name: 'servlet-basic (Tomcat GET + POST)', value: 'servlet-basic' },
42
49
  { name: 'servlet-jdbc (Tomcat + MySQL JDBC)', value: 'servlet-jdbc' },
@@ -45,14 +52,13 @@ const templates = [
45
52
  { name: 'springboot-mongo-aggregation ($group, $sum, $avg, $sort)', value: 'springboot-mongo-aggregation' },
46
53
  { name: 'springboot-mockmvc (Controller Tests)', value: 'springboot-mockmvc' },
47
54
  { name: 'springboot-mongo-aggregation-mockmvc (Full Tests)', value: 'springboot-mongo-aggregation-mockmvc' },
48
- { name: 'vue-basics (ref, reactive, computed, v-model)', value: 'vue-basics' },
49
- { name: 'vue-props-emits (Parent/Child Component Communication)', value: 'vue-props-emits' },
50
- { name: 'vue-router (Parent Layout & Nested Children)', value: 'vue-router' },
51
- { name: 'vue-pinia (Centralized State Store)', value: 'vue-pinia' },
52
- { name: 'vue-router-pinia (Router with Children + Pinia)', value: 'vue-router-pinia' },
53
- { name: 'vue-fetch (Native fetch CRUD)', value: 'vue-fetch' },
54
- { name: 'vue-axios (Axios CRUD Service)', value: 'vue-axios' },
55
- { name: 'vue-router-pinia-props (Router + Pinia + Props + Emits)', value: 'vue-router-pinia-props' },
55
+ { name: 'springboot-course-registration (Course Registration REST API)', value: 'springboot-course-registration' },
56
+ { name: 'game-bingo (5x5 Grid with B-I-N-G-O Win Check)', value: 'game-bingo' },
57
+ { name: 'game-rock-paper-scissors (Player vs Computer RPS)', value: 'game-rock-paper-scissors' },
58
+ { name: 'game-tic-tac-toe (3x3 Turn Grid with Win Check)', value: 'game-tic-tac-toe' },
59
+ { name: 'game-whack-a-mole (3x3 Mole Whack with Timer)', value: 'game-whack-a-mole' },
60
+ { name: 'game-memory-cards (3x4 Flashcard Matching Game)', value: 'game-memory-cards' },
61
+ { name: 'vue-memory-game (Vue 3 + Pinia Flashcard Matching)', value: 'vue-memory-game' },
56
62
  { name: 'vue-springboot-mongo-crud (Fullstack CRUD)', value: 'vue-springboot-mongo-crud' },
57
63
  { name: 'vue-springboot-mongo-aggregation (Fullstack Dashboard)', value: 'vue-springboot-mongo-aggregation' },
58
64
  { name: 'vue-router-pinia-springboot (Fullstack Enterprise)', value: 'vue-router-pinia-springboot' }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wad-lab",
3
- "version": "1.0.7",
3
+ "version": "1.0.8",
4
4
  "description": "Interactive CLI for WAD Lab starter templates compatible with Node 12+",
5
5
  "bin": {
6
6
  "wad-lab": "./bin/index.js"
@@ -0,0 +1,32 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Bingo Game</title>
7
+ <link rel="stylesheet" href="style.css">
8
+ <script src="script.js" defer></script>
9
+ </head>
10
+ <body>
11
+ <div class="game-container">
12
+ <h1>BINGO Game</h1>
13
+
14
+ <div class="bingo-header">
15
+ <span class="letter" id="letter-0">B</span>
16
+ <span class="letter" id="letter-1">I</span>
17
+ <span class="letter" id="letter-2">N</span>
18
+ <span class="letter" id="letter-3">G</span>
19
+ <span class="letter" id="letter-4">O</span>
20
+ </div>
21
+
22
+ <div class="status-bar">
23
+ <span>Completed Lines: <strong id="linesCompleted">0</strong> / 5</span>
24
+ <span id="winBanner" class="win-text"></span>
25
+ </div>
26
+
27
+ <button type="button" class="btn-new" onclick="startNewGame()">New Random Board</button>
28
+
29
+ <div class="grid" id="bingoGrid"></div>
30
+ </div>
31
+ </body>
32
+ </html>
@@ -0,0 +1,118 @@
1
+ const boardSize = 5;
2
+ let boardState = [];
3
+ let marked = [];
4
+ let isWon = false;
5
+
6
+ document.addEventListener("DOMContentLoaded", function () {
7
+ startNewGame();
8
+ });
9
+
10
+ function startNewGame() {
11
+ isWon = false;
12
+ document.getElementById("winBanner").textContent = "";
13
+ document.getElementById("linesCompleted").textContent = "0";
14
+
15
+ for (let i = 0; i < 5; i++) {
16
+ document.getElementById("letter-" + i).classList.remove("active");
17
+ }
18
+
19
+ const numbers = [];
20
+ for (let i = 1; i <= 25; i++) {
21
+ numbers.push(i);
22
+ }
23
+
24
+ numbers.sort(function () {
25
+ return 0.5 - Math.random();
26
+ });
27
+
28
+ boardState = numbers;
29
+ marked = new Array(25).fill(false);
30
+
31
+ const grid = document.getElementById("bingoGrid");
32
+ grid.innerHTML = "";
33
+
34
+ for (let i = 0; i < 25; i++) {
35
+ const cell = document.createElement("div");
36
+ cell.className = "cell";
37
+ cell.textContent = boardState[i];
38
+ cell.setAttribute("data-index", i);
39
+ cell.addEventListener("click", function () {
40
+ toggleCell(i, cell);
41
+ });
42
+ grid.appendChild(cell);
43
+ }
44
+ }
45
+
46
+ function toggleCell(index, cell) {
47
+ if (isWon) return;
48
+
49
+ marked[index] = !marked[index];
50
+ if (marked[index]) {
51
+ cell.classList.add("marked");
52
+ } else {
53
+ cell.classList.remove("marked");
54
+ }
55
+
56
+ checkBingo();
57
+ }
58
+
59
+ function checkBingo() {
60
+ let completedLines = 0;
61
+
62
+ for (let row = 0; row < 5; row++) {
63
+ let fullRow = true;
64
+ for (let col = 0; col < 5; col++) {
65
+ if (!marked[row * 5 + col]) {
66
+ fullRow = false;
67
+ break;
68
+ }
69
+ }
70
+ if (fullRow) completedLines++;
71
+ }
72
+
73
+ for (let col = 0; col < 5; col++) {
74
+ let fullCol = true;
75
+ for (let row = 0; row < 5; row++) {
76
+ if (!marked[row * 5 + col]) {
77
+ fullCol = false;
78
+ break;
79
+ }
80
+ }
81
+ if (fullCol) completedLines++;
82
+ }
83
+
84
+ let mainDiagonal = true;
85
+ for (let i = 0; i < 5; i++) {
86
+ if (!marked[i * 5 + i]) {
87
+ mainDiagonal = false;
88
+ break;
89
+ }
90
+ }
91
+ if (mainDiagonal) completedLines++;
92
+
93
+ let antiDiagonal = true;
94
+ for (let i = 0; i < 5; i++) {
95
+ if (!marked[i * 5 + (4 - i)]) {
96
+ antiDiagonal = false;
97
+ break;
98
+ }
99
+ }
100
+ if (antiDiagonal) completedLines++;
101
+
102
+ const displayLines = Math.min(completedLines, 5);
103
+ document.getElementById("linesCompleted").textContent = displayLines;
104
+
105
+ for (let i = 0; i < 5; i++) {
106
+ const letterEl = document.getElementById("letter-" + i);
107
+ if (i < displayLines) {
108
+ letterEl.classList.add("active");
109
+ } else {
110
+ letterEl.classList.remove("active");
111
+ }
112
+ }
113
+
114
+ if (displayLines >= 5 && !isWon) {
115
+ isWon = true;
116
+ document.getElementById("winBanner").textContent = "🎉 BINGO! You won! 🎉";
117
+ }
118
+ }
@@ -0,0 +1,104 @@
1
+ body {
2
+ font-family: Arial, sans-serif;
3
+ display: flex;
4
+ justify-content: center;
5
+ align-items: center;
6
+ min-height: 100vh;
7
+ margin: 0;
8
+ background-color: #f0f2f5;
9
+ }
10
+
11
+ .game-container {
12
+ text-align: center;
13
+ background: #ffffff;
14
+ padding: 25px;
15
+ border-radius: 8px;
16
+ border: 1px solid #ccc;
17
+ box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
18
+ }
19
+
20
+ .bingo-header {
21
+ display: flex;
22
+ justify-content: center;
23
+ gap: 15px;
24
+ margin: 15px 0;
25
+ }
26
+
27
+ .letter {
28
+ font-size: 28px;
29
+ font-weight: bold;
30
+ color: #bbb;
31
+ padding: 6px 14px;
32
+ border: 2px solid #bbb;
33
+ border-radius: 6px;
34
+ transition: all 0.3s ease;
35
+ }
36
+
37
+ .letter.active {
38
+ background-color: #e67e22;
39
+ color: #ffffff;
40
+ border-color: #d35400;
41
+ }
42
+
43
+ .status-bar {
44
+ font-size: 16px;
45
+ margin-bottom: 15px;
46
+ display: flex;
47
+ flex-direction: column;
48
+ gap: 5px;
49
+ }
50
+
51
+ .win-text {
52
+ font-weight: bold;
53
+ color: #27ae60;
54
+ font-size: 18px;
55
+ min-height: 24px;
56
+ }
57
+
58
+ .btn-new {
59
+ padding: 8px 16px;
60
+ background-color: #2980b9;
61
+ color: white;
62
+ border: none;
63
+ border-radius: 4px;
64
+ cursor: pointer;
65
+ font-size: 14px;
66
+ margin-bottom: 15px;
67
+ }
68
+
69
+ .btn-new:hover {
70
+ background-color: #1f618d;
71
+ }
72
+
73
+ .grid {
74
+ display: grid;
75
+ grid-template-columns: repeat(5, 55px);
76
+ grid-gap: 6px;
77
+ justify-content: center;
78
+ margin: 0 auto;
79
+ }
80
+
81
+ .cell {
82
+ width: 55px;
83
+ height: 55px;
84
+ background-color: #fafafa;
85
+ border: 2px solid #555;
86
+ font-size: 18px;
87
+ font-weight: bold;
88
+ cursor: pointer;
89
+ display: flex;
90
+ justify-content: center;
91
+ align-items: center;
92
+ border-radius: 4px;
93
+ user-select: none;
94
+ }
95
+
96
+ .cell:hover {
97
+ background-color: #eaeaea;
98
+ }
99
+
100
+ .cell.marked {
101
+ background-color: #2ecc71;
102
+ color: white;
103
+ border-color: #27ae60;
104
+ }
@@ -0,0 +1,3 @@
1
+ wrapperVersion=3.3.4
2
+ distributionType=only-script
3
+ distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.10.0/apache-maven-3.10.0-bin.zip
@@ -0,0 +1,295 @@
1
+ #!/bin/sh
2
+ # ----------------------------------------------------------------------------
3
+ # Licensed to the Apache Software Foundation (ASF) under one
4
+ # or more contributor license agreements. See the NOTICE file
5
+ # distributed with this work for additional information
6
+ # regarding copyright ownership. The ASF licenses this file
7
+ # to you under the Apache License, Version 2.0 (the
8
+ # "License"); you may not use this file except in compliance
9
+ # with the License. You may obtain a copy of the License at
10
+ #
11
+ # http://www.apache.org/licenses/LICENSE-2.0
12
+ #
13
+ # Unless required by applicable law or agreed to in writing,
14
+ # software distributed under the License is distributed on an
15
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
+ # KIND, either express or implied. See the License for the
17
+ # specific language governing permissions and limitations
18
+ # under the License.
19
+ # ----------------------------------------------------------------------------
20
+
21
+ # ----------------------------------------------------------------------------
22
+ # Apache Maven Wrapper startup batch script, version 3.3.4
23
+ #
24
+ # Optional ENV vars
25
+ # -----------------
26
+ # JAVA_HOME - location of a JDK home dir, required when download maven via java source
27
+ # MVNW_REPOURL - repo url base for downloading maven distribution
28
+ # MVNW_USERNAME/MVNW_PASSWORD - user and password for downloading maven
29
+ # MVNW_VERBOSE - true: enable verbose log; debug: trace the mvnw script; others: silence the output
30
+ # ----------------------------------------------------------------------------
31
+
32
+ set -euf
33
+ [ "${MVNW_VERBOSE-}" != debug ] || set -x
34
+
35
+ # OS specific support.
36
+ native_path() { printf %s\\n "$1"; }
37
+ case "$(uname)" in
38
+ CYGWIN* | MINGW*)
39
+ [ -z "${JAVA_HOME-}" ] || JAVA_HOME="$(cygpath --unix "$JAVA_HOME")"
40
+ native_path() { cygpath --path --windows "$1"; }
41
+ ;;
42
+ esac
43
+
44
+ # set JAVACMD and JAVACCMD
45
+ set_java_home() {
46
+ # For Cygwin and MinGW, ensure paths are in Unix format before anything is touched
47
+ if [ -n "${JAVA_HOME-}" ]; then
48
+ if [ -x "$JAVA_HOME/jre/sh/java" ]; then
49
+ # IBM's JDK on AIX uses strange locations for the executables
50
+ JAVACMD="$JAVA_HOME/jre/sh/java"
51
+ JAVACCMD="$JAVA_HOME/jre/sh/javac"
52
+ else
53
+ JAVACMD="$JAVA_HOME/bin/java"
54
+ JAVACCMD="$JAVA_HOME/bin/javac"
55
+
56
+ if [ ! -x "$JAVACMD" ] || [ ! -x "$JAVACCMD" ]; then
57
+ echo "The JAVA_HOME environment variable is not defined correctly, so mvnw cannot run." >&2
58
+ echo "JAVA_HOME is set to \"$JAVA_HOME\", but \"\$JAVA_HOME/bin/java\" or \"\$JAVA_HOME/bin/javac\" does not exist." >&2
59
+ return 1
60
+ fi
61
+ fi
62
+ else
63
+ JAVACMD="$(
64
+ 'set' +e
65
+ 'unset' -f command 2>/dev/null
66
+ 'command' -v java
67
+ )" || :
68
+ JAVACCMD="$(
69
+ 'set' +e
70
+ 'unset' -f command 2>/dev/null
71
+ 'command' -v javac
72
+ )" || :
73
+
74
+ if [ ! -x "${JAVACMD-}" ] || [ ! -x "${JAVACCMD-}" ]; then
75
+ echo "The java/javac command does not exist in PATH nor is JAVA_HOME set, so mvnw cannot run." >&2
76
+ return 1
77
+ fi
78
+ fi
79
+ }
80
+
81
+ # hash string like Java String::hashCode
82
+ hash_string() {
83
+ str="${1:-}" h=0
84
+ while [ -n "$str" ]; do
85
+ char="${str%"${str#?}"}"
86
+ h=$(((h * 31 + $(LC_CTYPE=C printf %d "'$char")) % 4294967296))
87
+ str="${str#?}"
88
+ done
89
+ printf %x\\n $h
90
+ }
91
+
92
+ verbose() { :; }
93
+ [ "${MVNW_VERBOSE-}" != true ] || verbose() { printf %s\\n "${1-}"; }
94
+
95
+ die() {
96
+ printf %s\\n "$1" >&2
97
+ exit 1
98
+ }
99
+
100
+ trim() {
101
+ # MWRAPPER-139:
102
+ # Trims trailing and leading whitespace, carriage returns, tabs, and linefeeds.
103
+ # Needed for removing poorly interpreted newline sequences when running in more
104
+ # exotic environments such as mingw bash on Windows.
105
+ printf "%s" "${1}" | tr -d '[:space:]'
106
+ }
107
+
108
+ scriptDir="$(dirname "$0")"
109
+ scriptName="$(basename "$0")"
110
+
111
+ # parse distributionUrl and optional distributionSha256Sum, requires .mvn/wrapper/maven-wrapper.properties
112
+ while IFS="=" read -r key value; do
113
+ case "${key-}" in
114
+ distributionUrl) distributionUrl=$(trim "${value-}") ;;
115
+ distributionSha256Sum) distributionSha256Sum=$(trim "${value-}") ;;
116
+ esac
117
+ done <"$scriptDir/.mvn/wrapper/maven-wrapper.properties"
118
+ [ -n "${distributionUrl-}" ] || die "cannot read distributionUrl property in $scriptDir/.mvn/wrapper/maven-wrapper.properties"
119
+
120
+ case "${distributionUrl##*/}" in
121
+ maven-mvnd-*bin.*)
122
+ MVN_CMD=mvnd.sh _MVNW_REPO_PATTERN=/maven/mvnd/
123
+ case "${PROCESSOR_ARCHITECTURE-}${PROCESSOR_ARCHITEW6432-}:$(uname -a)" in
124
+ *AMD64:CYGWIN* | *AMD64:MINGW*) distributionPlatform=windows-amd64 ;;
125
+ :Darwin*x86_64) distributionPlatform=darwin-amd64 ;;
126
+ :Darwin*arm64) distributionPlatform=darwin-aarch64 ;;
127
+ :Linux*x86_64*) distributionPlatform=linux-amd64 ;;
128
+ *)
129
+ echo "Cannot detect native platform for mvnd on $(uname)-$(uname -m), use pure java version" >&2
130
+ distributionPlatform=linux-amd64
131
+ ;;
132
+ esac
133
+ distributionUrl="${distributionUrl%-bin.*}-$distributionPlatform.zip"
134
+ ;;
135
+ maven-mvnd-*) MVN_CMD=mvnd.sh _MVNW_REPO_PATTERN=/maven/mvnd/ ;;
136
+ *) MVN_CMD="mvn${scriptName#mvnw}" _MVNW_REPO_PATTERN=/org/apache/maven/ ;;
137
+ esac
138
+
139
+ # apply MVNW_REPOURL and calculate MAVEN_HOME
140
+ # maven home pattern: ~/.m2/wrapper/dists/{apache-maven-<version>,maven-mvnd-<version>-<platform>}/<hash>
141
+ [ -z "${MVNW_REPOURL-}" ] || distributionUrl="$MVNW_REPOURL$_MVNW_REPO_PATTERN${distributionUrl#*"$_MVNW_REPO_PATTERN"}"
142
+ distributionUrlName="${distributionUrl##*/}"
143
+ distributionUrlNameMain="${distributionUrlName%.*}"
144
+ distributionUrlNameMain="${distributionUrlNameMain%-bin}"
145
+ MAVEN_USER_HOME="${MAVEN_USER_HOME:-${HOME}/.m2}"
146
+ MAVEN_HOME="${MAVEN_USER_HOME}/wrapper/dists/${distributionUrlNameMain-}/$(hash_string "$distributionUrl")"
147
+
148
+ exec_maven() {
149
+ unset MVNW_VERBOSE MVNW_USERNAME MVNW_PASSWORD MVNW_REPOURL || :
150
+ exec "$MAVEN_HOME/bin/$MVN_CMD" "$@" || die "cannot exec $MAVEN_HOME/bin/$MVN_CMD"
151
+ }
152
+
153
+ if [ -d "$MAVEN_HOME" ]; then
154
+ verbose "found existing MAVEN_HOME at $MAVEN_HOME"
155
+ exec_maven "$@"
156
+ fi
157
+
158
+ case "${distributionUrl-}" in
159
+ *?-bin.zip | *?maven-mvnd-?*-?*.zip) ;;
160
+ *) die "distributionUrl is not valid, must match *-bin.zip or maven-mvnd-*.zip, but found '${distributionUrl-}'" ;;
161
+ esac
162
+
163
+ # prepare tmp dir
164
+ if TMP_DOWNLOAD_DIR="$(mktemp -d)" && [ -d "$TMP_DOWNLOAD_DIR" ]; then
165
+ clean() { rm -rf -- "$TMP_DOWNLOAD_DIR"; }
166
+ trap clean HUP INT TERM EXIT
167
+ else
168
+ die "cannot create temp dir"
169
+ fi
170
+
171
+ mkdir -p -- "${MAVEN_HOME%/*}"
172
+
173
+ # Download and Install Apache Maven
174
+ verbose "Couldn't find MAVEN_HOME, downloading and installing it ..."
175
+ verbose "Downloading from: $distributionUrl"
176
+ verbose "Downloading to: $TMP_DOWNLOAD_DIR/$distributionUrlName"
177
+
178
+ # select .zip or .tar.gz
179
+ if ! command -v unzip >/dev/null; then
180
+ distributionUrl="${distributionUrl%.zip}.tar.gz"
181
+ distributionUrlName="${distributionUrl##*/}"
182
+ fi
183
+
184
+ # verbose opt
185
+ __MVNW_QUIET_WGET=--quiet __MVNW_QUIET_CURL=--silent __MVNW_QUIET_UNZIP=-q __MVNW_QUIET_TAR=''
186
+ [ "${MVNW_VERBOSE-}" != true ] || __MVNW_QUIET_WGET='' __MVNW_QUIET_CURL='' __MVNW_QUIET_UNZIP='' __MVNW_QUIET_TAR=v
187
+
188
+ # normalize http auth
189
+ case "${MVNW_PASSWORD:+has-password}" in
190
+ '') MVNW_USERNAME='' MVNW_PASSWORD='' ;;
191
+ has-password) [ -n "${MVNW_USERNAME-}" ] || MVNW_USERNAME='' MVNW_PASSWORD='' ;;
192
+ esac
193
+
194
+ if [ -z "${MVNW_USERNAME-}" ] && command -v wget >/dev/null; then
195
+ verbose "Found wget ... using wget"
196
+ wget ${__MVNW_QUIET_WGET:+"$__MVNW_QUIET_WGET"} "$distributionUrl" -O "$TMP_DOWNLOAD_DIR/$distributionUrlName" || die "wget: Failed to fetch $distributionUrl"
197
+ elif [ -z "${MVNW_USERNAME-}" ] && command -v curl >/dev/null; then
198
+ verbose "Found curl ... using curl"
199
+ curl ${__MVNW_QUIET_CURL:+"$__MVNW_QUIET_CURL"} -f -L -o "$TMP_DOWNLOAD_DIR/$distributionUrlName" "$distributionUrl" || die "curl: Failed to fetch $distributionUrl"
200
+ elif set_java_home; then
201
+ verbose "Falling back to use Java to download"
202
+ javaSource="$TMP_DOWNLOAD_DIR/Downloader.java"
203
+ targetZip="$TMP_DOWNLOAD_DIR/$distributionUrlName"
204
+ cat >"$javaSource" <<-END
205
+ public class Downloader extends java.net.Authenticator
206
+ {
207
+ protected java.net.PasswordAuthentication getPasswordAuthentication()
208
+ {
209
+ return new java.net.PasswordAuthentication( System.getenv( "MVNW_USERNAME" ), System.getenv( "MVNW_PASSWORD" ).toCharArray() );
210
+ }
211
+ public static void main( String[] args ) throws Exception
212
+ {
213
+ setDefault( new Downloader() );
214
+ java.nio.file.Files.copy( java.net.URI.create( args[0] ).toURL().openStream(), java.nio.file.Paths.get( args[1] ).toAbsolutePath().normalize() );
215
+ }
216
+ }
217
+ END
218
+ # For Cygwin/MinGW, switch paths to Windows format before running javac and java
219
+ verbose " - Compiling Downloader.java ..."
220
+ "$(native_path "$JAVACCMD")" "$(native_path "$javaSource")" || die "Failed to compile Downloader.java"
221
+ verbose " - Running Downloader.java ..."
222
+ "$(native_path "$JAVACMD")" -cp "$(native_path "$TMP_DOWNLOAD_DIR")" Downloader "$distributionUrl" "$(native_path "$targetZip")"
223
+ fi
224
+
225
+ # If specified, validate the SHA-256 sum of the Maven distribution zip file
226
+ if [ -n "${distributionSha256Sum-}" ]; then
227
+ distributionSha256Result=false
228
+ if [ "$MVN_CMD" = mvnd.sh ]; then
229
+ echo "Checksum validation is not supported for maven-mvnd." >&2
230
+ echo "Please disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." >&2
231
+ exit 1
232
+ elif command -v sha256sum >/dev/null; then
233
+ if echo "$distributionSha256Sum $TMP_DOWNLOAD_DIR/$distributionUrlName" | sha256sum -c - >/dev/null 2>&1; then
234
+ distributionSha256Result=true
235
+ fi
236
+ elif command -v shasum >/dev/null; then
237
+ if echo "$distributionSha256Sum $TMP_DOWNLOAD_DIR/$distributionUrlName" | shasum -a 256 -c >/dev/null 2>&1; then
238
+ distributionSha256Result=true
239
+ fi
240
+ else
241
+ echo "Checksum validation was requested but neither 'sha256sum' or 'shasum' are available." >&2
242
+ echo "Please install either command, or disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." >&2
243
+ exit 1
244
+ fi
245
+ if [ $distributionSha256Result = false ]; then
246
+ echo "Error: Failed to validate Maven distribution SHA-256, your Maven distribution might be compromised." >&2
247
+ echo "If you updated your Maven version, you need to update the specified distributionSha256Sum property." >&2
248
+ exit 1
249
+ fi
250
+ fi
251
+
252
+ # unzip and move
253
+ if command -v unzip >/dev/null; then
254
+ unzip ${__MVNW_QUIET_UNZIP:+"$__MVNW_QUIET_UNZIP"} "$TMP_DOWNLOAD_DIR/$distributionUrlName" -d "$TMP_DOWNLOAD_DIR" || die "failed to unzip"
255
+ else
256
+ tar xzf${__MVNW_QUIET_TAR:+"$__MVNW_QUIET_TAR"} "$TMP_DOWNLOAD_DIR/$distributionUrlName" -C "$TMP_DOWNLOAD_DIR" || die "failed to untar"
257
+ fi
258
+
259
+ # Find the actual extracted directory name (handles snapshots where filename != directory name)
260
+ actualDistributionDir=""
261
+
262
+ # First try the expected directory name (for regular distributions)
263
+ if [ -d "$TMP_DOWNLOAD_DIR/$distributionUrlNameMain" ]; then
264
+ if [ -f "$TMP_DOWNLOAD_DIR/$distributionUrlNameMain/bin/$MVN_CMD" ]; then
265
+ actualDistributionDir="$distributionUrlNameMain"
266
+ fi
267
+ fi
268
+
269
+ # If not found, search for any directory with the Maven executable (for snapshots)
270
+ if [ -z "$actualDistributionDir" ]; then
271
+ # enable globbing to iterate over items
272
+ set +f
273
+ for dir in "$TMP_DOWNLOAD_DIR"/*; do
274
+ if [ -d "$dir" ]; then
275
+ if [ -f "$dir/bin/$MVN_CMD" ]; then
276
+ actualDistributionDir="$(basename "$dir")"
277
+ break
278
+ fi
279
+ fi
280
+ done
281
+ set -f
282
+ fi
283
+
284
+ if [ -z "$actualDistributionDir" ]; then
285
+ verbose "Contents of $TMP_DOWNLOAD_DIR:"
286
+ verbose "$(ls -la "$TMP_DOWNLOAD_DIR")"
287
+ die "Could not find Maven distribution directory in extracted archive"
288
+ fi
289
+
290
+ verbose "Found extracted Maven distribution directory: $actualDistributionDir"
291
+ printf %s\\n "$distributionUrl" >"$TMP_DOWNLOAD_DIR/$actualDistributionDir/mvnw.url"
292
+ mv -- "$TMP_DOWNLOAD_DIR/$actualDistributionDir" "$MAVEN_HOME" || [ -d "$MAVEN_HOME" ] || die "fail to move MAVEN_HOME"
293
+
294
+ clean || :
295
+ exec_maven "$@"