Skip to content
This repository was archived by the owner on Jan 19, 2026. It is now read-only.

Commit 172cbf2

Browse files
Merge pull request #58 from storyblok/hotfix/revert-sync-query-filter
fix: revert starts-with and filter query features
2 parents b5a93dc + c36b30e commit 172cbf2

5 files changed

Lines changed: 7 additions & 61 deletions

File tree

README.md

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -247,10 +247,6 @@ $ storyblok sync --type <COMMAND> --source <SPACE_ID> --target <SPACE_ID>
247247
* `type`: describe the command type to execute. Can be: `folders`, `components`, `stories`, `datasources` or `roles`. It's possible pass multiple types separated by comma (`,`).
248248
* `source`: the source space to use to sync
249249
* `target`: the target space to use to sync
250-
* `starts-with`: sync only stories that starts with the given string
251-
* `filter`: sync stories based on the given filter. Required Options: Required options: `--keys`, `--operations`, `--values`
252-
* `keys`: Multiple keys should be separated by comma. Example: `--keys key1,key2`, `--keys key1`
253-
* `operations`: Operations to be used for filtering. Can be: `is`, `in`, `not_in`, `like`, `not_like`, `any_in_array`, `all_in_array`, `gt_date`, `lt_date`, `gt_int`, `lt_int`, `gt_float`, `lt_float`. Multiple operations should be separated by comma.
254250

255251
#### Examples
256252

@@ -261,14 +257,6 @@ $ storyblok sync --type components --source 00001 --target 00002
261257
# Sync components and stories from `00001` space to `00002` space
262258
$ storyblok sync --type components,stories --source 00001 --target 00002
263259

264-
# Sync only stories that starts with `myStartsWithString` from `00001` space to `00002` space
265-
$ storyblok sync --type stories --source 00001 --target 00002 --starts-with myStartsWithString
266-
267-
# Sync only stories with a category field like `reference` from `00001` space to `00002` space
268-
$ storyblok sync --type stories --source 00001 --target 00002 --filter --keys category --operations like --values reference
269-
270-
# Sync only stories with a category field like `reference` and a name field not like `demo` from `00001` space to `00002` space
271-
$ storyblok sync --type stories --source 00001 --target 00002 --filter --keys category,name --operations like,not_like --values reference,demo
272260
```
273261

274262
### quickstart

src/cli.js

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const updateNotifier = require('update-notifier')
1212
const pkg = require('../package.json')
1313

1414
const tasks = require('./tasks')
15-
const { getQuestions, lastStep, api, creds, buildFilterQuery } = require('./utils')
15+
const { getQuestions, lastStep, api, creds } = require('./utils')
1616
const { SYNC_TYPES, COMMANDS } = require('./constants')
1717

1818
clear()
@@ -271,11 +271,6 @@ program
271271
.requiredOption('--type <TYPE>', 'Define what will be sync. Can be components, folders, stories, datasources or roles')
272272
.requiredOption('--source <SPACE_ID>', 'Source space id')
273273
.requiredOption('--target <SPACE_ID>', 'Target space id')
274-
.option('--starts-with <STARTS_WITH>', 'Sync only stories that starts with the given string')
275-
.option('--filter', 'Enable filter options to sync only stories that match the given filter. Required options: --keys; --operations; --values')
276-
.option('--keys <KEYS>', 'Field names in your story object which should be used for filtering. Multiple keys should separated by comma.')
277-
.option('--operations <OPERATIONS>', 'Operations to be used for filtering. Can be: is, in, not_in, like, not_like, any_in_array, all_in_array, gt_date, lt_date, gt_int, lt_int, gt_float, lt_float. Multiple operations should be separated by comma.')
278-
.option('--values <VALUES>', 'Values to be used for filtering. Any string or number. If you want to use multiple values, separate them with a comma. Multiple values should be separated by comma.')
279274
.option('--components-groups <UUIDs>', 'Synchronize components based on their group UUIDs separated by commas')
280275
.action(async (options) => {
281276
console.log(`${chalk.blue('-')} Sync data between spaces\n`)
@@ -287,35 +282,27 @@ program
287282

288283
const {
289284
type,
290-
source,
291285
target,
292-
startsWith,
293-
filter,
294-
keys,
295-
operations,
296-
values,
286+
source,
297287
componentsGroups
298288
} = options
299289

300290
const _componentsGroups = componentsGroups ? componentsGroups.split(',') : null
301291

292+
const token = creds.get().token || null
293+
302294
const _types = type.split(',') || []
303295
_types.forEach(_type => {
304296
if (!SYNC_TYPES.includes(_type)) {
305297
throw new Error(`The type ${_type} is not valid`)
306298
}
307299
})
308300

309-
const filterQuery = filter ? buildFilterQuery(keys, operations, values) : undefined
310-
311-
const token = creds.get().token || null
312301
await tasks.sync(_types, {
313302
api,
314303
token,
315-
source,
316304
target,
317-
startsWith,
318-
filterQuery,
305+
source,
319306
_componentsGroups
320307
})
321308

src/tasks/sync.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ const chalk = require('chalk')
33
const SyncComponents = require('./sync-commands/components')
44
const SyncDatasources = require('./sync-commands/datasources')
55
const { capitalize } = require('../utils')
6-
const { startsWith } = require('lodash/string')
76

87
const SyncSpaces = {
98
targetComponents: [],
@@ -15,8 +14,6 @@ const SyncSpaces = {
1514
this.sourceSpaceId = options.source
1615
this.targetSpaceId = options.target
1716
this.oauthToken = options.token
18-
this.startsWith = options.startsWith
19-
this.filterQuery = options.filterQuery
2017
this.client = api.getClient()
2118
this.componentsGroups = options._componentsGroups
2219
},
@@ -60,9 +57,7 @@ const SyncSpaces = {
6057
}
6158

6259
const all = await this.client.getAll(`spaces/${this.sourceSpaceId}/stories`, {
63-
story_only: 1,
64-
...(this.startsWith ? { starts_with: this.startsWith } : {}),
65-
...(this.filterQuery ? { filter_query: this.filterQuery } : {})
60+
story_only: 1
6661
})
6762

6863
for (let i = 0; i < all.length; i++) {

src/utils/build-filter-query.js

Lines changed: 0 additions & 23 deletions
This file was deleted.

src/utils/index.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,5 @@ module.exports = {
66
capitalize: require('./capitalize'),
77
findByProperty: require('./find-by-property'),
88
parseError: require('./parse-error'),
9-
buildFilterQuery: require('./build-filter-query'),
109
saveFileFactory: require('./save-file-factory')
11-
}
10+
}

0 commit comments

Comments
 (0)