ep_stats 0.0.69 → 0.0.71

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.
@@ -16,7 +16,7 @@ jobs:
16
16
  steps:
17
17
  -
18
18
  name: Install libreoffice
19
- uses: awalsh128/cache-apt-pkgs-action@v1.6.1
19
+ uses: awalsh128/cache-apt-pkgs-action@v1.6.3
20
20
  with:
21
21
  packages: libreoffice libreoffice-pdfimport
22
22
  version: 1.0
@@ -26,11 +26,11 @@ jobs:
26
26
  with:
27
27
  repository: ether/etherpad-lite
28
28
  path: etherpad-lite
29
- - uses: actions/setup-node@v6
29
+ - uses: actions/setup-node@v7
30
30
  name: Install Node.js
31
31
  with:
32
32
  node-version: 25
33
- - uses: pnpm/action-setup@v6
33
+ - uses: pnpm/action-setup@v6.1.0
34
34
  name: Install pnpm
35
35
  with:
36
36
  package_json_file: ./etherpad-lite/package.json
@@ -16,11 +16,11 @@ jobs:
16
16
  with:
17
17
  repository: ether/etherpad-lite
18
18
  path: etherpad-lite
19
- - uses: actions/setup-node@v6
19
+ - uses: actions/setup-node@v7
20
20
  name: Install Node.js
21
21
  with:
22
22
  node-version: 25
23
- - uses: pnpm/action-setup@v6
23
+ - uses: pnpm/action-setup@v6.1.0
24
24
  name: Install pnpm
25
25
  with:
26
26
  package_json_file: ./etherpad-lite/package.json
@@ -0,0 +1,39 @@
1
+ name: Lint
2
+
3
+ on:
4
+ workflow_call:
5
+
6
+ jobs:
7
+ lint:
8
+ name: ESLint
9
+ runs-on: ubuntu-latest
10
+ # `eslint .` executes .eslintrc.cjs and every installed ESLint plugin, so
11
+ # don't hand it the caller's contents:write / id-token:write token.
12
+ permissions:
13
+ contents: read
14
+ steps:
15
+ - name: Check out plugin repository
16
+ uses: actions/checkout@v7
17
+ - uses: actions/setup-node@v7
18
+ name: Install Node.js
19
+ with:
20
+ node-version: 25
21
+ - uses: pnpm/action-setup@v6.1.0
22
+ name: Install pnpm
23
+ with:
24
+ version: 10
25
+ run_install: false
26
+ - name: Get pnpm store directory
27
+ shell: bash
28
+ run: echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
29
+ - uses: actions/cache@v6
30
+ name: Setup pnpm cache
31
+ with:
32
+ path: ${{ env.STORE_PATH }}
33
+ key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
34
+ restore-keys: |
35
+ ${{ runner.os }}-pnpm-store-
36
+ - name: Install dependencies
37
+ run: pnpm install --ignore-scripts
38
+ - name: Run ESLint
39
+ run: pnpm run lint
@@ -18,20 +18,24 @@ jobs:
18
18
  contents: write # for the atomic version-bump push (branch + tag)
19
19
  id-token: write # for npm OIDC trusted publishing
20
20
  steps:
21
- - uses: actions/setup-node@v6
21
+ - uses: actions/setup-node@v7
22
22
  with:
23
- # OIDC trusted publishing needs npm >= 11.5.1, which requires
24
- # Node >= 20.17.0. setup-node's `20` resolves to the latest
25
- # 20.x, which satisfies that.
26
- node-version: 25
23
+ # OIDC trusted publishing needs npm >= 11.5.1. Node 24 is an LTS
24
+ # line that every npm 11.x and 12.x supports; Node 25 is not —
25
+ # npm 12 requires ^22.22.2 || ^24.15.0 || >=26.0.0, so on Node 25
26
+ # the upgrade step below died with EBADENGINE and no plugin could
27
+ # publish.
28
+ node-version: 24
27
29
  registry-url: https://registry.npmjs.org/
30
+ # Pinned to a range rather than @latest: the next npm major dropping
31
+ # this Node line would silently break publishing fleet-wide again.
28
32
  - name: Upgrade npm to >=11.5.1 (required for trusted publishing)
29
- run: npm install -g npm@latest
33
+ run: npm install -g npm@^11.5.1
30
34
  - name: Check out Etherpad core
31
35
  uses: actions/checkout@v7
32
36
  with:
33
37
  repository: ether/etherpad-lite
34
- - uses: pnpm/action-setup@v6
38
+ - uses: pnpm/action-setup@v6.1.0
35
39
  name: Install pnpm
36
40
  with:
37
41
  run_install: false
@@ -73,7 +77,7 @@ jobs:
73
77
  # `pnpm version patch` bumps package.json, makes a commit, and creates
74
78
  # a `v<new-version>` tag. Capture the new tag name from package.json
75
79
  # rather than parsing pnpm's output, which has historically varied.
