-
Notifications
You must be signed in to change notification settings - Fork 147
/
Copy pathapply-rules.bat
162 lines (146 loc) · 4.94 KB
/
apply-rules.bat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
@echo off
setlocal EnableDelayedExpansion
chcp 65001 >nul
echo DEBUG: Script started
if "%~1"=="" (
echo Error: Please provide the target project directory
echo Usage: %~nx0 ^<target-project-directory^>
exit /b 1
)
set "TARGET_DIR=%~1"
if not exist "%TARGET_DIR%\" (
echo Creating new project directory: %TARGET_DIR%
mkdir "%TARGET_DIR%"
(
echo # New Project
echo.
echo This project has been initialized with agile workflow support and auto rule generation configured from [cursor-auto-rules-agile-workflow](https://github.com/bmadcode/cursor-auto-rules-agile-workflow)
echo.
echo For workflow documentation, see [Workflow Rules](docs/workflow-rules.md)
) > "%TARGET_DIR%\README.md"
)
REM Create .cursor directory if it doesn't exist
if not exist "%TARGET_DIR%\.cursor\" (
mkdir "%TARGET_DIR%\.cursor"
)
REM Function to copy file if it doesn't exist
:copy_if_not_exists
set "src=%~1"
set "dest=%~2"
if not exist "%dest%" (
echo 📦 Copying new file: %~nx2
copy "%src%" "%dest%" >nul
) else (
echo ⏭️ Skipping existing file: %~nx2
)
exit /b
REM Copy all files from .cursor directory structure
echo 📦 Copying .cursor directory files...
for /r ".cursor" %%F in (*) do (
set "rel_path=%%~pF"
set "rel_path=!rel_path:.cursor\=!"
REM Create target directory if it doesn't exist
if not exist "%TARGET_DIR%\.cursor\!rel_path!" (
mkdir "%TARGET_DIR%\.cursor\!rel_path!"
)
REM Copy file if it doesn't exist
call :copy_if_not_exists "%%F" "%TARGET_DIR%\.cursor\!rel_path!%%~nxF"
)
REM Create docs directory if it doesn't exist
if not exist "%TARGET_DIR%\docs\" (
mkdir "%TARGET_DIR%\docs"
)
REM Create workflow documentation
(
echo # Cursor Workflow Rules
echo.
echo This project has been updated to use the auto rule generator from [cursor-auto-rules-agile-workflow](https://github.com/bmadcode/cursor-auto-rules-agile-workflow)
echo.
echo ^> **Note**: This script can be safely re-run at any time to update the template rules to their latest versions^. It will not impact or overwrite any custom rules you've created^.
echo.
echo ## Core Features
echo.
echo - Automated rule generation
echo - Standardized documentation formats
echo - Supports all four Note Types automatically
echo - AI behavior control and optimization
echo - Flexible workflow integration options
echo.
echo ## Getting Started
echo.
echo 1^. Review the templates in `xnotes/`
echo 2^. Choose your preferred workflow approach
echo 3^. Start using the AI with confidence!
echo.
echo For demos and tutorials, visit: [BMad Code Videos](https://youtube^.com/bmadcode)
) > "%TARGET_DIR%\docs\workflow-rules.md"
REM Update .gitignore with xnotes and docs
if exist "%TARGET_DIR%\.gitignore" (
findstr /L /C:".cursor/rules/_*.mdc" "%TARGET_DIR%\.gitignore" >nul
if errorlevel 1 (
(
echo.
echo # Private individual user cursor rules
echo .cursor/rules/_*.mdc
echo.
echo # Documentation and templates
echo xnotes/
echo docs/
) >> "%TARGET_DIR%\.gitignore"
)
) else (
(
echo # Private individual user cursor rules
echo .cursor/rules/_*.mdc
echo.
echo # Documentation and templates
echo xnotes/
echo docs/
) > "%TARGET_DIR%\.gitignore"
)
REM Add sample xnotes
echo Setting up sample xnotes file...
if not exist "%TARGET_DIR%\xnotes\" (
mkdir "%TARGET_DIR%\xnotes"
)
xcopy "xnotes\*.*" "%TARGET_DIR%\xnotes\" /E /I /Y >nul
REM Update .cursorignore
if exist "%TARGET_DIR%\.cursorignore" (
findstr /L /C:"xnotes/" "%TARGET_DIR%\.cursorignore" >nul
if errorlevel 1 (
(
echo.
echo # Project notes and templates
echo xnotes/
) >> "%TARGET_DIR%\.cursorignore"
)
) else (
(
echo # Project notes and templates
echo xnotes/
) > "%TARGET_DIR%\.cursorignore"
)
REM Create or update .cursorindexingignore
if exist "%TARGET_DIR%\.cursorindexingignore" (
findstr /L /C:".cursor/templates/" "%TARGET_DIR%\.cursorindexingignore" >nul
if errorlevel 1 (
(
echo.
echo # Templates - accessible but not indexed
echo .cursor/templates/
) >> "%TARGET_DIR%\.cursorindexingignore"
)
) else (
(
echo # Templates - accessible but not indexed
echo .cursor/templates/
) > "%TARGET_DIR%\.cursorindexingignore"
)
echo.
echo ✨ Deployment Complete!
echo 📁 Core rule generator: %TARGET_DIR%\.cursor\rules\core-rules\rule-generating-agent.mdc
echo 📁 Sample sub-folders and rules: %TARGET_DIR%\.cursor\rules\{sub-folders}\
echo 📁 Sample Agile Workflow Templates: %TARGET_DIR%\.cursor\templates\
echo 📄 Workflow Documentation: %TARGET_DIR%\docs\workflow-rules.md
echo 🔒 Updated .gitignore, .cursorignore, and .cursorindexingignore
endlocal