* fix(e2e): update blocks e2e tests (#22010) * feat: preview content in an iframe (#22008) * feat: preview content * fix: pr suggestions * fix: pr suggestions * fix: iframe border * fix(content-manager): translate content-type and component attributes (#21951) * fix: review workflow persist data (#21984) * fix: review workflow persist data * fix: persist assignee * chore: comment * fix: typings and code simplification * Feat(cloud-cli): deploy command allows environment to be passed (#21898) * feat: deploy to env * chore: migrate media-library components to Typescript (#21622) * chore: migrate to TS AudoPreview component * chore: migrate to TS PaginationContext component * chore: migrate to TS Pagination component * chore: migrate to TS PaginationFolder components * chore: migrate to TS PaginationFooter index component * chore: migrate to TS isSelectable util * chore: migrate to TS PageSize component * chore: migrate to TS DialogFooter component * chore: migrate to TS Draggable component * chore: migrate to TS ContextInfo component * chore: migrate to TS ContextInfo test and index component * chore: migrate to TS PreviewBox components file * chore: migrate to TS DialogHeader component * chore: migrate to TS RemoveFolderDialog * chore: migrate to TS EmptyAssetGrid * chore: migrate to TS EmptyAssets index file * chore: migrate to TS AssetCardBase * chore: migrate to TS AudioAssetCard component * chore: migrate to TS DocAssetCard component * chore: migrate to TS ImageAssetCard component * chore: migrate to TS AssetCard unit tests * chore: migrate to TS SearchAsset component * chore: migrate to TS UploadProgress component * chore: migrate to TS FromComputerForm component * chore: migrate to TS FromUrlForm component * chore: migrate to TS AddAssetStep component * chore: migrate to TS VideoPreview component * chore: migrate to TS VideoAssetCard component * chore: migrate to TS UploadingAssetCard component * chore: migrate to TS PreviewCell component * chore: migrate to TS CellContent component * chore: migrate to TS TableRows component * chore: migrate to TS TableList component * chore: migrate to TS SortPicker component * chore: migrate to TS Option component with utils * chore: migrate to TS EmptyStateAsset and CarouselAsset * chore: migrate to TS CopyLinkButton component * chore: migrate to TS CarouselAssetActions component * chore: migrate to TS FolderGridList component * chore: migrate to TS FolderCardContext * chore: migrate to TS FolderCard component * chore: migrate to TS FolderCardBody component * chore: migrate to TS FolderCardBodyAction component * chore: migrate to TS FolderCardCheckbox component * chore: migrate to TS FolderCard unit test * chore: migrate to TS getFilterList * chore: migrate to TS FilterValueInput component * chore: migrate to TS FilterTag * chore: migrate to TS FilterList * chore: migrate to TS EditFolderModalHeader component * chore: migrate to TS AssetPreview component * chore: migrate to TS CroppingActions component * chore: migrate to TS RemoveAssetDialog component * chore: migrate to TS ReplaceMediaButton component * chore: migrate to TS AssetCard component * chore: migrate to TS AssetGridList * chore: migrate to TS PendingAssetStep component * chore: migrate to TS SelectedStep component * chore: migrate to TS PreviewBox component * chore: migrate to TS SelectTree * chore: migrate to TS SelectTree unit test * chore: migrate to TS BulkMoveDialog * chore: migrate to TS EditFolderContent component * chore: migrate to TS FilterValueInput * chore: migrato to TS CrumbSimpleMenuAsync * chore: migrate to TS Breadcrumbs * chore: migrate to TS Filters component * chore: migrate to TS EditAssetDialog * chore: migrate to TS CarouselAssets * chore: migrate to TS UploadAssetDialog and BrowseStep * chore: migrate to TS BrowseStep test * chore: migrate to TS AssetDialog component * chore: migrate to TS MediaLibraryDialog component * chore: migrate to TS MediaLibraryDialog component * chore: remove a useless type guard * chore: fix small stuff * chore: fix BulkMoveDialog unit test * chore: fix some types * chore: fix prettier problems * chore: fix review's comments * chore: fix review comments * chore: bump design system to 2.0.0-rc.12 (#22043) * chore: bump design system dep * fix: remove showBullet prop from Status components * chore: snapshot updates * feat(content-manager): integrate review workflows with releases (#21882) * feat(review-workflows): adding required stage for publishing (#21380) * feat(review-workflows): adding required stage for publishing * fix(review-workflows): fixs on rw required stage * fix(review-workflows): selected required stage when stage name changed * fix(review-workflows): bug when creating new rw * feat(review-workflows): check entry stage before publish (#21400) * feat(content-releases): add stage check to releases details page (#21497) * feat(content-releases): add stage check * fix(content-releases): apply suggestions on releases x review workflows * feat(content-releases): considered review stage when getting the action status (#21612) * feat(content-releases): considered review stage when getting the action status * fix: apply changes to reviewWorkflows on schema * fix: add api test for review workflows publish stage * fix: api tests * fix: validation message errors (#21878) * feat: add workflowId & hasRequiredStageToPublish to workflows metrics events (#21897) * fix(content-releases): skip flaky test * fix: update accessible name in history.spec.ts --------- * fix(e2e): enable e2e tests in editview.spec.ts (#21986) * fix: run discardDrafts without concurrency (#22074) * chore: config nx releases (#22087) * chore: dependency change * fix: revert release script * v5.3.0 --------- Co-authored-by: markkaylor <mark.kaylor@strapi.io> Co-authored-by: Gonzalo Andres Garcia <nouvellegon@gmail.com> Co-authored-by: Simone <startae14@gmail.com> Co-authored-by: Rémi de Juvigny <remi.dejuvigny@strapi.io> Co-authored-by: Rémi de Juvigny <8087692+remidej@users.noreply.github.com> Co-authored-by: Fernando Chávez <fernando.chavez@strapi.io> Co-authored-by: Ben Irvin <ben.irvin@strapi.io> Co-authored-by: Bassel Kanso <basselkanso82@gmail.com>
Strapi Upgrade Tool
Description
The Strapi Upgrade Tool is the CLI for facilitating upgrades between Strapi versions.
It handles updating a project's package.json with the correct version of Strapi, running the package installer, and running suggested code transforms for breaking changes (in major versions).
Once released, it will be the recommended way to update to any major, minor, and patch versions of Strapi instead of manually modifying package.json files.
The tool offers the following commands:
major [options] Upgrade to the next available major version of Strapi
minor [options] Upgrade to the latest minor and patch version of Strapi for the
current major
patch [options] Upgrade to latest patch version of Strapi for the current major
and minor
codemods [options] Run a set of available codemods for the selected target version
without updating the Strapi dependencies
What's a codemod / code transform?
Codemods are a scripted way to refactor code. Here we are providing and running these scripts for users for any changes necessary in user code between Strapi versions.
For example, if we need to rename a package used by Strapi projects, instead of instructing users to change the import, we provide a script that searches through the user's project and does the replacement for them.
Types of Transforms
The upgrade tool provides two types of transforms:
json: for updating a project's .json files, primarily intended for thepackage.jsoncode: codemods; for updating a project's .js and .ts files
Data Migrations
Data migrations are not handled by the upgrade tool.
For Strapi v4, no data migrations will be allowed and no support is planned (except in extenuating circumstances eg, a critical security issue somehow relating to the database shape)
For Strapi v5, automated data migrations can be added in the packages/core/database package of the develop branch of this repo.
Usage
This package is not yet released, so currently it can be run on a project in the monorepo /examples directory with the following command:
../../packages/utils/upgrade/bin/upgrade
Run the command with the --help option to see all the available options.
[Coming Soon] The Strapi Upgrade tool will be available using npx @strapi/upgrade and an alias for that within a project using strapi upgrade
Writing a code transforms
To begin your code transform script, create a file upgrade/resources/codemods/{X.X.X}/{short-description-of-action}.{code|json}.ts where X.X.X is the target version of Strapi the codemod will be run for.
For example, all breaking changes for the initial release of Strapi v5 will go in upgrade/resources/codemods/5.0.0
Note that "short-description-of-action" will be converted to text displayed to the user with hyphens converted to spaces, for example: "short description of action"
'json' transforms
Your transform will be called for every json file in a user's project, and you must return the json object (modified or not) at the end to be passed to the next transform.
Here is an example JSON Transform script:
import path from 'node:path';
import type { JSONTransform } from '../../..';
const transform: JSONTransform = (file, params) => {
// Extract the json api and the cwd so we can target specific files
const { cwd, json } = params;
// To target only a root level package.json file:
const rootPackageJsonPath = path.join(cwd, 'package.json');
if (file.path !== rootPackageJsonPath) {
// Return the json object unmodified to pass it to the next transform
return file.json;
}
// Use json() to get useful helpers for performing your transform
const j = json(file.json);
const strapiDepAddress = 'dependencies.@strapi/strapi';
// if this file contains a value at dependencies.@strapi/strapi
if (j.has(strapiDepAddress)) {
// we set the value to 5.0.0
j.set(strapiDepAddress, '5.0.0');
}
// at the end we must return the modified json object
return j.root();
};
export default transform;
For reference, these are the types for the relevant objects, which can be found in packages/utils/upgrade/src/modules/json/types.ts:
export interface JSONTransformParams {
cwd: string;
json: (object: Utils.JSONObject) => JSONTransformAPI;
}
export interface JSONTransformAPI {
get<T extends Utils.JSONValue>(path?: string, defaultValue?: T): T | undefined;
has(path: string): boolean;
set(path: string, value: Utils.JSONValue): this;
merge(other: Utils.JSONObject): this;
root(): Utils.JSONObject;
remove(path: string): this;
}
export type JSONTransform = (file: JSONSourceFile, params: JSONTransformParams) => Utils.JSONObject;
The methods available from json() are wrappers for the lodash methods of the same name:
- get(path, default): get path or default if not found
- set(path, value): set path (such as 'engines.node', 'dependencies', 'author.name') to value
- has(path): checks if path exists
- merge(obj): merges two json objects
- root(): returns the whole json object
- remove(path): removes the attribute given the path (such as 'dependencies.strapi')
'code' codemod transforms
Codemod transforms use the jscodeshift library to modify code passed in. Please see their documentation for advanced details.
The file and api parameters come directly from the jsoncodeshift arguments of the same name.
import type { Transform } from 'jscodeshift';
const transform: Transform = (file, api) => {
// Extract the jscodeshift API
const { j } = api;
// Parse the file content
const root = j(file.source);
root
// Find console.log calls expressions
.find(j.CallExpression, {
callee: { object: { name: 'console' }, property: { name: 'log' } },
})
// For each call expression
.forEach((path) => {
const { callee } = path.node;
if (
// Make sure the callee is a member expression (object/property)
j.MemberExpression.check(callee) &&
// Make sure the property is an actual identifier (contains a name property)
j.Identifier.check(callee.property)
) {
// Update the property's identifier name
callee.property.name = 'info';
}
});
// Return the updated file content
return root.toSource();
};
export default transform;