Skip to content

Commit

Permalink
refactor(gists): move payload & hooks to .run functions using gists a…
Browse files Browse the repository at this point in the history
…s the mvp
  • Loading branch information
Ryan Garant committed Sep 14, 2019
1 parent 2a1d3a4 commit 8a08218
Show file tree
Hide file tree
Showing 19 changed files with 659 additions and 465 deletions.
9 changes: 8 additions & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,14 @@
"request": "launch",
"env": { "NODE_ENV": "testing", "GH_USER": "protoEvangelion", "GH_TOKEN": "0001" },
"runtimeArgs": ["-r", "ts-node/register"],
"args": ["${workspaceFolder}/src/debug.ts", "is"],
"args": [
"${workspaceFolder}/src/debug.ts",
"gi",
"--new",
"hello",
"--content",
"Hello World\\!"
],
"console": "integratedTerminal"
}
]
Expand Down
1 change: 1 addition & 0 deletions BREAKING_CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
- Updated error handling
- Clearer logging messages
- Deeper end to end test coverage of critical code paths like authentication
- Remove gist paste deprecation warning

### Issues

Expand Down
24 changes: 14 additions & 10 deletions __tests__/__snapshots__/gists.test.ts.snap

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions __tests__/__snapshots__/repo.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ https://github.com/protoEvangelion/foo

exports[`E2E: Repo Module Test Delete repo \`gh re --delete foo\` 1`] = `
"Deleting repo protoEvangelion/foo
? Are you sure? This action CANNOT be undone. [y/N] ? Are you sure? This action CANNOT be undone. [y/N] y? Are you sure? This action CANNOT be undone. [y/N] y
Successfully deleted repo.
"
`;
Expand Down
4 changes: 2 additions & 2 deletions __tests__/gists.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ describe('E2E: Gist Module Test', () => {
done()
})

