Skip to content
This repository was archived by the owner on Oct 10, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
max_line_length = 120
trim_trailing_whitespace = true
insert_final_newline = true
40 changes: 40 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
const { overrides } = require('@netlify/eslint-config-node')

module.exports = {
extends: '@netlify/eslint-config-node',
rules: {
// TODO: enable those rules
'array-callback-return': 0,
complexity: 0,
'consistent-this': 0,
'func-names': 0,
'func-style': 0,
'id-length': 0,
'line-comment-position': 0,
'max-nested-callbacks': 0,
'max-statements': 0,
'no-await-in-loop': 0,
'no-inline-comments': 0,
'no-magic-numbers': 0,
'no-param-reassign': 0,
'no-promise-executor-return': 0,
'no-shadow': 0,
'fp/no-class': 0,
'fp/no-delete': 0,
'fp/no-let': 0,
'fp/no-loops': 0,
'fp/no-mutating-assign': 0,
'fp/no-mutating-methods': 0,
'fp/no-mutation': 0,
'fp/no-this': 0,
'node/exports-style': 0,
'node/global-require': 0,
'node/prefer-global/process': 0,
'promise/no-callback-in-promise': 0,
'promise/prefer-await-to-callbacks': 0,
'promise/prefer-await-to-then': 0,
'unicorn/filename-case': 0,
'you-dont-need-lodash-underscore/flatten': 0,
},
overrides: [...overrides],
}
41 changes: 0 additions & 41 deletions .eslintrc.json

This file was deleted.

1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* text=auto eol=lf
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Use the commands below to provide key information from your environment:
You do NOT have to include this information if this is a FEATURE REQUEST
-->

**- Do you want to request a *feature* or report a *bug*?**
**- Do you want to request a _feature_ or report a _bug_?**

**- What is the current behavior?**

Expand Down
33 changes: 21 additions & 12 deletions .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,20 @@ on:
tags: ['*']
pull_request:
types: [opened, synchronize, reopened]
env:
CI: 'true'
jobs:
build:
runs-on: ${{ matrix.os }}
timeout-minutes: 30
strategy:
matrix:
os: [ubuntu-latest, macOS-latest, windows-latest]
node-version: [8.3.0, 14]
node-version: [8.17.0, 14.x]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Align with Netlify Build. We're also removing Node 8 support soon.

