Skip to content

Commit 1f074c6

Browse files
committed
refactor: move root scripts to scripts directory
- Move new_problem, run_case, and run_tests scripts to scripts/ - Update script paths to reference parent directory - Update all documentation references to new script paths - Add script documentation to scripts/README.md
1 parent fe6ae56 commit 1f074c6

File tree

12 files changed

+80
-32
lines changed

12 files changed

+80
-32
lines changed

README.md

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ source leetcode/bin/activate
209209
pip install -r requirements.txt
210210

211211
# Make scripts executable
212-
chmod +x run_tests.sh run_case.sh new_problem.sh
212+
chmod +x scripts/run_tests.sh scripts/run_case.sh scripts/new_problem.sh
213213
```
214214

215215
</details>
@@ -218,10 +218,10 @@ chmod +x run_tests.sh run_case.sh new_problem.sh
218218

219219
```bash
220220
# Windows
221-
new_problem.bat 0001_two_sum
221+
scripts\new_problem.bat 0001_two_sum
222222

223223
# Linux/macOS
224-
./new_problem.sh 0001_two_sum
224+
./scripts/new_problem.sh 0001_two_sum
225225
```
226226

227227
This creates:
@@ -233,10 +233,10 @@ This creates:
233233

234234
```bash
235235
# Windows
236-
run_tests.bat 0001_two_sum
236+
scripts\run_tests.bat 0001_two_sum
237237

238238
# Linux/macOS
239-
./run_tests.sh 0001_two_sum
239+
./scripts/run_tests.sh 0001_two_sum
240240
```
241241

242242
### 4. Debug in VS Code
@@ -652,7 +652,7 @@ greedy 44.82ms O(kN) 3/3
652652
============================================================
653653
```
654654

655-
Create with template: `new_problem.bat 0023_merge_k_lists --multi`
655+
Create with template: `scripts\new_problem.bat 0023_merge_k_lists --multi`
656656

