@flowscripter/example-cli 1.8.8 → 1.8.9
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/bun.lock
CHANGED
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
"": {
|
|
6
6
|
"name": "@flowscripter/example-cli",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@flowscripter/dynamic-cli-framework": "5.3.
|
|
9
|
-
"@flowscripter/dynamic-cli-framework-api": "^2.3.
|
|
8
|
+
"@flowscripter/dynamic-cli-framework": "5.3.3",
|
|
9
|
+
"@flowscripter/dynamic-cli-framework-api": "^2.3.2",
|
|
10
10
|
"@flowscripter/dynamic-plugin-framework": "2.2.3",
|
|
11
11
|
},
|
|
12
12
|
"devDependencies": {
|
|
@@ -21,9 +21,9 @@
|
|
|
21
21
|
},
|
|
22
22
|
},
|
|
23
23
|
"packages": {
|
|
24
|
-
"@flowscripter/dynamic-cli-framework": ["@flowscripter/dynamic-cli-framework@5.3.
|
|
24
|
+
"@flowscripter/dynamic-cli-framework": ["@flowscripter/dynamic-cli-framework@5.3.3", "", { "dependencies": { "@flowscripter/dynamic-cli-framework-api": "^2.3.0", "@flowscripter/dynamic-plugin-framework": "^2.2.3", "emphasize": "^7.0.0", "fastest-levenshtein": "^1.0.16", "figlet": "^1.11.0", "highlight.js": "^11.11.1", "prettier": "^3.9.4", "semver": "^7.7.3", "supports-color": "^10.2.2", "supports-terminal-graphics": "^0.1.0" }, "peerDependencies": { "typescript": "^6.0.3" } }, "sha512-f7tcXpg4I6V7Y65+nyQ3MriwgMDCsVs/UQuIcsgmqK2rvBp5BQ/aDyDX3sid197ubB7HERjvtUSyEOYFR28Zgw=="],
|
|
25
25
|
|
|
26
|
-
"@flowscripter/dynamic-cli-framework-api": ["@flowscripter/dynamic-cli-framework-api@2.3.
|
|
26
|
+
"@flowscripter/dynamic-cli-framework-api": ["@flowscripter/dynamic-cli-framework-api@2.3.2", "", { "peerDependencies": { "typescript": "^7.0.2" } }, "sha512-N6icoIP5WBRt2EUF+PLWZr5iXAbAxa6QGkfBZNbxjJ5Z13+vUyTaTF6jEKGNv/9ekwTTmo0eBvOCqTNtFBi7zw=="],
|
|
27
27
|
|
|
28
28
|
"@flowscripter/dynamic-plugin-framework": ["@flowscripter/dynamic-plugin-framework@2.2.3", "", { "dependencies": { "semver": "^7.8.5" }, "peerDependencies": { "typescript": "^7.0.2" } }, "sha512-vLoGC2LktUVPWqA66CwSzZtjh09zSR2HTuLa8OMGDumePkgZD0UTE9D2jWsd3bFdqcy14eQf3IYRdDM47+wRKg=="],
|
|
29
29
|
|
|
@@ -1,27 +1,68 @@
|
|
|
1
1
|
import platform
|
|
2
2
|
import shlex
|
|
3
3
|
import subprocess
|
|
4
|
+
import threading
|
|
5
|
+
import time
|
|
4
6
|
import logging
|
|
5
7
|
|
|
6
8
|
log = logging.getLogger("subprocess_wrapper")
|
|
7
9
|
|
|
8
10
|
|
|
9
|
-
def
|
|
10
|
-
# TEMPORARY: diagnosing an intermittent Windows-only hang in `plugin:add`.
|
|
11
|
-
#
|
|
12
|
-
#
|
|
11
|
+
def _process_snapshot():
|
|
12
|
+
# TEMPORARY: diagnosing an intermittent Windows-only hang in `plugin:add`. `tasklist` alone
|
|
13
|
+
# doesn't show parent/child relationships or full command lines, so a renamed or wrapped
|
|
14
|
+
# process (e.g. a `cmd.exe /c bun.exe ...` shell hop) can't be distinguished from a process
|
|
15
|
+
# that never launched at all. Use PowerShell's Get-CimInstance for that detail on Windows.
|
|
13
16
|
try:
|
|
14
17
|
if platform.system() == 'Windows':
|
|
18
|
+
ps_cmd = (
|
|
19
|
+
"Get-CimInstance Win32_Process | "
|
|
20
|
+
"Select-Object ProcessId,ParentProcessId,Name,CommandLine | "
|
|
21
|
+
"Format-Table -AutoSize -Wrap | Out-String -Width 300"
|
|
22
|
+
)
|
|
15
23
|
out = subprocess.run(
|
|
16
|
-
['
|
|
24
|
+
['powershell', '-NoProfile', '-Command', ps_cmd],
|
|
25
|
+
capture_output=True, text=True, timeout=10
|
|
17
26
|
).stdout
|
|
18
27
|
else:
|
|
19
28
|
out = subprocess.run(
|
|
20
29
|
['ps', '-ef'], capture_output=True, text=True, timeout=10
|
|
21
30
|
).stdout
|
|
22
|
-
|
|
31
|
+
return out
|
|
23
32
|
except Exception as e:
|
|
24
|
-
|
|
33
|
+
return 'failed to snapshot process list: {}'.format(e)
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
class _ProcessTreeMonitor:
|
|
37
|
+
# TEMPORARY: diagnosing an intermittent Windows-only hang in `plugin:add`. Polls the process
|
|
38
|
+
# tree every few seconds while a subprocess is running (rather than only once at timeout) so
|
|
39
|
+
# we can see whether the child process ever appears, and if so, whether it appears and then
|
|
40
|
+
# disappears before the outer timeout fires. Remove once root-caused.
|
|
41
|
+
def __init__(self, interval_seconds=5):
|
|
42
|
+
self.interval_seconds = interval_seconds
|
|
43
|
+
self._stop_event = threading.Event()
|
|
44
|
+
self._thread = None
|
|
45
|
+
self._start_time = None
|
|
46
|
+
|
|
47
|
+
def _run(self):
|
|
48
|
+
while not self._stop_event.wait(self.interval_seconds):
|
|
49
|
+
elapsed = time.monotonic() - self._start_time
|
|
50
|
+
snapshot = _process_snapshot()
|
|
51
|
+
print(
|
|
52
|
+
'DEBUG: process snapshot at +{:.1f}s:\n{}'.format(elapsed, snapshot),
|
|
53
|
+
flush=True,
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
def __enter__(self):
|
|
57
|
+
self._start_time = time.monotonic()
|
|
58
|
+
self._thread = threading.Thread(target=self._run, daemon=True)
|
|
59
|
+
self._thread.start()
|
|
60
|
+
return self
|
|
61
|
+
|
|
62
|
+
def __exit__(self, exc_type, exc_value, traceback):
|
|
63
|
+
self._stop_event.set()
|
|
64
|
+
if self._thread is not None:
|
|
65
|
+
self._thread.join(timeout=self.interval_seconds + 5)
|
|
25
66
|
|
|
26
67
|
|
|
27
68
|
class SubprocessWrapper:
|
|
@@ -39,15 +80,19 @@ class SubprocessWrapper:
|
|
|
39
80
|
# hang in `plugin:add`. Remove once root-caused.
|
|
40
81
|
print('DEBUG: running: {}'.format(cmd), flush=True)
|
|
41
82
|
try:
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
83
|
+
with _ProcessTreeMonitor(interval_seconds=5):
|
|
84
|
+
result = subprocess.run(
|
|
85
|
+
cmd, capture_output=True, text=True, timeout=timeout, input=stdin_text,
|
|
86
|
+
encoding='utf-8', errors='replace'
|
|
87
|
+
)
|
|
46
88
|
except subprocess.TimeoutExpired as e:
|
|
47
89
|
print('DEBUG: TIMED OUT after {}s'.format(timeout), flush=True)
|
|
48
90
|
print('DEBUG: partial stdout: {!r}'.format(e.stdout), flush=True)
|
|
49
91
|
print('DEBUG: partial stderr: {!r}'.format(e.stderr), flush=True)
|
|
50
|
-
|
|
92
|
+
print(
|
|
93
|
+
'DEBUG: final process snapshot at timeout:\n{}'.format(_process_snapshot()),
|
|
94
|
+
flush=True,
|
|
95
|
+
)
|
|
51
96
|
raise
|
|
52
97
|
self.stdout = result.stdout
|
|
53
98
|
self.stderr = result.stderr
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flowscripter/example-cli",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.9",
|
|
4
4
|
"description": "Simple example CLI using https://github.com/flowscripter/dynamic-cli-framework",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"bun",
|
|
@@ -24,8 +24,8 @@
|
|
|
24
24
|
"access": "public"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@flowscripter/dynamic-cli-framework": "5.3.
|
|
28
|
-
"@flowscripter/dynamic-cli-framework-api": "^2.3.
|
|
27
|
+
"@flowscripter/dynamic-cli-framework": "5.3.3",
|
|
28
|
+
"@flowscripter/dynamic-cli-framework-api": "^2.3.2",
|
|
29
29
|
"@flowscripter/dynamic-plugin-framework": "2.2.3"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|