storyblok 4.6.7 → 4.6.9
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/dist/index.mjs +29 -12
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -3114,7 +3114,9 @@ async function saveRollbackData({
|
|
|
3114
3114
|
const rollbackData = {
|
|
3115
3115
|
storyId: story.id,
|
|
3116
3116
|
name: story.name,
|
|
3117
|
-
content: story.content
|
|
3117
|
+
content: story.content,
|
|
3118
|
+
published: story.published,
|
|
3119
|
+
unpublished_changes: story.unpublished_changes
|
|
3118
3120
|
};
|
|
3119
3121
|
const rollbacksPath = resolvePath(path, `migrations/${space}/rollbacks`);
|
|
3120
3122
|
const componentNames = migrationNames.map((n) => getComponentNameFromFilename(n));
|
|
@@ -3226,7 +3228,8 @@ class MigrationStream extends Transform {
|
|
|
3226
3228
|
return null;
|
|
3227
3229
|
}
|
|
3228
3230
|
const targetComponent = this.options.componentName || getComponentNameFromFilename(migrationFile.name);
|
|
3229
|
-
|
|
3231
|
+
const migrationProcessed = applyMigrationToAllBlocks(storyContent, migrationFunction, targetComponent);
|
|
3232
|
+
processed = processed || migrationProcessed;
|
|
3230
3233
|
}
|
|
3231
3234
|
const newContentHash = hash(storyContent);
|
|
3232
3235
|
const contentChanged = originalContentHash !== newContentHash;
|
|
@@ -3234,7 +3237,13 @@ class MigrationStream extends Transform {
|
|
|
3234
3237
|
await saveRollbackData({
|
|
3235
3238
|
space: this.options.space,
|
|
3236
3239
|
path: this.options.path,
|
|
3237
|
-
story: {
|
|
3240
|
+
story: {
|
|
3241
|
+
id: story.id,
|
|
3242
|
+
name: story.name || "",
|
|
3243
|
+
content: story.content,
|
|
3244
|
+
published: story.published,
|
|
3245
|
+
unpublished_changes: story.unpublished_changes
|
|
3246
|
+
},
|
|
3238
3247
|
migrationTimestamp: this.timestamp,
|
|
3239
3248
|
migrationNames
|
|
3240
3249
|
});
|
|
@@ -3247,7 +3256,9 @@ class MigrationStream extends Transform {
|
|
|
3247
3256
|
return {
|
|
3248
3257
|
storyId: story.id,
|
|
3249
3258
|
name: story.name,
|
|
3250
|
-
content: storyContent
|
|
3259
|
+
content: storyContent,
|
|
3260
|
+
published: story.published,
|
|
3261
|
+
unpublished_changes: story.unpublished_changes
|
|
3251
3262
|
};
|
|
3252
3263
|
} else if (processed && !contentChanged) {
|
|
3253
3264
|
this.results.skipped.push({
|
|
@@ -3317,10 +3328,10 @@ class MigrationStream extends Transform {
|
|
|
3317
3328
|
}
|
|
3318
3329
|
|
|
3319
3330
|
const isStoryPublishedWithoutChanges = (story) => {
|
|
3320
|
-
return
|
|
3331
|
+
return story.published && !story.unpublished_changes;
|
|
3321
3332
|
};
|
|
3322
3333
|
const isStoryWithUnpublishedChanges = (story) => {
|
|
3323
|
-
return story.unpublished_changes;
|
|
3334
|
+
return story.published && story.unpublished_changes;
|
|
3324
3335
|
};
|
|
3325
3336
|
|
|
3326
3337
|
class UpdateStream extends Writable {
|
|
@@ -3354,7 +3365,7 @@ class UpdateStream extends Writable {
|
|
|
3354
3365
|
}
|
|
3355
3366
|
}
|
|
3356
3367
|
async updateStory(migrationResult) {
|
|
3357
|
-
const { storyId, name, content } = migrationResult;
|
|
3368
|
+
const { storyId, name, content, published, unpublished_changes } = migrationResult;
|
|
3358
3369
|
const storyName = name || storyId.toString();
|
|
3359
3370
|
try {
|
|
3360
3371
|
const payload = {
|
|
@@ -3365,9 +3376,9 @@ class UpdateStream extends Writable {
|
|
|
3365
3376
|
},
|
|
3366
3377
|
force_update: "1"
|
|
3367
3378
|
};
|
|
3368
|
-
if (this.options.publish === "published" && isStoryPublishedWithoutChanges({ published
|
|
3379
|
+
if (this.options.publish === "published" && isStoryPublishedWithoutChanges({ published, unpublished_changes })) {
|
|
3369
3380
|
payload.publish = 1;
|
|
3370
|
-
} else if (this.options.publish === "published-with-changes" && isStoryWithUnpublishedChanges({ published
|
|
3381
|
+
} else if (this.options.publish === "published-with-changes" && isStoryWithUnpublishedChanges({ published, unpublished_changes })) {
|
|
3371
3382
|
payload.publish = 1;
|
|
3372
3383
|
} else if (this.options.publish === "all") {
|
|
3373
3384
|
payload.publish = 1;
|
|
@@ -3582,14 +3593,20 @@ migrationsCommand.command("rollback [migrationFile]").description("Rollback a mi
|
|
|
3582
3593
|
for (const story of rollbackData.stories) {
|
|
3583
3594
|
const spinner = new Spinner({ verbose }).start(`Restoring story ${chalk.hex(colorPalette.PRIMARY)(story.name || story.storyId)}...`);
|
|
3584
3595
|
try {
|
|
3585
|
-
|
|
3596
|
+
const payload = {
|
|
3586
3597
|
story: {
|
|
3587
3598
|
content: story.content,
|
|
3588
3599
|
id: story.storyId,
|
|
3589
3600
|
name: story.name
|
|
3590
3601
|
},
|
|
3591
3602
|
force_update: "1"
|
|
3592
|
-
}
|
|
3603
|
+
};
|
|
3604
|
+
if (story.published !== void 0 && story.unpublished_changes !== void 0) {
|
|
3605
|
+
if (story.published && !story.unpublished_changes) {
|
|
3606
|
+
payload.publish = 1;
|
|
3607
|
+
}
|
|
3608
|
+
}
|
|
3609
|
+
await updateStory(space, story.storyId, payload);
|
|
3593
3610
|
spinner.succeed(`Restored story ${chalk.hex(colorPalette.PRIMARY)(story.name || story.storyId)}`);
|
|
3594
3611
|
} catch (error) {
|
|
3595
3612
|
spinner.failed(`Failed to restore story ${chalk.hex(colorPalette.PRIMARY)(story.name || story.storyId)}: ${error.message}`);
|
|
@@ -5182,7 +5199,7 @@ program$1.command(`${commands.CREATE} [project-path]`).alias("c").description(`S
|
|
|
5182
5199
|
konsola.br();
|
|
5183
5200
|
});
|
|
5184
5201
|
|
|
5185
|
-
const version = "4.6.
|
|
5202
|
+
const version = "4.6.9";
|
|
5186
5203
|
const pkg = {
|
|
5187
5204
|
version: version};
|
|
5188
5205
|
|