Skip to content

Commit 5ff2787

Browse files
committed
Create ".jangle/settings.json" files for new projects
1 parent ed1b82a commit 5ff2787

File tree

13 files changed

+1010
-50
lines changed

13 files changed

+1010
-50
lines changed

elm.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@
1717
"elm-community/html-extra": "3.4.0",
1818
"elm-community/json-extra": "4.3.0",
1919
"elm-community/string-extra": "4.0.1",
20-
"ryannhg/graphql": "1.0.0"
20+
"miniBill/elm-codec": "2.0.0",
21+
"ryannhg/graphql": "1.0.0",
22+
"truqu/elm-base64": "2.0.4"
2123
},
2224
"indirect": {
2325
"elm/bytes": "1.0.8",

graphql/github/mutations/UpdateFile.graphql

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
mutation UpdateFile(
32
$branchId: ID!
43
$expectedHeadOid: GitObjectID!

graphql/github/queries/GetDefaultBranchInfo.graphql renamed to graphql/github/queries/DefaultBranchInfo.graphql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
query GetDefaultBranchInfo($owner: String!, $name: String!) {
1+
query DefaultBranchInfo($owner: String!, $name: String!) {
22
repository(name: $name, owner: $owner) {
33
defaultBranchRef {
44
id

src/Effect.elm

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -621,7 +621,8 @@ toCmd options effect =
621621
sendHttpWithErrorReporting options
622622
{ method = "POST"
623623
, headers =
624-
[ Http.header
624+
[ Http.header "X-Github-Next-Global-ID" "1"
625+
, Http.header
625626
"Authorization"
626627
("Bearer " ++ user.token)
627628
]

src/GitHub/Mutations/UpdateFile.elm

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
module GitHub.Mutations.UpdateFile exposing
2+
( Input, new
3+
, Data
4+
, CreateCommitOnBranchPayload, Commit
5+
)
6+
7+
{-|
8+
9+
@docs Input, new
10+
11+
@docs Data
12+
@docs CreateCommitOnBranchPayload, Commit
13+
14+
-}
15+
16+
import GitHub.Mutations.UpdateFile.Input
17+
import GitHub.Scalars.Base64String
18+
import GitHub.Scalars.GitObjectID
19+
import GraphQL.Decode
20+
import GraphQL.Encode
21+
import GraphQL.Operation exposing (Operation)
22+
import GraphQL.Scalar.Id
23+
24+
25+
26+
-- INPUT
27+
28+
29+
type alias Input =
30+
GitHub.Mutations.UpdateFile.Input.Input {}
31+
32+
33+
new : Input -> GraphQL.Operation.Operation Data
34+
new input =
35+
{ name = "UpdateFile"
36+
, query = """
37+
mutation UpdateFile(
38+
$branchId: ID!
39+
$expectedHeadOid: GitObjectID!
40+
$message: String!
41+
$path: String!
42+
$contents: Base64String!
43+
) {
44+
createCommitOnBranch(input: {
45+
clientMutationId: "jangle-cms"
46+
branch: { id: $branchId }
47+
expectedHeadOid: $expectedHeadOid
48+
message: { headline: $message }
49+
fileChanges: {
50+
additions: [
51+
{ path: $path, contents: $contents }
52+
]
53+
}
54+
}) {
55+
commit { id }
56+
}
57+
}
58+
"""
59+
, variables = GitHub.Mutations.UpdateFile.Input.toInternalValue input
60+
, decoder = decoder
61+
}
62+
63+
64+
65+
-- OUTPUT
66+
67+
68+
type alias Data =
69+
{ createCommitOnBranch : Maybe CreateCommitOnBranchPayload
70+
}
71+
72+
73+
type alias CreateCommitOnBranchPayload =
74+
{ commit : Maybe Commit
75+
}
76+
77+
78+
type alias Commit =
79+
{ id : GraphQL.Scalar.Id.Id
80+
}
81+
82+
83+
decoder : GraphQL.Decode.Decoder Data
84+
decoder =
85+
GraphQL.Decode.object Data
86+
|> GraphQL.Decode.field
87+
{ name = "createCommitOnBranch"
88+
, decoder =
89+
GraphQL.Decode.object CreateCommitOnBranchPayload
90+
|> GraphQL.Decode.field
91+
{ name = "commit"
92+
, decoder =
93+
GraphQL.Decode.object Commit
94+
|> GraphQL.Decode.field
95+
{ name = "id"
96+
, decoder = GraphQL.Decode.id
97+
}
98+
|> GraphQL.Decode.maybe
99+
}
100+
|> GraphQL.Decode.maybe
101+
}
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
module GitHub.Mutations.UpdateFile.Input exposing
2+
( Input, new
3+
, branchId, expectedHeadOid, message, path, contents
4+
, toInternalValue
5+
)
6+
7+
{-|
8+
9+
@docs Input, new
10+
11+
@docs branchId, expectedHeadOid, message, path, contents
12+
@docs null
13+
14+
@docs toInternalValue
15+
16+
-}
17+
18+
import Dict exposing (Dict)
19+
import GitHub.Scalars.Base64String
20+
import GitHub.Scalars.GitObjectID
21+
import GraphQL.Encode
22+
import GraphQL.Scalar.Id
23+
24+
25+
type Input missing
26+
= Input (Dict String GraphQL.Encode.Value)
27+
28+
29+
new :
30+
Input
31+
{ missing
32+
| branchId : GraphQL.Scalar.Id.Id
33+
, expectedHeadOid : GitHub.Scalars.GitObjectID.GitObjectID
34+
, message : String
35+
, path : String
36+
, contents : GitHub.Scalars.Base64String.Base64String
37+
}
38+
new =
39+
Input Dict.empty
40+
41+
42+
branchId :
43+
GraphQL.Scalar.Id.Id
44+
-> Input { missing | branchId : GraphQL.Scalar.Id.Id }
45+
-> Input missing
46+
branchId value_ (Input dict_) =
47+
Input (Dict.insert "branchId" (GraphQL.Encode.id value_) dict_)
48+
49+
50+
expectedHeadOid :
51+
GitHub.Scalars.GitObjectID.GitObjectID
52+
-> Input { missing | expectedHeadOid : GitHub.Scalars.GitObjectID.GitObjectID }
53+
-> Input missing
54+
expectedHeadOid value_ (Input dict_) =
55+
Input (Dict.insert "expectedHeadOid" (GitHub.Scalars.GitObjectID.encode value_) dict_)
56+
57+
58+
message :
59+
String
60+
-> Input { missing | message : String }
61+
-> Input missing
62+
message value_ (Input dict_) =
63+
Input (Dict.insert "message" (GraphQL.Encode.string value_) dict_)
64+
65+
66+
path :
67+
String
68+
-> Input { missing | path : String }
69+
-> Input missing
70+
path value_ (Input dict_) =
71+
Input (Dict.insert "path" (GraphQL.Encode.string value_) dict_)
72+
73+
74+
contents :
75+
GitHub.Scalars.Base64String.Base64String
76+
-> Input { missing | contents : GitHub.Scalars.Base64String.Base64String }
77+
-> Input missing
78+
contents value_ (Input dict_) =
79+
Input (Dict.insert "contents" (GitHub.Scalars.Base64String.encode value_) dict_)
80+
81+
82+
toInternalValue : Input {} -> List ( String, GraphQL.Encode.Value )
83+
toInternalValue (Input dict_) =
84+
Dict.toList dict_
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
module GitHub.Queries.DefaultBranchInfo exposing
2+
( Input, new
3+
, Data
4+
, Repository, Ref, GitObject
5+
)
6+
7+
{-|
8+
9+
@docs Input, new
10+
11+
@docs Data
12+
@docs Repository, Ref, GitObject
13+
14+
-}
15+
16+
import GitHub.Queries.DefaultBranchInfo.Input
17+
import GitHub.Scalars.GitObjectID
18+
import GraphQL.Decode
19+
import GraphQL.Encode
20+
import GraphQL.Operation exposing (Operation)
21+
import GraphQL.Scalar.Id
22+
23+
24+
25+
-- INPUT
26+
27+
28+
type alias Input =
29+
GitHub.Queries.DefaultBranchInfo.Input.Input {}
30+
31+
32+
new : Input -> GraphQL.Operation.Operation Data
33+
new input =
34+
{ name = "DefaultBranchInfo"
35+
, query = """
36+
query DefaultBranchInfo($owner: String!, $name: String!) {
37+
repository(name: $name, owner: $owner) {
38+
defaultBranchRef {
39+
id
40+
target {
41+
oid
42+
}
43+
}
44+
}
45+
}
46+
"""
47+
, variables = GitHub.Queries.DefaultBranchInfo.Input.toInternalValue input
48+
, decoder = decoder
49+
}
50+
51+
52+
53+
-- OUTPUT
54+
55+
56+
type alias Data =
57+
{ repository : Maybe Repository
58+
}
59+
60+
61+
type alias Repository =
62+
{ defaultBranchRef : Maybe Ref
63+
}
64+
65+
66+
type alias Ref =
67+
{ id : GraphQL.Scalar.Id.Id
68+
, target : Maybe GitObject
69+
}
70+
71+
72+
type alias GitObject =
73+
{ oid : GitHub.Scalars.GitObjectID.GitObjectID
74+
}
75+
76+
77+
decoder : GraphQL.Decode.Decoder Data
78+
decoder =
79+
GraphQL.Decode.object Data
80+
|> GraphQL.Decode.field
81+
{ name = "repository"
82+
, decoder =
83+
GraphQL.Decode.object Repository
84+
|> GraphQL.Decode.field
85+
{ name = "defaultBranchRef"
86+
, decoder =
87+
GraphQL.Decode.object Ref
88+
|> GraphQL.Decode.field
89+
{ name = "id"
90+
, decoder = GraphQL.Decode.id
91+
}
92+
|> GraphQL.Decode.field
93+
{ name = "target"
94+
, decoder =
95+
GraphQL.Decode.object GitObject
96+
|> GraphQL.Decode.field
97+
{ name = "oid"
98+
, decoder = GitHub.Scalars.GitObjectID.decoder
99+
}
100+
|> GraphQL.Decode.maybe
101+
}
102+
|> GraphQL.Decode.maybe
103+
}
104+
|> GraphQL.Decode.maybe
105+
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
module GitHub.Queries.DefaultBranchInfo.Input exposing
2+
( Input, new
3+
, owner, name
4+
, toInternalValue
5+
)
6+
7+
{-|
8+
9+
@docs Input, new
10+
11+
@docs owner, name
12+
@docs null
13+
14+
@docs toInternalValue
15+
16+
-}
17+
18+
import Dict exposing (Dict)
19+
import GraphQL.Encode
20+
21+
22+
type Input missing
23+
= Input (Dict String GraphQL.Encode.Value)
24+
25+
26+
new : Input { missing | owner : String, name : String }
27+
new =
28+
Input Dict.empty
29+
30+
31+
owner :
32+
String
33+
-> Input { missing | owner : String }
34+
-> Input missing
35+
owner value_ (Input dict_) =
36+
Input (Dict.insert "owner" (GraphQL.Encode.string value_) dict_)
37+
38+
39+
name :
40+
String
41+
-> Input { missing | name : String }
42+
-> Input missing
43+
name value_ (Input dict_) =
44+
Input (Dict.insert "name" (GraphQL.Encode.string value_) dict_)
45+
46+
47+
toInternalValue : Input {} -> List ( String, GraphQL.Encode.Value )
48+
toInternalValue (Input dict_) =
49+
Dict.toList dict_

0 commit comments

Comments
 (0)