@flowscripter/example-cli 1.3.6 → 1.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/bun.lock CHANGED
@@ -5,20 +5,24 @@
5
5
  "": {
6
6
  "name": "@flowscripter/example-cli",
7
7
  "dependencies": {
8
- "@flowscripter/dynamic-cli-framework": "latest",
8
+ "@flowscripter/dynamic-cli-framework": "1.7.3",
9
+ "@flowscripter/dynamic-plugin-framework": "1.10.0",
9
10
  },
10
11
  "devDependencies": {
11
- "@types/bun": "latest",
12
- "oxfmt": "latest",
13
- "oxlint": "latest",
12
+ "@types/bun": "^1.3.14",
13
+ "@types/node": "^26.1.0",
14
+ "oxfmt": "0.56.0",
15
+ "oxlint": "1.71.0",
14
16
  },
15
17
  "peerDependencies": {
16
- "typescript": "latest",
18
+ "typescript": "^6.0.3",
17
19
  },
18
20
  },
19
21
  },
20
22
  "packages": {
21
- "@flowscripter/dynamic-cli-framework": ["@flowscripter/dynamic-cli-framework@1.4.19", "", { "dependencies": { "emphasize": "^7.0.0", "fastest-levenshtein": "^1.0.16", "figlet": "^1.11.0", "highlight.js": "^11.11.1", "prettier": "^3.8.4", "supports-color": "^10.2.2", "supports-terminal-graphics": "^0.1.0" }, "peerDependencies": { "typescript": "^6.0.3" } }, "sha512-hUlUAoOKZmIFAKGht/Tgn79mxYqmi4MYucxsu6VFvUi7+5o7d3JGlOm/QNsi2vvpxTf5fKxZaMfGBrw1aFp2cg=="],
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
+
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=="],
22
26
 
23
27
  "@oxfmt/binding-android-arm-eabi": ["@oxfmt/binding-android-arm-eabi@0.56.0", "", { "os": "android", "cpu": "arm" }, "sha512-CSCxi7ovYojgfdPOdUb9T508HKeAdDIKeRGg7x8IZwVJrWz9gVgX7MbUnFqtQAE4QvoNo07mj2JlwnOzJw4qqA=="],
24
28
 
@@ -100,7 +104,7 @@
100
104
 
101
105
  "@types/hast": ["@types/hast@3.0.4", "", { "dependencies": { "@types/unist": "*" } }, "sha512-WPs+bbQw5aCj+x6laNGWLH3wviHtoCv/P3+otBhbOhJgG8qtpdAMlTCxLtsTWA7LH1Oh/bFCHsBn0TPS5m30EQ=="],
102
106
 
103
- "@types/node": ["@types/node@22.13.9", "", { "dependencies": { "undici-types": "~6.20.0" } }, "sha512-acBjXdRJ3A6Pb3tqnw9HZmyR3Fiol3aGxRCK1x3d+6CDAMjl7I649wpSd+yNURCjbOUGu9tqtLKnTGxmK6CyGw=="],
107
+ "@types/node": ["@types/node@26.1.0", "", { "dependencies": { "undici-types": "~8.3.0" } }, "sha512-O0A1G3xPGy4w7AgQdAQYUlQ+BKk2Oovw8eRpofyp5KdBZULnbe+WqaOVNrm705SHphCiG4XHsACrSmPu1f+Kgw=="],
104
108
 
105
109
  "@types/unist": ["@types/unist@3.0.3", "", {}, "sha512-ko/gIFJRv177XgZsZcBwnqJN5x/Gien8qNOn0D5bQU/zAzVf9Zt3BlcUiLqhV9y4ARk0GbT3tnUiPNgnTXzc/Q=="],
106
110
 
@@ -128,7 +132,9 @@
128
132
 
129
133
  "oxlint": ["oxlint@1.71.0", "", { "optionalDependencies": { "@oxlint/binding-android-arm-eabi": "1.71.0", "@oxlint/binding-android-arm64": "1.71.0", "@oxlint/binding-darwin-arm64": "1.71.0", "@oxlint/binding-darwin-x64": "1.71.0", "@oxlint/binding-freebsd-x64": "1.71.0", "@oxlint/binding-linux-arm-gnueabihf": "1.71.0", "@oxlint/binding-linux-arm-musleabihf": "1.71.0", "@oxlint/binding-linux-arm64-gnu": "1.71.0", "@oxlint/binding-linux-arm64-musl": "1.71.0", "@oxlint/binding-linux-ppc64-gnu": "1.71.0", "@oxlint/binding-linux-riscv64-gnu": "1.71.0", "@oxlint/binding-linux-riscv64-musl": "1.71.0", "@oxlint/binding-linux-s390x-gnu": "1.71.0", "@oxlint/binding-linux-x64-gnu": "1.71.0", "@oxlint/binding-linux-x64-musl": "1.71.0", "@oxlint/binding-openharmony-arm64": "1.71.0", "@oxlint/binding-win32-arm64-msvc": "1.71.0", "@oxlint/binding-win32-ia32-msvc": "1.71.0", "@oxlint/binding-win32-x64-msvc": "1.71.0" }, "peerDependencies": { "oxlint-tsgolint": ">=0.22.1", "vite-plus": "*" }, "optionalPeers": ["oxlint-tsgolint", "vite-plus"], "bin": { "oxlint": "bin/oxlint" } }, "sha512-U1m1X+C0vDj7DC1e13IoZULzEcPczE7UOMTs8VlZGHUEIUaSTZKo5qkPsQEfzpgnQ29Pea/w3Xntk62UCecxZw=="],
130
134
 
131
- "prettier": ["prettier@3.8.4", "", { "bin": { "prettier": "bin/prettier.cjs" } }, "sha512-N2MylSdi48+5N/6S5j+maeHbUSIzzZ5uOcX5Hm4QpV8Dkb1HFjfAKTKX6yNPJQD9AhcT3ifHNB66tWTTJDi11Q=="],
135
+ "prettier": ["prettier@3.9.4", "", { "bin": { "prettier": "bin/prettier.cjs" } }, "sha512-yWG/o/4oJfo036EKAfK6ACAoDOfHeRHx4tuxkfBZiauURiaSmYwlpOr5LQqKtIkRD2z1PLteme2WoxEnj4tHTg=="],
136
+
137
+ "semver": ["semver@7.8.5", "", { "bin": { "semver": "bin/semver.js" } }, "sha512-Y7/KDsb8LjooZpwaqGyulO6DQlksgCncchHGk+sZIY4SBvUocMBEFH5Ur1fI4dV+Jvl0w6cjvucaIi40puRioA=="],
132
138
 
133
139
  "supports-color": ["supports-color@10.2.2", "", {}, "sha512-SS+jx45GF1QjgEXQx4NJZV9ImqmO2NPz5FNsIHrsDjh2YsHnawpan7SNQ1o8NuhrbHZy9AZhIoCUiCeaW/C80g=="],
134
140
 
@@ -138,10 +144,16 @@
138
144
 
139
145
  "typescript": ["typescript@6.0.3", "", { "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" } }, "sha512-y2TvuxSZPDyQakkFRPZHKFm+KKVqIisdg9/CZwm9ftvKXLP8NRWj38/ODjNbr43SsoXqNuAisEf1GdCxqWcdBw=="],
