@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
package/dist/commands/reload.js
CHANGED
|
@@ -1,23 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { requestWatcherJson, writeRequestError } from '../watchers/requestWatcher.js';
|
|
1
|
+
import { defineWatcherCommand } from '../cli/defineWatcherCommand.js';
|
|
3
2
|
/** Execute the reload command for a watcher id. */
|
|
4
|
-
export const runReload =
|
|
5
|
-
|
|
6
|
-
const result = await requestWatcherJson({
|
|
7
|
-
id,
|
|
3
|
+
export const runReload = defineWatcherCommand({
|
|
4
|
+
build: (_args, options) => ({
|
|
8
5
|
path: '/reload',
|
|
9
6
|
method: 'POST',
|
|
10
7
|
body: { ignoreCache: options.ignoreCache ?? false },
|
|
11
8
|
timeoutMs: 10_000,
|
|
12
|
-
})
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
if (options.json) {
|
|
18
|
-
output.writeJson(result.data);
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
|
-
output.writeHuman(`reloaded ${result.watcher.id}`);
|
|
22
|
-
};
|
|
9
|
+
}),
|
|
10
|
+
formatHuman: (_response, { output, watcher }) => {
|
|
11
|
+
output.writeHuman(`reloaded ${watcher.id}`);
|
|
12
|
+
},
|
|
13
|
+
});
|
|
23
14
|
//# sourceMappingURL=reload.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reload.js","sourceRoot":"","sources":["../../src/commands/reload.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"reload.js","sourceRoot":"","sources":["../../src/commands/reload.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAA;AAQrE,mDAAmD;AACnD,MAAM,CAAC,MAAM,SAAS,GAAG,oBAAoB,CAAgC;IAC5E,KAAK,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE,CAAC,CAAC;QAC3B,IAAI,EAAE,SAAS;QACf,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,EAAE,WAAW,EAAE,OAAO,CAAC,WAAW,IAAI,KAAK,EAAE;QACnD,SAAS,EAAE,MAAM;KACjB,CAAC;IACF,WAAW,EAAE,CAAC,SAAS,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,EAAE;QAC/C,MAAM,CAAC,UAAU,CAAC,YAAY,OAAO,CAAC,EAAE,EAAE,CAAC,CAAA;IAC5C,CAAC;CACD,CAAC,CAAA"}
|
|
@@ -3,7 +3,8 @@ export type ScreenshotOptions = {
|
|
|
3
3
|
json?: boolean;
|
|
4
4
|
out?: string;
|
|
5
5
|
selector?: string;
|
|
6
|
+
clip?: string;
|
|
6
7
|
};
|
|
7
8
|
/** Execute the screenshot command for a watcher id. */
|
|
8
|
-
export declare const runScreenshot: (
|
|
9
|
+
export declare const runScreenshot: import("../cli/defineWatcherCommand.js").WatcherCommandRunner<[], ScreenshotOptions>;
|
|
9
10
|
//# sourceMappingURL=screenshot.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"screenshot.d.ts","sourceRoot":"","sources":["../../src/commands/screenshot.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"screenshot.d.ts","sourceRoot":"","sources":["../../src/commands/screenshot.ts"],"names":[],"mappings":"AAMA,0CAA0C;AAC1C,MAAM,MAAM,iBAAiB,GAAG;IAC/B,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,IAAI,CAAC,EAAE,MAAM,CAAA;CACb,CAAA;AAED,uDAAuD;AACvD,eAAO,MAAM,aAAa,sFAKxB,CAAA"}
|
|
@@ -1,27 +1,56 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { defineWatcherCommand } from '../cli/defineWatcherCommand.js';
|
|
2
|
+
const SCREENSHOT_REQUEST_TIMEOUT_MS = 45_000;
|
|
3
3
|
/** Execute the screenshot command for a watcher id. */
|
|
4
|
-
export const runScreenshot =
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
export const runScreenshot = defineWatcherCommand({
|
|
5
|
+
build: (_args, options, output) => buildScreenshotPlan(options, output),
|
|
6
|
+
formatHuman: (response, { output }) => {
|
|
7
|
+
output.writeHuman(`Screenshot saved: ${response.outFile}`);
|
|
8
|
+
},
|
|
9
|
+
});
|
|
10
|
+
const buildScreenshotPlan = (options, output) => {
|
|
11
|
+
const clip = parseScreenshotClip(options.clip, output);
|
|
12
|
+
if (clip === null) {
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
const selector = normalizeSelector(options.selector);
|
|
16
|
+
if (selector && clip) {
|
|
17
|
+
writeScreenshotOptionError(output, 'Cannot use both --selector and --clip');
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
return {
|
|
8
21
|
path: '/screenshot',
|
|
9
22
|
method: 'POST',
|
|
10
23
|
body: {
|
|
11
24
|
outFile: options.out,
|
|
12
|
-
selector
|
|
25
|
+
selector,
|
|
26
|
+
clip,
|
|
13
27
|
format: 'png',
|
|
14
28
|
},
|
|
15
|
-
timeoutMs:
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
29
|
+
timeoutMs: SCREENSHOT_REQUEST_TIMEOUT_MS,
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
const normalizeSelector = (selector) => {
|
|
33
|
+
const trimmed = selector?.trim();
|
|
34
|
+
return trimmed ? trimmed : undefined;
|
|
35
|
+
};
|
|
36
|
+
const parseScreenshotClip = (value, output) => {
|
|
37
|
+
if (value == null) {
|
|
38
|
+
return undefined;
|
|
39
|
+
}
|
|
40
|
+
const parts = value.split(',').map((part) => part.trim());
|
|
41
|
+
if (parts.length !== 4 || parts.some((part) => !part)) {
|
|
42
|
+
writeScreenshotOptionError(output, 'Invalid --clip value: expected x,y,width,height.');
|
|
43
|
+
return null;
|
|
20
44
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
45
|
+
const [x, y, width, height] = parts.map(Number);
|
|
46
|
+
if (![x, y, width, height].every(Number.isFinite) || width <= 0 || height <= 0) {
|
|
47
|
+
writeScreenshotOptionError(output, 'Invalid --clip value: x and y must be finite numbers; width and height must be > 0.');
|
|
48
|
+
return null;
|
|
24
49
|
}
|
|
25
|
-
|
|
50
|
+
return { x, y, width, height };
|
|
51
|
+
};
|
|
52
|
+
const writeScreenshotOptionError = (output, message) => {
|
|
53
|
+
output.writeWarn(message);
|
|
54
|
+
process.exitCode = 2;
|
|
26
55
|
};
|
|
27
56
|
//# sourceMappingURL=screenshot.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"screenshot.js","sourceRoot":"","sources":["../../src/commands/screenshot.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"screenshot.js","sourceRoot":"","sources":["../../src/commands/screenshot.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAA2B,MAAM,gCAAgC,CAAA;AAG9F,MAAM,6BAA6B,GAAG,MAAM,CAAA;AAU5C,uDAAuD;AACvD,MAAM,CAAC,MAAM,aAAa,GAAG,oBAAoB,CAAwC;IACxF,KAAK,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,CAAC,mBAAmB,CAAC,OAAO,EAAE,MAAM,CAAC;IACvE,WAAW,EAAE,CAAC,QAAQ,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE;QACrC,MAAM,CAAC,UAAU,CAAC,qBAAqB,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAA;IAC3D,CAAC;CACD,CAAC,CAAA;AAEF,MAAM,mBAAmB,GAAG,CAAC,OAA0B,EAAE,MAAc,EAA6B,EAAE;IACrG,MAAM,IAAI,GAAG,mBAAmB,CAAC,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,CAAA;IACtD,IAAI,IAAI,KAAK,IAAI,EAAE,CAAC;QACnB,OAAO,IAAI,CAAA;IACZ,CAAC;IAED,MAAM,QAAQ,GAAG,iBAAiB,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAA;IACpD,IAAI,QAAQ,IAAI,IAAI,EAAE,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,QAAQ,CAAC,IAAI,KAAK,IAAI,CAAC,IAAI,MAAM,IAAI,CAAC,EAAE,CAAC;QAChF,0BAA0B,CAAC,MAAM,EAAE,qFAAqF,CAAC,CAAA;QACzH,OAAO,IAAI,CAAA;IACZ,CAAC;IAED,OAAO,EAAE,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,CAAA;AAC/B,CAAC,CAAA;AAED,MAAM,0BAA0B,GAAG,CAAC,MAAc,EAAE,OAAe,EAAQ,EAAE;IAC5E,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,CAAA;IACzB,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAA;AACrB,CAAC,CAAA"}
|
|
@@ -6,5 +6,5 @@ export type SnapshotOptions = {
|
|
|
6
6
|
json?: boolean;
|
|
7
7
|
};
|
|
8
8
|
/** Execute the snapshot command for a watcher id. */
|
|
9
|
-
export declare const runSnapshot: (
|
|
9
|
+
export declare const runSnapshot: import("../cli/defineWatcherCommand.js").WatcherCommandRunner<[], SnapshotOptions>;
|
|
10
10
|
//# sourceMappingURL=snapshot.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"snapshot.d.ts","sourceRoot":"","sources":["../../src/commands/snapshot.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"snapshot.d.ts","sourceRoot":"","sources":["../../src/commands/snapshot.ts"],"names":[],"mappings":"AAKA,wCAAwC;AACxC,MAAM,MAAM,eAAe,GAAG;IAC7B,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,IAAI,CAAC,EAAE,OAAO,CAAA;CACd,CAAA;AAED,qDAAqD;AACrD,eAAO,MAAM,WAAW,oFAyBtB,CAAA"}
|
|
@@ -1,54 +1,31 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { createOutput } from '../output/io.js';
|
|
1
|
+
import { defineWatcherCommand } from '../cli/defineWatcherCommand.js';
|
|
3
2
|
import { parsePositiveInt } from '../cli/parse.js';
|
|
4
|
-
import {
|
|
3
|
+
import { formatAccessibilityTree } from '../output/accessibility.js';
|
|
5
4
|
/** Execute the snapshot command for a watcher id. */
|
|
6
|
-
export const runSnapshot =
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
14
|
-
const result = await requestWatcherJson({
|
|
15
|
-
id,
|
|
16
|
-
path: '/snapshot',
|
|
17
|
-
method: 'POST',
|
|
18
|
-
body: {
|
|
19
|
-
selector: options.selector,
|
|
20
|
-
depth,
|
|
21
|
-
interactive: options.interactive ?? false,
|
|
22
|
-
},
|
|
23
|
-
timeoutMs: 30_000,
|
|
24
|
-
returnErrorResponse: true,
|
|
25
|
-
});
|
|
26
|
-
if (!result.ok) {
|
|
27
|
-
writeRequestError(result, output);
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
|
-
const response = result.data;
|
|
31
|
-
if (!response.ok) {
|
|
32
|
-
const errorResp = response;
|
|
33
|
-
if (options.json) {
|
|
34
|
-
output.writeJson(response);
|
|
5
|
+
export const runSnapshot = defineWatcherCommand({
|
|
6
|
+
build: (_args, options, output) => {
|
|
7
|
+
const depth = parsePositiveInt(options.depth);
|
|
8
|
+
if (options.depth !== undefined && depth === undefined) {
|
|
9
|
+
output.writeWarn('--depth must be a positive integer');
|
|
10
|
+
process.exitCode = 2;
|
|
11
|
+
return null;
|
|
35
12
|
}
|
|
36
|
-
|
|
37
|
-
|
|
13
|
+
return {
|
|
14
|
+
path: '/snapshot',
|
|
15
|
+
method: 'POST',
|
|
16
|
+
body: {
|
|
17
|
+
selector: options.selector,
|
|
18
|
+
depth,
|
|
19
|
+
interactive: options.interactive ?? false,
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
},
|
|
23
|
+
formatHuman: (response, { output }) => {
|
|
24
|
+
if (response.roots.length === 0) {
|
|
25
|
+
output.writeWarn('Accessibility tree is empty.');
|
|
26
|
+
return;
|
|
38
27
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
const successResp = response;
|
|
43
|
-
if (options.json) {
|
|
44
|
-
output.writeJson(successResp);
|
|
45
|
-
return;
|
|
46
|
-
}
|
|
47
|
-
if (successResp.roots.length === 0) {
|
|
48
|
-
output.writeWarn('Accessibility tree is empty.');
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
const formatted = formatAccessibilityTree(successResp.roots);
|
|
52
|
-
output.writeHuman(formatted);
|
|
53
|
-
};
|
|
28
|
+
output.writeHuman(formatAccessibilityTree(response.roots));
|
|
29
|
+
},
|
|
30
|
+
});
|
|
54
31
|
//# sourceMappingURL=snapshot.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"snapshot.js","sourceRoot":"","sources":["../../src/commands/snapshot.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"snapshot.js","sourceRoot":"","sources":["../../src/commands/snapshot.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAA;AACrE,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAClD,OAAO,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAA;AAUpE,qDAAqD;AACrD,MAAM,CAAC,MAAM,WAAW,GAAG,oBAAoB,CAAoC;IAClF,KAAK,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE;QACjC,MAAM,KAAK,GAAG,gBAAgB,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;QAC7C,IAAI,OAAO,CAAC,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACxD,MAAM,CAAC,SAAS,CAAC,oCAAoC,CAAC,CAAA;YACtD,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAA;YACpB,OAAO,IAAI,CAAA;QACZ,CAAC;QACD,OAAO;YACN,IAAI,EAAE,WAAW;YACjB,MAAM,EAAE,MAAM;YACd,IAAI,EAAE;gBACL,QAAQ,EAAE,OAAO,CAAC,QAAQ;gBAC1B,KAAK;gBACL,WAAW,EAAE,OAAO,CAAC,WAAW,IAAI,KAAK;aACzC;SACD,CAAA;IACF,CAAC;IACD,WAAW,EAAE,CAAC,QAAQ,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE;QACrC,IAAI,QAAQ,CAAC,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACjC,MAAM,CAAC,SAAS,CAAC,8BAA8B,CAAC,CAAA;YAChD,OAAM;QACP,CAAC;QACD,MAAM,CAAC,UAAU,CAAC,uBAAuB,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAA;IAC3D,CAAC;CACD,CAAC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../../src/commands/storage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../../src/commands/storage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,WAAW,EAOX,MAAM,oBAAoB,CAAA;AAG3B,0CAA0C;AAC1C,MAAM,MAAM,cAAc,GAAG;IAC5B,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,IAAI,CAAC,EAAE,OAAO,CAAA;CACd,CAAA;AAKD,0CAA0C;AAC1C,eAAO,MAAM,aAAa,GAAI,MAAM,WAAW,EAAE,IAAI,MAAM,GAAG,SAAS,EAAE,KAAK,MAAM,EAAE,SAAS,cAAc,KAAG,OAAO,CAAC,IAAI,CACnF,CAAA;AAEzC,0CAA0C;AAC1C,eAAO,MAAM,aAAa,GAAI,MAAM,WAAW,EAAE,IAAI,MAAM,GAAG,SAAS,EAAE,KAAK,MAAM,EAAE,OAAO,MAAM,EAAE,SAAS,cAAc,KAAG,OAAO,CAAC,IAAI,CAC3F,CAAA;AAEhD,6CAA6C;AAC7C,eAAO,MAAM,gBAAgB,GAAI,MAAM,WAAW,EAAE,IAAI,MAAM,GAAG,SAAS,EAAE,KAAK,MAAM,EAAE,SAAS,cAAc,KAAG,OAAO,CAAC,IAAI,CACnF,CAAA;AAE5C,2CAA2C;AAC3C,eAAO,MAAM,cAAc,GAAI,MAAM,WAAW,EAAE,IAAI,MAAM,GAAG,SAAS,EAAE,SAAS,cAAc,KAAG,OAAO,CAAC,IAAI,CAC3E,CAAA;AAErC,4CAA4C;AAC5C,eAAO,MAAM,eAAe,GAAI,MAAM,WAAW,EAAE,IAAI,MAAM,GAAG,SAAS,EAAE,SAAS,cAAc,KAAG,OAAO,CAAC,IAAI,CAC3E,CAAA"}
|
package/dist/commands/storage.js
CHANGED
|
@@ -1,67 +1,35 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { requestWatcherJson, writeRequestError } from '../watchers/requestWatcher.js';
|
|
1
|
+
import { defineWatcherCommand } from '../cli/defineWatcherCommand.js';
|
|
3
2
|
/** Execute `argus storage <area> get`. */
|
|
4
|
-
export const runStorageGet =
|
|
5
|
-
await runStorageCommand(area, id, { action: 'get', key, origin: options.origin }, options, (response, output) => {
|
|
6
|
-
output.writeHuman(response.value ?? 'null');
|
|
7
|
-
});
|
|
8
|
-
};
|
|
3
|
+
export const runStorageGet = (area, id, key, options) => getRunner(id, key, { ...options, area });
|
|
9
4
|
/** Execute `argus storage <area> set`. */
|
|
10
|
-
export const runStorageSet =
|
|
11
|
-
await runStorageCommand(area, id, { action: 'set', key, value, origin: options.origin }, options, (response, output) => {
|
|
12
|
-
output.writeHuman(`Set ${response.key} on ${response.origin}`);
|
|
13
|
-
});
|
|
14
|
-
};
|
|
5
|
+
export const runStorageSet = (area, id, key, value, options) => setRunner(id, key, value, { ...options, area });
|
|
15
6
|
/** Execute `argus storage <area> remove`. */
|
|
16
|
-
export const runStorageRemove =
|
|
17
|
-
await runStorageCommand(area, id, { action: 'remove', key, origin: options.origin }, options, (response, output) => {
|
|
18
|
-
output.writeHuman(`Removed ${response.key} from ${response.origin}`);
|
|
19
|
-
});
|
|
20
|
-
};
|
|
7
|
+
export const runStorageRemove = (area, id, key, options) => removeRunner(id, key, { ...options, area });
|
|
21
8
|
/** Execute `argus storage <area> list`. */
|
|
22
|
-
export const runStorageList =
|
|
23
|
-
await runStorageCommand(area, id, { action: 'list', origin: options.origin }, options, (response, output) => {
|
|
24
|
-
for (const key of response.keys) {
|
|
25
|
-
output.writeHuman(key);
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
|
-
};
|
|
9
|
+
export const runStorageList = (area, id, options) => listRunner(id, { ...options, area });
|
|
29
10
|
/** Execute `argus storage <area> clear`. */
|
|
30
|
-
export const runStorageClear =
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
if (options.json) {
|
|
42
|
-
output.writeJson(response);
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
writeHuman(response, output);
|
|
46
|
-
};
|
|
47
|
-
const callStorage = async (area, id, payload, output) => {
|
|
48
|
-
const result = await requestWatcherJson({
|
|
49
|
-
id,
|
|
50
|
-
path: `/storage/${area}`,
|
|
11
|
+
export const runStorageClear = (area, id, options) => clearRunner(id, { ...options, area });
|
|
12
|
+
/**
|
|
13
|
+
* Build a runner for one storage command. Bakes in the shared HTTP shape
|
|
14
|
+
* (`POST /storage/<area>` with a 10s timeout); callers supply the per-action
|
|
15
|
+
* payload and human formatter.
|
|
16
|
+
*/
|
|
17
|
+
const storageRunner = (body, formatHuman) => defineWatcherCommand({
|
|
18
|
+
build: (args, options) => ({
|
|
19
|
+
path: `/storage/${options.area}`,
|
|
51
20
|
method: 'POST',
|
|
52
|
-
body:
|
|
21
|
+
body: body(args, options),
|
|
53
22
|
timeoutMs: 10_000,
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
return null;
|
|
23
|
+
}),
|
|
24
|
+
formatHuman,
|
|
25
|
+
});
|
|
26
|
+
const getRunner = storageRunner(([key], { origin }) => ({ action: 'get', key, origin }), (response, { output }) => output.writeHuman(response.value ?? 'null'));
|
|
27
|
+
const setRunner = storageRunner(([key, value], { origin }) => ({ action: 'set', key, value, origin }), (response, { output }) => output.writeHuman(`Set ${response.key} on ${response.origin}`));
|
|
28
|
+
const removeRunner = storageRunner(([key], { origin }) => ({ action: 'remove', key, origin }), (response, { output }) => output.writeHuman(`Removed ${response.key} from ${response.origin}`));
|
|
29
|
+
const listRunner = storageRunner((_args, { origin }) => ({ action: 'list', origin }), (response, { output }) => {
|
|
30
|
+
for (const key of response.keys) {
|
|
31
|
+
output.writeHuman(key);
|
|
64
32
|
}
|
|
65
|
-
|
|
66
|
-
};
|
|
33
|
+
});
|
|
34
|
+
const clearRunner = storageRunner((_args, { origin }) => ({ action: 'clear', origin }), (response, { output }) => output.writeHuman(`Cleared ${response.cleared} item(s) from ${response.origin}`));
|
|
67
35
|
//# sourceMappingURL=storage.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage.js","sourceRoot":"","sources":["../../src/commands/storage.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"storage.js","sourceRoot":"","sources":["../../src/commands/storage.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,oBAAoB,EAAyD,MAAM,gCAAgC,CAAA;AAW5H,0CAA0C;AAC1C,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,IAAiB,EAAE,EAAsB,EAAE,GAAW,EAAE,OAAuB,EAAiB,EAAE,CAC/H,SAAS,CAAC,EAAE,EAAE,GAAG,EAAE,EAAE,GAAG,OAAO,EAAE,IAAI,EAAE,CAAC,CAA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AA;IACvB,CAAC;AACF,CAAC,CACD,CAAA;AAED,MAAM,WAAW,GAAG,aAAa,CAChC,CAAC,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,EACpD,CAAC,QAAQ,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC,WAAW,QAAQ,CAAC,OAAO,iBAAiB,QAAQ,CAAC,MAAM,EAAE,CAAC,CAC1G,CAAA"}
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
export type ThrottleSetOptions = {
|
|
2
2
|
json?: boolean;
|
|
3
3
|
};
|
|
4
|
-
|
|
4
|
+
/** Execute `argus throttle set <id> <rate>`. */
|
|
5
|
+
export declare const runThrottleSet: import("../cli/defineWatcherCommand.js").WatcherCommandRunner<[rateRaw: string], ThrottleSetOptions>;
|
|
5
6
|
export type ThrottleClearOptions = {
|
|
6
7
|
json?: boolean;
|
|
7
8
|
};
|
|
8
|
-
|
|
9
|
+
/** Execute `argus throttle clear <id>`. */
|
|
10
|
+
export declare const runThrottleClear: import("../cli/defineWatcherCommand.js").WatcherCommandRunner<[], ThrottleClearOptions>;
|
|
9
11
|
export type ThrottleStatusOptions = {
|
|
10
12
|
json?: boolean;
|
|
11
13
|
};
|
|
12
|
-
|
|
14
|
+
/** Execute `argus throttle status <id>`. */
|
|
15
|
+
export declare const runThrottleStatus: import("../cli/defineWatcherCommand.js").WatcherCommandRunner<[], ThrottleStatusOptions>;
|
|
13
16
|
//# sourceMappingURL=throttle.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"throttle.d.ts","sourceRoot":"","sources":["../../src/commands/throttle.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"throttle.d.ts","sourceRoot":"","sources":["../../src/commands/throttle.ts"],"names":[],"mappings":"AAUA,MAAM,MAAM,kBAAkB,GAAG;IAChC,IAAI,CAAC,EAAE,OAAO,CAAA;CACd,CAAA;AAED,gDAAgD;AAChD,eAAO,MAAM,cAAc,sGAyBzB,CAAA;AAMF,MAAM,MAAM,oBAAoB,GAAG;IAClC,IAAI,CAAC,EAAE,OAAO,CAAA;CACd,CAAA;AAED,2CAA2C;AAC3C,eAAO,MAAM,gBAAgB,yFAK3B,CAAA;AAMF,MAAM,MAAM,qBAAqB,GAAG;IACnC,IAAI,CAAC,EAAE,OAAO,CAAA;CACd,CAAA;AAED,4CAA4C;AAC5C,eAAO,MAAM,iBAAiB,0FAc5B,CAAA"}
|
|
@@ -1,124 +1,52 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
id,
|
|
13
|
-
path: '/throttle',
|
|
14
|
-
method: 'POST',
|
|
15
|
-
body: { action: 'set', rate },
|
|
16
|
-
timeoutMs: 10_000,
|
|
17
|
-
returnErrorResponse: true,
|
|
18
|
-
});
|
|
19
|
-
if (!result.ok) {
|
|
20
|
-
writeRequestError(result, output);
|
|
21
|
-
return;
|
|
22
|
-
}
|
|
23
|
-
const response = result.data;
|
|
24
|
-
if (!response.ok) {
|
|
25
|
-
const err = response;
|
|
26
|
-
if (options.json) {
|
|
27
|
-
output.writeJson(response);
|
|
1
|
+
import { defineWatcherCommand } from '../cli/defineWatcherCommand.js';
|
|
2
|
+
const TIMEOUT_WRITE_MS = 10_000;
|
|
3
|
+
const TIMEOUT_READ_MS = 5_000;
|
|
4
|
+
/** Execute `argus throttle set <id> <rate>`. */
|
|
5
|
+
export const runThrottleSet = defineWatcherCommand({
|
|
6
|
+
build: ([rateRaw], _options, output) => {
|
|
7
|
+
const rate = Number(rateRaw);
|
|
8
|
+
if (!Number.isFinite(rate) || rate < 1) {
|
|
9
|
+
output.writeWarn('rate must be a number >= 1 (1 = no throttle, 4 = 4x slowdown)');
|
|
10
|
+
process.exitCode = 2;
|
|
11
|
+
return null;
|
|
28
12
|
}
|
|
29
|
-
|
|
30
|
-
|
|
13
|
+
return { path: '/throttle', method: 'POST', body: { action: 'set', rate }, timeoutMs: TIMEOUT_WRITE_MS };
|
|
14
|
+
},
|
|
15
|
+
formatHuman: (response, { output, args }) => {
|
|
16
|
+
const rate = Number(args[0]);
|
|
17
|
+
if (response.applied) {
|
|
18
|
+
output.writeHuman(`Applied CPU throttle: ${rate}x`);
|
|
19
|
+
return;
|
|
31
20
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
if (options.json) {
|
|
36
|
-
output.writeJson(response);
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
const res = response;
|
|
40
|
-
if (res.applied) {
|
|
41
|
-
output.writeHuman(`Applied CPU throttle: ${rate}x`);
|
|
42
|
-
}
|
|
43
|
-
else if (!res.attached) {
|
|
44
|
-
output.writeHuman(`Queued CPU throttle (watcher detached): ${rate}x`);
|
|
45
|
-
}
|
|
46
|
-
else {
|
|
47
|
-
output.writeHuman(`Throttle set but not applied: ${rate}x`);
|
|
48
|
-
if (res.error) {
|
|
49
|
-
output.writeWarn(`Error: ${res.error.message}`);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
export const runThrottleClear = async (id, options) => {
|
|
54
|
-
const output = createOutput(options);
|
|
55
|
-
const result = await requestWatcherJson({
|
|
56
|
-
id,
|
|
57
|
-
path: '/throttle',
|
|
58
|
-
method: 'POST',
|
|
59
|
-
body: { action: 'clear' },
|
|
60
|
-
timeoutMs: 10_000,
|
|
61
|
-
returnErrorResponse: true,
|
|
62
|
-
});
|
|
63
|
-
if (!result.ok) {
|
|
64
|
-
writeRequestError(result, output);
|
|
65
|
-
return;
|
|
66
|
-
}
|
|
67
|
-
const response = result.data;
|
|
68
|
-
if (!response.ok) {
|
|
69
|
-
const err = response;
|
|
70
|
-
if (options.json) {
|
|
71
|
-
output.writeJson(response);
|
|
21
|
+
if (!response.attached) {
|
|
22
|
+
output.writeHuman(`Queued CPU throttle (watcher detached): ${rate}x`);
|
|
23
|
+
return;
|
|
72
24
|
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
process.exitCode = 1;
|
|
77
|
-
return;
|
|
78
|
-
}
|
|
79
|
-
if (options.json) {
|
|
80
|
-
output.writeJson(response);
|
|
81
|
-
return;
|
|
82
|
-
}
|
|
83
|
-
output.writeHuman('Cleared CPU throttle');
|
|
84
|
-
};
|
|
85
|
-
export const runThrottleStatus = async (id, options) => {
|
|
86
|
-
const output = createOutput(options);
|
|
87
|
-
const result = await requestWatcherJson({
|
|
88
|
-
id,
|
|
89
|
-
path: '/throttle',
|
|
90
|
-
method: 'GET',
|
|
91
|
-
timeoutMs: 5_000,
|
|
92
|
-
returnErrorResponse: true,
|
|
93
|
-
});
|
|
94
|
-
if (!result.ok) {
|
|
95
|
-
writeRequestError(result, output);
|
|
96
|
-
return;
|
|
97
|
-
}
|
|
98
|
-
const response = result.data;
|
|
99
|
-
if (!response.ok) {
|
|
100
|
-
const err = response;
|
|
101
|
-
if (options.json) {
|
|
102
|
-
output.writeJson(response);
|
|
25
|
+
output.writeHuman(`Throttle set but not applied: ${rate}x`);
|
|
26
|
+
if (response.error) {
|
|
27
|
+
output.writeWarn(`Error: ${response.error.message}`);
|
|
103
28
|
}
|
|
104
|
-
|
|
105
|
-
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
/** Execute `argus throttle clear <id>`. */
|
|
32
|
+
export const runThrottleClear = defineWatcherCommand({
|
|
33
|
+
build: () => ({ path: '/throttle', method: 'POST', body: { action: 'clear' }, timeoutMs: TIMEOUT_WRITE_MS }),
|
|
34
|
+
formatHuman: (_response, { output }) => {
|
|
35
|
+
output.writeHuman('Cleared CPU throttle');
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
/** Execute `argus throttle status <id>`. */
|
|
39
|
+
export const runThrottleStatus = defineWatcherCommand({
|
|
40
|
+
build: () => ({ path: '/throttle', method: 'GET', timeoutMs: TIMEOUT_READ_MS }),
|
|
41
|
+
formatHuman: (response, { output }) => {
|
|
42
|
+
const lines = [];
|
|
43
|
+
lines.push(`attached: ${response.attached}`);
|
|
44
|
+
lines.push(`applied: ${response.applied}`);
|
|
45
|
+
lines.push(`cpu: ${response.state ? `${response.state.rate}x slowdown` : 'none'}`);
|
|
46
|
+
if (response.lastError) {
|
|
47
|
+
lines.push(`error: ${response.lastError.message}`);
|
|
106
48
|
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
if (options.json) {
|
|
111
|
-
output.writeJson(response);
|
|
112
|
-
return;
|
|
113
|
-
}
|
|
114
|
-
const res = response;
|
|
115
|
-
const lines = [];
|
|
116
|
-
lines.push(`attached: ${res.attached}`);
|
|
117
|
-
lines.push(`applied: ${res.applied}`);
|
|
118
|
-
lines.push(`cpu: ${res.state ? `${res.state.rate}x slowdown` : 'none'}`);
|
|
119
|
-
if (res.lastError) {
|
|
120
|
-
lines.push(`error: ${res.lastError.message}`);
|
|
121
|
-
}
|
|
122
|
-
output.writeHuman(lines.join('\n'));
|
|
123
|
-
};
|
|
49
|
+
output.writeHuman(lines.join('\n'));
|
|
50
|
+
},
|
|
51
|
+
});
|
|
124
52
|
//# sourceMappingURL=throttle.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"throttle.js","sourceRoot":"","sources":["../../src/commands/throttle.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"throttle.js","sourceRoot":"","sources":["../../src/commands/throttle.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAA;AAErE,MAAM,gBAAgB,GAAG,MAAM,CAAA;AAC/B,MAAM,eAAe,GAAG,KAAK,CAAA;AAU7B,gDAAgD;AAChD,MAAM,CAAC,MAAM,cAAc,GAAG,oB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@ export type WatcherStatusOptions = {
|
|
|
3
3
|
json?: boolean;
|
|
4
4
|
};
|
|
5
5
|
/** Execute the watcher status command. */
|
|
6
|
-
export declare const runWatcherStatus: (
|
|
6
|
+
export declare const runWatcherStatus: import("../cli/defineWatcherCommand.js").WatcherCommandRunner<[], WatcherStatusOptions>;
|
|
7
7
|
//# sourceMappingURL=watcherStatus.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"watcherStatus.d.ts","sourceRoot":"","sources":["../../src/commands/watcherStatus.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"watcherStatus.d.ts","sourceRoot":"","sources":["../../src/commands/watcherStatus.ts"],"names":[],"mappings":"AAGA,8CAA8C;AAC9C,MAAM,MAAM,oBAAoB,GAAG;IAClC,IAAI,CAAC,EAAE,OAAO,CAAA;CACd,CAAA;AAED,0CAA0C;AAC1C,eAAO,MAAM,gBAAgB,yFAM3B,CAAA"}
|