open-in-editor-bridge 0.3.0 → 0.5.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 +4 -4
- data/CHANGELOG.md +34 -0
- data/README.md +48 -12
- data/lib/open_in_editor_bridge/docker.rb +62 -40
- data/lib/open_in_editor_bridge/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f4c5a4d97eddd623771949a0d8f48010d3c246c3b54e42fc4d189d65186e0e10
|
|
4
|
+
data.tar.gz: 362dfa4623c2abcea425b112487c6810d4835e1d5905c753f5ccd65b77a5505f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 12be17610397f8dfa726f0e0dd4f481116bcda2e7e5bb85e8e772a16b3e1997e27d6cb5092d20aa3b56e836fb0206b2f16b3bcf024af4479daab40cd899a5d91
|
|
7
|
+
data.tar.gz: 48a7c90292b04d7ba27dad224a14af34014cb4fad9b516757c718fb1eb79c33e2b0000f98881ad287339781ffb511c4dd29410a468f8d7d61143726ddecebece
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,39 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.5.0 — 2026-10-13
|
|
4
|
+
|
|
5
|
+
### Changed
|
|
6
|
+
|
|
7
|
+
- The Docker Compose adapter defaults to `0.0.0.0` when no bind address is supplied, for both startup and teardown. Consumer wrappers no longer need the adapter's bind assignment.
|
|
8
|
+
- Explicit caller settings are preserved; Docker startup still rejects explicit loopback addresses. Selecting the default never mutates the caller's environment or process-global `ENV`.
|
|
9
|
+
- The retained Docker/Vite gate now exercises real editor invocation, concurrent checkout routing, and final cleanup with no bind override.
|
|
10
|
+
|
|
11
|
+
### Security and Compatibility
|
|
12
|
+
|
|
13
|
+
- Selecting the Docker adapter now exposes the editor listener on all IPv4 interfaces by default. Use only on a trusted/firewalled development network, or explicitly choose a narrower Docker-reachable interface.
|
|
14
|
+
- Standalone CLI and low-level Ruby APIs retain the `127.0.0.1` default. Authentication, host-only control credentials, and lease behavior are unchanged.
|
|
15
|
+
- Clients sharing a broker must use the same bind address. An existing loopback broker is never widened; low-level CLI cleanup of a Docker registration requires its matching bind configuration.
|
|
16
|
+
- This is an intentional development-minor policy change, not an API freeze. Prefer `~> 0.5.0` for the tested release line.
|
|
17
|
+
|
|
18
|
+
## 0.4.0 — 2026-10-10
|
|
19
|
+
|
|
20
|
+
### Added
|
|
21
|
+
|
|
22
|
+
- 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.
|
|
23
|
+
- The same runtime gate can exercise a clean installed gem via `OPEN_IN_EDITOR_BRIDGE_TEST_LIB`.
|
|
24
|
+
- Explicit public/internal API boundaries and evidence-based versioning/1.0 promotion policy.
|
|
25
|
+
|
|
26
|
+
### Fixed
|
|
27
|
+
|
|
28
|
+
- `up --wait` / `--wait=true` now retain detached editor registration after services become ready, rather than stopping the broker while containers remain running.
|
|
29
|
+
- 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.
|
|
30
|
+
- Invalid Compose configuration fails before acquiring a broker lease.
|
|
31
|
+
|
|
32
|
+
### Compatibility
|
|
33
|
+
|
|
34
|
+
- 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.
|
|
35
|
+
- This is a development minor release, not an API freeze. Prefer `~> 0.4.0` for the tested release line.
|
|
36
|
+
|
|
3
37
|
## 0.3.0 — 2026-10-09
|
|
4
38
|
|
|
5
39
|
### 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.
|
|
8
|
+
gem "open-in-editor-bridge", "~> 0.5.0"
|
|
9
9
|
```
|
|
10
10
|
|
|
11
11
|
```sh
|
|
@@ -16,13 +16,13 @@ gem install open-in-editor-bridge
|
|
|
16
16
|
|
|
17
17
|
Use the host-side Compose adapter and the gem's mounted Vite plugin. The library owns checkout identity transport, the host-gateway entry, and the editor proxy; **do not export a session variable or write a request rewrite**.
|
|
18
18
|
|
|
19
|
+
**Selecting the Docker adapter defaults the listener to `0.0.0.0` (all IPv4 interfaces), not just Docker. Use it only on a trusted development network with host firewall restrictions.** Set `OPEN_IN_EDITOR_BRIDGE_BIND_ADDRESS` to a narrower Docker-reachable host interface if needed. Explicit settings are preserved; explicit loopback startup is rejected. Standalone CLI and low-level Ruby use still default to `127.0.0.1`.
|
|
20
|
+
|
|
19
21
|
Replace the development Compose startup/shutdown call:
|
|
20
22
|
|
|
21
23
|
```ruby
|
|
22
24
|
require "open_in_editor_bridge"
|
|
23
25
|
|
|
24
|
-
# Explicit network-exposure opt-in; use only on a trusted development network.
|
|
25
|
-
ENV["OPEN_IN_EDITOR_BRIDGE_BIND_ADDRESS"] = "0.0.0.0"
|
|
26
26
|
ENV["OPEN_IN_EDITOR_COMMAND"] = "code"
|
|
27
27
|
|
|
28
28
|
OpenInEditorBridge.compose("up", service: "web")
|
|
@@ -47,18 +47,18 @@ 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.
|
|
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
|
|
|
54
54
|
- Select the Vite service (`service: "web"` by default); retain its image, command, source mounts, ports, and normal environment.
|
|
55
55
|
- Select Compose files/project options when necessary, for example `compose_options: ["-f", "docker-compose.development.yaml", "-p", "my-checkout"]`. Pass subcommand options after `"up"` / `"down"`, not in `compose_options`.
|
|
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
|
+
- Optionally select a narrower Docker-reachable bind address. Without an override, the adapter uses `0.0.0.0` for both startup and teardown without mutating `ENV` or the supplied environment.
|
|
58
58
|
|
|
59
|
-
|
|
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,9 +66,9 @@ 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.
|
|
69
|
+
After installing 0.5.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
|
-
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.
|
|
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. The wrapper's `0.0.0.0` bind assignment is also unnecessary; keep any intentionally narrower interface and existing root/editor settings. No consumer files are changed automatically.
|
|
72
72
|
|
|
73
73
|
## Low-Level Ruby API
|
|
74
74
|
|
|
@@ -109,7 +109,7 @@ Custom integrations may use the same session protocol. With exactly one checkout
|
|
|
109
109
|
| Variable | Default | Purpose |
|
|
110
110
|
|---|---|---|
|
|
111
111
|
| `OPEN_IN_EDITOR_BRIDGE_PORT` | `3333` | Shared host listener port |
|
|
112
|
-
| `OPEN_IN_EDITOR_BRIDGE_BIND_ADDRESS` | `127.0.0.1` | Listener address;
|
|
112
|
+
| `OPEN_IN_EDITOR_BRIDGE_BIND_ADDRESS` | Compose: `0.0.0.0`; standalone: `127.0.0.1` | Listener address; Docker's default exposes all IPv4 interfaces |
|
|
113
113
|
| `OPEN_IN_EDITOR_PROJECT_ROOT` | Current directory | Checkout identity and default host mapping |
|
|
114
114
|
| `OPEN_IN_EDITOR_CONTAINER_WEB_ROOT` | `/usr/src/web` | Container directory to translate |
|
|
115
115
|
| `OPEN_IN_EDITOR_HOST_WEB_ROOT` | `<project-root>/web` | Corresponding host directory |
|
|
@@ -121,14 +121,28 @@ The editor command is required when registering a checkout, but not for `--sessi
|
|
|
121
121
|
|
|
122
122
|
## Security and Upgrade Notes
|
|
123
123
|
|
|
124
|
-
|
|
124
|
+
Standalone CLI and low-level Ruby entrypoints default to loopback. **The Docker Compose adapter defaults to `0.0.0.0`, exposing the listener to other reachable network peers, not only Docker.** Use it only on a trusted development network with host firewall restrictions; an explicit Docker-reachable host interface can narrow exposure. Editor requests are intentionally unauthenticated and health exposes checkout IDs: anyone who can reach the listener can invoke configured editors. Do not expose it on an untrusted network or forward it publicly.
|
|
125
125
|
|
|
126
126
|
Registration and release use nonce-bound HMAC signatures derived from a random control token held in the private host runtime directory; the token is never sent over HTTP. Clients authenticate health and control responses and verify broker protocol/PID against shared state. The broker rejects replayed control requests. Shutdown uses authenticated HTTP control, never signals a PID read from disk. Unknown listeners, old bridge versions, mismatched PIDs, and mismatched bind configurations are not reused.
|
|
127
127
|
|
|
128
|
+
All clients sharing a port/runtime directory must agree on the bind address. The Docker adapter never widens an existing loopback broker; release its sessions with their original configuration before switching. Prefer Compose `down` to release Docker registrations. If using the low-level CLI for Docker cleanup, explicitly supply the adapter's bind address (for example `OPEN_IN_EDITOR_BRIDGE_BIND_ADDRESS=0.0.0.0 open-in-editor-bridge --shutdown`), since standalone defaults remain loopback.
|
|
129
|
+
|
|
128
130
|
A failed or timed-out health probe does not discard a still-listening broker's credentials. Lifecycle operations fail explicitly until its identity can be verified; retry after the listener becomes responsive.
|
|
129
131
|
|
|
130
132
|
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
133
|
|
|
134
|
+
## Public Contract and Versioning
|
|
135
|
+
|
|
136
|
+
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.
|
|
137
|
+
|
|
138
|
+
`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.
|
|
139
|
+
|
|
140
|
+
This project follows [Semantic Versioning](https://semver.org/). **0.5.0 remains a development release, not a claim that the integration is frozen.** Use `~> 0.5.0` to stay within the tested minor release line; `~> 0.5` would permit future 0.x minor changes. The Docker-only bind-default policy change is a minor release; standalone defaults and broker protocol are unchanged.
|
|
141
|
+
|
|
142
|
+
**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.
|
|
143
|
+
|
|
144
|
+
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.
|
|
145
|
+
|
|
132
146
|
## Development and Release
|
|
133
147
|
|
|
134
148
|
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 +157,26 @@ bundle exec rake test
|
|
|
143
157
|
gem build open-in-editor-bridge.gemspec
|
|
144
158
|
```
|
|
145
159
|
|
|
146
|
-
Release changes on an issue-linked branch and pull request, including the version and changelog. Self-review and
|
|
160
|
+
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.
|
|
161
|
+
|
|
162
|
+
### Retained Docker and Vite Gate
|
|
163
|
+
|
|
164
|
+
```sh
|
|
165
|
+
bundle exec rake test:docker
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
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 with no bind override, observes the Docker default, and records real editor invocations. It also covers 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.
|
|
169
|
+
|
|
170
|
+
To repeat it against the released gem while retaining the checkout's test tooling:
|
|
171
|
+
|
|
172
|
+
```sh
|
|
173
|
+
release_home="$(mktemp -d)"
|
|
174
|
+
GEM_HOME="$release_home" GEM_PATH="$release_home" \
|
|
175
|
+
gem install open-in-editor-bridge --version 0.5.0 \
|
|
176
|
+
--clear-sources --source https://rubygems.org --no-document
|
|
177
|
+
GEM_HOME="$release_home" GEM_PATH="$release_home" \
|
|
178
|
+
ruby -ropen_in_editor_bridge -e 'puts OpenInEditorBridge::VERSION'
|
|
179
|
+
OPEN_IN_EDITOR_BRIDGE_TEST_LIB="$release_home/gems/open-in-editor-bridge-0.5.0/lib" \
|
|
180
|
+
bundle exec rake test:docker
|
|
181
|
+
rm -rf "$release_home"
|
|
182
|
+
```
|
|
@@ -1,15 +1,15 @@
|
|
|
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
|
-
@env = env.to_h
|
|
11
|
+
@env = env.to_h.dup
|
|
12
|
+
@env["OPEN_IN_EDITOR_BRIDGE_BIND_ADDRESS"] = @env.fetch("OPEN_IN_EDITOR_BRIDGE_BIND_ADDRESS", "0.0.0.0")
|
|
13
13
|
@project_root = File.expand_path(project_root || @env.fetch("OPEN_IN_EDITOR_PROJECT_ROOT", Dir.pwd))
|
|
14
14
|
@service = service
|
|
15
15
|
@compose_options = compose_options
|
|
@@ -35,15 +35,18 @@ class OpenInEditorBridge
|
|
|
35
35
|
|
|
36
36
|
def up(args)
|
|
37
37
|
if %w[127.0.0.1 ::1 localhost].include?(configuration.bind_address)
|
|
38
|
-
raise ArgumentError, "Docker editor access requires
|
|
38
|
+
raise ArgumentError, "Docker editor access requires a Docker-reachable OPEN_IN_EDITOR_BRIDGE_BIND_ADDRESS (for example 0.0.0.0 on a trusted network); loopback is not reachable from containers."
|
|
39
39
|
end
|
|
40
40
|
raise ArgumentError, "Select a Compose service for the Vite integration" if @service.to_s.empty?
|
|
41
41
|
|
|
42
|
-
# Resolve Compose
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
42
|
+
# Resolve source files once with Compose, before acquiring a lease. Reuse
|
|
43
|
+
# its canonical model rather than trying to reproduce file discovery.
|
|
44
|
+
with_resolved_configuration do |resolved_file, profiles|
|
|
45
|
+
with_override do |override|
|
|
46
|
+
options = compose_options_for_resolved_configuration(profiles) +
|
|
47
|
+
["-f", resolved_file, "-f", override]
|
|
48
|
+
detached?(args) ? detached_up(args, options) : foreground_up(args, options)
|
|
49
|
+
end
|
|
47
50
|
end
|
|
48
51
|
end
|
|
49
52
|
|
|
@@ -73,15 +76,63 @@ class OpenInEditorBridge
|
|
|
73
76
|
end
|
|
74
77
|
|
|
75
78
|
def detached?(args)
|
|
79
|
+
wait_flag = args.reverse_each.find { |arg| %w[--wait --wait=true --wait=false].include?(arg) }
|
|
80
|
+
return true if wait_flag && wait_flag != "--wait=false"
|
|
81
|
+
|
|
76
82
|
flags = args.select { |arg| %w[-d --detach --detach=true --detach=false -d=true -d=false].include?(arg) }
|
|
77
83
|
!flags.empty? && !%w[--detach=false -d=false].include?(flags.last)
|
|
78
84
|
end
|
|
79
85
|
|
|
80
|
-
def run(args,
|
|
81
|
-
system(@env, "docker", "compose",
|
|
86
|
+
def run(args, compose_options = @compose_options)
|
|
87
|
+
system(@env, "docker", "compose", *compose_options, *args,
|
|
82
88
|
chdir: @project_root, exception: true)
|
|
83
89
|
end
|
|
84
90
|
|
|
91
|
+
def with_resolved_configuration
|
|
92
|
+
Tempfile.create(["compose-resolved-", ".json"]) do |file|
|
|
93
|
+
system(@env, "docker", "compose", *@compose_options, "config", "--format", "json",
|
|
94
|
+
chdir: @project_root, out: file, exception: true)
|
|
95
|
+
file.flush
|
|
96
|
+
yield file.path, active_profiles
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
def active_profiles
|
|
101
|
+
output, error, status = Open3.capture3(@env, "docker", "compose", *@compose_options,
|
|
102
|
+
"config", "--environment", chdir: @project_root)
|
|
103
|
+
unless status.success?
|
|
104
|
+
raise "Docker Compose config --environment failed (exit #{status.exitstatus}): #{error.strip}"
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
profiles = output.lines.find { |line| line.start_with?("COMPOSE_PROFILES=") }
|
|
108
|
+
return [] unless profiles
|
|
109
|
+
|
|
110
|
+
profiles.delete_prefix("COMPOSE_PROFILES=").strip.split(",").reject(&:empty?)
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
def compose_options_for_resolved_configuration(profiles)
|
|
114
|
+
options = []
|
|
115
|
+
skip_next = false
|
|
116
|
+
@compose_options.each do |option|
|
|
117
|
+
if skip_next
|
|
118
|
+
skip_next = false
|
|
119
|
+
next
|
|
120
|
+
end
|
|
121
|
+
if %w[-f --file --env-file].include?(option)
|
|
122
|
+
skip_next = true
|
|
123
|
+
elsif option.start_with?("--file=", "--env-file=") || option.match?(/\A-f.+/)
|
|
124
|
+
next
|
|
125
|
+
else
|
|
126
|
+
options << option
|
|
127
|
+
end
|
|
128
|
+
end
|
|
129
|
+
unless options.any? { |option| option == "--project-directory" || option.start_with?("--project-directory=") }
|
|
130
|
+
options.concat(["--project-directory", @project_root])
|
|
131
|
+
end
|
|
132
|
+
profiles.each { |profile| options.concat(["--profile", profile]) }
|
|
133
|
+
options
|
|
134
|
+
end
|
|
135
|
+
|
|
85
136
|
def with_override
|
|
86
137
|
configuration.ensure_runtime_directory
|
|
87
138
|
manifest = write_manifest
|
|
@@ -118,34 +169,5 @@ class OpenInEditorBridge
|
|
|
118
169
|
end
|
|
119
170
|
path
|
|
120
171
|
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
172
|
end
|
|
151
173
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: open-in-editor-bridge
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.5.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Marlen Brunner
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-10-
|
|
11
|
+
date: 2026-10-13 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
13
|
description: Ruby API and CLI for serving local open-in-editor requests during development.
|
|
14
14
|
email:
|