140
146
 
141
- "undici-types": ["undici-types@6.20.0", "", {}, "sha512-Ny6QZ2Nju20vw1SRHe3d9jVu6gJ+4e3+MMpqu7pqE5HT6WsTSlce++GQmK5UXS8mzV8DSYHrQH+Xrf2jVcuKNg=="],
147
+ "undici-types": ["undici-types@8.3.0", "", {}, "sha512-j375ScV60dom+YkPFIfTLcOiPxkN/buHz5GobjLhixFuANaNs3C9l4GmrWqejgXWJ7BbJcFYpTEUkS1Ge8bpZQ=="],
148
+
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
+ "bun-types/@types/node": ["@types/node@22.13.9", "", { "dependencies": { "undici-types": "~6.20.0" } }, "sha512-acBjXdRJ3A6Pb3tqnw9HZmyR3Fiol3aGxRCK1x3d+6CDAMjl7I649wpSd+yNURCjbOUGu9tqtLKnTGxmK6CyGw=="],
142
152
 
143
153
  "emphasize/highlight.js": ["highlight.js@11.9.0", "", {}, "sha512-fJ7cW7fQGCYAkgv4CPfwFHrfd/cLS4Hau96JuJ+ZTOWhjnhoeN1ub1tFmALm/+lW5z4WCAuAV9bm05AP0mS6Gw=="],
144
154
 
