sb-mig 6.0.0-beta.2 → 6.0.0-beta.3

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.
@@ -43,6 +43,7 @@ interface MigrateItems {
43
43
  startsWith?: string;
44
44
  };
45
45
  dryRun?: boolean;
46
+ publish?: boolean;
46
47
  fromFilePath?: string;
47
48
  fileName?: string;
48
49
  preparedMigrationConfigs?: PreparedMigrationConfig[];
@@ -67,8 +68,8 @@ export declare const runMigrationPipelineInMemory: ({ itemType, itemsToMigrate,
67
68
  itemsToMigrate: any[];
68
69
  preparedMigrationConfigs: PreparedMigrationConfig[];
69
70
  }) => MigrationPipelineResult;
70
- export declare const migrateAllComponentsDataInStories: ({ itemType, migrationConfig, migrateFrom, from, to, filters, dryRun, fromFilePath, fileName, migrationComponentAliases, migrationComponentOverrides, }: Omit<MigrateItems, "componentsToMigrate" | "preparedMigrationConfigs">, config: RequestBaseConfig) => Promise<void>;
71
- export declare const doTheMigration: ({ itemType, from, itemsToMigrate, migrationConfig, migrationConfigs, to, dryRun, migrateFrom, fromFilePath, fileName, }: {
71
+ export declare const migrateAllComponentsDataInStories: ({ itemType, migrationConfig, migrateFrom, from, to, filters, dryRun, publish, fromFilePath, fileName, migrationComponentAliases, migrationComponentOverrides, }: Omit<MigrateItems, "componentsToMigrate" | "preparedMigrationConfigs">, config: RequestBaseConfig) => Promise<void>;
72
+ export declare const doTheMigration: ({ itemType, from, itemsToMigrate, migrationConfig, migrationConfigs, to, dryRun, publish, migrateFrom, fromFilePath, fileName, }: {
72
73
  itemType?: "story" | "preset";
73
74
  from: string;
74
75
  itemsToMigrate: any[];
@@ -76,9 +77,10 @@ export declare const doTheMigration: ({ itemType, from, itemsToMigrate, migratio
76
77
  migrationConfigs?: PreparedMigrationConfig[];
77
78
  to: string;
78
79
  dryRun?: boolean;
80
+ publish?: boolean;
79
81
  migrateFrom: MigrateFrom;
80
82
  fromFilePath?: string;
81
83
  fileName?: string;
82
84
  }, config: RequestBaseConfig) => Promise<void>;
83
- export declare const migrateProvidedComponentsDataInStories: ({ itemType, migrationConfig, migrateFrom, from, to, componentsToMigrate, filters, dryRun, fromFilePath, fileName, preparedMigrationConfigs, migrationComponentAliases, migrationComponentOverrides, }: MigrateItems, config: RequestBaseConfig) => Promise<void>;
85
+ export declare const migrateProvidedComponentsDataInStories: ({ itemType, migrationConfig, migrateFrom, from, to, componentsToMigrate, filters, dryRun, publish, fromFilePath, fileName, preparedMigrationConfigs, migrationComponentAliases, migrationComponentOverrides, }: MigrateItems, config: RequestBaseConfig) => Promise<void>;
84
86
  export {};
@@ -295,7 +295,7 @@ export const runMigrationPipelineInMemory = ({ itemType, itemsToMigrate, prepare
295
295
  totalItems: workingItems.length,
296
296
  };
297
297
  };
298
- const savePipelineSummary = async ({ artifactBaseName, useDatestamp, from, itemType, dryRun, migrateFrom, fromFilePath, pipelineResult, }, config) => {
298
+ const savePipelineSummary = async ({ artifactBaseName, useDatestamp, from, itemType, dryRun, publish, migrateFrom, fromFilePath, pipelineResult, }, config) => {
299
299
  await createAndSaveToFile({
300
300
  datestamp: useDatestamp,
301
301
  ext: "json",
@@ -308,6 +308,7 @@ const savePipelineSummary = async ({ artifactBaseName, useDatestamp, from, itemT
308
308
  from,
309
309
  fromFilePath: fromFilePath || null,
310
310
  },
311
+ writeMode: itemType === "story" && publish ? "publish" : "save",
311
312
  totalItems: pipelineResult.totalItems,
312
313
  totalChangedItems: pipelineResult.changedItems.length,
313
314
  steps: pipelineResult.stepReports,
@@ -378,7 +379,7 @@ const loadItemsToMigrate = async ({ itemType, migrateFrom, from, filters, fromFi
378
379
  spaceId: from,
379
380
  });
380
381
  };
381
- export const migrateAllComponentsDataInStories = async ({ itemType, migrationConfig, migrateFrom, from, to, filters, dryRun, fromFilePath, fileName, migrationComponentAliases, migrationComponentOverrides, }, config) => {
382
+ export const migrateAllComponentsDataInStories = async ({ itemType, migrationConfig, migrateFrom, from, to, filters, dryRun, publish, fromFilePath, fileName, migrationComponentAliases, migrationComponentOverrides, }, config) => {
382
383
  Logger.warning(`Trying to migrate all ${itemType} from ${migrateFrom}, ${from} to ${to}...`);
383
384
  const preparedMigrationConfigs = prepareMigrationConfigs({
384
385
  migrationConfig,
@@ -397,12 +398,13 @@ export const migrateAllComponentsDataInStories = async ({ itemType, migrationCon
397
398
  to,
398
399
  filters,
399
400
  dryRun,
401
+ publish,
400
402
  fromFilePath,
401
403
  fileName,
402
404
  preparedMigrationConfigs,
403
405
  }, config);
404
406
  };
405
- export const doTheMigration = async ({ itemType = "story", from, itemsToMigrate, migrationConfig, migrationConfigs, to, dryRun, migrateFrom, fromFilePath, fileName, }, config) => {
407
+ export const doTheMigration = async ({ itemType = "story", from, itemsToMigrate, migrationConfig, migrationConfigs, to, dryRun, publish, migrateFrom, fromFilePath, fileName, }, config) => {
406
408
  const preparedMigrationConfigs = migrationConfigs ||
407
409
  prepareMigrationConfigs({
408
410
  migrationConfig: migrationConfig || [],
@@ -472,6 +474,7 @@ export const doTheMigration = async ({ itemType = "story", from, itemsToMigrate,
472
474
  from,
473
475
  itemType,
474
476
  dryRun,
477
+ publish,
475
478
  migrateFrom,
476
479
  fromFilePath,
477
480
  pipelineResult,
@@ -493,7 +496,7 @@ export const doTheMigration = async ({ itemType = "story", from, itemsToMigrate,
493
496
  writeResults = await managementApi.stories.updateStories({
494
497
  stories: pipelineResult.changedItems,
495
498
  spaceId: to,
496
- options: { publish: false },
499
+ options: { publish: Boolean(publish) },
497
500
  }, config);
498
501
  }
499
502
  else if (itemType === "preset") {
@@ -527,7 +530,7 @@ const saveBackupToFile = async ({ itemType, res, folder, filename }, config) =>
527
530
  res: res,
528
531
  }, config);
529
532
  };
530
- export const migrateProvidedComponentsDataInStories = async ({ itemType, migrationConfig, migrateFrom, from, to, componentsToMigrate, filters, dryRun, fromFilePath, fileName, preparedMigrationConfigs, migrationComponentAliases, migrationComponentOverrides, }, config) => {
533
+ export const migrateProvidedComponentsDataInStories = async ({ itemType, migrationConfig, migrateFrom, from, to, componentsToMigrate, filters, dryRun, publish, fromFilePath, fileName, preparedMigrationConfigs, migrationComponentAliases, migrationComponentOverrides, }, config) => {
531
534
  const resolvedMigrationConfigs = preparedMigrationConfigs ||
532
535
  prepareMigrationConfigs({
533
536
  migrationConfig,
@@ -562,6 +565,7 @@ export const migrateProvidedComponentsDataInStories = async ({ itemType, migrati
562
565
  from,
563
566
  to,
564
567
  dryRun,
568
+ publish,
565
569
  migrateFrom,
566
570
  fromFilePath,
567
571
  fileName,
@@ -1,7 +1,7 @@
1
1
  export declare const mainDescription = "\n USAGE\n $ sb-mig [command]\n \n COMMANDS\n sync Synchronize components, datasources, roles, stories, assets with Storyblok space.\n discover Discover components, migration configs and write to file or stdout.\n backup Command for backing up anything related to Storyblok\n migrate Migrate content from space to space, or from file to space.\n debug Output extra debugging information\n help This screen\n \n Examples\n $ sb-mig sync components --all\n $ sb-mig debug \n";
2
2
  export declare const syncDescription = "\n Usage\n $ sb-mig sync [components|roles|datasources|plugins|content] [space separated file names] or --all\n \n Description\n Synchronize components, roles, datasources, plugins, content with Storyblok space.\n \n COMMANDS\n components - sync components\n roles - sync roles\n datasources - sync datasources\n plugins - sync plugins\n content - sync content (stories, assets) - ! right now destructive, it will move content from 1 space to another, completelly overwriting it\n \n FLAGS\n --all - Sync all components, roles, datasources [components, roles, datasources]\n --presets - Pass it, if u want to sync also with presets (will take longer) [components only]\n --dry-run - Preview planned changes without making writes [components, roles, datasources, plugins, content]\n \n --yes - Skip ask for confirmation (dangerous, but useful in CI/CD) [content only]\n --from - Space ID from which you want to sync content [content only]\n --to - Space ID to which you want to sync content [content only]\n --syncDirection [fromSpaceToFile|fromFileToSpace|fromSpaceToSpace|fromAWStoSpace] \n - Sync direction (from, to) [content only]\n \n EXAMPLES\n $ sb-mig sync components --all\n $ sb-mig sync components --all --dry-run\n $ sb-mig sync components --all --presets\n $ sb-mig sync components accordion accordion-item\n $ sb-mig sync components accordion accordion-item --presets\n \n $ sb-mig sync roles --all\n $ sb-mig sync roles --all --dry-run\n \n $ sb-mig sync datasources --all\n $ sb-mig sync datasources --all --dry-run\n \n $ sb-mig sync plugins my-awesome-plugin - (you have to be in catalog which has ./dist/export.js file with compiled plugin)\n \n $ sb-mig sync content --all --from 12345 --to 12345\n $ sb-mig sync content --stories --from 12345 --to 12345\n $ sb-mig sync content --assets --from 12345 --to 12345\n";
3
3
  export declare const copyDescription = "\n Usage\n $ sb-mig copy\n \n Description\n Copy stuff\n \n COMMANDS\n ?\n \n FLAGS\n ?\n \n EXAMPLES\n $ sb-mig copy ?\n";
4
- export declare const migrateDescription = "\n Usage\n $ sb-mig migrate [content] [space separated file names] or --all --from [spaceId] --to [spaceId] --migration [migration-config-filename]\n $ sb-mig migrate content --all --migration migration-a --migration migration-b --migration migration-c\n \n Description\n Migrate content from space to space, or from file to space. It's potentially dangerous command, so it will ask for confirmation.\n Use with care.\n \n COMMANDS\n content - migrate content \n \n FLAGS\n --from - Space ID from which you want to migrate / or file name if passed '--migrate-from file'\n --fromFilePath - Direct path to stories JSON file when using '--migrate-from file'\n --to - Space ID to which you want to migrate\n --migrate-from - Migrate from (space, file) default: space\n --migration - File name of migration file (without extension). Can be repeated for ordered pipeline in content migration.\n --migrationComponentAlias - Add extra component aliases for a migration. Repeatable. Format: <migration>:<source>=<alias1>,<alias2>\n --migrationComponents - Override the exact component scope for a migration. Repeatable. Format: <migration>:<component1>,<component2>\n --withSlug - Filter stories by full slug (can be repeated)\n --startsWith - Filter stories by starts_with prefix\n --yes - Skip ask for confirmation (dangerous, but useful in CI/CD)\n --dry-run - Preview what would be migrated without making any API changes\n --fileName - Stable base name for migration output files (disables timestamp suffix for migration artifacts)\n\n EXAMPLES\n $ sb-mig migrate content --all --from 12345 --to 12345 --migration file-with-migration\n $ sb-mig migrate content --all --from 12345 --to 12345 --migration migration-a --migration migration-b --migration migration-c\n $ sb-mig migrate content --all --from 12345 --to 12345 --migration colorPickerModeValues --migrationComponentAlias colorPickerModeValues:sb-button=sb-open-drift-button\n $ sb-mig migrate content --all --from 12345 --to 12345 --migration colorPickerModeValues --migrationComponentAlias colorPickerModeValues:sb-section=sb-tour-page-section --migrationComponents colorPickerModeValues:sb-section,sb-tour-page-section\n $ sb-mig migrate content --all --from 12345 --to 12345 --migration file-with-migration --withSlug blog/home --withSlug docs/getting-started\n $ sb-mig migrate content --all --from 12345 --to 12345 --migration file-with-migration --startsWith blog/\n $ sb-mig migrate content --all --from 12345 --to 12345 --migration v3toV4AllMigrations --dry-run --fileName brand-hub-v3-v4-run\n $ sb-mig migrate content --all --migrate-from file --from file-with-stories --to 12345 --migration file-with-migration\n $ sb-mig migrate content --all --migrate-from file --fromFilePath sbmig/migrations/dry-run--123---story-to-migrate__2026-2-9_20-51.json --to 12345 --migration migration-a --migration migration-b\n $ sb-mig migrate content my-component-1 my-component-2 --from 12345 --to 12345 --migration file-with-migration\n $ sb-mig migrate content my-component-1 my-component-2 --migrate-from file --from file-with-stories --to 12345 --migration file-with-migration \n";
4
+ export declare const migrateDescription = "\n Usage\n $ sb-mig migrate [content] [space separated file names] or --all --from [spaceId] --to [spaceId] --migration [migration-config-filename]\n $ sb-mig migrate content --all --migration migration-a --migration migration-b --migration migration-c\n \n Description\n Migrate content from space to space, or from file to space. It's potentially dangerous command, so it will ask for confirmation.\n Use with care.\n \n COMMANDS\n content - migrate content \n \n FLAGS\n --from - Space ID from which you want to migrate / or file name if passed '--migrate-from file'\n --fromFilePath - Direct path to stories JSON file when using '--migrate-from file'\n --to - Space ID to which you want to migrate\n --migrate-from - Migrate from (space, file) default: space\n --migration - File name of migration file (without extension). Can be repeated for ordered pipeline in content migration.\n --migrationComponentAlias - Add extra component aliases for a migration. Repeatable. Format: <migration>:<source>=<alias1>,<alias2>\n --migrationComponents - Override the exact component scope for a migration. Repeatable. Format: <migration>:<component1>,<component2>\n --withSlug - Filter stories by full slug (can be repeated)\n --startsWith - Filter stories by starts_with prefix\n --yes - Skip ask for confirmation (dangerous, but useful in CI/CD)\n --dry-run - Preview what would be migrated without making any API changes\n --publish - Publish changed stories immediately after migration. Default: save draft. [content only]\n --fileName - Stable base name for migration output files (disables timestamp suffix for migration artifacts)\n\n EXAMPLES\n $ sb-mig migrate content --all --from 12345 --to 12345 --migration file-with-migration\n $ sb-mig migrate content --all --from 12345 --to 12345 --migration migration-a --migration migration-b --migration migration-c\n $ sb-mig migrate content --all --from 12345 --to 12345 --migration colorPickerModeValues --migrationComponentAlias colorPickerModeValues:sb-button=sb-open-drift-button\n $ sb-mig migrate content --all --from 12345 --to 12345 --migration colorPickerModeValues --migrationComponentAlias colorPickerModeValues:sb-section=sb-tour-page-section --migrationComponents colorPickerModeValues:sb-section,sb-tour-page-section\n $ sb-mig migrate content --all --from 12345 --to 12345 --migration file-with-migration --withSlug blog/home --withSlug docs/getting-started\n $ sb-mig migrate content --all --from 12345 --to 12345 --migration file-with-migration --startsWith blog/\n $ sb-mig migrate content --all --from 12345 --to 12345 --migration file-with-migration --publish --yes\n $ sb-mig migrate content --all --from 12345 --to 12345 --migration v3toV4AllMigrations --dry-run --fileName brand-hub-v3-v4-run\n $ sb-mig migrate content --all --migrate-from file --from file-with-stories --to 12345 --migration file-with-migration\n $ sb-mig migrate content --all --migrate-from file --fromFilePath sbmig/migrations/dry-run--123---story-to-migrate__2026-2-9_20-51.json --to 12345 --migration migration-a --migration migration-b\n $ sb-mig migrate content my-component-1 my-component-2 --from 12345 --to 12345 --migration file-with-migration\n $ sb-mig migrate content my-component-1 my-component-2 --migrate-from file --from file-with-stories --to 12345 --migration file-with-migration \n";
5
5
  export declare const revertDescription = "\n Usage\n $ sb-mig revert [content] --migration\n \n Description\n Revert content migration\n \n COMMANDS\n content - revert content migration \n \n FLAGS\n --migration - ???\n --yes - Skip ask for confirmation (dangerous, but useful in CI/CD) \n \n EXAMPLES\n $ sb-mig revert content --migration \n";
6
6
  export declare const discoverDescription = "\n Usage\n $ sb-mig discover [components|migrations] --all --write\n\n Description\n Discover all components or migration configs and write to file or stdout\n\n COMMANDS\n components - discover components\n migrations - discover migration config files\n\n FLAGS\n --all - Discover all components or migration configs\n --write - Write to file\n\n EXAMPLES\n $ sb-mig discover components --all\n $ sb-mig discover components --all --write\n $ sb-mig discover migrations --all\n";
7
7
  export declare const migrationsDescription = "\n Usage\n $ sb-mig migrations recognize\n \n Description\n Recognize migrations you need to apply\n \n COMMANDS\n recognize - recognize migrations\n \n FLAGS \n \n EXAMPLES\n $ sb-mig migrations recognize\n\n";
@@ -98,6 +98,7 @@ export const migrateDescription = `
98
98
  --startsWith - Filter stories by starts_with prefix
99
99
  --yes - Skip ask for confirmation (dangerous, but useful in CI/CD)
100
100
  --dry-run - Preview what would be migrated without making any API changes
101
+ --publish - Publish changed stories immediately after migration. Default: save draft. [content only]
101
102
  --fileName - Stable base name for migration output files (disables timestamp suffix for migration artifacts)
102
103
 
103
104
  EXAMPLES
@@ -107,6 +108,7 @@ export const migrateDescription = `
107
108
  $ sb-mig migrate content --all --from 12345 --to 12345 --migration colorPickerModeValues --migrationComponentAlias colorPickerModeValues:sb-section=sb-tour-page-section --migrationComponents colorPickerModeValues:sb-section,sb-tour-page-section
108
109
  $ sb-mig migrate content --all --from 12345 --to 12345 --migration file-with-migration --withSlug blog/home --withSlug docs/getting-started
109
110
  $ sb-mig migrate content --all --from 12345 --to 12345 --migration file-with-migration --startsWith blog/
111
+ $ sb-mig migrate content --all --from 12345 --to 12345 --migration file-with-migration --publish --yes
110
112
  $ sb-mig migrate content --all --from 12345 --to 12345 --migration v3toV4AllMigrations --dry-run --fileName brand-hub-v3-v4-run
111
113
  $ sb-mig migrate content --all --migrate-from file --from file-with-stories --to 12345 --migration file-with-migration
112
114
  $ sb-mig migrate content --all --migrate-from file --fromFilePath sbmig/migrations/dry-run--123---story-to-migrate__2026-2-9_20-51.json --to 12345 --migration migration-a --migration migration-b
@@ -41,6 +41,7 @@ export const migrate = async (props) => {
41
41
  "withSlug",
42
42
  "startsWith",
43
43
  "dryRun",
44
+ "publish",
44
45
  "fileName",
45
46
  ]);
46
47
  Logger.warning(`This feature is in BETA. Use it at your own risk. The API might change in the future. (Probably in a standard Prisma like migration way)`);
@@ -60,6 +61,7 @@ export const migrate = async (props) => {
60
61
  const migrationComponentAliases = parseMigrationComponentAliasFlags(flags["migrationComponentAlias"]);
61
62
  const migrationComponentOverrides = parseMigrationComponentOverrideFlags(flags["migrationComponents"]);
62
63
  const dryRun = flags["dryRun"];
64
+ const publish = Boolean(flags["publish"]);
63
65
  const fileName = flags["fileName"];
64
66
  const withSlugFlag = flags["withSlug"];
65
67
  const withSlug = Array.isArray(withSlugFlag)
@@ -97,6 +99,7 @@ export const migrate = async (props) => {
97
99
  migrationComponentOverrides,
98
100
  filters: { withSlug, startsWith },
99
101
  dryRun,
102
+ publish,
100
103
  fromFilePath,
101
104
  fileName,
102
105
  }, apiConfig);
@@ -124,6 +127,7 @@ export const migrate = async (props) => {
124
127
  migrationComponentOverrides,
125
128
  filters: { withSlug, startsWith },
126
129
  dryRun,
130
+ publish,
127
131
  fromFilePath,
128
132
  fileName,
129
133
  }, apiConfig);
@@ -158,9 +162,13 @@ export const migrate = async (props) => {
158
162
  fromFallback ||
159
163
  getFrom(flags, apiConfig);
160
164
  const to = getTo(flags, apiConfig);
165
+ const publish = Boolean(flags["publish"]);
161
166
  if (migrationConfigs.length === 0) {
162
167
  throw new Error("Missing migration config. Pass exactly one --migration value for presets.");
163
168
  }
169
+ if (publish) {
170
+ throw new Error("--publish is only supported for 'migrate content'. Presets cannot be published.");
171
+ }
164
172
  if (migrationConfigs.length > 1) {
165
173
  throw new Error("Multiple --migration values are currently supported only for 'migrate content'. Presets support a single migration config.");
166
174
  }
package/dist/cli/index.js CHANGED
@@ -80,6 +80,10 @@ app.migrate = () => ({
80
80
  type: "boolean",
81
81
  default: false,
82
82
  },
83
+ publish: {
84
+ type: "boolean",
85
+ default: false,
86
+ },
83
87
  fileName: {
84
88
  type: "string",
85
89
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sb-mig",
3
- "version": "6.0.0-beta.2",
3
+ "version": "6.0.0-beta.3",
4
4
  "description": "CLI to rule the world. (and handle stuff related to Storyblok CMS)",
5
5
  "author": "Marcin Krawczyk <marckraw@icloud.com>",
6
6
  "license": "MIT",