@patternslib/dev 4.5.1 → 4.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.
package/CHANGES.md CHANGED
@@ -1,5 +1,55 @@
1
1
  # Changelog
2
2
 
3
+ ## [4.6.1](https://github.com/Patternslib/dev/compare/4.6.0...4.6.1) (2026-11-30)
4
+
5
+ ### Bug Fixes
6
+
7
+ - **jest:** Let the matchMedia mock emulate a desktop device. ([12e094e](https://github.com/Patternslib/dev/commit/12e094e49ebf0f2d3bf9ced0a6af6f4334cde882))
8
+
9
+ The mock returned matches: false for every query. TinyMCE 8.11 detects
10
+ touch devices with !matchMedia("(any-pointer:fine)") and therefore
11
+ treated jsDOM as a touch device, disabling the editor resize handle.
12
+
13
+ Fine pointer and hover queries now match, all other queries still don't.
14
+
15
+ Ref: ADR 0002
16
+
17
+ - **release-it:** Filter attribution trailers from changelogs. ([0d347c8](https://github.com/Patternslib/dev/commit/0d347c87e39d4d20e01a494fd20044b2283ad6fe))
18
+
19
+ Omit Assisted-by, Assisted by and Co-authored-by lines (case-insensitive)
20
+ from rendered commit bodies and footers. Add tests for the changelog commit
21
+ partial.
22
+
23
+ ### Maintenance
24
+
25
+ - **docs:** Add ADR 0002 about the matchMedia mock emulating a desktop device. ([f9d063a](https://github.com/Patternslib/dev/commit/f9d063a1c46a878367f3294e1519d641be307fc9))
26
+
27
+ Ref: ADR 0002
28
+
29
+ ## [4.6.0](https://github.com/Patternslib/dev/compare/4.5.1...4.6.0) (2026-11-30)
30
+
31
+ ### Features
32
+
33
+ - **Makefile:** Run make upgrade from make update and drop the postinstall script. ([90211cc](https://github.com/Patternslib/dev/commit/90211ccf5ebe1a4c51566572dac0b62ffd6b07aa))
34
+
35
+ The postinstall script did not run reliably: pnpm's side-effects cache
36
+ skips it when a dev version is already built in the store, and pnpm
37
+ update overwrote package.json changes from the upgrade steps afterwards.
38
+ It would also create commits in CI.
39
+
40
+ make update now runs make upgrade in a sub-make as its last step, which
41
+ reads the newly installed Makefile.
42
+
43
+ Ref: ADR 0001
44
+
45
+ ### Maintenance
46
+
47
+ - **docs:** Add ADR 0001 about running upgrades from make update. ([7931180](https://github.com/Patternslib/dev/commit/7931180ac80e4195647b9aa0e82f776ba7943520))
48
+
49
+ Ref: ADR 0001
50
+
51
+ - **docs:** Start with ADR records. ([c7add1e](https://github.com/Patternslib/dev/commit/c7add1e6e6923ed436b6d2853e5b00b4a49996b4))
52
+
3
53
  ## [4.5.1](https://github.com/Patternslib/dev/compare/4.5.0...4.5.1) (2026-11-30)
4
54
 
5
55
  ### Features
@@ -12,14 +62,10 @@
12
62
  .gitignore. Both commit their change and skip files with uncommitted
13
63
  changes, so that unrelated work is never committed.
14
64
 
15
- Assisted-by: Claude Opus 5.5
16
-
17
65
  ### Bug Fixes
18
66
 
19
67
  - **Makefile:** Fall back to webpack-cli config discovery for bundle analysis. ([fd4918d](https://github.com/Patternslib/dev/commit/fd4918de0dbce20be20aa1f8fc4a7b50ec9793f0))
20
68
 
21
- Assisted-by: Claude Opus 5.5
22
-
23
69
  ### Maintenance
24
70
 
25
71
  - **docs:** Update README with recent changes. ([92ad74b](https://github.com/Patternslib/dev/commit/92ad74ba9ad7192b14342b29a9c8d64c1ad8509e))
@@ -72,8 +118,6 @@
72
118
  in the actual release run. Also abort if the version cannot be
73
119
  determined.
74
120
 
75
- Assisted-by: Claude Opus 5.5
76
-
77
121
  - **Makefile:** Open sunburst stats.html directly in browser. ([fe885bf](https://github.com/Patternslib/dev/commit/fe885bfdf85b18e845f45ef67ba4e20f509dd540))
78
122
  - **webpack:** Fix test for loaders configured with resolved paths. ([5cf5071](https://github.com/Patternslib/dev/commit/5cf5071bfe5953004c1acd919149c196db62b1d1))
79
123
 
@@ -88,8 +132,6 @@
88
132
  style-loader. It now compares against the resolved path, and the
89
133
  resolveLoader workaround is no longer needed.
90
134
 
91
- Assisted-by: Claude Opus 5.5
92
-
93
135
  - **webpack:** Use imports relative to @patternslib/dev. ([b8032f1](https://github.com/Patternslib/dev/commit/b8032f1f108c30be1bdaadb5fba75ae2e3ab727f))
94
136
 
95
137
  Depending packages might not have all dependencies installed.
@@ -169,7 +211,7 @@
169
211
 
170
212
  ### Maintenance
171
213
 
172
- - Allow releases from alpha/* and beta/* branches, alongside to master, main and *.x. ([73c49fa](https://github.com/Patternslib/dev/commit/73c49fa2cb7d797626411da76f3b702f8e03a960))
214
+ - Allow releases from alpha/_and beta/_ branches, alongside to master, main and *.x. ([73c49fa](https://github.com/Patternslib/dev/commit/73c49fa2cb7d797626411da76f3b702f8e03a960))
173
215
  - Migrate handlebars changelog template to JavaScript render functions. ([a1685f9](https://github.com/Patternslib/dev/commit/a1685f9d84e7e36c6d2c1cc6426b454228ddf15d))
174
216
 
175
217
  Co-authored-by: Codex <noreply@openai.com>
@@ -232,10 +274,10 @@ projects do anyways, so this change is fine, IMO.
232
274
 
233
275
  The following problems are now fixed:
234
276
 
235
- * Whole history included in new changelog entries.
236
- * No dist/ published due to silent failures.
237
- * No GitHub release page updates.
238
- * No GutHub bundle zip upload.
277
+ - Whole history included in new changelog entries.
278
+ - No dist/ published due to silent failures.
279
+ - No GitHub release page updates.
280
+ - No GutHub bundle zip upload.
239
281
 
240
282
  ### Maintenance
241
283
 
package/Makefile CHANGED
@@ -66,6 +66,10 @@ update:
66
66
  $(PNPM) update --latest --interactive
67
67
  -git commit package.json -m"maint: Update dependencies."
68
68
  -git commit pnpm-lock.yaml -m"pnpm-lock.yaml: Update." -n
69
+ @# Run the upgrades of a possibly updated @patternslib/dev.
70
+ @# A sub-make reads its newly installed Makefile, while this make still
71
+ @# uses the old one.
72
+ $(MAKE) upgrade
69
73
 
70
74
  .PHONY: clean-dist
71
75
  clean-dist:
package/README.md CHANGED
@@ -101,12 +101,12 @@ Run `make update` to update the dependencies in this or your dependent project.
101
101
  It creates a `dependencies-update` branch and makes up to three separate commits: one for the pnpm update, one for the updated dependencies in `package.json`, and one for `pnpm-lock.yaml`.
102
102
  The dependencies are updated interactively with `pnpm update --latest --interactive`.
103
103
  `package.json` must not have uncommitted changes.
104
+ Finally, `make update` runs `make upgrade` to apply the upgrade steps of a possibly updated `@patternslib/dev`.
104
105
 
105
106
  ## Upgrading
106
107
 
107
- Run `make upgrade` in your project.
108
-
109
- Alternatively, if there is a new `@patternslib/dev` version installed, the `postinstall` package.json script will automatically run `make upgrade` in the directory where package installer was invoked, that is your project directory which depends on `@patternslib/dev`.
108
+ `make update` runs the upgrade steps automatically.
109
+ If you updated `@patternslib/dev` in another way, run `make upgrade` in your project.
110
110
 
111
111
  Each upgrade step creates its own commit. Current upgrades:
112
112
 
@@ -0,0 +1,9 @@
1
+ # Architecture Decision Records
2
+
3
+ This directory contains Architecture Decision Records.
4
+
5
+ ## References
6
+
7
+ - https://www.heise.de/hintergrund/Gut-dokumentiert-Architecture-Decision-Records-4664988.html
8
+ - https://martinfowler.com/bliki/ArchitectureDecisionRecord.html
9
+ - https://adr.github.io/
@@ -0,0 +1,45 @@
1
+ # Run upgrades from `make update` instead of a postinstall script
2
+
3
+ Status: Accepted (2026-11-30)
4
+
5
+ ## Context
6
+
7
+ `@patternslib/dev` provides `make upgrade`, which brings a consuming project up to date with the current dev package.
8
+ Examples are creating `eslint.config.js`, removing the `build:stats` script from `package.json` and adding `stats.json` and `stats.html` to `.gitignore`.
9
+ Each upgrade step commits its change.
10
+
11
+ Until now, a `postinstall` script in `@patternslib/dev`'s `package.json` ran `cd $INIT_CWD && make upgrade || true` whenever the package was installed.
12
+ After the 4.5.1 release, the upgrades ran in only one of several add-ons updated with `make update`.
13
+ We found two causes:
14
+
15
+ 1. **pnpm's side-effects cache.**
16
+ pnpm caches the result of a dependency's build scripts in the store.
17
+ When another project installs the same package version, pnpm restores the cached result and does not run the scripts again.
18
+ The `postinstall` changes nothing inside the package, so restoring the cache counts as done.
19
+ As a result, `make upgrade` ran only once per machine and dev version, in whichever project installed it first.
20
+ The pnpm store had such a cache entry for every dev version installed.
21
+
22
+ 2. **`pnpm update` writes `package.json` after running install scripts.**
23
+ In the one add-on where the upgrade did run, `upgrade-remove-build-stats` removed the `build:stats` script and committed.
24
+ `pnpm update --latest` then wrote its in-memory copy of `package.json`, which still had the script, so the following "Update dependencies" commit added it back.
25
+
26
+ Also, a `postinstall` that commits also runs in CI or any other place where dependencies are installed, and we don't want automatic commits there.
27
+
28
+ ## Decision
29
+
30
+ Drop the `postinstall` script.
31
+ The `update` target of the shared Makefile runs `$(MAKE) upgrade` as its last step, after the pnpm, `package.json` and `pnpm-lock.yaml` commits.
32
+
33
+ The upgrade runs in a sub-make so that it reads the newly installed `node_modules/@patternslib/dev/Makefile`.
34
+ The make running `update` has already parsed the old one.
35
+
36
+ Developers who update `@patternslib/dev` in another way run `make upgrade` by hand.
37
+
38
+ ## Consequences
39
+
40
+ - Upgrades run every time `make update` runs, regardless of the pnpm store cache.
41
+ - Upgrades run after pnpm has finished writing `package.json`, so their changes are not overwritten.
42
+ - Installing dependencies, including in CI, never creates commits.
43
+ - A plain `pnpm install` or `pnpm update` no longer upgrades the project. Developers need to use `make update` or run `make upgrade`.
44
+ - Upgrade steps must stay idempotent, because `make update` runs all of them every time.
45
+ - Consuming projects still allow builds for `@patternslib/dev` in `pnpm-workspace.yaml` (`allowBuilds`). That entry is no longer needed, but it does no harm.
@@ -0,0 +1,31 @@
1
+ # The `matchMedia` mock emulates a desktop device
2
+
3
+ Status: Accepted (2026-11-30)
4
+
5
+ ## Context
6
+
7
+ jsDOM does not implement `window.matchMedia`.
8
+ `jest/setup-tests.js` provides a mock for it, which until now returned `matches: false` for every media query.
9
+
10
+ TinyMCE 8.11 changed its touch device detection to `isTouch = isMobile || !matchMedia("(any-pointer:fine)")`.
11
+ With the mock, every query fails, so TinyMCE treats the jsDOM test environment as a touch device.
12
+ On touch devices TinyMCE disables the editor resize handle by default and adds the `tox-platform-touch` class.
13
+ This broke a TinyMCE test in Mockup which checks the translated label of the resize handle.
14
+
15
+ Other libraries use the same kind of check to switch between a touch and a desktop UI.
16
+ Our tests are written with a desktop browser in mind.
17
+
18
+ ## Decision
19
+
20
+ The `matchMedia` mock emulates a desktop device with a mouse.
21
+ The queries `(pointer:fine)`, `(any-pointer:fine)`, `(hover:hover)` and `(any-hover:hover)` match.
22
+ Whitespace in the query is ignored, so `(any-pointer: fine)` matches too.
23
+ All other queries still don't match.
24
+
25
+ ## Consequences
26
+
27
+ - Libraries which detect touch devices through pointer or hover media queries render their desktop UI in tests.
28
+ - Queries which don't match before, like `(prefers-reduced-motion: reduce)` or `(min-width: 768px)`, still don't match.
29
+ - Combined queries like `(pointer:fine) and (hover:hover)` don't match.
30
+ The mock does not parse media queries.
31
+ - Tests which relied on the touch UI in jsDOM need to override `window.matchMedia` themselves.
@@ -102,11 +102,21 @@ Range.prototype.getBoundingClientRect = () => {
102
102
  return { x: 0, y: 0, width: 0, height: 0, top: 0, right: 0, bottom: 0, left: 0 };
103
103
  };
104
104
 
105
- // Originally from pat-tinymce.
105
+ // jsDOM does not implement ``matchMedia``. Originally from pat-tinymce.
106
+ // Emulate a desktop device with a mouse: pointer and hover queries for a fine
107
+ // pointer match, all other queries don't. Libraries like TinyMCE treat a device
108
+ // without a fine pointer as a touch device and change their UI accordingly.
109
+ // See: docs/adr/0002-match-media-mock-emulates-desktop.md
110
+ const desktop_media_features = [
111
+ "(pointer:fine)",
112
+ "(any-pointer:fine)",
113
+ "(hover:hover)",
114
+ "(any-hover:hover)",
115
+ ];
106
116
  Object.defineProperty(window, "matchMedia", {
107
117
  writable: true,
108
118
  value: jest.fn().mockImplementation((query) => ({
109
- matches: false,
119
+ matches: desktop_media_features.includes(query.replace(/\s+/g, "")),
110
120
  media: query,
111
121
  onchange: null,
112
122
  addListener: jest.fn(), // Deprecated
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@patternslib/dev",
3
- "version": "4.5.1",
3
+ "version": "4.6.1",
4
4
  "description": "Development base files for working with Patternslib and add-ons.",
5
5
  "license": "MIT",
6
6
  "packageManager": "pnpm@12.23.0",
@@ -36,7 +36,6 @@
36
36
  "node": "^22.18.0 || >=24.11.0"
37
37
  },
38
38
  "scripts": {
39
- "postinstall": "cd $INIT_CWD && make upgrade || true",
40
39
  "test": "jest"
41
40
  },
42
41
  "author": {
@@ -1,3 +1,10 @@
1
+ function stripAttribution(text) {
2
+ return text
3
+ ?.replace(/^[ \t]*(?:Assisted[- ]by|Co-authored-by):[^\r\n]*(?:\r?\n|$)/gim, "")
4
+ .replace(/^(?:[ \t]*\r?\n)+/, "")
5
+ .trimEnd();
6
+ }
7
+
1
8
  // The preset adds the list marker and indents continuation lines.
2
9
  module.exports = function commitPartial(context, commit) {
3
10
  const repoUrl = context.repository
@@ -36,8 +43,8 @@ module.exports = function commitPartial(context, commit) {
36
43
 
37
44
  return [
38
45
  summary,
39
- commit.body,
40
- commit.footer,
46
+ stripAttribution(commit.body),
47
+ stripAttribution(commit.footer),
41
48
  references.length && `closes ${references.join(" ")}`,
42
49
  ]
43
50
  .filter(Boolean)
@@ -0,0 +1,129 @@
1
+ const commitPartial = require("../release-it/conventional-changelog-commit");
2
+
3
+ // Commit objects are shaped like the output of conventional-commits-parser
4
+ // with the conventionalcommits preset, which puts the first trailer-like line
5
+ // and everything after it into `footer`.
6
+ function render(commit, context = {}) {
7
+ return commitPartial(
8
+ { linkReferences: false, ...context },
9
+ { hash: "abc123", shortHash: "abc", subject: "Subject.", ...commit },
10
+ );
11
+ }
12
+
13
+ describe("conventional-changelog-commit", () => {
14
+ it("renders scope, subject and hash.", () => {
15
+ expect(render({ scope: "pat-x" })).toBe("**pat-x:** Subject. abc123");
16
+ });
17
+
18
+ it("renders body and footer as separate paragraphs.", () => {
19
+ expect(render({ body: "Body.", footer: "Ref: ADR 0003" })).toBe(
20
+ "Subject. abc123\n\nBody.\n\nRef: ADR 0003",
21
+ );
22
+ });
23
+
24
+ describe("attribution trailers", () => {
25
+ it("removes an Assisted-by footer.", () => {
26
+ expect(render({ body: "Body.", footer: "Assisted-by: GPT-6" })).toBe(
27
+ "Subject. abc123\n\nBody.",
28
+ );
29
+ });
30
+
31
+ it.each([
32
+ "Assisted-by",
33
+ "Assisted-By",
34
+ "ASSISTED-BY",
35
+ "Assisted by",
36
+ "assisted by",
37
+ ])("removes an '%s' line.", (key) => {
38
+ // The parser does not recognize "Assisted by:" as a footer
39
+ // token, so it ends up in the body.
40
+ expect(render({ body: `Body.\n\n${key}: X`, footer: null })).toBe(
41
+ "Subject. abc123\n\nBody.",
42
+ );
43
+ expect(render({ body: "Body.", footer: `${key}: X` })).toBe(
44
+ "Subject. abc123\n\nBody.",
45
+ );
46
+ });
47
+
48
+ it.each([
49
+ "Co-authored-by",
50
+ "Co-Authored-By",
51
+ "co-authored-by",
52
+ "CO-AUTHORED-BY",
53
+ ])("removes a '%s' line.", (key) => {
54
+ expect(
55
+ render({
56
+ body: "Body.",
57
+ footer: `${key}: Someone <someone@example.com>`,
58
+ }),
59
+ ).toBe("Subject. abc123\n\nBody.");
60
+ });
61
+
62
+ it("keeps lines which only mention attribution words.", () => {
63
+ expect(
64
+ render({ body: "Assisted by the new API.\nCo-authored-by convention." }),
65
+ ).toBe(
66
+ "Subject. abc123\n\nAssisted by the new API.\nCo-authored-by convention.",
67
+ );
68
+ });
69
+
70
+ it("leaves no empty paragraph if only trailers are present.", () => {
71
+ expect(render({ body: "", footer: "Assisted-by: GPT-6" })).toBe(
72
+ "Subject. abc123",
73
+ );
74
+ });
75
+
76
+ it("keeps other footer lines.", () => {
77
+ expect(
78
+ render({
79
+ body: "Body.",
80
+ footer: [
81
+ "Ref: ADR 0003",
82
+ "Signed-off-by: A <a@example.com>",
83
+ "Assisted-by: X",
84
+ "Co-authored-by: Y <y@example.com>",
85
+ ].join("\n"),
86
+ }),
87
+ ).toBe(
88
+ "Subject. abc123\n\nBody.\n\nRef: ADR 0003\nSigned-off-by: A <a@example.com>",
89
+ );
90
+ });
91
+
92
+ it("keeps a BREAKING CHANGE footer.", () => {
93
+ expect(
94
+ render({
95
+ body: "Body.",
96
+ footer: "BREAKING CHANGE: API removed.\n\nAssisted-by: X",
97
+ }),
98
+ ).toBe("Subject. abc123\n\nBody.\n\nBREAKING CHANGE: API removed.");
99
+ });
100
+
101
+ it("keeps paragraphs following a trailer.", () => {
102
+ expect(render({ body: "First.", footer: "Assisted-by: X\n\nSecond." })).toBe(
103
+ "Subject. abc123\n\nFirst.\n\nSecond.",
104
+ );
105
+ });
106
+
107
+ it("handles CRLF line endings.", () => {
108
+ expect(
109
+ render({ body: "Body.", footer: "Assisted-by: X\r\nRef: ADR 0003\r\n" }),
110
+ ).toBe("Subject. abc123\n\nBody.\n\nRef: ADR 0003");
111
+ });
112
+
113
+ it("removes trailers from the body.", () => {
114
+ expect(render({ body: "Body.\nAssisted-by: X", footer: null })).toBe(
115
+ "Subject. abc123\n\nBody.",
116
+ );
117
+ });
118
+ });
119
+
120
+ it("appends issue references.", () => {
121
+ expect(
122
+ render({
123
+ body: "Body.",
124
+ footer: "Assisted-by: X",
125
+ references: [{ issue: "12" }],
126
+ }),
127
+ ).toBe("Subject. abc123\n\nBody.\n\ncloses #12");
128
+ });
129
+ });