paperlint 18.4.1 → 18.6.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.
Files changed (113) hide show
  1. package/CLAUDE.md +6 -2
  2. package/dist/adapters/hotcrp/portal.io.d.ts.map +1 -1
  3. package/dist/adapters/hotcrp/portal.io.js +1 -0
  4. package/dist/adapters/hotcrp/portal.io.js.map +1 -1
  5. package/dist/adapters/hotcrp/response.d.ts.map +1 -1
  6. package/dist/adapters/hotcrp/response.js +15 -0
  7. package/dist/adapters/hotcrp/response.js.map +1 -1
  8. package/dist/adapters/latex/abstract.d.ts +11 -0
  9. package/dist/adapters/latex/abstract.d.ts.map +1 -1
  10. package/dist/adapters/latex/abstract.js +1 -1
  11. package/dist/adapters/latex/abstract.js.map +1 -1
  12. package/dist/adapters/latex/index.d.ts.map +1 -1
  13. package/dist/adapters/latex/index.js +3 -0
  14. package/dist/adapters/latex/index.js.map +1 -1
  15. package/dist/adapters/latex/macros.d.ts +6 -0
  16. package/dist/adapters/latex/macros.d.ts.map +1 -0
  17. package/dist/adapters/latex/macros.js +27 -0
  18. package/dist/adapters/latex/macros.js.map +1 -0
  19. package/dist/adapters/osf/host.io.d.ts +12 -0
  20. package/dist/adapters/osf/host.io.d.ts.map +1 -0
  21. package/dist/adapters/osf/host.io.js +119 -0
  22. package/dist/adapters/osf/host.io.js.map +1 -0
  23. package/dist/adapters/osf/index.d.ts +10 -0
  24. package/dist/adapters/osf/index.d.ts.map +1 -0
  25. package/dist/adapters/osf/index.js +10 -0
  26. package/dist/adapters/osf/index.js.map +1 -0
  27. package/dist/adapters/osf/response.d.ts +11 -0
  28. package/dist/adapters/osf/response.d.ts.map +1 -0
  29. package/dist/adapters/osf/response.js +87 -0
  30. package/dist/adapters/osf/response.js.map +1 -0
  31. package/dist/artifact-upload-rule.d.ts +66 -0
  32. package/dist/artifact-upload-rule.d.ts.map +1 -0
  33. package/dist/artifact-upload-rule.js +151 -0
  34. package/dist/artifact-upload-rule.js.map +1 -0
  35. package/dist/artifact.d.ts +35 -0
  36. package/dist/artifact.d.ts.map +1 -0
  37. package/dist/artifact.js +251 -0
  38. package/dist/artifact.js.map +1 -0
  39. package/dist/cli.d.ts +7 -0
  40. package/dist/cli.d.ts.map +1 -1
  41. package/dist/cli.js +99 -7
  42. package/dist/cli.js.map +1 -1
  43. package/dist/domain/artifact-upload.d.ts +44 -0
  44. package/dist/domain/artifact-upload.d.ts.map +1 -0
  45. package/dist/domain/artifact-upload.js +80 -0
  46. package/dist/domain/artifact-upload.js.map +1 -0
  47. package/dist/domain/submission.d.ts +4 -0
  48. package/dist/domain/submission.d.ts.map +1 -1
  49. package/dist/domain/submission.js.map +1 -1
  50. package/dist/eslint-rules/CLAUDE.md.spec.d.ts.map +1 -1
  51. package/dist/eslint-rules/CLAUDE.md.spec.js +1 -0
  52. package/dist/eslint-rules/CLAUDE.md.spec.js.map +1 -1
  53. package/dist/ports/artifact-host.d.ts +54 -0
  54. package/dist/ports/artifact-host.d.ts.map +1 -0
  55. package/dist/ports/artifact-host.js +2 -0
  56. package/dist/ports/artifact-host.js.map +1 -0
  57. package/dist/ports/latex.d.ts +9 -0
  58. package/dist/ports/latex.d.ts.map +1 -1
  59. package/dist/submission-confirm-hook.d.ts +11 -1
  60. package/dist/submission-confirm-hook.d.ts.map +1 -1
  61. package/dist/submission-confirm-hook.js +83 -21
  62. package/dist/submission-confirm-hook.js.map +1 -1
  63. package/dist/submission.d.ts +19 -2
  64. package/dist/submission.d.ts.map +1 -1
  65. package/dist/submission.js +121 -17
  66. package/dist/submission.js.map +1 -1
  67. package/dist/types.d.ts +6 -0
  68. package/dist/types.d.ts.map +1 -1
  69. package/docs/artifact-upload.md +124 -0
  70. package/docs/optional-rules.md +1 -0
  71. package/docs/osf-artifact.md +4 -1
  72. package/docs/rules/artifact/upload-current.md +85 -0
  73. package/docs/rules.md +1 -0
  74. package/docs/submission.md +19 -4
  75. package/eslint-rules/CLAUDE.md +5 -1
  76. package/eslint-rules/CLAUDE.md.spec.ts +3 -0
  77. package/package.json +1 -1
  78. package/src/adapters/hotcrp/portal.io.ts +1 -0
  79. package/src/adapters/hotcrp/portal.test.ts +43 -2
  80. package/src/adapters/hotcrp/response.ts +21 -0
  81. package/src/adapters/latex/abstract.ts +3 -1
  82. package/src/adapters/latex/index.ts +3 -0
  83. package/src/adapters/latex/macros.test.ts +31 -0
  84. package/src/adapters/latex/macros.ts +43 -0
  85. package/src/adapters/osf/cassette/README.md +20 -0
  86. package/src/adapters/osf/cassette/get-file.json +108 -0
  87. package/src/adapters/osf/cassette/get-listing.json +111 -0
  88. package/src/adapters/osf/cassette/get-missing.json +1 -0
  89. package/src/adapters/osf/cassette/put-new.json +31 -0
  90. package/src/adapters/osf/host.io.ts +156 -0
  91. package/src/adapters/osf/host.test.ts +274 -0
  92. package/src/adapters/osf/index.ts +14 -0
  93. package/src/adapters/osf/response.ts +105 -0
  94. package/src/artifact-upload-rule.test.ts +213 -0
  95. package/src/artifact-upload-rule.ts +213 -0
  96. package/src/artifact.test.ts +504 -0
  97. package/src/artifact.ts +402 -0
  98. package/src/cli.test.ts +149 -1
  99. package/src/cli.ts +121 -8
  100. package/src/domain/artifact-upload.test.ts +80 -0
  101. package/src/domain/artifact-upload.ts +111 -0
  102. package/src/domain/submission.ts +4 -0
  103. package/src/ports/artifact-host.ts +65 -0
  104. package/src/ports/latex.ts +10 -0
  105. package/src/rule-cases.test.ts +44 -0
  106. package/src/submission-confirm-hook.test.ts +113 -1
  107. package/src/submission-confirm-hook.ts +120 -27
  108. package/src/submission-fields-run.test.ts +1 -0
  109. package/src/submission-prior-reviews.test.ts +9 -1
  110. package/src/submission-show.test.ts +81 -0
  111. package/src/submission-update.test.ts +164 -6
  112. package/src/submission.ts +208 -24
  113. package/src/types.ts +6 -0