145
155
  "lowlight/highlight.js": ["highlight.js@11.9.0", "", {}, "sha512-fJ7cW7fQGCYAkgv4CPfwFHrfd/cLS4Hau96JuJ+ZTOWhjnhoeN1ub1tFmALm/+lW5z4WCAuAV9bm05AP0mS6Gw=="],
156
+
157
+ "bun-types/@types/node/undici-types": ["undici-types@6.20.0", "", {}, "sha512-Ny6QZ2Nju20vw1SRHe3d9jVu6gJ+4e3+MMpqu7pqE5HT6WsTSlce++GQmK5UXS8mzV8DSYHrQH+Xrf2jVcuKNg=="],
146
158
  }
147
159
  }
@@ -30,6 +30,10 @@ Feature: Executable
30
30
  And the executable should have output "Chisel Font ASCII Banner Demo"
31
31
  And the executable should have output "ASCII Banner Subtitle Demo"
32
32
 
33
+ Scenario: Image demo
34
+ When the executable is launched with "demo:image"
35
+ Then the executable should complete with exit code 0
36
+
33
37
  Scenario: Completion demo
34
38
  When the executable is launched with "demo:completion"
35
39
  Then the executable should complete with exit code 0
@@ -40,3 +44,12 @@ Feature: Executable
40
44
  Then the executable should complete with exit code 0
41
45
  And the executable should have output "Key-Value Storage"
42
46
  And the executable should have output "Secret Storage"
47
+
48
+ Scenario: Completion stdout contains only completion values without banner
49
+ When bash completions are requested for "example-cli --h" at cursor 15
50
+ Then the stdout should contain "--help"
51
+ And the stdout should not contain "EXAMPLE-CLI"
52
+
53
+ Scenario: No completions after global command with trailing space
54
+ When bash completions are requested for "example-cli --help " at cursor 19
55
+ Then the stdout should be empty
@@ -0,0 +1,39 @@
1
+ Feature: Plugin management
2
+
3
+ Note: These scenarios require @flowscripter/example-cli-plugin to be
4
+ published on npmjs.com and the test machine to have network access.
5
+ The plugin install folder is ~/.example-cli/plugins.
6
+
7
+ Scenario: Search for example-cli-plugin on npmjs
8
+ When the executable is launched with "plugin:search example-cli-plugin"
9
+ Then the executable should complete with exit code 0
10
+ And the executable should have output "example-cli-plugin"
11
+
12
+ Scenario: List plugins when none installed
13
+ When the executable is launched with "plugin:list"
14
+ Then the executable should complete with exit code 0
15
+
16
+ Scenario: Install example-cli-plugin
17
+ When the executable stdout is captured for "--no-prompt plugin:add @flowscripter/example-cli-plugin"
18
+ Then the captured process should complete with exit code 0
19
+ And the stdout should contain "installed"
20
+ And the stderr should contain "Searching for plugin: @flowscripter/example-cli-plugin\n"
21
+ And the stderr should contain "Installing @flowscripter/example-cli-plugin...\n"
22
+
23
+ Scenario: List installed plugins after install
24
+ When the executable is launched with "plugin:list"
25
+ Then the executable should complete with exit code 0
26
+ And the executable should have output "example-cli-plugin"
27
+
28
+ Scenario: Use hello command from installed plugin
29
+ When the executable is launched with "hello"
30
+ Then the executable should complete with exit code 0
31
+ And the executable should have output "Hello"
32
+
33
+ Scenario: Remove example-cli-plugin
34
+ When the executable is launched with "plugin:remove @flowscripter/example-cli-plugin"
35
+ Then the executable should complete with exit code 0
36
+
37
+ Scenario: Plugin no longer listed after removal
38
+ When the executable is launched with "plugin:list"
39
+ Then the executable should complete with exit code 0
@@ -1,4 +1,9 @@
1
+ import os
2
+ import sys
3
+ sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
4
+
1
5
  from behave import when, then
6
+ from support.subprocess_wrapper import SubprocessWrapper
2
7
 
3
8
 
4
9
  @when('the executable is launched')
@@ -21,3 +26,50 @@ def step_impl(context, code):
21
26
  @then('the executable should have output "{message}"')
22
27
  def step_impl(context, message):
23
28
  context.pexpect_wrapper.expect(message)
