4
4
"context"
5
5
"fmt"
6
6
"github.com/shurcooL/graphql"
7
+ "io/ioutil"
8
+ "path/filepath"
7
9
)
8
10
9
11
type ExtensionContext struct {
@@ -16,7 +18,7 @@ type ExtensionLifecycle interface {
16
18
Build () (bool , error )
17
19
Pack () (string , error )
18
20
Publish () (bool , error )
19
- AddToRegistry () (bool , error )
21
+ AddToRegistry (context * ExtensionContext ) (bool , error )
20
22
}
21
23
22
24
type AbstractExtension struct {
@@ -40,22 +42,30 @@ func (ae AbstractExtension) Build() (bool, error) {
40
42
return runCommand (ae .Context .Dir , ae .Manifest .Scripts .Build , "" )
41
43
}
42
44
43
- func (ae AbstractExtension ) AddToRegistry () (bool , error ) {
45
+ func (ae AbstractExtension ) AddToRegistry (ctx * ExtensionContext ) (bool , error ) {
46
+ manifest := ae .Manifest .String ()
47
+
48
+ data , err := ioutil .ReadFile (filepath .Join (ctx .Dir , ctx .ManifestFile ))
49
+
50
+ if err == nil {
51
+ manifest = string (data )
52
+ }
53
+
44
54
mutation , variables := NewPublishExtensionMutation (PublishExtensionVariables {
45
55
force : true ,
56
+ manifest : manifest ,
46
57
name : ae .Manifest .Name ,
47
58
bundle : ae .Manifest .Bundle ,
48
59
version : ae .Manifest .Version ,
49
- manifest : ae .Manifest .String (),
50
60
extensionID : ae .Manifest .ExtensionID ,
51
61
})
52
62
53
- err := ae .Context .GraphqlClient .Mutate (context .Background (), & mutation , variables )
63
+ netErr := ae .Context .GraphqlClient .Mutate (context .Background (), & mutation , variables )
54
64
55
65
fmt .Printf ("Mutation %s \n " , ae .Manifest .String ())
56
66
57
- if err != nil {
58
- return false , err
67
+ if netErr != nil {
68
+ return false , netErr
59
69
}
60
70
61
71
return true , nil
0 commit comments