latex-kit 0.4.1 → 0.5.1
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/README.md +21 -2
- package/args.js +3 -3
- package/boilerplates.d.ts +14 -1
- package/boilerplates.js +200 -2
- package/build.d.ts +22 -2
- package/build.js +230 -95
- package/check.js +4 -3
- package/cli.js +2 -2
- package/commands.js +1 -0
- package/config.d.ts +13 -4
- package/config.js +1 -1
- package/diff.d.ts +2 -2
- package/diff.js +3 -3
- package/esm/args.js +3 -3
- package/esm/boilerplates.d.ts +14 -1
- package/esm/boilerplates.js +196 -1
- package/esm/build.d.ts +22 -2
- package/esm/build.js +231 -98
- package/esm/check.js +4 -3
- package/esm/cli.js +2 -2
- package/esm/commands.js +2 -1
- package/esm/config.d.ts +13 -4
- package/esm/config.js +1 -1
- package/esm/diff.d.ts +2 -2
- package/esm/diff.js +3 -3
- package/esm/import.js +1 -1
- package/esm/index.d.ts +6 -2
- package/esm/index.js +5 -2
- package/esm/lock.d.ts +24 -0
- package/esm/lock.js +50 -0
- package/esm/paper-style.d.ts +10 -0
- package/esm/paper-style.js +10 -0
- package/esm/project-commands.d.ts +4 -0
- package/esm/project-commands.js +76 -6
- package/esm/project.d.ts +18 -2
- package/esm/project.js +92 -5
- package/esm/render.js +4 -2
- package/esm/scaffold.d.ts +2 -1
- package/esm/scaffold.js +1 -1
- package/esm/usage.js +28 -7
- package/import.js +1 -1
- package/index.d.ts +6 -2
- package/index.js +24 -2
- package/lock.d.ts +24 -0
- package/lock.js +57 -0
- package/package.json +16 -17
- package/paper-style.d.ts +10 -0
- package/paper-style.js +13 -0
- package/project-commands.d.ts +4 -0
- package/project-commands.js +78 -6
- package/project.d.ts +18 -2
- package/project.js +90 -3
- package/render.js +4 -2
- package/scaffold.d.ts +2 -1
- package/scaffold.js +1 -1
- package/usage.js +28 -7
package/esm/render.js
CHANGED
|
@@ -7,6 +7,7 @@ function summary(r) {
|
|
|
7
7
|
pdf: relative(process.cwd(), r.pdf),
|
|
8
8
|
sha256: r.sha256,
|
|
9
9
|
engine: r.engine,
|
|
10
|
+
engineReason: r.engineReason,
|
|
10
11
|
backend: r.backend,
|
|
11
12
|
image: r.image,
|
|
12
13
|
sourceDateEpoch: r.sourceDateEpoch,
|
|
@@ -38,8 +39,9 @@ export async function renderCommand(argv, prompter) {
|
|
|
38
39
|
console.error(s);
|
|
39
40
|
};
|
|
40
41
|
try {
|
|
41
|
-
log(chalk.dim(`rendering ${opts.file}
|
|
42
|
+
log(chalk.dim(`rendering ${opts.file} (${opts.backend})…`));
|
|
42
43
|
const first = await render({ ...opts, file: opts.file });
|
|
44
|
+
log(chalk.dim(` engine ${first.engine}${first.engineReason === 'chosen' ? '' : ` (${first.engineReason})`}`));
|
|
43
45
|
for (const d of first.diagnostics)
|
|
44
46
|
log(chalk.yellow(formatDiagnostic(d)));
|
|
45
47
|
if (!first.reproducible) {
|
|
@@ -49,7 +51,7 @@ export async function renderCommand(argv, prompter) {
|
|
|
49
51
|
if (argv.verify) {
|
|
50
52
|
// same output path: some tools (Ghostscript) hash the path into the PDF ID
|
|
51
53
|
log(chalk.dim('rendering again to check the output is byte-identical…'));
|
|
52
|
-
const second = await render({ ...opts, file: opts.file, sourceDateEpoch: first.sourceDateEpoch });
|
|
54
|
+
const second = await render({ ...opts, file: opts.file, engine: first.engine, sourceDateEpoch: first.sourceDateEpoch });
|
|
53
55
|
verified = second.sha256 === first.sha256;
|
|
54
56
|
}
|
|
55
57
|
if (argv.json) {
|
package/esm/scaffold.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FileMap } from './boilerplates';
|
|
1
|
+
import { FileMap, PaperPreset } from './boilerplates';
|
|
2
2
|
import { Project } from './project';
|
|
3
3
|
export interface WriteResult {
|
|
4
4
|
written: string[];
|
|
@@ -9,6 +9,7 @@ export declare function writeFiles(dir: string, files: FileMap, force?: boolean)
|
|
|
9
9
|
/** Scaffold a latex-kit project (or a paper) in `dir`. */
|
|
10
10
|
export declare function initProject(dir: string, options: {
|
|
11
11
|
paper?: boolean;
|
|
12
|
+
preset?: PaperPreset;
|
|
12
13
|
force?: boolean;
|
|
13
14
|
version: string;
|
|
14
15
|
}): WriteResult;
|
package/esm/scaffold.js
CHANGED
|
@@ -27,7 +27,7 @@ export function initProject(dir, options) {
|
|
|
27
27
|
if (existing)
|
|
28
28
|
throw new Error(`${join(dir, existing)} already exists; use --force to add the starter files anyway`);
|
|
29
29
|
}
|
|
30
|
-
return writeFiles(dir, options.paper ? paperFiles() : projectFiles(options.version), options.force);
|
|
30
|
+
return writeFiles(dir, options.paper ? paperFiles(options.preset) : projectFiles(options.version), options.force);
|
|
31
31
|
}
|
|
32
32
|
export function newTemplate(project, name, force = false) {
|
|
33
33
|
if (!/^[a-z0-9][a-z0-9_-]*$/.test(name))
|
package/esm/usage.js
CHANGED
|
@@ -5,7 +5,10 @@ Usage
|
|
|
5
5
|
|
|
6
6
|
Start
|
|
7
7
|
init [dir] A new project: a letter template, data and a record
|
|
8
|
-
init [dir] --paper A paper
|
|
8
|
+
init [dir] --paper A paper in the Constructive whitepaper style (TikZ,
|
|
9
|
+
PSTricks, highlighted TypeScript listings, IEEE
|
|
10
|
+
references) with CI and release-on-tag; --preset plain
|
|
11
|
+
for a minimal LuaLaTeX paper
|
|
9
12
|
new template <name> A template folder with template.tex and schema.ts
|
|
10
13
|
new document <name> --template <t>
|
|
11
14
|
A record with every required field, linked to its schema
|
|
@@ -18,6 +21,7 @@ Project commands (run in a folder with templates/, data/, documents/)
|
|
|
18
21
|
fields <template> List every field a template reads
|
|
19
22
|
typegen Write JSON Schema and .d.ts for each template's data
|
|
20
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
|
|
21
25
|
import <file> Turn a Word/Markdown/HTML document (or an older .tex)
|
|
22
26
|
into a template; {{x}} and @GROUP@FIELD@ become \\field
|
|
23
27
|
diff <document> --against <ref>
|
|
@@ -41,16 +45,19 @@ always produces the same PDF bytes.
|
|
|
41
45
|
|
|
42
46
|
Options
|
|
43
47
|
-o, --out <dir> Output directory, relative to --root (default: out)
|
|
44
|
-
-e, --engine <name>
|
|
48
|
+
-e, --engine <name> auto (default), lualatex, xelatex, pdflatex or pdfps
|
|
45
49
|
--root <dir> Directory TeX can see (default: current directory)
|
|
46
|
-
--image <ref> Docker image (default: pinned
|
|
50
|
+
--image <ref> Docker image (default: pinned constructiveio/latex-kit)
|
|
47
51
|
--platform <os/arch> Docker --platform (default: native)
|
|
48
52
|
--local Use latexmk on PATH instead of Docker (not pinned)
|
|
49
53
|
--source-date-epoch <s> Build timestamp in seconds since 1970
|
|
50
54
|
--verify Build twice and fail if the PDFs differ
|
|
51
55
|
--json Print a JSON summary on stdout
|
|
52
56
|
|
|
53
|
-
|
|
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.
|
|
54
61
|
`;
|
|
55
62
|
const BUILD = `latex-kit build [documents…] [options]
|
|
56
63
|
|
|
@@ -62,20 +69,34 @@ Variants
|
|
|
62
69
|
as red markers (they fail instead when CI=true or --strict)
|
|
63
70
|
--variant final No marks. Missing values fail. Mints a document ID on the
|
|
64
71
|
--final first build and saves it in the record (JSON/YAML)
|
|
65
|
-
--variant signed Like final
|
|
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 } }
|
|
66
77
|
--variant blank Every field is a labelled line. With no documents, builds
|
|
67
78
|
each template (or --template <name>) as an empty form
|
|
68
79
|
|
|
69
80
|
Options
|
|
70
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
|
|
71
87
|
--strict Fail on missing values in drafts too
|
|
72
|
-
|
|
88
|
+
--force Rebuild even if the PDF is up to date
|
|
89
|
+
-e, --engine <name> auto (default), lualatex, xelatex, pdflatex or pdfps
|
|
73
90
|
--local Use latexmk on PATH instead of Docker
|
|
74
|
-
--image <ref> Docker image (default:
|
|
91
|
+
--image <ref> Docker image (default: latex-kit.lock, else the pinned
|
|
92
|
+
constructiveio/latex-kit on Docker Hub)
|
|
75
93
|
--verify Build twice and fail unless the PDFs are identical
|
|
76
94
|
--tex-only Write the .tex without running TeX
|
|
77
95
|
--json JSON results on stdout
|
|
78
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.
|
|
79
100
|
`;
|
|
80
101
|
const DOCTOR = `latex-kit doctor [--image <ref>] [--json]
|
|
81
102
|
|
package/import.js
CHANGED
|
@@ -92,7 +92,7 @@ async function importDocument(project, file, options = {}) {
|
|
|
92
92
|
}
|
|
93
93
|
const mediaDir = (0, path_1.join)(dir, 'media');
|
|
94
94
|
try {
|
|
95
|
-
await (0, render_1.runPandoc)({ root: project.root, input: source, output: target, extractMedia: mediaDir, backend: options.backend });
|
|
95
|
+
await (0, render_1.runPandoc)({ root: project.root, input: source, output: target, extractMedia: mediaDir, backend: options.backend, image: project.lock?.pandocImage });
|
|
96
96
|
}
|
|
97
97
|
finally {
|
|
98
98
|
if (staged)
|
package/index.d.ts
CHANGED
|
@@ -2,14 +2,18 @@
|
|
|
2
2
|
* latex-kit: typed, reproducible LaTeX documents.
|
|
3
3
|
*
|
|
4
4
|
* The CLI is `latex-kit`. This module is what project files import:
|
|
5
|
-
* `defineConfig` for latex-kit.config.ts
|
|
6
|
-
*
|
|
5
|
+
* `defineConfig` for latex-kit.config.ts; `z`, the shared types and `ref()`
|
|
6
|
+
* for schema.ts; `defineDocument` for TypeScript records; `defineComponent`,
|
|
7
|
+
* `table`, `tex` and friends for components/; `defineClause` for clauses.
|
|
7
8
|
*/
|
|
8
9
|
export * from './build';
|
|
9
10
|
export * from './check';
|
|
10
11
|
export * from './config';
|
|
11
12
|
export * from './diff';
|
|
12
13
|
export * from './import';
|
|
14
|
+
export * from './lock';
|
|
13
15
|
export * from './project';
|
|
14
16
|
export * from './scaffold';
|
|
17
|
+
export type { Cell, ClauseDefinition, Column, Component, ComponentContext, Exhibit, TableOptions } from '@latex-kit/components';
|
|
18
|
+
export { address, bilingual, BUILTIN_COMPONENTS, date, defineClause, defineComponent, escapeLatex, exhibit, exhibits, get, money, number, percent, raw, RawLatex, signatures, table, tex, } from '@latex-kit/components';
|
|
15
19
|
export * from '@latex-kit/schema';
|
package/index.js
CHANGED
|
@@ -14,18 +14,40 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.tex = exports.table = exports.signatures = exports.RawLatex = exports.raw = exports.percent = exports.number = exports.money = exports.get = exports.exhibits = exports.exhibit = exports.escapeLatex = exports.defineComponent = exports.defineClause = exports.date = exports.BUILTIN_COMPONENTS = exports.bilingual = exports.address = void 0;
|
|
17
18
|
/**
|
|
18
19
|
* latex-kit: typed, reproducible LaTeX documents.
|
|
19
20
|
*
|
|
20
21
|
* The CLI is `latex-kit`. This module is what project files import:
|
|
21
|
-
* `defineConfig` for latex-kit.config.ts
|
|
22
|
-
*
|
|
22
|
+
* `defineConfig` for latex-kit.config.ts; `z`, the shared types and `ref()`
|
|
23
|
+
* for schema.ts; `defineDocument` for TypeScript records; `defineComponent`,
|
|
24
|
+
* `table`, `tex` and friends for components/; `defineClause` for clauses.
|
|
23
25
|
*/
|
|
24
26
|
__exportStar(require("./build"), exports);
|
|
25
27
|
__exportStar(require("./check"), exports);
|
|
26
28
|
__exportStar(require("./config"), exports);
|
|
27
29
|
__exportStar(require("./diff"), exports);
|
|
28
30
|
__exportStar(require("./import"), exports);
|
|
31
|
+
__exportStar(require("./lock"), exports);
|
|
29
32
|
__exportStar(require("./project"), exports);
|
|
30
33
|
__exportStar(require("./scaffold"), exports);
|
|
34
|
+
var components_1 = require("@latex-kit/components");
|
|
35
|
+
Object.defineProperty(exports, "address", { enumerable: true, get: function () { return components_1.address; } });
|
|
36
|
+
Object.defineProperty(exports, "bilingual", { enumerable: true, get: function () { return components_1.bilingual; } });
|
|
37
|
+
Object.defineProperty(exports, "BUILTIN_COMPONENTS", { enumerable: true, get: function () { return components_1.BUILTIN_COMPONENTS; } });
|
|
38
|
+
Object.defineProperty(exports, "date", { enumerable: true, get: function () { return components_1.date; } });
|
|
39
|
+
Object.defineProperty(exports, "defineClause", { enumerable: true, get: function () { return components_1.defineClause; } });
|
|
40
|
+
Object.defineProperty(exports, "defineComponent", { enumerable: true, get: function () { return components_1.defineComponent; } });
|
|
41
|
+
Object.defineProperty(exports, "escapeLatex", { enumerable: true, get: function () { return components_1.escapeLatex; } });
|
|
42
|
+
Object.defineProperty(exports, "exhibit", { enumerable: true, get: function () { return components_1.exhibit; } });
|
|
43
|
+
Object.defineProperty(exports, "exhibits", { enumerable: true, get: function () { return components_1.exhibits; } });
|
|
44
|
+
Object.defineProperty(exports, "get", { enumerable: true, get: function () { return components_1.get; } });
|
|
45
|
+
Object.defineProperty(exports, "money", { enumerable: true, get: function () { return components_1.money; } });
|
|
46
|
+
Object.defineProperty(exports, "number", { enumerable: true, get: function () { return components_1.number; } });
|
|
47
|
+
Object.defineProperty(exports, "percent", { enumerable: true, get: function () { return components_1.percent; } });
|
|
48
|
+
Object.defineProperty(exports, "raw", { enumerable: true, get: function () { return components_1.raw; } });
|
|
49
|
+
Object.defineProperty(exports, "RawLatex", { enumerable: true, get: function () { return components_1.RawLatex; } });
|
|
50
|
+
Object.defineProperty(exports, "signatures", { enumerable: true, get: function () { return components_1.signatures; } });
|
|
51
|
+
Object.defineProperty(exports, "table", { enumerable: true, get: function () { return components_1.table; } });
|
|
52
|
+
Object.defineProperty(exports, "tex", { enumerable: true, get: function () { return components_1.tex; } });
|
|
31
53
|
__exportStar(require("@latex-kit/schema"), exports);
|
package/lock.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* latex-kit.lock: the exact images a project builds with. Commit it. A newer
|
|
3
|
+
* latex-kit with a newer default image keeps building this project with the
|
|
4
|
+
* locked one, so PDFs do not change until `latex-kit lock` moves the pins.
|
|
5
|
+
*/
|
|
6
|
+
export declare const LOCK_FILE = "latex-kit.lock";
|
|
7
|
+
export interface Lock {
|
|
8
|
+
lockfileVersion: 1;
|
|
9
|
+
/** The TeX Live image, by digest. */
|
|
10
|
+
image: string;
|
|
11
|
+
/** The pandoc image `latex-kit import` uses, by digest. */
|
|
12
|
+
pandocImage: string;
|
|
13
|
+
}
|
|
14
|
+
export declare class LockError extends Error {
|
|
15
|
+
name: string;
|
|
16
|
+
}
|
|
17
|
+
/** The pins this version of latex-kit would write. */
|
|
18
|
+
export declare function currentPins(): Lock;
|
|
19
|
+
export declare function readLock(root: string): Lock | null;
|
|
20
|
+
/** Write the current pins. Returns the previous lock, if any. */
|
|
21
|
+
export declare function writeLock(root: string): {
|
|
22
|
+
lock: Lock;
|
|
23
|
+
previous: Lock | null;
|
|
24
|
+
};
|
package/lock.js
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LockError = exports.LOCK_FILE = void 0;
|
|
4
|
+
exports.currentPins = currentPins;
|
|
5
|
+
exports.readLock = readLock;
|
|
6
|
+
exports.writeLock = writeLock;
|
|
7
|
+
const render_1 = require("@latex-kit/render");
|
|
8
|
+
const fs_1 = require("fs");
|
|
9
|
+
const path_1 = require("path");
|
|
10
|
+
/**
|
|
11
|
+
* latex-kit.lock: the exact images a project builds with. Commit it. A newer
|
|
12
|
+
* latex-kit with a newer default image keeps building this project with the
|
|
13
|
+
* locked one, so PDFs do not change until `latex-kit lock` moves the pins.
|
|
14
|
+
*/
|
|
15
|
+
exports.LOCK_FILE = 'latex-kit.lock';
|
|
16
|
+
class LockError extends Error {
|
|
17
|
+
name = 'LockError';
|
|
18
|
+
}
|
|
19
|
+
exports.LockError = LockError;
|
|
20
|
+
const PINNED = /@sha256:[0-9a-f]{64}$/;
|
|
21
|
+
/** The pins this version of latex-kit would write. */
|
|
22
|
+
function currentPins() {
|
|
23
|
+
return { lockfileVersion: 1, image: render_1.DEFAULT_IMAGE, pandocImage: render_1.PANDOC_IMAGE };
|
|
24
|
+
}
|
|
25
|
+
function readLock(root) {
|
|
26
|
+
const file = (0, path_1.join)(root, exports.LOCK_FILE);
|
|
27
|
+
if (!(0, fs_1.existsSync)(file))
|
|
28
|
+
return null;
|
|
29
|
+
let raw;
|
|
30
|
+
try {
|
|
31
|
+
raw = JSON.parse((0, fs_1.readFileSync)(file, 'utf8'));
|
|
32
|
+
}
|
|
33
|
+
catch (e) {
|
|
34
|
+
throw new LockError(`${exports.LOCK_FILE} is not valid JSON: ${e.message}`);
|
|
35
|
+
}
|
|
36
|
+
const l = raw;
|
|
37
|
+
if (!l || typeof l !== 'object' || l.lockfileVersion !== 1)
|
|
38
|
+
throw new LockError(`${exports.LOCK_FILE}: unknown lockfileVersion (this latex-kit reads version 1)`);
|
|
39
|
+
for (const k of ['image', 'pandocImage']) {
|
|
40
|
+
if (typeof l[k] !== 'string' || !PINNED.test(l[k]))
|
|
41
|
+
throw new LockError(`${exports.LOCK_FILE}: ${k} must be an image pinned by digest (…@sha256:<64 hex>)`);
|
|
42
|
+
}
|
|
43
|
+
return l;
|
|
44
|
+
}
|
|
45
|
+
/** Write the current pins. Returns the previous lock, if any. */
|
|
46
|
+
function writeLock(root) {
|
|
47
|
+
let previous = null;
|
|
48
|
+
try {
|
|
49
|
+
previous = readLock(root);
|
|
50
|
+
}
|
|
51
|
+
catch {
|
|
52
|
+
// an unreadable lock is replaced
|
|
53
|
+
}
|
|
54
|
+
const lock = currentPins();
|
|
55
|
+
(0, fs_1.writeFileSync)((0, path_1.join)(root, exports.LOCK_FILE), JSON.stringify(lock, null, 2) + '\n');
|
|
56
|
+
return { lock, previous };
|
|
57
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "latex-kit",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"description": "Build typed, reproducible LaTeX documents from the command line",
|
|
5
5
|
"author": "Constructive <developers@constructive.io>",
|
|
6
6
|
"main": "index.js",
|
|
@@ -19,16 +19,6 @@
|
|
|
19
19
|
"bugs": {
|
|
20
20
|
"url": "https://github.com/constructive-io/latex-kit/issues"
|
|
21
21
|
},
|
|
22
|
-
"scripts": {
|
|
23
|
-
"copy": "makage assets",
|
|
24
|
-
"clean": "makage clean",
|
|
25
|
-
"prepublishOnly": "npm run build",
|
|
26
|
-
"build": "makage build",
|
|
27
|
-
"build:dev": "makage build --dev",
|
|
28
|
-
"lint": "eslint . --fix",
|
|
29
|
-
"test": "NODE_OPTIONS=--experimental-vm-modules jest",
|
|
30
|
-
"test:watch": "NODE_OPTIONS=--experimental-vm-modules jest --watch"
|
|
31
|
-
},
|
|
32
22
|
"devDependencies": {
|
|
33
23
|
"@types/minimist": "^1.2.5",
|
|
34
24
|
"makage": "^0.8.0"
|
|
@@ -44,12 +34,21 @@
|
|
|
44
34
|
"latex-kit": "cli.js"
|
|
45
35
|
},
|
|
46
36
|
"dependencies": {
|
|
47
|
-
"@latex-kit/render": "0.4.0",
|
|
48
|
-
"@latex-kit/schema": "0.3.0",
|
|
49
|
-
"@latex-kit/template": "0.3.0",
|
|
50
37
|
"inquirerer": "^4.9.5",
|
|
51
38
|
"minimist": "^1.2.8",
|
|
52
|
-
"yanse": "^0.2.3"
|
|
39
|
+
"yanse": "^0.2.3",
|
|
40
|
+
"@latex-kit/schema": "0.4.1",
|
|
41
|
+
"@latex-kit/components": "0.2.1",
|
|
42
|
+
"@latex-kit/render": "0.5.1",
|
|
43
|
+
"@latex-kit/template": "0.4.1"
|
|
53
44
|
},
|
|
54
|
-
"
|
|
55
|
-
|
|
45
|
+
"scripts": {
|
|
46
|
+
"copy": "makage assets",
|
|
47
|
+
"clean": "makage clean",
|
|
48
|
+
"build": "makage build",
|
|
49
|
+
"build:dev": "makage build --dev",
|
|
50
|
+
"lint": "eslint . --fix",
|
|
51
|
+
"test": "NODE_OPTIONS=--experimental-vm-modules jest",
|
|
52
|
+
"test:watch": "NODE_OPTIONS=--experimental-vm-modules jest --watch"
|
|
53
|
+
}
|
|
54
|
+
}
|
package/paper-style.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Constructive whitepaper style, from constructive-io/rls-whitepaper and
|
|
3
|
+
* hyperweb-whitepaper (tex/headers/): the code colour palette and the
|
|
4
|
+
* TypeScript listings style, copied verbatim so new papers look like ours.
|
|
5
|
+
* Regenerate from those files rather than editing here.
|
|
6
|
+
*/
|
|
7
|
+
/** tex/headers/colors.tex */
|
|
8
|
+
export declare const WHITEPAPER_COLORS_TEX = "% Define colors for code highlighting\n\\definecolor{lightpurple}{rgb}{0.85, 0.85, 1}\n\\definecolor{white}{rgb}{1, 1, 1}\n\\definecolor{codegray}{gray}{0.9}\n\\definecolor{codeblue}{rgb}{0,0,0.6}\n\\definecolor{codegreen}{rgb}{0,0.6,0}\n\\definecolor{codepurple}{rgb}{0.58,0,0.82}\n\\definecolor{codebackground}{rgb}{0.95,0.95,0.95}\n\\definecolor{codeorange}{rgb}{1, 0.6, 0.2}\n\\definecolor{codered}{rgb}{0.8, 0, 0}\n\\definecolor{codeyellow}{rgb}{0.9, 0.9, 0.4}\n\\definecolor{codeteal}{rgb}{0, 0.5, 0.5}\n\\definecolor{codepink}{rgb}{1, 0.5, 0.7}\n\\definecolor{codebrown}{rgb}{0.6, 0.4, 0.2}\n\\definecolor{codelightblue}{rgb}{0.7, 0.85, 1}\n\\definecolor{codelightgreen}{rgb}{0.7, 1, 0.7}\n\\definecolor{codedarkblue}{rgb}{0, 0.2, 0.5}\n\\definecolor{codedarkpurple}{rgb}{0.4, 0.2, 0.6}\n\\definecolor{black}{rgb}{0, 0, 0}\n\\pagecolor{white}";
|
|
9
|
+
/** tex/headers/typescript.tex */
|
|
10
|
+
export declare const WHITEPAPER_TYPESCRIPT_TEX = "% Code style definition\n\\lstdefinelanguage{typescript}{\n keywords={abstract, arguments, await, boolean, break, byte, case, catch,\n class, const, continue, debugger, default, delete, do, double, else,\n enum, eval, export, extends, false, final, finally, float, for,\n function, goto, if, implements, import, in, instanceof, int, interface,\n let, long, native, new, null, package, private, protected, public,\n return, short, static, super, switch, synchronized, this, throw,\n throws, transient, true, try, typeof, var, void, volatile, while, with,\n yield, async, from, of},\n keywordstyle=\\color{codeblue},\n sensitive=true,\n comment=[l]{//},\n morecomment=[s]{/*}{*/},\n commentstyle=\\color{codegreen},\n stringstyle=\\color{codepurple},\n morestring=[b]',\n morestring=[b]\"\n}\n\n% Enhanced Code Style Definition for TypeScript and JavaScript\n\\lstdefinestyle{typescript}{\n language=typescript,\n backgroundcolor=\\color{white},\n basicstyle=\\ttfamily\\footnotesize,\n breakatwhitespace=false,\n breaklines=true,\n captionpos=b,\n keepspaces=true,\n numbers=left,\n numbersep=5pt,\n showspaces=false,\n showstringspaces=false,\n showtabs=false,\n tabsize=2,\n numberstyle=\\tiny\\color{black},\n % Additional TypeScript-specific highlighting\n moredelim=[is][\\textcolor{codepurple}]{\\#\\{}{\\}}, % Template literals\n moredelim=[is][\\textcolor{codeblue}]{<}{>}, % Generic types\n literate=\n {=>}{{\\textcolor{codeblue}{=>}}}2 \n {interface}{{\\textcolor{codeblue}{interface}}}9\n {type}{{\\textcolor{codered}{type}}}4\n {export}{{\\textcolor{codegreen}{export}}}6\n {import}{{\\textcolor{codeorange}{import}}}6\n {from}{{\\textcolor{codeblue}{from}}}4\n {return}{{\\textcolor{codeteal}{return}}}6 \n {function}{{\\textcolor{codeblue}{function}}}8\n {string}{{\\textcolor{codepink}{string}}}6 \n {let}{{\\textcolor{codered}{let}}}3 \n% {const}{{\\textcolor{codedarkpurple}{const}}}5 \n {var}{{\\textcolor{codelightblue}{var}}}3 \n {while}{{\\textcolor{codered}{while}}}5 \n {if}{{\\textcolor{codeorange}{if}}}2 \n {else}{{\\textcolor{codeyellow}{else}}}4\n\t{@onlyOwner}{{\\textcolor{codered}{@onlyOwner}}}9\n\t{@instantiate}{{\\textcolor{codered}{@instantiate}}}{10}\n}\n\n";
|
package/paper-style.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* The Constructive whitepaper style, from constructive-io/rls-whitepaper and
|
|
4
|
+
* hyperweb-whitepaper (tex/headers/): the code colour palette and the
|
|
5
|
+
* TypeScript listings style, copied verbatim so new papers look like ours.
|
|
6
|
+
* Regenerate from those files rather than editing here.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.WHITEPAPER_TYPESCRIPT_TEX = exports.WHITEPAPER_COLORS_TEX = void 0;
|
|
10
|
+
/** tex/headers/colors.tex */
|
|
11
|
+
exports.WHITEPAPER_COLORS_TEX = '% Define colors for code highlighting\n\\definecolor{lightpurple}{rgb}{0.85, 0.85, 1}\n\\definecolor{white}{rgb}{1, 1, 1}\n\\definecolor{codegray}{gray}{0.9}\n\\definecolor{codeblue}{rgb}{0,0,0.6}\n\\definecolor{codegreen}{rgb}{0,0.6,0}\n\\definecolor{codepurple}{rgb}{0.58,0,0.82}\n\\definecolor{codebackground}{rgb}{0.95,0.95,0.95}\n\\definecolor{codeorange}{rgb}{1, 0.6, 0.2}\n\\definecolor{codered}{rgb}{0.8, 0, 0}\n\\definecolor{codeyellow}{rgb}{0.9, 0.9, 0.4}\n\\definecolor{codeteal}{rgb}{0, 0.5, 0.5}\n\\definecolor{codepink}{rgb}{1, 0.5, 0.7}\n\\definecolor{codebrown}{rgb}{0.6, 0.4, 0.2}\n\\definecolor{codelightblue}{rgb}{0.7, 0.85, 1}\n\\definecolor{codelightgreen}{rgb}{0.7, 1, 0.7}\n\\definecolor{codedarkblue}{rgb}{0, 0.2, 0.5}\n\\definecolor{codedarkpurple}{rgb}{0.4, 0.2, 0.6}\n\\definecolor{black}{rgb}{0, 0, 0}\n\\pagecolor{white}';
|
|
12
|
+
/** tex/headers/typescript.tex */
|
|
13
|
+
exports.WHITEPAPER_TYPESCRIPT_TEX = "% Code style definition\n\\lstdefinelanguage{typescript}{\n keywords={abstract, arguments, await, boolean, break, byte, case, catch,\n class, const, continue, debugger, default, delete, do, double, else,\n enum, eval, export, extends, false, final, finally, float, for,\n function, goto, if, implements, import, in, instanceof, int, interface,\n let, long, native, new, null, package, private, protected, public,\n return, short, static, super, switch, synchronized, this, throw,\n throws, transient, true, try, typeof, var, void, volatile, while, with,\n yield, async, from, of},\n keywordstyle=\\color{codeblue},\n sensitive=true,\n comment=[l]{//},\n morecomment=[s]{/*}{*/},\n commentstyle=\\color{codegreen},\n stringstyle=\\color{codepurple},\n morestring=[b]',\n morestring=[b]\"\n}\n\n% Enhanced Code Style Definition for TypeScript and JavaScript\n\\lstdefinestyle{typescript}{\n language=typescript,\n backgroundcolor=\\color{white},\n basicstyle=\\ttfamily\\footnotesize,\n breakatwhitespace=false,\n breaklines=true,\n captionpos=b,\n keepspaces=true,\n numbers=left,\n numbersep=5pt,\n showspaces=false,\n showstringspaces=false,\n showtabs=false,\n tabsize=2,\n numberstyle=\\tiny\\color{black},\n % Additional TypeScript-specific highlighting\n moredelim=[is][\\textcolor{codepurple}]{\\#\\{}{\\}}, % Template literals\n moredelim=[is][\\textcolor{codeblue}]{<}{>}, % Generic types\n literate=\n {=>}{{\\textcolor{codeblue}{=>}}}2 \n {interface}{{\\textcolor{codeblue}{interface}}}9\n {type}{{\\textcolor{codered}{type}}}4\n {export}{{\\textcolor{codegreen}{export}}}6\n {import}{{\\textcolor{codeorange}{import}}}6\n {from}{{\\textcolor{codeblue}{from}}}4\n {return}{{\\textcolor{codeteal}{return}}}6 \n {function}{{\\textcolor{codeblue}{function}}}8\n {string}{{\\textcolor{codepink}{string}}}6 \n {let}{{\\textcolor{codered}{let}}}3 \n% {const}{{\\textcolor{codedarkpurple}{const}}}5 \n {var}{{\\textcolor{codelightblue}{var}}}3 \n {while}{{\\textcolor{codered}{while}}}5 \n {if}{{\\textcolor{codeorange}{if}}}2 \n {else}{{\\textcolor{codeyellow}{else}}}4\n\t{@onlyOwner}{{\\textcolor{codered}{@onlyOwner}}}9\n\t{@instantiate}{{\\textcolor{codered}{@instantiate}}}{10}\n}\n\n";
|
package/project-commands.d.ts
CHANGED
|
@@ -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>;
|
package/project-commands.js
CHANGED
|
@@ -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;
|
|
@@ -21,11 +23,13 @@ const fs_1 = require("fs");
|
|
|
21
23
|
const path_1 = require("path");
|
|
22
24
|
const yanse_1 = __importDefault(require("yanse"));
|
|
23
25
|
const args_1 = require("./args");
|
|
26
|
+
const boilerplates_1 = require("./boilerplates");
|
|
24
27
|
const build_1 = require("./build");
|
|
25
28
|
const check_1 = require("./check");
|
|
26
29
|
const commands_1 = require("./commands");
|
|
27
30
|
const diff_1 = require("./diff");
|
|
28
31
|
const import_1 = require("./import");
|
|
32
|
+
const lock_1 = require("./lock");
|
|
29
33
|
const project_1 = require("./project");
|
|
30
34
|
const scaffold_1 = require("./scaffold");
|
|
31
35
|
function printDiagnostics(ds, json) {
|
|
@@ -35,12 +39,35 @@ function printDiagnostics(ds, json) {
|
|
|
35
39
|
console.error((d.severity === 'error' ? yanse_1.default.red : yanse_1.default.yellow)((0, template_1.formatDiagnostic)(d)));
|
|
36
40
|
}
|
|
37
41
|
const rel = (p) => (p ? (0, path_1.relative)(process.cwd(), p) : null);
|
|
42
|
+
/** `--only nda-*,invoice-0001`: comma-separated names, * matches anything. */
|
|
43
|
+
function onlyMatcher(only) {
|
|
44
|
+
if (only === undefined || only === null || only === '' || only === true)
|
|
45
|
+
return null;
|
|
46
|
+
const patterns = (Array.isArray(only) ? only : [only]).flatMap((o) => String(o).split(',')).map((p) => p.trim()).filter(Boolean);
|
|
47
|
+
if (patterns.length === 0)
|
|
48
|
+
return null;
|
|
49
|
+
const res = patterns.map((p) => new RegExp(`^${p.replace(/[.+?^${}()|[\]\\]/g, '\\$&').replace(/\*/g, '.*')}$`));
|
|
50
|
+
return (name) => res.some((r) => r.test(name));
|
|
51
|
+
}
|
|
52
|
+
function checkLocale(locale) {
|
|
53
|
+
if (locale === undefined)
|
|
54
|
+
return undefined;
|
|
55
|
+
try {
|
|
56
|
+
return Intl.getCanonicalLocales(String(locale))[0];
|
|
57
|
+
}
|
|
58
|
+
catch {
|
|
59
|
+
throw new args_1.UsageError(`--locale ${locale} is not a language tag (like en-US or ja-JP)`);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
38
62
|
async function buildCommand(argv) {
|
|
39
63
|
const variant = (argv.variant ?? (argv.final ? 'final' : 'draft'));
|
|
40
64
|
if (!template_1.VARIANTS.includes(variant))
|
|
41
65
|
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(', ')}`);
|
|
66
|
+
if (argv.engine && argv.engine !== 'auto' && !render_1.ENGINES.includes(argv.engine))
|
|
67
|
+
throw new args_1.UsageError(`--engine must be auto or one of ${render_1.ENGINES.join(', ')}`);
|
|
68
|
+
if (argv.signatures !== undefined && variant !== 'signed')
|
|
69
|
+
throw new args_1.UsageError('--signatures only applies to --variant signed');
|
|
70
|
+
const only = onlyMatcher(argv.only);
|
|
44
71
|
const project = await project_1.Project.open(argv.root);
|
|
45
72
|
const options = {
|
|
46
73
|
variant,
|
|
@@ -51,13 +78,16 @@ async function buildCommand(argv) {
|
|
|
51
78
|
platform: argv.platform,
|
|
52
79
|
verify: Boolean(argv.verify),
|
|
53
80
|
texOnly: Boolean(argv['tex-only']),
|
|
81
|
+
locale: checkLocale(argv.locale),
|
|
82
|
+
force: Boolean(argv.force),
|
|
83
|
+
signatures: argv.signatures,
|
|
54
84
|
};
|
|
55
85
|
const json = Boolean(argv.json);
|
|
56
86
|
const log = (s) => !json && console.error(s);
|
|
57
87
|
const targets = [];
|
|
58
88
|
const files = (argv._ ?? []).map(String);
|
|
59
89
|
if (variant === 'blank' && files.length === 0) {
|
|
60
|
-
const names = argv.template ? [String(argv.template)] : project.templateNames();
|
|
90
|
+
const names = (argv.template ? [String(argv.template)] : project.templateNames()).filter((n) => !only || only(n));
|
|
61
91
|
for (const n of names)
|
|
62
92
|
targets.push({ label: `template ${n}`, run: () => (0, build_1.buildBlank)(project, n, options) });
|
|
63
93
|
}
|
|
@@ -74,13 +104,21 @@ async function buildCommand(argv) {
|
|
|
74
104
|
keep.push(f);
|
|
75
105
|
docs = keep;
|
|
76
106
|
}
|
|
107
|
+
if (only)
|
|
108
|
+
docs = docs.filter((f) => only(project.documentName(f)));
|
|
77
109
|
for (const f of docs)
|
|
78
110
|
targets.push({ label: rel(f), run: () => (0, build_1.buildDocument)(project, f, options) });
|
|
79
111
|
}
|
|
80
112
|
if (targets.length === 0) {
|
|
113
|
+
if (only) {
|
|
114
|
+
log(yanse_1.default.red(`--only ${argv.only} matched nothing`));
|
|
115
|
+
return 1;
|
|
116
|
+
}
|
|
81
117
|
log(yanse_1.default.yellow(`nothing to build (no documents in ${project.rel(project.documentsDir)}/)`));
|
|
82
118
|
return 0;
|
|
83
119
|
}
|
|
120
|
+
for (const d of project.codeDiagnostics)
|
|
121
|
+
printDiagnostics([d], json);
|
|
84
122
|
const results = [];
|
|
85
123
|
let failed = 0;
|
|
86
124
|
for (const t of targets) {
|
|
@@ -93,7 +131,8 @@ async function buildCommand(argv) {
|
|
|
93
131
|
failed++;
|
|
94
132
|
results.push({ ...r, tex: rel(r.tex), pdf: rel(r.pdf), diagnostics: r.diagnostics.length });
|
|
95
133
|
if (!json) {
|
|
96
|
-
|
|
134
|
+
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(' ');
|
|
135
|
+
console.log(`${bad ? yanse_1.default.red('✗') : yanse_1.default.green('✓')} ${rel(r.pdf ?? r.tex)}${notes ? yanse_1.default.dim(` ${notes}`) : ''}`);
|
|
97
136
|
if (r.minted)
|
|
98
137
|
console.log(yanse_1.default.dim(` minted ${r.docId} and saved it in ${t.label}`));
|
|
99
138
|
if (r.verified !== undefined)
|
|
@@ -150,7 +189,7 @@ async function fieldsCommand(argv) {
|
|
|
150
189
|
const width = Math.max(...fields.map((f) => f.absolute.length), 4);
|
|
151
190
|
for (const f of fields) {
|
|
152
191
|
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(
|
|
192
|
+
console.log(`${f.absolute.padEnd(width)} ${yanse_1.default.dim(f.kind.padEnd(9))} ${yanse_1.default.dim(`${f.file}:${f.line}`)}${filters}`);
|
|
154
193
|
}
|
|
155
194
|
return diagnostics.some((d) => d.severity === 'error') ? 1 : 0;
|
|
156
195
|
}
|
|
@@ -237,9 +276,42 @@ async function diffCommand(argv) {
|
|
|
237
276
|
console.log(`${yanse_1.default.green('✓')} ${rel(result.pdf)} ${yanse_1.default.dim('(insertions underlined in blue, deletions struck through in red)')}`);
|
|
238
277
|
return 0;
|
|
239
278
|
}
|
|
279
|
+
/** Pin the TeX and pandoc images in latex-kit.lock (commit it). */
|
|
280
|
+
async function lockCommand(argv) {
|
|
281
|
+
const project = await project_1.Project.open(argv.root);
|
|
282
|
+
const pins = (0, lock_1.currentPins)();
|
|
283
|
+
const file = (0, path_1.join)(project.root, lock_1.LOCK_FILE);
|
|
284
|
+
if (argv.check) {
|
|
285
|
+
if (!project.lock) {
|
|
286
|
+
console.log(yanse_1.default.yellow(`no ${lock_1.LOCK_FILE}: builds use this latex-kit's default image`));
|
|
287
|
+
return 1;
|
|
288
|
+
}
|
|
289
|
+
const stale = project.lock.image !== pins.image || project.lock.pandocImage !== pins.pandocImage;
|
|
290
|
+
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`);
|
|
291
|
+
return stale ? 1 : 0;
|
|
292
|
+
}
|
|
293
|
+
const { lock, previous } = (0, lock_1.writeLock)(project.root);
|
|
294
|
+
console.log(`${yanse_1.default.green('✓')} ${rel(file)}`);
|
|
295
|
+
if (previous && previous.image !== lock.image)
|
|
296
|
+
console.log(yanse_1.default.dim(` image ${previous.image}\n → ${lock.image}\n rebuilt PDFs will differ from earlier ones`));
|
|
297
|
+
else if (!previous)
|
|
298
|
+
console.log(yanse_1.default.dim(` image ${lock.image}`));
|
|
299
|
+
else
|
|
300
|
+
console.log(yanse_1.default.dim(' already up to date'));
|
|
301
|
+
return 0;
|
|
302
|
+
}
|
|
240
303
|
async function initCommand(argv) {
|
|
241
304
|
const dir = (0, path_1.join)(process.cwd(), argv._?.[0] ? String(argv._[0]) : '.');
|
|
242
|
-
const
|
|
305
|
+
const preset = (argv.preset ?? 'whitepaper');
|
|
306
|
+
if (!boilerplates_1.PAPER_PRESETS.includes(preset))
|
|
307
|
+
throw new args_1.UsageError(`--preset must be one of ${boilerplates_1.PAPER_PRESETS.join(', ')}`);
|
|
308
|
+
if (argv.preset && !argv.paper)
|
|
309
|
+
throw new args_1.UsageError('--preset only applies to init --paper');
|
|
310
|
+
const r = (0, scaffold_1.initProject)(dir, { paper: Boolean(argv.paper), preset, force: Boolean(argv.force), version: (0, commands_1.version)() });
|
|
311
|
+
if (!argv.paper && !(0, fs_1.existsSync)((0, path_1.join)(dir, lock_1.LOCK_FILE))) {
|
|
312
|
+
(0, lock_1.writeLock)(dir);
|
|
313
|
+
r.written.push((0, path_1.join)(dir, lock_1.LOCK_FILE));
|
|
314
|
+
}
|
|
243
315
|
for (const f of r.written)
|
|
244
316
|
console.log(`${yanse_1.default.green('+')} ${rel(f)}`);
|
|
245
317
|
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[];
|