76
- # Bump the patch component directly with Node. pnpm/action-setup@v6
80
+ # Bump the patch component directly with Node. pnpm/action-setup@v6.0.10
77
81
  # sometimes installs pnpm 11 pre-releases even when version: 10.x is
78
82
  # requested (pnpm/action-setup#225); those pre-releases either skip
79
83
  # the git commit/tag or reject --no-git-tag-version as unknown.
@@ -14,6 +14,9 @@ permissions:
14
14
  id-token: write
15
15
 
16
16
  jobs:
17
+ lint:
18
+ uses: ./.github/workflows/lint.yml
19
+ secrets: inherit
17
20
  backend:
18
21
  uses: ./.github/workflows/backend-tests.yml
19
22
  secrets: inherit
@@ -23,6 +26,7 @@ jobs:
23
26
  release:
24
27
  if: ${{ github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main' }}
25
28
  needs:
29
+ - lint
26
30
  - backend
27
31
  - frontend
28
32
  permissions:
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "ep_stats",
3
3
  "description": "See pad Stats in Etherpad",
4
- "version": "0.0.69",
4
+ "version": "0.0.71",
5
5
  "author": {
6
6
  "name": "John McLear",
7
7
  "email": "john@mclear.co.uk",
@@ -28,15 +28,15 @@
28
28
  },
29
29
  "devDependencies": {
30
30
  "eslint": "^8.57.1",
31
- "eslint-config-etherpad": "^4.0.5",
32
- "typescript": "^6.0.3"
31
+ "eslint-config-etherpad": "^5.0.0",
32
+ "typescript": "~6.0.3"
33
33
  },
34
34
  "scripts": {
35
35
  "lint": "eslint .",
36
36
  "lint:fix": "eslint --fix ."
37
37
  },
38
38
  "engines": {
39
- "node": ">=18.0.0"
39
+ "node": ">=22.0.0"
40
40
  },
41
41
  "dependencies": {
42
42
  "ep_plugin_helpers": "^0.6.7"
@@ -0,0 +1,10 @@
1
+ # js-yaml and brace-expansion arrive only as transitive dev dependencies (via
2
+ # eslint and minimatch@3), so `pnpm update` cannot move them. The selectors are
3
+ # scoped to the affected major line: an unbounded range would drag minimatch@3
4
+ # onto brace-expansion 5.x and eslint onto js-yaml 5.x.
5
+ #
6
+ # pnpm 11 no longer reads `pnpm.overrides` from package.json — these must live
7
+ # here or the lockfile and the install disagree (ERR_PNPM_LOCKFILE_CONFIG_MISMATCH).
8
+ overrides:
9
+ js-yaml@^4: '>=4.3.2 <5'
10
+ brace-expansion@^1: '>=1.1.16 <2'
@@ -1,5 +1,16 @@
1
1
  'use strict';
2
2
 
3
+ // Etherpad attributes inserts to this reserved id when no real author made
4
+ // them: the default pad content written on pad creation, HTTP API
5
+ // setText/appendText/setHTML calls without an authorId, server-side imports.
6
+ // It is changeset bookkeeping rather than a contributor — core keeps it out
7
+ // of historicalAuthorData and listAuthorsOfPad — so counting its spans put
8
+ // the whole welcome text under an "Unknown Author" row on every fresh pad.
9
+ // See ether/etherpad#8044.
10
+ const SYSTEM_AUTHOR_ID = 'a.etherpad-system';
11
+ const isSystemAuthorClass =
12
+ (spanClass) => exports.className2Author(spanClass) === SYSTEM_AUTHOR_ID;
13
+
3
14
  // Sub-path import keeps the client bundle clean — the top-level
4
15
  // `ep_plugin_helpers` index pulls in server-only modules.
5
16
  const {padToggle} = require('ep_plugin_helpers/pad-toggle');
@@ -90,6 +101,7 @@ stats.authors = {
90
101
  classes = classes.split(' ');
91
102
  $.each(classes, (k, spanClass) => {
92
103
  if (spanClass.indexOf('author') !== -1) { // if an author class exists on this span
104
+ if (isSystemAuthorClass(spanClass)) return; // nobody wrote it
93
105
  // how many words are in this string?
94
106
  const number = $(line).text().split(' ').length;
95
107
  if (!results[spanClass]) {
@@ -118,6 +130,7 @@ stats.authors = {
118
130
  $.each(classes, (k, spanClass) => {
119
131
  // if an author class exists on this span
120
132
  if (spanClass.indexOf('author') !== -1) {
133
+ if (isSystemAuthorClass(spanClass)) return; // nobody wrote it
121
134
  // how many words are in this string?
122
135
  // const number = $(line).text().split(' ').length;
123
136
  // TODO: Why was this not used?
@@ -146,6 +159,7 @@ stats.authors = {
146
159
  classes = classes.split(' ');
147
160
  $.each(classes, (k, spanClass) => {
148
161
  if (spanClass.indexOf('author') !== -1) { // if an author class exists on this span
162
+ if (isSystemAuthorClass(spanClass)) return; // nobody wrote it
149
163
  if (!line[lineCount]) {
150
164
  line[lineCount] = {};
151
165
  line[lineCount].author = spanClass; // first author!
@@ -179,12 +193,15 @@ stats.authors = {
179
193
  classes = classes.split(' ');
180
194
  const number = $(this).text().length;
181
195
  $.each(classes, (k, spanClass) => {
182
- if (spanClass.indexOf('author') !== -1) { // if an author class exists on this span
183
- results[spanClass] = number;
184
- } else {
185
- if (!results[spanClass]) results[spanClass] = 0;
186
- results[spanClass] += 1;
187
- }
196
+ // Author classes only. Spans routinely carry other classes too
197
+ // (`url`, plus whatever plugins add); the old else branch counted
198
+ // those as if they were authors, so a pad containing a link grew
199
+ // an "Unknown Author" row here.
200
+ if (spanClass.indexOf('author') === -1) return;
201
+ if (isSystemAuthorClass(spanClass)) return; // nobody wrote it
202
+ // Accumulate: an author usually holds several spans, and a plain
203
+ // assignment kept only the last one's length.
204
+ results[spanClass] = (results[spanClass] || 0) + number;
188
205
  });
189
206
  }
190
207
  });
@@ -202,11 +219,15 @@ stats.authors = {
202
219
  classes = classes.split(' ');
203
220
  const number = $(this).text().replace(/\s/g, '').length; // get length without whitespace
204
221
  $.each(classes, (k, spanClass) => {
205
- if (spanClass.indexOf('author') !== -1) { // if an author class exists on this span
206
- results[spanClass] = number;
207
- } else {
208
- results[spanClass] += number;
209
- }
222
+ // Author classes only. Spans routinely carry other classes too
223
+ // (`url`, plus whatever plugins add); the old else branch counted
224
+ // those as if they were authors, so a pad containing a link grew
225
+ // an "Unknown Author" row here.
226
+ if (spanClass.indexOf('author') === -1) return;
227
+ if (isSystemAuthorClass(spanClass)) return; // nobody wrote it
228
+ // Accumulate: an author usually holds several spans, and a plain
229
+ // assignment kept only the last one's length.
230
+ results[spanClass] = (results[spanClass] || 0) + number;
210
231
  });
211
232
  }
212
233
  });
@@ -8,7 +8,7 @@ const cssPath = path.resolve(
8
8
  __dirname, '..', '..', '..', '..', 'static', 'css', 'stats.css');
9
9
 
10
10
  describe(__filename, function () {
11
- it('stats overlay uses a z-index below Etherpad toolbar popups (#10)', function () {
11
+ it('stats overlay uses a z-index below Etherpad toolbar popups (#10)', async function () {
12
12
  // Etherpad's toolbar dropdowns / popups use z-index values in the
13
13
  // 150–500 range (see core pad/toolbar.css and pad/icons.css). The
14
14
  // stats overlay is position:fixed, so without a lower explicit
@@ -1,5 +1,9 @@
1
1
  import {expect, test} from '@playwright/test';
2
- import {getPadBody, goToNewPad} from 'ep_etherpad-lite/tests/frontend-new/helper/padHelper';
2
+ import {
3
+ getPadBody,
4
+ goToNewPad,
5
+ writeToPad,
6
+ } from 'ep_etherpad-lite/tests/frontend-new/helper/padHelper';
3
7
 
4
8
  test.beforeEach(async ({page}) => {
5
9
  await goToNewPad(page);
@@ -10,4 +14,27 @@ test.describe('ep_stats', () => {
10
14
  const padBody = await getPadBody(page);
11
15
  await expect(padBody).toBeVisible();
12
16
  });
17
+
18
+ test('author stats credit your writing to you', async ({page}) => {
19
+ await writeToPad(page, 'MYTEXT');
20
+ await expect(page.locator('#wordsContributed .stats')).toContainText('Me');
21
+ // The default pad text contains a link, whose span carries a `url` class
22
+ // alongside the author class. Character counts must ignore that class
23
+ // rather than book it as a contributor of its own.
24
+ await expect(page.locator('#numberOfCharsIncWS .stats')).toContainText('Me');
25
+ });
26
+
27
+ test('author stats ignore text the system author holds', async ({page}) => {
28
+ // The default pad content is attributed to `a.etherpad-system`; nobody
29
+ // wrote it, and core ships no author record for that id, so every span of
30
+ // the welcome text used to land in an "Unknown Author" row here
31
+ // (ether/etherpad#8044).
32
+ await writeToPad(page, 'MYTEXT');
33
+ // #numberOfCharsExcWS is commented out of templates/stats.html, so the
34
+ // four rendered tables are the ones to check.
35
+ for (const id of ['#wordsContributed', '#linesContributed',
36
+ '#linesAsOnlyContributor', '#numberOfCharsIncWS']) {
37
+ await expect(page.locator(`${id} .stats`)).not.toContainText('Unknown Author');
38
+ }
39
+ });
13
40
  });