open-in-editor-bridge 0.3.0 → 0.4.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7d25bb9c59762f68ee9b164865d324147c717b4b1d5c13bb3163dc57b2c65763
4
- data.tar.gz: 85c973a0426c36ece6f5daec5b767380bc4621d0c39e28ccb01e572279c58db0
3
+ metadata.gz: eaaf6a230a717d29cee22bd54955b4602c9fef5779499808bdc8732b379de7fc
4
+ data.tar.gz: 28e77df9eb6041a821ce65d784d30cb31cbd7a3a08c3e8f9e1695c8947a4d290
5
5
  SHA512:
6
- metadata.gz: d35441d1493bfda18b675cacf05e94baa1c2872543d4464492bc8271b4032213b8aa8826e9b567334aa19cc6cdf7f7c1fbfed1bccda78e60a3bcfb66b09d9d1c
7
- data.tar.gz: 7d8a2e2aaf8641d415ea9f8cd6a4d78f67735506bcb38a3095d9dca4b1123635661995e2358767d496be9ef13c3d2d81412ca777cb1d815f393c1854c633cd83
6
+ metadata.gz: 23f9ee5e974031a4b05bfa1a47d15f85eac1748265e829879fcc322926062268f52503e08295d2b1d4d9034b93262662c336e079dcb3247800ba1214cea932af
7
+ data.tar.gz: a441abf55c7ababc5061eaf7d9e8d2b5dec7497c623e478dd5fcd9f29f11919beaf9907c9d35f487a8f6a27bb8837a31b0c7d19949495f9dc14482ae960f84a8
data/CHANGELOG.md CHANGED
@@ -1,5 +1,24 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.4.0 — 2026-10-10
4
+
5
+ ### Added
6
+
7
+ - Retained opt-in `rake test:docker` gate for real multi-checkout routing, editor invocation, configuration parity, and cleanup, including consumer Vite 5.4.20 / 8.0.9 and the prior 6.0.0 reference.
8
+ - The same runtime gate can exercise a clean installed gem via `OPEN_IN_EDITOR_BRIDGE_TEST_LIB`.
9
+ - Explicit public/internal API boundaries and evidence-based versioning/1.0 promotion policy.
10
+
11
+ ### Fixed
12
+
13
+ - `up --wait` / `--wait=true` now retain detached editor registration after services become ready, rather than stopping the broker while containers remain running.
14
+ - Compose's native canonical configuration replaces handwritten file discovery, honoring `.env` / `--env-file` / `COMPOSE_FILE` and preserving project identity, paths, profiles, interpolation, and literal dollar values.
15
+ - Invalid Compose configuration fails before acquiring a broker lease.
16
+
17
+ ### Compatibility
18
+
19
+ - Docker startup requires Compose's `config --format json` and `config --environment` capabilities. Broker protocol, explicit network exposure, host-only control credentials, and existing Ruby lifecycle APIs are unchanged.
20
+ - This is a development minor release, not an API freeze. Prefer `~> 0.4.0` for the tested release line.
21
+
3
22
  ## 0.3.0 — 2026-10-09
4
23
 
5
24
  ### Added
data/README.md CHANGED
@@ -5,7 +5,7 @@ A Ruby gem that runs a shared local HTTP bridge for opening container files in t
5
5
  ## Install
6
6
 
7
7
  ```ruby
8
- gem "open-in-editor-bridge", "~> 0.3"
8
+ gem "open-in-editor-bridge", "~> 0.4.0"
9
9
  ```
10
10
 
11
11
  ```sh
@@ -47,7 +47,7 @@ export default defineConfig(async ({ command, mode }) => {
47
47
  });
48
48
  ```
49
49
 
50
- Keep your application's existing plugins and other Vite settings. The variable-based dynamic import is intentional: production builds and test-mode configuration can load without Docker's development mounts. This path supports Docker-hosted Vite development; native-host Vite and custom development modes need their own explicit opt-in condition. The plugin requires a valid mounted manifest when enabled and fails startup if it is missing or malformed. Vite 6 is exercised by release QA.
50
+ Keep your application's existing plugins and other Vite settings. The variable-based dynamic import is intentional: production builds and test-mode configuration can load without Docker's development mounts. This path supports Docker-hosted Vite development; native-host Vite and custom development modes need their own explicit opt-in condition. The plugin requires a valid mounted manifest when enabled and fails startup if it is missing or malformed. The retained Docker gate covers the consumer versions Vite 5.4.20, 6.0.0, and 8.0.9.
51
51
 
