# How to migrate a tenant to XPLib
This guide describes how to enable XP as a Library in a tenant.
The new Marfeel architecture uses providers as its main extension point and requires that MediaGroups are decoupled from the core infrastructure. Achieve this decoupling, and unlock the usage of any provider with XP as a library.
TIP
Even if some of the following files are at the root of the MediaGroup, you can activate XPLib one tenant at a time in features.json.
# Step 1: Assess the complexity
First, scan the MediaGroup looking for incompatibilities and anything that will require migration.
Find your tenant's audit result in Kibana (opens new window) for a quick overview of the complexity. Depending on the audit results, check the following points:
- Check the
main.js
file/s. They should contain only the initialization functions or as little customizations as possible.
- Remove old widgets if possible
- Ask TEN if there is any customization you don't know how to migrate
- Fix the imports if necessary
Imports
Take the opportunity to clean JavaScript imports, if you can.
Use the caretaker command on each JS file:
cd MediaGroup/tenant.com
npx @marfeel/caretaker to-marfeel-packages index/src/js/main.js
Make sure the tenant still works after any import change. You can also search the public-modules file (opens new window) to find the available functions.
- Ad configuration: Check which AdServers the tenant uses and note which ones will need migration to providers. If the tenant doesn't use inventory.json, you must create it.
- Validate if required Adserver providers exist
- Check if the old Adservers are still in use: if not, remove them.
Metrics: XPLib tenants use analytics.json, which is only compatible with analytics providers. Assess which metrics the tenant is using and check if they exist as providers. The ones that aren't, need to be migrated.
Widgets: Check if the tenant is using widgets. If there are any in
main.js
, they ideally need to be migrated to a widget provider. Also, check for widgets using metadata: if there are any, replace them with a middlewareCustom JSP: Some custom JSP can be removed or replaced by new Marfeel components.
Check if the tenant uses PhantomJS and how complex would be the migration to Puppeteer.
Check if the tenant uses LayoutDescriptor and otherwise, it needs to be configured.
renovate.json
must be in the root folder of the repository. Add it if it isn't already there:
{
"extends": ["github>Marfeel/renovate-config"]
}
After all these checks, you will have a clear idea of how complex the migration is. Now it's time to discuss with CS / Tech Lead about how to distribute tasks and give a rough estimation to the tenant if necessary.
# Step 2: Migrate the tenant
- Create the package.json file from the template (opens new window).
Make sure all dependencies use the latest versions, especially @marfeel/core.
Replace
REPOSITORY_NAME
with your MediaGroup information.Remove
"**/src/whiteCollar/*.js"
fromeslintIgnore
if the tenant uses Puppeteer.Fast packages update
To update all the dependencies to their latest version, follow these steps:
- Run
npx npm-check-updates -u
in the MediaGroup: it updates all the versions in yourpackage.json
. - Remove the
package-lock.json
file. - Run
npm install
: the new versions are installed, and the newpackage-lock.json
is generated!
- Run
Update the
.gitignore
file so it has the same content as the template (opens new window).Add
.npmrc
file as it is in the template (opens new window).Replace the providers that already exist in core for metrics, widgets, and ads.
- Add the provider in the right JSON
- Remove the old implementation
npm install
each package
Remove all main.l.js files, or rename them to main.xl.js if xl doesn't exist.
Add
useMarfeelXPAsALibrary
flag to features.json.Remove the
useMetricsJson
flag from the definition.Change the links from
bc.
tolive.mrf.io
indefinition.json
and check if there are other resources that require this change.Implement the necessary providers spotted in Step 1: Assess the complexity.
Once all providers are implemented, add them to the right JSON files and install their packages.
- Verify all widgets, metrics, and ads are working as expected
- Run
npm i
to generate the final package-lock.json, which you must also commit.
Optional considerations:
- Add the
invokeMiddleware
flag in features.json if there is any middleware - Add the
enableReact
flag in definition.json if there are any widget providers