storyblok 3.22.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
@@ -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-1234.json grid-1234.json
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "storyblok",
3
- "version": "3.22.0",
3
+ "version": "3.23.0",
4
4
  "description": "A simple CLI to start Storyblok from your command line.",
5
5
  "repository": {
6
6
  "type": "git",
package/src/cli.js CHANGED
@@ -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, { space, separateFiles, path })
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 { space: Number, separateFiles: Boolean, path: String }
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 { space, separateFiles, path } = options
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}-${space}.json`
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}-${space}.json`
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.${space}.json`
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.${space}.json`
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}`)
@@ -40,7 +40,7 @@ describe('testing pullComponents', () => {
40
40
  }
41
41
 
42
42
  const options = {
43
- space: SPACE
43
+ compFileName: SPACE
44
44
  }
45
45
 
46
46
  const expectFileName = `components.${SPACE}.json`