@flowscripter/example-cli 1.5.0 → 1.7.0

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,9 @@
5
5
  "": {
6
6
  "name": "@flowscripter/example-cli",
7
7
  "dependencies": {
8
- "@flowscripter/dynamic-cli-framework": "1.7.3",
9
- "@flowscripter/dynamic-plugin-framework": "1.10.0",
8
+ "@flowscripter/dynamic-cli-framework": "2.3.3",
9
+ "@flowscripter/dynamic-cli-framework-api": "^1.2.0",
10
+ "@flowscripter/dynamic-plugin-framework": "1.11.1",
10
11
  },
11
12
  "devDependencies": {
12
13
  "@types/bun": "^1.3.14",
@@ -20,9 +21,11 @@
20
21
  },
21
22
  },
22
23
  "packages": {
23
- "@flowscripter/dynamic-cli-framework": ["@flowscripter/dynamic-cli-framework@1.7.3", "", { "dependencies": { "@flowscripter/dynamic-plugin-framework": "1.10.1", "emphasize": "^7.0.0", "fastest-levenshtein": "^1.0.16", "figlet": "^1.11.0", "highlight.js": "^11.11.1", "prettier": "^3.9.4", "supports-color": "^10.2.2", "supports-terminal-graphics": "^0.1.0" }, "peerDependencies": { "typescript": "^6.0.3" } }, "sha512-odf0w9VoghMvFLO3TKVUYUB8FFVfPVF1MH3a38S91cs/vhve6/d57+Lf8iWaCNSCqUswnxGtdTbUMa7OXvz03A=="],
24
+ "@flowscripter/dynamic-cli-framework": ["@flowscripter/dynamic-cli-framework@2.3.3", "", { "dependencies": { "@flowscripter/dynamic-cli-framework-api": "^1.2.0", "@flowscripter/dynamic-plugin-framework": "1.11.1", "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-neY8YtiBHMU8IkBU1k5i1wECbDrDG4J1eyLbTi4RZwEIqzDl285/QLbXbEuNAnHiLZTphN/2YEDaEJxQ94mqnA=="],
24
25
 
25
- "@flowscripter/dynamic-plugin-framework": ["@flowscripter/dynamic-plugin-framework@1.10.0", "", { "dependencies": { "semver": "^7.8.5" }, "peerDependencies": { "typescript": "^6.0.3" } }, "sha512-WC0PKxQsk4KJSP/fstL2+Po5/2OB1hSgwM3HGLGwoHyH5qV7pNF/aZct6mDnLIi0aECVWM1sm7LXg75cb9FWLQ=="],
26
+ "@flowscripter/dynamic-cli-framework-api": ["@flowscripter/dynamic-cli-framework-api@1.2.0", "", { "peerDependencies": { "typescript": "^7.0.2" } }, "sha512-ajR6PwQQwsQN96OH3OwO0SH5h3TGY3lLPM5lIYNUCpUXrOZ9MYJtsXvDcDKz8U/heWe0FBJeRY0nsNDJV4p9Vw=="],
27
+
28
+ "@flowscripter/dynamic-plugin-framework": ["@flowscripter/dynamic-plugin-framework@1.11.1", "", { "dependencies": { "semver": "^7.8.5" }, "peerDependencies": { "typescript": "^7.0.2" } }, "sha512-m8bioReoQzzm7uj3sxXLH7Haclyj1UWnPCSxy2QXvGQ2yp24H1GnzqohVnXo3JfBpJzmCUAaHT+lAhYu9Gh6Aw=="],
26
29
 
27
30
  "@oxfmt/binding-android-arm-eabi": ["@oxfmt/binding-android-arm-eabi@0.56.0", "", { "os": "android", "cpu": "arm" }, "sha512-CSCxi7ovYojgfdPOdUb9T508HKeAdDIKeRGg7x8IZwVJrWz9gVgX7MbUnFqtQAE4QvoNo07mj2JlwnOzJw4qqA=="],
28
31
 
@@ -146,8 +149,6 @@
146
149
 
147
150
  "undici-types": ["undici-types@8.3.0", "", {}, "sha512-j375ScV60dom+YkPFIfTLcOiPxkN/buHz5GobjLhixFuANaNs3C9l4GmrWqejgXWJ7BbJcFYpTEUkS1Ge8bpZQ=="],
148
151
 
149
- "@flowscripter/dynamic-cli-framework/@flowscripter/dynamic-plugin-framework": ["@flowscripter/dynamic-plugin-framework@1.10.1", "", { "dependencies": { "semver": "^7.8.5" }, "peerDependencies": { "typescript": "^6.0.3" } }, "sha512-9yUz64tj1R2RRuUAtHEqJf4hZYF4cIbUGHOOM32q4jDsdd4g5BQKa1gPhh7UPqHggs890XJxgE6R12opKKudAA=="],
150
-
151
152
  "bun-types/@types/node": ["@types/node@22.13.9", "", { "dependencies": { "undici-types": "~6.20.0" } }, "sha512-acBjXdRJ3A6Pb3tqnw9HZmyR3Fiol3aGxRCK1x3d+6CDAMjl7I649wpSd+yNURCjbOUGu9tqtLKnTGxmK6CyGw=="],
152
153
 
153
154
  "emphasize/highlight.js": ["highlight.js@11.9.0", "", {}, "sha512-fJ7cW7fQGCYAkgv4CPfwFHrfd/cLS4Hau96JuJ+ZTOWhjnhoeN1ub1tFmALm/+lW5z4WCAuAV9bm05AP0mS6Gw=="],
@@ -1,9 +1,17 @@
1
1
  import os
2
+ import platform
2
3
 
3
4
  from support.pexpect_wrapper import PExpectWrapper
4
5
 
6
+ IS_WINDOWS = platform.system() == 'Windows'
7
+
5
8
 
6
9
  def before_scenario(context, scenario):
7
10
 
11
+ if IS_WINDOWS and 'requires_tty' in scenario.effective_tags:
12
+ scenario.skip('pexpect on Windows uses PopenSpawn (pipes), which cannot provide '
13
+ 'the real TTY this scenario depends on')
14
+ return
15
+
8
16
  context.config.setup_logging()
9
17
  context.pexpect_wrapper = PExpectWrapper(os.environ.get('EXECUTABLE'))
@@ -1,5 +1,6 @@
1
1
  Feature: Executable
2
2
 
3
+ @requires_tty
3
4
  Scenario: No command specified
4
5
  When the executable is launched
5
6
  Then the executable should complete with exit code 2
@@ -30,6 +31,7 @@ Feature: Executable
30
31
  And the executable should have output "Chisel Font ASCII Banner Demo"
31
32
  And the executable should have output "ASCII Banner Subtitle Demo"
32
33
 
34
+ @requires_tty
33
35
  Scenario: Image demo
34
36
  When the executable is launched with "demo:image"
35
37
  Then the executable should complete with exit code 0
@@ -0,0 +1,18 @@
1
+ Feature: Non-TTY (piped/non-interactive) mode
2
+
3
+ Scenario: Printing demo runs non-interactively without ANSI escape codes
4
+ When the executable stdout is captured for "demo:printing"
5
+ Then the captured process should complete with exit code 0
6
+ And the stdout should contain "Hello, World!"
7
+ And the stdout should not contain ANSI escape codes
8
+ And the stderr should not contain ANSI escape codes
9
+
10
+ Scenario: Printing demo runs non-interactively with piped stdin
11
+ When the executable stdout is captured for "demo:printing" with piped stdin
12
+ Then the captured process should complete with exit code 0
13
+ And the stdout should contain "Hello, World!"
14
+
15
+ Scenario: Prompting demo fails cleanly instead of hanging when run non-interactively
16
+ When the executable stdout is captured for "demo:prompting Alice"
17
+ Then the captured process should complete with exit code 3
18
+ And the stderr should contain "Execution error"
@@ -14,17 +14,24 @@ Feature: Plugin management
14
14
  Then the executable should complete with exit code 0
15
15
 
16
16
  Scenario: Install example-cli-plugin
17
- When the executable stdout is captured for "--no-prompt plugin:add @flowscripter/example-cli-plugin"
17
+ When the executable stdout is captured for "--no-prompt plugin:add @flowscripter/example-cli-plugin" with timeout 60s
18
18
  Then the captured process should complete with exit code 0
19
19
  And the stdout should contain "installed"
20
20
  And the stderr should contain "Searching for plugin: @flowscripter/example-cli-plugin\n"
21
21
  And the stderr should contain "Installing @flowscripter/example-cli-plugin...\n"
22
22
 
23
+ Scenario: Installing example-cli-plugin does not pull in the full dynamic-cli-framework
24
+ Then the installed plugin dependencies should not include "figlet, emphasize, highlight.js, prettier, supports-color, supports-terminal-graphics"
25
+
23
26
  Scenario: List installed plugins after install
24
27
  When the executable is launched with "plugin:list"
25
28
  Then the executable should complete with exit code 0
26
29
  And the executable should have output "example-cli-plugin"
27
30
 
31
+ Scenario: Plugin dependencies are installed
32
+ Then the plugin node_modules directory should contain "cowsay"
33
+ And the plugin node_modules directory should contain "@flowscripter/dynamic-cli-framework-api"
34
+
28
35
  Scenario: Use hello command from installed plugin
29
36
  When the executable is launched with "hello"
30
37
  Then the executable should complete with exit code 0
@@ -42,3 +49,9 @@ Feature: Plugin management
42
49
  Scenario: Plugin no longer listed after removal
43
50
  When the executable is launched with "plugin:list"
44
51
  Then the executable should complete with exit code 0
52
+
53
+ Scenario: No orphaned transitive dependencies remain after removal
54
+ Then the plugin node_modules directory should not contain "@flowscripter/example-cli-plugin"
55
+ And the plugin node_modules directory should not contain "cowsay"
56
+ And the plugin node_modules directory should not contain "@flowscripter/template-bun-rust-library"
57
+ And the plugin node_modules directory should not contain "@flowscripter/dynamic-cli-framework"
@@ -35,10 +35,24 @@ def step_impl(context, args):
35
35
  context.subprocess_wrapper = wrapper
36
36
 
37
37
 
38
+ @when('the executable stdout is captured for "{args}" with timeout {timeout:d}s')
39
+ def step_impl(context, args, timeout):
40
+ wrapper = SubprocessWrapper(os.environ.get('EXECUTABLE'))
41
+ wrapper.run(args, timeout=timeout)
42
+ context.subprocess_wrapper = wrapper
43
+
44
+
45
+ @when('the executable stdout is captured for "{args}" with piped stdin')
46
+ def step_impl(context, args):
47
+ wrapper = SubprocessWrapper(os.environ.get('EXECUTABLE'))
48
+ wrapper.run(args, stdin_text='')
49
+ context.subprocess_wrapper = wrapper
50
+
51
+
38
52
  @when('bash completions are requested for "{line}" at cursor {cursor:d}')
39
53
  def step_impl(context, line, cursor):
40
54
  wrapper = SubprocessWrapper(os.environ.get('EXECUTABLE'))
41
- wrapper.run('completions:complete bash "{}" {}'.format(line, cursor))
55
+ wrapper.run('completion:complete bash "{}" {}'.format(line, cursor))
42
56
  context.subprocess_wrapper = wrapper
43
57
 
44
58
 
@@ -73,3 +87,31 @@ def step_impl(context, text):
73
87
  def step_impl(context):
74
88
  assert context.subprocess_wrapper.stdout.strip() == '', \
75
89
  'expected empty stdout but got {!r}'.format(context.subprocess_wrapper.stdout)
90
+
91
+
92
+ @then('the stdout should not contain ANSI escape codes')
93
+ def step_impl(context):
94
+ assert '\x1b[' not in context.subprocess_wrapper.stdout, \
95
+ 'expected no ANSI escape codes in stdout but got {!r}'.format(
96
+ context.subprocess_wrapper.stdout)
97
+
98
+
99
+ @then('the stderr should not contain ANSI escape codes')
100
+ def step_impl(context):
101
+ assert '\x1b[' not in context.subprocess_wrapper.stderr, \
102
+ 'expected no ANSI escape codes in stderr but got {!r}'.format(
103
+ context.subprocess_wrapper.stderr)
104
+
105
+
106
+ @then('the installed plugin dependencies should not include "{packages}"')
107
+ def step_impl(context, packages):
108
+ plugins_node_modules = os.path.expanduser('~/.example-cli/plugins/node_modules')
109
+ found = []
110
+ for package in packages.split(','):
111
+ package = package.strip()
112
+ for root, dirs, _ in os.walk(plugins_node_modules):
113
+ if package in dirs:
114
+ found.append(os.path.join(root, package))
115
+ assert not found, \
116
+ 'expected none of the heavy framework dependencies to be installed alongside ' \
117
+ 'the plugin, but found: {!r}'.format(found)
@@ -0,0 +1,21 @@
1
+ import os
2
+
3
+ from behave import then
4
+
5
+ PLUGINS_NODE_MODULES = os.path.expanduser(
6
+ os.path.join('~', '.example-cli', 'plugins', 'node_modules')
7
+ )
8
+
9
+
10
+ @then('the plugin node_modules directory should contain "{name}"')
11
+ def step_impl(context, name):
12
+ path = os.path.join(PLUGINS_NODE_MODULES, name)
13
+ assert os.path.exists(path), \
14
+ 'expected {!r} to exist under {!r}'.format(name, PLUGINS_NODE_MODULES)
15
+
16
+
17
+ @then('the plugin node_modules directory should not contain "{name}"')
18
+ def step_impl(context, name):
19
+ path = os.path.join(PLUGINS_NODE_MODULES, name)
20
+ assert not os.path.exists(path), \
21
+ 'expected {!r} not to exist under {!r}'.format(name, PLUGINS_NODE_MODULES)
@@ -13,10 +13,13 @@ class SubprocessWrapper:
13
13
  self.stderr = None
14
14
  self.returncode = None
15
15
 
16
- def run(self, args=''):
16
+ def run(self, args='', stdin_text=None, timeout=30):
17
17
  cmd = [self.executable] + (shlex.split(args) if args else [])
18
18
  log.debug('running: {}'.format(cmd))
19
- result = subprocess.run(cmd, capture_output=True, text=True, timeout=30)
19
+ result = subprocess.run(
20
+ cmd, capture_output=True, text=True, timeout=timeout, input=stdin_text,
21
+ encoding='utf-8', errors='replace'
22
+ )
20
23
  self.stdout = result.stdout
21
24
  self.stderr = result.stderr
22
25
  self.returncode = result.returncode
@@ -0,0 +1,6 @@
1
+ Feature: Upgrade
2
+
3
+ Scenario: Running upgrade reports already up to date
4
+ When the executable is launched with "upgrade"
5
+ Then the executable should complete with exit code 0
6
+ And the executable should have output "example-cli is already up to date"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flowscripter/example-cli",
3
- "version": "1.5.0",
3
+ "version": "1.7.0",
4
4
  "description": "Simple example CLI using https://github.com/flowscripter/dynamic-cli-framework",
5
5
  "keywords": [
6
6
  "bun",
@@ -24,8 +24,9 @@
24
24
  "access": "public"
25
25
  },
26
26
  "dependencies": {
27
- "@flowscripter/dynamic-cli-framework": "1.7.3",
28
- "@flowscripter/dynamic-plugin-framework": "1.10.0"
27
+ "@flowscripter/dynamic-cli-framework": "2.3.3",
28
+ "@flowscripter/dynamic-cli-framework-api": "^1.2.0",
29
+ "@flowscripter/dynamic-plugin-framework": "1.11.1"
29
30
  },
30
31
  "devDependencies": {
31
32
  "@types/bun": "^1.3.14",
package/src/cli.ts CHANGED
@@ -6,6 +6,7 @@ import {
6
6
  SyntaxHighlighterServiceProvider,
7
7
  TreePrinterServiceProvider,
8
8
  } from "@flowscripter/dynamic-cli-framework";
9
+ import { SupportedArch, SupportedOs } from "@flowscripter/dynamic-cli-framework-api";
9
10
  import {
10
11
  NpmPluginManager,
11
12
  NpmPluginRepository,
@@ -49,6 +50,33 @@ export async function cli(): Promise<void> {
49
50
  argumentPrompterServiceEnabled: true,
50
51
  completionServiceEnabled: true,
51
52
  imagePrinterServiceEnabled: true,
53
+ spawnServiceEnabled: true,
54
+ upgradeServiceEnabled: true,
55
+ upgradeLocationsConfig: {
56
+ supportedPlatforms: [
57
+ { os: SupportedOs.LINUX, arch: SupportedArch.X64 },
58
+ { os: SupportedOs.LINUX, arch: SupportedArch.ARM64 },
59
+ { os: SupportedOs.MACOS, arch: SupportedArch.X64 },
60
+ { os: SupportedOs.MACOS, arch: SupportedArch.ARM64 },
61
+ { os: SupportedOs.WINDOWS, arch: SupportedArch.X64 },
62
+ ],
63
+ githubRelease: {
64
+ owner: "flowscripter",
65
+ repo: "example-cli",
66
+ assetPattern: "example-cli_{os}_{arch}.zip",
67
+ },
68
+ linuxScript: {
69
+ scriptUrl:
70
+ "https://raw.githubusercontent.com/flowscripter/example-cli/main/script/install.sh",
71
+ },
72
+ homebrew: {
73
+ tap: "flowscripter/tap",
74
+ formula: "example-cli",
75
+ },
76
+ winget: {
77
+ packageId: "Flowscripter.example-cli",
78
+ },
79
+ },
52
80
  },
53
81
  );
54
82
  }