exclude:
- os: macOS-latest
node-version: 8.3.0
node-version: 8.17.0
- os: windows-latest
node-version: 8.3.0
node-version: 8.17.0
fail-fast: false
runs-on: ${{ matrix.os }}
steps:
- name: Git checkout
uses: actions/checkout@v2
Expand All @@ -29,14 +28,24 @@ jobs:
with:
node-version: ${{ matrix.node-version }}
- name: Install dependencies
run: npm install
run: npm ci
- name: Linting
run: npm run format
if: "${{ matrix.node-version == '14' }}"
run: npm run format:ci
if: "${{ matrix.node-version == '14.x' }}"
- name: Tests
run: npm run test:ci
- name: Get test coverage flags
id: test-coverage-flags
run: |-
os=${{ matrix.os }}
node=${{ matrix.node-version }}
echo "::set-output name=os::${os/-latest/}"
echo "::set-output name=node::node_${node//./}"
shell: bash
- uses: codecov/codecov-action@v1
with:
file: coverage/coverage-final.json
flags: ${{ steps.test-coverage-flags.outputs.os }},${{ steps.test-coverage-flags.outputs.node }}
- name: Build
run: npm run build
if: "${{ matrix.node-version == '14' }}"
- name: Codecov test coverage
run: bash scripts/coverage.sh "${{ matrix.os }}" "${{ matrix.node-version }}"
if: "${{ matrix.node-version == '14.x' }}"
6 changes: 1 addition & 5 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
{
"semi": false,
"singleQuote": true,
"printWidth": 120
}
"@netlify/eslint-config-node/.prettierrc.json"
61 changes: 34 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,31 +9,38 @@ A Netlify [OpenAPI](https://github.com/netlify/open-api) client that works in th

```js
const NetlifyAPI = require('netlify')
const client = new NetlifyAPI('1234myAccessToken')
const sites = await client.listSites()

const listNetlifySites = async function() {
const client = new NetlifyAPI('1234myAccessToken')
const sites = await client.listSites()
return sites
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Top-level await still confuses ESLint.

```

## Using OpenAPI operations

```js
const NetlifyAPI = require('netlify')

const client = new NetlifyAPI('1234myAccessToken')

// Fetch sites
const sites = await client.listSites()
const listCreateAndDeleteSite = async function() {
// Fetch sites
const sites = await client.listSites()

// Create a site. Notice `body` here for sending OpenAPI body
const site = await client.createSite({
body: {
name: `my-awesome-site`,
// ... https://open-api.netlify.com/#/default/createSite
},
})
// Create a site. Notice `body` here for sending OpenAPI body
const site = await client.createSite({
body: {
name: `my-awesome-site`,
// ... https://open-api.netlify.com/#/default/createSite
},
})

// Delete site. Notice `site_id` is a path parameter https://open-api.netlify.com/#/default/deleteSite
await client.deleteSite({
site_id: siteId,
})
// Delete site. Notice `site_id` is a path parameter https://open-api.netlify.com/#/default/deleteSite
await client.deleteSite({
site_id: siteId,
})
}
```

## API
Expand All @@ -47,7 +54,7 @@ Create a new instance of the Netlify API client with the provided `accessToken`.
`opts` includes:

```js
{
const opts = {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Otherwise, ESLint seems to fail at parsing this.

userAgent: 'netlify/js-client',
scheme: 'https',
host: 'api.netlify.com',
Expand Down Expand Up @@ -83,7 +90,7 @@ Performs a call to the given endpoint corresponding with the `operationId`. Retu

```js
// example params
{
const params = {
any_param_needed,
paramsCanAlsoBeCamelCase,
body: {
Expand All @@ -96,7 +103,7 @@ Optional `opts` can include any property you want passed to [`node-fetch`](https

```js
// example opts
{
const opts = {
headers: { // Default headers
'User-agent': 'netlify-js-client',
accept: 'application/json'
Expand All @@ -115,7 +122,7 @@ async function getSomeData() {
siteId: '1234abcd',
deploy_id: '4567',
})
} catch (e) {
} catch (error) {
// handle error
}
}
Expand All @@ -134,7 +141,7 @@ Pass in a [`ticket`](https://open-api.netlify.com/#model-ticket) and get back an
Optional `opts` include:

```js
{
const opts = {
poll: 1000, // number of ms to wait between polling
timeout: 3.6e6 // number of ms to wait before timing out
}
Expand Down Expand Up @@ -169,7 +176,7 @@ The following paths can be passed in the options:
Optional `opts` include:

```js
{
const opts = {
fnDir: null, // path to a folder of functions to deploy
branch: null, // branch to pass onto the netlify api
configPath: null, // path to a netlify.toml file to include in the deploy (e.g. redirect support for manual deploys)
Expand All @@ -183,17 +190,17 @@ Optional `opts` include:
tmpDir: tempy.directory(), // a temporary directory to zip functions into
statusCb: statusObj => {
// a callback function to receive status events
/* statusObj: {
type: name-of-step
msg: msg to print
phase: [start, progress, stop]
} */
// statusObj: {
// type: name-of-step
// msg: msg to print
// phase: [start, progress, stop]
// }
// See https://github.com/netlify/cli/blob/v2.0.0-beta.3/src/commands/deploy.js#L161-L195
// for an example of how this can be used.
},
// passing a deployId will update an existing deploy based on the provided options
deployId: null
}
}
```

## Proxy support
Expand Down
6 changes: 0 additions & 6 deletions ava.config.js

This file was deleted.

Loading