Skip to content
This repository was archived by the owner on Oct 10, 2022. It is now read-only.

Commit 7c16080

Browse files
committed
Change tomlPath to configPath
1 parent dcfe15a commit 7c16080

File tree

4 files changed

+39
-23
lines changed

4 files changed

+39
-23
lines changed

CONTRIBUTING.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ Projects that depend heavily on this client that should be taken into considerat
4444

4545
```console
4646
# Make changes
47+
# Update README docs if they have changed.
4748
# Update the changelog
4849
$ npm version [major|minor|patch]
4950
$ git push && git push --tags

README.md

Lines changed: 33 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -28,29 +28,38 @@ Create a new instance of the Netlify API client with the provided `accessToken`.
2828
scheme: 'https',
2929
host: 'api.netlify.com',
3030
pathPrefix: '/api/v1',
31-
globalParams: {} // parameters you want available for every request
31+
globalParams: {} // parameters you want available for every request.
32+
// Global params are only sent of the open-api spec specifies the provided params.
3233
}
3334
```
3435

3536
### `client.accessToken`
3637

37-
A setter/getter that returns the `accessToken` that the client is configured to use. You can set this after the class is instantiated, and all subsequent calls will use the newly set `accessToken`.
38+
A setter/getter that returns the `accessToken` that the client is configured to use.
39+
You can set this after the class is instantiated, and all subsequent calls will use the newly set `accessToken`.
3840

3941
### `client.basePath`
4042

4143
A getter that returns the formatted base URL of the endpoint the client is configured to use.
4244

4345
### Open API Client methods
4446

