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.
@@ -22,24 +22,22 @@ var LOOKUP_TYPE;
22
22
  // problem with glob sync is, that when there is only one folder to search for
23
23
  // we have to omit { } and when a lot, we have to use {folder1, folder2}
24
24
  // so this function will normalize it based on amount of folders provided
25
- const normalizeDiscover = ({ segments, }) => {
25
+ const normalizeDiscover = ({ segments }) => {
26
26
  if (segments.length === 1) {
27
27
  return segments[0];
28
28
  }
29
- else {
30
- return `{${segments.join(",")}}`;
31
- }
29
+ return `{${segments.join(',')}}`;
32
30
  };
33
- exports.compare = (request) => {
31
+ const compare = (request) => {
34
32
  const splittedLocal = request.local.map(path => {
35
33
  return {
36
- name: path.split("/")[path.split("/").length - 1],
34
+ name: path.split('/')[path.split('/').length - 1],
37
35
  path,
38
36
  };
39
37
  });
40
38
  const splittedExternal = request.external.map(path => {
41
39
  return {
42
- name: path.split("/")[path.split("/").length - 1],
40
+ name: path.split('/')[path.split('/').length - 1],
43
41
  path,
44
42
  };
45
43
  });
@@ -51,14 +49,13 @@ exports.compare = (request) => {
51
49
  if (splittedLocal.find(localComponent => externalComponent.name === localComponent.name)) {
52
50
  return false;
53
51
  }
54
- else {
55
- return true;
56
- }
57
- })
52
+ return true;
53
+ }),
58
54
  };
59
55
  return result;
60
56
  };
