sb-mig 2.9.13 → 3.0.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. package/README.md +107 -495
  2. package/{lib → dist}/api/componentPresets.d.ts +1 -1
  3. package/dist/api/componentPresets.js +18 -0
  4. package/{lib → dist}/api/components.d.ts +2 -2
  5. package/dist/api/components.js +63 -0
  6. package/dist/api/config.d.ts +2 -0
  7. package/dist/api/config.js +4 -0
  8. package/{lib → dist}/api/datasources.d.ts +1 -1
  9. package/dist/api/datasources.js +181 -0
  10. package/dist/api/migrate.d.ts +17 -0
  11. package/dist/api/migrate.js +139 -0
  12. package/{lib → dist}/api/mutateComponents.d.ts +0 -0
  13. package/dist/api/mutateComponents.js +45 -0
  14. package/{lib → dist}/api/presets.d.ts +1 -1
  15. package/dist/api/presets.js +52 -0
  16. package/{lib → dist}/api/resolvePresets.d.ts +0 -0
  17. package/{lib → dist}/api/resolvePresets.js +15 -14
  18. package/{lib → dist}/api/roles.d.ts +2 -2
  19. package/dist/api/roles.js +125 -0
  20. package/dist/cli-descriptions.d.ts +4 -0
  21. package/dist/cli-descriptions.js +69 -0
  22. package/dist/commands/backup.d.ts +2 -0
  23. package/dist/commands/backup.js +201 -0
  24. package/dist/commands/debug.d.ts +1 -0
  25. package/dist/commands/debug.js +5 -0
  26. package/dist/commands/sync.d.ts +2 -0
  27. package/dist/commands/sync.js +58 -0
  28. package/dist/config/config.d.ts +14 -0
  29. package/dist/config/config.js +49 -0
  30. package/dist/index.d.ts +2 -0
  31. package/dist/index.js +52 -0
  32. package/{lib/utils/discover2.d.ts → dist/utils/discover.d.ts} +1 -7
  33. package/{lib/utils/discover2.js → dist/utils/discover.js} +200 -143
  34. package/{lib → dist}/utils/files.d.ts +7 -1
  35. package/dist/utils/files.js +54 -0
  36. package/dist/utils/interfaces.d.ts +4 -0
  37. package/dist/utils/interfaces.js +1 -0
  38. package/{lib → dist}/utils/logger.d.ts +0 -3
  39. package/{lib → dist}/utils/logger.js +2 -12
  40. package/dist/utils/main.d.ts +13 -0
  41. package/dist/utils/main.js +28 -0
  42. package/{lib → dist}/utils/others.d.ts +0 -0
  43. package/dist/utils/others.js +1 -0
  44. package/package.json +63 -63
  45. package/bin/run +0 -5
  46. package/bin/run.cmd +0 -3
  47. package/lib/api/apiConfig.d.ts +0 -2
  48. package/lib/api/apiConfig.js +0 -9
  49. package/lib/api/componentPresets.js +0 -22
  50. package/lib/api/components.js +0 -71
  51. package/lib/api/datasources.js +0 -193
  52. package/lib/api/migrate.d.ts +0 -19
  53. package/lib/api/migrate.js +0 -220
  54. package/lib/api/mutateComponents.js +0 -50
  55. package/lib/api/presets.js +0 -59
  56. package/lib/api/roles.js +0 -133
  57. package/lib/api/spaces.d.ts +0 -2
  58. package/lib/api/spaces.js +0 -29
  59. package/lib/commands/backup.d.ts +0 -22
  60. package/lib/commands/backup.js +0 -217
  61. package/lib/commands/debug.d.ts +0 -9
  62. package/lib/commands/debug.js +0 -27
  63. package/lib/commands/sync.d.ts +0 -26
  64. package/lib/commands/sync.js +0 -93
  65. package/lib/config/StoryblokComponentsConfig.d.ts +0 -68
  66. package/lib/config/StoryblokComponentsConfig.js +0 -220
  67. package/lib/config/config.d.ts +0 -37
  68. package/lib/config/config.js +0 -36
  69. package/lib/core.d.ts +0 -16
  70. package/lib/core.js +0 -75
  71. package/lib/index.d.ts +0 -1
  72. package/lib/index.js +0 -5
  73. package/lib/types/storyblokTypes.d.ts +0 -171
  74. package/lib/types/storyblokTypes.js +0 -3
  75. package/lib/utils/discover.d.ts +0 -4
  76. package/lib/utils/discover.js +0 -96
  77. package/lib/utils/files.js +0 -54
  78. package/lib/utils/others.js +0 -5
  79. package/oclif.manifest.json +0 -1
@@ -1,24 +1,22 @@
1
- "use strict";
2
1
  // component resolution file borrowed from great storyblok-migrate
3
2
  // https://github.com/maoberlehner/storyblok-migrate
