Skip to content

feat: gate fields and country-code case by declared publiccodeYmlVersion - #642

Merged
valeriocomo merged 1 commit into
mainfrom
feat/version-gated-fields
Aug 25, 2026
Merged

feat: gate fields and country-code case by declared publiccodeYmlVersion#642
valeriocomo merged 1 commit into
mainfrom
feat/version-gated-fields

Conversation

@AlexPalaz

Copy link
Copy Markdown
Collaborator

What

Make the editor consistent with the declared publiccodeYmlVersion: if you load/declare a 0.5.0 file you see (and export) the 0.5.0 fields, if you declare 0.7.0 you get the 0.7.0 ones.

Before this, the supports section (introduced in 0.7.0) was always visible and serialized, so loading e.g. a 0.5.0 file and filling it produced an inconsistent YAML declaring publiccodeYmlVersion: '0.5.0' while containing a 0.7.0-only key.

How

  • New FIELD_MIN_VERSIONS map (supports → 0.7.0, organisation/fundedBy → 0.5.0, the only keys ever added after the earliest supported versions) and a isVersionAtLeast semver helper.
  • Editor: the supports, organisation and fundedBy sections are rendered only when the declared version (reactive via watch) is at least their minimum version.
  • Linter/YAML output: the same gating is applied on serialization, so stale form values can never leak into a YAML declaring an older version.
  • Country case: the country section key (IT: vs it:) and the ISO 3166-1 alpha-2 codes in intendedAudience are now serialized uppercase from 0.5.0 onwards (previous behavior) and lowercase for older versions, matching what each version of the standard mandates. Import keeps accepting both forms.

Values are only hidden and excluded from the output, never deleted from the form state: switching the version select back and forth loses no data.

Testing

  • 7 new jest tests (supports.spec.ts, semver.spec.ts, new country-case.spec.ts), 82 total passing.
  • tsc --noEmit and eslint clean.

Show and serialize only the keys that exist in the declared
publiccode.yml version:

- supports (since 0.7.0), organisation and fundedBy (since 0.5.0) are
  hidden in the editor and dropped from the YAML output when the
  declared version is older
- country section key (IT: vs it:) and ISO 3166-1 alpha-2 codes in
  intendedAudience are serialized uppercase since 0.5.0 and lowercase
  for older versions, matching what each version of the standard
  mandates

Values are only hidden and excluded from the output, never deleted from
the form, so switching the version back and forth loses no data.
@vercel

vercel Bot commented Aug 25, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
publiccode-editor Ready Ready Preview Aug 25, 2026 1:43pm

Request Review

@valeriocomo valeriocomo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@valeriocomo
valeriocomo merged commit 0e6322e into main Aug 25, 2026
9 checks passed
@valeriocomo
valeriocomo deleted the feat/version-gated-fields branch August 25, 2026 14:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants