sb-mig 3.1.7 → 3.1.8

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
@@ -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,516 +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:inspect PLUGIN...`](#sb-mig-pluginsinspect-plugin)
306
- * [`sb-mig plugins:install PLUGIN...`](#sb-mig-pluginsinstall-plugin)
307
- * [`sb-mig plugins:link PLUGIN`](#sb-mig-pluginslink-plugin)
308
- * [`sb-mig plugins:uninstall PLUGIN...`](#sb-mig-pluginsuninstall-plugin)
309
- * [`sb-mig plugins:update`](#sb-mig-pluginsupdate)
310
- * [`sb-mig sync TYPE [LIST]`](#sb-mig-sync-type-list)
311
-
312
- ## `sb-mig backup`
313
-
314
- Command for backing up anything related to Storyblok
100
+ * [`sb-mig sync`](#sb-mig-sync)
315
101
 
102
+ ## `sb-mig version`
316
103
  ```
317
- Command for backing up anything related to Storyblok
104
+ $ sb-mig --version
318
105
 
319
- USAGE
320
- $ sb-mig backup
321
-
322
- OPTIONS
323
- -R, --allRoles Backup all roles and permissions.
324
- -a, --allComponents Backup all components.
325
- -d, --allDatasources Backup all datasources.
326
- -e, --datasourceEntries=datasourceEntries Backup one datasource entries by datasource name.
327
- -f, --oneComponentsGroup=oneComponentsGroup Backup one components group by name.
328
- -g, --allComponentsGroups Backup all components groups.
329
- -h, --help show CLI help
330
- -i, --onePreset=onePreset Backup one preset by id.
331
- -l, --allPresets Backup all presets.
332
- -o, --oneComponent=oneComponent Backup one component by name.
333
- -p, --oneComponentPresets=oneComponentPresets Backup all presets for one component
334
- -r, --oneRole=oneRole Backup one role by name.
335
- -x, --oneDatasource=oneDatasource Backup one datasource by name.
106
+ 3.1.7
336
107
  ```
337
108
 
338
- _See code: [lib/commands/backup.js](https://github.com/sb-mig/sb-mig/blob/v2.9.11/lib/commands/backup.js)_
339
-
340
- ## `sb-mig debug`
341
-
342
- Output extra debugging.
343
-
344
- ```
345
- Output extra debugging.
346
-
347
- USAGE
348
- $ sb-mig debug
349
-
350
- OPTIONS
351
- -h, --help show CLI help
352
- ```
353
-
354
- _See code: [lib/commands/debug.js](https://github.com/sb-mig/sb-mig/blob/v2.9.11/lib/commands/debug.js)_
355
-
356
- ## `sb-mig help [COMMAND]`
357
-
358
- display help for sb-mig
359
-
360
- ```
361
- display help for <%= config.bin %>
362
-
363
- USAGE
364
- $ sb-mig help [COMMAND]
365
-
366
- ARGUMENTS
367
- COMMAND command to show help for
368
-
369
- OPTIONS
370
- --all see all commands in CLI
371
- ```
372
-
373
- _See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v2.2.3/src/commands/help.ts)_
374
-
375
- ## `sb-mig plugins`
376
-
377
- List installed plugins.
378
-
379
- ```
380
- List installed plugins.
381
-
382
- USAGE
383
- $ sb-mig plugins
384
-
385
- OPTIONS
386
- --core Show core plugins.
387
-
388
- EXAMPLE
389
- $ sb-mig plugins
390
- ```
391
-
392
- _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v2.0.11/src/commands/plugins/index.ts)_
393
-
394
- ## `sb-mig plugins:inspect PLUGIN...`
395
-
396
- Displays installation properties of a plugin.
397
-
398
- ```
399
- Displays installation properties of a plugin.
400
-
401
- USAGE
402
- $ sb-mig plugins:inspect PLUGIN...
403
-
404
- ARGUMENTS
405
- PLUGIN [default: .] Plugin to inspect.
406
-
407
- OPTIONS
408
- -h, --help Show CLI help.
409
- -v, --verbose
410
-
411
- EXAMPLE
412
- $ sb-mig plugins:inspect myplugin
413
- ```
414
-
415
- _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v2.0.11/src/commands/plugins/inspect.ts)_
416
-
417
- ## `sb-mig plugins:install PLUGIN...`
418
-
419
- Installs a plugin into the CLI.
420
-
421
- ```
422
- Installs a plugin into the CLI.
423
- Can be installed from npm or a git url.
424
-
425
- Installation of a user-installed plugin will override a core plugin.
426
-
427
- 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.
428
-
429
-
430
- USAGE
431
- $ sb-mig plugins:install PLUGIN...
432
-
433
- ARGUMENTS
434
- PLUGIN Plugin to install.
435
-
436
- OPTIONS
437
- -f, --force Run yarn install with force flag.
438
- -h, --help Show CLI help.
439
- -v, --verbose
440
-
441
- DESCRIPTION
442
- Can be installed from npm or a git url.
443
-
444
- Installation of a user-installed plugin will override a core plugin.
445
-
446
- e.g. If you have a core plugin that has a 'hello' command, installing a user-installed plugin with a 'hello' command
447
- will override the core plugin implementation. This is useful if a user needs to update core plugin functionality in
448
- the CLI without the need to patch and update the whole CLI.
449
-
450
- ALIASES
451
- $ sb-mig plugins:add
452
-
453
- EXAMPLES
454
- $ sb-mig plugins:install myplugin
455
- $ sb-mig plugins:install https://github.com/someuser/someplugin
456
- $ sb-mig plugins:install someuser/someplugin
457
- ```
458
-
459
- _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v2.0.11/src/commands/plugins/install.ts)_
460
-
461
- ## `sb-mig plugins:link PLUGIN`
109
+ ## `sb-mig backup`
462
110
 
463
- Links a plugin into the CLI for development.
111
+ Command for backing up anything related to Storyblok
464
112
 
465
113
  ```
466
- Links a plugin into the CLI for development.
467
- Installation of a linked plugin will override a user-installed or core plugin.
468
-
469
- 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.
470
-
471
-
472
- USAGE
473
- $ sb-mig plugins:link PLUGIN
474
-
475
- ARGUMENTS
476
- PATH [default: .] path to plugin
477
-
478
- OPTIONS
479
- -h, --help Show CLI help.
480
- -v, --verbose
114
+ $ sb-mig backup --help
481
115
 
482
- DESCRIPTION
483
- Installation of a linked plugin will override a user-installed or core plugin.
484
116
 
485
- e.g. If you have a user-installed or core plugin that has a 'hello' command, installing a linked plugin with a 'hello'
486
- command will override the user-installed or core plugin implementation. This is useful for development work.
487
117
 
488
- EXAMPLE
489
- $ sb-mig plugins:link myplugin
490
- ```
118
+ CLI to rule the world. (and handle stuff related to Storyblok CMS)
491
119
 
492
- _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v2.0.11/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
493
124
 
494
- ## `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
495
132
 
496
- Removes a plugin from the CLI.
133
+ FLAGS
134
+ --all - Backup all
135
+ --one - Backup one
497
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
498
142
  ```
499
- Removes a plugin from the CLI.
500
-
501
- USAGE
502
- $ sb-mig plugins:uninstall PLUGIN...
503
143
 
504
- ARGUMENTS
505
- PLUGIN plugin to uninstall
144
+ ## `sb-mig debug`
506
145
 
507
- OPTIONS
508
- -h, --help Show CLI help.
509
- -v, --verbose
146
+ Output extra debugging.
510
147
 
511
- ALIASES
512
- $ sb-mig plugins:unlink
513
- $ sb-mig plugins:remove
514
148
  ```
149
+ $ sb-mig debug
515
150
 
516
- _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v2.0.11/src/commands/plugins/uninstall.ts)_
517
-
518
- ## `sb-mig plugins:update`
519
-
520
- Update installed plugins.
521
-
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
+ }
522
169
  ```
523
- Update installed plugins.
524
-
525
- USAGE
526
- $ sb-mig plugins:update
527
170
 
528
- OPTIONS
529
- -h, --help Show CLI help.
530
- -v, --verbose
531
- ```
532
171
 
533
- _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v2.0.11/src/commands/plugins/update.ts)_
534
172
 
535
- ## `sb-mig sync TYPE [LIST]`
173
+ ## `sb-mig sync`
536
174
 
537
175
  Synchronize components, datasources or roles with Storyblok space.
538
176
 
