devzone 0.59.0 → 1.0.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/.devcontainer/agent-workspace.sh +1 -1
- package/.devcontainer/argocd/argocd.sh +0 -12
- package/.devcontainer/catalogue/mysql/mysql.sh +0 -12
- package/.devcontainer/catalogue.sh +1 -13
- package/.devcontainer/command-aliases.sh +78 -114
- package/.devcontainer/devzone +21 -36
- package/.devcontainer/gitlab/gitlab.sh +0 -12
- package/.devcontainer/gitlab/test-gitlab.sh +1 -1
- package/.devcontainer/help.sh +3 -3
- package/.devcontainer/paquets.sh +0 -12
- package/.devcontainer/ports.sh +0 -12
- package/.devcontainer/postgres/postgres.sh +0 -12
- package/.devcontainer/skills/devzone/SKILL.md +2 -2
- package/README.md +11 -1
- package/manage/devzone +61 -569
- package/manage/scripts/argocd-services.sh +2 -2
- package/manage/scripts/devzone-create.sh +138 -0
- package/manage/scripts/devzone-manifest.sh +171 -0
- package/manage/scripts/devzone-update.sh +222 -0
- package/manage/scripts/migrer.sh +2 -6
- package/manage/scripts/workspace-aliases.sh +4 -31
- package/manage/workspace.sh +7 -12
- package/package.json +1 -1
package/manage/devzone
CHANGED
|
@@ -1,28 +1,31 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
|
-
#
|
|
3
|
-
# devzone <
|
|
4
|
-
# devzone update
|
|
5
|
-
# devzone uninstall
|
|
2
|
+
# devzone command on your machine (npm package):
|
|
3
|
+
# devzone <folder> creates a devzone in <folder>, then starts it
|
|
4
|
+
# devzone update in a devzone folder: moves to the package version
|
|
5
|
+
# devzone uninstall in a devzone folder: removes everything it created
|
|
6
6
|
# devzone --version | --help
|
|
7
|
-
#
|
|
7
|
+
# In the container, « devzone » is another command: the modules
|
|
8
8
|
# (.devcontainer/devzone).
|
|
9
|
-
# DEVZONE_SANS_DEMARRER=1
|
|
9
|
+
# DEVZONE_SANS_DEMARRER=1: copy only, without starting the container (tests).
|
|
10
|
+
# The helpers live in manage/scripts/devzone-*.sh, sourced by the command that
|
|
11
|
+
# needs them (so --version and --help work with this file alone).
|
|
12
|
+
# shellcheck disable=SC2034 # PACKAGE_ITEMS, GITIGNORE_LINES: read by the sourced devzone-*.sh
|
|
10
13
|
set -euo pipefail
|
|
11
14
|
|
|
12
|
-
#
|
|
13
|
-
#
|
|
14
|
-
#
|
|
15
|
-
#
|
|
15
|
+
# Script path. From cmd, the npm .cmd shim calls bash with the Windows path
|
|
16
|
+
# (C:\…\bin\devzone): without "/", dirname/readlink would give "." and PAQUET
|
|
17
|
+
# would be wrong. We normalize first (cygpath from Git Bash, else \ → /);
|
|
18
|
+
# macOS/Linux: POSIX path, unchanged.
|
|
16
19
|
SCRIPT="${BASH_SOURCE[0]}"
|
|
17
20
|
case "$SCRIPT" in
|
|
18
21
|
[A-Za-z]:[\\/]*) SCRIPT="$(cygpath -u "$SCRIPT" 2>/dev/null || echo "${SCRIPT//\\//}")" ;;
|
|
19
22
|
esac
|
|
20
23
|
PAQUET="$(cd "$(dirname "$(readlink -f "$SCRIPT" 2>/dev/null || echo "$SCRIPT")")/.." && pwd)"
|
|
21
|
-
#
|
|
22
|
-
#
|
|
23
|
-
|
|
24
|
-
#
|
|
25
|
-
|
|
24
|
+
# Items copied into a devzone (same list as the « files » of package.json,
|
|
25
|
+
# without the command manage/devzone); manage/scripts is copied apart, under manage/
|
|
26
|
+
PACKAGE_ITEMS=(.devcontainer Makefile .gitattributes README.md LICENSE)
|
|
27
|
+
# Lines always present in the .gitignore of a devzone: added to, never overwritten
|
|
28
|
+
GITIGNORE_LINES=(
|
|
26
29
|
'# Chaque projet du workspace a son propre dépôt git'
|
|
27
30
|
'workspace/*'
|
|
28
31
|
'!workspace/.gitkeep'
|
|
@@ -35,390 +38,16 @@ LIGNES_GITIGNORE=(
|
|
|
35
38
|
'.devcontainer/without-host-docker/'
|
|
36
39
|
)
|
|
37
40
|
|
|
41
|
+
# Version of the package (package.json next to manage/)
|
|
38
42
|
version() {
|
|
39
|
-
#
|
|
40
|
-
#
|
|
41
|
-
#
|
|
43
|
+
# Path passed as an argument to node, never written in the JavaScript code of -p:
|
|
44
|
+
# under Git Bash $PAQUET is /c/… and only a separate argument is converted
|
|
45
|
+
# for a Windows program (cygpath not needed)
|
|
42
46
|
node -p 'require(process.argv[1]).version' "$PAQUET/package.json" 2>/dev/null || echo inconnue
|
|
43
47
|
}
|
|
44
48
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
empreinte() {
|
|
48
|
-
node -e 'const fs = require("fs"), crypto = require("crypto"); const h = crypto.createHash("sha256"); h.update(fs.readFileSync(process.argv[1])); process.stdout.write(h.digest("hex"))' "$1"
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
# Fichiers du paquet copiés dans un devzone, chemins absolus puis relatifs
|
|
52
|
-
fichiers_paquet() {
|
|
53
|
-
local base
|
|
54
|
-
for base in "${FICHIERS[@]}"; do
|
|
55
|
-
if [ -d "$PAQUET/$base" ]; then
|
|
56
|
-
find "$PAQUET/$base" -type f -print
|
|
57
|
-
elif [ -f "$PAQUET/$base" ]; then
|
|
58
|
-
printf '%s\n' "$PAQUET/$base"
|
|
59
|
-
fi
|
|
60
|
-
done
|
|
61
|
-
if [ -d "$PAQUET/manage/scripts" ]; then
|
|
62
|
-
find "$PAQUET/manage/scripts" -type f -print
|
|
63
|
-
fi
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
fichiers_relatifs() {
|
|
67
|
-
local f
|
|
68
|
-
fichiers_paquet | while IFS= read -r f; do
|
|
69
|
-
printf '%s\n' "${f#"$PAQUET"/}"
|
|
70
|
-
done | LC_ALL=C sort
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
# .devzone.version : version du dossier, puis une empreinte par fichier copié
|
|
74
|
-
ecrire_manifeste() {
|
|
75
|
-
local dossier="$1" rel
|
|
76
|
-
{
|
|
77
|
-
printf 'version %s\n' "$(version)"
|
|
78
|
-
fichiers_relatifs | while IFS= read -r rel; do
|
|
79
|
-
printf '%s %s\n' "$(empreinte "$dossier/$rel")" "$rel"
|
|
80
|
-
done
|
|
81
|
-
} >"$dossier/.devzone.version"
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
version_dossier() {
|
|
85
|
-
local dossier="${1:-.}" v
|
|
86
|
-
if [ -f "$dossier/.devzone.version" ]; then
|
|
87
|
-
v="$(sed -n '1s/^version //p' "$dossier/.devzone.version" 2>/dev/null | head -1 || true)"
|
|
88
|
-
if [ -n "$v" ]; then
|
|
89
|
-
printf '%s\n' "$v"
|
|
90
|
-
return 0
|
|
91
|
-
fi
|
|
92
|
-
fi
|
|
93
|
-
printf 'inconnue\n'
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
empreinte_manifeste() {
|
|
97
|
-
local dossier="$1" cible="$2" ligne h p
|
|
98
|
-
[ -f "$dossier/.devzone.version" ] || return 1
|
|
99
|
-
while IFS= read -r ligne; do
|
|
100
|
-
case "$ligne" in
|
|
101
|
-
version\ * | '') continue ;;
|
|
102
|
-
esac
|
|
103
|
-
h="${ligne%% *}"
|
|
104
|
-
p="${ligne#* }"
|
|
105
|
-
if [ "$p" = "$cible" ]; then
|
|
106
|
-
printf '%s\n' "$h"
|
|
107
|
-
return 0
|
|
108
|
-
fi
|
|
109
|
-
done <"$dossier/.devzone.version"
|
|
110
|
-
return 1
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
fichiers_manifeste() {
|
|
114
|
-
local dossier="$1" ligne
|
|
115
|
-
[ -f "$dossier/.devzone.version" ] || return 0
|
|
116
|
-
while IFS= read -r ligne; do
|
|
117
|
-
case "$ligne" in
|
|
118
|
-
version\ * | '') continue ;;
|
|
119
|
-
esac
|
|
120
|
-
printf '%s\n' "${ligne#* }"
|
|
121
|
-
done <"$dossier/.devzone.version"
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
# Un chemin lu dans le manifeste n'est accepté que s'il est relatif, simple
|
|
125
|
-
# (ni « .. », « . », « // », retour à la ligne ou tabulation), et sous un
|
|
126
|
-
# dossier géré par le paquet ou un fichier de sa racine. Sinon : refus.
|
|
127
|
-
chemin_sur() {
|
|
128
|
-
local rel="$1"
|
|
129
|
-
case "$rel" in
|
|
130
|
-
'' | /* | *//* | *$'\n'* | *$'\t'*) return 1 ;;
|
|
131
|
-
esac
|
|
132
|
-
case "/$rel/" in
|
|
133
|
-
*/../* | */./*) return 1 ;;
|
|
134
|
-
esac
|
|
135
|
-
case "$rel" in
|
|
136
|
-
.devcontainer/* | manage/* | core/* | scripts/* | \
|
|
137
|
-
Makefile | README.md | LICENSE | .gitattributes) return 0 ;;
|
|
138
|
-
esac
|
|
139
|
-
return 1
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
# Défense en profondeur : le dossier parent réel doit rester sous le dossier
|
|
143
|
-
# devzone réel (pwd -P) ; un lien symbolique qui en sort est donc refusé.
|
|
144
|
-
dans_dossier() {
|
|
145
|
-
local dossier="$1" rel="$2" racine parent
|
|
146
|
-
racine="$(cd "$dossier" && pwd -P)" || return 1
|
|
147
|
-
parent="$(cd "$dossier/$(dirname "$rel")" 2>/dev/null && pwd -P)" || return 1
|
|
148
|
-
case "$parent" in
|
|
149
|
-
"$racine" | "$racine"/*) return 0 ;;
|
|
150
|
-
esac
|
|
151
|
-
return 1
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
# Jamais touchés par mettre-a-jour, même si un ancien manifeste les cite
|
|
155
|
-
protege() {
|
|
156
|
-
case "$1" in
|
|
157
|
-
workspace | workspace/* | .devzone.version | .devzone.modules | .devzone.modules-* | \
|
|
158
|
-
.devzone.paquets | .password | .app | .devzone.log | .git | .git/*) return 0 ;;
|
|
159
|
-
esac
|
|
160
|
-
return 1
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
dans_liste() {
|
|
164
|
-
grep -Fqx -- "$2" "$1"
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
# Ancienne arborescence de devzone (d'avant manage/) : core/ n'est reconnu que
|
|
168
|
-
# par ses fichiers marqueurs, scripts/ que par les deux siens. Sinon, c'est un
|
|
169
|
-
# dossier de l'utilisateur : jamais touché.
|
|
170
|
-
arbre_ancien() {
|
|
171
|
-
local dossier="$1" arbre="$2"
|
|
172
|
-
case "$arbre" in
|
|
173
|
-
core)
|
|
174
|
-
[ -f "$dossier/core/devzone" ] || [ -f "$dossier/core/scripts/desinstaller.sh" ]
|
|
175
|
-
;;
|
|
176
|
-
scripts)
|
|
177
|
-
[ -f "$dossier/scripts/desinstaller.sh" ] && [ -f "$dossier/scripts/lancer.sh" ]
|
|
178
|
-
;;
|
|
179
|
-
*) return 1 ;;
|
|
180
|
-
esac
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
# Fichier connu de l'ancien paquet : les noms de manage/scripts/ ramenés dans
|
|
184
|
-
# core/scripts/ ou scripts/, core/devzone, et tout core/test/ et core/docs/.
|
|
185
|
-
fichier_ancien_connu() {
|
|
186
|
-
local rel="$1" nom
|
|
187
|
-
case "$rel" in
|
|
188
|
-
core/devzone | core/test/* | core/docs/*) return 0 ;;
|
|
189
|
-
core/scripts/*) nom="${rel#core/scripts/}" ;;
|
|
190
|
-
scripts/*) nom="${rel#scripts/}" ;;
|
|
191
|
-
*) return 1 ;;
|
|
192
|
-
esac
|
|
193
|
-
[ -f "$PAQUET/manage/scripts/$nom" ]
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
completer_gitignore() {
|
|
197
|
-
local dossier="$1" ligne
|
|
198
|
-
touch "$dossier/.gitignore"
|
|
199
|
-
for ligne in "${LIGNES_GITIGNORE[@]}"; do
|
|
200
|
-
grep -qxF -- "$ligne" "$dossier/.gitignore" || printf '%s\n' "$ligne" >>"$dossier/.gitignore"
|
|
201
|
-
done
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
# Six étapes de la conception (#349)
|
|
205
|
-
mettre_a_jour() {
|
|
206
|
-
local oui="" sans="" arg dossier pkg vdossier liste_paquet liste_anciens
|
|
207
|
-
local manquants rel actuelle attendue reponse sauvegarde base n ancien f
|
|
208
|
-
for arg in "$@"; do
|
|
209
|
-
case "$arg" in
|
|
210
|
-
--oui) oui=1 ;;
|
|
211
|
-
--sans-reconstruire) sans=1 ;;
|
|
212
|
-
*)
|
|
213
|
-
echo "✖ option inconnue : $arg (devzone mettre-a-jour [--oui] [--sans-reconstruire])" >&2
|
|
214
|
-
exit 1
|
|
215
|
-
;;
|
|
216
|
-
esac
|
|
217
|
-
done
|
|
218
|
-
if [ ! -d .devcontainer ]; then
|
|
219
|
-
echo "✖ À lancer dans un dossier devzone (.devcontainer introuvable ici)." >&2
|
|
220
|
-
exit 1
|
|
221
|
-
fi
|
|
222
|
-
|
|
223
|
-
dossier="$(pwd)"
|
|
224
|
-
pkg="$(version)"
|
|
225
|
-
vdossier="$(version_dossier "$dossier")"
|
|
226
|
-
travail="$(mktemp -d)"
|
|
227
|
-
trap 'rm -rf "$travail"' EXIT
|
|
228
|
-
liste_paquet="$travail/paquet"
|
|
229
|
-
liste_anciens="$travail/anciens"
|
|
230
|
-
fichiers_relatifs >"$liste_paquet"
|
|
231
|
-
fichiers_manifeste "$dossier" | LC_ALL=C sort >"$liste_anciens"
|
|
232
|
-
|
|
233
|
-
# 1. Versions et fichiers du paquet présents
|
|
234
|
-
manquants=""
|
|
235
|
-
while IFS= read -r rel; do
|
|
236
|
-
[ -f "$dossier/$rel" ] || manquants=1
|
|
237
|
-
done <"$liste_paquet"
|
|
238
|
-
if [ "$vdossier" = "$pkg" ] && [ -z "$manquants" ]; then
|
|
239
|
-
echo "✔ devzone $vdossier : déjà à jour."
|
|
240
|
-
echo "Pour la dernière version publiée : npx devzone@latest mettre-a-jour"
|
|
241
|
-
return 0
|
|
242
|
-
fi
|
|
243
|
-
echo "devzone : dossier $vdossier, paquet $pkg"
|
|
244
|
-
|
|
245
|
-
# 2. Fichiers modifiés localement (empreinte différente du manifeste ;
|
|
246
|
-
# sans manifeste, différente de celle du paquet)
|
|
247
|
-
: >"$travail/modifies"
|
|
248
|
-
: >"$travail/sauver"
|
|
249
|
-
: >"$travail/supprimer"
|
|
250
|
-
: >"$travail/arbres"
|
|
251
|
-
while IFS= read -r rel; do
|
|
252
|
-
[ -f "$dossier/$rel" ] || continue
|
|
253
|
-
printf '%s\n' "$rel" >>"$travail/sauver"
|
|
254
|
-
actuelle="$(empreinte "$dossier/$rel")"
|
|
255
|
-
if attendue="$(empreinte_manifeste "$dossier" "$rel")"; then
|
|
256
|
-
:
|
|
257
|
-
else
|
|
258
|
-
attendue="$(empreinte "$PAQUET/$rel")"
|
|
259
|
-
fi
|
|
260
|
-
[ "$actuelle" = "$attendue" ] || printf '%s\n' "$rel" >>"$travail/modifies"
|
|
261
|
-
done <"$liste_paquet"
|
|
262
|
-
while IFS= read -r rel; do
|
|
263
|
-
[ -n "$rel" ] || continue
|
|
264
|
-
if ! chemin_sur "$rel"; then
|
|
265
|
-
echo "devzone : manifeste : chemin refusé : $rel" >&2
|
|
266
|
-
continue
|
|
267
|
-
fi
|
|
268
|
-
dans_liste "$liste_paquet" "$rel" && continue
|
|
269
|
-
protege "$rel" && continue
|
|
270
|
-
if ! dans_dossier "$dossier" "$rel"; then
|
|
271
|
-
echo "devzone : manifeste : chemin refusé : $rel" >&2
|
|
272
|
-
continue
|
|
273
|
-
fi
|
|
274
|
-
printf '%s\n' "$rel" >>"$travail/supprimer"
|
|
275
|
-
[ -f "$dossier/$rel" ] || continue
|
|
276
|
-
printf '%s\n' "$rel" >>"$travail/sauver"
|
|
277
|
-
if attendue="$(empreinte_manifeste "$dossier" "$rel")"; then
|
|
278
|
-
[ "$(empreinte "$dossier/$rel")" = "$attendue" ] || printf '%s\n' "$rel" >>"$travail/modifies"
|
|
279
|
-
else
|
|
280
|
-
printf '%s\n' "$rel" >>"$travail/modifies"
|
|
281
|
-
fi
|
|
282
|
-
done <"$liste_anciens"
|
|
283
|
-
for ancien in core scripts; do
|
|
284
|
-
[ -d "$dossier/$ancien" ] || continue
|
|
285
|
-
arbre_ancien "$dossier" "$ancien" || continue
|
|
286
|
-
printf '%s\n' "$ancien" >>"$travail/arbres"
|
|
287
|
-
while IFS= read -r f; do
|
|
288
|
-
rel="${f#"$dossier"/}"
|
|
289
|
-
if ! chemin_sur "$rel"; then
|
|
290
|
-
echo "devzone : manifeste : chemin refusé : $rel" >&2
|
|
291
|
-
continue
|
|
292
|
-
fi
|
|
293
|
-
protege "$rel" && continue
|
|
294
|
-
# Un fichier inconnu de l'ancien paquet appartient à l'utilisateur
|
|
295
|
-
fichier_ancien_connu "$rel" || continue
|
|
296
|
-
printf '%s\n' "$rel" >>"$travail/supprimer"
|
|
297
|
-
printf '%s\n' "$rel" >>"$travail/sauver"
|
|
298
|
-
# Toujours confirmé : la suppression d'un fichier de l'ancien paquet
|
|
299
|
-
# est un changement, même avec un manifeste
|
|
300
|
-
printf '%s\n' "$rel" >>"$travail/modifies"
|
|
301
|
-
done < <(find "$dossier/$ancien" -type f -print)
|
|
302
|
-
done
|
|
303
|
-
LC_ALL=C sort -u "$travail/modifies" >"$travail/modifies.tri"
|
|
304
|
-
mv "$travail/modifies.tri" "$travail/modifies"
|
|
305
|
-
LC_ALL=C sort -u "$travail/sauver" >"$travail/sauver.tri"
|
|
306
|
-
mv "$travail/sauver.tri" "$travail/sauver"
|
|
307
|
-
|
|
308
|
-
if [ -s "$travail/modifies" ]; then
|
|
309
|
-
echo "Fichiers modifiés localement :"
|
|
310
|
-
while IFS= read -r rel; do
|
|
311
|
-
printf ' %s\n' "$rel"
|
|
312
|
-
done <"$travail/modifies"
|
|
313
|
-
if [ -z "$oui" ]; then
|
|
314
|
-
if [ ! -t 0 ]; then
|
|
315
|
-
echo "✖ Fichiers modifiés localement : relance avec --oui pour les remplacer (sauvegarde dans .devzone.sauvegarde/)." >&2
|
|
316
|
-
exit 1
|
|
317
|
-
fi
|
|
318
|
-
printf 'Remplacer ces fichiers (sauvegarde dans .devzone.sauvegarde/) ? [o/N] ' >&2
|
|
319
|
-
read -r reponse || reponse=""
|
|
320
|
-
case "$reponse" in
|
|
321
|
-
o | O | oui | Oui | OUI) ;;
|
|
322
|
-
*)
|
|
323
|
-
echo "Abandon : rien n'a été modifié."
|
|
324
|
-
return 1
|
|
325
|
-
;;
|
|
326
|
-
esac
|
|
327
|
-
fi
|
|
328
|
-
fi
|
|
329
|
-
|
|
330
|
-
# 3. Sauvegarde de tout fichier remplacé ou supprimé
|
|
331
|
-
if [ -s "$travail/sauver" ]; then
|
|
332
|
-
base="$dossier/.devzone.sauvegarde/$(date +%Y%m%d-%H%M%S)"
|
|
333
|
-
sauvegarde="$base"
|
|
334
|
-
n=1
|
|
335
|
-
while [ -e "$sauvegarde" ]; do
|
|
336
|
-
n=$((n + 1))
|
|
337
|
-
sauvegarde="$base-$n"
|
|
338
|
-
done
|
|
339
|
-
while IFS= read -r rel; do
|
|
340
|
-
[ -f "$dossier/$rel" ] || continue
|
|
341
|
-
if ! dans_dossier "$dossier" "$rel"; then
|
|
342
|
-
echo "devzone : manifeste : chemin refusé : $rel" >&2
|
|
343
|
-
continue
|
|
344
|
-
fi
|
|
345
|
-
mkdir -p "$sauvegarde/$(dirname "$rel")"
|
|
346
|
-
# -P : un lien est sauvegardé tel quel, jamais sa cible
|
|
347
|
-
cp -P -p "$dossier/$rel" "$sauvegarde/$rel"
|
|
348
|
-
done <"$travail/sauver"
|
|
349
|
-
echo "Sauvegarde : $sauvegarde"
|
|
350
|
-
fi
|
|
351
|
-
|
|
352
|
-
# 4. Remplacement, suppression de l'ancien paquet et des anciennes
|
|
353
|
-
# arborescences, .gitignore complété sans être écrasé
|
|
354
|
-
completer_gitignore "$dossier"
|
|
355
|
-
while IFS= read -r rel; do
|
|
356
|
-
mkdir -p "$dossier/$(dirname "$rel")"
|
|
357
|
-
if ! dans_dossier "$dossier" "$rel"; then
|
|
358
|
-
echo "devzone : manifeste : chemin refusé : $rel" >&2
|
|
359
|
-
continue
|
|
360
|
-
fi
|
|
361
|
-
# Jamais d'écriture à travers un lien : le lien (pas sa cible) est retiré
|
|
362
|
-
if [ -L "$dossier/$rel" ]; then
|
|
363
|
-
rm -f -- "$dossier/$rel"
|
|
364
|
-
echo "devzone : manifeste : lien remplacé : $rel" >&2
|
|
365
|
-
fi
|
|
366
|
-
cp -p "$PAQUET/$rel" "$dossier/$rel"
|
|
367
|
-
if [ -x "$PAQUET/$rel" ]; then
|
|
368
|
-
chmod +x "$dossier/$rel"
|
|
369
|
-
fi
|
|
370
|
-
done <"$liste_paquet"
|
|
371
|
-
while IFS= read -r rel; do
|
|
372
|
-
[ -n "$rel" ] || continue
|
|
373
|
-
[ -f "$dossier/$rel" ] || continue
|
|
374
|
-
if ! dans_dossier "$dossier" "$rel"; then
|
|
375
|
-
echo "devzone : manifeste : chemin refusé : $rel" >&2
|
|
376
|
-
continue
|
|
377
|
-
fi
|
|
378
|
-
# rm ne suit pas les liens : seul le lien est retiré, jamais sa cible
|
|
379
|
-
rm -f -- "$dossier/$rel"
|
|
380
|
-
done <"$travail/supprimer"
|
|
381
|
-
while IFS= read -r ancien; do
|
|
382
|
-
[ -n "$ancien" ] || continue
|
|
383
|
-
[ -d "$dossier/$ancien" ] || continue
|
|
384
|
-
# Seuls les dossiers devenus vides sont retirés, jamais leur contenu
|
|
385
|
-
find "$dossier/$ancien" -depth -type d -empty -delete
|
|
386
|
-
done <"$travail/arbres"
|
|
387
|
-
|
|
388
|
-
# 6. Nouveau manifeste, puis reconstruction proposée
|
|
389
|
-
ecrire_manifeste "$dossier"
|
|
390
|
-
echo "✔ devzone $pkg : mis à jour."
|
|
391
|
-
bash "$PAQUET/manage/scripts/poste.sh" conseil "$dossier" || true
|
|
392
|
-
# la mise à jour ne change jamais le mode du poste (#472)
|
|
393
|
-
if [ "$(grep -E '^workspace=' "$dossier/.devzone.modules" 2>/dev/null | tail -1)" = "workspace=kubernetes" ]; then
|
|
394
|
-
return 0
|
|
395
|
-
fi
|
|
396
|
-
if [ -n "$sans" ]; then
|
|
397
|
-
echo "Reconstruction non lancée (--sans-reconstruire)."
|
|
398
|
-
return 0
|
|
399
|
-
fi
|
|
400
|
-
if [ ! -t 0 ]; then
|
|
401
|
-
echo "Reconstruction : make -C $dossier rebuild (à lancer dans un terminal)"
|
|
402
|
-
return 0
|
|
403
|
-
fi
|
|
404
|
-
printf 'Reconstruire le conteneur maintenant (make rebuild) ? [o/N] ' >&2
|
|
405
|
-
read -r reponse || reponse=""
|
|
406
|
-
case "$reponse" in
|
|
407
|
-
o | O | oui | Oui | OUI) ;;
|
|
408
|
-
*)
|
|
409
|
-
echo "Reconstruction non lancée : make -C $dossier rebuild"
|
|
410
|
-
return 0
|
|
411
|
-
;;
|
|
412
|
-
esac
|
|
413
|
-
if [ -n "${DEVZONE_RECONSTRUIRE:-}" ]; then
|
|
414
|
-
sh -c "$DEVZONE_RECONSTRUIRE"
|
|
415
|
-
else
|
|
416
|
-
make -C "$dossier" rebuild
|
|
417
|
-
fi
|
|
418
|
-
}
|
|
419
|
-
|
|
420
|
-
aide() {
|
|
421
|
-
cat <<EOF
|
|
49
|
+
show_help() {
|
|
50
|
+
cat <<EOT
|
|
422
51
|
devzone $(version) : environnement de développement conteneurisé
|
|
423
52
|
|
|
424
53
|
devzone <dossier> [--gitops github|none|<url>] [--kubernetes|--docker]
|
|
@@ -428,7 +57,7 @@ devzone $(version) : environnement de développement conteneurisé
|
|
|
428
57
|
fails with nothing created without one)
|
|
429
58
|
--docker: deprecated Docker workstation, no cluster check
|
|
430
59
|
(without a cluster nothing is created, no silent Docker)
|
|
431
|
-
devzone update [--
|
|
60
|
+
devzone update [--yes] [--sans-reconstruire]
|
|
432
61
|
dans un dossier devzone : passe à la version du paquet
|
|
433
62
|
(sauvegarde les fichiers remplacés, propose make rebuild)
|
|
434
63
|
devzone uninstall dans un dossier devzone : retire conteneur, image, volumes
|
|
@@ -440,200 +69,59 @@ devzone $(version) : environnement de développement conteneurisé
|
|
|
440
69
|
services (gitlab, postgres, argocd) du workspace Kubernetes
|
|
441
70
|
devzone workspace argocd status|init|apply|app add|list|remove
|
|
442
71
|
Argo CD du workspace : dépôt GitOps, .argocd.conf, projets
|
|
443
|
-
(anciens noms français
|
|
72
|
+
(anciens noms français : refusés avec le nouveau nom, voir README, « Noms retirés »)
|
|
444
73
|
devzone --version
|
|
445
|
-
|
|
446
|
-
}
|
|
447
|
-
|
|
448
|
-
gitops_saisir() {
|
|
449
|
-
# GitOps repository of Argo CD for the creation (#539): github, an
|
|
450
|
-
# existing URL, or none. Asked in a terminal (default: github when gh is
|
|
451
|
-
# connected), or none with a notice without one (the --gitops option names
|
|
452
|
-
# the choice).
|
|
453
|
-
local reponse defaut=""
|
|
454
|
-
if gh auth status >/dev/null 2>&1; then
|
|
455
|
-
defaut="github"
|
|
456
|
-
fi
|
|
457
|
-
printf 'GitOps repository for Argo CD? [G]itHub (created under your gh account at first start) / a URL / [n]one : ' >&2
|
|
458
|
-
read -r reponse || reponse=""
|
|
459
|
-
reponse="${reponse:-$defaut}"
|
|
460
|
-
case "$reponse" in
|
|
461
|
-
G | g | GitHub | github | Oui | oui | OUI) echo "github" ;;
|
|
462
|
-
n | N | none | None | Non | non | NON | aucun | Aucun) echo "none" ;;
|
|
463
|
-
*) echo "$reponse" ;;
|
|
464
|
-
esac
|
|
74
|
+
EOT
|
|
465
75
|
}
|
|
466
76
|
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
for arg in "$@"; do
|
|
471
|
-
if [ "$expect" = gitops ]; then gitops="$arg"; expect=""; continue; fi
|
|
472
|
-
case "$arg" in
|
|
473
|
-
--gitops) expect=gitops ;;
|
|
474
|
-
--gitops=*) gitops="${arg#--gitops=}" ;;
|
|
475
|
-
--kubernetes | --docker)
|
|
476
|
-
if [ -n "$option" ] && [ "$option" != "${arg#--}" ]; then
|
|
477
|
-
echo "✖ --kubernetes and --docker: choose one" >&2
|
|
478
|
-
exit 1
|
|
479
|
-
fi
|
|
480
|
-
option="${arg#--}"
|
|
481
|
-
;;
|
|
482
|
-
*) echo "✖ option inconnue : $arg (devzone <dossier> [--gitops github|none|<url>] [--kubernetes|--docker])" >&2; exit 1 ;;
|
|
483
|
-
esac
|
|
484
|
-
done
|
|
485
|
-
if [ -n "$expect" ]; then
|
|
486
|
-
echo "✖ --gitops attend une valeur (github, none or a URL)" >&2
|
|
487
|
-
exit 1
|
|
488
|
-
fi
|
|
489
|
-
|
|
490
|
-
if [ -e "$cible" ] && [ -n "$(ls -A "$cible" 2>/dev/null)" ]; then
|
|
491
|
-
echo "✖ $cible existe et n'est pas vide : rien n'est écrasé. Choisis un autre dossier." >&2
|
|
492
|
-
exit 1
|
|
493
|
-
fi
|
|
494
|
-
|
|
495
|
-
# Mode before any copy: --kubernetes without a cluster creates nothing (#497)
|
|
496
|
-
# shellcheck source=SCRIPTDIR/scripts/create-mode.sh
|
|
497
|
-
. "$PAQUET/manage/scripts/create-mode.sh"
|
|
498
|
-
create_mode_choose "$option" || exit 1
|
|
499
|
-
|
|
500
|
-
if [ -z "$gitops" ]; then
|
|
501
|
-
if [ -t 0 ]; then
|
|
502
|
-
gitops="$(gitops_saisir)"
|
|
503
|
-
else
|
|
504
|
-
echo "⚠ no GitOps repository for Argo CD: pass --gitops <github|none|https://github.com/<login>/<name>.git> to create a devzone without a terminal; using none" >&2
|
|
505
|
-
gitops="none"
|
|
506
|
-
fi
|
|
507
|
-
fi
|
|
508
|
-
mkdir -p "$cible/workspace" "$cible/manage"
|
|
509
|
-
cp -R "${FICHIERS[@]/#/$PAQUET/}" "$cible/"
|
|
510
|
-
cp -R "$PAQUET/manage/scripts" "$cible/manage/"
|
|
511
|
-
touch "$cible/workspace/.gitkeep"
|
|
512
|
-
# npm n'embarque jamais .gitignore : écrit ici
|
|
513
|
-
: >"$cible/.gitignore"
|
|
514
|
-
completer_gitignore "$cible"
|
|
515
|
-
chmod +x "$cible/manage/scripts/desinstaller.sh" "$cible/manage/scripts/lancer.sh"
|
|
516
|
-
create_mode_write "$cible" "$CREATE_MODE"
|
|
517
|
-
# The GitOps repository of the new devzone (#539): github, an existing URL,
|
|
518
|
-
# or none, written in the .argocd.conf of the new devzone (conf.sh writes
|
|
519
|
-
# the header of the file when absent)
|
|
520
|
-
. "$PAQUET/.devcontainer/argocd/conf.sh"
|
|
521
|
-
# shellcheck disable=SC2034 # read by conf.sh
|
|
522
|
-
ARGOCD_CONF="$cible/.argocd.conf"
|
|
523
|
-
if [ "$gitops" = github ]; then
|
|
524
|
-
if ! gh auth status >/dev/null 2>&1; then
|
|
525
|
-
echo "⚠ GitHub not connected (gh auth login): no GitOps repository, the Applications are applied directly; pass --gitops none" >&2
|
|
526
|
-
valeur="none"
|
|
527
|
-
else
|
|
528
|
-
login="$(gh api user --jq .login 2>/dev/null)" || login=""
|
|
529
|
-
if [ -z "$login" ]; then
|
|
530
|
-
echo "⚠ GitHub login unreadable (gh api user): no GitOps repository, the Applications are applied directly; pass --gitops none" >&2
|
|
531
|
-
valeur="none"
|
|
532
|
-
else
|
|
533
|
-
nom="${DEVZONE_GITOPS_REPO_NAME:-devzone-argocd}"
|
|
534
|
-
instance="${DEVZONE_VOLUMES:-devzone}"
|
|
535
|
-
if [ "$instance" != "devzone" ]; then
|
|
536
|
-
nom="$nom-$instance"
|
|
537
|
-
fi
|
|
538
|
-
valeur="https://github.com/$login/$nom.git"
|
|
539
|
-
fi
|
|
540
|
-
fi
|
|
541
|
-
elif [ "$gitops" = none ]; then
|
|
542
|
-
valeur="none"
|
|
543
|
-
else
|
|
544
|
-
valeur="$gitops"
|
|
545
|
-
fi
|
|
546
|
-
conf_set argocd "repo=$valeur"
|
|
547
|
-
case "$valeur" in
|
|
548
|
-
none) echo "✔ no GitOps repository: the Applications are applied directly (devzone workspace argocd init to change)" ;;
|
|
549
|
-
*) echo "✔ GitOps repository: $valeur ($cible/.argocd.conf)" ;;
|
|
550
|
-
esac
|
|
551
|
-
cible="$(cd "$cible" && pwd)"
|
|
552
|
-
ecrire_manifeste "$cible"
|
|
553
|
-
echo "✔ devzone $(version) créé dans $cible"
|
|
554
|
-
# Kubernetes: the workspace goes to the cluster, no Docker check (Docker
|
|
555
|
-
# Desktop hosts the cluster, but devzone does not need it directly)
|
|
556
|
-
if [ "$CREATE_MODE" = kubernetes ]; then
|
|
557
|
-
create_mode_start "$cible" "$PAQUET/manage/workspace.sh"
|
|
558
|
-
return
|
|
559
|
-
fi
|
|
560
|
-
if [ -n "${DEVZONE_SANS_DEMARRER:-}" ]; then
|
|
561
|
-
echo "Pour le lancer : cd $cible && make up"
|
|
562
|
-
return 0
|
|
563
|
-
fi
|
|
564
|
-
# Docker d'abord : le dossier reste prêt, à lancer une fois Docker démarré
|
|
565
|
-
# shellcheck source=SCRIPTDIR/scripts/docker.sh
|
|
566
|
-
. "$PAQUET/manage/scripts/docker.sh"
|
|
567
|
-
if ! docker_ready "cd $cible && make shell"; then
|
|
568
|
-
echo " Le dossier est prêt : rien à refaire, sauf ce lancement." >&2
|
|
569
|
-
exit 1
|
|
570
|
-
fi
|
|
571
|
-
echo "▶ Lancement (quelques minutes la première fois)…"
|
|
572
|
-
if command -v make >/dev/null 2>&1; then
|
|
573
|
-
make -C "$cible" up
|
|
574
|
-
else
|
|
575
|
-
bash "$cible/manage/scripts/lancer.sh" up "$cible"
|
|
576
|
-
fi
|
|
577
|
-
echo "Ensuite : cd $cible && make shell (ou ouvre le dossier dans VS Code : Reopen in Container)."
|
|
578
|
-
}
|
|
579
|
-
|
|
580
|
-
# Commandes du conteneur (#471) : liste figée, à garder alignée sur le case
|
|
581
|
-
# final de .devcontainer/devzone (test de cohérence dans manage/test/cli.bats)
|
|
582
|
-
commande_du_conteneur() {
|
|
77
|
+
# Container commands (#471): a fixed list, to keep aligned with the final case
|
|
78
|
+
# of .devcontainer/devzone (consistency test in manage/test/cli.bats)
|
|
79
|
+
container_command() {
|
|
583
80
|
case "$1" in
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
test-gitlab | ticket |
|
|
588
|
-
# English names of the container commands (#502)
|
|
589
|
-
ai | is-enabled | enable | disable | apply | catalog | start | status | \
|
|
590
|
-
passwords | packages | platform | repair | use) return 0 ;;
|
|
81
|
+
ai | agent | apply | argocd | build | catalog | cluster | clusters | disable | \
|
|
82
|
+
enable | gitlab | is-enabled | llm | metrics | modules | mysql | packages | \
|
|
83
|
+
passwords | platform | port | postgres | repair | start | status | \
|
|
84
|
+
test-bash32 | test-gitlab | ticket | use) return 0 ;;
|
|
591
85
|
*) return 1 ;;
|
|
592
86
|
esac
|
|
593
87
|
}
|
|
594
88
|
|
|
595
|
-
#
|
|
596
|
-
#
|
|
597
|
-
#
|
|
598
|
-
#
|
|
89
|
+
# Renamed names (#695): the French names of the host and container commands are
|
|
90
|
+
# refused before anything is created (« devzone mettre-a-jour » must not create a
|
|
91
|
+
# folder; « devzone stop » still creates ./stop). A copied devzone may miss the
|
|
92
|
+
# aliases file: then no check.
|
|
599
93
|
# shellcheck source=SCRIPTDIR/../.devcontainer/command-aliases.sh
|
|
600
94
|
# shellcheck disable=SC1091
|
|
601
95
|
if [ -f "$PAQUET/.devcontainer/command-aliases.sh" ]; then
|
|
602
96
|
. "$PAQUET/.devcontainer/command-aliases.sh"
|
|
603
|
-
|
|
604
|
-
canon="$(command_canonical "$1")"
|
|
605
|
-
if command -v command_deprecated_warning >/dev/null 2>&1; then
|
|
606
|
-
command_deprecated_warning "$1"
|
|
607
|
-
fi
|
|
608
|
-
case "$canon" in
|
|
609
|
-
mettre-a-jour | desinstaller | aide | workspace) set -- "$canon" "${@:2}" ;;
|
|
610
|
-
*)
|
|
611
|
-
if commande_du_conteneur "$canon"; then
|
|
612
|
-
set -- "$canon" "${@:2}"
|
|
613
|
-
fi
|
|
614
|
-
;;
|
|
615
|
-
esac
|
|
616
|
-
fi
|
|
97
|
+
reject_renamed "$@" || exit 1
|
|
617
98
|
fi
|
|
618
99
|
|
|
100
|
+
|
|
619
101
|
case "${1:-}" in
|
|
620
|
-
"" | -h | --help |
|
|
102
|
+
"" | -h | --help | help) show_help ;;
|
|
621
103
|
-v | --version) version ;;
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
#
|
|
626
|
-
|
|
104
|
+
update)
|
|
105
|
+
# shellcheck source=SCRIPTDIR/scripts/devzone-manifest.sh
|
|
106
|
+
. "$PAQUET/manage/scripts/devzone-manifest.sh"
|
|
107
|
+
# shellcheck source=SCRIPTDIR/scripts/devzone-update.sh
|
|
108
|
+
. "$PAQUET/manage/scripts/devzone-update.sh"
|
|
109
|
+
update_workstation "${@:2}"
|
|
110
|
+
;;
|
|
111
|
+
uninstall)
|
|
112
|
+
# Devzone folder (.devcontainer/); an older devzone has its desinstaller.sh
|
|
113
|
+
# in manage/scripts/ (new), core/scripts or scripts/ (old), or at the root
|
|
114
|
+
uninstaller=""
|
|
627
115
|
if [ -d .devcontainer ]; then
|
|
628
116
|
for f in manage/scripts/desinstaller.sh core/scripts/desinstaller.sh scripts/desinstaller.sh desinstaller.sh; do
|
|
629
|
-
if [ -f "$f" ]; then
|
|
117
|
+
if [ -f "$f" ]; then uninstaller="$f" && break; fi
|
|
630
118
|
done
|
|
631
119
|
fi
|
|
632
|
-
if [ -z "$
|
|
120
|
+
if [ -z "$uninstaller" ]; then
|
|
633
121
|
echo "✖ À lancer dans un dossier devzone (desinstaller.sh introuvable ici)." >&2
|
|
634
122
|
exit 1
|
|
635
123
|
fi
|
|
636
|
-
DEVZONE_COMMANDE="devzone
|
|
124
|
+
DEVZONE_COMMANDE="devzone uninstall" bash "$uninstaller"
|
|
637
125
|
;;
|
|
638
126
|
workspace)
|
|
639
127
|
bash "$PAQUET/manage/workspace.sh" "${@:2}"
|
|
@@ -643,10 +131,14 @@ case "${1:-}" in
|
|
|
643
131
|
exit 1
|
|
644
132
|
;;
|
|
645
133
|
*)
|
|
646
|
-
if
|
|
134
|
+
if container_command "$1"; then
|
|
647
135
|
echo "✖ devzone $1 : commande du conteneur ; lance-la dans devzone (make shell), ou choisis un autre nom de dossier" >&2
|
|
648
136
|
exit 2
|
|
649
137
|
fi
|
|
650
|
-
|
|
138
|
+
# shellcheck source=SCRIPTDIR/scripts/devzone-manifest.sh
|
|
139
|
+
. "$PAQUET/manage/scripts/devzone-manifest.sh"
|
|
140
|
+
# shellcheck source=SCRIPTDIR/scripts/devzone-create.sh
|
|
141
|
+
. "$PAQUET/manage/scripts/devzone-create.sh"
|
|
142
|
+
create_workstation "$1" "${@:2}"
|
|
651
143
|
;;
|
|
652
144
|
esac
|