@formfeed/devkit 0.2.0 → 0.3.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 +17 -2
- package/index.cjs +859 -56
- package/index.js +839 -49
- package/package.json +3 -3
- package/types/index.d.cts +9 -4
- package/types/index.d.ts +9 -4
- package/types/lib/brand.d.cts +14 -0
- package/types/lib/brand.d.ts +14 -0
- package/types/lib/local-render.d.cts +39 -3
- package/types/lib/local-render.d.ts +39 -3
- package/types/lib/partials.d.cts +2 -0
- package/types/lib/partials.d.ts +2 -0
- package/types/lib/project-config.d.cts +19 -0
- package/types/lib/project-config.d.ts +19 -0
- package/types/lib/project.d.cts +71 -7
- package/types/lib/project.d.ts +71 -7
- package/types/lib/redact.d.cts +19 -0
- package/types/lib/redact.d.ts +19 -0
- package/types/lib/types/emit-python.d.cts +6 -0
- package/types/lib/types/emit-python.d.ts +6 -0
- package/types/lib/types/emit-ts.d.cts +10 -0
- package/types/lib/types/emit-ts.d.ts +10 -0
- package/types/lib/types/index.d.cts +15 -0
- package/types/lib/types/index.d.ts +15 -0
- package/types/lib/types/model.d.cts +81 -0
- package/types/lib/types/model.d.ts +81 -0
package/README.md
CHANGED
|
@@ -13,7 +13,7 @@ npm install @formfeed/devkit
|
|
|
13
13
|
```ts
|
|
14
14
|
import { defaultData, diagnose, projectAround, readTemplate, renderLocal } from '@formfeed/devkit';
|
|
15
15
|
|
|
16
|
-
// a folder with template.html, template.json,
|
|
16
|
+
// a folder with template.html, template.json, style.css, data/*.json (see the project layout docs)
|
|
17
17
|
const project = projectAround('templates/invoice-de');
|
|
18
18
|
const tpl = readTemplate(project, 'invoice-de');
|
|
19
19
|
const { data } = defaultData(tpl); // data/default.json, or the first data set
|
|
@@ -22,7 +22,22 @@ console.log(diagnose(tpl, data)); // the editor's diagnostics: syntax errors, un
|
|
|
22
22
|
const { document } = await renderLocal(project, tpl, data, { mode: 'print' }); // complete HTML, no browser
|
|
23
23
|
```
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
A folder can hold a Word or PowerPoint document (`template.docx` or `template.pptx`) instead of the
|
|
26
|
+
HTML files; `readTemplate` returns it as `tpl.file` and `templateFileName(kind)` names the file for
|
|
27
|
+
a kind. `diagnose` lists such a template's findings by part and paragraph, `renderOfficeLocal` fills
|
|
28
|
+
it (`bytes`, `warnings`) and `officeSnapshot(bytes)` turns the filled file into readable XML for
|
|
29
|
+
snapshot tests:
|
|
30
|
+
|
|
31
|
+
```ts
|
|
32
|
+
import { officeSnapshot, readTemplate, renderOfficeLocal } from '@formfeed/devkit';
|
|
33
|
+
|
|
34
|
+
const offer = readTemplate(project, 'offer');
|
|
35
|
+
const filled = await renderOfficeLocal(project, offer, { customer: { name: 'Olvarest GmbH' } });
|
|
36
|
+
console.log(filled.warnings, officeSnapshot(filled.bytes));
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
`renderLocal` works on HTML templates only. Errors are `DevkitError` instances with a `code`, which
|
|
40
|
+
the CLI maps to its exit codes.
|
|
26
41
|
|
|
27
42
|
## Documentation
|
|
28
43
|
|