Skip to content

Commit 593283b

Browse files
chore: init
0 parents  commit 593283b

15 files changed

+7465
-0
lines changed

.babelrc

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"env": {
3+
"test": {
4+
"presets": [
5+
["@babel/preset-env", {
6+
"targets": {
7+
"node": "current"
8+
}
9+
}]
10+
]
11+
}
12+
}
13+
}

.eslintrc.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module.exports = {
2+
root: true,
3+
extends: [
4+
'@nuxtjs'
5+
]
6+
}

.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
node_modules
2+
*.iml
3+
.idea
4+
*.log*
5+
.nuxt*
6+
.vscode
7+
.DS_STORE
8+
coverage
9+
dist

.idea/vcs.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.travis.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
language: node_js
2+
node_js:
3+
- "10"
4+
- "11"
5+
cache:
6+
yarn: true
7+
directories:
8+
- node_modules
9+
install:
10+
- yarn
11+
script:
12+
- yarn test
13+
after_success:
14+
- yarn coverage

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) Alexander Lichter <[email protected]>
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# wait-for-netlify-preview
2+
3+
> Let you Travis CI wait for the Netlify build preview
4+
5+
[![npm (scoped with tag)](https://img.shields.io/npm/v/wait-for-netlify-preview/latest.svg?style=flat-square)](https://npmjs.com/package/wait-for-netlify-preview)
6+
[![npm](https://img.shields.io/npm/dt/wait-for-netlify-preview.svg?style=flat-square)](https://npmjs.com/package/wait-for-netlify-preview)
7+
[![Build Status](https://travis-ci.com/Developmint/wait-for-netlify-preview.svg?branch=master)](https://travis-ci.com/Developmint/wait-for-netlify-preview)
8+
[![codecov](https://codecov.io/gh/Developmint/wait-for-netlify-preview/branch/master/graph/badge.svg)](https://codecov.io/gh/Developmint/wait-for-netlify-preview)
9+
[![Dependencies](https://david-dm.org/Developmint/wait-for-netlify-preview/status.svg?style=flat-square)](https://david-dm.org/Developmint/wait-for-netlify-preview)
10+
[![js-standard-style](https://img.shields.io/badge/code_style-standard-brightgreen.svg?style=flat-square)](http://standardjs.com)
11+
[![thanks](https://img.shields.io/badge/thanks-%E2%99%A5-ff69b4.svg)](https://thanks.lichter.io/)
12+
13+
[📖 **Release Notes**](./CHANGELOG.md)
14+
15+
## Setup
16+
17+
### Yarn
18+
19+
```
20+
$ yarn add wait-for-netlify-preview
21+
```
22+
23+
### npm
24+
25+
```
26+
$ npm install --save wait-for-netlify-preview
27+
```
28+
29+
## Usage
30+
31+
Requires the following environment variables:
32+
- `GITHUB_API_TOKEN`
33+
- `TRAVIS_PULL_REQUEST_SHA`
34+
- `TRAVIS_REPO_SLUG`
35+
36+
```
37+
$ wait-for-netlify-preview
38+
```
39+
40+
An example `.travis.yml` can be found here soon!
41+
42+
## Development
43+
44+
- Clone this repository
45+
- Install dependencies using `yarn install` or `npm install`
46+
- Start development server using `npm run dev`
47+
48+
## License
49+
50+
[MIT License](./LICENSE)
51+
52+
Copyright (c) Alexander Lichter
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
{
2+
"state": "success",
3+
"statuses": [
4+
{
5+
"url": "https://api.github.com/repos/manniL/lichter.io/statuses/50ad1b7dccafa9b08ee3fe70b18df5cce3b6c4b0",
6+
"avatar_url": "https://avatars3.githubusercontent.com/in/13473?v=4",
7+
"id": 6027259754,
8+
"node_id": "MDEzOlN0YXR1c0NvbnRleHQ2MDI3MjU5NzU0",
9+
"state": "success",
10+
"description": "Deploy preview ready!",
11+
"target_url": "https://deploy-preview-26--lichterio.netlify.com",
12+
"context": "netlify/lichterio/deploy-preview",
13+
"created_at": "2019-01-04T00:46:53Z",
14+
"updated_at": "2019-01-04T00:46:53Z"
15+
}
16+
],
17+
"sha": "50ad1b7dccafa9b08ee3fe70b18df5cce3b6c4b0",
18+
"total_count": 1,
19+
"repository": {
20+
"id": 110095223,
21+
"node_id": "MDEwOlJlcG9zaXRvcnkxMTAwOTUyMjM=",
22+
"name": "lichter.io",
23+
"full_name": "manniL/lichter.io",
24+
"private": false,
25+
"html_url": "https://github.com/manniL/lichter.io",
26+
"description": "My own website and CV",
27+
"fork": false,
28+
"url": "https://api.github.com/repos/manniL/lichter.io",
29+
"forks_url": "https://api.github.com/repos/manniL/lichter.io/forks",
30+
"keys_url": "https://api.github.com/repos/manniL/lichter.io/keys{/key_id}",
31+
"collaborators_url": "https://api.github.com/repos/manniL/lichter.io/collaborators{/collaborator}",
32+
"teams_url": "https://api.github.com/repos/manniL/lichter.io/teams",
33+
"hooks_url": "https://api.github.com/repos/manniL/lichter.io/hooks",
34+
"issue_events_url": "https://api.github.com/repos/manniL/lichter.io/issues/events{/number}",
35+
"events_url": "https://api.github.com/repos/manniL/lichter.io/events",
36+
"assignees_url": "https://api.github.com/repos/manniL/lichter.io/assignees{/user}",
37+
"branches_url": "https://api.github.com/repos/manniL/lichter.io/branches{/branch}",
38+
"tags_url": "https://api.github.com/repos/manniL/lichter.io/tags",
39+
"blobs_url": "https://api.github.com/repos/manniL/lichter.io/git/blobs{/sha}",
40+
"git_tags_url": "https://api.github.com/repos/manniL/lichter.io/git/tags{/sha}",
41+
"git_refs_url": "https://api.github.com/repos/manniL/lichter.io/git/refs{/sha}",
42+
"trees_url": "https://api.github.com/repos/manniL/lichter.io/git/trees{/sha}",
43+
"statuses_url": "https://api.github.com/repos/manniL/lichter.io/statuses/{sha}",
44+
"languages_url": "https://api.github.com/repos/manniL/lichter.io/languages",
45+
"stargazers_url": "https://api.github.com/repos/manniL/lichter.io/stargazers",
46+
"contributors_url": "https://api.github.com/repos/manniL/lichter.io/contributors",
47+
"subscribers_url": "https://api.github.com/repos/manniL/lichter.io/subscribers",
48+
"subscription_url": "https://api.github.com/repos/manniL/lichter.io/subscription",
49+
"commits_url": "https://api.github.com/repos/manniL/lichter.io/commits{/sha}",
50+
"git_commits_url": "https://api.github.com/repos/manniL/lichter.io/git/commits{/sha}",
51+
"comments_url": "https://api.github.com/repos/manniL/lichter.io/comments{/number}",
52+
"issue_comment_url": "https://api.github.com/repos/manniL/lichter.io/issues/comments{/number}",
53+
"contents_url": "https://api.github.com/repos/manniL/lichter.io/contents/{+path}",
54+
"compare_url": "https://api.github.com/repos/manniL/lichter.io/compare/{base}...{head}",
55+
"merges_url": "https://api.github.com/repos/manniL/lichter.io/merges",
56+
"archive_url": "https://api.github.com/repos/manniL/lichter.io/{archive_format}{/ref}",
57+
"downloads_url": "https://api.github.com/repos/manniL/lichter.io/downloads",
58+
"issues_url": "https://api.github.com/repos/manniL/lichter.io/issues{/number}",
59+
"pulls_url": "https://api.github.com/repos/manniL/lichter.io/pulls{/number}",
60+
"milestones_url": "https://api.github.com/repos/manniL/lichter.io/milestones{/number}",
61+
"notifications_url": "https://api.github.com/repos/manniL/lichter.io/notifications{?since,all,participating}",
62+
"labels_url": "https://api.github.com/repos/manniL/lichter.io/labels{/name}",
63+
"releases_url": "https://api.github.com/repos/manniL/lichter.io/releases{/id}",
64+
"deployments_url": "https://api.github.com/repos/manniL/lichter.io/deployments"
65+
},
66+
"commit_url": "https://api.github.com/repos/manniL/lichter.io/commits/50ad1b7dccafa9b08ee3fe70b18df5cce3b6c4b0",
67+
"url": "https://api.github.com/repos/manniL/lichter.io/commits/50ad1b7dccafa9b08ee3fe70b18df5cce3b6c4b0/status"
68+
}

__test__/index.test.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import nock from 'nock'
2+
import pWaitFor from 'p-wait-for'
3+
import consola from 'consola'
4+
import combinedStatusResponse from './combined-status-response'
5+
6+
process.env.TRAVIS_REPO_SLUG = 'manniL/lichter.io'
7+
process.env.TRAVIS_PULL_REQUEST_SHA = '50ad1b7dccafa9b08ee3fe70b18df5cce3b6c4b0'
8+
process.env.GITHUB_API_TOKEN = '111'
9+
10+
beforeEach(() => {
11+
consola.mockTypes(() => jest.fn())
12+
})
13+
14+
nock('https://api.github.com')
15+
.persist()
16+
.get(`/repos/${process.env.TRAVIS_REPO_SLUG}/commits/${process.env.TRAVIS_PULL_REQUEST_SHA}/status`)
17+
.query({ access_token: '111' })
18+
.reply(200, combinedStatusResponse)
19+
20+
test('it calls console.log with deployed url', async () => {
21+
require('..')
22+
await pWaitFor(() => consola.log.mock.calls.length > 0)
23+
24+
const consolaMessages = consola.log.mock.calls.map(c => c[0])
25+
expect(consolaMessages).toContain(combinedStatusResponse.statuses[0].target_url)
26+
}, 30000)

index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#! /usr/bin/env node
2+
module.exports = require('esm')(module, { mode: 'all' })('./main.js').default

0 commit comments

Comments
 (0)