Skip to content

v0.49.1

Latest

Choose a tag to compare

@github-actions github-actions released this 30 Jul 21:33

Environments no longer have to be written out one combination at a time: a file can declare independent groups and you pick one profile from each. Opening another workspace now switches the environment with it, instead of keeping the previous workspace's environment, credentials and cookies.

Added

Grouped environments

A file can declare independent groups, for example which backend, who you are, and where it runs. Pick one profile per group and Resterm builds the environment from them, so you no longer write out every combination by hand.

{
  "$shared": { "region": "eu" },
  "$groups": {
    "api": {
      "$default": "dev",
      "dev":  { "services.api.base": "https://dev.example.com" },
      "prod": { "services.api.base": "https://api.example.com" }
    },
    "credentials": {
      "$default": "personal",
      "personal": { "auth.token": "local-token" },
      "ci":       { "auth.token": "ci-token" }
    }
  }
}

All the groups live in the one environment file the workspace loads, either the resterm.env.json it finds or the file you pass with --env-file. Resterm loads a single file per workspace and never merges several, so groups cannot be spread across files. That file is either flat or grouped, never both.

A group with several profiles needs a $default, one with a single profile uses it automatically. The same variable cannot appear in two groups, because profiles from different groups are active together. Two profiles in the same group can reuse a name, since only one of them is ever active.

In the TUI, Ctrl+E lists one group = profile row per choice and can now be searched. Space picks a profile, Enter applies, so several groups can change at once. The header keeps it short (ENV: api=prod +2) while the picker and the status line use the whole selection.

From the CLI, pass one flag per group. Groups you leave out keep their defaults:

resterm run --env-group api=prod --env-group 'credentials=ci' ./requests.http

Scripts can read the selection:

env.name              // "api=prod, credentials=ci"
env.groups.api        // "prod"
env.groups.get("credentials")

Compare varies one group and holds every other choice fixed:

# @compare group=api dev stage prod base=stage
GET {{services.api.base}}/health

The CLI equivalent is --compare dev,stage,prod --compare-group api --compare-base stage. An unknown group, profile or baseline is rejected before the first request is sent.

There is a runnable sample in _examples/grouped/: three groups of three profiles, so 9 declarations cover 27 combinations.

Changed

Opening another workspace switches the environment

Opening workspace B from a session started in A used to keep A's environment, credentials, cookies, OAuth tokens and responses, and could quietly fall back to B's default even when the session was started with --env prod.

The environment is now resolved again for the new folder, and it looks for the one you chose rather than the one you happened to end up with. A session started with --env prod, or switched later with Ctrl+E, looks for that same environment in the new workspace. When it is not there, nothing is selected, because falling back to that workspace's default could put a dev session on prod:

ENV: none selected
No environment selected. Choose one with Ctrl+E

Globals, file variables, cookies, OAuth tokens, command auth and the last response are cleared when the workspace changes. Switching is refused while a request is running, since that request can still write values back afterwards. An --env-file passed on the command line applies to the whole session, so it stays in effect after the switch, and Resterm warns you when the new workspace has an environment file of its own.

Stored values are kept apart per project

Cookies, globals, OAuth tokens and the rest are now filed under both the environment and the file it was read from, so two projects that each call an environment dev never read each other's values. With groups, the whole selection counts: change only the credentials profile and you get separate cookies, globals and OAuth cache.

For resterm run, persisted state now goes to <config-dir>/runner/<workspace>-<digest>, one folder per workspace. --state-dir is still used exactly as you pass it. Anything written before this change stays where it was and is not moved, so the first run after upgrading has to authenticate again.

Smaller changes

  • Resterm now tells you at startup, and after a workspace switch, about environment files it can see but will not load, and about *.env.json files that discovery never opens.
  • JSON reports gained environmentSelection and compare.group. The schema stays at version 1, and envName still holds the full display label. Text and JUnit output are unchanged.
  • History saves the selection (schema version 3) and restores it on replay. If a group or profile is gone, Resterm keeps what you have selected, warns, and refuses the resend rather than running with different credentials.
  • In flat files, an environment variable now always wins over $shared, even when the two spellings differ only in case. Before, both could survive the merge and either one could win.
  • A generated resterm.env.example.json keeps $groups, group names, profile names and $default, and replaces only the values.

Fixed

  • Environment files with entries that are not objects loaded wrongly: a plain string became an empty environment, an array became numbered variables. Both now fail with a parse error naming the environment.
  • A broken environment file found by discovery was ignored, so Resterm started with no environments and left every variable unresolved. Discovery and --env-file now report the parse error and stop startup.
  • An explicit OAuth cache_key skipped environment scoping, so two environments using the same key shared one token. Keys are now scoped to the environment, and older unscoped entries are discarded on load so the next request fetches a fresh token.
  • When the baseline snapshot was missing, compare used the target's own response as its baseline and showed a diff that looked identical. It now warns and leaves both panes alone.
  • A --compare-base that matched none of the targets was added to the target list instead of being reported.
  • --compare could not express profile names with spaces in them. Commas and semicolons now win as separators, so --compare 'dev app 1,dev app 2' works.
  • Grouped compare history could not find its baseline row, and redaction of compare rows relied on rows and targets lining up by index. Each row now carries its own selection.
  • Error output printed the operation twice, once as the headline and again in the list of causes below it.