@@ -2,6 +2,7 @@ package cli
2
2
3
3
import (
4
4
"context"
5
+ "encoding/json"
5
6
"fmt"
6
7
"os"
7
8
"path/filepath"
@@ -23,7 +24,6 @@ func add() *cobra.Command {
23
24
artifactory string
24
25
extdir string
25
26
repo string
26
- signature bool
27
27
)
28
28
29
29
cmd := & cobra.Command {
@@ -75,7 +75,7 @@ func add() *cobra.Command {
75
75
return err
76
76
}
77
77
for _ , file := range files {
78
- s , err := doAdd (ctx , filepath .Join (args [0 ], file .Name ()), signature , store )
78
+ s , err := doAdd (ctx , filepath .Join (args [0 ], file .Name ()), store )
79
79
if err != nil {
80
80
_ , _ = fmt .Fprintf (cmd .OutOrStdout (), "Failed to unpack %s: %s\n " , file .Name (), err .Error ())
81
81
failed = append (failed , file .Name ())
@@ -84,7 +84,7 @@ func add() *cobra.Command {
84
84
}
85
85
}
86
86
} else {
87
- s , err := doAdd (ctx , args [0 ], signature , store )
87
+ s , err := doAdd (ctx , args [0 ], store )
88
88
if err != nil {
89
89
return err
90
90
}
@@ -104,12 +104,11 @@ func add() *cobra.Command {
104
104
cmd .Flags ().StringVar (& extdir , "extensions-dir" , "" , "The path to extensions." )
105
105
cmd .Flags ().StringVar (& artifactory , "artifactory" , "" , "Artifactory server URL." )
106
106
cmd .Flags ().StringVar (& repo , "repo" , "" , "Artifactory repository." )
107
- cmd .Flags ().BoolVar (& signature , "signature" , true , "Include signature" )
108
107
109
108
return cmd
110
109
}
111
110
112
- func doAdd (ctx context.Context , source string , includeSignature bool , store storage.Storage ) ([]string , error ) {
111
+ func doAdd (ctx context.Context , source string , store storage.Storage ) ([]string , error ) {
113
112
// Read in the extension. In the future we might support stdin as well.
114
113
vsix , err := storage .ReadVSIX (ctx , source )
115
114
if err != nil {
@@ -123,31 +122,28 @@ func doAdd(ctx context.Context, source string, includeSignature bool, store stor
123
122
return nil , err
124
123
}
125
124
126
- var extra []storage.File
127
- if includeSignature {
128
- sigManifest , err := extensionsign .GenerateSignatureManifest (vsix )
129
- if err != nil {
130
- return nil , xerrors .Errorf ("generate signature manifest: %w" , err )
131
- }
125
+ sigManifest , err := extensionsign .GenerateSignatureManifest (vsix )
126
+ if err != nil {
127
+ return nil , xerrors .Errorf ("zip signature manifest: %w" , err )
128
+ }
132
129
133
- zipped , err := extensionsign . Zip (sigManifest )
134
- if err != nil {
135
- return nil , xerrors .Errorf ("zip signature manifest: %w" , err )
136
- }
130
+ data , err := json . Marshal (sigManifest )
131
+ if err != nil {
132
+ return nil , xerrors .Errorf ("encode manifest: %w" , err )
133
+ }
137
134
138
- extra = append (extra , storage.File {
139
- RelativePath : "extension.sigzip" ,
140
- Content : zipped ,
141
- })
135
+ key , _ := extensionsign .GenerateKey ()
136
+ sigZip , _ := extensionsign .SignAndZipVSIX (key , vsix )
142
137
143
- manifest .Assets .Asset = append (manifest .Assets .Asset , storage.VSIXAsset {
144
- Type : storage .VSIXSignatureType ,
145
- Path : "extension.sigzip" ,
146
- Addressable : "true" , // TODO: Idk if this is right
138
+ location , err := store .AddExtension (ctx , manifest , vsix ,
139
+ storage.File {
140
+ RelativePath : "extension.sigzip" ,
141
+ Content : sigZip ,
142
+ },
143
+ storage.File {
144
+ RelativePath : ".signature.manifest" ,
145
+ Content : data ,
147
146
})
148
- }
149
-
150
- location , err := store .AddExtension (ctx , manifest , vsix , extra ... )
151
147
if err != nil {
152
148
return nil , err
153
149
}
0 commit comments