@vforsh/argus 0.1.13 → 0.1.15
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/.tsbuildinfo +1 -1
- package/dist/argus.js +3963 -2198
- package/dist/cli/defineCommand.d.ts +26 -0
- package/dist/cli/defineCommand.d.ts.map +1 -0
- package/dist/cli/defineCommand.js +55 -0
- package/dist/cli/defineCommand.js.map +1 -0
- package/dist/cli/defineWatcherCommand.d.ts +112 -0
- package/dist/cli/defineWatcherCommand.d.ts.map +1 -0
- package/dist/cli/defineWatcherCommand.js +89 -0
- package/dist/cli/defineWatcherCommand.js.map +1 -0
- package/dist/cli/plugins/pluginAliases.d.ts +6 -0
- package/dist/cli/plugins/pluginAliases.d.ts.map +1 -0
- package/dist/cli/plugins/pluginAliases.js +10 -0
- package/dist/cli/plugins/pluginAliases.js.map +1 -0
- package/dist/cli/plugins/pluginHost.d.ts +3 -0
- package/dist/cli/plugins/pluginHost.d.ts.map +1 -0
- package/dist/cli/plugins/pluginHost.js +30 -0
- package/dist/cli/plugins/pluginHost.js.map +1 -0
- package/dist/cli/plugins/registerPlugins.d.ts +32 -1
- package/dist/cli/plugins/registerPlugins.d.ts.map +1 -1
- package/dist/cli/plugins/registerPlugins.js +102 -12
- package/dist/cli/plugins/registerPlugins.js.map +1 -1
- package/dist/cli/program.d.ts.map +1 -1
- package/dist/cli/program.js +2 -0
- package/dist/cli/program.js.map +1 -1
- package/dist/cli/register/index.d.ts.map +1 -1
- package/dist/cli/register/index.js +8 -2
- package/dist/cli/register/index.js.map +1 -1
- package/dist/cli/register/registerAuth.d.ts.map +1 -1
- package/dist/cli/register/registerAuth.js +13 -8
- package/dist/cli/register/registerAuth.js.map +1 -1
- package/dist/cli/register/registerCode.d.ts.map +1 -1
- package/dist/cli/register/registerCode.js +19 -0
- package/dist/cli/register/registerCode.js.map +1 -1
- package/dist/cli/register/registerDom.d.ts.map +1 -1
- package/dist/cli/register/registerDom.js +3 -1
- package/dist/cli/register/registerDom.js.map +1 -1
- package/dist/cli/register/registerEval.d.ts.map +1 -1
- package/dist/cli/register/registerEval.js +13 -0
- package/dist/cli/register/registerEval.js.map +1 -1
- package/dist/cli/register/registerExtension.d.ts.map +1 -1
- package/dist/cli/register/registerExtension.js +12 -0
- package/dist/cli/register/registerExtension.js.map +1 -1
- package/dist/cli/register/registerNet.d.ts.map +1 -1
- package/dist/cli/register/registerNet.js +40 -6
- package/dist/cli/register/registerNet.js.map +1 -1
- package/dist/cli/register/registerPage.d.ts.map +1 -1
- package/dist/cli/register/registerPage.js +17 -0
- package/dist/cli/register/registerPage.js.map +1 -1
- package/dist/cli/register/registerPlugin.d.ts +3 -0
- package/dist/cli/register/registerPlugin.d.ts.map +1 -0
- package/dist/cli/register/registerPlugin.js +34 -0
- package/dist/cli/register/registerPlugin.js.map +1 -0
- package/dist/cli/register/registerSnapshot.d.ts.map +1 -1
- package/dist/cli/register/registerSnapshot.js +2 -1
- package/dist/cli/register/registerSnapshot.js.map +1 -1
- package/dist/cli/register/registerWatcher.d.ts.map +1 -1
- package/dist/cli/register/registerWatcher.js +19 -0
- package/dist/cli/register/registerWatcher.js.map +1 -1
- package/dist/commands/auth.d.ts.map +1 -1
- package/dist/commands/auth.js +4 -9
- package/dist/commands/auth.js.map +1 -1
- package/dist/commands/authCookieSupport.d.ts.map +1 -1
- package/dist/commands/authCookieSupport.js +4 -6
- package/dist/commands/authCookieSupport.js.map +1 -1
- package/dist/commands/authCookies.d.ts +4 -4
- package/dist/commands/authCookies.d.ts.map +1 -1
- package/dist/commands/authCookies.js +85 -105
- package/dist/commands/authCookies.js.map +1 -1
- package/dist/commands/code.js +3 -25
- package/dist/commands/code.js.map +1 -1
- package/dist/commands/codeEdit.d.ts +9 -0
- package/dist/commands/codeEdit.d.ts.map +1 -0
- package/dist/commands/codeEdit.js +155 -0
- package/dist/commands/codeEdit.js.map +1 -0
- package/dist/commands/configInit.d.ts.map +1 -1
- package/dist/commands/configInit.js +1 -0
- package/dist/commands/configInit.js.map +1 -1
- package/dist/commands/dialog.d.ts +5 -5
- package/dist/commands/dialog.d.ts.map +1 -1
- package/dist/commands/dialog.js +36 -54
- package/dist/commands/dialog.js.map +1 -1
- package/dist/commands/domAdd.d.ts +1 -1
- package/dist/commands/domAdd.d.ts.map +1 -1
- package/dist/commands/domAdd.js +26 -30
- package/dist/commands/domAdd.js.map +1 -1
- package/dist/commands/domClick.d.ts +4 -1
- package/dist/commands/domClick.d.ts.map +1 -1
- package/dist/commands/domClick.js +83 -75
- package/dist/commands/domClick.js.map +1 -1
- package/dist/commands/domFill.d.ts +2 -2
- package/dist/commands/domFill.d.ts.map +1 -1
- package/dist/commands/domFill.js +56 -67
- package/dist/commands/domFill.js.map +1 -1
- package/dist/commands/domFocus.d.ts +1 -1
- package/dist/commands/domFocus.d.ts.map +1 -1
- package/dist/commands/domFocus.js +27 -35
- package/dist/commands/domFocus.js.map +1 -1
- package/dist/commands/domHover.d.ts +1 -1
- package/dist/commands/domHover.d.ts.map +1 -1
- package/dist/commands/domHover.js +27 -35
- package/dist/commands/domHover.js.map +1 -1
- package/dist/commands/domInfo.d.ts +1 -1
- package/dist/commands/domInfo.d.ts.map +1 -1
- package/dist/commands/domInfo.js +18 -23
- package/dist/commands/domInfo.js.map +1 -1
- package/dist/commands/domKeydown.d.ts +1 -1
- package/dist/commands/domKeydown.d.ts.map +1 -1
- package/dist/commands/domKeydown.js +22 -43
- package/dist/commands/domKeydown.js.map +1 -1
- package/dist/commands/domModify.js +27 -30
- package/dist/commands/domModify.js.map +1 -1
- package/dist/commands/domRemove.d.ts +1 -1
- package/dist/commands/domRemove.d.ts.map +1 -1
- package/dist/commands/domRemove.js +25 -34
- package/dist/commands/domRemove.js.map +1 -1
- package/dist/commands/domScroll.d.ts +2 -2
- package/dist/commands/domScroll.d.ts.map +1 -1
- package/dist/commands/domScroll.js +19 -25
- package/dist/commands/domScroll.js.map +1 -1
- package/dist/commands/domScrollTo.d.ts +1 -1
- package/dist/commands/domScrollTo.d.ts.map +1 -1
- package/dist/commands/domScrollTo.js +15 -24
- package/dist/commands/domScrollTo.js.map +1 -1
- package/dist/commands/domSetFile.d.ts +1 -1
- package/dist/commands/domSetFile.d.ts.map +1 -1
- package/dist/commands/domSetFile.js +24 -33
- package/dist/commands/domSetFile.js.map +1 -1
- package/dist/commands/domTree.d.ts +1 -1
- package/dist/commands/domTree.d.ts.map +1 -1
- package/dist/commands/domTree.js +18 -24
- package/dist/commands/domTree.js.map +1 -1
- package/dist/commands/eval.d.ts +4 -0
- package/dist/commands/eval.d.ts.map +1 -1
- package/dist/commands/eval.js +43 -56
- package/dist/commands/eval.js.map +1 -1
- package/dist/commands/evalPolling.d.ts +55 -0
- package/dist/commands/evalPolling.d.ts.map +1 -0
- package/dist/commands/evalPolling.js +59 -0
- package/dist/commands/evalPolling.js.map +1 -0
- package/dist/commands/evalShared.d.ts +24 -0
- package/dist/commands/evalShared.d.ts.map +1 -1
- package/dist/commands/evalShared.js +75 -7
- package/dist/commands/evalShared.js.map +1 -1
- package/dist/commands/evalUntil.d.ts +4 -0
- package/dist/commands/evalUntil.d.ts.map +1 -1
- package/dist/commands/evalUntil.js +47 -64
- package/dist/commands/evalUntil.js.map +1 -1
- package/dist/commands/extension/resolveExtensionWatcher.d.ts +20 -0
- package/dist/commands/extension/resolveExtensionWatcher.d.ts.map +1 -0
- package/dist/commands/extension/resolveExtensionWatcher.js +73 -0
- package/dist/commands/extension/resolveExtensionWatcher.js.map +1 -0
- package/dist/commands/extension/tabs.d.ts +8 -0
- package/dist/commands/extension/tabs.d.ts.map +1 -0
- package/dist/commands/extension/tabs.js +85 -0
- package/dist/commands/extension/tabs.js.map +1 -0
- package/dist/commands/locate.js +2 -2
- package/dist/commands/locate.js.map +1 -1
- package/dist/commands/logs.d.ts +1 -1
- package/dist/commands/logs.d.ts.map +1 -1
- package/dist/commands/logs.js +18 -27
- package/dist/commands/logs.js.map +1 -1
- package/dist/commands/net.d.ts +1 -1
- package/dist/commands/net.d.ts.map +1 -1
- package/dist/commands/net.js +14 -19
- package/dist/commands/net.js.map +1 -1
- package/dist/commands/netCapture.d.ts +10 -5
- package/dist/commands/netCapture.d.ts.map +1 -1
- package/dist/commands/netCapture.js +113 -15
- package/dist/commands/netCapture.js.map +1 -1
- package/dist/commands/netClear.d.ts +1 -1
- package/dist/commands/netClear.d.ts.map +1 -1
- package/dist/commands/netClear.js +7 -19
- package/dist/commands/netClear.js.map +1 -1
- package/dist/commands/netExport.d.ts +2 -7
- package/dist/commands/netExport.d.ts.map +1 -1
- package/dist/commands/netExport.js.map +1 -1
- package/dist/commands/netSse.d.ts +6 -0
- package/dist/commands/netSse.d.ts.map +1 -0
- package/dist/commands/netSse.js +26 -0
- package/dist/commands/netSse.js.map +1 -0
- package/dist/commands/netWatch.d.ts +2 -7
- package/dist/commands/netWatch.d.ts.map +1 -1
- package/dist/commands/netWatch.js.map +1 -1
- package/dist/commands/netWebSocket.d.ts +10 -0
- package/dist/commands/netWebSocket.d.ts.map +1 -0
- package/dist/commands/netWebSocket.js +58 -0
- package/dist/commands/netWebSocket.js.map +1 -0
- package/dist/commands/pageEmulation.d.ts +3 -3
- package/dist/commands/pageEmulation.d.ts.map +1 -1
- package/dist/commands/pageEmulation.js +72 -143
- package/dist/commands/pageEmulation.js.map +1 -1
- package/dist/commands/pageVisibility.d.ts +9 -0
- package/dist/commands/pageVisibility.d.ts.map +1 -0
- package/dist/commands/pageVisibility.js +24 -0
- package/dist/commands/pageVisibility.js.map +1 -0
- package/dist/commands/pluginConfig.d.ts +7 -0
- package/dist/commands/pluginConfig.d.ts.map +1 -0
- package/dist/commands/pluginConfig.js +199 -0
- package/dist/commands/pluginConfig.js.map +1 -0
- package/dist/commands/pluginList.d.ts +5 -0
- package/dist/commands/pluginList.d.ts.map +1 -0
- package/dist/commands/pluginList.js +26 -0
- package/dist/commands/pluginList.js.map +1 -0
- package/dist/commands/reload.d.ts +1 -1
- package/dist/commands/reload.d.ts.map +1 -1
- package/dist/commands/reload.js +8 -17
- package/dist/commands/reload.js.map +1 -1
- package/dist/commands/screenshot.d.ts +2 -1
- package/dist/commands/screenshot.d.ts.map +1 -1
- package/dist/commands/screenshot.js +45 -16
- package/dist/commands/screenshot.js.map +1 -1
- package/dist/commands/snapshot.d.ts +1 -1
- package/dist/commands/snapshot.d.ts.map +1 -1
- package/dist/commands/snapshot.js +26 -49
- package/dist/commands/snapshot.js.map +1 -1
- package/dist/commands/storage.d.ts.map +1 -1
- package/dist/commands/storage.js +26 -58
- package/dist/commands/storage.js.map +1 -1
- package/dist/commands/throttle.d.ts +6 -3
- package/dist/commands/throttle.d.ts.map +1 -1
- package/dist/commands/throttle.js +46 -118
- package/dist/commands/throttle.js.map +1 -1
- package/dist/commands/watcherStatus.d.ts +1 -1
- package/dist/commands/watcherStatus.d.ts.map +1 -1
- package/dist/commands/watcherStatus.js +8 -20
- package/dist/commands/watcherStatus.js.map +1 -1
- package/dist/config/argusConfig.d.ts +5 -0
- package/dist/config/argusConfig.d.ts.map +1 -1
- package/dist/config/argusConfig.js +33 -2
- package/dist/config/argusConfig.js.map +1 -1
- package/dist/eval/evalClient.d.ts +1 -0
- package/dist/eval/evalClient.d.ts.map +1 -1
- package/dist/eval/evalClient.js +2 -0
- package/dist/eval/evalClient.js.map +1 -1
- package/dist/output/net.d.ts +4 -1
- package/dist/output/net.d.ts.map +1 -1
- package/dist/output/net.js +59 -0
- package/dist/output/net.js.map +1 -1
- package/package.json +2 -2
- package/schemas/argus.config.schema.json +16 -0
- package/dist/cli/register/registerClick.d.ts +0 -3
- package/dist/cli/register/registerClick.d.ts.map +0 -1
- package/dist/cli/register/registerClick.js +0 -24
- package/dist/cli/register/registerClick.js.map +0 -1
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
export type ArgusCommandOption = {
|
|
3
|
+
flags: string;
|
|
4
|
+
description: string;
|
|
5
|
+
defaultValue?: string | boolean | string[];
|
|
6
|
+
required?: boolean;
|
|
7
|
+
};
|
|
8
|
+
export type ArgusCommandDefinition = {
|
|
9
|
+
name: string;
|
|
10
|
+
alias?: string;
|
|
11
|
+
description?: string;
|
|
12
|
+
arguments?: readonly {
|
|
13
|
+
flags: string;
|
|
14
|
+
description: string;
|
|
15
|
+
}[];
|
|
16
|
+
options?: readonly ArgusCommandOption[];
|
|
17
|
+
examples?: readonly string[];
|
|
18
|
+
configure?: (command: Command) => void;
|
|
19
|
+
action?: (...args: any[]) => Promise<void> | void;
|
|
20
|
+
subcommands?: readonly ArgusCommandDefinition[];
|
|
21
|
+
};
|
|
22
|
+
/** Register a declarative command definition with Commander. */
|
|
23
|
+
export declare const defineCommand: (parent: Command, definition: ArgusCommandDefinition) => Command;
|
|
24
|
+
/** Register a list of command definitions in order. */
|
|
25
|
+
export declare const defineCommands: (parent: Command, definitions: readonly ArgusCommandDefinition[]) => void;
|
|
26
|
+
//# sourceMappingURL=defineCommand.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defineCommand.d.ts","sourceRoot":"","sources":["../../src/cli/defineCommand.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAEnC,MAAM,MAAM,kBAAkB,GAAG;IAChC,KAAK,EAAE,MAAM,CAAA;IACb,WAAW,EAAE,MAAM,CAAA;IACnB,YAAY,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,MAAM,EAAE,CAAA;IAC1C,QAAQ,CAAC,EAAE,OAAO,CAAA;CAClB,CAAA;AAED,MAAM,MAAM,sBAAsB,GAAG;IACpC,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,SAAS,CAAC,EAAE,SAAS;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE,EAAE,CAAA;IAC7D,OAAO,CAAC,EAAE,SAAS,kBAAkB,EAAE,CAAA;IACvC,QAAQ,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;IAC5B,SAAS,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAA;IACtC,MAAM,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAA;IACjD,WAAW,CAAC,EAAE,SAAS,sBAAsB,EAAE,CAAA;CAC/C,CAAA;AAED,gEAAgE;AAChE,eAAO,MAAM,aAAa,GAAI,QAAQ,OAAO,EAAE,YAAY,sBAAsB,KAAG,OAgCnF,CAAA;AAED,uDAAuD;AACvD,eAAO,MAAM,cAAc,GAAI,QAAQ,OAAO,EAAE,aAAa,SAAS,sBAAsB,EAAE,KAAG,IAIhG,CAAA"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
/** Register a declarative command definition with Commander. */
|
|
3
|
+
export const defineCommand = (parent, definition) => {
|
|
4
|
+
const command = parent.command(definition.name);
|
|
5
|
+
if (definition.alias) {
|
|
6
|
+
command.alias(definition.alias);
|
|
7
|
+
}
|
|
8
|
+
if (definition.description) {
|
|
9
|
+
command.description(definition.description);
|
|
10
|
+
}
|
|
11
|
+
for (const argument of definition.arguments ?? []) {
|
|
12
|
+
command.argument(argument.flags, argument.description);
|
|
13
|
+
}
|
|
14
|
+
for (const option of definition.options ?? []) {
|
|
15
|
+
if (option.required) {
|
|
16
|
+
addRequiredOption(command, option);
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
addOption(command, option);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
if (definition.examples && definition.examples.length > 0) {
|
|
23
|
+
command.addHelpText('after', formatExamples(definition.examples));
|
|
24
|
+
}
|
|
25
|
+
definition.configure?.(command);
|
|
26
|
+
for (const subcommand of definition.subcommands ?? []) {
|
|
27
|
+
defineCommand(command, subcommand);
|
|
28
|
+
}
|
|
29
|
+
if (definition.action) {
|
|
30
|
+
command.action(definition.action);
|
|
31
|
+
}
|
|
32
|
+
return command;
|
|
33
|
+
};
|
|
34
|
+
/** Register a list of command definitions in order. */
|
|
35
|
+
export const defineCommands = (parent, definitions) => {
|
|
36
|
+
for (const definition of definitions) {
|
|
37
|
+
defineCommand(parent, definition);
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
const addRequiredOption = (command, option) => {
|
|
41
|
+
if (option.defaultValue === undefined) {
|
|
42
|
+
command.requiredOption(option.flags, option.description);
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
command.requiredOption(option.flags, option.description, option.defaultValue);
|
|
46
|
+
};
|
|
47
|
+
const addOption = (command, option) => {
|
|
48
|
+
if (option.defaultValue === undefined) {
|
|
49
|
+
command.option(option.flags, option.description);
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
command.option(option.flags, option.description, option.defaultValue);
|
|
53
|
+
};
|
|
54
|
+
const formatExamples = (examples) => `\nExamples:\n${examples.map((example) => ` $ ${example}`).join('\n')}\n`;
|
|
55
|
+
//# sourceMappingURL=defineCommand.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defineCommand.js","sourceRoot":"","sources":["../../src/cli/defineCommand.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAqBnC,gEAAgE;AAChE,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,MAAe,EAAE,UAAkC,EAAW,EAAE;IAC7F,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,CAAA;IAE/C,IAAI,UAAU,CAAC,KAAK,EAAE,CAAC;QACtB,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,CAAA;IAChC,CAAC;IACD,IAAI,UAAU,CAAC,WAAW,EAAE,CAAC;QAC5B,OAAO,CAAC,WAAW,CAAC,UAAU,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AAiB,GAAG,CAAC,OAAgB,EAAE,MAA0B,EAAQ,EAAE;IAChF,IAAI,MAAM,CAAC,YAAY,KAAK,SAAS,EAAE,CAAC;QACvC,OAAO,CAAC,cAAc,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,WAAW,CAAC,CAAA;QACxD,OAAM;IACP,CAAC;IACD,OAAO,CAAC,cAAc,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,WAAW,EAAE,MAAM,CAAC,YAAY,CAAC,CAAA;AAC9E,CAAC,CAAA;AAED,MAAM,SAAS,GAAG,CAAC,OAAgB,EAAE,MAA0B,EAAQ,EAAE;IACxE,IAAI,MAAM,CAAC,YAAY,KAAK,SAAS,EAAE,CAAC;QACvC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,WAAW,CAAC,CAAA;QAChD,OAAM;IACP,CAAC;IACD,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,WAAW,EAAE,MAAM,CAAC,YAAY,CAAC,CAAA;AACtE,CAAC,CAAA;AAED,MAAM,cAAc,GAAG,CAAC,QAA2B,EAAU,EAAE,CAAC,gBAAgB,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,OAAO,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAA"}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import type { ProtocolSchema, WatcherRecord } from '@vforsh/argus-core';
|
|
2
|
+
import type { Output } from '../output/io.js';
|
|
3
|
+
import { requestWatcherAction, type WatcherRequestInput, type WatcherRequestSuccess } from '../watchers/requestWatcher.js';
|
|
4
|
+
/**
|
|
5
|
+
* Plan for a single watcher HTTP request, produced by a command's `build` step.
|
|
6
|
+
*
|
|
7
|
+
* Most commands return a constant plan; commands that adapt the path or timeout
|
|
8
|
+
* to their inputs (`/storage/<area>`, `Math.max(30s, wait + 5s)`) compute the
|
|
9
|
+
* plan from `options`. Returning `null` from `build` short-circuits the command
|
|
10
|
+
* after the build step has written its own warning + set `process.exitCode`.
|
|
11
|
+
*/
|
|
12
|
+
export type WatcherRequestPlan = {
|
|
13
|
+
/** Request path. May be dynamic (e.g. ``/storage/${area}``). */
|
|
14
|
+
path: string;
|
|
15
|
+
/** HTTP method. Defaults to `'POST'` when `body` is set, else `'GET'`. */
|
|
16
|
+
method?: 'GET' | 'POST';
|
|
17
|
+
/** Request body. Encoded as JSON. Subject to schema validation when `spec.schema` is set. */
|
|
18
|
+
body?: unknown;
|
|
19
|
+
/** Optional query string. */
|
|
20
|
+
query?: URLSearchParams;
|
|
21
|
+
/** Override the default 30s timeout. */
|
|
22
|
+
timeoutMs?: number;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Shared one-shot request helper for commands that need the watcher metadata
|
|
26
|
+
* for additional local work instead of a direct JSON/human render pipeline.
|
|
27
|
+
*/
|
|
28
|
+
export declare const requestWatcherCommandJson: <T>(input: WatcherRequestInput, output: Output) => Promise<WatcherRequestSuccess<T> | null>;
|
|
29
|
+
/**
|
|
30
|
+
* Shared API-action request helper for command support modules that cannot use
|
|
31
|
+
* `defineWatcherCommand` directly because they compose multiple watcher calls.
|
|
32
|
+
*/
|
|
33
|
+
export declare const requestWatcherCommandAction: typeof requestWatcherAction;
|
|
34
|
+
/** Context passed to `formatHuman` / `formatJson` after a successful request. */
|
|
35
|
+
export type WatcherCommandContext<TArgs extends readonly unknown[], TOptions> = {
|
|
36
|
+
output: Output;
|
|
37
|
+
watcher: WatcherRecord;
|
|
38
|
+
args: TArgs;
|
|
39
|
+
options: TOptions;
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* Spec for a CLI command that talks to a watcher.
|
|
43
|
+
*
|
|
44
|
+
* The runner produced by {@link defineWatcherCommand} owns the cross-cutting
|
|
45
|
+
* pipeline (createOutput → build → optional schema → requestWatcherAction →
|
|
46
|
+
* JSON-vs-human dispatch). The spec only needs the parts that are unique to
|
|
47
|
+
* this command.
|
|
48
|
+
*
|
|
49
|
+
* `TArgs` is a tuple of positional CLI arguments (excluding the watcher id and
|
|
50
|
+
* the trailing options object). Most commands use `[]`; commands like `argus
|
|
51
|
+
* fill <id> <value>` use `[string | undefined]`.
|
|
52
|
+
*/
|
|
53
|
+
export type WatcherCommandSpec<TArgs extends readonly unknown[], TOptions extends {
|
|
54
|
+
json?: boolean;
|
|
55
|
+
}, TBody, TResponse extends {
|
|
56
|
+
ok: true;
|
|
57
|
+
}> = {
|
|
58
|
+
/**
|
|
59
|
+
* Validate inputs and produce the HTTP request plan. May read stdin/files,
|
|
60
|
+
* so it can be async. Return `null` to short-circuit (after the build has
|
|
61
|
+
* already written a warning and set `process.exitCode`).
|
|
62
|
+
*/
|
|
63
|
+
build: (args: TArgs, options: TOptions, output: Output) => Promise<WatcherRequestPlan | null> | WatcherRequestPlan | null;
|
|
64
|
+
/**
|
|
65
|
+
* Treat non-standard flags as JSON mode. Use sparingly for legacy commands
|
|
66
|
+
* such as `logs --json-full` where JSON output predates the shared `--json`
|
|
67
|
+
* flag contract.
|
|
68
|
+
*/
|
|
69
|
+
isJson?: (options: TOptions) => boolean;
|
|
70
|
+
/**
|
|
71
|
+
* Optional protocol schema applied to `plan.body` before sending. When the
|
|
72
|
+
* schema rejects the body, the runner writes the issues and exits with code 2.
|
|
73
|
+
*/
|
|
74
|
+
schema?: ProtocolSchema<TBody>;
|
|
75
|
+
/**
|
|
76
|
+
* Render the success response for human users.
|
|
77
|
+
* Defaults to compact pretty-printed JSON when omitted.
|
|
78
|
+
*/
|
|
79
|
+
formatHuman?: (response: TResponse, ctx: WatcherCommandContext<TArgs, TOptions>) => void;
|
|
80
|
+
/**
|
|
81
|
+
* Map the success response to the JSON output payload.
|
|
82
|
+
* Defaults to identity (`response`).
|
|
83
|
+
*/
|
|
84
|
+
formatJson?: (response: TResponse, ctx: WatcherCommandContext<TArgs, TOptions>) => unknown;
|
|
85
|
+
};
|
|
86
|
+
/**
|
|
87
|
+
* Runner produced by {@link defineWatcherCommand}. Signature is
|
|
88
|
+
* `(id, ...args, options) => Promise<void>` — the same shape Commander
|
|
89
|
+
* action callbacks already use, so the runner drops in unchanged.
|
|
90
|
+
*/
|
|
91
|
+
export type WatcherCommandRunner<TArgs extends readonly unknown[], TOptions> = (id: string | undefined, ...rest: [...TArgs, TOptions]) => Promise<void>;
|
|
92
|
+
/**
|
|
93
|
+
* Build a runner for a watcher CLI command.
|
|
94
|
+
*
|
|
95
|
+
* Pipeline (in order):
|
|
96
|
+
* 1. `createOutput(options)` — JSON vs human stream selection.
|
|
97
|
+
* 2. `spec.build(args, options, output)` — validation + body/path/timeout.
|
|
98
|
+
* Returning `null` cleanly aborts.
|
|
99
|
+
* 3. Optional `spec.schema.parse(plan.body)` — protocol validation.
|
|
100
|
+
* 4. `requestWatcherAction(...)` — resolve watcher + transport + ErrorResponse.
|
|
101
|
+
* 5. JSON path: write `formatJson?.(...) ?? response`.
|
|
102
|
+
* 6. Human path: call `formatHuman` (or pretty-print JSON as fallback).
|
|
103
|
+
*
|
|
104
|
+
* Type inference resolves `TArgs`/`TOptions`/`TResponse` from the spec, so most
|
|
105
|
+
* call sites don't need explicit generics.
|
|
106
|
+
*/
|
|
107
|
+
export declare const defineWatcherCommand: <TOptions extends {
|
|
108
|
+
json?: boolean;
|
|
109
|
+
}, TResponse extends {
|
|
110
|
+
ok: true;
|
|
111
|
+
}, TBody = unknown, TArgs extends readonly unknown[] = []>(spec: WatcherCommandSpec<TArgs, TOptions, TBody, TResponse>) => WatcherCommandRunner<TArgs, TOptions>;
|
|
112
|
+
//# sourceMappingURL=defineWatcherCommand.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defineWatcherCommand.d.ts","sourceRoot":"","sources":["../../src/cli/defineWatcherCommand.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,oBAAoB,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import { createOutput } from '../output/io.js';
|
|
3
|
+
import { requestWatcherAction, requestWatcherJson, writeRequestError, } from '../watchers/requestWatcher.js';
|
|
4
|
+
/** Default request timeout when a plan does not specify one. */
|
|
5
|
+
const DEFAULT_TIMEOUT_MS = 30_000;
|
|
6
|
+
/**
|
|
7
|
+
* Shared one-shot request helper for commands that need the watcher metadata
|
|
8
|
+
* for additional local work instead of a direct JSON/human render pipeline.
|
|
9
|
+
*/
|
|
10
|
+
export const requestWatcherCommandJson = async (input, output) => {
|
|
11
|
+
const result = await requestWatcherJson(input);
|
|
12
|
+
if (!result.ok) {
|
|
13
|
+
writeRequestError(result, output);
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
return result;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Shared API-action request helper for command support modules that cannot use
|
|
20
|
+
* `defineWatcherCommand` directly because they compose multiple watcher calls.
|
|
21
|
+
*/
|
|
22
|
+
export const requestWatcherCommandAction = requestWatcherAction;
|
|
23
|
+
/**
|
|
24
|
+
* Build a runner for a watcher CLI command.
|
|
25
|
+
*
|
|
26
|
+
* Pipeline (in order):
|
|
27
|
+
* 1. `createOutput(options)` — JSON vs human stream selection.
|
|
28
|
+
* 2. `spec.build(args, options, output)` — validation + body/path/timeout.
|
|
29
|
+
* Returning `null` cleanly aborts.
|
|
30
|
+
* 3. Optional `spec.schema.parse(plan.body)` — protocol validation.
|
|
31
|
+
* 4. `requestWatcherAction(...)` — resolve watcher + transport + ErrorResponse.
|
|
32
|
+
* 5. JSON path: write `formatJson?.(...) ?? response`.
|
|
33
|
+
* 6. Human path: call `formatHuman` (or pretty-print JSON as fallback).
|
|
34
|
+
*
|
|
35
|
+
* Type inference resolves `TArgs`/`TOptions`/`TResponse` from the spec, so most
|
|
36
|
+
* call sites don't need explicit generics.
|
|
37
|
+
*/
|
|
38
|
+
export const defineWatcherCommand = (spec) => async (id, ...rest) => {
|
|
39
|
+
// `rest` ends with the options object; everything before it is positional CLI args.
|
|
40
|
+
const tail = rest.length - 1;
|
|
41
|
+
const options = rest[tail];
|
|
42
|
+
const args = rest.slice(0, tail);
|
|
43
|
+
const output = createOutput({ ...options, json: options.json === true || spec.isJson?.(options) === true });
|
|
44
|
+
const plan = await spec.build(args, options, output);
|
|
45
|
+
if (plan == null)
|
|
46
|
+
return;
|
|
47
|
+
const body = validateBody(plan, spec.schema, output);
|
|
48
|
+
if (body === SCHEMA_REJECTED)
|
|
49
|
+
return;
|
|
50
|
+
const result = await requestWatcherAction({
|
|
51
|
+
id,
|
|
52
|
+
path: plan.path,
|
|
53
|
+
method: plan.method ?? (plan.body !== undefined ? 'POST' : 'GET'),
|
|
54
|
+
body,
|
|
55
|
+
query: plan.query,
|
|
56
|
+
timeoutMs: plan.timeoutMs ?? DEFAULT_TIMEOUT_MS,
|
|
57
|
+
}, output);
|
|
58
|
+
if (!result)
|
|
59
|
+
return;
|
|
60
|
+
const ctx = { output, watcher: result.watcher, args, options };
|
|
61
|
+
if (output.json) {
|
|
62
|
+
output.writeJson(spec.formatJson ? spec.formatJson(result.data, ctx) : result.data);
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
if (spec.formatHuman) {
|
|
66
|
+
spec.formatHuman(result.data, ctx);
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
output.writeHuman(JSON.stringify(result.data, null, 2));
|
|
70
|
+
};
|
|
71
|
+
/** Sentinel returned by {@link validateBody} when schema validation failed. */
|
|
72
|
+
const SCHEMA_REJECTED = Symbol('schema-rejected');
|
|
73
|
+
/**
|
|
74
|
+
* Validate `plan.body` against an optional schema. On failure, write a warning,
|
|
75
|
+
* set `process.exitCode = 2`, and return {@link SCHEMA_REJECTED} so the caller
|
|
76
|
+
* can early-exit. On success (or when no schema is provided), return the body
|
|
77
|
+
* to send.
|
|
78
|
+
*/
|
|
79
|
+
const validateBody = (plan, schema, output) => {
|
|
80
|
+
if (!schema || plan.body === undefined)
|
|
81
|
+
return plan.body;
|
|
82
|
+
const parsed = schema.parse(plan.body);
|
|
83
|
+
if (parsed.ok)
|
|
84
|
+
return parsed.value;
|
|
85
|
+
output.writeWarn(formatProtocolValidationIssues(parsed.issues));
|
|
86
|
+
process.exitCode = 2;
|
|
87
|
+
return SCHEMA_REJECTED;
|
|
88
|
+
};
|
|
89
|
+
//# sourceMappingURL=defineWatcherCommand.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defineWatcherCommand.js","sourceRoot":"","sources":["../../src/cli/defineWatcherCommand.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,8BAA8B,EAAE,MAAM,oBAAoB,CAAA;AAEnE,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAC9C,OAAO,EACN,oBAAoB,EACpB,kBAAkB,EAClB,iBAAiB,GAGjB,MAAM,+BAA+B,CAAA;AAuBtC,gEAAgE;AAChE,MAAM,kBAAkB,GAAG,MAAM,CAAA;AAEjC;;;GAGG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,KAAK,EAAK,KAA0B,EAAE,MAAc,EAA4C,EAAE;IAC1I,MAAM,MAAM,GAAG,MAAM,kBAAkB,CAAI,KAAK,CAAC,CAAA;IACjD,IAAI,CAAC,MAAM,CAAC,EAAE,EAAE,CAAC;QAChB,iBAAiB,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;QACjC,OAAO,IAAI,CAAA;IACZ,CAAC;IACD,OAAO,MAAM,CAAA;AACd,CAAC,CAAA;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG,oBAAoB,CAAA;AAkE/D;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAChC,CACC,IAA2D,EACnB,EAAE,CAC3C,KAAK,EAAE,EAAE,EAAE,GAAG,IAAI,EAAE,EAAE;IACrB,oFAAoF;IACpF,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,GAAG,CAAC,CAAA;IAC5B,MAAM,OAAO,GAA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;IAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;CAItH,CAAA"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export const BUILTIN_PLUGIN_ALIASES = {
|
|
2
|
+
gsheets: '@vforsh/argus-plugin-google-sheets',
|
|
3
|
+
gs: '@vforsh/argus-plugin-google-sheets',
|
|
4
|
+
};
|
|
5
|
+
export const resolvePluginAlias = (spec, aliases) => {
|
|
6
|
+
const trimmed = spec.trim();
|
|
7
|
+
const resolved = aliases[trimmed];
|
|
8
|
+
return resolved ? { spec: resolved, alias: trimmed } : { spec: trimmed, alias: null };
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=pluginAliases.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pluginAliases.js","sourceRoot":"","sources":["../../../src/cli/plugins/pluginAliases.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,sBAAsB,GAA2B;IAC7D,OAAO,EAAE,oCAAoC;IAC7C,EAAE,EAAE,oCAAoC;CACxC,CAAA;AAED,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,IAAY,EAAE,OAA+B,EAA0C,EAAE;IAC3H,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,EAAE,CAAA;IAC3B,MAAM,QAAQ,GAAG,OAAO,CAAC,OAAO,CAAC,CAAA;IACjC,OAAO,QAAQ,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,CAAA;AACtF,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pluginHost.d.ts","sourceRoot":"","sources":["../../../src/cli/plugins/pluginHost.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAkD,iBAAiB,EAAE,MAAM,0BAA0B,CAAA;AA2BjH,eAAO,MAAM,gBAAgB,QAAO,iBAOlC,CAAA"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { createOutput } from '../../output/io.js';
|
|
2
|
+
import { runChromeOpen } from '../../commands/chrome.js';
|
|
3
|
+
import { defineWatcherCommand } from '../defineWatcherCommand.js';
|
|
4
|
+
import { requestWatcherJson, writeRequestError } from '../../watchers/requestWatcher.js';
|
|
5
|
+
const DEFAULT_TIMEOUT_MS = 30_000;
|
|
6
|
+
const postWatcherJson = (id, path, body, timeoutMs = DEFAULT_TIMEOUT_MS) => requestWatcherJson({
|
|
7
|
+
id,
|
|
8
|
+
path,
|
|
9
|
+
method: 'POST',
|
|
10
|
+
body,
|
|
11
|
+
timeoutMs,
|
|
12
|
+
});
|
|
13
|
+
const argus = {
|
|
14
|
+
eval: (id, request, options) => postWatcherJson(id, '/eval', request, options?.timeoutMs ?? request.timeoutMs ?? DEFAULT_TIMEOUT_MS),
|
|
15
|
+
dom: {
|
|
16
|
+
click: (id, request, options) => postWatcherJson(id, '/dom/click', request, options?.timeoutMs),
|
|
17
|
+
info: (id, request, options) => postWatcherJson(id, '/dom/info', request, options?.timeoutMs),
|
|
18
|
+
keydown: (id, request, options) => postWatcherJson(id, '/dom/keydown', request, options?.timeoutMs),
|
|
19
|
+
},
|
|
20
|
+
screenshot: (id, request = {}, options) => postWatcherJson(id, '/screenshot', request, options?.timeoutMs),
|
|
21
|
+
};
|
|
22
|
+
export const createPluginHost = () => ({
|
|
23
|
+
createOutput,
|
|
24
|
+
requestWatcherJson,
|
|
25
|
+
writeRequestError,
|
|
26
|
+
runChromeOpen,
|
|
27
|
+
defineWatcherCommand: defineWatcherCommand,
|
|
28
|
+
argus,
|
|
29
|
+
});
|
|
30
|
+
//# sourceMappingURL=pluginHost.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pluginHost.js","sourceRoot":"","sources":["../../../src/cli/plugins/pluginHost.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE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EAAE,OAAO,EAAE,SAAS,CAAC;CAC1G,CAAA;AAED,MAAM,CAAC,MAAM,gBAAgB,GAAG,GAAsB,EAAE,CAAC,CAAC;IACzD,YAAY;IACZ,kBAAkB;IAClB,iBAAiB;IACjB,aAAa;IACb,oBAAoB,EAAE,oBAAiD;IACvE,KAAK;CACL,CAAC,CAAA"}
|
|
@@ -1,3 +1,34 @@
|
|
|
1
1
|
import type { Command } from 'commander';
|
|
2
|
-
|
|
2
|
+
type PluginSource = 'config' | 'env' | 'cli';
|
|
3
|
+
export type PluginLoadEntry = {
|
|
4
|
+
source: PluginSource;
|
|
5
|
+
spec: string;
|
|
6
|
+
resolvedSpec: string;
|
|
7
|
+
alias: string | null;
|
|
8
|
+
status: 'loaded';
|
|
9
|
+
name: string;
|
|
10
|
+
version: string | null;
|
|
11
|
+
description: string | null;
|
|
12
|
+
commands: string[];
|
|
13
|
+
homepage: string | null;
|
|
14
|
+
minArgusVersion: string | null;
|
|
15
|
+
url: string;
|
|
16
|
+
} | {
|
|
17
|
+
source: PluginSource;
|
|
18
|
+
spec: string;
|
|
19
|
+
resolvedSpec: string;
|
|
20
|
+
alias: string | null;
|
|
21
|
+
status: 'failed';
|
|
22
|
+
error: string;
|
|
23
|
+
url?: string;
|
|
24
|
+
};
|
|
25
|
+
export type PluginLoadReport = {
|
|
26
|
+
configPath: string | null;
|
|
27
|
+
configDir: string | null;
|
|
28
|
+
cwd: string;
|
|
29
|
+
entries: PluginLoadEntry[];
|
|
30
|
+
};
|
|
31
|
+
export declare const getPluginLoadReport: () => PluginLoadReport;
|
|
32
|
+
export declare const registerPlugins: (program: Command, argv?: readonly string[]) => Promise<void>;
|
|
33
|
+
export {};
|
|
3
34
|
//# sourceMappingURL=registerPlugins.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registerPlugins.d.ts","sourceRoot":"","sources":["../../../src/cli/plugins/registerPlugins.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"regist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C,IAAI,CA+ErH,CAAA"}
|
|
@@ -1,10 +1,18 @@
|
|
|
1
1
|
import path from 'node:path';
|
|
2
|
+
import { existsSync } from 'node:fs';
|
|
2
3
|
import { pathToFileURL } from 'node:url';
|
|
3
4
|
import { ARGUS_PLUGIN_API_VERSION } from '@vforsh/argus-plugin-api';
|
|
4
5
|
import { resolveArgusConfigPath, loadArgusConfig } from '../../config/argusConfig.js';
|
|
5
6
|
import { createOutput } from '../../output/io.js';
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
7
|
+
import { BUILTIN_PLUGIN_ALIASES, resolvePluginAlias } from './pluginAliases.js';
|
|
8
|
+
import { createPluginHost } from './pluginHost.js';
|
|
9
|
+
let lastPluginLoadReport = {
|
|
10
|
+
configPath: null,
|
|
11
|
+
configDir: null,
|
|
12
|
+
cwd: process.cwd(),
|
|
13
|
+
entries: [],
|
|
14
|
+
};
|
|
15
|
+
export const getPluginLoadReport = () => lastPluginLoadReport;
|
|
8
16
|
const parseEnvPlugins = () => {
|
|
9
17
|
const raw = process.env.ARGUS_PLUGINS;
|
|
10
18
|
if (!raw)
|
|
@@ -15,6 +23,31 @@ const parseEnvPlugins = () => {
|
|
|
15
23
|
.filter(Boolean);
|
|
16
24
|
};
|
|
17
25
|
const uniq = (values) => Array.from(new Set(values));
|
|
26
|
+
const createPluginInput = (source, spec, aliases) => {
|
|
27
|
+
const resolved = resolvePluginAlias(spec, aliases);
|
|
28
|
+
return { source, spec, resolvedSpec: resolved.spec, alias: resolved.alias };
|
|
29
|
+
};
|
|
30
|
+
/** Plugins must be loaded before Commander parses commands, so scan raw argv for dynamic loads. */
|
|
31
|
+
const parseCliPlugins = (argv) => {
|
|
32
|
+
const plugins = [];
|
|
33
|
+
for (let i = 0; i < argv.length; i++) {
|
|
34
|
+
const arg = argv[i];
|
|
35
|
+
if (arg === '--plugin') {
|
|
36
|
+
const value = argv[i + 1];
|
|
37
|
+
if (value && !value.startsWith('-')) {
|
|
38
|
+
plugins.push(value);
|
|
39
|
+
i++;
|
|
40
|
+
}
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
if (arg.startsWith('--plugin=')) {
|
|
44
|
+
const value = arg.slice('--plugin='.length).trim();
|
|
45
|
+
if (value)
|
|
46
|
+
plugins.push(value);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return plugins;
|
|
50
|
+
};
|
|
18
51
|
const resolveWithImportMeta = (specifier, parentUrl) => {
|
|
19
52
|
const resolver = import.meta.resolve;
|
|
20
53
|
if (typeof resolver !== 'function') {
|
|
@@ -22,6 +55,7 @@ const resolveWithImportMeta = (specifier, parentUrl) => {
|
|
|
22
55
|
}
|
|
23
56
|
return resolver(specifier, parentUrl);
|
|
24
57
|
};
|
|
58
|
+
const isPathLikeSpecifier = (specifier) => specifier.startsWith('.') || specifier.startsWith('/');
|
|
25
59
|
const resolvePluginModuleUrl = (specifier, baseDirs) => {
|
|
26
60
|
const trimmed = specifier.trim();
|
|
27
61
|
if (!trimmed) {
|
|
@@ -31,6 +65,22 @@ const resolvePluginModuleUrl = (specifier, baseDirs) => {
|
|
|
31
65
|
return { ok: true, url: trimmed };
|
|
32
66
|
}
|
|
33
67
|
const errors = [];
|
|
68
|
+
if (isPathLikeSpecifier(trimmed)) {
|
|
69
|
+
for (const baseDir of baseDirs) {
|
|
70
|
+
try {
|
|
71
|
+
const resolvedPath = path.resolve(baseDir, trimmed);
|
|
72
|
+
if (existsSync(resolvedPath)) {
|
|
73
|
+
return { ok: true, url: pathToFileURL(resolvedPath).href };
|
|
74
|
+
}
|
|
75
|
+
errors.push(`${baseDir}: ${resolvedPath} does not exist`);
|
|
76
|
+
}
|
|
77
|
+
catch (error) {
|
|
78
|
+
const msg = error instanceof Error ? error.message : String(error);
|
|
79
|
+
errors.push(`${baseDir}: ${msg}`);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return { ok: false, error: `Failed to resolve plugin path "${specifier}". Tried:\n${errors.map((e) => `- ${e}`).join('\n')}` };
|
|
83
|
+
}
|
|
34
84
|
// 1) Prefer resolving relative to the Argus installation itself.
|
|
35
85
|
// This covers "plugin installed next to argus" (e.g. global install or argus dependency).
|
|
36
86
|
try {
|
|
@@ -68,27 +118,66 @@ const extractPlugin = (mod) => {
|
|
|
68
118
|
return null;
|
|
69
119
|
return plugin;
|
|
70
120
|
};
|
|
121
|
+
const normalizeOptionalString = (value) => (typeof value === 'string' && value.trim() ? value.trim() : null);
|
|
122
|
+
const normalizeCommands = (value) => {
|
|
123
|
+
if (!Array.isArray(value))
|
|
124
|
+
return [];
|
|
125
|
+
const commands = value
|
|
126
|
+
.filter((item) => typeof item === 'string')
|
|
127
|
+
.map((item) => item.trim())
|
|
128
|
+
.filter(Boolean);
|
|
129
|
+
return Array.from(new Set(commands));
|
|
130
|
+
};
|
|
71
131
|
const warnPluginLoad = (source, spec, message) => {
|
|
72
132
|
const output = createOutput({ json: false });
|
|
73
133
|
output.writeWarn(`[plugins] Failed to load (${source}) "${spec}": ${message}`);
|
|
74
134
|
};
|
|
75
|
-
|
|
135
|
+
const recordPluginFailure = (entries, entry, error, url) => {
|
|
136
|
+
entries.push({ source: entry.source, spec: entry.spec, resolvedSpec: entry.resolvedSpec, alias: entry.alias, status: 'failed', url, error });
|
|
137
|
+
warnPluginLoad(entry.source, entry.spec, error);
|
|
138
|
+
};
|
|
139
|
+
const createLoadedEntry = (entry, plugin, url) => ({
|
|
140
|
+
source: entry.source,
|
|
141
|
+
spec: entry.spec,
|
|
142
|
+
resolvedSpec: entry.resolvedSpec,
|
|
143
|
+
alias: entry.alias,
|
|
144
|
+
status: 'loaded',
|
|
145
|
+
name: plugin.name,
|
|
146
|
+
version: normalizeOptionalString(plugin.version),
|
|
147
|
+
description: normalizeOptionalString(plugin.description),
|
|
148
|
+
commands: normalizeCommands(plugin.commands),
|
|
149
|
+
homepage: normalizeOptionalString(plugin.homepage),
|
|
150
|
+
minArgusVersion: normalizeOptionalString(plugin.minArgusVersion),
|
|
151
|
+
url,
|
|
152
|
+
});
|
|
153
|
+
export const registerPlugins = async (program, argv = process.argv.slice(2)) => {
|
|
76
154
|
const cwd = process.cwd();
|
|
77
155
|
const configPath = resolveArgusConfigPath({ cwd });
|
|
78
156
|
const configResult = configPath ? loadArgusConfig(configPath) : null;
|
|
157
|
+
const aliases = { ...BUILTIN_PLUGIN_ALIASES, ...(configResult?.config.pluginAliases ?? {}) };
|
|
79
158
|
const configPlugins = configResult?.config.plugins ?? [];
|
|
80
159
|
const envPlugins = parseEnvPlugins();
|
|
160
|
+
const cliPlugins = parseCliPlugins(argv);
|
|
81
161
|
const all = [];
|
|
82
162
|
for (const spec of configPlugins)
|
|
83
|
-
all.push(
|
|
163
|
+
all.push(createPluginInput('config', spec, aliases));
|
|
84
164
|
for (const spec of envPlugins)
|
|
85
|
-
all.push(
|
|
165
|
+
all.push(createPluginInput('env', spec, aliases));
|
|
166
|
+
for (const spec of cliPlugins)
|
|
167
|
+
all.push(createPluginInput('cli', spec, aliases));
|
|
168
|
+
const entries = [];
|
|
169
|
+
lastPluginLoadReport = {
|
|
170
|
+
configPath,
|
|
171
|
+
configDir: configResult?.configDir ?? null,
|
|
172
|
+
cwd,
|
|
173
|
+
entries,
|
|
174
|
+
};
|
|
86
175
|
if (all.length === 0)
|
|
87
176
|
return;
|
|
88
177
|
// Preserve original order, but avoid duplicate loads.
|
|
89
178
|
const seen = new Set();
|
|
90
179
|
const ordered = all.filter((p) => {
|
|
91
|
-
const key = p.
|
|
180
|
+
const key = p.resolvedSpec.trim();
|
|
92
181
|
if (!key)
|
|
93
182
|
return false;
|
|
94
183
|
if (seen.has(key))
|
|
@@ -99,15 +188,15 @@ export const registerPlugins = async (program) => {
|
|
|
99
188
|
const baseDirs = uniq([configResult?.configDir, cwd].filter((v) => Boolean(v)));
|
|
100
189
|
const ctxBase = {
|
|
101
190
|
apiVersion: ARGUS_PLUGIN_API_VERSION,
|
|
102
|
-
host:
|
|
191
|
+
host: createPluginHost(),
|
|
103
192
|
cwd,
|
|
104
193
|
configPath,
|
|
105
194
|
configDir: configResult?.configDir ?? null,
|
|
106
195
|
};
|
|
107
196
|
for (const entry of ordered) {
|
|
108
|
-
const resolved = resolvePluginModuleUrl(entry.
|
|
197
|
+
const resolved = resolvePluginModuleUrl(entry.resolvedSpec, baseDirs);
|
|
109
198
|
if (!resolved.ok) {
|
|
110
|
-
|
|
199
|
+
recordPluginFailure(entries, entry, resolved.error);
|
|
111
200
|
continue;
|
|
112
201
|
}
|
|
113
202
|
let mod;
|
|
@@ -115,19 +204,20 @@ export const registerPlugins = async (program) => {
|
|
|
115
204
|
mod = await import(resolved.url);
|
|
116
205
|
}
|
|
117
206
|
catch (error) {
|
|
118
|
-
|
|
207
|
+
recordPluginFailure(entries, entry, error instanceof Error ? error.message : String(error), resolved.url);
|
|
119
208
|
continue;
|
|
120
209
|
}
|
|
121
210
|
const plugin = extractPlugin(mod);
|
|
122
211
|
if (!plugin) {
|
|
123
|
-
|
|
212
|
+
recordPluginFailure(entries, entry, 'Invalid plugin export (expected default export with { apiVersion: 1, name, register() }).', resolved.url);
|
|
124
213
|
continue;
|
|
125
214
|
}
|
|
126
215
|
try {
|
|
127
216
|
await plugin.register({ ...ctxBase, program });
|
|
217
|
+
entries.push(createLoadedEntry(entry, plugin, resolved.url));
|
|
128
218
|
}
|
|
129
219
|
catch (error) {
|
|
130
|
-
|
|
220
|
+
recordPluginFailure(entries, entry, error instanceof Error ? error.message : String(error), resolved.url);
|
|
131
221
|
}
|
|
132
222
|
}
|
|
133
223
|
};
|