@sous-io/sous-plugin-api 1.1.0 → 1.1.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/dist/handlers.d.ts +10 -2
- package/dist/report-styles.d.ts +7 -0
- package/dist/report-styles.js +2 -0
- package/dist/reporter.d.ts +7 -2
- package/dist/reporter.js +9 -2
- package/package.json +1 -1
package/dist/handlers.d.ts
CHANGED
|
@@ -40,8 +40,16 @@ export interface HandlerRegistration<P extends HandlerPurpose = HandlerPurpose>
|
|
|
40
40
|
/** Moves it within its purpose: lower runs earlier. Default `500`. */
|
|
41
41
|
order?: number;
|
|
42
42
|
}
|
|
43
|
+
/**
|
|
44
|
+
* A purpose a plugin may add a handler for. `uninstall` and `migrate` run only for a recipe, so a
|
|
45
|
+
* plugin declares them in its recipe's manifest instead, pointing at a function its bundle exports.
|
|
46
|
+
*/
|
|
47
|
+
export type PluginHandlerPurpose = Exclude<HandlerPurpose, "uninstall" | "migrate">;
|
|
43
48
|
/** `sous.handlers`. */
|
|
44
49
|
export interface HandlerRegistry {
|
|
45
|
-
/**
|
|
46
|
-
|
|
50
|
+
/**
|
|
51
|
+
* Adds a handler for a purpose, as a `handler` entity of this plugin. Throws a `PluginError` for
|
|
52
|
+
* `uninstall` and `migrate`.
|
|
53
|
+
*/
|
|
54
|
+
add<const P extends PluginHandlerPurpose>(purpose: P, definition: HandlerRegistration<P>): void;
|
|
47
55
|
}
|
package/dist/report-styles.d.ts
CHANGED
|
@@ -23,6 +23,8 @@ export declare const ReportEntryStyle: {
|
|
|
23
23
|
readonly Detail: "detail";
|
|
24
24
|
/** One action done (or to be done) to one target, such as a file written. {@link OperationDetails}. */
|
|
25
25
|
readonly Operation: "operation";
|
|
26
|
+
/** One line saying what an operation did in all, shown just before it ends, such as "Files: 2 written, 13 unchanged." No details. */
|
|
27
|
+
readonly OperationSummary: "operation-summary";
|
|
26
28
|
/** How an operation ended, such as "Done." {@link OperationEndDetails}. */
|
|
27
29
|
readonly OperationEnd: "operation-end";
|
|
28
30
|
/** One label and its value. The message is a `VariableSet`. */
|
|
@@ -123,6 +125,11 @@ export interface TableColumn {
|
|
|
123
125
|
header: string;
|
|
124
126
|
/** Whether a long cell wraps onto more lines or is cut. Defaults to wrapping. */
|
|
125
127
|
overflow?: ColumnOverflow;
|
|
128
|
+
/**
|
|
129
|
+
* The most lines a wrapped cell takes. A cell that needs more shows this many, the last ending
|
|
130
|
+
* in `...` to say text was left out. Defaults to no limit.
|
|
131
|
+
*/
|
|
132
|
+
maxLines?: number;
|
|
126
133
|
/** Which end a cut takes from. Defaults by kind: the middle of a path or a URL, the end of anything else. */
|
|
127
134
|
truncate?: TruncateSide;
|
|
128
135
|
/** What the column holds. Defaults to plain text. */
|
package/dist/report-styles.js
CHANGED
|
@@ -23,6 +23,8 @@ export const ReportEntryStyle = {
|
|
|
23
23
|
Detail: "detail",
|
|
24
24
|
/** One action done (or to be done) to one target, such as a file written. {@link OperationDetails}. */
|
|
25
25
|
Operation: "operation",
|
|
26
|
+
/** One line saying what an operation did in all, shown just before it ends, such as "Files: 2 written, 13 unchanged." No details. */
|
|
27
|
+
OperationSummary: "operation-summary",
|
|
26
28
|
/** How an operation ended, such as "Done." {@link OperationEndDetails}. */
|
|
27
29
|
OperationEnd: "operation-end",
|
|
28
30
|
/** One label and its value. The message is a `VariableSet`. */
|
package/dist/reporter.d.ts
CHANGED
|
@@ -91,8 +91,11 @@ export declare abstract class BaseReporter {
|
|
|
91
91
|
constructor(thresholdSource?: LogLevel | (() => LogLevel));
|
|
92
92
|
/** The least severe level shown now. */
|
|
93
93
|
protected threshold(): LogLevel;
|
|
94
|
-
/**
|
|
95
|
-
|
|
94
|
+
/**
|
|
95
|
+
* Whether a message at `level` passes the threshold now. A caller asks it before working out
|
|
96
|
+
* something only a more detailed level shows (`reporter.shows(LogLevel.Debug)`).
|
|
97
|
+
*/
|
|
98
|
+
shows(level: LogLevel): boolean;
|
|
96
99
|
/** Writes one message that passed the threshold, in the way this reporter shows `style`. */
|
|
97
100
|
protected abstract write(level: LogLevel, message: ReportMessage, details: ReportDetails | undefined, style: ReportEntryStyle): void;
|
|
98
101
|
/**
|
|
@@ -141,6 +144,8 @@ export declare abstract class BaseReporter {
|
|
|
141
144
|
* ```
|
|
142
145
|
*/
|
|
143
146
|
operation(action: OperationAction, target: string, facts?: Omit<OperationDetails, "action" | "target">, level?: LogLevel): void;
|
|
147
|
+
/** What an operation did in all, in one line, reported just before it ends: `Files: 2 written (1 new, 1 updated), 13 unchanged.` */
|
|
148
|
+
operationSummary(text: string, level?: LogLevel): void;
|
|
144
149
|
/** How an operation ended: `Done.`, or `Done with 2 errors.` The level defaults to `info`, or `error` when it failed. */
|
|
145
150
|
operationEnd(summary: string, ok?: boolean, level?: LogLevel): void;
|
|
146
151
|
/** One label and its value: `Repository: /work/recipes`. */
|
package/dist/reporter.js
CHANGED
|
@@ -117,7 +117,10 @@ export class BaseReporter {
|
|
|
117
117
|
threshold() {
|
|
118
118
|
return typeof this.thresholdSource === "function" ? this.thresholdSource() : this.thresholdSource;
|
|
119
119
|
}
|
|
120
|
-
/**
|
|
120
|
+
/**
|
|
121
|
+
* Whether a message at `level` passes the threshold now. A caller asks it before working out
|
|
122
|
+
* something only a more detailed level shows (`reporter.shows(LogLevel.Debug)`).
|
|
123
|
+
*/
|
|
121
124
|
shows(level) {
|
|
122
125
|
return isLevelShown(level, this.threshold());
|
|
123
126
|
}
|
|
@@ -210,6 +213,10 @@ export class BaseReporter {
|
|
|
210
213
|
const text = facts.note === undefined ? `${action}: ${target}` : `${action}: ${target} (${facts.note})`;
|
|
211
214
|
this.log(level ?? (action === "failed" ? LogLevel.Error : LogLevel.Info), text, details, ReportEntryStyle.Operation);
|
|
212
215
|
}
|
|
216
|
+
/** What an operation did in all, in one line, reported just before it ends: `Files: 2 written (1 new, 1 updated), 13 unchanged.` */
|
|
217
|
+
operationSummary(text, level = LogLevel.Info) {
|
|
218
|
+
this.log(level, text, undefined, ReportEntryStyle.OperationSummary);
|
|
219
|
+
}
|
|
213
220
|
/** How an operation ended: `Done.`, or `Done with 2 errors.` The level defaults to `info`, or `error` when it failed. */
|
|
214
221
|
operationEnd(summary, ok = true, level) {
|
|
215
222
|
this.log(level ?? (ok ? LogLevel.Info : LogLevel.Error), summary, { ok }, ReportEntryStyle.OperationEnd);
|
|
@@ -307,7 +314,7 @@ function joinLines(first, rest, last) {
|
|
|
307
314
|
return [first, ...body, last].filter((line) => line !== undefined).join("\n");
|
|
308
315
|
}
|
|
309
316
|
/** The members of `BaseReporter.prototype` that {@link Reporting} does not copy. */
|
|
310
|
-
const NOT_ALIASED = ["constructor", "log", "write", "threshold"
|
|
317
|
+
const NOT_ALIASED = ["constructor", "log", "write", "threshold"];
|
|
311
318
|
/**
|
|
312
319
|
* Gives a class every reporting method of {@link BaseReporter} (`info`, `warn`, `operationStart`,
|
|
313
320
|
* ...) as a shorthand for the same method on its `reporter`, which the class provides. The methods
|
package/package.json
CHANGED