52
52
  ### Application Configuration That Remains
53
53
 
@@ -56,9 +56,9 @@ Keep your application's existing plugins and other Vite settings. The variable-b
56
56
  - Select checkout/container/host roots and the editor through the existing bridge configuration below. `project_root:` defaults to the current checkout; `env:` supplies bridge configuration and child-process environment overrides.
57
57
  - Explicitly select a Docker-reachable bind address. The adapter rejects loopback startup and never changes the default binding itself.
58
58
 
59
- When no explicit `-f` is supplied, the adapter respects `COMPOSE_FILE` / `COMPOSE_PATH_SEPARATOR`, or discovers a standard Compose file and its default override from the project directory upward. `--project-directory` is supported. Compose runs in `project_root:` and inherits normal process input/output. Failures raise; successful commands return `true`.
59
+ Compose itself resolves the original project configuration before the adapter adds its mounts: default file discovery, `.env` / `--env-file`, `COMPOSE_FILE` / `COMPOSE_PATH_SEPARATOR`, explicit multi-file inputs, project name, source-relative paths, interpolation, and active profiles remain Compose-owned. The adapter reuses Compose's canonical JSON model in a private host-only temporary file, preserving Compose's literal-dollar escaping instead of merging the original sources a second time. `compose_options` retains other global options, and the original subcommand arguments still select services. Compose runs in `project_root:` and inherits normal process input/output. Failures raise; successful commands return `true`.
60
60
 
61
- Only `up` adds editor setup. Foreground `up` owns an independent lease and releases it even on failure. `up -d` / `up --detach` use the existing idempotent detached registration. Failed detached startup releases a newly acquired registration but preserves one that was already active. Successful `down` releases that checkout's detached registration; failed `down` keeps it. Other commands (`config`, `build`, `exec`, `run`, `logs`, and so on) execute ordinary Compose without editor setup or requiring an editor. `stop` does not release detached registration; use `down` or `--shutdown` when done. If a new container needs the editor mounts, create it through `up`.
61
+ Only `up` adds editor setup. Foreground `up` owns an independent lease and releases it even on failure. `up -d` / `up --detach` and `up --wait` / `up --wait=true` use the existing idempotent detached registration: readiness-based startup returns while containers remain running, so the editor registration must remain too. Failed detached startup releases a newly acquired registration but preserves one that was already active. Successful `down` releases that checkout's detached registration; failed `down` keeps it. Other commands (`config`, `build`, `exec`, `run`, `logs`, and so on) execute ordinary Compose without editor setup or requiring an editor. `stop` does not release detached registration; use `down` or `--shutdown` when done. If a new container needs the editor mounts, create it through `up`.
62
62
 
63
63
  The generated override mounts just two read-only files at `/open-in-editor-bridge`: the packaged `vite.mjs` and a checkout-specific `session.json` containing identity and target URL. It never mounts broker state, the whole private runtime directory, or lifecycle control credentials. Temporary Compose overrides are removed after each invocation; non-secret manifests remain in the private host runtime directory for existing detached containers.
64
64
 
@@ -66,7 +66,7 @@ All checkouts share the standard host port `3333`, bind address, and private run
66
66
 
67
67
  ### Adopting in ELCC
68
68
 
69
- After installing 0.3.0, ELCC can replace the editor lifecycle/Compose `up` and `down` path in `bin/dev` with `OpenInEditorBridge.compose`, passing its existing development/gateway `-f` options, project name, host user/group variables, and gateway hostname. Keep gateway lifecycle ownership and pipe-input handling for unrelated commands unchanged.
69
+ After installing 0.4.0, ELCC can replace the editor lifecycle/Compose `up` and `down` path in `bin/dev` with `OpenInEditorBridge.compose`, passing its existing development/gateway `-f` options, project name, host user/group variables, and gateway hostname. Keep gateway lifecycle ownership and pipe-input handling for unrelated commands unchanged.
70
70
 
