sb-mig 2.9.0 → 2.9.13

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.
@@ -17,201 +17,201 @@ class Backup extends core_1.default {
17
17
  const { args, flags, argv } = this.parse(Backup);
18
18
  // Backup one role as json file
19
19
  if (flags.oneRole) {
20
- console.log("oneRole argument: ", flags.oneRole);
21
- return roles_1.getRole(flags.oneRole).then(async (res) => {
20
+ console.log('oneRole argument: ', flags.oneRole);
21
+ return (0, roles_1.getRole)(flags.oneRole).then(async (res) => {
22
22
  if (res) {
23
23
  const datestamp = new Date();
24
- const filename = `role-${flags.oneRole}-${others_1.generateDatestamp(datestamp)}`;
25
- await files_1.createDir(`${config_1.default.sbmigWorkingDirectory}/roles/`);
26
- await files_1.createJsonFile(JSON.stringify(res, undefined, 2), `${config_1.default.sbmigWorkingDirectory}/roles/${filename}.json`);
24
+ const filename = `role-${flags.oneRole}-${(0, others_1.generateDatestamp)(datestamp)}`;
25
+ await (0, files_1.createDir)(`${config_1.default.sbmigWorkingDirectory}/roles/`);
26
+ await (0, files_1.createJsonFile)(JSON.stringify(res, undefined, 2), `${config_1.default.sbmigWorkingDirectory}/roles/${filename}.json`);
27
27
  logger_1.default.success(`Role for ${flags.oneRole} written to a file: ${filename}`);
28
28
  }
29
29
  })
30
30
  .catch((err) => {
31
31
  console.log(err);
32
- this.error("error happened... :(");
32
+ this.error('error happened... :(');
33
33
  });
34
34
  }
35
35
  // Backup all roles and permission as json file
36
36
  if (flags.allRoles) {
37
- return roles_1.getAllRoles()
37
+ return (0, roles_1.getAllRoles)()
38
38
  .then(async (res) => {
39
39
  const datestamp = new Date();
40
- const filename = `all-roles-${others_1.generateDatestamp(datestamp)}`;
41
- await files_1.createDir(`${config_1.default.sbmigWorkingDirectory}/roles/`);
42
- await files_1.createJsonFile(JSON.stringify(res, undefined, 2), `${config_1.default.sbmigWorkingDirectory}/roles/${filename}.json`);
40
+ const filename = `all-roles-${(0, others_1.generateDatestamp)(datestamp)}`;
41
+ await (0, files_1.createDir)(`${config_1.default.sbmigWorkingDirectory}/roles/`);
42
+ await (0, files_1.createJsonFile)(JSON.stringify(res, undefined, 2), `${config_1.default.sbmigWorkingDirectory}/roles/${filename}.json`);
43
43
  logger_1.default.success(`All roles written to a file: ${filename}`);
44
44
  return true;
45
45
  })
46
46
  .catch((err) => {
47
47
  console.log(err);
48
- this.error("error happened... :(");
48
+ this.error('error happened... :(');
49
49
  });
50
50
  }
51
51
  // Backup all components as json file
52
52
  if (flags.allComponents) {
53
- return components_1.getAllComponents()
53
+ return (0, components_1.getAllComponents)()
54
54
  .then(async (res) => {
55
55
  const datestamp = new Date();
56
- const filename = `all-components-${others_1.generateDatestamp(datestamp)}`;
57
- await files_1.createDir(`${config_1.default.sbmigWorkingDirectory}/components/`);
58
- await files_1.createJsonFile(JSON.stringify(res, undefined, 2), `${config_1.default.sbmigWorkingDirectory}/components/${filename}.json`);
56
+ const filename = `all-components-${(0, others_1.generateDatestamp)(datestamp)}`;
57
+ await (0, files_1.createDir)(`${config_1.default.sbmigWorkingDirectory}/components/`);
58
+ await (0, files_1.createJsonFile)(JSON.stringify(res, undefined, 2), `${config_1.default.sbmigWorkingDirectory}/components/${filename}.json`);
59
59
  logger_1.default.success(`All components written to a file: ${filename}`);
60
60
  return true;
61
61
  })
62
62
  .catch((err) => {
63
63
  console.log(err);
64
- this.error("error happened... :(");
64
+ this.error('error happened... :(');
65
65
  });
66
66
  }
67
67
  // Backup one component as json file
68
68
  if (flags.oneComponent) {
69
- return components_1.getComponent(flags.oneComponent).then(async (res) => {
69
+ return (0, components_1.getComponent)(flags.oneComponent).then(async (res) => {
70
70
  if (res) {
71
71
  const datestamp = new Date();
72
- const filename = `component-${flags.oneComponent}-${others_1.generateDatestamp(datestamp)}`;
73
- await files_1.createDir(`${config_1.default.sbmigWorkingDirectory}/components/`);
74
- await files_1.createJsonFile(JSON.stringify(res, undefined, 2), `${config_1.default.sbmigWorkingDirectory}/components/${filename}.json`);
72
+ const filename = `component-${flags.oneComponent}-${(0, others_1.generateDatestamp)(datestamp)}`;
73
+ await (0, files_1.createDir)(`${config_1.default.sbmigWorkingDirectory}/components/`);
74
+ await (0, files_1.createJsonFile)(JSON.stringify(res, undefined, 2), `${config_1.default.sbmigWorkingDirectory}/components/${filename}.json`);
75
75
  logger_1.default.success(`Component for ${flags.oneComponent} written to a file: ${filename}`);
76
76
  }
77
77
  })
78
78
  .catch((err) => {
79
79
  console.log(err);
80
- this.error("error happened... :(");
80
+ this.error('error happened... :(');
81
81
  });
82
82
  }
83
83
  if (flags.allComponentsGroups) {
84
- return components_1.getAllComponentsGroups().then(async (res) => {
84
+ return (0, components_1.getAllComponentsGroups)().then(async (res) => {
85
85
  const datestamp = new Date();
86
- const filename = `all-component_groups-${others_1.generateDatestamp(datestamp)}`;
87
- await files_1.createDir(`${config_1.default.sbmigWorkingDirectory}/component_groups/`);
88
- await files_1.createJsonFile(JSON.stringify(res, undefined, 2), `${config_1.default.sbmigWorkingDirectory}/component_groups/${filename}.json`);
86
+ const filename = `all-component_groups-${(0, others_1.generateDatestamp)(datestamp)}`;
87
+ await (0, files_1.createDir)(`${config_1.default.sbmigWorkingDirectory}/component_groups/`);
88
+ await (0, files_1.createJsonFile)(JSON.stringify(res, undefined, 2), `${config_1.default.sbmigWorkingDirectory}/component_groups/${filename}.json`);
89
89
  logger_1.default.success(`All groups written to a file: ${filename}`);
90
90
  })
91
91
  .catch((err) => {
92
92
  console.log(err);
93
- this.error("error happened... :(");
93
+ this.error('error happened... :(');
94
94
  });
95
95
  }
96
96
  if (flags.oneComponentsGroup) {
97
- return components_1.getComponentsGroup(flags.oneComponentsGroup).then(async (res) => {
97
+ return (0, components_1.getComponentsGroup)(flags.oneComponentsGroup).then(async (res) => {
98
98
  if (res) {
99
99
  const datestamp = new Date();
100
- const filename = `components_group-${flags.oneComponentsGroup}-${others_1.generateDatestamp(datestamp)}`;
101
- await files_1.createDir(`${config_1.default.sbmigWorkingDirectory}/component_groups/`);
102
- await files_1.createJsonFile(JSON.stringify(res, undefined, 2), `${config_1.default.sbmigWorkingDirectory}/component_groups/${filename}.json`);
100
+ const filename = `components_group-${flags.oneComponentsGroup}-${(0, others_1.generateDatestamp)(datestamp)}`;
101
+ await (0, files_1.createDir)(`${config_1.default.sbmigWorkingDirectory}/component_groups/`);
102
+ await (0, files_1.createJsonFile)(JSON.stringify(res, undefined, 2), `${config_1.default.sbmigWorkingDirectory}/component_groups/${filename}.json`);
103
103
  logger_1.default.success(`Components group for ${flags.oneComponentsGroup} written to a file: ${filename}`);
104
104
  }
105
105
  })
106
106
  .catch((err) => {
107
107
  console.log(err);
108
- this.error("error happened... :(");
108
+ this.error('error happened... :(');
109
109
  });
110
110
  }
111
111
  if (flags.allDatasources) {
112
- return datasources_1.getAllDatasources().then(async (res) => {
112
+ return (0, datasources_1.getAllDatasources)().then(async (res) => {
113
113
  const datestamp = new Date();
114
- const filename = `all-datasources-${others_1.generateDatestamp(datestamp)}`;
115
- await files_1.createDir(`${config_1.default.sbmigWorkingDirectory}/datasources/`);
116
- await files_1.createJsonFile(JSON.stringify(res, undefined, 2), `${config_1.default.sbmigWorkingDirectory}/datasources/${filename}.json`);
114
+ const filename = `all-datasources-${(0, others_1.generateDatestamp)(datestamp)}`;
115
+ await (0, files_1.createDir)(`${config_1.default.sbmigWorkingDirectory}/datasources/`);
116
+ await (0, files_1.createJsonFile)(JSON.stringify(res, undefined, 2), `${config_1.default.sbmigWorkingDirectory}/datasources/${filename}.json`);
117
117
  logger_1.default.success(`All datasources written to a file: ${filename}`);
118
118
  })
119
119
  .catch((err) => {
120
120
  console.log(err);
121
- this.error("error happened... :(");
121
+ this.error('error happened... :(');
122
122
  });
123
123
  }
124
124
  if (flags.oneDatasource) {
125
- return datasources_1.getDatasource(flags.oneDatasource).then(async (res) => {
125
+ return (0, datasources_1.getDatasource)(flags.oneDatasource).then(async (res) => {
126
126
  if (res) {
127
127
  const datestamp = new Date();
128
- const filename = `datasource-${flags.oneDatasource}-${others_1.generateDatestamp(datestamp)}`;
129
- await files_1.createDir(`${config_1.default.sbmigWorkingDirectory}/datasources/`);
130
- await files_1.createJsonFile(JSON.stringify(res, undefined, 2), `${config_1.default.sbmigWorkingDirectory}/datasources/${filename}.json`);
128
+ const filename = `datasource-${flags.oneDatasource}-${(0, others_1.generateDatestamp)(datestamp)}`;
129
+ await (0, files_1.createDir)(`${config_1.default.sbmigWorkingDirectory}/datasources/`);
130
+ await (0, files_1.createJsonFile)(JSON.stringify(res, undefined, 2), `${config_1.default.sbmigWorkingDirectory}/datasources/${filename}.json`);
131
131
  logger_1.default.success(`Datasource for ${flags.oneDatasource} written to a file: ${filename}`);
132
132
  }
133
133
  })
134
134
  .catch((err) => {
135
135
  console.log(err);
136
- this.error("error happened... :(");
136
+ this.error('error happened... :(');
137
137
  });
138
138
  }
139
139
  if (flags.datasourceEntries) {
140
- return datasources_1.getDatasourceEntries(flags.datasourceEntries).then(async (res) => {
140
+ return (0, datasources_1.getDatasourceEntries)(flags.datasourceEntries).then(async (res) => {
141
141
  if (res) {
142
142
  const datestamp = new Date();
143
- const filename = `datasource-entries-${flags.datasourceEntries}-${others_1.generateDatestamp(datestamp)}`;
144
- await files_1.createDir(`${config_1.default.sbmigWorkingDirectory}/datasources/`);
145
- await files_1.createJsonFile(JSON.stringify(res, undefined, 2), `${config_1.default.sbmigWorkingDirectory}/datasources/${filename}.json`);
143
+ const filename = `datasource-entries-${flags.datasourceEntries}-${(0, others_1.generateDatestamp)(datestamp)}`;
144
+ await (0, files_1.createDir)(`${config_1.default.sbmigWorkingDirectory}/datasources/`);
145
+ await (0, files_1.createJsonFile)(JSON.stringify(res, undefined, 2), `${config_1.default.sbmigWorkingDirectory}/datasources/${filename}.json`);
146
146
  logger_1.default.success(`Datasource entries for ${flags.datasourceEntries} written to a file: ${filename}`);
147
147
  }
148
148
  })
149
149
  .catch((err) => {
150
150
  console.log(err);
151
- this.error("error happened... :(");
151
+ this.error('error happened... :(');
152
152
  });
153
153
  }
154
154
  if (flags.oneComponentPresets) {
155
- return componentPresets_1.getComponentPresets(flags.oneComponentPresets).then(async (res) => {
155
+ return (0, componentPresets_1.getComponentPresets)(flags.oneComponentPresets).then(async (res) => {
156
156
  if (res) {
157
157
  const datestamp = new Date();
158
- const filename = `component-${flags.oneComponentPresets}-${others_1.generateDatestamp(datestamp)}`;
159
- await files_1.createDir(`${config_1.default.sbmigWorkingDirectory}/component-presets/`);
160
- await files_1.createJsonFile(JSON.stringify(res, undefined, 2), `${config_1.default.sbmigWorkingDirectory}/component-presets/${filename}.json`);
158
+ const filename = `component-${flags.oneComponentPresets}-${(0, others_1.generateDatestamp)(datestamp)}`;
159
+ await (0, files_1.createDir)(`${config_1.default.sbmigWorkingDirectory}/component-presets/`);
160
+ await (0, files_1.createJsonFile)(JSON.stringify(res, undefined, 2), `${config_1.default.sbmigWorkingDirectory}/component-presets/${filename}.json`);
161
161
  logger_1.default.success(`Presets for ${flags.oneComponentPresets} written to a file: ${filename}`);
162
162
  }
163
163
  })
164
164
  .catch((err) => {
165
165
  console.log(err);
166
- this.error("error happened... :(");
166
+ this.error('error happened... :(');
167
167
  });
168
168
  }
169
169
  if (flags.allPresets) {
170
- return presets_1.getAllPresets().then(async (res) => {
170
+ return (0, presets_1.getAllPresets)().then(async (res) => {
171
171
  const datestamp = new Date();
172
- const filename = `all-presets-${others_1.generateDatestamp(datestamp)}`;
173
- await files_1.createDir(`${config_1.default.sbmigWorkingDirectory}/presets/`);
174
- await files_1.createJsonFile(JSON.stringify(res, undefined, 2), `${config_1.default.sbmigWorkingDirectory}/presets/${filename}.json`);
172
+ const filename = `all-presets-${(0, others_1.generateDatestamp)(datestamp)}`;
173
+ await (0, files_1.createDir)(`${config_1.default.sbmigWorkingDirectory}/presets/`);
174
+ await (0, files_1.createJsonFile)(JSON.stringify(res, undefined, 2), `${config_1.default.sbmigWorkingDirectory}/presets/${filename}.json`);
175
175
  logger_1.default.success(`All presets written to a file: ${filename}`);
176
176
  })
177
177
  .catch((err) => {
178
178
  console.log(err);
179
- this.error("error happened... :(");
179
+ this.error('error happened... :(');
180
180
  });
181
181
  }
182
182
  if (flags.onePreset) {
183
- return presets_1.getPreset(flags.onePreset).then(async (res) => {
183
+ return (0, presets_1.getPreset)(flags.onePreset).then(async (res) => {
184
184
  if (res) {
185
185
  const datestamp = new Date();
186
- const filename = `preset-${flags.onePreset}-${others_1.generateDatestamp(datestamp)}`;
187
- await files_1.createDir(`${config_1.default.sbmigWorkingDirectory}/presets/`);
188
- await files_1.createJsonFile(JSON.stringify(res, undefined, 2), `${config_1.default.sbmigWorkingDirectory}/presets/${filename}.json`);
186
+ const filename = `preset-${flags.onePreset}-${(0, others_1.generateDatestamp)(datestamp)}`;
187
+ await (0, files_1.createDir)(`${config_1.default.sbmigWorkingDirectory}/presets/`);
188
+ await (0, files_1.createJsonFile)(JSON.stringify(res, undefined, 2), `${config_1.default.sbmigWorkingDirectory}/presets/${filename}.json`);
189
189
  logger_1.default.success(`Preset for '${flags.onePreset}' have been written to a file: ${filename}`);
190
190
  }
191
191
  })
192
192
  .catch((err) => {
193
193
  console.log(err);
194
- this.error("error happened... :(");
194
+ this.error('error happened... :(');
195
195
  });
196
196
  }
197
197
  this.exit();
198
198
  }
199
199
  }
200
200
  exports.default = Backup;
201
- Backup.description = "Command for backing up anything related to Storyblok";
201
+ Backup.description = 'Command for backing up anything related to Storyblok';
202
202
  Backup.flags = {
203
- help: command_1.flags.help({ char: "h" }),
204
- allComponents: command_1.flags.boolean({ char: "a", description: "Backup all components." }),
205
- oneComponent: command_1.flags.string({ char: "o", description: "Backup one component by name." }),
206
- allComponentsGroups: command_1.flags.boolean({ char: "g", description: "Backup all components groups." }),
207
- oneComponentsGroup: command_1.flags.string({ char: 'f', description: "Backup one components group by name." }),
208
- oneComponentPresets: command_1.flags.string({ char: 'p', description: "Backup all presets for one component" }),
209
- allPresets: command_1.flags.boolean({ char: 'l', description: "Backup all presets." }),
210
- onePreset: command_1.flags.string({ char: 'i', description: "Backup one preset by id." }),
211
- allDatasources: command_1.flags.boolean({ char: 'd', description: "Backup all datasources." }),
212
- oneDatasource: command_1.flags.string({ char: 'x', description: "Backup one datasource by name." }),
213
- datasourceEntries: command_1.flags.string({ char: 'e', description: "Backup one datasource entries by datasource name." }),
214
- allRoles: command_1.flags.boolean({ char: 'R', description: "Backup all roles and permissions." }),
215
- oneRole: command_1.flags.string({ char: 'r', description: "Backup one role by name." }),
203
+ help: command_1.flags.help({ char: 'h' }),
204
+ allComponents: command_1.flags.boolean({ char: 'a', description: 'Backup all components.' }),
205
+ oneComponent: command_1.flags.string({ char: 'o', description: 'Backup one component by name.' }),
206
+ allComponentsGroups: command_1.flags.boolean({ char: 'g', description: 'Backup all components groups.' }),
207
+ oneComponentsGroup: command_1.flags.string({ char: 'f', description: 'Backup one components group by name.' }),
208
+ oneComponentPresets: command_1.flags.string({ char: 'p', description: 'Backup all presets for one component' }),
209
+ allPresets: command_1.flags.boolean({ char: 'l', description: 'Backup all presets.' }),
210
+ onePreset: command_1.flags.string({ char: 'i', description: 'Backup one preset by id.' }),
211
+ allDatasources: command_1.flags.boolean({ char: 'd', description: 'Backup all datasources.' }),
212
+ oneDatasource: command_1.flags.string({ char: 'x', description: 'Backup one datasource by name.' }),
213
+ datasourceEntries: command_1.flags.string({ char: 'e', description: 'Backup one datasource entries by datasource name.' }),
214
+ allRoles: command_1.flags.boolean({ char: 'R', description: 'Backup all roles and permissions.' }),
215
+ oneRole: command_1.flags.string({ char: 'r', description: 'Backup one role by name.' }),
216
216
  };
217
217
  Backup.args = [];
@@ -5,11 +5,18 @@ const core_1 = require("../core");
5
5
  // TODO: implement --verbose flag to be available in every command
6
6
  class Debug extends core_1.default {
7
7
  async run() {
8
- const { args, flags } = this.parse(Debug);
8
+ // const {} = this.parse(Debug)
9
9
  const config = this.storyblokConfig();
10
10
  const componentsConfig = this.storyblokComponentsConfig().getAllData();
11
- console.log("storyblok.config.js: ", config, '\n');
12
- console.log("storyblok.components.lock.js: ", componentsConfig);
11
+ // eslint-disable-next-line no-console
12
+ console.log('Thius are changes!');
13
+ // eslint-disable-next-line no-console
14
+ console.log('storyblok.config.js: ', config, '\n');
15
+ // eslint-disable-next-line no-console
16
+ console.log('storyblok.components.lock.js: ', componentsConfig);
17
+ const test = '2';
18
+ // eslint-disable-next-line no-console
19
+ console.log(test);
13
20
  }
14
21
  }
15
22
  exports.default = Debug;
@@ -11,83 +11,83 @@ class Sync extends core_1.default {
11
11
  async run() {
12
12
  const { argv, args, flags } = this.parse(Sync);
13
13
  const components = argv.splice(1, argv.length);
14
- if (args.type === "roles" && flags.all && flags.ext) {
15
- logger_1.default.log("Syncing all roles...");
16
- roles_1.syncAllRoles();
14
+ if (args.type === 'roles' && flags.all && flags.ext) {
15
+ logger_1.default.log('Syncing all roles...');
16
+ (0, roles_1.syncAllRoles)();
17
17
  }
18
- if (args.type === "roles" && !flags.all && flags.ext) {
18
+ if (args.type === 'roles' && !flags.all && flags.ext) {
19
19
  const roles = components;
20
- logger_1.default.log("Syncing provided roles...");
21
- roles_1.syncProvidedRoles({ roles });
20
+ logger_1.default.log('Syncing provided roles...');
21
+ (0, roles_1.syncProvidedRoles)({ roles });
22
22
  }
23
- if (args.type === "components" && flags.all && flags.ext) {
23
+ if (args.type === 'components' && flags.all && flags.ext) {
24
24
  logger_1.default.log(`Syncing all components with ${config_1.default.schemaFileExt} extension...`);
25
- migrate_1.sync2AllComponents({ presets: flags.presets });
25
+ (0, migrate_1.sync2AllComponents)({ presets: flags.presets });
26
26
  }
27
- if (args.type === "components" && flags.all && !flags.ext) {
28
- logger_1.default.warning("### DEPRECATED method. Method of syncing files without .sb.js extension, will be removed in version 4.0.0 ###");
29
- logger_1.default.warning("Use sb-mig sync components --all --ext instead (you need to update your schema files to be named with .sb.js extension)");
27
+ if (args.type === 'components' && flags.all && !flags.ext) {
28
+ logger_1.default.warning('### DEPRECATED method. Method of syncing files without .sb.js extension, will be removed in version 4.0.0 ###');
29
+ logger_1.default.warning('Use sb-mig sync components --all --ext instead (you need to update your schema files to be named with .sb.js extension)');
30
30
  logger_1.default.log(`Syncing all components from ${config_1.default.componentDirectory} directory...`);
31
- migrate_1.syncAllComponents(!!flags.ext, !!flags.presets);
31
+ (0, migrate_1.syncAllComponents)(Boolean(flags.ext), Boolean(flags.presets));
32
32
  }
33
- if (args.type === "components" && !flags.all && flags.ext) {
33
+ if (args.type === 'components' && !flags.all && flags.ext) {
34
34
  logger_1.default.log(`Syncing provided components with ${config_1.default.schemaFileExt} extension...`);
35
35
  if (components.length === 0) {
36
- logger_1.default.warning(`You have to provide some components separated with empty space. For exmaple: 'row column card'`);
36
+ logger_1.default.warning('You have to provide some components separated with empty space. For exmaple: \'row column card\'');
37
37
  }
38
38
  else {
39
- migrate_1.syncProvidedComponents({ components, presets: !!flags.presets, packageName: flags.packageName });
39
+ (0, migrate_1.syncProvidedComponents)({ components, presets: Boolean(flags.presets), packageName: flags.packageName });
40
40
  }
41
41
  }
42
- if (args.type === "components" && !flags.all && !flags.ext && !flags.lock) {
43
- logger_1.default.warning("### DEPRECATED method. Method of syncing files without .sb.js extension, will be removed in version 4.0.0 ###");
44
- logger_1.default.warning("Use sb-mig sync components --ext instead (you need to update your schema files to be named with .sb.js extension)");
45
- logger_1.default.log("Syncing provided components...");
42
+ if (args.type === 'components' && !flags.all && !flags.ext && !flags.lock) {
43
+ logger_1.default.warning('### DEPRECATED method. Method of syncing files without .sb.js extension, will be removed in version 4.0.0 ###');
44
+ logger_1.default.warning('Use sb-mig sync components --ext instead (you need to update your schema files to be named with .sb.js extension)');
45
+ logger_1.default.log('Syncing provided components...');
46
46
  if (components.length === 0) {
47
- logger_1.default.warning(`You have to provide some components separated with empty space. For exmaple: 'row column card'`);
47
+ logger_1.default.warning('You have to provide some components separated with empty space. For exmaple: \'row column card\'');
48
48
  }
49
49
  else {
50
- migrate_1.syncComponents(components, !!flags.ext, !!flags.presets, flags.packageName);
50
+ (0, migrate_1.syncComponents)(components, Boolean(flags.ext), Boolean(flags.presets), flags.packageName);
51
51
  }
52
52
  }
53
- if (args.type === "datasources" && flags.all && !flags.ext) {
54
- this.error("Datasources are only synced while using --ext optioon. use sb-mig sync datasources --all --ext to sync all datasources with extension (default: .sb.datasources.js)");
53
+ if (args.type === 'datasources' && flags.all && !flags.ext) {
54
+ this.error('Datasources are only synced while using --ext optioon. use sb-mig sync datasources --all --ext to sync all datasources with extension (default: .sb.datasources.js)');
55
55
  }
56
- if (args.type === "datasources" && !flags.all && !flags.ext) {
56
+ if (args.type === 'datasources' && !flags.all && !flags.ext) {
57
57
  const datasources = components;
58
- this.error(`Datasources are only synced while using --ext optioon. use sb-mig sync datasources ${datasources.join(" ")} --ext to sync provided datasources with extension (default: .sb.datasources.js)`);
58
+ this.error(`Datasources are only synced while using --ext optioon. use sb-mig sync datasources ${datasources.join(' ')} --ext to sync provided datasources with extension (default: .sb.datasources.js)`);
59
59
  }
60
- if (args.type === "datasources" && flags.all && flags.ext) {
61
- logger_1.default.log("Syncing all datasources with extension...");
62
- datasources_1.syncAllDatasources();
60
+ if (args.type === 'datasources' && flags.all && flags.ext) {
61
+ logger_1.default.log('Syncing all datasources with extension...');
62
+ (0, datasources_1.syncAllDatasources)();
63
63
  }
64
- if (args.type === "datasources" && !flags.all && flags.ext) {
64
+ if (args.type === 'datasources' && !flags.all && flags.ext) {
65
65
  const datasources = components;
66
- logger_1.default.log("Syncing provided datasources with extension...");
67
- datasources_1.syncProvidedDatasources({ datasources });
66
+ logger_1.default.log('Syncing provided datasources with extension...');
67
+ (0, datasources_1.syncProvidedDatasources)({ datasources });
68
68
  }
69
69
  }
70
70
  }
71
71
  exports.default = Sync;
72
72
  Sync.description = 'Synchronize components, datasources or roles with Storyblok space.';
73
73
  Sync.examples = [
74
- `$ sb-mig sync components --all --ext`,
75
- `$ sb-mig sync components @storyblok-components/text-block --ext --packageName`,
76
- `$ sb-mig sync components @storyblok-components/text-block @storyblok-components/button --ext --packageName`,
77
- `$ sb-mig sync components text-block button --ext`,
78
- `$ sb-mig sync components text-block button`,
79
- `$ sb-mig sync roles`,
74
+ '$ sb-mig sync components --all --ext',
75
+ '$ sb-mig sync components @storyblok-components/text-block --ext --packageName',
76
+ '$ sb-mig sync components @storyblok-components/text-block @storyblok-components/button --ext --packageName',
77
+ '$ sb-mig sync components text-block button --ext',
78
+ '$ sb-mig sync components text-block button',
79
+ '$ sb-mig sync roles',
80
80
  ];
81
81
  Sync.flags = {
82
82
  help: command_1.flags.help({ char: 'h' }),
83
- all: command_1.flags.boolean({ char: 'a', description: "Synchronize all components." }),
83
+ all: command_1.flags.boolean({ char: 'a', description: 'Synchronize all components.' }),
84
84
  ext: command_1.flags.boolean({ char: 'e', description: "Synchronize with file extension. Default extension: '.sb.js'" }),
85
- packageName: command_1.flags.boolean({ char: 'n', description: "Synchronize based on installed package name." }),
86
- presets: command_1.flags.boolean({ char: 'p', description: "Synchronize components with presets." }),
87
- lock: command_1.flags.boolean({ char: 'l', description: "Synchronize based on storyblok.components.lock.js file" })
85
+ packageName: command_1.flags.boolean({ char: 'n', description: 'Synchronize based on installed package name.' }),
86
+ presets: command_1.flags.boolean({ char: 'p', description: 'Synchronize components with presets.' }),
87
+ lock: command_1.flags.boolean({ char: 'l', description: 'Synchronize based on storyblok.components.lock.js file' }),
88
88
  };
89
89
  Sync.strict = false;
90
90
  Sync.args = [
91
- { name: 'type', description: "What to synchronize", options: ['components', 'datasources', 'roles'], required: true },
92
- { name: "list", description: "Space separated list of component names. Example: card product-card row layout" }
91
+ { name: 'type', description: 'What to synchronize', options: ['components', 'datasources', 'roles'], required: true },
92
+ { name: 'list', description: 'Space separated list of component names. Example: card product-card row layout' },
93
93
  ];
@@ -16,24 +16,24 @@ var SWAP_TOKEN;
16
16
  })(SWAP_TOKEN = exports.SWAP_TOKEN || (exports.SWAP_TOKEN = {}));
17
17
  class StoryblokComponentsConfig {
18
18
  constructor(data) {
19
- this.componentImportsToken = "// --- sb-mig scoped component imports ---";
20
- this.componentComponentsListToken = "// --- sb-mig scoped component list ---";
21
- this.componentStylesImportsToken = "// --- sb-mig scoped component styles imports ---";
22
- this.storyblokComponentsConfigUrl = path.resolve(process.cwd(), "storyblok.components.lock.js");
19
+ this.componentImportsToken = '// --- sb-mig scoped component imports ---';
20
+ this.componentComponentsListToken = '// --- sb-mig scoped component list ---';
21
+ this.componentStylesImportsToken = '// --- sb-mig scoped component styles imports ---';
22
+ this.storyblokComponentsConfigUrl = path.resolve(process.cwd(), 'storyblok.components.lock.js');
23
23
  this.data = data;
24
24
  }
25
25
  updateComponentsConfigFile() {
26
26
  const content = `module.exports = ${JSON.stringify(this.data, undefined, 2)}`;
27
27
  fs_1.promises.writeFile(this.storyblokComponentsConfigUrl, content, {
28
- encoding: "utf-8",
28
+ encoding: 'utf-8',
29
29
  })
30
- .then((result) => {
31
- console.log("Done");
30
+ .then(result => {
31
+ console.log('Done');
32
32
  console.log(result);
33
33
  return true;
34
34
  })
35
35
  .catch((err) => {
36
- console.log("error, wtf ?");
36
+ console.log('error, wtf ?');
37
37
  console.log(err.message);
38
38
  return false;
39
39
  });
@@ -44,7 +44,7 @@ class StoryblokComponentsConfig {
44
44
  ...this.data,
45
45
  ...installedComponents.reduce((prev, curr) => {
46
46
  if (!this.getSingleData(`${curr.scope}/${curr.name}`)) {
47
- const stylesFileAvailable = discover2_1.discoverManyStyles({
47
+ const stylesFileAvailable = (0, discover2_1.discoverManyStyles)({
48
48
  fileNames: [curr.name],
49
49
  scope: discover2_1.SCOPE.all,
50
50
  type: discover2_1.LOOKUP_TYPE.fileName,
@@ -54,23 +54,23 @@ class StoryblokComponentsConfig {
54
54
  [`${curr.scope}/${curr.name}`]: {
55
55
  name: `${curr.scope}/${curr.name}`,
56
56
  scope: curr.scope,
57
- location: local ? "local" : "node_modules",
58
- locationPath: local
59
- ? `${config_1.default.storyblokComponentsLocalDirectory}/${curr.name}`
60
- : `node_modules/${curr.scope}/${curr.name}`,
57
+ location: local ? 'local' : 'node_modules',
58
+ locationPath: local ?
59
+ `${config_1.default.storyblokComponentsLocalDirectory}/${curr.name}` :
60
+ `node_modules/${curr.scope}/${curr.name}`,
61
61
  links: {
62
62
  [config_1.default.storyblokComponentsListfile]: {
63
- "// --- sb-mig scoped component imports ---": local
64
- ? `import * as Scoped${camelcase(curr.name, { pascalCase: true })} from "./${curr.name}";`
65
- : `import * as Scoped${camelcase(curr.name, { pascalCase: true })} from "${curr.scope}/${curr.name}";`,
66
- "// --- sb-mig scoped component list ---": `Scoped${camelcase(curr.name, { pascalCase: true })}.ComponentList`,
63
+ '// --- sb-mig scoped component imports ---': local ?
64
+ `import * as Scoped${camelcase(curr.name, { pascalCase: true })} from "./${curr.name}";` :
65
+ `import * as Scoped${camelcase(curr.name, { pascalCase: true })} from "${curr.scope}/${curr.name}";`,
66
+ '// --- sb-mig scoped component list ---': `Scoped${camelcase(curr.name, { pascalCase: true })}.ComponentList`,
67
67
  },
68
68
  [config_1.default.componentsStylesMatchFile]: {
69
- "// --- sb-mig scoped component styles imports ---": stylesFileAvailable
70
- ? local
71
- ? `@import './${curr.name}/${curr.name}.scss';`
72
- : `@import '${curr.scope}/${curr.name}/src/${curr.name}.scss';`
73
- : "",
69
+ '// --- sb-mig scoped component styles imports ---': stylesFileAvailable ?
70
+ local ?
71
+ `@import './${curr.name}/${curr.name}.scss';` :
72
+ `@import '${curr.scope}/${curr.name}/src/${curr.name}.scss';` :
73
+ '',
74
74
  },
75
75
  },
76
76
  },
@@ -105,9 +105,9 @@ class StoryblokComponentsConfig {
105
105
  switch (token) {
106
106
  case SWAP_TOKEN.componentImports:
107
107
  temp = dataEntries
108
- .map((component) => component[1].links)
109
- .map((component) => component[to] !== undefined && component[to])
110
- .filter((elements) => elements !== false)
108
+ .map(component => component[1].links)
109
+ .map(component => component[to] !== undefined && component[to])
110
+ .filter(elements => elements !== false)
111
111
  .reduce(
112
112
  // @ts-ignore
113
113
  (acc, curr) => {
@@ -116,9 +116,9 @@ class StoryblokComponentsConfig {
116
116
  break;
117
117
  case SWAP_TOKEN.componentLists:
118
118
  temp = dataEntries
119
- .map((component) => component[1].links)
120
- .map((component) => component[to] !== undefined && component[to])
121
- .filter((elements) => elements !== false)
119
+ .map(component => component[1].links)
120
+ .map(component => component[to] !== undefined && component[to])
121
+ .filter(elements => elements !== false)
122
122
  .reduce(
123
123
  // @ts-ignore
124
124
  (acc, curr) => {
@@ -130,9 +130,9 @@ class StoryblokComponentsConfig {
130
130
  break;
131
131
  case SWAP_TOKEN.styleImports:
132
132
  temp = dataEntries
133
- .map((component) => component[1].links)
134
- .map((component) => component[to] !== undefined && component[to])
135
- .filter((elements) => elements !== false)
133
+ .map(component => component[1].links)
134
+ .map(component => component[to] !== undefined && component[to])
135
+ .filter(elements => elements !== false)
136
136
  .reduce(
137
137
  // @ts-ignore
138
138
  (acc, curr) => {
@@ -158,26 +158,26 @@ class StoryblokComponentsConfig {
158
158
  to: config_1.default.storyblokComponentsListfile,
159
159
  token: SWAP_TOKEN.componentImports,
160
160
  });
161
- let crumb2 = this.createCrumb({
161
+ const crumb2 = this.createCrumb({
162
162
  to: config_1.default.storyblokComponentsListfile,
163
163
  token: SWAP_TOKEN.componentLists,
164
164
  });
165
- let content = `${crumb1.join("\n")}\n`;
165
+ let content = `${crumb1.join('\n')}\n`;
166
166
  content = `${content}\nexport default [
167
167
  ${crumb2.shift()}
168
- ${crumb2.map((partial) => `${partial},`).join("\n")}
168
+ ${crumb2.map((partial) => `${partial},`).join('\n')}
169
169
  ]\n`;
170
170
  // update actual file
171
171
  fs_1.promises.writeFile(config_1.default.storyblokComponentsListfile, content, {
172
- encoding: "utf-8",
172
+ encoding: 'utf-8',
173
173
  })
174
- .then((result) => {
175
- console.log("Done");
174
+ .then(result => {
175
+ console.log('Done');
176
176
  console.log(result);
177
177
  return true;
178
178
  })
179
179
  .catch((err) => {
180
- console.log("error, wtf ?");
180
+ console.log('error, wtf ?');
181
181
  console.log(err.message);
182
182
  return false;
183
183
  });
@@ -192,18 +192,18 @@ class StoryblokComponentsConfig {
192
192
  to: config_1.default.componentsStylesMatchFile,
193
193
  token: SWAP_TOKEN.styleImports,
194
194
  });
195
- let content = `${crumb1.join("\n")}\n`;
195
+ const content = `${crumb1.join('\n')}\n`;
196
196
  // update actual file
197
197
  fs_1.promises.writeFile(config_1.default.componentsStylesMatchFile, content, {
198
- encoding: "utf-8",
198
+ encoding: 'utf-8',
199
199
  })
200
- .then((result) => {
201
- console.log("Done");
200
+ .then(result => {
201
+ console.log('Done');
202
202
  console.log(result);
203
203
  return true;
204
204
  })
205
205
  .catch((err) => {
206
- console.log("error, wtf ?");
206
+ console.log('error, wtf ?');
207
207
  console.log(err.message);
208
208
  return false;
209
209
  });
@@ -212,7 +212,7 @@ class StoryblokComponentsConfig {
212
212
  exports.StoryblokComponentsConfig = StoryblokComponentsConfig;
213
213
  let fileContent;
214
214
  try {
215
- fileContent = require(path.resolve(process.cwd(), "storyblok.components.lock.js"));
215
+ fileContent = require(path.resolve(process.cwd(), 'storyblok.components.lock.js'));
216
216
  }
217
217
  catch (err) {
218
218
  fileContent = {};