Skip to content

Fix: Add migration scripts for legacy YouTube _media properties (fixes #49)#50

Open
swashbuck wants to merge 3 commits into
masterfrom
issue/49
Open

Fix: Add migration scripts for legacy YouTube _media properties (fixes #49)#50
swashbuck wants to merge 3 commits into
masterfrom
issue/49

Conversation

@swashbuck

Copy link
Copy Markdown
Contributor

Fixes #49

Fix

  • Adds a migrations/ directory (the plugin previously shipped none). The new migration reconciles legacy course content against the current component schema so it imports cleanly into the Adapt Authoring Tool instead of aborting.
  • Coerces _media._aspectRatio from a string (e.g. "1.778") to a number. Non-numeric strings are left untouched so no data is destroyed, and values already stored as numbers are skipped.
  • Normalises _media._progressColor from the stray value "default" (never a member of the schema enum) to "red", matching the modern schema default. Existing "red"/"white" values are left alone.
  • Corrects the legacy properties.schema default for _progressColor from "default" to "red", so the Authoring Tool stops writing the invalid value into new content.

Dependencies

  • Adds semantic-release-replace-plugin so the migration's @@CURRENT_VERSION/@@RELEASE_VERSION placeholders resolve to real version numbers on release. This required bumping semantic-release to ^21.0.1 (the replace plugin's peer requirement), matching other adaptlearning plugins that ship migrations.

Testing

  1. Check out the branch and run the migration test suite against a framework instance: grunt migration:test --file=adapt-youtube.
  2. Confirm all 7 cases pass (4 success, 3 stop).
  3. To verify end to end: build a course with a YouTube component whose _media._aspectRatio is a quoted string, import it into an Authoring Tool instance whose framework types that field as a number, and confirm the import now succeeds without manual JSON edits.

Posted via collaboration with Claude Code

@oliverfoster

oliverfoster commented Jun 25, 2026

Copy link
Copy Markdown
Member
  • Adds a migrations/ directory (the plugin previously shipped none). The new migration reconciles legacy course content against the current component schema so it imports cleanly into the Adapt Authoring Tool instead of aborting.

This needs to be solved elsewhere. It should be fine to have a plugin with no migrations/

@swashbuck

Copy link
Copy Markdown
Contributor Author
  • Adds a migrations/ directory (the plugin previously shipped none). The new migration reconciles legacy course content against the current component schema so it imports cleanly into the Adapt Authoring Tool instead of aborting.

This needs to be solved elsewhere. It should be fine to have a plugin with no migrations/

Do you mean the migration script isn't needed or that the schema default fix should happen in a separate PR?

Add two migration scripts for the adapt-youtube plugin:

- migrations/v1.js: migration from v1.0.2–<1.2.0 to 1.2.0. Renames global _globals._youtube.transcriptButton to skipToTranscript, adds _media._controls and _media._allowFullscreen to youtube components when missing, ensures _transcript exists on components, updates plugin metadata to 1.2.0, and includes unit tests and guards.

- migrations/v2.js: migration from v2.1.0–<2.1.1 to 2.1.1. Adds _media._playsinline (false) to youtube components that have _media but lack _playsinline, updates plugin metadata to 2.1.1, and includes tests and stop conditions.

Both files include checks to validate changes and test cases covering expected and guard scenarios.
@joe-replin

Copy link
Copy Markdown
Contributor

Adding migrations for v1 & v2.
migrations/v1.js — v1.0.2 → v1.2.0 (framework >=3.3): renames _globals._youtube.transcriptButtonskipToTranscript, adds _media._controls, _media._allowFullscreen, and _transcript: {}
migrations/v2.js — v2.1.0 → v2.1.1 (framework >=5.8.0): adds _media._playsinline (guarded so it only touches components that already have a _media object)

Add // @ts-nocheck to the migration file, change direct assignment of _transcript to use _.set for safer mutation, and update a testStopWhere description to clarify that no migration is needed when YouTube components already have the required properties.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Needs Reviewing

Development

Successfully merging this pull request may close these issues.

Add migration scripts

3 participants