latex-kit 0.4.1 → 0.5.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "latex-kit",
3
- "version": "0.4.1",
3
+ "version": "0.5.0",
4
4
  "description": "Build typed, reproducible LaTeX documents from the command line",
5
5
  "author": "Constructive <developers@constructive.io>",
6
6
  "main": "index.js",
@@ -44,12 +44,13 @@
44
44
  "latex-kit": "cli.js"
45
45
  },
46
46
  "dependencies": {
47
- "@latex-kit/render": "0.4.0",
48
- "@latex-kit/schema": "0.3.0",
49
- "@latex-kit/template": "0.3.0",
47
+ "@latex-kit/components": "0.2.0",
48
+ "@latex-kit/render": "0.5.0",
49
+ "@latex-kit/schema": "0.4.0",
50
+ "@latex-kit/template": "0.4.0",
50
51
  "inquirerer": "^4.9.5",
51
52
  "minimist": "^1.2.8",
52
53
  "yanse": "^0.2.3"
53
54
  },
54
- "gitHead": "023ede48131a32e9250ec48b0dde17e71c6a1536"
55
+ "gitHead": "b169d7b7a018ec26e5099e021b3529dcf6c006fa"
55
56
  }
@@ -1,4 +1,6 @@
1
1
  import type { ParsedArgs } from 'minimist';
2
+ /** `--only nda-*,invoice-0001`: comma-separated names, * matches anything. */
3
+ export declare function onlyMatcher(only: unknown): ((name: string) => boolean) | null;
2
4
  export declare function buildCommand(argv: Partial<ParsedArgs>): Promise<number>;
3
5
  export declare function checkCommand(argv: Partial<ParsedArgs>): Promise<number>;
4
6
  export declare function fieldsCommand(argv: Partial<ParsedArgs>): Promise<number>;
@@ -6,6 +8,8 @@ export declare function typegenCommand(argv: Partial<ParsedArgs>): Promise<numbe
6
8
  export declare function styCommand(argv: Partial<ParsedArgs>): Promise<number>;
7
9
  export declare function importCommand(argv: Partial<ParsedArgs>): Promise<number>;
8
10
  export declare function diffCommand(argv: Partial<ParsedArgs>): Promise<number>;
11
+ /** Pin the TeX and pandoc images in latex-kit.lock (commit it). */
12
+ export declare function lockCommand(argv: Partial<ParsedArgs>): Promise<number>;
9
13
  export declare function initCommand(argv: Partial<ParsedArgs>): Promise<number>;
10
14
  export declare function newCommand(argv: Partial<ParsedArgs>): Promise<number>;
11
15
  export declare function cleanCommand(argv: Partial<ParsedArgs>): Promise<number>;
@@ -3,6 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.onlyMatcher = onlyMatcher;
6
7
  exports.buildCommand = buildCommand;
7
8
  exports.checkCommand = checkCommand;
8
9
  exports.fieldsCommand = fieldsCommand;
@@ -10,6 +11,7 @@ exports.typegenCommand = typegenCommand;
10
11
  exports.styCommand = styCommand;
11
12
  exports.importCommand = importCommand;
12
13
  exports.diffCommand = diffCommand;
14
+ exports.lockCommand = lockCommand;
13
15
  exports.initCommand = initCommand;
14
16
  exports.newCommand = newCommand;
15
17
  exports.cleanCommand = cleanCommand;
@@ -26,6 +28,7 @@ const check_1 = require("./check");
26
28
  const commands_1 = require("./commands");
27
29
  const diff_1 = require("./diff");
28
30
  const import_1 = require("./import");
31
+ const lock_1 = require("./lock");
29
32
  const project_1 = require("./project");
30
33
  const scaffold_1 = require("./scaffold");