@@ -2,7 +2,11 @@
2
2
  import { expect, test } from "vitest";
3
3
  import { memoryFiles } from "./adapters/memory/index.ts";
4
4
  import { err, ok } from "./domain/result.ts";
5
- import { type PortalFailure, type UpdateOutcome } from "./domain/submission.ts";
5
+ import {
6
+ type PortalFailure,
7
+ type SubmissionView,
8
+ type UpdateOutcome,
9
+ } from "./domain/submission.ts";
6
10
  import {
7
11
  PAPER,
8
12
  SITE,
@@ -14,6 +18,10 @@ import {
14
18
  run,
15
19
  NO_ERRORS,
16
20
  facts,
21
+ DEFAULT_TEX,
22
+ ABSTRACT_TEX,
23
+ VIEW,
24
+ WANT,
17
25
  } from "../test/submission-fixtures.ts";
18
26
 
19
27
  test("update: a dry run by default — the paper's PDF sent, nothing saved, exit 0", async () => {
@@ -25,6 +33,7 @@ test("update: a dry run by default — the paper's PDF sent, nothing saved, exit
25
33
  7,
26
34
  {
27
35
  pdf: { name: "paper.pdf", bytes: PDF },
36
+ title: null,
28
37
  abstract: null,
29
38
  submit: false,
30
39
  fields: {},
@@ -35,6 +44,8 @@ test("update: a dry run by default — the paper's PDF sent, nothing saved, exit
35
44
  expect(r.out).toStrictEqual([
36
45
  CHECK("papers/p/paper.pdf", "the call for papers, https://example.org/cfp"),
37
46
  NO_ERRORS,
47
+ NOT_CHECKED,
48
+ NO_ABSTRACT,
38
49
  "dry run — the portal checked the change and kept nothing; --save sends it for real",
39
50
  "HTTP 200",
40
51
  "valid yes",
@@ -64,6 +75,7 @@ test("update --save --submit --abstract --pdf: all of it sent, and said to be sa
64
75
  7,
65
76
  {
66
77
  pdf: { name: "other.pdf", bytes: PDF },
78
+ title: null,
67
79
  abstract: "The abstract.",
68
80
  submit: true,
69
81
  fields: {},
@@ -72,9 +84,11 @@ test("update --save --submit --abstract --pdf: all of it sent, and said to be sa
72
84
  ],
73
85
  ]);
74
86
  // Guards: the PDF that is sent is the one named, and --save is told to check it too.
75
- expect(r.out.slice(0, 3)).toStrictEqual([
87
+ expect(r.out.slice(0, 5)).toStrictEqual([
76
88
  CHECK("other.pdf", "the call for papers, https://example.org/cfp"),
77
89
  NO_ERRORS,
90
+ NOT_CHECKED,
91
+ "abstract sends abs.txt (2 words), from --abstract",
78
92
  "saved",
79
93
  ]);
80
94
  });
@@ -113,7 +127,7 @@ test("update: valid:false, or a non-2xx status, exits 1 with the portal's messag
113
127
  { portal: fakePortal({ update: invalid }) },
114
128
  );
115
129
  expect(r1.code).toBe(1);
116
- expect(r1.out.slice(4)).toStrictEqual([
130
+ expect(r1.out.slice(6)).toStrictEqual([
117
131
  "valid NO",
118
132
  "changes —",
119
133
  `local PDF papers/p/paper.pdf sha2-${HEX}`,
@@ -154,7 +168,7 @@ test("update --save that the portal withheld says so", async () => {
154
168
  { sub: "update", save: true },
155
169
  { portal: fakePortal({ update: withheld }) },
156
170
  );
157
- expect(r.out[2]).toBe("SAVE WITHHELD by the portal — nothing changed");
171
+ expect(r.out[4]).toBe("SAVE WITHHELD by the portal — nothing changed");
158
172
  });
159
173
 
160
174
  test("update: no PDF to send, or no abstract file, is refused before the portal is asked", async () => {
@@ -169,6 +183,14 @@ test("update: no PDF to send, or no abstract file, is refused before the portal
169
183
  expect(r2.errs).toStrictEqual(["--abstract: no file at nope.txt"]);
170
184
  });
171
185
 
186
+ /** `update`'s title line for the made-up paper, which has no paper.tex and no PDF Title. */
187
+ const NOT_CHECKED =
188
+ "title not checked — no \\title in paper.tex, and the PDF names no Title — add \\title{…}, or \\hypersetup{pdftitle={…}}, and rebuild";
189
+
190
+ /** `update`'s abstract line for the made-up paper, which has no paper.tex. */
191
+ const NO_ABSTRACT =
192
+ "abstract not checked — no paper.tex to read the abstract from — give the abstract with --abstract <file>, a plain-text file";
193
+
172
194
  // ── the venue check before a send (paperlint#264) ─────────────────────────────────────
173
195
 
174
196
  /** A paper of kind `short` (6 body pages) at a venue over AIDC, not blind, built 8 body pages long. */
@@ -197,11 +219,13 @@ const LINT_BLOCK = (level: "error" | "warning", text: string): string[] => [
197
219
  test("update over the page limit: the venue rules' findings on that PDF, as lint prints them, before the portal is asked; a dry run still runs", async () => {
198
220
  const r = await run({ sub: "update" }, { files: OVER });
199
221
  expect(r.code).toBe(0);
200
- expect(r.out.slice(1, 7)).toStrictEqual([
222
+ expect(r.out.slice(1, 9)).toStrictEqual([
201
223
  ...LINT_BLOCK(
202
224
  "error",
203
225
  "body pages (up to the references on page 9): 8, over the limit 6 for venue/short — a desk reject; cut the text format/page-limit",
204
226
  ),
227
+ NOT_CHECKED,
228
+ NO_ABSTRACT,
205
229
  "dry run — the portal checked the change and kept nothing; --save sends it for real",
206
230
  ]);
207
231
  expect(r.seen[0]?.calls).toHaveLength(1);
@@ -209,7 +233,7 @@ test("update over the page limit: the venue rules' findings on that PDF, as lint
209
233
 
210
234
  test("update --save over the limit: the same findings, and the send goes ahead — the person decides on them, not the command", async () => {
211
235
  const r = await run({ sub: "update", save: true }, { files: OVER });
212
- expect([r.code, r.errs, r.out[2], r.out[6]]).toStrictEqual([
236
+ expect([r.code, r.errs, r.out[2], r.out[8]]).toStrictEqual([
213
237
  0,
214
238
  [],
215
239
  `${PAPER}/paper.tex`,
@@ -314,3 +338,137 @@ test("porting skips the venue rules, not the freshness: --save with facts about
314
338
  );
315
339
  expect([unbuilt.code, unbuilt.errs]).toStrictEqual([2, [REFUSAL]]);
316
340
  });
341
+
342
+ /** The made-up paper with its source, so `update` has a title and an abstract to compare with the portal's. */
343
+ const titled = (tex: string = DEFAULT_TEX) =>
344
+ files({ extra: { [`${PAPER}/paper.tex`]: tex } });
345
+
346
+ /** The portal holding the paper's own title and abstract, spaced differently. */
347
+ const holding = (more: Partial<SubmissionView> = {}) =>
348
+ fakePortal({
349
+ show: ok({
350
+ ...VIEW,
351
+ title: " Agents That Lie ",
352
+ abstract: `${WANT.abstract.replaceAll(" ", "\n")}\n`,
353
+ ...more,
354
+ }),
355
+ });
356
+
357
+ /** What `update` sends of the made-up paper with nothing else asked. */
358
+ const SENT = (text: { title: string | null; abstract: string | null }) => [
359
+ "update",
360
+ 7,
361
+ {
362
+ pdf: { name: "paper.pdf", bytes: PDF },
363
+ ...text,
364
+ submit: false,
365
+ fields: {},
366
+ },
367
+ { save: false },
368
+ ];
369
+
370
+ test("🔴 update: a \\title and an abstract that differ from the portal's are sent, and said, in the dry run", async () => {
371
+ const r = await run({ sub: "update" }, { files: titled() });
372
+ expect(r.code).toBe(0);
373
+ expect(r.seen[0]?.calls).toStrictEqual([
374
+ ["show", 7],
375
+ SENT({ title: "Agents That Lie", abstract: WANT.abstract }),
376
+ ]);
377
+ expect(r.out.slice(0, 5)).toStrictEqual([
378
+ CHECK("papers/p/paper.pdf", "the call for papers, https://example.org/cfp"),
379
+ NO_ERRORS,
380
+ "title sends «Agents That Lie» — the portal has «A Fake Title»",
381
+ "abstract sends the paper's (17 words) — the portal has another (4 words)",
382
+ "dry run — the portal checked the change and kept nothing; --save sends it for real",
383
+ ]);
384
+ });
385
+
386
+ test("update: a \\title and an abstract the portal already holds are not sent", async () => {
387
+ const r = await run(
388
+ { sub: "update" },
389
+ { files: titled(), portal: holding() },
390
+ );
391
+ expect(r.code).toBe(0);
392
+ expect(r.seen[0]?.calls[1]).toStrictEqual(
393
+ SENT({ title: null, abstract: null }),
394
+ );
395
+ expect(r.out.slice(2, 4)).toStrictEqual([
396
+ "title unchanged — the portal holds «Agents That Lie»",
397
+ "abstract unchanged — the portal holds the paper's (17 words)",
398
+ ]);
399
+ });
400
+
401
+ test("update: a portal with no title and no abstract gets the paper's, said as none", async () => {
402
+ const none = holding({ title: null, abstract: null });
403
+ const r = await run({ sub: "update" }, { files: titled(), portal: none });
404
+ expect(r.out.slice(2, 4)).toStrictEqual([
405
+ "title sends «Agents That Lie» — the portal has none",
406
+ "abstract sends the paper's (17 words) — the portal has none",
407
+ ]);
408
+ });
409
+
410
+ test("update: neither readable — both said, nothing asked of the portal for them, and the PDF still sent", async () => {
411
+ const r = await run({ sub: "update" });
412
+ expect(r.code).toBe(0);
413
+ expect(r.seen[0]?.calls).toStrictEqual([
414
+ SENT({ title: null, abstract: null }),
415
+ ]);
416
+ expect(r.out.slice(2, 4)).toStrictEqual([NOT_CHECKED, NO_ABSTRACT]);
417
+ });
418
+
419
+ test("update: one of the two readable is enough to ask the portal — an abstract with no \\title, a \\title with no abstract", async () => {
420
+ const abstractOnly = `\\documentclass{article}\n\\newcommand{\\ours}{TestLie}\n\\begin{document}\n${ABSTRACT_TEX}\\end{document}\n`;
421
+ const r1 = await run(
422
+ { sub: "update" },
423
+ { files: titled(abstractOnly), portal: holding() },
424
+ );
425
+ expect(r1.seen[0]?.calls).toStrictEqual([
426
+ ["show", 7],
427
+ SENT({ title: null, abstract: null }),
428
+ ]);
429
+ const titleOnly =
430
+ "\\documentclass{article}\n\\title{Agents That Lie}\n\\begin{document}\\end{document}\n";
431
+ const r2 = await run(
432
+ { sub: "update" },
433
+ { files: titled(titleOnly), portal: holding() },
434
+ );
435
+ expect(r2.seen[0]?.calls).toStrictEqual([
436
+ ["show", 7],
437
+ SENT({ title: null, abstract: null }),
438
+ ]);
439
+ expect(r2.out[3]).toBe(
440
+ "abstract not checked — paper.tex has no \\begin{abstract}…\\end{abstract} — give the abstract with --abstract <file>, a plain-text file",
441
+ );
442
+ });
443
+
444
+ test("update --abstract: the file is sent whatever the portal holds, and said", async () => {
445
+ const fs = files({
446
+ extra: {
447
+ [`${PAPER}/paper.tex`]: DEFAULT_TEX,
448
+ "/w/abs.txt": "Two words.\n",
449
+ },
450
+ });
451
+ const r = await run(
452
+ { sub: "update", abstract: "abs.txt" },
453
+ { files: fs, portal: holding() },
454
+ );
455
+ expect(r.seen[0]?.calls[1]).toStrictEqual(
456
+ SENT({ title: null, abstract: "Two words." }),
457
+ );
458
+ expect(r.out[3]).toBe(
459
+ "abstract sends abs.txt (2 words), from --abstract",
460
+ );
461
+ });
462
+
463
+ test("update: the portal refusing the read exits 1 and sends nothing", async () => {
464
+ const refused = fakePortal({
465
+ show: err<PortalFailure>({
466
+ kind: "refused",
467
+ httpStatus: 401,
468
+ messages: [{ message: "Missing credentials", field: null, status: 2 }],
469
+ }),
470
+ });
471
+ const r = await run({ sub: "update" }, { files: titled(), portal: refused });
472
+ expect(r.code).toBe(1);
473
+ expect(r.seen[0]?.calls).toStrictEqual([["show", 7]]);
474
+ });
package/src/submission.ts CHANGED
@@ -8,8 +8,10 @@
8
8
  * adapter per portal kind does the talking (`src/adapters/hotcrp/`).
9
9
  *
10
10
  * show status, id, title, paper type, topics, abstract length, the PDF the portal holds — and
11
- * whether it is the local `paper.pdf`, by sha256
12
- * update send the PDF (and, if asked, an abstract, or "submitted"). A DRY RUN unless `--save`:
11
+ * whether it is the local `paper.pdf`, by sha256; the paper's title, abstract and authors
12
+ * where they differ
13
+ * update send the PDF, the paper's title and abstract each when the portal holds another (or
14
+ * `--abstract`'s file), "submitted" if asked. A DRY RUN unless `--save`:
13
15
  * the portal checks the change and keeps nothing
14
16
  * topics the topics the portal offers, against the ones the venue preset records
15
17
  *
@@ -26,6 +28,7 @@
26
28
  * 🔴 THE TOKEN IS AN INPUT, AND ONLY AN INPUT. It comes from the environment (the root reads it), is
27
29
  * handed to the adapter, and never appears in anything printed here.
28
30
  */
31
+ import { zip } from "remeda";
29
32
  import { venueCycleOf } from "./domain/cycle.ts";
30
33
  import { basename, join, resolve } from "node:path";
31
34
  import { absolutePath } from "./domain/paths.ts";
@@ -164,8 +167,8 @@ export interface SubmissionArgs {
164
167
  /** `--pdf <file>`, relative to `cwd`; null: the paper's own PDF. */
165
168
  readonly pdf: string | null;
166
169
  /**
167
- * `--abstract <file>`, relative to `cwd`; null: `update` leaves the abstract as it is, `new` reads
168
- * it from the build.
170
+ * `--abstract <file>`, relative to `cwd`; null: `new` and `update` read the abstract from the
171
+ * paper's source, and `update` sends it only when the portal holds another.
169
172
  */
170
173
  readonly abstract: string | null;
171
174
  readonly submit: boolean;
@@ -372,19 +375,70 @@ export function deadlineLine(d: InForce): string {
372
375
  return `deadline ${d.what} ${set}${also}`;
373
376
  }
374
377
 
378
+ /** A text the paper sets, said when the portal holds another; nothing when they match or it is unread. */
379
+ const notThePortals = (
380
+ label: string,
381
+ paper: string | null,
382
+ portal: string | null,
383
+ shown: (text: string) => string,
384
+ ): readonly string[] =>
385
+ paper === null || sameText(paper, portal)
386
+ ? []
387
+ : [
388
+ `${label} ${shown(paper)} — NOT the portal's; \`paperlint submission update\` sends it`,
389
+ ];
390
+
391
+ const words = (text: string): string => `${String(wordCount(text))} words`;
392
+
393
+ const authorText = (a: Author): string =>
394
+ `${a.name} <${a.email}>${a.affiliation === null ? "" : `, ${a.affiliation}`}`;
395
+
396
+ /** One author on both sides: the email in any case, the name in any spacing, the affiliation. Pure. */
397
+ const sameAuthor = ([a, b]: readonly [Author, Author]): boolean =>
398
+ a.email.toLowerCase() === b.email.toLowerCase() &&
399
+ sameText(a.name, b.name) &&
400
+ (a.affiliation ?? "") === (b.affiliation ?? "");
401
+
402
+ /**
403
+ * The paper's authors (`paperlint.json`) said when the portal records others; nothing when either
404
+ * side names none. `update` never changes them: that is the site's, and the line says so. Pure.
405
+ */
406
+ function authorsLines(
407
+ paper: readonly Author[] | null,
408
+ portal: readonly Author[] | null,
409
+ ): readonly string[] {
410
+ if (paper === null || portal === null) return [];
411
+ const same =
412
+ paper.length === portal.length && zip(paper, portal).every(sameAuthor);
413
+ return same
414
+ ? []
415
+ : [
416
+ `paper authors ${paper.map(authorText).join("; ")} — NOT the portal's (${portal.map(authorText).join("; ")}); \`paperlint submission update\` does not change the authors: change them on the site`,
417
+ ];
418
+ }
419
+
375
420
  /** `show`'s report. Pure. */
376
421
  export function showLines(
377
422
  t: SubmissionTarget,
378
423
  view: SubmissionView,
379
- local: { readonly shown: string; readonly sha256: Sha256 | null },
424
+ local: {
425
+ readonly shown: string;
426
+ readonly sha256: Sha256 | null;
427
+ /** The paper's own title and abstract; null when paperlint cannot read one. */
428
+ readonly title: string | null;
429
+ readonly abstract: string | null;
430
+ },
380
431
  ): readonly string[] {
381
432
  return [
382
433
  `submission ${String(view.id)} on ${t.portal.url} (${t.portal.kind})`,
383
434
  `status ${view.status}${view.submittedAt === null ? "" : `, submitted ${iso(view.submittedAt)}`}`,
384
435
  `title ${view.title ?? "—"}`,
436
+ ...notThePortals("paper title ", local.title, view.title, (x) => x),
385
437
  `paper type ${view.paperType ?? "—"}`,
386
438
  `topics ${view.topics.length ? view.topics.join("; ") : "—"}`,
387
- `abstract ${view.abstract === null ? "—" : `${String(wordCount(view.abstract))} words`}`,
439
+ `abstract ${view.abstract === null ? "—" : words(view.abstract)}`,
440
+ ...notThePortals("paper abstract", local.abstract, view.abstract, words),
441
+ ...authorsLines(t.authors, view.authors),
388
442
  pdfLine(view),
389
443
  `local PDF ${local.shown} ${local.sha256 === null ? "(missing)" : `sha2-${local.sha256}`}`,
390
444
  matchLine(view, local.sha256),
@@ -489,9 +543,12 @@ async function runShow(
489
543
  const view = await portal.show(t.id);
490
544
  if (!view.ok) return failed(view.error, deps);
491
545
  const bytes = bytesAt(deps.files, pdfPath);
546
+ const text = paperText(t.paperDir, bytes, deps);
492
547
  const local = {
493
548
  shown: shownPath(deps.cwd, pdfPath),
494
549
  sha256: bytes === null ? null : sha256Hex(bytes),
550
+ title: text.title.ok ? text.title.value : null,
551
+ abstract: text.abstract.ok ? text.abstract.value : null,
495
552
  };
496
553
  // With `cycles`, the frozen versions beside the portal's copy: which is under review, which is history.
497
554
  const versions = versionLines(t.paperDir, deps);
@@ -517,15 +574,15 @@ function abstractOf(
517
574
  : ok(new TextDecoder().decode(bytes).trim());
518
575
  }
519
576
 
520
- /** What `update` sends: the PDF's bytes, the abstract's text, whether to mark it submitted, the fields. */
577
+ /** What `update` sends: the PDF's bytes, the title, the abstract's text, whether to mark it submitted, the fields. */
521
578
  const changeOf = (
522
579
  a: SubmissionArgs & { readonly pdfPath: string },
523
580
  bytes: Uint8Array,
524
- abstract: string | null,
581
+ text: { readonly title: string | null; readonly abstract: string | null },
525
582
  fields: FieldValues,
526
583
  ) => ({
527
584
  pdf: { name: basename(a.pdfPath), bytes },
528
- abstract,
585
+ ...text,
529
586
  submit: a.submit,
530
587
  fields,
531
588
  });
@@ -619,7 +676,7 @@ const VENUE_RULES = "venue rules at their default options";
619
676
  const REBUILD_REFUSAL =
620
677
  "refused: no build facts describe this PDF (none, unreadable, or of other bytes), so the venue rules did not see it — rebuild (`paperlint build`), run the dry run again, and read its venue check; nothing was sent";
621
678
 
622
- /** `update`: send the PDF (and the abstract, and "submitted" when asked); a dry run unless saving. */
679
+ /** `update`: send the PDF, a changed title and abstract, and "submitted" when asked; a dry run unless saving. */
623
680
  async function runUpdate(
624
681
  t: SubmissionTarget & { readonly id: number },
625
682
  portal: SubmissionPortal,
@@ -641,8 +698,8 @@ async function runUpdate(
641
698
  if (refused) return 2;
642
699
  const plan = planFor(t, a.save, deps);
643
700
  if (!plan.ok) return (deps.err(plan.error), 2);
644
- const change = changeOf(a, bytes, abstract.value, t.fields);
645
- const r = await portal.update(t.id, change, { save: a.save });
701
+ const sent = { a, bytes, abstract: abstract.value };
702
+ const r = await sendChange(t, portal, sent, deps);
646
703
  if (!r.ok) return failed(r.error, deps);
647
704
  return afterUpdate(t, r.value, sentOf(a, { shown, bytes }, plan.value), deps);
648
705
  }
@@ -654,6 +711,118 @@ const sentOf = (
654
711
  plan: FreezePlan | null,
655
712
  ) => ({ ...file, save: a.save, submit: a.submit, plan });
656
713
 
714
+ /** Two texts that differ only in spacing are one text. Pure. */
715
+ const sameText = (paper: string, portal: string | null): boolean =>
716
+ portal !== null &&
717
+ paper.replace(/\s+/g, " ").trim() === portal.replace(/\s+/g, " ").trim();
718
+
719
+ /** One text `update` may send: the text (null: none), and the line saying what happens to it. */
720
+ interface TextChange {
721
+ readonly send: string | null;
722
+ readonly line: string;
723
+ }
724
+
725
+ /** How a text is named in `update`'s line: its label, the paper's text, and the portal's when it differs. */
726
+ interface Shown {
727
+ readonly label: string;
728
+ readonly paper: (text: string) => string;
729
+ readonly portal: (text: string) => string;
730
+ }
731
+
732
+ const TITLE: Shown = {
733
+ label: "title ",
734
+ paper: (x) => `«${x}»`,
735
+ portal: (x) => `«${x}»`,
736
+ };
737
+
738
+ const ABSTRACT: Shown = {
739
+ label: "abstract ",
740
+ paper: (x) => `the paper's (${words(x)})`,
741
+ portal: (x) => `another (${words(x)})`,
742
+ };
743
+
744
+ /** What `update` does about one text the paper sets: sends it when the portal holds another. Pure. */
745
+ export function textChange(
746
+ shown: Shown,
747
+ paper: Result<string, string>,
748
+ portal: string | null,
749
+ ): TextChange {
750
+ if (!paper.ok)
751
+ return { send: null, line: `${shown.label}not checked — ${paper.error}` };
752
+ return sameText(paper.value, portal)
753
+ ? {
754
+ send: null,
755
+ line: `${shown.label}unchanged — the portal holds ${shown.paper(paper.value)}`,
756
+ }
757
+ : {
758
+ send: paper.value,
759
+ line: `${shown.label}sends ${shown.paper(paper.value)} — the portal has ${portal === null ? "none" : shown.portal(portal)}`,
760
+ };
761
+ }
762
+
763
+ /** What `update` sends: the PDF and its name, `--abstract`'s text (null: the paper's is compared). */
764
+ interface Sent {
765
+ readonly a: SubmissionArgs & { readonly pdfPath: string };
766
+ readonly bytes: Uint8Array;
767
+ readonly abstract: string | null;
768
+ }
769
+
770
+ /** `--abstract`'s text, sent whatever the portal holds, and said. Pure. */
771
+ const fromFile = (sent: Sent, abstract: string): TextChange => ({
772
+ send: abstract,
773
+ line: `${ABSTRACT.label}sends ${String(sent.a.abstract)} (${words(abstract)}), from --abstract`,
774
+ });
775
+
776
+ /**
777
+ * The title and abstract `update` sends: the paper's, each when the portal holds another (#619);
778
+ * `--abstract`'s file whatever it holds. The portal is read once, and only when there is something
779
+ * of the paper's to compare; a failed read stops the update.
780
+ */
781
+ async function textsToSend(
782
+ t: SubmissionTarget & { readonly id: number },
783
+ portal: SubmissionPortal,
784
+ sent: Sent,
785
+ deps: RunDeps,
786
+ ): Promise<
787
+ Result<
788
+ { readonly title: TextChange; readonly abstract: TextChange },
789
+ PortalFailure
790
+ >
791
+ > {
792
+ const text = paperText(t.paperDir, sent.bytes, deps);
793
+ const read = text.title.ok || (sent.abstract === null && text.abstract.ok);
794
+ const view = read ? await portal.show(t.id) : ok(null);
795
+ if (!view.ok) return err(view.error);
796
+ const held = view.value;
797
+ return ok({
798
+ title: textChange(TITLE, text.title, held === null ? null : held.title),
799
+ abstract:
800
+ sent.abstract === null
801
+ ? textChange(
802
+ ABSTRACT,
803
+ text.abstract,
804
+ held === null ? null : held.abstract,
805
+ )
806
+ : fromFile(sent, sent.abstract),
807
+ });
808
+ }
809
+
810
+ /** The change sent, its title and abstract lines printed first: the portal's answer, or why there is none. */
811
+ async function sendChange(
812
+ t: SubmissionTarget & { readonly id: number },
813
+ portal: SubmissionPortal,
814
+ sent: Sent,
815
+ deps: RunDeps,
816
+ ): Promise<Result<UpdateOutcome, PortalFailure>> {
817
+ const texts = await textsToSend(t, portal, sent, deps);
818
+ if (!texts.ok) return err(texts.error);
819
+ const { title, abstract } = texts.value;
820
+ logAll([title.line, abstract.line], deps);
821
+ const text = { title: title.send, abstract: abstract.send };
822
+ const change = changeOf(sent.a, sent.bytes, text, t.fields);
823
+ return portal.update(t.id, change, { save: sent.a.save });
824
+ }
825
+
657
826
  /** The portal's answer to `update` printed, and what it kept frozen: the exit code. */
658
827
  function afterUpdate(
659
828
  t: SubmissionTarget,
@@ -950,6 +1119,30 @@ function assembledPaper(
950
1119
  : readPaper(join(paperDir, MAIN), new TextDecoder().decode(bytes), deps);
951
1120
  }
952
1121
 
1122
+ /**
1123
+ * The paper's title (`titleOf`, falling back on the build's facts about `pdf`, none without one)
1124
+ * and its abstract (`sourceAbstract`): what `new` sends, and what `update` and `show` compare.
1125
+ */
1126
+ function paperText(
1127
+ paperDir: string,
1128
+ pdf: Uint8Array | null,
1129
+ deps: SubmissionDeps,
1130
+ ): {
1131
+ readonly title: Result<string, string>;
1132
+ readonly abstract: Result<string, string>;
1133
+ } {
1134
+ const paper = assembledPaper(paperDir, deps);
1135
+ const facts = pdf === null ? null : factsOfSent(paperDir, pdf, deps);
1136
+ const title = titleOf(
1137
+ paper === null
1138
+ ? null
1139
+ : { text: paper.text, where: (o: number) => placeIn(paper, o) },
1140
+ deps.latex,
1141
+ facts?.text.metadata ?? null,
1142
+ );
1143
+ return { title, abstract: sourceAbstract(paper, deps) };
1144
+ }
1145
+
953
1146
  /** The title and the abstract: the paper's `\title`, and `--abstract`'s file or the source's abstract. */
954
1147
  function titleAndAbstract(
955
1148
  a: SubmissionArgs & { readonly paperDir: string },
@@ -958,20 +1151,11 @@ function titleAndAbstract(
958
1151
  ): Result<{ readonly title: string; readonly abstract: string }, string> {
959
1152
  const own = abstractOf(a, deps);
960
1153
  if (!own.ok) return own;
961
- const paper = assembledPaper(a.paperDir, deps);
962
- const metadata = factsOfSent(a.paperDir, pdf, deps)?.text.metadata ?? null;
963
- const title = titleOf(
964
- paper === null
965
- ? null
966
- : { text: paper.text, where: (o: number) => placeIn(paper, o) },
967
- deps.latex,
968
- metadata,
969
- );
1154
+ const text = paperText(a.paperDir, pdf, deps);
1155
+ const title = text.title;
970
1156
  if (!title.ok) return title;
971
1157
  const abstract =
972
- own.value === null
973
- ? sourceAbstract(paper, deps)
974
- : ok(own.value.replace(/\s+/g, " "));
1158
+ own.value === null ? text.abstract : ok(own.value.replace(/\s+/g, " "));
975
1159
  return abstract.ok
976
1160
  ? ok({ title: title.value, abstract: abstract.value })
977
1161
  : abstract;
package/src/types.ts CHANGED
@@ -74,6 +74,12 @@ export interface Args {
74
74
  submit: boolean;
75
75
  /** `--save` for `submission update`: really change the submission; without it, a dry run. */
76
76
  save: boolean;
77
+ /** `--url`, `--host`, `--to`, `--node`, `--numbers` for `artifact`: where the upload is, and what it holds. */
78
+ url: string | null;
79
+ host: string | null;
80
+ to: string | null;
81
+ node: string | null;
82
+ numbers: string | null;
77
83
  /**
78
84
  * `--allow-venue-name` for `new`: create the folder even though its name names a venue. Skips
79
85
  * that one refusal and no other.