ide на основе vs code · VibeGit
ide на основе vs code Это ide на основе vs code(code oss), в ней будет встроенный умный апи роутинг, свой маркет с плагинами(агент харнесс, поддержка java/kotlin/мобильной разработки, командная разработка проектов, orca, оркестратор агентов
krutaya-ide-na-osnove-vs-code / build / azure-pipelines / common / publish.ts 1100 строк · изменён 14 нояб., 04:52
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
import fs from 'fs' ;
import path from 'path' ;
import { Readable } from 'stream' ;
import type { ReadableStream } from 'stream/web' ;
import { pipeline } from 'node:stream/promises' ;
import yauzl from 'yauzl' ;
import crypto from 'crypto' ;
import { retry } from './retry.ts' ;
import { CosmosClient } from '@azure/cosmos' ;
import cp from
os
Worker isMainThread workerData
ConfidentialClientApplication
BlobClient BlobServiceClient BlockBlobClient ContainerClient ContainerSASPermissions generateBlobSASQueryParameters
jws
clearInterval setInterval
name
result process env name
result
result
hashName stream Readable Buffer
c e
shasum crypto hashName
stream
shasum shasum
e
shasum
operationId
esrpCorrelationId
code
message
target
innerError
activityId
activityType
name
status
errorCode
errorMessages
beginTime Date
endTime Date
lastModifiedAt Date
code
details key
innerError InnerServiceError
errorCode
errorMessages
StatusCode Object
Pass
Aborted
Inprogress
FailCanRetry
FailDoNotRetry
PendingAnalysis
Cancelled
StatusCode StatusCode
activities ReleaseActivityInfo
childWorkflowType
clientId
customerCorrelationId
errorInfo InnerServiceError
groupId
lastModifiedAt Date
operationId
releaseError ReleaseError
requestSubmittedAt Date
routedRegion
status StatusCode
totalFileCount
totalReleaseSize
version
name
hash
sourceLocation FileLocation
sizeInBytes
hashType FileHashType
fileId
distributionRelativePath
partNumber
friendlyFileName
tenantFileLocationType
tenantFileLocation
signedEngineeringCopyLocation
encryptedDistributionBlobLocation
preEncryptedDistributionBlobLocation
secondaryDistributionHashRequired
secondaryDistributionHashType FileHashType
lastModifiedAt Date
cultureCodes
displayFileInDownloadCenter
isPrimaryFileInDownloadCenter
fileDownloadDetails FileDownloadDetails
clusterRegion
correlationVector
releaseCompletedAt Date
releaseInfo ReleaseInfo
productInfo ProductInfo
createdBy UserInfo
owners OwnerInfo
accessPermissionsInfo AccessPermissionsInfo
files ReleaseDetailsFileInfo
comments
cancellationReason
downloadCenterInfo DownloadCenterInfo
name
version
description
title
minimumNumberOfApprovers
properties key
isRevision
revisionNumber
type FileLocationType
blobUrl
uncPath
url
portalName
downloadUrl
intent
contentType
contentOrigin
productState
audience
name
hash
sourceLocation FileLocation
sizeInBytes
hashType FileHashType
fileId
distributionRelativePath
partNumber
friendlyFileName
tenantFileLocationType
tenantFileLocation
signedEngineeringCopyLocation
encryptedDistributionBlobLocation
preEncryptedDistributionBlobLocation
secondaryDistributionHashRequired
secondaryDistributionHashType FileHashType
lastModifiedAt Date
cultureCodes
displayFileInDownloadCenter
isPrimaryFileInDownloadCenter
fileDownloadDetails FileDownloadDetails
userPrincipalName
owner UserInfo
approver UserInfo
isAutoApproved
isMandatory
mainPublisher
releasePublishers
channelDownloadEntityDetails key
cultureCode
downloadTitle
shortName
shortDescription
longDescription
instructions
additionalInfo
keywords
version
relatedLinks key
downloadCenterId
publishToDownloadCenter
publishingGroup
operatingSystems
relatedReleases
kbNumbers
sbNumbers
locales DownloadCenterLocaleInfo
additionalProperties key
driEmail
groupId
customerCorrelationId
esrpCorrelationId
contextData key
releaseInfo ReleaseInfo
productInfo ProductInfo
files ReleaseFileInfo
routingInfo RoutingInfo
createdBy UserInfo
owners OwnerInfo
approvers ApproverInfo
accessPermissionsInfo AccessPermissionsInfo
jwsToken
publisherId
downloadCenterInfo DownloadCenterInfo
input
Buffer input
input algorithm Buffer
buffer input
crypto algorithm buffer
pfx
pfxCertificatePath path os
pemKeyPath path os
pfxCertificate Buffer pfx
fs pfxCertificatePath pfxCertificate
cp
raw fs pemKeyPath
result raw
result
fs pfxCertificatePath force
fs pemKeyPath force
pfx
pfxCertificatePath path os
pemCertificatePath path os
pfxCertificate Buffer pfx
fs pfxCertificatePath pfxCertificate
cp
raw fs pemCertificatePath
matches raw
matches matches
fs pfxCertificatePath force
fs pemCertificatePath force
args
tenantId
clientId
authCertificatePfx
requestSigningCertificatePfx
containerClient ContainerClient
stagingSasToken
authKey authCertificatePfx
authCertificate authCertificatePfx
requestSigningKey requestSigningCertificatePfx
requestSigningCertificates requestSigningCertificatePfx
app
auth
clientId
authority
clientCertificate
thumbprintSha256 authCertificate
privateKey authKey
x5c authCertificate
response app
scopes
log clientId response accessToken requestSigningCertificates requestSigningKey containerClient stagingSasToken
args
clientId
accessToken
requestSigningCertificates
requestSigningKey
containerClient ContainerClient
stagingSasToken
args
clientId
accessToken
requestSigningCertificates
requestSigningKey
containerClient ContainerClient
stagingSasToken
log log
clientId clientId
accessToken accessToken
requestSigningCertificates requestSigningCertificates
requestSigningKey requestSigningKey
containerClient containerClient
stagingSasToken stagingSasToken
version filePath friendlyFileName
correlationId crypto
blobClient containerClient correlationId
blobClient filePath
submitReleaseResult version filePath friendlyFileName correlationId blobClient
i i i
c c
releaseStatus submitReleaseResult operationId
releaseStatus status
releaseStatus status
releaseStatus
releaseStatus status
releaseStatus
releaseDetails submitReleaseResult operationId
releaseDetails status
releaseDetails files fileDownloadDetails downloadUrl
releaseDetails files fileDownloadDetails downloadUrl
blobClient
version
filePath
friendlyFileName
correlationId
blobClient BlobClient
ReleaseSubmitResponse
size fs filePath size
hash fs filePath
blobUrl
message ReleaseRequestMessage
customerCorrelationId correlationId
esrpCorrelationId correlationId
driEmail
createdBy userPrincipalName
owners owner userPrincipalName
approvers approver userPrincipalName isAutoApproved isMandatory
releaseInfo
title
properties
minimumNumberOfApprovers
productInfo
name
version
description
accessPermissionsInfo
mainPublisher
channelDownloadEntityDetails
AllDownloadEntities
routingInfo
intent
files
name path filePath
friendlyFileName
tenantFileLocation blobUrl
tenantFileLocationType
sourceLocation
type
blobUrl
hashType
hash hash
sizeInBytes size
message jwsToken message
res
method
headers
body message
res ok
text res
res ReleaseSubmitResponse
releaseId ReleaseResultMessage
url
res url
headers
res ok
text res
res ReleaseResultMessage
releaseId ReleaseDetailsMessage
url
res url
headers
res ok
text res
res ReleaseDetailsMessage
message ReleaseRequestMessage
header jws Header
alg
crit
exp Date
x5t requestSigningCertificates
header Record requestSigningCertificates c c
jws
header
payload message
privateKey requestSigningKey
statePath
set
pipelineWorkspacePath
previousState fs pipelineWorkspacePath
name name
match match RegExpExecArray match
match name match attempt match
a b b attempt a attempt
previousState
previousStatePath path pipelineWorkspacePath previousState name previousState name
fs previousStatePath name name name set name
stageAttempt
statePath path pipelineWorkspacePath
fs path statePath recursive
fs statePath set name
set size
name
set name
name
set name
fs statePath
Symbol iterator IterableIterator
set Symbol iterator
azdoFetchOptions
headers
Authorization
path
abortController
timeout abortController
res azdoFetchOptions signal abortController signal
res ok
res
timeout
name
resource
downloadUrl
properties
artifactsize
Artifact
result
result value a a name a name
records
name
type
state
result
Timeline
artifact Artifact downloadPath
abortController
timeout abortController
res artifact resource downloadUrl azdoFetchOptions signal abortController signal
res ok
Readable res body ReadableStream fs downloadPath
timeout
packagePath outputPath
resolve reject
yauzl packagePath lazyEntries autoClose err zipfile
err
err
result
zipfile entry
entry fileName
zipfile
zipfile entry err istream
err
err
filePath path outputPath entry fileName
fs path filePath recursive
ostream fs filePath
ostream
result filePath
zipfile
istream err err
istream ostream
zipfile result
zipfile
platform
type
url
mooncakeUrl
prssUrl
hash
sha256hash
size
supportsFastUpdate
product os arch type
os
product
type
product
type
product
arch
product
type
arch
arch
arch
type
type
type
client BlockBlobClient
lease client
i i i
client
lease
abortController
refresher c e
abortController signal
interval
interval
lease err
interval
err
result refresher
abortController
result
lease
err
err statusCode err statusCode
err
c c
artifact Artifact
filePath
args args
match artifact name
match
cosmosDBAccessToken blobServiceAccessToken
quality
version
friendlyFileName
blobServiceClient blobServiceAccessToken
leasesContainerClient blobServiceClient
leasesContainerClient
leaseBlobClient leasesContainerClient friendlyFileName
leaseBlobClient
url
res url
res status
stagingContainerClient blobServiceClient
stagingContainerClient
now
oneHour
oneHourAgo now oneHour
oneHourFromNow now oneHour
userDelegationKey blobServiceClient oneHourAgo oneHourFromNow
sasOptions containerName permissions ContainerSASPermissions read startsOn oneHourAgo expiresOn oneHourFromNow
stagingSasToken sasOptions userDelegationKey
releaseService ESRPReleaseService
log
stagingContainerClient
stagingSasToken
releaseService version filePath friendlyFileName
product os arch unprocessedType match groups
platform product os arch unprocessedType
type unprocessedType
size fs filePath size
stream fs filePath
hash sha256hash stream stream
asset Asset platform type url hash hash sha256hash sha256hash size supportsFastUpdate
result attempt
client endpoint
scripts client quality scripts
resource result scripts version asset
result
result
asset
isMainThread
artifact artifactFilePath workerData
artifact artifactFilePath
done
processing
name done
stages
stages
stages
stages
stages
stages
timeline Timeline
artifacts Artifact
resultPromise
operations name operation
timeline artifacts
stagesCompleted timeline records r r type r state stages r name r r name
stagesInProgress stages s stagesCompleted s
artifactsInProgress artifacts a processing a name
stagesInProgress length artifacts length done size processing size
stagesInProgress length
stagesInProgress
artifactsInProgress length
artifactsInProgress a a name
artifact artifacts
done artifact name processing artifact name
artifactZipPath path
attempt
start Date
artifact artifactZipPath
archiveSize fs artifactZipPath size
downloadDurationS Date start
downloadSpeedKBS Math archiveSize downloadDurationS
artifactFilePaths artifactZipPath
artifactFilePath artifactFilePaths p p
processing artifact name
promise resolve reject
worker meta filename workerData artifact artifactFilePath
worker reject
worker code
code
operation promise
processing artifact name
done artifact name
operations name artifact name operation
resultPromise operations o o operation
c c
artifactsInProgress operations o processing o name
artifactsInProgress length
artifactsInProgress a a name
results resultPromise
i i operations length i
result results i
result status
result reason
results r r status
shouldFail
stage stages
record timeline records r r name stage r type
record result record result
shouldFail
shouldFail
meta main
process
err
err
process
'child_process'
;
import
from
'os'
;
import
{
,
,
}
from
'node:worker_threads'
;
import
{
}
from
'@azure/msal-node'
;
import
{
,
,
,
,
,
}
from
'@azure/storage-blob'
;
import
from
'jws'
;
import
{
,
}
from
'node:timers'
;
export
function
e
(
:
string
)
:
string
{
const
=
.
[
]
;
if
(
typeof
!==
'string'
)
{
throw
new
Error
(
` Missing env: ${ name} `
)
;
}
return
;
}
function
hashStream
(
:
string
,
:
)
:
Promise
<
>
{
return
new
Promise < Buffer>
(
(
,
)
=>
{
const
=
.
createHash
(
)
;
.
on
(
'data'
,
.
update
.
bind
(
)
)
.
on
(
'error'
,
)
.
on
(
'close'
,
(
)
=>
c
(
.
digest
(
)
)
)
;
}
)
;
}
interface
ReleaseSubmitResponse
{
:
string
;
:
string
;
?
:
string
;
?
:
string
;
?
:
string
;
?
:
any
;
}
interface
ReleaseActivityInfo
{
:
string
;
:
string
;
:
string
;
:
string
;
:
number
;
:
string
[
]
;
?
:
;
?
:
;
?
:
;
}
interface
InnerServiceError
{
:
string
;
:
{
[
:
string
]
:
string
}
;
?
:
;
}
interface
ReleaseError
{
:
number
;
:
string
[
]
;
}
const
=
.
freeze
(
{
:
'pass'
,
:
'aborted'
,
:
'inprogress'
,
:
'failCanRetry'
,
:
'failDoNotRetry'
,
:
'pendingAnalysis'
,
:
'cancelled'
}
)
;
type
StatusCode
=
typeof
[
keyof
typeof
]
;
interface
ReleaseResultMessage
{
:
[
]
;
:
string
;
:
string
;
:
string
;
:
;
:
string
;
:
;
:
string
;
:
;
:
;
:
string
;
:
;
:
number
;
:
number
;
:
string
;
}
interface
ReleaseFileInfo
{
?
:
string
;
?
:
number
[
]
;
?
:
;
?
:
number
;
?
:
;
?
:
any
;
?
:
string
;
?
:
string
;
?
:
string
;
?
:
string
;
?
:
string
;
?
:
string
;
?
:
string
;
?
:
string
;
?
:
boolean
;
?
:
;
?
:
;
?
:
string
[
]
;
?
:
boolean
;
?
:
boolean
;
?
:
[
]
;
}
interface
ReleaseDetailsFileInfo
extends
ReleaseFileInfo
{
}
interface
ReleaseDetailsMessage
extends
ReleaseResultMessage
{
:
string
;
:
string
;
?
:
;
:
;
:
;
:
;
:
[
]
;
:
;
:
[
]
;
:
string
[
]
;
:
string
;
:
;
}
interface
ProductInfo
{
?
:
string
;
?
:
string
;
?
:
string
;
}
interface
ReleaseInfo
{
?
:
string
;
:
number
;
?
:
{
[
:
string
]
:
string
}
;
?
:
boolean
;
?
:
string
;
}
type
FileLocationType
=
'azureBlob'
;
interface
FileLocation
{
:
;
:
string
;
?
:
string
;
?
:
string
;
}
type
FileHashType
=
'sha256'
|
'sha1'
;
interface
FileDownloadDetails
{
:
string
;
:
string
;
}
interface
RoutingInfo
{
?
:
string
;
?
:
string
;
?
:
string
;
?
:
string
;
?
:
string
;
}
interface
ReleaseFileInfo
{
?
:
string
;
?
:
number
[
]
;
?
:
;
?
:
number
;
?
:
;
?
:
any
;
?
:
string
;
?
:
string
;
?
:
string
;
?
:
string
;
?
:
string
;
?
:
string
;
?
:
string
;
?
:
string
;
?
:
boolean
;
?
:
;
?
:
;
?
:
string
[
]
;
?
:
boolean
;
?
:
boolean
;
?
:
[
]
;
}
interface
UserInfo
{
?
:
string
;
}
interface
OwnerInfo
{
:
;
}
interface
ApproverInfo
{
:
;
:
boolean
;
:
boolean
;
}
interface
AccessPermissionsInfo
{
?
:
string
;
?
:
string
[
]
;
?
:
{
[
:
string
]
:
string
[
]
}
;
}
interface
DownloadCenterLocaleInfo
{
?
:
string
;
?
:
string
;
?
:
string
;
?
:
string
;
?
:
string
;
?
:
string
;
?
:
string
;
?
:
string
[
]
;
?
:
string
;
?
:
{
[
:
string
]
:
URL
}
;
}
interface
DownloadCenterInfo
{
:
number
;
?
:
boolean
;
?
:
string
;
?
:
string
[
]
;
?
:
string
[
]
;
?
:
string
[
]
;
?
:
string
[
]
;
?
:
[
]
;
?
:
{
[
:
string
]
:
string
}
;
}
interface
ReleaseRequestMessage
{
:
string
[
]
;
?
:
string
;
:
string
;
:
string
;
?
:
{
[
:
string
]
:
string
}
;
:
;
:
;
:
[
]
;
?
:
;
:
;
:
[
]
;
:
[
]
;
:
;
?
:
string
;
?
:
string
;
?
:
;
}
function
getCertificateBuffer
(
:
string
)
{
return
.
from
(
.
replace
(
/ -----BEGIN CERTIFICATE-----| -----END CERTIFICATE-----| \n / g
,
''
)
,
'base64'
)
;
}
function
getThumbprint
(
:
string
,
:
string
)
:
{
const
=
getCertificateBuffer
(
)
;
return
.
createHash
(
)
.
update
(
)
.
digest
(
)
;
}
function
getKeyFromPFX
(
:
string
)
:
string
{
const
=
.
join
(
.
tmpdir
(
)
,
'cert.pfx'
)
;
const
=
.
join
(
.
tmpdir
(
)
,
'key.pem'
)
;
try
{
const
=
.
from
(
,
'base64'
)
;
.
writeFileSync
(
,
)
;
.
execSync
(
` openssl pkcs12 -in " ${ pfxCertificatePath} " -nocerts -nodes -out " ${ pemKeyPath} " -passin pass: `
)
;
const
=
.
readFileSync
(
,
'utf-8'
)
;
const
=
.
match
(
/ -----BEGIN PRIVATE KEY-----[ \s \S ] +? -----END PRIVATE KEY----- / g
)
!
[
0
]
;
return
;
}
finally
{
.
rmSync
(
,
{
:
true
}
)
;
.
rmSync
(
,
{
:
true
}
)
;
}
}
function
getCertificatesFromPFX
(
:
string
)
:
string
[
]
{
const
=
.
join
(
.
tmpdir
(
)
,
'cert.pfx'
)
;
const
=
.
join
(
.
tmpdir
(
)
,
'cert.pem'
)
;
try
{
const
=
.
from
(
,
'base64'
)
;
.
writeFileSync
(
,
)
;
.
execSync
(
` openssl pkcs12 -in " ${ pfxCertificatePath} " -nokeys -out " ${ pemCertificatePath} " -passin pass: `
)
;
const
=
.
readFileSync
(
,
'utf-8'
)
;
const
=
.
match
(
/ -----BEGIN CERTIFICATE-----[ \s \S ] +? -----END CERTIFICATE----- / g
)
;
return
?
.
reverse
(
)
:
[
]
;
}
finally
{
.
rmSync
(
,
{
:
true
}
)
;
.
rmSync
(
,
{
:
true
}
)
;
}
}
class
ESRPReleaseService
{
static
async
create
(
log
:
(
...
:
unknown
[
]
)
=>
void
,
:
string
,
:
string
,
:
string
,
:
string
,
:
,
:
string
)
{
const
=
getKeyFromPFX
(
)
;
const
=
getCertificatesFromPFX
(
)
[
0
]
;
const
=
getKeyFromPFX
(
)
;
const
=
getCertificatesFromPFX
(
)
;
const
=
new
ConfidentialClientApplication
(
{
:
{
,
:
` https://login.microsoftonline.com/ ${ tenantId} `
,
:
{
:
getThumbprint
(
,
'sha256'
)
.
toString
(
'hex'
)
,
:
,
:
}
}
}
)
;
const
=
await
.
acquireTokenByClientCredential
(
{
:
[
'https://msazurecloud.onmicrosoft.com/api.esrp.microsoft.com/.default'
]
}
)
;
return
new
ESRPReleaseService
(
,
,
!
.
,
,
,
,
)
;
}
private
static
API_URL
=
'https://api.esrp.microsoft.com/api/v3/releaseservices/clients/'
;
private
readonly
log
:
(
...
:
unknown
[
]
)
=>
void
;
private
readonly
:
string
;
private
readonly
:
string
;
private
readonly
:
string
[
]
;
private
readonly
:
string
;
private
readonly
:
;
private
readonly
:
string
;
private
constructor
(
log
:
(
...
:
unknown
[
]
)
=>
void
,
:
string
,
:
string
,
:
string
[
]
,
:
string
,
:
,
:
string
)
{
this
.
=
;
this
.
=
;
this
.
=
;
this
.
=
;
this
.
=
;
this
.
=
;
this
.
=
;
}
async
createRelease
(
:
string
,
:
string
,
:
string
)
{
const
=
.
randomUUID
(
)
;
const
=
this
.
.
getBlockBlobClient
(
)
;
this
.
log
(
` Uploading ${ filePath} to ${ blobClient. url} `
)
;
await
.
uploadFile
(
)
;
this
.
log
(
'Uploaded blob successfully'
)
;
try
{
this
.
log
(
` Submitting release for ${ version} : ${ filePath} `
)
;
const
=
await
this
.
submitRelease
(
,
,
,
,
)
;
this
.
log
(
` Successfully submitted release ${ submitReleaseResult. operationId} . Polling for completion... `
)
;
for
(
let
=
0
;
<
720
;
++
)
{
await
new
Promise
(
=>
setTimeout
(
,
5000
)
)
;
const
=
await
this
.
getReleaseStatus
(
.
)
;
if
(
.
===
'pass'
)
{
break
;
}
else
if
(
.
===
'aborted'
)
{
this
.
log
(
JSON
.
stringify
(
)
)
;
throw
new
Error
(
` Release was aborted `
)
;
}
else
if
(
.
!==
'inprogress'
)
{
this
.
log
(
JSON
.
stringify
(
)
)
;
throw
new
Error
(
` Unknown error when polling for release `
)
;
}
}
const
=
await
this
.
getReleaseDetails
(
.
)
;
if
(
.
!==
'pass'
)
{
throw
new
Error
(
` Timed out waiting for release: ${ JSON . stringify ( releaseDetails) } `
)
;
}
this
.
log
(
'Successfully created release:'
,
.
[
0
]
.
!
[
0
]
.
)
;
return
.
[
0
]
.
!
[
0
]
.
;
}
finally
{
this
.
log
(
` Deleting blob ${ blobClient. url} `
)
;
await
.
delete
(
)
;
this
.
log
(
'Deleted blob successfully'
)
;
}
}
private
async
submitRelease
(
:
string
,
:
string
,
:
string
,
:
string
,
:
)
:
Promise
<
>
{
const
=
.
statSync
(
)
.
;
const
=
await
hashStream
(
'sha256'
,
.
createReadStream
(
)
)
;
const
=
` ${ blobClient. url} ? ${ this . stagingSasToken} `
;
const
:
=
{
:
,
:
,
:
[
'lszomoru@microsoft.com'
]
,
:
{
:
'lszomoru@microsoft.com'
}
,
:
[
{
:
{
:
'lszomoru@microsoft.com'
}
}
]
,
:
[
{
:
{
:
'lszomoru@microsoft.com'
}
,
:
true
,
:
false
}
]
,
:
{
:
'VS Code'
,
:
{
'ReleaseContentType'
:
'InstallPackage'
}
,
:
1
}
,
:
{
:
'VS Code'
,
,
:
'VS Code'
}
,
:
{
:
'VSCode'
,
:
{
:
[
'VSCode'
]
}
}
,
:
{
:
'filedownloadlinkgeneration'
}
,
:
[
{
:
.
basename
(
)
,
,
:
,
:
'AzureBlob'
,
:
{
:
'azureBlob'
,
}
,
:
'sha256'
,
:
Array
.
from
(
)
,
:
}
]
}
;
.
=
await
this
.
generateJwsToken
(
)
;
const
=
await
fetch
(
` ${ ESRPReleaseService. API_URL } ${ this . clientId} /workflows/release/operations `
,
{
:
'POST'
,
:
{
'Content-Type'
:
'application/json'
,
'Authorization'
:
` Bearer ${ this . accessToken} `
}
,
:
JSON
.
stringify
(
)
}
)
;
if
(
!
.
)
{
const
=
await
.
text
(
)
;
throw
new
Error
(
` Failed to submit release: ${ res. statusText} \n ${ text} `
)
;
}
return
await
.
json
(
)
as
;
}
private
async
getReleaseStatus
(
:
string
)
:
Promise
<
>
{
const
=
` ${ ESRPReleaseService. API_URL } ${ this . clientId} /workflows/release/operations/grs/ ${ releaseId} `
;
const
=
await
retry
(
(
)
=>
fetch
(
,
{
:
{
'Authorization'
:
` Bearer ${ this . accessToken} `
}
}
)
)
;
if
(
!
.
)
{
const
=
await
.
text
(
)
;
throw
new
Error
(
` Failed to get release status: ${ res. statusText} \n ${ text} `
)
;
}
return
await
.
json
(
)
as
;
}
private
async
getReleaseDetails
(
:
string
)
:
Promise
<
>
{
const
=
` ${ ESRPReleaseService. API_URL } ${ this . clientId} /workflows/release/operations/grd/ ${ releaseId} `
;
const
=
await
retry
(
(
)
=>
fetch
(
,
{
:
{
'Authorization'
:
` Bearer ${ this . accessToken} `
}
}
)
)
;
if
(
!
.
)
{
const
=
await
.
text
(
)
;
throw
new
Error
(
` Failed to get release status: ${ res. statusText} \n ${ text} `
)
;
}
return
await
.
json
(
)
as
;
}
private
async
generateJwsToken
(
:
)
:
Promise
<
string
>
{
const
:
.
=
{
:
'RS256'
,
:
[
'exp'
,
'x5t'
]
,
:
(
(
.
now
(
)
+
(
6
*
60
*
1000
)
)
*
10000
)
+
621355968000000000
,
:
getThumbprint
(
this
.
[
0
]
,
'sha1'
)
.
toString
(
'hex'
)
,
}
;
(
as
<
string
,
unknown
>
)
[
'x5c'
]
=
this
.
.
map
(
=>
getCertificateBuffer
(
)
.
toString
(
'base64url'
)
)
.
join
(
'.'
)
;
return
.
sign
(
{
,
:
,
:
this
.
,
}
)
;
}
}
class
State
{
private
:
string
;
private
=
new
Set< string >
(
)
;
constructor
(
)
{
const
=
e
(
'PIPELINE_WORKSPACE'
)
;
const
=
.
readdirSync
(
)
.
map
(
=>
/ ^ artifacts_processed_( \d + ) $ /
.
exec
(
)
)
.
filter
(
(
)
:
is
=>
!
!
)
.
map
(
=>
(
{
:
!
[
0
]
,
:
Number
(
!
[
1
]
)
}
)
)
.
sort
(
(
,
)
=>
.
-
.
)
[
0
]
;
if
(
)
{
const
=
.
join
(
,
.
,
.
+
'.txt'
)
;
.
readFileSync
(
,
'utf8'
)
.
split
(
/ \n /
)
.
filter
(
=>
!
!
)
.
forEach
(
=>
this
.
.
add
(
)
)
;
}
const
=
e
(
'SYSTEM_STAGEATTEMPT'
)
;
this
.
=
.
join
(
,
` artifacts_processed_ ${ stageAttempt} `
,
` artifacts_processed_ ${ stageAttempt} .txt `
)
;
.
mkdirSync
(
.
dirname
(
this
.
)
,
{
:
true
}
)
;
.
writeFileSync
(
this
.
,
[
...
this
.
.
values
(
)
]
.
map
(
=>
` ${ name} \n `
)
.
join
(
''
)
)
;
}
get
size
(
)
:
number
{
return
this
.
.
;
}
has
(
:
string
)
:
boolean
{
return
this
.
.
has
(
)
;
}
add
(
:
string
)
:
void
{
this
.
.
add
(
)
;
.
appendFileSync
(
this
.
,
` ${ name} \n `
)
;
}
[
.
]
(
)
:
<
string
>
{
return
this
.
[
.
]
(
)
;
}
}
const
=
{
:
{
'User-Agent'
:
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36 Edg/119.0.0.0'
,
'Accept'
:
'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7'
,
'Accept-Encoding'
:
'gzip, deflate, br'
,
'Accept-Language'
:
'en-US,en;q=0.9'
,
'Referer'
:
'https://dev.azure.com'
,
:
` Bearer ${ e ( 'SYSTEM_ACCESSTOKEN' ) } `
}
}
;
export
async
function
requestAZDOAPI < T >
(
:
string
)
:
Promise
<
T
>
{
const
=
new
AbortController
(
)
;
const
=
setTimeout
(
(
)
=>
.
abort
(
)
,
2
*
60
*
1000
)
;
try
{
const
=
await
retry
(
(
)
=>
fetch
(
` ${ e ( 'BUILDS_API_URL' ) } ${ path} ?api-version=6.0 `
,
{
...
,
:
.
}
)
)
;
if
(
!
.
)
{
throw
new
Error
(
` Unexpected status code: ${ res. status} `
)
;
}
return
await
.
json
(
)
as
T
;
}
finally
{
clearTimeout
(
)
;
}
}
export
interface
Artifact
{
readonly
:
string
;
readonly
:
{
readonly
:
string
;
readonly
:
{
readonly
:
number
;
}
;
}
;
}
async
function
getPipelineArtifacts
(
)
:
Promise
<
[
]
>
{
const
=
await
requestAZDOAPI < { readonly value: Artifact[ ] } >
(
'artifacts'
)
;
return
.
.
filter
(
=>
/ ^ vscode_/
.
test
(
.
)
&&
!
/ sbom$ /
.
test
(
.
)
)
;
}
interface
Timeline
{
readonly
:
{
readonly
:
string
;
readonly
:
string
;
readonly
:
string
;
readonly
:
string
;
}
[
]
;
}
async
function
getPipelineTimeline
(
)
:
Promise
<
>
{
return
await
requestAZDOAPI < Timeline>
(
'timeline'
)
;
}
async
function
downloadArtifact
(
:
,
:
string
)
:
Promise
<
void
>
{
const
=
new
AbortController
(
)
;
const
=
setTimeout
(
(
)
=>
.
abort
(
)
,
4
*
60
*
1000
)
;
try
{
const
=
await
fetch
(
.
.
,
{
...
,
:
.
}
)
;
if
(
!
.
)
{
throw
new
Error
(
` Unexpected status code: ${ res. status} `
)
;
}
await
pipeline
(
.
fromWeb
(
.
as
)
,
.
createWriteStream
(
)
)
;
}
finally
{
clearTimeout
(
)
;
}
}
async
function
unzip
(
:
string
,
:
string
)
:
Promise
<
string
[
]
>
{
return
new
Promise
(
(
,
)
=>
{
.
open
(
,
{
:
true
,
:
true
}
,
(
,
)
=>
{
if
(
)
{
return
reject
(
)
;
}
const
:
string
[
]
=
[
]
;
!
.
on
(
'entry'
,
=>
{
if
(
/ \/ $ /
.
test
(
.
)
)
{
!
.
readEntry
(
)
;
}
else
{
!
.
openReadStream
(
,
(
,
)
=>
{
if
(
)
{
return
reject
(
)
;
}
const
=
.
join
(
,
.
)
;
.
mkdirSync
(
.
dirname
(
)
,
{
:
true
}
)
;
const
=
.
createWriteStream
(
)
;
.
on
(
'finish'
,
(
)
=>
{
.
push
(
)
;
!
.
readEntry
(
)
;
}
)
;
?.
on
(
'error'
,
=>
reject
(
)
)
;
!
.
pipe
(
)
;
}
)
;
}
}
)
;
!
.
on
(
'close'
,
(
)
=>
resolve
(
)
)
;
!
.
readEntry
(
)
;
}
)
;
}
)
;
}
interface
Asset
{
:
string
;
:
string
;
:
string
;
?
:
string
;
?
:
string
;
:
string
;
:
string
;
:
number
;
?
:
boolean
;
}
function
getPlatform
(
:
string
,
:
string
,
:
string
,
:
string
)
:
string
{
switch
(
)
{
case
'win32'
:
switch
(
)
{
case
'client'
:
{
switch
(
)
{
case
'archive'
:
return
` win32- ${ arch} -archive `
;
case
'setup'
:
return
` win32- ${ arch} `
;
case
'user-setup'
:
return
` win32- ${ arch} -user `
;
default
:
throw
new
Error
(
` Unrecognized: ${ product} ${ os} ${ arch} ${ type } `
)
;
}
}
case
'server'
:
return
` server-win32- ${ arch} `
;
case
'web'
:
return
` server-win32- ${ arch} -web `
;
case
'cli'
:
return
` cli-win32- ${ arch} `
;
default
:
throw
new
Error
(
` Unrecognized: ${ product} ${ os} ${ arch} ${ type } `
)
;
}
case
'alpine'
:
switch
(
)
{
case
'server'
:
return
` server-alpine- ${ arch} `
;
case
'web'
:
return
` server-alpine- ${ arch} -web `
;
case
'cli'
:
return
` cli-alpine- ${ arch} `
;
default
:
throw
new
Error
(
` Unrecognized: ${ product} ${ os} ${ arch} ${ type } `
)
;
}
case
'linux'
:
switch
(
)
{
case
'snap'
:
return
` linux-snap- ${ arch} `
;
case
'archive-unsigned'
:
switch
(
)
{
case
'client'
:
return
` linux- ${ arch} `
;
case
'server'
:
return
` server-linux- ${ arch} `
;
case
'web'
:
if
(
===
'standalone'
)
{
return
'web-standalone'
;
}
return
` server-linux- ${ arch} -web `
;
default
:
throw
new
Error
(
` Unrecognized: ${ product} ${ os} ${ arch} ${ type } `
)
;
}
case
'deb-package'
:
return
` linux-deb- ${ arch} `
;
case
'rpm-package'
:
return
` linux-rpm- ${ arch} `
;
case
'cli'
:
return
` cli-linux- ${ arch} `
;
default
:
throw
new
Error
(
` Unrecognized: ${ product} ${ os} ${ arch} ${ type } `
)
;
}
case
'darwin'
:
switch
(
)
{
case
'client'
:
switch
(
)
{
case
'dmg'
:
return
` darwin- ${ arch} -dmg `
;
case
'archive'
:
default
:
if
(
===
'x64'
)
{
return
'darwin'
;
}
return
` darwin- ${ arch} `
;
}
case
'server'
:
if
(
===
'x64'
)
{
return
'server-darwin'
;
}
return
` server-darwin- ${ arch} `
;
case
'web'
:
if
(
===
'x64'
)
{
return
'server-darwin-web'
;
}
return
` server-darwin- ${ arch} -web `
;
case
'cli'
:
return
` cli-darwin- ${ arch} `
;
default
:
throw
new
Error
(
` Unrecognized: ${ product} ${ os} ${ arch} ${ type } `
)
;
}
default
:
throw
new
Error
(
` Unrecognized: ${ product} ${ os} ${ arch} ${ type } `
)
;
}
}
function
getRealType
(
:
string
)
{
switch
(
)
{
case
'user-setup'
:
return
'setup'
;
case
'deb-package'
:
case
'rpm-package'
:
return
'package'
;
default
:
return
;
}
}
async
function
withLease < T >
(
:
,
fn
:
(
)
=>
Promise
<
T
>
)
{
const
=
.
getBlobLeaseClient
(
)
;
for
(
let
=
0
;
<
360
;
++
)
{
try
{
await
.
uploadData
(
new
ArrayBuffer
(
)
)
;
await
.
acquireLease
(
60
)
;
try
{
const
=
new
AbortController
(
)
;
const
=
new
Promise < void >
(
(
,
)
=>
{
.
.
onabort
=
(
)
=>
{
clearInterval
(
)
;
c
(
)
;
}
;
const
=
setInterval
(
(
)
=>
{
.
renewLease
(
)
.
catch
(
=>
{
clearInterval
(
)
;
e
(
new
Error
(
'Failed to renew lease '
+
)
)
;
}
)
;
}
,
30_000
)
;
}
)
;
const
=
await
Promise
.
race
(
[
fn
(
)
,
]
)
;
.
abort
(
)
;
return
;
}
finally
{
await
.
releaseLease
(
)
;
}
}
catch
(
)
{
if
(
.
!==
409
&&
.
!==
412
)
{
throw
;
}
await
new
Promise
(
=>
setTimeout
(
,
5000
)
)
;
}
}
throw
new
Error
(
'Failed to acquire lease on blob after 30 minutes'
)
;
}
async
function
processArtifact
(
:
,
:
string
)
{
const
log
=
(
...
:
unknown
[
]
)
=>
console
.
log
(
` [ ${ artifact. name} ] `
,
...
)
;
const
=
/ ^ vscode_(?<product > [ ^ _] + ) _(?<os > [ ^ _] + ) (?: _legacy) ? _(?<arch > [ ^ _] + ) _(?<unprocessedType > [ ^ _] + ) $ /
.
exec
(
.
)
;
if
(
!
)
{
throw
new
Error
(
` Invalid artifact name: ${ artifact. name} `
)
;
}
const
{
,
}
=
JSON
.
parse
(
e
(
'PUBLISH_AUTH_TOKENS'
)
)
;
const
=
e
(
'VSCODE_QUALITY'
)
;
const
=
e
(
'BUILD_SOURCEVERSION'
)
;
const
=
` ${ quality} / ${ version} / ${ path. basename ( filePath) } `
;
const
=
new
BlobServiceClient
(
` https:// ${ e ( 'VSCODE_STAGING_BLOB_STORAGE_ACCOUNT_NAME' ) } .blob.core.windows.net/ `
,
{
getToken
:
async
(
)
=>
}
)
;
const
=
.
getContainerClient
(
'leases'
)
;
await
.
createIfNotExists
(
)
;
const
=
.
getBlockBlobClient
(
)
;
log
(
` Acquiring lease for: ${ friendlyFileName} `
)
;
await
withLease
(
,
async
(
)
=>
{
log
(
` Successfully acquired lease for: ${ friendlyFileName} `
)
;
const
=
` ${ e ( 'PRSS_CDN_URL' ) } / ${ friendlyFileName} `
;
const
=
await
retry
(
(
)
=>
fetch
(
)
)
;
if
(
.
===
200
)
{
log
(
` Already released and provisioned: ${ url} `
)
;
}
else
{
const
=
.
getContainerClient
(
'staging'
)
;
await
.
createIfNotExists
(
)
;
const
=
new
Date
(
)
.
valueOf
(
)
;
const
=
120
*
60
*
1000
;
const
=
new
Date
(
-
)
;
const
=
new
Date
(
+
)
;
const
=
await
.
getUserDelegationKey
(
,
)
;
const
=
{
:
'staging'
,
:
.
from
(
{
:
true
}
)
,
:
,
:
}
;
const
=
generateBlobSASQueryParameters
(
,
,
e
(
'VSCODE_STAGING_BLOB_STORAGE_ACCOUNT_NAME'
)
)
.
toString
(
)
;
const
=
await
.
create
(
,
e
(
'RELEASE_TENANT_ID'
)
,
e
(
'RELEASE_CLIENT_ID'
)
,
e
(
'RELEASE_AUTH_CERT'
)
,
e
(
'RELEASE_REQUEST_SIGNING_CERT'
)
,
,
)
;
await
.
createRelease
(
,
,
)
;
}
const
{
,
,
,
}
=
.
!
;
const
=
getPlatform
(
,
,
,
)
;
const
=
getRealType
(
)
;
const
=
.
statSync
(
)
.
;
const
=
.
createReadStream
(
)
;
const
[
,
]
=
await
Promise
.
all
(
[
hashStream
(
'sha1'
,
)
,
hashStream
(
'sha256'
,
)
]
)
;
const
:
=
{
,
,
,
:
.
toString
(
'hex'
)
,
:
.
toString
(
'hex'
)
,
,
:
true
}
;
log
(
'Creating asset...'
)
;
const
=
await
retry
(
async
(
)
=>
{
log
(
` Creating asset in Cosmos DB (attempt ${ attempt} )... `
)
;
const
=
new
CosmosClient
(
{
:
e
(
'AZURE_DOCUMENTDB_ENDPOINT'
)
!
,
tokenProvider
:
(
)
=>
Promise
.
resolve
(
` type=aad&ver=1.0&sig= ${ cosmosDBAccessToken. token} `
)
}
)
;
const
=
.
database
(
'builds'
)
.
container
(
)
.
;
const
{
:
}
=
await
.
storedProcedure
(
'createAsset'
)
.
execute < 'ok' | 'already exists' >
(
''
,
[
,
,
true
]
)
;
return
;
}
)
;
if
(
===
'already exists'
)
{
log
(
'Asset already exists!'
)
;
}
else
{
log
(
'Asset successfully created: '
,
JSON
.
stringify
(
,
undefined
,
2
)
)
;
}
}
)
;
log
(
` Successfully released lease for: ${ friendlyFileName} `
)
;
}
async
function
main
(
)
{
if
(
!
)
{
const
{
,
}
=
;
await
processArtifact
(
,
)
;
return
;
}
const
=
new
State
(
)
;
const
=
new
Set< string >
(
)
;
for
(
const
of
)
{
console
.
log
(
` \u2705 ${ name} `
)
;
}
const
=
new
Set< string >
(
[
'Quality'
]
)
;
if
(
e
(
'VSCODE_BUILD_STAGE_WINDOWS'
)
===
'True'
)
{
.
add
(
'Windows'
)
;
}
if
(
e
(
'VSCODE_BUILD_STAGE_LINUX'
)
===
'True'
)
{
.
add
(
'Linux'
)
;
}
if
(
e
(
'VSCODE_BUILD_STAGE_ALPINE'
)
===
'True'
)
{
.
add
(
'Alpine'
)
;
}
if
(
e
(
'VSCODE_BUILD_STAGE_MACOS'
)
===
'True'
)
{
.
add
(
'macOS'
)
;
}
if
(
e
(
'VSCODE_BUILD_STAGE_WEB'
)
===
'True'
)
{
.
add
(
'Web'
)
;
}
let
:
;
let
:
[
]
;
let
=
Promise
.
resolve < PromiseSettledResult< void > [ ] >
(
[
]
)
;
const
:
{
:
string
;
:
Promise
<
void
>
}
[
]
=
[
]
;
while
(
true
)
{
[
,
]
=
await
Promise
.
all
(
[
retry
(
(
)
=>
getPipelineTimeline
(
)
)
,
retry
(
(
)
=>
getPipelineArtifacts
(
)
)
]
)
;
const
=
new
Set< string >
(
.
.
filter
(
=>
.
===
'Stage'
&&
.
===
'completed'
&&
.
has
(
.
)
)
.
map
(
=>
.
)
)
;
const
=
[
...
]
.
filter
(
=>
!
.
has
(
)
)
;
const
=
.
filter
(
=>
.
has
(
.
)
)
;
if
(
.
===
0
&&
.
===
.
+
.
)
{
break
;
}
else
if
(
.
>
0
)
{
console
.
log
(
'Stages in progress:'
,
.
join
(
', '
)
)
;
}
else
if
(
.
>
0
)
{
console
.
log
(
'Artifacts in progress:'
,
.
map
(
=>
.
)
.
join
(
', '
)
)
;
}
else
{
console
.
log
(
` Waiting for a total of ${ artifacts. length} , ${ done. size} done, ${ processing. size} in progress... `
)
;
}
for
(
const
of
)
{
if
(
.
has
(
.
)
||
.
has
(
.
)
)
{
continue
;
}
console
.
log
(
` [ ${ artifact. name} ] Found new artifact `
)
;
const
=
.
join
(
e
(
'AGENT_TEMPDIRECTORY'
)
,
` ${ artifact. name} .zip `
)
;
await
retry
(
async
(
)
=>
{
const
=
.
now
(
)
;
console
.
log
(
` [ ${ artifact. name} ] Downloading (attempt ${ attempt} )... `
)
;
await
downloadArtifact
(
,
)
;
const
=
.
statSync
(
)
.
;
const
=
(
.
now
(
)
-
)
/
1000
;
const
=
.
round
(
(
/
1024
)
/
)
;
console
.
log
(
` [ ${ artifact. name} ] Successfully downloaded after ${ Math. floor ( downloadDurationS) } seconds( ${ downloadSpeedKBS} KB/s). `
)
;
}
)
;
const
=
await
unzip
(
,
e
(
'AGENT_TEMPDIRECTORY'
)
)
;
const
=
.
filter
(
=>
!
/ _manifest /
.
test
(
)
)
[
0
]
;
.
add
(
.
)
;
const
=
new
Promise < void >
(
(
,
)
=>
{
const
=
new
Worker
(
import
.
.
,
{
:
{
,
}
}
)
;
.
on
(
'error'
,
)
;
.
on
(
'exit'
,
=>
{
if
(
===
0
)
{
resolve
(
)
;
}
else
{
reject
(
new
Error
(
` [ ${ artifact. name} ] Worker stopped with exit code ${ code} `
)
)
;
}
}
)
;
}
)
;
const
=
.
then
(
(
)
=>
{
.
delete
(
.
)
;
.
add
(
.
)
;
console
.
log
(
` \u2705 ${ artifact. name} `
)
;
}
)
;
.
push
(
{
:
.
,
}
)
;
=
Promise
.
allSettled
(
.
map
(
=>
.
)
)
;
}
await
new
Promise
(
=>
setTimeout
(
,
10_000
)
)
;
}
console
.
log
(
` Found all ${ done. size + processing. size} artifacts, waiting for ${ processing. size} artifacts to finish publishing... `
)
;
const
=
.
filter
(
=>
.
has
(
.
)
)
;
if
(
.
>
0
)
{
console
.
log
(
'Artifacts in progress:'
,
.
map
(
=>
.
)
.
join
(
', '
)
)
;
}
const
=
await
;
for
(
let
=
0
;
<
.
;
++
)
{
const
=
[
]
;
if
(
.
===
'rejected'
)
{
console
.
error
(
` [ ${ operations[ i] . name} ] `
,
.
)
;
}
}
if
(
.
some
(
=>
.
===
'rejected'
)
)
{
throw
new
Error
(
'Some artifacts failed to publish'
)
;
}
let
=
false
;
for
(
const
of
)
{
const
=
.
.
find
(
=>
.
===
&&
.
===
'Stage'
)
!
;
if
(
.
!==
'succeeded'
&&
.
!==
'succeededWithIssues'
)
{
=
true
;
console
.
error
(
` Stage ${ stage} did not succeed: ${ record. result} `
)
;
}
}
if
(
)
{
throw
new
Error
(
'Some stages did not succeed'
)
;
}
console
.
log
(
` All ${ done. size} artifacts published! `
)
;
}
if
(
import
.
.
)
{
main
(
)
.
then
(
(
)
=>
{
.
exit
(
0
)
;
}
,
=>
{
console
.
error
(
)
;
.
exit
(
1
)
;
}
)
;
}