539
177
  ```
540
- Synchronize components, datasources or roles with Storyblok space.
541
-
542
- USAGE
543
- $ sb-mig sync TYPE [LIST]
544
-
545
- ARGUMENTS
546
- TYPE (components|datasources|roles) What to synchronize
547
- LIST Space separated list of component names. Example: card product-card row layout
178
+ $ sb-mig sync --help
548
179
 
549
- OPTIONS
550
- -a, --all Synchronize all components.
551
- -e, --ext Synchronize with file extension. Default extension: '.sb.js'
552
- -h, --help show CLI help
553
- -l, --lock Synchronize based on storyblok.components.lock.js file
554
- -n, --packageName Synchronize based on installed package name.
555
- -p, --presets Synchronize components with presets.
180
+ CLI to rule the world. (and handle stuff related to Storyblok CMS)
556
181
 
557
- EXAMPLES
558
- $ sb-mig sync components --all --ext
559
- $ sb-mig sync components @storyblok-components/text-block --ext --packageName
560
- $ sb-mig sync components @storyblok-components/text-block @storyblok-components/button --ext --packageName
561
- $ sb-mig sync components text-block button --ext
562
- $ sb-mig sync components text-block button
563
- $ sb-mig sync roles
564
- ```
182
+ Usage
183
+ $ sb-mig-v3 sync [components|roles|datasources] [space separated file names] or --all --packageName
565
184
 
566
- _See code: [lib/commands/sync.js](https://github.com/sb-mig/sb-mig/blob/v2.9.11/lib/commands/sync.js)_
567
- <!-- commandsstop -->
185
+ Description
186
+ Synchronize components or roles with Storyblok space.
568
187
 
569
- # Plugins
570
- `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
571
192
 
572
- - [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](#) )
573
- - [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
574
- - [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)
575
197
 
576
- 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
+ ```
577
203
 
578
204
  # Schema documentation:
579
205
 
580
206
  ## Basics
581
207
 
582
- 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:
583
209
 
584
210
  ```
585
- module.exports = {
211
+ expport default {
586
212
  name: "text-block",
587
213
  display_name: "Text block",
588
214
  is_root: false,
@@ -596,7 +222,7 @@ module.exports = {
596
222
  };
597
223
  ```
598
224
 
599
- **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.
600
226
 
601
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).
602
228
 
@@ -639,21 +265,16 @@ There is also support for `sections` inside components:
639
265
 
640
266
  ## Syncing components
641
267
 
642
- 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.
643
269
 
644
- 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:
645
271
 
646
272
  ```
647
273
  sb-mig sync components row column
648
274
  ```
649
275
 
650
- 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))
651
-
652
- ```
653
- sb-mig sync components --ext row column
654
- ```
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))
655
277
 
656
- 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))
657
278
 
658
279
  ## Syncing datasources
659
280
 
@@ -663,7 +284,7 @@ Add `datasourceExt: "your-own-extension",` to your `storyblok.config.js`. If u w
663
284
 
664
285
  ```
665
286
  // storyblok.config.js
666
- module.exports = {
287
+ export default {
667
288
  ...
668
289
  datasourcesDirectory: "mydatasource.ext.js"
669
290
  ...
@@ -673,7 +294,7 @@ module.exports = {
673
294
  Create file with `.sb.datasource.js` (or your defined one) extension inside it. Basic schema for datasources file:
674
295
 
675
296
  ```
