@tipeline/cli 0.1.0 → 0.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/CommandService.d.ts +12 -2
- package/dist/CommandService.js +107 -36
- package/dist/Printer.d.ts +11 -0
- package/dist/Printer.js +76 -17
- package/dist/index.js +3 -3
- package/package.json +6 -6
package/dist/CommandService.d.ts
CHANGED
|
@@ -36,7 +36,7 @@ export default class CommandService {
|
|
|
36
36
|
static stop(options?: {
|
|
37
37
|
force?: boolean;
|
|
38
38
|
remote?: boolean;
|
|
39
|
-
}):
|
|
39
|
+
}): Promise<undefined>;
|
|
40
40
|
private static forceKill;
|
|
41
41
|
static status(attemptsLeft?: number, waited?: boolean): void;
|
|
42
42
|
static taskRun(source: string, options: RunOptions): Promise<void>;
|
|
@@ -52,6 +52,11 @@ export default class CommandService {
|
|
|
52
52
|
static taskList(): Promise<void>;
|
|
53
53
|
static taskReload(identifier: string, path: string): Promise<void>;
|
|
54
54
|
private static secretsNote;
|
|
55
|
+
/**
|
|
56
|
+
* An --output path made absolute. One ending in a slash names a folder: it's created when
|
|
57
|
+
* missing, so the file goes inside it rather than being written under the folder's name.
|
|
58
|
+
*/
|
|
59
|
+
private static outputPath;
|
|
55
60
|
static taskExport(identifier: string, options: {
|
|
56
61
|
output?: string;
|
|
57
62
|
includeSecrets?: boolean;
|
|
@@ -137,7 +142,12 @@ export default class CommandService {
|
|
|
137
142
|
}): Promise<void>;
|
|
138
143
|
static hubCheck(id?: string): Promise<void>;
|
|
139
144
|
static pluginList(): Promise<void>;
|
|
140
|
-
|
|
145
|
+
/**
|
|
146
|
+
* An installed plugin by its identifier, group or identifier in the hub catalog (any
|
|
147
|
+
* case). Exits with an error when there's none.
|
|
148
|
+
*/
|
|
149
|
+
private static findPlugin;
|
|
150
|
+
static pluginSetEnabled(identifierOrGroup: string, enabled: boolean): Promise<void>;
|
|
141
151
|
static agentPrompt(prompt: string, options?: {
|
|
142
152
|
yes?: boolean;
|
|
143
153
|
project?: string;
|
package/dist/CommandService.js
CHANGED
|
@@ -10,7 +10,7 @@ import { stopCoreServiceNow } from '@tipeline/utils/coreService';
|
|
|
10
10
|
import Printer from './Printer.js';
|
|
11
11
|
import IpcMessageService from './IpcMessageService.js';
|
|
12
12
|
import { WsCommandService } from './WsCommandService.js';
|
|
13
|
-
import { generateIdentifier, parseSchedule, defaultDeleteSelection, inOtherProjects, outsideUsers } from '@tipeline/utils';
|
|
13
|
+
import { checkCron, generateIdentifier, parseSchedule, defaultDeleteSelection, inOtherProjects, outsideUsers } from '@tipeline/utils';
|
|
14
14
|
import readline from 'node:readline/promises';
|
|
15
15
|
import { coreVersionWarning } from './coreVersionWarning.js';
|
|
16
16
|
import { McpClient, createProvider, draftWorkflow, missingInputs, parseRunResult, runAgent, summarizeRun, PROVIDERS, PROVIDER_LABELS, CHOICE_MEMORY_SETTING, INSTRUCTIONS_SETTING, parseChoiceMemory, proposalFromChoice, rememberChoice, } from '@tipeline/agent';
|
|
@@ -236,11 +236,26 @@ export default class CommandService {
|
|
|
236
236
|
}
|
|
237
237
|
}
|
|
238
238
|
/** Like `start` and `service`, stop means this machine's Core unless told otherwise. */
|
|
239
|
-
static stop(options = {}) {
|
|
239
|
+
static async stop(options = {}) {
|
|
240
240
|
if (options.force) {
|
|
241
241
|
CommandService.forceKill();
|
|
242
242
|
return;
|
|
243
243
|
}
|
|
244
|
+
// --remote means the active remote: with none, stopping this machine's Core instead
|
|
245
|
+
// would be a surprise. (Which remote is active is kept by the Core on this machine.)
|
|
246
|
+
if (options.remote) {
|
|
247
|
+
try {
|
|
248
|
+
const active = await CommandService.localRequest('connectionGetActive', 'onConnectionGetActive', null);
|
|
249
|
+
if (!active?.connection) {
|
|
250
|
+
Printer.printError("No remote is in use, so nothing was stopped. Pick one with: tipeline remote use <name>, or stop this machine's Core with: tipeline stop");
|
|
251
|
+
return process.exit(1);
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
catch (error) {
|
|
255
|
+
Printer.printError(error?.message ?? String(error));
|
|
256
|
+
return process.exit(1);
|
|
257
|
+
}
|
|
258
|
+
}
|
|
244
259
|
const connect = options.remote
|
|
245
260
|
? CommandService.connectAndHandle.bind(CommandService)
|
|
246
261
|
: CommandService.connectLocalAndHandle.bind(CommandService);
|
|
@@ -455,9 +470,19 @@ export default class CommandService {
|
|
|
455
470
|
if (count)
|
|
456
471
|
Printer.printMessage(`${plural(count, 'secret value')} left out. Add --include-secrets to write them in plain text.`);
|
|
457
472
|
}
|
|
473
|
+
/**
|
|
474
|
+
* An --output path made absolute. One ending in a slash names a folder: it's created when
|
|
475
|
+
* missing, so the file goes inside it rather than being written under the folder's name.
|
|
476
|
+
*/
|
|
477
|
+
static outputPath(output) {
|
|
478
|
+
const resolved = nodePath.resolve(process.cwd(), output);
|
|
479
|
+
if (/[\\/]$/.test(output))
|
|
480
|
+
fs.mkdirSync(resolved, { recursive: true });
|
|
481
|
+
return resolved;
|
|
482
|
+
}
|
|
458
483
|
static async taskExport(identifier, options) {
|
|
459
484
|
// Without --output, Core names the file after the workflow in the current folder.
|
|
460
|
-
const targetPath =
|
|
485
|
+
const targetPath = CommandService.outputPath(options.output ?? '.');
|
|
461
486
|
const correlationId = generateIdentifier();
|
|
462
487
|
const payload = await IpcMessageService.generatePayload(correlationId, {
|
|
463
488
|
identifier,
|
|
@@ -488,7 +513,11 @@ export default class CommandService {
|
|
|
488
513
|
});
|
|
489
514
|
}
|
|
490
515
|
static async taskExportAll(options) {
|
|
491
|
-
const
|
|
516
|
+
const defaultName = `tipeline-workflows-export-${Date.now()}.zip`;
|
|
517
|
+
const outputPath = CommandService.outputPath(options.output ?? defaultName);
|
|
518
|
+
const targetPath = fs.existsSync(outputPath) && fs.statSync(outputPath).isDirectory()
|
|
519
|
+
? nodePath.join(outputPath, defaultName)
|
|
520
|
+
: outputPath;
|
|
492
521
|
const correlationId = generateIdentifier();
|
|
493
522
|
const payload = await IpcMessageService.generatePayload(correlationId, {
|
|
494
523
|
targetPath,
|
|
@@ -861,7 +890,9 @@ export default class CommandService {
|
|
|
861
890
|
process.exit(1);
|
|
862
891
|
}
|
|
863
892
|
// Read here too, so a mistake shows before connecting and a good one shows what it means.
|
|
864
|
-
|
|
893
|
+
// --cron takes only a cron expression, so its mistakes are explained as cron ones.
|
|
894
|
+
const cronCheck = cron ? checkCron(cron) : null;
|
|
895
|
+
const parsed = cronCheck && !cronCheck.ok ? cronCheck : parseSchedule(when ?? cron);
|
|
865
896
|
if (!parsed.ok) {
|
|
866
897
|
Printer.printError(parsed.message);
|
|
867
898
|
process.exit(1);
|
|
@@ -927,7 +958,8 @@ export default class CommandService {
|
|
|
927
958
|
const elsewhere = [...workflows, ...apps].filter(inOtherProjects);
|
|
928
959
|
const withContents = !!options.withContents && workflows.length + apps.length > 0;
|
|
929
960
|
const named = (users) => users.map((u) => (u.projects?.length ? `${u.name} (${u.projects.map((p) => p.name).join(', ')})` : u.name)).join(', ');
|
|
930
|
-
|
|
961
|
+
// With --yes nothing is asked: only what happens to its contents is worth showing.
|
|
962
|
+
const lines = [options.yes ? `Deleting project "${project.name}".` : `Delete project "${project.name}"?`];
|
|
931
963
|
if (!withContents) {
|
|
932
964
|
if (workflows.length + apps.length > 0) {
|
|
933
965
|
lines.push(` Its ${plural(workflows.length, 'workflow')} and ${plural(apps.length, 'app')} stay, out of the project.`);
|
|
@@ -965,7 +997,8 @@ export default class CommandService {
|
|
|
965
997
|
}
|
|
966
998
|
}
|
|
967
999
|
}
|
|
968
|
-
|
|
1000
|
+
if (!options.yes || lines.length > 1)
|
|
1001
|
+
Printer.printMessage(lines.join('\n'));
|
|
969
1002
|
if (!options.yes) {
|
|
970
1003
|
if (!(process.stdin.isTTY && process.stdout.isTTY)) {
|
|
971
1004
|
Printer.printError('Nothing deleted. Run with --yes to delete without asking.');
|
|
@@ -1013,10 +1046,13 @@ export default class CommandService {
|
|
|
1013
1046
|
try {
|
|
1014
1047
|
const connections = (await CommandService.localRequest('connectionList', 'onConnectionList', null)) ?? [];
|
|
1015
1048
|
const active = await CommandService.localRequest('connectionGetActive', 'onConnectionGetActive', null);
|
|
1016
|
-
|
|
1017
|
-
if (connections.length === 0)
|
|
1018
|
-
Printer.printMessage(
|
|
1019
|
-
|
|
1049
|
+
const goesTo = `Commands go to: ${connections.find((c) => c.id === active?.activeId)?.name ?? 'this machine'}`;
|
|
1050
|
+
if (connections.length === 0) {
|
|
1051
|
+
Printer.printMessage(`${goesTo}\nNo remote connections configured.`);
|
|
1052
|
+
}
|
|
1053
|
+
else {
|
|
1054
|
+
Printer.printTable(['', 'ID', 'Name', 'Address'], connections.map((c) => [c.id === active?.activeId ? '*' : '', c.id, c.name, c.host]), goesTo);
|
|
1055
|
+
}
|
|
1020
1056
|
process.exit(0);
|
|
1021
1057
|
}
|
|
1022
1058
|
catch (error) {
|
|
@@ -1080,7 +1116,13 @@ export default class CommandService {
|
|
|
1080
1116
|
Printer.printMessage('No hubs configured.');
|
|
1081
1117
|
}
|
|
1082
1118
|
else {
|
|
1083
|
-
|
|
1119
|
+
Printer.printTable(['ID', 'Name', 'Type', 'Address', 'Status'], hubs.map((h) => [
|
|
1120
|
+
h.id,
|
|
1121
|
+
h.name,
|
|
1122
|
+
h.type,
|
|
1123
|
+
h.target,
|
|
1124
|
+
`${h.enabled ? 'enabled' : 'disabled'}${h.hasToken ? ', token' : ''}`,
|
|
1125
|
+
]));
|
|
1084
1126
|
}
|
|
1085
1127
|
}
|
|
1086
1128
|
else {
|
|
@@ -1161,7 +1203,8 @@ export default class CommandService {
|
|
|
1161
1203
|
Printer.printMessage('No items in this hub catalog.');
|
|
1162
1204
|
}
|
|
1163
1205
|
else {
|
|
1164
|
-
items.
|
|
1206
|
+
Printer.printTable(['Type', 'Identifier', 'Name', 'Version'], items.map((i) => [i.type === 'task' ? 'workflow' : i.type, i.identifier, i.name, i.version ?? '']));
|
|
1207
|
+
console.log(` ${items.length} item(s). Install one with: tipeline hub install <type> ${id} <identifier>\n`);
|
|
1165
1208
|
}
|
|
1166
1209
|
}
|
|
1167
1210
|
else {
|
|
@@ -1230,23 +1273,26 @@ export default class CommandService {
|
|
|
1230
1273
|
const events = response.data ?? [];
|
|
1231
1274
|
if (events.length === 0)
|
|
1232
1275
|
Printer.printMessage('No hub updates yet.');
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1276
|
+
else
|
|
1277
|
+
Printer.printTable(['What happened', 'Type', 'Identifier', 'Name'], events.map((e) => {
|
|
1278
|
+
const type = e.item_type === 'task' ? 'workflow' : e.item_type;
|
|
1279
|
+
const lines = [Printer.hubUpdateKind(e.kind, e.from_version, e.to_version)];
|
|
1280
|
+
if (e.kind === 'breaks_workflows') {
|
|
1281
|
+
let problems = [];
|
|
1282
|
+
try {
|
|
1283
|
+
problems = JSON.parse(e.message ?? '[]');
|
|
1284
|
+
}
|
|
1285
|
+
catch {
|
|
1286
|
+
problems = [];
|
|
1287
|
+
}
|
|
1288
|
+
problems.forEach((p) => lines.push(`• ${p.workflow?.name}, step ${p.position} (${p.action}): ${p.kind}${p.detail ? ` — ${p.detail}` : ''}`));
|
|
1289
|
+
lines.push(`Fix those steps, or install anyway: tipeline hub update plugin ${e.item_identifier} --accept-breaking`);
|
|
1242
1290
|
}
|
|
1243
|
-
|
|
1244
|
-
|
|
1291
|
+
else if (e.kind === 'failed' && e.message) {
|
|
1292
|
+
lines.push(e.message);
|
|
1245
1293
|
}
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
}
|
|
1249
|
-
});
|
|
1294
|
+
return [lines.join('\n'), type, e.item_identifier, e.item_name ?? ''];
|
|
1295
|
+
}));
|
|
1250
1296
|
}
|
|
1251
1297
|
else {
|
|
1252
1298
|
Printer.printError(response.error ?? 'Unknown error');
|
|
@@ -1264,12 +1310,19 @@ export default class CommandService {
|
|
|
1264
1310
|
Printer.printError(`Unknown type "${rawType}". Use workflow, app or plugin.`);
|
|
1265
1311
|
process.exit(1);
|
|
1266
1312
|
}
|
|
1313
|
+
// Plugins go by the same names as in `plugin enable`: identifier, group or hub name.
|
|
1314
|
+
let label = identifier;
|
|
1315
|
+
if (type === 'plugin') {
|
|
1316
|
+
const plugin = await CommandService.findPlugin(identifier);
|
|
1317
|
+
identifier = plugin.identifier;
|
|
1318
|
+
label = plugin.name ?? identifier;
|
|
1319
|
+
}
|
|
1267
1320
|
const correlationId = generateIdentifier();
|
|
1268
1321
|
const payload = await IpcMessageService.generatePayload(correlationId, type === 'plugin' && acceptBreaking ? { identifier, acceptBreaking } : { identifier });
|
|
1269
1322
|
CommandService.connectAndHandle(channel, payload, {
|
|
1270
1323
|
[responseEvent]: (response) => {
|
|
1271
1324
|
if (response?.success) {
|
|
1272
|
-
Printer.printMessage(`${rawType} "${
|
|
1325
|
+
Printer.printMessage(`${rawType} "${label}" updated to ${response.data?.version ?? 'the hub version'}.`);
|
|
1273
1326
|
}
|
|
1274
1327
|
else {
|
|
1275
1328
|
Printer.printError(response.error ?? 'Unknown error');
|
|
@@ -1310,7 +1363,8 @@ export default class CommandService {
|
|
|
1310
1363
|
const plugins = (await CommandService.request('pluginList', 'onPluginList', null)) ?? [];
|
|
1311
1364
|
if (plugins.length === 0)
|
|
1312
1365
|
Printer.printMessage('No plugins installed.');
|
|
1313
|
-
|
|
1366
|
+
else
|
|
1367
|
+
Printer.printTable(['Identifier', 'Group', 'Name', 'Version', 'Status'], plugins.map((p) => [p.identifier, p.group, p.name, p.version ?? '', p.enabled ? 'enabled' : 'disabled']));
|
|
1314
1368
|
process.exit(0);
|
|
1315
1369
|
}
|
|
1316
1370
|
catch (error) {
|
|
@@ -1318,14 +1372,31 @@ export default class CommandService {
|
|
|
1318
1372
|
process.exit(1);
|
|
1319
1373
|
}
|
|
1320
1374
|
}
|
|
1375
|
+
/**
|
|
1376
|
+
* An installed plugin by its identifier, group or identifier in the hub catalog (any
|
|
1377
|
+
* case). Exits with an error when there's none.
|
|
1378
|
+
*/
|
|
1379
|
+
static async findPlugin(name) {
|
|
1380
|
+
let plugins = [];
|
|
1381
|
+
try {
|
|
1382
|
+
plugins = (await CommandService.request('pluginList', 'onPluginList', null)) ?? [];
|
|
1383
|
+
}
|
|
1384
|
+
catch (error) {
|
|
1385
|
+
Printer.printError(error?.message ?? String(error));
|
|
1386
|
+
process.exit(1);
|
|
1387
|
+
}
|
|
1388
|
+
const wanted = name.trim().toLowerCase();
|
|
1389
|
+
const plugin = plugins.find((p) => [p.identifier, p.group, p.hub_plugin_identifier].includes(name)) ??
|
|
1390
|
+
plugins.find((p) => [p.group, p.hub_plugin_identifier, p.name].some((v) => typeof v === 'string' && v.toLowerCase() === wanted));
|
|
1391
|
+
if (!plugin) {
|
|
1392
|
+
Printer.printError(`No plugin "${name}". See the installed ones with: tipeline plugin list`);
|
|
1393
|
+
process.exit(1);
|
|
1394
|
+
}
|
|
1395
|
+
return plugin;
|
|
1396
|
+
}
|
|
1321
1397
|
static async pluginSetEnabled(identifierOrGroup, enabled) {
|
|
1322
1398
|
try {
|
|
1323
|
-
const
|
|
1324
|
-
const plugin = plugins.find((p) => [p.identifier, p.group, p.hub_plugin_identifier].includes(identifierOrGroup));
|
|
1325
|
-
if (!plugin) {
|
|
1326
|
-
Printer.printError(`No plugin "${identifierOrGroup}". See the installed ones with: tipeline plugin list`);
|
|
1327
|
-
return process.exit(1);
|
|
1328
|
-
}
|
|
1399
|
+
const plugin = await CommandService.findPlugin(identifierOrGroup);
|
|
1329
1400
|
await CommandService.request('pluginSetEnabled', 'onPluginSetEnabled', {
|
|
1330
1401
|
identifier: plugin.identifier,
|
|
1331
1402
|
enabled,
|
package/dist/Printer.d.ts
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import type { ActionErrorData } from '@tipeline/types';
|
|
2
2
|
import type { ChoiceOption, DraftOutcome, ReusedWorkflow, RunProposal, RunResult } from '@tipeline/agent';
|
|
3
3
|
import type { HubTaskPreview } from './CommandService.js';
|
|
4
|
+
/** A time in this machine's time zone, like the schedule times: "YYYY-MM-DD HH:MM:SS". */
|
|
5
|
+
export declare function formatDate(value: string | Date | null | undefined): string;
|
|
6
|
+
/**
|
|
7
|
+
* Breaks text into lines of at most `maxLen`, between words. Only a word longer than a whole
|
|
8
|
+
* line (a long path or URL) is cut. A line's leading spaces are kept.
|
|
9
|
+
*/
|
|
10
|
+
export declare function wrapText(text: string, maxLen: number): string[];
|
|
4
11
|
export default class Printer {
|
|
5
12
|
static printTaskList(data: any): void;
|
|
6
13
|
static printTaskInfo(task: any): void;
|
|
@@ -60,6 +67,10 @@ export default class Printer {
|
|
|
60
67
|
private static formatScheduleTime;
|
|
61
68
|
static printApprovalList(approvals: any[]): void;
|
|
62
69
|
static printAlertList(alerts: any[], includeClosed?: boolean): void;
|
|
70
|
+
/** What a hub update event says happened, in the words Desktop uses. */
|
|
71
|
+
static hubUpdateKind(kind: string, from?: string | null, to?: string | null): string;
|
|
72
|
+
/** A plain list as a table, like the other lists. An optional title line goes above it. */
|
|
73
|
+
static printTable(head: string[], rows: string[][], title?: string): void;
|
|
63
74
|
static printScheduleList(data: any): void;
|
|
64
75
|
private static printActionError;
|
|
65
76
|
}
|
package/dist/Printer.js
CHANGED
|
@@ -5,7 +5,9 @@ import { isActionErrorData } from '@tipeline/types';
|
|
|
5
5
|
import { describeCron, describeInterval, descriptionSummary, markdownToText, } from '@tipeline/utils';
|
|
6
6
|
const require = createRequire(import.meta.url);
|
|
7
7
|
const validationMessages = require('@tipeline/i18n/locales/en/validation.json');
|
|
8
|
-
const
|
|
8
|
+
const uiStrings = require('@tipeline/i18n/locales/en/ui.json');
|
|
9
|
+
const capabilityLabels = uiStrings.capabilities.label;
|
|
10
|
+
const hubUpdateKinds = uiStrings.hub.updates.kind;
|
|
9
11
|
// "files.write" → "Changes or deletes files", the words Desktop uses.
|
|
10
12
|
const capabilityLabel = (capability) => capabilityLabels[capability.replace(/\.(\w)/g, (_, letter) => letter.toUpperCase())] ?? capability;
|
|
11
13
|
/** One line per capability: its name (review ones in yellow) and the steps that cause it. */
|
|
@@ -68,18 +70,21 @@ function formatBytes(bytes) {
|
|
|
68
70
|
return `${(bytes / 1024).toFixed(1)} KB`;
|
|
69
71
|
return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
|
|
70
72
|
}
|
|
71
|
-
|
|
73
|
+
/** A time in this machine's time zone, like the schedule times: "YYYY-MM-DD HH:MM:SS". */
|
|
74
|
+
export function formatDate(value) {
|
|
72
75
|
if (!value)
|
|
73
76
|
return '';
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
77
|
+
let date = value;
|
|
78
|
+
if (typeof value === 'string') {
|
|
79
|
+
// SQLite's "YYYY-MM-DD HH:MM:SS" has no zone but is UTC, like ISO strings ending in Z.
|
|
80
|
+
const sqlite = /^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}(\.\d+)?$/.test(value);
|
|
81
|
+
date = new Date(sqlite ? `${value.replace(' ', 'T')}Z` : value);
|
|
78
82
|
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
const
|
|
82
|
-
return
|
|
83
|
+
if (!(date instanceof Date) || Number.isNaN(date.getTime()))
|
|
84
|
+
return String(value);
|
|
85
|
+
const pad = (n) => String(n).padStart(2, '0');
|
|
86
|
+
return (`${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())} ` +
|
|
87
|
+
`${pad(date.getHours())}:${pad(date.getMinutes())}:${pad(date.getSeconds())}`);
|
|
83
88
|
}
|
|
84
89
|
function flattenActionDefs(actions, map = {}) {
|
|
85
90
|
if (!Array.isArray(actions))
|
|
@@ -136,20 +141,47 @@ function failureReasonTag(metadata) {
|
|
|
136
141
|
return null;
|
|
137
142
|
}
|
|
138
143
|
const explainsStatus = (status) => status === 'failed' || status === 'canceled';
|
|
139
|
-
|
|
144
|
+
/**
|
|
145
|
+
* Breaks text into lines of at most `maxLen`, between words. Only a word longer than a whole
|
|
146
|
+
* line (a long path or URL) is cut. A line's leading spaces are kept.
|
|
147
|
+
*/
|
|
148
|
+
export function wrapText(text, maxLen) {
|
|
140
149
|
const lines = [];
|
|
141
150
|
text.split('\n').forEach((line) => {
|
|
142
151
|
if (line.length <= maxLen) {
|
|
143
152
|
lines.push(line);
|
|
153
|
+
return;
|
|
144
154
|
}
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
155
|
+
const indent = line.match(/^\s*/)[0];
|
|
156
|
+
let current = indent;
|
|
157
|
+
const flush = () => {
|
|
158
|
+
if (current.trim())
|
|
159
|
+
lines.push(current.trimEnd());
|
|
160
|
+
current = indent;
|
|
161
|
+
};
|
|
162
|
+
for (const word of line.slice(indent.length).split(/ +/)) {
|
|
163
|
+
if (!word)
|
|
164
|
+
continue;
|
|
165
|
+
const sep = current.trim() ? ' ' : '';
|
|
166
|
+
if (current.length + sep.length + word.length <= maxLen) {
|
|
167
|
+
current += sep + word;
|
|
168
|
+
continue;
|
|
148
169
|
}
|
|
170
|
+
flush();
|
|
171
|
+
let rest = word;
|
|
172
|
+
while (indent.length + rest.length > maxLen) {
|
|
173
|
+
const room = Math.max(1, maxLen - indent.length);
|
|
174
|
+
lines.push(indent + rest.slice(0, room));
|
|
175
|
+
rest = rest.slice(room);
|
|
176
|
+
}
|
|
177
|
+
current = indent + rest;
|
|
149
178
|
}
|
|
179
|
+
flush();
|
|
150
180
|
});
|
|
151
181
|
return lines.length ? lines : [''];
|
|
152
182
|
}
|
|
183
|
+
/** Why a step with `cache:` ran again: its result held a secret, and the cache is plain text. */
|
|
184
|
+
const CACHE_SKIPPED_SECRET = 'not cached: its result contains a secret, and cached results are stored as plain text';
|
|
153
185
|
export default class Printer {
|
|
154
186
|
static printTaskList(data) {
|
|
155
187
|
if (!Array.isArray(data) || data.length === 0) {
|
|
@@ -339,7 +371,9 @@ export default class Printer {
|
|
|
339
371
|
}
|
|
340
372
|
static printAction(data, verbose) {
|
|
341
373
|
if (verbose) {
|
|
342
|
-
console.log(' ' + chalk.bold.cyan(data.name));
|
|
374
|
+
console.log(' ' + chalk.bold.cyan(data.name) + (data.cached ? ' ' + chalk.magenta('cached') : ''));
|
|
375
|
+
if (data.cacheSkipped === 'secret')
|
|
376
|
+
console.log(' ' + chalk.dim('├─ ') + chalk.yellow(CACHE_SKIPPED_SECRET));
|
|
343
377
|
if (data.params && Object.keys(data.params).length > 0) {
|
|
344
378
|
Object.entries(data.params).forEach(([key, value]) => {
|
|
345
379
|
if (typeof value === 'string' && value.includes('\n')) {
|
|
@@ -384,6 +418,7 @@ export default class Printer {
|
|
|
384
418
|
' ' +
|
|
385
419
|
chalk.bold.white(data.name) +
|
|
386
420
|
(data.cached ? ' ' + chalk.magenta('cached') : '') +
|
|
421
|
+
(data.cacheSkipped === 'secret' ? ' ' + chalk.yellow('not cached: result has a secret') : '') +
|
|
387
422
|
' ' +
|
|
388
423
|
chalk.dim('→ ') +
|
|
389
424
|
chalk.dim(result));
|
|
@@ -654,7 +689,7 @@ export default class Printer {
|
|
|
654
689
|
};
|
|
655
690
|
for (const alert of alerts) {
|
|
656
691
|
const times = alert.count > 1 ? chalk.dim(` ×${alert.count}`) : '';
|
|
657
|
-
const status = alert.status !== 'open' ? chalk.dim(` (${alert.status === 'dismissed' ? '
|
|
692
|
+
const status = alert.status !== 'open' ? chalk.dim(` (${alert.status === 'dismissed' ? 'dismissed' : 'resolved'})`) : '';
|
|
658
693
|
console.log(`\n ${levelMark[alert.level] ?? '●'} ${chalk.bold(alert.title)}${times}${status} ${chalk.dim(alert.workflowName ?? alert.taskIdentifier ?? '')}`);
|
|
659
694
|
console.log(chalk.dim(` id ${alert.id}`));
|
|
660
695
|
console.log(chalk.dim(` level ${alert.level}`));
|
|
@@ -664,7 +699,31 @@ export default class Printer {
|
|
|
664
699
|
if (alert.message)
|
|
665
700
|
console.log(` ${truncate(String(alert.message), MAX_WIDTH - 4)}`);
|
|
666
701
|
}
|
|
667
|
-
|
|
702
|
+
if (alerts.some((alert) => alert.status === 'open')) {
|
|
703
|
+
console.log(chalk.dim('\n Dismiss with: tipeline alert dismiss <id> (or --all).\n'));
|
|
704
|
+
}
|
|
705
|
+
else {
|
|
706
|
+
console.log('');
|
|
707
|
+
}
|
|
708
|
+
}
|
|
709
|
+
/** What a hub update event says happened, in the words Desktop uses. */
|
|
710
|
+
static hubUpdateKind(kind, from, to) {
|
|
711
|
+
const text = hubUpdateKinds[kind];
|
|
712
|
+
if (!text)
|
|
713
|
+
return [kind, [from, to].filter(Boolean).join(' -> ')].filter(Boolean).join(' ');
|
|
714
|
+
return text.replace('{from}', from ?? '?').replace('{to}', to ?? '?');
|
|
715
|
+
}
|
|
716
|
+
/** A plain list as a table, like the other lists. An optional title line goes above it. */
|
|
717
|
+
static printTable(head, rows, title) {
|
|
718
|
+
const table = new Table({
|
|
719
|
+
head: head.map((h) => chalk.bold(h)),
|
|
720
|
+
style: { head: [], border: ['dim'] },
|
|
721
|
+
wordWrap: true,
|
|
722
|
+
});
|
|
723
|
+
rows.forEach((row) => table.push(row));
|
|
724
|
+
if (title)
|
|
725
|
+
console.log(`\n ${title}`);
|
|
726
|
+
console.log(table.toString());
|
|
668
727
|
}
|
|
669
728
|
static printScheduleList(data) {
|
|
670
729
|
if (!Array.isArray(data) || data.length === 0) {
|
package/dist/index.js
CHANGED
|
@@ -289,7 +289,7 @@ hub
|
|
|
289
289
|
.command('update')
|
|
290
290
|
.description('Install the version a hub offers, such as a major version waiting for approval')
|
|
291
291
|
.argument('<type>', '"workflow", "app", or "plugin" ("task" also accepted)')
|
|
292
|
-
.argument('<identifier>', 'Identifier of the installed item')
|
|
292
|
+
.argument('<identifier>', 'Identifier of the installed item (a plugin also by its group or name)')
|
|
293
293
|
.option('--accept-breaking', 'Plugins: install even though saved workflow steps would stop working with the new version')
|
|
294
294
|
.action((type, identifier, options) => CommandService.hubUpdate(type, identifier, { acceptBreaking: !!options.acceptBreaking }));
|
|
295
295
|
// Plugin Commands
|
|
@@ -303,12 +303,12 @@ plugin
|
|
|
303
303
|
plugin
|
|
304
304
|
.command('enable')
|
|
305
305
|
.description('Turn a plugin on. It runs its own code on this machine, so enable only ones you trust')
|
|
306
|
-
.argument('<plugin>', 'Plugin identifier, group
|
|
306
|
+
.argument('<plugin>', 'Plugin identifier, group or name')
|
|
307
307
|
.action((identifier) => CommandService.pluginSetEnabled(identifier, true));
|
|
308
308
|
plugin
|
|
309
309
|
.command('disable')
|
|
310
310
|
.description('Turn a plugin off. Workflows that use it fail until it is on again')
|
|
311
|
-
.argument('<plugin>', 'Plugin identifier, group
|
|
311
|
+
.argument('<plugin>', 'Plugin identifier, group or name')
|
|
312
312
|
.action((identifier) => CommandService.pluginSetEnabled(identifier, false));
|
|
313
313
|
// Schedule Commands
|
|
314
314
|
const schedule = program
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tipeline/cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Tipeline CLI",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -17,11 +17,11 @@
|
|
|
17
17
|
"author": "José Daniel Estrada Guzmán",
|
|
18
18
|
"license": "Apache-2.0",
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@tipeline/agent": "0.1.
|
|
21
|
-
"@tipeline/core": "0.1.
|
|
22
|
-
"@tipeline/i18n": "0.1.
|
|
23
|
-
"@tipeline/types": "0.1.
|
|
24
|
-
"@tipeline/utils": "0.1.
|
|
20
|
+
"@tipeline/agent": "0.1.1",
|
|
21
|
+
"@tipeline/core": "0.1.1",
|
|
22
|
+
"@tipeline/i18n": "0.1.1",
|
|
23
|
+
"@tipeline/types": "0.1.1",
|
|
24
|
+
"@tipeline/utils": "0.1.1",
|
|
25
25
|
"chalk": "^5.4.1",
|
|
26
26
|
"cli-table3": "^0.6.5",
|
|
27
27
|
"commander": "^13.1.0",
|