Merge pull request 'upgrade' (#2) from upgrade into main

## Détails

- Upgrade npm packages
- Fix breaking change on [9.5.2](https://github.com/directus/directus/releases/tag/v9.5.2)
- Upgrade package version

Reviewed-on: https://git.weko.io/resilien/directus-to-markdown/pulls/2
This commit is contained in:
Simon 2022-02-21 17:35:52 +01:00
commit bed1ea7676
4 changed files with 22 additions and 21 deletions

View File

@ -53,9 +53,9 @@ const config = {
} }
``` ```
### readManyOption ### readByQueryOption
`readManyOption` match https://docs.directus.io/reference/sdk/#read-multiple-items `readByQueryOption` match https://docs.directus.io/reference/sdk/#read-by-query
### Export to specific path ### Export to specific path
@ -73,9 +73,10 @@ const config = {
contentKey: 'body', contentKey: 'body',
collections: { collections: {
news: { news: {
readManyOption: { readByQueryOption: {
fields: ['title', 'slug', 'date', 'image', 'image_credit', 'draft', 'body'], fields: ['title', 'slug', 'date', 'image', 'image_credit', 'draft', 'body'],
filter: { draft: { _eq: 'false' } } filter: { draft: { _eq: 'false' } },
limit: -1
}, },
pathBuilder: (article) => { pathBuilder: (article) => {
if (article.slug) { if (article.slug) {

View File

@ -78,8 +78,8 @@ export default class DirectusToMarkdown {
async export() { async export() {
for (const collectionName in this.collections) { for (const collectionName in this.collections) {
const collection = this.collections[collectionName] const collection = this.collections[collectionName]
const readManyOption = collection.readManyOption const readByQueryOption = collection.readByQueryOption
const items = (await this.directus.items(collectionName).readMany(readManyOption)).data const items = (await this.directus.items(collectionName).readByQuery(readByQueryOption)).data
for (const item of items) { for (const item of items) {
const itemPath = collection.pathBuilder(item) const itemPath = collection.pathBuilder(item)
if (!fs.existsSync(itemPath)) { if (!fs.existsSync(itemPath)) {

26
package-lock.json generated
View File

@ -9,14 +9,14 @@
"version": "0.2.0", "version": "0.2.0",
"license": "ISC", "license": "ISC",
"dependencies": { "dependencies": {
"@directus/sdk": "^9.5.0", "@directus/sdk": "^9.5.2",
"js-yaml": "^4.1.0" "js-yaml": "^4.1.0"
} }
}, },
"node_modules/@directus/sdk": { "node_modules/@directus/sdk": {
"version": "9.5.0", "version": "9.5.2",
"resolved": "https://registry.npmjs.org/@directus/sdk/-/sdk-9.5.0.tgz", "resolved": "https://registry.npmjs.org/@directus/sdk/-/sdk-9.5.2.tgz",
"integrity": "sha512-zrQmE8Wde5ITKhTpeYgJgb+QhFc8ySq/mFPfLq1+vO/xzvx5mg7v1OER1tMs7Byq3X/78euZCN4rxrvVRWQGNA==", "integrity": "sha512-E9VM8nNQfgeEl/tfZmcvf7es0ArqYQPjZDevxQ+hPk4OCqZ3raJHPa9+sqkDnKS763Q0DdnsfZ2Lb+iUUuE5nw==",
"dependencies": { "dependencies": {
"axios": "^0.24.0" "axios": "^0.24.0"
} }
@ -35,9 +35,9 @@
} }
}, },
"node_modules/follow-redirects": { "node_modules/follow-redirects": {
"version": "1.14.7", "version": "1.14.9",
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.7.tgz", "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.9.tgz",
"integrity": "sha512-+hbxoLbFMbRKDwohX8GkTataGqO6Jb7jGwpAlwgy2bIz25XtRm7KEzJM76R1WiNT5SwZkX4Y75SwBolkpmE7iQ==", "integrity": "sha512-MQDfihBQYMcyy5dhRDJUHcw7lb2Pv/TuE6xP1vyraLukNDHKbDxDNaOE3NbCAdKQApno+GPRyo1YAp89yCjK4w==",
"funding": [ "funding": [
{ {
"type": "individual", "type": "individual",
@ -67,9 +67,9 @@
}, },
"dependencies": { "dependencies": {
"@directus/sdk": { "@directus/sdk": {
"version": "9.5.0", "version": "9.5.2",
"resolved": "https://registry.npmjs.org/@directus/sdk/-/sdk-9.5.0.tgz", "resolved": "https://registry.npmjs.org/@directus/sdk/-/sdk-9.5.2.tgz",
"integrity": "sha512-zrQmE8Wde5ITKhTpeYgJgb+QhFc8ySq/mFPfLq1+vO/xzvx5mg7v1OER1tMs7Byq3X/78euZCN4rxrvVRWQGNA==", "integrity": "sha512-E9VM8nNQfgeEl/tfZmcvf7es0ArqYQPjZDevxQ+hPk4OCqZ3raJHPa9+sqkDnKS763Q0DdnsfZ2Lb+iUUuE5nw==",
"requires": { "requires": {
"axios": "^0.24.0" "axios": "^0.24.0"
} }
@ -88,9 +88,9 @@
} }
}, },
"follow-redirects": { "follow-redirects": {
"version": "1.14.7", "version": "1.14.9",
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.7.tgz", "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.9.tgz",
"integrity": "sha512-+hbxoLbFMbRKDwohX8GkTataGqO6Jb7jGwpAlwgy2bIz25XtRm7KEzJM76R1WiNT5SwZkX4Y75SwBolkpmE7iQ==" "integrity": "sha512-MQDfihBQYMcyy5dhRDJUHcw7lb2Pv/TuE6xP1vyraLukNDHKbDxDNaOE3NbCAdKQApno+GPRyo1YAp89yCjK4w=="
}, },
"js-yaml": { "js-yaml": {
"version": "4.1.0", "version": "4.1.0",

View File

@ -1,6 +1,6 @@
{ {
"name": "@resilien/directus-to-markdown", "name": "@resilien/directus-to-markdown",
"version": "0.2.0", "version": "1.0.0",
"description": "Export Directus items to markdown files with assets", "description": "Export Directus items to markdown files with assets",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {
@ -21,7 +21,7 @@
"license": "ISC", "license": "ISC",
"type": "module", "type": "module",
"dependencies": { "dependencies": {
"@directus/sdk": "^9.5.0", "@directus/sdk": "^9.5.2",
"js-yaml": "^4.1.0" "js-yaml": "^4.1.0"
} }
} }