Add --entrypoint flag for remote Edge Apps + bundle screenly_inject.js#284
Merged
sergey-borovkov merged 6 commits intomasterfrom May 5, 2026
Merged
Conversation
Make remote-entrypoint Edge Apps a first-class create option and lay the
groundwork for a per-deploy JS injection workflow.
- `screenly edge-app create --name X --entrypoint <URL>` writes
`screenly.yml` with `entrypoint.type: remote-global` + URI, drops a
starter `screenly_inject.js`, and adds it to `.ignore`. No `index.html`
on disk for remote apps.
- `deploy` materializes a placeholder `index.html` for the duration of
the upload (the backend rejects publishing versions with no signed
assets) and removes it after.
- Adds `is_first_deploy` short-circuit so the first deploy of a fresh
app isn't blocked by the no-changes check.
- New `sync_js_injection` step at the end of `deploy`: looks up the
installation's stable asset and PATCHes `js_injection` from the
local file. Wait/retry until the asset is provisioned.
- Adds request URL/status logging to `commands::get` for easier
diagnosis.
- Docs (`docs/EdgeApps.md`) describe the new flow and the
`screenly_settings` runtime hook for inject scripts.
WIP: the final `js_injection` PATCH currently 400s on the live API
({"code":"22P02","error":"Invalid input value: nil"}). TODO marker in
`set_asset_js_injection` — switch to the new revision-scoped
js_injection endpoint when the backend ships it.
Lift the four recurring patterns from the Playground javascript-injectors examples (setValue, setReactValue for framework-controlled inputs, setCookie for SSO, onPath for path-guarded execution) into the bundled screenly_inject.js. Includes commented examples for form-fill login, cookie-based SSO, and a fetch-override Bearer-token attach so users porting from Playground get a familiar starting shape.
The player will read screenly_inject.js straight from the edge app's file tree (octo-avenger change in a separate commit), so the CLI no longer needs to talk to the assets endpoint to set js_injection. This removes: - `sync_js_injection`, `wait_for_installation_stable_asset` and their call site at the end of `deploy` - `set_asset_js_injection` and `get_installation_stable_asset` on the Api struct - `screenly_inject.js` from the always-excluded list (so it's actually uploaded as a normal asset file) - the `.ignore` write in `create --entrypoint` (file is bundled now) Kept: the `--entrypoint` flag, the `screenly_inject.js` template write on `create`, the `VirtualIndexHtml` placeholder for the case where the user removes the inject file (the version still needs at least one signed asset to publish), the URL+status logging in `commands::get`. Docs updated to describe the file-based flow.
The player runs the inject script after the page is fully loaded, so
wrapping code in `document.addEventListener('DOMContentLoaded', ...)`
silently fails — the listener gets registered after the event has
already fired. Added a comment in the bundled template warning about
this so users don't reach for the familiar pattern by reflex.
…text - `cargo fmt` (extra blank lines). - `--entrypoint` help string was still describing the old behavior of adding the inject file to `.ignore`; updated to describe the bundle-with-revision flow. - Regenerated `docs/CommandLineHelp.md` to match.
rusko124
approved these changes
May 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
screenly edge-app create --entrypoint <URL>for remote-global Edge Apps. Writesentrypoint.type: remote-global+uriintoscreenly.yml, drops a starterscreenly_inject.jsnext to the manifest, and skips theindex.htmlstub.screenly_inject.jsis treated as a normal bundled asset file: it ships with the revision and the player reads it from the file tree.deploymaterializes a one-shot virtualindex.htmlplaceholder if the user has none, so the version always has at least one signed asset to publish. First-deploy short-circuit added so the no-changes guard doesn't block the initial publish.screenly_inject.jstemplate ships with helpers (setValue,setReactValue,setCookie,onPath) and commented examples drawn from the Playground javascript-injectors patterns (form-fill login, cookie-based SSO, fetch-override). Includes a comment warning that DOMContentLoaded has already fired by the time the inject runs.commands::getso failures insidedeploycan be diagnosed without bisection.docs/EdgeApps.mddescribes the new flow,screenly_settings, and how to wire credentials/secrets through.Test plan
cargo build --release,cargo test— all 200+ tests pass (one pre-existing flaky env-races test in utils.rs is unaffected by this change).create --entrypoint https://httpbin.org/headers→ set settings/secret →instance create→deploy→ playlist → append. Player picks up the bundledscreenly_inject.js, IIFE-wraps it withscreenly_settings, executes — green banner with the greeting and api_token visible above httpbin's JSON output.createwithout--entrypointand confirm the existing flow (writesindex.html, noscreenly_inject.js) is unchanged.