From d422b4e2e9f3be3d226064b34677b99245819f23 Mon Sep 17 00:00:00 2001 From: David Sherret Date: Fri, 1 Mar 2024 11:32:19 -0500 Subject: [PATCH 1/2] fix: use hyphens for jsr package exports --- _tools/convert_to_workspace.ts | 23 +++++++++-------------- _tools/packages.ts | 2 +- 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/_tools/convert_to_workspace.ts b/_tools/convert_to_workspace.ts index ba9a3f97a4ad..efa3c10e2148 100644 --- a/_tools/convert_to_workspace.ts +++ b/_tools/convert_to_workspace.ts @@ -97,20 +97,16 @@ for (const { specifier, dependencies } of graph.modules) { const fromPkg = from.split("/")[0]; for (const dep of dependencies ?? []) { if (dep.code) { - const to = relative(cwd, fromFileUrl(dep.code.specifier)).replaceAll( - "\\", - "/", - ); + const to = relative(cwd, fromFileUrl(dep.code.specifier)) + .replaceAll("\\", "/"); const toPkg = to.split("/")[0]; if (fromPkg !== toPkg) { pkgDeps.get(fromPkg)!.add(toPkg); } } if (dep.types) { - const to = relative(cwd, fromFileUrl(dep.types.specifier)).replaceAll( - "\\", - "/", - ); + const to = relative(cwd, fromFileUrl(dep.types.specifier)) + .replaceAll("\\", "/"); const toPkg = to.split("/")[0]; if (fromPkg !== toPkg) { pkgDeps.get(fromPkg)!.add(toPkg); @@ -182,10 +178,8 @@ for await (const entry of walk(cwd)) { const target = relative(cwd, path).replaceAll("\\", "/"); const pkg = target.split("/")[0]; if (pkg === currentPkg) { - let newSpecifier = relative(dirname(entry.path), target).replaceAll( - "\\", - "/", - ); + let newSpecifier = relative(dirname(entry.path), target) + .replaceAll( "\\", "/",); if (!newSpecifier.startsWith(".")) { newSpecifier = "./" + newSpecifier; } @@ -249,9 +243,10 @@ function fixPackageName(pkg: string) { function fixPackagePath(path: string) { const packageName = /^[^/]+/.exec(path); if (packageName) { - return path.replace(packageName[0], fixPackageName(packageName[0])); + return path.replace(packageName[0], fixPackageName(packageName[0])) + .replaceAll("_", "-"); } - return path; + return path.replaceAll("_", "-"); } // Generate `deno.json` file. diff --git a/_tools/packages.ts b/_tools/packages.ts index 1223bee9d05c..92d116b168f4 100644 --- a/_tools/packages.ts +++ b/_tools/packages.ts @@ -50,7 +50,7 @@ async function discoverExports(pkg: string) { if (name.includes("/testdata/")) continue; // testdata files if (name.endsWith("/deno.json")) continue; // deno.json files - const key = "." + name.replace(/\/mod$/, ""); + const key = "." + name.replace(/\/mod$/, "").replaceAll("_", "-"); exports.push([key, "." + path]); } exports.sort((a, b) => a[0].localeCompare(b[0])); From c8d8a41b78738b608ccf4e6b6f618ef3a7e6eb61 Mon Sep 17 00:00:00 2001 From: David Sherret Date: Fri, 1 Mar 2024 11:39:33 -0500 Subject: [PATCH 2/2] Format. --- _tools/convert_to_workspace.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_tools/convert_to_workspace.ts b/_tools/convert_to_workspace.ts index efa3c10e2148..67c6f30c5a96 100644 --- a/_tools/convert_to_workspace.ts +++ b/_tools/convert_to_workspace.ts @@ -179,7 +179,7 @@ for await (const entry of walk(cwd)) { const pkg = target.split("/")[0]; if (pkg === currentPkg) { let newSpecifier = relative(dirname(entry.path), target) - .replaceAll( "\\", "/",); + .replaceAll("\\", "/"); if (!newSpecifier.startsWith(".")) { newSpecifier = "./" + newSpecifier; }