From ad4dd62cf90f690c94a9ad2e9fa82e6f2a5317d7 Mon Sep 17 00:00:00 2001 From: Jacek Date: Thu, 18 Dec 2025 13:06:18 -0600 Subject: [PATCH 1/3] fix(repo): local astro integration tests --- integration/presets/astro.ts | 6 ++++- integration/presets/utils.ts | 46 ++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+), 1 deletion(-) diff --git a/integration/presets/astro.ts b/integration/presets/astro.ts index e9e310bf5fc..5b6b941485e 100644 --- a/integration/presets/astro.ts +++ b/integration/presets/astro.ts @@ -11,8 +11,12 @@ const astroNode = applicationConfig() .addScript('build', 'pnpm build') .addScript('serve', 'pnpm preview') .addDependency('@clerk/astro', linkPackage('astro')) + .addDependency('@clerk/backend', linkPackage('backend')) .addDependency('@clerk/shared', linkPackage('shared')) - .addDependency('@clerk/localizations', linkPackage('localizations')); + .addDependency('@clerk/localizations', linkPackage('localizations')) + // Resolutions ensure the tarball's transitive dependencies use our local packages + .addResolution('@clerk/backend', linkPackage('backend')) + .addResolution('@clerk/shared', linkPackage('shared')); const astroStatic = astroNode.clone().setName('astro-hybrid').useTemplate(templates['astro-hybrid']); diff --git a/integration/presets/utils.ts b/integration/presets/utils.ts index 21672d16b5b..3a8bcf377c5 100644 --- a/integration/presets/utils.ts +++ b/integration/presets/utils.ts @@ -1,5 +1,45 @@ +import { execSync } from 'node:child_process'; +import fs from 'node:fs'; +import os from 'node:os'; import path from 'node:path'; +// Cache for tarball paths to avoid re-packing the same package +const tarballCache = new Map(); + +// Packages that contain .astro files and cannot be symlinked due to +// Astro's Vite plugin path resolution issues with symlinks +const PACKAGES_REQUIRING_TARBALL = ['astro']; + +/** + * Creates a tarball of a package and returns the file: protocol path to it. + * This is needed for packages containing .astro files because Astro's Vite + * plugin cannot properly resolve paths in symlinked packages. + */ +function createPackageTarball(pkg: string): string { + if (tarballCache.has(pkg)) { + return tarballCache.get(pkg)!; + } + + const pkgPath = path.resolve(process.cwd(), `packages/${pkg}`); + const tmpDir = path.join(os.tmpdir(), '.clerk-integration-tarballs'); + + // Ensure the temp directory exists + fs.mkdirSync(tmpDir, { recursive: true }); + + // Create the tarball + const result = execSync('pnpm pack --pack-destination ' + tmpDir, { + cwd: pkgPath, + encoding: 'utf-8', + }); + + // The output contains the full path to the created tarball + const tgzPath = result.trim().split('\n').pop()!; + const tarballPath = `file:${tgzPath}`; + + tarballCache.set(pkg, tarballPath); + return tarballPath; +} + export function linkPackage(pkg: string, tag?: string) { // eslint-disable-next-line turbo/no-undeclared-env-vars if (process.env.CI === 'true') { @@ -8,5 +48,11 @@ export function linkPackage(pkg: string, tag?: string) { return '*'; } + // For packages with .astro files, use tarballs to avoid symlink issues + // See: https://github.com/withastro/astro/issues/8312 + if (PACKAGES_REQUIRING_TARBALL.includes(pkg)) { + return createPackageTarball(pkg); + } + return `link:${path.resolve(process.cwd(), `packages/${pkg}`)}`; } From 12356fd89a239f1f21ee21f94b3f83d74a7e6a06 Mon Sep 17 00:00:00 2001 From: Jacek Date: Thu, 18 Dec 2025 13:32:51 -0600 Subject: [PATCH 2/3] wip --- integration/presets/utils.ts | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/integration/presets/utils.ts b/integration/presets/utils.ts index 3a8bcf377c5..b776eb91bfe 100644 --- a/integration/presets/utils.ts +++ b/integration/presets/utils.ts @@ -3,11 +3,8 @@ import fs from 'node:fs'; import os from 'node:os'; import path from 'node:path'; -// Cache for tarball paths to avoid re-packing the same package const tarballCache = new Map(); -// Packages that contain .astro files and cannot be symlinked due to -// Astro's Vite plugin path resolution issues with symlinks const PACKAGES_REQUIRING_TARBALL = ['astro']; /** @@ -17,30 +14,27 @@ const PACKAGES_REQUIRING_TARBALL = ['astro']; */ function createPackageTarball(pkg: string): string { if (tarballCache.has(pkg)) { - return tarballCache.get(pkg)!; + return tarballCache.get(pkg); } const pkgPath = path.resolve(process.cwd(), `packages/${pkg}`); const tmpDir = path.join(os.tmpdir(), '.clerk-integration-tarballs'); - // Ensure the temp directory exists fs.mkdirSync(tmpDir, { recursive: true }); - // Create the tarball const result = execSync('pnpm pack --pack-destination ' + tmpDir, { cwd: pkgPath, encoding: 'utf-8', }); - // The output contains the full path to the created tarball - const tgzPath = result.trim().split('\n').pop()!; + const tgzPath = result.trim().split('\n').pop(); const tarballPath = `file:${tgzPath}`; tarballCache.set(pkg, tarballPath); return tarballPath; } -export function linkPackage(pkg: string, tag?: string) { +export function linkPackage(pkg: string) { // eslint-disable-next-line turbo/no-undeclared-env-vars if (process.env.CI === 'true') { // In CI, use '*' to get the latest version from Verdaccio @@ -48,7 +42,6 @@ export function linkPackage(pkg: string, tag?: string) { return '*'; } - // For packages with .astro files, use tarballs to avoid symlink issues // See: https://github.com/withastro/astro/issues/8312 if (PACKAGES_REQUIRING_TARBALL.includes(pkg)) { return createPackageTarball(pkg); From ca710e6a86a00618383ab18ffe387cb9a1d87697 Mon Sep 17 00:00:00 2001 From: Jacek Date: Thu, 18 Dec 2025 13:34:30 -0600 Subject: [PATCH 3/3] chore: empty changeset --- .changeset/bold-spoons-act.md | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .changeset/bold-spoons-act.md diff --git a/.changeset/bold-spoons-act.md b/.changeset/bold-spoons-act.md new file mode 100644 index 00000000000..a845151cc84 --- /dev/null +++ b/.changeset/bold-spoons-act.md @@ -0,0 +1,2 @@ +--- +---