
* fix: make contrib docs landing message clearer to users * v5.1.1 to main (#21954) * enhancement: ui issues and french translations (#21633) * chore: ui issues and french translations * chore: added missing translation * chore: made it prettier * fix: test CI/CD building repo 2 times (#21740) * fix: do not display fill from locales if i18n no enabled (#21737) * fix: do not display fill from locales if i18n no enabled * chore: disable only if there is not i18n enabled * fix: send ids when connecting relations to update u&p user role (#21726) * fix:update role * fix: send entry id when connecting/disconnecting relations * fix: changed empty components wording (#21630) * fix: changed empty components wording * fix: updated selectors * fix: made it prettier * enhancement: add preview panel button (#21776) * chore: add test workflow filters for each test type (#21770) * chore: upgrade mysql2 package to 3.9.8 (#21795) * feat: add mapping property support for documentation plugin's open api generated docs (#21752) * feat: add mapping property support for documentation plugin's open API generated spec Dynamic zones are reflected in the OpenAPI docs generated as an anyOf. We can use a discriminator and mapping to improve the docs. * fix: missing one value enum for __component property * enhancement: extract logic to convert component names to OpenAPI names * chore: run prettier write on clean schema attributes --------- Co-authored-by: Jamie Howard <48524071+jhoward1994@users.noreply.github.com> * chore: fix mysql workflow (#21801) * chore: upgrade koa/router to 12.0.2 (#21802) * Update "upgrade major" rules (#21745) * fix: broken list view pagination (#21800) * fix: broken list view pagination * chore: add list view pagination e2e test * enhancement: add copy preview url button (#21780) * enhancement: add copy preview button * chore: remove useClipboard from upload plugin * Add <latest> Upgrade Command (#21754) * Make locale/localizations private for non-localized cts (#21495) * chore: upgrade sendgrid-mail to 8.1.3 (#21797) * chore: re-enable history e2e tests (#21739) * fix: reenable history api tests fix: flaky findAndClose fix: close notifications * chore: add test workflow filters for each test type * chore: fix node versions * fix: match format of test.yml * revert: don't add test_result to skipped_tests * fix: add new outputs vars --------- Co-authored-by: Ben Irvin <ben@innerdvations.com> * fix: search by numeric numbers in a relation (#21873) * Sort Generated Content-Types and Components Definitions (#21868) * fix(e2e): remove webkit skip conditions (#21611) * fix(e2e): remove webkit skip conditions * chore: revert uniqueness spec to test others on ci * fix(e2e): ctb navigation * chore: ci config to speed up testing * chore: revert lock * chore(e2e): wip add webkit waiting * chore: single out history spec changes for ci * chore(e2e): use new webkit navigation for all affected test files * chore(e2e): revert e2e ci config so all tests run again * chore(e2e): temp skip uniqueness to test others * chore(e2e): revert so all tests run again * chore(e2e): re-skip uniqueness in webkit * chore(e2e): revert workflow yaml * chore(e2e): pr feedback --------- Co-authored-by: Ben Irvin <ben.irvin@strapi.io> * fix(strapi/types): add Attribute column type (#21858) * chore: add preview tracking (#21913) * chore: upgrade plop to 4.0.1 (#21798) * chore: upgrade cookie to 0.7.1 (#21833) * enhancement: DTS assert count of items sent and received is equal (#21900) * feat: added a count, start, finish counts to compare data recieved with data sent * feat: refactoring * feat: refactoring * v5.1.1 --------- Co-authored-by: Lucas Boilly <45385696+lucasboilly@users.noreply.github.com> Co-authored-by: Boegie19 <34578426+Boegie19@users.noreply.github.com> Co-authored-by: Rémi de Juvigny <8087692+remidej@users.noreply.github.com> Co-authored-by: Ben Irvin <ben.irvin@strapi.io> Co-authored-by: Pedro Cerejo <pedro.cerejo@tecnico.ulisboa.pt> Co-authored-by: Jamie Howard <48524071+jhoward1994@users.noreply.github.com> Co-authored-by: Jean-Sébastien Herbaux <jean-sebastien.herbaux@epitech.eu> Co-authored-by: Rémi de Juvigny <remi.dejuvigny@strapi.io> Co-authored-by: Ben Irvin <ben@innerdvations.com> Co-authored-by: Andrei Luca <1881266+iamandrewluca@users.noreply.github.com> Co-authored-by: Bassel Kanso <basselkanso82@gmail.com> * fix: prettier --------- Co-authored-by: Pierre Wizla <pwizla@users.noreply.github.com> Co-authored-by: Alexandre BODIN <alexandrebodin@users.noreply.github.com> Co-authored-by: Lucas Boilly <45385696+lucasboilly@users.noreply.github.com> Co-authored-by: Boegie19 <34578426+Boegie19@users.noreply.github.com> Co-authored-by: Rémi de Juvigny <8087692+remidej@users.noreply.github.com> Co-authored-by: Ben Irvin <ben.irvin@strapi.io> Co-authored-by: Pedro Cerejo <pedro.cerejo@tecnico.ulisboa.pt> Co-authored-by: Jamie Howard <48524071+jhoward1994@users.noreply.github.com> Co-authored-by: Jean-Sébastien Herbaux <jean-sebastien.herbaux@epitech.eu> Co-authored-by: Rémi de Juvigny <remi.dejuvigny@strapi.io> Co-authored-by: Ben Irvin <ben@innerdvations.com> Co-authored-by: Andrei Luca <1881266+iamandrewluca@users.noreply.github.com> 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.json
code
: 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;