sb-mig 2.9.3 → 3.0.0-beta.2

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.
Files changed (81) hide show
  1. package/README.md +107 -471
  2. package/dist/api/componentPresets.d.ts +1 -0
  3. package/dist/api/componentPresets.js +18 -0
  4. package/{lib → dist}/api/components.d.ts +2 -2
  5. package/dist/api/components.js +63 -0
  6. package/dist/api/config.d.ts +2 -0
  7. package/dist/api/config.js +4 -0
  8. package/{lib → dist}/api/datasources.d.ts +1 -1
  9. package/dist/api/datasources.js +181 -0
  10. package/dist/api/migrate.d.ts +17 -0
  11. package/dist/api/migrate.js +139 -0
  12. package/{lib → dist}/api/mutateComponents.d.ts +0 -0
  13. package/dist/api/mutateComponents.js +45 -0
  14. package/{lib → dist}/api/presets.d.ts +1 -1
  15. package/dist/api/presets.js +52 -0
  16. package/{lib → dist}/api/resolvePresets.d.ts +0 -0
  17. package/{lib → dist}/api/resolvePresets.js +15 -14
  18. package/{lib → dist}/api/roles.d.ts +2 -2
  19. package/dist/api/roles.js +125 -0
  20. package/dist/cli-descriptions.d.ts +4 -0
  21. package/dist/cli-descriptions.js +69 -0
  22. package/dist/commands/backup.d.ts +2 -0
  23. package/dist/commands/backup.js +201 -0
  24. package/dist/commands/debug.d.ts +1 -0
  25. package/dist/commands/debug.js +5 -0
  26. package/dist/commands/sync.d.ts +2 -0
  27. package/dist/commands/sync.js +58 -0
  28. package/dist/config/config.d.ts +14 -0
  29. package/dist/config/config.js +49 -0
  30. package/dist/index.d.ts +2 -0
  31. package/dist/index.js +52 -0
  32. package/{lib/utils/discover2.d.ts → dist/utils/discover.d.ts} +1 -7
  33. package/{lib/utils/discover2.js → dist/utils/discover.js} +200 -143
  34. package/{lib → dist}/utils/files.d.ts +7 -1
  35. package/dist/utils/files.js +54 -0
  36. package/dist/utils/interfaces.d.ts +4 -0
  37. package/dist/utils/interfaces.js +1 -0
  38. package/{lib → dist}/utils/logger.d.ts +0 -3
  39. package/{lib → dist}/utils/logger.js +2 -12
  40. package/dist/utils/main.d.ts +13 -0
  41. package/dist/utils/main.js +28 -0
  42. package/{lib → dist}/utils/others.d.ts +0 -0
  43. package/dist/utils/others.js +1 -0
  44. package/package.json +63 -57
  45. package/CHANGELOG.md +0 -996
  46. package/bin/run +0 -5
  47. package/bin/run.cmd +0 -3
  48. package/lib/api/apiConfig.d.ts +0 -2
  49. package/lib/api/apiConfig.js +0 -9
  50. package/lib/api/componentPresets.d.ts +0 -1
  51. package/lib/api/componentPresets.js +0 -22
  52. package/lib/api/components.js +0 -71
  53. package/lib/api/datasources.js +0 -193
  54. package/lib/api/migrate.d.ts +0 -19
  55. package/lib/api/migrate.js +0 -220
  56. package/lib/api/mutateComponents.js +0 -50
  57. package/lib/api/presets.js +0 -59
  58. package/lib/api/roles.js +0 -133
  59. package/lib/api/spaces.d.ts +0 -2
  60. package/lib/api/spaces.js +0 -29
  61. package/lib/commands/backup.d.ts +0 -22
  62. package/lib/commands/backup.js +0 -217
  63. package/lib/commands/debug.d.ts +0 -9
  64. package/lib/commands/debug.js +0 -21
  65. package/lib/commands/sync.d.ts +0 -26
  66. package/lib/commands/sync.js +0 -93
  67. package/lib/config/StoryblokComponentsConfig.d.ts +0 -68
  68. package/lib/config/StoryblokComponentsConfig.js +0 -220
  69. package/lib/config/config.d.ts +0 -37
  70. package/lib/config/config.js +0 -36
  71. package/lib/core.d.ts +0 -16
  72. package/lib/core.js +0 -75
  73. package/lib/index.d.ts +0 -1
  74. package/lib/index.js +0 -5
  75. package/lib/types/storyblokTypes.d.ts +0 -171
  76. package/lib/types/storyblokTypes.js +0 -3
  77. package/lib/utils/discover.d.ts +0 -4
  78. package/lib/utils/discover.js +0 -96
  79. package/lib/utils/files.js +0 -54
  80. package/lib/utils/others.js +0 -5
  81. package/oclif.manifest.json +0 -1
