contentful 9.1.13 → 10.0.0-beta-v10.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ADVANCED.md +244 -0
- package/CONTRIBUTING.md +111 -0
- package/README.md +171 -234
- package/TYPESCRIPT.md +219 -0
- package/dist/contentful.browser.js +376 -7452
- package/dist/contentful.browser.min.js +1 -1
- package/dist/contentful.node.js +430 -9034
- package/dist/contentful.node.min.js +1 -1
- package/dist/types/contentful.d.ts +29 -0
- package/dist/types/create-contentful-api.d.ts +310 -0
- package/dist/types/create-global-options.d.ts +17 -0
- package/dist/types/index.d.ts +7 -0
- package/dist/types/make-client.d.ts +2 -0
- package/dist/types/mixins/stringify-safe.d.ts +1 -0
- package/dist/types/paged-sync.d.ts +36 -0
- package/dist/types/types/asset-key.d.ts +4 -0
- package/dist/types/types/asset.d.ts +32 -0
- package/dist/types/types/collection.d.ts +6 -0
- package/dist/types/types/content-type.d.ts +64 -0
- package/dist/types/types/entry.d.ts +94 -0
- package/dist/types/types/index.d.ts +12 -0
- package/dist/types/types/link.d.ts +12 -0
- package/dist/types/types/locale.d.ts +18 -0
- package/dist/types/types/metadata.d.ts +4 -0
- package/dist/types/types/query/equality.d.ts +14 -0
- package/dist/types/types/query/existence.d.ts +8 -0
- package/dist/types/types/query/index.d.ts +1 -0
- package/dist/types/types/query/location.d.ts +33 -0
- package/dist/types/types/query/query.d.ts +32 -0
- package/dist/types/types/query/range.d.ts +14 -0
- package/dist/types/types/query/search.d.ts +9 -0
- package/dist/types/types/query/select.d.ts +8 -0
- package/dist/types/types/query/subset.d.ts +14 -0
- package/dist/types/types/query/util.d.ts +10 -0
- package/dist/types/types/space.d.ts +13 -0
- package/dist/types/types/sync.d.ts +9 -0
- package/dist/types/types/sys.d.ts +18 -0
- package/dist/types/types/tag.d.ts +19 -0
- package/dist/types/utils/client-helpers.d.ts +44 -0
- package/dist/types/utils/normalize-select.d.ts +1 -0
- package/dist/types/utils/resolve-circular.d.ts +4 -0
- package/dist/types/utils/validate-params.d.ts +2 -0
- package/dist/types/utils/validate-timestamp.d.ts +6 -0
- package/dist/types/utils/validation-error.d.ts +3 -0
- package/images/contentful-icon.png +0 -0
- package/images/dynamic-query-keys.png +0 -0
- package/images/static-query-keys.png +0 -0
- package/lib/contentful.ts +90 -0
- package/lib/create-contentful-api.ts +905 -0
- package/lib/create-global-options.ts +32 -0
- package/lib/global.d.ts +2 -0
- package/lib/index.ts +8 -0
- package/lib/make-client.ts +178 -0
- package/lib/mixins/stringify-safe.ts +21 -0
- package/lib/paged-sync.ts +178 -0
- package/lib/types/asset-key.ts +4 -0
- package/lib/types/asset.ts +50 -0
- package/lib/types/collection.ts +6 -0
- package/lib/types/content-type.ts +78 -0
- package/lib/types/entry.ts +186 -0
- package/lib/types/index.ts +12 -0
- package/lib/types/link.ts +14 -0
- package/lib/types/locale.ts +22 -0
- package/lib/types/metadata.ts +5 -0
- package/lib/types/query/equality.ts +29 -0
- package/lib/types/query/existence.ts +17 -0
- package/lib/types/query/index.ts +1 -0
- package/lib/types/query/location.ts +68 -0
- package/lib/types/query/query.ts +66 -0
- package/lib/types/query/range.ts +18 -0
- package/lib/types/query/search.ts +17 -0
- package/lib/types/query/select.ts +13 -0
- package/lib/types/query/subset.ts +19 -0
- package/lib/types/query/util.ts +29 -0
- package/lib/types/space.ts +15 -0
- package/lib/types/sync.ts +10 -0
- package/lib/types/sys.ts +16 -0
- package/lib/types/tag.ts +18 -0
- package/lib/utils/client-helpers.ts +99 -0
- package/lib/utils/normalize-select.ts +33 -0
- package/lib/utils/resolve-circular.ts +13 -0
- package/lib/utils/validate-params.ts +37 -0
- package/lib/utils/validate-timestamp.ts +33 -0
- package/lib/utils/validation-error.ts +6 -0
- package/package.json +87 -84
- package/dist/contentful.browser.js.map +0 -1
- package/dist/contentful.node.js.map +0 -1
- package/dist/es-modules/contentful.js +0 -94
- package/dist/es-modules/create-contentful-api.js +0 -565
- package/dist/es-modules/create-global-options.js +0 -23
- package/dist/es-modules/entities/asset-key.js +0 -29
- package/dist/es-modules/entities/asset.js +0 -58
- package/dist/es-modules/entities/content-type.js +0 -53
- package/dist/es-modules/entities/entry.js +0 -129
- package/dist/es-modules/entities/index.js +0 -35
- package/dist/es-modules/entities/locale.js +0 -54
- package/dist/es-modules/entities/space.js +0 -28
- package/dist/es-modules/entities/tag.js +0 -50
- package/dist/es-modules/mixins/stringify-safe.js +0 -32
- package/dist/es-modules/paged-sync.js +0 -212
- package/dist/es-modules/utils/normalize-select.js +0 -42
- package/dist/es-modules/utils/validate-timestamp.js +0 -33
- package/index.d.ts +0 -286
package/ADVANCED.md
ADDED
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
<!-- shared header START -->
|
|
2
|
+
|
|
3
|
+
<p align="center">
|
|
4
|
+
<a href="https://www.contentful.com/developers/docs/references/content-delivery-api/">
|
|
5
|
+
<img alt="Contentful Logo" title="Contentful" src="images/contentful-icon.png" width="150">
|
|
6
|
+
</a>
|
|
7
|
+
</p>
|
|
8
|
+
|
|
9
|
+
<h1 align='center'>Content Delivery API</h1>
|
|
10
|
+
|
|
11
|
+
<h3 align="center">Advanced Concepts & Tips</h3>
|
|
12
|
+
|
|
13
|
+
<p align="center">
|
|
14
|
+
<a href="README.md">Readme</a> ·
|
|
15
|
+
<a href="MIGRATION.md">Migration</a> ·
|
|
16
|
+
<a href="ADVANCED.md">Advanced</a> ·
|
|
17
|
+
<a href="TYPESCRIPT.md">TypeScript</a> ·
|
|
18
|
+
<a href="CONTRIBUTING.md">Contributing</a>
|
|
19
|
+
</p>
|
|
20
|
+
|
|
21
|
+
<p align="center">
|
|
22
|
+
<a href="https://www.contentful.com/slack/">
|
|
23
|
+
<img src="https://img.shields.io/badge/-Join%20Community%20Slack-2AB27B.svg?logo=slack&maxAge=31557600" alt="Join Contentful Community Slack">
|
|
24
|
+
</a>
|
|
25
|
+
</p>
|
|
26
|
+
|
|
27
|
+
<!-- shared header END -->
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
> Find helpful concepts and tips about how to use this library.
|
|
31
|
+
|
|
32
|
+
- [Using ES6 import](#using-es6-import)
|
|
33
|
+
- [Framework specifics](#framework-specifics)
|
|
34
|
+
- [Link resolution](#link-resolution)
|
|
35
|
+
- [Note: link resolution for versions older than 10.0.0](#note:-link-resolution-for-versions-older-than-10.0.0)
|
|
36
|
+
- [Note: link resolution for versions older than 7.0.0](#note:-link-resolution-for-versions-older-than-7.0.0)
|
|
37
|
+
- [Sync](#sync)
|
|
38
|
+
- [Sync without pagination](#sync-without-pagination)
|
|
39
|
+
- [Querying & Search parameters](#querying--search-parameters)
|
|
40
|
+
|
|
41
|
+
## Using ES6 import
|
|
42
|
+
|
|
43
|
+
You can use the es6 import with the SDK as follow
|
|
44
|
+
|
|
45
|
+
```js
|
|
46
|
+
import { createClient } from "contentful";
|
|
47
|
+
const client = createClient({...});
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
OR
|
|
51
|
+
|
|
52
|
+
```js
|
|
53
|
+
import * as contentful from "contentful";
|
|
54
|
+
const client = contentful.createClient({...});
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## Framework specifics
|
|
58
|
+
|
|
59
|
+
### React Native & Server Side Rendering
|
|
60
|
+
|
|
61
|
+
This library is able to handle Server Side Rendering and React Native. Depending on your implementation, you may need to explicitly require the `browser` or `node` variant of the library. (webpack usually is able to handle this on its own)
|
|
62
|
+
|
|
63
|
+
```js
|
|
64
|
+
const contentful = require("contentful");
|
|
65
|
+
// will become the following to enforce the browser version
|
|
66
|
+
const contentful = require("contentful/dist/contentful.browser.min.js");
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### Angular Universal
|
|
70
|
+
|
|
71
|
+
This library is able to handle Server Side Rendering with Angular Universal. To use it, you will have to provide a custom [Axios adapter](https://github.com/axios/axios/tree/master/lib/adapters), one example for Angular would be the [ngx-axios-adapter](https://github.com/patrickhousley/ngx-axios-adapter).
|
|
72
|
+
|
|
73
|
+
## Link resolution
|
|
74
|
+
|
|
75
|
+
In Contentful, you can create content that references other content. We call them "linked" or "referenced" entries. In contrast to a simple REST call, this library can render the content of a linked entry in place, using
|
|
76
|
+
the [contentful-resolve-response](https://github.com/contentful/contentful-resolve-response) package. This enables what we call link resolution.
|
|
77
|
+
|
|
78
|
+
**Example entry response without link resolution:**
|
|
79
|
+
|
|
80
|
+
```
|
|
81
|
+
{
|
|
82
|
+
"sys": { ... },
|
|
83
|
+
"metadata": { ... },
|
|
84
|
+
"fields": {
|
|
85
|
+
"referencedEntry": {
|
|
86
|
+
"type": "Link",
|
|
87
|
+
"linkType": "Entry",
|
|
88
|
+
"id": "<referenced-entry-id>"
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
**Example entry response with link resolution:**
|
|
95
|
+
|
|
96
|
+
```
|
|
97
|
+
{
|
|
98
|
+
"sys": { ... },
|
|
99
|
+
"metadata": { ... },
|
|
100
|
+
"fields": {
|
|
101
|
+
"referencedEntry": {
|
|
102
|
+
"sys": { ... },
|
|
103
|
+
"metadata": { ... },
|
|
104
|
+
fields {
|
|
105
|
+
...
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
This makes parsing the response easier, and you don't need to manually extract every linked entry from the response object.
|
|
113
|
+
|
|
114
|
+
The link resolution is applied to one level deep by default. If you need it to be applied deeper, you may specify the `include` parameter when fetching your entries as follows `client.getEntries( {include: <value> })`. The `include` parameter can be set to a number up to 10, which would represent a ten layers deep link resolution.
|
|
115
|
+
|
|
116
|
+
**We resolve links by default**. If this behaviour is not what you want, you can use the chain modifier `withoutLinkResolution` on the Contentful client to keep the link objects instead of the inlined entries in your response object. See [Chained Clients](README.md#chained-clients)
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
**Links which could not get resolved will be kept by default**. If you want to completely remove fields which could not be resolved, you can use the chain modifier `withoutUnresolvableLinks.`
|
|
120
|
+
|
|
121
|
+
Please see the notes below for link resolution prior to v.10.0.0 and v.7.0.0.
|
|
122
|
+
|
|
123
|
+
#### Note: link resolution for versions older than 10.0.0
|
|
124
|
+
|
|
125
|
+
Please note that for versions older than 10.0.0, disabling link resolution needs to be done via [configuration options](README.md#response-configuration-options) during client creation.
|
|
126
|
+
To disable it, set `resolveLinks` to `false` when creating the Contentful client. Like so:
|
|
127
|
+
|
|
128
|
+
```js
|
|
129
|
+
const contentful = require("contentful");
|
|
130
|
+
const client = contentful.createClient({
|
|
131
|
+
accessToken: "<you-access-token>",
|
|
132
|
+
space: "<your-space-id>",
|
|
133
|
+
resolveLinks: false
|
|
134
|
+
});
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
If you want to completely remove fields which could not be resolved, set `removeUnresolved` to `true` in the configuration options.
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
#### Note: link resolution for versions older than 7.0.0
|
|
141
|
+
|
|
142
|
+
Please note that for versions older than 7.0.0, link resolution is only possible when requesting records from the collection endpoint using `client.getEntries()` or by performing an initial sync `client.sync({initial: true})`. In case you want to request one entry and benefit from the link resolution you can use the collection end point with the following query parameter `'sys.id': '<your-entry-id>'`.
|
|
143
|
+
|
|
144
|
+
**e.g.** assuming that you have a Content Type `post` that has a reference field `author`
|
|
145
|
+
|
|
146
|
+
```js
|
|
147
|
+
const contentful = require("contentful");
|
|
148
|
+
const client = contentful.createClient({
|
|
149
|
+
accessToken: "<you-access-token>",
|
|
150
|
+
space: "<your-space-id>"
|
|
151
|
+
});
|
|
152
|
+
// getting a specific Post
|
|
153
|
+
client
|
|
154
|
+
.getEntries({ "sys.id": "<entry-id>" })
|
|
155
|
+
.then(response => {
|
|
156
|
+
// output the author name
|
|
157
|
+
console.log(response.items[0].fields.author.fields.name);
|
|
158
|
+
})
|
|
159
|
+
.catch(err => console.log(err));
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
## Sync
|
|
164
|
+
|
|
165
|
+
The Sync API allows you to keep a local copy of all content in a space up-to-date via delta updates, meaning only changes that occurred since last sync call.
|
|
166
|
+
Whenever you perform a sync operation the endpoint will send back a `syncToken` which you can use in a subsequent sync to only retrieve data which changed since the last call.
|
|
167
|
+
**e.g.**
|
|
168
|
+
|
|
169
|
+
```js
|
|
170
|
+
const contentful = require("contentful");
|
|
171
|
+
const client = contentful.createClient({
|
|
172
|
+
accessToken: "<you-access-token>",
|
|
173
|
+
space: "<your-space-id>"
|
|
174
|
+
});
|
|
175
|
+
// first time you are syncing make sure to specify `initial: true`
|
|
176
|
+
client
|
|
177
|
+
.sync({ initial: true })
|
|
178
|
+
.then(response => {
|
|
179
|
+
// You should save the `nextSyncToken` to use in the following sync
|
|
180
|
+
console.log(response.nextSyncToken);
|
|
181
|
+
})
|
|
182
|
+
.catch(err => console.log(err));
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
The SDK will go through all the pages for you and gives you back a response object with the full data so you don't need to handle pagination.
|
|
186
|
+
|
|
187
|
+
### Sync without pagination
|
|
188
|
+
|
|
189
|
+
You may use syncing without pagination if you want to handle it on your own. To do this, you have to pass `paginate: false` as option when calling sync. You manually have to take care to pass `nextPageToken` or `nextSyncToken` to your subsequent calls. The logic follows our [sync API docs](https://www.contentful.com/developers/docs/references/content-delivery-api/#/reference/synchronization/pagination-and-subsequent-syncs) while you pass tokens instead of full urls.
|
|
190
|
+
|
|
191
|
+
```js
|
|
192
|
+
const contentful = require("contentful");
|
|
193
|
+
const client = contentful.createClient({
|
|
194
|
+
accessToken: "<you-access-token>",
|
|
195
|
+
space: "<your-space-id>"
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
function customPaginatedSync(query) {
|
|
199
|
+
// Call sync, make sure you set paginate to false for every call
|
|
200
|
+
return client.sync(query, { paginate: false }).then(response => {
|
|
201
|
+
// Do something with the respond. For example save result to disk.
|
|
202
|
+
console.log("Result of current sync page:", response.items);
|
|
203
|
+
|
|
204
|
+
// Sync finished when `nextSyncToken` is available
|
|
205
|
+
if (response.nextSyncToken) {
|
|
206
|
+
console.log(
|
|
207
|
+
"Syncing done. Start a new sync via " + response.nextSyncToken
|
|
208
|
+
);
|
|
209
|
+
return;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
// Otherwise, just continue to next page of the current sync run
|
|
213
|
+
return customPaginatedSync({ nextPageToken: response.nextPageToken });
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
customPaginatedSync({ initial: true }).then(() => console.log("Sync done"));
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
## Querying & Search parameters
|
|
221
|
+
|
|
222
|
+
You can pass your query parameters as `key: value` pairs in the query object whenever request a resource. For example:
|
|
223
|
+
|
|
224
|
+
```js
|
|
225
|
+
const contentful = require("contentful");
|
|
226
|
+
const client = contentful.createClient({
|
|
227
|
+
accessToken: "<you-access-token>",
|
|
228
|
+
space: "<your-space-id>"
|
|
229
|
+
});
|
|
230
|
+
|
|
231
|
+
// getting a specific Post
|
|
232
|
+
client
|
|
233
|
+
.getEntries({ "sys.id": "<entry-id>" })
|
|
234
|
+
.then(response => {
|
|
235
|
+
// output the author name
|
|
236
|
+
console.log(response.items[0].fields.author.fields.name);
|
|
237
|
+
})
|
|
238
|
+
.catch(err => console.log(err));
|
|
239
|
+
|
|
240
|
+
// You can pass a query when requesting a single entity
|
|
241
|
+
client.getEntry("<entry-id>", { key: value });
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
For more information about the search parameters, check the [documentation](https://www.contentful.com/developers/docs/references/content-delivery-api/#/reference/search-parameters).
|
package/CONTRIBUTING.md
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
<!-- shared header START -->
|
|
2
|
+
|
|
3
|
+
<p align="center">
|
|
4
|
+
<a href="https://www.contentful.com/developers/docs/references/content-delivery-api/">
|
|
5
|
+
<img alt="Contentful Logo" title="Contentful" src="images/contentful-icon.png" width="150">
|
|
6
|
+
</a>
|
|
7
|
+
</p>
|
|
8
|
+
|
|
9
|
+
<h1 align='center'>Content Delivery API</h1>
|
|
10
|
+
|
|
11
|
+
<h3 align="center">Contributing</h3>
|
|
12
|
+
|
|
13
|
+
<p align="center">
|
|
14
|
+
<a href="README.md">Readme</a> ·
|
|
15
|
+
<a href="MIGRATION.md">Migration</a> ·
|
|
16
|
+
<a href="ADVANCED.md">Advanced</a> ·
|
|
17
|
+
<a href="TYPESCRIPT.md">Typescript</a> ·
|
|
18
|
+
<a href="CONTRIBUTING.md">Contributing</a>
|
|
19
|
+
</p>
|
|
20
|
+
|
|
21
|
+
<p align="center">
|
|
22
|
+
<a href="https://www.contentful.com/slack/">
|
|
23
|
+
<img src="https://img.shields.io/badge/-Join%20Community%20Slack-2AB27B.svg?logo=slack&maxAge=31557600" alt="Join Contentful Community Slack">
|
|
24
|
+
</a>
|
|
25
|
+
</p>
|
|
26
|
+
|
|
27
|
+
<!-- shared header END -->
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
<p align="center">
|
|
31
|
+
<a href="http://makeapullrequest.com">
|
|
32
|
+
<img src="https://img.shields.io/badge/PRs-welcome-brightgreen.svg?maxAge=31557600" alt="PRs Welcome">
|
|
33
|
+
</a>
|
|
34
|
+
|
|
35
|
+
<a href="http://makeapullrequest.com">
|
|
36
|
+
<img src="https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg?maxAge=31557600" alt="Semantic Release">
|
|
37
|
+
</a>
|
|
38
|
+
|
|
39
|
+
<a href="http://standardjs.com/">
|
|
40
|
+
<img src="https://img.shields.io/badge/code%20style-standard-brightgreen.svg?maxAge=31557600" alt="JS Standard Style">
|
|
41
|
+
</a>
|
|
42
|
+
</p>
|
|
43
|
+
|
|
44
|
+
We appreciate any community contributions to this project, whether in the form of issues or pull requests.
|
|
45
|
+
|
|
46
|
+
This document outlines what we'd like you to follow in terms of commit messages and code style.
|
|
47
|
+
|
|
48
|
+
It also explains what to do in case you want to setup the project locally and run tests.
|
|
49
|
+
|
|
50
|
+
**Working on your first Pull Request?** You can learn how from this *free* series [How to Contribute to an Open Source Project on GitHub](https://egghead.io/series/how-to-contribute-to-an-open-source-project-on-github)
|
|
51
|
+
|
|
52
|
+
## Setup
|
|
53
|
+
|
|
54
|
+
This project is written in ES2015 and transpiled to ES5 using Babel, to the `dist` directory. This should generally only happen at publishing time, or for testing purposes only.
|
|
55
|
+
|
|
56
|
+
Run `npm install` to install all necessary dependencies. When running `npm install` locally, `dist` is not compiled.
|
|
57
|
+
|
|
58
|
+
All necessary dependencies are installed under `node_modules` and any necessary tools can be accessed via npm scripts. There is no need to install anything globally.
|
|
59
|
+
|
|
60
|
+
When importing local, in develoment code, via `index.js`, this file checks if `dist` exists and uses that. Otherwise, it uses the code from `lib`.
|
|
61
|
+
|
|
62
|
+
If you have a `dist` directory, run `npm run clean`.
|
|
63
|
+
|
|
64
|
+
Axios, one of the main dependencies is vendored. This generally shouldn't matter, but if you'd like to understand why, check [SETUP.md](SETUP.md)
|
|
65
|
+
|
|
66
|
+
## Useful npm scripts
|
|
67
|
+
|
|
68
|
+
- `npm run clean` removes any built files
|
|
69
|
+
- `npm run build` builds vendored files, node package and browser version
|
|
70
|
+
- `npm run build:dist` builds ES5 sources from ES6 ones
|
|
71
|
+
- `npm run build:standalone` builds unminified and minified sources for browsers
|
|
72
|
+
|
|
73
|
+
## Running tests
|
|
74
|
+
|
|
75
|
+
This project has unit and integration tests. Both of these run on both Node.js and Browser environments.
|
|
76
|
+
|
|
77
|
+
Both of these test environments are setup to deal with Babel and code transpiling, so there's no need to worry about that
|
|
78
|
+
|
|
79
|
+
- `npm test` runs all three kinds of tests and generates a coverage report
|
|
80
|
+
- `npm run test:only` runs Node.js unit tests without coverage. `npm run test:cover` to run Node.js unit tests with coverage. `npm run test:debug` runs babel-node in debug mode (same as running `node debug`).
|
|
81
|
+
- `npm run test:integration` runs the integration tests against the Contentful CDA API
|
|
82
|
+
- `npm run test:browser-local` runs both the unit and integration tests using Karma against local browsers.
|
|
83
|
+
- `npm run test:ci` runs tests in CI
|
|
84
|
+
- `npm run test:browser-remote` runs both the unit and integration tests using Karma against Sauce Labs. This is only usable in the CI environment, as it expects the credentials and connection tunnel to be present.
|
|
85
|
+
|
|
86
|
+
## Documentation
|
|
87
|
+
|
|
88
|
+
Code is documented using JSDoc 3, and reference documentation is published automatically with each new version.
|
|
89
|
+
|
|
90
|
+
- `npm run docs:watch` watches code directory, and rebuilds documentation when anything changes. Useful for documentation writing and development.
|
|
91
|
+
- `npm run docs:dev` builds code and builds docs afterwards. Used by `npm run docs:watch`. Code building is required as the documentation is generated from the unminified ES5 compiled sources, rather than the original ES6 sources. You should then open the generated `out/contentful/index.html` in your browser.
|
|
92
|
+
- `npm run docs:build` builds documentation.
|
|
93
|
+
- `npm run docs:publish` builds documentation and publishes it to github pages.
|
|
94
|
+
|
|
95
|
+
## Code style
|
|
96
|
+
|
|
97
|
+
This project uses [standard](https://github.com/feross/standard). Install a relevant editor plugin if you'd like.
|
|
98
|
+
|
|
99
|
+
Everywhere where it isn't applicable, follow a style similar to the existing code.
|
|
100
|
+
|
|
101
|
+
## Commit messages and issues
|
|
102
|
+
|
|
103
|
+
This project uses the [Angular JS Commit Message Conventions](https://docs.google.com/document/d/1QrDFcIiPjSLDn3EL15IJygNPiHORgU1_OOAqWjiDU5Y/edit), via semantic-release. See the semantic-release [Default Commit Message Format](https://github.com/semantic-release/semantic-release#default-commit-message-format) section for more details.
|
|
104
|
+
|
|
105
|
+
## Versioning
|
|
106
|
+
|
|
107
|
+
This project strictly follows [Semantic Versioning](http://semver.org/) by use of [semantic-release](https://github.com/semantic-release/semantic-release).
|
|
108
|
+
|
|
109
|
+
This means that new versions are released automatically as fixes, features or breaking changes are released.
|
|
110
|
+
|
|
111
|
+
You can check the changelog on the [releases](https://github.com/contentful/contentful.js/releases) page.
|