45-
The client is dynamically generated from the [open-api](https://github.com/netlify/open-api) definition file. Each method is is named after the `operationId` name of each endpoint action. **To see list of available operations see the [open-api website](https://open-api.netlify.com/)**.
47+
The client is dynamically generated from the [open-api](https://github.com/netlify/open-api) definition file.
48+
Each method is is named after the `operationId` name of each endpoint action.
49+
**To see list of available operations see the [open-api website](https://open-api.netlify.com/)**.
4650

4751
Every open-api method has the following signature:
4852

4953
#### `promise(response) = client.operationId([params], [opts])`
5054

51-
Perform a call to the given endpoint corresponding with the `operationId`. Returns promise that will resolve with the body of the response, or reject with an error with details about the request attached. Rejects if the `status` > 400. Successful response objects have `status` and `statusText` properties on their prototype.
55+
Perform a call to the given endpoint corresponding with the `operationId`.
56+
Returns promise that will resolve with the body of the response, or reject with an error with details about the request attached.
57+
Rejects if the `status` > 400.
58+
Successful response objects have `status` and `statusText` properties on their prototype.
5259

53-
`params` is an object that includes any of the required or optional endpoint parameters. `params.body` should be an object which gets serialized to JSON automatically. If the endpoint accepts `binary`, `params.body` can be a Node.js readable stream.
60+
`params` is an object that includes any of the required or optional endpoint parameters.
61+
`params.body` should be an object which gets serialized to JSON automatically.
62+
If the endpoint accepts `binary`, `params.body` can be a Node.js readable stream.
5463

5564
```js
5665
// example params
@@ -63,7 +72,8 @@ Perform a call to the given endpoint corresponding with the `operationId`. Retu
6372
}
6473
```
6574

66-
Optional `opts` can include any property you want passed to `node-fetch`. The `headers` property is merged with some `defaultHeaders`.
75+
Optional `opts` can include any property you want passed to `node-fetch`.
76+
The `headers` property is merged with some `defaultHeaders`.
6777

6878
```js
6979
// example opts
@@ -82,23 +92,28 @@ All methods are conveniently consumed with async/await:
8292
async function getSomeData () {
8393
// Calls may fail!
8494
try {
85-
const resposnse = await client.getSites()
86-
return response
95+
return await client.getSiteDeploy({
96+
siteId: '1234abcd',
97+
deploy_id: '4567'
98+
})
8799
} catch (e) {
88100
// handle error
89101
}
90102
}
91103
```
92104

93-
If the request response includes `json` in the `contentType` header, fetch will deserialize the JSON body. Otherwise the `text` of the response is returned.
105+
If the request response includes `json` in the `contentType` header, fetch will deserialize the JSON body.
106+
Otherwise the `text` of the response is returned.
94107

95-
### Convenience Methods
108+
### API Flow Methods
96109

97110
Some methods have been added in addition to the open API methods that make certain actions simpler to perform.
98111

99112
#### `promise(accessToken) = client.getAccessToken(ticket, [opts])`
100113

101-
Pass in a [`ticket`](https://open-api.netlify.com/#model-ticket) and get back an `accessToken`. Call this with the response from a `client.createTicket({ client_id })` call. Automatically sets the `accessToken` to `this.accessToken` and returns `accessToken` for the consumer to save for later.
114+
Pass in a [`ticket`](https://open-api.netlify.com/#model-ticket) and get back an `accessToken`.
115+
Call this with the response from a `client.createTicket({ client_id })` call.
116+
Automatically sets the `accessToken` to `this.accessToken` and returns `accessToken` for the consumer to save for later.
102117

103118
Optional `opts` include:
104119

@@ -121,34 +136,34 @@ async function login () {
121136
await openBrowser(`https://app.netlify.com/authorize?response_type=ticket&ticket=${ticket.id}`)
122137
const accessToken = await api.getAccessToken(ticket)
123138
// API is also set up to use the returned access token as a side effect
124-
return accessToken
139+
return accessToken // Save this for later so you can quickly set up an authenticated client
125140
}
126141
```
127142

128143
#### `promise(deploy) = client.deploy(siteId, buildDir, [opts])`
129144

130145
**Node.js Only**: Pass in a `siteId`, a `buildDir` (the folder you want to deploy) and an options object to deploy the contents of that folder.
131-
Sometimes need to write to a `tmpDir`.
146+
Sometimes this method needs to write to a `tmpDir`. By default `tmpDir` is the default system default.
132147

133148
The following paths can be passed in the options:
134149

135-
- `tomlPath` (a `netlify.toml` file that includes redirect rules for the deploy)
150+
- `configPath` (path to a `netlify.toml` file that includes redirect rules for the deploy, etc.)
136151
- `functionsDir` (a folder with lambda functions to deploy)
137152

138153
Optional `opts` include:
139154

140155
```js
141156
{
142157
functionsDir: null, // path to a folder of functions to deploy
143-
tomlPath: null, // path to a netlify.toml file to include in the deploy (e.g. redirect support for manual deploys)
158+
configPath: null, // path to a netlify.toml file to include in the deploy (e.g. redirect support for manual deploys)
144159
draft: false, // draft deploy or production deploy
145160
message: undefined, // a short message to associate with the deploy
146161
deployTimeout: 1.2e6, // 20 mins
147162
parallelHash: 100, // number of parallel hashing calls
148-
parallelUpload: 4, // number of files to upload in parallel
163+
parallelUpload: 15, // number of files to upload in parallel
149164
maxRetry: 5, // number of times to try on failed file uploads
150-
filter: filename => { /* return false to filter a file from the deploy */ },
151-
tmpDir: tempy.directory(), // a temporary directory to zip loose files into
165+
filter: filepath => { /* return false to filter a file from the deploy */ },
166+
tmpDir: tempy.directory(), // a temporary directory to zip functions into
152167
statusCb: statusObj => {
153168
// a callback function to receive status events
154169
/* statusObj: {

src/deploy/hash-files.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const pump = promisify(require('pump'))
44
const { hasherCtor, manifestCollectorCtor, fileFilterCtor, fileNormalizerCtor } = require('./hasher-segments')
55

66
module.exports = hashFiles
7-
async function hashFiles(dir, tomlPath, opts) {
7+
async function hashFiles(dir, configPath, opts) {
88
opts = Object.assign(
99
{
1010
concurrentHash: 100,
@@ -15,7 +15,7 @@ async function hashFiles(dir, tomlPath, opts) {
1515
)
1616

1717
if (!opts.filter) throw new Error('Missing filter function option')
18-
const fileStream = walker([tomlPath, dir], { filter: opts.filter })
18+
const fileStream = walker([configPath, dir], { filter: opts.filter })
1919
const filter = fileFilterCtor()
2020
const hasher = hasherCtor(opts)
2121
const fileNormalizer = fileNormalizerCtor(opts)

src/deploy/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ module.exports = async (api, siteId, dir, opts) => {
1111
opts = Object.assign(
1212
{
1313
fnDir: null,
14-
tomlPath: null,
14+
configPath: null,
1515
draft: false,
1616
message: undefined, // API calls this the 'title'
1717
tmpDir: tempy.directory(),
@@ -34,7 +34,7 @@ module.exports = async (api, siteId, dir, opts) => {
3434
opts
3535
)
3636

37-
const { fnDir, tomlPath, statusCb, message: title } = opts
37+
const { fnDir, configPath, statusCb, message: title } = opts
3838

3939
statusCb({
4040
type: 'hashing',
@@ -43,7 +43,7 @@ module.exports = async (api, siteId, dir, opts) => {
4343
})
4444

4545
const [{ files, filesShaMap }, { functions, fnShaMap }] = await Promise.all([
46-
hashFiles(dir, tomlPath, opts),
46+
hashFiles(dir, configPath, opts),
4747
hashFns(fnDir, opts)
4848
])
4949

0 commit comments

Comments
 (0)