657657
> 📖 See [`docs/SOLUTION_CONTRACT.md` §B](docs/SOLUTION_CONTRACT.md#b-solutions-metadata-schema) for complete SOLUTIONS schema and validation rules.
658658
@@ -868,7 +868,7 @@ neetcode/
868868
├── .dev/ # 🧪 Maintainer zone (unit tests)
869869
│ ├── tests/ # Unit test suite (150+ cases)
870870
│ ├── tests_solutions/ # Solution validation tests
871-
│ ├── run_tests.bat/.sh # Run runner unit tests
871+
│ ├── scripts/run_tests.bat/.sh # Run runner unit tests
872872
│ ├── run_all_tests.bat/.sh # Run all unit tests
873873
│ ├── run_tests_solutions.bat/.sh # Run solution tests
874874
│ ├── TESTING.md # Testing documentation
@@ -881,9 +881,11 @@ neetcode/
881881
882882
├── leetcode/ # 🐍 Python virtual environment (3.11)
883883
884-
├── run_tests.bat / .sh # Run all tests for a problem
885-
├── run_case.bat / .sh # Run single test case
886-
├── new_problem.bat / .sh # Create new problem from template
884+
├── scripts/ # 🔧 Utility scripts
885+
│ ├── new_problem.bat / .sh # Create new problem from template
886+
│ ├── run_tests.bat / .sh # Run all tests for a problem
887+
│ ├── run_case.bat / .sh # Run single test case
888+
│ └── build_docs.bat / .sh # Build documentation site
887889
888890
├── requirements.txt # Python dependencies
889891
├── mkdocs.yml # MkDocs configuration

README_zh-TW.md

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ source leetcode/bin/activate
209209
pip install -r requirements.txt
210210

211211
# 設定腳本執行權限
212-
chmod +x run_tests.sh run_case.sh new_problem.sh
212+
chmod +x scripts/run_tests.sh scripts/run_case.sh scripts/new_problem.sh
213213
```
214214

215215
</details>
@@ -218,10 +218,10 @@ chmod +x run_tests.sh run_case.sh new_problem.sh
218218

219219
```bash
220220
# Windows
221-
new_problem.bat 0001_two_sum
221+
scripts\new_problem.bat 0001_two_sum
222222

223223
# Linux/macOS
224-
./new_problem.sh 0001_two_sum
224+
./scripts/new_problem.sh 0001_two_sum
225225
```
226226

227227
這會自動建立:
@@ -233,10 +233,10 @@ new_problem.bat 0001_two_sum
233233

234234
```bash
235235
# Windows
236-
run_tests.bat 0001_two_sum
236+
scripts\run_tests.bat 0001_two_sum
237237

238238
# Linux/macOS
239-
./run_tests.sh 0001_two_sum
239+
./scripts/run_tests.sh 0001_two_sum
240240
```
241241

242242
### 4. 在 VS Code 中除錯
@@ -604,7 +604,7 @@ greedy 44.82ms O(kN) 3/3
604604
============================================================
605605
```
606606

607-
使用模板建立:`new_problem.bat 0023_merge_k_lists --multi`
607+
使用模板建立:`scripts\new_problem.bat 0023_merge_k_lists --multi`
608608

609609
> 📖 完整 SOLUTIONS schema 和驗證規則請參見 [`docs/SOLUTION_CONTRACT.md` §B](docs/SOLUTION_CONTRACT.md#b-solutions-metadata-schema)
610610
@@ -820,7 +820,7 @@ neetcode/
820820
├── .dev/ # 🧪 維護者專區(單元測試)
821821
│ ├── tests/ # 單元測試套件(150+ 案例)
822822
│ ├── tests_solutions/ # 解答驗證測試
823-
│ ├── run_tests.bat/.sh # 執行 runner 單元測試
823+
│ ├── scripts/run_tests.bat/.sh # 執行 runner 單元測試
824824
│ ├── run_all_tests.bat/.sh # 執行所有單元測試
825825
│ ├── run_tests_solutions.bat/.sh # 執行解答測試
826826
│ ├── TESTING.md # 測試文件
@@ -833,9 +833,11 @@ neetcode/
833833
834834
├── leetcode/ # 🐍 Python 虛擬環境(3.11)
835835
836-
├── run_tests.bat / .sh # 執行某題目的所有測試
837-
├── run_case.bat / .sh # 執行單一測資
838-
├── new_problem.bat / .sh # 從模板建立新題目
836+
├── scripts/ # 🔧 工具腳本
837+
│ ├── new_problem.bat / .sh # 從模板建立新題目
838+
│ ├── run_tests.bat / .sh # 執行某題目的所有測試
839+
│ ├── run_case.bat / .sh # 執行單一測資
840+
│ └── build_docs.bat / .sh # 建置文件網站
839841
840842
├── requirements.txt # Python 相依套件
841843
├── mkdocs.yml # MkDocs 配置

docs/ACT_LOCAL_GITHUB_ACTIONS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ This guide shows you how to use `act` to run GitHub Actions workflows locally wi
1212
>
1313
> **Core LeetCode practice functionality does NOT require this:**
1414
> - ✅ Solving problems (`solutions/`, `generators/`)
15-
> - ✅ Running tests (`run_tests.bat/sh`, `run_case.bat/sh`)
15+
> - ✅ Running tests (`scripts/run_tests.bat/sh`, `scripts/run_case.bat/sh`)
1616
> - ✅ Using the runner framework (`runner/`)
1717
> - ✅ All core practice features work without any CI/CD setup
1818
>

docs/ARCHITECTURE_MIGRATION.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ SOLUTIONS = {
424424
- Updated `template_solution.py` to use `SOLUTIONS` + `get_solver()`
425425
- Updated `template_solution_multi.py` to use polymorphic pattern
426426
- Deleted deprecated `template_solution_wrapper.py`
427-
- Updated `new_problem.bat` and `new_problem.sh` (removed `--wrapper` option)
428-
- Updated `run_tests.bat` to pass all arguments
427+
- Updated `scripts/new_problem.bat` and `scripts/new_problem.sh` (removed `--wrapper` option)
428+
- Updated `scripts/run_tests.bat` to pass all arguments
429429
- Created `docs/SOLUTION_CONTRACT.md` as canonical specification
430430

docs/BUILD_DOCS_MANUAL.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ This guide shows you how to build documentation locally using simple batch/shell
1212
>
1313
> **Core LeetCode practice functionality does NOT require this:**
1414
> - ✅ Solving problems (`solutions/`, `generators/`)
15-
> - ✅ Running tests (`run_tests.bat/sh`, `run_case.bat/sh`)
15+
> - ✅ Running tests (`scripts/run_tests.bat/sh`, `scripts/run_case.bat/sh`)
1616
> - ✅ Using the runner framework (`runner/`)
1717
> - ✅ All core practice features work without any documentation build setup
1818
>

scripts/README.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,20 @@ This directory contains utility scripts for project maintenance and development.
88

99
## 📋 Available Scripts
1010

11+
### Problem Management Scripts
12+
13+
| Script | Purpose | Usage |
14+
|:-------|:--------|:------|
15+
| `new_problem.bat` / `new_problem.sh` | Create new problem from template | `scripts\new_problem.bat 0001_two_sum` (Windows)<br>`./scripts/new_problem.sh 0001_two_sum` (Linux/macOS) |
16+
| `run_tests.bat` / `run_tests.sh` | Run all tests for a problem | `scripts\run_tests.bat 0001_two_sum` (Windows)<br>`./scripts/run_tests.sh 0001_two_sum` (Linux/macOS) |
17+
| `run_case.bat` / `run_case.sh` | Run single test case | `scripts\run_case.bat 0001_two_sum 1` (Windows)<br>`./scripts/run_case.sh 0001_two_sum 1` (Linux/macOS) |
18+
19+
**Features:**
20+
- ✅ Create problems from templates (single or multi-solution)
21+
- ✅ Run all test cases or individual cases
22+
- ✅ Support for benchmarking and multiple solutions
23+
- ✅ Cross-platform (Windows/Linux/macOS)
24+
1125
### Documentation Build Scripts
1226

1327
| Script | Purpose | Usage |
@@ -26,6 +40,36 @@ This directory contains utility scripts for project maintenance and development.
2640

2741
## 🎯 Usage
2842

43+
### Create New Problem
44+
45+
```bash
46+
# Windows
47+
scripts\new_problem.bat 0001_two_sum
48+
scripts\new_problem.bat 0023_merge_k_lists --multi
49+
50+
# Linux/macOS
51+
./scripts/new_problem.sh 0001_two_sum
52+
./scripts/new_problem.sh 0023_merge_k_lists --multi
53+
```
54+
55+
### Run Tests
56+
57+
```bash
58+
# Windows - Run all tests
59+
scripts\run_tests.bat 0001_two_sum
60+
scripts\run_tests.bat 0001_two_sum --all --benchmark
61+
62+
# Windows - Run single test case
63+
scripts\run_case.bat 0001_two_sum 1
64+
65+
# Linux/macOS - Run all tests
66+
./scripts/run_tests.sh 0001_two_sum
67+
./scripts/run_tests.sh 0001_two_sum --all --benchmark
68+
69+
# Linux/macOS - Run single test case
70+
./scripts/run_case.sh 0001_two_sum 1
71+
```
72+
2973
### Build Documentation
3074

3175
```bash

new_problem.bat renamed to scripts/new_problem.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ if "%~1"=="" (
2121
)
2222

2323
set PROBLEM=%~1
24-
set BASE_DIR=%~dp0
24+
set BASE_DIR=%~dp0..\
2525
set TEMPLATE=template_solution.py
2626
set TEMPLATE_TYPE=single
2727

new_problem.sh renamed to scripts/new_problem.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ if [ -z "$1" ]; then
2020
fi
2121

2222
PROBLEM="$1"
23-
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
23+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
2424
TEMPLATE="template_solution.py"
2525
TEMPLATE_TYPE="single"
2626

run_case.bat renamed to scripts/run_case.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ if "%~2"=="" (
1818
)
1919

2020
REM Use virtual environment Python
21-
"%~dp0leetcode\Scripts\python.exe" runner/case_runner.py %1 %2
21+
"%~dp0..\leetcode\Scripts\python.exe" "%~dp0..\runner\case_runner.py" %1 %2

run_case.sh renamed to scripts/run_case.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ if [ -z "$2" ]; then
1616
exit 1
1717
fi
1818

19-
# Get the directory where the script is located
20-
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
19+
# Get the directory where the script is located (parent directory)
20+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
2121

2222
# Use virtual environment Python
2323
"${SCRIPT_DIR}/leetcode/bin/python" "${SCRIPT_DIR}/runner/case_runner.py" "$1" "$2"

0 commit comments

Comments
 (0)