aw-spec-cli 0.1.2 → 0.1.3
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/assets/docs/ModularMonolith/ModularMonolith.Reference.pack.txt +25248 -0
- package/assets/docs/ModularMonolith/ModularMonolith.pack.txt +5726 -0
- package/assets/docs/ModularMonolith/pack-foundation.ps1 +145 -0
- package/assets/docs/ModularMonolith/pack-foundation.sh +196 -0
- package/assets/docs/ModularMonolith/pack-reference-foundation.ps1 +157 -0
- package/assets/docs/ModularMonolith/pack-reference-foundation.sh +209 -0
- package/assets/docs/ModularMonolith/unpack-foundation.ps1 +126 -0
- package/assets/docs/ModularMonolith/unpack-foundation.sh +217 -0
- package/assets/docs/ModularMonolith/unpack-reference-foundation.ps1 +129 -0
- package/assets/docs/ModularMonolith/unpack-reference-foundation.sh +218 -0
- package/assets/docs/VerticalSlice/VerticalSlice.Reference.pack.txt +19318 -0
- package/assets/docs/VerticalSlice/pack-reference-foundation.ps1 +157 -0
- package/assets/docs/VerticalSlice/pack-reference-foundation.sh +209 -0
- package/assets/docs/VerticalSlice/unpack-reference-foundation.ps1 +129 -0
- package/assets/docs/VerticalSlice/unpack-reference-foundation.sh +218 -0
- package/assets/docs/components/Email/README.md +7 -0
- package/assets/docs/components/Email/ReferenceEndpoints/SendEmailEndpoint.cs +84 -0
- package/assets/docs/components/Email/integration.md +57 -17
- package/assets/docs/components/Jobs/integration.md +29 -15
- package/assets/docs/components/QrGenerator/README.md +7 -0
- package/assets/docs/components/QrGenerator/ReferenceEndpoints/GenerateQrEndpoint.cs +57 -0
- package/assets/docs/components/QrGenerator/integration.md +51 -6
- package/assets/docs/components/README.md +19 -2
- package/assets/docs/domainspecs/healthcare/comandrulemap.md +47 -0
- package/assets/docs/domainspecs/pharma/comandrulemap.md +50 -0
- package/package.json +5 -2
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
#
|
|
3
|
+
# unpack-reference-foundation.sh — bash/macOS port of unpack-reference-foundation.ps1
|
|
4
|
+
#
|
|
5
|
+
# SYNOPSIS
|
|
6
|
+
# Unpack an AW-Spec reference pack file into a target project, renaming the
|
|
7
|
+
# sentinel app name to the caller's app name.
|
|
8
|
+
#
|
|
9
|
+
# DESCRIPTION
|
|
10
|
+
# Reads --pack-file (produced by pack-reference-foundation.sh/.ps1), takes the sentinel
|
|
11
|
+
# from its header (override with --sentinel), derives four case forms of the target app
|
|
12
|
+
# name, and writes every file block to --out-dir with the sentinel rewritten in both file
|
|
13
|
+
# CONTENTS and file/dir PATHS. Text blocks are rewritten and written as UTF-8; base64
|
|
14
|
+
# blocks are decoded as-is. Refuses to overwrite existing files unless --force.
|
|
15
|
+
#
|
|
16
|
+
# EXAMPLE
|
|
17
|
+
# ./unpack-reference-foundation.sh \
|
|
18
|
+
# --pack-file ./VerticalSlice.Reference.pack.txt \
|
|
19
|
+
# --target-app-name AppWeaver.Pharma \
|
|
20
|
+
# --out-dir ../../
|
|
21
|
+
#
|
|
22
|
+
set -euo pipefail
|
|
23
|
+
|
|
24
|
+
# ------------------------------------------------------------------ defaults ---
|
|
25
|
+
PACK_FILE=''
|
|
26
|
+
TARGET_APP_NAME=''
|
|
27
|
+
OUT_DIR='.'
|
|
28
|
+
SENTINEL=''
|
|
29
|
+
FORCE=0
|
|
30
|
+
DRYRUN=0
|
|
31
|
+
|
|
32
|
+
usage() {
|
|
33
|
+
cat >&2 <<'EOF'
|
|
34
|
+
Usage: unpack-reference-foundation.sh --pack-file <file> --target-app-name <name>
|
|
35
|
+
[--out-dir <dir>] [--sentinel <name>]
|
|
36
|
+
[--force] [--dry-run]
|
|
37
|
+
|
|
38
|
+
-p, --pack-file <file> Reference pack file to unpack (required)
|
|
39
|
+
-t, --target-app-name <name> New app name to rename the sentinel into (required)
|
|
40
|
+
-o, --out-dir <dir> Output root (default: .)
|
|
41
|
+
--sentinel <name> Override the sentinel from the pack header
|
|
42
|
+
--force Overwrite files that already exist
|
|
43
|
+
--dry-run List what would be written, write nothing
|
|
44
|
+
-h, --help Show this help
|
|
45
|
+
|
|
46
|
+
Positional fallback: unpack-reference-foundation.sh <pack-file> <target-app-name> [out-dir]
|
|
47
|
+
EOF
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
# -------------------------------------------------------------- arg parsing ---
|
|
51
|
+
while [ $# -gt 0 ]; do
|
|
52
|
+
case "$1" in
|
|
53
|
+
-p|--pack-file) PACK_FILE="${2:?--pack-file needs a value}"; shift 2 ;;
|
|
54
|
+
-t|--target-app-name) TARGET_APP_NAME="${2:?--target-app-name needs a value}"; shift 2 ;;
|
|
55
|
+
-o|--out-dir) OUT_DIR="${2:?--out-dir needs a value}"; shift 2 ;;
|
|
56
|
+
--sentinel) SENTINEL="${2:?--sentinel needs a value}"; shift 2 ;;
|
|
57
|
+
--force) FORCE=1; shift ;;
|
|
58
|
+
--dry-run) DRYRUN=1; shift ;;
|
|
59
|
+
-h|--help) usage; exit 0 ;;
|
|
60
|
+
--) shift; break ;;
|
|
61
|
+
-*) echo "Error: unknown option: $1" >&2; usage; exit 2 ;;
|
|
62
|
+
*)
|
|
63
|
+
if [ -z "$PACK_FILE" ]; then PACK_FILE="$1"
|
|
64
|
+
elif [ -z "$TARGET_APP_NAME" ]; then TARGET_APP_NAME="$1"
|
|
65
|
+
else OUT_DIR="$1"
|
|
66
|
+
fi
|
|
67
|
+
shift ;;
|
|
68
|
+
esac
|
|
69
|
+
done
|
|
70
|
+
|
|
71
|
+
[ -n "$PACK_FILE" ] || { echo "Error: --pack-file is required." >&2; usage; exit 2; }
|
|
72
|
+
[ -n "$TARGET_APP_NAME" ] || { echo "Error: --target-app-name is required." >&2; usage; exit 2; }
|
|
73
|
+
[ -f "$PACK_FILE" ] || { echo "Error: pack file not found: $PACK_FILE" >&2; exit 1; }
|
|
74
|
+
|
|
75
|
+
case "$TARGET_APP_NAME" in
|
|
76
|
+
*[!A-Za-z0-9._-]*)
|
|
77
|
+
echo "Error: --target-app-name may contain only letters, digits, '.', '_' or '-': $TARGET_APP_NAME" >&2
|
|
78
|
+
exit 2 ;;
|
|
79
|
+
esac
|
|
80
|
+
|
|
81
|
+
# ------------------------------------------------ sentinel from header --------
|
|
82
|
+
if [ -z "$SENTINEL" ]; then
|
|
83
|
+
SENTINEL="$(LC_ALL=C sed -n 's/^#[[:space:]]*sentinel:[[:space:]]*\(.*[^[:space:]]\)[[:space:]]*$/\1/p' "$PACK_FILE" | head -n1)"
|
|
84
|
+
fi
|
|
85
|
+
[ -n "$SENTINEL" ] || { echo "Error: Sentinel not found in pack header; supply it with --sentinel." >&2; exit 1; }
|
|
86
|
+
|
|
87
|
+
# ------------------------------------------------ derive case forms -----------
|
|
88
|
+
to_lower() { printf '%s' "$1" | LC_ALL=C tr '[:upper:]' '[:lower:]'; }
|
|
89
|
+
|
|
90
|
+
S_DOT="$SENTINEL"; T_DOT="$TARGET_APP_NAME"
|
|
91
|
+
S_UND="${SENTINEL//./_}"; T_UND="${TARGET_APP_NAME//./_}"
|
|
92
|
+
s_low="$(to_lower "$SENTINEL")"; t_low="$(to_lower "$TARGET_APP_NAME")"
|
|
93
|
+
S_HYP="${s_low//./-}"; T_HYP="${t_low//./-}"
|
|
94
|
+
S_LDOT="$s_low"; T_LDOT="$t_low"
|
|
95
|
+
|
|
96
|
+
FROM=(); TO=()
|
|
97
|
+
add_form() {
|
|
98
|
+
local from="$1" to="$2" e
|
|
99
|
+
[ -n "$from" ] || return 0
|
|
100
|
+
[ "$from" = "$to" ] && return 0
|
|
101
|
+
if [ "${#FROM[@]}" -gt 0 ]; then
|
|
102
|
+
for e in "${FROM[@]}"; do [ "$e" = "$from" ] && return 0; done
|
|
103
|
+
fi
|
|
104
|
+
FROM+=("$from"); TO+=("$to")
|
|
105
|
+
}
|
|
106
|
+
add_form "$S_DOT" "$T_DOT"
|
|
107
|
+
add_form "$S_UND" "$T_UND"
|
|
108
|
+
add_form "$S_HYP" "$T_HYP"
|
|
109
|
+
add_form "$S_LDOT" "$T_LDOT"
|
|
110
|
+
|
|
111
|
+
# Sort indices by FROM length descending
|
|
112
|
+
ORDER=()
|
|
113
|
+
{
|
|
114
|
+
local_n="${#FROM[@]}"
|
|
115
|
+
used=(); for ((k = 0; k < local_n; k++)); do used[$k]=0; done
|
|
116
|
+
for ((pass = 0; pass < local_n; pass++)); do
|
|
117
|
+
best=-1; bestlen=-1
|
|
118
|
+
for ((j = 0; j < local_n; j++)); do
|
|
119
|
+
if [ "${used[$j]}" -eq 0 ] && [ "${#FROM[$j]}" -gt "$bestlen" ]; then
|
|
120
|
+
bestlen="${#FROM[$j]}"; best="$j"
|
|
121
|
+
fi
|
|
122
|
+
done
|
|
123
|
+
used[$best]=1; ORDER+=("$best")
|
|
124
|
+
done
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
REPL_OUT=''
|
|
128
|
+
apply_repl() {
|
|
129
|
+
local text="$1" idx from to
|
|
130
|
+
if [ "${#ORDER[@]}" -gt 0 ]; then
|
|
131
|
+
for idx in "${ORDER[@]}"; do
|
|
132
|
+
from="${FROM[$idx]}"; to="${TO[$idx]}"
|
|
133
|
+
text="${text//"$from"/$to}"
|
|
134
|
+
done
|
|
135
|
+
fi
|
|
136
|
+
REPL_OUT="$text"
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
# ------------------------------------------------ output root ----------------
|
|
140
|
+
[ -d "$OUT_DIR" ] || mkdir -p "$OUT_DIR"
|
|
141
|
+
OUT_ROOT="$(cd "$OUT_DIR" && pwd -P)"
|
|
142
|
+
|
|
143
|
+
# ------------------------------------------------ base64 decoder (portable) --
|
|
144
|
+
B64D=()
|
|
145
|
+
if printf 'aGk=' | base64 -d >/dev/null 2>&1; then B64D=(base64 -d)
|
|
146
|
+
elif printf 'aGk=' | base64 -D >/dev/null 2>&1; then B64D=(base64 -D)
|
|
147
|
+
elif printf 'aGk=' | base64 --decode >/dev/null 2>&1; then B64D=(base64 --decode)
|
|
148
|
+
else B64D=(openssl base64 -d -A)
|
|
149
|
+
fi
|
|
150
|
+
|
|
151
|
+
# ------------------------------------------------ parse file blocks ----------
|
|
152
|
+
rels=(); encs=(); contents=()
|
|
153
|
+
in_block=0; cur_rel=''; cur_enc=''; cur_content=''; first_line=1
|
|
154
|
+
file_re='^<<<FILE path="([^"]+)"( encoding="([^"]+)")?>>>[[:space:]]*$'
|
|
155
|
+
|
|
156
|
+
while IFS= read -r line || [ -n "$line" ]; do
|
|
157
|
+
line="${line%$'\r'}"
|
|
158
|
+
if [ "$in_block" -eq 0 ]; then
|
|
159
|
+
if [[ "$line" =~ $file_re ]]; then
|
|
160
|
+
cur_rel="${BASH_REMATCH[1]}"
|
|
161
|
+
cur_enc="${BASH_REMATCH[3]:-}"
|
|
162
|
+
in_block=1; first_line=1; cur_content=''
|
|
163
|
+
fi
|
|
164
|
+
else
|
|
165
|
+
if [ "$line" = '<<<ENDFILE>>>' ]; then
|
|
166
|
+
rels+=("$cur_rel"); encs+=("$cur_enc"); contents+=("$cur_content")
|
|
167
|
+
in_block=0
|
|
168
|
+
elif [ "$first_line" -eq 1 ]; then
|
|
169
|
+
cur_content="$line"; first_line=0
|
|
170
|
+
else
|
|
171
|
+
cur_content="$cur_content"$'\n'"$line"
|
|
172
|
+
fi
|
|
173
|
+
fi
|
|
174
|
+
done < "$PACK_FILE"
|
|
175
|
+
|
|
176
|
+
[ "${#rels[@]}" -gt 0 ] || { echo "Error: No <<<FILE>>> blocks found in pack: $PACK_FILE" >&2; exit 1; }
|
|
177
|
+
|
|
178
|
+
# ------------------------------------------------ resolve destinations -------
|
|
179
|
+
dests=()
|
|
180
|
+
for ((i = 0; i < ${#rels[@]}; i++)); do
|
|
181
|
+
apply_repl "${rels[$i]}"
|
|
182
|
+
dests+=("$OUT_ROOT/$REPL_OUT")
|
|
183
|
+
done
|
|
184
|
+
|
|
185
|
+
# ------------------------------------------------ conflict guard -------------
|
|
186
|
+
if [ "$FORCE" -eq 0 ] && [ "$DRYRUN" -eq 0 ]; then
|
|
187
|
+
conflicts=()
|
|
188
|
+
for d in "${dests[@]}"; do [ -e "$d" ] && conflicts+=("$d"); done
|
|
189
|
+
if [ "${#conflicts[@]}" -gt 0 ]; then
|
|
190
|
+
echo "Error: Refusing to overwrite existing files (re-run with --force):" >&2
|
|
191
|
+
printf ' %s\n' "${conflicts[@]}" >&2
|
|
192
|
+
exit 1
|
|
193
|
+
fi
|
|
194
|
+
fi
|
|
195
|
+
|
|
196
|
+
# ------------------------------------------------ write ----------------------
|
|
197
|
+
written=0
|
|
198
|
+
for ((i = 0; i < ${#rels[@]}; i++)); do
|
|
199
|
+
rel="${rels[$i]}"; enc="${encs[$i]}"; dest="${dests[$i]}"
|
|
200
|
+
if [ "$DRYRUN" -eq 1 ]; then
|
|
201
|
+
echo "WOULD WRITE $rel -> $dest"
|
|
202
|
+
continue
|
|
203
|
+
fi
|
|
204
|
+
mkdir -p "$(dirname "$dest")"
|
|
205
|
+
if [ "$enc" = 'base64' ]; then
|
|
206
|
+
printf '%s' "${contents[$i]}" | tr -d '[:space:]' | "${B64D[@]}" > "$dest"
|
|
207
|
+
else
|
|
208
|
+
apply_repl "${contents[$i]}"
|
|
209
|
+
printf '%s' "$REPL_OUT" > "$dest"
|
|
210
|
+
fi
|
|
211
|
+
written=$((written + 1))
|
|
212
|
+
done
|
|
213
|
+
|
|
214
|
+
if [ "$DRYRUN" -eq 1 ]; then
|
|
215
|
+
echo "DryRun: ${#rels[@]} file(s) would be written to $OUT_ROOT (sentinel '$SENTINEL' -> '$TARGET_APP_NAME')."
|
|
216
|
+
else
|
|
217
|
+
echo "Unpacked $written file(s) to $OUT_ROOT (sentinel '$SENTINEL' -> '$TARGET_APP_NAME')."
|
|
218
|
+
fi
|