diff --git a/packages/catalog/package.json b/packages/catalog/package.json index ebdb326aa2a..35e62fabf1a 100644 --- a/packages/catalog/package.json +++ b/packages/catalog/package.json @@ -37,10 +37,9 @@ "ember-modify-based-class-resource": "catalog:" }, "scripts": { - "catalog:setup": "([ -d contents ] || git clone git@github.com:cardstack/boxel-catalog.git contents || git clone https://github.com/cardstack/boxel-catalog.git contents || { echo 'both ssh and https clone failed; check GitHub auth and network'; exit 1; }) && pnpm catalog:rewrite-legacy-aliases", - "catalog:update": "sh scripts/catalog-update.sh && pnpm catalog:rewrite-legacy-aliases", + "catalog:setup": "[ -d contents ] || git clone git@github.com:cardstack/boxel-catalog.git contents || git clone https://github.com/cardstack/boxel-catalog.git contents || { echo 'both ssh and https clone failed; check GitHub auth and network'; exit 1; }", + "catalog:update": "sh scripts/catalog-update.sh", "catalog:reset": "rm -rf contents && pnpm catalog:setup", - "catalog:rewrite-legacy-aliases": "node ./scripts/rewrite-legacy-aliases.mjs", "lint": "concurrently \"pnpm:lint:*(!fix)\" --names \"lint:\"", "lint:fix": "concurrently \"pnpm:lint:*:fix\" --names \"fix:\"", "lint:hbs": "ember-template-lint contents --no-error-on-unmatched-pattern", diff --git a/packages/catalog/scripts/rewrite-legacy-aliases.mjs b/packages/catalog/scripts/rewrite-legacy-aliases.mjs deleted file mode 100644 index 5734e836416..00000000000 --- a/packages/catalog/scripts/rewrite-legacy-aliases.mjs +++ /dev/null @@ -1,179 +0,0 @@ -#!/usr/bin/env node -// Temporary shim for CS-10992: boxel-catalog still references some host -// commands and field names that were renamed from URL-flavored to -// identifier-flavored. This script rewrites the cloned `contents/` tree -// in place after catalog:setup / catalog:update / catalog:reset so the -// renamed surface resolves at load time. -// -// Edits are pinned to exact source spans so reruns are no-ops once the -// strings are gone, and unintended matches in unrelated code are -// impossible. Every edit must apply or the script fails loudly. -// -// Once the boxel-catalog PR landing the new surface is merged, delete -// this file and remove its invocation from package.json. Tracked by -// CS-11046. - -import { readFile, writeFile } from 'node:fs/promises'; -import { dirname, join } from 'node:path'; -import { fileURLToPath } from 'node:url'; -import { existsSync } from 'node:fs'; - -const HERE = dirname(fileURLToPath(import.meta.url)); -const ROOT = join(HERE, '..', 'contents'); - -if (!existsSync(ROOT)) { - console.log(`[rewrite-legacy-aliases] ${ROOT} not found, skipping.`); - process.exit(0); -} - -// Each entry is [relativePath, [[oldString, newString], ...]]. -// The old strings include enough context to be unambiguous within the -// file. If `oldString` is missing AND `newString` is already present, -// the edit is a no-op (idempotent). If neither is present, that's a -// failure — the file diverged from what the script expects. -const REWRITES = [ - [ - 'catalog-app/components/listing-fitted.gts', - [ - [ - 'realmMeta.url !== this.args.model[realmURL]?.href,', - 'realmMeta.realmIdentifier !== this.args.model[realmURL]?.href,', - ], - ['url: realmMeta.url,', 'url: realmMeta.realmIdentifier,'], - ], - ], - [ - 'catalog-app/listing/listing.gts', - [ - [ - 'realmMeta.url !== this.args.model[realmURL]?.href,', - 'realmMeta.realmIdentifier !== this.args.model[realmURL]?.href,', - ], - ['url: realmMeta.url,', 'url: realmMeta.realmIdentifier,'], - ], - ], - [ - 'commands/listing-create.ts', - [ - [ - "import GetCatalogRealmUrlsCommand from '@cardstack/boxel-host/commands/get-catalog-realm-urls';", - "import GetCatalogRealmIdentifiersCommand from '@cardstack/boxel-host/commands/get-catalog-realm-identifiers';", - ], - [ - "import GetRealmOfUrlCommand from '@cardstack/boxel-host/commands/get-realm-of-url';", - "import GetRealmOfResourceIdentifierCommand from '@cardstack/boxel-host/commands/get-realm-of-resource-identifier';", - ], - [ - 'const { urls } = await new GetCatalogRealmUrlsCommand(', - 'const { realmIdentifiers: urls } = await new GetCatalogRealmIdentifiersCommand(', - ], - [ - 'const { moduleUrls } = await new SanitizeModuleListCommand(\n this.commandContext,\n ).execute({ moduleUrls: Array.from(modulesToCreate) });', - 'const { moduleIdentifiers: moduleUrls } = await new SanitizeModuleListCommand(\n this.commandContext,\n ).execute({ moduleIdentifiers: Array.from(modulesToCreate) });', - ], - [ - 'const { realmUrl: resourceRealmUrl } = await new GetRealmOfUrlCommand(\n this.commandContext,\n ).execute({ url: resourceUrl });', - 'const { realmIdentifier: resourceRealmUrl } = await new GetRealmOfResourceIdentifierCommand(\n this.commandContext,\n ).execute({ resourceIdentifier: resourceUrl });', - ], - ], - ], - [ - 'commands/listing-install.ts', - [ - [ - 'let { realmUrl } = await new ValidateRealmCommand(\n this.commandContext,\n ).execute({ realmUrl: realm });', - 'let { realmIdentifier: realmUrl } = await new ValidateRealmCommand(\n this.commandContext,\n ).execute({ realmIdentifier: realm });', - ], - [ - '.execute({ url: sourceCard.id });', - '.execute({ cardIdentifier: sourceCard.id });', - ], - [ - '.execute({ realmUrl, operations }));', - '.execute({ realmIdentifier: realmUrl, operations }));', - ], - ], - ], - [ - 'commands/listing-use.ts', - [ - [ - 'let { realmUrl } = await new ValidateRealmCommand(\n this.commandContext,\n ).execute({ realmUrl: realm });', - 'let { realmIdentifier: realmUrl } = await new ValidateRealmCommand(\n this.commandContext,\n ).execute({ realmIdentifier: realm });', - ], - ], - ], - [ - 'commands/listing-remix.ts', - [ - [ - 'let { realmUrl } = await new ValidateRealmCommand(\n this.commandContext,\n ).execute({ realmUrl: realm });', - 'let { realmIdentifier: realmUrl } = await new ValidateRealmCommand(\n this.commandContext,\n ).execute({ realmIdentifier: realm });', - ], - ], - ], - [ - 'commands/listing-update-specs.ts', - [ - [ - 'const { moduleUrls } = await new SanitizeModuleListCommand(\n this.commandContext,\n ).execute({ moduleUrls: deps });', - 'const { moduleIdentifiers: moduleUrls } = await new SanitizeModuleListCommand(\n this.commandContext,\n ).execute({ moduleIdentifiers: deps });', - ], - ], - ], - [ - 'commands/collect-submission-files.ts', - [ - [ - 'let binary = await readBinaryFileCommand.execute({\n url: thumbnailUrl,\n });', - 'let binary = await readBinaryFileCommand.execute({\n fileIdentifier: thumbnailUrl,\n });', - ], - [ - 'let binary = await readBinaryFileCommand.execute({ url: fileDefUrl });', - 'let binary = await readBinaryFileCommand.execute({ fileIdentifier: fileDefUrl });', - ], - ], - ], -]; - -let totalEdits = 0; -let touchedFiles = 0; -let errors = []; - -for (let [relPath, edits] of REWRITES) { - let path = join(ROOT, relPath); - if (!existsSync(path)) { - errors.push(`missing file: ${relPath}`); - continue; - } - let original = await readFile(path, 'utf8'); - let updated = original; - let edited = false; - for (let [oldStr, newStr] of edits) { - if (updated.includes(oldStr)) { - updated = updated.split(oldStr).join(newStr); - edited = true; - totalEdits += 1; - } else if (!updated.includes(newStr)) { - errors.push( - `${relPath}: neither old nor new form found for edit:\n old: ${JSON.stringify(oldStr.slice(0, 80))}...`, - ); - } - // else: already rewritten — idempotent re-run - } - if (edited) { - await writeFile(path, updated); - touchedFiles += 1; - console.log(` rewrote ${relPath}`); - } -} - -if (errors.length) { - console.error('[rewrite-legacy-aliases] errors:'); - for (let e of errors) console.error(' ' + e); - process.exit(1); -} - -console.log( - `[rewrite-legacy-aliases] applied ${totalEdits} edit${totalEdits === 1 ? '' : 's'} across ${touchedFiles} file${touchedFiles === 1 ? '' : 's'}.`, -); diff --git a/packages/host/app/commands/get-available-realm-urls.ts b/packages/host/app/commands/get-available-realm-urls.ts deleted file mode 100644 index c8c621d6b63..00000000000 --- a/packages/host/app/commands/get-available-realm-urls.ts +++ /dev/null @@ -1,5 +0,0 @@ -// Deprecated alias kept for backwards compatibility with cards still -// referencing the old URL-flavored module path. Remove once all -// downstream consumers have been on the renamed path for at least one -// release. Tracked by CS-11046. -export { default } from './get-available-realm-identifiers'; diff --git a/packages/host/app/commands/get-catalog-realm-urls.ts b/packages/host/app/commands/get-catalog-realm-urls.ts deleted file mode 100644 index 37440e1bab4..00000000000 --- a/packages/host/app/commands/get-catalog-realm-urls.ts +++ /dev/null @@ -1,5 +0,0 @@ -// Deprecated alias kept for backwards compatibility with cards still -// referencing the old URL-flavored module path. Remove once all -// downstream consumers have been on the renamed path for at least one -// release. Tracked by CS-11046. -export { default } from './get-catalog-realm-identifiers'; diff --git a/packages/host/app/commands/get-realm-of-url.ts b/packages/host/app/commands/get-realm-of-url.ts deleted file mode 100644 index a380a283161..00000000000 --- a/packages/host/app/commands/get-realm-of-url.ts +++ /dev/null @@ -1,5 +0,0 @@ -// Deprecated alias kept for backwards compatibility with cards still -// referencing the old URL-flavored module path. Remove once all -// downstream consumers have been on the renamed path for at least one -// release. Tracked by CS-11046. -export { default } from './get-realm-of-resource-identifier'; diff --git a/packages/host/app/commands/index.ts b/packages/host/app/commands/index.ts index 6b8d80960d6..a12c2e9db22 100644 --- a/packages/host/app/commands/index.ts +++ b/packages/host/app/commands/index.ts @@ -97,19 +97,6 @@ import * as ValidateRealmCommandModule from './validate-realm'; import * as WriteBinaryFileCommandModule from './write-binary-file'; import * as WriteTextFileCommandModule from './write-text-file'; -// Deprecated URL-flavored aliases kept for backwards compatibility with -// boxel-skills/boxel-catalog cards still referencing the old module -// paths. Each module is a thin re-export of its renamed counterpart. -// Remove this block (imports + shimModule calls below + the .ts files -// themselves) once downstream consumers have been on the renamed paths -// for at least one release. Tracked by CS-11046. -/* eslint-disable import/order */ -import * as GetRealmOfUrlCommandModule from './get-realm-of-url'; -import * as GetAvailableRealmUrlsCommandModule from './get-available-realm-urls'; -import * as GetCatalogRealmUrlsCommandModule from './get-catalog-realm-urls'; -import * as InvalidateRealmUrlsCommandModule from './invalidate-realm-urls'; -/* eslint-enable import/order */ - import type HostBaseCommand from '../lib/host-base-command'; export function shimHostCommands(virtualNetwork: VirtualNetwork) { @@ -501,25 +488,6 @@ export function shimHostCommands(virtualNetwork: VirtualNetwork) { '@cardstack/boxel-host/commands/set-user-system-card', SetUserSystemCardCommandModule, ); - - // Deprecated URL-flavored aliases — see the import-block comment for - // these modules above. Tracked by CS-11046. - virtualNetwork.shimModule( - '@cardstack/boxel-host/commands/get-realm-of-url', - GetRealmOfUrlCommandModule, - ); - virtualNetwork.shimModule( - '@cardstack/boxel-host/commands/get-available-realm-urls', - GetAvailableRealmUrlsCommandModule, - ); - virtualNetwork.shimModule( - '@cardstack/boxel-host/commands/get-catalog-realm-urls', - GetCatalogRealmUrlsCommandModule, - ); - virtualNetwork.shimModule( - '@cardstack/boxel-host/commands/invalidate-realm-urls', - InvalidateRealmUrlsCommandModule, - ); } // Note - this is used for the tests diff --git a/packages/host/app/commands/invalidate-realm-urls.ts b/packages/host/app/commands/invalidate-realm-urls.ts deleted file mode 100644 index dacd52bd93b..00000000000 --- a/packages/host/app/commands/invalidate-realm-urls.ts +++ /dev/null @@ -1,5 +0,0 @@ -// Deprecated alias kept for backwards compatibility with cards still -// referencing the old URL-flavored module path. Remove once all -// downstream consumers have been on the renamed path for at least one -// release. Tracked by CS-11046. -export { default } from './invalidate-realm-identifiers'; diff --git a/packages/host/memory-baseline.json b/packages/host/memory-baseline.json index 318cd20c3a0..04c4e3c117f 100644 --- a/packages/host/memory-baseline.json +++ b/packages/host/memory-baseline.json @@ -303,24 +303,15 @@ "Integration | commands | get-available-realm-identifiers": { "delta_mb": -2.2 }, - "Integration | commands | get-available-realm-urls": { - "delta_mb": -4.3 - }, "Integration | commands | get-catalog-realm-identifiers": { "delta_mb": 0.6 }, - "Integration | commands | get-catalog-realm-urls": { - "delta_mb": -11.9 - }, "Integration | commands | get-default-writable-realm": { "delta_mb": 7 }, "Integration | commands | get-realm-of-resource-identifier": { "delta_mb": 0 }, - "Integration | commands | get-realm-of-url": { - "delta_mb": 0.2 - }, "Integration | commands | get-user-system-card": { "delta_mb": 0.3 }, @@ -330,9 +321,6 @@ "Integration | commands | invalidate-realm-identifiers": { "delta_mb": -16 }, - "Integration | commands | invalidate-realm-urls": { - "delta_mb": -9.9 - }, "Integration | commands | invite-user-to-room": { "delta_mb": 6.1 }, diff --git a/packages/skills-realm/package.json b/packages/skills-realm/package.json index 3767c08608e..712758a2ce2 100644 --- a/packages/skills-realm/package.json +++ b/packages/skills-realm/package.json @@ -3,9 +3,8 @@ "version": "1.0.0", "license": "MIT", "scripts": { - "skills:setup": "([ -d contents ] || (git clone git@github.com:cardstack/boxel-skills.git contents || git clone https://github.com/cardstack/boxel-skills.git contents)) && pnpm skills:rewrite-legacy-aliases", - "skills:update": "pnpm skills:setup && cd contents && git pull && cd .. && pnpm skills:rewrite-legacy-aliases", - "skills:reset": "rm -rf contents && pnpm skills:setup", - "skills:rewrite-legacy-aliases": "node ./scripts/rewrite-legacy-aliases.mjs" + "skills:setup": "[ -d contents ] || git clone git@github.com:cardstack/boxel-skills.git contents || git clone https://github.com/cardstack/boxel-skills.git contents", + "skills:update": "pnpm skills:setup && cd contents && git pull", + "skills:reset": "rm -rf contents && pnpm skills:setup" } } diff --git a/packages/skills-realm/scripts/rewrite-legacy-aliases.mjs b/packages/skills-realm/scripts/rewrite-legacy-aliases.mjs deleted file mode 100644 index 072e948b39a..00000000000 --- a/packages/skills-realm/scripts/rewrite-legacy-aliases.mjs +++ /dev/null @@ -1,71 +0,0 @@ -#!/usr/bin/env node -// Temporary shim for CS-10992: boxel-skills cards reference some host -// commands by their old URL-flavored module paths. This script rewrites -// the cloned `contents/` tree in place so the renamed commands resolve -// when skills are loaded. -// -// Runs after `skills:setup` / `skills:update` / `skills:reset`. Once the -// boxel-skills PR landing the new paths is merged, delete this file -// and remove its invocation from package.json. Tracked by CS-11046. - -import { readdir, readFile, writeFile, stat } from 'node:fs/promises'; -import { join } from 'node:path'; -import { fileURLToPath } from 'node:url'; -import { existsSync } from 'node:fs'; - -const ALIASES = [ - [ - '@cardstack/boxel-host/commands/get-realm-of-url', - '@cardstack/boxel-host/commands/get-realm-of-resource-identifier', - ], - [ - '@cardstack/boxel-host/commands/get-available-realm-urls', - '@cardstack/boxel-host/commands/get-available-realm-identifiers', - ], - [ - '@cardstack/boxel-host/commands/get-catalog-realm-urls', - '@cardstack/boxel-host/commands/get-catalog-realm-identifiers', - ], - [ - '@cardstack/boxel-host/commands/invalidate-realm-urls', - '@cardstack/boxel-host/commands/invalidate-realm-identifiers', - ], -]; - -const ROOT = fileURLToPath(new URL('../contents', import.meta.url)); - -if (!existsSync(ROOT)) { - console.log(`[rewrite-legacy-aliases] ${ROOT} not found, skipping.`); - process.exit(0); -} - -async function* walkJson(dir) { - for (let entry of await readdir(dir)) { - if (entry === '.git') continue; - let full = join(dir, entry); - let s = await stat(full); - if (s.isDirectory()) { - yield* walkJson(full); - } else if (s.isFile() && entry.endsWith('.json')) { - yield full; - } - } -} - -let rewritten = 0; -for await (let path of walkJson(ROOT)) { - let original = await readFile(path, 'utf8'); - let updated = original; - for (let [from, to] of ALIASES) { - updated = updated.split(from).join(to); - } - if (updated !== original) { - await writeFile(path, updated); - rewritten += 1; - console.log(` rewrote ${path}`); - } -} - -console.log( - `[rewrite-legacy-aliases] updated ${rewritten} file${rewritten === 1 ? '' : 's'}.`, -);