sb-mig 2.9.3 → 3.0.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +107 -471
- package/dist/api/componentPresets.d.ts +1 -0
- package/dist/api/componentPresets.js +18 -0
- package/{lib → dist}/api/components.d.ts +2 -2
- package/dist/api/components.js +63 -0
- package/dist/api/config.d.ts +2 -0
- package/dist/api/config.js +4 -0
- package/{lib → dist}/api/datasources.d.ts +1 -1
- package/dist/api/datasources.js +181 -0
- package/dist/api/migrate.d.ts +17 -0
- package/dist/api/migrate.js +139 -0
- package/{lib → dist}/api/mutateComponents.d.ts +0 -0
- package/dist/api/mutateComponents.js +45 -0
- package/{lib → dist}/api/presets.d.ts +1 -1
- package/dist/api/presets.js +52 -0
- package/{lib → dist}/api/resolvePresets.d.ts +0 -0
- package/{lib → dist}/api/resolvePresets.js +15 -14
- package/{lib → dist}/api/roles.d.ts +2 -2
- package/dist/api/roles.js +125 -0
- package/dist/cli-descriptions.d.ts +4 -0
- package/dist/cli-descriptions.js +69 -0
- package/dist/commands/backup.d.ts +2 -0
- package/dist/commands/backup.js +201 -0
- package/dist/commands/debug.d.ts +1 -0
- package/dist/commands/debug.js +5 -0
- package/dist/commands/sync.d.ts +2 -0
- package/dist/commands/sync.js +58 -0
- package/dist/config/config.d.ts +14 -0
- package/dist/config/config.js +49 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +52 -0
- package/{lib/utils/discover2.d.ts → dist/utils/discover.d.ts} +1 -7
- package/{lib/utils/discover2.js → dist/utils/discover.js} +200 -143
- package/{lib → dist}/utils/files.d.ts +7 -1
- package/dist/utils/files.js +54 -0
- package/dist/utils/interfaces.d.ts +4 -0
- package/dist/utils/interfaces.js +1 -0
- package/{lib → dist}/utils/logger.d.ts +0 -3
- package/{lib → dist}/utils/logger.js +2 -12
- package/dist/utils/main.d.ts +13 -0
- package/dist/utils/main.js +28 -0
- package/{lib → dist}/utils/others.d.ts +0 -0
- package/dist/utils/others.js +1 -0
- package/package.json +63 -57
- package/CHANGELOG.md +0 -996
- package/bin/run +0 -5
- package/bin/run.cmd +0 -3
- package/lib/api/apiConfig.d.ts +0 -2
- package/lib/api/apiConfig.js +0 -9
- package/lib/api/componentPresets.d.ts +0 -1
- package/lib/api/componentPresets.js +0 -22
- package/lib/api/components.js +0 -71
- package/lib/api/datasources.js +0 -193
- package/lib/api/migrate.d.ts +0 -19
- package/lib/api/migrate.js +0 -220
- package/lib/api/mutateComponents.js +0 -50
- package/lib/api/presets.js +0 -59
- package/lib/api/roles.js +0 -133
- package/lib/api/spaces.d.ts +0 -2
- package/lib/api/spaces.js +0 -29
- package/lib/commands/backup.d.ts +0 -22
- package/lib/commands/backup.js +0 -217
- package/lib/commands/debug.d.ts +0 -9
- package/lib/commands/debug.js +0 -21
- package/lib/commands/sync.d.ts +0 -26
- package/lib/commands/sync.js +0 -93
- package/lib/config/StoryblokComponentsConfig.d.ts +0 -68
- package/lib/config/StoryblokComponentsConfig.js +0 -220
- package/lib/config/config.d.ts +0 -37
- package/lib/config/config.js +0 -36
- package/lib/core.d.ts +0 -16
- package/lib/core.js +0 -75
- package/lib/index.d.ts +0 -1
- package/lib/index.js +0 -5
- package/lib/types/storyblokTypes.d.ts +0 -171
- package/lib/types/storyblokTypes.js +0 -3
- package/lib/utils/discover.d.ts +0 -4
- package/lib/utils/discover.js +0 -96
- package/lib/utils/files.js +0 -54
- package/lib/utils/others.js +0 -5
- 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
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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
|
|
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
|
|
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
|
-
|
|
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(
|
|
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(
|
|
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
|
-
.
|
|
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
|
-
|
|
58
|
-
const
|
|
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 =
|
|
68
|
-
pattern = path.join(`${directory}/${normalizeDiscover({
|
|
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(
|
|
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
|
|
75
|
-
|
|
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 =
|
|
83
|
-
pattern = path.join(`${directory}/${normalizeDiscover({
|
|
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((
|
|
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
|
|
90
|
-
|
|
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({
|
|
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((
|
|
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
|
|
104
|
-
|
|
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
|
-
|
|
115
|
-
const
|
|
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 =
|
|
125
|
-
pattern = path.join(`${directory}/${normalizeDiscover({
|
|
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 => (
|
|
129
|
-
.
|
|
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
|
|
132
|
-
|
|
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 =
|
|
140
|
-
pattern = path.join(`${directory}/${normalizeDiscover({
|
|
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 => (
|
|
144
|
-
.
|
|
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
|
|
147
|
-
|
|
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({
|
|
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 => (
|
|
158
|
-
.
|
|
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
|
|
161
|
-
|
|
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
|
-
|
|
172
|
-
const
|
|
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 =
|
|
181
|
-
pattern = path.join(`${directory}/${normalizeDiscover({
|
|
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 =
|
|
187
|
-
pattern = path.join(`${directory}/${normalizeDiscover({
|
|
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({
|
|
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
|
-
|
|
201
|
-
const
|
|
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 =
|
|
210
|
-
pattern = path.join(`${directory}/${normalizeDiscover({
|
|
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 =
|
|
216
|
-
pattern = path.join(`${directory}/${normalizeDiscover({
|
|
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({
|
|
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
|
-
|
|
230
|
-
const
|
|
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 =
|
|
239
|
-
pattern = path.join(`${directory}/${normalizeDiscover({
|
|
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 =
|
|
246
|
-
pattern = path.join(`${directory}/${normalizeDiscover({
|
|
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({
|
|
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
|
-
|
|
262
|
-
const
|
|
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 =
|
|
271
|
-
pattern = path.join(`${directory}/${normalizeDiscover({
|
|
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 =
|
|
278
|
-
pattern = path.join(`${directory}/${normalizeDiscover({
|
|
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({
|
|
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
|
-
|
|
293
|
-
const
|
|
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
|
|
300
|
-
|
|
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 =
|
|
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 =
|
|
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(
|
|
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
|
-
|
|
327
|
-
const
|
|
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 =
|
|
336
|
-
pattern = path.join(`${directory}/${normalizeDiscover({
|
|
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 =
|
|
342
|
-
pattern = path.join(`${directory}/${normalizeDiscover({
|
|
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({
|
|
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
|
-
|
|
356
|
-
const
|
|
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 =
|
|
365
|
-
pattern = path.join(`${directory}/${normalizeDiscover({
|
|
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 =
|
|
372
|
-
pattern = path.join(`${directory}/${normalizeDiscover({
|
|
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({
|
|
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
|
-
|
|
388
|
-
const
|
|
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 =
|
|
397
|
-
pattern = path.join(`${directory}/${normalizeDiscover({
|
|
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 =
|
|
403
|
-
pattern = path.join(`${directory}/${normalizeDiscover({
|
|
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({
|
|
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;
|