11import { execSync } from 'node:child_process' ;
2- import { existsSync , mkdtempSync , readdirSync , rmSync , symlinkSync } from 'node:fs' ;
2+ import {
3+ existsSync ,
4+ mkdtempSync ,
5+ readFileSync ,
6+ readdirSync ,
7+ rmSync ,
8+ symlinkSync ,
9+ writeFileSync ,
10+ } from 'node:fs' ;
311import os from 'node:os' ;
412import path from 'node:path' ;
513import { fileURLToPath } from 'node:url' ;
@@ -78,8 +86,9 @@ export function installGlobalCli() {
7886 VITE_PLUS_HOME : installDir ,
7987 VITE_PLUS_VERSION : 'local-dev' ,
8088 CI : 'true' ,
81- // Skip vp install in install.sh — we set up node_modules manually below
82- // because workspace:* deps resolve to 0.0.0 which don't exist on npm
89+ // Skip vp install in install.sh — we handle deps ourselves:
90+ // - Local dev: symlink monorepo node_modules
91+ // - CI (--tgz): rewrite @voidzero-dev/* deps to file: protocol and npm install
8392 VITE_PLUS_SKIP_DEPS_INSTALL : '1' ,
8493 } ;
8594
@@ -103,7 +112,11 @@ export function installGlobalCli() {
103112 // Set up node_modules for local dev by rewriting workspace deps to file: protocol
104113 // and running pnpm install. Production installs use `vp install` in install.sh directly.
105114 const versionDir = path . join ( installDir , 'local-dev' ) ;
106- setupLocalDevDeps ( versionDir ) ;
115+ if ( values . tgz ) {
116+ installCiDeps ( versionDir , tgzPath ) ;
117+ } else {
118+ setupLocalDevDeps ( versionDir ) ;
119+ }
107120 } finally {
108121 // Cleanup temp dir only if we created it
109122 if ( tempDir ) {
@@ -135,10 +148,46 @@ function findVpBinary(binaryName: string) {
135148 return null ;
136149}
137150
151+ /**
152+ * Install dependencies for CI by rewriting @voidzero-dev/* deps to file: protocol
153+ * pointing at sibling tgz files, then running npm install.
154+ */
155+ function installCiDeps ( versionDir : string , mainTgzPath : string ) {
156+ const pkgJsonPath = path . join ( versionDir , 'package.json' ) ;
157+ const pkg = JSON . parse ( readFileSync ( pkgJsonPath , 'utf-8' ) ) ;
158+ const deps : Record < string , string > = pkg . dependencies ?? { } ;
159+ const tgzDir = path . dirname ( mainTgzPath ) ;
160+
161+ let modified = false ;
162+ for ( const [ name , version ] of Object . entries ( deps ) ) {
163+ if ( ! name . startsWith ( '@voidzero-dev/' ) ) {
164+ continue ;
165+ }
166+ // @voidzero -dev/vite-plus-core@0.0.0 -> voidzero-dev-vite-plus-core-0.0.0.tgz
167+ const tgzName = name . replace ( '@' , '' ) . replace ( '/' , '-' ) + `-${ version } .tgz` ;
168+ const tgzFilePath = path . join ( tgzDir , tgzName ) ;
169+ if ( ! existsSync ( tgzFilePath ) ) {
170+ console . warn ( `Warning: tgz not found for ${ name } @${ version } : ${ tgzFilePath } ` ) ;
171+ continue ;
172+ }
173+ deps [ name ] = `file:${ tgzFilePath } ` ;
174+ modified = true ;
175+ console . log ( ` ${ name } : ${ version } -> file:${ tgzFilePath } ` ) ;
176+ }
177+
178+ if ( modified ) {
179+ writeFileSync ( pkgJsonPath , JSON . stringify ( pkg , null , 2 ) + '\n' ) ;
180+ }
181+
182+ execSync ( 'npm install --no-audit --no-fund --legacy-peer-deps' , {
183+ cwd : versionDir ,
184+ stdio : 'inherit' ,
185+ } ) ;
186+ }
187+
138188/**
139189 * Set up dependencies for local dev by symlinking the monorepo's node_modules.
140190 * This avoids issues with workspace:* protocol deps that don't exist on npm at 0.0.0.
141- * Production installs use `vp install` in install.sh which resolves real versions.
142191 */
143192function setupLocalDevDeps ( versionDir : string ) {
144193 const nodeModulesLink = path . join ( versionDir , 'node_modules' ) ;
0 commit comments