71
71
  Remove the `OPEN_IN_EDITOR_SESSION_ID` export from `dynamic_environment_variables`, its web-service pass-through in `docker-compose.development.yaml`, and the handwritten `/__open-in-editor` target/rewrite in `web/vite.config.js`. Add the mounted plugin to the existing Vue/Vuetify/gateway plugin list under the development-only condition above. The adapter supplies the host-gateway entry, so an editor-only `extra_hosts` entry is no longer necessary. Keep the explicit trusted-network bind opt-in and existing root/editor settings. No consumer files are changed automatically.
72
72
 
@@ -129,6 +129,18 @@ A failed or timed-out health probe does not discard a still-listening broker's c
129
129
 
130
130
  Version 0.2 replaces checkout-local PID/log files with shared runtime state. Stop any 0.1.x bridge using its original installed version before upgrading; it cannot share the new protocol. Sessions live in the broker's memory. After a broker crash or deliberate manual stop, rerun `--ensure-running` for detached applications. Abruptly killed foreground clients cannot execute `ensure`; stop that broker manually and re-register surviving checkouts if their leases become orphaned.
131
131
 
132
+ ## Public Contract and Versioning
133
+
134
+ Supported entrypoints are the documented Ruby class methods `compose`, `with_running`, `call`, `session_id`, and `new(env:, project_root:)`; instance `call` / `session_id`; the CLI lifecycle commands; and the health/editor HTTP endpoints. Their documented routing, cleanup, configuration, and error semantics are the consumer contract. `StartupError` identifies broker startup/control failures; Compose process failures raise rather than return a false success.
135
+
136
+ `Configuration`, `Client`, `Server`, `Docker`, raw lease methods, control-request signing, runtime file layout, generated Compose inputs, and proxy implementation details are internal, even where Ruby permits direct access. Do not build a consumer on those details or put control credentials in containers. HTTP error text, status-log wording, checkout-ID derivation details, and temporary filenames are not compatibility interfaces.
137
+
138
+ This project follows [Semantic Versioning](https://semver.org/). **0.4.0 remains a development release, not a claim that the integration is frozen.** Use `~> 0.4.0` to stay within the tested minor release line; `~> 0.4` would permit future 0.x minor changes.
139
+
140
+ **1.0 is a public-API compatibility commitment, not a feature-count milestone.** The Ruby lifecycle is already used by consumers, but the Compose/Vite path is recent and this cycle found configuration-selection and readiness-lifetime defects. Promotion should follow an explicit freeze of the supported API, platform/tool prerequisites, and upgrade policy after real consumer adoption confirms the integration shape and the retained installed-artifact gate passes. No additional feature backlog or arbitrary sequence through 0.5–0.9 is required; the next stable-contract release can go directly to 1.0.
141
+
142
+ Verified release environments are Linux with Docker Compose supporting `config --format json` and `config --environment` (5.6.0 exercised here), Node 22 with Vite 5.4.20 / 6.0.0, and Node 24 with Vite 8.0.9. Other platforms/tool versions are not implied by this evidence. These capabilities are needed only for the Docker adapter; unrelated Compose commands do not resolve editor configuration.
143
+
132
144
  ## Development and Release
133
145
 
134
146
  Commit the root `Gemfile.lock` to keep development and release-test dependencies reproducible. Regenerate it with Bundler after changing `Gemfile`, and commit both files together when both change. This development lockfile is not included in the gem package and does not constrain applications installing this gem; those applications resolve the gemspec's dependencies using their own lockfiles.
@@ -143,4 +155,26 @@ bundle exec rake test
143
155
  gem build open-in-editor-bridge.gemspec
144
156
  ```
145
157
 
146
- Release changes on an issue-linked branch and pull request, including the version and changelog. Self-review and exercise real host/container lifecycle and editor invocation before merging. From synchronized `main`, build and push the gem with the maintainer's RubyGems credentials, then create a matching GitHub tag/release. Install the published version from RubyGems into a clean `GEM_HOME`, confirm `OpenInEditorBridge::VERSION`, and repeat foreground, detached, routing, and Docker-reachability checks. A recorded editor process proves invocation and arguments, not that an editor window rendered.
158
+ Release changes on an issue-linked branch and pull request, including the version and changelog. Self-review and run the normal test gate plus the real Docker gate below before merging. From synchronized `main`, build and push the gem with the maintainer's RubyGems credentials, then create a matching GitHub tag/release. Install the published version from RubyGems into a clean `GEM_HOME`, confirm `OpenInEditorBridge::VERSION`, and run the same Docker gate against its installed library. A recorded editor process proves invocation and arguments, not that an editor window rendered.
159
+
160
+ ### Retained Docker and Vite Gate
161
+
162
+ ```sh
163
+ bundle exec rake test:docker
164
+ ```
165
+
166
+ The opt-in gate creates isolated temporary Compose projects and requires host port 3333 to be free. It exercises two checkout mappings for each pinned Vite version, encoded paths/locations and hostile selectors, credential isolation, native configuration parity, readiness-based detached lifetime, foreground/error cleanup, ordinary commands, and production builds without editor mounts. It does not run as part of the fast `rake test` gate. Docker and npm registry access are required to prepare the Node/Vite fixture images; projects, leases, networks, and temporary directories are cleaned on exit. Images may be reused between QA runs.
167
+
168
+ To repeat it against the released gem while retaining the checkout's test tooling:
169
+
170
+ ```sh
171
+ release_home="$(mktemp -d)"
172
+ GEM_HOME="$release_home" GEM_PATH="$release_home" \
173
+ gem install open-in-editor-bridge --version 0.4.0 \
174
+ --clear-sources --source https://rubygems.org --no-document
175
+ GEM_HOME="$release_home" GEM_PATH="$release_home" \
176
+ ruby -ropen_in_editor_bridge -e 'puts OpenInEditorBridge::VERSION'
177
+ OPEN_IN_EDITOR_BRIDGE_TEST_LIB="$release_home/gems/open-in-editor-bridge-0.4.0/lib" \
178
+ bundle exec rake test:docker
179
+ rm -rf "$release_home"
180
+ ```
@@ -1,12 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "open3"
3
4
  require "tempfile"
4
5
 
5
6
  class OpenInEditorBridge
6
7
  class Docker
7
8
  CONTAINER_DIRECTORY = "/open-in-editor-bridge"
8
- COMPOSE_FILES = %w[compose.yaml compose.yml docker-compose.yaml docker-compose.yml].freeze
9
- OVERRIDE_FILES = %w[compose.override.yaml compose.override.yml docker-compose.override.yaml docker-compose.override.yml].freeze
10
9
 
11
10
  def initialize(env:, project_root:, service:, compose_options:)
12
11
  @env = env.to_h
@@ -39,11 +38,14 @@ class OpenInEditorBridge
39
38
  end
40
39
  raise ArgumentError, "Select a Compose service for the Vite integration" if @service.to_s.empty?
41
40
 
42
- # Resolve Compose inputs before acquiring a lease; invalid setup must not leave a broker behind.
43
- files = compose_file_options
44
- with_override do |override|
45
- options = [*files, "-f", override]
46
- detached?(args) ? detached_up(args, options) : foreground_up(args, options)
41
+ # Resolve source files once with Compose, before acquiring a lease. Reuse
42
+ # its canonical model rather than trying to reproduce file discovery.
43
+ with_resolved_configuration do |resolved_file, profiles|
44
+ with_override do |override|
45
+ options = compose_options_for_resolved_configuration(profiles) +
46
+ ["-f", resolved_file, "-f", override]
47
+ detached?(args) ? detached_up(args, options) : foreground_up(args, options)
48
+ end
47
49
  end
48
50
  end
49
51
 
@@ -73,15 +75,63 @@ class OpenInEditorBridge
73
75
  end
74
76
 
75
77
  def detached?(args)
78
+ wait_flag = args.reverse_each.find { |arg| %w[--wait --wait=true --wait=false].include?(arg) }
79
+ return true if wait_flag && wait_flag != "--wait=false"
80
+
76
81
  flags = args.select { |arg| %w[-d --detach --detach=true --detach=false -d=true -d=false].include?(arg) }
77
82
  !flags.empty? && !%w[--detach=false -d=false].include?(flags.last)
78
83
  end
79
84
 
80
- def run(args, extra_options = [])
81
- system(@env, "docker", "compose", *@compose_options, *extra_options, *args,
85
+ def run(args, compose_options = @compose_options)
86
+ system(@env, "docker", "compose", *compose_options, *args,
82
87
  chdir: @project_root, exception: true)
83
88
  end
84
89
 
90
+ def with_resolved_configuration
91
+ Tempfile.create(["compose-resolved-", ".json"]) do |file|
92
+ system(@env, "docker", "compose", *@compose_options, "config", "--format", "json",
93
+ chdir: @project_root, out: file, exception: true)
94
+ file.flush
95
+ yield file.path, active_profiles
96
+ end
97
+ end
98
+
99
+ def active_profiles
100
+ output, error, status = Open3.capture3(@env, "docker", "compose", *@compose_options,
101
+ "config", "--environment", chdir: @project_root)
102
+ unless status.success?
103
+ raise "Docker Compose config --environment failed (exit #{status.exitstatus}): #{error.strip}"
104
+ end
105
+
106
+ profiles = output.lines.find { |line| line.start_with?("COMPOSE_PROFILES=") }
107
+ return [] unless profiles
108
+
109
+ profiles.delete_prefix("COMPOSE_PROFILES=").strip.split(",").reject(&:empty?)
110
+ end
111
+
112
+ def compose_options_for_resolved_configuration(profiles)
113
+ options = []
114
+ skip_next = false
115
+ @compose_options.each do |option|
116
+ if skip_next
117
+ skip_next = false
118
+ next
119
+ end
120
+ if %w[-f --file --env-file].include?(option)
121
+ skip_next = true
122
+ elsif option.start_with?("--file=", "--env-file=") || option.match?(/\A-f.+/)
123
+ next
124
+ else
125
+ options << option
126
+ end
127
+ end
128
+ unless options.any? { |option| option == "--project-directory" || option.start_with?("--project-directory=") }
129
+ options.concat(["--project-directory", @project_root])
130
+ end
131
+ profiles.each { |profile| options.concat(["--profile", profile]) }
132
+ options
133
+ end
134
+
85
135
  def with_override
86
136
  configuration.ensure_runtime_directory
87
137
  manifest = write_manifest
@@ -118,34 +168,5 @@ class OpenInEditorBridge
118
168
  end
119
169
  path
120
170
  end
121
-
122
- def compose_file_options
123
- return [] if @compose_options.any? { |arg| arg == "-f" || arg == "--file" || arg.start_with?("--file=") || arg.match?(/\A-f.+/) }
124
-
125
- if @env["COMPOSE_FILE"] && !@env["COMPOSE_FILE"].empty?
126
- separator = @env.fetch("COMPOSE_PATH_SEPARATOR", File::PATH_SEPARATOR)
127
- return @env.fetch("COMPOSE_FILE").split(separator).flat_map { |path| ["-f", File.expand_path(path, @project_root)] }
128
- end
129
-
130
- directory = discovery_directory
131
- loop do
132
- base = COMPOSE_FILES.find { |name| File.file?(File.join(directory, name)) }
133
- if base
134
- override = OVERRIDE_FILES.find { |name| File.file?(File.join(directory, name)) }
135
- return [base, override].compact.flat_map { |name| ["-f", File.join(directory, name)] }
136
- end
137
- parent = File.dirname(directory)
138
- raise ArgumentError, "No Compose file found; select it with compose_options: [\"-f\", path]" if parent == directory
139
- directory = parent
140
- end
141
- end
142
-
143
- def discovery_directory
144
- @compose_options.each_with_index do |option, index|
145
- return File.expand_path(@compose_options.fetch(index + 1), @project_root) if option == "--project-directory"
146
- return File.expand_path(option.delete_prefix("--project-directory="), @project_root) if option.start_with?("--project-directory=")
147
- end
148
- @project_root
149
- end
150
171
  end
151
172
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class OpenInEditorBridge
4
- VERSION = "0.3.0"
4
+ VERSION = "0.4.0"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: open-in-editor-bridge
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marlen Brunner