29
+
30
+
31
+ @when('the executable stdout is captured for "{args}"')
32
+ def step_impl(context, args):
33
+ wrapper = SubprocessWrapper(os.environ.get('EXECUTABLE'))
34
+ wrapper.run(args)
35
+ context.subprocess_wrapper = wrapper
36
+
37
+
38
+ @when('bash completions are requested for "{line}" at cursor {cursor:d}')
39
+ def step_impl(context, line, cursor):
40
+ wrapper = SubprocessWrapper(os.environ.get('EXECUTABLE'))
41
+ wrapper.run('completions:complete bash "{}" {}'.format(line, cursor))
42
+ context.subprocess_wrapper = wrapper
43
+
44
+
45
+ @then('the captured process should complete with exit code {code:d}')
46
+ def step_impl(context, code):
47
+ status = context.subprocess_wrapper.returncode
48
+ assert status == code, 'unexpected exit status: {} (expected {})'.format(status, code)
49
+
50
+
51
+ @then('the stdout should contain "{text}"')
52
+ def step_impl(context, text):
53
+ text = text.replace('\\n', '\n')
54
+ assert text in context.subprocess_wrapper.stdout, \
55
+ 'expected {!r} in stdout {!r}'.format(text, context.subprocess_wrapper.stdout)
56
+
57
+
58
+ @then('the stdout should not contain "{text}"')
59
+ def step_impl(context, text):
60
+ text = text.replace('\\n', '\n')
61
+ assert text not in context.subprocess_wrapper.stdout, \
62
+ 'expected {!r} not in stdout {!r}'.format(text, context.subprocess_wrapper.stdout)
63
+
64
+
65
+ @then('the stderr should contain "{text}"')
66
+ def step_impl(context, text):
67
+ text = text.replace('\\n', '\n')
68
+ assert text in context.subprocess_wrapper.stderr, \
69
+ 'expected {!r} in stderr {!r}'.format(text, context.subprocess_wrapper.stderr)
70
+
71
+
72
+ @then('the stdout should be empty')
73
+ def step_impl(context):
74
+ assert context.subprocess_wrapper.stdout.strip() == '', \
75
+ 'expected empty stdout but got {!r}'.format(context.subprocess_wrapper.stdout)
@@ -0,0 +1,25 @@
1
+ import shlex
2
+ import subprocess
3
+ import logging
4
+
5
+ log = logging.getLogger("subprocess_wrapper")
6
+
7
+
8
+ class SubprocessWrapper:
9
+
10
+ def __init__(self, executable):
11
+ self.executable = executable
12
+ self.stdout = None
13
+ self.stderr = None
14
+ self.returncode = None
15
+
16
+ def run(self, args=''):
17
+ cmd = [self.executable] + (shlex.split(args) if args else [])
18
+ log.debug('running: {}'.format(cmd))
19
+ result = subprocess.run(cmd, capture_output=True, text=True, timeout=30)
20
+ self.stdout = result.stdout
21
+ self.stderr = result.stderr
22
+ self.returncode = result.returncode
23
+ log.debug('stdout: {!r}'.format(self.stdout))
24
+ log.debug('stderr: {!r}'.format(self.stderr))
25
+ log.debug('returncode: {}'.format(self.returncode))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flowscripter/example-cli",
3
- "version": "1.3.6",
3
+ "version": "1.4.1",
4
4
  "description": "Simple example CLI using https://github.com/flowscripter/dynamic-cli-framework",
5
5
  "keywords": [
6
6
  "bun",
@@ -24,10 +24,12 @@
24
24
  "access": "public"
25
25
  },
26
26
  "dependencies": {
27
- "@flowscripter/dynamic-cli-framework": "^1.4.19"
27
+ "@flowscripter/dynamic-cli-framework": "1.7.3",
28
+ "@flowscripter/dynamic-plugin-framework": "1.10.0"
28
29
  },
29
30
  "devDependencies": {
30
31
  "@types/bun": "^1.3.14",
32
+ "@types/node": "^26.1.0",
31
33
  "oxfmt": "0.56.0",
32
34
  "oxlint": "1.71.0"
33
35
  },
@@ -0,0 +1,4 @@
1
+ declare module "*.png" {
2
+ const path: string;
3
+ export default path;
4
+ }
package/src/cli.ts CHANGED
@@ -2,15 +2,35 @@ import {
2
2
  AsciiBannerGeneratorServiceProvider,
3
3
  BannerServiceProvider,
4
4
  DataDumpGeneratorServiceProvider,
5
- launchMultiCommandCLI,
5
+ launchDynamicPluginMultiCommandCLI,
6
6
  SyntaxHighlighterServiceProvider,
7
7
  TreePrinterServiceProvider,
8
8
  } from "@flowscripter/dynamic-cli-framework";