31
34
  function printDiagnostics(ds, json) {
@@ -35,12 +38,35 @@ function printDiagnostics(ds, json) {
35
38
  console.error((d.severity === 'error' ? yanse_1.default.red : yanse_1.default.yellow)((0, template_1.formatDiagnostic)(d)));
36
39
  }
37
40
  const rel = (p) => (p ? (0, path_1.relative)(process.cwd(), p) : null);
41
+ /** `--only nda-*,invoice-0001`: comma-separated names, * matches anything. */
42
+ function onlyMatcher(only) {
43
+ if (only === undefined || only === null || only === '' || only === true)
44
+ return null;
45
+ const patterns = (Array.isArray(only) ? only : [only]).flatMap((o) => String(o).split(',')).map((p) => p.trim()).filter(Boolean);
46
+ if (patterns.length === 0)
47
+ return null;
48
+ const res = patterns.map((p) => new RegExp(`^${p.replace(/[.+?^${}()|[\]\\]/g, '\\$&').replace(/\*/g, '.*')}$`));
49
+ return (name) => res.some((r) => r.test(name));
50
+ }
51
+ function checkLocale(locale) {
52
+ if (locale === undefined)
53
+ return undefined;
54
+ try {
55
+ return Intl.getCanonicalLocales(String(locale))[0];
56
+ }
57
+ catch {
58
+ throw new args_1.UsageError(`--locale ${locale} is not a language tag (like en-US or ja-JP)`);
59
+ }
60
+ }
38
61
  async function buildCommand(argv) {
39
62
  const variant = (argv.variant ?? (argv.final ? 'final' : 'draft'));
40
63
  if (!template_1.VARIANTS.includes(variant))
41
64
  throw new args_1.UsageError(`--variant must be one of ${template_1.VARIANTS.join(', ')}`);
42
- if (argv.engine && !render_1.ENGINES.includes(argv.engine))
43
- throw new args_1.UsageError(`--engine must be one of ${render_1.ENGINES.join(', ')}`);
65
+ if (argv.engine && argv.engine !== 'auto' && !render_1.ENGINES.includes(argv.engine))
66
+ throw new args_1.UsageError(`--engine must be auto or one of ${render_1.ENGINES.join(', ')}`);
67
+ if (argv.signatures !== undefined && variant !== 'signed')
68
+ throw new args_1.UsageError('--signatures only applies to --variant signed');
69
+ const only = onlyMatcher(argv.only);
44
70
  const project = await project_1.Project.open(argv.root);
45
71
  const options = {
46
72
  variant,
@@ -51,13 +77,16 @@ async function buildCommand(argv) {
51
77
  platform: argv.platform,
52
78
  verify: Boolean(argv.verify),
53
79
  texOnly: Boolean(argv['tex-only']),
80
+ locale: checkLocale(argv.locale),
81
+ force: Boolean(argv.force),
82
+ signatures: argv.signatures,
54
83
  };
55
84
  const json = Boolean(argv.json);
56
85
  const log = (s) => !json && console.error(s);
57
86
  const targets = [];
58
87
  const files = (argv._ ?? []).map(String);
59
88
  if (variant === 'blank' && files.length === 0) {
60
- const names = argv.template ? [String(argv.template)] : project.templateNames();
89
+ const names = (argv.template ? [String(argv.template)] : project.templateNames()).filter((n) => !only || only(n));
61
90
  for (const n of names)
62
91
  targets.push({ label: `template ${n}`, run: () => (0, build_1.buildBlank)(project, n, options) });
63
92
  }
@@ -74,13 +103,21 @@ async function buildCommand(argv) {
74
103
  keep.push(f);
75
104
  docs = keep;
76
105
  }
106
+ if (only)
107
+ docs = docs.filter((f) => only(project.documentName(f)));
77
108
  for (const f of docs)
78
109
  targets.push({ label: rel(f), run: () => (0, build_1.buildDocument)(project, f, options) });
79
110
  }
80
111
  if (targets.length === 0) {
112
+ if (only) {
113
+ log(yanse_1.default.red(`--only ${argv.only} matched nothing`));
114
+ return 1;
115
+ }
81
116
  log(yanse_1.default.yellow(`nothing to build (no documents in ${project.rel(project.documentsDir)}/)`));
82
117
  return 0;
83
118
  }
119
+ for (const d of project.codeDiagnostics)
120
+ printDiagnostics([d], json);
84
121
  const results = [];
85
122
  let failed = 0;
86
123
  for (const t of targets) {
@@ -93,7 +130,8 @@ async function buildCommand(argv) {
93
130
  failed++;
94
131
  results.push({ ...r, tex: rel(r.tex), pdf: rel(r.pdf), diagnostics: r.diagnostics.length });
95
132
  if (!json) {
96
- console.log(`${bad ? yanse_1.default.red('✗') : yanse_1.default.green('✓')} ${rel(r.pdf ?? r.tex)}${r.docId ? yanse_1.default.dim(` ${r.docId}`) : ''}`);
133
+ const notes = [r.docId, r.cached ? 'unchanged' : null, r.engine && r.engineReason !== 'chosen' && r.engine !== 'lualatex' ? `${r.engine}, ${r.engineReason?.replace(/^auto: /, '')}` : null].filter(Boolean).join(' ');
134
+ console.log(`${bad ? yanse_1.default.red('✗') : yanse_1.default.green('✓')} ${rel(r.pdf ?? r.tex)}${notes ? yanse_1.default.dim(` ${notes}`) : ''}`);
97
135
  if (r.minted)
98
136
  console.log(yanse_1.default.dim(` minted ${r.docId} and saved it in ${t.label}`));
99
137
  if (r.verified !== undefined)
@@ -150,7 +188,7 @@ async function fieldsCommand(argv) {
150
188
  const width = Math.max(...fields.map((f) => f.absolute.length), 4);
151
189
  for (const f of fields) {
152
190
  const filters = f.filters.length ? yanse_1.default.cyan(` | ${f.filters.join(' | ')}`) : '';
153
- console.log(`${f.absolute.padEnd(width)} ${yanse_1.default.dim(f.kind.padEnd(5))} ${yanse_1.default.dim(`${f.file}:${f.line}`)}${filters}`);
191
+ console.log(`${f.absolute.padEnd(width)} ${yanse_1.default.dim(f.kind.padEnd(9))} ${yanse_1.default.dim(`${f.file}:${f.line}`)}${filters}`);
154
192
  }
155
193
  return diagnostics.some((d) => d.severity === 'error') ? 1 : 0;
156
194
  }
@@ -237,9 +275,37 @@ async function diffCommand(argv) {
237
275
  console.log(`${yanse_1.default.green('✓')} ${rel(result.pdf)} ${yanse_1.default.dim('(insertions underlined in blue, deletions struck through in red)')}`);
238
276
  return 0;
239
277
  }
278
+ /** Pin the TeX and pandoc images in latex-kit.lock (commit it). */
279
+ async function lockCommand(argv) {
280
+ const project = await project_1.Project.open(argv.root);
281
+ const pins = (0, lock_1.currentPins)();
282
+ const file = (0, path_1.join)(project.root, lock_1.LOCK_FILE);
283
+ if (argv.check) {
284
+ if (!project.lock) {
285
+ console.log(yanse_1.default.yellow(`no ${lock_1.LOCK_FILE}: builds use this latex-kit's default image`));
286
+ return 1;
287
+ }
288
+ const stale = project.lock.image !== pins.image || project.lock.pandocImage !== pins.pandocImage;
289
+ console.log(stale ? yanse_1.default.yellow(`${rel(file)} pins older images than this latex-kit's defaults; run latex-kit lock to move them (PDF bytes will change)`) : `${yanse_1.default.green('✓')} ${rel(file)} matches this latex-kit`);
290
+ return stale ? 1 : 0;
291
+ }
292
+ const { lock, previous } = (0, lock_1.writeLock)(project.root);
293
+ console.log(`${yanse_1.default.green('✓')} ${rel(file)}`);
294
+ if (previous && previous.image !== lock.image)
295
+ console.log(yanse_1.default.dim(` image ${previous.image}\n → ${lock.image}\n rebuilt PDFs will differ from earlier ones`));
296
+ else if (!previous)
297
+ console.log(yanse_1.default.dim(` image ${lock.image}`));
298
+ else
299
+ console.log(yanse_1.default.dim(' already up to date'));
300
+ return 0;
301
+ }
240
302
  async function initCommand(argv) {
241
303
  const dir = (0, path_1.join)(process.cwd(), argv._?.[0] ? String(argv._[0]) : '.');
242
304
  const r = (0, scaffold_1.initProject)(dir, { paper: Boolean(argv.paper), force: Boolean(argv.force), version: (0, commands_1.version)() });
305
+ if (!argv.paper && !(0, fs_1.existsSync)((0, path_1.join)(dir, lock_1.LOCK_FILE))) {
306
+ (0, lock_1.writeLock)(dir);
307
+ r.written.push((0, path_1.join)(dir, lock_1.LOCK_FILE));
308
+ }
243
309
  for (const f of r.written)
244
310
  console.log(`${yanse_1.default.green('+')} ${rel(f)}`);
245
311
  for (const f of r.skipped)
package/project.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { JsonSchema, TemplateMeta, z } from '@latex-kit/schema';
2
- import { CompiledTemplate, LoadedClause } from '@latex-kit/template';
2
+ import { CompiledTemplate, Component, Diagnostic, LoadedClause } from '@latex-kit/template';
3
3
  import { ResolvedConfig } from './config';
4
+ import { Lock } from './lock';
4
5
  export interface Template {
5
6
  name: string;
6
7
  dir: string;
@@ -15,11 +16,26 @@ export interface Template {
15
16
  export declare class Project {
16
17
  readonly root: string;
17
18
  readonly config: ResolvedConfig;
19
+ /** latex-kit.lock, when the project has one. */
20
+ readonly lock: Lock | null;
18
21
  private templates;
19
22
  private snippets;
20
23
  private clauses;
24
+ /** Clauses written in TypeScript, loaded when the project opens. */
25
+ private codeClauses;
26
+ /** Built-in components, then the project's own (which win). */
27
+ readonly components: Record<string, Component>;
28
+ /** Source files of the project's components, by name. */
29
+ readonly componentFiles: Record<string, string>;
30
+ /** Problems loading components/ and TypeScript clauses. */
31
+ readonly codeDiagnostics: Diagnostic[];
21
32
  private constructor();
22
33
  static open(root?: string): Promise<Project>;
34
+ /** The Docker image to build with: --image, then config, then latex-kit.lock. */
35
+ image(override?: string): string | undefined;
36
+ private loadCode;
37
+ /** Names \\component can use. */
38
+ componentNames(): string[];
23
39
  path(...parts: string[]): string;
24
40
  rel(file: string): string;
25
41
  get templatesDir(): string;
@@ -39,7 +55,7 @@ export declare class Project {
39
55
  * `.tex` is added when the name has no extension. Never outside the project.
40
56
  */
41
57
  loadSnippet: (name: string, from: string) => CompiledTemplate | null;
42
- /** \\clause{id}: `clauses/<id>.tex` from the clause library. */
58
+ /** \\clause{id}: `clauses/<id>.tex` (or `.ts`) from the clause library. */
43
59
  loadClause: (id: string) => LoadedClause | null;
44
60
  /** Absolute paths of every snippet loaded so far. */
45
61
  snippetFiles(): string[];
package/project.js CHANGED
@@ -1,26 +1,110 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Project = void 0;
4
+ const components_1 = require("@latex-kit/components");
4
5
  const schema_1 = require("@latex-kit/schema");
5
6
  const template_1 = require("@latex-kit/template");
6
7
  const fs_1 = require("fs");
7
8
  const path_1 = require("path");
8
9
  const config_1 = require("./config");
10
+ const lock_1 = require("./lock");
11
+ const CODE_EXTENSIONS = ['.ts', '.mts', '.cts', '.js', '.mjs', '.cjs'];
12
+ /** Every code file under `dir`, as [name without extension, absolute path]. */
13
+ function codeFiles(dir) {
14
+ const out = [];
15
+ const walk = (d, prefix) => {
16
+ if (!(0, fs_1.existsSync)(d))
17
+ return;
18
+ for (const name of (0, fs_1.readdirSync)(d).sort()) {
19
+ if (name.startsWith('.') || name.startsWith('_'))
20
+ continue;
21
+ const p = (0, path_1.join)(d, name);
22
+ if ((0, fs_1.statSync)(p).isDirectory())
23
+ walk(p, `${prefix}${name}/`);
24
+ else if (CODE_EXTENSIONS.includes((0, path_1.extname)(name)) && !name.endsWith('.d.ts'))
25
+ out.push([`${prefix}${name.slice(0, -(0, path_1.extname)(name).length)}`, p]);
26
+ }
27
+ };
28
+ walk(dir, '');
29
+ return out;
30
+ }
9
31
  const SCHEMA_FILES = ['schema.ts', 'schema.mts', 'schema.js', 'schema.mjs', 'schema.cjs'];
10
32
  /** A latex-kit project: a folder with templates, data and documents. */
11
33
  class Project {
12
34
  root;
13
35
  config;
36
+ lock;
14
37
  templates = new Map();
15
38
  snippets = new Map();
16
39
  clauses = new Map();
17
- constructor(root, config) {
40
+ /** Clauses written in TypeScript, loaded when the project opens. */
41
+ codeClauses = new Map();
42
+ /** Built-in components, then the project's own (which win). */
43
+ components = { ...components_1.BUILTIN_COMPONENTS };
44
+ /** Source files of the project's components, by name. */
45
+ componentFiles = {};
46
+ /** Problems loading components/ and TypeScript clauses. */
47
+ codeDiagnostics = [];
48
+ constructor(root, config,
49
+ /** latex-kit.lock, when the project has one. */
50
+ lock) {
18
51
  this.root = root;
19
52
  this.config = config;
53
+ this.lock = lock;
20
54
  }
21
55
  static async open(root = process.cwd()) {
22
56
  const abs = (0, path_1.resolve)(root);
23
- return new Project(abs, await (0, config_1.loadConfig)(abs));
57
+ const project = new Project(abs, await (0, config_1.loadConfig)(abs), (0, lock_1.readLock)(abs));
58
+ await project.loadCode();
59
+ return project;
60
+ }
61
+ /** The Docker image to build with: --image, then config, then latex-kit.lock. */
62
+ image(override) {
63
+ return override ?? this.config.image ?? this.lock?.image;
64
+ }
65
+ async loadCode() {
66
+ for (const [name, file] of codeFiles(this.path(this.config.components))) {
67
+ const at = { file: this.rel(file), line: 1, column: 1 };
68
+ this.componentFiles[name] = file;
69
+ try {
70
+ const mod = await (0, schema_1.loadModule)(file);
71
+ const fn = mod.default;
72
+ if (typeof fn !== 'function')
73
+ throw new Error('the default export must be a component function (use defineComponent)');
74
+ this.components[name] = fn;
75
+ }
76
+ catch (e) {
77
+ this.codeDiagnostics.push((0, template_1.diag)('error', `component ${name}: ${e.message}`, at));
78
+ const message = e.message;
79
+ this.components[name] = () => {
80
+ throw new Error(`failed to load: ${message}`);
81
+ };
82
+ }
83
+ }
84
+ for (const [id, file] of codeFiles(this.path(this.config.clauses))) {
85
+ const at = { file: this.rel(file), line: 1, column: 1 };
86
+ try {
87
+ const mod = await (0, schema_1.loadModule)(file);
88
+ const def = mod.default;
89
+ if (!def || typeof def !== 'object' || (typeof def.body !== 'string' && typeof def.render !== 'function')) {
90
+ throw new Error('the default export must be defineClause({ title, version, body | render })');
91
+ }
92
+ this.codeClauses.set(id, {
93
+ id,
94
+ title: def.title,
95
+ version: def.version === undefined ? undefined : String(def.version),
96
+ template: (0, template_1.compileTemplate)(def.body ?? '', this.rel(file)),
97
+ render: def.render,
98
+ });
99
+ }
100
+ catch (e) {
101
+ this.codeDiagnostics.push((0, template_1.diag)('error', `clause ${id}: ${e.message}`, at));
102
+ }
103
+ }
104
+ }
105
+ /** Names \\component can use. */
106
+ componentNames() {
107
+ return Object.keys(this.components).sort();
24
108
  }
25
109
  path(...parts) {
26
110
  return (0, path_1.join)(this.root, ...parts);
@@ -122,7 +206,7 @@ class Project {
122
206
  }
123
207
  return null;
124
208
  };
125
- /** \\clause{id}: `clauses/<id>.tex` from the clause library. */
209
+ /** \\clause{id}: `clauses/<id>.tex` (or `.ts`) from the clause library. */
126
210
  loadClause = (id) => {
127
211
  if (this.clauses.has(id))
128
212
  return this.clauses.get(id);
@@ -132,6 +216,9 @@ class Project {
132
216
  const text = (0, fs_1.readFileSync)(file, 'utf8');
133
217
  loaded = { id, template: (0, template_1.compileTemplate)(text, this.rel(file)), ...(0, template_1.parseClauseHeader)(text) };
134
218
  }
219
+ else if (this.codeClauses.has(id)) {
220
+ loaded = this.codeClauses.get(id);
221
+ }
135
222
  this.clauses.set(id, loaded);
136
223
  return loaded;
137
224
  };
package/render.js CHANGED
@@ -13,6 +13,7 @@ function summary(r) {
13
13
  pdf: (0, path_1.relative)(process.cwd(), r.pdf),
14
14
  sha256: r.sha256,
15
15
  engine: r.engine,
16
+ engineReason: r.engineReason,
16
17
  backend: r.backend,
17
18
  image: r.image,
18
19
  sourceDateEpoch: r.sourceDateEpoch,
@@ -44,8 +45,9 @@ async function renderCommand(argv, prompter) {
44
45
  console.error(s);
45
46
  };
46
47
  try {
47
- log(yanse_1.default.dim(`rendering ${opts.file} with ${opts.engine} (${opts.backend})…`));
48
+ log(yanse_1.default.dim(`rendering ${opts.file} (${opts.backend})…`));
48
49
  const first = await (0, render_1.render)({ ...opts, file: opts.file });
50
+ log(yanse_1.default.dim(` engine ${first.engine}${first.engineReason === 'chosen' ? '' : ` (${first.engineReason})`}`));
49
51
  for (const d of first.diagnostics)
50
52
  log(yanse_1.default.yellow((0, render_1.formatDiagnostic)(d)));
51
53
  if (!first.reproducible) {
@@ -55,7 +57,7 @@ async function renderCommand(argv, prompter) {
55
57
  if (argv.verify) {
56
58
  // same output path: some tools (Ghostscript) hash the path into the PDF ID
57
59
  log(yanse_1.default.dim('rendering again to check the output is byte-identical…'));
58
- const second = await (0, render_1.render)({ ...opts, file: opts.file, sourceDateEpoch: first.sourceDateEpoch });
60
+ const second = await (0, render_1.render)({ ...opts, file: opts.file, engine: first.engine, sourceDateEpoch: first.sourceDateEpoch });
59
61
  verified = second.sha256 === first.sha256;
60
62
  }
61
63
  if (argv.json) {
package/usage.js CHANGED
@@ -21,6 +21,7 @@ Project commands (run in a folder with templates/, data/, documents/)
21
21
  fields <template> List every field a template reads
22
22
  typegen Write JSON Schema and .d.ts for each template's data
23
23
  sty [dir] Write latex-kit.sty so editors can preview templates
24
+ lock [--check] Pin the TeX and pandoc images in latex-kit.lock
24
25
  import <file> Turn a Word/Markdown/HTML document (or an older .tex)
25
26
  into a template; {{x}} and @GROUP@FIELD@ become \\field
26
27
  diff <document> --against <ref>
@@ -44,7 +45,7 @@ always produces the same PDF bytes.
44
45
 
45
46
  Options
46
47
  -o, --out <dir> Output directory, relative to --root (default: out)
47
- -e, --engine <name> lualatex (default), xelatex, pdflatex or pdfps
48
+ -e, --engine <name> auto (default), lualatex, xelatex, pdflatex or pdfps
48
49
  --root <dir> Directory TeX can see (default: current directory)
49
50
  --image <ref> Docker image (default: pinned ghcr.io/constructive-io/latex-kit)
50
51
  --platform <os/arch> Docker --platform (default: native)
@@ -53,7 +54,10 @@ Options
53
54
  --verify Build twice and fail if the PDFs differ
54
55
  --json Print a JSON summary on stdout
55
56
 
56
- Only lualatex is byte-reproducible in the default image.
57
+ auto reads the file: a "% !TEX program =" line wins; PSTricks packages
58
+ pick pdfps, xeCJK or ctex pick xelatex, CJK/CJKutf8 pick pdflatex, and
59
+ everything else uses lualatex, the only engine that is byte-reproducible in
60
+ the default image.
57
61
  `;
58
62
  const BUILD = `latex-kit build [documents…] [options]
59
63
 
@@ -65,20 +69,34 @@ Variants
65
69
  as red markers (they fail instead when CI=true or --strict)
66
70
  --variant final No marks. Missing values fail. Mints a document ID on the
67
71
  --final first build and saves it in the record (JSON/YAML)
68
- --variant signed Like final; templates can test \\when{$variant == "signed"}
72
+ --variant signed Like final, and \\signature blocks are signed: each signer's
73
+ image from --signatures (a folder outside the repo,
74
+ <name>.png|pdf|jpg or the signer's "signature" file),
75
+ else "/s/ Name"; dates come from the record:
76
+ signed: { discloser: { date: 2026-11-25 } }
69
77
  --variant blank Every field is a labelled line. With no documents, builds
70
78
  each template (or --template <name>) as an empty form
71
79
 
72
80
  Options
73
81
  --template <name> Only documents that use this template
82
+ --only <names> Only these documents (or templates, for blanks);
83
+ comma-separated, * matches anything: --only 'nda-*'
84
+ --locale <tag> Build in another locale (dates, numbers, bilingual
85
+ order); writes <document>-<tag>.pdf
86
+ --signatures <dir> Signature images for --variant signed
74
87
  --strict Fail on missing values in drafts too
75
- -e, --engine <name> lualatex (default), xelatex, pdflatex or pdfps
88
+ --force Rebuild even if the PDF is up to date
89
+ -e, --engine <name> auto (default), lualatex, xelatex, pdflatex or pdfps
76
90
  --local Use latexmk on PATH instead of Docker
77
- --image <ref> Docker image (default: pinned ghcr.io/constructive-io/latex-kit)
91
+ --image <ref> Docker image (default: latex-kit.lock, else the pinned
92
+ ghcr.io/constructive-io/latex-kit)
78
93
  --verify Build twice and fail unless the PDFs are identical
79
94
  --tex-only Write the .tex without running TeX
80
95
  --json JSON results on stdout
81
96
  --root <dir> Project folder (default: current directory)
97
+
98
+ A build is skipped ("unchanged") when the last PDF came from exactly the
99
+ same .tex, template folder, engine, image and build date.
82
100
  `;
83
101
  const DOCTOR = `latex-kit doctor [--image <ref>] [--json]
84
102