Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

storyblok

Package Overview
Dependencies
Maintainers
7
Versions
95
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

storyblok - npm Package Compare versions

Comparing version 3.11.0 to 3.12.0

4

package.json
{
"name": "storyblok",
"version": "3.11.0",
"version": "3.12.0",
"description": "A simple CLI to start Storyblok from your command line.",

@@ -40,3 +40,3 @@ "keywords": [

"path": "^0.12.7",
"storyblok-js-client": "^3.3.1",
"storyblok-js-client": "^4.5.6",
"update-notifier": "^5.1.0",

@@ -43,0 +43,0 @@ "xml-js": "^1.6.11"

@@ -36,3 +36,3 @@ <p align="center">

```sh
$ storyblok pull-components --space <SPACE_ID>
$ storyblok pull-components --space <SPACE_ID> --region <REGION>
```

@@ -43,2 +43,3 @@

* `space`: your space id
* `region`: your space region (default: `eu`). If your space was created under US region, you should use `us` instead.

@@ -50,3 +51,3 @@ ### push-components

```sh
$ storyblok push-components <SOURCE> --space <SPACE_ID> --presets-source <PRESETS_SOURCE>
$ storyblok push-components <SOURCE> --space <SPACE_ID> --region <REGION> --presets-source <PRESETS_SOURCE>
```

@@ -57,2 +58,3 @@

* `source`: can be a URL or path to JSON file.
* `region`: your space region (default: `eu`). If your space was created under US region, you should use `us` instead.

@@ -74,2 +76,3 @@ Using an **URL**

* `space`: your space id
* `region`: your space region (default: `eu`). If your space was created under US region, you should use `us` instead.
* `presets-source` (optional): it can be a URL or path to JSON file with the presets

@@ -104,2 +107,3 @@

* `target`: the target space to use to sync
* `region`: your space region (default: `eu`). If your space was created under US region, you should use `us` instead.

@@ -147,2 +151,3 @@ #### Examples

```
It's important to note that the `component` and `field` parameters are required and must be spelled exactly as they are in Storyblok. You can check the exact name by looking at the `Block library` inside your space.

@@ -154,2 +159,3 @@ #### Options

* `field`: name of field
* `region`: your space region (default: `eu`). If your space was created under US region, you should use `us` instead.

@@ -181,2 +187,3 @@ ### run-migration

* `publish-languages` (optional): publish specific languages. You can publish more than one language at a time by separating the languages by `,`
* `region`: your space region (default: `eu`). If your space was created under US region, you should use `us` instead.

@@ -183,0 +190,0 @@ ### rollback-migration

@@ -16,3 +16,3 @@ #!/usr/bin/env node

const { getQuestions, lastStep, api, creds } = require('./utils')
const { SYNC_TYPES } = require('./constants')
const { SYNC_TYPES, COMMANDS } = require('./constants')

@@ -41,3 +41,3 @@ clear()

program
.command('login')
.command(COMMANDS.LOGIN)
.description('Login to the Storyblok cli')

@@ -61,3 +61,3 @@ .action(async () => {

program
.command('logout')
.command(COMMANDS.LOGOUT)
.description('Logout from the Storyblok cli')

@@ -77,5 +77,6 @@ .action(async () => {

program
.command('pull-components')
.command(COMMANDS.PULL_COMPONENTS)
.option('-r, --region [value]', 'region', 'eu')
.description("Download your space's components schema as json")
.action(async () => {
.action(async (source) => {
console.log(`${chalk.blue('-')} Executing pull-components task`)

@@ -93,7 +94,11 @@ const space = program.space

const { region } = source
if (program.args.length > 0) {
api.setRegion(region)
}
api.setSpaceId(space)
await tasks.pullComponents(api, { space })
} catch (e) {
console.log(chalk.red('X') + ' An error occurred when executing the pull-components task: ' + e.message)
process.exit(1)
errorHandler(e, COMMANDS.PULL_COMPONENTS)
}

@@ -104,4 +109,5 @@ })

program
.command('push-components <source>')
.command(COMMANDS.PUSH_COMPONENTS + ' <source>')
.option('-p, --presets-source <presetsSource>', 'Path to presets file')
.option('-r, --region [value]', 'region', 'eu')
.description("Download your space's components schema as json. The source parameter can be a URL to your JSON file or a path to it")

@@ -122,7 +128,12 @@ .action(async (source, options) => {

}
const { region } = options
if (program.args.length > 0) {
api.setRegion(region)
}
api.setSpaceId(space)
await tasks.pushComponents(api, { source, presetsSource })
} catch (e) {
console.log(chalk.red('X') + ' An error occurred when executing the push-components task: ' + e.message)
process.exit(1)
errorHandler(e, COMMANDS.PUSH_COMPONENTS)
}

@@ -133,3 +144,3 @@ })

program
.command('scaffold <name>')
.command(COMMANDS.SCAFFOLD + ' <name>')
.description('Scaffold <name> component')

@@ -157,3 +168,3 @@ .action(async (name) => {

program
.command('select')
.command(COMMANDS.SELECT)
.description('Usage to kickstart a boilerplate, fieldtype or theme')

@@ -176,3 +187,3 @@ .action(async () => {

program
.command('sync')
.command(COMMANDS.SYNC)
.description('Sync schemas, roles, folders and stories between spaces')

@@ -182,14 +193,21 @@ .requiredOption('--type <TYPE>', 'Define what will be sync. Can be components, folders, stories, datasources or roles')

.requiredOption('--target <SPACE_ID>', 'Target space id')
.option('-r, --region [value]', 'region', 'eu')
.action(async (options) => {
console.log(`${chalk.blue('-')} Sync data between spaces\n`)
const {
type,
source,
target
} = options
try {
if (!api.isAuthorized()) {
await api.processLogin()
}
try {
const {
type,
source,
target,
region
} = options
api.setRegion(region)
const _types = type.split(',') || []
_types.forEach(_type => {

@@ -201,9 +219,6 @@ if (!SYNC_TYPES.includes(_type)) {

if (!api.isAuthorized()) {
await api.processLogin()
}
const token = creds.get().token || null
await tasks.sync(_types, {
api,
token,

@@ -216,4 +231,3 @@ source,

} catch (e) {
console.error(chalk.red('X') + ' An error ocurred when syncing spaces: ' + e.message)
process.exit(1)
errorHandler(e, COMMANDS.SYNC)
}

@@ -224,3 +238,3 @@ })

program
.command('quickstart')
.command(COMMANDS.QUICKSTART)
.description('Start a project quickly')

@@ -240,9 +254,10 @@ .action(async () => {

program
.command('generate-migration')
.command(COMMANDS.GENERATE_MIGRATION)
.description('Generate a content migration file')
.option('-r, --region [value]', 'region', 'eu')
.requiredOption('-c, --component <COMPONENT_NAME>', 'Name of the component')
.requiredOption('-f, --field <FIELD_NAME>', 'Name of the component field')
.action(async (options) => {
const field = options.field || ''
const component = options.component || ''
const { field = '' } = options
const { component = '' } = options

@@ -262,2 +277,5 @@ const space = program.space

const { region } = options
api.setRegion(region)
api.setSpaceId(space)

@@ -272,6 +290,7 @@ await tasks.generateMigration(api, component, field)

program
.command('run-migration')
.command(COMMANDS.RUN_MIGRATION)
.description('Run a migration file')
.requiredOption('-c, --component <COMPONENT_NAME>', 'Name of the component')
.requiredOption('-f, --field <FIELD_NAME>', 'Name of the component field')
.option('-r, --region [value]', 'region', 'eu')
.option('--dryrun', 'Do not update the story content')

@@ -324,3 +343,3 @@ .option('--publish <PUBLISH_OPTION>', 'Publish the content. It can be: all, published or published-with-changes')

program
.command('rollback-migration')
.command(COMMANDS.ROLLBACK_MIGRATION)
.description('Rollback-migration a migration file')

@@ -354,3 +373,3 @@ .requiredOption('-c, --component <COMPONENT_NAME>', 'Name of the component')

program
.command('spaces')
.command(COMMANDS.SPACES)
.description('List all spaces of the logged account')

@@ -372,3 +391,3 @@ .action(async () => {

program
.command('import')
.command(COMMANDS.IMPORT)
.description('Import data from other systems and relational databases.')

@@ -409,1 +428,10 @@ .requiredOption('-f, --file <FILE_NAME>', 'Name of the file')

}
function errorHandler (e, command) {
if (/404/.test(e.message)) {
console.log(chalk.yellow('/!\\') + ' If your space was created under US region, you must provide the region as argument --region us. Otherwise, you can use the default --region eu or omit this flag.')
} else {
console.log(chalk.red('X') + ' An error occurred when executing the ' + command + ' task: ' + e || e.message)
}
process.exit(1)
}
const API_URL = 'https://api.storyblok.com/v1/'
const US_API_URL = 'https://api-us.storyblok.com/v1/'
const LOGIN_URL = `${API_URL}users/login`

@@ -13,2 +14,18 @@ const SIGNUP_URL = `${API_URL}users/signup`

const COMMANDS = {
GENERATE_MIGRATION: 'generate-migration',
IMPORT: 'import',
LOGIN: 'login',
LOGOUT: 'logout',
PULL_COMPONENTS: 'pull-components',
PUSH_COMPONENTS: 'push-components',
QUICKSTART: 'quickstart',
ROLLBACK_MIGRATION: 'rollback-migration',
RUN_MIGRATION: 'run-migration',
SCAFFOLD: 'scaffold',
SELECT: 'select',
SPACES: 'spaces',
SYNC: 'sync'
}
module.exports = {

@@ -18,3 +35,5 @@ LOGIN_URL,

API_URL,
SYNC_TYPES
SYNC_TYPES,
US_API_URL,
COMMANDS
}

@@ -106,3 +106,3 @@ const axios = require('axios')

if (schema[field].component_group_whitelist) {
schema[field].component_group_whitelist = schema[field].component_group_whitelist.map(uuid =>
schema[field].component_group_whitelist = schema[field].component_group_whitelist.map(uuid =>
getGroupByUuid(componentsGroups, uuid) ? getGroupByUuid(componentsGroups, uuid).uuid : uuid

@@ -109,0 +109,0 @@ )

const pSeries = require('p-series')
const chalk = require('chalk')
const StoryblokClient = require('storyblok-js-client')
const SyncComponents = require('./sync-commands/components')

@@ -13,2 +12,3 @@ const SyncDatasources = require('./sync-commands/datasources')

init (options) {
const { api } = options
console.log(chalk.green('✓') + ' Loading options')

@@ -18,5 +18,3 @@ this.sourceSpaceId = options.source

this.oauthToken = options.token
this.client = new StoryblokClient({
oauthToken: options.token
}, options.api)
this.client = api.getClient()
},

@@ -23,0 +21,0 @@

@@ -8,12 +8,17 @@ const chalk = require('chalk')

const getQuestions = require('./get-questions')
const { LOGIN_URL, SIGNUP_URL, API_URL } = require('../constants')
const { LOGIN_URL, SIGNUP_URL, API_URL, US_API_URL } = require('../constants')
module.exports = {
accessToken: '',
oauthToken: '',
spaceId: null,
region: 'eu',
getClient () {
const apiURL = this.region === 'us' ? US_API_URL : API_URL
return new Storyblok({
oauthToken: this.accessToken
}, API_URL)
accessToken: this.accessToken,
oauthToken: this.oauthToken,
region: this.region
}, apiURL)
},

@@ -74,3 +79,3 @@

if (token) {
this.accessToken = token
this.oauthToken = token
creds.set(email, token)

@@ -120,3 +125,3 @@

const token = this.extractToken(response)
this.accessToken = token
this.oauthToken = token
creds.set(email, token)

@@ -133,3 +138,3 @@

if (token) {
this.accessToken = token
this.oauthToken = token
return true

@@ -145,2 +150,6 @@ }

setRegion (region) {
this.region = region
},
getPresets () {

@@ -147,0 +156,0 @@ const client = this.getClient()

@@ -102,3 +102,3 @@ const sync = require('../../src/tasks/sync')

component: 'hero',
image: 'https://a.storyblok.com/f/002/bd78c087d1/screen-shot.png',
image: 'https://a.storyblok.com/f/002/bd78c087d1/screen-shot.png'
},

@@ -225,2 +225,5 @@ component_id: 3, // from FAKE_COMPONENTS 'hero'

return sync(_types, {
api: {
getClient: jest.fn(() => ({}))
},
token: TOKEN_TEST,

@@ -296,3 +299,3 @@ source: SOURCE_SPACE_TEST,

component: 'hero',
image: 'https://a.storyblok.com/f/002/bd78c087d1/screen-shot.png',
image: 'https://a.storyblok.com/f/002/bd78c087d1/screen-shot.png'
},

@@ -299,0 +302,0 @@ component_id: 3, // from FAKE_COMPONENTS 'hero'

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc