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,220 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.StoryblokComponentsConfig = exports.SWAP_TOKEN = void 0;
|
|
4
|
-
const path = require("path");
|
|
5
|
-
const dotenv = require("dotenv");
|
|
6
|
-
const fs_1 = require("fs");
|
|
7
|
-
const camelcase = require("camelcase");
|
|
8
|
-
const config_1 = require("./config");
|
|
9
|
-
const discover2_1 = require("../utils/discover2");
|
|
10
|
-
dotenv.config();
|
|
11
|
-
var SWAP_TOKEN;
|
|
12
|
-
(function (SWAP_TOKEN) {
|
|
13
|
-
SWAP_TOKEN["componentImports"] = "componentImports";
|
|
14
|
-
SWAP_TOKEN["componentLists"] = "componentLists";
|
|
15
|
-
SWAP_TOKEN["styleImports"] = "styleImports";
|
|
16
|
-
})(SWAP_TOKEN = exports.SWAP_TOKEN || (exports.SWAP_TOKEN = {}));
|
|
17
|
-
class StoryblokComponentsConfig {
|
|
18
|
-
constructor(data) {
|
|
19
|
-
this.componentImportsToken = '// --- sb-mig scoped component imports ---';
|
|
20
|
-
this.componentComponentsListToken = '// --- sb-mig scoped component list ---';
|
|
21
|
-
this.componentStylesImportsToken = '// --- sb-mig scoped component styles imports ---';
|
|
22
|
-
this.storyblokComponentsConfigUrl = path.resolve(process.cwd(), 'storyblok.components.lock.js');
|
|
23
|
-
this.data = data;
|
|
24
|
-
}
|
|
25
|
-
updateComponentsConfigFile() {
|
|
26
|
-
const content = `module.exports = ${JSON.stringify(this.data, undefined, 2)}`;
|
|
27
|
-
fs_1.promises.writeFile(this.storyblokComponentsConfigUrl, content, {
|
|
28
|
-
encoding: 'utf-8',
|
|
29
|
-
})
|
|
30
|
-
.then(result => {
|
|
31
|
-
console.log('Done');
|
|
32
|
-
console.log(result);
|
|
33
|
-
return true;
|
|
34
|
-
})
|
|
35
|
-
.catch((err) => {
|
|
36
|
-
console.log('error, wtf ?');
|
|
37
|
-
console.log(err.message);
|
|
38
|
-
return false;
|
|
39
|
-
});
|
|
40
|
-
return true;
|
|
41
|
-
}
|
|
42
|
-
addComponentsToComponentsConfigFile({ installedComponents, local, }) {
|
|
43
|
-
return {
|
|
44
|
-
...this.data,
|
|
45
|
-
...installedComponents.reduce((prev, curr) => {
|
|
46
|
-
if (!this.getSingleData(`${curr.scope}/${curr.name}`)) {
|
|
47
|
-
const stylesFileAvailable = (0, discover2_1.discoverManyStyles)({
|
|
48
|
-
fileNames: [curr.name],
|
|
49
|
-
scope: discover2_1.SCOPE.all,
|
|
50
|
-
type: discover2_1.LOOKUP_TYPE.fileName,
|
|
51
|
-
}).length > 0;
|
|
52
|
-
return {
|
|
53
|
-
...prev,
|
|
54
|
-
[`${curr.scope}/${curr.name}`]: {
|
|
55
|
-
name: `${curr.scope}/${curr.name}`,
|
|
56
|
-
scope: curr.scope,
|
|
57
|
-
location: local ? 'local' : 'node_modules',
|
|
58
|
-
locationPath: local ?
|
|
59
|
-
`${config_1.default.storyblokComponentsLocalDirectory}/${curr.name}` :
|
|
60
|
-
`node_modules/${curr.scope}/${curr.name}`,
|
|
61
|
-
links: {
|
|
62
|
-
[config_1.default.storyblokComponentsListfile]: {
|
|
63
|
-
'// --- sb-mig scoped component imports ---': local ?
|
|
64
|
-
`import * as Scoped${camelcase(curr.name, { pascalCase: true })} from "./${curr.name}";` :
|
|
65
|
-
`import * as Scoped${camelcase(curr.name, { pascalCase: true })} from "${curr.scope}/${curr.name}";`,
|
|
66
|
-
'// --- sb-mig scoped component list ---': `Scoped${camelcase(curr.name, { pascalCase: true })}.ComponentList`,
|
|
67
|
-
},
|
|
68
|
-
[config_1.default.componentsStylesMatchFile]: {
|
|
69
|
-
'// --- sb-mig scoped component styles imports ---': stylesFileAvailable ?
|
|
70
|
-
local ?
|
|
71
|
-
`@import './${curr.name}/${curr.name}.scss';` :
|
|
72
|
-
`@import '${curr.scope}/${curr.name}/src/${curr.name}.scss';` :
|
|
73
|
-
'',
|
|
74
|
-
},
|
|
75
|
-
},
|
|
76
|
-
},
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
|
-
}, {}),
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
getAllData() {
|
|
83
|
-
return this.data;
|
|
84
|
-
}
|
|
85
|
-
getSingleData(componentName) {
|
|
86
|
-
return this.data[componentName];
|
|
87
|
-
}
|
|
88
|
-
setAllData(data) {
|
|
89
|
-
this.data = {
|
|
90
|
-
...data,
|
|
91
|
-
};
|
|
92
|
-
}
|
|
93
|
-
setSingleData(singleComponentData) {
|
|
94
|
-
this.data[singleComponentData.name] = singleComponentData;
|
|
95
|
-
}
|
|
96
|
-
/**
|
|
97
|
-
*
|
|
98
|
-
* Based on storyblok.componnets.lock.js file,
|
|
99
|
-
* return proper content of specific files
|
|
100
|
-
* (storyblok-components.componentList.js and storyblok-componnets-styles.scss)
|
|
101
|
-
*/
|
|
102
|
-
createCrumb({ to, token }) {
|
|
103
|
-
const dataEntries = Object.entries(this.data);
|
|
104
|
-
let temp;
|
|
105
|
-
switch (token) {
|
|
106
|
-
case SWAP_TOKEN.componentImports:
|
|
107
|
-
temp = dataEntries
|
|
108
|
-
.map(component => component[1].links)
|
|
109
|
-
.map(component => component[to] !== undefined && component[to])
|
|
110
|
-
.filter(elements => elements !== false)
|
|
111
|
-
.reduce(
|
|
112
|
-
// @ts-ignore
|
|
113
|
-
(acc, curr) => {
|
|
114
|
-
return [...acc, curr[this.componentImportsToken]];
|
|
115
|
-
}, [this.componentImportsToken]);
|
|
116
|
-
break;
|
|
117
|
-
case SWAP_TOKEN.componentLists:
|
|
118
|
-
temp = dataEntries
|
|
119
|
-
.map(component => component[1].links)
|
|
120
|
-
.map(component => component[to] !== undefined && component[to])
|
|
121
|
-
.filter(elements => elements !== false)
|
|
122
|
-
.reduce(
|
|
123
|
-
// @ts-ignore
|
|
124
|
-
(acc, curr) => {
|
|
125
|
-
return [
|
|
126
|
-
...acc,
|
|
127
|
-
curr[this.componentComponentsListToken],
|
|
128
|
-
];
|
|
129
|
-
}, [this.componentComponentsListToken]);
|
|
130
|
-
break;
|
|
131
|
-
case SWAP_TOKEN.styleImports:
|
|
132
|
-
temp = dataEntries
|
|
133
|
-
.map(component => component[1].links)
|
|
134
|
-
.map(component => component[to] !== undefined && component[to])
|
|
135
|
-
.filter(elements => elements !== false)
|
|
136
|
-
.reduce(
|
|
137
|
-
// @ts-ignore
|
|
138
|
-
(acc, curr) => {
|
|
139
|
-
return [
|
|
140
|
-
...acc,
|
|
141
|
-
curr[this.componentStylesImportsToken],
|
|
142
|
-
];
|
|
143
|
-
}, [this.componentStylesImportsToken]);
|
|
144
|
-
break;
|
|
145
|
-
default:
|
|
146
|
-
break;
|
|
147
|
-
}
|
|
148
|
-
return temp === null || temp === void 0 ? void 0 : temp.filter((element) => element);
|
|
149
|
-
}
|
|
150
|
-
/**
|
|
151
|
-
* This updates storyblok components file with imports and
|
|
152
|
-
* exports of componentList part of the component, based on
|
|
153
|
-
* storyblok.components.lock file links property
|
|
154
|
-
*/
|
|
155
|
-
updateStoryblokComponentsFile() {
|
|
156
|
-
// one file
|
|
157
|
-
const crumb1 = this.createCrumb({
|
|
158
|
-
to: config_1.default.storyblokComponentsListfile,
|
|
159
|
-
token: SWAP_TOKEN.componentImports,
|
|
160
|
-
});
|
|
161
|
-
const crumb2 = this.createCrumb({
|
|
162
|
-
to: config_1.default.storyblokComponentsListfile,
|
|
163
|
-
token: SWAP_TOKEN.componentLists,
|
|
164
|
-
});
|
|
165
|
-
let content = `${crumb1.join('\n')}\n`;
|
|
166
|
-
content = `${content}\nexport default [
|
|
167
|
-
${crumb2.shift()}
|
|
168
|
-
${crumb2.map((partial) => `${partial},`).join('\n')}
|
|
169
|
-
]\n`;
|
|
170
|
-
// update actual file
|
|
171
|
-
fs_1.promises.writeFile(config_1.default.storyblokComponentsListfile, content, {
|
|
172
|
-
encoding: 'utf-8',
|
|
173
|
-
})
|
|
174
|
-
.then(result => {
|
|
175
|
-
console.log('Done');
|
|
176
|
-
console.log(result);
|
|
177
|
-
return true;
|
|
178
|
-
})
|
|
179
|
-
.catch((err) => {
|
|
180
|
-
console.log('error, wtf ?');
|
|
181
|
-
console.log(err.message);
|
|
182
|
-
return false;
|
|
183
|
-
});
|
|
184
|
-
}
|
|
185
|
-
/**
|
|
186
|
-
* This updates storyblok components styles file with style imports
|
|
187
|
-
* based on storyblok.components.lock file links property
|
|
188
|
-
*/
|
|
189
|
-
updateStoryblokComponentStylesFile() {
|
|
190
|
-
// one file
|
|
191
|
-
const crumb1 = this.createCrumb({
|
|
192
|
-
to: config_1.default.componentsStylesMatchFile,
|
|
193
|
-
token: SWAP_TOKEN.styleImports,
|
|
194
|
-
});
|
|
195
|
-
const content = `${crumb1.join('\n')}\n`;
|
|
196
|
-
// update actual file
|
|
197
|
-
fs_1.promises.writeFile(config_1.default.componentsStylesMatchFile, content, {
|
|
198
|
-
encoding: 'utf-8',
|
|
199
|
-
})
|
|
200
|
-
.then(result => {
|
|
201
|
-
console.log('Done');
|
|
202
|
-
console.log(result);
|
|
203
|
-
return true;
|
|
204
|
-
})
|
|
205
|
-
.catch((err) => {
|
|
206
|
-
console.log('error, wtf ?');
|
|
207
|
-
console.log(err.message);
|
|
208
|
-
return false;
|
|
209
|
-
});
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
exports.StoryblokComponentsConfig = StoryblokComponentsConfig;
|
|
213
|
-
let fileContent;
|
|
214
|
-
try {
|
|
215
|
-
fileContent = require(path.resolve(process.cwd(), 'storyblok.components.lock.js'));
|
|
216
|
-
}
|
|
217
|
-
catch (err) {
|
|
218
|
-
fileContent = {};
|
|
219
|
-
}
|
|
220
|
-
exports.default = new StoryblokComponentsConfig(fileContent);
|
package/lib/config/config.d.ts
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
export interface IStoryblokConfig {
|
|
2
|
-
componentsMatchFile: string;
|
|
3
|
-
storyblokComponentsListfile: string;
|
|
4
|
-
storyblokComponentsLocalDirectory: string;
|
|
5
|
-
componentsStylesMatchFile: string;
|
|
6
|
-
boilerplateUrl: string;
|
|
7
|
-
sbmigWorkingDirectory: string;
|
|
8
|
-
componentDirectory: string;
|
|
9
|
-
datasourcesDirectory: string;
|
|
10
|
-
componentsDirectories: string[];
|
|
11
|
-
schemaFileExt: string;
|
|
12
|
-
datasourceExt: string;
|
|
13
|
-
rolesExt: string;
|
|
14
|
-
storyblokApiUrl: string;
|
|
15
|
-
oauthToken: string | undefined;
|
|
16
|
-
spaceId: string | undefined;
|
|
17
|
-
accessToken: string | undefined;
|
|
18
|
-
}
|
|
19
|
-
declare const _default: {
|
|
20
|
-
componentsMatchFile: string;
|
|
21
|
-
storyblokComponentsListfile: string;
|
|
22
|
-
storyblokComponentsLocalDirectory: string;
|
|
23
|
-
componentsStylesMatchFile: string;
|
|
24
|
-
boilerplateUrl: string;
|
|
25
|
-
sbmigWorkingDirectory: string;
|
|
26
|
-
componentDirectory: string;
|
|
27
|
-
datasourcesDirectory: string;
|
|
28
|
-
componentsDirectories: string[];
|
|
29
|
-
schemaFileExt: string;
|
|
30
|
-
datasourceExt: string;
|
|
31
|
-
rolesExt: string;
|
|
32
|
-
storyblokApiUrl: string;
|
|
33
|
-
oauthToken: string | undefined;
|
|
34
|
-
spaceId: string | undefined;
|
|
35
|
-
accessToken: string | undefined;
|
|
36
|
-
};
|
|
37
|
-
export default _default;
|
package/lib/config/config.js
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const path = require("path");
|
|
4
|
-
const dotenv = require("dotenv");
|
|
5
|
-
dotenv.config();
|
|
6
|
-
let customConfig = {};
|
|
7
|
-
try {
|
|
8
|
-
customConfig = require(path.resolve(process.cwd(), 'storyblok.config'));
|
|
9
|
-
}
|
|
10
|
-
catch (error) {
|
|
11
|
-
// default config will be used
|
|
12
|
-
if (error.code !== 'MODULE_NOT_FOUND')
|
|
13
|
-
throw error;
|
|
14
|
-
}
|
|
15
|
-
const defaultConfig = {
|
|
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
|
-
oauthToken: process.env.STORYBLOK_OAUTH_TOKEN,
|
|
30
|
-
spaceId: process.env.STORYBLOK_SPACE_ID,
|
|
31
|
-
accessToken: process.env.GATSBY_STORYBLOK_ACCESS_TOKEN || process.env.NEXT_STORYBLOK_ACCESS_TOKEN,
|
|
32
|
-
};
|
|
33
|
-
exports.default = {
|
|
34
|
-
...defaultConfig,
|
|
35
|
-
...customConfig,
|
|
36
|
-
};
|
package/lib/core.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import Command from '@oclif/command';
|
|
2
|
-
import { IStoryblokConfig } from './config/config';
|
|
3
|
-
import { StoryblokComponentsConfig } from './config/StoryblokComponentsConfig';
|
|
4
|
-
export default abstract class extends Command {
|
|
5
|
-
storyblokConfig(): IStoryblokConfig;
|
|
6
|
-
storyblokComponentsConfig(): StoryblokComponentsConfig;
|
|
7
|
-
files(): {
|
|
8
|
-
getCurrentDirectoryBase: () => string;
|
|
9
|
-
isDirectoryExists: (path: string) => boolean;
|
|
10
|
-
createDir: (dirPath: string) => Promise<void>;
|
|
11
|
-
createJsonFile: (content: string, pathWithFilename: string) => Promise<void>;
|
|
12
|
-
copyFolder: (src: string, dest: string) => Promise<unknown>;
|
|
13
|
-
copyFile: (src: string, dest: string) => Promise<void>;
|
|
14
|
-
};
|
|
15
|
-
api(): any;
|
|
16
|
-
}
|
package/lib/core.js
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const command_1 = require("@oclif/command");
|
|
4
|
-
const config_1 = require("./config/config");
|
|
5
|
-
const StoryblokComponentsConfig_1 = require("./config/StoryblokComponentsConfig");
|
|
6
|
-
const files_1 = require("./utils/files");
|
|
7
|
-
const discover_1 = require("./utils/discover");
|
|
8
|
-
const components_1 = require("./api/components");
|
|
9
|
-
const datasources_1 = require("./api/datasources");
|
|
10
|
-
const componentPresets_1 = require("./api/componentPresets");
|
|
11
|
-
const presets_1 = require("./api/presets");
|
|
12
|
-
const migrate_1 = require("./api/migrate");
|
|
13
|
-
const mutateComponents_1 = require("./api/mutateComponents");
|
|
14
|
-
const spaces_1 = require("./api/spaces");
|
|
15
|
-
class default_1 extends command_1.default {
|
|
16
|
-
storyblokConfig() {
|
|
17
|
-
return config_1.default;
|
|
18
|
-
}
|
|
19
|
-
storyblokComponentsConfig() {
|
|
20
|
-
return StoryblokComponentsConfig_1.default;
|
|
21
|
-
}
|
|
22
|
-
files() {
|
|
23
|
-
return {
|
|
24
|
-
getCurrentDirectoryBase: files_1.getCurrentDirectoryBase,
|
|
25
|
-
isDirectoryExists: files_1.isDirectoryExists,
|
|
26
|
-
createDir: files_1.createDir,
|
|
27
|
-
createJsonFile: files_1.createJsonFile,
|
|
28
|
-
copyFolder: files_1.copyFolder,
|
|
29
|
-
copyFile: files_1.copyFile,
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
api() {
|
|
33
|
-
return {
|
|
34
|
-
discover: {
|
|
35
|
-
findComponents: discover_1.findComponents,
|
|
36
|
-
findComponentsWithExt: discover_1.findComponentsWithExt,
|
|
37
|
-
findDatasources: discover_1.findDatasources,
|
|
38
|
-
},
|
|
39
|
-
datasources: {
|
|
40
|
-
getAllDatasources: datasources_1.getAllDatasources,
|
|
41
|
-
getDatasource: datasources_1.getDatasource,
|
|
42
|
-
getDatasourceEntries: datasources_1.getDatasourceEntries,
|
|
43
|
-
createDatasource: datasources_1.createDatasource,
|
|
44
|
-
createDatasourceEntry: datasources_1.createDatasourceEntry,
|
|
45
|
-
updateDatasourceEntry: datasources_1.updateDatasourceEntry,
|
|
46
|
-
updateDatasource: datasources_1.updateDatasource,
|
|
47
|
-
createDatasourceEntries: datasources_1.createDatasourceEntries,
|
|
48
|
-
syncDatasources: datasources_1.syncDatasources,
|
|
49
|
-
},
|
|
50
|
-
components: {
|
|
51
|
-
getAllComponents: components_1.getAllComponents,
|
|
52
|
-
getComponent: components_1.getComponent,
|
|
53
|
-
getComponentsGroup: components_1.getComponentsGroup,
|
|
54
|
-
getAllComponentsGroups: components_1.getAllComponentsGroups,
|
|
55
|
-
createComponentsGroup: components_1.createComponentsGroup,
|
|
56
|
-
syncComponents: migrate_1.syncComponents,
|
|
57
|
-
syncAllComponents: migrate_1.syncAllComponents,
|
|
58
|
-
updateComponent: mutateComponents_1.updateComponent,
|
|
59
|
-
createComponent: mutateComponents_1.createComponent,
|
|
60
|
-
},
|
|
61
|
-
presets: {
|
|
62
|
-
getComponentPresets: componentPresets_1.getComponentPresets,
|
|
63
|
-
getPreset: presets_1.getPreset,
|
|
64
|
-
getAllPresets: presets_1.getAllPresets,
|
|
65
|
-
createPreset: presets_1.createPreset,
|
|
66
|
-
updatePreset: presets_1.updatePreset,
|
|
67
|
-
},
|
|
68
|
-
spaces: {
|
|
69
|
-
createSpace: spaces_1.createSpace,
|
|
70
|
-
getSpace: spaces_1.getSpace,
|
|
71
|
-
},
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
exports.default = default_1;
|
package/lib/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { run } from "@oclif/command";
|
package/lib/index.js
DELETED
|
@@ -1,171 +0,0 @@
|
|
|
1
|
-
declare global {
|
|
2
|
-
interface StoryblokBridgeConfig {
|
|
3
|
-
initOnlyOnce?: boolean;
|
|
4
|
-
accessToken?: string;
|
|
5
|
-
}
|
|
6
|
-
interface StoryblokEventPayload<S extends StoryblokComponent<string> = any> {
|
|
7
|
-
action: 'customEvent' | 'published' | 'input' | 'change' | 'unpublished' | 'enterEditmode';
|
|
8
|
-
event?: string;
|
|
9
|
-
story?: S;
|
|
10
|
-
slug?: string;
|
|
11
|
-
storyId?: string;
|
|
12
|
-
reload?: boolean;
|
|
13
|
-
}
|
|
14
|
-
interface StoryblokBridge {
|
|
15
|
-
init: (config?: StoryblokBridgeConfig) => void;
|
|
16
|
-
pingEditor: (callback: (instance: StoryblokBridge) => void) => void;
|
|
17
|
-
isInEditor: () => boolean;
|
|
18
|
-
enterEditmode: () => void;
|
|
19
|
-
on: (event: 'customEvent' | 'published' | 'input' | 'change' | 'unpublished' | 'enterEditmode' | string[], callback: (payload?: StoryblokEventPayload) => void) => void;
|
|
20
|
-
addComments: (tree: StoryblokComponent<string>, storyId: string) => StoryblokComponent<string>;
|
|
21
|
-
}
|
|
22
|
-
interface Window {
|
|
23
|
-
storyblok: StoryblokBridge;
|
|
24
|
-
StoryblokCacheVersion: number;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
import { AxiosInstance, AxiosProxyConfig } from 'axios';
|
|
28
|
-
export interface StoryblokConfig {
|
|
29
|
-
accessToken?: string;
|
|
30
|
-
oauthToken?: string;
|
|
31
|
-
cache?: StoryblokCache;
|
|
32
|
-
timeout?: number;
|
|
33
|
-
headers?: any;
|
|
34
|
-
region?: string;
|
|
35
|
-
maxRetries?: number;
|
|
36
|
-
https?: boolean;
|
|
37
|
-
rateLimit?: number;
|
|
38
|
-
proxy?: AxiosProxyConfig;
|
|
39
|
-
componentResolver?: (component: string, data: any) => void;
|
|
40
|
-
}
|
|
41
|
-
export interface StoryblokCache {
|
|
42
|
-
type?: 'memory';
|
|
43
|
-
clear?: 'auto' | 'manual';
|
|
44
|
-
}
|
|
45
|
-
export interface StoryblokCacheProvider {
|
|
46
|
-
get: (key: string) => Promise<StoryblokResult | null> | (StoryblokResult | null);
|
|
47
|
-
set: (key: string, content: StoryblokResult) => Promise<void> | any;
|
|
48
|
-
flush: () => Promise<void> | void;
|
|
49
|
-
}
|
|
50
|
-
export interface StoryblokResult {
|
|
51
|
-
data: any;
|
|
52
|
-
perPage: number;
|
|
53
|
-
total: number;
|
|
54
|
-
headers: any;
|
|
55
|
-
}
|
|
56
|
-
export interface StoryblokManagmentApiResult {
|
|
57
|
-
data: any;
|
|
58
|
-
headers: any;
|
|
59
|
-
}
|
|
60
|
-
export interface StoryblokComponent<TComp extends string> {
|
|
61
|
-
_uid: string;
|
|
62
|
-
component: TComp;
|
|
63
|
-
_editable?: string;
|
|
64
|
-
}
|
|
65
|
-
export interface StoryData<Content = StoryblokComponent<string> & {
|
|
66
|
-
[index: string]: any;
|
|
67
|
-
}> {
|
|
68
|
-
content: Content;
|
|
69
|
-
created_at: string;
|
|
70
|
-
full_slug: string;
|
|
71
|
-
group_id: string;
|
|
72
|
-
id: number;
|
|
73
|
-
is_startpage: boolean;
|
|
74
|
-
meta_data: any;
|
|
75
|
-
name: string;
|
|
76
|
-
parent_id: number;
|
|
77
|
-
position: number;
|
|
78
|
-
published_at: string | null;
|
|
79
|
-
first_published_at: string | null;
|
|
80
|
-
slug: string;
|
|
81
|
-
sort_by_date: string | null;
|
|
82
|
-
tag_list: string[];
|
|
83
|
-
uuid: string;
|
|
84
|
-
}
|
|
85
|
-
export interface AlternateObject {
|
|
86
|
-
id: number;
|
|
87
|
-
name: string;
|
|
88
|
-
slug: string;
|
|
89
|
-
published: boolean;
|
|
90
|
-
full_slug: string;
|
|
91
|
-
is_folder: boolean;
|
|
92
|
-
parent_id: number;
|
|
93
|
-
}
|
|
94
|
-
export interface Stories {
|
|
95
|
-
data: {
|
|
96
|
-
stories: StoryData[];
|
|
97
|
-
};
|
|
98
|
-
perPage: number;
|
|
99
|
-
total: number;
|
|
100
|
-
headers: any;
|
|
101
|
-
}
|
|
102
|
-
export interface Story {
|
|
103
|
-
data: {
|
|
104
|
-
story: StoryData;
|
|
105
|
-
};
|
|
106
|
-
headers: any;
|
|
107
|
-
}
|
|
108
|
-
export interface StoriesParams {
|
|
109
|
-
token?: string;
|
|
110
|
-
with_tag?: string;
|
|
111
|
-
is_startpage?: 0 | 1;
|
|
112
|
-
starts_with?: string;
|
|
113
|
-
by_uuids?: string;
|
|
114
|
-
by_uuids_ordered?: string;
|
|
115
|
-
excluding_ids?: string;
|
|
116
|
-
excluding_fields?: string;
|
|
117
|
-
resolve_links?: 'url' | 'story' | '0' | '1';
|
|
118
|
-
version?: 'draft' | 'published';
|
|
119
|
-
resolve_relations?: string;
|
|
120
|
-
cv?: number;
|
|
121
|
-
sort_by?: string;
|
|
122
|
-
search_term?: string;
|
|
123
|
-
filter_query?: any;
|
|
124
|
-
per_page?: number;
|
|
125
|
-
page?: string;
|
|
126
|
-
from_release?: string;
|
|
127
|
-
fallback_language?: string;
|
|
128
|
-
first_published_at_gt?: string;
|
|
129
|
-
first_published_at_lt?: string;
|
|
130
|
-
published_at_gt?: string;
|
|
131
|
-
published_at_lt?: string;
|
|
132
|
-
}
|
|
133
|
-
export interface StoryParams {
|
|
134
|
-
token?: string;
|
|
135
|
-
find_by?: 'uuid';
|
|
136
|
-
version?: 'draft' | 'published';
|
|
137
|
-
resolve_links?: 'url' | 'story' | '0' | '1';
|
|
138
|
-
resolve_relations?: string;
|
|
139
|
-
cv?: number;
|
|
140
|
-
from_release?: string;
|
|
141
|
-
}
|
|
142
|
-
export interface Richtext {
|
|
143
|
-
content: Array<Object>;
|
|
144
|
-
}
|
|
145
|
-
export interface RichtextInstance {
|
|
146
|
-
render: (data: Richtext) => string;
|
|
147
|
-
}
|
|
148
|
-
declare class Storyblok {
|
|
149
|
-
throttle: any;
|
|
150
|
-
cacheVersion: number;
|
|
151
|
-
accessToken: string;
|
|
152
|
-
cache: StoryblokCache;
|
|
153
|
-
client: AxiosInstance;
|
|
154
|
-
richTextResolver: RichtextInstance;
|
|
155
|
-
constructor(config: StoryblokConfig, endpoint?: string);
|
|
156
|
-
get(slug: string, params?: any): Promise<StoryblokResult>;
|
|
157
|
-
getAll(slug: string, params?: any, entity?: string): Promise<any[]>;
|
|
158
|
-
post(slug: string, params?: any): Promise<StoryblokManagmentApiResult>;
|
|
159
|
-
put(slug: string, params?: any): Promise<StoryblokManagmentApiResult>;
|
|
160
|
-
delete(slug: string, params?: any): Promise<StoryblokManagmentApiResult>;
|
|
161
|
-
getStories(params?: StoriesParams): Promise<Stories>;
|
|
162
|
-
getStory(slug: string, params?: StoryParams): Promise<Story>;
|
|
163
|
-
setToken(token: string): void;
|
|
164
|
-
getToken(): string;
|
|
165
|
-
cacheResponse(url: string, params: any): Promise<StoryblokResult>;
|
|
166
|
-
newVersion(): number;
|
|
167
|
-
cacheProvider(): StoryblokCacheProvider;
|
|
168
|
-
flushCache(): Promise<this>;
|
|
169
|
-
setComponentResolver(renderFunction: (component: string, data: any) => void): void;
|
|
170
|
-
}
|
|
171
|
-
export default Storyblok;
|
package/lib/utils/discover.d.ts
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
export declare const findComponents: (componentDirectory: string) => any[];
|
|
2
|
-
export declare const findComponentsWithExt: (ext: string | boolean) => any[];
|
|
3
|
-
export declare const findComponentsByPackageName: (ext: string | boolean, specifiedComponents: string[], local?: boolean | undefined) => any[];
|
|
4
|
-
export declare const findDatasources: () => any[];
|
package/lib/utils/discover.js
DELETED
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// component resolution file borrowed from great storyblok-migrate
|
|
3
|
-
// https://github.com/maoberlehner/storyblok-migrate
|
|
4
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
-
exports.findDatasources = exports.findComponentsByPackageName = exports.findComponentsWithExt = exports.findComponents = void 0;
|
|
6
|
-
const glob = require("glob");
|
|
7
|
-
const path = require("path");
|
|
8
|
-
const config_1 = require("../config/config");
|
|
9
|
-
const findComponents = (componentDirectory) => {
|
|
10
|
-
const directory = path.resolve(process.cwd(), componentDirectory);
|
|
11
|
-
return glob
|
|
12
|
-
.sync(path.join(directory, '**', '!(_*|*.datasource)*.js'))
|
|
13
|
-
.map(file => require(path.resolve(directory, file)));
|
|
14
|
-
};
|
|
15
|
-
exports.findComponents = findComponents;
|
|
16
|
-
const findComponentsWithExt = (ext) => {
|
|
17
|
-
const rootDirectory = './';
|
|
18
|
-
const directory = path.resolve(process.cwd(), rootDirectory);
|
|
19
|
-
const files = glob
|
|
20
|
-
.sync(path.join(`${directory}/{${config_1.default.componentsDirectories.join(',')}}`, '**', `[^_]*.${ext}`), {
|
|
21
|
-
follow: true,
|
|
22
|
-
})
|
|
23
|
-
.map(file => require(path.resolve(directory, file)));
|
|
24
|
-
const fileNames = files.map(file => file.name);
|
|
25
|
-
return files;
|
|
26
|
-
};
|
|
27
|
-
exports.findComponentsWithExt = findComponentsWithExt;
|
|
28
|
-
const findComponentsByPackageName = (ext, specifiedComponents, local) => {
|
|
29
|
-
const rootDirectory = './';
|
|
30
|
-
const directory = path.resolve(process.cwd(), rootDirectory);
|
|
31
|
-
// @ts-ignore
|
|
32
|
-
if (local === true) {
|
|
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'), {
|
|
35
|
-
follow: true,
|
|
36
|
-
});
|
|
37
|
-
return onlyLocalPackages
|
|
38
|
-
.filter(file => {
|
|
39
|
-
return specifiedComponents.includes(require(path.resolve(directory, file)).name);
|
|
40
|
-
})
|
|
41
|
-
.map(file => {
|
|
42
|
-
const fileFolderPath = file.split('/').slice(0, -1).join('/');
|
|
43
|
-
return glob
|
|
44
|
-
.sync(path.join(`${fileFolderPath}`, '**', `[^_]*.${ext}`), {
|
|
45
|
-
follow: true,
|
|
46
|
-
})
|
|
47
|
-
.map(file => require(path.resolve(directory, file)).name);
|
|
48
|
-
})
|
|
49
|
-
.flat();
|
|
50
|
-
}
|
|
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'), {
|
|
54
|
-
follow: true,
|
|
55
|
-
});
|
|
56
|
-
return onlyNodeModulesPackages
|
|
57
|
-
.filter(file => {
|
|
58
|
-
return specifiedComponents.includes(require(path.resolve(directory, file)).name);
|
|
59
|
-
})
|
|
60
|
-
.map(file => {
|
|
61
|
-
const fileFolderPath = file.split('/').slice(0, -1).join('/');
|
|
62
|
-
return glob
|
|
63
|
-
.sync(path.join(`${fileFolderPath}`, '**', `[^_]*.${ext}`), {
|
|
64
|
-
follow: true,
|
|
65
|
-
})
|
|
66
|
-
.map(file => require(path.resolve(directory, file)).name);
|
|
67
|
-
})
|
|
68
|
-
.flat();
|
|
69
|
-
}
|
|
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('/');
|
|
79
|
-
return glob
|
|
80
|
-
.sync(path.join(`${fileFolderPath}`, '**', `[^_]*.${ext}`), {
|
|
81
|
-
follow: true,
|
|
82
|
-
})
|
|
83
|
-
.map(file => require(path.resolve(directory, file)).name);
|
|
84
|
-
})
|
|
85
|
-
.flat();
|
|
86
|
-
};
|
|
87
|
-
exports.findComponentsByPackageName = findComponentsByPackageName;
|
|
88
|
-
const findDatasources = () => {
|
|
89
|
-
const rootDirectory = './';
|
|
90
|
-
const directory = path.resolve(process.cwd(), rootDirectory);
|
|
91
|
-
return (glob
|
|
92
|
-
.sync(path.join(`${directory}/${config_1.default.datasourcesDirectory}`, '**', '[^_]*.sb.datasource.js'))
|
|
93
|
-
// eslint-disable-next-line global-require, import/no-dynamic-require
|
|
94
|
-
.map(file => require(path.resolve(directory, file))));
|
|
95
|
-
};
|
|
96
|
-
exports.findDatasources = findDatasources;
|