@open-tomato/rafa 0.41.0 → 0.42.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 +5 -0
- package/dist/cli.js +19907 -23010
- package/dist/effort/store/index.js +4 -6
- package/dist/{index-zg0qsb5b.js → index-7ycam8pq.js} +3 -5
- package/dist/{index-3jpz9nr3.js → index-bceachy6.js} +456 -53
- package/dist/{index-wp8c28fd.js → index-hf2k497d.js} +1 -3
- package/dist/{index-d6d0942q.js → index-nv34ptht.js} +1 -1
- package/dist/{index-cd0wzc12.js → index-q0dmfp8m.js} +108 -252
- package/dist/index.js +30751 -32
- package/dist/learning/index.js +2 -2
- package/dist/plan/index.js +4 -6
- package/package.json +1 -1
- package/dist/describe-pwhh0vws.js +0 -14
- package/dist/index-eyjq63mx.js +0 -243
- package/dist/index-m2ahxjw8.js +0 -450
- package/dist/index-snf04fpt.js +0 -27628
- package/dist/index-sr3kc4mf.js +0 -129
- package/dist/index-wjsarzf5.js +0 -36069
package/dist/index-sr3kc4mf.js
DELETED
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import {
|
|
3
|
-
describeValue
|
|
4
|
-
} from "./index-m2ahxjw8.js";
|
|
5
|
-
|
|
6
|
-
// src/cli/spends.ts
|
|
7
|
-
var SPENDS_GLYPH = "\uD83E\uDE99";
|
|
8
|
-
var SPENDS_WHEN = ["always", "with", "unless", "through"];
|
|
9
|
-
var FLAGGED = ["with", "unless"];
|
|
10
|
-
var FLAG_SPELLING = /^--[^\s-]\S*$/;
|
|
11
|
-
function flagProblem(when, flag) {
|
|
12
|
-
if (FLAGGED.includes(when)) {
|
|
13
|
-
return typeof flag === "string" && FLAG_SPELLING.test(flag) ? null : `spends.flag is ${describeValue(flag)}, expected a flag as typed, starting with --`;
|
|
14
|
-
}
|
|
15
|
-
return flag === undefined ? null : `spends.flag is ${describeValue(flag)}, expected absent when spends.when is "${when}"`;
|
|
16
|
-
}
|
|
17
|
-
function spendsProblem(value) {
|
|
18
|
-
if (value === undefined)
|
|
19
|
-
return null;
|
|
20
|
-
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
21
|
-
return `spends is ${describeValue(value)}, expected absent or a mapping`;
|
|
22
|
-
}
|
|
23
|
-
const { when, what, flag } = value;
|
|
24
|
-
if (!SPENDS_WHEN.includes(when)) {
|
|
25
|
-
return `spends.when is ${describeValue(when)}, expected one of ${SPENDS_WHEN.join(", ")}`;
|
|
26
|
-
}
|
|
27
|
-
if (typeof what !== "string") {
|
|
28
|
-
return `spends.what is ${describeValue(what)}, expected a string`;
|
|
29
|
-
}
|
|
30
|
-
return flagProblem(when, flag);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
// src/cli/command.ts
|
|
34
|
-
var COMMAND_OUTPUTS = ["text", "json", "events", "tui"];
|
|
35
|
-
var MAX_EXIT_CODE = 255;
|
|
36
|
-
|
|
37
|
-
class CommandExit extends Error {
|
|
38
|
-
exitCode;
|
|
39
|
-
constructor(exitCode, message = "") {
|
|
40
|
-
super(message);
|
|
41
|
-
if (!Number.isInteger(exitCode) || exitCode < 0 || exitCode > MAX_EXIT_CODE) {
|
|
42
|
-
throw new TypeError(`CommandExit: exit code is ${describeValue(exitCode)}, expected a whole number from 0 to ${MAX_EXIT_CODE}`);
|
|
43
|
-
}
|
|
44
|
-
this.name = "CommandExit";
|
|
45
|
-
this.exitCode = exitCode;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
function isListOf(value, check) {
|
|
49
|
-
return Array.isArray(value) && value.every(check);
|
|
50
|
-
}
|
|
51
|
-
function hasStrings(value, keys) {
|
|
52
|
-
if (typeof value !== "object" || value === null)
|
|
53
|
-
return false;
|
|
54
|
-
const record = value;
|
|
55
|
-
return keys.every((key) => typeof record[key] === "string");
|
|
56
|
-
}
|
|
57
|
-
function isRoutingWord(value) {
|
|
58
|
-
return typeof value === "string" && /^[^\s/-][^\s/]*$/.test(value);
|
|
59
|
-
}
|
|
60
|
-
function isFlag(item) {
|
|
61
|
-
if (!hasStrings(item, ["name"]))
|
|
62
|
-
return false;
|
|
63
|
-
const { deprecated } = item;
|
|
64
|
-
return deprecated === undefined || hasStrings(deprecated, ["use"]);
|
|
65
|
-
}
|
|
66
|
-
function fieldProblem(fields) {
|
|
67
|
-
const checks = [
|
|
68
|
-
["subject", isRoutingWord(fields.subject), "a word with no space, no slash and no leading dash"],
|
|
69
|
-
["action", isRoutingWord(fields.action), "a word with no space, no slash and no leading dash"],
|
|
70
|
-
["name", typeof fields.name === "string", "a string"],
|
|
71
|
-
["summary", typeof fields.summary === "string", "a string"],
|
|
72
|
-
["description", typeof fields.description === "string", "a string"],
|
|
73
|
-
["args", isListOf(fields.args, (item) => hasStrings(item, ["name"])), "a list of named arguments"],
|
|
74
|
-
["flags", isListOf(fields.flags, isFlag), "a list of named flags, each deprecation naming its use"],
|
|
75
|
-
["examples", isListOf(fields.examples, (item) => hasStrings(item, ["cmd", "note"])), "a list of examples"],
|
|
76
|
-
[
|
|
77
|
-
"outputs",
|
|
78
|
-
isListOf(fields.outputs, (item) => COMMAND_OUTPUTS.includes(item)),
|
|
79
|
-
`a list of ${COMMAND_OUTPUTS.join(", ")}`
|
|
80
|
-
],
|
|
81
|
-
[
|
|
82
|
-
"aliases",
|
|
83
|
-
fields.aliases === undefined || isListOf(fields.aliases, (item) => typeof item === "string"),
|
|
84
|
-
"absent or a list of strings"
|
|
85
|
-
],
|
|
86
|
-
[
|
|
87
|
-
"lastingAliases",
|
|
88
|
-
fields.lastingAliases === undefined || isListOf(fields.lastingAliases, (item) => typeof item === "string"),
|
|
89
|
-
"absent or a list of strings"
|
|
90
|
-
],
|
|
91
|
-
[
|
|
92
|
-
"deprecated",
|
|
93
|
-
fields.deprecated === undefined || hasStrings(fields.deprecated, ["since", "use"]),
|
|
94
|
-
"absent or a mapping of since and use"
|
|
95
|
-
],
|
|
96
|
-
["hidden", fields.hidden === undefined || typeof fields.hidden === "boolean", "absent or a boolean"],
|
|
97
|
-
[
|
|
98
|
-
"needsProject",
|
|
99
|
-
fields.needsProject === undefined || typeof fields.needsProject === "boolean",
|
|
100
|
-
"absent or a boolean"
|
|
101
|
-
],
|
|
102
|
-
["exec", fields.exec === undefined || fields.exec === true, "absent or true"],
|
|
103
|
-
["run", typeof fields.run === "function", "a function"]
|
|
104
|
-
];
|
|
105
|
-
const failed = checks.find(([, passes]) => !passes);
|
|
106
|
-
if (failed === undefined)
|
|
107
|
-
return null;
|
|
108
|
-
const [key, , expected] = failed;
|
|
109
|
-
return `${key} is ${describeValue(fields[key])}, expected ${expected}`;
|
|
110
|
-
}
|
|
111
|
-
function commandProblem(value) {
|
|
112
|
-
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
113
|
-
return `a command is ${describeValue(value)}, expected a mapping`;
|
|
114
|
-
}
|
|
115
|
-
const fields = value;
|
|
116
|
-
const problem = fieldProblem(fields) ?? spendsProblem(fields.spends);
|
|
117
|
-
if (problem === null)
|
|
118
|
-
return null;
|
|
119
|
-
const named = isRoutingWord(fields.subject) && isRoutingWord(fields.action) ? `command "${commandSpelling(fields)}"` : "a command";
|
|
120
|
-
return `${named}: ${problem}`;
|
|
121
|
-
}
|
|
122
|
-
function isTopLevel(command) {
|
|
123
|
-
return command.subject === command.action;
|
|
124
|
-
}
|
|
125
|
-
function commandSpelling(command) {
|
|
126
|
-
return isTopLevel(command) ? command.subject : `${command.subject} ${command.action}`;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
export { SPENDS_GLYPH, CommandExit, isRoutingWord, commandProblem, isTopLevel, commandSpelling };
|