@okfit/cli 0.2.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -7
- package/bin/okfit.js +2 -51
- package/commands/context.js +3 -6
- package/commands/init.js +3 -9
- package/commands/sync.js +3 -6
- package/commands/validate.js +3 -8
- package/commands/verify.js +3 -7
- package/errors.js +2 -105
- package/index.d.ts +25 -769
- package/index.js +4 -13
- package/main.d.ts +15 -0
- package/main.js +44 -0
- package/package.json +9 -6
- package/render/context.js +1 -80
- package/render/human.js +1 -1
- package/render/sync.js +1 -61
- package/render/verify.js +1 -44
- package/version.js +6 -6
- package/config/anchor.js +0 -57
- package/config/layer.js +0 -129
- package/config/resolve.js +0 -67
- package/context/run.js +0 -35
- package/init/scaffold.js +0 -174
- package/package.js +0 -5
- package/render/exit.js +0 -53
- package/render/json.js +0 -126
- package/render/sort.js +0 -46
- package/sync/generated.js +0 -111
- package/sync/index.js +0 -73
- package/sync/log.js +0 -127
- package/sync/run.js +0 -65
- package/sync/write.js +0 -48
- package/validate/run.js +0 -63
- package/verify/locate.js +0 -249
- package/verify/run.js +0 -106
- package/verify/splice.js +0 -75
package/verify/splice.js
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import { MarkdownEdit } from "@effected/markdown";
|
|
2
|
-
|
|
3
|
-
//#region src/verify/splice.ts
|
|
4
|
-
/** Prefix two spaces to every line but the first, joining with `newline` (V-13). */
|
|
5
|
-
const reindent = (original, newline) => original.split(/\r\n|\n|\r/).map((line, index) => index === 0 ? line : ` ${line}`).join(newline);
|
|
6
|
-
/**
|
|
7
|
-
* Build the one edit for `target` (contract §3.2). Never calls a YAML
|
|
8
|
-
* stringifier: the only syntax emitted is `- `, `{`, `}`, `: `, `,`,
|
|
9
|
-
* spaces and `newline`.
|
|
10
|
-
*
|
|
11
|
-
* @internal
|
|
12
|
-
*/
|
|
13
|
-
const splice = (target, entry, newline) => {
|
|
14
|
-
const flow = `{ by: ${entry.by}, at: ${entry.at} }`;
|
|
15
|
-
const block = (indent) => `${indent}- by: ${entry.by}${newline}${indent} at: ${entry.at}`;
|
|
16
|
-
switch (target._tag) {
|
|
17
|
-
case "absent": return MarkdownEdit.make({
|
|
18
|
-
offset: target.insertAt,
|
|
19
|
-
length: 0,
|
|
20
|
-
content: `verified:${newline} - by: ${entry.by}${newline} at: ${entry.at}${newline}`
|
|
21
|
-
});
|
|
22
|
-
case "blockSeq": {
|
|
23
|
-
const fragment = target.lastItemStyle === "flow" ? `${target.indent}- ${flow}` : block(target.indent);
|
|
24
|
-
return MarkdownEdit.make({
|
|
25
|
-
offset: target.insertAt,
|
|
26
|
-
length: 0,
|
|
27
|
-
content: target.afterNewline ? `${fragment}${newline}` : `${newline}${fragment}`
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
case "flowSeq": return MarkdownEdit.make({
|
|
31
|
-
offset: target.insertAt,
|
|
32
|
-
length: 0,
|
|
33
|
-
content: target.empty ? flow : `, ${flow}`
|
|
34
|
-
});
|
|
35
|
-
case "bareMapping": return target.style === "flow" ? MarkdownEdit.make({
|
|
36
|
-
offset: target.start,
|
|
37
|
-
length: target.end - target.start,
|
|
38
|
-
content: `${newline}${target.indent}- ${target.original}${newline}${target.indent}- ${flow}`
|
|
39
|
-
}) : MarkdownEdit.make({
|
|
40
|
-
offset: target.start,
|
|
41
|
-
length: target.end - target.start,
|
|
42
|
-
content: `${newline}${target.indent}- ${reindent(target.original, newline)}${newline}${block(target.indent)}${newline}`
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
/**
|
|
47
|
-
* Build the one edit for `target` (contract §6.1). Never calls a YAML
|
|
48
|
-
* stringifier: the only syntax emitted is the indent, `at: `, the
|
|
49
|
-
* preserved quote character (if any), and `newline`. `encodedAt` is
|
|
50
|
-
* already `Schema.encodeSync(Timestamp)`'d by the caller (S-1: splice,
|
|
51
|
-
* never `YamlFormat.modify` — it drops quote style and re-normalises line
|
|
52
|
-
* endings, V-12/V-15 violations `sync/generated.ts` cannot afford).
|
|
53
|
-
*
|
|
54
|
-
* @internal
|
|
55
|
-
*/
|
|
56
|
-
const spliceGenerated = (target, encodedAt, newline) => {
|
|
57
|
-
switch (target._tag) {
|
|
58
|
-
case "insertAfterLastKey": return MarkdownEdit.make({
|
|
59
|
-
offset: target.insertAt,
|
|
60
|
-
length: 0,
|
|
61
|
-
content: `${target.indent}at: ${encodedAt}${newline}`
|
|
62
|
-
});
|
|
63
|
-
case "replaceScalar": {
|
|
64
|
-
const quoted = target.quote === "single-quoted" ? `'${encodedAt}'` : target.quote === "double-quoted" ? `"${encodedAt}"` : encodedAt;
|
|
65
|
-
return MarkdownEdit.make({
|
|
66
|
-
offset: target.start,
|
|
67
|
-
length: target.end - target.start,
|
|
68
|
-
content: quoted
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
//#endregion
|
|
75
|
-
export { splice, spliceGenerated };
|