@@ -10,6 +10,18 @@ const mockTrace = () => ({
10
10
traceChild : ( ) => mockTrace ( ) ,
11
11
} )
12
12
13
+ let turboRepoRoot = path . join ( __dirname , '..' , '..' , '..' , '..' , '..' )
14
+
15
+ // stats-action runs this code without access to the original repo.
16
+ // In that case we just use the temporary directory (everything is temporary anyway in CI)
17
+ if ( turboRepoRoot === '/' ) {
18
+ turboRepoRoot = path . join ( __dirname , '..' , '..' )
19
+ }
20
+
21
+ /** Save turbo cache to persistent storage */
22
+ const turboCacheLocation = path . join ( turboRepoRoot , 'node_modules/.cache/turbo' )
23
+ const packedPkgsDir = path . join ( turboRepoRoot , 'test/tmp/packedPkgs' )
24
+
13
25
module . exports = ( actionInfo ) => {
14
26
return {
15
27
async cloneRepo ( repoPath = '' , dest = '' ) {
@@ -81,9 +93,15 @@ module.exports = (actionInfo) => {
81
93
await rootSpan
82
94
. traceChild ( 'prepare packages for packing' )
83
95
. traceAsyncFn ( async ( ) => {
96
+ await fs . ensureDir ( packedPkgsDir )
97
+ const repoData = require ( path . join ( repoDir , 'package.json' ) )
98
+
84
99
for ( const pkg of pkgs ) {
85
100
const pkgPath = path . join ( repoDir , 'packages' , pkg )
86
- const packedPkgPath = path . join ( pkgPath , `${ pkg } -packed.tgz` )
101
+ const packedPkgPath = path . join (
102
+ packedPkgsDir ,
103
+ `${ pkg } -packed.tgz`
104
+ )
87
105
88
106
const pkgDataPath = path . join ( pkgPath , 'package.json' )
89
107
if ( ! fs . existsSync ( pkgDataPath ) ) {
@@ -103,7 +121,8 @@ module.exports = (actionInfo) => {
103
121
}
104
122
105
123
for ( const pkg of pkgDatas . keys ( ) ) {
106
- const { pkgDataPath, pkgData } = pkgDatas . get ( pkg )
124
+ const { pkgDataPath, pkgData, pkgPath, packedPkgPath } =
125
+ pkgDatas . get ( pkg )
107
126
108
127
for ( const pkg of pkgDatas . keys ( ) ) {
109
128
const { packedPkgPath } = pkgDatas . get ( pkg )
@@ -139,6 +158,15 @@ module.exports = (actionInfo) => {
139
158
}
140
159
}
141
160
161
+ // Turbo requires package manager specification
162
+ pkgData . packageManager =
163
+ pkgData . packageManager || repoData . packageManager
164
+
165
+ pkgData . scripts = {
166
+ ...pkgData . scripts ,
167
+ 'test-pack' : `yarn pack -f ${ packedPkgPath } ` ,
168
+ }
169
+
142
170
await fs . writeFile (
143
171
pkgDataPath ,
144
172
JSON . stringify ( pkgData , null , 2 ) ,
@@ -157,11 +185,8 @@ module.exports = (actionInfo) => {
157
185
await packingSpan
158
186
. traceChild ( `pack ${ pkgName } ` )
159
187
. traceAsyncFn ( async ( ) => {
160
- const { pkg, pkgPath } = pkgDatas . get ( pkgName )
161
- await exec (
162
- `cd ${ pkgPath } && yarn pack -f '${ pkg } -packed.tgz'` ,
163
- true
164
- )
188
+ const { pkgPath } = pkgDatas . get ( pkgName )
189
+ await exec ( `pnpm run --dir="${ pkgPath } " test-pack` , true )
165
190
} )
166
191
} )
167
192
)
0 commit comments