package/README.md CHANGED
@@ -7,27 +7,20 @@ If you've found an issue or you have feature request - <a href="https://github.c
7
7
  [![npm](https://img.shields.io/npm/dt/sb-mig.svg)](ttps://img.shields.io/npm/dt/sb-mig.svg)
8
8
  [![GitHub issues](https://img.shields.io/github/issues/sb-mig/sb-mig.svg?style=flat-square&v=1)](https://github.com/sb-mig/sb-mig/issues?q=is%3Aopen+is%3Aissue)
9
9
 
10
- # 2.x.x version released!
10
+ # 3.x.x version released!
11
11
 
12
- - completely rewritten to [Oclif](https://github.com/oclif/oclif) framework written in Typescript (with as little changes to usage as possible, check [migration guide](https://github.com/sb-mig/sb-mig/blob/oclif-research/MIGRATION-GUIDE.md))
13
- - support for Oclif plugin system
14
- - created [sb-mig](https://github.com/sb-mig) organization for better grouping related stuff
15
- - created npm `@sb-mig` scope aswell, for the same reason
12
+ - completely rewritten to simple [Meow](https://github.com/sindresorhus/meow) lib with help of Typescript. Check [migration guide](https://github.com/sb-mig/sb-mig/blob/oclif-research/MIGRATION-GUIDE-v3.md)
13
+ - support native es modules
14
+ - thinner then Oclif framework, still with Typescript
15
+ - decide to remove plugin support, cause it was not used enough
16
+ - make all commands follow same standard (`backup` command, had some very weird syntax before, now it works like `sync`)
16
17
 
17
18
  ## Contents
18
19
 
19
20
  - [How to install and configure](#how-to-install-and-configure)
20
21
  - NEW [Adding Scoped Storyblok components](#adding-scoped-storyblok-components)
21
22
  - NEW [Overwriting schema files from scoped components](#overwriting-schema-files-from-scoped-components)
22
- - [Generate whole starter project](#generate-whole-starter-project)
23
23
  - [Usage](#usage)
24
- - [Commands](#commands)
25
- - [`sb-mig backup`](#sb-mig-backup)
26
- - [`sb-mig debug`](#sb-mig-debug)
27
- - [`sb-mig help [COMMAND]`](#sb-mig-help-command)
28
- - [`sb-mig plugins`](#sb-mig-plugins)
29
- - [`sb-mig sync TYPE [LIST]`](#sb-mig-sync-type-list)
30
- - [Plugins](#plugins)
31
24
  - [Schema documentation:](#schema-documentation)
32
25
  - [Basics](#basics)
33
26
  - [Syncing components](#syncing-components)
@@ -57,10 +50,12 @@ You can also provide your custom config. To do that u have to create `storyblok.
57
50
  ```
58
51
  // storyblok.config.js
59
52
  module.exports = {
53
+ storyblokComponentsLocalDirectory: "src/@storyblok-components",
60
54
  sbmigWorkingDirectory: "sbmig",
61
- componentDirectory: "sbmig/storyblok",
62
55
  componentsDirectories: ["src", "storyblok"],
63
56
  schemaFileExt: "sb.js",
57
+ datasourceExt: "sb.datasource.js",
58
+ rolesExt: "sb.roles.js",
64
59
  storyblokApiUrl: "https://api.storyblok.com/v1",
65
60
  oauthToken: process.env.STORYBLOK_OAUTH_TOKEN,
66
61
  spaceId: process.env.STORYBLOK_SPACE_ID,
@@ -73,492 +68,147 @@ You don't need to pass everything to the config file, just add what you need and
73
68
  ```
74
69
  // storyblok.config.js
75
70
  module.exports = {
76
- componentDirectory: 'storyblok',
71
+ componentsDirectories: ["src", "storyblok", "@storyblok-components"],
77
72
  };
78
73
  ```
79
74
 
80
- ## Adding scoped storyblok components
81
- ** this feature is still experimental **
82
-
83
- For that feature to work you need to install [add-components-plugin](https://github.com/sb-mig/sb-mig/tree/master/%40sb-mig/plugin-add-components).
84
-
85
- To do that, run (from root of your project)
86
- ```
87
- sb-mig plugins:install add-components
88
- ```
89
-
90
- Now you have access to `sb-mig add components`.
91
-
92
- ### Adding components and Lock file
93
-
94
- Let's say we want to add `@storyblok-components/text-block` and `@storyblok-components/heading` component. Lets run:
95
- ```
96
- sb-mig add components @storyblok-components/text-block @storyblok-components/heading
97
- ```
98
-
99
- This command, will install provided components from `npm` and will create special file called `storyblok.components.lock.js` in root of your project.
100
- This file is responsible for tracking where, and how your components end up being installed to your project, and is also tracking for any relations/links in your project. It is single source of truth for scoped components you installed with `sb-mig add components` command.
101
-
102
- Example output of `storyblok.components.lock.js` file:
103
-
104
- ```
105
- module.exports = {
106
- "@storyblok-components/text-block": {
107
- "name": "@storyblok-components/text-block",
108
- "scope": "@storyblok-components",
109
- "location": "node_modules",
110
- "locationPath": "node_modules/@storyblok-components/text-block",
111
- "links": {
112
- "src/@storyblok-components/storyblok-components.componentList.js": {
113
- "// --- sb-mig scoped component imports ---": "import * as ScopedTextBlock from '@storyblok-components/text-block';",
114
- "// --- sb-mig scoped component list ---": "ScopedTextBlock.ComponentList"
115
- },
116
- "src/@storyblok-components/_storyblok-components.scss": {
117
- "// --- sb-mig scoped component styles imports ---": "@import '@storyblok-components/text-block/src/text-block.scss';"
118
- }
119
- }
120
- },
121
- "@storyblok-components/heading": {
122
- "name": "@storyblok-components/heading",
123
- "scope": "@storyblok-components",
124
- "location": "node_modules",
125
- "locationPath": "node_modules/@storyblok-components/heading",
126
- "links": {
127
- "src/@storyblok-components/storyblok-components.componentList.js": {
128
- "// --- sb-mig scoped component imports ---": "import * as ScopedHeading from '@storyblok-components/heading';",
129
- "// --- sb-mig scoped component list ---": "ScopedHeading.ComponentList"
130
- },
131
- "src/@storyblok-components/_storyblok-components.scss": {
132
- "// --- sb-mig scoped component styles imports ---": ""
133
- }
134
- }
135
- }
136
- }
137
- ```
138
-
139
- We can also install our components with `--copy` flag, which will copy all files of the component from `node_modules` to local file system, and will use them in needed imports.
140
-
141
- Command:
142
- ```
143
- sb-mig add components @storyblok-components/image --copy
144
- ```
145
-
146
- Will add
147
- ```
148
- ...
149
- "@storyblok-components/image": {
150
- "name": "@storyblok-components/image",
151
- "scope": "@storyblok-components",
152
- "location": "local",
153
- "locationPath": "src/@storyblok-components/image",
154
- "links": {
155
- "src/@storyblok-components/storyblok-components.componentList.js": {
156
- "// --- sb-mig scoped component imports ---": "import * as ScopedImage from './image';",
157
- "// --- sb-mig scoped component list ---": "ScopedImage.ComponentList"
158
- },
159
- "src/@storyblok-components/_storyblok-components.scss": {
160
- "// --- sb-mig scoped component styles imports ---": ""
161
- }
162
- }
163
- }
164
- ...
165
- ```
166
-
167
- to `storyblok.components.lock.js`
168
-
169
- As you can see, `location`, `locationPath` and also imports inside `links` are reffering now to local file system.
170
-
171
- After all this, you can easy schema part of components by running
172
- ```
173
- sb-mig sync components --all --ext
174
- ```
175
-
176
- This command will sync all your components, `local one`, those from `node_modules`. Command will always favor local schema components, that way you can also overwrites schema files, which will be shown in next section.
177
-
178
- ## Overwriting schema files from scoped components
179
- So, you can install components with `sb-mig add components` command, but let's say you want to restrict something in schema of that components, or you want to change `description` of the component, or even a `component_group_name`. We have overwrites mechanism.
180
-
181
- Let's say you've installed `@storyblok-components/section` component which has following original schema:
182
- ```
183
- module.exports = {
184
- name: 'section',
185
- schema: {
186
- title: {
187
- type: 'text',
188
- },
189
- content: {
190
- type: 'bloks',
191
- restrict_components: false,
192
- },
193
- },
194
- }
195
- ```
196
-
197
- And your goal is to overwrite some of the schema properties: you want to give a proper description to it, you want to assign it to group, and you want to restrict that only `image` and `heading` component can be nested in it. Lets do that.
198
-
199
- 1. We have to create schema file with the same name and extension, wherever in our project. So in that example, let's create `src/overwrites` folder and `section.sb.js` file.
200
- 2. Now, we will import original schema file, and write our overwrites. Take a look at final overwrites for `section` component
201
-
202
- ```
203
- const section = require("@storyblok-components/section)
204
-
205
- module.exports = {
206
- ...section
207
- name: 'section',
208
- description: 'This is my awesome section component overwrites',
209
- schema: {
210
- ...section.schema,
211
- content: {
212
- restrict_components: true,
213
- component_whitelist: [
214
- 'image',
215
- 'heading'
216
- ],
217
- },
218
- },
219
- }
220
- ```
221
-
222
- Now, if we run `sb-mig sync components --all --ext`, `sb-mig` will sync all components, and in the situation above, it will choose proper schema file (is always prefer local schema files over node_modules one).
223
-
224
- ## Generate whole starter project
225
-
226
- 1. Create folder with custom name and get inside
227
- 2. Create `storyblok.config.js` file if u want to use custom gatsby storyblok starter, or custom npm component scope
228
-
229
- ```
230
- module.exports = {
231
- ...
232
- boilerplateUrl: "git@github.com:your-custom-gatsby-storyblok-boilerplate.git",
233
- componentsDirectories: ["src", "storyblok","node_modules/@custom-scope","node_modules/@storyblok-components"],
234
- ...
235
- }
236
-
237
- ```
238
-
239
- 3. Create `.env` file only with your storyblok oauth token (which you can get from your storyblok account - this is needed for script to have access to creating space api)
240
-
241
- ```
242
- STORYBLOK_OAUTH_TOKEN=1234567890qwertyuiop
243
- ```
244
-
245
- 4. Install `generate-project` `sb-mig` plugin.
246
- ```
247
- sb-mig plugins:install generate-project
248
- ```
249
-
250
- 5. Run
251
-
252
- ```
253
- sb-mig generate "My Greatest Project"
254
- ```
255
-
256
- It will generate basic boilerplate.
257
-
258
- If u want to specify components you would like to add you can do that by adding parameter to the command, and list of components (list of all public available components in @storyblok-components scope: [npm list](https://www.npmjs.com/settings/storyblok-components/packages)):
259
-
260
- ```
261
- sb-mig generate "My Greatest Project" --add @custom-scope/ui-text-block @storyblok-components/ui-surface
262
- ```
263
-
264
- 6. You can also pass `--copy` flag, which will copy component files from `node_modules` to your local, and add it properly to `components.js` file.
265
- ```
266
- sb-mig generate "My Greatest Project" --add @custom-scope/ui-text-block @storyblok-components/ui-surface --copy
267
- ```
268
-
269
- 7. Wait for magic to happen.
270
- 8. Run sync command to sync all components to storyblok.
271
-
272
- ```
273
- sb-mig sync components --all --ext
274
- ```
275
-
276
- 7. `npm start`
277
- 8. Enjoy your new project.
278
-
279
75
  # Usage
280
76
 
281
77
  ```sh-session
282
- $ sb-mig help
283
- CLI to rule the world. (and handle stuff related to Storyblok CMS)
78
+ $ sb-mig --help
79
+ CLI to rule the world. (and handle stuff related to Storyblok CMS)
284
80
 
285
- VERSION
286
- sb-mig/2.0.0-beta.5 darwin-x64 node-v12.16.2
81
+ USAGE
82
+ $ sb-mig [command]
287
83
 
288
- USAGE
289
- $ sb-mig [COMMAND]
84
+ COMMANDS
85
+ sync Synchronize components, datasources or roles with Storyblok space.
86
+ backup Command for backing up anything related to Storyblok
87
+ debug Output extra debugging information
88
+ help This screen
290
89
 
291
- COMMANDS
292
- backup Command for backing up anything related to Storyblok
293
- debug Output extra debugging
294
- help display help for sb-mig
295
- sync Synchronize components, datasources with Storyblok space.
90
+ Examples
91
+ $ sb-migv sync components --all
92
+ $ sb-mig debug
296
93
  ```
297
94
 
298
95
  # Commands
299
96
 
300
- <!-- commands -->
97
+ * [`sb-mig version`](#sb-mig-version)
301
98
  * [`sb-mig backup`](#sb-mig-backup)
302
99
  * [`sb-mig debug`](#sb-mig-debug)
303
- * [`sb-mig help [COMMAND]`](#sb-mig-help-command)
304
- * [`sb-mig plugins`](#sb-mig-plugins)
305
- * [`sb-mig plugins:install PLUGIN...`](#sb-mig-pluginsinstall-plugin)
306
- * [`sb-mig plugins:link PLUGIN`](#sb-mig-pluginslink-plugin)
307
- * [`sb-mig plugins:uninstall PLUGIN...`](#sb-mig-pluginsuninstall-plugin)
308
- * [`sb-mig plugins:update`](#sb-mig-pluginsupdate)
309
- * [`sb-mig sync TYPE [LIST]`](#sb-mig-sync-type-list)
310
-
311
- ## `sb-mig backup`
312
-
313
- Command for backing up anything related to Storyblok
314
-
315
- ```
316
- Command for backing up anything related to Storyblok
317
-
318
- USAGE
319
- $ sb-mig backup
100
+ * [`sb-mig sync`](#sb-mig-sync)
320
101
 
321
- OPTIONS
322
- -R, --allRoles Backup all roles and permissions.
323
- -a, --allComponents Backup all components.
324
- -d, --allDatasources Backup all datasources.
325
- -e, --datasourceEntries=datasourceEntries Backup one datasource entries by datasource name.
326
- -f, --oneComponentsGroup=oneComponentsGroup Backup one components group by name.
327
- -g, --allComponentsGroups Backup all components groups.
328
- -h, --help show CLI help
329
- -i, --onePreset=onePreset Backup one preset by id.
330
- -l, --allPresets Backup all presets.
331
- -o, --oneComponent=oneComponent Backup one component by name.
332
- -p, --oneComponentPresets=oneComponentPresets Backup all presets for one component
333
- -r, --oneRole=oneRole Backup one role by name.
334
- -x, --oneDatasource=oneDatasource Backup one datasource by name.
102
+ ## `sb-mig version`
335
103
  ```
104
+ $ sb-mig --version
336
105
 
337
- _See code: [lib/commands/backup.js](https://github.com/sb-mig/sb-mig/blob/v2.9.3/lib/commands/backup.js)_
338
-
339
- ## `sb-mig debug`
340
-
341
- Output extra debugging
342
-
343
- ```
344
- Output extra debugging
345
-
346
- USAGE
347
- $ sb-mig debug
348
-
349
- OPTIONS
350
- -h, --help show CLI help
351
- ```
352
-
353
- _See code: [lib/commands/debug.js](https://github.com/sb-mig/sb-mig/blob/v2.9.3/lib/commands/debug.js)_
354
-
355
- ## `sb-mig help [COMMAND]`
356
-
357
- display help for sb-mig
358
-
359
- ```
360
- display help for <%= config.bin %>
361
-
362
- USAGE
363
- $ sb-mig help [COMMAND]
364
-
365
- ARGUMENTS
366
- COMMAND command to show help for
367
-
368
- OPTIONS
369
- --all see all commands in CLI
370
- ```
371
-
372
- _See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v2.2.3/src/commands/help.ts)_
373
-
374
- ## `sb-mig plugins`
375
-
376
- list installed plugins
377
-
378
- ```
379
- list installed plugins
380
-
381
- USAGE
382
- $ sb-mig plugins
383
-
384
- OPTIONS
385
- --core show core plugins
386
-
387
- EXAMPLE
388
- $ sb-mig plugins
389
- ```
390
-
391
- _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v1.9.5/src/commands/plugins/index.ts)_
392
-
393
- ## `sb-mig plugins:install PLUGIN...`
394
-
395
- installs a plugin into the CLI
396
-
397
- ```
398
- installs a plugin into the CLI
399
- Can be installed from npm or a git url.
400
-
401
- Installation of a user-installed plugin will override a core plugin.
402
-
403
- e.g. If you have a core plugin that has a 'hello' command, installing a user-installed plugin with a 'hello' command will override the core plugin implementation. This is useful if a user needs to update core plugin functionality in the CLI without the need to patch and update the whole CLI.
404
-
405
-
406
- USAGE
407
- $ sb-mig plugins:install PLUGIN...
408
-
409
- ARGUMENTS
410
- PLUGIN plugin to install
411
-
412
- OPTIONS
413
- -f, --force yarn install with force flag
414
- -h, --help show CLI help
415
- -v, --verbose
416
-
417
- DESCRIPTION
418
- Can be installed from npm or a git url.
419
-
420
- Installation of a user-installed plugin will override a core plugin.
421
-
422
- e.g. If you have a core plugin that has a 'hello' command, installing a user-installed plugin with a 'hello' command
423
- will override the core plugin implementation. This is useful if a user needs to update core plugin functionality in
424
- the CLI without the need to patch and update the whole CLI.
425
-
426
- ALIASES
427
- $ sb-mig plugins:add
428
-
429
- EXAMPLES
430
- $ sb-mig plugins:install myplugin
431
- $ sb-mig plugins:install https://github.com/someuser/someplugin
432
- $ sb-mig plugins:install someuser/someplugin
106
+ 3.1.7
433
107
  ```
434
108
 
435
- _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v1.9.5/src/commands/plugins/install.ts)_
436
-
437
- ## `sb-mig plugins:link PLUGIN`
109
+ ## `sb-mig backup`
438
110
 
439
- links a plugin into the CLI for development
111
+ Command for backing up anything related to Storyblok
440
112
 
441
113
  ```
442
- links a plugin into the CLI for development
443
- Installation of a linked plugin will override a user-installed or core plugin.
444
-
445
- e.g. If you have a user-installed or core plugin that has a 'hello' command, installing a linked plugin with a 'hello' command will override the user-installed or core plugin implementation. This is useful for development work.
114
+ $ sb-mig backup --help
446
115
 
447
116
 
448
- USAGE
449
- $ sb-mig plugins:link PLUGIN
450
117
 
451
- ARGUMENTS
452
- PATH [default: .] path to plugin
453
-
454
- OPTIONS
455
- -h, --help show CLI help
456
- -v, --verbose
457
-
458
- DESCRIPTION
459
- Installation of a linked plugin will override a user-installed or core plugin.
460
-
461
- e.g. If you have a user-installed or core plugin that has a 'hello' command, installing a linked plugin with a 'hello'
462
- command will override the user-installed or core plugin implementation. This is useful for development work.
463
-
464
- EXAMPLE
465
- $ sb-mig plugins:link myplugin
466
- ```
118
+ CLI to rule the world. (and handle stuff related to Storyblok CMS)
467
119
 
468
- _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v1.9.5/src/commands/plugins/link.ts)_
120
+ Usage
121
+ $ sb-mig-v3 backup [components|component-groups|roles|datasources|presets|component-presets] [space separated file names] or --all
122
+ Description
123
+ Command for backing up anything related to Storyblok
469
124
 
470
- ## `sb-mig plugins:uninstall PLUGIN...`
125
+ COMMANDS
126
+ components - backup components
127
+ component-groups - backuo component-groups
128
+ roles - backup components
129
+ datasources - backup components
130
+ presets - backup presets
131
+ component-presets - backup component presets
471
132
 
472
- removes a plugin from the CLI
133
+ FLAGS
134
+ --all - Backup all
135
+ --one - Backup one
473
136
 
137
+ EXAMPLES
138
+ $ sb-mig backup components --all
139
+ $ sb-mig backup components accordion accordion-item carousel text-block
140
+ $ sb-mig backup datasources --all
141
+ $ sb-mig backup roles admin normal-user
474
142
  ```
475
- removes a plugin from the CLI
476
143
 
477
- USAGE
478
- $ sb-mig plugins:uninstall PLUGIN...
479
-
480
- ARGUMENTS
481
- PLUGIN plugin to uninstall
144
+ ## `sb-mig debug`
482
145
 
483
- OPTIONS
484
- -h, --help show CLI help
485
- -v, --verbose
146
+ Output extra debugging.
486
147
 
487
- ALIASES
488
- $ sb-mig plugins:unlink
489
- $ sb-mig plugins:remove
490
148
  ```
149
+ $ sb-mig debug
491
150
 
492
- _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v1.9.5/src/commands/plugins/uninstall.ts)_
493
-
494
- ## `sb-mig plugins:update`
495
-
496
- update installed plugins
497
-
151
+ storyblok.config.js: {
152
+ componentsMatchFile: 'src/components/components.js',
153
+ storyblokComponentsListfile: 'src/components/storyblok-components.componentList.js',
154
+ storyblokComponentsLocalDirectory: 'src/@storyblok-components',
155
+ componentsStylesMatchFile: 'src/@storyblok-components/_storyblok-components.scss',
156
+ boilerplateUrl: 'git@github.com:storyblok-components/gatsby-storyblok-boilerplate.git',
157
+ sbmigWorkingDirectory: 'sbmig',
158
+ componentDirectory: 'storyblok',
159
+ datasourcesDirectory: 'storyblok',
160
+ componentsDirectories: [ 'src', 'storyblok' ],
161
+ schemaFileExt: 'sb.js',
162
+ datasourceExt: 'sb.datasource.js',
163
+ rolesExt: 'sb.roles.js',
164
+ storyblokApiUrl: 'https://api.storyblok.com/v1',
165
+ oauthToken: '',
166
+ spaceId: '',
167
+ accessToken: ''
168
+ }
498
169
  ```
499
- update installed plugins
500
-
501
- USAGE
502
- $ sb-mig plugins:update
503
170
 
504
- OPTIONS
505
- -h, --help show CLI help
506
- -v, --verbose
507
- ```
508
171
 
509
- _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v1.9.5/src/commands/plugins/update.ts)_
510
172
 
511
- ## `sb-mig sync TYPE [LIST]`
173
+ ## `sb-mig sync`
512
174
 
513
175
  Synchronize components, datasources or roles with Storyblok space.
514
176
 
515
177
  ```
516
- Synchronize components, datasources or roles with Storyblok space.
517
-
518
- USAGE
519
- $ sb-mig sync TYPE [LIST]
178
+ $ sb-mig sync --help
520
179
 
521
- ARGUMENTS
522
- TYPE (components|datasources|roles) What to synchronize
523
- LIST Space separated list of component names. Example: card product-card row layout
524
-
525
- OPTIONS
526
- -a, --all Synchronize all components.
527
- -e, --ext Synchronize with file extension. Default extension: '.sb.js'
528
- -h, --help show CLI help
529
- -l, --lock Synchronize based on storyblok.components.lock.js file
530
- -n, --packageName Synchronize based on installed package name.
531
- -p, --presets Synchronize components with presets.
180
+ CLI to rule the world. (and handle stuff related to Storyblok CMS)
532
181
 
533
- EXAMPLES
534
- $ sb-mig sync components --all --ext
535
- $ sb-mig sync components @storyblok-components/text-block --ext --packageName
536
- $ sb-mig sync components @storyblok-components/text-block @storyblok-components/button --ext --packageName
537
- $ sb-mig sync components text-block button --ext
538
- $ sb-mig sync components text-block button
539
- $ sb-mig sync roles
540
- ```
182
+ Usage
183
+ $ sb-mig-v3 sync [components|roles|datasources] [space separated file names] or --all --packageName
541
184
 
542
- _See code: [lib/commands/sync.js](https://github.com/sb-mig/sb-mig/blob/v2.9.3/lib/commands/sync.js)_
543
- <!-- commandsstop -->
185
+ Description
186
+ Synchronize components or roles with Storyblok space.
544
187
 
545
- # Plugins
546
- `sb-mig` core features are part of this repository. But `sb-mig` is build in a way that you can easily add your own command as a plugin. Here will be the list of plugins, which are already supported by `sb-mig`. For installation instructions see: [TBD](#)
188
+ COMMANDS
189
+ components - sync components
190
+ roles - sync roles
191
+ datasources - sync datasources
547
192
 
548
- - [plugin-add-components](https://github.com/sb-mig/plugin-add-components) - with this plugin, you can easily install storyblok react components to your project ( compliant with `components.js` file syntax: [TBD](#) )
549
- - [plugin-create-component](https://github.com/sb-mig/plugin-create-component) - with this plugin, you can easily add working dummy component with all needed syntax to monorepos with storyblok components, like this unofficial one [storyblok-components/components](https://github.com/storyblok-components/components) which is deployed to `@storyblok-components` scope of public npm
550
- - [plugin-generate-project](https://github.com/sb-mig/plugin-generate-project) - with this plugin, you need only one command, to generate and bootstrap whole new Storyblok project with provided list of available components. It is also created storyblok space for you, and after command is done, you are ready to develop, edit and use installed components. ()
193
+ FLAGS
194
+ --all - Sync all components
195
+ --packageName - Sync based on package name, instead of file name (package can have multiple schema files to sync)
196
+ --presets - Pass it, if u want to sync also with presets (will take longer)
551
197
 
552
- To build your own plugin, head over to this instruction: [TBD](#)
198
+ EXAMPLES
199
+ $ sb-mig sync components --all
200
+ $ sb-mig sync components accordion accordion-item
201
+ $ sb-mig sync components @storyblok-components/accordion --packageName
202
+ ```
553
203
 
554
204
  # Schema documentation:
555
205
 
556
206
  ## Basics
557
207
 
558
- This is what a basic storyblok `.js` schema file which maps to a component looks like:
208
+ This is what a basic storyblok `.sb.js` schema file which maps to a component looks like:
559
209
 
560
210
  ```
561
- module.exports = {
211
+ expport default {
562
212
  name: "text-block",
563
213
  display_name: "Text block",
564
214
  is_root: false,
@@ -572,7 +222,7 @@ module.exports = {
572
222
  };
573
223
  ```
574
224
 
575
- **Important notice:** name inside `.js` schema need to match `.js` filename.
225
+ **Important notice:** name inside `.sb.js` schema need to match `.sb.js` filename.
576
226
 
577
227
  You can add anything mentioned here: https://www.storyblok.com/docs/api/management#core-resources/components/components to your component. (with the exception of `component_group_uuid`: insert `component_group_name` and `sb-mig` will resolve `uuid` automagically).
578
228
 
@@ -615,21 +265,16 @@ There is also support for `sections` inside components:
615
265
 
616
266
  ## Syncing components
617
267
 
618
- The main purpose of `sb-mig` is to sync your `.js` component schema files with your `Storyblok` space.
268
+ The main purpose of `sb-mig` is to sync your `.sb.js` component schema files with your `Storyblok` space.
619
269
 
620
- There are 2 ways to sync your schemas, which to use depends on your file structure. If you are keeping all of your schema files in a single folder, use:
270
+ In v3.x.x There is 1 way to sync your schemas, which is to name all your schemas with `.sb.js` extension. You can have them in any place of your repositories, as long as this place is pointed in `storyblok.config.js` `componentDirectories` field, which is set to `componentsDirectories: ["src", "storyblok"],` by default:
621
271
 
622
272
  ```
623
273
  sb-mig sync components row column
624
274
  ```
625
275
 
626
- This command will look for `row.js` and `column.js` files inside a directory named `storyblok`. You can change the directory name mapping by modifying `componentDirectory` inside `storyblok.config.js`). [How to install and configure](#how-to-install-and-configure))
276
+ This command will look for `row.sb.js` and `column.sb.js` files inside a directories mentioned in `componentDirectories` field. (You can change directories name mapping by modifying `componentDirectories` inside `storyblok.config.js`). You can also change the extension searched by changing `schemaFileExt`. [How to install and configure](#how-to-install-and-configure))
627
277
 
628
- ```
629
- sb-mig sync components --ext row column
630
- ```
631
-
632
- This command will look for any file named `row.sb.js` and `column.sb.js` inside `src` and `storyblok` folders. To modify the directories in this case you can set `componentsDirectories` in the config. You can also change the extension searched by changing `schemaFileExt`. [How to install and configure](#how-to-install-and-configure))
633
278
 
634
279
  ## Syncing datasources
635
280
 
@@ -639,7 +284,7 @@ Add `datasourceExt: "your-own-extension",` to your `storyblok.config.js`. If u w
639
284
 
640
285
  ```
641
286
  // storyblok.config.js
642
- module.exports = {
287
+ export default {
643
288
  ...
644
289
  datasourcesDirectory: "mydatasource.ext.js"
645
290
  ...
@@ -649,7 +294,7 @@ module.exports = {
649
294
  Create file with `.sb.datasource.js` (or your defined one) extension inside it. Basic schema for datasources file:
650
295
 
651
296
  ```
652
- module.exports = {
297
+ export default {
653
298
  name: "icons",
654
299
  slug: "icons",
655
300
  datasource_entries: [
@@ -679,7 +324,7 @@ Single `datasource entry` consist of **precisely** 2 fields. But they can be nam
679
324
  Command for syncing datasources:
680
325
 
681
326
  ```
682
- sb-mig sync datasources icons --ext
327
+ sb-mig sync datasources icons
683
328
  ```
684
329
 
685
330
  Example output from above command
@@ -696,7 +341,7 @@ Trying to get 'icons' datasource.
696
341
  Like with syncing component, you can also use syncing multiple datasources at once:
697
342
 
698
343
  ```
699
- sb-mig sync datasources icons logos --ext
344
+ sb-mig sync datasources icons logos
700
345
  ```
701
346
 
702
347
  ```
@@ -707,15 +352,13 @@ sb-mig sync datasources icons logos --ext
707
352
  You can also sync all datasources, and that's the command we strongly recommend. It will sync all datasources also the one from node_modules, so potentially from `storyblok-components`. But will prefer syncing local ones, if there will be clash of datasources filenames (for example, you can have datasource from node_modules, but wanted to overwrite some fields, you will be able to do that.
708
353
 
709
354
  ```
710
- sb-mig sync datasources --all --ext
355
+ sb-mig sync datasources --all
711
356
  ```
712
357
 
713
358
 
714
359
  ## Presets support
715
360
 
716
- - Experimental
717
-
718
- Writing your own predefined data (presets) for components can be a pain, so with `sb-mig` you can create presets for your components in the storyblok gui, and then export them to a schema based `.js` file to be picked up while syncing.
361
+ Writing your own predefined data (presets) for components can be a pain, so with `sb-mig` you can create presets for your components in the storyblok gui, and then export them to a schema based `.sb.js` file to be picked up while syncing.
719
362
 
720
363
  To do so, first create a preset for your component in storyblok:
721
364
 
@@ -726,7 +369,7 @@ To do so, first create a preset for your component in storyblok:
726
369
  then run
727
370
 
728
371
  ```
729
- sb-mig backup --oneComponentPresets text-block // component you've created preset for
372
+ sb-mig backup component-presets --one text-block // component you've created preset for
730
373
  ```
731
374
 
732
375
  The tool will now download all presets related to the `text-block` component.
@@ -737,9 +380,9 @@ You should remove the id field from the preset (it will be looked up by name)
737
380
  Finally, add the `all_presets` field to your `text-block` component schema.
738
381
 
739
382
  ```
740
- const allPresets = require('./presets/_text-block-preset.json');
383
+ import allPresets from './presets/_text-block-preset.json'
741
384
 
742
- module.exports = {
385
+ export default {
743
386
  ...
744
387
  schema: {
745
388
  title: {
@@ -794,24 +437,17 @@ Link package to easy test it with `sb-mig` command
794
437
  yarn link
795
438
  ```
796
439
 
797
- or use it like that without linking:
798
-
799
- ```
800
- ./bin/run // same as linked `sb-mig` command
801
- ```
802
-
803
440
  ## Roadmap
804
441
 
805
442
  - [ ] Sync / Migrate content (stories)
806
443
  - [ ] Improve preset creation/update
807
- - ~~[ ] End-to-end solution to add / update components~~ // it will be responsibility of different plugin. Check [here](https://github.com/sb-mig/plugin-generate-project)
808
444
  - [x] Sync Roles
809
445
  - [x] Sync / Migrate datasources
810
446
  - [x] Sync components with extensions
811
447
  - [x] Sync presets
812
448
  - [x] Sync single component
813
449
  - [x] Sync all components
814
- - [x] Sync components using schema based .js file (based on idea from [storyblok-migrate](https://github.com/maoberlehner/storyblok-migrate))
450
+ - [x] Sync components using schema based .sb.js file (based on idea from [storyblok-migrate](https://github.com/maoberlehner/storyblok-migrate))
815
451
  - [x] Component groups
816
452
  - [x] Sync custom fields
817
453