@@ -75,11 +75,7 @@ const { values: rawOptions } = parseArgs({
75
75
76
76
// We can't use parseArgs' strict mode as it errors on hereby's --tasks flag.
77
77
/**
78
- * @typedef {{ [K in keyof T as {} extends Record<K, 1> ? never : K]: T[K] } } RemoveIndex<T>
79
- * @template T
80
- */
81
- /**
82
- * @typedef {RemoveIndex<typeof rawOptions> } Options
78
+ * @typedef {{ [K in keyof typeof rawOptions as {} extends Record<K, 1> ? never : K]: typeof rawOptions[K] } } Options
83
79
*/
84
80
const options = /** @type {Options } */ ( rawOptions ) ;
85
81
@@ -107,9 +103,12 @@ const goBuildFlags = [
107
103
] ;
108
104
109
105
/**
110
- * @type {<T>(fn: () => T) => (() => T) }
106
+ * @template T
107
+ * @param {() => T } fn
108
+ * @returns {() => T }
111
109
*/
112
110
function memoize ( fn ) {
111
+ /** @type {T } */
113
112
let value ;
114
113
return ( ) => {
115
114
if ( fn !== undefined ) {
@@ -842,21 +841,20 @@ const mainNativePreviewPackage = {
842
841
* @typedef {"win32" | "linux" | "darwin" } OS
843
842
* @typedef {"x64" | "arm" | "arm64" } Arch
844
843
* @typedef {"Microsoft400" | "LinuxSign" | "MacDeveloperHarden" | "8020" | "VSCodePublisher" } Cert
845
- * @typedef {`${OS}-${Exclude<Arch, "arm"> | "armhf"}` } VSCodeTarget
844
+ * @typedef {`${OS | "alpine" }-${Exclude<Arch, "arm"> | "armhf"}` } VSCodeTarget
846
845
*/
847
846
void 0 ;
848
847
849
848
const nativePreviewPlatforms = memoize ( ( ) => {
850
- /** @type {[OS, Arch, Cert][] } */
849
+ /** @type {[os: OS, arch: Arch, cert: Cert, alpine?: boolean ][] } */
851
850
let supportedPlatforms = [
852
851
[ "win32" , "x64" , "Microsoft400" ] ,
853
852
[ "win32" , "arm64" , "Microsoft400" ] ,
854
- [ "linux" , "x64" , "LinuxSign" ] ,
853
+ [ "linux" , "x64" , "LinuxSign" , true ] ,
855
854
[ "linux" , "arm" , "LinuxSign" ] ,
856
- [ "linux" , "arm64" , "LinuxSign" ] ,
855
+ [ "linux" , "arm64" , "LinuxSign" , true ] ,
857
856
[ "darwin" , "x64" , "MacDeveloperHarden" ] ,
858
857
[ "darwin" , "arm64" , "MacDeveloperHarden" ] ,
859
- // Alpine?
860
858
// Wasm?
861
859
] ;
862
860
@@ -865,17 +863,32 @@ const nativePreviewPlatforms = memoize(() => {
865
863
assert . equal ( supportedPlatforms . length , 1 , "No supported platforms found" ) ;
866
864
}
867
865
868
- return supportedPlatforms . map ( ( [ os , arch , cert ] ) => {
866
+ return supportedPlatforms . map ( ( [ os , arch , cert , alpine ] ) => {
869
867
const npmDirName = `native-preview-${ os } -${ arch } ` ;
870
868
const npmDir = path . join ( builtNpm , npmDirName ) ;
871
869
const npmTarball = `${ npmDir } .tgz` ;
872
870
const npmPackageName = `@typescript/${ npmDirName } ` ;
873
- /** @type {VSCodeTarget } */
874
- const vscodeTarget = `${ os } -${ arch === "arm" ? "armhf" : arch } ` ;
875
- const extensionDir = path . join ( builtVsix , `typescript-native-preview-${ vscodeTarget } ` ) ;
876
- const vsixPath = extensionDir + ".vsix" ;
877
- const vsixManifestPath = extensionDir + ".manifest" ;
878
- const vsixSignaturePath = extensionDir + ".signature.p7s" ;
871
+
872
+ /** @type {VSCodeTarget[] } */
873
+ const vscodeTargets = [ `${ os } -${ arch === "arm" ? "armhf" : arch } ` ] ;
874
+ if ( alpine ) {
875
+ vscodeTargets . push ( `alpine-${ arch === "arm" ? "armhf" : arch } ` ) ;
876
+ }
877
+
878
+ const extensions = vscodeTargets . map ( vscodeTarget => {
879
+ const extensionDir = path . join ( builtVsix , `typescript-native-preview-${ vscodeTarget } ` ) ;
880
+ const vsixPath = extensionDir + ".vsix" ;
881
+ const vsixManifestPath = extensionDir + ".manifest" ;
882
+ const vsixSignaturePath = extensionDir + ".signature.p7s" ;
883
+ return {
884
+ vscodeTarget,
885
+ extensionDir,
886
+ vsixPath,
887
+ vsixManifestPath,
888
+ vsixSignaturePath,
889
+ } ;
890
+ } ) ;
891
+
879
892
return {
880
893
nodeOs : os ,
881
894
nodeArch : arch ,
@@ -885,11 +898,7 @@ const nativePreviewPlatforms = memoize(() => {
885
898
npmDirName,
886
899
npmDir,
887
900
npmTarball,
888
- vscodeTarget,
889
- extensionDir,
890
- vsixPath,
891
- vsixManifestPath,
892
- vsixSignaturePath,
901
+ extensions,
893
902
cert,
894
903
} ;
895
904
} ) ;
@@ -1040,6 +1049,7 @@ export const signNativePreviewPackages = task({
1040
1049
SignFileRecordList : [ ] ,
1041
1050
} ;
1042
1051
1052
+ /** @type {{ path: string; unsignedZipPath: string; signedZipPath: string; notarizedZipPath: string; }[] } */
1043
1053
const macZips = [ ] ;
1044
1054
1045
1055
// First, sign the files.
@@ -1175,8 +1185,9 @@ export const packNativePreviewExtensions = task({
1175
1185
console . log ( "Version:" , version ) ;
1176
1186
1177
1187
const platforms = nativePreviewPlatforms ( ) ;
1188
+ const extensions = platforms . flatMap ( ( { npmDir, extensions } ) => extensions . map ( e => ( { npmDir, ...e } ) ) ) ;
1178
1189
1179
- await Promise . all ( platforms . map ( async ( { npmDir, vscodeTarget, extensionDir : thisExtensionDir , vsixPath, vsixManifestPath, vsixSignaturePath } ) => {
1190
+ await Promise . all ( extensions . map ( async ( { npmDir, vscodeTarget, extensionDir : thisExtensionDir , vsixPath, vsixManifestPath, vsixSignaturePath } ) => {
1180
1191
const npmLibDir = path . join ( npmDir , "lib" ) ;
1181
1192
const extensionLibDir = path . join ( thisExtensionDir , "lib" ) ;
1182
1193
await fs . promises . mkdir ( extensionLibDir , { recursive : true } ) ;
@@ -1211,10 +1222,12 @@ export const signNativePreviewExtensions = task({
1211
1222
}
1212
1223
1213
1224
const platforms = nativePreviewPlatforms ( ) ;
1225
+ const extensions = platforms . flatMap ( ( { npmDir, extensions } ) => extensions . map ( e => ( { npmDir, ...e } ) ) ) ;
1226
+
1214
1227
await sign ( {
1215
1228
SignFileRecordList : [
1216
1229
{
1217
- SignFileList : platforms . map ( ( { vsixSignaturePath } ) => ( { SrcPath : vsixSignaturePath , DstPath : null } ) ) ,
1230
+ SignFileList : extensions . map ( ( { vsixSignaturePath } ) => ( { SrcPath : vsixSignaturePath , DstPath : null } ) ) ,
1218
1231
Certs : "VSCodePublisher" ,
1219
1232
} ,
1220
1233
] ,
@@ -1244,7 +1257,7 @@ export const installExtension = task({
1244
1257
throw new Error ( `No platform found for ${ process . platform } -${ process . arch } ` ) ;
1245
1258
}
1246
1259
1247
- await $ `${ options . insiders ? "code-insiders" : "code" } --install-extension ${ myPlatform . vsixPath } ` ;
1260
+ await $ `${ options . insiders ? "code-insiders" : "code" } --install-extension ${ myPlatform . extensions [ 0 ] . vsixPath } ` ;
1248
1261
console . log ( pc . yellowBright ( "\nExtension installed. " ) + "To enable this extension, set:\n" ) ;
1249
1262
console . log ( pc . whiteBright ( ` "typescript.experimental.useTsgo": true\n` ) ) ;
1250
1263
console . log ( "To configure the extension to use built/local instead of its bundled tsgo, set:\n" ) ;
0 commit comments