pulpweaver4-cli 0.0.0-stage → 0.0.88
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/dist/bridge.d.ts +25 -0
- package/dist/bridge.js +109 -0
- package/dist/bridge.js.map +1 -0
- package/dist/build.d.ts +12 -0
- package/dist/build.js +95 -0
- package/dist/build.js.map +1 -0
- package/dist/chromium.d.ts +83 -0
- package/dist/chromium.js +213 -0
- package/dist/chromium.js.map +1 -0
- package/dist/commands.d.ts +217 -0
- package/dist/commands.js +162 -0
- package/dist/commands.js.map +1 -0
- package/dist/csl.d.ts +8 -0
- package/dist/csl.js +53 -0
- package/dist/csl.js.map +1 -0
- package/dist/index.d.ts +28 -0
- package/dist/index.js +135 -0
- package/dist/index.js.map +1 -0
- package/dist/lint.d.ts +13 -0
- package/dist/lint.js +80 -0
- package/dist/lint.js.map +1 -0
- package/dist/new.d.ts +12 -0
- package/dist/new.js +92 -0
- package/dist/new.js.map +1 -0
- package/dist/node-fs.d.ts +17 -0
- package/dist/node-fs.js +78 -0
- package/dist/node-fs.js.map +1 -0
- package/dist/page/host.d.ts +111 -0
- package/dist/page/host.js +202 -0
- package/dist/page/host.js.map +1 -0
- package/dist/page/test-setup.d.ts +11 -0
- package/dist/page/test-setup.js +24 -0
- package/dist/page/test-setup.js.map +1 -0
- package/dist/paint-corpus.d.ts +8 -0
- package/dist/paint-corpus.js +89 -0
- package/dist/paint-corpus.js.map +1 -0
- package/dist/plugin-commands.d.ts +26 -0
- package/dist/plugin-commands.js +49 -0
- package/dist/plugin-commands.js.map +1 -0
- package/dist/plugins.d.ts +23 -0
- package/dist/plugins.js +85 -0
- package/dist/plugins.js.map +1 -0
- package/dist/problems.d.ts +29 -0
- package/dist/problems.js +28 -0
- package/dist/problems.js.map +1 -0
- package/dist/profiles.d.ts +37 -0
- package/dist/profiles.js +224 -0
- package/dist/profiles.js.map +1 -0
- package/dist/pw.d.ts +2 -0
- package/dist/pw.js +4 -0
- package/dist/pw.js.map +1 -0
- package/dist/spike.d.ts +27 -0
- package/dist/spike.js +79 -0
- package/dist/spike.js.map +1 -0
- package/dist/test.d.ts +35 -0
- package/dist/test.js +228 -0
- package/dist/test.js.map +1 -0
- package/docs/README.md +9 -0
- package/docs/reference/commands/build.md +40 -0
- package/docs/reference/commands/index.md +42 -0
- package/docs/reference/commands/lint.md +35 -0
- package/docs/reference/commands/new.md +34 -0
- package/docs/reference/commands/preflight.md +35 -0
- package/docs/reference/commands/profiles.md +57 -0
- package/docs/reference/commands/spike.md +30 -0
- package/docs/reference/commands/test.md +47 -0
- package/package.json +40 -4
- package/template/chapters/01-beginning.dj +14 -0
- package/template/chapters/02-writing.dj +16 -0
- package/template/fonts/CrimsonPro-Italic-VF.ttf +0 -0
- package/template/fonts/CrimsonPro-VF.ttf +0 -0
- package/template/fonts/NotoSansSymbols2-Boxes.ttf +0 -0
- package/template/fonts/OFL.txt +94 -0
- package/template/gitignore +2 -0
- package/template/pulpweaver4.toml +23 -0
- package/template/styles/book.css +109 -0
- package/template/tests/book.test.ts +23 -0
- package/README.md +0 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"host.js","sourceRoot":"","sources":["../../src/page/host.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EACL,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,iBAAiB,EAAwE,iBAAiB,EAAE,SAAS,EAAE,WAAW,EAAE,WAAW,EAAuD,UAAU,EACjP,KAAK,EAAE,YAAY,EAAE,WAAW,EAAY,QAAQ,EAAqB,YAAY,GACtF,MAAM,aAAa,CAAA;AAUpB,KAAK,UAAU,IAAI,CAAI,EAAU,EAAE,GAAG,IAAe;IACnD,MAAM,KAAK,GAAG,MAAM,UAAU,CAAC,UAAU,CAAC,EAAE,EAAE,IAAI,CAAC,CAAA;IACnD,IAAI,OAAO,IAAI,KAAK;QAAE,OAAO,KAAK,CAAC,KAAU,CAAA;IAC7C,MAAM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CAAC,CAAC,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAC3J,CAAC,CAAA;IACF,QAAQ,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAA;IACjC,OAAO,MAAM,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,CAAC,CAAA;AACjE,CAAC;AAED,qDAAqD;AACrD,KAAK,UAAU,SAAS,CAAC,EAAO,EAAE,QAA4B;IAC5D,MAAM,GAAG,GAA2B,EAAE,CAAA;IACtC,KAAK,MAAM,IAAI,IAAI,IAAI,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC;QACxD,IAAI,CAAC,IAAI;YAAE,SAAQ;QACnB,IAAI,CAAC;YACH,GAAG,CAAC,IAAI,CAAC,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAA;QACrC,CAAC;QAAC,MAAM,CAAC,CAAC,wDAAwD,CAAC,CAAC;IACtE,CAAC;IACD,OAAO,GAAG,CAAA;AACZ,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `pw test`'s setup file, in the browser: the test API under Vitest
|
|
3
|
+
* (`pulpweaver4/test/vitest`), with the project `build()` builds read from
|
|
4
|
+
* its folder through the CLI (`bridge.ts`'s calls, as a Vitest command),
|
|
5
|
+
* its CSL styles and locales fetched through the CLI's cache as `pw build`'s are,
|
|
6
|
+
* and its plugins loaded by `build()` as `pw build` loads them, its own
|
|
7
|
+
* modules from the project's folder and its npm plugins bundled by the CLI,
|
|
8
|
+
* all served by Vite (`test.ts`), which resolves their `pulpweaver4` to the
|
|
9
|
+
* tests' own core.
|
|
10
|
+
*/
|
|
11
|
+
import 'pulpweaver4/test/vitest';
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `pw test`'s setup file, in the browser: the test API under Vitest
|
|
3
|
+
* (`pulpweaver4/test/vitest`), with the project `build()` builds read from
|
|
4
|
+
* its folder through the CLI (`bridge.ts`'s calls, as a Vitest command),
|
|
5
|
+
* its CSL styles and locales fetched through the CLI's cache as `pw build`'s are,
|
|
6
|
+
* and its plugins loaded by `build()` as `pw build` loads them, its own
|
|
7
|
+
* modules from the project's folder and its npm plugins bundled by the CLI,
|
|
8
|
+
* all served by Vite (`test.ts`), which resolves their `pulpweaver4` to the
|
|
9
|
+
* tests' own core.
|
|
10
|
+
*/
|
|
11
|
+
import 'pulpweaver4/test/vitest';
|
|
12
|
+
import { loadProject } from 'pulpweaver4';
|
|
13
|
+
import { setTestEnvironment, testEnvironment } from 'pulpweaver4/test';
|
|
14
|
+
import { commands } from 'vitest/browser';
|
|
15
|
+
import { HostFS, hostFetchText, pluginImporter } from './host.js';
|
|
16
|
+
const call = commands.pwHostCall;
|
|
17
|
+
globalThis.pwHostCall = (op, args) => call(op, args);
|
|
18
|
+
setTestEnvironment({
|
|
19
|
+
...testEnvironment(),
|
|
20
|
+
project: await loadProject(new HostFS(), { fetchText: hostFetchText }),
|
|
21
|
+
// Vite serves the project's folder at its root, so a test that imports a plugin's module has the one build() loads.
|
|
22
|
+
pluginImporter: pluginImporter({ project: '/', packages: '/@pw-plugins/' }),
|
|
23
|
+
});
|
|
24
|
+
//# sourceMappingURL=test-setup.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test-setup.js","sourceRoot":"","sources":["../../src/page/test-setup.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,yBAAyB,CAAA;AAChC,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AACzC,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAA;AACtE,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AACzC,OAAO,EAAkB,MAAM,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AAEjF,MAAM,IAAI,GAAI,QAAuF,CAAC,UAAU,CAAA;AAChH,UAAU,CAAC,UAAU,GAAG,CAAC,EAAE,EAAE,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,CAAA;AACpD,kBAAkB,CAAC;IACjB,GAAG,eAAe,EAAE;IACpB,OAAO,EAAE,MAAM,WAAW,CAAC,IAAI,MAAM,EAAE,EAAE,EAAE,SAAS,EAAE,aAAa,EAAE,CAAC;IACtE,oHAAoH;IACpH,cAAc,EAAE,cAAc,CAAC,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,eAAe,EAAE,CAAC;CAC5E,CAAC,CAAA"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type ChromiumHostOptions } from './chromium.js';
|
|
2
|
+
/** The corpus module, from the core's sources. */
|
|
3
|
+
export declare const PAINT_CORPUS_MODULE: string;
|
|
4
|
+
/** Each corpus page (or those named) as our PDF and Chromium's, by name. */
|
|
5
|
+
export declare function paintCorpusPdfs(opts: ChromiumHostOptions, names?: readonly string[]): Promise<Map<string, {
|
|
6
|
+
ours: Uint8Array;
|
|
7
|
+
chromium: Uint8Array;
|
|
8
|
+
}>>;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The painter's corpus (core's `paint/testing/corpus.ts`), each page as our
|
|
3
|
+
* PDF and as Chromium prints it: built in headless Chromium, painted and
|
|
4
|
+
* written by the core in the page, then printed by the browser, the test
|
|
5
|
+
* oracle (https://plans.inkylabs.com/pulpweaver#writing-pdfs).
|
|
6
|
+
*/
|
|
7
|
+
import { fileURLToPath } from 'node:url';
|
|
8
|
+
import { ChromiumHost } from './chromium.js';
|
|
9
|
+
/** The corpus module, from the core's sources. */
|
|
10
|
+
export const PAINT_CORPUS_MODULE = fileURLToPath(new URL('../../core/src/paint/testing/corpus.ts', import.meta.url));
|
|
11
|
+
/** Each corpus page (or those named) as our PDF and Chromium's, by name. */
|
|
12
|
+
export async function paintCorpusPdfs(opts, names) {
|
|
13
|
+
const host = await ChromiumHost.launch({ ...opts, extra: { ...opts.extra, testing: PAINT_CORPUS_MODULE } });
|
|
14
|
+
const out = new Map();
|
|
15
|
+
try {
|
|
16
|
+
const all = await host.page.evaluate(() => globalThis.pw.testing.PAINT_CORPUS.map((p) => p.name));
|
|
17
|
+
for (const name of names ?? all) {
|
|
18
|
+
const ours = await host.page.evaluate(async (name) => {
|
|
19
|
+
const pw = globalThis.pw;
|
|
20
|
+
const spec = pw.testing.PAINT_CORPUS.find((p) => p.name === name);
|
|
21
|
+
if (!spec)
|
|
22
|
+
throw new Error(`no corpus page ${name}`);
|
|
23
|
+
document.head.querySelectorAll('style').forEach((s) => s.remove());
|
|
24
|
+
document.body.replaceChildren();
|
|
25
|
+
const hyphenator = new pw.Hyphenator();
|
|
26
|
+
const { page, fonts } = await pw.testing.buildCorpusPage(spec, document.body, {
|
|
27
|
+
font: async (file) => new Uint8Array(await (await fetch(`/fonts/${file}`)).arrayBuffer()),
|
|
28
|
+
image: async (file) => new Uint8Array(await (await fetch(`/images/${file}`)).arrayBuffer()),
|
|
29
|
+
hyphenator,
|
|
30
|
+
});
|
|
31
|
+
await pw.initPdfWriter();
|
|
32
|
+
const doc = await pw.paintDocument([page], fonts);
|
|
33
|
+
doc.metadata = { ...doc.metadata, title: `The painter’s corpus: ${spec.name}` };
|
|
34
|
+
// The page alone, at the paper's size, for Chromium's print.
|
|
35
|
+
const style = document.createElement('style');
|
|
36
|
+
style.textContent = `@page { size: ${spec.width}px ${spec.height}px; margin: 0 } html, body { margin: 0; padding: 0 }`;
|
|
37
|
+
document.head.append(style);
|
|
38
|
+
return [...pw.writePdf(doc)];
|
|
39
|
+
}, name);
|
|
40
|
+
const { width, height, oracle } = await host.page.evaluate((name) => {
|
|
41
|
+
const spec = globalThis.pw.testing.PAINT_CORPUS.find((p) => p.name === name);
|
|
42
|
+
return { width: spec.width, height: spec.height, oracle: spec.oracle };
|
|
43
|
+
}, name);
|
|
44
|
+
const chromium = oracle === 'screen'
|
|
45
|
+
? await screenPdf(host, width, height)
|
|
46
|
+
: await host.page.pdf({
|
|
47
|
+
width: `${width}px`, height: `${height}px`, printBackground: true, preferCSSPageSize: true,
|
|
48
|
+
margin: { top: '0', right: '0', bottom: '0', left: '0' },
|
|
49
|
+
});
|
|
50
|
+
out.set(name, { ours: new Uint8Array(ours), chromium: new Uint8Array(chromium) });
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
finally {
|
|
54
|
+
await host.close();
|
|
55
|
+
}
|
|
56
|
+
return out;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* What Chromium draws on screen of the page (`.pw-page`), at 600 dpi (6.25
|
|
60
|
+
* device pixels a CSS px), as the one image of a PDF of the page's size:
|
|
61
|
+
* the oracle of a page whose print Chromium gets wrong.
|
|
62
|
+
*/
|
|
63
|
+
async function screenPdf(host, width, height) {
|
|
64
|
+
const cdp = await host.page.context().newCDPSession(host.page);
|
|
65
|
+
const scale = 600 / 96;
|
|
66
|
+
await cdp.send('Emulation.setDeviceMetricsOverride', { width, height, deviceScaleFactor: scale, mobile: false });
|
|
67
|
+
try {
|
|
68
|
+
const box = await host.page.evaluate(() => {
|
|
69
|
+
const r = document.querySelector('.pw-page').getBoundingClientRect();
|
|
70
|
+
return { x: r.left, y: r.top, width: r.width, height: r.height };
|
|
71
|
+
});
|
|
72
|
+
const png = await host.page.screenshot({ clip: box, animations: 'disabled' });
|
|
73
|
+
const pdf = await host.page.evaluate(async ({ png, width, height }) => {
|
|
74
|
+
const pw = globalThis.pw;
|
|
75
|
+
const pt = 0.75;
|
|
76
|
+
return [...pw.writePdf({
|
|
77
|
+
fonts: [],
|
|
78
|
+
images: [{ data: Uint8Array.from(png) }],
|
|
79
|
+
pages: [{ width: width * pt, height: height * pt, ops: [{ op: 'image', image: 0, x: 0, y: 0, width: width * pt, height: height * pt }] }],
|
|
80
|
+
})];
|
|
81
|
+
}, { png: [...png], width, height });
|
|
82
|
+
return new Uint8Array(pdf);
|
|
83
|
+
}
|
|
84
|
+
finally {
|
|
85
|
+
await cdp.send('Emulation.clearDeviceMetricsOverride');
|
|
86
|
+
await cdp.detach();
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
//# sourceMappingURL=paint-corpus.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paint-corpus.js","sourceRoot":"","sources":["../src/paint-corpus.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AACxC,OAAO,EAAE,YAAY,EAA4B,MAAM,eAAe,CAAA;AAKtE,kDAAkD;AAClD,MAAM,CAAC,MAAM,mBAAmB,GAAG,aAAa,CAAC,IAAI,GAAG,CAAC,wCAAwC,EAAE,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,CAAA;AAEpH,4EAA4E;AAC5E,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,IAAyB,EAAE,KAAyB;IAExF,MAAM,IAAI,GAAG,MAAM,YAAY,CAAC,MAAM,CAAC,EAAE,GAAG,IAAI,EAAE,KAAK,EAAE,EAAE,GAAG,IAAI,CAAC,KAAK,EAAE,OAAO,EAAE,mBAAmB,EAAE,EAAE,CAAC,CAAA;IAC3G,MAAM,GAAG,GAAG,IAAI,GAAG,EAAsD,CAAA;IACzE,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAE,UAAoC,CAAC,EAAE,CAAC,OAAO,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAA;QAC5H,KAAK,MAAM,IAAI,IAAI,KAAK,IAAI,GAAG,EAAE,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import { type ColourEnvironment } from './problems.js';
|
|
3
|
+
/** A project's plugins, as its commands need them. */
|
|
4
|
+
export interface ProjectPlugins {
|
|
5
|
+
readonly project: Project;
|
|
6
|
+
readonly registry: PluginRegistry;
|
|
7
|
+
/** What loading the project and its plugins found. */
|
|
8
|
+
readonly problems: readonly Problem[];
|
|
9
|
+
}
|
|
10
|
+
/** A plugin's command, as `pw --help` lists it. */
|
|
11
|
+
export interface PluginCommand {
|
|
12
|
+
readonly name: string;
|
|
13
|
+
readonly plugin: string;
|
|
14
|
+
readonly usage?: string;
|
|
15
|
+
readonly description: string;
|
|
16
|
+
}
|
|
17
|
+
/** The project in `dir` with its plugins, or nothing if `dir` has no `pulpweaver4.toml`. */
|
|
18
|
+
export declare function loadProjectPlugins(dir: string): Promise<ProjectPlugins | undefined>;
|
|
19
|
+
/** The plugins' commands, by name. */
|
|
20
|
+
export declare function pluginCommands(registry: PluginRegistry): PluginCommand[];
|
|
21
|
+
/**
|
|
22
|
+
* Runs the plugins' command `name` with `args`, if one registered it:
|
|
23
|
+
* its exit status (0 if it gives none), or 1 if it threw. `undefined` if
|
|
24
|
+
* no plugin has the command, having printed what loading them found.
|
|
25
|
+
*/
|
|
26
|
+
export declare function runPluginCommand(loaded: ProjectPlugins, name: string, args: readonly string[], out: (line: string) => void, env: ColourEnvironment): Promise<number | undefined>;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Plugins' commands (https://plans.inkylabs.com/pulpweaver#plugins): in a
|
|
3
|
+
* project, `pw <command>` that isn't one of pw's own runs the command of
|
|
4
|
+
* the plugin that registered it, its plugins loaded in Node as
|
|
5
|
+
* `nodePluginImporter` loads them, and `pw --help` lists them after pw's.
|
|
6
|
+
* A command that throws is named as a plugin that throws anywhere is, and
|
|
7
|
+
* fails with exit status 1.
|
|
8
|
+
*/
|
|
9
|
+
import { stat } from 'node:fs/promises';
|
|
10
|
+
import { join } from 'node:path';
|
|
11
|
+
import { loadPlugins, loadProject, tryPluginAsync } from 'pulpweaver4';
|
|
12
|
+
import { NodeFS } from './node-fs.js';
|
|
13
|
+
import { nodePluginImporter } from './plugins.js';
|
|
14
|
+
import { printProblems } from './problems.js';
|
|
15
|
+
/** The project in `dir` with its plugins, or nothing if `dir` has no `pulpweaver4.toml`. */
|
|
16
|
+
export async function loadProjectPlugins(dir) {
|
|
17
|
+
if (!(await stat(join(dir, 'pulpweaver4.toml')).catch(() => undefined)))
|
|
18
|
+
return undefined;
|
|
19
|
+
const project = await loadProject(new NodeFS(dir));
|
|
20
|
+
const loaded = await loadPlugins(project, { importer: nodePluginImporter(dir) });
|
|
21
|
+
return { project: loaded.project, registry: loaded.registry, problems: [...loaded.project.problems, ...loaded.problems] };
|
|
22
|
+
}
|
|
23
|
+
/** The plugins' commands, by name. */
|
|
24
|
+
export function pluginCommands(registry) {
|
|
25
|
+
return [...registry.commands].sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0)).map(([name, { plugin, definition: d }]) => ({
|
|
26
|
+
name, plugin, description: d.description, ...(d.usage === undefined ? {} : { usage: d.usage }),
|
|
27
|
+
}));
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Runs the plugins' command `name` with `args`, if one registered it:
|
|
31
|
+
* its exit status (0 if it gives none), or 1 if it threw. `undefined` if
|
|
32
|
+
* no plugin has the command, having printed what loading them found.
|
|
33
|
+
*/
|
|
34
|
+
export async function runPluginCommand(loaded, name, args, out, env) {
|
|
35
|
+
const sources = new Map([['pulpweaver4.toml', loaded.project.configText]]);
|
|
36
|
+
const owned = loaded.registry.commands.get(name);
|
|
37
|
+
if (!owned) {
|
|
38
|
+
printProblems(loaded.problems, sources, out, { env });
|
|
39
|
+
return undefined;
|
|
40
|
+
}
|
|
41
|
+
const problems = [];
|
|
42
|
+
const status = await tryPluginAsync(owned.plugin, 'command', { what: `pw ${name}`, leftOut: `pw ${name} stopped` }, problems, () => owned.definition.run(args, { plugin: owned.plugin, fs: loaded.project.fs, out }));
|
|
43
|
+
if (problems.length) {
|
|
44
|
+
printProblems(problems, sources, out, { env });
|
|
45
|
+
return 1;
|
|
46
|
+
}
|
|
47
|
+
return typeof status === 'number' ? status : 0;
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=plugin-commands.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin-commands.js","sourceRoot":"","sources":["../src/plugin-commands.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAA;AACvC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAChC,OAAO,EAAE,WAAW,EAAE,WAAW,EAAmD,cAAc,EAAE,MAAM,aAAa,CAAA;AACvH,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AACrC,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAA;AACjD,OAAO,EAAE,aAAa,EAA0B,MAAM,eAAe,CAAA;AAkBrE,4FAA4F;AAC5F,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAAC,GAAW;IAClD,IAAI,CAAC,CAAC,MAAM,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,kBAAkB,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;QAAE,OAAO,SAAS,CAAA;IACzF,MAAM,OAAO,GAAG,MAAM,WAAW,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAA;IAClD,MAAM,MAAM,GAAG,MAAM,WAAW,CAAC,OAAO,EAAE,EAAE,QAAQ,EAAE,kBAAkB,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA;IAChF,OAAO,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,QAAQ,EAAE,MAAM,CAAC,QAAQ,EAAE,QAAQ,EAAE,CAAC,GAAG,MAAM,CAAC,OAAO,CAAC,QAAQ,EAAE,GAAG,MAAM,CAAC,QAAQ,C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,GAAc,EAAE,CAAA;IAC9B,MAAM,MAAM,GAAG,MAAM,cAAc,CAAC,KAAK,CAAC,MAAM,EAAE,SAAS,EAAE,EAAE,IAAI,EAAE,MAAM,IAAI,EAAE,EAAE,OAAO,EAAE,MAAM,IAAI,UAAU,EAAE,EAAE,QAAQ,EAAE,GAAG,EAAE,CACjI,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,EAAE,EAAE,MAAM,CAAC,OAAO,CAAC,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC,CAAA;IACnF,IAAI,QAAQ,CAAC,MAAM,EAAE,CAAC;QACpB,aAAa,CAAC,QAAQ,EAAE,OAAO,EAAE,GAAG,EAAE,EAAE,GAAG,EAAE,CAAC,CAAA;QAC9C,OAAO,CAAC,CAAA;IACV,CAAC;IACD,OAAO,OAAO,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAA;AAChD,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { PluginImporter } from 'pulpweaver4';
|
|
2
|
+
interface PackageJson {
|
|
3
|
+
exports?: unknown;
|
|
4
|
+
module?: string;
|
|
5
|
+
main?: string;
|
|
6
|
+
}
|
|
7
|
+
/** A package's folder: `node_modules/<name>` in the project's folder or the nearest folder above it that has one. */
|
|
8
|
+
export declare function packageDir(name: string, from: string): Promise<{
|
|
9
|
+
dir: string;
|
|
10
|
+
json: PackageJson;
|
|
11
|
+
}>;
|
|
12
|
+
/** The file a package's `import` names: its `exports` for `.` under `import`, `node` or `default`, else `module`, `main` or `index.js`. */
|
|
13
|
+
export declare function packageEntry(json: PackageJson): string;
|
|
14
|
+
/**
|
|
15
|
+
* Has Node resolve `pulpweaver4` and `pulpweaver4/…`, wherever this process
|
|
16
|
+
* imports them, as the module at `parentURL` (this one) does: a plugin's,
|
|
17
|
+
* in the project or in its `node_modules`, is the CLI's core, which the
|
|
18
|
+
* project needn't have installed. Once per process.
|
|
19
|
+
*/
|
|
20
|
+
export declare function resolveCoreAsCli(parentURL?: string): void;
|
|
21
|
+
/** Imports the project's modules from its folder and its npm plugins from `node_modules`, starting there. */
|
|
22
|
+
export declare function nodePluginImporter(projectDir: string): PluginImporter;
|
|
23
|
+
export {};
|
package/dist/plugins.js
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Plugins on Node (https://plans.inkylabs.com/pulpweaver#plugins): the
|
|
3
|
+
* CLI is the host with `node_modules`, so it imports a project's npm
|
|
4
|
+
* plugins (`pulpweaver4-epub = {}`) from there, as Node would from the
|
|
5
|
+
* project's folder. A module in the project is imported from its file, as
|
|
6
|
+
* pw's browser hosts import it from their servers (`page/host.ts`'s
|
|
7
|
+
* `pluginImporter`), and in both, a plugin's `pulpweaver4` is pw's own
|
|
8
|
+
* core (#148). URLs load as the core loads them anywhere.
|
|
9
|
+
*/
|
|
10
|
+
import { readFile } from 'node:fs/promises';
|
|
11
|
+
import { registerHooks } from 'node:module';
|
|
12
|
+
import { dirname, join, relative, resolve, sep } from 'node:path';
|
|
13
|
+
import { pathToFileURL } from 'node:url';
|
|
14
|
+
/** A package's folder: `node_modules/<name>` in the project's folder or the nearest folder above it that has one. */
|
|
15
|
+
export async function packageDir(name, from) {
|
|
16
|
+
if (!/^(@[a-z0-9-~][a-z0-9-._~]*\/)?[a-z0-9-~][a-z0-9-._~]*$/.test(name))
|
|
17
|
+
throw new Error(`${JSON.stringify(name)} isn't an npm package's name`);
|
|
18
|
+
for (let dir = resolve(from);; dir = dirname(dir)) {
|
|
19
|
+
const candidate = join(dir, 'node_modules', name);
|
|
20
|
+
const text = await readFile(join(candidate, 'package.json'), 'utf8').catch(() => undefined);
|
|
21
|
+
if (text !== undefined)
|
|
22
|
+
return { dir: candidate, json: JSON.parse(text) };
|
|
23
|
+
if (dirname(dir) === dir)
|
|
24
|
+
throw new Error(`${name} isn't installed: run npm install ${name} in the project`);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
/** The file a package's `import` names: its `exports` for `.` under `import`, `node` or `default`, else `module`, `main` or `index.js`. */
|
|
28
|
+
export function packageEntry(json) {
|
|
29
|
+
const pick = (target) => {
|
|
30
|
+
if (typeof target === 'string')
|
|
31
|
+
return target;
|
|
32
|
+
if (Array.isArray(target))
|
|
33
|
+
return target.map(pick).find((t) => t !== undefined);
|
|
34
|
+
if (typeof target !== 'object' || target === null)
|
|
35
|
+
return undefined;
|
|
36
|
+
const conditions = target;
|
|
37
|
+
if (Object.keys(conditions).some((k) => k.startsWith('.')))
|
|
38
|
+
return pick(conditions['.']);
|
|
39
|
+
for (const condition of ['import', 'node', 'default']) {
|
|
40
|
+
const found = Object.hasOwn(conditions, condition) ? pick(conditions[condition]) : undefined;
|
|
41
|
+
if (found !== undefined)
|
|
42
|
+
return found;
|
|
43
|
+
}
|
|
44
|
+
return undefined;
|
|
45
|
+
};
|
|
46
|
+
return (json.exports === undefined ? undefined : pick(json.exports)) ?? json.module ?? json.main ?? 'index.js';
|
|
47
|
+
}
|
|
48
|
+
let resolvingCore = false;
|
|
49
|
+
/**
|
|
50
|
+
* Has Node resolve `pulpweaver4` and `pulpweaver4/…`, wherever this process
|
|
51
|
+
* imports them, as the module at `parentURL` (this one) does: a plugin's,
|
|
52
|
+
* in the project or in its `node_modules`, is the CLI's core, which the
|
|
53
|
+
* project needn't have installed. Once per process.
|
|
54
|
+
*/
|
|
55
|
+
export function resolveCoreAsCli(parentURL = import.meta.url) {
|
|
56
|
+
if (resolvingCore)
|
|
57
|
+
return;
|
|
58
|
+
resolvingCore = true;
|
|
59
|
+
registerHooks({
|
|
60
|
+
resolve: (specifier, context, next) => next(specifier, /^pulpweaver4(\/|$)/.test(specifier) ? { ...context, parentURL } : context),
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
/** Imports the project's modules from its folder and its npm plugins from `node_modules`, starting there. */
|
|
64
|
+
export function nodePluginImporter(projectDir) {
|
|
65
|
+
resolveCoreAsCli();
|
|
66
|
+
const inside = (dir, path) => {
|
|
67
|
+
const file = resolve(dir, path);
|
|
68
|
+
if (relative(dir, file).split(sep)[0] === '..')
|
|
69
|
+
throw new Error(`${path} is outside the package`);
|
|
70
|
+
return file;
|
|
71
|
+
};
|
|
72
|
+
return {
|
|
73
|
+
// The file the core read the source from, so that its imports resolve beside it.
|
|
74
|
+
text: (_source, path) => import(/* @vite-ignore */ pathToFileURL(inside(projectDir, path)).href),
|
|
75
|
+
async package(name) {
|
|
76
|
+
const { dir, json } = await packageDir(name, projectDir);
|
|
77
|
+
return import(/* @vite-ignore */ pathToFileURL(inside(dir, packageEntry(json))).href);
|
|
78
|
+
},
|
|
79
|
+
async packageFile(name, path) {
|
|
80
|
+
const { dir, json } = await packageDir(name, projectDir);
|
|
81
|
+
return readFile(inside(dir, join(dirname(packageEntry(json)), path)), 'utf8');
|
|
82
|
+
},
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
//# sourceMappingURL=plugins.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugins.js","sourceRoot":"","sources":["../src/plugins.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAC3C,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAC3C,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAA;AACjE,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AASxC,qHAAqH;AACrH,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,IAAY,EAAE,IAAY;IACzD,IAAI,CAAC,wDAAwD,CAAC,IAAI,CAAC,IAAI,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,8BAA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AAM,IAAI,GAAG,OAAO,CAAC,GAAG,EAAE,IAAI,CAAC,CAAA;QAC/B,IAAI,QAAQ,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,IAAI;YAAE,MAAM,IAAI,KAAK,CAAC,GAAG,IAAI,yBAAyB,CAAC,CAAA;QACjG,OAAO,IAAI,CAAA;IACb,CAAC,CAAA;IACD,OAAO;QACL,iFAAiF;QACjF,IAAI,EAAE,CAAC,OAAO,EAAE,IAAI,EAAE,EAAE,CAAC,MAAM,CAAC,kBAAkB,CAAC,aAAa,CAAC,MAAM,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;QAChG,KAAK,CAAC,OAAO,CAAC,IAAI;YAChB,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,MAAM,UAAU,CAAC,IAAI,EAAE,UAAU,CAAC,CAAA;YACxD,OAAO,MAAM,CAAC,kBAAkB,CAAC,aAAa,CAAC,MAAM,CAAC,GAAG,EAAE,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAA;QACvF,CAAC;QACD,KAAK,CAAC,WAAW,CAAC,IAAI,EAAE,IAAI;YAC1B,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,MAAM,UAAU,CAAC,IAAI,EAAE,UAAU,CAAC,CAAA;YACxD,OAAO,QAAQ,CAAC,MAAM,CAAC,GAAG,EAAE,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,EAAE,MAAM,CAAC,CAAA;QAC/E,CAAC;KACF,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Problems on the terminal (https://plans.inkylabs.com/pulpweaver#when-it-fails):
|
|
3
|
+
* the core's `formatProblems`, in colour when pw writes to a terminal that
|
|
4
|
+
* shows it, as compilers do. `pw build`, `pw lint` and `pw test` print what
|
|
5
|
+
* they find with this.
|
|
6
|
+
*/
|
|
7
|
+
import { type Problem, type Sources } from 'pulpweaver4';
|
|
8
|
+
/** The environment colour depends on (https://no-color.org, and `FORCE_COLOR` as Node reads it). */
|
|
9
|
+
export interface ColourEnvironment {
|
|
10
|
+
NO_COLOR?: string | undefined;
|
|
11
|
+
FORCE_COLOR?: string | undefined;
|
|
12
|
+
TERM?: string | undefined;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Whether to colour what goes to `stream`: a TTY, unless `NO_COLOR` is set
|
|
16
|
+
* or the terminal is `dumb`; `FORCE_COLOR` (anything but `0`) colours even
|
|
17
|
+
* a pipe, and `FORCE_COLOR=0` never.
|
|
18
|
+
*/
|
|
19
|
+
export declare function useColour(stream: {
|
|
20
|
+
readonly isTTY?: boolean;
|
|
21
|
+
}, env?: ColourEnvironment): boolean;
|
|
22
|
+
/** The problems as pw prints them, sorted, with their lines and the count; nothing if there are none. */
|
|
23
|
+
export declare function printProblems(problems: readonly Problem[], sources: Sources, out: (text: string) => void, options?: {
|
|
24
|
+
readonly stream?: {
|
|
25
|
+
readonly isTTY?: boolean;
|
|
26
|
+
};
|
|
27
|
+
readonly env?: ColourEnvironment;
|
|
28
|
+
readonly files?: readonly string[];
|
|
29
|
+
}): void;
|
package/dist/problems.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Problems on the terminal (https://plans.inkylabs.com/pulpweaver#when-it-fails):
|
|
3
|
+
* the core's `formatProblems`, in colour when pw writes to a terminal that
|
|
4
|
+
* shows it, as compilers do. `pw build`, `pw lint` and `pw test` print what
|
|
5
|
+
* they find with this.
|
|
6
|
+
*/
|
|
7
|
+
import { formatProblems } from 'pulpweaver4';
|
|
8
|
+
/**
|
|
9
|
+
* Whether to colour what goes to `stream`: a TTY, unless `NO_COLOR` is set
|
|
10
|
+
* or the terminal is `dumb`; `FORCE_COLOR` (anything but `0`) colours even
|
|
11
|
+
* a pipe, and `FORCE_COLOR=0` never.
|
|
12
|
+
*/
|
|
13
|
+
export function useColour(stream, env = process.env) {
|
|
14
|
+
if (env.FORCE_COLOR !== undefined && env.FORCE_COLOR !== '')
|
|
15
|
+
return env.FORCE_COLOR !== '0';
|
|
16
|
+
if (env.NO_COLOR !== undefined && env.NO_COLOR !== '')
|
|
17
|
+
return false;
|
|
18
|
+
return stream.isTTY === true && env.TERM !== 'dumb';
|
|
19
|
+
}
|
|
20
|
+
/** The problems as pw prints them, sorted, with their lines and the count; nothing if there are none. */
|
|
21
|
+
export function printProblems(problems, sources, out, options = {}) {
|
|
22
|
+
const text = formatProblems(problems, sources, {
|
|
23
|
+
colour: useColour(options.stream ?? process.stdout, options.env ?? process.env), ...(options.files ? { files: options.files } : {}),
|
|
24
|
+
});
|
|
25
|
+
if (text)
|
|
26
|
+
out(text);
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=problems.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"problems.js","sourceRoot":"","sources":["../src/problems.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,cAAc,EAA8B,MAAM,aAAa,CAAA;AASxE;;;;GAIG;AACH,MAAM,UAAU,SAAS,CAAC,MAAoC,EAAE,GAAG,GAAsB,OAAO,CAAC,GAAG;IAClG,IAAI,GAAG,CAAC,WAAW,KAAK,SAAS,IAAI,GAAG,CAAC,WAAW,KAAK,EAAE;QAAE,OAAO,GAAG,CAAC,WAAW,KAAK,GAAG,CAAA;IAC3F,IAAI,GAAG,CAAC,QAAQ,KAAK,SAAS,IAAI,GAAG,CAAC,QAAQ,KAAK,EAAE;QAAE,OAAO,KAAK,CAAA;IACnE,OAAO,MAAM,CAAC,KAAK,KAAK,IAAI,IAAI,GAAG,CAAC,IAAI,KAAK,MAAM,CAAA;AACrD,CAAC;AAED,yGAAyG;AACzG,MAAM,UAAU,aAAa,CAC3B,QAA4B,EAAE,OAAgB,EAAE,GAA2B,EAC3E,OAAO,GAA6H,EAAE;IAEtI,MAAM,IAAI,GAAG,cAAc,CAAC,QAAQ,EAAE,OAAO,EAAE;QAC7C,MAAM,EAAE,SAAS,CAAC,OAAO,CAAC,MAAM,IAAI,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,OAAO,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KACpI,CAAC,CAAA;IACF,IAAI,IAAI;QAAE,GAAG,CAAC,IAAI,CAAC,CAAA;AACrB,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { type StandardOutputIntent } from 'pulpweaver4';
|
|
2
|
+
/** Where pw keeps what it fetches: `$XDG_CACHE_HOME/pulpweaver4`, else `~/.cache/pulpweaver4`. */
|
|
3
|
+
export declare function cacheDir(env?: NodeJS.ProcessEnv): string;
|
|
4
|
+
/** Where the cache keeps a profile's file. */
|
|
5
|
+
export declare function cachedProfilePath(file: string, env?: NodeJS.ProcessEnv): string;
|
|
6
|
+
/** A profile's file from the cache, if it is there. */
|
|
7
|
+
export declare function cachedProfile(file: string, env?: NodeJS.ProcessEnv): Promise<Uint8Array | undefined>;
|
|
8
|
+
/**
|
|
9
|
+
* A shareable standard profile, from pw's cache or fetched from the ICC's
|
|
10
|
+
* registry into it. The core checks its hash, so a bad file in the cache
|
|
11
|
+
* fails the build rather than printing in the wrong colours.
|
|
12
|
+
*/
|
|
13
|
+
export declare function standardProfile(url: string, file: string, env?: NodeJS.ProcessEnv): Promise<Uint8Array>;
|
|
14
|
+
/** What `getProfile` reads and writes: the environment (for the cache), its output, the user's answer, and the network. */
|
|
15
|
+
export interface GetProfileOptions {
|
|
16
|
+
env?: NodeJS.ProcessEnv;
|
|
17
|
+
out: (line: string) => void;
|
|
18
|
+
/** The user accepted the owner's licence beforehand (`--accept-licence`). */
|
|
19
|
+
accepted?: boolean;
|
|
20
|
+
/** Asks the user a question and gives their answer; undefined where no one can answer (no terminal). */
|
|
21
|
+
ask?: (question: string) => Promise<string | undefined>;
|
|
22
|
+
fetch?: typeof fetch;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Puts a standard output intent's profile in pw's cache, checked against
|
|
26
|
+
* its pinned SHA-256: from the ICC's registry if it may be shared, or, if
|
|
27
|
+
* its owner gives it to each user to download, from the owner's own zip
|
|
28
|
+
* once the user accepts the owner's licence. Returns the exit status: 0 when
|
|
29
|
+
* the profile is in the cache, 1 when it couldn't be put there or the user
|
|
30
|
+
* declined, 2 when no one was there to accept the licence.
|
|
31
|
+
*/
|
|
32
|
+
export declare function getProfile(intent: StandardOutputIntent, options: GetProfileOptions): Promise<number>;
|
|
33
|
+
/**
|
|
34
|
+
* `pw profiles get <name>… [--accept-licence]` and `pw profiles list`.
|
|
35
|
+
* `io` stands in for the terminal and the network in the tests.
|
|
36
|
+
*/
|
|
37
|
+
export declare function profilesCommand(args: readonly string[], out: (line: string) => void, env: NodeJS.ProcessEnv, io?: Pick<GetProfileOptions, 'ask' | 'fetch'>): Promise<number>;
|