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.
- package/README.md +72 -20
- package/lib/api/componentPresets.d.ts +1 -1
- package/lib/api/componentPresets.js +6 -9
- package/lib/api/components.js +25 -20
- package/lib/api/datasources.js +53 -46
- package/lib/api/migrate.d.ts +2 -2
- package/lib/api/migrate.js +69 -64
- package/lib/api/mutateComponents.js +10 -8
- package/lib/api/presets.js +11 -7
- package/lib/api/resolvePresets.js +7 -7
- package/lib/api/roles.d.ts +1 -1
- package/lib/api/roles.js +39 -32
- package/lib/api/spaces.js +8 -6
- package/lib/commands/backup.d.ts +1 -1
- package/lib/commands/backup.js +75 -75
- package/lib/commands/debug.js +10 -3
- package/lib/commands/sync.js +43 -43
- package/lib/config/StoryblokComponentsConfig.js +44 -44
- package/lib/config/config.js +16 -16
- package/lib/core.js +5 -5
- package/lib/index.js +1 -0
- package/lib/utils/discover.d.ts +1 -1
- package/lib/utils/discover.js +46 -44
- package/lib/utils/discover2.js +100 -91
- package/lib/utils/files.js +21 -15
- package/lib/utils/logger.js +5 -5
- package/lib/utils/others.js +2 -1
- package/oclif.manifest.json +1 -1
- package/package.json +18 -30
- package/CHANGELOG.md +0 -968
package/lib/config/config.js
CHANGED
|
@@ -9,28 +9,28 @@ try {
|
|
|
9
9
|
}
|
|
10
10
|
catch (error) {
|
|
11
11
|
// default config will be used
|
|
12
|
-
if (error.code !==
|
|
12
|
+
if (error.code !== 'MODULE_NOT_FOUND')
|
|
13
13
|
throw error;
|
|
14
14
|
}
|
|
15
15
|
const defaultConfig = {
|
|
16
|
-
componentsMatchFile:
|
|
17
|
-
storyblokComponentsListfile:
|
|
18
|
-
storyblokComponentsLocalDirectory:
|
|
19
|
-
componentsStylesMatchFile:
|
|
20
|
-
boilerplateUrl:
|
|
21
|
-
sbmigWorkingDirectory:
|
|
22
|
-
componentDirectory:
|
|
23
|
-
datasourcesDirectory:
|
|
24
|
-
componentsDirectories: [
|
|
25
|
-
schemaFileExt:
|
|
26
|
-
datasourceExt:
|
|
27
|
-
rolesExt:
|
|
28
|
-
storyblokApiUrl:
|
|
16
|
+
componentsMatchFile: 'src/components/components.js',
|
|
17
|
+
storyblokComponentsListfile: 'src/components/storyblok-components.componentList.js',
|
|
18
|
+
storyblokComponentsLocalDirectory: 'src/@storyblok-components',
|
|
19
|
+
componentsStylesMatchFile: 'src/@storyblok-components/_storyblok-components.scss',
|
|
20
|
+
boilerplateUrl: 'git@github.com:storyblok-components/gatsby-storyblok-boilerplate.git',
|
|
21
|
+
sbmigWorkingDirectory: 'sbmig',
|
|
22
|
+
componentDirectory: 'storyblok',
|
|
23
|
+
datasourcesDirectory: 'storyblok',
|
|
24
|
+
componentsDirectories: ['src', 'storyblok'],
|
|
25
|
+
schemaFileExt: 'sb.js',
|
|
26
|
+
datasourceExt: 'sb.datasource.js',
|
|
27
|
+
rolesExt: 'sb.roles.js',
|
|
28
|
+
storyblokApiUrl: 'https://api.storyblok.com/v1',
|
|
29
29
|
oauthToken: process.env.STORYBLOK_OAUTH_TOKEN,
|
|
30
30
|
spaceId: process.env.STORYBLOK_SPACE_ID,
|
|
31
|
-
accessToken: process.env.GATSBY_STORYBLOK_ACCESS_TOKEN || process.env.NEXT_STORYBLOK_ACCESS_TOKEN
|
|
31
|
+
accessToken: process.env.GATSBY_STORYBLOK_ACCESS_TOKEN || process.env.NEXT_STORYBLOK_ACCESS_TOKEN,
|
|
32
32
|
};
|
|
33
33
|
exports.default = {
|
|
34
34
|
...defaultConfig,
|
|
35
|
-
...customConfig
|
|
35
|
+
...customConfig,
|
|
36
36
|
};
|
package/lib/core.js
CHANGED
|
@@ -26,7 +26,7 @@ class default_1 extends command_1.default {
|
|
|
26
26
|
createDir: files_1.createDir,
|
|
27
27
|
createJsonFile: files_1.createJsonFile,
|
|
28
28
|
copyFolder: files_1.copyFolder,
|
|
29
|
-
copyFile: files_1.copyFile
|
|
29
|
+
copyFile: files_1.copyFile,
|
|
30
30
|
};
|
|
31
31
|
}
|
|
32
32
|
api() {
|
|
@@ -56,19 +56,19 @@ class default_1 extends command_1.default {
|
|
|
56
56
|
syncComponents: migrate_1.syncComponents,
|
|
57
57
|
syncAllComponents: migrate_1.syncAllComponents,
|
|
58
58
|
updateComponent: mutateComponents_1.updateComponent,
|
|
59
|
-
createComponent: mutateComponents_1.createComponent
|
|
59
|
+
createComponent: mutateComponents_1.createComponent,
|
|
60
60
|
},
|
|
61
61
|
presets: {
|
|
62
62
|
getComponentPresets: componentPresets_1.getComponentPresets,
|
|
63
63
|
getPreset: presets_1.getPreset,
|
|
64
64
|
getAllPresets: presets_1.getAllPresets,
|
|
65
65
|
createPreset: presets_1.createPreset,
|
|
66
|
-
updatePreset: presets_1.updatePreset
|
|
66
|
+
updatePreset: presets_1.updatePreset,
|
|
67
67
|
},
|
|
68
68
|
spaces: {
|
|
69
69
|
createSpace: spaces_1.createSpace,
|
|
70
|
-
getSpace: spaces_1.getSpace
|
|
71
|
-
}
|
|
70
|
+
getSpace: spaces_1.getSpace,
|
|
71
|
+
},
|
|
72
72
|
};
|
|
73
73
|
}
|
|
74
74
|
}
|
package/lib/index.js
CHANGED
package/lib/utils/discover.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export declare const findComponents: (componentDirectory: string) => any[];
|
|
2
|
-
export declare const findComponentsWithExt: (ext: string) => any[];
|
|
2
|
+
export declare const findComponentsWithExt: (ext: string | boolean) => any[];
|
|
3
3
|
export declare const findComponentsByPackageName: (ext: string | boolean, specifiedComponents: string[], local?: boolean | undefined) => any[];
|
|
4
4
|
export declare const findDatasources: () => any[];
|
package/lib/utils/discover.js
CHANGED
|
@@ -6,89 +6,91 @@ exports.findDatasources = exports.findComponentsByPackageName = exports.findComp
|
|
|
6
6
|
const glob = require("glob");
|
|
7
7
|
const path = require("path");
|
|
8
8
|
const config_1 = require("../config/config");
|
|
9
|
-
|
|
9
|
+
const findComponents = (componentDirectory) => {
|
|
10
10
|
const directory = path.resolve(process.cwd(), componentDirectory);
|
|
11
11
|
return glob
|
|
12
|
-
.sync(path.join(directory,
|
|
13
|
-
.map(
|
|
12
|
+
.sync(path.join(directory, '**', '!(_*|*.datasource)*.js'))
|
|
13
|
+
.map(file => require(path.resolve(directory, file)));
|
|
14
14
|
};
|
|
15
|
-
exports.
|
|
16
|
-
|
|
15
|
+
exports.findComponents = findComponents;
|
|
16
|
+
const findComponentsWithExt = (ext) => {
|
|
17
|
+
const rootDirectory = './';
|
|
17
18
|
const directory = path.resolve(process.cwd(), rootDirectory);
|
|
18
19
|
const files = glob
|
|
19
|
-
.sync(path.join(`${directory}/{${config_1.default.componentsDirectories.join(
|
|
20
|
+
.sync(path.join(`${directory}/{${config_1.default.componentsDirectories.join(',')}}`, '**', `[^_]*.${ext}`), {
|
|
20
21
|
follow: true,
|
|
21
22
|
})
|
|
22
|
-
.map(
|
|
23
|
-
const fileNames = files.map(
|
|
23
|
+
.map(file => require(path.resolve(directory, file)));
|
|
24
|
+
const fileNames = files.map(file => file.name);
|
|
24
25
|
return files;
|
|
25
26
|
};
|
|
26
|
-
exports.
|
|
27
|
-
|
|
27
|
+
exports.findComponentsWithExt = findComponentsWithExt;
|
|
28
|
+
const findComponentsByPackageName = (ext, specifiedComponents, local) => {
|
|
29
|
+
const rootDirectory = './';
|
|
28
30
|
const directory = path.resolve(process.cwd(), rootDirectory);
|
|
29
31
|
// @ts-ignore
|
|
30
32
|
if (local === true) {
|
|
31
|
-
const onlyLocalComponentsDirectories = config_1.default.componentsDirectories.filter(
|
|
32
|
-
const onlyLocalPackages = glob.sync(path.join(`${directory}/{${onlyLocalComponentsDirectories.join(
|
|
33
|
+
const onlyLocalComponentsDirectories = config_1.default.componentsDirectories.filter(dir => !dir.includes('node_modules'));
|
|
34
|
+
const onlyLocalPackages = glob.sync(path.join(`${directory}/{${onlyLocalComponentsDirectories.join(',')}}`, '**', 'package.json'), {
|
|
33
35
|
follow: true,
|
|
34
36
|
});
|
|
35
37
|
return onlyLocalPackages
|
|
36
|
-
.filter(
|
|
38
|
+
.filter(file => {
|
|
37
39
|
return specifiedComponents.includes(require(path.resolve(directory, file)).name);
|
|
38
40
|
})
|
|
39
|
-
.map(
|
|
40
|
-
const fileFolderPath = file.split(
|
|
41
|
+
.map(file => {
|
|
42
|
+
const fileFolderPath = file.split('/').slice(0, -1).join('/');
|
|
41
43
|
return glob
|
|
42
|
-
.sync(path.join(`${fileFolderPath}`,
|
|
44
|
+
.sync(path.join(`${fileFolderPath}`, '**', `[^_]*.${ext}`), {
|
|
43
45
|
follow: true,
|
|
44
46
|
})
|
|
45
|
-
.map(
|
|
47
|
+
.map(file => require(path.resolve(directory, file)).name);
|
|
46
48
|
})
|
|
47
49
|
.flat();
|
|
48
50
|
}
|
|
49
|
-
|
|
50
|
-
const onlyNodeModulesPackagesComponentsDirectories = config_1.default.componentsDirectories.filter(
|
|
51
|
-
const onlyNodeModulesPackages = glob.sync(path.join(`${directory}/{${onlyNodeModulesPackagesComponentsDirectories.join(
|
|
51
|
+
if (local === false) {
|
|
52
|
+
const onlyNodeModulesPackagesComponentsDirectories = config_1.default.componentsDirectories.filter(dir => dir.includes('node_modules'));
|
|
53
|
+
const onlyNodeModulesPackages = glob.sync(path.join(`${directory}/{${onlyNodeModulesPackagesComponentsDirectories.join(',')}}`, '**', 'package.json'), {
|
|
52
54
|
follow: true,
|
|
53
55
|
});
|
|
54
56
|
return onlyNodeModulesPackages
|
|
55
|
-
.filter(
|
|
57
|
+
.filter(file => {
|
|
56
58
|
return specifiedComponents.includes(require(path.resolve(directory, file)).name);
|
|
57
59
|
})
|
|
58
|
-
.map(
|
|
59
|
-
const fileFolderPath = file.split(
|
|
60
|
+
.map(file => {
|
|
61
|
+
const fileFolderPath = file.split('/').slice(0, -1).join('/');
|
|
60
62
|
return glob
|
|
61
|
-
.sync(path.join(`${fileFolderPath}`,
|
|
63
|
+
.sync(path.join(`${fileFolderPath}`, '**', `[^_]*.${ext}`), {
|
|
62
64
|
follow: true,
|
|
63
65
|
})
|
|
64
|
-
.map(
|
|
66
|
+
.map(file => require(path.resolve(directory, file)).name);
|
|
65
67
|
})
|
|
66
68
|
.flat();
|
|
67
69
|
}
|
|
68
|
-
|
|
70
|
+
return glob
|
|
71
|
+
.sync(path.join(`${directory}/{${config_1.default.componentsDirectories.join(',')}}`, '**', 'package.json'), {
|
|
72
|
+
follow: true,
|
|
73
|
+
})
|
|
74
|
+
.filter(file => {
|
|
75
|
+
return specifiedComponents.includes(require(path.resolve(directory, file)).name);
|
|
76
|
+
})
|
|
77
|
+
.map(file => {
|
|
78
|
+
const fileFolderPath = file.split('/').slice(0, -1).join('/');
|
|
69
79
|
return glob
|
|
70
|
-
.sync(path.join(`${
|
|
80
|
+
.sync(path.join(`${fileFolderPath}`, '**', `[^_]*.${ext}`), {
|
|
71
81
|
follow: true,
|
|
72
82
|
})
|
|
73
|
-
.
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
.map((file) => {
|
|
77
|
-
const fileFolderPath = file.split("/").slice(0, -1).join("/");
|
|
78
|
-
return glob
|
|
79
|
-
.sync(path.join(`${fileFolderPath}`, `**`, `[^_]*.${ext}`), {
|
|
80
|
-
follow: true,
|
|
81
|
-
})
|
|
82
|
-
.map((file) => require(path.resolve(directory, file)).name);
|
|
83
|
-
})
|
|
84
|
-
.flat();
|
|
85
|
-
}
|
|
83
|
+
.map(file => require(path.resolve(directory, file)).name);
|
|
84
|
+
})
|
|
85
|
+
.flat();
|
|
86
86
|
};
|
|
87
|
-
exports.
|
|
88
|
-
|
|
87
|
+
exports.findComponentsByPackageName = findComponentsByPackageName;
|
|
88
|
+
const findDatasources = () => {
|
|
89
|
+
const rootDirectory = './';
|
|
89
90
|
const directory = path.resolve(process.cwd(), rootDirectory);
|
|
90
91
|
return (glob
|
|
91
|
-
.sync(path.join(`${directory}/${config_1.default.datasourcesDirectory}`,
|
|
92
|
+
.sync(path.join(`${directory}/${config_1.default.datasourcesDirectory}`, '**', '[^_]*.sb.datasource.js'))
|
|
92
93
|
// eslint-disable-next-line global-require, import/no-dynamic-require
|
|
93
|
-
.map(
|
|
94
|
+
.map(file => require(path.resolve(directory, file))));
|
|
94
95
|
};
|
|
96
|
+
exports.findDatasources = findDatasources;
|