4
3
  // edit: changed a lot in here, but inspiration still is valid :)
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getFileContent = exports.getFilesContent = exports.discoverManyRoles = exports.discoverRoles = exports.discoverManyStyles = exports.discover = exports.discoverOne = exports.discoverDatasources = exports.discoverManyDatasources = exports.discoverMany = exports.discoverOneByPackageName = exports.discoverManyByPackageName = exports.compare = exports.LOOKUP_TYPE = exports.SCOPE = void 0;
7
- const glob = require("glob");
8
- const path = require("path");
9
- const config_1 = require("../config/config");
10
- var SCOPE;
4
+ import glob from "glob";
5
+ import path from "path";
6
+ import storyblokConfig from "../config/config.js";
7
+ import { getFileContentWithRequire } from "./main.js";
8
+ export var SCOPE;
11
9
  (function (SCOPE) {
12
10
  SCOPE["local"] = "local";
13
11
  SCOPE["external"] = "external";
14
12
  SCOPE["lock"] = "lock";
15
13
  SCOPE["all"] = "all";
16
- })(SCOPE = exports.SCOPE || (exports.SCOPE = {}));
17
- var LOOKUP_TYPE;
14
+ })(SCOPE || (SCOPE = {}));
15
+ export var LOOKUP_TYPE;
18
16
  (function (LOOKUP_TYPE) {
19
17
  LOOKUP_TYPE["packagName"] = "packageName";
20
18
  LOOKUP_TYPE["fileName"] = "fileName";
21
- })(LOOKUP_TYPE = exports.LOOKUP_TYPE || (exports.LOOKUP_TYPE = {}));
19
+ })(LOOKUP_TYPE || (LOOKUP_TYPE = {}));
22
20
  // problem with glob sync is, that when there is only one folder to search for
23
21
  // we have to omit { } and when a lot, we have to use {folder1, folder2}
24
22
  // so this function will normalize it based on amount of folders provided
@@ -26,27 +24,28 @@ const normalizeDiscover = ({ segments }) => {
26
24
  if (segments.length === 1) {
27
25
  return segments[0];
28
26
  }
29
- return `{${segments.join(',')}}`;
27
+ return `{${segments.join(",")}}`;
30
28
  };
