sb-mig 2.9.13 → 3.0.0-beta.1
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 -495
- package/{lib → dist}/api/componentPresets.d.ts +1 -1
- 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 -63
- 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.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 -27
- 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
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;
|
package/lib/utils/files.js
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.copyFile = exports.copyFolder = exports.createJsonFile = exports.createDir = exports.isDirectoryExists = exports.getCurrentDirectoryBase = void 0;
|
|
4
|
-
const fs = require("fs");
|
|
5
|
-
const ncp_1 = require("ncp");
|
|
6
|
-
const path = require("path");
|
|
7
|
-
const logger_1 = require("./logger");
|
|
8
|
-
const getCurrentDirectoryBase = () => path.basename(process.cwd());
|
|
9
|
-
exports.getCurrentDirectoryBase = getCurrentDirectoryBase;
|
|
10
|
-
const isDirectoryExists = (path) => fs.existsSync(path);
|
|
11
|
-
exports.isDirectoryExists = isDirectoryExists;
|
|
12
|
-
const createDir = async (dirPath) => {
|
|
13
|
-
await fs.promises.mkdir(`${process.cwd()}/${dirPath}`, {
|
|
14
|
-
recursive: true,
|
|
15
|
-
});
|
|
16
|
-
};
|
|
17
|
-
exports.createDir = createDir;
|
|
18
|
-
const createJsonFile = async (content, pathWithFilename) => {
|
|
19
|
-
await fs.promises.writeFile(pathWithFilename, content, { flag: 'w' });
|
|
20
|
-
};
|
|
21
|
-
exports.createJsonFile = createJsonFile;
|
|
22
|
-
const copyFolder = async (src, dest) => {
|
|
23
|
-
return new Promise((resolve, reject) => {
|
|
24
|
-
(0, ncp_1.ncp)(src, dest, function (err) {
|
|
25
|
-
if (err) {
|
|
26
|
-
reject({
|
|
27
|
-
failed: true,
|
|
28
|
-
message: `${src} copied unsuccessfully.`,
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
resolve({
|
|
32
|
-
failed: false,
|
|
33
|
-
message: `${src} copied successfully.`,
|
|
34
|
-
});
|
|
35
|
-
});
|
|
36
|
-
});
|
|
37
|
-
};
|
|
38
|
-
exports.copyFolder = copyFolder;
|
|
39
|
-
const copyFile = async (src, dest) => {
|
|
40
|
-
const directory = dest.split('/').slice(0, dest.split('/').length - 1);
|
|
41
|
-
const fileName = src.split('/')[src.split('/').length - 1];
|
|
42
|
-
if (!(0, exports.isDirectoryExists)(directory.join('/'))) {
|
|
43
|
-
await (0, exports.createDir)(directory.join('/'));
|
|
44
|
-
}
|
|
45
|
-
fs.copyFile(src, dest, err => {
|
|
46
|
-
if (err) {
|
|
47
|
-
logger_1.default.error(`There is no file to copy, named ${fileName}`);
|
|
48
|
-
console.log(err);
|
|
49
|
-
return false;
|
|
50
|
-
}
|
|
51
|
-
console.log(`${fileName} was copied to ${dest}`);
|
|
52
|
-
});
|
|
53
|
-
};
|
|
54
|
-
exports.copyFile = copyFile;
|
package/lib/utils/others.js
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.generateDatestamp = void 0;
|
|
4
|
-
const generateDatestamp = (datestamp) => `${datestamp.getFullYear()}-${datestamp.getMonth()}-${datestamp.getDay()}_${datestamp.getTime()}`;
|
|
5
|
-
exports.generateDatestamp = generateDatestamp;
|
package/oclif.manifest.json
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":"2.9.13","commands":{"backup":{"id":"backup","description":"Command for backing up anything related to Storyblok","pluginName":"sb-mig","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false},"allComponents":{"name":"allComponents","type":"boolean","char":"a","description":"Backup all components.","allowNo":false},"oneComponent":{"name":"oneComponent","type":"option","char":"o","description":"Backup one component by name."},"allComponentsGroups":{"name":"allComponentsGroups","type":"boolean","char":"g","description":"Backup all components groups.","allowNo":false},"oneComponentsGroup":{"name":"oneComponentsGroup","type":"option","char":"f","description":"Backup one components group by name."},"oneComponentPresets":{"name":"oneComponentPresets","type":"option","char":"p","description":"Backup all presets for one component"},"allPresets":{"name":"allPresets","type":"boolean","char":"l","description":"Backup all presets.","allowNo":false},"onePreset":{"name":"onePreset","type":"option","char":"i","description":"Backup one preset by id."},"allDatasources":{"name":"allDatasources","type":"boolean","char":"d","description":"Backup all datasources.","allowNo":false},"oneDatasource":{"name":"oneDatasource","type":"option","char":"x","description":"Backup one datasource by name."},"datasourceEntries":{"name":"datasourceEntries","type":"option","char":"e","description":"Backup one datasource entries by datasource name."},"allRoles":{"name":"allRoles","type":"boolean","char":"R","description":"Backup all roles and permissions.","allowNo":false},"oneRole":{"name":"oneRole","type":"option","char":"r","description":"Backup one role by name."}},"args":[]},"debug":{"id":"debug","description":"Output extra debugging","pluginName":"sb-mig","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false}},"args":[]},"sync":{"id":"sync","description":"Synchronize components, datasources or roles with Storyblok space.","pluginName":"sb-mig","pluginType":"core","aliases":[],"examples":["$ sb-mig sync components --all --ext","$ sb-mig sync components @storyblok-components/text-block --ext --packageName","$ sb-mig sync components @storyblok-components/text-block @storyblok-components/button --ext --packageName","$ sb-mig sync components text-block button --ext","$ sb-mig sync components text-block button","$ sb-mig sync roles"],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false},"all":{"name":"all","type":"boolean","char":"a","description":"Synchronize all components.","allowNo":false},"ext":{"name":"ext","type":"boolean","char":"e","description":"Synchronize with file extension. Default extension: '.sb.js'","allowNo":false},"packageName":{"name":"packageName","type":"boolean","char":"n","description":"Synchronize based on installed package name.","allowNo":false},"presets":{"name":"presets","type":"boolean","char":"p","description":"Synchronize components with presets.","allowNo":false},"lock":{"name":"lock","type":"boolean","char":"l","description":"Synchronize based on storyblok.components.lock.js file","allowNo":false}},"args":[{"name":"type","description":"What to synchronize","required":true,"options":["components","datasources","roles"]},{"name":"list","description":"Space separated list of component names. Example: card product-card row layout"}]}}}
|