blueprint-shared-templates 0.1.0 → 0.2.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.
@@ -10,9 +10,9 @@
10
10
  // checks from `gh pr checks --json name,bucket`; bucket is pass, fail, pending, skipping or cancel
11
11
  // changedFiles the paths the pull request changes (only used for the checks in config.pathFiltered)
12
12
  // config JSON { label, requiredChecks, pathFiltered, reviewPaths, syncPr }, written when the repository is composed
13
- // from blueprint.merge.required-checks. pathFiltered maps a check name to the path globs of the workflow that
13
+ // from blueprint-shared.merge.required-checks. pathFiltered maps a check name to the path globs of the workflow that
14
14
  // has a path filter: when none of the changed files matches, that workflow did not run and the check
15
- // counts as skipped. reviewPaths are the CODEOWNERS style paths (blueprint.git-flow.review-paths) that need
15
+ // counts as skipped. reviewPaths are the CODEOWNERS style paths (blueprint-shared.git-flow.review-paths) that need
16
16
  // a review; empty or missing means no pull request needs one here. syncPr is { author, branch }: the
17
17
  // pull request that blueprint opens in a demo repository (blueprint.sync.pull-request), which needs no review.
18
18
  // pr also needs author ({ login, is_bot }) and latestReviews ([{ state }]) from `gh pr view --json`.
@@ -20,7 +20,7 @@
20
20
  # description differ.
21
21
  #
22
22
  # The values of squash, delete-branch, days and the label come from github-repo-settings.json next to this script,
23
- # a copy of blueprint.merge.method and blueprint.retention.repository-days (tests/repo-settings.test.mjs
23
+ # a copy of blueprint-shared.merge.method and blueprint-shared.retention.repository-days (tests/repo-settings.test.mjs
24
24
  # fails when they drift).
25
25
  #
26
26
  # Reads the current values first and sends only the requests that change something. A failing repository
