Skip to content

Commit 92cdd95

Browse files
jrolfsclaude
andcommitted
fix(fork): create repository field when a package omits it
The editor package has no repository field at source, so the relink (which only modified an existing field) skipped it — leaving @<scope>/pascal-editor unlinked from the fork. Create the field when absent so every package links, including its monorepo directory. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 33d1523 commit 92cdd95

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

scripts/publish-fork.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,17 @@ const rewriteScope = (dir: string): void => {
5656
/**
5757
* Point the packed package's repository.url at the publishing fork so GitHub
5858
* Packages links the package to this repo. The source field still points at
59-
* upstream (pascalorg/editor); only the published artifact is changed.
59+
* upstream (pascalorg/editor); only the published artifact is changed. Creates
60+
* the field when a package omits it (e.g. editor), so every package links.
6061
*/
61-
const relinkRepository = (packageDir: string, repo: string): void => {
62+
const relinkRepository = (packageDir: string, repo: string, directory: string): void => {
6263
const manifestPath = join(packageDir, "package.json");
6364
const manifest = JSON.parse(readFileSync(manifestPath, "utf8"));
64-
if (!manifest.repository) return;
6565
const url = `https://github.com/${repo}.git`;
6666
manifest.repository =
67-
typeof manifest.repository === "string" ? url : { ...manifest.repository, url };
67+
typeof manifest.repository === "string"
68+
? url
69+
: { type: "git", ...manifest.repository, url, directory };
6870
writeFileSync(manifestPath, `${JSON.stringify(manifest, null, 2)}\n`);
6971
};
7072

@@ -97,7 +99,7 @@ for (const dir of readdirSync("packages")) {
9799

98100
const packed = join(work, "package");
99101
rewriteScope(packed);
100-
if (GITHUB_REPOSITORY) relinkRepository(packed, GITHUB_REPOSITORY);
102+
if (GITHUB_REPOSITORY) relinkRepository(packed, GITHUB_REPOSITORY, `packages/${dir}`);
101103

102104
if (DRY_RUN) {
103105
console.log(`→ [dry-run] ${tag}`);

0 commit comments

Comments
 (0)