paperlint 10.4.1 → 11.1.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.
- package/.github/workflows/deadlines.yml +27 -7
- package/README.md +16 -15
- package/dist/adapters/hotcrp/index.d.ts +6 -4
- package/dist/adapters/hotcrp/index.d.ts.map +1 -1
- package/dist/adapters/hotcrp/index.js +6 -4
- package/dist/adapters/hotcrp/index.js.map +1 -1
- package/dist/adapters/hotcrp/portal.io.d.ts +3 -1
- package/dist/adapters/hotcrp/portal.io.d.ts.map +1 -1
- package/dist/adapters/hotcrp/portal.io.js +51 -11
- package/dist/adapters/hotcrp/portal.io.js.map +1 -1
- package/dist/adapters/hotcrp/response.d.ts +12 -1
- package/dist/adapters/hotcrp/response.d.ts.map +1 -1
- package/dist/adapters/hotcrp/response.js +52 -3
- package/dist/adapters/hotcrp/response.js.map +1 -1
- package/dist/adapters/hotcrp/site.d.ts +9 -0
- package/dist/adapters/hotcrp/site.d.ts.map +1 -0
- package/dist/adapters/hotcrp/site.js +21 -0
- package/dist/adapters/hotcrp/site.js.map +1 -0
- package/dist/adapters/hotcrp/token.d.ts +13 -0
- package/dist/adapters/hotcrp/token.d.ts.map +1 -0
- package/dist/adapters/hotcrp/token.js +48 -0
- package/dist/adapters/hotcrp/token.js.map +1 -0
- package/dist/adapters/latex/abstract.d.ts +22 -0
- package/dist/adapters/latex/abstract.d.ts.map +1 -0
- package/dist/adapters/latex/abstract.js +187 -0
- package/dist/adapters/latex/abstract.js.map +1 -0
- package/dist/adapters/latex/headings.d.ts +6 -0
- package/dist/adapters/latex/headings.d.ts.map +1 -1
- package/dist/adapters/latex/headings.js +5 -4
- package/dist/adapters/latex/headings.js.map +1 -1
- package/dist/adapters/latex/index.d.ts.map +1 -1
- package/dist/adapters/latex/index.js +2 -0
- package/dist/adapters/latex/index.js.map +1 -1
- package/dist/adapters/latex/parse.d.ts +15 -0
- package/dist/adapters/latex/parse.d.ts.map +1 -1
- package/dist/adapters/latex/parse.js +58 -1
- package/dist/adapters/latex/parse.js.map +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +25 -8
- package/dist/cli.js.map +1 -1
- package/dist/cycle-rules.d.ts.map +1 -1
- package/dist/cycle-rules.js +3 -4
- package/dist/cycle-rules.js.map +1 -1
- package/dist/domain/deadline.d.ts +8 -1
- package/dist/domain/deadline.d.ts.map +1 -1
- package/dist/domain/deadline.js +26 -12
- package/dist/domain/deadline.js.map +1 -1
- package/dist/domain/portal-token.d.ts +44 -0
- package/dist/domain/portal-token.d.ts.map +1 -0
- package/dist/domain/portal-token.js +32 -0
- package/dist/domain/portal-token.js.map +1 -0
- package/dist/domain/submission-fields.d.ts +77 -0
- package/dist/domain/submission-fields.d.ts.map +1 -0
- package/dist/domain/submission-fields.js +127 -0
- package/dist/domain/submission-fields.js.map +1 -0
- package/dist/domain/submission.d.ts +40 -0
- package/dist/domain/submission.d.ts.map +1 -1
- package/dist/domain/submission.js +68 -0
- package/dist/domain/submission.js.map +1 -1
- package/dist/lib/paper-config.d.ts +1 -1
- package/dist/lib/paper-config.d.ts.map +1 -1
- package/dist/lib/paper-config.js +8 -4
- package/dist/lib/paper-config.js.map +1 -1
- package/dist/paper-settings.d.ts +8 -1
- package/dist/paper-settings.d.ts.map +1 -1
- package/dist/paper-settings.js +14 -5
- package/dist/paper-settings.js.map +1 -1
- package/dist/ports/latex.d.ts +23 -0
- package/dist/ports/latex.d.ts.map +1 -1
- package/dist/ports/submission-portal.d.ts +41 -2
- package/dist/ports/submission-portal.d.ts.map +1 -1
- package/dist/ports/venue-deadlines.d.ts +1 -1
- package/dist/presets.d.ts +3 -0
- package/dist/presets.d.ts.map +1 -1
- package/dist/presets.js +3 -1
- package/dist/presets.js.map +1 -1
- package/dist/submission.d.ts +68 -11
- package/dist/submission.d.ts.map +1 -1
- package/dist/submission.js +441 -63
- package/dist/submission.js.map +1 -1
- package/dist/tex-requirements.d.ts +3 -0
- package/dist/tex-requirements.d.ts.map +1 -1
- package/dist/tex-requirements.js +30 -2
- package/dist/tex-requirements.js.map +1 -1
- package/docs/configuration.md +2 -1
- package/docs/rules/cycle/record.md +9 -6
- package/docs/submission.md +73 -51
- package/eslint.config.mjs +3 -0
- package/lib/paper-config.ts +10 -4
- package/package.json +6 -1
- package/presets/msr.jsonc +75 -7
- package/presets/msr.md +14 -10
- package/presets/venue-profile.schema.json +41 -0
- package/scripts/check.ts +1 -1
- package/scripts/refresh-deadlines/compare.test.ts +75 -0
- package/scripts/refresh-deadlines/compare.ts +101 -0
- package/scripts/refresh-deadlines/main.test.ts +140 -0
- package/scripts/refresh-deadlines/main.ts +56 -0
- package/scripts/refresh-deadlines/refresh.test.ts +287 -0
- package/scripts/refresh-deadlines/refresh.ts +183 -0
- package/skills/submission-portal/SKILL.md +92 -45
- package/skills/submission-portal/SKILL.md.spec.ts +94 -44
- package/skills/submission-portal/submission-portal.test.ts +4 -73
- package/src/adapters/hotcrp/cassette/README.md +11 -10
- package/src/adapters/hotcrp/cassette/deadlines-msr2027.html +9 -9
- package/src/adapters/hotcrp/cassette/get-searchcompletion.json +100 -0
- package/src/adapters/hotcrp/deadlines.io.test.ts +2 -2
- package/src/adapters/hotcrp/deadlines.test.ts +3 -3
- package/src/adapters/hotcrp/index.ts +16 -3
- package/src/adapters/hotcrp/portal.io.ts +81 -17
- package/src/adapters/hotcrp/portal.test.ts +208 -3
- package/src/adapters/hotcrp/response.ts +66 -4
- package/src/adapters/hotcrp/site.ts +33 -0
- package/src/adapters/hotcrp/token.test.ts +69 -0
- package/src/adapters/hotcrp/token.ts +51 -0
- package/src/adapters/latex/abstract.test.ts +280 -0
- package/src/adapters/latex/abstract.ts +272 -0
- package/src/adapters/latex/headings.ts +5 -4
- package/src/adapters/latex/index.test.ts +31 -1
- package/src/adapters/latex/index.ts +2 -0
- package/src/adapters/latex/parse.ts +64 -3
- package/src/cli.test.ts +20 -8
- package/src/cli.ts +27 -13
- package/src/cycle-rules.test.ts +6 -6
- package/src/cycle-rules.ts +7 -4
- package/src/domain/deadline.test.ts +31 -2
- package/src/domain/deadline.ts +42 -16
- package/src/domain/portal-token.test.ts +55 -0
- package/src/domain/portal-token.ts +63 -0
- package/src/domain/submission-fields.test.ts +183 -0
- package/src/domain/submission-fields.ts +190 -0
- package/src/domain/submission.test.ts +88 -0
- package/src/domain/submission.ts +110 -0
- package/src/new-paper.test.ts +2 -0
- package/src/paper-settings.test.ts +26 -0
- package/src/paper-settings.ts +25 -5
- package/src/ports/latex.ts +25 -0
- package/src/ports/submission-portal.ts +46 -1
- package/src/ports/venue-deadlines.ts +1 -1
- package/src/presets.test.ts +8 -5
- package/src/presets.ts +12 -2
- package/src/submission-fields-run.test.ts +247 -0
- package/src/submission-new.test.ts +569 -0
- package/src/submission-show.test.ts +210 -0
- package/src/submission-update.test.ts +166 -0
- package/src/submission.test.ts +140 -518
- package/src/submission.ts +667 -81
- package/src/tex-requirements.test.ts +21 -0
- package/src/tex-requirements.ts +67 -2
- package/scripts/refresh-deadlines.test.ts +0 -431
- package/scripts/refresh-deadlines.ts +0 -387
package/dist/submission.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* `paperlint submission show|update [paper-dir]` — read and change a paper's
|
|
3
|
-
* venue's portal, through the portal's API.
|
|
2
|
+
* `paperlint submission new|show|update|topics [paper-dir]` — create, read and change a paper's
|
|
3
|
+
* submission on the venue's portal, through the portal's API.
|
|
4
4
|
*
|
|
5
5
|
* The command is named by the job, not by the portal: WHERE the submission lives is data. The venue
|
|
6
6
|
* preset declares the portal (`"portal": { "kind": "hotcrp", "url": … }`), the paper's
|
|
@@ -11,53 +11,103 @@
|
|
|
11
11
|
* whether it is the local `paper.pdf`, by sha256
|
|
12
12
|
* update send the PDF (and, if asked, an abstract, or "submitted"). A DRY RUN unless `--save`:
|
|
13
13
|
* the portal checks the change and keeps nothing
|
|
14
|
+
* topics the topics the portal offers, against the ones the venue preset records
|
|
15
|
+
*
|
|
16
|
+
* `new` and `update` also send the paper's `fields` — its answers to the venue's own form fields
|
|
17
|
+
* (topics, PC conflicts, …), checked against the preset's `submission_fields` before anything is
|
|
18
|
+
* sent (`src/domain/submission-fields.ts`). A checkbox field the portal did not take is said, and
|
|
19
|
+
* fails the command: HotCRP keeps an option it does not know as nothing, without an error.
|
|
14
20
|
*
|
|
15
21
|
* 🔴 THE TOKEN IS AN INPUT, AND ONLY AN INPUT. It comes from the environment (the root reads it), is
|
|
16
22
|
* handed to the adapter, and never appears in anything printed here.
|
|
17
23
|
*/
|
|
18
24
|
import { basename, join, resolve } from "node:path";
|
|
19
25
|
import { absolutePath } from "./domain/paths.js";
|
|
26
|
+
import { messageOf } from "./domain/text.js";
|
|
20
27
|
import { err, ok } from "./domain/result.js";
|
|
21
28
|
import { sha256Hex } from "./domain/sha256.js";
|
|
22
|
-
import { supportedPortal, wordCount, } from "./domain/submission.js";
|
|
29
|
+
import { supportedPortal, withSubmissionId, wordCount, } from "./domain/submission.js";
|
|
30
|
+
import { droppedFields, parsePaperFields, } from "./domain/submission-fields.js";
|
|
23
31
|
import { paperPreset, unusablePresetLine, } from "./presets.js";
|
|
24
32
|
import { currentDeadlines } from "./domain/cycle.js";
|
|
25
|
-
import { deadlinesInForce, } from "./domain/deadline.js";
|
|
33
|
+
import { deadlinesInForce, readingText, } from "./domain/deadline.js";
|
|
26
34
|
import { CONFIG_FILE } from "#lib/paper-config";
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
35
|
+
import { hostOf, lookUpToken, } from "./domain/portal-token.js";
|
|
36
|
+
import { LINE_BREAK, OPAQUE, runText } from "./domain/tex-document.js";
|
|
37
|
+
import { factsPath, parseFactsText } from "./facts-file.js";
|
|
38
|
+
import { lineColumn, readPaper } from "./tex-paper.js";
|
|
39
|
+
import { originOf } from "./domain/paper-source.js";
|
|
40
|
+
import { MAIN } from "./build.js";
|
|
41
|
+
/** How to make and set the site's token: the page, the scopes, the variable. Pure. */
|
|
42
|
+
export function tokenSteps(portal, site, variable) {
|
|
43
|
+
const c = site.credentials;
|
|
44
|
+
return [
|
|
45
|
+
` 1. create a token on this site: ${c.page} (${c.where}), with the scopes ${c.scopes}`,
|
|
46
|
+
` 2. set it in your environment — never paste it into a chat: export ${variable}=<the token>`,
|
|
47
|
+
` tokens are per ${portal.kind} site: ${variable} is read for ${hostOf(portal.url)} alone, so two venues take two variables`,
|
|
48
|
+
];
|
|
49
|
+
}
|
|
50
|
+
/** Why there is no token, as the complete instruction the author follows. Pure. */
|
|
51
|
+
export function tokenProblemLines(portal, site, p) {
|
|
52
|
+
const head = p.kind === "missing"
|
|
53
|
+
? `no ${portal.kind} token for ${portal.url}: ${p.variable} is not set`
|
|
54
|
+
: `${p.siteLess} is no longer read: tokens are per ${portal.kind} site. If it was made on ${hostOf(portal.url)}, rename it to ${p.variable}; if it was made on another site, rename it to that site's variable (${site.variablePattern}) and create a token here:`;
|
|
55
|
+
return [head, ...tokenSteps(portal, site, p.variable)];
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* What to do when the portal turned the token away: 401 is "this site does not know the token", 403
|
|
59
|
+
* a token without the scope — both answered with the site's token page. Empty for anything else. Pure.
|
|
60
|
+
*/
|
|
61
|
+
export function tokenRefusedLines(portal, site, f) {
|
|
62
|
+
if (f.kind !== "refused" || (f.httpStatus !== 401 && f.httpStatus !== 403))
|
|
63
|
+
return [];
|
|
64
|
+
const variable = site.tokenVariable;
|
|
65
|
+
const why = f.httpStatus === 401
|
|
66
|
+
? `${variable} was used; it may belong to another ${portal.kind} site (tokens are per site), or be revoked or expired`
|
|
67
|
+
: `${variable} was used; the site turned the request away — the token may lack a scope this subcommand needs`;
|
|
68
|
+
return [why, ...tokenSteps(portal, site, variable)];
|
|
69
|
+
}
|
|
70
|
+
export const SUBCOMMANDS = ["new", "show", "update", "topics"];
|
|
36
71
|
const isSubcommand = (s) => SUBCOMMANDS.some((x) => x === s);
|
|
37
72
|
const configOf = (dir) => join(dir, CONFIG_FILE);
|
|
38
73
|
/** Why a paper without a venue preset has no portal: the key to set, or — with cycles — where. */
|
|
39
74
|
const noPresetLine = (paperDir, settings) => settings === null || settings.cycles === null
|
|
40
75
|
? `${configOf(paperDir)}: no "extends" — the venue preset it names declares the portal ("portal": { "kind": …, "url": … })`
|
|
41
76
|
: `${configOf(paperDir)}: the current cycle names no venue preset, and the preset is what declares the portal — set the venue in the current cycle ("venue": { "kind": "preset", "extends": "paperlint:…" }), or upload by hand`;
|
|
77
|
+
/** The paper's `fields`, checked against its venue preset's form, or the line naming what is wrong. */
|
|
78
|
+
function fieldsOf(paperDir, p) {
|
|
79
|
+
const fields = parsePaperFields(p.settings.fields, p.preset.submissionFields, p.preset.chain.join(", "));
|
|
80
|
+
return fields.ok ? fields : err(`${configOf(paperDir)}: ${fields.error}`);
|
|
81
|
+
}
|
|
82
|
+
/** The venue preset's portal, if it declares one that paperlint can talk to; else the line to act on. */
|
|
83
|
+
function portalOfPreset(p) {
|
|
84
|
+
const declared = p.preset.portal;
|
|
85
|
+
return declared === null
|
|
86
|
+
? err(`the venue preset declares no "portal" (read: ${p.preset.chain.join(", ")}) — add "portal": { "kind": "hotcrp", "url": "<the site>" } to the venue's preset, or upload by hand`)
|
|
87
|
+
: supportedPortal(declared);
|
|
88
|
+
}
|
|
42
89
|
/** A resolved paper → its portal and submission, or the line naming the file and key to set. */
|
|
43
90
|
function targetOf(paperDir, p) {
|
|
44
|
-
const
|
|
45
|
-
if (declared === null)
|
|
46
|
-
return err(`the venue preset declares no "portal" (read: ${p.preset.chain.join(", ")}) — add "portal": { "kind": "hotcrp", "url": "<the site>" } to the venue's preset, or upload by hand`);
|
|
47
|
-
const sub = p.settings.submission;
|
|
48
|
-
if (sub === null)
|
|
49
|
-
return err(`${configOf(paperDir)}: no "submission" — add "submission": { "id": <the submission number on ${declared.url}> }`);
|
|
50
|
-
const portal = supportedPortal(declared);
|
|
91
|
+
const portal = portalOfPreset(p);
|
|
51
92
|
if (!portal.ok)
|
|
52
93
|
return portal;
|
|
53
|
-
const pdf = join(paperDir, p.settings.pdf ?? "paper.pdf");
|
|
54
94
|
const identity = p.preset.identity;
|
|
55
|
-
const call = identity.type === "venue" ? identity.url : null;
|
|
56
95
|
const own = p.settings.cycles === null
|
|
57
96
|
? []
|
|
58
97
|
: currentDeadlines(p.settings.cycles.current);
|
|
59
|
-
|
|
60
|
-
|
|
98
|
+
return ok({
|
|
99
|
+
portal: portal.value,
|
|
100
|
+
id: p.settings.submission?.id ?? null,
|
|
101
|
+
config: configOf(paperDir),
|
|
102
|
+
authors: p.settings.authors,
|
|
103
|
+
answers: fieldsOf(paperDir, p),
|
|
104
|
+
fields: {},
|
|
105
|
+
venueFields: p.preset.submissionFields,
|
|
106
|
+
accepted: p.settings.cycles?.current.kind === "accepted",
|
|
107
|
+
pdf: join(paperDir, p.settings.pdf ?? "paper.pdf"),
|
|
108
|
+
call: identity.type === "venue" ? identity.url : null,
|
|
109
|
+
deadlines: deadlinesInForce(own, p.preset.deadlines),
|
|
110
|
+
});
|
|
61
111
|
}
|
|
62
112
|
/** The paper directory → its portal and submission, or the line naming the file and key to set. */
|
|
63
113
|
export function submissionTarget(paperDir, deps) {
|
|
@@ -72,14 +122,6 @@ export function submissionTarget(paperDir, deps) {
|
|
|
72
122
|
return targetOf(paperDir, p);
|
|
73
123
|
}
|
|
74
124
|
}
|
|
75
|
-
/** The token from the environment, or the line naming the variable and where to get one. */
|
|
76
|
-
export function tokenFor(portal, env) {
|
|
77
|
-
const name = TOKEN_ENV[portal.kind];
|
|
78
|
-
const v = env(name)?.trim();
|
|
79
|
-
return v
|
|
80
|
-
? ok(v)
|
|
81
|
-
: err(`${name} is not set — the ${portal.kind} API needs a token: ${TOKEN_HELP[portal.kind]}. Then: export ${name}=…`);
|
|
82
|
-
}
|
|
83
125
|
const iso = (seconds) => seconds === null ? "—" : new Date(seconds * 1000).toISOString();
|
|
84
126
|
const messageLine = (m) => ` portal says: ${m.field === null ? "" : `${m.field}: `}${m.message}`;
|
|
85
127
|
/** A failure in words: HTTP status and the portal's own messages. Never the token. */
|
|
@@ -110,18 +152,17 @@ function matchLine(view, local) {
|
|
|
110
152
|
const pdfLine = (view) => view.pdf === null
|
|
111
153
|
? "portal PDF none"
|
|
112
154
|
: `portal PDF ${view.pdf.hash}, ${view.pdf.size === null ? "?" : String(view.pdf.size)} bytes, uploaded ${iso(view.pdf.uploadedAt)}`;
|
|
113
|
-
const readingText = (o) => `${o.source} ${o.at}, read ${o.read}`;
|
|
114
155
|
/** One deadline in force, what set it, and the other readings of it. Pure. */
|
|
115
156
|
export function deadlineLine(d) {
|
|
116
157
|
const by = d.by;
|
|
117
|
-
const
|
|
118
|
-
?
|
|
119
|
-
:
|
|
158
|
+
const set = by.kind === "override"
|
|
159
|
+
? `${d.at} — override: ${by.override.reason} (${by.override.evidence})`
|
|
160
|
+
: readingText(by.reading);
|
|
120
161
|
const others = d.readings.filter((r) => by.kind === "override" || r !== by.reading);
|
|
121
162
|
const also = others.length
|
|
122
163
|
? `; also ${others.map(readingText).join("; ")}`
|
|
123
164
|
: "";
|
|
124
|
-
return `deadline ${d.what} ${
|
|
165
|
+
return `deadline ${d.what} ${set}${also}`;
|
|
125
166
|
}
|
|
126
167
|
/** `show`'s report. Pure. */
|
|
127
168
|
export function showLines(t, view, local) {
|
|
@@ -145,6 +186,16 @@ export function showLines(t, view, local) {
|
|
|
145
186
|
* counts. Pure.
|
|
146
187
|
*/
|
|
147
188
|
export const checkPdfLine = (shown, call) => `before you rely on it, open ${shown} yourself and check it against ${call === null ? "the venue's call for papers" : `the call for papers, ${call}`}: the page count and what counts toward the limit, the template and its class options, anonymity, and that every figure, table and reference renders — paperlint passing is not the venue accepting the format`;
|
|
189
|
+
/** The fields the paper sent, one line each, as the portal will get them. Pure. */
|
|
190
|
+
export const fieldLines = (fields) => Object.entries(fields).map(([key, value]) => `field ${key}: ${JSON.stringify(value)}`);
|
|
191
|
+
/** The checkbox fields the portal did not take, said; none when it took them all. Pure. */
|
|
192
|
+
export function droppedLines(fields, venue, o) {
|
|
193
|
+
const dropped = droppedFields(fields, venue, {
|
|
194
|
+
changes: o.changes,
|
|
195
|
+
messageFields: o.messages.map((m) => m.field),
|
|
196
|
+
});
|
|
197
|
+
return dropped.map((key) => `NOT TAKEN ${key}: the portal kept none of ${JSON.stringify(fields[key])} — an option it does not know is dropped without an error; \`paperlint submission topics\` lists what it offers`);
|
|
198
|
+
}
|
|
148
199
|
/** `update`'s report. Pure. */
|
|
149
200
|
export function updateLines(o, local, save) {
|
|
150
201
|
const mode = save
|
|
@@ -164,11 +215,27 @@ export function updateLines(o, local, save) {
|
|
|
164
215
|
const shownPath = (cwd, p) => p.startsWith(`${cwd}/`) ? p.slice(cwd.length + 1) : p;
|
|
165
216
|
/** The file's bytes, or null when there is none. */
|
|
166
217
|
const bytesAt = (files, p) => files.readBytes(absolutePath(p));
|
|
218
|
+
const logAll = (lines, deps) => {
|
|
219
|
+
lines.forEach((l) => {
|
|
220
|
+
deps.log(l);
|
|
221
|
+
});
|
|
222
|
+
};
|
|
223
|
+
/** A failure printed — the portal's words, then what to do about the token if it was the token — exit 1. */
|
|
224
|
+
function failed(f, deps) {
|
|
225
|
+
[failureText(f), ...deps.refused(f)].forEach((l) => {
|
|
226
|
+
deps.err(l);
|
|
227
|
+
});
|
|
228
|
+
return 1;
|
|
229
|
+
}
|
|
230
|
+
/** The submission's id, or the line naming the key to set — `show` and `update` need one. */
|
|
231
|
+
const idOf = (t) => t.id === null
|
|
232
|
+
? err(`${t.config}: no "submission" — add "submission": { "id": <the submission number on ${t.portal.url}> }, or create the submission with \`paperlint submission new\``)
|
|
233
|
+
: ok(t.id);
|
|
167
234
|
/** `show`: read the submission and compare its PDF with the local one. */
|
|
168
235
|
async function runShow(t, portal, pdfPath, deps) {
|
|
169
236
|
const view = await portal.show(t.id);
|
|
170
237
|
if (!view.ok)
|
|
171
|
-
return (
|
|
238
|
+
return failed(view.error, deps);
|
|
172
239
|
const bytes = bytesAt(deps.files, pdfPath);
|
|
173
240
|
const local = {
|
|
174
241
|
shown: shownPath(deps.cwd, pdfPath),
|
|
@@ -189,11 +256,12 @@ function abstractOf(a, deps) {
|
|
|
189
256
|
? err(`--abstract: no file at ${shownPath(deps.cwd, p)}`)
|
|
190
257
|
: ok(new TextDecoder().decode(bytes).trim());
|
|
191
258
|
}
|
|
192
|
-
/** What `update` sends: the PDF's bytes, the abstract's text,
|
|
193
|
-
const changeOf = (a, bytes, abstract) => ({
|
|
259
|
+
/** What `update` sends: the PDF's bytes, the abstract's text, whether to mark it submitted, the fields. */
|
|
260
|
+
const changeOf = (a, bytes, abstract, fields) => ({
|
|
194
261
|
pdf: { name: basename(a.pdfPath), bytes },
|
|
195
262
|
abstract,
|
|
196
263
|
submit: a.submit,
|
|
264
|
+
fields,
|
|
197
265
|
});
|
|
198
266
|
/** `update`: send the PDF (and the abstract, and "submitted" when asked); a dry run unless saving. */
|
|
199
267
|
async function runUpdate(t, portal, a, deps) {
|
|
@@ -205,35 +273,330 @@ async function runUpdate(t, portal, a, deps) {
|
|
|
205
273
|
const abstract = abstractOf(a, deps);
|
|
206
274
|
if (!abstract.ok)
|
|
207
275
|
return (deps.err(abstract.error), 2);
|
|
208
|
-
|
|
209
|
-
const
|
|
210
|
-
|
|
211
|
-
});
|
|
276
|
+
logAll([checkPdfLine(shown, t.call), ...fieldLines(t.fields)], deps);
|
|
277
|
+
const change = changeOf(a, bytes, abstract.value, t.fields);
|
|
278
|
+
const r = await portal.update(t.id, change, { save: a.save });
|
|
212
279
|
if (!r.ok)
|
|
213
|
-
return (
|
|
280
|
+
return failed(r.error, deps);
|
|
214
281
|
const local = { shown, sha256: sha256Hex(bytes) };
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
});
|
|
282
|
+
const dropped = droppedLines(t.fields, t.venueFields, r.value);
|
|
283
|
+
logAll([...updateLines(r.value, local, a.save), ...dropped], deps);
|
|
218
284
|
const fine = r.value.valid && r.value.httpStatus >= 200 && r.value.httpStatus < 300;
|
|
219
|
-
return fine ? 0 : 1;
|
|
285
|
+
return fine && dropped.length === 0 ? 0 : 1;
|
|
286
|
+
}
|
|
287
|
+
// ── new ──────────────────────────────────────────────────────────────────────────────
|
|
288
|
+
/**
|
|
289
|
+
* The metadata of the PDF that is sent, from the build's facts — the title's fallback; null when
|
|
290
|
+
* there are no facts, or they describe another PDF.
|
|
291
|
+
*/
|
|
292
|
+
function pdfMetadata(paperDir, pdf, deps) {
|
|
293
|
+
const bytes = bytesAt(deps.files, factsPath(paperDir));
|
|
294
|
+
const facts = bytes === null ? null : parseFactsText(new TextDecoder().decode(bytes));
|
|
295
|
+
return facts?.ok === true && facts.value.sha === sha256Hex(pdf)
|
|
296
|
+
? facts.value.text.metadata
|
|
297
|
+
: null;
|
|
298
|
+
}
|
|
299
|
+
/** Where an offset of the assembled paper stands in its own file: `file:line:column`. */
|
|
300
|
+
function placeIn(paper, offset) {
|
|
301
|
+
const o = originOf(paper, { start: offset, end: offset });
|
|
302
|
+
return o === null ? MAIN : `${o.file}:${lineColumn(o.source, o.span.start)}`;
|
|
303
|
+
}
|
|
304
|
+
/**
|
|
305
|
+
* The abstract from the paper's source: its `abstract` environment, with the files it includes
|
|
306
|
+
* spliced in as the build recorded them, as plain text — or why it cannot be read without guessing.
|
|
307
|
+
*/
|
|
308
|
+
function sourceAbstract(paper, deps) {
|
|
309
|
+
const instead = "give the abstract with --abstract <file>, a plain-text file";
|
|
310
|
+
if (paper === null)
|
|
311
|
+
return err(`no ${MAIN} to read the abstract from — ${instead}`);
|
|
312
|
+
const r = deps.latex.abstractText(paper.text);
|
|
313
|
+
if (r.ok)
|
|
314
|
+
return r;
|
|
315
|
+
const guess = "paperlint sends no text it would have to guess";
|
|
316
|
+
switch (r.error.kind) {
|
|
317
|
+
case "none":
|
|
318
|
+
return err(`${MAIN} has no \\begin{abstract}…\\end{abstract} — ${instead}`);
|
|
319
|
+
case "unreadable":
|
|
320
|
+
return err(`the abstract, ${placeIn(paper, r.error.at)}: ${r.error.what} — ${guess}; ${instead}`);
|
|
321
|
+
case "redefined":
|
|
322
|
+
return err(`the abstract uses \\${r.error.name}, which the paper defines ${String(r.error.at.length)} times (${r.error.at.map((o) => placeIn(paper, o)).join(", ")}) — which one TeX uses there is not guessed; ${instead}`);
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
/**
|
|
326
|
+
* The title as the paper sets it: its `\title`, as text — or, when the title holds a command
|
|
327
|
+
* paperlint cannot read (a macro of the author's own), the PDF's own Title (`pdftitle`). Pure.
|
|
328
|
+
*/
|
|
329
|
+
export function titleOf(source, latex, metadata) {
|
|
330
|
+
const titles = (source === null ? [] : latex.headings(source.text)).filter((h) => h.command.kind === "title" && h.argument === "title");
|
|
331
|
+
// One \title is read; several are not chosen between — the PDF's own Title stands in, or the fix.
|
|
332
|
+
const [heading] = titles.length === 1 ? titles : [];
|
|
333
|
+
const text = heading === undefined
|
|
334
|
+
? ""
|
|
335
|
+
: runText(heading.title)
|
|
336
|
+
.replaceAll(LINE_BREAK, " ")
|
|
337
|
+
.replace(/\s+/g, " ")
|
|
338
|
+
.trim();
|
|
339
|
+
if (text !== "" && !text.includes(OPAQUE))
|
|
340
|
+
return ok(text);
|
|
341
|
+
const pdfTitle = pdfTitleOf(metadata);
|
|
342
|
+
if (pdfTitle !== "")
|
|
343
|
+
return ok(pdfTitle);
|
|
344
|
+
return err(titles.length > 1
|
|
345
|
+
? `the paper sets \\title ${String(titles.length)} times (${titles.map((h) => source?.where(h.title.segments[0].at)).join(", ")}), and the PDF names no Title — which one to send is not guessed: keep one \\title, or set \\hypersetup{pdftitle={<the title as plain text>}} and rebuild`
|
|
346
|
+
: noReadableTitle(text));
|
|
347
|
+
}
|
|
348
|
+
/** The Info dictionary's Title, else the XMP packet's dc:title (pdf-content.ts keeps both); "" for none. */
|
|
349
|
+
const pdfTitleOf = (metadata) => [metadata?.["Title"], metadata?.["dc:title"]]
|
|
350
|
+
.map((t) => t?.trim() ?? "")
|
|
351
|
+
.find((t) => t !== "") ?? "";
|
|
352
|
+
/** The fix when the one \\title is missing (`text` "") or holds a command paperlint does not read. */
|
|
353
|
+
const noReadableTitle = (text) => text === ""
|
|
354
|
+
? `no \\title in ${MAIN}, and the PDF names no Title — add \\title{…}, or \\hypersetup{pdftitle={…}}, and rebuild`
|
|
355
|
+
: `the \\title in ${MAIN} uses a command paperlint does not read («${text.replaceAll(OPAQUE, "…")}»), and the PDF names no Title — set \\hypersetup{pdftitle={<the title as plain text>}} and rebuild`;
|
|
356
|
+
/** What `new` will send, as the author reads it before saying yes. Pure. */
|
|
357
|
+
export function newLines(p) {
|
|
358
|
+
return [
|
|
359
|
+
`title ${p.title}`,
|
|
360
|
+
...p.authors.map((a, i) => `author ${String(i + 1).padEnd(6)} ${a.name} <${a.email}>${a.affiliation === null ? "" : `, ${a.affiliation}`}`),
|
|
361
|
+
`abstract ${String(wordCount(p.abstract))} words:`,
|
|
362
|
+
` ${p.abstract}`,
|
|
363
|
+
...fieldLines(p.fields),
|
|
364
|
+
];
|
|
365
|
+
}
|
|
366
|
+
/** What is left after `new`: the venue's fields the paper did not answer, what only the site takes, the submit. Pure. */
|
|
367
|
+
export function onTheSiteLines(site, t, id, paperArg) {
|
|
368
|
+
const sent = Object.keys(t.fields);
|
|
369
|
+
const unanswered = Object.keys(t.venueFields?.fields ?? {}).filter((k) => !sent.includes(k));
|
|
370
|
+
return [
|
|
371
|
+
`still to do for ${site.submissionPage(id)} — paperlint sent the title, the abstract, the authors and the PDF${sent.length ? `, and ${sent.join(", ")}` : ""}:`,
|
|
372
|
+
...unanswered.map((k) => ` - answer ${k} in the paper's paperlint.json "fields" (the venue preset records it), then: npx paperlint submission update ${paperArg} (a dry run; --save after your yes)`),
|
|
373
|
+
...site.siteOnly.map((f) => ` - on the site: ${f}`),
|
|
374
|
+
` - then mark it submitted: npx paperlint submission update ${paperArg} --submit (a dry run; --save after your yes)`,
|
|
375
|
+
];
|
|
220
376
|
}
|
|
377
|
+
/** `new`'s report of the portal's answer. Pure. */
|
|
378
|
+
export function createLines(o, save) {
|
|
379
|
+
const mode = save
|
|
380
|
+
? o.id === null
|
|
381
|
+
? "NOTHING CREATED — the portal did not save it"
|
|
382
|
+
: `created submission ${String(o.id)}`
|
|
383
|
+
: "dry run — the portal checked the new submission and kept nothing; --save creates it for real";
|
|
384
|
+
return [
|
|
385
|
+
mode,
|
|
386
|
+
`HTTP ${String(o.httpStatus)}`,
|
|
387
|
+
`valid ${o.valid ? "yes" : "NO"}`,
|
|
388
|
+
`changes ${o.changes.length ? o.changes.join(", ") : "—"}`,
|
|
389
|
+
...o.messages.map(messageLine),
|
|
390
|
+
];
|
|
391
|
+
}
|
|
392
|
+
/** A file's JSON, or why there is none: gone, or not JSON. */
|
|
393
|
+
function jsonAt(files, path) {
|
|
394
|
+
const bytes = bytesAt(files, path);
|
|
395
|
+
if (bytes === null)
|
|
396
|
+
return err("the file is gone");
|
|
397
|
+
try {
|
|
398
|
+
return ok(JSON.parse(new TextDecoder().decode(bytes)));
|
|
399
|
+
}
|
|
400
|
+
catch (e) {
|
|
401
|
+
return err(`not JSON: ${messageOf(e)}`);
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
/** `paperlint.json` with the new id recorded in it, written; or why it was not. */
|
|
405
|
+
function recordId(config, id, deps) {
|
|
406
|
+
const json = jsonAt(deps.files, config);
|
|
407
|
+
if (!json.ok)
|
|
408
|
+
return json;
|
|
409
|
+
const next = withSubmissionId(json.value, id);
|
|
410
|
+
if (!next.ok)
|
|
411
|
+
return next;
|
|
412
|
+
// A write that fails (read-only, disk full) must not lose the id the portal just gave.
|
|
413
|
+
try {
|
|
414
|
+
deps.files.writeAtomic(absolutePath(config), new TextEncoder().encode(`${JSON.stringify(next.value, null, 2)}\n`));
|
|
415
|
+
return ok(null);
|
|
416
|
+
}
|
|
417
|
+
catch (e) {
|
|
418
|
+
return err(messageOf(e));
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
//** Why `new` cannot run for this paper, or the authors it sends: checked before anything is read. */
|
|
422
|
+
function readyForNew(t) {
|
|
423
|
+
if (t.id !== null)
|
|
424
|
+
return err(`${t.config}: the paper already has submission ${String(t.id)} on ${t.portal.url} — \`paperlint submission show\` reads it, \`paperlint submission update\` changes it`);
|
|
425
|
+
if (t.accepted)
|
|
426
|
+
return err(`${t.config}: the current attempt is accepted — a new submission belongs to a new cycle`);
|
|
427
|
+
return t.authors === null
|
|
428
|
+
? err(`${t.config}: no "authors" — add "authors": [{ "name": "…", "email": "…", "affiliation": "…" }], every author in the paper's order, as ${hostOf(t.portal.url)} should record them; paperlint never guesses them`)
|
|
429
|
+
: ok(t.authors);
|
|
430
|
+
}
|
|
431
|
+
/** The paper as the build read it: paper.tex with the files it includes spliced in; null without one. */
|
|
432
|
+
function assembledPaper(paperDir, deps) {
|
|
433
|
+
const bytes = bytesAt(deps.files, join(paperDir, MAIN));
|
|
434
|
+
return bytes === null
|
|
435
|
+
? null
|
|
436
|
+
: readPaper(join(paperDir, MAIN), new TextDecoder().decode(bytes), deps);
|
|
437
|
+
}
|
|
438
|
+
/** The title and the abstract: the paper's `\title`, and `--abstract`'s file or the source's abstract. */
|
|
439
|
+
function titleAndAbstract(a, pdf, deps) {
|
|
440
|
+
const own = abstractOf(a, deps);
|
|
441
|
+
if (!own.ok)
|
|
442
|
+
return own;
|
|
443
|
+
const paper = assembledPaper(a.paperDir, deps);
|
|
444
|
+
const metadata = pdfMetadata(a.paperDir, pdf, deps);
|
|
445
|
+
const title = titleOf(paper === null
|
|
446
|
+
? null
|
|
447
|
+
: { text: paper.text, where: (o) => placeIn(paper, o) }, deps.latex, metadata);
|
|
448
|
+
if (!title.ok)
|
|
449
|
+
return title;
|
|
450
|
+
const abstract = own.value === null
|
|
451
|
+
? sourceAbstract(paper, deps)
|
|
452
|
+
: ok(own.value.replace(/\s+/g, " "));
|
|
453
|
+
return abstract.ok
|
|
454
|
+
? ok({ title: title.value, abstract: abstract.value })
|
|
455
|
+
: abstract;
|
|
456
|
+
}
|
|
457
|
+
/** What `new` sends, or the first line saying what is missing. */
|
|
458
|
+
function newSubmissionOf(t, a, deps) {
|
|
459
|
+
const authors = readyForNew(t);
|
|
460
|
+
if (!authors.ok)
|
|
461
|
+
return authors;
|
|
462
|
+
const shown = shownPath(deps.cwd, a.pdfPath);
|
|
463
|
+
const pdf = bytesAt(deps.files, a.pdfPath);
|
|
464
|
+
if (pdf === null)
|
|
465
|
+
return err(`no PDF at ${shown} — build the paper, or name one with --pdf`);
|
|
466
|
+
const text = titleAndAbstract(a, pdf, deps);
|
|
467
|
+
if (!text.ok)
|
|
468
|
+
return text;
|
|
469
|
+
const paper = {
|
|
470
|
+
...text.value,
|
|
471
|
+
authors: authors.value,
|
|
472
|
+
pdf: { name: basename(a.pdfPath), bytes: pdf },
|
|
473
|
+
fields: t.fields,
|
|
474
|
+
};
|
|
475
|
+
return ok({ paper, shown });
|
|
476
|
+
}
|
|
477
|
+
//** After a save that created one: the id written into `paperlint.json`, and the next command. */
|
|
478
|
+
function recordCreated(t, id, paperArg, deps) {
|
|
479
|
+
const config = shownPath(deps.cwd, t.config);
|
|
480
|
+
const recorded = recordId(t.config, id, deps);
|
|
481
|
+
if (!recorded.ok) {
|
|
482
|
+
deps.err(`submission ${String(id)} was created (${deps.portalSite.submissionPage(id)}), but ${config} was not changed (${recorded.error}) — add "submission": { "id": ${String(id)} } to the current attempt by hand`);
|
|
483
|
+
return 1;
|
|
484
|
+
}
|
|
485
|
+
deps.log(`recorded "submission": { "id": ${String(id)} } in ${config}`);
|
|
486
|
+
deps.log(`next npx paperlint submission show ${paperArg} — it should say "match yes"`);
|
|
487
|
+
return 0;
|
|
488
|
+
}
|
|
489
|
+
/** After a creation the portal took: what is still to do, and the id recorded when it saved one. */
|
|
490
|
+
function afterCreated(t, id, a, deps) {
|
|
491
|
+
const paperArg = a.paperDir === deps.cwd ? "." : shownPath(deps.cwd, a.paperDir);
|
|
492
|
+
logAll(onTheSiteLines(deps.portalSite, t, id, paperArg), deps);
|
|
493
|
+
return id === null ? 0 : recordCreated(t, id, paperArg, deps);
|
|
494
|
+
}
|
|
495
|
+
/**
|
|
496
|
+
* `new`: create the paper's submission — title and abstract from the build, the authors the paper
|
|
497
|
+
* declares, the PDF. A dry run unless `--save`; after a save, the id goes into `paperlint.json`.
|
|
498
|
+
*/
|
|
499
|
+
async function runNew(t, portal, a, deps) {
|
|
500
|
+
const n = newSubmissionOf(t, a, deps);
|
|
501
|
+
if (!n.ok)
|
|
502
|
+
return (deps.err(n.error), 2);
|
|
503
|
+
const { paper, shown } = n.value;
|
|
504
|
+
deps.log(checkPdfLine(shown, t.call));
|
|
505
|
+
logAll(newLines(paper), deps);
|
|
506
|
+
const r = await portal.create(paper, { save: a.save });
|
|
507
|
+
if (!r.ok)
|
|
508
|
+
return failed(r.error, deps);
|
|
509
|
+
const dropped = droppedLines(t.fields, t.venueFields, r.value);
|
|
510
|
+
logAll([...createLines(r.value, a.save), ...dropped], deps);
|
|
511
|
+
const fine = r.value.valid && r.value.httpStatus >= 200 && r.value.httpStatus < 300;
|
|
512
|
+
if (!fine || (a.save && r.value.id === null))
|
|
513
|
+
return 1;
|
|
514
|
+
const recorded = afterCreated(t, r.value.id, a, deps);
|
|
515
|
+
return dropped.length === 0 ? recorded : 1;
|
|
516
|
+
}
|
|
517
|
+
/** The subcommands that run before the paper has a submission id: `new` creates it, `topics` needs none. */
|
|
518
|
+
const NEEDS_NO_ID = ["new", "topics"];
|
|
519
|
+
/** The subcommands that send the paper's answers to the venue's fields. */
|
|
520
|
+
const SENDS_FIELDS = ["new", "update"];
|
|
521
|
+
/**
|
|
522
|
+
* What the subcommand needs before a token is looked up: the submission id (`show`, `update`) and
|
|
523
|
+
* the paper's checked answers (`new`, `update`) — or the line naming what to fix.
|
|
524
|
+
*/
|
|
525
|
+
function readyFor(sub, t) {
|
|
526
|
+
const id = NEEDS_NO_ID.some((s) => s === sub) ? ok(null) : idOf(t);
|
|
527
|
+
if (!id.ok)
|
|
528
|
+
return id;
|
|
529
|
+
const fields = SENDS_FIELDS.some((s) => s === sub) ? t.answers : ok({});
|
|
530
|
+
return fields.ok ? ok({ id: id.value, fields: fields.value }) : fields;
|
|
531
|
+
}
|
|
532
|
+
/** The checkbox field the preset records the portal's topics under: the one named `topics`. */
|
|
533
|
+
const TOPICS = "topics";
|
|
534
|
+
/** `topics`' report: each topic the portal offers against the preset's options, and whether they agree. Pure. */
|
|
535
|
+
export function topicsReport(t, offered) {
|
|
536
|
+
const declared = t.venueFields?.fields[TOPICS];
|
|
537
|
+
const head = `topics on ${t.portal.url}: ${String(offered.length)}`;
|
|
538
|
+
if (t.venueFields === null || declared?.kind !== "checkboxes")
|
|
539
|
+
return {
|
|
540
|
+
lines: [
|
|
541
|
+
head,
|
|
542
|
+
...offered.map((n) => ` ${n}`),
|
|
543
|
+
`the venue preset records no "submission_fields" with "topics" — record these, spelled as listed, before a paper can send any`,
|
|
544
|
+
],
|
|
545
|
+
agrees: false,
|
|
546
|
+
};
|
|
547
|
+
const recorded = declared.options;
|
|
548
|
+
const extra = offered.filter((n) => !recorded.includes(n));
|
|
549
|
+
const missing = recorded.filter((n) => !offered.includes(n));
|
|
550
|
+
return {
|
|
551
|
+
lines: [
|
|
552
|
+
`${head}; the preset records ${String(recorded.length)} (read ${t.venueFields.read})`,
|
|
553
|
+
...offered.map((n) => ` ${recorded.includes(n) ? "✓" : "+ not in the preset:"} ${n}`),
|
|
554
|
+
...missing.map((n) => ` − in the preset, not offered: ${n}`),
|
|
555
|
+
],
|
|
556
|
+
agrees: extra.length === 0 && missing.length === 0,
|
|
557
|
+
};
|
|
558
|
+
}
|
|
559
|
+
/** `topics`: what the portal offers, and whether the preset records the same — exit 1 when not. */
|
|
560
|
+
async function runTopics(t, portal, deps) {
|
|
561
|
+
const r = await portal.options();
|
|
562
|
+
if (!r.ok)
|
|
563
|
+
return failed(r.error, deps);
|
|
564
|
+
const report = topicsReport(t, r.value.topics);
|
|
565
|
+
logAll(report.lines, deps);
|
|
566
|
+
return report.agrees ? 0 : 1;
|
|
567
|
+
}
|
|
568
|
+
//** The flags that change something, as given. */
|
|
569
|
+
const writingFlags = (a) => [
|
|
570
|
+
a.abstract === null ? null : "--abstract",
|
|
571
|
+
a.submit ? "--submit" : null,
|
|
572
|
+
a.save ? "--save" : null,
|
|
573
|
+
].filter((f) => f !== null);
|
|
221
574
|
/** Why the command line cannot be run as asked; null when it can. Pure. */
|
|
222
575
|
export function usageProblem(a) {
|
|
223
576
|
if (!isSubcommand(a.sub))
|
|
224
577
|
return `\`submission\` needs a subcommand: ${SUBCOMMANDS.join(" or ")} — got \`${a.sub ?? ""}\``;
|
|
225
578
|
if (a.extra.length > 0)
|
|
226
579
|
return `\`submission ${a.sub}\` takes one paper folder — got also \`${a.extra.join(" ")}\``;
|
|
227
|
-
const
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
return a.sub === "show" && updateOnly.length > 0
|
|
233
|
-
? `${updateOnly.join(", ")}: only \`submission update\` changes anything; \`show\` reads`
|
|
580
|
+
const writing = writingFlags(a);
|
|
581
|
+
if ((a.sub === "show" || a.sub === "topics") && writing.length > 0)
|
|
582
|
+
return `${writing.join(", ")}: only \`submission new\` and \`submission update\` change anything; \`${a.sub}\` reads`;
|
|
583
|
+
return a.sub === "new" && a.submit
|
|
584
|
+
? "--submit: `submission new` creates the submission; mark it submitted with `submission update --submit` once `show` says the portal holds this build"
|
|
234
585
|
: null;
|
|
235
586
|
}
|
|
236
|
-
/**
|
|
587
|
+
/** The variables a site's token lookup reads. */
|
|
588
|
+
const tokenNames = (site) => ({
|
|
589
|
+
variable: site.tokenVariable,
|
|
590
|
+
siteLess: site.siteLessVariable,
|
|
591
|
+
});
|
|
592
|
+
/** No token to use: the complete instruction, exit 2 — nothing is sent. */
|
|
593
|
+
function tokenMissing(portal, site, p, deps) {
|
|
594
|
+
tokenProblemLines(portal, site, p).forEach((l) => {
|
|
595
|
+
deps.err(l);
|
|
596
|
+
});
|
|
597
|
+
return 2;
|
|
598
|
+
}
|
|
599
|
+
/** `paperlint submission <new|show|update> [paper-dir]` — exit 0, 1 (the portal said no), or 2 (usage). */
|
|
237
600
|
export async function runSubmission(a, deps) {
|
|
238
601
|
const usage = usageProblem(a);
|
|
239
602
|
if (usage !== null)
|
|
@@ -242,13 +605,28 @@ export async function runSubmission(a, deps) {
|
|
|
242
605
|
const t = submissionTarget(paperDir, deps.presets);
|
|
243
606
|
if (!t.ok)
|
|
244
607
|
return (deps.err(t.error), 2);
|
|
245
|
-
const
|
|
246
|
-
if (!
|
|
247
|
-
return (deps.err(
|
|
248
|
-
const
|
|
608
|
+
const ready = readyFor(a.sub, t.value);
|
|
609
|
+
if (!ready.ok)
|
|
610
|
+
return (deps.err(ready.error), 2);
|
|
611
|
+
const site = deps.site(t.value.portal);
|
|
612
|
+
const found = lookUpToken(tokenNames(site), deps.env);
|
|
613
|
+
if (!found.ok)
|
|
614
|
+
return tokenMissing(t.value.portal, site, found.error, deps);
|
|
615
|
+
const portal = site.connect(found.value.token);
|
|
249
616
|
const pdfPath = a.pdf === null ? t.value.pdf : resolve(deps.cwd, a.pdf);
|
|
617
|
+
const withToken = {
|
|
618
|
+
...deps,
|
|
619
|
+
portalSite: site,
|
|
620
|
+
refused: (f) => tokenRefusedLines(t.value.portal, site, f),
|
|
621
|
+
};
|
|
622
|
+
const sending = { ...t.value, fields: ready.value.fields };
|
|
623
|
+
if (a.sub === "topics")
|
|
624
|
+
return runTopics(sending, portal, withToken);
|
|
625
|
+
if (ready.value.id === null)
|
|
626
|
+
return runNew(sending, portal, { ...a, pdfPath, paperDir }, withToken);
|
|
627
|
+
const target = { ...sending, id: ready.value.id };
|
|
250
628
|
return a.sub === "show"
|
|
251
|
-
? runShow(
|
|
252
|
-
: runUpdate(
|
|
629
|
+
? runShow(target, portal, pdfPath, withToken)
|
|
630
|
+
: runUpdate(target, portal, { ...a, pdfPath }, withToken);
|
|
253
631
|
}
|
|
254
632
|
//# sourceMappingURL=submission.js.map
|