Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
contentful-sync-cli
Advanced tools
Command line program to sync data from Contentful to local files on disk.
Command line program to sync Contentful data to local files on disk. Data is stored in JSON format.
npm install -g contentful-sync-cli
Use of the Contentful Sync API requires an access token from Contentful. It should be stored in the CONTENTFUL_ACCESS_TOKEN
environment variable.
CONTENTFUL_ACCESS_TOKEN=e5e8d4c5c122cf28fc1af3ff77d28bef78a3952957f15067bbc29f2f0dde0b50
mkdir /tmp/contentful-data-cfexampleapi
cd /tmp/contentful-data-cfexampleapi
contentful-sync fetch cfexampleapi
The current working directory will be populated with the assets and entries from the specified space grouped by content type. Each asset and entry will occupy one file. Each entry will be saved in JSON.
The environment variable containing the Contentful Acces Token may be added to your shell profile.
If you need to sync from multiple Contentful Spaces, then you'll need an access token for each space. Then add the Space ID as a suffix to the environment variable name. For example:
CONTENTFUL_ACCESS_TOKEN_cfexampleapi=e5e8d4c5c122cf28fc1af3ff77d28bef78a3952957f15067bbc29f2f0dde0b50
Run contentful-sync --help
for more details.
Usage: contentful-sync [options] [command]
Commands:
fetch <space> [destination] Fetch content from a space with the Contentful Sync API
Options:
-h, --help output usage information
-V, --version output the version number
-q, --quiet Progress is not reported to the standard error stream.
-v, --verbose Be verbose.
-a, --access-token <token> Contentful Access Token
-i, --initial Fetch everything instead of fetching only what has changed.
-r, --resolve-links <boolean> Resolve links to other entries and assets.
-t, --type <type> What to sync: all (default), Asset, Entry, Deletion, DeletedAsset, or DeletedEntry
-c, --content-type <content-type> Limit sync to entries of specified content type. Implies --type Entry
--host <api host> Sync from Content Preview API or Content Delivery API
const contentfulSync = require('contentful-sync-cli');
let options = {
"accessToken": process.env.CONTENTFUL_ACCESS_TOKEN,
"space": "cfexampleapi",
"destination": "/tmp/contentful-data-cfexampleapi"
};
contentfulSync.fetch(options)
.then(() => {
console.log("Saved data to %s", options.destination);
})
.catch((err) => {
console.log(err);
});
Once the Contentful data is fetched, then it may be accessed with the contentful-local
library. This library mirrors the official client API with the following differences:
By default, you get all entries, instead of 100, with no upper limit.
const contentful = require("contentful-sync-cli/contentful-local");
const client = contentful.createClient({
space: "cfexampleapi",
localPath: "/tmp/contentful-data-cfexampleapi"
});
client.getEntries()
.then(function (entries) {
// log the title for all the entries that have it
entries.items.forEach(function (entry) {
if(entry.fields.productName) {
console.log(entry.fields.productName)
}
});
});
Or, if you would like to limit the number of entries you get:
client.getEntries({
skip: 100,
limit: 200,
order: 'sys.createdAt'
})
.then(function (entries) {
console.log(entries.items.length) // 200
});
To proxy HTTP(S) requests, then set the appropriate npm config variables.
npm config set https-proxy http://proxy.example.com:3128/
npm config set proxy http://proxy.example.com:3128/
If the npm config variables are not found, then these environment variables will be used.
HTTPS_PROXY=http://proxy.example.com:3128/
HTTP_PROXY=http://proxy.example.com:3128/
{
"space": null, // ID of the space you want to sync
"destination": null, // where to save the data files
"accessToken": null, // your acces token
"initial": null, // set to true to delete local data files and sync
"resolveLinks": true, // links from entries to other entries and assets will also be resolved
"type": "all", // OR Asset, Entry, Deletion, DeletedAsset, or DeletedEntry
"content_type": null, // type must be Entry,
"host": null, // API host, defaults to preview.contentful.com unless NODE_ENV is production
}
October 21, 2019 – v3.0.9
October 21, 2019 – v3.0.8
February 19, 2019 – v3.0.7
January 8, 2019 – v3.0.6
November 6, 2018 – v3.0.5
June 19, 2018 – v3.0.4
January 5, 2018 – v3.0.3
October 17, 2017 – v3.0.2
October 16, 2017 – v3.0.1
June 5, 2017 – v3.0.0
June 2, 2017 – v2.2.1
June 1, 2017 – v2.2.0
June 1, 2017 – v2.1.4
May 19, 2017 – v2.1.3
May 19, 2017 – v2.1.2
April 6, 2017 – v2.1.1
March 15, 2017 – v2.1.0
March 14, 2017 – v2.0.2
March 14, 2017 – v2.0.1
March 14, 2017 – v2.0.0
host
option for #fetch()locale
option to request a specific localeinclude
option for additional levelsFebruary 13, 2017 – v1.1.0
January 19, 2017 – v1.0.3
January 19, 2017 – v1.0.2
October 26, 2016 – v1.0.1
October 20, 2016 – v1.0.0
fetch
sub-commandFAQs
Command line program to sync data from Contentful to local files on disk.
The npm package contentful-sync-cli receives a total of 6 weekly downloads. As such, contentful-sync-cli popularity was classified as not popular.
We found that contentful-sync-cli demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.