@flowscripter/flowscripter-io-cli 3.0.3 → 3.0.5

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
@@ -7,8 +7,8 @@
7
7
  "dependencies": {
8
8
  "@flowscripter/dynamic-cli-framework": "^9.1.3",
9
9
  "@flowscripter/dynamic-cli-framework-api": "^5.0.2",
10
- "@flowscripter/dynamic-plugin-framework": "^2.2.22",
11
- "@flowscripter/flowscripter-io-cli-hash-native": "^1.0.16",
10
+ "@flowscripter/dynamic-plugin-framework": "^2.2.25",
11
+ "@flowscripter/flowscripter-io-cli-hash-native": "^1.0.18",
12
12
  "@flowscripter/pluggable-io-framework": "^2.1.2",
13
13
  "@flowscripter/pluggable-io-framework-api": "^3.1.3",
14
14
  "zod": "^4.6.7",
@@ -30,9 +30,9 @@
30
30
 
31
31
  "@flowscripter/dynamic-cli-framework-api": ["@flowscripter/dynamic-cli-framework-api@5.0.2", "", { "peerDependencies": { "typescript": "^7.0.2" } }, "sha512-e5eUP/6S9KTY6Va0mhe/UmIrt0W9k5KDnugvhiQxlGbqcGnzuwjhHvmXdeYSjHTaUSxcj8YTWvDIsj7m2P1c1w=="],
32
32
 
33
- "@flowscripter/dynamic-plugin-framework": ["@flowscripter/dynamic-plugin-framework@2.2.22", "", { "dependencies": { "semver": "^7.8.5" }, "peerDependencies": { "typescript": "^7.0.2" } }, "sha512-OOWux0t4ttGuiGMRS6hbc1B6NkFQLAha1DZjhSOtoF7CzHEZneUvix4FDnpzlRp8GPCy/sOaCpqMJTeQEHSpVA=="],
33
+ "@flowscripter/dynamic-plugin-framework": ["@flowscripter/dynamic-plugin-framework@2.2.25", "", { "dependencies": { "semver": "^7.8.5" }, "peerDependencies": { "typescript": "^7.0.2" } }, "sha512-12bvEep1XsbTS2kFwhd5veLUFU6pQxgKqOT4x8K8j/aS/uBzGMoeLgiHh+9kp8BpfJmwnPLQrFPj7/ffdPxZPw=="],
34
34
 
35
- "@flowscripter/flowscripter-io-cli-hash-native": ["@flowscripter/flowscripter-io-cli-hash-native@1.0.16", "", { "peerDependencies": { "typescript": "^7.0.2" } }, "sha512-xv+OXu2rsh8OxVe3YsqwtNOUEu+fHvGNMJlPRQEGJ1cyVDdIG7QlNFj6brkglMNmHJIZKBOpmPyNXikUFo5PhQ=="],
35
+ "@flowscripter/flowscripter-io-cli-hash-native": ["@flowscripter/flowscripter-io-cli-hash-native@1.0.18", "", { "peerDependencies": { "typescript": "^7.0.2" } }, "sha512-r726UVFwuyawFoRvCEl+zcdnZKhxydw0eUVk4yYSZXjTtc/evVj3LvP0PSQits3aHbcj4k/UD0sH1MliMoWyyw=="],
36
36
 
37
37
  "@flowscripter/io-plugin-filesystem": ["@flowscripter/io-plugin-filesystem@2.0.3", "", { "dependencies": { "@flowscripter/pluggable-io-framework-api": "^3.1.2", "zod": "^4.6.6" }, "peerDependencies": { "@flowscripter/dynamic-plugin-framework": "*", "typescript": "^7.0.2" } }, "sha512-RYYXfy3t7Nt0w3b+BmxIn1CdsyMh6z/3BoCTFLqkhMSe+3tcQs+jLnZp1f456FQKR3hq5dS4MxAalaepfdy4fg=="],
38
38
 
@@ -17,10 +17,12 @@ Run the functional tests:
17
17
  export EXECUTABLE=./executable
18
18
  behave
19
19
 
20
- `before_all` installs `@flowscripter/io-plugin-filesystem` via
21
- `plugin:add` into a fresh `~/.flowscripter-io-cli` plugin store before any
22
- scenario runs - these tests require network access to the real npm
23
- registry.
20
+ `before_all` installs `@flowscripter/io-plugin-filesystem` and
21
+ `@flowscripter/io-plugin-s3` via `plugin:add` into a fresh
22
+ `~/.flowscripter-io-cli` plugin store before any scenario runs - these tests
23
+ require network access to the real npm registry. It also starts a local moto
24
+ S3 server on a free port (stopped in `after_all`) which the `s3.feature`
25
+ scenarios use with static test credentials.
24
26
 
25
27
  To run with logging output from the test steps:
26
28
 
@@ -1,7 +1,12 @@
1
1
  import os
2
2
  import shutil
3
+ import socket
3
4
  import subprocess
4
5
  import sys
6
+ import time
7
+
8
+
9
+ import boto3
5
10
 
6
11
  IS_WINDOWS = sys.platform.startswith('win')
7
12
 
@@ -26,17 +31,59 @@ def before_all(context):
26
31
  if os.path.isdir(plugins_dir):
27
32
  shutil.rmtree(plugins_dir)
28
33
 
29
- result = subprocess.run(
30
- [executable, 'plugin:add', '@flowscripter/io-plugin-filesystem'],
31
- capture_output=True, text=True, timeout=120,
34
+ for plugin in ['@flowscripter/io-plugin-filesystem', '@flowscripter/io-plugin-s3']:
35
+ result = subprocess.run(
36
+ [executable, 'plugin:add', plugin],
37
+ capture_output=True, text=True, timeout=120,
38
+ )
39
+ assert result.returncode == 0, \
40
+ 'failed to install {}: stdout={!r} stderr={!r}'.format(
41
+ plugin, result.stdout, result.stderr)
42
+
43
+ start_s3_server(context)
44
+
45
+
46
+ def after_all(context):
47
+ server = getattr(context, 's3_server', None)
48
+ if server:
49
+ server.terminate()
50
+ try:
51
+ server.wait(timeout=10)
52
+ except subprocess.TimeoutExpired:
53
+ server.kill()
54
+
55
+
56
+ def start_s3_server(context):
57
+ with socket.socket() as s:
58
+ s.bind(('127.0.0.1', 0))
59
+ port = s.getsockname()[1]
60
+
61
+ context.s3_server = subprocess.Popen(
62
+ [sys.executable, '-m', 'moto.server', '--host', '127.0.0.1', '--port', str(port)],
63
+ stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL,
64
+ )
65
+ context.s3_endpoint = 'http://127.0.0.1:{}'.format(port)
66
+
67
+ deadline = time.time() + 60
68
+ while time.time() < deadline:
69
+ assert context.s3_server.poll() is None, 'moto server exited early'
70
+ try:
71
+ socket.create_connection(('127.0.0.1', port), timeout=1).close()
72
+ break
73
+ except OSError:
74
+ time.sleep(0.2)
75
+ else:
76
+ raise AssertionError('moto server did not start listening on port {}'.format(port))
77
+
78
+ context.s3_client = boto3.client(
79
+ 's3', endpoint_url=context.s3_endpoint, region_name='us-east-1',
80
+ aws_access_key_id='test', aws_secret_access_key='test',
32
81
  )
33
- assert result.returncode == 0, \
34
- 'failed to install io-plugin-filesystem: stdout={!r} stderr={!r}'.format(
35
- result.stdout, result.stderr)
36
82
 
37
83
 
38
84
  def before_scenario(context, scenario):
39
85
  context.workdir = None
86
+ context.s3_bucket = None
40
87
 
41
88
 
42
89
  def after_scenario(context, scenario):
@@ -0,0 +1,53 @@
1
+ Feature: S3 IO commands
2
+
3
+ Note: these scenarios use the real @flowscripter/io-plugin-s3 from npm
4
+ (installed by before_all) against a local moto S3 server started by
5
+ before_all.
6
+
7
+ Background:
8
+ Given an empty S3 bucket
9
+
10
+ Scenario: list shows an object that was written
11
+ Given an S3 object "data/a.txt" containing "hello"
12
+ When the executable stdout is captured for "list --location.protocol=s3 --location.s3.bucket={bucket} --location.s3.endpoint={endpoint} --location.s3.region=us-east-1 --location.s3.accessKeyId=test --location.s3.secretAccessKey=test --location.s3.path=data"
13
+ Then the captured process should complete with exit code 0
14
+ And the stdout should contain "a.txt"
15
+
16
+ Scenario: get-properties reports size
17
+ Given an S3 object "data/a.txt" containing "hello"
18
+ When the executable stdout is captured for "get-properties --location.protocol=s3 --location.s3.bucket={bucket} --location.s3.endpoint={endpoint} --location.s3.region=us-east-1 --location.s3.accessKeyId=test --location.s3.secretAccessKey=test --location.s3.path=data --location.s3.filename=a.txt"
19
+ Then the captured process should complete with exit code 0
20
+ And the stdout should contain '"size": 5'
21
+
22
+ Scenario: copy duplicates an object, leaving the original in place
23
+ Given an S3 object "data/a.txt" containing "hello"
24
+ When the executable stdout is captured for "copy --source.protocol=s3 --source.s3.bucket={bucket} --source.s3.endpoint={endpoint} --source.s3.region=us-east-1 --source.s3.accessKeyId=test --source.s3.secretAccessKey=test --source.s3.path=data --source.s3.filename=a.txt --dest.protocol=s3 --dest.s3.bucket={bucket} --dest.s3.endpoint={endpoint} --dest.s3.region=us-east-1 --dest.s3.accessKeyId=test --dest.s3.secretAccessKey=test --dest.s3.path=data --dest.s3.filename=b.txt"
25
+ Then the captured process should complete with exit code 0
26
+ And the S3 object "data/b.txt" should contain "hello"
27
+ And the S3 object "data/a.txt" should contain "hello"
28
+
29
+ Scenario: copy uploads a local file to S3
30
+ Given a temporary working directory
31
+ And a file "a.txt" containing "hello" in the working directory
32
+ When the executable stdout is captured for "copy --source.protocol=file --source.file.path={workdir} --source.file.filename=a.txt --dest.protocol=s3 --dest.s3.bucket={bucket} --dest.s3.endpoint={endpoint} --dest.s3.region=us-east-1 --dest.s3.accessKeyId=test --dest.s3.secretAccessKey=test --dest.s3.path=up --dest.s3.filename=a.txt"
33
+ Then the captured process should complete with exit code 0
34
+ And the S3 object "up/a.txt" should contain "hello"
35
+
36
+ Scenario: copy downloads an object to a local file
37
+ Given a temporary working directory
38
+ And an S3 object "data/a.txt" containing "hello"
39
+ When the executable stdout is captured for "copy --source.protocol=s3 --source.s3.bucket={bucket} --source.s3.endpoint={endpoint} --source.s3.region=us-east-1 --source.s3.accessKeyId=test --source.s3.secretAccessKey=test --source.s3.path=data --source.s3.filename=a.txt --dest.protocol=file --dest.file.path={workdir} --dest.file.filename=down.txt"
40
+ Then the captured process should complete with exit code 0
41
+ And a file "down.txt" should exist in the working directory
42
+
43
+ Scenario: hash outputs the expected sha256 digest
44
+ Given an S3 object "data/a.txt" containing "hello"
45
+ When the executable stdout is captured for "hash --location.protocol=s3 --location.s3.bucket={bucket} --location.s3.endpoint={endpoint} --location.s3.region=us-east-1 --location.s3.accessKeyId=test --location.s3.secretAccessKey=test --location.s3.path=data --location.s3.filename=a.txt"
46
+ Then the captured process should complete with exit code 0
47
+ And the stdout should contain "2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824"
48
+
49
+ Scenario: delete removes an object
50
+ Given an S3 object "data/a.txt" containing "hello"
51
+ When the executable stdout is captured for "delete --location.protocol=s3 --location.s3.bucket={bucket} --location.s3.endpoint={endpoint} --location.s3.region=us-east-1 --location.s3.accessKeyId=test --location.s3.secretAccessKey=test --location.s3.path=data --location.s3.filename=a.txt"
52
+ Then the captured process should complete with exit code 0
53
+ And the S3 object "data/a.txt" should not exist
@@ -9,6 +9,8 @@ from support.subprocess_wrapper import SubprocessWrapper
9
9
  @when('the executable stdout is captured for "{args}"')
10
10
  def step_impl(context, args):
11
11
  args = args.replace('{workdir}', context.workdir or '')
12
+ args = args.replace('{endpoint}', getattr(context, 's3_endpoint', ''))
13
+ args = args.replace('{bucket}', context.s3_bucket or '')
12
14
  wrapper = SubprocessWrapper(context.executable)
13
15
  wrapper.run(args)
14
16
  context.subprocess_wrapper = wrapper
@@ -0,0 +1,33 @@
1
+ import uuid
2
+
3
+ from behave import given, then
4
+
5
+
6
+ @given('an empty S3 bucket')
7
+ def step_impl(context):
8
+ context.s3_bucket = 'functest-{}'.format(uuid.uuid4().hex[:12])
9
+ context.s3_client.create_bucket(Bucket=context.s3_bucket)
10
+
11
+
12
+ @given('an S3 object "{key}" containing "{content}"')
13
+ def step_impl(context, key, content):
14
+ context.s3_client.put_object(Bucket=context.s3_bucket, Key=key, Body=content.encode('utf-8'))
15
+
16
+
17
+ def get_object(context, key):
18
+ try:
19
+ return context.s3_client.get_object(Bucket=context.s3_bucket, Key=key)['Body'].read()
20
+ except context.s3_client.exceptions.NoSuchKey:
21
+ return None
22
+
23
+
24
+ @then('the S3 object "{key}" should contain "{content}"')
25
+ def step_impl(context, key, content):
26
+ body = get_object(context, key)
27
+ assert body == content.encode('utf-8'), 'unexpected S3 object {!r}: {!r}'.format(key, body)
28
+
29
+
30
+ @then('the S3 object "{key}" should not exist')
31
+ def step_impl(context, key):
32
+ body = get_object(context, key)
33
+ assert body is None, 'expected S3 object {!r} not to exist'.format(key)
@@ -1 +1,7 @@
1
1
  behave
2
+ boto3
3
+ moto[s3]
4
+ flask
5
+ flask-cors
6
+ # last release with a Windows ARM wheel; later ones need a Rust toolchain to build there
7
+ cryptography==46.0.3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flowscripter/flowscripter-io-cli",
3
- "version": "3.0.3",
3
+ "version": "3.0.5",
4
4
  "description": "CLI for https://github.com/flowscripter/pluggable-io-framework",
5
5
  "keywords": [
6
6
  "bun",
@@ -23,8 +23,8 @@
23
23
  "dependencies": {
24
24
  "@flowscripter/dynamic-cli-framework": "^9.1.3",
25
25
  "@flowscripter/dynamic-cli-framework-api": "^5.0.2",
26
- "@flowscripter/dynamic-plugin-framework": "^2.2.22",
27
- "@flowscripter/flowscripter-io-cli-hash-native": "^1.0.16",
26
+ "@flowscripter/dynamic-plugin-framework": "^2.2.25",
27
+ "@flowscripter/flowscripter-io-cli-hash-native": "^1.0.18",
28
28
  "@flowscripter/pluggable-io-framework": "^2.1.2",
29
29
  "@flowscripter/pluggable-io-framework-api": "^3.1.3",
30
30
  "zod": "^4.6.7"
@@ -73,7 +73,9 @@ function toOption(name: string, schema: ZodNode): Option | ComplexOption {
73
73
  }
74
74
 
75
75
  function toOptions(node: ZodNode): ReadonlyArray<Option | ComplexOption> {
76
- return Object.entries(node.shape ?? {}).map(([name, child]) => toOption(name, child));
76
+ return Object.entries(node.shape ?? {})
77
+ .filter(([, child]) => unwrap(child).node.def.type !== "record")
78
+ .map(([name, child]) => toOption(name, child));
77
79
  }
78
80
 
79
81
  /**
@@ -83,6 +85,8 @@ function toOptions(node: ZodNode): ReadonlyArray<Option | ComplexOption> {
83
85
  * values, nested objects become nested `ComplexOption`s and arrays of objects
84
86
  * become array `ComplexOption`s. Optional and defaulted fields are optional.
85
87
  * A field's `.describe()` text is its description, defaulting to its name.
88
+ * Record fields (free-form key/value maps) have no command line form and are
89
+ * left out.
86
90
  */
87
91
  export function zodToComplexOption(schema: ZodType): ReadonlyArray<Option | ComplexOption> {
88
92
  const { node } = unwrap(schema as unknown as ZodNode);
@@ -110,6 +110,13 @@ describe("zodToComplexOption", () => {
110
110
  );
111
111
  });
112
112
 
113
+ test("leaves out record fields", () => {
114
+ const options = zodToComplexOption(
115
+ z.object({ name: z.string(), tags: z.record(z.string(), z.string()).optional() }),
116
+ );
117
+ expect(options.map((o) => o.name)).toEqual(["name"]);
118
+ });
119
+
113
120
  test("rejects a non-object schema", () => {
114
121
  expect(() => zodToComplexOption(z.string())).toThrow('Expected an object schema, got "string"');
115
122
  });