9
+ import {
10
+ NpmPluginManager,
11
+ NpmPluginRepository,
12
+ NpmjsPluginRepository,
13
+ } from "@flowscripter/dynamic-plugin-framework";
9
14
  import demo from "./commands/demo.ts";
10
15
  import packageJson from "../package.json";
16
+ import path from "node:path";
17
+ import os from "node:os";
11
18
 
12
19
  export async function cli(): Promise<void> {
13
- await launchMultiCommandCLI(
20
+ const pluginsDir = path.join(os.homedir(), ".example-cli", "plugins", "node_modules");
21
+ const pluginManager = new NpmPluginManager(
22
+ [
23
+ new NpmjsPluginRepository({
24
+ name: "npmjs",
25
+ registryUrl: "https://registry.npmjs.org",
26
+ packageJsonNamespace: "dynamic-cli-framework",
27
+ }),
28
+ ],
29
+ new NpmPluginRepository(pluginsDir, "dynamic-cli-framework"),
30
+ );
31
+
32
+ await launchDynamicPluginMultiCommandCLI(
33
+ pluginManager,
14
34
  [demo],
15
35
  "Simple example CLI using dynamic-cli-framework.",
16
36
  "example-cli",
@@ -1,3 +1,4 @@
1
+ import process from "node:process";
1
2
  import {
2
3
  type ArgumentValues,
3
4
  COMPLETION_SERVICE_ID,
@@ -18,7 +19,11 @@ const completion: SubCommand = {
18
19
  const printerService = context.getServiceById(PRINTER_SERVICE_ID) as PrinterService;
19
20
  const completionService = context.getServiceById(COMPLETION_SERVICE_ID) as CompletionService;
20
21
 
21
- const bootstrapScript = completionService.getBootstrapScript(ShellType.BASH, "example-cli");
22
+ const bootstrapScript = completionService.getBootstrapScript(
23
+ ShellType.BASH,
24
+ "example-cli",
25
+ process.execPath,
26
+ );
22
27
  await printerService.print(`Bash bootstrap script:\n${bootstrapScript}\n`);
23
28
 
24
29
  const configPath = completionService.getDefaultConfigPath(ShellType.BASH);
@@ -7,8 +7,7 @@ import {
7
7
  type PrinterService,
8
8
  type SubCommand,
9
9
  } from "@flowscripter/dynamic-cli-framework";
10
- import path from "node:path";
11
- import process from "node:process";
10
+ import logoAsset from "../../assets/logo.png" with { type: "file" };
12
11
 
13
12
  const image: SubCommand = {
14
13
  name: "image",
@@ -21,13 +20,7 @@ const image: SubCommand = {
21
20
  IMAGE_PRINTER_SERVICE_ID,
22
21
  ) as ImagePrinterService;
23
22
 
24
- const baseDir = path.dirname(process.execPath);
25
- let imagePath = path.join(baseDir, "assets", "logo.png");
26
- const logoFile = Bun.file(imagePath);
27
- if (!(await logoFile.exists())) {
28
- imagePath = path.join(import.meta.dir, "..", "..", "assets", "logo.png");
29
- }
30
- const imageBuffer = await Bun.file(imagePath).bytes();
23
+ const imageBuffer = await Bun.file(logoAsset).bytes();
31
24
  const imageOutput = await imagePrinterService.image(imageBuffer, 25, "#FFFFFF");
32
25
  await printerService.print(imageOutput + "\n");
33
26
  },
@@ -117,6 +117,10 @@ const printing: SubCommand = {
117
117
  printerService.backgroundColor("Custom Hex Background", "#FF6600") + "\n",
118
118
  );
119
119
 
120
+ // --- Italic ---
121
+ await printerService.print("--- Italic ---\n");
122
+ await printerService.print(printerService.italic("Italic text") + "\n");
123
+
120
124
  // --- Hyperlink ---
121
125
  await printerService.print("--- Hyperlink ---\n");
122
126
  await printerService.print(
package/tsconfig.json CHANGED
@@ -26,5 +26,5 @@
26
26
  "noUnusedParameters": false,
27
27
  "noPropertyAccessFromIndexSignature": false
28
28
  },
29
- "exclude": ["tests"]
29
+ "exclude": ["dist"]
30
30
  }