676
- module.exports = {
297
+ export default {
677
298
  name: "icons",
678
299
  slug: "icons",
679
300
  datasource_entries: [
@@ -703,7 +324,7 @@ Single `datasource entry` consist of **precisely** 2 fields. But they can be nam
703
324
  Command for syncing datasources:
704
325
 
705
326
  ```
706
- sb-mig sync datasources icons --ext
327
+ sb-mig sync datasources icons
707
328
  ```
708
329
 
709
330
  Example output from above command
@@ -720,7 +341,7 @@ Trying to get 'icons' datasource.
720
341
  Like with syncing component, you can also use syncing multiple datasources at once:
721
342
 
722
343
  ```
723
- sb-mig sync datasources icons logos --ext
344
+ sb-mig sync datasources icons logos
724
345
  ```
725
346
 
726
347
  ```
@@ -731,15 +352,13 @@ sb-mig sync datasources icons logos --ext
731
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.
732
353
 
733
354
  ```
734
- sb-mig sync datasources --all --ext
355
+ sb-mig sync datasources --all
735
356
  ```
736
357
 
737
358
 
738
359
  ## Presets support
739
360
 
740
- - Experimental
741
-
742
- 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.
743
362
 
744
363
  To do so, first create a preset for your component in storyblok:
745
364
 
@@ -750,7 +369,7 @@ To do so, first create a preset for your component in storyblok:
750
369
  then run
751
370
 
752
371
  ```
753
- 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
754
373
  ```
755
374
 
756
375
  The tool will now download all presets related to the `text-block` component.
@@ -761,9 +380,9 @@ You should remove the id field from the preset (it will be looked up by name)
761
380
  Finally, add the `all_presets` field to your `text-block` component schema.
762
381
 
763
382
  ```
764
- const allPresets = require('./presets/_text-block-preset.json');
383
+ import allPresets from './presets/_text-block-preset.json'
765
384
 
766
- module.exports = {
385
+ export default {
767
386
  ...
768
387
  schema: {
769
388
  title: {
@@ -818,24 +437,17 @@ Link package to easy test it with `sb-mig` command
818
437
  yarn link
819
438
  ```
820
439
 
821
- or use it like that without linking:
822
-
823
- ```
824
- ./bin/run // same as linked `sb-mig` command
825
- ```
826
-
827
440
  ## Roadmap
828
441
 
829
442
  - [ ] Sync / Migrate content (stories)
830
443
  - [ ] Improve preset creation/update
831
- - ~~[ ] 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)
832
444
  - [x] Sync Roles
833
445
  - [x] Sync / Migrate datasources
834
446
  - [x] Sync components with extensions
835
447
  - [x] Sync presets
836
448
  - [x] Sync single component
837
449
  - [x] Sync all components
838
- - [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))
839
451
  - [x] Component groups
840
452
  - [x] Sync custom fields
841
453
 
@@ -1,4 +1,4 @@
1
- export declare const mainDescription = "\n CLI to rule the world. (and handle stuff related to Storyblok CMS)\n \n VERSION\n sb-mig/3.0.0@beta\n \n USAGE\n $ sb-mig [command]\n \n COMMANDS\n sync Synchronize components, datasources or roles with Storyblok space.\n backup Command for backing up anything related to Storyblok\n debug Output extra debugging information\n help This screen\n \n Examples\n $ sb-migv-3 sync\n $ sb-mig-v3 debug \n";
2
- export declare const syncDescription = "\n Usage\n $ sb-mig-v3 sync [components|roles|datasources] [space separated file names] or --all --packageName\n \n Description\n Synchronize components or roles with Storyblok space.\n \n COMMANDS\n components - sync components\n roles - sync roles\n datasources - sync datasources\n \n FLAGS\n --all - Sync all components\n --packageName - Sync based on package name, instead of file name (package can have multiple schema files to sync)\n --presets - Pass it, if u want to sync also with presets (will take longer) \n \n EXAMPLES\n $ sb-mig sync components --all\n $ sb-mig sync components accordion accordion-item\n $ sb-mig sync components @storyblok-components/accordion --packageName\n \n";
3
- export declare const backupDescription = "\n Usage\n $ sb-mig-v3 backup [components|component-groups|roles|datasources|presets|component-presets] [space separated file names ] or --all\n Description\n Command for backing up anything related to Storyblok\n \n COMMANDS\n components - backup components\n component-groups - backuo component-groups\n roles - backup components\n datasources - backup components\n presets - backup presets\n component-presets - backup component presets\n \n FLAGS\n --all - Backup all \n --one - Backup one \n \n EXAMPLES\n $ sb-mig backup components --all\n $ sb-mig backup components accordion accordion-item carousel text-block\n $ sb-mig backup datasources --all\n $ sb-mig backup roles admin normal-user\n";
1
+ export declare const mainDescription = "\n CLI to rule the world. (and handle stuff related to Storyblok CMS)\n \n USAGE\n $ sb-mig [command]\n \n COMMANDS\n sync Synchronize components, datasources or roles with Storyblok space.\n backup Command for backing up anything related to Storyblok\n debug Output extra debugging information\n help This screen\n \n Examples\n $ sb-migv-3 sync\n $ sb-mig-v3 debug \n";
2
+ export declare const syncDescription = "\n Usage\n $ sb-mig-v3 sync [components|roles|datasources] [space separated file names] or --all --packageName\n \n Description\n Synchronize components or roles with Storyblok space.\n \n COMMANDS\n components - sync components\n roles - sync roles\n datasources - sync datasources\n \n FLAGS\n --all - Sync all components\n --packageName - Sync based on package name, instead of file name (package can have multiple schema files to sync)\n --presets - Pass it, if u want to sync also with presets (will take longer) \n \n EXAMPLES\n $ sb-mig sync components --all\n $ sb-mig sync components accordion accordion-item\n $ sb-mig sync components @storyblok-components/accordion --packageName\n \n";
3
+ export declare const backupDescription = "\n Usage\n $ sb-mig-v3 backup [components|component-groups|roles|datasources|presets|component-presets] [space separated file names ] or --all\n Description\n Command for backing up anything related to Storyblok\n \n COMMANDS\n components - backup components\n component-groups - backuo component-groups\n roles - backup components\n datasources - backup components\n presets - backup presets\n component-presets - backup component presets\n \n FLAGS\n --all - Backup all \n --one - Backup one \n \n EXAMPLES\n $ sb-mig backup components --all\n $ sb-mig backup components accordion accordion-item carousel text-block\n $ sb-mig backup datasources --all\n $ sb-mig backup roles admin normal-user\n";
4
4
  export declare const debugDescription = "\n Usage\n $ sb-mig-v3 debug\n Description\n Output extra debugging information\n";
@@ -1,9 +1,6 @@
1
1
  export const mainDescription = `
2
2
  CLI to rule the world. (and handle stuff related to Storyblok CMS)
3
3
 
4
- VERSION
5
- sb-mig/3.0.0@beta
6
-
7
4
  USAGE
8
5
  $ sb-mig [command]
9
6
 
@@ -25,14 +22,14 @@ export const syncDescription = `
25
22
  Synchronize components or roles with Storyblok space.
26
23
 
27
24
  COMMANDS
28
- components - sync components
29
- roles - sync roles
30
- datasources - sync datasources
25
+ components - sync components
26
+ roles - sync roles
27
+ datasources - sync datasources
31
28
 
32
29
  FLAGS
33
- --all - Sync all components
34
- --packageName - Sync based on package name, instead of file name (package can have multiple schema files to sync)
35
- --presets - Pass it, if u want to sync also with presets (will take longer)
30
+ --all - Sync all components
31
+ --packageName - Sync based on package name, instead of file name (package can have multiple schema files to sync)
32
+ --presets - Pass it, if u want to sync also with presets (will take longer)
36
33
 
37
34
  EXAMPLES
38
35
  $ sb-mig sync components --all
@@ -47,16 +44,16 @@ export const backupDescription = `
47
44
  Command for backing up anything related to Storyblok
48
45
 
49
46
  COMMANDS
50
- components - backup components
51
- component-groups - backuo component-groups
52
- roles - backup components
53
- datasources - backup components
54
- presets - backup presets
47
+ components - backup components
48
+ component-groups - backuo component-groups
49
+ roles - backup components
50
+ datasources - backup components
51
+ presets - backup presets
55
52
  component-presets - backup component presets
56
53
 
57
54
  FLAGS
58
- --all - Backup all
59
- --one - Backup one
55
+ --all - Backup all
56
+ --one - Backup one
60
57
 
61
58
  EXAMPLES
62
59
  $ sb-mig backup components --all
@@ -1,12 +1,6 @@
1
1
  export interface IStoryblokConfig {
2
- componentsMatchFile: string;
3
- storyblokComponentsListfile: string;
4
2
  storyblokComponentsLocalDirectory: string;
5
- componentsStylesMatchFile: string;
6
- boilerplateUrl: string;
7
3
  sbmigWorkingDirectory: string;
8
- componentDirectory: string;
9
- datasourcesDirectory: string;
10
4
  componentsDirectories: string[];
11
5
  schemaFileExt: string;
12
6
  datasourceExt: string;
@@ -4,14 +4,8 @@ import dotenv from "dotenv";
4
4
  import { getFileContent } from "../utils/main.js";
5
5
  dotenv.config();
6
6
  const defaultConfig = {
7
- componentsMatchFile: "src/components/components.js",
8
- storyblokComponentsListfile: "src/components/storyblok-components.componentList.js",
9
7
  storyblokComponentsLocalDirectory: "src/@storyblok-components",
10
- componentsStylesMatchFile: "src/@storyblok-components/_storyblok-components.scss",
11
- boilerplateUrl: "git@github.com:storyblok-components/gatsby-storyblok-boilerplate.git",
12
8
  sbmigWorkingDirectory: "sbmig",
13
- componentDirectory: "storyblok",
14
- datasourcesDirectory: "storyblok",
15
9
  componentsDirectories: ["src", "storyblok"],
16
10
  schemaFileExt: "sb.js",
17
11
  datasourceExt: "sb.datasource.js",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sb-mig",
3
- "version": "3.1.7",
3
+ "version": "3.1.8",
4
4
  "description": "CLI to rule the world. (and handle stuff related to Storyblok CMS)",
5
5
  "author": "Marcin Krawczyk <marckraw@icloud.com>",
6
6
  "license": "MIT",
@@ -57,5 +57,5 @@
57
57
  "conventional-changelog-cli": "^2.0.31",
58
58
  "typescript": "^4.5.5"
59
59
  },
60
- "gitHead": "995b2c45f9da0b37eb6cc7530db4b7edfd874fdb"
60
+ "gitHead": "0965a4b3896f2e94c052d3990fa33f1166747811"
61
61
  }