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.
Files changed (81) hide show
  1. package/README.md +107 -471
  2. package/dist/api/componentPresets.d.ts +1 -0
  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 -57
  45. package/CHANGELOG.md +0 -996
  46. package/bin/run +0 -5
  47. package/bin/run.cmd +0 -3
  48. package/lib/api/apiConfig.d.ts +0 -2
  49. package/lib/api/apiConfig.js +0 -9
  50. package/lib/api/componentPresets.d.ts +0 -1
  51. package/lib/api/componentPresets.js +0 -22
  52. package/lib/api/components.js +0 -71
  53. package/lib/api/datasources.js +0 -193
  54. package/lib/api/migrate.d.ts +0 -19
  55. package/lib/api/migrate.js +0 -220
  56. package/lib/api/mutateComponents.js +0 -50
  57. package/lib/api/presets.js +0 -59
  58. package/lib/api/roles.js +0 -133
  59. package/lib/api/spaces.d.ts +0 -2
  60. package/lib/api/spaces.js +0 -29
  61. package/lib/commands/backup.d.ts +0 -22
  62. package/lib/commands/backup.js +0 -217
  63. package/lib/commands/debug.d.ts +0 -9
  64. package/lib/commands/debug.js +0 -21
  65. package/lib/commands/sync.d.ts +0 -26
  66. package/lib/commands/sync.js +0 -93
  67. package/lib/config/StoryblokComponentsConfig.d.ts +0 -68
  68. package/lib/config/StoryblokComponentsConfig.js +0 -220
  69. package/lib/config/config.d.ts +0 -37
  70. package/lib/config/config.js +0 -36
  71. package/lib/core.d.ts +0 -16
  72. package/lib/core.js +0 -75
  73. package/lib/index.d.ts +0 -1
  74. package/lib/index.js +0 -5
  75. package/lib/types/storyblokTypes.d.ts +0 -171
  76. package/lib/types/storyblokTypes.js +0 -3
  77. package/lib/utils/discover.d.ts +0 -4
  78. package/lib/utils/discover.js +0 -96
  79. package/lib/utils/files.js +0 -54
  80. package/lib/utils/others.js +0 -5
  81. package/oclif.manifest.json +0 -1
