sb-mig 2.9.13 → 3.1.0

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 (52) hide show
  1. package/README.md +5 -5
  2. package/dist/index.js +52 -0
  3. package/package.json +39 -62
  4. package/bin/run +0 -5
  5. package/bin/run.cmd +0 -3
  6. package/lib/api/apiConfig.d.ts +0 -2
  7. package/lib/api/apiConfig.js +0 -9
  8. package/lib/api/componentPresets.d.ts +0 -1
  9. package/lib/api/componentPresets.js +0 -22
  10. package/lib/api/components.d.ts +0 -5
  11. package/lib/api/components.js +0 -71
  12. package/lib/api/datasources.d.ts +0 -24
  13. package/lib/api/datasources.js +0 -193
  14. package/lib/api/migrate.d.ts +0 -19
  15. package/lib/api/migrate.js +0 -220
  16. package/lib/api/mutateComponents.d.ts +0 -2
  17. package/lib/api/mutateComponents.js +0 -50
  18. package/lib/api/presets.d.ts +0 -4
  19. package/lib/api/presets.js +0 -59
  20. package/lib/api/resolvePresets.d.ts +0 -2
  21. package/lib/api/resolvePresets.js +0 -40
  22. package/lib/api/roles.d.ts +0 -14
  23. package/lib/api/roles.js +0 -133
  24. package/lib/api/spaces.d.ts +0 -2
  25. package/lib/api/spaces.js +0 -29
  26. package/lib/commands/backup.d.ts +0 -22
  27. package/lib/commands/backup.js +0 -217
  28. package/lib/commands/debug.d.ts +0 -9
  29. package/lib/commands/debug.js +0 -27
  30. package/lib/commands/sync.d.ts +0 -26
  31. package/lib/commands/sync.js +0 -93
  32. package/lib/config/StoryblokComponentsConfig.d.ts +0 -68
  33. package/lib/config/StoryblokComponentsConfig.js +0 -220
  34. package/lib/config/config.d.ts +0 -37
  35. package/lib/config/config.js +0 -36
  36. package/lib/core.d.ts +0 -16
  37. package/lib/core.js +0 -75
  38. package/lib/index.d.ts +0 -1
  39. package/lib/index.js +0 -5
  40. package/lib/types/storyblokTypes.d.ts +0 -171
  41. package/lib/types/storyblokTypes.js +0 -3
  42. package/lib/utils/discover.d.ts +0 -4
  43. package/lib/utils/discover.js +0 -96
  44. package/lib/utils/discover2.d.ts +0 -63
  45. package/lib/utils/discover2.js +0 -424
  46. package/lib/utils/files.d.ts +0 -6
  47. package/lib/utils/files.js +0 -54
  48. package/lib/utils/logger.d.ts +0 -11
  49. package/lib/utils/logger.js +0 -30
  50. package/lib/utils/others.d.ts +0 -1
  51. package/lib/utils/others.js +0 -5
  52. package/oclif.manifest.json +0 -1
@@ -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;
@@ -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,5 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.run = void 0;
4
- var command_1 = require("@oclif/command");
5
- Object.defineProperty(exports, "run", { enumerable: true, get: function () { return command_1.run; } });
@@ -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;
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = Storyblok;
@@ -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[];
@@ -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;
@@ -1,63 +0,0 @@
1
- export declare enum SCOPE {
2
- local = "local",
3
- external = "external",
4
- lock = "lock",
5
- all = "all"
6
- }
7
- export declare enum LOOKUP_TYPE {
8
- packagName = "packageName",
9
- fileName = "fileName"
10
- }
11
- interface DiscoverRequest {
12
- scope: SCOPE;
13
- type: LOOKUP_TYPE;
14
- }
15
- interface DiscoverOneRequest {
16
- fileName: string;
17
- scope: SCOPE;
18
- type: LOOKUP_TYPE;
19
- }
20
- interface DiscoverManyRequest {
21
- fileNames: string[];
22
- scope: SCOPE;
23
- type: LOOKUP_TYPE;
24
- }
25
- interface DiscoverOneByPackageNameRequest {
26
- packageName: string;
27
- scope: SCOPE;
28
- }
29
- interface DiscoverManyByPackageNameRequest {
30
- packageNames: string[];
31
- scope: SCOPE;
32
- }
33
- interface CompareRequest {
34
- local: string[];
35
- external: string[];
36
- }
37
- export interface OneComponent {
38
- name: string;
39
- path: string;
40
- }
41
- export interface CompareResult {
42
- local: OneComponent[];
43
- external: OneComponent[];
44
- }
45
- declare type DiscoverResult = string[];
46
- export declare const compare: (request: CompareRequest) => CompareResult;
47
- export declare const discoverManyByPackageName: (request: DiscoverManyByPackageNameRequest) => DiscoverResult;
48
- export declare const discoverOneByPackageName: (request: DiscoverOneByPackageNameRequest) => DiscoverResult;
49
- export declare const discoverMany: (request: DiscoverManyRequest) => DiscoverResult;
50
- export declare const discoverManyDatasources: (request: DiscoverManyRequest) => DiscoverResult;
51
- export declare const discoverDatasources: (request: DiscoverRequest) => DiscoverResult;
52
- export declare const discoverOne: (request: DiscoverOneRequest) => DiscoverResult;
53
- export declare const discover: (request: DiscoverRequest) => DiscoverResult;
54
- export declare const discoverManyStyles: (request: DiscoverManyRequest) => DiscoverResult;
55
- export declare const discoverRoles: (request: DiscoverRequest) => DiscoverResult;
56
- export declare const discoverManyRoles: (request: DiscoverManyRequest) => DiscoverResult;
57
- export declare const getFilesContent: (data: {
58
- files: string[];
59
- }) => any[];
60
- export declare const getFileContent: (data: {
61
- file: string;
62
- }) => any;
63
- export {};