61
- exports.discoverManyByPackageName = (request) => {
57
+ exports.compare = compare;
58
+ const discoverManyByPackageName = (request) => {
62
59
  const rootDirectory = './';
63
60
  const directory = path.resolve(process.cwd(), rootDirectory);
64
61
  let pattern;
@@ -67,44 +64,44 @@ exports.discoverManyByPackageName = (request) => {
67
64
  switch (request.scope) {
68
65
  case SCOPE.local:
69
66
  // ### MANY by PACKAGE - LOCAL - packageName
70
- const onlyLocalComponentsDirectories = config_1.default.componentsDirectories.filter(path => !path.includes("node_modules"));
71
- pattern = path.join(`${directory}/${normalizeDiscover({ segments: onlyLocalComponentsDirectories })}`, `**`, `package.json`);
67
+ const onlyLocalComponentsDirectories = config_1.default.componentsDirectories.filter(path => !path.includes('node_modules'));
68
+ pattern = path.join(`${directory}/${normalizeDiscover({ segments: onlyLocalComponentsDirectories })}`, '**', 'package.json');
72
69
  listOfPackagesJsonFiles = glob.sync(pattern, { follow: true });
73
70
  listOfFiles = listOfPackagesJsonFiles
74
- .filter(file => request.packageNames.includes(exports.getFileContent({ file }).name)) // filter only package.json from provided request.packageNames
71
+ .filter(file => request.packageNames.includes((0, exports.getFileContent)({ file }).name)) // filter only package.json from provided request.packageNames
75
72
  .map(file => {
76
73
  // get path to folder in which current package.json is
77
- const fileFolderPath = file.split("/").slice(0, -1).join("/");
78
- const allStoryblokSchemaFilesWithinFolderPattern = path.join(`${fileFolderPath}`, `**`, `[^_]*.${config_1.default.schemaFileExt}`);
74
+ const fileFolderPath = file.split('/').slice(0, -1).join('/');
75
+ const allStoryblokSchemaFilesWithinFolderPattern = path.join(`${fileFolderPath}`, '**', `[^_]*.${config_1.default.schemaFileExt}`);
79
76
  return glob.sync(allStoryblokSchemaFilesWithinFolderPattern, { follow: true });
80
77
  })
81
78
  .flat();
82
79
  break;
83
80
  case SCOPE.external:
84
81
  // ### MANY by PACKAGE - EXTERNAL - packageName
85
- const onlyNodeModulesPackagesComponentsDirectories = config_1.default.componentsDirectories.filter(path => path.includes("node_modules"));
86
- pattern = path.join(`${directory}/${normalizeDiscover({ segments: onlyNodeModulesPackagesComponentsDirectories })}`, `**`, `package.json`);
82
+ const onlyNodeModulesPackagesComponentsDirectories = config_1.default.componentsDirectories.filter(path => path.includes('node_modules'));
83
+ pattern = path.join(`${directory}/${normalizeDiscover({ segments: onlyNodeModulesPackagesComponentsDirectories })}`, '**', 'package.json');
87
84
  listOfPackagesJsonFiles = glob.sync(pattern, { follow: true });
88
85
  listOfFiles = listOfPackagesJsonFiles
89
- .filter(file => request.packageNames.includes(exports.getFileContent({ file }).name)) // filter only package.json from provided request.packageNames
86
+ .filter(file => request.packageNames.includes((0, exports.getFileContent)({ file }).name)) // filter only package.json from provided request.packageNames
90
87
  .map(file => {
91
88
  // get path to folder in which current package.json is
92
- const fileFolderPath = file.split("/").slice(0, -1).join("/");
93
- const allStoryblokSchemaFilesWithinFolderPattern = path.join(`${fileFolderPath}`, `**`, `[^_]*.${config_1.default.schemaFileExt}`);
89
+ const fileFolderPath = file.split('/').slice(0, -1).join('/');
90
+ const allStoryblokSchemaFilesWithinFolderPattern = path.join(`${fileFolderPath}`, '**', `[^_]*.${config_1.default.schemaFileExt}`);
94
91
  return glob.sync(allStoryblokSchemaFilesWithinFolderPattern, { follow: true });
95
92
  })
96
93
  .flat();
97
94
  break;
98
95
  case SCOPE.all:
99
96
  // ### MANY by PACKAGE - ALL - packageName
100
- pattern = path.join(`${directory}/${normalizeDiscover({ segments: config_1.default.componentsDirectories })}`, `**`, `package.json`);
97
+ pattern = path.join(`${directory}/${normalizeDiscover({ segments: config_1.default.componentsDirectories })}`, '**', 'package.json');
101
98
  listOfPackagesJsonFiles = glob.sync(pattern, { follow: true });
102
99
  listOfFiles = listOfPackagesJsonFiles
103
- .filter(file => request.packageNames.includes(exports.getFileContent({ file }).name)) // filter only package.json from provided request.packageNames
100
+ .filter(file => request.packageNames.includes((0, exports.getFileContent)({ file }).name)) // filter only package.json from provided request.packageNames
104
101
  .map(file => {
105
102
  // get path to folder in which current package.json is
106
- const fileFolderPath = file.split("/").slice(0, -1).join("/");
107
- const allStoryblokSchemaFilesWithinFolderPattern = path.join(`${fileFolderPath}`, `**`, `[^_]*.${config_1.default.schemaFileExt}`);
103
+ const fileFolderPath = file.split('/').slice(0, -1).join('/');
104
+ const allStoryblokSchemaFilesWithinFolderPattern = path.join(`${fileFolderPath}`, '**', `[^_]*.${config_1.default.schemaFileExt}`);
108
105
  return glob.sync(allStoryblokSchemaFilesWithinFolderPattern, { follow: true });
109
106
  })
110
107
  .flat();
@@ -114,7 +111,8 @@ exports.discoverManyByPackageName = (request) => {
114
111
  }
115
112
  return listOfFiles;
116
113
  };
117
- exports.discoverOneByPackageName = (request) => {
114
+ exports.discoverManyByPackageName = discoverManyByPackageName;
115
+ const discoverOneByPackageName = (request) => {
118
116
  const rootDirectory = './';
119
117
  const directory = path.resolve(process.cwd(), rootDirectory);
120
118
  let pattern;
@@ -123,44 +121,44 @@ exports.discoverOneByPackageName = (request) => {
123
121
  switch (request.scope) {
124
122
  case SCOPE.local:
125
123
  // ### ONE by PACKAGE - LOCAL - packageName
126
- const onlyLocalComponentsDirectories = config_1.default.componentsDirectories.filter(path => !path.includes("node_modules"));
127
- pattern = path.join(`${directory}/${normalizeDiscover({ segments: onlyLocalComponentsDirectories })}`, `**`, `package.json`);
124
+ const onlyLocalComponentsDirectories = config_1.default.componentsDirectories.filter(path => !path.includes('node_modules'));
125
+ pattern = path.join(`${directory}/${normalizeDiscover({ segments: onlyLocalComponentsDirectories })}`, '**', 'package.json');
128
126
  listOfPackagesJsonFiles = glob.sync(pattern, { follow: true });
129
127
  listOfFiles = listOfPackagesJsonFiles
130
- .filter(file => exports.getFileContent({ file }).name === request.packageName) // filter only package.json from provided request.packageName
128
+ .filter(file => (0, exports.getFileContent)({ file }).name === request.packageName) // filter only package.json from provided request.packageName
131
129
  .map(file => {
132
130
  // get path to folder in which current package.json is
133
- const fileFolderPath = file.split("/").slice(0, -1).join("/");
134
- const allStoryblokSchemaFilesWithinFolderPattern = path.join(`${fileFolderPath}`, `**`, `[^_]*.${config_1.default.schemaFileExt}`);
131
+ const fileFolderPath = file.split('/').slice(0, -1).join('/');
132
+ const allStoryblokSchemaFilesWithinFolderPattern = path.join(`${fileFolderPath}`, '**', `[^_]*.${config_1.default.schemaFileExt}`);
135
133
  return glob.sync(allStoryblokSchemaFilesWithinFolderPattern, { follow: true });
136
134
  })
137
135
  .flat();
138
136
  break;
139
137
  case SCOPE.external:
140
138
  // ### ONE by PACKAGE - EXTERNAL - packageName
141
- const onlyNodeModulesPackagesComponentsDirectories = config_1.default.componentsDirectories.filter(path => path.includes("node_modules"));
142
- pattern = path.join(`${directory}/${normalizeDiscover({ segments: onlyNodeModulesPackagesComponentsDirectories })}`, `**`, `package.json`);
139
+ const onlyNodeModulesPackagesComponentsDirectories = config_1.default.componentsDirectories.filter(path => path.includes('node_modules'));
140
+ pattern = path.join(`${directory}/${normalizeDiscover({ segments: onlyNodeModulesPackagesComponentsDirectories })}`, '**', 'package.json');
143
141
  listOfPackagesJsonFiles = glob.sync(pattern, { follow: true });
144
142
  listOfFiles = listOfPackagesJsonFiles
145
- .filter(file => exports.getFileContent({ file }).name === request.packageName) // filter only package.json from provided request.packageName
143
+ .filter(file => (0, exports.getFileContent)({ file }).name === request.packageName) // filter only package.json from provided request.packageName
146
144
  .map(file => {
147
145
  // get path to folder in which current package.json is
148
- const fileFolderPath = file.split("/").slice(0, -1).join("/");
149
- const allStoryblokSchemaFilesWithinFolderPattern = path.join(`${fileFolderPath}`, `**`, `[^_]*.${config_1.default.schemaFileExt}`);
146
+ const fileFolderPath = file.split('/').slice(0, -1).join('/');
147
+ const allStoryblokSchemaFilesWithinFolderPattern = path.join(`${fileFolderPath}`, '**', `[^_]*.${config_1.default.schemaFileExt}`);
150
148
  return glob.sync(allStoryblokSchemaFilesWithinFolderPattern, { follow: true });
151
149
  })
152
150
  .flat();
153
151
  break;
154
152
  case SCOPE.all:
155
153
  // ### ONE by PACKAGE - ALL - packageName
156
- pattern = path.join(`${directory}/${normalizeDiscover({ segments: config_1.default.componentsDirectories })}`, `**`, `package.json`);
154
+ pattern = path.join(`${directory}/${normalizeDiscover({ segments: config_1.default.componentsDirectories })}`, '**', 'package.json');
157
155
  listOfPackagesJsonFiles = glob.sync(pattern, { follow: true });
158
156
  listOfFiles = listOfPackagesJsonFiles
159
- .filter(file => exports.getFileContent({ file }).name === request.packageName) // filter only package.json from provided request.packageName
157
+ .filter(file => (0, exports.getFileContent)({ file }).name === request.packageName) // filter only package.json from provided request.packageName
160
158
  .map(file => {
161
159
  // get path to folder in which current package.json is
162
- const fileFolderPath = file.split("/").slice(0, -1).join("/");
163
- const allStoryblokSchemaFilesWithinFolderPattern = path.join(`${fileFolderPath}`, `**`, `[^_]*.${config_1.default.schemaFileExt}`);
160
+ const fileFolderPath = file.split('/').slice(0, -1).join('/');
161
+ const allStoryblokSchemaFilesWithinFolderPattern = path.join(`${fileFolderPath}`, '**', `[^_]*.${config_1.default.schemaFileExt}`);
164
162
  return glob.sync(allStoryblokSchemaFilesWithinFolderPattern, { follow: true });
165
163
  })
166
164
  .flat();
@@ -170,7 +168,8 @@ exports.discoverOneByPackageName = (request) => {
170
168
  }
171
169
  return listOfFiles;
172
170
  };
173
- exports.discoverMany = (request) => {
171
+ exports.discoverOneByPackageName = discoverOneByPackageName;
172
+ const discoverMany = (request) => {
174
173
  const rootDirectory = './';
175
174
  const directory = path.resolve(process.cwd(), rootDirectory);
176
175
  let pattern;
@@ -178,19 +177,19 @@ exports.discoverMany = (request) => {
178
177
  switch (request.scope) {
179
178
  case SCOPE.local:
180
179
  // ### MANY - LOCAL - fileName ###
181
- const onlyLocalComponentsDirectories = config_1.default.componentsDirectories.filter(path => !path.includes("node_modules"));
182
- pattern = path.join(`${directory}/${normalizeDiscover({ segments: onlyLocalComponentsDirectories })}`, `**`, `${normalizeDiscover({ segments: request.fileNames })}.${config_1.default.schemaFileExt}`);
180
+ const onlyLocalComponentsDirectories = config_1.default.componentsDirectories.filter(path => !path.includes('node_modules'));
181
+ pattern = path.join(`${directory}/${normalizeDiscover({ segments: onlyLocalComponentsDirectories })}`, '**', `${normalizeDiscover({ segments: request.fileNames })}.${config_1.default.schemaFileExt}`);
183
182
  listOfFiles = glob.sync(pattern, { follow: true });
184
183
  break;
185
184
  case SCOPE.external:
186
185
  // ### MANY - EXTERNAL - fileName ###
187
- const onlyNodeModulesPackagesComponentsDirectories = config_1.default.componentsDirectories.filter(path => path.includes("node_modules"));
188
- pattern = path.join(`${directory}/${normalizeDiscover({ segments: onlyNodeModulesPackagesComponentsDirectories })}`, `**`, `${normalizeDiscover({ segments: request.fileNames })}.${config_1.default.schemaFileExt}`);
186
+ const onlyNodeModulesPackagesComponentsDirectories = config_1.default.componentsDirectories.filter(path => path.includes('node_modules'));
187
+ pattern = path.join(`${directory}/${normalizeDiscover({ segments: onlyNodeModulesPackagesComponentsDirectories })}`, '**', `${normalizeDiscover({ segments: request.fileNames })}.${config_1.default.schemaFileExt}`);
189
188
  listOfFiles = glob.sync(pattern, { follow: true });
190
189
  break;
191
190
  case SCOPE.all:
192
191
  // ### MANY - ALL - fileName ###
193
- pattern = path.join(`${directory}/${normalizeDiscover({ segments: config_1.default.componentsDirectories })}`, `**`, `${normalizeDiscover({ segments: request.fileNames })}.${config_1.default.schemaFileExt}`);
192
+ pattern = path.join(`${directory}/${normalizeDiscover({ segments: config_1.default.componentsDirectories })}`, '**', `${normalizeDiscover({ segments: request.fileNames })}.${config_1.default.schemaFileExt}`);
194
193
  listOfFiles = glob.sync(pattern, { follow: true });
195
194
  break;
196
195
  default:
@@ -198,7 +197,8 @@ exports.discoverMany = (request) => {
198
197
  }
199
198
  return listOfFiles;
200
199
  };
201
- exports.discoverManyDatasources = (request) => {
200
+ exports.discoverMany = discoverMany;
201
+ const discoverManyDatasources = (request) => {
202
202
  const rootDirectory = './';
203
203
  const directory = path.resolve(process.cwd(), rootDirectory);
204
204
  let pattern;
@@ -206,19 +206,19 @@ exports.discoverManyDatasources = (request) => {
206
206
  switch (request.scope) {
207
207
  case SCOPE.local:
208
208
  // ### MANY - LOCAL - fileName ###
209
- const onlyLocalComponentsDirectories = config_1.default.componentsDirectories.filter(path => !path.includes("node_modules"));
210
- pattern = path.join(`${directory}/${normalizeDiscover({ segments: onlyLocalComponentsDirectories })}`, `**`, `${normalizeDiscover({ segments: request.fileNames })}.${config_1.default.datasourceExt}`);
209
+ const onlyLocalComponentsDirectories = config_1.default.componentsDirectories.filter(path => !path.includes('node_modules'));
210
+ pattern = path.join(`${directory}/${normalizeDiscover({ segments: onlyLocalComponentsDirectories })}`, '**', `${normalizeDiscover({ segments: request.fileNames })}.${config_1.default.datasourceExt}`);
211
211
  listOfFiles = glob.sync(pattern, { follow: true });
212
212
  break;
213
213
  case SCOPE.external:
214
214
  // ### MANY - EXTERNAL - fileName ###
215
- const onlyNodeModulesPackagesComponentsDirectories = config_1.default.componentsDirectories.filter(path => path.includes("node_modules"));
216
- pattern = path.join(`${directory}/${normalizeDiscover({ segments: onlyNodeModulesPackagesComponentsDirectories })}`, `**`, `${normalizeDiscover({ segments: request.fileNames })}.${config_1.default.datasourceExt}`);
215
+ const onlyNodeModulesPackagesComponentsDirectories = config_1.default.componentsDirectories.filter(path => path.includes('node_modules'));
216
+ pattern = path.join(`${directory}/${normalizeDiscover({ segments: onlyNodeModulesPackagesComponentsDirectories })}`, '**', `${normalizeDiscover({ segments: request.fileNames })}.${config_1.default.datasourceExt}`);
217
217
  listOfFiles = glob.sync(pattern, { follow: true });
218
218
  break;
219
219
  case SCOPE.all:
220
220
  // ### MANY - ALL - fileName ###
221
- pattern = path.join(`${directory}/${normalizeDiscover({ segments: config_1.default.componentsDirectories })}`, `**`, `${normalizeDiscover({ segments: request.fileNames })}.${config_1.default.datasourceExt}`);
221
+ pattern = path.join(`${directory}/${normalizeDiscover({ segments: config_1.default.componentsDirectories })}`, '**', `${normalizeDiscover({ segments: request.fileNames })}.${config_1.default.datasourceExt}`);
222
222
  listOfFiles = glob.sync(pattern, { follow: true });
223
223
  break;
224
224
  default:
@@ -226,7 +226,8 @@ exports.discoverManyDatasources = (request) => {
226
226
  }
227
227
  return listOfFiles;
228
228
  };
229
- exports.discoverDatasources = (request) => {
229
+ exports.discoverManyDatasources = discoverManyDatasources;
230
+ const discoverDatasources = (request) => {
230
231
  const rootDirectory = './';
231
232
  const directory = path.resolve(process.cwd(), rootDirectory);
232
233
  let pattern;
@@ -234,21 +235,21 @@ exports.discoverDatasources = (request) => {
234
235
  switch (request.scope) {
235
236
  case SCOPE.local:
236
237
  // ### ALL - LOCAL - fileName ###
237
- const onlyLocalComponentsDirectories = config_1.default.componentsDirectories.filter(path => !path.includes("node_modules"));
238
- pattern = path.join(`${directory}/${normalizeDiscover({ segments: onlyLocalComponentsDirectories })}`, `**`, `[^_]*.${config_1.default.datasourceExt}` // all files with 'ext' extension, without files beggining with _
238
+ const onlyLocalComponentsDirectories = config_1.default.componentsDirectories.filter(path => !path.includes('node_modules'));
239
+ pattern = path.join(`${directory}/${normalizeDiscover({ segments: onlyLocalComponentsDirectories })}`, '**', `[^_]*.${config_1.default.datasourceExt}` // all files with 'ext' extension, without files beggining with _
239
240
  );
240
241
  listOfFiles = glob.sync(pattern, { follow: true });
241
242
  break;
242
243
  case SCOPE.external:
243
244
  // ### ALL - EXTERNAL - fileName ###
244
- const onlyNodeModulesPackagesComponentsDirectories = config_1.default.componentsDirectories.filter(path => path.includes("node_modules"));
245
- pattern = path.join(`${directory}/${normalizeDiscover({ segments: onlyNodeModulesPackagesComponentsDirectories })}`, `**`, `[^_]*.${config_1.default.datasourceExt}` // all files with 'ext' extension, without files beggining with _
245
+ const onlyNodeModulesPackagesComponentsDirectories = config_1.default.componentsDirectories.filter(path => path.includes('node_modules'));
246
+ pattern = path.join(`${directory}/${normalizeDiscover({ segments: onlyNodeModulesPackagesComponentsDirectories })}`, '**', `[^_]*.${config_1.default.datasourceExt}` // all files with 'ext' extension, without files beggining with _
246
247
  );
247
248
  listOfFiles = glob.sync(pattern, { follow: true });
248
249
  break;
249
250
  case SCOPE.all:
250
251
  // ### ALL - LOCAL - fileName ###
251
- pattern = path.join(`${directory}/${normalizeDiscover({ segments: config_1.default.componentsDirectories })}`, `**`, `[^_]*.${config_1.default.datasourceExt}` // all files with 'ext' extension, without files beggining with _
252
+ pattern = path.join(`${directory}/${normalizeDiscover({ segments: config_1.default.componentsDirectories })}`, '**', `[^_]*.${config_1.default.datasourceExt}` // all files with 'ext' extension, without files beggining with _
252
253
  );
253
254
  listOfFiles = glob.sync(pattern, { follow: true });
254
255
  break;
@@ -257,7 +258,8 @@ exports.discoverDatasources = (request) => {
257
258
  }
258
259
  return listOfFiles;
259
260
  };
260
- exports.discoverOne = (request) => {
261
+ exports.discoverDatasources = discoverDatasources;
262
+ const discoverOne = (request) => {
261
263
  const rootDirectory = './';
262
264
  const directory = path.resolve(process.cwd(), rootDirectory);
263
265
  let pattern;
@@ -265,21 +267,21 @@ exports.discoverOne = (request) => {
265
267
  switch (request.scope) {
266
268
  case SCOPE.local:
267
269
  // ### ONE - LOCAL - fileName ###
268
- const onlyLocalComponentsDirectories = config_1.default.componentsDirectories.filter(path => !path.includes("node_modules"));
269
- pattern = path.join(`${directory}/${normalizeDiscover({ segments: onlyLocalComponentsDirectories })}`, `**`, `${request.fileName}.${config_1.default.schemaFileExt}` // all files with 'ext' extension, without files beggining with _
270
+ const onlyLocalComponentsDirectories = config_1.default.componentsDirectories.filter(path => !path.includes('node_modules'));
271
+ pattern = path.join(`${directory}/${normalizeDiscover({ segments: onlyLocalComponentsDirectories })}`, '**', `${request.fileName}.${config_1.default.schemaFileExt}` // all files with 'ext' extension, without files beggining with _
270
272
  );
271
273
  listOfFiles = glob.sync(pattern, { follow: true });
272
274
  break;
273
275
  case SCOPE.external:
274
276
  // ### ONE - EXTERNAL - fileName ###
275
- const onlyNodeModulesPackagesComponentsDirectories = config_1.default.componentsDirectories.filter(path => path.includes("node_modules"));
276
- pattern = path.join(`${directory}/${normalizeDiscover({ segments: onlyNodeModulesPackagesComponentsDirectories })}`, `**`, `${request.fileName}.${config_1.default.schemaFileExt}` // all files with 'ext' extension, without files beggining with _
277
+ const onlyNodeModulesPackagesComponentsDirectories = config_1.default.componentsDirectories.filter(path => path.includes('node_modules'));
278
+ pattern = path.join(`${directory}/${normalizeDiscover({ segments: onlyNodeModulesPackagesComponentsDirectories })}`, '**', `${request.fileName}.${config_1.default.schemaFileExt}` // all files with 'ext' extension, without files beggining with _
277
279
  );
278
280
  listOfFiles = glob.sync(pattern, { follow: true });
279
281
  break;
280
282
  case SCOPE.all:
281
283
  // ### ONE - ALL - fileName ###
282
- pattern = path.join(`${directory}/${normalizeDiscover({ segments: config_1.default.componentsDirectories })}`, `**`, `${request.fileName}.${config_1.default.schemaFileExt}`);
284
+ pattern = path.join(`${directory}/${normalizeDiscover({ segments: config_1.default.componentsDirectories })}`, '**', `${request.fileName}.${config_1.default.schemaFileExt}`);
283
285
  listOfFiles = glob.sync(pattern, { follow: true });
284
286
  break;
285
287
  default:
@@ -287,26 +289,27 @@ exports.discoverOne = (request) => {
287
289
  }
288
290
  return listOfFiles;
289
291
  };
290
- exports.discover = (request) => {
292
+ exports.discoverOne = discoverOne;
293
+ const discover = (request) => {
291
294
  const rootDirectory = './';
292
295
  const directory = path.resolve(process.cwd(), rootDirectory);
293
296
  let pattern;
294
297
  let listOfFiles = [''];
295
298
  const filesPattern = (componentDirectories) => {
296
- return componentDirectories.length === 1 ? path.join(`${directory}/${componentDirectories[0]}`, `**`, `[^_]*.${config_1.default.schemaFileExt}` // all files with 'ext' extension, without files beggining with _
297
- ) : path.join(`${directory}/{${componentDirectories.join(",")}}`, `**`, `[^_]*.${config_1.default.schemaFileExt}` // all files with 'ext' extension, without files beggining with _
299
+ return componentDirectories.length === 1 ? path.join(`${directory}/${componentDirectories[0]}`, '**', `[^_]*.${config_1.default.schemaFileExt}` // all files with 'ext' extension, without files beggining with _
300
+ ) : path.join(`${directory}/{${componentDirectories.join(',')}}`, '**', `[^_]*.${config_1.default.schemaFileExt}` // all files with 'ext' extension, without files beggining with _
298
301
  );
299
302
  };
300
303
  switch (request.scope) {
301
304
  case SCOPE.local:
302
305
  // ### ALL - LOCAL - fileName ###
303
- const onlyLocalComponentsDirectories = config_1.default.componentsDirectories.filter(path => !path.includes("node_modules"));
306
+ const onlyLocalComponentsDirectories = config_1.default.componentsDirectories.filter(path => !path.includes('node_modules'));
304
307
  pattern = filesPattern(onlyLocalComponentsDirectories);
305
308
  listOfFiles = glob.sync(pattern, { follow: true });
306
309
  break;
307
310
  case SCOPE.external:
308
311
  // ### ALL - EXTERNAL - fileName ###
309
- const onlyNodeModulesPackagesComponentsDirectories = config_1.default.componentsDirectories.filter(path => path.includes("node_modules"));
312
+ const onlyNodeModulesPackagesComponentsDirectories = config_1.default.componentsDirectories.filter(path => path.includes('node_modules'));
310
313
  pattern = filesPattern(onlyNodeModulesPackagesComponentsDirectories);
311
314
  listOfFiles = glob.sync(pattern, { follow: true });
312
315
  break;
@@ -320,7 +323,8 @@ exports.discover = (request) => {
320
323
  }
321
324
  return listOfFiles;
322
325
  };
323
- exports.discoverManyStyles = (request) => {
326
+ exports.discover = discover;
327
+ const discoverManyStyles = (request) => {
324
328
  const rootDirectory = './';
325
329
  const directory = path.resolve(process.cwd(), rootDirectory);
326
330
  let pattern;
@@ -328,19 +332,19 @@ exports.discoverManyStyles = (request) => {
328
332
  switch (request.scope) {
329
333
  case SCOPE.local:
330
334
  // ### MANY - LOCAL - fileName ###
331
- const onlyLocalComponentsDirectories = config_1.default.componentsDirectories.filter(path => !path.includes("node_modules"));
332
- pattern = path.join(`${directory}/${normalizeDiscover({ segments: onlyLocalComponentsDirectories })}`, `**`, `${normalizeDiscover({ segments: request.fileNames })}.scss`);
335
+ const onlyLocalComponentsDirectories = config_1.default.componentsDirectories.filter(path => !path.includes('node_modules'));
336
+ pattern = path.join(`${directory}/${normalizeDiscover({ segments: onlyLocalComponentsDirectories })}`, '**', `${normalizeDiscover({ segments: request.fileNames })}.scss`);
333
337
  listOfFiles = glob.sync(pattern, { follow: true });
334
338
  break;
335
339
  case SCOPE.external:
336
340
  // ### MANY - EXTERNAL - fileName ###
337
- const onlyNodeModulesPackagesComponentsDirectories = config_1.default.componentsDirectories.filter(path => path.includes("node_modules"));
338
- pattern = path.join(`${directory}/${normalizeDiscover({ segments: onlyNodeModulesPackagesComponentsDirectories })}`, `**`, `${normalizeDiscover({ segments: request.fileNames })}.scss`);
341
+ const onlyNodeModulesPackagesComponentsDirectories = config_1.default.componentsDirectories.filter(path => path.includes('node_modules'));
342
+ pattern = path.join(`${directory}/${normalizeDiscover({ segments: onlyNodeModulesPackagesComponentsDirectories })}`, '**', `${normalizeDiscover({ segments: request.fileNames })}.scss`);
339
343
  listOfFiles = glob.sync(pattern, { follow: true });
340
344
  break;
341
345
  case SCOPE.all:
342
346
  // ### MANY - ALL - fileName ###
343
- pattern = path.join(`${directory}/${normalizeDiscover({ segments: config_1.default.componentsDirectories })}`, `**`, `${normalizeDiscover({ segments: request.fileNames })}.scss`);
347
+ pattern = path.join(`${directory}/${normalizeDiscover({ segments: config_1.default.componentsDirectories })}`, '**', `${normalizeDiscover({ segments: request.fileNames })}.scss`);
344
348
  listOfFiles = glob.sync(pattern, { follow: true });
345
349
  break;
346
350
  default:
@@ -348,7 +352,8 @@ exports.discoverManyStyles = (request) => {
348
352
  }
349
353
  return listOfFiles;
350
354
  };
351
- exports.discoverRoles = (request) => {
355
+ exports.discoverManyStyles = discoverManyStyles;
356
+ const discoverRoles = (request) => {
352
357
  const rootDirectory = './';
353
358
  const directory = path.resolve(process.cwd(), rootDirectory);
354
359
  let pattern;
@@ -356,21 +361,21 @@ exports.discoverRoles = (request) => {
356
361
  switch (request.scope) {
357
362
  case SCOPE.local:
358
363
  // ### ALL - LOCAL - fileName ###
359
- const onlyLocalComponentsDirectories = config_1.default.componentsDirectories.filter(path => !path.includes("node_modules"));
360
- pattern = path.join(`${directory}/${normalizeDiscover({ segments: onlyLocalComponentsDirectories })}`, `**`, `[^_]*.${config_1.default.rolesExt}` // all files with 'ext' extension, without files beggining with _
364
+ const onlyLocalComponentsDirectories = config_1.default.componentsDirectories.filter(path => !path.includes('node_modules'));
365
+ pattern = path.join(`${directory}/${normalizeDiscover({ segments: onlyLocalComponentsDirectories })}`, '**', `[^_]*.${config_1.default.rolesExt}` // all files with 'ext' extension, without files beggining with _
361
366
  );
362
367
  listOfFiles = glob.sync(pattern, { follow: true });
363
368
  break;
364
369
  case SCOPE.external:
365
370
  // ### ALL - EXTERNAL - fileName ###
366
- const onlyNodeModulesPackagesComponentsDirectories = config_1.default.componentsDirectories.filter(path => path.includes("node_modules"));
367
- pattern = path.join(`${directory}/${normalizeDiscover({ segments: onlyNodeModulesPackagesComponentsDirectories })}`, `**`, `[^_]*.${config_1.default.rolesExt}` // all files with 'ext' extension, without files beggining with _
371
+ const onlyNodeModulesPackagesComponentsDirectories = config_1.default.componentsDirectories.filter(path => path.includes('node_modules'));
372
+ pattern = path.join(`${directory}/${normalizeDiscover({ segments: onlyNodeModulesPackagesComponentsDirectories })}`, '**', `[^_]*.${config_1.default.rolesExt}` // all files with 'ext' extension, without files beggining with _
368
373
  );
369
374
  listOfFiles = glob.sync(pattern, { follow: true });
370
375
  break;
371
376
  case SCOPE.all:
372
377
  // ### ALL - LOCAL - fileName ###
373
- pattern = path.join(`${directory}/${normalizeDiscover({ segments: config_1.default.componentsDirectories })}`, `**`, `[^_]*.${config_1.default.rolesExt}` // all files with 'ext' extension, without files beggining with _
378
+ pattern = path.join(`${directory}/${normalizeDiscover({ segments: config_1.default.componentsDirectories })}`, '**', `[^_]*.${config_1.default.rolesExt}` // all files with 'ext' extension, without files beggining with _
374
379
  );
375
380
  listOfFiles = glob.sync(pattern, { follow: true });
376
381
  break;
@@ -379,7 +384,8 @@ exports.discoverRoles = (request) => {
379
384
  }
380
385
  return listOfFiles;
381
386
  };
382
- exports.discoverManyRoles = (request) => {
387
+ exports.discoverRoles = discoverRoles;
388
+ const discoverManyRoles = (request) => {
383
389
  const rootDirectory = './';
384
390
  const directory = path.resolve(process.cwd(), rootDirectory);
385
391
  let pattern;
@@ -387,19 +393,19 @@ exports.discoverManyRoles = (request) => {
387
393
  switch (request.scope) {
388
394
  case SCOPE.local:
389
395
  // ### ALL - LOCAL - fileName ###
390
- const onlyLocalComponentsDirectories = config_1.default.componentsDirectories.filter(path => !path.includes("node_modules"));
391
- pattern = path.join(`${directory}/${normalizeDiscover({ segments: onlyLocalComponentsDirectories })}`, `**`, `${normalizeDiscover({ segments: request.fileNames })}.${config_1.default.rolesExt}`);
396
+ const onlyLocalComponentsDirectories = config_1.default.componentsDirectories.filter(path => !path.includes('node_modules'));
397
+ pattern = path.join(`${directory}/${normalizeDiscover({ segments: onlyLocalComponentsDirectories })}`, '**', `${normalizeDiscover({ segments: request.fileNames })}.${config_1.default.rolesExt}`);
392
398
  listOfFiles = glob.sync(pattern, { follow: true });
393
399
  break;
394
400
  case SCOPE.external:
395
401
  // ### ALL - EXTERNAL - fileName ###
396
- const onlyNodeModulesPackagesComponentsDirectories = config_1.default.componentsDirectories.filter(path => path.includes("node_modules"));
397
- pattern = path.join(`${directory}/${normalizeDiscover({ segments: onlyNodeModulesPackagesComponentsDirectories })}`, `**`, `${normalizeDiscover({ segments: request.fileNames })}.${config_1.default.rolesExt}`);
402
+ const onlyNodeModulesPackagesComponentsDirectories = config_1.default.componentsDirectories.filter(path => path.includes('node_modules'));
403
+ pattern = path.join(`${directory}/${normalizeDiscover({ segments: onlyNodeModulesPackagesComponentsDirectories })}`, '**', `${normalizeDiscover({ segments: request.fileNames })}.${config_1.default.rolesExt}`);
398
404
  listOfFiles = glob.sync(pattern, { follow: true });
399
405
  break;
400
406
  case SCOPE.all:
401
407
  // ### ALL - LOCAL - fileName ###
402
- pattern = path.join(`${directory}/${normalizeDiscover({ segments: config_1.default.componentsDirectories })}`, `**`, `${normalizeDiscover({ segments: request.fileNames })}.${config_1.default.rolesExt}`);
408
+ pattern = path.join(`${directory}/${normalizeDiscover({ segments: config_1.default.componentsDirectories })}`, '**', `${normalizeDiscover({ segments: request.fileNames })}.${config_1.default.rolesExt}`);
403
409
  listOfFiles = glob.sync(pattern, { follow: true });
404
410
  break;
405
411
  default:
@@ -407,9 +413,12 @@ exports.discoverManyRoles = (request) => {
407
413
  }
408
414
  return listOfFiles;
409
415
  };
410
- exports.getFilesContent = (data) => {
411
- return data.files.map((file) => require(file));
416
+ exports.discoverManyRoles = discoverManyRoles;
417
+ const getFilesContent = (data) => {
418
+ return data.files.map(file => require(file));
412
419
  };
413
- exports.getFileContent = (data) => {
420
+ exports.getFilesContent = getFilesContent;
421
+ const getFileContent = (data) => {
414
422
  return require(data.file);
415
423
  };
424
+ exports.getFileContent = getFileContent;
@@ -5,37 +5,42 @@ const fs = require("fs");
5
5
  const ncp_1 = require("ncp");
6
6
  const path = require("path");
7
7
  const logger_1 = require("./logger");
8
- exports.getCurrentDirectoryBase = () => path.basename(process.cwd());
9
- exports.isDirectoryExists = (path) => fs.existsSync(path);
10
- exports.createDir = async (dirPath) => {
8
+ const getCurrentDirectoryBase = () => path.basename(process.cwd());
9
+ exports.getCurrentDirectoryBase = getCurrentDirectoryBase;
10
+ const isDirectoryExists = (path) => fs.existsSync(path);
11
+ exports.isDirectoryExists = isDirectoryExists;
12
+ const createDir = async (dirPath) => {
11
13
  await fs.promises.mkdir(`${process.cwd()}/${dirPath}`, {
12
- recursive: true
14
+ recursive: true,
13
15
  });
14
16
  };
15
- exports.createJsonFile = async (content, pathWithFilename) => {
16
- await fs.promises.writeFile(pathWithFilename, content, { flag: `w` });
17
+ exports.createDir = createDir;
18
+ const createJsonFile = async (content, pathWithFilename) => {
19
+ await fs.promises.writeFile(pathWithFilename, content, { flag: 'w' });
17
20
  };
18
- exports.copyFolder = async (src, dest) => {
21
+ exports.createJsonFile = createJsonFile;
22
+ const copyFolder = async (src, dest) => {
19
23
  return new Promise((resolve, reject) => {
20
- ncp_1.ncp(src, dest, function (err) {
24
+ (0, ncp_1.ncp)(src, dest, function (err) {
21
25
  if (err) {
22
26
  reject({
23
27
  failed: true,
24
- message: `${src} copied unsuccessfully.`
28
+ message: `${src} copied unsuccessfully.`,
25
29
  });
26
30
  }
27
31
  resolve({
28
32
  failed: false,
29
- message: `${src} copied successfully.`
33
+ message: `${src} copied successfully.`,
30
34
  });
31
35
  });
32
36
  });
33
37
  };
34
- exports.copyFile = async (src, dest) => {
35
- const directory = dest.split("/").slice(0, dest.split("/").length - 1);
36
- const fileName = src.split("/")[src.split("/").length - 1];
37
- if (!exports.isDirectoryExists(directory.join("/"))) {
38
- await exports.createDir(directory.join("/"));
38
+ exports.copyFolder = copyFolder;
39
+ const copyFile = async (src, dest) => {
40
+ const directory = dest.split('/').slice(0, dest.split('/').length - 1);
41
+ const fileName = src.split('/')[src.split('/').length - 1];
42
+ if (!(0, exports.isDirectoryExists)(directory.join('/'))) {
43
+ await (0, exports.createDir)(directory.join('/'));
39
44
  }
40
45
  fs.copyFile(src, dest, err => {
41
46
  if (err) {
@@ -46,3 +51,4 @@ exports.copyFile = async (src, dest) => {
46
51
  console.log(`${fileName} was copied to ${dest}`);
47
52
  });
48
53
  };
54
+ exports.copyFile = copyFile;
@@ -1,29 +1,29 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const chalk_1 = require("chalk");
3
+ const chalk = require("chalk");
4
4
  const figlet = require("figlet");
5
5
  class Logger {
6
6
  constructor(name) {
7
7
  this.name = name;
8
8
  }
9
9
  static bigLog(content) {
10
- console.log(chalk_1.default.yellow(figlet.textSync(content, { horizontalLayout: "full" })));
10
+ console.log(chalk.yellow(figlet.textSync(content, { horizontalLayout: 'full' })));
11
11
  }
12
12
  static log(content) {
13
13
  console.log(content);
14
14
  }
15
15
  static success(content) {
16
- console.log(chalk_1.default.green(`✓ ${content}`));
16
+ console.log(chalk.green(`✓ ${content}`));
17
17
  }
18
18
  static warning(content) {
19
- console.log(chalk_1.default.yellow(`! ${content}`));
19
+ console.log(chalk.yellow(`! ${content}`));
20
20
  }
21
21
  static error(content, { verbose } = { verbose: false }) {
22
22
  if (verbose) {
23
23
  console.log(content);
24
24
  }
25
25
  else {
26
- console.log(chalk_1.default.red(`✘ ${content}`));
26
+ console.log(chalk.red(`✘ ${content}`));
27
27
  }
28
28
  }
29
29
  }
@@ -1,4 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.generateDatestamp = void 0;
4
- exports.generateDatestamp = (datestamp) => `${datestamp.getFullYear()}-${datestamp.getMonth()}-${datestamp.getDay()}_${datestamp.getTime()}`;
4
+ const generateDatestamp = (datestamp) => `${datestamp.getFullYear()}-${datestamp.getMonth()}-${datestamp.getDay()}_${datestamp.getTime()}`;
5
+ exports.generateDatestamp = generateDatestamp;
@@ -1 +1 @@
1
- {"version":"2.9.0","commands":{"backup":{"id":"backup","description":"Command for backing up anything related to Storyblok","pluginName":"sb-mig","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false},"allComponents":{"name":"allComponents","type":"boolean","char":"a","description":"Backup all components.","allowNo":false},"oneComponent":{"name":"oneComponent","type":"option","char":"o","description":"Backup one component by name."},"allComponentsGroups":{"name":"allComponentsGroups","type":"boolean","char":"g","description":"Backup all components groups.","allowNo":false},"oneComponentsGroup":{"name":"oneComponentsGroup","type":"option","char":"f","description":"Backup one components group by name."},"oneComponentPresets":{"name":"oneComponentPresets","type":"option","char":"p","description":"Backup all presets for one component"},"allPresets":{"name":"allPresets","type":"boolean","char":"l","description":"Backup all presets.","allowNo":false},"onePreset":{"name":"onePreset","type":"option","char":"i","description":"Backup one preset by id."},"allDatasources":{"name":"allDatasources","type":"boolean","char":"d","description":"Backup all datasources.","allowNo":false},"oneDatasource":{"name":"oneDatasource","type":"option","char":"x","description":"Backup one datasource by name."},"datasourceEntries":{"name":"datasourceEntries","type":"option","char":"e","description":"Backup one datasource entries by datasource name."},"allRoles":{"name":"allRoles","type":"boolean","char":"R","description":"Backup all roles and permissions.","allowNo":false},"oneRole":{"name":"oneRole","type":"option","char":"r","description":"Backup one role by name."}},"args":[]},"debug":{"id":"debug","description":"Output extra debugging","pluginName":"sb-mig","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false}},"args":[]},"sync":{"id":"sync","description":"Synchronize components, datasources or roles with Storyblok space.","pluginName":"sb-mig","pluginType":"core","aliases":[],"examples":["$ sb-mig sync components --all --ext","$ sb-mig sync components @storyblok-components/text-block --ext --packageName","$ sb-mig sync components @storyblok-components/text-block @storyblok-components/button --ext --packageName","$ sb-mig sync components text-block button --ext","$ sb-mig sync components text-block button","$ sb-mig sync roles"],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false},"all":{"name":"all","type":"boolean","char":"a","description":"Synchronize all components.","allowNo":false},"ext":{"name":"ext","type":"boolean","char":"e","description":"Synchronize with file extension. Default extension: '.sb.js'","allowNo":false},"packageName":{"name":"packageName","type":"boolean","char":"n","description":"Synchronize based on installed package name.","allowNo":false},"presets":{"name":"presets","type":"boolean","char":"p","description":"Synchronize components with presets.","allowNo":false},"lock":{"name":"lock","type":"boolean","char":"l","description":"Synchronize based on storyblok.components.lock.js file","allowNo":false}},"args":[{"name":"type","description":"What to synchronize","required":true,"options":["components","datasources","roles"]},{"name":"list","description":"Space separated list of component names. Example: card product-card row layout"}]}}}
1
+ {"version":"2.9.13","commands":{"backup":{"id":"backup","description":"Command for backing up anything related to Storyblok","pluginName":"sb-mig","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false},"allComponents":{"name":"allComponents","type":"boolean","char":"a","description":"Backup all components.","allowNo":false},"oneComponent":{"name":"oneComponent","type":"option","char":"o","description":"Backup one component by name."},"allComponentsGroups":{"name":"allComponentsGroups","type":"boolean","char":"g","description":"Backup all components groups.","allowNo":false},"oneComponentsGroup":{"name":"oneComponentsGroup","type":"option","char":"f","description":"Backup one components group by name."},"oneComponentPresets":{"name":"oneComponentPresets","type":"option","char":"p","description":"Backup all presets for one component"},"allPresets":{"name":"allPresets","type":"boolean","char":"l","description":"Backup all presets.","allowNo":false},"onePreset":{"name":"onePreset","type":"option","char":"i","description":"Backup one preset by id."},"allDatasources":{"name":"allDatasources","type":"boolean","char":"d","description":"Backup all datasources.","allowNo":false},"oneDatasource":{"name":"oneDatasource","type":"option","char":"x","description":"Backup one datasource by name."},"datasourceEntries":{"name":"datasourceEntries","type":"option","char":"e","description":"Backup one datasource entries by datasource name."},"allRoles":{"name":"allRoles","type":"boolean","char":"R","description":"Backup all roles and permissions.","allowNo":false},"oneRole":{"name":"oneRole","type":"option","char":"r","description":"Backup one role by name."}},"args":[]},"debug":{"id":"debug","description":"Output extra debugging","pluginName":"sb-mig","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false}},"args":[]},"sync":{"id":"sync","description":"Synchronize components, datasources or roles with Storyblok space.","pluginName":"sb-mig","pluginType":"core","aliases":[],"examples":["$ sb-mig sync components --all --ext","$ sb-mig sync components @storyblok-components/text-block --ext --packageName","$ sb-mig sync components @storyblok-components/text-block @storyblok-components/button --ext --packageName","$ sb-mig sync components text-block button --ext","$ sb-mig sync components text-block button","$ sb-mig sync roles"],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false},"all":{"name":"all","type":"boolean","char":"a","description":"Synchronize all components.","allowNo":false},"ext":{"name":"ext","type":"boolean","char":"e","description":"Synchronize with file extension. Default extension: '.sb.js'","allowNo":false},"packageName":{"name":"packageName","type":"boolean","char":"n","description":"Synchronize based on installed package name.","allowNo":false},"presets":{"name":"presets","type":"boolean","char":"p","description":"Synchronize components with presets.","allowNo":false},"lock":{"name":"lock","type":"boolean","char":"l","description":"Synchronize based on storyblok.components.lock.js file","allowNo":false}},"args":[{"name":"type","description":"What to synchronize","required":true,"options":["components","datasources","roles"]},{"name":"list","description":"Space separated list of component names. Example: card product-card row layout"}]}}}