@plexus-ms/cli-template 0.0.0-stage → 0.129.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/LICENSE.copier +25 -0
- package/dist/bin.d.ts +3 -0
- package/dist/bin.d.ts.map +1 -0
- package/dist/bin.js +6 -0
- package/dist/bin.js.map +1 -0
- package/dist/cli.d.ts +12 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +412 -0
- package/dist/cli.js.map +1 -0
- package/dist/directory.d.ts +16 -0
- package/dist/directory.d.ts.map +1 -0
- package/dist/directory.js +240 -0
- package/dist/directory.js.map +1 -0
- package/dist/errors.d.ts +8 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +15 -0
- package/dist/errors.js.map +1 -0
- package/dist/files.d.ts +17 -0
- package/dist/files.d.ts.map +1 -0
- package/dist/files.js +209 -0
- package/dist/files.js.map +1 -0
- package/dist/git-merge-file.d.ts +4 -0
- package/dist/git-merge-file.d.ts.map +1 -0
- package/dist/git-merge-file.js +95 -0
- package/dist/git-merge-file.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +15 -0
- package/dist/index.js.map +1 -0
- package/dist/jinja.d.ts +7 -0
- package/dist/jinja.d.ts.map +1 -0
- package/dist/jinja.js +36 -0
- package/dist/jinja.js.map +1 -0
- package/dist/manifest.d.ts +13 -0
- package/dist/manifest.d.ts.map +1 -0
- package/dist/manifest.js +209 -0
- package/dist/manifest.js.map +1 -0
- package/dist/merge.d.ts +4 -0
- package/dist/merge.d.ts.map +1 -0
- package/dist/merge.js +185 -0
- package/dist/merge.js.map +1 -0
- package/dist/questions.d.ts +14 -0
- package/dist/questions.d.ts.map +1 -0
- package/dist/questions.js +290 -0
- package/dist/questions.js.map +1 -0
- package/dist/render.d.ts +4 -0
- package/dist/render.d.ts.map +1 -0
- package/dist/render.js +245 -0
- package/dist/render.js.map +1 -0
- package/dist/types.d.ts +130 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +80 -0
- package/dist/types.js.map +1 -0
- package/package.json +45 -4
- package/README.md +0 -3
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
// The answers of a template's questions, resolved against the given answers,
|
|
2
|
+
// and the given answers a render leaves unused.
|
|
3
|
+
//
|
|
4
|
+
// `resolveAnswers` resolves one template's questions in the manifest's order.
|
|
5
|
+
// What a default, `when`, `choices` or `validator` may use is the template's
|
|
6
|
+
// earlier answers and the scope `render` passes in, the variables that do not
|
|
7
|
+
// come from the template's own questions. It returns two views of the result:
|
|
8
|
+
// the answers `render` reports, and what the questions add to the context the
|
|
9
|
+
// template's files render in. The two differ where a question is skipped: it
|
|
10
|
+
// is absent from the answers, while its default, where it has one, is in the
|
|
11
|
+
// context.
|
|
12
|
+
//
|
|
13
|
+
// A question takes the given answer of its name, and without one its default; a
|
|
14
|
+
// question with neither is an error, one per question, naming its help text, so
|
|
15
|
+
// that one render lists all of them. Either is then cast to the question's type
|
|
16
|
+
// and checked against its choices, and a failure is an error naming the question.
|
|
17
|
+
// A given answer that no question of the render's manifests owns and none of them
|
|
18
|
+
// reads is unused.
|
|
19
|
+
//
|
|
20
|
+
// What the engine resolves is what copier (v9.19.1, see LICENSE.copier) resolves
|
|
21
|
+
// in `_ask` and `Question`, without prompts, answers files, `ask`, `secret`,
|
|
22
|
+
// `multiselect` or user defaults. Where it deliberately differs, a sentence below
|
|
23
|
+
// says so, and a test pins the engine's side.
|
|
24
|
+
//
|
|
25
|
+
// What a question sees. Its default, `when`, choices and validator are rendered
|
|
26
|
+
// in the scope, in every given answer to a question of this template, as given,
|
|
27
|
+
// and in the resolved answer of each question before it, which replaces the given
|
|
28
|
+
// one. A later question's default is not seen, and neither is a given answer that
|
|
29
|
+
// no question of this template owns.
|
|
30
|
+
//
|
|
31
|
+
// Strings in a manifest are Jinja, rendered to text. A list is rendered item by
|
|
32
|
+
// item, anything else is taken as it is. A default is rendered and then cast by
|
|
33
|
+
// the type, as copier does, so `"{{ n + 1 }}"` is 2 for `int` and "2" for `str`,
|
|
34
|
+
// `"true"` is true for `bool`, and `"{{ a }}-{{ b }}"` is text. `evaluate` of the
|
|
35
|
+
// adapter is not used: a native value and render-then-cast can differ, and one
|
|
36
|
+
// rule is better than two. An undefined variable is an error in every field,
|
|
37
|
+
// where copier's default Jinja renders an empty string.
|
|
38
|
+
//
|
|
39
|
+
// Type: the question's own, else that of its raw default (a string `str`, a bool
|
|
40
|
+
// `bool`, a whole number `int`, any other number `float`), else `yaml`. Casts:
|
|
41
|
+
// str a string; a number is its text, a bool is `True` or `False`; a list,
|
|
42
|
+
// a map and null are errors
|
|
43
|
+
// int a safe integer, or a string of digits with a sign and whitespace
|
|
44
|
+
// float a number, or a string that reads as one: sign, fraction or leading
|
|
45
|
+
// dot, exponent, whitespace
|
|
46
|
+
// bool as copier's `cast_to_bool`: a number, or a string Python's `float`
|
|
47
|
+
// reads (`0_0` and `nan` included, `0x0` not), by its value; any other
|
|
48
|
+
// string is true unless it is blank or one of n no f false off ~ null none,
|
|
49
|
+
// in any case; a list or map by whether it is empty
|
|
50
|
+
// json a string is parsed as JSON; any other value is taken as it is
|
|
51
|
+
// yaml a string is parsed as YAML 1.1 (`yes`, `010`, `1:30`) by the `yaml`
|
|
52
|
+
// package; any other value is taken as it is
|
|
53
|
+
// A null is an error for every type but `json` and `yaml`.
|
|
54
|
+
//
|
|
55
|
+
// `when` is rendered and read as a bool. A question it skips is left out of the
|
|
56
|
+
// reported answers. A given answer is always cast, checked against the choices and
|
|
57
|
+
// validated, as in copier, where `get_default` reads the given answer first; the
|
|
58
|
+
// default of a skipped question is cast and checked but not validated. A skipped
|
|
59
|
+
// question with neither a given answer nor a default is absent.
|
|
60
|
+
//
|
|
61
|
+
// `choices` is a list, a map of label to value, or a string of Jinja that renders
|
|
62
|
+
// YAML 1.1 of either, which must be a list or a map; an empty one restricts
|
|
63
|
+
// nothing. List items are rendered, every value is cast to the question's type,
|
|
64
|
+
// and the answer, once cast, must equal one of them deeply and strictly. In a map
|
|
65
|
+
// a null value stands for its label, as it does in copier; the answer is then the
|
|
66
|
+
// label. A manifest's choices keep their order, which the error message lists.
|
|
67
|
+
//
|
|
68
|
+
// `validator` is rendered with the cast answer added to the context; its output,
|
|
69
|
+
// trimmed, is the error message when it is not empty.
|
|
70
|
+
//
|
|
71
|
+
// Where the engine differs from copier on purpose:
|
|
72
|
+
// - `int` of 1.5 or of a bool is an error, where copier truncates and takes 1.
|
|
73
|
+
// - `int` beyond 2^53 - 1 is an error, where Python's integers have no limit.
|
|
74
|
+
// - A string with an underscore, `nan` or `inf` is no `int` or `float`, where
|
|
75
|
+
// Python's `float` reads them; `bool` still follows Python for them.
|
|
76
|
+
// - A number carries no `.0`: a `float` of 1.0 prints `1`, a `str` of it is "1", and
|
|
77
|
+
// an untyped default written `1.0` is inferred as `int`.
|
|
78
|
+
// - A two-item list among choices is a list value, not copier's label and value,
|
|
79
|
+
// and a null item of a list is the value null; only a map has labels.
|
|
80
|
+
// - The extended choices of copier (`{value, validator}`) and `multiselect` do
|
|
81
|
+
// not exist.
|
|
82
|
+
// - `float` of a bool is an error as well.
|
|
83
|
+
// - A given answer that no question of the template owns is not in view of its
|
|
84
|
+
// questions, where copier shows every given answer.
|
|
85
|
+
// - YAML is read by the `yaml` package's 1.1 mode, not by PyYAML: `y` and `n` are
|
|
86
|
+
// booleans here and strings there, and a duplicate key is an error here.
|
|
87
|
+
// - Characters Python counts as digits or whitespace and JavaScript does not
|
|
88
|
+
// (fullwidth digits, U+0085, a byte order mark) read differently in the `bool`
|
|
89
|
+
// cast.
|
|
90
|
+
// - An undefined variable is an error, as said above.
|
|
91
|
+
import { isDeepStrictEqual } from 'node:util';
|
|
92
|
+
import { isMap, isNode, isSeq, parseDocument, parse as parseYaml } from 'yaml';
|
|
93
|
+
import { messageOf } from "./errors.js";
|
|
94
|
+
import { renderString } from "./jinja.js";
|
|
95
|
+
/** What a manifest value is in `context`: a string is Jinja rendered to text, a list is rendered item by item; other values are as they are. */
|
|
96
|
+
function value(source, context) {
|
|
97
|
+
if (typeof source === 'string')
|
|
98
|
+
return renderString(source, context);
|
|
99
|
+
if (Array.isArray(source))
|
|
100
|
+
return source.map((item) => value(item, context));
|
|
101
|
+
return source;
|
|
102
|
+
}
|
|
103
|
+
/** The type of a question: its own, else its raw default's, else `yaml`. */
|
|
104
|
+
function typeOf(question) {
|
|
105
|
+
if (question.type !== undefined)
|
|
106
|
+
return question.type;
|
|
107
|
+
const raw = question.default;
|
|
108
|
+
if (typeof raw === 'string')
|
|
109
|
+
return 'str';
|
|
110
|
+
if (typeof raw === 'boolean')
|
|
111
|
+
return 'bool';
|
|
112
|
+
if (typeof raw === 'number')
|
|
113
|
+
return Number.isInteger(raw) ? 'int' : 'float';
|
|
114
|
+
return 'yaml';
|
|
115
|
+
}
|
|
116
|
+
const INTEGER = /^\s*[+-]?\d+\s*$/;
|
|
117
|
+
const NUMBER = /^\s*[+-]?(\d+\.?\d*|\.\d+)([eE][+-]?\d+)?\s*$/;
|
|
118
|
+
/** `answer` as a value of `type`; throws where it is none. */
|
|
119
|
+
function cast(type, answer) {
|
|
120
|
+
const fail = () => new Error(`${JSON.stringify(answer)} is no ${type}`);
|
|
121
|
+
if (answer === null && type !== 'json' && type !== 'yaml')
|
|
122
|
+
throw fail();
|
|
123
|
+
switch (type) {
|
|
124
|
+
case 'str':
|
|
125
|
+
if (typeof answer === 'string')
|
|
126
|
+
return answer;
|
|
127
|
+
if (typeof answer === 'number')
|
|
128
|
+
return String(answer);
|
|
129
|
+
if (typeof answer === 'boolean')
|
|
130
|
+
return answer ? 'True' : 'False';
|
|
131
|
+
throw fail();
|
|
132
|
+
case 'int':
|
|
133
|
+
if (typeof answer === 'number' && Number.isSafeInteger(answer))
|
|
134
|
+
return answer;
|
|
135
|
+
if (typeof answer === 'string' && INTEGER.test(answer) && Number.isSafeInteger(Number.parseInt(answer, 10)))
|
|
136
|
+
return Number.parseInt(answer, 10);
|
|
137
|
+
throw fail();
|
|
138
|
+
case 'float':
|
|
139
|
+
if (typeof answer === 'number')
|
|
140
|
+
return answer;
|
|
141
|
+
if (typeof answer === 'string' && NUMBER.test(answer))
|
|
142
|
+
return Number(answer);
|
|
143
|
+
throw fail();
|
|
144
|
+
case 'bool':
|
|
145
|
+
return toBool(answer);
|
|
146
|
+
case 'json':
|
|
147
|
+
return typeof answer === 'string' ? JSON.parse(answer) : answer;
|
|
148
|
+
case 'yaml':
|
|
149
|
+
return typeof answer === 'string' ? parseYaml11(answer) : answer;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
const DECIMAL = '\\d+(?:_\\d+)*';
|
|
153
|
+
/** What Python's `float()` reads: a decimal with a sign, a fraction, an exponent and underscores between digits, or nan and inf. */
|
|
154
|
+
const PYTHON_FLOAT = new RegExp(`^[+-]?(?:(?:${DECIMAL}(?:\\.(?:${DECIMAL})?)?|\\.${DECIMAL})(?:e[+-]?${DECIMAL})?)$`, 'i');
|
|
155
|
+
const FALSE_WORDS = ['', 'n', 'no', 'f', 'false', 'off', '~', 'null', 'none'];
|
|
156
|
+
/** `cast_to_bool` of copier: a number by its value, a string that Python reads as a number the same, a string else by its words, anything else by its truthiness. */
|
|
157
|
+
function toBool(source) {
|
|
158
|
+
if (typeof source === 'number')
|
|
159
|
+
return source !== 0;
|
|
160
|
+
if (typeof source === 'string') {
|
|
161
|
+
const text = source.trim();
|
|
162
|
+
if (PYTHON_FLOAT.test(text)) {
|
|
163
|
+
const number = Number(text.replaceAll('_', ''));
|
|
164
|
+
return number !== 0;
|
|
165
|
+
}
|
|
166
|
+
return !FALSE_WORDS.includes(text.toLowerCase());
|
|
167
|
+
}
|
|
168
|
+
if (Array.isArray(source))
|
|
169
|
+
return source.length > 0;
|
|
170
|
+
if (typeof source === 'object' && source !== null)
|
|
171
|
+
return Object.keys(source).length > 0;
|
|
172
|
+
return Boolean(source);
|
|
173
|
+
}
|
|
174
|
+
/** YAML 1.1 by the `yaml` package, which copier's PyYAML is close to but not: `yes` and `on` are booleans, `010` is octal. */
|
|
175
|
+
function parseYaml11(text) {
|
|
176
|
+
return parseYaml(text, { version: '1.1' });
|
|
177
|
+
}
|
|
178
|
+
/** The values of a map of choices, in its order; a null value stands for its label. */
|
|
179
|
+
function labelled(entries) {
|
|
180
|
+
return [...entries].map(([label, choice]) => (choice === null ? cast('str', label) : choice));
|
|
181
|
+
}
|
|
182
|
+
/** The choices that YAML text holds, a list or a map in the order it is written. */
|
|
183
|
+
function parseChoices(text) {
|
|
184
|
+
const doc = parseDocument(text, { version: '1.1' });
|
|
185
|
+
const [error] = doc.errors;
|
|
186
|
+
if (error !== undefined)
|
|
187
|
+
throw error;
|
|
188
|
+
const js = (node) => (isNode(node) ? node.toJS(doc) : node);
|
|
189
|
+
if (isMap(doc.contents))
|
|
190
|
+
return labelled(doc.contents.items.map((pair) => [js(pair.key), js(pair.value)]));
|
|
191
|
+
if (isSeq(doc.contents))
|
|
192
|
+
return js(doc.contents);
|
|
193
|
+
throw new Error('they render to neither a list nor a map');
|
|
194
|
+
}
|
|
195
|
+
/** The values a question's choices allow, rendered and cast to its type, in the manifest's order. */
|
|
196
|
+
function allowed(question, type, context) {
|
|
197
|
+
const { choices } = question;
|
|
198
|
+
let values;
|
|
199
|
+
if (typeof choices === 'string') {
|
|
200
|
+
try {
|
|
201
|
+
values = parseChoices(renderString(choices, context));
|
|
202
|
+
}
|
|
203
|
+
catch (error) {
|
|
204
|
+
throw new Error(`choices \`${choices}\`: ${messageOf(error)}`);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
else if (choices instanceof Map) {
|
|
208
|
+
values = labelled([...choices].map(([label, choice]) => [value(label, context), value(choice, context)]));
|
|
209
|
+
}
|
|
210
|
+
else
|
|
211
|
+
values = Array.isArray(choices) ? choices.map((choice) => value(choice, context)) : [];
|
|
212
|
+
return values.map((choice) => cast(type, choice));
|
|
213
|
+
}
|
|
214
|
+
/** `answer` cast to the question's type, and checked against its choices. */
|
|
215
|
+
function accept(question, answer, context) {
|
|
216
|
+
const type = typeOf(question);
|
|
217
|
+
const result = cast(type, answer);
|
|
218
|
+
if (question.choices === undefined)
|
|
219
|
+
return result;
|
|
220
|
+
const choices = allowed(question, type, context);
|
|
221
|
+
if (choices.length > 0 && !choices.some((choice) => isDeepStrictEqual(choice, result))) {
|
|
222
|
+
const listed = choices.map((choice) => (typeof choice === 'string' ? choice : JSON.stringify(choice)));
|
|
223
|
+
throw new Error(`${JSON.stringify(result)} is not one of ${listed.join(', ')}`);
|
|
224
|
+
}
|
|
225
|
+
return result;
|
|
226
|
+
}
|
|
227
|
+
/** `value` of the field `what` of a question, an error naming the field's source where it fails. */
|
|
228
|
+
function field(what, source, context) {
|
|
229
|
+
try {
|
|
230
|
+
return value(source, context);
|
|
231
|
+
}
|
|
232
|
+
catch (error) {
|
|
233
|
+
throw new Error(`${what} \`${String(source)}\`: ${messageOf(error)}`);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
const MISSING = Symbol('missing');
|
|
237
|
+
/** The answer of one question, cast, checked against its choices and validated, or `MISSING` where there is none to resolve. */
|
|
238
|
+
function resolve(question, given, seen, applies) {
|
|
239
|
+
const isGiven = Object.hasOwn(given, question.name);
|
|
240
|
+
const hasDefault = Object.hasOwn(question, 'default');
|
|
241
|
+
if (!isGiven && !hasDefault)
|
|
242
|
+
return MISSING;
|
|
243
|
+
const answer = isGiven
|
|
244
|
+
? accept(question, given[question.name], seen)
|
|
245
|
+
: accept(question, field('default', question.default, seen), seen);
|
|
246
|
+
// A default is not validated for a skipped question; a given answer always is.
|
|
247
|
+
if (question.validator !== undefined && (applies || isGiven)) {
|
|
248
|
+
const message = String(field('validator', question.validator, { ...seen, [question.name]: answer })).trim();
|
|
249
|
+
if (message !== '')
|
|
250
|
+
throw new Error(message);
|
|
251
|
+
}
|
|
252
|
+
return answer;
|
|
253
|
+
}
|
|
254
|
+
/** The questions `manifest` owns, resolved against `given` with `scope` in view; problems go to `errors`. */
|
|
255
|
+
export function resolveAnswers(manifest, given, scope, errors) {
|
|
256
|
+
const answers = {};
|
|
257
|
+
// Every given answer to one of the template's questions is in view from the start, as it is given,
|
|
258
|
+
// and gives way to the answer its question resolves to.
|
|
259
|
+
const context = {};
|
|
260
|
+
for (const { name } of manifest.questions)
|
|
261
|
+
if (Object.hasOwn(given, name))
|
|
262
|
+
context[name] = given[name];
|
|
263
|
+
for (const question of manifest.questions) {
|
|
264
|
+
try {
|
|
265
|
+
// What the question sees: the scope, and this template's answers so far, given or resolved.
|
|
266
|
+
const seen = { ...scope, ...context };
|
|
267
|
+
const applies = question.when === undefined || toBool(field('when', question.when, seen));
|
|
268
|
+
const answer = resolve(question, given, seen, applies);
|
|
269
|
+
if (answer !== MISSING) {
|
|
270
|
+
context[question.name] = answer;
|
|
271
|
+
if (applies)
|
|
272
|
+
answers[question.name] = answer;
|
|
273
|
+
}
|
|
274
|
+
else if (applies) {
|
|
275
|
+
const help = question.help === undefined ? '' : `: ${question.help}`;
|
|
276
|
+
errors.push({ template: manifest.name, question: question.name, message: `no answer and no default${help}` });
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
catch (error) {
|
|
280
|
+
errors.push({ template: manifest.name, question: question.name, message: messageOf(error) });
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
return { answers, context };
|
|
284
|
+
}
|
|
285
|
+
/** The names of the `given` answers that no question of the render's `manifests` owns and none of them reads. */
|
|
286
|
+
export function unusedAnswers(manifests, given) {
|
|
287
|
+
const used = new Set(manifests.flatMap(({ questions, reads }) => [...questions, ...reads].map(({ name }) => name)));
|
|
288
|
+
return Object.keys(given).filter((name) => !used.has(name));
|
|
289
|
+
}
|
|
290
|
+
//# sourceMappingURL=questions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"questions.js","sourceRoot":"","sources":["../src/questions.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,gDAAgD;AAChD,EAAE;AACF,8EAA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CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,CAAC,IAAI,CAAC,EAAE,QAAQ,EAAE,QAAQ,CAAC,IAAI,EAAE,QAAQ,EAAE,QAAQ,CAAC,IAAI,EAAE,OAAO,EAAE,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QAC/F,CAAC;IACH,CAAC;IACD,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC;AAC9B,CAAC;AAED,iHAAiH;AACjH,MAAM,UAAU,aAAa,CAAC,SAA8B,EAAE,KAAc;IAC1E,MAAM,IAAI,GAAG,IAAI,GAAG,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,CAAC,GAAG,SAAS,EAAE,GAAG,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACpH,OAAO,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC;AAC9D,CAAC"}
|
package/dist/render.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { Answers, RenderResult, Tree } from './types.ts';
|
|
2
|
+
/** The tree `templates` render with the `given` answers, and what it is made of. */
|
|
3
|
+
export declare function render(templates: readonly Tree[], given: Answers): RenderResult;
|
|
4
|
+
//# sourceMappingURL=render.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../src/render.ts"],"names":[],"mappings":"AA2FA,OAAO,KAAK,EAAE,OAAO,EAA4C,YAAY,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAExG,oFAAoF;AACpF,wBAAgB,MAAM,CAAC,SAAS,EAAE,SAAS,IAAI,EAAE,EAAE,KAAK,EAAE,OAAO,GAAG,YAAY,CAgD/E"}
|
package/dist/render.js
ADDED
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
// render: templates and answers to one tree, and the result that describes it
|
|
2
|
+
// (types.ts states the shapes). It runs in three passes over the templates, so
|
|
3
|
+
// that each pass can see what the one before produced for all of them:
|
|
4
|
+
//
|
|
5
|
+
// 1. read each template: its manifest and its files (manifest.ts)
|
|
6
|
+
// 2. resolve each template's reads and questions against the given answers
|
|
7
|
+
// (questions.ts), in its scope: the engine's variables and its reads
|
|
8
|
+
// 3. render the files of all templates together (files.ts), each template's
|
|
9
|
+
// in its scope and its own answers, and give each path its owner and
|
|
10
|
+
// policy
|
|
11
|
+
//
|
|
12
|
+
// Every step adds what it finds wrong to one list of errors and carries on, so
|
|
13
|
+
// that one render reports them all; a render with errors returns no files.
|
|
14
|
+
//
|
|
15
|
+
// The rules of composing several templates into one tree:
|
|
16
|
+
//
|
|
17
|
+
// Templates. Each template has a name of its own: two templates of one name
|
|
18
|
+
// are an error naming both by their position in the list, and the second is
|
|
19
|
+
// left out.
|
|
20
|
+
//
|
|
21
|
+
// Answers. The given answers are one flat namespace for the whole render. Each
|
|
22
|
+
// question is declared by exactly one template, its owner: two templates
|
|
23
|
+
// declaring the same question are an error naming both, and the one whose name
|
|
24
|
+
// sorts first owns it for the templates that read it. A template takes the
|
|
25
|
+
// given answers to its own questions, and declares as reads the answers it
|
|
26
|
+
// uses but does not own.
|
|
27
|
+
//
|
|
28
|
+
// Reads. The value of a read is what its owner in the render resolved, cast
|
|
29
|
+
// to the owner's type; else the given answer, as it is given, which is how a
|
|
30
|
+
// caller passes an answer that no template of the render owns; else the read's
|
|
31
|
+
// default from the manifest. A supplied value always wins over the default.
|
|
32
|
+
// A read without a default that nothing supplies is an error naming the
|
|
33
|
+
// template and the read. A read sees what its owner's files see: where the
|
|
34
|
+
// owner's `when` skips the question, that is the owner's given answer or
|
|
35
|
+
// default, and where the owner has neither, the read falls to its own default,
|
|
36
|
+
// and without one it is an error naming the owner as well.
|
|
37
|
+
//
|
|
38
|
+
// Order. A template is resolved after the owners of the answers it reads, and
|
|
39
|
+
// otherwise by name, so that the order of the templates does not change the
|
|
40
|
+
// tree; there are no dependencies between templates besides their reads.
|
|
41
|
+
// Templates whose reads form a cycle, and the templates that read from them,
|
|
42
|
+
// are one error naming them all by name, and none of them is resolved.
|
|
43
|
+
//
|
|
44
|
+
// Nor does the order given change the rest of the result, but for the birth
|
|
45
|
+
// commands: `tree` and `files` come in path order, `answers` and `unused` in
|
|
46
|
+
// name order, and `errors` by template name, each template's in the order its
|
|
47
|
+
// passes found them (its reads and questions in its manifest's order, its
|
|
48
|
+
// files in its tree's). An error between two templates in one role, a
|
|
49
|
+
// question both declare, a path both write or a cycle of reads, names in
|
|
50
|
+
// `template` the one whose name sorts first; where the roles differ, it names
|
|
51
|
+
// the reader of a read, and the template of a file with another's path below
|
|
52
|
+
// it. Two templates of one name are named by their position in the list,
|
|
53
|
+
// which is all that tells them apart.
|
|
54
|
+
//
|
|
55
|
+
// Scope. A template sees only its own slice of the namespace: the engine's
|
|
56
|
+
// variables, its declared reads, and its own questions. Its questions'
|
|
57
|
+
// defaults, `when`, choices and validators see the scope (the engine's
|
|
58
|
+
// variables and its reads) and its own answers as questions.ts states; its
|
|
59
|
+
// file names and contents see the scope and its own answers. A variable
|
|
60
|
+
// outside the slice is undefined, which is an error wherever it is used, even
|
|
61
|
+
// when another template of the render owns it.
|
|
62
|
+
//
|
|
63
|
+
// Engine variables. Their names start with `_`, which the manifest reader
|
|
64
|
+
// forbids for questions and reads. There is one: `_templates`, the names of
|
|
65
|
+
// the templates rendered together, sorted by name so that it does not depend
|
|
66
|
+
// on the order given, for a file that is written only when another template
|
|
67
|
+
// is present (`{% if 'shelf' in _templates %}`).
|
|
68
|
+
//
|
|
69
|
+
// One cause, one error. A template whose read or question fails renders no
|
|
70
|
+
// files, since every file that uses the failed variable would add an error of
|
|
71
|
+
// its own; its other files are checked by the render that follows the fix. A
|
|
72
|
+
// read of a question whose owner failed to resolve it has no value and adds no
|
|
73
|
+
// error, and the reader renders no files; the reader's own questions are still
|
|
74
|
+
// resolved, so that every missing answer is listed, and one that uses that
|
|
75
|
+
// read reports it as undefined. Where a template of the render failed to read,
|
|
76
|
+
// whether its manifest is wrong or its name is taken, what it owns is unknown:
|
|
77
|
+
// a read that nothing supplies then adds no error of its own either, and the
|
|
78
|
+
// reader renders no files.
|
|
79
|
+
//
|
|
80
|
+
// Paths. Each path is written by exactly one template, and an empty directory
|
|
81
|
+
// several templates hold is one, owned by the one whose name sorts first;
|
|
82
|
+
// files.ts checks it across the templates where it checks it within one. The result names each
|
|
83
|
+
// path's owner and policy, and lists the birth commands of each template in
|
|
84
|
+
// the order the templates were given, which `render` does not run.
|
|
85
|
+
//
|
|
86
|
+
// Unused answers. A given answer that no template owns or reads is listed as
|
|
87
|
+
// unused and is no error: a caller may pass more than one render needs.
|
|
88
|
+
import { renderFiles } from "./files.js";
|
|
89
|
+
import { MANIFEST, readTemplate } from "./manifest.js";
|
|
90
|
+
import { resolveAnswers, unusedAnswers } from "./questions.js";
|
|
91
|
+
/** The tree `templates` render with the `given` answers, and what it is made of. */
|
|
92
|
+
export function render(templates, given) {
|
|
93
|
+
const errors = [];
|
|
94
|
+
// In the order given for the birth commands, and by name for everything else.
|
|
95
|
+
const listed = readAll(templates, errors);
|
|
96
|
+
const read = listed.toSorted((a, b) => compare(a.manifest.name, b.manifest.name));
|
|
97
|
+
const owners = ownersOf(read, errors);
|
|
98
|
+
const engine = { _templates: read.map(({ manifest }) => manifest.name) };
|
|
99
|
+
const resolved = new Map();
|
|
100
|
+
for (const template of resolutionOrder(read, owners, errors)) {
|
|
101
|
+
const own = [];
|
|
102
|
+
const reads = readsOf(template, owners, resolved, listed.length < templates.length, given, own);
|
|
103
|
+
const scope = { ...engine, ...reads.values };
|
|
104
|
+
const resolution = resolveAnswers(template.manifest, given, scope, own);
|
|
105
|
+
errors.push(...own);
|
|
106
|
+
const unresolved = new Set(own.flatMap(({ question }) => question ?? []));
|
|
107
|
+
resolved.set(template, { scope, resolution, unresolved, failed: own.length > 0 || !reads.complete });
|
|
108
|
+
}
|
|
109
|
+
const renderings = read.flatMap((template) => {
|
|
110
|
+
const done = resolved.get(template);
|
|
111
|
+
return done === undefined || done.failed
|
|
112
|
+
? []
|
|
113
|
+
: [{ template, context: { ...done.scope, ...done.resolution.context } }];
|
|
114
|
+
});
|
|
115
|
+
const tree = new Map();
|
|
116
|
+
const files = new Map();
|
|
117
|
+
const rendered = [...renderFiles(renderings, errors)].sort(([a], [b]) => compare(a, b));
|
|
118
|
+
for (const [path, { entry, source, owner }] of rendered) {
|
|
119
|
+
tree.set(path, entry);
|
|
120
|
+
files.set(path, { template: owner.manifest.name, policy: owner.manifest.policies.get(source) ?? 'merge' });
|
|
121
|
+
}
|
|
122
|
+
const birth = listed.flatMap(({ manifest }) => manifest.birth.map((command) => ({ template: manifest.name, command })));
|
|
123
|
+
const answers = Object.fromEntries(read
|
|
124
|
+
.flatMap((template) => Object.entries(resolved.get(template)?.resolution.answers ?? {}))
|
|
125
|
+
.sort(([a], [b]) => compare(a, b)));
|
|
126
|
+
const unused = unusedAnswers(read.map(({ manifest }) => manifest), given).sort(compare);
|
|
127
|
+
// By template, and within one in the order the passes found them.
|
|
128
|
+
errors.sort((a, b) => compare(a.template ?? '', b.template ?? ''));
|
|
129
|
+
if (errors.length > 0)
|
|
130
|
+
return { tree: new Map(), answers, unused, files: new Map(), birth: [], errors };
|
|
131
|
+
return { tree, answers, unused, files, birth, errors };
|
|
132
|
+
}
|
|
133
|
+
/** The order of two names or paths, by code unit, as JavaScript sorts strings. */
|
|
134
|
+
const compare = (a, b) => (a < b ? -1 : a > b ? 1 : 0);
|
|
135
|
+
/** The templates read, in the order given; a template named like one before it is an error and is left out. */
|
|
136
|
+
function readAll(templates, errors) {
|
|
137
|
+
const positions = new Map();
|
|
138
|
+
return templates.flatMap((tree, i) => {
|
|
139
|
+
const template = readTemplate(tree, i + 1, errors);
|
|
140
|
+
if (template === undefined)
|
|
141
|
+
return [];
|
|
142
|
+
const { name } = template.manifest;
|
|
143
|
+
const first = positions.get(name);
|
|
144
|
+
if (first === undefined) {
|
|
145
|
+
positions.set(name, i + 1);
|
|
146
|
+
return [template];
|
|
147
|
+
}
|
|
148
|
+
const message = `templates ${first} and ${i + 1} are both named ${name}`;
|
|
149
|
+
errors.push({ template: name, other: name, path: MANIFEST, message });
|
|
150
|
+
return [];
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* The templates in the order they resolve: each after the owners of the answers
|
|
155
|
+
* it reads, else in the order of `read`. The templates left over each read from
|
|
156
|
+
* another left over, in a cycle or from one; they are one error naming them
|
|
157
|
+
* all, and none of them is resolved.
|
|
158
|
+
*/
|
|
159
|
+
function resolutionOrder(read, owners, errors) {
|
|
160
|
+
/** The reads of `template` that another template owns, each with its owner. */
|
|
161
|
+
const edges = (template) => template.manifest.reads.flatMap(({ name }) => {
|
|
162
|
+
const owner = owners.get(name);
|
|
163
|
+
return owner === undefined ? [] : [{ name, owner }];
|
|
164
|
+
});
|
|
165
|
+
const order = [];
|
|
166
|
+
const pending = [...read];
|
|
167
|
+
for (;;) {
|
|
168
|
+
const next = pending.findIndex((template) => edges(template).every(({ owner }) => order.includes(owner)));
|
|
169
|
+
if (next === -1)
|
|
170
|
+
break;
|
|
171
|
+
order.push(...pending.splice(next, 1));
|
|
172
|
+
}
|
|
173
|
+
if (pending.length === 0)
|
|
174
|
+
return order;
|
|
175
|
+
const left = pending.toSorted((a, b) => compare(a.manifest.name, b.manifest.name));
|
|
176
|
+
const names = left.map(({ manifest }) => manifest.name);
|
|
177
|
+
const waits = left.flatMap((template) => edges(template)
|
|
178
|
+
.filter(({ owner }) => pending.includes(owner))
|
|
179
|
+
.map(({ name, owner }) => `${template.manifest.name} reads ${name} from ${owner.manifest.name}`));
|
|
180
|
+
const listed = `${names.slice(0, -1).join(', ')} and ${names.at(-1)}`;
|
|
181
|
+
const message = `the reads of ${listed} wait on each other: ${waits.join(', ')}`;
|
|
182
|
+
errors.push({ template: names[0], other: names[1], path: MANIFEST, message });
|
|
183
|
+
return order;
|
|
184
|
+
}
|
|
185
|
+
/** The template that declares each question; a question two templates declare is an error naming both. */
|
|
186
|
+
function ownersOf(read, errors) {
|
|
187
|
+
const owners = new Map();
|
|
188
|
+
for (const template of read) {
|
|
189
|
+
for (const { name } of template.manifest.questions) {
|
|
190
|
+
const first = owners.get(name);
|
|
191
|
+
if (first === undefined)
|
|
192
|
+
owners.set(name, template);
|
|
193
|
+
else
|
|
194
|
+
errors.push({
|
|
195
|
+
template: first.manifest.name,
|
|
196
|
+
other: template.manifest.name,
|
|
197
|
+
path: MANIFEST,
|
|
198
|
+
question: name,
|
|
199
|
+
message: `${first.manifest.name} and ${template.manifest.name} both declare the question ${name}`,
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
return owners;
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* The value of each answer `template` reads: what its owner resolved, else the
|
|
207
|
+
* given answer, else the read's default. A read that nothing supplies is an
|
|
208
|
+
* error, naming the owner where the owner skipped the question. A read adds no
|
|
209
|
+
* error where the error is another's: where its owner failed to resolve it, or
|
|
210
|
+
* where it has no owner and a template of the render failed to read (`unread`),
|
|
211
|
+
* which may have owned it. `complete` is false where a read has no value.
|
|
212
|
+
*/
|
|
213
|
+
function readsOf(template, owners, resolved, unread, given, errors) {
|
|
214
|
+
const values = {};
|
|
215
|
+
let complete = true;
|
|
216
|
+
for (const read of template.manifest.reads) {
|
|
217
|
+
const owner = owners.get(read.name);
|
|
218
|
+
const done = owner === undefined ? undefined : resolved.get(owner);
|
|
219
|
+
const owned = done?.resolution.context ?? {};
|
|
220
|
+
if (done?.unresolved.has(read.name))
|
|
221
|
+
complete = false;
|
|
222
|
+
else if (Object.hasOwn(owned, read.name))
|
|
223
|
+
values[read.name] = owned[read.name];
|
|
224
|
+
else if (Object.hasOwn(given, read.name))
|
|
225
|
+
values[read.name] = given[read.name];
|
|
226
|
+
else if (Object.hasOwn(read, 'default'))
|
|
227
|
+
values[read.name] = read.default;
|
|
228
|
+
else {
|
|
229
|
+
complete = false;
|
|
230
|
+
const name = template.manifest.name;
|
|
231
|
+
const error = { template: name, path: MANIFEST, question: read.name };
|
|
232
|
+
if (owner !== undefined) {
|
|
233
|
+
const other = owner.manifest.name;
|
|
234
|
+
const message = `${name} reads ${read.name}, which ${other} owns and skips without a default`;
|
|
235
|
+
errors.push({ ...error, other, message });
|
|
236
|
+
}
|
|
237
|
+
else if (!unread) {
|
|
238
|
+
const message = `${name} reads ${read.name}, which no template of the render owns and no answer gives`;
|
|
239
|
+
errors.push({ ...error, message });
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
return { values, complete };
|
|
244
|
+
}
|
|
245
|
+
//# sourceMappingURL=render.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"render.js","sourceRoot":"","sources":["../src/render.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,+EAA+E;AAC/E,uEAAuE;AACvE,EAAE;AACF,oEAAoE;AACpE,6EAA6E;AAC7E,0EAA0E;AAC1E,8EAA8E;AAC9E,0EAA0E;AAC1E,cAAc;AACd,EAAE;AACF,+EAA+E;AAC/E,2EAA2E;AAC3E,EAAE;AACF,0DAA0D;AAC1D,EAAE;AACF,4EAA4E;AAC5E,4EAA4E;AAC5E,YAAY;AACZ,EAAE;AACF,+EAA+E;AAC/E,yEAAyE;AACzE,+EAA+E;AAC/E,2EAA2E;AAC3E,2EAA2E;AAC3E,yBAAyB;AACzB,EAAE;AACF,4EAA4E;AAC5E,6EAA6E;AAC7E,+EAA+E;AAC/E,4EAA4E;AAC5E,wEAAwE;AACxE,2EAA2E;AAC3E,yEAAyE;AACzE,+EAA+E;AAC/E,2DAA2D;AAC3D,EAAE;AACF,8EAA8E;AA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