blueprint-shared-templates 0.6.0 → 0.6.1
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.
|
@@ -22,6 +22,19 @@ AUDIT_LOG="$TASK_DIR/external-ops.log"
|
|
|
22
22
|
CONFIG="release-please-config.json"
|
|
23
23
|
MANIFEST=".release-please-manifest.json"
|
|
24
24
|
|
|
25
|
+
# config_dirs_with <marker file> → "<path>\t<component>" per package of release-please-config.json whose directory
|
|
26
|
+
# (path relative to the repository root) holds that file; the component is the unit name. Prints nothing without the
|
|
27
|
+
# config. The facts and docs steps use it to find a single-layer package wherever it sits, so the config stays the one
|
|
28
|
+
# list of units and no directory name is hard-coded.
|
|
29
|
+
config_dirs_with() {
|
|
30
|
+
[[ -f "$REPO_ROOT/$CONFIG" ]] || return 0
|
|
31
|
+
local p c
|
|
32
|
+
while IFS=$'\t' read -r p c; do
|
|
33
|
+
[[ "$p" != "." && -f "$REPO_ROOT/$p/$1" ]] && printf '%s\t%s\n' "$p" "$c"
|
|
34
|
+
done < <(jq -r '.packages | to_entries[] | [.key, (.value.component // (.key | split("/") | last))] | @tsv' "$REPO_ROOT/$CONFIG")
|
|
35
|
+
return 0
|
|
36
|
+
}
|
|
37
|
+
|
|
25
38
|
log() { printf '%s\n' "→ $*"; }
|
|
26
39
|
info() { printf '%s\n' " $*"; }
|
|
27
40
|
warn() { printf '%s\n' "! $*" >&2; }
|
package/package.json
CHANGED
|
@@ -11,6 +11,9 @@
|
|
|
11
11
|
# docs/<package>/ a shared document package published on its own (docs/<RepoName>-shared-docs): a directory
|
|
12
12
|
# with its own package.json, found by the unit name, which is the name of that package
|
|
13
13
|
# without its scope. Pinned like a component layer, to the version of its own unit.
|
|
14
|
+
# <path> a package that release-please-config.json lists at any path and whose own directory holds a
|
|
15
|
+
# clarify-kit.config.json (demos/_docs): found by its component, which is the unit name. Looked
|
|
16
|
+
# up last (never docs/ itself), so the two layers above keep their directories.
|
|
14
17
|
# Anything else under docs/ is not pinned by the scripts. Only the packages' own files are read and nothing
|
|
15
18
|
# outside docs/.
|
|
16
19
|
#
|
|
@@ -48,7 +51,8 @@ docs_pin_product() {
|
|
|
48
51
|
|
|
49
52
|
# docs_unit_dir <unit> → the directory under the repository root that holds the documents of a unit, printed
|
|
50
53
|
# when there is one: docs/<package> whose package.json carries the unit as its name (without scope), else the
|
|
51
|
-
# component layer docs/<unit
|
|
54
|
+
# component layer docs/<unit>, else the package that release-please-config.json lists under that component with a
|
|
55
|
+
# clarify-kit.config.json of its own.
|
|
52
56
|
docs_unit_dir() {
|
|
53
57
|
has_docs || return 1
|
|
54
58
|
local f n
|
|
@@ -58,6 +62,10 @@ docs_unit_dir() {
|
|
|
58
62
|
if [[ "${n##*/}" == "$1" ]]; then f="${f%/package.json}"; printf '%s\n' "${f#"$REPO_ROOT"/}"; return 0; fi
|
|
59
63
|
done
|
|
60
64
|
[[ -d "$REPO_ROOT/docs/$1" ]] && { printf '%s\n' "docs/$1"; return 0; }
|
|
65
|
+
local p c
|
|
66
|
+
while IFS=$'\t' read -r p c; do
|
|
67
|
+
[[ "$c" == "$1" && "$p" != docs ]] && { printf '%s\n' "$p"; return 0; }
|
|
68
|
+
done < <(config_dirs_with clarify-kit.config.json)
|
|
61
69
|
return 1
|
|
62
70
|
}
|
|
63
71
|
|
|
@@ -42,18 +42,24 @@ facts_package_dir() {
|
|
|
42
42
|
# case is a facts/*/ whose fact-kit.config.json has no "aggregate" key and whose package.json is not private: it
|
|
43
43
|
# has nothing to aggregate and is published on its own, so it is itself the component and its directory name is
|
|
44
44
|
# the unit. A private facts/*/ without an "aggregate" key is a component that an aggregate lists, never a unit.
|
|
45
|
+
# A fourth case is found through release-please-config.json (config_dirs_with): a package whose own directory holds a
|
|
46
|
+
# fact-kit.config.json without an "aggregate" key, wherever it sits (demos/_facts), is a single-layer package like the
|
|
47
|
+
# third case, and its unit is the component the config gives it. A directory already listed above is not listed twice.
|
|
45
48
|
# The unit is what a release unit is called, and the callers keep the rows of the units they were given. The built "describes" is not read here: it follows
|
|
46
49
|
# the version file of the unit's directory, which is still 0.0.0 until the unit's first Release PR is merged (then
|
|
47
50
|
# "describes" is {}), so a unit's first release would find no component package and its "next" rows would stay unpinned. The aggregate itself never appears.
|
|
48
51
|
# Builds each package first, so a caller can read the built indexes afterwards.
|
|
49
52
|
facts_components() {
|
|
50
53
|
has_facts || return 0
|
|
51
|
-
local root pkg dir out unit cfg
|
|
54
|
+
local root pkg dir out unit cfg p c
|
|
55
|
+
local -A seen=()
|
|
52
56
|
while IFS= read -r root; do
|
|
57
|
+
seen[$root]=1
|
|
53
58
|
unit=""; [[ "$root" == "$REPO_ROOT/facts" ]] || unit="${root##*/}"
|
|
54
59
|
while IFS= read -r pkg; do
|
|
55
60
|
dir="$(facts_package_dir "$pkg" "$root")" || { warn "${root#"$REPO_ROOT"/}/fact-kit.config.json 的 aggregate 列了 ${pkg},但 ${root#"$REPO_ROOT"/}/ 底下找不到這個套件"; continue; }
|
|
56
61
|
out="$(fact_kit build --cwd "$dir" 2>&1)" || { printf '%s\n' "$out" >&2; die "建置 ${dir#"$REPO_ROOT"/} 失敗(facts 的依賴裝了嗎?先在倉庫根目錄執行 pnpm install)"; }
|
|
62
|
+
seen[$dir]=1
|
|
57
63
|
printf '%s\t%s\n' "$dir" "${unit:-${dir##*/}}"
|
|
58
64
|
done < <(jq -r '.aggregate // {} | to_entries[] | .value' "$root/fact-kit.config.json")
|
|
59
65
|
done < <(facts_roots)
|
|
@@ -64,8 +70,18 @@ facts_components() {
|
|
|
64
70
|
[[ -f "$dir/package.json" ]] || continue
|
|
65
71
|
[[ "$(jq -r '.private // false' "$dir/package.json")" == "true" ]] && continue
|
|
66
72
|
out="$(fact_kit build --cwd "$dir" 2>&1)" || { printf '%s\n' "$out" >&2; die "建置 ${dir#"$REPO_ROOT"/} 失敗(facts 的依賴裝了嗎?先在倉庫根目錄執行 pnpm install)"; }
|
|
73
|
+
seen[$dir]=1
|
|
67
74
|
printf '%s\t%s\n' "$dir" "${dir##*/}"
|
|
68
75
|
done
|
|
76
|
+
while IFS=$'\t' read -r p c; do
|
|
77
|
+
dir="$REPO_ROOT/$p"
|
|
78
|
+
[[ -z "${seen[$dir]:-}" ]] || continue
|
|
79
|
+
jq -e 'has("aggregate")' "$dir/fact-kit.config.json" >/dev/null 2>&1 && continue
|
|
80
|
+
[[ -f "$dir/package.json" ]] || continue
|
|
81
|
+
out="$(fact_kit build --cwd "$dir" 2>&1)" || { printf '%s\n' "$out" >&2; die "建置 ${dir#"$REPO_ROOT"/} 失敗(facts 的依賴裝了嗎?先在倉庫根目錄執行 pnpm install)"; }
|
|
82
|
+
seen[$dir]=1
|
|
83
|
+
printf '%s\t%s\n' "$dir" "$c"
|
|
84
|
+
done < <(config_dirs_with fact-kit.config.json)
|
|
69
85
|
return 0
|
|
70
86
|
}
|
|
71
87
|
|
|
@@ -289,7 +289,8 @@ RELEASE_PIN_RESULT="" RELEASE_PIN_REASON=""
|
|
|
289
289
|
# shellcheck disable=SC2034 # RELEASE_PIN_RESULT is read by pin-release-pr.sh and merge-release-pr.sh, which source this file
|
|
290
290
|
release_pin_open_pr() {
|
|
291
291
|
local branch="$1" line="$2" n head_ref pr_sha base out row pair u v comps
|
|
292
|
-
local -a specs=() pr_units=() pinned=() docs_pinned=()
|
|
292
|
+
local -a specs=() pr_units=() pinned=() docs_pinned=() fact_paths=(facts) doc_paths=(docs)
|
|
293
|
+
local dir c d
|
|
293
294
|
RELEASE_PIN_RESULT="" RELEASE_PIN_REASON=""
|
|
294
295
|
n="$(release_pr_open_number "$branch")"
|
|
295
296
|
if [[ -z "$n" ]]; then
|
|
@@ -336,9 +337,11 @@ release_pin_open_pr() {
|
|
|
336
337
|
[[ -n "${comp_units[$u]:-}" ]] || continue
|
|
337
338
|
facts_pin "$u" "$v"
|
|
338
339
|
pinned+=("$u@$v")
|
|
340
|
+
# a package outside facts/ (listed in the release-please config) is committed too
|
|
341
|
+
while IFS=$'\t' read -r dir c; do [[ "$c" == "$u" ]] && fact_paths+=("${dir#"$REPO_ROOT"/}"); done <<<"$comps"
|
|
339
342
|
done
|
|
340
|
-
if [[ -n "$(git status --porcelain --
|
|
341
|
-
git add --
|
|
343
|
+
if [[ -n "$(git status --porcelain -- "${fact_paths[@]}")" ]]; then
|
|
344
|
+
git add -- "${fact_paths[@]}"
|
|
342
345
|
run git commit -q -m "chore(facts): 釘 next 為 ${pinned[*]}" \
|
|
343
346
|
-m "合併 Release PR #${n} 之前,把這次要發的單元的 next 釘成 PR 的版號。釘在發布分支,不放 Release PR 分支,因為 release-please 重算時會強制改寫它。"
|
|
344
347
|
else
|
|
@@ -350,12 +353,13 @@ release_pin_open_pr() {
|
|
|
350
353
|
if has_docs; then
|
|
351
354
|
for pair in "${pr_units[@]}"; do
|
|
352
355
|
u="${pair% *}" v="${pair#* }"
|
|
353
|
-
docs_unit_dir "$u"
|
|
356
|
+
d="$(docs_unit_dir "$u")" || continue
|
|
354
357
|
docs_pin_unit "$u" "$v"
|
|
358
|
+
doc_paths+=("$d")
|
|
355
359
|
docs_pinned+=("$u@$v")
|
|
356
360
|
done
|
|
357
|
-
if [[ -n "$(git status --porcelain --
|
|
358
|
-
git add --
|
|
361
|
+
if [[ -n "$(git status --porcelain -- "${doc_paths[@]}")" ]]; then
|
|
362
|
+
git add -- "${doc_paths[@]}"
|
|
359
363
|
run git commit -q -m "chore(docs): 釘 next 為 ${docs_pinned[*]}" \
|
|
360
364
|
-m "合併 Release PR #${n} 之前,把這次要發的單元的文件 next 釘成 PR 的版號。釘在發布分支,不放 Release PR 分支,因為 release-please 重算時會強制改寫它。"
|
|
361
365
|
else
|