it('Delete gists `gh gi --delete 027b64c22a5e8d1bf16bc2cfede77e43 --delete 1ad5b3b35fe6906e8980c0fd7522e2d6`', done => {
it('Delete gists `gh gi --delete 5250d21093b46bd0665c2e8656d16bd2 --delete 30e5d3c69a6997617ab69d07b733105e`', done => {
expect(
runCmd(
'gh gi --delete 027b64c22a5e8d1bf16bc2cfede77e43 --delete 1ad5b3b35fe6906e8980c0fd7522e2d6'
'yes | gh gi --delete 5250d21093b46bd0665c2e8656d16bd2 --delete 30e5d3c69a6997617ab69d07b733105e'
)
).toMatchSnapshot()
done()
Expand Down
104 changes: 100 additions & 4 deletions __tests__/nockFixtures/GistsDelete.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,106 @@
[
{
"scope": "https://api.github.com:443",
"method": "delete",
"path": "/gists/1ad5b3b35fe6906e8980c0fd7522e2d6?",
"method": "DELETE",
"path": "/gists/5250d21093b46bd0665c2e8656d16bd2",
"body": "",
"status": 204,
"response": {}
"response": {},
"rawHeaders": [
"Date",
"Thu, 18 Apr 2019 22:42:02 GMT",
"Content-Type",
"application/octet-stream",
"Connection",
"close",
"Server",
"GitHub.com",
"Status",
"204 No Content",
"X-RateLimit-Limit",
"5000",
"X-RateLimit-Remaining",
"4999",
"X-RateLimit-Reset",
"1555630922",
"X-OAuth-Scopes",
"user, public_repo, repo, repo:status, delete_repo, gist",
"X-Accepted-OAuth-Scopes",
"",
"X-GitHub-Media-Type",
"github.v3; format=json",
"Access-Control-Expose-Headers",
"ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type",
"Access-Control-Allow-Origin",
"*",
"Strict-Transport-Security",
"max-age=31536000; includeSubdomains; preload",
"X-Frame-Options",
"deny",
"X-Content-Type-Options",
"nosniff",
"X-XSS-Protection",
"1; mode=block",
"Referrer-Policy",
"origin-when-cross-origin, strict-origin-when-cross-origin",
"Content-Security-Policy",
"default-src 'none'",
"Vary",
"Accept-Encoding",
"X-GitHub-Request-Id",
"EB65:747E:1C30D89:221FF9E:5CB8FD3A"
]
},
{
"scope": "https://api.github.com:443",
"method": "DELETE",
"path": "/gists/30e5d3c69a6997617ab69d07b733105e",
"body": "",
"status": 204,
"response": {},
"rawHeaders": [
"Date",
"Thu, 18 Apr 2019 22:42:04 GMT",
"Content-Type",
"application/octet-stream",
"Connection",
"close",
"Server",
"GitHub.com",
"Status",
"204 No Content",
"X-RateLimit-Limit",
"5000",
"X-RateLimit-Remaining",
"4998",
"X-RateLimit-Reset",
"1555630922",
"X-OAuth-Scopes",
"user, public_repo, repo, repo:status, delete_repo, gist",
"X-Accepted-OAuth-Scopes",
"",
"X-GitHub-Media-Type",
"github.v3; format=json",
"Access-Control-Expose-Headers",
"ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type",
"Access-Control-Allow-Origin",
"*",
"Strict-Transport-Security",
"max-age=31536000; includeSubdomains; preload",
"X-Frame-Options",
"deny",
"X-Content-Type-Options",
"nosniff",
"X-XSS-Protection",
"1; mode=block",
"Referrer-Policy",
"origin-when-cross-origin, strict-origin-when-cross-origin",
"Content-Security-Policy",
"default-src 'none'",
"Vary",
"Accept-Encoding",
"X-GitHub-Request-Id",
"EB67:4A58:1B763C9:216AADD:5CB8FD3C"
]
}
]
]
78 changes: 65 additions & 13 deletions __tests__/nockFixtures/GistsFork.json
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
[
{
"scope": "https://api.github.com:443",
"method": "post",
"path": "/gists/5444883/fork?",
"body": {},
"method": "POST",
"path": "/gists/5444883/forks",
"body": "",
"status": 201,
"response": {
"url": "https://api.github.com/gists/1ad5b3b35fe000000001e8980c0fd7522e2d6",
"forks_url": "https://api.github.com/gists/1ad5b3b35fe000000001e8980c0fd7522e2d6/forks",
"commits_url": "https://api.github.com/gists/1ad5b3b35fe000000001e8980c0fd7522e2d6/commits",
"url": "https://api.github.com/gists/c93ab6d93dde5dfa3fe9f0b000000001b1643c",
"forks_url": "https://api.github.com/gists/c93ab6d93dde5dfa3fe9f0b000000001b1643c/forks",
"commits_url": "https://api.github.com/gists/c93ab6d93dde5dfa3fe9f0b000000001b1643c/commits",
"id": 1000,
"node_id": 1001,
"git_pull_url": "https://gist.github.com/1ad5b3b35fe000000001e8980c0fd7522e2d6.git",
"git_push_url": "https://gist.github.com/1ad5b3b35fe000000001e8980c0fd7522e2d6.git",
"html_url": "https://gist.github.com/1ad5b3b35fe000000001e8980c0fd7522e2d6",
"git_pull_url": "https://gist.github.com/c93ab6d93dde5dfa3fe9f0b000000001b1643c.git",
"git_push_url": "https://gist.github.com/c93ab6d93dde5dfa3fe9f0b000000001b1643c.git",
"html_url": "https://gist.github.com/c93ab6d93dde5dfa3fe9f0b000000001b1643c",
"files": {
"html5-demos.md": {
"filename": "html5-demos.md",
"type": "text/plain",
"language": "Markdown",
"raw_url": "https://gist.githubusercontent.com/protoEvangelion/1ad5b3b35fe000000001e8980c0fd7522e2d6/raw/25ec9d6bae86e0a41b5fec48ea918a92d8bed480/html5-demos.md",
"raw_url": "https://gist.githubusercontent.com/protoEvangelion/c93ab6d93dde5dfa3fe9f0b000000001b1643c/raw/25ec9d6bae86e0a41b5fec48ea918a92d8bed480/html5-demos.md",
"size": 987
}
},
Expand All @@ -29,7 +29,7 @@
"description": "The HTML5 Amount of Awesomeness (work in progress)",
"comments": 0,
"user": null,
"comments_url": "https://api.github.com/gists/1ad5b3b35fe000000001e8980c0fd7522e2d6/comments",
"comments_url": "https://api.github.com/gists/c93ab6d93dde5dfa3fe9f0b000000001b1643c/comments",
"owner": {
"login": "protoEvangelion",
"id": 1002,
Expand All @@ -51,6 +51,58 @@
"site_admin": false
},
"truncated": false
}
},
"rawHeaders": [
"Server",
"GitHub.com",
"Date",
"Fri, 19 Apr 2019 02:14:07 GMT",
"Content-Type",
"application/json; charset=utf-8",
"Content-Length",
"2121",
"Connection",
"close",
"Status",
"201 Created",
"X-RateLimit-Limit",
"5000",
"X-RateLimit-Remaining",
"4992",
"X-RateLimit-Reset",
"1555643647",
"Cache-Control",
"private, max-age=60, s-maxage=60",
"Vary",
"Accept, Authorization, Cookie, X-GitHub-OTP",
"ETag",
"\"9d15cff921b11df0d08a61ac5f7eaa9e\"",
"X-OAuth-Scopes",
"user, public_repo, repo, repo:status, delete_repo, gist",
"X-Accepted-OAuth-Scopes",
"",
"Location",
"https://api.github.com/gists/c93ab6d93dde5dfa3fe9f0b987b1643c",
"X-GitHub-Media-Type",
"github.v3; format=json",
"Access-Control-Expose-Headers",
"ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type",
"Access-Control-Allow-Origin",
"*",
"Strict-Transport-Security",
"max-age=31536000; includeSubdomains; preload",
"X-Frame-Options",
"deny",
"X-Content-Type-Options",
"nosniff",
"X-XSS-Protection",
"1; mode=block",
"Referrer-Policy",
"origin-when-cross-origin, strict-origin-when-cross-origin",
"Content-Security-Policy",
"default-src 'none'",
"X-GitHub-Request-Id",
"E78D:1EAF:1D5000:417B33:5CB92EED"
]
}
]
]
84 changes: 68 additions & 16 deletions __tests__/nockFixtures/GistsNew.json
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
[
{
"scope": "https://api.github.com:443",
"method": "post",
"path": "/gists?",
"method": "POST",
"path": "/gists",
"body": {
"public": true,
"description": "",
"files": {
"hello": {
"content": "Hello World!"
}
}
},
"public": true
},
"status": 201,
"response": {
"url": "https://api.github.com/gists/027b64c22a5e8d1bf16bc2cfede77e43",
"forks_url": "https://api.github.com/gists/027b64c22a5e8d1bf16bc2cfede77e43/forks",
"commits_url": "https://api.github.com/gists/027b64c22a5e8d1bf16bc2cfede77e43/commits",
"url": "https://api.github.com/gists/000000001e9f6422a8d3cd0feda0a3be845d4",
"forks_url": "https://api.github.com/gists/000000001e9f6422a8d3cd0feda0a3be845d4/forks",
"commits_url": "https://api.github.com/gists/000000001e9f6422a8d3cd0feda0a3be845d4/commits",
"id": 1000,
"node_id": 1001,
"git_pull_url": "https://gist.github.com/027b64c22a5e8d1bf16bc2cfede77e43.git",
"git_push_url": "https://gist.github.com/027b64c22a5e8d1bf16bc2cfede77e43.git",
"html_url": "https://gist.github.com/027b64c22a5e8d1bf16bc2cfede77e43",
"git_pull_url": "https://gist.github.com/000000001e9f6422a8d3cd0feda0a3be845d4.git",
"git_push_url": "https://gist.github.com/000000001e9f6422a8d3cd0feda0a3be845d4.git",
"html_url": "https://gist.github.com/000000001e9f6422a8d3cd0feda0a3be845d4",
"files": {
"hello": {
"filename": "hello",
"type": "text/plain",
"language": null,
"raw_url": "https://gist.githubusercontent.com/protoEvangelion/027b64c22a5e8d1bf16bc2cfede77e43/raw/c57eff55ebc0c000000001af5f72bac72762cf4f4/hello",
"raw_url": "https://gist.githubusercontent.com/protoEvangelion/000000001e9f6422a8d3cd0feda0a3be845d4/raw/c57eff55ebc0c54973903af5f72bac72762cf4f4/hello",
"size": 12,
"truncated": false,
"content": "Hello World!"
Expand All @@ -39,7 +39,7 @@
"description": "",
"comments": 0,
"user": null,
"comments_url": "https://api.github.com/gists/027b64c22a5e8d1bf16bc2cfede77e43/comments",
"comments_url": "https://api.github.com/gists/000000001e9f6422a8d3cd0feda0a3be845d4/comments",
"owner": {
"login": "protoEvangelion",
"id": 1002,
Expand Down Expand Up @@ -83,17 +83,69 @@
"type": "User",
"site_admin": false
},
"version": "f7647e901e64d646af67a085f59cad9d34ecf56f",
"version": "748167055c2d7cdec298a590357095d2709cb2ca",
"committed_at": "2017-10-10T16:00:00Z",
"change_status": {
"total": 1,
"additions": 1,
"deletions": 0
},
"url": "https://api.github.com/gists/027b64c22a5e8d1bf16bc2cfede77e43/f000000001e901e64d646af67a085f59cad9d34ecf56f"
"url": "https://api.github.com/gists/000000001e9f6422a8d3cd0feda0a3be845d4/748167055c2d7cdec298a590357095d2709cb2ca"
}
],
"truncated": false
}
},
"rawHeaders": [
"Server",
"GitHub.com",
"Date",
"Fri, 19 Apr 2019 02:34:19 GMT",
"Content-Type",
"application/json; charset=utf-8",
"Content-Length",
"3363",
"Connection",
"close",
"Status",
"201 Created",
"X-RateLimit-Limit",
"5000",
"X-RateLimit-Remaining",
"4973",
"X-RateLimit-Reset",
"1555644859",
"Cache-Control",
"private, max-age=60, s-maxage=60",
"Vary",
"Accept, Authorization, Cookie, X-GitHub-OTP",
"ETag",
"\"79f4a901ce09891a2467e2b8186f3f7a\"",
"X-OAuth-Scopes",
"user, public_repo, repo, repo:status, delete_repo, gist",
"X-Accepted-OAuth-Scopes",
"",
"Location",
"https://api.github.com/gists/3960e9f6422a8d3cd0feda0a3be845d4",
"X-GitHub-Media-Type",
"github.v3; format=json",
"Access-Control-Expose-Headers",
"ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type",
"Access-Control-Allow-Origin",
"*",
"Strict-Transport-Security",
"max-age=31536000; includeSubdomains; preload",
"X-Frame-Options",
"deny",
"X-Content-Type-Options",
"nosniff",
"X-XSS-Protection",
"1; mode=block",
"Referrer-Policy",
"origin-when-cross-origin, strict-origin-when-cross-origin",
"Content-Security-Policy",
"default-src 'none'",
"X-GitHub-Request-Id",
"E885:4FD3:273707:51E577:5CB933AA"
]
}
]
]
Loading

0 comments on commit 8a08218

Please sign in to comment.