storyblok 4.15.2 → 4.16.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 +3 -3
- package/dist/config/index.mjs.map +1 -1
- package/dist/index.mjs +56 -30
- package/dist/index.mjs.map +1 -1
- package/package.json +8 -9
package/README.md
CHANGED
|
@@ -99,7 +99,7 @@ Then you can set breakpoints directly to the typescript files and the debugger w
|
|
|
99
99
|
|
|
100
100
|
For help, discussion about best practices, or any other conversation that would benefit from being searchable:
|
|
101
101
|
|
|
102
|
-
- [Discuss Storyblok on
|
|
102
|
+
- [Discuss Storyblok on GitHub Discussions](https://github.com/storyblok/storyblok/discussions)
|
|
103
103
|
|
|
104
104
|
For community support, chatting with other users, please visit:
|
|
105
105
|
|
|
@@ -114,7 +114,7 @@ For bugs or feature requests, please [submit an issue](https://github.com/storyb
|
|
|
114
114
|
|
|
115
115
|
### I can't share my company project code
|
|
116
116
|
|
|
117
|
-
We understand that you might not be able to share your company's project code. Please provide a minimal reproducible example that demonstrates the issue by using tools like [Stackblitz](https://stackblitz.com) or a link to a
|
|
117
|
+
We understand that you might not be able to share your company's project code. Please provide a minimal reproducible example that demonstrates the issue by using tools like [Stackblitz](https://stackblitz.com) or a link to a GitHub repo. Please make sure you include a README file with the instructions to build and run the project, important not to include any access token, password or personal information of any kind.
|
|
118
118
|
|
|
119
119
|
### I only have a question
|
|
120
120
|
|
|
@@ -122,7 +122,7 @@ If you have a question, please ask in the [Discuss Storyblok on Discord](https:/
|
|
|
122
122
|
|
|
123
123
|
## Contributing
|
|
124
124
|
|
|
125
|
-
If you're interested in contributing to Storyblok CLI, please read our [contributing docs](
|
|
125
|
+
If you're interested in contributing to Storyblok CLI, please read our [contributing docs](../../CONTRIBUTING.md) before submitting a pull request.
|
|
126
126
|
|
|
127
127
|
## License
|
|
128
128
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../../src/lib/config/types.ts"],"sourcesContent":["import type { RegionCode } from '../../constants';\nimport type { Command, Option } from 'commander';\nimport type { CommandOptions } from '../../types';\nimport type { PullComponentsOptions } from '../../commands/components/pull/constants';\nimport type { PushComponentsOptions } from '../../commands/components/push/constants';\nimport type { PullDatasourcesOptions } from '../../commands/datasources/pull/constants';\nimport type { PushDatasourcesOptions } from '../../commands/datasources/push/constants';\nimport type { DeleteDatasourceOptions } from '../../commands/datasources/delete/constants';\nimport type { MigrationsGenerateOptions } from '../../commands/migrations/generate/constants';\nimport type { MigrationsRunOptions } from '../../commands/migrations/run/constants';\nimport type { MigrationsRollbackOptions } from '../../commands/migrations/rollback/types';\nimport type { GenerateTypesOptions } from '../../commands/types/generate/constants';\nimport type { PullLanguagesOptions } from '../../commands/languages/constants';\nimport type { PullAssetsOptions } from '../../commands/assets/pull/types';\nimport type { PushAssetsOptions } from '../../commands/assets/push/types';\nimport type { PullStoriesOptions } from '../../commands/stories/pull/types';\nimport type { PushStoriesOptions } from '../../commands/stories/push/types';\nimport type { PruneLogsOptions } from '../../commands/logs/prune/types';\nimport type { PruneReportsOptions } from '../../commands/reports/prune/types';\nimport type { DeepPartial } from '../../utils/types';\n\nexport type PlainObject = Record<string, any>;\n\nexport interface ApiConfig {\n maxRetries: number;\n maxConcurrency: number;\n}\n\nexport interface LogConsoleConfig {\n enabled: boolean;\n level: string;\n}\n\nexport interface LogFileConfig {\n enabled: boolean;\n level: string;\n maxFiles: number;\n}\n\nexport interface LogConfig {\n console: LogConsoleConfig;\n file: LogFileConfig;\n}\n\nexport interface ReportConfig {\n enabled: boolean;\n maxFiles: number;\n}\n\nexport interface UiConfig {\n enabled: boolean;\n}\n\nexport interface GlobalConfig {\n region?: RegionCode;\n space?: number | string;\n path?: string;\n api: ApiConfig;\n log: LogConfig;\n report: ReportConfig;\n ui: UiConfig;\n verbose: boolean;\n}\n\nexport interface ResolvedCliConfig extends GlobalConfig {\n [key: string]: any;\n}\n\ntype StripCommandOption<T> = T extends CommandOptions ? Omit<T, keyof CommandOptions> : T;\ntype CommandConfig<T> = Partial<StripCommandOption<T>>;\n\nexport interface SharedConfigOptions {\n space?: number | string;\n path?: string;\n}\n\nexport interface CommandOptionsMap {\n components: { pull: PullComponentsOptions; push: PushComponentsOptions };\n datasources: { pull: PullDatasourcesOptions; push: PushDatasourcesOptions; delete: DeleteDatasourceOptions };\n migrations: { generate: MigrationsGenerateOptions; run: MigrationsRunOptions; rollback: MigrationsRollbackOptions };\n types: { generate: GenerateTypesOptions };\n languages: { pull: PullLanguagesOptions };\n assets: { pull: PullAssetsOptions; push: PushAssetsOptions };\n stories: { pull: PullStoriesOptions; push: PushStoriesOptions };\n logs: { list: Record<string, never>; prune: PruneLogsOptions };\n reports: { list: Record<string, never>; prune: PruneReportsOptions };\n}\n\ntype SubcommandConfig<T> = SharedConfigOptions & CommandConfig<T>;\n\ntype ModuleConfig<Subs extends Record<string, any>> = SharedConfigOptions & {\n [K in keyof Subs]?: SubcommandConfig<Subs[K]>;\n};\n\nexport type ModulesConfig = {\n [K in keyof CommandOptionsMap]?: ModuleConfig<CommandOptionsMap[K]>;\n};\n\nexport type ComponentsModuleConfig = ModulesConfig['components'];\nexport type DatasourcesModuleConfig = ModulesConfig['datasources'];\nexport type MigrationsModuleConfig = ModulesConfig['migrations'];\nexport type TypesModuleConfig = ModulesConfig['types'];\nexport type LanguagesModuleConfig = ModulesConfig['languages'];\nexport type AssetsModuleConfig = ModulesConfig['assets'];\nexport type StoriesModuleConfig = ModulesConfig['stories'];\nexport type LogsModuleConfig = ModulesConfig['logs'];\nexport type ReportsModuleConfig = ModulesConfig['reports'];\n\nexport interface StoryblokConfig extends DeepPartial<GlobalConfig> {\n modules?: ModulesConfig;\n}\n\nexport function defineConfig<T extends StoryblokConfig>(config: T): T {\n return config;\n}\n\nexport type OptionParser<T> = (value: string, previous?: T) => T;\n\nexport interface GlobalOptionDefinition<T = unknown> {\n flags: string;\n description: string;\n defaultValue?: T;\n parser?: OptionParser<T>;\n}\n\nexport interface ConfigLocation {\n cwd: string;\n configFile: string;\n}\n\nexport type CommanderOption = Option;\nexport type CommanderCommand = Command;\n"],"names":[],"mappings":"AAgHO,SAAS,aAAwC,
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../../src/lib/config/types.ts"],"sourcesContent":["import type { RegionCode } from '../../constants';\nimport type { Command, Option } from 'commander';\nimport type { CommandOptions } from '../../types';\nimport type { PullComponentsOptions } from '../../commands/components/pull/constants';\nimport type { PushComponentsOptions } from '../../commands/components/push/constants';\nimport type { PullDatasourcesOptions } from '../../commands/datasources/pull/constants';\nimport type { PushDatasourcesOptions } from '../../commands/datasources/push/constants';\nimport type { DeleteDatasourceOptions } from '../../commands/datasources/delete/constants';\nimport type { MigrationsGenerateOptions } from '../../commands/migrations/generate/constants';\nimport type { MigrationsRunOptions } from '../../commands/migrations/run/constants';\nimport type { MigrationsRollbackOptions } from '../../commands/migrations/rollback/types';\nimport type { GenerateTypesOptions } from '../../commands/types/generate/constants';\nimport type { PullLanguagesOptions } from '../../commands/languages/constants';\nimport type { PullAssetsOptions } from '../../commands/assets/pull/types';\nimport type { PushAssetsOptions } from '../../commands/assets/push/types';\nimport type { PullStoriesOptions } from '../../commands/stories/pull/types';\nimport type { PushStoriesOptions } from '../../commands/stories/push/types';\nimport type { PruneLogsOptions } from '../../commands/logs/prune/types';\nimport type { PruneReportsOptions } from '../../commands/reports/prune/types';\nimport type { DeepPartial } from '../../utils/types';\n\nexport type PlainObject = Record<string, any>;\n\nexport interface ApiConfig {\n maxRetries: number;\n maxConcurrency: number;\n}\n\nexport interface LogConsoleConfig {\n enabled: boolean;\n level: string;\n}\n\nexport interface LogFileConfig {\n enabled: boolean;\n level: string;\n maxFiles: number;\n}\n\nexport interface LogConfig {\n console: LogConsoleConfig;\n file: LogFileConfig;\n}\n\nexport interface ReportConfig {\n enabled: boolean;\n maxFiles: number;\n}\n\nexport interface UiConfig {\n enabled: boolean;\n}\n\nexport interface GlobalConfig {\n region?: RegionCode;\n space?: number | string;\n path?: string;\n api: ApiConfig;\n log: LogConfig;\n report: ReportConfig;\n ui: UiConfig;\n verbose: boolean;\n}\n\nexport interface ResolvedCliConfig extends GlobalConfig {\n [key: string]: any;\n}\n\ntype StripCommandOption<T> = T extends CommandOptions ? Omit<T, keyof CommandOptions> : T;\ntype CommandConfig<T> = Partial<StripCommandOption<T>>;\n\nexport interface SharedConfigOptions {\n space?: number | string;\n path?: string;\n}\n\nexport interface CommandOptionsMap {\n components: { pull: PullComponentsOptions; push: PushComponentsOptions };\n datasources: { pull: PullDatasourcesOptions; push: PushDatasourcesOptions; delete: DeleteDatasourceOptions };\n migrations: { generate: MigrationsGenerateOptions; run: MigrationsRunOptions; rollback: MigrationsRollbackOptions };\n types: { generate: GenerateTypesOptions };\n languages: { pull: PullLanguagesOptions };\n assets: { pull: PullAssetsOptions; push: PushAssetsOptions };\n stories: { pull: PullStoriesOptions; push: PushStoriesOptions };\n logs: { list: Record<string, never>; prune: PruneLogsOptions };\n reports: { list: Record<string, never>; prune: PruneReportsOptions };\n}\n\ntype SubcommandConfig<T> = SharedConfigOptions & CommandConfig<T>;\n\ntype ModuleConfig<Subs extends Record<string, any>> = SharedConfigOptions & {\n [K in keyof Subs]?: SubcommandConfig<Subs[K]>;\n};\n\nexport type ModulesConfig = {\n [K in keyof CommandOptionsMap]?: ModuleConfig<CommandOptionsMap[K]>;\n};\n\nexport type ComponentsModuleConfig = ModulesConfig['components'];\nexport type DatasourcesModuleConfig = ModulesConfig['datasources'];\nexport type MigrationsModuleConfig = ModulesConfig['migrations'];\nexport type TypesModuleConfig = ModulesConfig['types'];\nexport type LanguagesModuleConfig = ModulesConfig['languages'];\nexport type AssetsModuleConfig = ModulesConfig['assets'];\nexport type StoriesModuleConfig = ModulesConfig['stories'];\nexport type LogsModuleConfig = ModulesConfig['logs'];\nexport type ReportsModuleConfig = ModulesConfig['reports'];\n\nexport interface StoryblokConfig extends DeepPartial<GlobalConfig> {\n modules?: ModulesConfig;\n}\n\nexport function defineConfig<T extends StoryblokConfig>(config: T): T {\n return config;\n}\n\nexport type OptionParser<T> = (value: string, previous?: T) => T;\n\nexport interface GlobalOptionDefinition<T = unknown> {\n flags: string;\n description: string;\n defaultValue?: T;\n parser?: OptionParser<T>;\n}\n\nexport interface ConfigLocation {\n cwd: string;\n configFile: string;\n}\n\nexport type CommanderOption = Option;\nexport type CommanderCommand = Command;\n"],"names":[],"mappings":"AAgHO,SAAS,aAAwC,MAAA,EAAc;AACpE,EAAA,OAAO,MAAA;AACT;;;;"}
|
package/dist/index.mjs
CHANGED
|
@@ -1074,10 +1074,10 @@ const konsola = {
|
|
|
1074
1074
|
}
|
|
1075
1075
|
};
|
|
1076
1076
|
|
|
1077
|
-
const __filename$
|
|
1078
|
-
const __dirname$
|
|
1077
|
+
const __filename$2 = fileURLToPath(import.meta.url);
|
|
1078
|
+
const __dirname$2 = dirname(__filename$2);
|
|
1079
1079
|
const result = await readPackageUp({
|
|
1080
|
-
cwd: __dirname$
|
|
1080
|
+
cwd: __dirname$2
|
|
1081
1081
|
});
|
|
1082
1082
|
const packageJson$1 = result ? result.packageJson : {
|
|
1083
1083
|
name: "storyblok",
|
|
@@ -1091,8 +1091,8 @@ function getPackageJson() {
|
|
|
1091
1091
|
return packageJson$1;
|
|
1092
1092
|
}
|
|
1093
1093
|
|
|
1094
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
1095
|
-
const __dirname = dirname(__filename);
|
|
1094
|
+
const __filename$1 = fileURLToPath(import.meta.url);
|
|
1095
|
+
const __dirname$1 = dirname(__filename$1);
|
|
1096
1096
|
function isRegion(value) {
|
|
1097
1097
|
return Object.values(regions).includes(value);
|
|
1098
1098
|
}
|
|
@@ -4077,6 +4077,36 @@ const updateStory = async (spaceId, storyId, payload) => {
|
|
|
4077
4077
|
handleAPIError("update_story", error);
|
|
4078
4078
|
}
|
|
4079
4079
|
};
|
|
4080
|
+
const prefetchTargetStories = async (spaceId, options) => {
|
|
4081
|
+
const result = {
|
|
4082
|
+
bySlug: /* @__PURE__ */ new Map(),
|
|
4083
|
+
byId: /* @__PURE__ */ new Map()
|
|
4084
|
+
};
|
|
4085
|
+
let page = 1;
|
|
4086
|
+
let totalPages = 1;
|
|
4087
|
+
while (page <= totalPages) {
|
|
4088
|
+
const response = await fetchStories(spaceId, { page, per_page: 100 });
|
|
4089
|
+
if (!response) {
|
|
4090
|
+
break;
|
|
4091
|
+
}
|
|
4092
|
+
const total = Number(response.headers.get("Total"));
|
|
4093
|
+
const perPage = Number(response.headers.get("Per-Page"));
|
|
4094
|
+
totalPages = Math.ceil(total / perPage);
|
|
4095
|
+
if (page === 1) {
|
|
4096
|
+
options?.onTotal?.(total);
|
|
4097
|
+
}
|
|
4098
|
+
for (const story of response.stories) {
|
|
4099
|
+
const ref = { id: story.id, uuid: story.uuid };
|
|
4100
|
+
if (story.full_slug) {
|
|
4101
|
+
result.bySlug.set(story.full_slug, ref);
|
|
4102
|
+
}
|
|
4103
|
+
result.byId.set(story.id, ref);
|
|
4104
|
+
}
|
|
4105
|
+
options?.onIncrement?.(response.stories.length);
|
|
4106
|
+
page++;
|
|
4107
|
+
}
|
|
4108
|
+
return result;
|
|
4109
|
+
};
|
|
4080
4110
|
|
|
4081
4111
|
const ERROR_CODES = {
|
|
4082
4112
|
MIGRATION_APPLY_TO_STORY_ERROR: "MIGRATION_APPLY_TO_STORY_ERROR",
|
|
@@ -5785,7 +5815,7 @@ const saveTypesToComponentsFile = async (space, typedefData, options) => {
|
|
|
5785
5815
|
const generateStoryblokTypes = async (options = {}) => {
|
|
5786
5816
|
const { path } = options;
|
|
5787
5817
|
try {
|
|
5788
|
-
const storyblokTypesPath = resolve(__dirname, "./index.d.ts");
|
|
5818
|
+
const storyblokTypesPath = resolve(__dirname$1, "./index.d.ts");
|
|
5789
5819
|
const storyblokTypesContent = readFileSync(storyblokTypesPath, "utf-8");
|
|
5790
5820
|
const typeDefs = [
|
|
5791
5821
|
"// This file was generated by the Storyblok CLI.",
|
|
@@ -8186,23 +8216,8 @@ const mapReferencesStream = ({
|
|
|
8186
8216
|
}
|
|
8187
8217
|
});
|
|
8188
8218
|
};
|
|
8189
|
-
const getRemoteStory = async ({ spaceId, storyId }) => {
|
|
8190
|
-
const { data, response } = await getMapiClient().stories.get({
|
|
8191
|
-
path: {
|
|
8192
|
-
space_id: spaceId,
|
|
8193
|
-
story_id: storyId
|
|
8194
|
-
}
|
|
8195
|
-
});
|
|
8196
|
-
if (!response.ok && response.status !== 404) {
|
|
8197
|
-
handleAPIError("pull_story", new FetchError(response.statusText, response));
|
|
8198
|
-
}
|
|
8199
|
-
if (data?.story?.deleted_at) {
|
|
8200
|
-
return void 0;
|
|
8201
|
-
}
|
|
8202
|
-
return data?.story;
|
|
8203
|
-
};
|
|
8204
8219
|
const makeCreateStoryAPITransport = ({ spaceId }) => async (localStory) => {
|
|
8205
|
-
const { id: _id, uuid: _uuid, parent_id: _parentId, content, ...newStoryData } = localStory;
|
|
8220
|
+
const { id: _id, uuid: _uuid, parent_id: _parentId, is_startpage: _isStartpage, content, ...newStoryData } = localStory;
|
|
8206
8221
|
if (!localStory.is_folder && !content?.component) {
|
|
8207
8222
|
throw new Error(`Story "${localStory.slug}" is missing a content type (content.component). Every story must define a content field with a valid component.`);
|
|
8208
8223
|
}
|
|
@@ -8233,7 +8248,8 @@ const makeAppendToManifestFSTransport = ({ manifestFile }) => async (localStory,
|
|
|
8233
8248
|
};
|
|
8234
8249
|
const createStoryPlaceholderStream = ({
|
|
8235
8250
|
maps,
|
|
8236
|
-
|
|
8251
|
+
existingTargetStories,
|
|
8252
|
+
isCrossSpace,
|
|
8237
8253
|
transports,
|
|
8238
8254
|
onIncrement,
|
|
8239
8255
|
onStorySuccess,
|
|
@@ -8248,16 +8264,19 @@ const createStoryPlaceholderStream = ({
|
|
|
8248
8264
|
const task = (async () => {
|
|
8249
8265
|
try {
|
|
8250
8266
|
const mappedStoryId = maps.stories?.get(localStory.id);
|
|
8251
|
-
const mappedRemoteStory = mappedStoryId
|
|
8267
|
+
const mappedRemoteStory = mappedStoryId ? existingTargetStories.byId.get(Number(mappedStoryId)) : void 0;
|
|
8252
8268
|
if (mappedRemoteStory) {
|
|
8253
8269
|
onStorySkipped?.(localStory, mappedRemoteStory);
|
|
8254
8270
|
return;
|
|
8255
8271
|
}
|
|
8256
|
-
const
|
|
8257
|
-
if (
|
|
8258
|
-
|
|
8259
|
-
|
|
8260
|
-
|
|
8272
|
+
const existingBySlug = localStory.full_slug ? existingTargetStories.bySlug.get(localStory.full_slug) : void 0;
|
|
8273
|
+
if (existingBySlug) {
|
|
8274
|
+
const isMatchConfirmed = isCrossSpace || existingBySlug.uuid === localStory.uuid;
|
|
8275
|
+
if (isMatchConfirmed) {
|
|
8276
|
+
await transports.appendStoryManifest(localStory, existingBySlug);
|
|
8277
|
+
onStorySkipped?.(localStory, existingBySlug);
|
|
8278
|
+
return;
|
|
8279
|
+
}
|
|
8261
8280
|
}
|
|
8262
8281
|
const newRemoteStory = await transports.createStory(localStory);
|
|
8263
8282
|
await transports.appendStoryManifest(localStory, newRemoteStory);
|
|
@@ -8895,6 +8914,12 @@ pushCmd.action(async (options, command) => {
|
|
|
8895
8914
|
logger.error(message);
|
|
8896
8915
|
return;
|
|
8897
8916
|
}
|
|
8917
|
+
const fetchProgress = ui.createProgressBar({ title: "Matching Stories...".padEnd(21) });
|
|
8918
|
+
const existingTargetStories = await prefetchTargetStories(space, {
|
|
8919
|
+
onTotal: (total) => fetchProgress.setTotal(total),
|
|
8920
|
+
onIncrement: (count) => fetchProgress.increment(count)
|
|
8921
|
+
});
|
|
8922
|
+
fetchProgress.stop();
|
|
8898
8923
|
const storiesDirectoryPath = resolveCommandPath(directories.stories, fromSpace, basePath);
|
|
8899
8924
|
const creationProgress = ui.createProgressBar({ title: "Creating Stories...".padEnd(21) });
|
|
8900
8925
|
const processProgress = ui.createProgressBar({ title: "Processing Stories...".padEnd(21) });
|
|
@@ -8924,7 +8949,8 @@ pushCmd.action(async (options, command) => {
|
|
|
8924
8949
|
// Create remote stories.
|
|
8925
8950
|
createStoryPlaceholderStream({
|
|
8926
8951
|
maps,
|
|
8927
|
-
|
|
8952
|
+
existingTargetStories,
|
|
8953
|
+
isCrossSpace: fromSpace !== space,
|
|
8928
8954
|
transports: {
|
|
8929
8955
|
createStory: options.dryRun ? async (story) => story : makeCreateStoryAPITransport({
|
|
8930
8956
|
spaceId: space
|