31
- const compare = (request) => {
32
- const splittedLocal = request.local.map(path => {
29
+ // export const compare = (request: CompareRequest): CompareResult => {
30
+ export const compare = (request) => {
31
+ // TODO: figure out types
32
+ const splittedLocal = request.local.map((path) => {
33
33
  return {
34
- name: path.split('/')[path.split('/').length - 1],
34
+ name: path.split("/")[path.split("/").length - 1],
35
35
  path,
36
36
  };
37
37
  });
38
- const splittedExternal = request.external.map(path => {
38
+ const splittedExternal = request.external.map((path) => {
39
39
  return {
40
- name: path.split('/')[path.split('/').length - 1],
40
+ name: path.split("/")[path.split("/").length - 1],
41
41
  path,
42
42
  };
43
43
  });
44
44
  // we only want to modify external array, because we want sometimes remove stuff which are already on local (overwrite node_modules ones)
45
45
  const result = {
46
46
  local: splittedLocal,
47
- external: splittedExternal
48
- .filter(externalComponent => {
49
- if (splittedLocal.find(localComponent => externalComponent.name === localComponent.name)) {
47
+ external: splittedExternal.filter((externalComponent) => {
48
+ if (splittedLocal.find((localComponent) => externalComponent.name === localComponent.name)) {
50
49
  return false;
51
50
  }
52
51
  return true;
@@ -54,54 +53,68 @@ const compare = (request) => {
54
53
  };
55
54
  return result;
56
55
  };
57
- exports.compare = compare;
58
- const discoverManyByPackageName = (request) => {
59
- const rootDirectory = './';
56
+ export const discoverManyByPackageName = (request) => {
57
+ const rootDirectory = "./";
60
58
  const directory = path.resolve(process.cwd(), rootDirectory);
61
59
  let pattern;
62
- let listOfFiles = [''];
60
+ let listOfFiles = [""];
63
61
  let listOfPackagesJsonFiles;
64
62
  switch (request.scope) {
65
63
  case SCOPE.local:
66
64
  // ### MANY by PACKAGE - LOCAL - packageName
67
- const onlyLocalComponentsDirectories = config_1.default.componentsDirectories.filter(path => !path.includes('node_modules'));
68
- pattern = path.join(`${directory}/${normalizeDiscover({ segments: onlyLocalComponentsDirectories })}`, '**', 'package.json');
65
+ const onlyLocalComponentsDirectories = storyblokConfig.componentsDirectories.filter((path) => !path.includes("node_modules"));
66
+ pattern = path.join(`${directory}/${normalizeDiscover({
67
+ segments: onlyLocalComponentsDirectories,
68
+ })}`, "**", "package.json");
69
69
  listOfPackagesJsonFiles = glob.sync(pattern, { follow: true });
70
70
  listOfFiles = listOfPackagesJsonFiles
71
- .filter(file => request.packageNames.includes((0, exports.getFileContent)({ file }).name)) // filter only package.json from provided request.packageNames
72
- .map(file => {
71
+ .filter(async (file) => request.packageNames.includes(await getFileContentWithRequire({ file }).name)) // filter only package.json from provided request.packageNames
72
+ .map((file) => {
73
73
  // get path to folder in which current package.json is
74
- const fileFolderPath = file.split('/').slice(0, -1).join('/');
75
- const allStoryblokSchemaFilesWithinFolderPattern = path.join(`${fileFolderPath}`, '**', `[^_]*.${config_1.default.schemaFileExt}`);
74
+ const fileFolderPath = file
75
+ .split("/")
76
+ .slice(0, -1)
77
+ .join("/");
78
+ const allStoryblokSchemaFilesWithinFolderPattern = path.join(`${fileFolderPath}`, "**", `[^_]*.${storyblokConfig.schemaFileExt}`);
76
79
  return glob.sync(allStoryblokSchemaFilesWithinFolderPattern, { follow: true });
77
80
  })
78
81
  .flat();
79
82
  break;
80
83
  case SCOPE.external:
81
84
  // ### MANY by PACKAGE - EXTERNAL - packageName
82
- const onlyNodeModulesPackagesComponentsDirectories = config_1.default.componentsDirectories.filter(path => path.includes('node_modules'));
83
- pattern = path.join(`${directory}/${normalizeDiscover({ segments: onlyNodeModulesPackagesComponentsDirectories })}`, '**', 'package.json');
85
+ const onlyNodeModulesPackagesComponentsDirectories = storyblokConfig.componentsDirectories.filter((path) => path.includes("node_modules"));
86
+ pattern = path.join(`${directory}/${normalizeDiscover({
87
+ segments: onlyNodeModulesPackagesComponentsDirectories,
88
+ })}`, "**", "package.json");
84
89
  listOfPackagesJsonFiles = glob.sync(pattern, { follow: true });
85
90
  listOfFiles = listOfPackagesJsonFiles
86
- .filter(file => request.packageNames.includes((0, exports.getFileContent)({ file }).name)) // filter only package.json from provided request.packageNames
87
- .map(file => {
91
+ .filter((file) => request.packageNames.includes(getFileContentWithRequire({ file }).name)) // filter only package.json from provided request.packageNames
92
+ .map((file) => {
88
93
  // get path to folder in which current package.json is
89
- const fileFolderPath = file.split('/').slice(0, -1).join('/');
90
- const allStoryblokSchemaFilesWithinFolderPattern = path.join(`${fileFolderPath}`, '**', `[^_]*.${config_1.default.schemaFileExt}`);
94
+ const fileFolderPath = file
95
+ .split("/")
96
+ .slice(0, -1)
97
+ .join("/");
98
+ const allStoryblokSchemaFilesWithinFolderPattern = path.join(`${fileFolderPath}`, "**", `[^_]*.${storyblokConfig.schemaFileExt}`);
91
99
  return glob.sync(allStoryblokSchemaFilesWithinFolderPattern, { follow: true });
92
100
  })
93
101
  .flat();
94
102
  break;
95
103
  case SCOPE.all:
96
104
  // ### MANY by PACKAGE - ALL - packageName
97
- pattern = path.join(`${directory}/${normalizeDiscover({ segments: config_1.default.componentsDirectories })}`, '**', 'package.json');
105
+ pattern = path.join(`${directory}/${normalizeDiscover({
106
+ segments: storyblokConfig.componentsDirectories,
107
+ })}`, "**", "package.json");
98
108
  listOfPackagesJsonFiles = glob.sync(pattern, { follow: true });
99
109
  listOfFiles = listOfPackagesJsonFiles
100
- .filter(file => request.packageNames.includes((0, exports.getFileContent)({ file }).name)) // filter only package.json from provided request.packageNames
101
- .map(file => {
110
+ .filter((file) => request.packageNames.includes(getFileContentWithRequire({ file }).name)) // filter only package.json from provided request.packageNames
111
+ .map((file) => {
102
112
  // get path to folder in which current package.json is
103
- const fileFolderPath = file.split('/').slice(0, -1).join('/');
104
- const allStoryblokSchemaFilesWithinFolderPattern = path.join(`${fileFolderPath}`, '**', `[^_]*.${config_1.default.schemaFileExt}`);
113
+ const fileFolderPath = file
114
+ .split("/")
115
+ .slice(0, -1)
116
+ .join("/");
117
+ const allStoryblokSchemaFilesWithinFolderPattern = path.join(`${fileFolderPath}`, "**", `[^_]*.${storyblokConfig.schemaFileExt}`);
105
118
  return glob.sync(allStoryblokSchemaFilesWithinFolderPattern, { follow: true });
106
119
  })
107
120
  .flat();
@@ -111,54 +124,71 @@ const discoverManyByPackageName = (request) => {
111
124
  }
112
125
  return listOfFiles;
113
126
  };
114
- exports.discoverManyByPackageName = discoverManyByPackageName;
115
- const discoverOneByPackageName = (request) => {
116
- const rootDirectory = './';
127
+ export const discoverOneByPackageName = (request) => {
128
+ const rootDirectory = "./";
117
129
  const directory = path.resolve(process.cwd(), rootDirectory);
118
130
  let pattern;
119
- let listOfFiles = [''];
131
+ let listOfFiles = [""];
120
132
  let listOfPackagesJsonFiles;
121
133
  switch (request.scope) {
122
134
  case SCOPE.local:
123
135
  // ### ONE by PACKAGE - LOCAL - packageName
124
- const onlyLocalComponentsDirectories = config_1.default.componentsDirectories.filter(path => !path.includes('node_modules'));
125
- pattern = path.join(`${directory}/${normalizeDiscover({ segments: onlyLocalComponentsDirectories })}`, '**', 'package.json');
136
+ const onlyLocalComponentsDirectories = storyblokConfig.componentsDirectories.filter((path) => !path.includes("node_modules"));
137
+ pattern = path.join(`${directory}/${normalizeDiscover({
138
+ segments: onlyLocalComponentsDirectories,
139
+ })}`, "**", "package.json");
126
140
  listOfPackagesJsonFiles = glob.sync(pattern, { follow: true });
127
141
  listOfFiles = listOfPackagesJsonFiles
128
- .filter(file => (0, exports.getFileContent)({ file }).name === request.packageName) // filter only package.json from provided request.packageName
129
- .map(file => {
142
+ .filter((file) => getFileContentWithRequire({ file }).name ===
143
+ request.packageName) // filter only package.json from provided request.packageName
144
+ .map((file) => {
130
145
  // get path to folder in which current package.json is
131
- const fileFolderPath = file.split('/').slice(0, -1).join('/');
132
- const allStoryblokSchemaFilesWithinFolderPattern = path.join(`${fileFolderPath}`, '**', `[^_]*.${config_1.default.schemaFileExt}`);
146
+ const fileFolderPath = file
147
+ .split("/")
148
+ .slice(0, -1)
149
+ .join("/");
150
+ const allStoryblokSchemaFilesWithinFolderPattern = path.join(`${fileFolderPath}`, "**", `[^_]*.${storyblokConfig.schemaFileExt}`);
133
151
  return glob.sync(allStoryblokSchemaFilesWithinFolderPattern, { follow: true });
134
152
  })
135
153
  .flat();
136
154
  break;
137
155
  case SCOPE.external:
138
156
  // ### ONE by PACKAGE - EXTERNAL - packageName
139
- const onlyNodeModulesPackagesComponentsDirectories = config_1.default.componentsDirectories.filter(path => path.includes('node_modules'));
140
- pattern = path.join(`${directory}/${normalizeDiscover({ segments: onlyNodeModulesPackagesComponentsDirectories })}`, '**', 'package.json');
157
+ const onlyNodeModulesPackagesComponentsDirectories = storyblokConfig.componentsDirectories.filter((path) => path.includes("node_modules"));
158
+ pattern = path.join(`${directory}/${normalizeDiscover({
159
+ segments: onlyNodeModulesPackagesComponentsDirectories,
160
+ })}`, "**", "package.json");
141
161
  listOfPackagesJsonFiles = glob.sync(pattern, { follow: true });
142
162
  listOfFiles = listOfPackagesJsonFiles
143
- .filter(file => (0, exports.getFileContent)({ file }).name === request.packageName) // filter only package.json from provided request.packageName
144
- .map(file => {
163
+ .filter((file) => getFileContentWithRequire({ file }).name ===
164
+ request.packageName) // filter only package.json from provided request.packageName
165
+ .map((file) => {
145
166
  // get path to folder in which current package.json is
146
- const fileFolderPath = file.split('/').slice(0, -1).join('/');
147
- const allStoryblokSchemaFilesWithinFolderPattern = path.join(`${fileFolderPath}`, '**', `[^_]*.${config_1.default.schemaFileExt}`);
167
+ const fileFolderPath = file
168
+ .split("/")
169
+ .slice(0, -1)
170
+ .join("/");
171
+ const allStoryblokSchemaFilesWithinFolderPattern = path.join(`${fileFolderPath}`, "**", `[^_]*.${storyblokConfig.schemaFileExt}`);
148
172
  return glob.sync(allStoryblokSchemaFilesWithinFolderPattern, { follow: true });
149
173
  })
150
174
  .flat();
151
175
  break;
152
176
  case SCOPE.all:
153
177
  // ### ONE by PACKAGE - ALL - packageName
154
- pattern = path.join(`${directory}/${normalizeDiscover({ segments: config_1.default.componentsDirectories })}`, '**', 'package.json');
178
+ pattern = path.join(`${directory}/${normalizeDiscover({
179
+ segments: storyblokConfig.componentsDirectories,
180
+ })}`, "**", "package.json");
155
181
  listOfPackagesJsonFiles = glob.sync(pattern, { follow: true });
156
182
  listOfFiles = listOfPackagesJsonFiles
157
- .filter(file => (0, exports.getFileContent)({ file }).name === request.packageName) // filter only package.json from provided request.packageName
158
- .map(file => {
183
+ .filter((file) => getFileContentWithRequire({ file }).name ===
184
+ request.packageName) // filter only package.json from provided request.packageName
185
+ .map((file) => {
159
186
  // get path to folder in which current package.json is
160
- const fileFolderPath = file.split('/').slice(0, -1).join('/');
161
- const allStoryblokSchemaFilesWithinFolderPattern = path.join(`${fileFolderPath}`, '**', `[^_]*.${config_1.default.schemaFileExt}`);
187
+ const fileFolderPath = file
188
+ .split("/")
189
+ .slice(0, -1)
190
+ .join("/");
191
+ const allStoryblokSchemaFilesWithinFolderPattern = path.join(`${fileFolderPath}`, "**", `[^_]*.${storyblokConfig.schemaFileExt}`);
162
192
  return glob.sync(allStoryblokSchemaFilesWithinFolderPattern, { follow: true });
163
193
  })
164
194
  .flat();
@@ -168,28 +198,33 @@ const discoverOneByPackageName = (request) => {
168
198
  }
169
199
  return listOfFiles;
170
200
  };
171
- exports.discoverOneByPackageName = discoverOneByPackageName;
172
- const discoverMany = (request) => {
173
- const rootDirectory = './';
201
+ export const discoverMany = (request) => {
202
+ const rootDirectory = "./";
174
203
  const directory = path.resolve(process.cwd(), rootDirectory);
175
204
  let pattern;
176
- let listOfFiles = [''];
205
+ let listOfFiles = [""];
177
206
  switch (request.scope) {
178
207
  case SCOPE.local:
179
208
  // ### MANY - LOCAL - fileName ###
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}`);
209
+ const onlyLocalComponentsDirectories = storyblokConfig.componentsDirectories.filter((path) => !path.includes("node_modules"));
210
+ pattern = path.join(`${directory}/${normalizeDiscover({
211
+ segments: onlyLocalComponentsDirectories,
212
+ })}`, "**", `${normalizeDiscover({ segments: request.fileNames })}.${storyblokConfig.schemaFileExt}`);
182
213
  listOfFiles = glob.sync(pattern, { follow: true });
183
214
  break;
184
215
  case SCOPE.external:
185
216
  // ### MANY - EXTERNAL - fileName ###
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}`);
217
+ const onlyNodeModulesPackagesComponentsDirectories = storyblokConfig.componentsDirectories.filter((path) => path.includes("node_modules"));
218
+ pattern = path.join(`${directory}/${normalizeDiscover({
219
+ segments: onlyNodeModulesPackagesComponentsDirectories,
220
+ })}`, "**", `${normalizeDiscover({ segments: request.fileNames })}.${storyblokConfig.schemaFileExt}`);
188
221
  listOfFiles = glob.sync(pattern, { follow: true });
189
222
  break;
190
223
  case SCOPE.all:
191
224
  // ### MANY - ALL - fileName ###
192
- pattern = path.join(`${directory}/${normalizeDiscover({ segments: config_1.default.componentsDirectories })}`, '**', `${normalizeDiscover({ segments: request.fileNames })}.${config_1.default.schemaFileExt}`);
225
+ pattern = path.join(`${directory}/${normalizeDiscover({
226
+ segments: storyblokConfig.componentsDirectories,
227
+ })}`, "**", `${normalizeDiscover({ segments: request.fileNames })}.${storyblokConfig.schemaFileExt}`);
193
228
  listOfFiles = glob.sync(pattern, { follow: true });
194
229
  break;
195
230
  default:
@@ -197,28 +232,33 @@ const discoverMany = (request) => {
197
232
  }
198
233
  return listOfFiles;
199
234
  };
200
- exports.discoverMany = discoverMany;
201
- const discoverManyDatasources = (request) => {
202
- const rootDirectory = './';
235
+ export const discoverManyDatasources = (request) => {
236
+ const rootDirectory = "./";
203
237
  const directory = path.resolve(process.cwd(), rootDirectory);
204
238
  let pattern;
205
- let listOfFiles = [''];
239
+ let listOfFiles = [""];
206
240
  switch (request.scope) {
207
241
  case SCOPE.local:
208
242
  // ### 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}`);
243
+ const onlyLocalComponentsDirectories = storyblokConfig.componentsDirectories.filter((path) => !path.includes("node_modules"));
244
+ pattern = path.join(`${directory}/${normalizeDiscover({
245
+ segments: onlyLocalComponentsDirectories,
246
+ })}`, "**", `${normalizeDiscover({ segments: request.fileNames })}.${storyblokConfig.datasourceExt}`);
211
247
  listOfFiles = glob.sync(pattern, { follow: true });
212
248
  break;
213
249
  case SCOPE.external:
214
250
  // ### 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}`);
251
+ const onlyNodeModulesPackagesComponentsDirectories = storyblokConfig.componentsDirectories.filter((path) => path.includes("node_modules"));
252
+ pattern = path.join(`${directory}/${normalizeDiscover({
253
+ segments: onlyNodeModulesPackagesComponentsDirectories,
254
+ })}`, "**", `${normalizeDiscover({ segments: request.fileNames })}.${storyblokConfig.datasourceExt}`);
217
255
  listOfFiles = glob.sync(pattern, { follow: true });
218
256
  break;
219
257
  case SCOPE.all:
220
258
  // ### MANY - ALL - fileName ###
221
- pattern = path.join(`${directory}/${normalizeDiscover({ segments: config_1.default.componentsDirectories })}`, '**', `${normalizeDiscover({ segments: request.fileNames })}.${config_1.default.datasourceExt}`);
259
+ pattern = path.join(`${directory}/${normalizeDiscover({
260
+ segments: storyblokConfig.componentsDirectories,
261
+ })}`, "**", `${normalizeDiscover({ segments: request.fileNames })}.${storyblokConfig.datasourceExt}`);
222
262
  listOfFiles = glob.sync(pattern, { follow: true });
223
263
  break;
224
264
  default:
@@ -226,30 +266,35 @@ const discoverManyDatasources = (request) => {
226
266
  }
227
267
  return listOfFiles;
228
268
  };
229
- exports.discoverManyDatasources = discoverManyDatasources;
230
- const discoverDatasources = (request) => {
231
- const rootDirectory = './';
269
+ export const discoverDatasources = (request) => {
270
+ const rootDirectory = "./";
232
271
  const directory = path.resolve(process.cwd(), rootDirectory);
233
272
  let pattern;
234
- let listOfFiles = [''];
273
+ let listOfFiles = [""];
235
274
  switch (request.scope) {
236
275
  case SCOPE.local:
237
276
  // ### ALL - LOCAL - fileName ###
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 _
277
+ const onlyLocalComponentsDirectories = storyblokConfig.componentsDirectories.filter((path) => !path.includes("node_modules"));
278
+ pattern = path.join(`${directory}/${normalizeDiscover({
279
+ segments: onlyLocalComponentsDirectories,
280
+ })}`, "**", `[^_]*.${storyblokConfig.datasourceExt}` // all files with 'ext' extension, without files beggining with _
240
281
  );
241
282
  listOfFiles = glob.sync(pattern, { follow: true });
242
283
  break;
243
284
  case SCOPE.external:
244
285
  // ### ALL - EXTERNAL - fileName ###
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 _
286
+ const onlyNodeModulesPackagesComponentsDirectories = storyblokConfig.componentsDirectories.filter((path) => path.includes("node_modules"));
287
+ pattern = path.join(`${directory}/${normalizeDiscover({
288
+ segments: onlyNodeModulesPackagesComponentsDirectories,
289
+ })}`, "**", `[^_]*.${storyblokConfig.datasourceExt}` // all files with 'ext' extension, without files beggining with _
247
290
  );
248
291
  listOfFiles = glob.sync(pattern, { follow: true });
249
292
  break;
250
293
  case SCOPE.all:
251
294
  // ### ALL - LOCAL - fileName ###
252
- pattern = path.join(`${directory}/${normalizeDiscover({ segments: config_1.default.componentsDirectories })}`, '**', `[^_]*.${config_1.default.datasourceExt}` // all files with 'ext' extension, without files beggining with _
295
+ pattern = path.join(`${directory}/${normalizeDiscover({
296
+ segments: storyblokConfig.componentsDirectories,
297
+ })}`, "**", `[^_]*.${storyblokConfig.datasourceExt}` // all files with 'ext' extension, without files beggining with _
253
298
  );
254
299
  listOfFiles = glob.sync(pattern, { follow: true });
255
300
  break;
@@ -258,30 +303,35 @@ const discoverDatasources = (request) => {
258
303
  }
259
304
  return listOfFiles;
260
305
  };
261
- exports.discoverDatasources = discoverDatasources;
262
- const discoverOne = (request) => {
263
- const rootDirectory = './';
306
+ export const discoverOne = (request) => {
307
+ const rootDirectory = "./";
264
308
  const directory = path.resolve(process.cwd(), rootDirectory);
265
309
  let pattern;
266
- let listOfFiles = [''];
310
+ let listOfFiles = [""];
267
311
  switch (request.scope) {
268
312
  case SCOPE.local:
269
313
  // ### ONE - LOCAL - fileName ###
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 _
314
+ const onlyLocalComponentsDirectories = storyblokConfig.componentsDirectories.filter((path) => !path.includes("node_modules"));
315
+ pattern = path.join(`${directory}/${normalizeDiscover({
316
+ segments: onlyLocalComponentsDirectories,
317
+ })}`, "**", `${request.fileName}.${storyblokConfig.schemaFileExt}` // all files with 'ext' extension, without files beggining with _
272
318
  );
273
319
  listOfFiles = glob.sync(pattern, { follow: true });
274
320
  break;
275
321
  case SCOPE.external:
276
322
  // ### ONE - EXTERNAL - fileName ###
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 _
323
+ const onlyNodeModulesPackagesComponentsDirectories = storyblokConfig.componentsDirectories.filter((path) => path.includes("node_modules"));
324
+ pattern = path.join(`${directory}/${normalizeDiscover({
325
+ segments: onlyNodeModulesPackagesComponentsDirectories,
326
+ })}`, "**", `${request.fileName}.${storyblokConfig.schemaFileExt}` // all files with 'ext' extension, without files beggining with _
279
327
  );
280
328
  listOfFiles = glob.sync(pattern, { follow: true });
281
329
  break;
282
330
  case SCOPE.all:
283
331
  // ### ONE - ALL - fileName ###
284
- pattern = path.join(`${directory}/${normalizeDiscover({ segments: config_1.default.componentsDirectories })}`, '**', `${request.fileName}.${config_1.default.schemaFileExt}`);
332
+ pattern = path.join(`${directory}/${normalizeDiscover({
333
+ segments: storyblokConfig.componentsDirectories,
334
+ })}`, "**", `${request.fileName}.${storyblokConfig.schemaFileExt}`);
285
335
  listOfFiles = glob.sync(pattern, { follow: true });
286
336
  break;
287
337
  default:
@@ -289,33 +339,34 @@ const discoverOne = (request) => {
289
339
  }
290
340
  return listOfFiles;
291
341
  };
292
- exports.discoverOne = discoverOne;
293
- const discover = (request) => {
294
- const rootDirectory = './';
342
+ export const discover = (request) => {
343
+ const rootDirectory = "./";
295
344
  const directory = path.resolve(process.cwd(), rootDirectory);
296
345
  let pattern;
297
- let listOfFiles = [''];
346
+ let listOfFiles = [""];
298
347
  const filesPattern = (componentDirectories) => {
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 _
301
- );
348
+ return componentDirectories.length === 1
349
+ ? path.join(`${directory}/${componentDirectories[0]}`, "**", `[^_]*.${storyblokConfig.schemaFileExt}` // all files with 'ext' extension, without files beggining with _
350
+ )
351
+ : path.join(`${directory}/{${componentDirectories.join(",")}}`, "**", `[^_]*.${storyblokConfig.schemaFileExt}` // all files with 'ext' extension, without files beggining with _
352
+ );
302
353
  };
303
354
  switch (request.scope) {
304
355
  case SCOPE.local:
305
356
  // ### ALL - LOCAL - fileName ###
306
- const onlyLocalComponentsDirectories = config_1.default.componentsDirectories.filter(path => !path.includes('node_modules'));
357
+ const onlyLocalComponentsDirectories = storyblokConfig.componentsDirectories.filter((path) => !path.includes("node_modules"));
307
358
  pattern = filesPattern(onlyLocalComponentsDirectories);
308
359
  listOfFiles = glob.sync(pattern, { follow: true });
309
360
  break;
310
361
  case SCOPE.external:
311
362
  // ### ALL - EXTERNAL - fileName ###
312
- const onlyNodeModulesPackagesComponentsDirectories = config_1.default.componentsDirectories.filter(path => path.includes('node_modules'));
363
+ const onlyNodeModulesPackagesComponentsDirectories = storyblokConfig.componentsDirectories.filter((path) => path.includes("node_modules"));
313
364
  pattern = filesPattern(onlyNodeModulesPackagesComponentsDirectories);
314
365
  listOfFiles = glob.sync(pattern, { follow: true });
315
366
  break;
316
367
  case SCOPE.all:
317
368
  // ### ALL - LOCAL - fileName ###
318
- pattern = filesPattern(config_1.default.componentsDirectories);
369
+ pattern = filesPattern(storyblokConfig.componentsDirectories);
319
370
  listOfFiles = glob.sync(pattern, { follow: true });
320
371
  break;
321
372
  default:
@@ -323,28 +374,33 @@ const discover = (request) => {
323
374
  }
324
375
  return listOfFiles;
325
376
  };
326
- exports.discover = discover;
327
- const discoverManyStyles = (request) => {
328
- const rootDirectory = './';
377
+ export const discoverManyStyles = (request) => {
378
+ const rootDirectory = "./";
329
379
  const directory = path.resolve(process.cwd(), rootDirectory);
330
380
  let pattern;
331
- let listOfFiles = [''];
381
+ let listOfFiles = [""];
332
382
  switch (request.scope) {
333
383
  case SCOPE.local:
334
384
  // ### MANY - LOCAL - fileName ###
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`);
385
+ const onlyLocalComponentsDirectories = storyblokConfig.componentsDirectories.filter((path) => !path.includes("node_modules"));
386
+ pattern = path.join(`${directory}/${normalizeDiscover({
387
+ segments: onlyLocalComponentsDirectories,
388
+ })}`, "**", `${normalizeDiscover({ segments: request.fileNames })}.scss`);
337
389
  listOfFiles = glob.sync(pattern, { follow: true });
338
390
  break;
339
391
  case SCOPE.external:
340
392
  // ### MANY - EXTERNAL - fileName ###
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`);
393
+ const onlyNodeModulesPackagesComponentsDirectories = storyblokConfig.componentsDirectories.filter((path) => path.includes("node_modules"));
394
+ pattern = path.join(`${directory}/${normalizeDiscover({
395
+ segments: onlyNodeModulesPackagesComponentsDirectories,
396
+ })}`, "**", `${normalizeDiscover({ segments: request.fileNames })}.scss`);
343
397
  listOfFiles = glob.sync(pattern, { follow: true });
344
398
  break;
345
399
  case SCOPE.all:
346
400
  // ### MANY - ALL - fileName ###
347
- pattern = path.join(`${directory}/${normalizeDiscover({ segments: config_1.default.componentsDirectories })}`, '**', `${normalizeDiscover({ segments: request.fileNames })}.scss`);
401
+ pattern = path.join(`${directory}/${normalizeDiscover({
402
+ segments: storyblokConfig.componentsDirectories,
403
+ })}`, "**", `${normalizeDiscover({ segments: request.fileNames })}.scss`);
348
404
  listOfFiles = glob.sync(pattern, { follow: true });
349
405
  break;
350
406
  default:
@@ -352,30 +408,35 @@ const discoverManyStyles = (request) => {
352
408
  }
353
409
  return listOfFiles;
354
410
  };
355
- exports.discoverManyStyles = discoverManyStyles;
356
- const discoverRoles = (request) => {
357
- const rootDirectory = './';
411
+ export const discoverRoles = (request) => {
412
+ const rootDirectory = "./";
358
413
  const directory = path.resolve(process.cwd(), rootDirectory);
359
414
  let pattern;
360
- let listOfFiles = [''];
415
+ let listOfFiles = [""];
361
416
  switch (request.scope) {
362
417
  case SCOPE.local:
363
418
  // ### ALL - LOCAL - fileName ###
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 _
419
+ const onlyLocalComponentsDirectories = storyblokConfig.componentsDirectories.filter((path) => !path.includes("node_modules"));
420
+ pattern = path.join(`${directory}/${normalizeDiscover({
421
+ segments: onlyLocalComponentsDirectories,
422
+ })}`, "**", `[^_]*.${storyblokConfig.rolesExt}` // all files with 'ext' extension, without files beggining with _
366
423
  );
367
424
  listOfFiles = glob.sync(pattern, { follow: true });
368
425
  break;
369
426
  case SCOPE.external:
370
427
  // ### ALL - EXTERNAL - fileName ###
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 _
428
+ const onlyNodeModulesPackagesComponentsDirectories = storyblokConfig.componentsDirectories.filter((path) => path.includes("node_modules"));
429
+ pattern = path.join(`${directory}/${normalizeDiscover({
430
+ segments: onlyNodeModulesPackagesComponentsDirectories,
431
+ })}`, "**", `[^_]*.${storyblokConfig.rolesExt}` // all files with 'ext' extension, without files beggining with _
373
432
  );
374
433
  listOfFiles = glob.sync(pattern, { follow: true });
375
434
  break;
376
435
  case SCOPE.all:
377
436
  // ### ALL - LOCAL - fileName ###
378
- pattern = path.join(`${directory}/${normalizeDiscover({ segments: config_1.default.componentsDirectories })}`, '**', `[^_]*.${config_1.default.rolesExt}` // all files with 'ext' extension, without files beggining with _
437
+ pattern = path.join(`${directory}/${normalizeDiscover({
438
+ segments: storyblokConfig.componentsDirectories,
439
+ })}`, "**", `[^_]*.${storyblokConfig.rolesExt}` // all files with 'ext' extension, without files beggining with _
379
440
  );
380
441
  listOfFiles = glob.sync(pattern, { follow: true });
381
442
  break;
@@ -384,28 +445,33 @@ const discoverRoles = (request) => {
384
445
  }
385
446
  return listOfFiles;
386
447
  };
387
- exports.discoverRoles = discoverRoles;
388
- const discoverManyRoles = (request) => {
389
- const rootDirectory = './';
448
+ export const discoverManyRoles = (request) => {
449
+ const rootDirectory = "./";
390
450
  const directory = path.resolve(process.cwd(), rootDirectory);
391
451
  let pattern;
392
- let listOfFiles = [''];
452
+ let listOfFiles = [""];
393
453
  switch (request.scope) {
394
454
  case SCOPE.local:
395
455
  // ### ALL - LOCAL - fileName ###
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}`);
456
+ const onlyLocalComponentsDirectories = storyblokConfig.componentsDirectories.filter((path) => !path.includes("node_modules"));
457
+ pattern = path.join(`${directory}/${normalizeDiscover({
458
+ segments: onlyLocalComponentsDirectories,
459
+ })}`, "**", `${normalizeDiscover({ segments: request.fileNames })}.${storyblokConfig.rolesExt}`);
398
460
  listOfFiles = glob.sync(pattern, { follow: true });
399
461
  break;
400
462
  case SCOPE.external:
401
463
  // ### ALL - EXTERNAL - fileName ###
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}`);
464
+ const onlyNodeModulesPackagesComponentsDirectories = storyblokConfig.componentsDirectories.filter((path) => path.includes("node_modules"));
465
+ pattern = path.join(`${directory}/${normalizeDiscover({
466
+ segments: onlyNodeModulesPackagesComponentsDirectories,
467
+ })}`, "**", `${normalizeDiscover({ segments: request.fileNames })}.${storyblokConfig.rolesExt}`);
404
468
  listOfFiles = glob.sync(pattern, { follow: true });
405
469
  break;
406
470
  case SCOPE.all:
407
471
  // ### ALL - LOCAL - fileName ###
408
- pattern = path.join(`${directory}/${normalizeDiscover({ segments: config_1.default.componentsDirectories })}`, '**', `${normalizeDiscover({ segments: request.fileNames })}.${config_1.default.rolesExt}`);
472
+ pattern = path.join(`${directory}/${normalizeDiscover({
473
+ segments: storyblokConfig.componentsDirectories,
474
+ })}`, "**", `${normalizeDiscover({ segments: request.fileNames })}.${storyblokConfig.rolesExt}`);
409
475
  listOfFiles = glob.sync(pattern, { follow: true });
410
476
  break;
411
477
  default:
@@ -413,12 +479,3 @@ const discoverManyRoles = (request) => {
413
479
  }
414
480
  return listOfFiles;
415
481
  };
416
- exports.discoverManyRoles = discoverManyRoles;
417
- const getFilesContent = (data) => {
418
- return data.files.map(file => require(file));
419
- };
420
- exports.getFilesContent = getFilesContent;
421
- const getFileContent = (data) => {
422
- return require(data.file);
423
- };
424
- exports.getFileContent = getFileContent;