package/lib/api/roles.js DELETED
@@ -1,133 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.syncProvidedRoles = exports.syncAllRoles = exports.syncRoles = exports.getRole = exports.getAllRoles = exports.updateRole = exports.createRole = void 0;
4
- const logger_1 = require("../utils/logger");
5
- const config_1 = require("../config/config");
6
- const apiConfig_1 = require("./apiConfig");
7
- const discover2_1 = require("../utils/discover2");
8
- const { spaceId } = config_1.default;
9
- // POST
10
- const createRole = (role) => {
11
- apiConfig_1.sbApi
12
- .post(`spaces/${spaceId}/space_roles/`, {
13
- space_role: role,
14
- })
15
- .then(res => {
16
- logger_1.default.success(`Role '${role.role}' has been created.`);
17
- })
18
- .catch(err => {
19
- logger_1.default.error('error happened... :(');
20
- console.log(`${err.message} in migration of ${role.role} in createRole function`);
21
- });
22
- };
23
- exports.createRole = createRole;
24
- // PUT
25
- const updateRole = (role) => {
26
- apiConfig_1.sbApi
27
- .put(`spaces/${spaceId}/space_roles/${role.id}`, {
28
- space_role: role,
29
- })
30
- .then(res => {
31
- logger_1.default.success(`Role '${role.role}' has been updated.`);
32
- })
33
- .catch(err => {
34
- logger_1.default.error('error happened... :(');
35
- console.log(`${err.message} in migration of ${role.role} in updateRole function`);
36
- });
37
- };
38
- exports.updateRole = updateRole;
39
- // GET
40
- const getAllRoles = async () => {
41
- return apiConfig_1.sbApi
42
- .get(`spaces/${spaceId}/space_roles/`)
43
- .then(({ data }) => data)
44
- .catch(err => {
45
- if (err.response.status === 404) {
46
- logger_1.default.error(`There is no roles in your Storyblok ${spaceId} space.`);
47
- }
48
- else {
49
- logger_1.default.error(err);
50
- return false;
51
- }
52
- });
53
- };
54
- exports.getAllRoles = getAllRoles;
55
- // GET
56
- const getRole = async (roleName) => {
57
- logger_1.default.log(`Trying to get '${roleName}' role.`);
58
- return (0, exports.getAllRoles)()
59
- .then(res => res.space_roles.filter((role) => role.role === roleName))
60
- .then(res => {
61
- if (Array.isArray(res) && res.length === 0) {
62
- logger_1.default.warning(`There is no role named '${roleName}'`);
63
- return false;
64
- }
65
- return res;
66
- })
67
- .catch(err => logger_1.default.error(err));
68
- };
69
- exports.getRole = getRole;
70
- const syncRoles = async ({ specifiedRoles }) => {
71
- const specifiedRolesContent = specifiedRoles.map(roles => (0, discover2_1.getFileContent)({ file: roles.path }));
72
- const { space_roles } = await (0, exports.getAllRoles)();
73
- const rolesToUpdate = [];
74
- const rolesToCreate = [];
75
- for (const role of specifiedRolesContent) {
76
- const shouldBeUpdated = space_roles.find((remoteRole) => role.role === remoteRole.role);
77
- if (shouldBeUpdated) {
78
- rolesToUpdate.push({ id: shouldBeUpdated.id, ...role });
79
- }
80
- else {
81
- rolesToCreate.push(role);
82
- }
83
- }
84
- rolesToUpdate.map(async (role) => {
85
- await (0, exports.updateRole)(role);
86
- });
87
- rolesToCreate.map(async (role) => {
88
- await (0, exports.createRole)(role);
89
- });
90
- };
91
- exports.syncRoles = syncRoles;
92
- const syncAllRoles = async () => {
93
- // #1: discover all external .roles.sb.js files
94
- const allLocalSbComponentsSchemaFiles = (0, discover2_1.discoverRoles)({
95
- scope: discover2_1.SCOPE.local,
96
- type: discover2_1.LOOKUP_TYPE.fileName,
97
- });
98
- // #2: discover all local .roles.sb.js files
99
- const allExternalSbComponentsSchemaFiles = (0, discover2_1.discoverRoles)({
100
- scope: discover2_1.SCOPE.external,
101
- type: discover2_1.LOOKUP_TYPE.fileName,
102
- });
103
- // #3: compare results, prefare local ones (so we have to create final external paths array and local array of things to sync from where)
104
- const { local, external } = (0, discover2_1.compare)({
105
- local: allLocalSbComponentsSchemaFiles,
106
- external: allExternalSbComponentsSchemaFiles,
107
- });
108
- // #4: sync - do all stuff already done (groups resolving, and so on)
109
- (0, exports.syncRoles)({ specifiedRoles: [...local, ...external] });
110
- };
111
- exports.syncAllRoles = syncAllRoles;
112
- const syncProvidedRoles = ({ roles }) => {
113
- // #1: discover all external .sb.js files
114
- const allLocalSbComponentsSchemaFiles = (0, discover2_1.discoverManyRoles)({
115
- scope: discover2_1.SCOPE.local,
116
- type: discover2_1.LOOKUP_TYPE.fileName,
117
- fileNames: roles,
118
- });
119
- // #2: discover all local .sb.js files
120
- const allExternalSbComponentsSchemaFiles = (0, discover2_1.discoverManyRoles)({
121
- scope: discover2_1.SCOPE.external,
122
- type: discover2_1.LOOKUP_TYPE.fileName,
123
- fileNames: roles,
124
- });
125
- // #3: compare results, prefer local ones (so we have to create final external paths array and local array of things to sync from where)
126
- const { local, external } = (0, discover2_1.compare)({
127
- local: allLocalSbComponentsSchemaFiles,
128
- external: allExternalSbComponentsSchemaFiles,
129
- });
130
- // #4: sync - do all stuff already done (groups resolving, and so on)
131
- (0, exports.syncRoles)({ specifiedRoles: [...local, ...external] });
132
- };
133
- exports.syncProvidedRoles = syncProvidedRoles;
@@ -1,2 +0,0 @@
1
- export declare const createSpace: (spaceName: string) => Promise<void | import("../types/storyblokTypes").StoryblokManagmentApiResult>;
2
- export declare const getSpace: (spaceId: string) => Promise<import("../types/storyblokTypes").StoryblokResult>;
package/lib/api/spaces.js DELETED
@@ -1,29 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getSpace = exports.createSpace = void 0;
4
- const logger_1 = require("../utils/logger");
5
- const apiConfig_1 = require("./apiConfig");
6
- // CREATE
7
- const createSpace = (spaceName) => {
8
- logger_1.default.warning(`Trying to create space ${spaceName}...`);
9
- return apiConfig_1.sbApi
10
- .post('spaces/', {
11
- space: {
12
- name: spaceName,
13
- domain: 'http://localhost:8000/editor?path=',
14
- },
15
- })
16
- .then(res => {
17
- return res;
18
- })
19
- .catch(err => {
20
- logger_1.default.error('Error happened. Can\'t create space');
21
- console.log(err.message);
22
- });
23
- };
24
- exports.createSpace = createSpace;
25
- // GET
26
- const getSpace = (spaceId) => {
27
- return apiConfig_1.sbApi.get(`spaces/${spaceId}`).then(res => res);
28
- };
29
- exports.getSpace = getSpace;
@@ -1,22 +0,0 @@
1
- import { flags } from '@oclif/command';
2
- import Command from '../core';
3
- export default class Backup extends Command {
4
- static description: string;
5
- static flags: {
6
- help: import("@oclif/parser/lib/flags").IBooleanFlag<void>;
7
- allComponents: import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
8
- oneComponent: flags.IOptionFlag<string | undefined>;
9
- allComponentsGroups: import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
10
- oneComponentsGroup: flags.IOptionFlag<string | undefined>;
11
- oneComponentPresets: flags.IOptionFlag<string | undefined>;
12
- allPresets: import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
13
- onePreset: flags.IOptionFlag<string | undefined>;
14
- allDatasources: import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
15
- oneDatasource: flags.IOptionFlag<string | undefined>;
16
- datasourceEntries: flags.IOptionFlag<string | undefined>;
17
- allRoles: import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
18
- oneRole: flags.IOptionFlag<string | undefined>;
19
- };
20
- static args: never[];
21
- run(): Promise<boolean | void>;
22
- }
@@ -1,217 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const command_1 = require("@oclif/command");
4
- const core_1 = require("../core");
5
- const config_1 = require("../config/config");
6
- const components_1 = require("../api/components");
7
- const datasources_1 = require("../api/datasources");
8
- const componentPresets_1 = require("../api/componentPresets");
9
- const presets_1 = require("../api/presets");
10
- const logger_1 = require("../utils/logger");
11
- const files_1 = require("../utils/files");
12
- const others_1 = require("../utils/others");
13
- const roles_1 = require("../api/roles");
14
- class Backup extends core_1.default {
15
- // static strict = false;
16
- async run() {
17
- const { args, flags, argv } = this.parse(Backup);
18
- // Backup one role as json file
19
- if (flags.oneRole) {
20
- console.log('oneRole argument: ', flags.oneRole);
21
- return (0, roles_1.getRole)(flags.oneRole).then(async (res) => {
22
- if (res) {
23
- const datestamp = new Date();
24
- const filename = `role-${flags.oneRole}-${(0, others_1.generateDatestamp)(datestamp)}`;
25
- await (0, files_1.createDir)(`${config_1.default.sbmigWorkingDirectory}/roles/`);
26
- await (0, files_1.createJsonFile)(JSON.stringify(res, undefined, 2), `${config_1.default.sbmigWorkingDirectory}/roles/${filename}.json`);
27
- logger_1.default.success(`Role for ${flags.oneRole} written to a file: ${filename}`);
28
- }
29
- })
30
- .catch((err) => {
31
- console.log(err);
32
- this.error('error happened... :(');
33
- });
34
- }
35
- // Backup all roles and permission as json file
36
- if (flags.allRoles) {
37
- return (0, roles_1.getAllRoles)()
38
- .then(async (res) => {
39
- const datestamp = new Date();
40
- const filename = `all-roles-${(0, others_1.generateDatestamp)(datestamp)}`;
41
- await (0, files_1.createDir)(`${config_1.default.sbmigWorkingDirectory}/roles/`);
42
- await (0, files_1.createJsonFile)(JSON.stringify(res, undefined, 2), `${config_1.default.sbmigWorkingDirectory}/roles/${filename}.json`);
43
- logger_1.default.success(`All roles written to a file: ${filename}`);
44
- return true;
45
- })
46
- .catch((err) => {
47
- console.log(err);
48
- this.error('error happened... :(');
49
- });
50
- }
51
- // Backup all components as json file
52
- if (flags.allComponents) {
53
- return (0, components_1.getAllComponents)()
54
- .then(async (res) => {
55
- const datestamp = new Date();
56
- const filename = `all-components-${(0, others_1.generateDatestamp)(datestamp)}`;
57
- await (0, files_1.createDir)(`${config_1.default.sbmigWorkingDirectory}/components/`);
58
- await (0, files_1.createJsonFile)(JSON.stringify(res, undefined, 2), `${config_1.default.sbmigWorkingDirectory}/components/${filename}.json`);
59
- logger_1.default.success(`All components written to a file: ${filename}`);
60
- return true;
61
- })
62
- .catch((err) => {
63
- console.log(err);
64
- this.error('error happened... :(');
65
- });
66
- }
67
- // Backup one component as json file
68
- if (flags.oneComponent) {
69
- return (0, components_1.getComponent)(flags.oneComponent).then(async (res) => {
70
- if (res) {
71
- const datestamp = new Date();
72
- const filename = `component-${flags.oneComponent}-${(0, others_1.generateDatestamp)(datestamp)}`;
73
- await (0, files_1.createDir)(`${config_1.default.sbmigWorkingDirectory}/components/`);
74
- await (0, files_1.createJsonFile)(JSON.stringify(res, undefined, 2), `${config_1.default.sbmigWorkingDirectory}/components/${filename}.json`);
75
- logger_1.default.success(`Component for ${flags.oneComponent} written to a file: ${filename}`);
76
- }
77
- })
78
- .catch((err) => {
79
- console.log(err);
80
- this.error('error happened... :(');
81
- });
82
- }
83
- if (flags.allComponentsGroups) {
84
- return (0, components_1.getAllComponentsGroups)().then(async (res) => {
85
- const datestamp = new Date();
86
- const filename = `all-component_groups-${(0, others_1.generateDatestamp)(datestamp)}`;
87
- await (0, files_1.createDir)(`${config_1.default.sbmigWorkingDirectory}/component_groups/`);
88
- await (0, files_1.createJsonFile)(JSON.stringify(res, undefined, 2), `${config_1.default.sbmigWorkingDirectory}/component_groups/${filename}.json`);
89
- logger_1.default.success(`All groups written to a file: ${filename}`);
90
- })
91
- .catch((err) => {
92
- console.log(err);
93
- this.error('error happened... :(');
94
- });
95
- }
96
- if (flags.oneComponentsGroup) {
97
- return (0, components_1.getComponentsGroup)(flags.oneComponentsGroup).then(async (res) => {
98
- if (res) {
99
- const datestamp = new Date();
100
- const filename = `components_group-${flags.oneComponentsGroup}-${(0, others_1.generateDatestamp)(datestamp)}`;
101
- await (0, files_1.createDir)(`${config_1.default.sbmigWorkingDirectory}/component_groups/`);
102
- await (0, files_1.createJsonFile)(JSON.stringify(res, undefined, 2), `${config_1.default.sbmigWorkingDirectory}/component_groups/${filename}.json`);
103
- logger_1.default.success(`Components group for ${flags.oneComponentsGroup} written to a file: ${filename}`);
104
- }
105
- })
106
- .catch((err) => {
107
- console.log(err);
108
- this.error('error happened... :(');
109
- });
110
- }
111
- if (flags.allDatasources) {
112
- return (0, datasources_1.getAllDatasources)().then(async (res) => {
113
- const datestamp = new Date();
114
- const filename = `all-datasources-${(0, others_1.generateDatestamp)(datestamp)}`;
115
- await (0, files_1.createDir)(`${config_1.default.sbmigWorkingDirectory}/datasources/`);
116
- await (0, files_1.createJsonFile)(JSON.stringify(res, undefined, 2), `${config_1.default.sbmigWorkingDirectory}/datasources/${filename}.json`);
117
- logger_1.default.success(`All datasources written to a file: ${filename}`);
118
- })
119
- .catch((err) => {
120
- console.log(err);
121
- this.error('error happened... :(');
122
- });
123
- }
124
- if (flags.oneDatasource) {
125
- return (0, datasources_1.getDatasource)(flags.oneDatasource).then(async (res) => {
126
- if (res) {
127
- const datestamp = new Date();
128
- const filename = `datasource-${flags.oneDatasource}-${(0, others_1.generateDatestamp)(datestamp)}`;
129
- await (0, files_1.createDir)(`${config_1.default.sbmigWorkingDirectory}/datasources/`);
130
- await (0, files_1.createJsonFile)(JSON.stringify(res, undefined, 2), `${config_1.default.sbmigWorkingDirectory}/datasources/${filename}.json`);
131
- logger_1.default.success(`Datasource for ${flags.oneDatasource} written to a file: ${filename}`);
132
- }
133
- })
134
- .catch((err) => {
135
- console.log(err);
136
- this.error('error happened... :(');
137
- });
138
- }
139
- if (flags.datasourceEntries) {
140
- return (0, datasources_1.getDatasourceEntries)(flags.datasourceEntries).then(async (res) => {
141
- if (res) {
142
- const datestamp = new Date();
143
- const filename = `datasource-entries-${flags.datasourceEntries}-${(0, others_1.generateDatestamp)(datestamp)}`;
144
- await (0, files_1.createDir)(`${config_1.default.sbmigWorkingDirectory}/datasources/`);
145
- await (0, files_1.createJsonFile)(JSON.stringify(res, undefined, 2), `${config_1.default.sbmigWorkingDirectory}/datasources/${filename}.json`);
146
- logger_1.default.success(`Datasource entries for ${flags.datasourceEntries} written to a file: ${filename}`);
147
- }
148
- })
149
- .catch((err) => {
150
- console.log(err);
151
- this.error('error happened... :(');
152
- });
153
- }
154
- if (flags.oneComponentPresets) {
155
- return (0, componentPresets_1.getComponentPresets)(flags.oneComponentPresets).then(async (res) => {
156
- if (res) {
157
- const datestamp = new Date();
158
- const filename = `component-${flags.oneComponentPresets}-${(0, others_1.generateDatestamp)(datestamp)}`;
159
- await (0, files_1.createDir)(`${config_1.default.sbmigWorkingDirectory}/component-presets/`);
160
- await (0, files_1.createJsonFile)(JSON.stringify(res, undefined, 2), `${config_1.default.sbmigWorkingDirectory}/component-presets/${filename}.json`);
161
- logger_1.default.success(`Presets for ${flags.oneComponentPresets} written to a file: ${filename}`);
162
- }
163
- })
164
- .catch((err) => {
165
- console.log(err);
166
- this.error('error happened... :(');
167
- });
168
- }
169
- if (flags.allPresets) {
170
- return (0, presets_1.getAllPresets)().then(async (res) => {
171
- const datestamp = new Date();
172
- const filename = `all-presets-${(0, others_1.generateDatestamp)(datestamp)}`;
173
- await (0, files_1.createDir)(`${config_1.default.sbmigWorkingDirectory}/presets/`);
174
- await (0, files_1.createJsonFile)(JSON.stringify(res, undefined, 2), `${config_1.default.sbmigWorkingDirectory}/presets/${filename}.json`);
175
- logger_1.default.success(`All presets written to a file: ${filename}`);
176
- })
177
- .catch((err) => {
178
- console.log(err);
179
- this.error('error happened... :(');
180
- });
181
- }
182
- if (flags.onePreset) {
183
- return (0, presets_1.getPreset)(flags.onePreset).then(async (res) => {
184
- if (res) {
185
- const datestamp = new Date();
186
- const filename = `preset-${flags.onePreset}-${(0, others_1.generateDatestamp)(datestamp)}`;
187
- await (0, files_1.createDir)(`${config_1.default.sbmigWorkingDirectory}/presets/`);
188
- await (0, files_1.createJsonFile)(JSON.stringify(res, undefined, 2), `${config_1.default.sbmigWorkingDirectory}/presets/${filename}.json`);
189
- logger_1.default.success(`Preset for '${flags.onePreset}' have been written to a file: ${filename}`);
190
- }
191
- })
192
- .catch((err) => {
193
- console.log(err);
194
- this.error('error happened... :(');
195
- });
196
- }
197
- this.exit();
198
- }
199
- }
200
- exports.default = Backup;
201
- Backup.description = 'Command for backing up anything related to Storyblok';
202
- Backup.flags = {
203
- help: command_1.flags.help({ char: 'h' }),
204
- allComponents: command_1.flags.boolean({ char: 'a', description: 'Backup all components.' }),
205
- oneComponent: command_1.flags.string({ char: 'o', description: 'Backup one component by name.' }),
206
- allComponentsGroups: command_1.flags.boolean({ char: 'g', description: 'Backup all components groups.' }),
207
- oneComponentsGroup: command_1.flags.string({ char: 'f', description: 'Backup one components group by name.' }),
208
- oneComponentPresets: command_1.flags.string({ char: 'p', description: 'Backup all presets for one component' }),
209
- allPresets: command_1.flags.boolean({ char: 'l', description: 'Backup all presets.' }),
210
- onePreset: command_1.flags.string({ char: 'i', description: 'Backup one preset by id.' }),
211
- allDatasources: command_1.flags.boolean({ char: 'd', description: 'Backup all datasources.' }),
212
- oneDatasource: command_1.flags.string({ char: 'x', description: 'Backup one datasource by name.' }),
213
- datasourceEntries: command_1.flags.string({ char: 'e', description: 'Backup one datasource entries by datasource name.' }),
214
- allRoles: command_1.flags.boolean({ char: 'R', description: 'Backup all roles and permissions.' }),
215
- oneRole: command_1.flags.string({ char: 'r', description: 'Backup one role by name.' }),
216
- };
217
- Backup.args = [];
@@ -1,9 +0,0 @@
1
- import Command from '../core';
2
- export default class Debug extends Command {
3
- static description: string;
4
- static flags: {
5
- help: import("@oclif/parser/lib/flags").IBooleanFlag<void>;
6
- };
7
- static args: never[];
8
- run(): Promise<void>;
9
- }
@@ -1,21 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const command_1 = require("@oclif/command");
4
- const core_1 = require("../core");
5
- // TODO: implement --verbose flag to be available in every command
6
- class Debug extends core_1.default {
7
- async run() {
8
- const { args, flags } = this.parse(Debug);
9
- const config = this.storyblokConfig();
10
- const componentsConfig = this.storyblokComponentsConfig().getAllData();
11
- console.log('Thius are changes!');
12
- console.log('storyblok.config.js: ', config, '\n');
13
- console.log('storyblok.components.lock.js: ', componentsConfig);
14
- }
15
- }
16
- exports.default = Debug;
17
- Debug.description = 'Output extra debugging';
18
- Debug.flags = {
19
- help: command_1.flags.help({ char: 'h' }),
20
- };
21
- Debug.args = [];
@@ -1,26 +0,0 @@
1
- import Command from '../core';
2
- export default class Sync extends Command {
3
- static description: string;
4
- static examples: string[];
5
- static flags: {
6
- help: import("@oclif/parser/lib/flags").IBooleanFlag<void>;
7
- all: import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
8
- ext: import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
9
- packageName: import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
10
- presets: import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
11
- lock: import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
12
- };
13
- static strict: boolean;
14
- static args: ({
15
- name: string;
16
- description: string;
17
- options: string[];
18
- required: boolean;
19
- } | {
20
- name: string;
21
- description: string;
22
- options?: undefined;
23
- required?: undefined;
24
- })[];
25
- run(): Promise<void>;
26
- }
@@ -1,93 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const command_1 = require("@oclif/command");
4
- const core_1 = require("../core");
5
- const config_1 = require("../config/config");
6
- const logger_1 = require("../utils/logger");
7
- const migrate_1 = require("../api/migrate");
8
- const datasources_1 = require("../api/datasources");
9
- const roles_1 = require("../api/roles");
10
- class Sync extends core_1.default {
11
- async run() {
12
- const { argv, args, flags } = this.parse(Sync);
13
- const components = argv.splice(1, argv.length);
14
- if (args.type === 'roles' && flags.all && flags.ext) {
15
- logger_1.default.log('Syncing all roles...');
16
- (0, roles_1.syncAllRoles)();
17
- }
18
- if (args.type === 'roles' && !flags.all && flags.ext) {
19
- const roles = components;
20
- logger_1.default.log('Syncing provided roles...');
21
- (0, roles_1.syncProvidedRoles)({ roles });
22
- }
23
- if (args.type === 'components' && flags.all && flags.ext) {
24
- logger_1.default.log(`Syncing all components with ${config_1.default.schemaFileExt} extension...`);
25
- (0, migrate_1.sync2AllComponents)({ presets: flags.presets });
26
- }
27
- if (args.type === 'components' && flags.all && !flags.ext) {
28
- logger_1.default.warning('### DEPRECATED method. Method of syncing files without .sb.js extension, will be removed in version 4.0.0 ###');
29
- logger_1.default.warning('Use sb-mig sync components --all --ext instead (you need to update your schema files to be named with .sb.js extension)');
30
- logger_1.default.log(`Syncing all components from ${config_1.default.componentDirectory} directory...`);
31
- (0, migrate_1.syncAllComponents)(Boolean(flags.ext), Boolean(flags.presets));
32
- }
33
- if (args.type === 'components' && !flags.all && flags.ext) {
34
- logger_1.default.log(`Syncing provided components with ${config_1.default.schemaFileExt} extension...`);
35
- if (components.length === 0) {
36
- logger_1.default.warning('You have to provide some components separated with empty space. For exmaple: \'row column card\'');
37
- }
38
- else {
39
- (0, migrate_1.syncProvidedComponents)({ components, presets: Boolean(flags.presets), packageName: flags.packageName });
40
- }
41
- }
42
- if (args.type === 'components' && !flags.all && !flags.ext && !flags.lock) {
43
- logger_1.default.warning('### DEPRECATED method. Method of syncing files without .sb.js extension, will be removed in version 4.0.0 ###');
44
- logger_1.default.warning('Use sb-mig sync components --ext instead (you need to update your schema files to be named with .sb.js extension)');
45
- logger_1.default.log('Syncing provided components...');
46
- if (components.length === 0) {
47
- logger_1.default.warning('You have to provide some components separated with empty space. For exmaple: \'row column card\'');
48
- }
49
- else {
50
- (0, migrate_1.syncComponents)(components, Boolean(flags.ext), Boolean(flags.presets), flags.packageName);
51
- }
52
- }
53
- if (args.type === 'datasources' && flags.all && !flags.ext) {
54
- this.error('Datasources are only synced while using --ext optioon. use sb-mig sync datasources --all --ext to sync all datasources with extension (default: .sb.datasources.js)');
55
- }
56
- if (args.type === 'datasources' && !flags.all && !flags.ext) {
57
- const datasources = components;
58
- this.error(`Datasources are only synced while using --ext optioon. use sb-mig sync datasources ${datasources.join(' ')} --ext to sync provided datasources with extension (default: .sb.datasources.js)`);
59
- }
60
- if (args.type === 'datasources' && flags.all && flags.ext) {
61
- logger_1.default.log('Syncing all datasources with extension...');
62
- (0, datasources_1.syncAllDatasources)();
63
- }
64
- if (args.type === 'datasources' && !flags.all && flags.ext) {
65
- const datasources = components;
66
- logger_1.default.log('Syncing provided datasources with extension...');
67
- (0, datasources_1.syncProvidedDatasources)({ datasources });
68
- }
69
- }
70
- }
71
- exports.default = Sync;
72
- Sync.description = 'Synchronize components, datasources or roles with Storyblok space.';
73
- Sync.examples = [
74
- '$ sb-mig sync components --all --ext',
75
- '$ sb-mig sync components @storyblok-components/text-block --ext --packageName',
76
- '$ sb-mig sync components @storyblok-components/text-block @storyblok-components/button --ext --packageName',
77
- '$ sb-mig sync components text-block button --ext',
78
- '$ sb-mig sync components text-block button',
79
- '$ sb-mig sync roles',
80
- ];
81
- Sync.flags = {
82
- help: command_1.flags.help({ char: 'h' }),
83
- all: command_1.flags.boolean({ char: 'a', description: 'Synchronize all components.' }),
84
- ext: command_1.flags.boolean({ char: 'e', description: "Synchronize with file extension. Default extension: '.sb.js'" }),
85
- packageName: command_1.flags.boolean({ char: 'n', description: 'Synchronize based on installed package name.' }),
86
- presets: command_1.flags.boolean({ char: 'p', description: 'Synchronize components with presets.' }),
87
- lock: command_1.flags.boolean({ char: 'l', description: 'Synchronize based on storyblok.components.lock.js file' }),
88
- };
89
- Sync.strict = false;
90
- Sync.args = [
91
- { name: 'type', description: 'What to synchronize', options: ['components', 'datasources', 'roles'], required: true },
92
- { name: 'list', description: 'Space separated list of component names. Example: card product-card row layout' },
93
- ];
@@ -1,68 +0,0 @@
1
- export interface IStoryblokComponentConfig {
2
- name: string;
3
- version: string;
4
- modified: boolean;
5
- location: string;
6
- locationPath: string;
7
- scope: string;
8
- isLinkedInComponentFile: boolean;
9
- isComponentStyleImported: boolean;
10
- links: {
11
- [name: string]: {
12
- [name: string]: string;
13
- };
14
- };
15
- }
16
- export interface IStoryblokComponentsConfig {
17
- [name: string]: IStoryblokComponentConfig;
18
- }
19
- export interface IInstalledComponents {
20
- scope: string | undefined;
21
- name: string | undefined;
22
- }
23
- export declare enum SWAP_TOKEN {
24
- componentImports = "componentImports",
25
- componentLists = "componentLists",
26
- styleImports = "styleImports"
27
- }
28
- interface CreateCrumb {
29
- to: string;
30
- token: SWAP_TOKEN;
31
- }
32
- export declare class StoryblokComponentsConfig {
33
- private componentImportsToken;
34
- private componentComponentsListToken;
35
- private componentStylesImportsToken;
36
- private data;
37
- private storyblokComponentsConfigUrl;
38
- constructor(data: IStoryblokComponentsConfig);
39
- updateComponentsConfigFile(): boolean;
40
- addComponentsToComponentsConfigFile({ installedComponents, local, }: {
41
- installedComponents: IInstalledComponents[];
42
- local: boolean;
43
- }): IStoryblokComponentsConfig;
44
- getAllData(): IStoryblokComponentsConfig;
45
- getSingleData(componentName: string): IStoryblokComponentConfig;
46
- setAllData(data: IStoryblokComponentsConfig): void;
47
- setSingleData(singleComponentData: IStoryblokComponentConfig): void;
48
- /**
49
- *
50
- * Based on storyblok.componnets.lock.js file,
51
- * return proper content of specific files
52
- * (storyblok-components.componentList.js and storyblok-componnets-styles.scss)
53
- */
54
- createCrumb({ to, token }: CreateCrumb): any;
55
- /**
56
- * This updates storyblok components file with imports and
57
- * exports of componentList part of the component, based on
58
- * storyblok.components.lock file links property
59
- */
60
- updateStoryblokComponentsFile(): void;
61
- /**
62
- * This updates storyblok components styles file with style imports
63
- * based on storyblok.components.lock file links property
64
- */
65
- updateStoryblokComponentStylesFile(): void;
66
- }
67
- declare const _default: StoryblokComponentsConfig;
68
- export default _default;