@@ -71,7 +71,7 @@ export function factsSkeleton({ repoName, repoUrl, access, metaFactName, product
71
71
  );
72
72
  if (c.unit) out.set(`facts/${c.name}/fact-kit.config.json`, json({ implDirs: [`../../${c.unit.dir}`] }));
73
73
  const publish = c.unit?.publish ? ` publish: { target: '${c.unit.publish.target}', name: '${c.unit.publish.name}' },\n` : "";
74
- // Every facts entry declares its layer (blueprint.doc-layers.layers): a unit's facts are the implementation
74
+ // Every facts entry declares its layer (blueprint-shared.doc-layers.layers): a unit's facts are the implementation
75
75
  // layer, the product-level spec is the product layer.
76
76
  out.set(
77
77
  `facts/${c.name}/facts/${c.name}/index.ts`,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "blueprint-shared-templates",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "Templates shared by several products, published on its own",
5
5
  "license": "MIT",
6
6
  "author": "Carlos Space",
@@ -1,6 +1,6 @@
1
1
  // Deletes the old versions of private packages on GitHub Packages. Each package keeps its latest GA version and every
2
2
  // prerelease newer than that GA. Every older GA and every prerelease older than the latest GA is deleted. There is no
3
- // exception list. The rule is the fact blueprint.templates.private-package-cleanup.
3
+ // exception list. The rule is the fact blueprint-shared.templates.private-package-cleanup.
4
4
  //
5
5
  // a package with no GA version nothing is deleted: there is no latest GA to count from
6
6
  // a version that is not X.Y.Z or left alone and listed as skipped, because its order is unknown
@@ -85,8 +85,8 @@ unit_registry() {
85
85
 
86
86
  # is_aggregate_path <config path> → succeeds when the path is a facts or docs package of the aggregate kind:
87
87
  # the aggregate package of the repository (a one-segment path whose component is named <RepoName>-facts or
88
- # <RepoName>-docs, or plain facts or docs, blueprint.naming.unit-name) or a shared package published on its own from inside that
89
- # directory (facts/<RepoName>-shared-facts, docs/<RepoName>-shared-docs, blueprint.repo-layout.unit-dirs). The
88
+ # <RepoName>-docs, or plain facts or docs, blueprint-shared.naming.unit-name) or a shared package published on its own from inside that
89
+ # directory (facts/<RepoName>-shared-facts, docs/<RepoName>-shared-docs, blueprint-shared.repo-layout.unit-dirs). The
90
90
  # directory is found from the name of the package, so nothing here spells out "facts" or "docs".
91
91
  is_aggregate_path() {
92
92
  local p="${1%/}" c
@@ -116,15 +116,22 @@ aggregate_unit() {
116
116
  # those of <unit>... that have been released (unit_released). A merge-back commit covers the units its
117
117
  # Release-Train-Units lists; one with no such trailer covers all of them. The result is the cut that covers the
118
118
  # last of them, so a unit left out of the newest releases still counts from the cut of the release that had it.
119
+ # No release lists a unit that has never been released, so a cut with the trailer covers such a unit when it is
120
+ # strictly older than the unit's first commit: every commit of the unit then comes after the cut and counts toward
121
+ # its first version.
119
122
  # With nothing to cover it is the newest cut; when the walk ends with a unit uncovered it is the oldest cut;
120
123
  # with no cut at all it is empty (no previous release). The walk has no depth limit: the cut is a fact of an
121
124
  # earlier release, however far back.
122
125
  release_start_point() {
123
- local base="$1" u c b us row
124
- local -a left=() listed=() keep=()
126
+ local base="$1" u c b us row first
127
+ local -a left=() firsts=() listed=() keep=()
125
128
  shift
126
129
  RELEASE_START=""; RELEASE_SKIPPED=()
127
- for u in "$@"; do if unit_released "$u"; then left+=("$u"); fi; done
130
+ for u in "$@"; do
131
+ if unit_released "$u"; then left+=("$u"); continue; fi
132
+ first="$(git rev-list --reverse "$base" -- "$(unit_path "$u")" | sed -n 1p)"
133
+ [[ -z "$first" ]] || firsts+=("$first")
134
+ done
128
135
  while IFS= read -r row; do
129
136
  b="${row%%$'\x1f'*}"; us="${row#*$'\x1f'}"
130
137
  [[ "$b" =~ ^[0-9a-f]{7,40}$ ]] || continue
@@ -132,13 +139,17 @@ release_start_point() {
132
139
  if ! git merge-base --is-ancestor "$c" "$base" 2>/dev/null; then RELEASE_SKIPPED+=("$c"); continue; fi
133
140
  # shellcheck disable=SC2034 # read by cut-release.sh, which sources this file
134
141
  RELEASE_START="$c"
135
- (( ${#left[@]} )) || break
136
- [[ -n "$us" ]] || { left=(); break; }
142
+ [[ -n "$us" ]] || break
137
143
  read -r -a listed <<<"$us"
138
144
  keep=()
139
- for u in "${left[@]}"; do in_array "$u" "${listed[@]}" || keep+=("$u"); done
145
+ for u in "${left[@]+"${left[@]}"}"; do in_array "$u" "${listed[@]}" || keep+=("$u"); done
140
146
  left=("${keep[@]+"${keep[@]}"}")
141
- (( ${#left[@]} )) || break
147
+ keep=()
148
+ for first in "${firsts[@]+"${firsts[@]}"}"; do
149
+ if [[ "$c" == "$first" ]] || ! git merge-base --is-ancestor "$c" "$first"; then keep+=("$first"); fi
150
+ done
151
+ firsts=("${keep[@]+"${keep[@]}"}")
152
+ (( ${#left[@]} + ${#firsts[@]} )) || break
142
153
  done < <(git log origin/main --format='%(trailers:key=Release-Train-Base,valueonly,unfold,separator=%x20)%x1f%(trailers:key=Release-Train-Units,valueonly,unfold,separator=%x20)' 2>/dev/null || true)
143
154
  }
144
155
 
@@ -115,7 +115,7 @@ if [[ "$from" == "main" ]]; then
115
115
  # 回溯不設筆數上限:切點是上一次發布的事實,離現在多遠都要找得到,只看最近 200 筆時,兩次發布之間
116
116
  # main 超過 200 筆就會誤判成「無前一次發布」而重算全部歷史。
117
117
  # 一次發布不一定帶全部單元(獨立發布的單元自己開線),所以合回 commit 另寫 Release-Train-Units,
118
- # 函式取「涵蓋這條線已發過版的單元」的切點,沒帶上的單元的 commit 才不會漏版。
118
+ # 函式取「涵蓋這條線的單元」的切點,沒帶上的單元與第一次發布的單元的 commit 才不會漏版。
119
119
  prev_cut=""
120
120
  else
121
121
  # 自產品 tag(如 v1.3.0)重建的修補發布:該 tag 之前的內容全部已發布,起算點就是它本身。
package/transform.mjs CHANGED
@@ -52,7 +52,7 @@ export function roleBlocks(text, roles, file = "workflow") {
52
52
  return out.join("\n");
53
53
  }
54
54
 
55
- // A public repository runs every job on a GitHub-hosted runner (blueprint.git-flow.runner-rule-public-repo): every
55
+ // A public repository runs every job on a GitHub-hosted runner (blueprint-shared.git-flow.runner-rule-public-repo): every
56
56
  // self-hosted runner label becomes ubuntu-latest (macos-latest for the macOS one), and the line
57
57
  // `# 獨立發布 job:{理由}` above a runs-on, which explains why a private repository runs one job on a hosted runner,
58
58
  // is dropped with the label change (check-workflows public-runner).