Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
94 commits
Select commit Hold shift + click to select a range
399c188
docs(gamut-docs): add the color system concept page
dreamwasp Oct 29, 2026
ed1f8a6
docs(gamut-docs): list the rebuilt admin, platform, percipio and lxSt…
dreamwasp Oct 29, 2026
e5165c3
Merge branch 'cass-gmt-1825-color-legacy-brands' into cass-gmt-1825-c…
dreamwasp Oct 29, 2026
41c22f7
docs(gamut-docs): navy and beige unpinned; status alerts carry their ink
dreamwasp Oct 29, 2026
fcd29d1
docs(gamut-docs): percipioTheme is removed; five brands ship
dreamwasp Nov 4, 2026
f11a9dd
Merge remote-tracking branch 'origin/cass-gmt-1825-color-legacy-brand…
dreamwasp Nov 4, 2026
fe7333e
docs(gamut-docs): color system page follows design's sandbox update
dreamwasp Nov 4, 2026
0c54a72
Merge cass-gmt-1825-color-legacy-brands into cass-gmt-1825-color-docs
dreamwasp Nov 4, 2026
bdab784
docs(gamut-docs): skillsoftTheme replaces percipioTheme; 204 componen…
dreamwasp Nov 4, 2026
1f4d7fa
Merge branch 'cass-gmt-1825-color-legacy-brands' into cass-gmt-1825-c…
dreamwasp Nov 4, 2026
2d9af71
Merge remote-tracking branch 'origin/cass-gmt-1825-color-legacy-brand…
dreamwasp Nov 4, 2026
75a06be
Merge branch 'cass-gmt-1825-color-white-label' into cass-gmt-1825-col…
dreamwasp Nov 5, 2026
ed87041
docs(gamut-docs): color system page covers per-brand CSS and building…
dreamwasp Nov 5, 2026
ab01baf
Merge branch 'cass-gmt-1825-color-white-label' into cass-gmt-1825-col…
dreamwasp Nov 5, 2026
47d1213
Merge branch 'cass-gmt-1825-color-docs' into cass-gmt-1825-color-site
dreamwasp Nov 5, 2026
5086aa2
docs(gamut-docs): move the docs site onto the color system
dreamwasp Nov 5, 2026
3e08400
refactor: use the singular --color- prefix for color variables
dreamwasp Nov 10, 2026
c30e2cb
refactor: use the singular --color- prefix for color variables
dreamwasp Nov 10, 2026
6590fa7
Merge remote-tracking branch 'origin/cass-gmt-1825-color-legacy-brand…
dreamwasp Nov 10, 2026
c737460
fix(gamut-styles): preload each font file once
dreamwasp Nov 13, 2026
ef89118
fix(gamut-styles): preload each font file once
dreamwasp Nov 13, 2026
069f6f1
docs(gamut-agent-tools): cover color-roles in the scope-swap skill
dreamwasp Nov 18, 2026
841147d
docs(gamut-agent-tools): cover color-roles in the scope-swap skill
dreamwasp Nov 18, 2026
1b5a4fc
docs(gamut-agent-tools): rename the scope-swap skill to gamut-migrati…
dreamwasp Nov 18, 2026
ee7f571
docs(gamut-agent-tools): point the README at the gamut-migration skill
dreamwasp Nov 18, 2026
7712bcd
docs(gamut-agent-tools): drop a duplicated sentence in the migration …
dreamwasp Nov 18, 2026
312dd33
docs(gamut-agent-tools): rename the scope-swap skill to gamut-migrati…
dreamwasp Nov 18, 2026
c7e9801
docs(gamut-agent-tools): point the README at the gamut-migration skill
dreamwasp Nov 18, 2026
6195ab8
docs(gamut-agent-tools): drop a duplicated sentence in the migration …
dreamwasp Nov 18, 2026
8124769
docs(gamut-codemods): point the README at the gamut-migration skill
dreamwasp Nov 18, 2026
33bfc9a
feat(gamut-codemods): add required peers to scope-swap
dreamwasp Nov 18, 2026
10834c5
docs(gamut-agent-tools): cover the migration gaps in the gamut-migrat…
dreamwasp Nov 18, 2026
4b7f0ea
docs(gamut-agent-tools): cover the migration gaps in the gamut-migrat…
dreamwasp Nov 18, 2026
fe13dfa
docs(gamut-codemods): document the added peers
dreamwasp Nov 18, 2026
c43cce4
docs(gamut-agent-tools): explain the palette defaults in the gamut-mi…
dreamwasp Nov 19, 2026
f916969
docs(gamut-agent-tools): explain the palette defaults in the gamut-mi…
dreamwasp Nov 19, 2026
25b3269
docs(gamut-agent-tools): add hyper and yellow guidance to the gamut-m…
dreamwasp Nov 19, 2026
0f0b2b8
docs(gamut-agent-tools): add hyper and yellow guidance to the gamut-m…
dreamwasp Nov 19, 2026
cf98537
docs(gamut-agent-tools): add blue-500 guidance to the gamut-migration…
dreamwasp Nov 19, 2026
b97fc5c
docs(gamut-agent-tools): add blue-500 guidance to the gamut-migration…
dreamwasp Nov 19, 2026
a7dc219
docs(gamut-agent-tools): work through open color decisions with the u…
dreamwasp Nov 19, 2026
45df730
docs(gamut-agent-tools): work through open color decisions with the u…
dreamwasp Nov 19, 2026
3de67b7
docs(gamut-agent-tools): stop adding stylis by hand; cover the duplic…
dreamwasp Nov 20, 2026
eeb48e1
docs(gamut-agent-tools): stop adding stylis by hand; cover the duplic…
dreamwasp Nov 20, 2026
affc466
fix(gamut-codemods): stop adding stylis as a peer
dreamwasp Nov 20, 2026
9adb2a9
docs(gamut-agent-tools): add Video peers only for apps that import Video
dreamwasp Nov 20, 2026
be2a19d
docs(gamut-agent-tools): add Video peers only for apps that import Video
dreamwasp Nov 20, 2026
366f13e
feat(gamut-codemods): add vidstack and react-player only for apps tha…
dreamwasp Nov 20, 2026
284d888
docs(gamut-codemods): the Video peers apply only to apps that import …
dreamwasp Nov 20, 2026
7971516
Merge branch 'stack-white' into stack-docs
dreamwasp Nov 20, 2026
c1ce7f0
Merge branch 'stack-behavior' into stack-site
dreamwasp Nov 20, 2026
ed6e005
Merge branch 'stack-docs' into stack-site
dreamwasp Nov 20, 2026
cc84dcd
merge: bring the behavior and docs layers into the site branch
dreamwasp Nov 20, 2026
1a45c88
Merge remote-tracking branch 'origin/main' into stack-docs
dreamwasp Nov 20, 2026
68f96a0
Merge remote-tracking branch 'origin/main' into stack-site
dreamwasp Nov 20, 2026
947de85
Merge branch 'stack-behavior' into stack-site
dreamwasp Nov 20, 2026
00400bb
Merge branch 'stack-docs' into stack-site
dreamwasp Nov 20, 2026
e9607d3
Merge branch 'stack-white' into stack-docs
dreamwasp Nov 20, 2026
e998634
Merge branch 'stack-behavior' into stack-site
dreamwasp Nov 20, 2026
a59e9b0
Merge branch 'stack-behavior' into stack-site
dreamwasp Nov 20, 2026
7dc4381
Merge remote-tracking branch 'origin/main' into stack-docs
dreamwasp Nov 20, 2026
2728b83
Merge remote-tracking branch 'origin/main' into stack-site
dreamwasp Nov 20, 2026
a55ade6
Merge branch 'stack-behavior' into stack-site
dreamwasp Nov 20, 2026
7182867
Merge branch 'stack-white' into stack-docs
dreamwasp Nov 20, 2026
c5dfcb8
Merge branch 'stack-docs' into stack-site
dreamwasp Nov 20, 2026
404f3a8
Merge branch 'stack-white' into stack-docs
dreamwasp Nov 20, 2026
b26083a
Merge branch 'stack-behavior' into stack-site
dreamwasp Nov 20, 2026
fd29895
Merge branch 'stack-docs' into stack-site
dreamwasp Nov 20, 2026
111c48e
Merge branch 'stack-behavior' into stack-site
dreamwasp Nov 20, 2026
8be6a9d
Merge branch 'stack-docs' into stack-site
dreamwasp Nov 20, 2026
11c1e5b
Merge branch 'stack-white' into stack-docs
dreamwasp Nov 20, 2026
24437f5
Merge branch 'stack-behavior' into stack-site
dreamwasp Nov 20, 2026
5227597
style(badge): use the warning ramp for the yellow gradient stop
dreamwasp Nov 23, 2026
479a0e3
Merge commit '32e726434' into stack-site
dreamwasp Nov 23, 2026
c777e81
Merge commit '32e726434' into stack-docs
dreamwasp Nov 23, 2026
cb5826a
Merge branch 'cass-gmt-1825-color-site' of github.com:Codecademy/skil…
dreamwasp Nov 24, 2026
b7ad33e
feat(gamut-docs): load skillsoft theme fonts on the docs site
dreamwasp Nov 30, 2026
f1235eb
Merge branch 'cass-gmt-1825-color-white-label' into cass-gmt-1825-col…
dreamwasp Dec 1, 2026
414010e
Merge branch 'cass-gmt-1825-color-behavior' into cass-gmt-1825-color-…
dreamwasp Dec 1, 2026
dab7ff6
Merge branch 'cass-gmt-1825-color-docs' into cass-gmt-1825-color-site
dreamwasp Dec 1, 2026
4092e13
docs(gamut-docs): add disabled fields to the color system's role table
dreamwasp Dec 1, 2026
879e11c
Merge branch 'cass-gmt-1825-color-docs' into cass-gmt-1825-color-site
dreamwasp Dec 1, 2026
7003c4f
Merge branch 'cass-gmt-1825-color-behavior' into cass-gmt-1825-color-…
dreamwasp Dec 1, 2026
2d73ebf
Merge branch 'cass-gmt-1825-color-behavior' into cass-gmt-1825-color-…
dreamwasp Dec 2, 2026
f4ec813
merge: bring the updated behavior into site
dreamwasp Dec 2, 2026
c00b544
merge: bring cass-gmt-1825-color-behavior into cass-gmt-1825-color-site
dreamwasp Dec 2, 2026
25d6a79
merge: bring cass-gmt-1825-color-behavior into site
dreamwasp Dec 2, 2026
4b4c162
Merge remote-tracking branch 'origin/cass-gmt-1825-color-behavior' in…
dreamwasp Dec 3, 2026
1f79f5f
Merge remote-tracking branch 'origin/cass-gmt-1825-color-behavior' in…
dreamwasp Dec 3, 2026
6e5aafd
Merge remote-tracking branch 'origin/cass-gmt-1825-color-behavior' in…
dreamwasp Dec 3, 2026
25d5e00
Merge remote-tracking branch 'origin/cass-gmt-1825-color-behavior' in…
dreamwasp Dec 3, 2026
36ef9ef
Merge remote-tracking branch 'origin/cass-gmt-1825-color-behavior' in…
dreamwasp Dec 3, 2026
700830d
merge: bring the brand override fixes from white-label (from cass-gmt…
dreamwasp Dec 4, 2026
24e9986
Merge remote-tracking branch 'origin/cass-gmt-1825-color-behavior' in…
dreamwasp Dec 4, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion packages/gamut-codemods/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ Each preset is one upgrade. Run them in order if you're more than one behind.

`npx @skillsoft/gamut-codemods list` shows every preset and the migrations inside it.

The `gamut-migration` agent skill in [`@skillsoft/gamut-agent-tools`](../gamut-agent-tools/README.md) covers every preset: what each one reports, what it leaves for a person, and how to check the result. Read it alongside the preset's section here.

## Running scope-swap

Start from a clean working tree. The codemod won't write into uncommitted changes (pass `--force` to override), so `git checkout .` always undoes a run.
Expand Down Expand Up @@ -62,7 +64,7 @@ Every skillsoft-gamut pull request publishes installable previews through pkg.pr
| `mf-shared` | Replaces `@codecademy/gamut-kit` in Module Federation `shared` config with the packages it bundled. Gamut becomes a real singleton, so test the host and remotes together. |
| `eslint-comments` | `// eslint-disable-next-line gamut/x` → `@skillsoft/gamut/x`. |
| `scope-rename` | Every `@codecademy/gamut*` module string becomes `@skillsoft/gamut*`: imports, exports, `require`, `import()`, `jest.mock`/`vi.mock`, `declare module`, and `import('x').T`. Also exact package-name strings elsewhere, like `transpilePackages`, with one warning per file, and package names in comments (`/dist` paths and removed packages are left for the leftovers). |
| `package-json` | Renames dependencies and sets their versions. A new package that's already listed keeps its value (a preview URL, say), and a `*` peer range stays `*`. Replaces `@codecademy/gamut-kit` with the individual packages. |
| `package-json` | Renames dependencies and sets their versions. A new package that's already listed keeps its value (a preview URL, say), and a `*` peer range stays `*`. It also adds the peers the new packages need and don't install: `@vidstack/react` and `react-player`, only when the app imports `Video` from gamut and doesn't list the peer. Replaces `@codecademy/gamut-kit` with the individual packages. |
| `eslint-config` | `.eslintrc` / `.eslintrc.json`: plugin name, `plugin:` extends, and rule keys. |
| `mdx-imports` | Runs the migrations above over `import`/`export` statements in `.mdx` files. Fenced code blocks are left alone. |
| `yarnrc` | `.yarnrc.yml` list items, like `npmPreapprovedPackages`: renames old package names, or drops them if a glob like `'@skillsoft/*'` already covers the new one. |
Expand Down Expand Up @@ -127,6 +129,8 @@ Two rules hold it together:

Create `src/presets/<name>/` with a manifest and an `index.ts`, register it in `src/presets/index.ts`, and reuse migrations from `src/migrations`.

Then document it in the `gamut-migration` skill (`packages/gamut-agent-tools/skills/gamut-migration/SKILL.md`): a row in its Presets table and a `## Preset: <name>` section. Add the same preset to the table at the top of this README. The skill's "Adding a preset" section lists what to cover.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

good to know, I'll update the prop name stack to include this info!


### recast gotchas already hit

- Rebuild specifiers instead of mutating them. Changing `imported` on `import { List }` drops the alias, because `imported` and `local` share one source range.
Expand Down
35 changes: 19 additions & 16 deletions packages/gamut-codemods/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,10 @@ import path from 'node:path';

import jscodeshift from 'jscodeshift';

import { findFlatEslintConfig } from './lib/eslint';
import { gamutUsage, videoUsage } from './lib/gamut-imports';
import { dirtyTreeReason } from './lib/git';
import { findLeftovers, walk } from './lib/leftovers';
import {
activeSourceMigrations,
mentionsOldNames,
runSourceMigrations,
} from './lib/run-source';
import { GENERATED_FILES, SKIP_DIRS, walk } from './lib/leftovers';
import { activeSourceMigrations, runSourceMigrations } from './lib/run-source';
import type { FileMigration, Preset } from './lib/types';
import { getPreset, presets } from './presets';

Expand Down Expand Up @@ -72,17 +68,19 @@ export const parseArgs = (argv: string[]): Options | 'help' | 'list' => {
const heading = (text: string) => console.log(`\n— ${text} —`);

const runFileMigrations = (
preset: Preset,
preset: Preset<any>,
opts: Options,
note: (key: string) => void
) => {
const only = opts.only ? new Set(opts.only.split(',')) : null;
const skip = new Set(opts.skip ? opts.skip.split(',') : []);
const active = preset.migrations.filter(
(m): m is FileMigration =>
(m): m is FileMigration<any> =>
m.kind === 'file' && (!only || only.has(m.name)) && !skip.has(m.name)
);
let changed = 0;
const usesGamut = gamutUsage();
const usesVideo = videoUsage();

for (const root of opts.paths) {
const files = fs.statSync(root).isDirectory() ? walk(root) : [root];
Expand All @@ -93,7 +91,7 @@ const runFileMigrations = (
const warn = (msg: string) =>
console.log(`[${migration.name}] ${file} ${msg}`);
const transformSource = (code: string) =>
mentionsOldNames(preset.manifest, code)
preset.mentions(code)
? runSourceMigrations({
j: jscodeshift.withParser('tsx'),
source: code,
Expand All @@ -113,6 +111,8 @@ const runFileMigrations = (
manifest: preset.manifest,
warn,
note,
usesGamut: () => usesGamut(file),
usesVideo: () => usesVideo(file),
transformSource,
});
if (next === null) continue;
Expand All @@ -125,7 +125,7 @@ const runFileMigrations = (
return changed;
};

const printChecklist = (preset: Preset, notes: Set<string>) => {
const printChecklist = (preset: Preset<any>, notes: Set<string>) => {
heading('next steps');
const items = [
...Object.entries(preset.conditionalChecklist)
Expand Down Expand Up @@ -194,7 +194,12 @@ export const main = async (argv: string[]) => {
dry: opts.dry,
extensions: 'ts,tsx,js,jsx,mjs,cjs,mts,cts',
/* .d.ts stays in: Emotion theme augmentations import gamut-styles. */
ignorePattern: ['**/node_modules/**', '**/dist/**', '**/build/**'],
/* Same list as the leftovers walk: build output and caches, which hold
minified bundles that aren't source and won't parse. */
ignorePattern: [
...[...SKIP_DIRS].map((dir) => `**/${dir}/**`),
...[...GENERATED_FILES].map((file) => `**/${file}`),
],
parser: 'tsx',
babel: false,
verbose: 0,
Expand All @@ -213,10 +218,8 @@ export const main = async (argv: string[]) => {
heading(
'leftovers skipped in --dry (nothing was written, so everything would show up)'
);
} else if (opts.report) {
const hits = findLeftovers(opts.paths, preset.manifest, {
eslintRuleKeys: !findFlatEslintConfig(opts.paths),
});
} else if (opts.report && preset.leftovers) {
const hits = preset.leftovers(opts.paths);
heading(`leftovers (${hits.length})`);
hits.forEach((hit) =>
console.log(
Expand Down
58 changes: 58 additions & 0 deletions packages/gamut-codemods/src/lib/gamut-imports.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import fs from 'node:fs';
import path from 'node:path';

import { walk } from './leftovers';

/*
Whether the source under a directory imports gamut, under either scope or
any of its subpaths. A worker in a repo that also has a gamut app never
imports it, and warnings about gamut's behaviour don't apply there.
*/
const SOURCE = /\.(m?[jt]sx?|c[jt]s|mdx?)$/;
const GAMUT_SPECIFIER = /['"`](?:@codecademy|@skillsoft)\/gamut[\w./-]*['"`]/;

const GAMUT_VIDEO_PATH =
/['"`](?:@codecademy|@skillsoft)\/gamut\/Video[\w/-]*['"`]/;
const IMPORT =
/import\s[^;]*?from\s*['"`]((?:@codecademy|@skillsoft)\/gamut[\w./-]*)['"`]/g;
const VIDEO_NAME = /\b(?:Video|VideoProps|MarkdownVideo)\b/;

/* True when the file imports a Video name from gamut, or reaches the Video subpath. */
const usesVideoIn = (source: string) => {
if (GAMUT_VIDEO_PATH.test(source)) return true;
for (const match of source.matchAll(IMPORT)) {
const clause = match[0].slice(0, match[0].lastIndexOf('from'));
if (VIDEO_NAME.test(clause)) return true;
}
return false;
};

const containsGamut = (dir: string, test: (source: string) => boolean) => {
for (const file of walk(dir)) {
if (!SOURCE.test(file)) continue;
if (test(fs.readFileSync(file, 'utf8'))) return true;
}
return false;
};

const memoizedPer = (test: (source: string) => boolean) => {
const seen = new Map<string, boolean>();
return (file: string) => {
const dir = path.dirname(file);
let known = seen.get(dir);
if (known === undefined) {
known = containsGamut(dir, test);
seen.set(dir, known);
}
return known;
};
};

export const videoUsage = () => memoizedPer(usesVideoIn);

/*
One check per run: each directory is walked once, however many files in
it ask. The CLI makes one of these and hands each file a closure over it.
*/
export const gamutUsage = () =>
memoizedPer((source) => GAMUT_SPECIFIER.test(source));
11 changes: 10 additions & 1 deletion packages/gamut-codemods/src/lib/leftovers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,15 @@ export const SKIP_DIRS = new Set([
'.nx',
'tmp',
]);
/*
Generated by a tool and rebuilt on demand, so nobody edits them by hand.
worker-configuration.d.ts is `wrangler types`: a Babel bug rejects its
`declare module` block, and it has no color names to rewrite anyway.
*/
export const GENERATED_FILES = new Set([
'worker-configuration.d.ts',
'next-env.d.ts',
]);
const SKIP_FILES =
/(^|\/)(yarn\.lock|package-lock\.json|pnpm-lock\.yaml|CHANGELOG\.md)$/;
/* .mdc is Cursor rules; .code-snippets is VS Code snippets (JSONC). */
Expand Down Expand Up @@ -72,7 +81,7 @@ export function* walk(dir: string): Generator<string> {
for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
if (entry.isDirectory()) {
if (!SKIP_DIRS.has(entry.name)) yield* walk(path.join(dir, entry.name));
} else {
} else if (!GENERATED_FILES.has(entry.name)) {
yield path.join(dir, entry.name);
}
}
Expand Down
15 changes: 15 additions & 0 deletions packages/gamut-codemods/src/lib/manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,21 @@ export interface Manifest {
the new package doesn't have yet; package-json warns.
*/
sourceVersions: Record<string, string>;
/*
Peers the packages in `when` declare and need at runtime. The new
packages don't install them, so package-json adds them to an app that
depends on one of those packages. `when` uses OLD names, like the rest
of the manifest; manifest.test.ts checks `range` against the source.
*/
requiredPeers: Record<
string,
{
range: string;
when: string[];
/* Only when the app imports Video, which is the one thing that loads these. */
video?: boolean;
}
>;
movedExports: MovedExport[];
deepImports: DeepImport[];
/* ESLint plugin prefix, for rule keys, `plugin:` extends, and comments. */
Expand Down
53 changes: 37 additions & 16 deletions packages/gamut-codemods/src/lib/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { Collection, JSCodeshift } from 'jscodeshift';

import type { Leftover } from './leftovers';
import type { Manifest } from './manifest';

/* Anything with a source location, so warnings can point at a line. */
Expand All @@ -16,11 +17,15 @@ export type Warn = (node: Locatable, message: string) => void;
*/
export type Note = (checklistKey: string) => void;

export interface SourceContext {
/*
`M` is the preset's manifest type. It defaults to scope-swap's Manifest, so
migrations written for that preset don't name it.
*/
export interface SourceContext<M = Manifest> {
j: JSCodeshift;
root: Collection;
source: string;
manifest: Manifest;
manifest: M;
warn: Warn;
note: Note;
}
Expand All @@ -31,40 +36,40 @@ export interface Edit {
text: string;
}

interface MigrationBase {
interface MigrationBase<M = Manifest> {
name: string;
description: string;
/*
Checked once per run, before any file is touched. Return a reason to
skip this migration for the whole run (the CLI prints it and notes
`skipped:<name>`), or null to run it.
*/
skipReason?(roots: string[], manifest: Manifest): string | null;
skipReason?(roots: string[], manifest: M): string | null;
}

/*
Mutates the shared AST. Use for structural rewrites only: recast reprints
whatever it thinks changed, and in semicolon-less files that has spread to
neighbouring statements. Return true if anything changed.
*/
export interface AstMigration extends MigrationBase {
export interface AstMigration<M = Manifest> extends MigrationBase<M> {
kind: 'ast';
run(ctx: SourceContext): boolean;
run(ctx: SourceContext<M>): boolean;
/* Formatting fixes on the printed output that the AST can't express. */
postPrint?(source: string, ctx: { manifest: Manifest }): string;
postPrint?(source: string, ctx: { manifest: M }): string;
}

/*
Uses the AST to find ranges, then edits the original text by offset. The
default for anything that swaps one string for another.
*/
export interface SpliceMigration extends MigrationBase {
export interface SpliceMigration<M = Manifest> extends MigrationBase<M> {
kind: 'splice';
edits(ctx: SourceContext): Edit[];
edits(ctx: SourceContext<M>): Edit[];
}

/* Gets raw text for non-source files (package.json, .eslintrc, .mdx). */
export interface FileMigration extends MigrationBase {
export interface FileMigration<M = Manifest> extends MigrationBase<M> {
kind: 'file';
/*
Not `match`: CodeQL reads `migration.match(file)` as
Expand All @@ -73,9 +78,16 @@ export interface FileMigration extends MigrationBase {
appliesTo(path: string): boolean;
run(ctx: {
source: string;
manifest: Manifest;
manifest: M;
warn: (message: string) => void;
note: Note;
/*
Whether the source under this file's directory imports gamut. For
warnings that only matter where gamut is used, like a worker's tsconfig.
*/
usesGamut: () => boolean;
/* Whether the source under this file's directory imports Video from gamut. */
usesVideo: () => boolean;
/*
Runs the preset's source migrations (respecting --only) over a
snippet of JS/TS, for files that embed code, like MDX's ESM blocks.
Expand All @@ -84,15 +96,24 @@ export interface FileMigration extends MigrationBase {
}): string | null;
}

export type SourceMigration = AstMigration | SpliceMigration;
export type Migration = SourceMigration | FileMigration;
export type SourceMigration<M = Manifest> =
| AstMigration<M>
| SpliceMigration<M>;
export type Migration<M = Manifest> = SourceMigration<M> | FileMigration<M>;

export interface Preset {
export interface Preset<M = Manifest> {
name: string;
description: string;
manifest: Manifest;
manifest: M;
/*
The cheap pre-filter every caller uses, so big repos don't parse every
file: false means no migration in this preset could change `source`.
*/
mentions(source: string): boolean;
/* After a write run, what's left for a person. Omit for no report. */
leftovers?(roots: string[]): Leftover[];
/* Run in order. All `ast` migrations must come before any `splice` one. */
migrations: Migration[];
migrations: Migration<M>[];
/* Printed at the end of every run. */
checklist: string[];
/* Printed only when a migration calls note(key). */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
"@skillsoft/gamut-patterns": "^{{version}}",
"@skillsoft/gamut-styles": "^{{version}}",
"@skillsoft/gamut-tests": "^{{version}}",
"@skillsoft/variance": "^{{version}}"
"@skillsoft/variance": "^{{version}}",
"@vidstack/react": "~1.12.12",
"react-player": "^3.4.0"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
"@skillsoft/gamut-styles": "^{{version}}",
"@skillsoft/gamut-tests": "^{{version}}",
"@skillsoft/variance": "^{{version}}",
"react": "^19.0.0"
"@vidstack/react": "~1.12.12",
"react": "^19.0.0",
"react-player": "^3.4.0"
},
"devDependencies": {
"@skillsoft/eslint-plugin-gamut": "^0.0.1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
"name": "app",
"dependencies": {
"@skillsoft/gamut": "^{{version}}",
"@skillsoft/gamut-styles": "^{{version}}"
"@skillsoft/gamut-styles": "^{{version}}",
"@vidstack/react": "~1.12.12",
"react-player": "^3.4.0"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
"name": "lib",
"peerDependencies": {
"@skillsoft/gamut": "*",
"@skillsoft/gamut-styles": "^{{version}}"
"@skillsoft/gamut-styles": "^{{version}}",
"@vidstack/react": "~1.12.12",
"react-player": "^3.4.0"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "app",
"dependencies": {
"@codecademy/gamut": "^73.0.0",
"react": "^18.3.0"
}
}
Loading
Loading