@atlashub/smartstack-cli 1.1.0
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.
- package/.documentation/agents.html +912 -0
- package/.documentation/apex.html +1014 -0
- package/.documentation/business-analyse.html +1074 -0
- package/.documentation/commands.html +676 -0
- package/.documentation/css/styles.css +2030 -0
- package/.documentation/efcore.html +2501 -0
- package/.documentation/gitflow.html +2053 -0
- package/.documentation/hooks.html +409 -0
- package/.documentation/index.html +319 -0
- package/.documentation/installation.html +458 -0
- package/.documentation/js/app.js +794 -0
- package/.documentation/test-web.html +509 -0
- package/README.md +90 -0
- package/config/default-config.json +86 -0
- package/config/settings.json +53 -0
- package/config/settings.local.example.json +16 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +38198 -0
- package/dist/index.js.map +1 -0
- package/package.json +86 -0
- package/templates/agents/action.md +36 -0
- package/templates/agents/efcore/conflicts.md +57 -0
- package/templates/agents/efcore/db-deploy.md +51 -0
- package/templates/agents/efcore/db-reset.md +59 -0
- package/templates/agents/efcore/db-seed.md +56 -0
- package/templates/agents/efcore/db-status.md +43 -0
- package/templates/agents/efcore/migration.md +85 -0
- package/templates/agents/efcore/rebase-snapshot.md +62 -0
- package/templates/agents/efcore/scan.md +60 -0
- package/templates/agents/efcore/squash.md +67 -0
- package/templates/agents/explore-codebase.md +65 -0
- package/templates/agents/explore-docs.md +97 -0
- package/templates/agents/fix-grammar.md +49 -0
- package/templates/agents/gitflow/abort.md +45 -0
- package/templates/agents/gitflow/cleanup.md +85 -0
- package/templates/agents/gitflow/commit.md +40 -0
- package/templates/agents/gitflow/exec.md +48 -0
- package/templates/agents/gitflow/finish.md +92 -0
- package/templates/agents/gitflow/init.md +139 -0
- package/templates/agents/gitflow/merge.md +62 -0
- package/templates/agents/gitflow/plan.md +42 -0
- package/templates/agents/gitflow/pr.md +78 -0
- package/templates/agents/gitflow/review.md +49 -0
- package/templates/agents/gitflow/start.md +61 -0
- package/templates/agents/gitflow/status.md +32 -0
- package/templates/agents/snipper.md +36 -0
- package/templates/agents/websearch.md +46 -0
- package/templates/commands/_resources/formatting-guide.md +124 -0
- package/templates/commands/ai-prompt.md +315 -0
- package/templates/commands/apex/1-analyze.md +100 -0
- package/templates/commands/apex/2-plan.md +145 -0
- package/templates/commands/apex/3-execute.md +171 -0
- package/templates/commands/apex/4-examine.md +116 -0
- package/templates/commands/apex/5-tasks.md +209 -0
- package/templates/commands/apex.md +76 -0
- package/templates/commands/application/create.md +362 -0
- package/templates/commands/application/templates-backend.md +463 -0
- package/templates/commands/application/templates-frontend.md +517 -0
- package/templates/commands/application/templates-i18n.md +478 -0
- package/templates/commands/application/templates-seed.md +362 -0
- package/templates/commands/application.md +303 -0
- package/templates/commands/business-analyse/1-init.md +269 -0
- package/templates/commands/business-analyse/2-discover.md +520 -0
- package/templates/commands/business-analyse/3-analyse.md +408 -0
- package/templates/commands/business-analyse/4-specify.md +598 -0
- package/templates/commands/business-analyse/5-validate.md +326 -0
- package/templates/commands/business-analyse/6-handoff.md +746 -0
- package/templates/commands/business-analyse/7-doc-html.md +602 -0
- package/templates/commands/business-analyse/bug.md +325 -0
- package/templates/commands/business-analyse/change-request.md +368 -0
- package/templates/commands/business-analyse/hotfix.md +200 -0
- package/templates/commands/business-analyse.md +559 -0
- package/templates/commands/controller/create.md +216 -0
- package/templates/commands/controller/postman-templates.md +528 -0
- package/templates/commands/controller/templates.md +600 -0
- package/templates/commands/controller.md +278 -0
- package/templates/commands/debug.md +95 -0
- package/templates/commands/documentation/module.md +202 -0
- package/templates/commands/documentation/templates.md +432 -0
- package/templates/commands/documentation.md +190 -0
- package/templates/commands/efcore/_env-check.md +153 -0
- package/templates/commands/efcore/conflicts.md +269 -0
- package/templates/commands/efcore/db-deploy.md +193 -0
- package/templates/commands/efcore/db-reset.md +426 -0
- package/templates/commands/efcore/db-seed.md +326 -0
- package/templates/commands/efcore/db-status.md +214 -0
- package/templates/commands/efcore/migration.md +388 -0
- package/templates/commands/efcore/rebase-snapshot.md +264 -0
- package/templates/commands/efcore/scan.md +202 -0
- package/templates/commands/efcore/squash.md +298 -0
- package/templates/commands/efcore.md +176 -0
- package/templates/commands/epct.md +69 -0
- package/templates/commands/explain.md +186 -0
- package/templates/commands/explore.md +45 -0
- package/templates/commands/feature-full.md +267 -0
- package/templates/commands/gitflow/1-init.md +1038 -0
- package/templates/commands/gitflow/10-start.md +768 -0
- package/templates/commands/gitflow/11-finish.md +323 -0
- package/templates/commands/gitflow/12-cleanup.md +276 -0
- package/templates/commands/gitflow/13-sync.md +216 -0
- package/templates/commands/gitflow/14-rebase.md +251 -0
- package/templates/commands/gitflow/2-status.md +167 -0
- package/templates/commands/gitflow/3-commit.md +194 -0
- package/templates/commands/gitflow/4-plan.md +145 -0
- package/templates/commands/gitflow/5-exec.md +147 -0
- package/templates/commands/gitflow/6-abort.md +344 -0
- package/templates/commands/gitflow/7-pull-request.md +226 -0
- package/templates/commands/gitflow/8-review.md +176 -0
- package/templates/commands/gitflow/9-merge.md +224 -0
- package/templates/commands/gitflow.md +128 -0
- package/templates/commands/implement.md +663 -0
- package/templates/commands/notification.md +129 -0
- package/templates/commands/oneshot.md +57 -0
- package/templates/commands/quick-search.md +72 -0
- package/templates/commands/review.md +106 -0
- package/templates/commands/utils/test-web-config.md +160 -0
- package/templates/commands/utils/test-web.md +151 -0
- package/templates/commands/workflow.md +193 -0
- package/templates/gitflow/config.json +138 -0
- package/templates/hooks/ef-migration-check.md +139 -0
- package/templates/hooks/hooks.json +15 -0
- package/templates/skills/ai-prompt/SKILL.md +778 -0
- package/templates/skills/application/SKILL.md +563 -0
- package/templates/skills/application/templates-backend.md +450 -0
- package/templates/skills/application/templates-frontend.md +531 -0
- package/templates/skills/application/templates-i18n.md +520 -0
- package/templates/skills/application/templates-seed.md +647 -0
- package/templates/skills/business-analyse/SKILL.md +191 -0
- package/templates/skills/business-analyse/questionnaire.md +283 -0
- package/templates/skills/business-analyse/templates-frd.md +477 -0
- package/templates/skills/business-analyse/templates-react.md +580 -0
- package/templates/skills/controller/SKILL.md +240 -0
- package/templates/skills/controller/postman-templates.md +614 -0
- package/templates/skills/controller/templates.md +1468 -0
- package/templates/skills/documentation/SKILL.md +133 -0
- package/templates/skills/documentation/templates.md +476 -0
- package/templates/skills/feature-full/SKILL.md +838 -0
- package/templates/skills/notification/SKILL.md +555 -0
- package/templates/skills/ui-components/SKILL.md +870 -0
- package/templates/skills/workflow/SKILL.md +582 -0
- package/templates/test-web/api-health.json +38 -0
- package/templates/test-web/minimal.json +19 -0
- package/templates/test-web/npm-package.json +46 -0
- package/templates/test-web/seo-check.json +54 -0
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
# EF Core Environment Check (Shared Step)
|
|
2
|
+
|
|
3
|
+
> **Usage:** Include ce step dans toutes les commandes EF Core qui interagissent avec la base de donnees.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## STEP 0: Verification environnement et connexion
|
|
8
|
+
|
|
9
|
+
### 0.1 Detecter les fichiers appsettings disponibles
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
# Scanner les fichiers appsettings dans le projet API
|
|
13
|
+
API_DIR=$(find . -type d -name "*.Api" -o -name "*Web" | head -1)
|
|
14
|
+
if [ -z "$API_DIR" ]; then
|
|
15
|
+
API_DIR="."
|
|
16
|
+
fi
|
|
17
|
+
|
|
18
|
+
# Lister tous les appsettings
|
|
19
|
+
APPSETTINGS_FILES=$(find "$API_DIR" -maxdepth 1 -name "appsettings*.json" 2>/dev/null | sort)
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
### 0.2 Determiner l'environnement a utiliser
|
|
23
|
+
|
|
24
|
+
**Priorite:**
|
|
25
|
+
1. Flag `--env {Environment}` si fourni
|
|
26
|
+
2. `appsettings.Local.json` (defaut recommande)
|
|
27
|
+
3. Erreur si aucun fichier trouve
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
# Logique de selection
|
|
31
|
+
ENV_FLAG="$1" # --env Development par exemple
|
|
32
|
+
|
|
33
|
+
if [ -n "$ENV_FLAG" ]; then
|
|
34
|
+
SELECTED_ENV="appsettings.${ENV_FLAG}.json"
|
|
35
|
+
elif [ -f "$API_DIR/appsettings.Local.json" ]; then
|
|
36
|
+
SELECTED_ENV="appsettings.Local.json"
|
|
37
|
+
else
|
|
38
|
+
echo "ERROR: Aucun fichier appsettings trouve"
|
|
39
|
+
echo " Creez appsettings.Local.json ou utilisez --env {Environment}"
|
|
40
|
+
exit 1
|
|
41
|
+
fi
|
|
42
|
+
|
|
43
|
+
# Verifier que le fichier existe
|
|
44
|
+
if [ ! -f "$API_DIR/$SELECTED_ENV" ]; then
|
|
45
|
+
echo "ERROR: $SELECTED_ENV non trouve dans $API_DIR"
|
|
46
|
+
exit 1
|
|
47
|
+
fi
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### 0.3 Extraire et afficher la connection string
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
# Extraire la connection string (PowerShell pour parsing JSON fiable)
|
|
54
|
+
CONNECTION_STRING=$(powershell -Command "
|
|
55
|
+
\$json = Get-Content '$API_DIR/$SELECTED_ENV' | ConvertFrom-Json
|
|
56
|
+
\$json.ConnectionStrings.DefaultConnection
|
|
57
|
+
")
|
|
58
|
+
|
|
59
|
+
# Extraire le nom de la base de donnees
|
|
60
|
+
DATABASE_NAME=$(echo "$CONNECTION_STRING" | grep -oP 'Database=\K[^;]+' || echo "Unknown")
|
|
61
|
+
SERVER_NAME=$(echo "$CONNECTION_STRING" | grep -oP 'Server=\K[^;]+' || echo "Unknown")
|
|
62
|
+
|
|
63
|
+
# Masquer le mot de passe si present
|
|
64
|
+
CONNECTION_MASKED=$(echo "$CONNECTION_STRING" | sed 's/Password=[^;]*/Password=****/g')
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### 0.4 Afficher le resume
|
|
68
|
+
|
|
69
|
+
```
|
|
70
|
+
================================================================================
|
|
71
|
+
EF CORE - ENVIRONNEMENT
|
|
72
|
+
================================================================================
|
|
73
|
+
|
|
74
|
+
FICHIERS DISPONIBLES:
|
|
75
|
+
{liste des appsettings detectes}
|
|
76
|
+
|
|
77
|
+
SELECTION: {SELECTED_ENV} {(defaut) si Local}
|
|
78
|
+
|
|
79
|
+
CONNEXION:
|
|
80
|
+
Server: {SERVER_NAME}
|
|
81
|
+
Database: {DATABASE_NAME}
|
|
82
|
+
String: {CONNECTION_MASKED}
|
|
83
|
+
|
|
84
|
+
================================================================================
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### 0.5 Protection Production
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
# Bloquer si Production detecte (sauf pour db-status qui est read-only)
|
|
91
|
+
if [[ "$SELECTED_ENV" == *"Production"* ]]; then
|
|
92
|
+
echo "================================================================================
|
|
93
|
+
BLOQUE - ENVIRONNEMENT PRODUCTION
|
|
94
|
+
================================================================================
|
|
95
|
+
|
|
96
|
+
Cette commande est bloquee pour proteger les donnees de production.
|
|
97
|
+
|
|
98
|
+
OPTIONS:
|
|
99
|
+
1. Utilisez un environnement non-production
|
|
100
|
+
2. Contactez support@atlshub.ch pour assistance
|
|
101
|
+
|
|
102
|
+
================================================================================
|
|
103
|
+
"
|
|
104
|
+
exit 1
|
|
105
|
+
fi
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### 0.6 Confirmation (pour commandes destructives)
|
|
109
|
+
|
|
110
|
+
> **Note:** Utiliser uniquement pour db-reset, db-seed, et autres commandes destructives.
|
|
111
|
+
|
|
112
|
+
```javascript
|
|
113
|
+
AskUserQuestion({
|
|
114
|
+
questions: [{
|
|
115
|
+
question: "Confirmer l'execution sur cette base de donnees?",
|
|
116
|
+
header: "Confirm",
|
|
117
|
+
options: [
|
|
118
|
+
{ label: "Oui, continuer", description: "Executer sur " + DATABASE_NAME },
|
|
119
|
+
{ label: "Non, annuler", description: "Arreter l'execution" }
|
|
120
|
+
],
|
|
121
|
+
multiSelect: false
|
|
122
|
+
}]
|
|
123
|
+
})
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
---
|
|
127
|
+
|
|
128
|
+
## Variables exportees
|
|
129
|
+
|
|
130
|
+
Apres ce step, les variables suivantes sont disponibles:
|
|
131
|
+
|
|
132
|
+
| Variable | Description |
|
|
133
|
+
|----------|-------------|
|
|
134
|
+
| `SELECTED_ENV` | Fichier appsettings utilise |
|
|
135
|
+
| `CONNECTION_STRING` | Connection string complete |
|
|
136
|
+
| `CONNECTION_MASKED` | Connection string masquee |
|
|
137
|
+
| `DATABASE_NAME` | Nom de la base de donnees |
|
|
138
|
+
| `SERVER_NAME` | Nom du serveur |
|
|
139
|
+
| `API_DIR` | Repertoire du projet API |
|
|
140
|
+
|
|
141
|
+
---
|
|
142
|
+
|
|
143
|
+
## Utilisation dans les commandes
|
|
144
|
+
|
|
145
|
+
```markdown
|
|
146
|
+
## STEP 0: Verification environnement
|
|
147
|
+
|
|
148
|
+
> **Include:** `_env-check.md`
|
|
149
|
+
|
|
150
|
+
{Executer les etapes 0.1 a 0.4}
|
|
151
|
+
{Executer 0.5 si commande modifie la base}
|
|
152
|
+
{Executer 0.6 si commande est destructive}
|
|
153
|
+
```
|
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Analyze conflicts before merge (BLOCKING if conflict detected)
|
|
3
|
+
agent: efcore-conflicts
|
|
4
|
+
model: sonnet
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# EF Core Conflicts - Cross-Branch Conflict Analysis
|
|
8
|
+
|
|
9
|
+
Analyzes potential conflicts between current branch and develop. **BLOCKING** if conflict detected.
|
|
10
|
+
|
|
11
|
+
**USAGE:** Before a merge or commit to ensure there are no migration conflicts.
|
|
12
|
+
|
|
13
|
+
**BEHAVIOR:** Returns exit code 1 if conflict detected (blocks merge/commit).
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## STEP 1: Check current branch
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
CURRENT_BRANCH=$(git branch --show-current)
|
|
21
|
+
echo "Current branch: $CURRENT_BRANCH"
|
|
22
|
+
|
|
23
|
+
if [ "$CURRENT_BRANCH" = "main" ] || [ "$CURRENT_BRANCH" = "develop" ]; then
|
|
24
|
+
echo "No analysis needed on $CURRENT_BRANCH"
|
|
25
|
+
exit 0
|
|
26
|
+
fi
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
## STEP 2: Locate ModelSnapshots
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
# Find local ModelSnapshot
|
|
35
|
+
LOCAL_SNAPSHOT=$(find . -name "*ModelSnapshot.cs" -not -path "*/node_modules/*" 2>/dev/null | head -1)
|
|
36
|
+
|
|
37
|
+
if [ -z "$LOCAL_SNAPSHOT" ]; then
|
|
38
|
+
echo "No ModelSnapshot found - no EF Core migrations"
|
|
39
|
+
exit 0
|
|
40
|
+
fi
|
|
41
|
+
|
|
42
|
+
echo "Local ModelSnapshot: $LOCAL_SNAPSHOT"
|
|
43
|
+
|
|
44
|
+
# Find develop's ModelSnapshot
|
|
45
|
+
WORKTREE_BASE=$(git config --get gitflow.worktrees.basePath 2>/dev/null || echo "../worktrees")
|
|
46
|
+
DEVELOP_SNAPSHOT="$WORKTREE_BASE/develop/$(dirname $LOCAL_SNAPSHOT)/*ModelSnapshot.cs"
|
|
47
|
+
|
|
48
|
+
if [ ! -f "$DEVELOP_SNAPSHOT" ]; then
|
|
49
|
+
# Fallback: get from git
|
|
50
|
+
DEVELOP_SNAPSHOT_CONTENT=$(git show develop:$LOCAL_SNAPSHOT 2>/dev/null)
|
|
51
|
+
if [ -z "$DEVELOP_SNAPSHOT_CONTENT" ]; then
|
|
52
|
+
echo "Cannot find develop's ModelSnapshot"
|
|
53
|
+
exit 1
|
|
54
|
+
fi
|
|
55
|
+
fi
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
---
|
|
59
|
+
|
|
60
|
+
## STEP 3: Compare ModelSnapshots
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
echo ""
|
|
64
|
+
echo "MODELSNAPSHOT COMPARISON"
|
|
65
|
+
echo "========================="
|
|
66
|
+
|
|
67
|
+
# Create temporary file for develop if needed
|
|
68
|
+
if [ -n "$DEVELOP_SNAPSHOT_CONTENT" ]; then
|
|
69
|
+
TEMP_DEVELOP=$(mktemp)
|
|
70
|
+
echo "$DEVELOP_SNAPSHOT_CONTENT" > "$TEMP_DEVELOP"
|
|
71
|
+
DEVELOP_SNAPSHOT="$TEMP_DEVELOP"
|
|
72
|
+
fi
|
|
73
|
+
|
|
74
|
+
# Compare
|
|
75
|
+
if diff -q "$LOCAL_SNAPSHOT" "$DEVELOP_SNAPSHOT" > /dev/null 2>&1; then
|
|
76
|
+
echo "Identical ModelSnapshots - No conflict"
|
|
77
|
+
CONFLICT_LEVEL="NONE"
|
|
78
|
+
else
|
|
79
|
+
# Analyze differences
|
|
80
|
+
DIFF_OUTPUT=$(diff "$DEVELOP_SNAPSHOT" "$LOCAL_SNAPSHOT" 2>/dev/null)
|
|
81
|
+
DIFF_LINES=$(echo "$DIFF_OUTPUT" | wc -l)
|
|
82
|
+
|
|
83
|
+
echo "Differences detected: $DIFF_LINES lines"
|
|
84
|
+
fi
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
---
|
|
88
|
+
|
|
89
|
+
## STEP 4: Analyze conflict type
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
if [ "$CONFLICT_LEVEL" != "NONE" ]; then
|
|
93
|
+
# Extract modified entities
|
|
94
|
+
LOCAL_ENTITIES=$(grep -E "entity\.(Property|HasKey|HasIndex|ToTable)" "$LOCAL_SNAPSHOT" | sort -u)
|
|
95
|
+
DEVELOP_ENTITIES=$(grep -E "entity\.(Property|HasKey|HasIndex|ToTable)" "$DEVELOP_SNAPSHOT" | sort -u)
|
|
96
|
+
|
|
97
|
+
# Find locally modified tables
|
|
98
|
+
LOCAL_TABLES=$(grep -oE 'ToTable\("([^"]+)"' "$LOCAL_SNAPSHOT" | sort -u)
|
|
99
|
+
DEVELOP_TABLES=$(grep -oE 'ToTable\("([^"]+)"' "$DEVELOP_SNAPSHOT" | sort -u)
|
|
100
|
+
|
|
101
|
+
# Compare tables
|
|
102
|
+
COMMON_MODIFIED=$(comm -12 <(echo "$LOCAL_TABLES") <(echo "$DEVELOP_TABLES"))
|
|
103
|
+
|
|
104
|
+
if [ -n "$COMMON_MODIFIED" ]; then
|
|
105
|
+
echo ""
|
|
106
|
+
echo "TABLES MODIFIED ON BOTH SIDES:"
|
|
107
|
+
echo "$COMMON_MODIFIED"
|
|
108
|
+
CONFLICT_LEVEL="HIGH"
|
|
109
|
+
else
|
|
110
|
+
CONFLICT_LEVEL="LOW"
|
|
111
|
+
fi
|
|
112
|
+
|
|
113
|
+
# Check columns
|
|
114
|
+
LOCAL_COLUMNS=$(grep -oE 'Property<[^>]+>\("([^"]+)"' "$LOCAL_SNAPSHOT" | sort -u)
|
|
115
|
+
DEVELOP_COLUMNS=$(grep -oE 'Property<[^>]+>\("([^"]+)"' "$DEVELOP_SNAPSHOT" | sort -u)
|
|
116
|
+
|
|
117
|
+
# New local columns
|
|
118
|
+
NEW_LOCAL_COLUMNS=$(comm -23 <(echo "$LOCAL_COLUMNS") <(echo "$DEVELOP_COLUMNS"))
|
|
119
|
+
|
|
120
|
+
if [ -n "$NEW_LOCAL_COLUMNS" ]; then
|
|
121
|
+
echo ""
|
|
122
|
+
echo "NEW COLUMNS (this branch):"
|
|
123
|
+
echo "$NEW_LOCAL_COLUMNS" | head -10
|
|
124
|
+
fi
|
|
125
|
+
fi
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
---
|
|
129
|
+
|
|
130
|
+
## STEP 5: Scan other active branches
|
|
131
|
+
|
|
132
|
+
```bash
|
|
133
|
+
echo ""
|
|
134
|
+
echo "OTHER BRANCHES WITH MIGRATIONS"
|
|
135
|
+
echo "==============================="
|
|
136
|
+
|
|
137
|
+
for worktree in $(git worktree list --porcelain | grep "^worktree" | cut -d' ' -f2); do
|
|
138
|
+
BRANCH=$(git -C "$worktree" branch --show-current 2>/dev/null)
|
|
139
|
+
|
|
140
|
+
if [ "$BRANCH" = "$CURRENT_BRANCH" ] || [ "$BRANCH" = "develop" ] || [ "$BRANCH" = "main" ]; then
|
|
141
|
+
continue
|
|
142
|
+
fi
|
|
143
|
+
|
|
144
|
+
OTHER_SNAPSHOT=$(find "$worktree" -name "*ModelSnapshot.cs" 2>/dev/null | head -1)
|
|
145
|
+
|
|
146
|
+
if [ -n "$OTHER_SNAPSHOT" ]; then
|
|
147
|
+
if ! diff -q "$LOCAL_SNAPSHOT" "$OTHER_SNAPSHOT" > /dev/null 2>&1; then
|
|
148
|
+
echo "$BRANCH: Different ModelSnapshot"
|
|
149
|
+
|
|
150
|
+
# Check if same table modified
|
|
151
|
+
OTHER_TABLES=$(grep -oE 'ToTable\("([^"]+)"' "$OTHER_SNAPSHOT" | sort -u)
|
|
152
|
+
OVERLAP=$(comm -12 <(echo "$LOCAL_TABLES") <(echo "$OTHER_TABLES"))
|
|
153
|
+
|
|
154
|
+
if [ -n "$OVERLAP" ]; then
|
|
155
|
+
echo " WARNING: Common tables modified with $BRANCH"
|
|
156
|
+
CONFLICT_LEVEL="HIGH"
|
|
157
|
+
fi
|
|
158
|
+
fi
|
|
159
|
+
fi
|
|
160
|
+
done
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
---
|
|
164
|
+
|
|
165
|
+
## STEP 6: Final verdict
|
|
166
|
+
|
|
167
|
+
```bash
|
|
168
|
+
echo ""
|
|
169
|
+
echo "================================================================================
|
|
170
|
+
ANALYSIS RESULT
|
|
171
|
+
================================================================================
|
|
172
|
+
"
|
|
173
|
+
|
|
174
|
+
case $CONFLICT_LEVEL in
|
|
175
|
+
"NONE")
|
|
176
|
+
echo "STATUS: OK"
|
|
177
|
+
echo "No conflict detected. Merge allowed."
|
|
178
|
+
exit 0
|
|
179
|
+
;;
|
|
180
|
+
"LOW")
|
|
181
|
+
echo "STATUS: OK (with caution)"
|
|
182
|
+
echo "Modifications on different tables. Merge allowed."
|
|
183
|
+
exit 0
|
|
184
|
+
;;
|
|
185
|
+
"MEDIUM")
|
|
186
|
+
echo "STATUS: CAUTION"
|
|
187
|
+
echo "FK to same tables. Check merge order."
|
|
188
|
+
exit 0
|
|
189
|
+
;;
|
|
190
|
+
"HIGH")
|
|
191
|
+
echo "STATUS: CONFLICT DETECTED"
|
|
192
|
+
echo ""
|
|
193
|
+
echo "RESOLUTION REQUIRED:"
|
|
194
|
+
echo " 1. /efcore:rebase-snapshot (recommended)"
|
|
195
|
+
echo " 2. /efcore:conflicts --force (not recommended)"
|
|
196
|
+
echo " 3. Merge other branch first"
|
|
197
|
+
echo ""
|
|
198
|
+
echo "BLOCKING: Merge not allowed."
|
|
199
|
+
exit 1
|
|
200
|
+
;;
|
|
201
|
+
"CRITICAL")
|
|
202
|
+
echo "STATUS: CRITICAL CONFLICT"
|
|
203
|
+
echo ""
|
|
204
|
+
echo "Same column modified on both sides."
|
|
205
|
+
echo "Manual intervention required."
|
|
206
|
+
echo ""
|
|
207
|
+
exit 1
|
|
208
|
+
;;
|
|
209
|
+
esac
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
---
|
|
213
|
+
|
|
214
|
+
## Output Format
|
|
215
|
+
|
|
216
|
+
```
|
|
217
|
+
================================================================================
|
|
218
|
+
EF CORE CONFLICT ANALYSIS
|
|
219
|
+
================================================================================
|
|
220
|
+
|
|
221
|
+
BRANCH: feature/user-auth
|
|
222
|
+
TARGET: develop
|
|
223
|
+
|
|
224
|
+
MODELSNAPSHOT
|
|
225
|
+
Local: a1b2c3d4 (13 migrations)
|
|
226
|
+
Develop: e5f6g7h8 (12 migrations)
|
|
227
|
+
Status: DIFFERENT
|
|
228
|
+
|
|
229
|
+
MODIFIED TABLES
|
|
230
|
+
Local: Users, Roles, UserRoles
|
|
231
|
+
Develop: Users, Permissions
|
|
232
|
+
|
|
233
|
+
CONFLICT DETECTED
|
|
234
|
+
Table "Users" modified on both sides
|
|
235
|
+
|
|
236
|
+
OTHER BRANCHES
|
|
237
|
+
feature/add-products: OK (different tables)
|
|
238
|
+
|
|
239
|
+
================================================================================
|
|
240
|
+
STATUS: CONFLICT - EXIT CODE 1
|
|
241
|
+
================================================================================
|
|
242
|
+
|
|
243
|
+
RESOLUTION:
|
|
244
|
+
/efcore:rebase-snapshot Rebase on develop (recommended)
|
|
245
|
+
/efcore:conflicts --force Force (not recommended)
|
|
246
|
+
|
|
247
|
+
================================================================================
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
---
|
|
251
|
+
|
|
252
|
+
## Options
|
|
253
|
+
|
|
254
|
+
| Option | Description |
|
|
255
|
+
|--------|-------------|
|
|
256
|
+
| `--force` | Ignore conflict (not recommended) |
|
|
257
|
+
| `--verbose` | Display detailed differences |
|
|
258
|
+
| `--json` | JSON output for CI/CD |
|
|
259
|
+
| `--target <branch>` | Compare with branch other than develop |
|
|
260
|
+
|
|
261
|
+
---
|
|
262
|
+
|
|
263
|
+
## Exit Codes
|
|
264
|
+
|
|
265
|
+
| Code | Meaning |
|
|
266
|
+
|------|---------|
|
|
267
|
+
| 0 | No conflict or minor conflict |
|
|
268
|
+
| 1 | Conflict detected - merge blocked |
|
|
269
|
+
| 2 | Technical error |
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Deploy EF Core migrations to local database
|
|
3
|
+
agent: efcore-db-deploy
|
|
4
|
+
model: haiku
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# EF Core Database Deploy
|
|
8
|
+
|
|
9
|
+
Applies all pending migrations to the configured database.
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## STEP 0: Verification environnement et connexion
|
|
14
|
+
|
|
15
|
+
> **Include:** `_env-check.md` (etapes 0.1 a 0.4)
|
|
16
|
+
|
|
17
|
+
### 0.1 Detecter les fichiers appsettings
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
# Scanner les fichiers appsettings
|
|
21
|
+
API_DIR=$(find . -type d -name "*.Api" | head -1)
|
|
22
|
+
[ -z "$API_DIR" ] && API_DIR="src/SmartStack.Api"
|
|
23
|
+
|
|
24
|
+
APPSETTINGS_FILES=$(find "$API_DIR" -maxdepth 1 -name "appsettings*.json" 2>/dev/null | sort)
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### 0.2 Selectionner l'environnement
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
# Priorite: --env flag > appsettings.Local.json > erreur
|
|
31
|
+
ENV_FLAG="${1#--env=}" # Extraire valeur si --env=Development
|
|
32
|
+
|
|
33
|
+
if [ -n "$ENV_FLAG" ] && [ "$ENV_FLAG" != "$1" ]; then
|
|
34
|
+
SELECTED_ENV="appsettings.${ENV_FLAG}.json"
|
|
35
|
+
elif [ -f "$API_DIR/appsettings.Local.json" ]; then
|
|
36
|
+
SELECTED_ENV="appsettings.Local.json"
|
|
37
|
+
else
|
|
38
|
+
echo "ERROR: Aucun fichier appsettings trouve"
|
|
39
|
+
exit 1
|
|
40
|
+
fi
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### 0.3 Extraire et afficher la connexion
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
# Extraire connection string
|
|
47
|
+
CONNECTION_STRING=$(powershell -Command "
|
|
48
|
+
\$json = Get-Content '$API_DIR/$SELECTED_ENV' | ConvertFrom-Json
|
|
49
|
+
\$json.ConnectionStrings.DefaultConnection
|
|
50
|
+
")
|
|
51
|
+
|
|
52
|
+
DATABASE_NAME=$(echo "$CONNECTION_STRING" | grep -oP 'Database=\K[^;]+')
|
|
53
|
+
SERVER_NAME=$(echo "$CONNECTION_STRING" | grep -oP 'Server=\K[^;]+')
|
|
54
|
+
CONNECTION_MASKED=$(echo "$CONNECTION_STRING" | sed 's/Password=[^;]*/Password=****/g')
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### 0.4 Afficher le resume
|
|
58
|
+
|
|
59
|
+
```
|
|
60
|
+
================================================================================
|
|
61
|
+
EF CORE - DATABASE DEPLOY
|
|
62
|
+
================================================================================
|
|
63
|
+
|
|
64
|
+
FICHIERS DISPONIBLES:
|
|
65
|
+
{liste des appsettings detectes}
|
|
66
|
+
|
|
67
|
+
ENVIRONNEMENT: {SELECTED_ENV}
|
|
68
|
+
|
|
69
|
+
CONNEXION CIBLE:
|
|
70
|
+
Server: {SERVER_NAME}
|
|
71
|
+
Database: {DATABASE_NAME}
|
|
72
|
+
String: {CONNECTION_MASKED}
|
|
73
|
+
|
|
74
|
+
================================================================================
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### 0.5 Protection Production
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
# Bloquer si Production
|
|
81
|
+
if [[ "$SELECTED_ENV" == *"Production"* ]]; then
|
|
82
|
+
echo "BLOQUE: Environnement Production detecte"
|
|
83
|
+
echo " Utilisez un environnement non-production"
|
|
84
|
+
exit 1
|
|
85
|
+
fi
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
---
|
|
89
|
+
|
|
90
|
+
## STEP 1: Detecter le projet EF Core
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
# Detect EF Core project
|
|
94
|
+
CSPROJ=$(find . -name "*.csproj" -exec grep -l "Microsoft.EntityFrameworkCore" {} \; | head -1)
|
|
95
|
+
if [ -z "$CSPROJ" ]; then
|
|
96
|
+
echo "ERROR: No EF Core project detected"
|
|
97
|
+
exit 1
|
|
98
|
+
fi
|
|
99
|
+
|
|
100
|
+
PROJECT_DIR=$(dirname "$CSPROJ")
|
|
101
|
+
PROJECT_NAME=$(basename "$CSPROJ" .csproj)
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
---
|
|
105
|
+
|
|
106
|
+
## STEP 2: Check pending migrations
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
cd "$PROJECT_DIR"
|
|
110
|
+
dotnet ef migrations list --json 2>/dev/null | grep -E '"applied": false'
|
|
111
|
+
PENDING_COUNT=$(dotnet ef migrations list --json 2>/dev/null | grep -c '"applied": false' || echo "0")
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
**Display status:**
|
|
115
|
+
|
|
116
|
+
```
|
|
117
|
+
================================================================================
|
|
118
|
+
EF CORE - DATABASE DEPLOY
|
|
119
|
+
================================================================================
|
|
120
|
+
|
|
121
|
+
PROJECT: {PROJECT_NAME}
|
|
122
|
+
CONFIG: appsettings.Local.json
|
|
123
|
+
MIGRATIONS: {PENDING_COUNT} pending
|
|
124
|
+
|
|
125
|
+
================================================================================
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
---
|
|
129
|
+
|
|
130
|
+
## STEP 3: Apply migrations
|
|
131
|
+
|
|
132
|
+
```bash
|
|
133
|
+
# Apply migrations with local config
|
|
134
|
+
dotnet ef database update --configuration Release --verbose
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
**If connection error:**
|
|
138
|
+
|
|
139
|
+
```
|
|
140
|
+
⚠️ Database connection error
|
|
141
|
+
|
|
142
|
+
CHECKS:
|
|
143
|
+
1. Is SQL Server running?
|
|
144
|
+
2. Does the database exist?
|
|
145
|
+
3. Are the credentials correct?
|
|
146
|
+
|
|
147
|
+
USEFUL COMMANDS:
|
|
148
|
+
- Check connection: sqlcmd -S {SERVER} -E
|
|
149
|
+
- Create database: /efcore:db-reset
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
---
|
|
153
|
+
|
|
154
|
+
## STEP 4: Confirmation
|
|
155
|
+
|
|
156
|
+
```
|
|
157
|
+
================================================================================
|
|
158
|
+
DEPLOYMENT COMPLETE
|
|
159
|
+
================================================================================
|
|
160
|
+
|
|
161
|
+
✓ {N} migration(s) applied
|
|
162
|
+
✓ Database is up to date
|
|
163
|
+
|
|
164
|
+
NEXT COMMANDS:
|
|
165
|
+
/efcore:db-status → Check status
|
|
166
|
+
/efcore:db-seed → Populate test data
|
|
167
|
+
|
|
168
|
+
================================================================================
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
---
|
|
172
|
+
|
|
173
|
+
## Options
|
|
174
|
+
|
|
175
|
+
| Option | Description |
|
|
176
|
+
|--------|-------------|
|
|
177
|
+
| `--env {name}` | Utiliser appsettings.{name}.json (ex: --env Development) |
|
|
178
|
+
| `--verbose` | Display SQL details |
|
|
179
|
+
| `--connection "..."` | Override connection string |
|
|
180
|
+
| `--context {name}` | Specify DbContext if multiple |
|
|
181
|
+
|
|
182
|
+
## Exemples
|
|
183
|
+
|
|
184
|
+
```bash
|
|
185
|
+
# Deployer sur la base locale (defaut)
|
|
186
|
+
/efcore:db-deploy
|
|
187
|
+
|
|
188
|
+
# Deployer sur l'environnement Development
|
|
189
|
+
/efcore:db-deploy --env Development
|
|
190
|
+
|
|
191
|
+
# Deployer sur Staging
|
|
192
|
+
/efcore:db-deploy --env Staging
|
|
193
|
+
```
|