@@ -113,6 +113,49 @@ async function mergeEnvFiles(filename, config) {
113113 ) ;
114114}
115115
116+ /**
117+ * Checks if the current working directory contains a lockfile that can be imported with `pnpm import`
118+ * @returns {boolean }
119+ */
120+ function hasSupportedLockfile ( ) {
121+ const SUPPORTED_LOCKFILES = [ 'package-lock.json' , 'yarn.lock' ] ;
122+ for ( const lockfile of SUPPORTED_LOCKFILES ) {
123+ if ( existsSync ( join ( process . cwd ( ) , lockfile ) ) ) {
124+ return true ;
125+ }
126+ }
127+
128+ return false ;
129+ }
130+
131+ /**
132+ * Imports a compatible lockfile with `pnpm import` if present.
133+ * @returns {Promise<void> }
134+ */
135+ async function importPackageLock ( ) {
136+ return new Promise ( ( resolve , reject ) => {
137+ if ( ! hasSupportedLockfile ( ) ) {
138+ resolve ( ) ;
139+ }
140+ console . log ( 'Supported non-pnpm lockfile detected, importing with `pnpm import`...' ) ;
141+
142+ const child = spawn ( 'pnpm' , [ 'import' ] , {
143+ stdio : 'inherit' ,
144+ env : {
145+ ...process . env ,
146+ } ,
147+ } ) ;
148+
149+ child . on ( 'close' , code => {
150+ if ( code !== 0 ) {
151+ reject ( ) ;
152+ return ;
153+ }
154+ resolve ( ) ;
155+ } ) ;
156+ } ) ;
157+ }
158+
116159/**
117160 * Installs the monorepo versions of the Clerk dependencies listed in the `package.json` file of the cwd.
118161 * @returns {Promise<void> }
@@ -128,15 +171,13 @@ async function linkDependencies() {
128171 . filter ( dep => dep in clerkPackages )
129172 . map ( clerkDep => clerkPackages [ clerkDep ] ) ;
130173
131- const args = [ 'install' , '--no-audit' , '--no-fund ', ...dependenciesToBeInstalled ] ;
174+ const args = [ 'add ' , ...dependenciesToBeInstalled ] ;
132175
133176 return new Promise ( ( resolve , reject ) => {
134- const child = spawn ( 'npm ' , args , {
177+ const child = spawn ( 'pnpm ' , args , {
135178 stdio : 'inherit' ,
136179 env : {
137180 ...process . env ,
138- ADBLOCK : '1' ,
139- DISABLE_OPENCOLLECTIVE : '1' ,
140181 } ,
141182 } ) ;
142183
@@ -160,6 +201,7 @@ async function linkDependencies() {
160201export async function setup ( { js = true , skipInstall = false } ) {
161202 if ( ! skipInstall ) {
162203 console . log ( 'Installing monorepo versions of Clerk packages from package.json...' ) ;
204+ await importPackageLock ( ) ;
163205 await linkDependencies ( ) ;
164206 }
165207
0 commit comments