ep_who_did_what 11.0.36 → 11.0.38
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/.github/workflows/backend-tests.yml +1 -1
- package/.github/workflows/frontend-tests.yml +1 -1
- package/.github/workflows/lint.yml +39 -0
- package/.github/workflows/npmpublish.yml +10 -6
- package/.github/workflows/test-and-release.yml +4 -0
- package/exportWhoDidWhat.js +11 -1
- package/package.json +5 -5
- package/pnpm-workspace.yaml +10 -0
- package/static/tests/backend/specs/changeset_volume.js +7 -6
- package/static/tests/backend/specs/system_author.js +41 -0
|
@@ -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,15 +18,19 @@ 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@
|
|
21
|
+
- uses: actions/setup-node@v7
|
|
22
22
|
with:
|
|
23
|
-
# OIDC trusted publishing needs npm >= 11.5.1
|
|
24
|
-
#
|
|
25
|
-
#
|
|
26
|
-
|
|
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
|
|
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:
|
|
@@ -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/exportWhoDidWhat.js
CHANGED
|
@@ -5,6 +5,15 @@ const Changeset = require('ep_etherpad-lite/static/js/Changeset');
|
|
|
5
5
|
const padManager = require('ep_etherpad-lite/node/db/PadManager');
|
|
6
6
|
const authorManager = require('ep_etherpad-lite/node/db/AuthorManager');
|
|
7
7
|
|
|
8
|
+
// Etherpad attributes revisions to this reserved id when no real author made
|
|
9
|
+
// them: the default pad content written on pad creation, HTTP API
|
|
10
|
+
// setText/appendText/setHTML calls without an authorId, server-side imports.
|
|
11
|
+
// It has no author record, so those revisions used to fall through to
|
|
12
|
+
// "Anonymous" — indistinguishable from a real user who never set a name.
|
|
13
|
+
// See ether/etherpad#8044.
|
|
14
|
+
const SYSTEM_AUTHOR_ID = 'a.etherpad-system';
|
|
15
|
+
const SYSTEM_AUTHOR_LABEL = 'Etherpad';
|
|
16
|
+
|
|
8
17
|
// Returns the volume of a changeset — i.e. how many characters were inserted
|
|
9
18
|
// plus how many were deleted. The previous implementation used the difference
|
|
10
19
|
// between oldLen and newLen, which incorrectly reported zero when a user
|
|
@@ -68,7 +77,8 @@ exports.whoDidWhat = async (padId, revNum, cb) => {
|
|
|
68
77
|
let color = await authorManager.getAuthorColorId(authors[author]);
|
|
69
78
|
const authorName = await authorManager.getAuthorName(authors[author]);
|
|
70
79
|
authorsObj[authors[author]] = {};
|
|
71
|
-
authorsObj[authors[author]].name =
|
|
80
|
+
authorsObj[authors[author]].name =
|
|
81
|
+
authors[author] === SYSTEM_AUTHOR_ID ? SYSTEM_AUTHOR_LABEL : authorName;
|
|
72
82
|
|
|
73
83
|
if (typeof color === 'string' && color.indexOf('#') !== -1) {
|
|
74
84
|
authorsObj[authors[author]].color = color;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ep_who_did_what",
|
|
3
|
-
"version": "11.0.
|
|
3
|
+
"version": "11.0.38",
|
|
4
4
|
"description": "Who made what changes to a pad? A historical report available in the timeslider",
|
|
5
5
|
"author": "John McLear <john@mclear.co.uk>",
|
|
6
6
|
"contributors": [],
|
|
@@ -10,22 +10,22 @@
|
|
|
10
10
|
},
|
|
11
11
|
"devDependencies": {
|
|
12
12
|
"eslint": "^8.57.1",
|
|
13
|
-
"eslint-config-etherpad": "^
|
|
14
|
-
"typescript": "
|
|
13
|
+
"eslint-config-etherpad": "^5.0.0",
|
|
14
|
+
"typescript": "~6.0.3"
|
|
15
15
|
},
|
|
16
16
|
"scripts": {
|
|
17
17
|
"lint": "eslint .",
|
|
18
18
|
"lint:fix": "eslint --fix ."
|
|
19
19
|
},
|
|
20
20
|
"engines": {
|
|
21
|
-
"node": ">=
|
|
21
|
+
"node": ">=22.0.0"
|
|
22
22
|
},
|
|
23
23
|
"repository": {
|
|
24
24
|
"type": "git",
|
|
25
25
|
"url": "https://github.com/ether/ep_who_did_what.git"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"ep_plugin_helpers": "^0.6.
|
|
28
|
+
"ep_plugin_helpers": "^0.6.8",
|
|
29
29
|
"async": "^3.2.6"
|
|
30
30
|
}
|
|
31
31
|
}
|
|
@@ -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'
|
|
@@ -10,12 +10,12 @@ const buildChangeset = (oldText, newText) => Changeset.makeSplice(
|
|
|
10
10
|
|
|
11
11
|
describe(__filename, function () {
|
|
12
12
|
describe('changesetVolume()', function () {
|
|
13
|
-
it('counts a pure insert', function () {
|
|
13
|
+
it('counts a pure insert', async function () {
|
|
14
14
|
const cs = buildChangeset('', 'hello world');
|
|
15
15
|
assert.equal(exporter.changesetVolume(cs), 11);
|
|
16
16
|
});
|
|
17
17
|
|
|
18
|
-
it('counts a pure delete', function () {
|
|
18
|
+
it('counts a pure delete', async function () {
|
|
19
19
|
const cs = buildChangeset('hello world', '');
|
|
20
20
|
assert.equal(exporter.changesetVolume(cs), 11);
|
|
21
21
|
});
|
|
@@ -23,7 +23,7 @@ describe(__filename, function () {
|
|
|
23
23
|
// Regression for #89: same length REPLACE used to report volume 0
|
|
24
24
|
// because the old impl was `Math.abs(oldLen - newLen)`, which lost
|
|
25
25
|
// every contributor whose edits were corrections rather than appends.
|
|
26
|
-
it('counts a same-length replace (regression for #89)', function () {
|
|
26
|
+
it('counts a same-length replace (regression for #89)', async function () {
|
|
27
27
|
const cs = buildChangeset('hello world', 'world hello');
|
|
28
28
|
// 11 chars deleted + 11 inserted (the diff is a full swap).
|
|
29
29
|
// Old impl returned 0; we just need this to be > 0.
|
|
@@ -31,7 +31,7 @@ describe(__filename, function () {
|
|
|
31
31
|
'same-length replace must report non-zero volume');
|
|
32
32
|
});
|
|
33
33
|
|
|
34
|
-
it('counts a partial replace shorter than original', function () {
|
|
34
|
+
it('counts a partial replace shorter than original', async function () {
|
|
35
35
|
const cs = buildChangeset('hello world', 'hi');
|
|
36
36
|
// 11 deleted, 2 inserted = 13. Old impl reported abs(11-2)=9.
|
|
37
37
|
assert.equal(exporter.changesetVolume(cs), 13);
|
|
@@ -39,10 +39,11 @@ describe(__filename, function () {
|
|
|
39
39
|
});
|
|
40
40
|
|
|
41
41
|
describe('typeOfOp()', function () {
|
|
42
|
-
it('returns + for an insert', function () {
|
|
42
|
+
it('returns + for an insert', async function () {
|
|
43
43
|
assert.equal(exporter.typeOfOp(buildChangeset('', 'hello')), '+');
|
|
44
44
|
});
|
|
45
|
-
|
|
45
|
+
|
|
46
|
+
it('returns - for a delete', async function () {
|
|
46
47
|
assert.equal(exporter.typeOfOp(buildChangeset('hello', '')), '-');
|
|
47
48
|
});
|
|
48
49
|
});
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const assert = require('assert').strict;
|
|
4
|
+
const common = require('ep_etherpad-lite/tests/backend/common');
|
|
5
|
+
const padManager = require('ep_etherpad-lite/node/db/PadManager');
|
|
6
|
+
const randomString = require('ep_etherpad-lite/static/js/pad_utils').randomString;
|
|
7
|
+
const exporter = require('../../../../exportWhoDidWhat');
|
|
8
|
+
|
|
9
|
+
const SYSTEM_AUTHOR_ID = 'a.etherpad-system';
|
|
10
|
+
|
|
11
|
+
const whoDidWhat = async (padId) => await new Promise((resolve, reject) => {
|
|
12
|
+
exporter.whoDidWhat(padId, null, (err, items) => err ? reject(err) : resolve(items));
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
describe(__filename, function () {
|
|
16
|
+
before(async function () {
|
|
17
|
+
await common.init();
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it('labels revisions nobody authored as the system, not as a person',
|
|
21
|
+
async function () {
|
|
22
|
+
// A pad created with text but no authorId attributes the revision to
|
|
23
|
+
// `a.etherpad-system`, which has no author record — the same shape as
|
|
24
|
+
// default pad content and API-written pads (ether/etherpad#8044).
|
|
25
|
+
const padId = `wdw-${randomString(10)}`;
|
|
26
|
+
const pad = await padManager.getPad(padId, 'some content that a machine wrote\n');
|
|
27
|
+
try {
|
|
28
|
+
assert.equal(await pad.getRevisionAuthor(0), SYSTEM_AUTHOR_ID);
|
|
29
|
+
|
|
30
|
+
const items = await whoDidWhat(padId);
|
|
31
|
+
const names = Object.values(items).map((i) => i.authorName);
|
|
32
|
+
assert.ok(names.length > 0, 'the report should not be empty');
|
|
33
|
+
// "Anonymous" is what a real user with no display name gets; machine
|
|
34
|
+
// writes must not be indistinguishable from them.
|
|
35
|
+
assert.deepEqual(names.filter((n) => n === 'Anonymous'), []);
|
|
36
|
+
assert.ok(names.includes('Etherpad'), `got ${JSON.stringify(names)}`);
|
|
37
|
+
} finally {
|
|
38
|
+
await pad.remove();
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
});
|