storyblok 3.21.0 → 3.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
CHANGED
|
@@ -44,7 +44,7 @@ $ storyblok login
|
|
|
44
44
|
|
|
45
45
|
**For Both login options you nedd to pass the region**
|
|
46
46
|
|
|
47
|
-
* `region`:
|
|
47
|
+
* `region`: region you would like to work in. Please keep in mind that the region must match the region of your space. You can use `us`, `cn` or `eu`, if left empty, default is `eu`. This region flag will be used for the other cli's commands.
|
|
48
48
|
|
|
49
49
|
#### Login with token flag
|
|
50
50
|
You can also add the token directly from the login’s command, like the example below:
|
|
@@ -98,7 +98,7 @@ $ storyblok pull-components --space <SPACE_ID> # Will save files like components
|
|
|
98
98
|
```
|
|
99
99
|
|
|
100
100
|
```sh
|
|
101
|
-
$ storyblok pull-components --space <SPACE_ID> --separate-files # Will save files like feature-
|
|
101
|
+
$ storyblok pull-components --space <SPACE_ID> --separate-files --file-name production # Will save files like feature-production.json grid-production.json
|
|
102
102
|
```
|
|
103
103
|
|
|
104
104
|
#### Options
|
|
@@ -106,6 +106,7 @@ $ storyblok pull-components --space <SPACE_ID> --separate-files # Will save file
|
|
|
106
106
|
* `space`: your space id
|
|
107
107
|
* `separate-files`: boolean flag to save components and presets in single files instead a file with all
|
|
108
108
|
* `path`: the path to save your components and preset files
|
|
109
|
+
* `file-name`(optional): a custom filename used to generate the component and present files, default is the space id
|
|
109
110
|
|
|
110
111
|
### push-components
|
|
111
112
|
|
package/package.json
CHANGED
package/src/cli.js
CHANGED
|
@@ -40,7 +40,7 @@ program
|
|
|
40
40
|
.command(COMMANDS.LOGIN)
|
|
41
41
|
.description('Login to the Storyblok cli')
|
|
42
42
|
.option('-t, --token <token>', 'Token to login directly without questions, like for CI enviroments')
|
|
43
|
-
.option('-r, --region <region>', '
|
|
43
|
+
.option('-r, --region <region>', 'The region you would like to work in. Please keep in mind that the region must match the region of your space. You can use us, cn or eu, if left empty, default is eu. This region flag will be used for the other cli\'s commands')
|
|
44
44
|
.action(async (options) => {
|
|
45
45
|
const { token, region } = options
|
|
46
46
|
|
|
@@ -121,6 +121,7 @@ program
|
|
|
121
121
|
.command(COMMANDS.PULL_COMPONENTS)
|
|
122
122
|
.option('--sf, --separate-files [value]', 'Argument to create a single file for each component')
|
|
123
123
|
.option('-p, --path <path>', 'Path to save the component files')
|
|
124
|
+
.option('-f, --file-name <fileName>', 'custom name to be used in file(s) name instead of space id')
|
|
124
125
|
.description("Download your space's components schema as json")
|
|
125
126
|
.action(async (options) => {
|
|
126
127
|
console.log(`${chalk.blue('-')} Executing pull-components task`)
|
|
@@ -131,13 +132,15 @@ program
|
|
|
131
132
|
process.exit(0)
|
|
132
133
|
}
|
|
133
134
|
|
|
135
|
+
const fileName = options.fileName ? options.fileName : space
|
|
136
|
+
|
|
134
137
|
try {
|
|
135
138
|
if (!api.isAuthorized()) {
|
|
136
139
|
await api.processLogin()
|
|
137
140
|
}
|
|
138
141
|
|
|
139
142
|
api.setSpaceId(space)
|
|
140
|
-
await tasks.pullComponents(api, {
|
|
143
|
+
await tasks.pullComponents(api, { fileName, separateFiles, path })
|
|
141
144
|
} catch (e) {
|
|
142
145
|
errorHandler(e, COMMANDS.PULL_COMPONENTS)
|
|
143
146
|
}
|
|
@@ -20,11 +20,11 @@ const getNameFromComponentGroups = (groups, uuid) => {
|
|
|
20
20
|
/**
|
|
21
21
|
* @method pullComponents
|
|
22
22
|
* @param {Object} api
|
|
23
|
-
* @param {Object} options {
|
|
23
|
+
* @param {Object} options { fileName: string, separateFiles: Boolean, path: String }
|
|
24
24
|
* @return {Promise<Object>}
|
|
25
25
|
*/
|
|
26
26
|
const pullComponents = async (api, options) => {
|
|
27
|
-
const {
|
|
27
|
+
const { fileName, separateFiles, path } = options
|
|
28
28
|
|
|
29
29
|
try {
|
|
30
30
|
const componentGroups = await api.getComponentGroups()
|
|
@@ -43,7 +43,7 @@ const pullComponents = async (api, options) => {
|
|
|
43
43
|
|
|
44
44
|
if (separateFiles) {
|
|
45
45
|
for (const comp in components) {
|
|
46
|
-
const compFileName = `${components[comp].name}-${
|
|
46
|
+
const compFileName = `${components[comp].name}-${fileName}.json`
|
|
47
47
|
const data = JSON.stringify(components[comp], null, 2)
|
|
48
48
|
saveFileFactory(compFileName, data, path)
|
|
49
49
|
}
|
|
@@ -52,7 +52,7 @@ const pullComponents = async (api, options) => {
|
|
|
52
52
|
if (presets.length === 0) return
|
|
53
53
|
|
|
54
54
|
for (const preset in presets) {
|
|
55
|
-
const presetFileName = `${presets[preset].name}-${
|
|
55
|
+
const presetFileName = `${presets[preset].name}-${fileName}.json`
|
|
56
56
|
const data = JSON.stringify(presets[preset], null, 2)
|
|
57
57
|
saveFileFactory(presetFileName, data, path)
|
|
58
58
|
}
|
|
@@ -60,7 +60,7 @@ const pullComponents = async (api, options) => {
|
|
|
60
60
|
return
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
-
const file = `components.${
|
|
63
|
+
const file = `components.${fileName}.json`
|
|
64
64
|
const data = JSON.stringify({ components }, null, 2)
|
|
65
65
|
|
|
66
66
|
console.log(`${chalk.green('✓')} We've saved your components in the file: ${file}`)
|
|
@@ -69,7 +69,7 @@ const pullComponents = async (api, options) => {
|
|
|
69
69
|
|
|
70
70
|
if (presets.length === 0) return
|
|
71
71
|
|
|
72
|
-
const presetsFile = `presets.${
|
|
72
|
+
const presetsFile = `presets.${fileName}.json`
|
|
73
73
|
const presetsData = JSON.stringify({ presets }, null, 2)
|
|
74
74
|
|
|
75
75
|
console.log(`${chalk.green('✓')} We've saved your presets in the file: ${presetsFile}`)
|
|
@@ -9,7 +9,7 @@ const getOptions = (subCommand, argv = {}, api = {}) => {
|
|
|
9
9
|
const regionInput = {
|
|
10
10
|
type: 'input',
|
|
11
11
|
name: 'region',
|
|
12
|
-
message: '
|
|
12
|
+
message: 'Please enter the region you would like to work in (us, eu or cn) - if not set, default is eu:',
|
|
13
13
|
validate: function (value) {
|
|
14
14
|
const flagList = ['us', 'cn', 'eu']
|
|
15
15
|
if (flagList.indexOf(value) > -1) {
|