Comparing version 3.25.1 to 3.25.2
{ | ||
"name": "storyblok", | ||
"version": "3.25.1", | ||
"version": "3.25.2", | ||
"description": "A simple CLI to start Storyblok from your command line.", | ||
@@ -45,3 +45,3 @@ "repository": { | ||
"simple-uuid": "^0.0.1", | ||
"storyblok-js-client": "^5.12.0", | ||
"storyblok-js-client": "^5.14.0", | ||
"update-notifier": "^5.1.0", | ||
@@ -48,0 +48,0 @@ "xml-js": "^1.6.11" |
@@ -412,2 +412,20 @@ <p align="center"> | ||
### delete-datasources | ||
The delete-datasources command enables you to remove all datasources within the designated space. By utilizing the `--by-slug` option, you can filter the datasources based on their slugs, selectively deleting specific datasources. Similarly, the `--by-name` option functions in the same way, allowing you to filter and delete datasources based on their names. | ||
```sh | ||
$ storyblok delete-datasources --space-id <SPACE_ID> # Will delete all datasources | ||
``` | ||
```sh | ||
$ storyblok delete-datasources --space-id <SPACE_ID> --by-slug global-translations # Will only delete datasources where the slug starts with global-translations | ||
``` | ||
#### Options | ||
* `space-id`: your space id | ||
* `by-slug`: Filter Datasources by slug | ||
* `by-name`: Filter Datasources by name | ||
## Content migrations | ||
@@ -414,0 +432,0 @@ |
@@ -495,2 +495,26 @@ #!/usr/bin/env node | ||
// delete-datasources | ||
program | ||
.command(COMMANDS.DELETE_DATASOURCES) | ||
.requiredOption('--space-id <SPACE_ID>', 'Space id') | ||
.option('--by-slug <SLUG>', 'Delete datasources by slug') | ||
.option('--by-name <name>', 'Delete datasources by name') | ||
.action(async (options) => { | ||
console.log(`${chalk.blue('-')} Executing ${COMMANDS.DELETE_DATASOURCES} task`) | ||
const { spaceId, bySlug, byName } = options | ||
try { | ||
if (!api.isAuthorized()) { | ||
await api.processLogin() | ||
} | ||
api.setSpaceId(spaceId) | ||
await tasks.deleteDatasources(api, { byName, bySlug }) | ||
} catch (e) { | ||
errorHandler(e, COMMANDS.DELETE_DATASOURCES) | ||
} | ||
}) | ||
program.parse(process.argv) | ||
@@ -497,0 +521,0 @@ |
@@ -28,3 +28,4 @@ const API_URL = 'https://api.storyblok.com/v1/' | ||
SPACES: 'spaces', | ||
SYNC: 'sync' | ||
SYNC: 'sync', | ||
DELETE_DATASOURCES: 'delete-datasources' | ||
} | ||
@@ -31,0 +32,0 @@ |
const chalk = require('chalk') | ||
const axios = require('axios') | ||
const fs = require('fs') | ||
const isEmpty = require('lodash/isEmpty') | ||
const deleteComponent = require('./delete-component') | ||
@@ -47,3 +48,3 @@ | ||
else if (Array.isArray(content)) return [...content] | ||
else return [content] | ||
else return !isEmpty(content) ? [content] : [] | ||
} | ||
@@ -50,0 +51,0 @@ |
@@ -14,3 +14,4 @@ module.exports = { | ||
deleteComponent: require('./delete-component'), | ||
deleteComponents: require('./delete-components') | ||
deleteComponents: require('./delete-components'), | ||
deleteDatasources: require('./delete-datasources') | ||
} |
@@ -5,2 +5,3 @@ const axios = require('axios') | ||
const PresetsLib = require('../utils/presets-lib') | ||
const isEmpty = require('lodash/isEmpty') | ||
@@ -62,3 +63,3 @@ const isUrl = source => source.indexOf('http') === 0 | ||
else if (Array.isArray(content)) return [...content] | ||
else return [content] | ||
else return !isEmpty(content) ? [content] : [] | ||
} | ||
@@ -65,0 +66,0 @@ |
@@ -115,3 +115,3 @@ const chalk = require('chalk') | ||
} catch (e) { | ||
if (e.response && e.response.status && e.response.status === 422) { | ||
if (e.response && e.response.status || e.status === 422) { | ||
console.log( | ||
@@ -118,0 +118,0 @@ `${chalk.yellow('-')} Component ${component.name} already exists, updating it...` |
@@ -241,2 +241,20 @@ const chalk = require('chalk') | ||
getDatasources () { | ||
const client = this.getClient() | ||
return client | ||
.get(this.getPath('datasources')) | ||
.then(data => data.data.datasources || []) | ||
.catch(err => Promise.reject(err)) | ||
}, | ||
deleteDatasource (id) { | ||
const client = this.getClient() | ||
return client | ||
.delete(this.getPath(`datasources/${id}`)) | ||
.catch(err => Promise.reject(err)) | ||
}, | ||
post (path, props) { | ||
@@ -243,0 +261,0 @@ return this.sendRequest(path, 'post', props) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
216823
66
5840
557
Updatedstoryblok-js-client@^5.14.0