1
+ const assert = require ( `assert` ) ;
1
2
const cp = require ( `child_process` ) ;
2
3
const crypto = require ( `crypto` ) ;
3
4
const fs = require ( `fs` ) ;
@@ -27,91 +28,141 @@ const SLICES = [
27
28
to : `426f5a7` ,
28
29
onto : `e39bdc3` ,
29
30
range : `>=3.2 <3.5` ,
31
+ volta : {
32
+ node : `14.15.5` ,
33
+ npm : `6.14.11` ,
34
+ } ,
30
35
} ,
31
36
{
32
37
from : `5d50de3` ,
33
38
to : `426f5a7` ,
34
39
onto : `cf7b2d4` ,
35
40
range : `>=3.5 <=3.6` ,
41
+ volta : {
42
+ node : `14.15.5` ,
43
+ npm : `6.14.11` ,
44
+ } ,
36
45
} ,
37
46
{
38
47
from : `5d50de3` ,
39
48
to : `426f5a7` ,
40
49
onto : `cda54b8` ,
41
50
range : `>3.6 <3.7` ,
51
+ volta : {
52
+ node : `14.15.5` ,
53
+ npm : `6.14.11` ,
54
+ } ,
42
55
} ,
43
56
{
44
57
from : `5d50de3` ,
45
58
to : `2f85932` ,
46
59
onto : `e39bdc3` ,
47
60
range : `>=3.7 <3.9` ,
61
+ volta : {
62
+ node : `14.15.5` ,
63
+ npm : `6.14.11` ,
64
+ } ,
48
65
} ,
49
66
{
50
67
from : `5d50de3` ,
51
68
to : `3af06df` ,
52
69
onto : `551f0dd` ,
53
70
range : `>=3.9 <4.0` ,
71
+ volta : {
72
+ node : `14.15.5` ,
73
+ npm : `6.14.11` ,
74
+ } ,
54
75
} ,
55
76
{
56
77
from : `6dbdd2f` ,
57
78
to : `6dbdd2f` ,
58
79
onto : `56865f7` ,
59
80
range : `>=4.0 <4.1` ,
81
+ volta : {
82
+ node : `14.15.5` ,
83
+ npm : `6.14.11` ,
84
+ } ,
60
85
} ,
61
86
{
62
87
from : `746d79b` ,
63
88
to : `746d79b` ,
64
89
onto : `69972a3` ,
65
90
range : `>=4.1 <4.2` ,
91
+ volta : {
92
+ node : `14.15.5` ,
93
+ npm : `6.14.11` ,
94
+ } ,
66
95
} ,
67
96
// https://github.com/merceyz/TypeScript/tree/merceyz/pnp-4.2
68
97
{
69
98
from : `8e0e8703b9c95013aec7819e4593d099cdf7763a` ,
70
99
to : `178a67b4663d80b0fcbea542e7255b4499b51708` ,
71
100
onto : `bfc55b5762443c37ecdef08a3b5a4e057b4d1e85` ,
72
101
range : `>=4.2 <4.3` ,
102
+ volta : {
103
+ node : `14.15.5` ,
104
+ npm : `6.14.11` ,
105
+ } ,
73
106
} ,
74
107
// https://github.com/merceyz/TypeScript/tree/merceyz/pnp-4.3
75
108
{
76
109
from : `530aad19e4ac19d35cb6b200168c91ce86cb0050` ,
77
110
to : `ffa54c5a104e7940b5c23666ddffbf44878f9d9f` ,
78
111
onto : `28e3e6ff2f49f1dbf06d31809ec73dbe42f1aa63` ,
79
112
range : `>=4.3 <4.4` ,
113
+ volta : {
114
+ npm : `6.14.11` ,
115
+ } ,
80
116
} ,
81
117
// https://github.com/merceyz/TypeScript/tree/merceyz/pnp-4.4
82
118
{
83
119
from : `793bfe32745bf6797924354b0fd5be62cf01950c` ,
84
120
to : `20ffca2f3c48591c971e6606a55b7b1820d8a64f` ,
85
121
onto : `a10409ccaa3604790dc45f52ef0402eb49015dcf` ,
86
122
range : `>=4.4 <4.5` ,
123
+ volta : {
124
+ npm : `6.14.11` ,
125
+ } ,
87
126
} ,
88
127
// https://github.com/merceyz/TypeScript/tree/merceyz/pnp-4.5
89
128
{
90
- from : `79fe5d206f89e5f1585807bdcd7feeb567a69646 ` ,
91
- to : `fff89a12766fa485e35b1c65d8631d109c4e2c0e ` ,
92
- onto : `7893f689fedcfe28a499d119d34844840bce9160 ` ,
129
+ from : `9232978f8e54f073b5451d0bf2737d42a0fd672f ` ,
130
+ to : `3a2388d39d41d000b5c5f9bcd48096b39fcedf8f ` ,
131
+ onto : `55e13e9115b3cc5458d76c39da1211dc28d7b51f ` ,
93
132
range : `>=4.5.2 <4.6` ,
133
+ volta : {
134
+ npm : `6.14.11` ,
135
+ } ,
94
136
} ,
95
137
// https://github.com/merceyz/TypeScript/tree/merceyz/pnp-4.6
96
138
{
97
139
from : `fbec717ef33fc2db5791f2a1d5f9a315e293a50a` ,
98
140
to : `fbec717ef33fc2db5791f2a1d5f9a315e293a50a` ,
99
141
onto : `83efc9f0d646bf86a3469e00c5ef5e4f7ab7cb95` ,
100
142
range : `>=4.6.1-rc <4.7` ,
143
+ volta : {
144
+ npm : `6.14.11` ,
145
+ } ,
101
146
} ,
102
147
// https://github.com/merceyz/TypeScript/tree/merceyz/pnp-4.7
103
148
{
104
149
from : `cd8d000510ed2d2910e0ebaa903a51adda546a0a` ,
105
150
to : `cd8d000510ed2d2910e0ebaa903a51adda546a0a` ,
106
151
onto : `6e62273fa1e7469b89b589667c2c233789c62176` ,
107
152
range : `>=4.7.0-beta <4.8` ,
153
+ volta : {
154
+ npm : `6.14.11` ,
155
+ } ,
108
156
} ,
109
157
// https://github.com/merceyz/TypeScript/tree/merceyz/pnp-4.8.0-beta
110
158
{
111
159
from : `3287098f4785fd652112beadf3b33a960fcd19aa` ,
112
160
to : `3287098f4785fd652112beadf3b33a960fcd19aa` ,
113
161
onto : `9a09c37878a45b06994485fdb510eb4d24587dcb` ,
114
162
range : `>=4.8.0-beta <4.8.1-rc` ,
163
+ volta : {
164
+ npm : `6.14.11` ,
165
+ } ,
115
166
} ,
116
167
// https://github.com/merceyz/TypeScript/tree/merceyz/pnp-4.8-stable
117
168
{
@@ -344,21 +395,16 @@ async function cloneRepository() {
344
395
async function resetGit ( hash ) {
345
396
await execFile ( `git` , [ `reset` , `--hard` , hash ] , TS_REPO_SPAWN ) ;
346
397
await execFile ( `git` , [ `clean` , `-df` ] , TS_REPO_SPAWN ) ;
347
-
348
- if ( fs . existsSync ( path . join ( TS_REPO , `package-lock.json` ) ) ) {
349
- await execFile ( `npm` , [ `install` ] , TS_REPO_SPAWN ) ;
350
- } else {
351
- const date = await execFile ( `git` , [ `show` , `-s` , `--format=%ci` ] , TS_REPO_SPAWN ) ;
352
- await execFile ( `npm` , [ `install` , `--before` , date . toString ( ) . trim ( ) ] , TS_REPO_SPAWN ) ;
353
- }
354
398
}
355
399
356
- async function buildRepository ( { from, to, onto} ) {
400
+ async function buildRepository ( { from, to, onto, volta } ) {
357
401
const code = Math . floor ( Math . random ( ) * 0x100000000 ) . toString ( 16 ) . padStart ( 8 , `0` ) ;
358
402
const tmpDir = path . join ( TMP_DIR , `${ code } ` ) ;
359
403
360
404
await resetGit ( onto ) ;
361
405
406
+ const date = await execFile ( `git` , [ `show` , `-s` , `--format=%ci` ] , TS_REPO_SPAWN ) ;
407
+
362
408
if ( to ) {
363
409
let isAncestor ;
364
410
try {
@@ -375,7 +421,31 @@ async function buildRepository({from, to, onto}) {
375
421
}
376
422
}
377
423
378
- await execFile ( fs . existsSync ( `${ TS_REPO } /node_modules/.bin/hereby` ) ? `./node_modules/.bin/hereby` : `./node_modules/.bin/gulp` , [ `local` , `LKG` ] , TS_REPO_SPAWN ) ;
424
+ {
425
+ const pkgPath = path . join ( TS_REPO , `package.json` ) ;
426
+ const pkg = JSON . parse ( await fs . promises . readFile ( pkgPath , `utf8` ) ) ;
427
+
428
+ assert ( ! ( pkg . volta ?. node && volta ?. node ) , `node version is already set for ${ pkg . version } ` ) ;
429
+ assert ( ! ( pkg . volta ?. npm && volta ?. npm ) , `npm version is already set for ${ pkg . version } ` ) ;
430
+
431
+ const voltaConfig = {
432
+ ...volta ,
433
+ ...pkg . volta ,
434
+ } ;
435
+ assert ( voltaConfig . node && voltaConfig . npm , `Missing complete volta configuration for ${ pkg . version } , current config: ${ JSON . stringify ( voltaConfig ) } ` ) ;
436
+
437
+ if ( JSON . stringify ( pkg . volta ) !== JSON . stringify ( voltaConfig ) ) {
438
+ pkg . volta = voltaConfig ;
439
+ await fs . promises . writeFile ( pkgPath , JSON . stringify ( pkg , null , 4 ) ) ;
440
+ }
441
+ }
442
+
443
+ if ( fs . existsSync ( path . join ( TS_REPO , `package-lock.json` ) ) )
444
+ await execFile ( `volta` , [ `run` , `npm` , `ci` ] , TS_REPO_SPAWN ) ;
445
+ else
446
+ await execFile ( `volta` , [ `run` , `npm` , `install` , `--before` , date . toString ( ) . trim ( ) ] , TS_REPO_SPAWN ) ;
447
+
448
+ await execFile ( `volta` , [ `run` , `node` , fs . existsSync ( `${ TS_REPO } /node_modules/.bin/hereby` ) ? `./node_modules/.bin/hereby` : `./node_modules/.bin/gulp` , `local` , `LKG` ] , TS_REPO_SPAWN ) ;
379
449
380
450
// It seems that in some circumstances the build can produce incorrect artifacts. When
381
451
// that happens, the final binary is very small. We try to detect that.
@@ -392,7 +462,7 @@ async function buildRepository({from, to, onto}) {
392
462
return tmpDir ;
393
463
}
394
464
395
- async function run ( { from, to, onto, range} ) {
465
+ async function run ( { from, to, onto, range, volta } ) {
396
466
const hash = crypto
397
467
. createHash ( `md5` )
398
468
. update ( JSON . stringify ( { from, to, onto} ) )
@@ -414,8 +484,8 @@ async function run({from, to, onto, range}) {
414
484
415
485
await cloneRepository ( ) ;
416
486
417
- const base = await buildRepository ( { onto} ) ;
418
- const patched = await buildRepository ( { from, to, onto} ) ;
487
+ const base = await buildRepository ( { onto, volta } ) ;
488
+ const patched = await buildRepository ( { from, to, onto, volta } ) ;
419
489
420
490
const buffer = await execFile ( `git` , [ `diff` , `--no-index` , base , patched ] , { checkExitCode : false } ) ;
421
491
0 commit comments