Merge pull request #126 from pluginpal/feature/migrate-v5

feat: initial v5 migration
pull/127/head 2.0.0-beta.1
Boaz Poolman 2024-05-08 23:04:40 +02:00 committed by GitHub
commit 980593dc54
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
43 changed files with 8599 additions and 553 deletions

View File

@ -26,6 +26,13 @@
"strapi": true "strapi": true
}, },
"rules": { "rules": {
"import/no-unresolved": [2, {
"ignore": [
"@strapi/strapi/admin",
"@strapi/admin/strapi-admin"
]
}],
"template-curly-spacing" : "off", "template-curly-spacing" : "off",
"indent" : "off", "indent" : "off",

View File

@ -8,6 +8,7 @@ on:
branches: branches:
- master - master
- develop - develop
- beta
jobs: jobs:
lint: lint:

View File

@ -4,15 +4,16 @@ import { useDispatch, useSelector } from 'react-redux';
import { isEmpty } from 'lodash'; import { isEmpty } from 'lodash';
import { Button } from '@strapi/design-system'; import { Button } from '@strapi/design-system';
import { Map } from 'immutable'; import { Map } from 'immutable';
import { useNotification } from '@strapi/helper-plugin'; import { getFetchClient, useNotification } from '@strapi/strapi/admin';
import { useIntl } from 'react-intl'; import { useIntl } from 'react-intl';
import ConfirmModal from '../ConfirmModal'; import ConfirmModal from '../ConfirmModal';
import { exportAllConfig, importAllConfig } from '../../state/actions/Config'; import { exportAllConfig, importAllConfig } from '../../state/actions/Config';
const ActionButtons = () => { const ActionButtons = () => {
const { post, get } = getFetchClient();
const dispatch = useDispatch(); const dispatch = useDispatch();
const toggleNotification = useNotification(); const { toggleNotification } = useNotification();
const [modalIsOpen, setModalIsOpen] = useState(false); const [modalIsOpen, setModalIsOpen] = useState(false);
const [actionType, setActionType] = useState(''); const [actionType, setActionType] = useState('');
const partialDiff = useSelector((state) => state.getIn(['config', 'partialDiff'], Map({}))).toJS(); const partialDiff = useSelector((state) => state.getIn(['config', 'partialDiff'], Map({}))).toJS();
@ -43,7 +44,7 @@ const ActionButtons = () => {
isOpen={modalIsOpen} isOpen={modalIsOpen}
onClose={closeModal} onClose={closeModal}
type={actionType} type={actionType}
onSubmit={(force) => actionType === 'import' ? dispatch(importAllConfig(partialDiff, force, toggleNotification)) : dispatch(exportAllConfig(partialDiff, toggleNotification))} onSubmit={(force) => actionType === 'import' ? dispatch(importAllConfig(partialDiff, force, toggleNotification, formatMessage, post, get)) : dispatch(exportAllConfig(partialDiff, toggleNotification, formatMessage, post, get))}
/> />
</ActionButtonsStyling> </ActionButtonsStyling>
); );

View File

@ -1,14 +1,16 @@
import React, { useState } from 'react'; import React, { useState } from 'react';
import { useIntl } from 'react-intl'; import { useIntl } from 'react-intl';
import { useDispatch } from 'react-redux'; import { useDispatch } from 'react-redux';
import { NoContent, useNotification } from '@strapi/helper-plugin'; import { getFetchClient, useNotification } from '@strapi/strapi/admin';
import { Button } from '@strapi/design-system'; import { Button, EmptyStateLayout } from '@strapi/design-system';
import { EmptyDocuments } from '@strapi/icons';
import { exportAllConfig } from '../../state/actions/Config'; import { exportAllConfig } from '../../state/actions/Config';
import ConfirmModal from '../ConfirmModal'; import ConfirmModal from '../ConfirmModal';
const FirstExport = () => { const FirstExport = () => {
const toggleNotification = useNotification(); const { post, get } = getFetchClient();
const { toggleNotification } = useNotification();
const dispatch = useDispatch(); const dispatch = useDispatch();
const [modalIsOpen, setModalIsOpen] = useState(false); const [modalIsOpen, setModalIsOpen] = useState(false);
const { formatMessage } = useIntl(); const { formatMessage } = useIntl();
@ -19,15 +21,12 @@ const FirstExport = () => {
isOpen={modalIsOpen} isOpen={modalIsOpen}
onClose={() => setModalIsOpen(false)} onClose={() => setModalIsOpen(false)}
type="export" type="export"
onSubmit={() => dispatch(exportAllConfig([], toggleNotification))} onSubmit={() => dispatch(exportAllConfig([], toggleNotification, formatMessage, post, get))}
/> />
<NoContent <EmptyStateLayout
content={{ content={formatMessage({ id: 'config-sync.FirstExport.Message' })}
id: 'emptyState',
defaultMessage:
formatMessage({ id: 'config-sync.FirstExport.Message' }),
}}
action={<Button onClick={() => setModalIsOpen(true)}>{formatMessage({ id: 'config-sync.FirstExport.Button' })}</Button>} action={<Button onClick={() => setModalIsOpen(true)}>{formatMessage({ id: 'config-sync.FirstExport.Button' })}</Button>}
icon={<EmptyDocuments width={160} />}
/> />
</div> </div>
); );

View File

@ -1,18 +0,0 @@
import React from 'react';
import { NoContent } from '@strapi/helper-plugin';
import { useIntl } from 'react-intl';
const NoChanges = () => {
const { formatMessage } = useIntl();
return (
<NoContent
content={{
id: 'emptyState',
defaultMessage:
formatMessage({ id: 'config-sync.NoChanges.Message' }),
}}
/>
);
};
export default NoChanges;

View File

@ -0,0 +1,16 @@
import React from 'react';
import { EmptyStateLayout } from '@strapi/design-system';
import { useIntl } from 'react-intl';
import { EmptyDocuments } from '@strapi/icons';
const NoChanges = () => {
const { formatMessage } = useIntl();
return (
<EmptyStateLayout
content={formatMessage({ id: 'config-sync.NoChanges.Message', defaultMessage: 'No differences between DB and sync directory. You are up-to-date!' })}
icon={<EmptyDocuments width={160} />}
/>
);
};
export default NoChanges;

View File

@ -7,7 +7,7 @@
import React from 'react'; import React from 'react';
import { Provider } from 'react-redux'; import { Provider } from 'react-redux';
import { CheckPagePermissions } from '@strapi/helper-plugin'; import { Page } from '@strapi/strapi/admin';
import pluginPermissions from '../../permissions'; import pluginPermissions from '../../permissions';
import Header from '../../components/Header'; import Header from '../../components/Header';
@ -16,12 +16,12 @@ import ConfigPage from '../ConfigPage';
const App = () => { const App = () => {
return ( return (
<CheckPagePermissions permissions={pluginPermissions.settings}> <Page.Protect permissions={pluginPermissions.settings}>
<Provider store={store}> <Provider store={store}>
<Header /> <Header />
<ConfigPage /> <ConfigPage />
</Provider> </Provider>
</CheckPagePermissions> </Page.Protect>
); );
}; };

View File

@ -7,22 +7,27 @@ import {
Alert, Alert,
Typography, Typography,
} from '@strapi/design-system'; } from '@strapi/design-system';
import { useNotification } from '@strapi/helper-plugin'; import { useNotification } from '@strapi/strapi/admin';
import { getFetchClient } from '@strapi/admin/strapi-admin';
import { useIntl } from 'react-intl';
import { getAllConfigDiff, getAppEnv } from '../../state/actions/Config'; import { getAllConfigDiff, getAppEnv } from '../../state/actions/Config';
import ConfigList from '../../components/ConfigList'; import ConfigList from '../../components/ConfigList';
import ActionButtons from '../../components/ActionButtons'; import ActionButtons from '../../components/ActionButtons';
const ConfigPage = () => { const ConfigPage = () => {
const toggleNotification = useNotification(); const { toggleNotification } = useNotification();
const { get } = getFetchClient();
const { formatMessage } = useIntl();
const dispatch = useDispatch(); const dispatch = useDispatch();
const isLoading = useSelector((state) => state.getIn(['config', 'isLoading'], Map({}))); const isLoading = useSelector((state) => state.getIn(['config', 'isLoading'], Map({})));
const configDiff = useSelector((state) => state.getIn(['config', 'configDiff'], Map({}))); const configDiff = useSelector((state) => state.getIn(['config', 'configDiff'], Map({})));
const appEnv = useSelector((state) => state.getIn(['config', 'appEnv', 'env'])); const appEnv = useSelector((state) => state.getIn(['config', 'appEnv', 'env']));
useEffect(() => { useEffect(() => {
dispatch(getAllConfigDiff(toggleNotification)); dispatch(getAllConfigDiff(toggleNotification, formatMessage, get));
dispatch(getAppEnv(toggleNotification)); dispatch(getAppEnv(toggleNotification, formatMessage, get));
}, []); }, []);
return ( return (

View File

@ -1,8 +1,8 @@
const pluginPkg = require('../../../package.json'); import pluginPkg from '../../../package.json';
const pluginId = pluginPkg.name.replace( const pluginId = pluginPkg.name.replace(
/^strapi-plugin-/i, /^strapi-plugin-/i,
'', '',
); );
module.exports = pluginId; export default pluginId;

View File

@ -0,0 +1,11 @@
const prefixPluginTranslations = (trad, pluginId) => {
if (!pluginId) {
throw new TypeError("pluginId can't be empty");
}
return Object.keys(trad).reduce((acc, current) => {
acc[`${pluginId}.${current}`] = trad[current];
return acc;
}, {});
};
export { prefixPluginTranslations };

View File

@ -1,6 +1,6 @@
import { prefixPluginTranslations } from '@strapi/helper-plugin';
import pluginPkg from '../../package.json'; import pluginPkg from '../../package.json';
import pluginId from './helpers/pluginId'; import pluginId from './helpers/pluginId';
import { prefixPluginTranslations } from './helpers/prefixPluginTranslations';
import pluginPermissions from './permissions'; import pluginPermissions from './permissions';
// import pluginIcon from './components/PluginIcon'; // import pluginIcon from './components/PluginIcon';
// import getTrad from './helpers/getTrad'; // import getTrad from './helpers/getTrad';

View File

@ -4,18 +4,16 @@
* *
*/ */
import { request } from '@strapi/helper-plugin'; export function getAllConfigDiff(toggleNotification, formatMessage, get) {
export function getAllConfigDiff(toggleNotification) {
return async function(dispatch) { return async function(dispatch) {
dispatch(setLoadingState(true)); dispatch(setLoadingState(true));
try { try {
const configDiff = await request('/config-sync/diff', { method: 'GET' }); const configDiff = await get('/config-sync/diff');
dispatch(setConfigPartialDiffInState([])); dispatch(setConfigPartialDiffInState([]));
dispatch(setConfigDiffInState(configDiff)); dispatch(setConfigDiffInState(configDiff.data));
dispatch(setLoadingState(false)); dispatch(setLoadingState(false));
} catch (err) { } catch (err) {
toggleNotification({ type: 'warning', message: { id: 'notification.error' } }); toggleNotification({ type: 'warning', message: formatMessage({ id: 'notification.error' }) });
dispatch(setLoadingState(false)); dispatch(setLoadingState(false));
} }
}; };
@ -37,40 +35,34 @@ export function setConfigPartialDiffInState(config) {
}; };
} }
export function exportAllConfig(partialDiff, toggleNotification) { export function exportAllConfig(partialDiff, toggleNotification, formatMessage, post, get) {
return async function(dispatch) { return async function(dispatch) {
dispatch(setLoadingState(true)); dispatch(setLoadingState(true));
try { try {
const { message } = await request('/config-sync/export', { const response = await post('/config-sync/export', partialDiff);
method: 'POST', toggleNotification({ type: 'success', message: response.data.message });
body: partialDiff, dispatch(getAllConfigDiff(toggleNotification, formatMessage, get));
});
toggleNotification({ type: 'success', message });
dispatch(getAllConfigDiff(toggleNotification));
dispatch(setLoadingState(false)); dispatch(setLoadingState(false));
} catch (err) { } catch (err) {
toggleNotification({ type: 'warning', message: { id: 'notification.error' } }); toggleNotification({ type: 'warning', message: formatMessage({ id: 'notification.error' }) });
dispatch(setLoadingState(false)); dispatch(setLoadingState(false));
} }
}; };
} }
export function importAllConfig(partialDiff, force, toggleNotification) { export function importAllConfig(partialDiff, force, toggleNotification, formatMessage, post, get) {
return async function(dispatch) { return async function(dispatch) {
dispatch(setLoadingState(true)); dispatch(setLoadingState(true));
try { try {
const { message } = await request('/config-sync/import', { const response = await post('/config-sync/import', {
method: 'POST', force,
body: { config: partialDiff,
force,
config: partialDiff,
},
}); });
toggleNotification({ type: 'success', message }); toggleNotification({ type: 'success', message: response.data.message });
dispatch(getAllConfigDiff(toggleNotification)); dispatch(getAllConfigDiff(toggleNotification, formatMessage, get));
dispatch(setLoadingState(false)); dispatch(setLoadingState(false));
} catch (err) { } catch (err) {
toggleNotification({ type: 'warning', message: { id: 'notification.error' } }); toggleNotification({ type: 'warning', message: formatMessage({ id: 'notification.error' }) });
dispatch(setLoadingState(false)); dispatch(setLoadingState(false));
} }
}; };
@ -84,15 +76,13 @@ export function setLoadingState(value) {
}; };
} }
export function getAppEnv(toggleNotification) { export function getAppEnv(toggleNotification, formatMessage, get) {
return async function(dispatch) { return async function(dispatch) {
try { try {
const envVars = await request('/config-sync/app-env', { const envVars = await get('/config-sync/app-env');
method: 'GET', dispatch(setAppEnvInState(envVars.data));
});
dispatch(setAppEnvInState(envVars));
} catch (err) { } catch (err) {
toggleNotification({ type: 'warning', message: { id: 'notification.error' } }); toggleNotification({ type: 'warning', message: formatMessage({ id: 'notification.error' }) });
} }
}; };
} }

View File

@ -32,6 +32,7 @@
"inquirer": "^8.2.0", "inquirer": "^8.2.0",
"react-diff-viewer-continued": "3.2.6", "react-diff-viewer-continued": "3.2.6",
"redux-immutable": "^4.0.0", "redux-immutable": "^4.0.0",
"react-intl": "6.6.2",
"redux-thunk": "^2.3.0" "redux-thunk": "^2.3.0"
}, },
"author": { "author": {
@ -54,13 +55,13 @@
"strapi-server.js" "strapi-server.js"
], ],
"peerDependencies": { "peerDependencies": {
"@strapi/strapi": "^4.0.0" "@strapi/strapi": "^5.0.0-beta.2"
}, },
"devDependencies": { "devDependencies": {
"@strapi/design-system": "^1.14.1", "@strapi/design-system": "^1.16.0",
"@strapi/helper-plugin": "^4.19.0", "@strapi/icons": "^1.16.0",
"@strapi/icons": "^1.14.1", "@strapi/utils": "5.0.0-beta.2",
"@strapi/utils": "^4.19.0", "@strapi/strapi": "5.0.0-beta.2",
"babel-eslint": "9.0.0", "babel-eslint": "9.0.0",
"eslint": "^7.32.0", "eslint": "^7.32.0",
"eslint-config-airbnb": "^18.2.1", "eslint-config-airbnb": "^18.2.1",
@ -78,7 +79,6 @@
"jest-styled-components": "^7.0.2", "jest-styled-components": "^7.0.2",
"lodash": "^4.17.11", "lodash": "^4.17.11",
"react": "^17.0.2", "react": "^17.0.2",
"react-intl": "^5.20.12",
"react-redux": "^7.2.2", "react-redux": "^7.2.2",
"redux": "^4.0.5", "redux": "^4.0.5",
"styled-components": "^5.2.3" "styled-components": "^5.2.3"

View File

@ -1,7 +1,10 @@
HOST=0.0.0.0 HOST=0.0.0.0
PORT=1337 PORT=1337
APP_KEYS=SIwLyqu+IpSHIuUBDQfPZg==,Nzqbq2C3ATsR19u5XEAJQA==,/Agk5Sn8M4EzfoSiIHcDlQ==,gSxT2T0k2zbQatKXUV0zCA== APP_KEYS=ujfpKPEst1tv0WDxJEhjJw==,MOnFjWYKbWYmtrBZ3cQTFQ==,zQpX70tJw/Mw+Y656kXfVA==,xJT1vbsiz3cgabfgpLu72w==
API_TOKEN_SALT=reQcUBbGXD2KWG2QpRn7DA== API_TOKEN_SALT=5FoJkYoZV8IA6+NnZJDzng==
ADMIN_JWT_SECRET= 69mzgwRGfEBUhPEaas8EBA== ADMIN_JWT_SECRET=tkeg3+HqE+QmTd2ITEivtA==
TRANSFER_TOKEN_SALT=/LTsSGpC5afHICjZu0oEuQ== TRANSFER_TOKEN_SALT=UUMCRQ2cx9qvKw/RkB815Q==
JWT_SECRET=E0TTVdsr+M/FXAjfrNIgXA== # Database
DATABASE_CLIENT=sqlite
DATABASE_FILENAME=.tmp/data.db
JWT_SECRET=Dn/nUGQsREUw4/lfQYOScw==

View File

@ -1,2 +1,7 @@
HOST=0.0.0.0 HOST=0.0.0.0
PORT=1337 PORT=1337
APP_KEYS="toBeModified1,toBeModified2"
API_TOKEN_SALT=tobemodified
ADMIN_JWT_SECRET=tobemodified
TRANSFER_TOKEN_SALT=tobemodified
JWT_SECRET=tobemodified

View File

@ -0,0 +1,14 @@
/**
* This file was automatically generated by Strapi.
* Any modifications made will be discarded.
*/
import usersPermissions from "@strapi/plugin-users-permissions/strapi-admin";
import strapiCloud from "@strapi/plugin-cloud/strapi-admin";
import { renderAdmin } from "@strapi/strapi/admin";
renderAdmin(document.getElementById("strapi"), {
plugins: {
"users-permissions": usersPermissions,
"strapi-cloud": strapiCloud,
},
});

View File

@ -0,0 +1,63 @@
<!doctype html>
<html lang="en">
<!--
This file was automatically generated by Strapi.
Any modifications made will be discarded.
-->
<head>
<meta charset="utf-8" />
<meta
name="viewport"
content="width=device-width, initial-scale=1, viewport-fit=cover"
/>
<meta name="robots" content="noindex" />
<meta name="referrer" content="same-origin" />
<title>Strapi Admin</title>
<style>
html,
body,
#strapi {
height: 100%;
}
body {
margin: 0;
-webkit-font-smoothing: antialiased;
}
</style>
</head>
<body>
<div id="strapi"></div>
<noscript
><div class="strapi--root">
<div class="strapi--no-js">
<style type="text/css">
.strapi--root {
position: absolute;
top: 0;
right: 0;
left: 0;
bottom: 0;
background: #fff;
}
.strapi--no-js {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
text-align: center;
font-family: helvetica, arial, sans-serif;
}
</style>
<h1>JavaScript disabled</h1>
<p>
Please
<a href="https://www.enable-javascript.com/">enable JavaScript</a>
in your browser and reload the page to proceed.
</p>
</div>
</div></noscript
>
<script type="module" src="/.strapi/client/app.js"></script>
</body>
</html>

View File

@ -1,3 +1,57 @@
# Strapi application # 🚀 Getting started with Strapi
A quick description of your strapi application Strapi comes with a full featured [Command Line Interface](https://docs.strapi.io/dev-docs/cli) (CLI) which lets you scaffold and manage your project in seconds.
### `develop`
Start your Strapi application with autoReload enabled. [Learn more](https://docs.strapi.io/dev-docs/cli#strapi-develop)
```
npm run develop
# or
yarn develop
```
### `start`
Start your Strapi application with autoReload disabled. [Learn more](https://docs.strapi.io/dev-docs/cli#strapi-start)
```
npm run start
# or
yarn start
```
### `build`
Build your admin panel. [Learn more](https://docs.strapi.io/dev-docs/cli#strapi-build)
```
npm run build
# or
yarn build
```
## ⚙️ Deployment
Strapi gives you many possible deployment options for your project including [Strapi Cloud](https://cloud.strapi.io). Browse the [deployment section of the documentation](https://docs.strapi.io/dev-docs/deployment) to find the best solution for your use case.
## 📚 Learn more
- [Resource center](https://strapi.io/resource-center) - Strapi resource center.
- [Strapi documentation](https://docs.strapi.io) - Official Strapi documentation.
- [Strapi tutorials](https://strapi.io/tutorials) - List of tutorials made by the core team and the community.
- [Strapi blog](https://strapi.io/blog) - Official Strapi blog containing articles made by the Strapi team and the community.
- [Changelog](https://strapi.io/changelog) - Find out about the Strapi product updates, new features and general improvements.
Feel free to check out the [Strapi GitHub repository](https://github.com/strapi/strapi). Your feedback and contributions are welcome!
## ✨ Community
- [Discord](https://discord.strapi.io) - Come chat with the Strapi community including the core team.
- [Forum](https://forum.strapi.io/) - Place to discuss, ask questions and find answers, show your Strapi project and get feedback or just talk with other Community members.
- [Awesome Strapi](https://github.com/strapi/awesome-strapi) - A curated list of awesome things related to Strapi.
---
<sub>🤫 Psst! [Strapi is hiring](https://strapi.io/careers).</sub>

View File

@ -1,11 +1,12 @@
const fs = require('fs'); const fs = require('fs');
const Strapi = require('@strapi/strapi'); const { createStrapi, compileStrapi } = require('@strapi/strapi');
let instance; let instance;
async function setupStrapi() { async function setupStrapi() {
if (!instance) { if (!instance) {
await Strapi().load(); const appContext = await compileStrapi();
await createStrapi(appContext).load();
instance = strapi; instance = strapi;
await instance.server.mount(); await instance.server.mount();

View File

@ -1,10 +1,7 @@
module.exports = ({ env }) => ({ module.exports = ({ env }) => ({
auth: { auth: {
secret: env('ADMIN_JWT_SECRET', 'c27c3833823a12b0761e32b22dc0113a'), secret: env('ADMIN_JWT_SECRET'),
}, },
watchIgnoreFiles: [
'**/config/sync/**',
],
apiToken: { apiToken: {
salt: env('API_TOKEN_SALT'), salt: env('API_TOKEN_SALT'),
}, },
@ -13,4 +10,8 @@ module.exports = ({ env }) => ({
salt: env('TRANSFER_TOKEN_SALT'), salt: env('TRANSFER_TOKEN_SALT'),
}, },
}, },
flags: {
nps: env.bool('FLAG_NPS', true),
promoteEE: env.bool('FLAG_PROMOTE_EE', true),
},
}); });

View File

@ -1,11 +1,12 @@
module.exports = [ module.exports = [
'strapi::logger',
'strapi::errors', 'strapi::errors',
'strapi::security', 'strapi::security',
'strapi::cors', 'strapi::cors',
'strapi::poweredBy', 'strapi::poweredBy',
'strapi::logger',
'strapi::query', 'strapi::query',
'strapi::body', 'strapi::body',
'strapi::session',
'strapi::favicon', 'strapi::favicon',
'strapi::public', 'strapi::public',
]; ];

View File

@ -1,4 +1,10 @@
module.exports = ({ env }) => ({ module.exports = ({ env }) => ({
host: env('HOST', '0.0.0.0'), host: env('HOST', '0.0.0.0'),
port: env.int('PORT', 1337), port: env.int('PORT', 1337),
app: {
keys: env.array('APP_KEYS'),
},
webhooks: {
populateRelations: env.bool('WEBHOOKS_POPULATE_RELATIONS', false),
},
}); });

View File

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.6 KiB

BIN
playground/favicon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 497 B

8
playground/jsconfig.json Normal file
View File

@ -0,0 +1,8 @@
{
"compilerOptions": {
"moduleResolution": "nodenext",
"target": "ES2021",
"checkJs": true,
"allowJs": true
}
}

View File

@ -1,5 +1,5 @@
{ {
"name": "playground", "name": "strapi-5-beta",
"private": true, "private": true,
"version": "0.1.0", "version": "0.1.0",
"description": "A Strapi application", "description": "A Strapi application",
@ -16,24 +16,24 @@
"supertest": "^6.3.3" "supertest": "^6.3.3"
}, },
"dependencies": { "dependencies": {
"@strapi/plugin-i18n": "^4.19.0", "@strapi/strapi": "5.0.0-beta.2",
"@strapi/plugin-users-permissions": "^4.19.0", "@strapi/plugin-users-permissions": "5.0.0-beta.2",
"@strapi/strapi": "^4.19.0", "@strapi/plugin-cloud": "5.0.0-beta.2",
"better-sqlite3": "^8.6.0", "better-sqlite3": "9.4.3",
"react": "^18.0.0", "react": "^18.0.0",
"react-dom": "^18.0.0", "react-dom": "^18.0.0",
"react-router-dom": "^5.2.0", "react-router-dom": "^6.0.0",
"strapi-plugin-config-sync": "./..", "strapi-plugin-config-sync": "./..",
"styled-components": "^5.2.1" "styled-components": "5.3.3"
}, },
"author": { "author": {
"name": "A Strapi developer" "name": "A Strapi developer"
}, },
"strapi": { "strapi": {
"uuid": "2e84e366-1e09-43c2-a99f-a0d0acbc2ca5" "uuid": "edadddbd-0f25-4da7-833b-d4cd7dcae2fc"
}, },
"engines": { "engines": {
"node": ">=18.x.x <=20.x.x", "node": ">=18.0.0 <=20.x.x",
"npm": ">=6.0.0" "npm": ">=6.0.0"
}, },
"license": "MIT" "license": "MIT"

View File

@ -0,0 +1,5 @@
import type { Struct, Schema } from '@strapi/strapi';
declare module '@strapi/strapi' {
export module Public {}
}

View File

@ -0,0 +1,730 @@
import type { Struct, Schema } from '@strapi/strapi';
export interface AdminPermission extends Struct.CollectionTypeSchema {
collectionName: 'admin_permissions';
info: {
name: 'Permission';
description: '';
singularName: 'permission';
pluralName: 'permissions';
displayName: 'Permission';
};
options: {
draftAndPublish: false;
};
pluginOptions: {
'content-manager': {
visible: false;
};
'content-type-builder': {
visible: false;
};
};
attributes: {
action: Schema.Attribute.String &
Schema.Attribute.Required &
Schema.Attribute.SetMinMaxLength<{
minLength: 1;
}>;
actionParameters: Schema.Attribute.JSON & Schema.Attribute.DefaultTo<{}>;
subject: Schema.Attribute.String &
Schema.Attribute.SetMinMaxLength<{
minLength: 1;
}>;
properties: Schema.Attribute.JSON & Schema.Attribute.DefaultTo<{}>;
conditions: Schema.Attribute.JSON & Schema.Attribute.DefaultTo<[]>;
role: Schema.Attribute.Relation<'manyToOne', 'admin::role'>;
createdAt: Schema.Attribute.DateTime;
updatedAt: Schema.Attribute.DateTime;
publishedAt: Schema.Attribute.DateTime;
createdBy: Schema.Attribute.Relation<'oneToOne', 'admin::user'> &
Schema.Attribute.Private;
updatedBy: Schema.Attribute.Relation<'oneToOne', 'admin::user'> &
Schema.Attribute.Private;
locale: Schema.Attribute.String;
};
}
export interface AdminUser extends Struct.CollectionTypeSchema {
collectionName: 'admin_users';
info: {
name: 'User';
description: '';
singularName: 'user';
pluralName: 'users';
displayName: 'User';
};
options: {
draftAndPublish: false;
};
pluginOptions: {
'content-manager': {
visible: false;
};
'content-type-builder': {
visible: false;
};
};
attributes: {
firstname: Schema.Attribute.String &
Schema.Attribute.SetMinMaxLength<{
minLength: 1;
}>;
lastname: Schema.Attribute.String &
Schema.Attribute.SetMinMaxLength<{
minLength: 1;
}>;
username: Schema.Attribute.String;
email: Schema.Attribute.Email &
Schema.Attribute.Required &
Schema.Attribute.Private &
Schema.Attribute.Unique &
Schema.Attribute.SetMinMaxLength<{
minLength: 6;
}>;
password: Schema.Attribute.Password &
Schema.Attribute.Private &
Schema.Attribute.SetMinMaxLength<{
minLength: 6;
}>;
resetPasswordToken: Schema.Attribute.String & Schema.Attribute.Private;
registrationToken: Schema.Attribute.String & Schema.Attribute.Private;
isActive: Schema.Attribute.Boolean &
Schema.Attribute.Private &
Schema.Attribute.DefaultTo<false>;
roles: Schema.Attribute.Relation<'manyToMany', 'admin::role'> &
Schema.Attribute.Private;
blocked: Schema.Attribute.Boolean &
Schema.Attribute.Private &
Schema.Attribute.DefaultTo<false>;
preferedLanguage: Schema.Attribute.String;
createdAt: Schema.Attribute.DateTime;
updatedAt: Schema.Attribute.DateTime;
publishedAt: Schema.Attribute.DateTime;
createdBy: Schema.Attribute.Relation<'oneToOne', 'admin::user'> &
Schema.Attribute.Private;
updatedBy: Schema.Attribute.Relation<'oneToOne', 'admin::user'> &
Schema.Attribute.Private;
locale: Schema.Attribute.String;
};
}
export interface AdminRole extends Struct.CollectionTypeSchema {
collectionName: 'admin_roles';
info: {
name: 'Role';
description: '';
singularName: 'role';
pluralName: 'roles';
displayName: 'Role';
};
options: {
draftAndPublish: false;
};
pluginOptions: {
'content-manager': {
visible: false;
};
'content-type-builder': {
visible: false;
};
};
attributes: {
name: Schema.Attribute.String &
Schema.Attribute.Required &
Schema.Attribute.Unique &
Schema.Attribute.SetMinMaxLength<{
minLength: 1;
}>;
code: Schema.Attribute.String &
Schema.Attribute.Required &
Schema.Attribute.Unique &
Schema.Attribute.SetMinMaxLength<{
minLength: 1;
}>;
description: Schema.Attribute.String;
users: Schema.Attribute.Relation<'manyToMany', 'admin::user'>;
permissions: Schema.Attribute.Relation<'oneToMany', 'admin::permission'>;
createdAt: Schema.Attribute.DateTime;
updatedAt: Schema.Attribute.DateTime;
publishedAt: Schema.Attribute.DateTime;
createdBy: Schema.Attribute.Relation<'oneToOne', 'admin::user'> &
Schema.Attribute.Private;
updatedBy: Schema.Attribute.Relation<'oneToOne', 'admin::user'> &
Schema.Attribute.Private;
locale: Schema.Attribute.String;
};
}
export interface AdminApiToken extends Struct.CollectionTypeSchema {
collectionName: 'strapi_api_tokens';
info: {
name: 'Api Token';
singularName: 'api-token';
pluralName: 'api-tokens';
displayName: 'Api Token';
description: '';
};
options: {
draftAndPublish: false;
};
pluginOptions: {
'content-manager': {
visible: false;
};
'content-type-builder': {
visible: false;
};
};
attributes: {
name: Schema.Attribute.String &
Schema.Attribute.Required &
Schema.Attribute.Unique &
Schema.Attribute.SetMinMaxLength<{
minLength: 1;
}>;
description: Schema.Attribute.String &
Schema.Attribute.SetMinMaxLength<{
minLength: 1;
}> &
Schema.Attribute.DefaultTo<''>;
type: Schema.Attribute.Enumeration<['read-only', 'full-access', 'custom']> &
Schema.Attribute.Required &
Schema.Attribute.DefaultTo<'read-only'>;
accessKey: Schema.Attribute.String &
Schema.Attribute.Required &
Schema.Attribute.SetMinMaxLength<{
minLength: 1;
}>;
lastUsedAt: Schema.Attribute.DateTime;
permissions: Schema.Attribute.Relation<
'oneToMany',
'admin::api-token-permission'
>;
expiresAt: Schema.Attribute.DateTime;
lifespan: Schema.Attribute.BigInteger;
createdAt: Schema.Attribute.DateTime;
updatedAt: Schema.Attribute.DateTime;
publishedAt: Schema.Attribute.DateTime;
createdBy: Schema.Attribute.Relation<'oneToOne', 'admin::user'> &
Schema.Attribute.Private;
updatedBy: Schema.Attribute.Relation<'oneToOne', 'admin::user'> &
Schema.Attribute.Private;
locale: Schema.Attribute.String;
};
}
export interface AdminApiTokenPermission extends Struct.CollectionTypeSchema {
collectionName: 'strapi_api_token_permissions';
info: {
name: 'API Token Permission';
description: '';
singularName: 'api-token-permission';
pluralName: 'api-token-permissions';
displayName: 'API Token Permission';
};
options: {
draftAndPublish: false;
};
pluginOptions: {
'content-manager': {
visible: false;
};
'content-type-builder': {
visible: false;
};
};
attributes: {
action: Schema.Attribute.String &
Schema.Attribute.Required &
Schema.Attribute.SetMinMaxLength<{
minLength: 1;
}>;
token: Schema.Attribute.Relation<'manyToOne', 'admin::api-token'>;
createdAt: Schema.Attribute.DateTime;
updatedAt: Schema.Attribute.DateTime;
publishedAt: Schema.Attribute.DateTime;
createdBy: Schema.Attribute.Relation<'oneToOne', 'admin::user'> &
Schema.Attribute.Private;
updatedBy: Schema.Attribute.Relation<'oneToOne', 'admin::user'> &
Schema.Attribute.Private;
locale: Schema.Attribute.String;
};
}
export interface AdminTransferToken extends Struct.CollectionTypeSchema {
collectionName: 'strapi_transfer_tokens';
info: {
name: 'Transfer Token';
singularName: 'transfer-token';
pluralName: 'transfer-tokens';
displayName: 'Transfer Token';
description: '';
};
options: {
draftAndPublish: false;
};
pluginOptions: {
'content-manager': {
visible: false;
};
'content-type-builder': {
visible: false;
};
};
attributes: {
name: Schema.Attribute.String &
Schema.Attribute.Required &
Schema.Attribute.Unique &
Schema.Attribute.SetMinMaxLength<{
minLength: 1;
}>;
description: Schema.Attribute.String &
Schema.Attribute.SetMinMaxLength<{
minLength: 1;
}> &
Schema.Attribute.DefaultTo<''>;
accessKey: Schema.Attribute.String &
Schema.Attribute.Required &
Schema.Attribute.SetMinMaxLength<{
minLength: 1;
}>;
lastUsedAt: Schema.Attribute.DateTime;
permissions: Schema.Attribute.Relation<
'oneToMany',
'admin::transfer-token-permission'
>;
expiresAt: Schema.Attribute.DateTime;
lifespan: Schema.Attribute.BigInteger;
createdAt: Schema.Attribute.DateTime;
updatedAt: Schema.Attribute.DateTime;
publishedAt: Schema.Attribute.DateTime;
createdBy: Schema.Attribute.Relation<'oneToOne', 'admin::user'> &
Schema.Attribute.Private;
updatedBy: Schema.Attribute.Relation<'oneToOne', 'admin::user'> &
Schema.Attribute.Private;
locale: Schema.Attribute.String;
};
}
export interface AdminTransferTokenPermission
extends Struct.CollectionTypeSchema {
collectionName: 'strapi_transfer_token_permissions';
info: {
name: 'Transfer Token Permission';
description: '';
singularName: 'transfer-token-permission';
pluralName: 'transfer-token-permissions';
displayName: 'Transfer Token Permission';
};
options: {
draftAndPublish: false;
};
pluginOptions: {
'content-manager': {
visible: false;
};
'content-type-builder': {
visible: false;
};
};
attributes: {
action: Schema.Attribute.String &
Schema.Attribute.Required &
Schema.Attribute.SetMinMaxLength<{
minLength: 1;
}>;
token: Schema.Attribute.Relation<'manyToOne', 'admin::transfer-token'>;
createdAt: Schema.Attribute.DateTime;
updatedAt: Schema.Attribute.DateTime;
publishedAt: Schema.Attribute.DateTime;
createdBy: Schema.Attribute.Relation<'oneToOne', 'admin::user'> &
Schema.Attribute.Private;
updatedBy: Schema.Attribute.Relation<'oneToOne', 'admin::user'> &
Schema.Attribute.Private;
locale: Schema.Attribute.String;
};
}
export interface PluginUploadFile extends Struct.CollectionTypeSchema {
collectionName: 'files';
info: {
singularName: 'file';
pluralName: 'files';
displayName: 'File';
description: '';
};
options: {
draftAndPublish: false;
};
pluginOptions: {
'content-manager': {
visible: false;
};
'content-type-builder': {
visible: false;
};
};
attributes: {
name: Schema.Attribute.String & Schema.Attribute.Required;
alternativeText: Schema.Attribute.String;
caption: Schema.Attribute.String;
width: Schema.Attribute.Integer;
height: Schema.Attribute.Integer;
formats: Schema.Attribute.JSON;
hash: Schema.Attribute.String & Schema.Attribute.Required;
ext: Schema.Attribute.String;
mime: Schema.Attribute.String & Schema.Attribute.Required;
size: Schema.Attribute.Decimal & Schema.Attribute.Required;
url: Schema.Attribute.String & Schema.Attribute.Required;
previewUrl: Schema.Attribute.String;
provider: Schema.Attribute.String & Schema.Attribute.Required;
provider_metadata: Schema.Attribute.JSON;
related: Schema.Attribute.Relation<'morphToMany'>;
folder: Schema.Attribute.Relation<'manyToOne', 'plugin::upload.folder'> &
Schema.Attribute.Private;
folderPath: Schema.Attribute.String &
Schema.Attribute.Required &
Schema.Attribute.Private &
Schema.Attribute.SetMinMaxLength<{
minLength: 1;
}>;
createdAt: Schema.Attribute.DateTime;
updatedAt: Schema.Attribute.DateTime;
publishedAt: Schema.Attribute.DateTime;
createdBy: Schema.Attribute.Relation<'oneToOne', 'admin::user'> &
Schema.Attribute.Private;
updatedBy: Schema.Attribute.Relation<'oneToOne', 'admin::user'> &
Schema.Attribute.Private;
locale: Schema.Attribute.String;
};
}
export interface PluginUploadFolder extends Struct.CollectionTypeSchema {
collectionName: 'upload_folders';
info: {
singularName: 'folder';
pluralName: 'folders';
displayName: 'Folder';
};
options: {
draftAndPublish: false;
};
pluginOptions: {
'content-manager': {
visible: false;
};
'content-type-builder': {
visible: false;
};
};
attributes: {
name: Schema.Attribute.String &
Schema.Attribute.Required &
Schema.Attribute.SetMinMaxLength<{
minLength: 1;
}>;
pathId: Schema.Attribute.Integer &
Schema.Attribute.Required &
Schema.Attribute.Unique;
parent: Schema.Attribute.Relation<'manyToOne', 'plugin::upload.folder'>;
children: Schema.Attribute.Relation<'oneToMany', 'plugin::upload.folder'>;
files: Schema.Attribute.Relation<'oneToMany', 'plugin::upload.file'>;
path: Schema.Attribute.String &
Schema.Attribute.Required &
Schema.Attribute.SetMinMaxLength<{
minLength: 1;
}>;
createdAt: Schema.Attribute.DateTime;
updatedAt: Schema.Attribute.DateTime;
publishedAt: Schema.Attribute.DateTime;
createdBy: Schema.Attribute.Relation<'oneToOne', 'admin::user'> &
Schema.Attribute.Private;
updatedBy: Schema.Attribute.Relation<'oneToOne', 'admin::user'> &
Schema.Attribute.Private;
locale: Schema.Attribute.String;
};
}
export interface PluginI18NLocale extends Struct.CollectionTypeSchema {
collectionName: 'i18n_locale';
info: {
singularName: 'locale';
pluralName: 'locales';
collectionName: 'locales';
displayName: 'Locale';
description: '';
};
options: {
draftAndPublish: false;
};
pluginOptions: {
'content-manager': {
visible: false;
};
'content-type-builder': {
visible: false;
};
};
attributes: {
name: Schema.Attribute.String &
Schema.Attribute.SetMinMax<
{
min: 1;
max: 50;
},
number
>;
code: Schema.Attribute.String & Schema.Attribute.Unique;
createdAt: Schema.Attribute.DateTime;
updatedAt: Schema.Attribute.DateTime;
publishedAt: Schema.Attribute.DateTime;
createdBy: Schema.Attribute.Relation<'oneToOne', 'admin::user'> &
Schema.Attribute.Private;
updatedBy: Schema.Attribute.Relation<'oneToOne', 'admin::user'> &
Schema.Attribute.Private;
locale: Schema.Attribute.String;
};
}
export interface PluginContentReleasesRelease
extends Struct.CollectionTypeSchema {
collectionName: 'strapi_releases';
info: {
singularName: 'release';
pluralName: 'releases';
displayName: 'Release';
};
options: {
draftAndPublish: false;
};
pluginOptions: {
'content-manager': {
visible: false;
};
'content-type-builder': {
visible: false;
};
};
attributes: {
name: Schema.Attribute.String & Schema.Attribute.Required;
releasedAt: Schema.Attribute.DateTime;
scheduledAt: Schema.Attribute.DateTime;
timezone: Schema.Attribute.String;
status: Schema.Attribute.Enumeration<
['ready', 'blocked', 'failed', 'done', 'empty']
> &
Schema.Attribute.Required;
actions: Schema.Attribute.Relation<
'oneToMany',
'plugin::content-releases.release-action'
>;
createdAt: Schema.Attribute.DateTime;
updatedAt: Schema.Attribute.DateTime;
publishedAt: Schema.Attribute.DateTime;
createdBy: Schema.Attribute.Relation<'oneToOne', 'admin::user'> &
Schema.Attribute.Private;
updatedBy: Schema.Attribute.Relation<'oneToOne', 'admin::user'> &
Schema.Attribute.Private;
locale: Schema.Attribute.String;
};
}
export interface PluginContentReleasesReleaseAction
extends Struct.CollectionTypeSchema {
collectionName: 'strapi_release_actions';
info: {
singularName: 'release-action';
pluralName: 'release-actions';
displayName: 'Release Action';
};
options: {
draftAndPublish: false;
};
pluginOptions: {
'content-manager': {
visible: false;
};
'content-type-builder': {
visible: false;
};
};
attributes: {
type: Schema.Attribute.Enumeration<['publish', 'unpublish']> &
Schema.Attribute.Required;
entry: Schema.Attribute.Relation<'morphToOne'>;
contentType: Schema.Attribute.String & Schema.Attribute.Required;
locale: Schema.Attribute.String;
release: Schema.Attribute.Relation<
'manyToOne',
'plugin::content-releases.release'
>;
isEntryValid: Schema.Attribute.Boolean;
createdAt: Schema.Attribute.DateTime;
updatedAt: Schema.Attribute.DateTime;
publishedAt: Schema.Attribute.DateTime;
createdBy: Schema.Attribute.Relation<'oneToOne', 'admin::user'> &
Schema.Attribute.Private;
updatedBy: Schema.Attribute.Relation<'oneToOne', 'admin::user'> &
Schema.Attribute.Private;
};
}
export interface PluginUsersPermissionsPermission
extends Struct.CollectionTypeSchema {
collectionName: 'up_permissions';
info: {
name: 'permission';
description: '';
singularName: 'permission';
pluralName: 'permissions';
displayName: 'Permission';
};
options: {
draftAndPublish: false;
};
pluginOptions: {
'content-manager': {
visible: false;
};
'content-type-builder': {
visible: false;
};
};
attributes: {
action: Schema.Attribute.String & Schema.Attribute.Required;
role: Schema.Attribute.Relation<
'manyToOne',
'plugin::users-permissions.role'
>;
createdAt: Schema.Attribute.DateTime;
updatedAt: Schema.Attribute.DateTime;
publishedAt: Schema.Attribute.DateTime;
createdBy: Schema.Attribute.Relation<'oneToOne', 'admin::user'> &
Schema.Attribute.Private;
updatedBy: Schema.Attribute.Relation<'oneToOne', 'admin::user'> &
Schema.Attribute.Private;
locale: Schema.Attribute.String;
};
}
export interface PluginUsersPermissionsRole
extends Struct.CollectionTypeSchema {
collectionName: 'up_roles';
info: {
name: 'role';
description: '';
singularName: 'role';
pluralName: 'roles';
displayName: 'Role';
};
options: {
draftAndPublish: false;
};
pluginOptions: {
'content-manager': {
visible: false;
};
'content-type-builder': {
visible: false;
};
};
attributes: {
name: Schema.Attribute.String &
Schema.Attribute.Required &
Schema.Attribute.SetMinMaxLength<{
minLength: 3;
}>;
description: Schema.Attribute.String;
type: Schema.Attribute.String & Schema.Attribute.Unique;
permissions: Schema.Attribute.Relation<
'oneToMany',
'plugin::users-permissions.permission'
>;
users: Schema.Attribute.Relation<
'oneToMany',
'plugin::users-permissions.user'
>;
createdAt: Schema.Attribute.DateTime;
updatedAt: Schema.Attribute.DateTime;
publishedAt: Schema.Attribute.DateTime;
createdBy: Schema.Attribute.Relation<'oneToOne', 'admin::user'> &
Schema.Attribute.Private;
updatedBy: Schema.Attribute.Relation<'oneToOne', 'admin::user'> &
Schema.Attribute.Private;
locale: Schema.Attribute.String;
};
}
export interface PluginUsersPermissionsUser
extends Struct.CollectionTypeSchema {
collectionName: 'up_users';
info: {
name: 'user';
description: '';
singularName: 'user';
pluralName: 'users';
displayName: 'User';
};
options: {
timestamps: true;
draftAndPublish: false;
};
attributes: {
username: Schema.Attribute.String &
Schema.Attribute.Required &
Schema.Attribute.Unique &
Schema.Attribute.SetMinMaxLength<{
minLength: 3;
}>;
email: Schema.Attribute.Email &
Schema.Attribute.Required &
Schema.Attribute.SetMinMaxLength<{
minLength: 6;
}>;
provider: Schema.Attribute.String;
password: Schema.Attribute.Password &
Schema.Attribute.Private &
Schema.Attribute.SetMinMaxLength<{
minLength: 6;
}>;
resetPasswordToken: Schema.Attribute.String & Schema.Attribute.Private;
confirmationToken: Schema.Attribute.String & Schema.Attribute.Private;
confirmed: Schema.Attribute.Boolean & Schema.Attribute.DefaultTo<false>;
blocked: Schema.Attribute.Boolean & Schema.Attribute.DefaultTo<false>;
role: Schema.Attribute.Relation<
'manyToOne',
'plugin::users-permissions.role'
>;
createdAt: Schema.Attribute.DateTime;
updatedAt: Schema.Attribute.DateTime;
publishedAt: Schema.Attribute.DateTime;
createdBy: Schema.Attribute.Relation<'oneToOne', 'admin::user'> &
Schema.Attribute.Private;
updatedBy: Schema.Attribute.Relation<'oneToOne', 'admin::user'> &
Schema.Attribute.Private;
locale: Schema.Attribute.String;
};
}
declare module '@strapi/strapi' {
export module Public {
export interface ContentTypeSchemas {
'admin::permission': AdminPermission;
'admin::user': AdminUser;
'admin::role': AdminRole;
'admin::api-token': AdminApiToken;
'admin::api-token-permission': AdminApiTokenPermission;
'admin::transfer-token': AdminTransferToken;
'admin::transfer-token-permission': AdminTransferTokenPermission;
'plugin::upload.file': PluginUploadFile;
'plugin::upload.folder': PluginUploadFolder;
'plugin::i18n.locale': PluginI18NLocale;
'plugin::content-releases.release': PluginContentReleasesRelease;
'plugin::content-releases.release-action': PluginContentReleasesReleaseAction;
'plugin::users-permissions.permission': PluginUsersPermissionsPermission;
'plugin::users-permissions.role': PluginUsersPermissionsRole;
'plugin::users-permissions.user': PluginUsersPermissionsUser;
}
}
}

View File

@ -23,21 +23,21 @@ module.exports = async () => {
// The default types provided by the plugin. // The default types provided by the plugin.
defaultTypes(strapi).map((type) => { defaultTypes(strapi).map((type) => {
if (!strapi.config.get('plugin.config-sync.excludedTypes').includes(type.configName)) { if (!strapi.config.get('plugin::config-sync.excludedTypes').includes(type.configName)) {
types[type.configName] = new ConfigType(type); types[type.configName] = new ConfigType(type);
} }
}); });
// The types provided by other plugins. // The types provided by other plugins.
strapi.plugin('config-sync').pluginTypes.map((type) => { strapi.plugin('config-sync').pluginTypes.map((type) => {
if (!strapi.config.get('plugin.config-sync.excludedTypes').includes(type.configName)) { if (!strapi.config.get('plugin::config-sync.excludedTypes').includes(type.configName)) {
types[type.configName] = new ConfigType(type); types[type.configName] = new ConfigType(type);
} }
}); });
// The custom types provided by the user. // The custom types provided by the user.
strapi.config.get('plugin.config-sync.customTypes').map((type) => { strapi.config.get('plugin::config-sync.customTypes').map((type) => {
if (!strapi.config.get('plugin.config-sync.excludedTypes').includes(type.configName)) { if (!strapi.config.get('plugin::config-sync.excludedTypes').includes(type.configName)) {
types[type.configName] = new ConfigType(type); types[type.configName] = new ConfigType(type);
} }
}); });
@ -47,12 +47,12 @@ module.exports = async () => {
strapi.plugin('config-sync').types = registerTypes(); strapi.plugin('config-sync').types = registerTypes();
// Import on bootstrap. // Import on bootstrap.
if (strapi.config.get('plugin.config-sync.importOnBootstrap')) { if (strapi.config.get('plugin::config-sync.importOnBootstrap')) {
if (strapi.server.app.env === 'development') { if (strapi.server.app.env === 'development') {
strapi.log.warn(logMessage(`You can't use the 'importOnBootstrap' setting in the development env.`)); strapi.log.warn(logMessage(`You can't use the 'importOnBootstrap' setting in the development env.`));
} else if (process.env.CONFIG_SYNC_CLI === 'true') { } else if (process.env.CONFIG_SYNC_CLI === 'true') {
strapi.log.warn(logMessage(`The 'importOnBootstrap' setting was ignored because Strapi was started from the config-sync CLI itself.`)); strapi.log.warn(logMessage(`The 'importOnBootstrap' setting was ignored because Strapi was started from the config-sync CLI itself.`));
} else if (fs.existsSync(strapi.config.get('plugin.config-sync.syncDir'))) { } else if (fs.existsSync(strapi.config.get('plugin::config-sync.syncDir'))) {
await strapi.plugin('config-sync').service('main').importAllConfig(); await strapi.plugin('config-sync').service('main').importAllConfig();
} }
} }

View File

@ -6,7 +6,7 @@ const Table = require('cli-table');
const chalk = require('chalk'); const chalk = require('chalk');
const inquirer = require('inquirer'); const inquirer = require('inquirer');
const { isEmpty } = require('lodash'); const { isEmpty } = require('lodash');
const strapi = require('@strapi/strapi'); // eslint-disable-line const { createStrapi, compileStrapi } = require('@strapi/strapi');
const gitDiff = require('git-diff'); const gitDiff = require('git-diff');
const warnings = require('./warnings'); const warnings = require('./warnings');
@ -15,33 +15,11 @@ const packageJSON = require('../package.json');
const program = new Command(); const program = new Command();
const getStrapiApp = async () => { const getStrapiApp = async () => {
process.env.CONFIG_SYNC_CLI = true; process.env.CONFIG_SYNC_CLI = 'true';
try { const appContext = await compileStrapi();
const tsUtils = require('@strapi/typescript-utils'); // eslint-disable-line const app = await createStrapi(appContext).load();
return app;
const appDir = process.cwd();
const isTSProject = await tsUtils.isUsingTypeScript(appDir);
const outDir = await tsUtils.resolveOutDir(appDir);
const alreadyCompiled = await fs.existsSync(outDir);
if (isTSProject && !alreadyCompiled) {
await tsUtils.compile(appDir, {
watch: false,
configOptions: { options: { incremental: true } },
});
}
const distDir = isTSProject ? outDir : appDir;
const app = await strapi({ appDir, distDir }).load();
return app;
} catch (e) {
// Fallback for pre Strapi 4.2.
const app = await strapi().load();
return app;
}
}; };
const initTable = (head) => { const initTable = (head) => {
@ -100,7 +78,7 @@ const getConfigState = (diff, configName, syncType) => {
const handleAction = async (syncType, skipConfirm, configType, partials, force) => { const handleAction = async (syncType, skipConfirm, configType, partials, force) => {
const app = await getStrapiApp(); const app = await getStrapiApp();
const hasSyncDir = fs.existsSync(app.config.get('plugin.config-sync.syncDir')); const hasSyncDir = fs.existsSync(app.config.get('plugin::config-sync.syncDir'));
// No import with empty sync dir. // No import with empty sync dir.
if (!hasSyncDir && syncType === 'import') { if (!hasSyncDir && syncType === 'import') {

View File

@ -39,10 +39,10 @@ const ConfigType = class ConfigType {
*/ */
importSingle = async (configName, configContent, force) => { importSingle = async (configName, configContent, force) => {
// Check if the config should be excluded. // Check if the config should be excluded.
const shouldExclude = !isEmpty(strapi.config.get('plugin.config-sync.excludedConfig').filter((option) => `${this.configPrefix}.${configName}`.startsWith(option))); const shouldExclude = !isEmpty(strapi.config.get('plugin::config-sync.excludedConfig').filter((option) => `${this.configPrefix}.${configName}`.startsWith(option)));
if (shouldExclude) return; if (shouldExclude) return;
const softImport = strapi.config.get('plugin.config-sync.soft'); const softImport = strapi.config.get('plugin::config-sync.soft');
const queryAPI = strapi.query(this.queryString); const queryAPI = strapi.query(this.queryString);
const uidParams = getUidParamsFromName(this.uidKeys, configName); const uidParams = getUidParamsFromName(this.uidKeys, configName);
const combinedUidWhereFilter = getCombinedUidWhereFilter(this.uidKeys, uidParams); const combinedUidWhereFilter = getCombinedUidWhereFilter(this.uidKeys, uidParams);
@ -174,7 +174,7 @@ const ConfigType = class ConfigType {
const formattedDiff = await strapi.plugin('config-sync').service('main').getFormattedDiff(this.configPrefix); const formattedDiff = await strapi.plugin('config-sync').service('main').getFormattedDiff(this.configPrefix);
// Check if the config should be excluded. // Check if the config should be excluded.
const shouldExclude = !isEmpty(strapi.config.get('plugin.config-sync.excludedConfig').filter((option) => configName.startsWith(option))); const shouldExclude = !isEmpty(strapi.config.get('plugin::config-sync.excludedConfig').filter((option) => configName.startsWith(option)));
if (shouldExclude) return; if (shouldExclude) return;
const currentConfig = formattedDiff.databaseConfig[configName]; const currentConfig = formattedDiff.databaseConfig[configName];
@ -211,7 +211,7 @@ const ConfigType = class ConfigType {
} }
// Check if the config should be excluded. // Check if the config should be excluded.
const shouldExclude = !isEmpty(strapi.config.get('plugin.config-sync.excludedConfig').filter((option) => `${this.configPrefix}.${combinedUid}`.startsWith(option))); const shouldExclude = !isEmpty(strapi.config.get('plugin::config-sync.excludedConfig').filter((option) => `${this.configPrefix}.${combinedUid}`.startsWith(option)));
if (shouldExclude) return; if (shouldExclude) return;
const formattedConfig = { ...sanitizeConfig(config) }; const formattedConfig = { ...sanitizeConfig(config) };

View File

@ -25,7 +25,7 @@ module.exports = {
ctx.send({ ctx.send({
message: `Config was successfully exported to ${strapi.config.get('plugin.config-sync.syncDir')}.`, message: `Config was successfully exported to ${strapi.config.get('plugin::config-sync.syncDir')}.`,
}); });
}, },
@ -37,7 +37,7 @@ module.exports = {
*/ */
importAll: async (ctx) => { importAll: async (ctx) => {
// Check for existance of the config file sync dir. // Check for existance of the config file sync dir.
if (!fs.existsSync(strapi.config.get('plugin.config-sync.syncDir'))) { if (!fs.existsSync(strapi.config.get('plugin::config-sync.syncDir'))) {
ctx.send({ ctx.send({
message: 'No config files were found.', message: 'No config files were found.',
}); });
@ -73,7 +73,7 @@ module.exports = {
*/ */
getDiff: async (ctx) => { getDiff: async (ctx) => {
// Check for existance of the config file sync dir. // Check for existance of the config file sync dir.
if (!fs.existsSync(strapi.config.get('plugin.config-sync.syncDir'))) { if (!fs.existsSync(strapi.config.get('plugin::config-sync.syncDir'))) {
ctx.send({ ctx.send({
message: 'No config files were found.', message: 'No config files were found.',
}); });
@ -91,7 +91,7 @@ module.exports = {
getAppEnv: async () => { getAppEnv: async () => {
return { return {
env: strapi.server.app.env, env: strapi.server.app.env,
config: strapi.config.get('plugin.config-sync'), config: strapi.config.get('plugin::config-sync'),
}; };
}, },
}; };

View File

@ -21,23 +21,23 @@ module.exports = () => ({
*/ */
writeConfigFile: async (configType, configName, fileContents) => { writeConfigFile: async (configType, configName, fileContents) => {
// Check if the config should be excluded. // Check if the config should be excluded.
const shouldExclude = !isEmpty(strapi.config.get('plugin.config-sync.excludedConfig').filter((option) => `${configType}.${configName}`.startsWith(option))); const shouldExclude = !isEmpty(strapi.config.get('plugin::config-sync.excludedConfig').filter((option) => `${configType}.${configName}`.startsWith(option)));
if (shouldExclude) return; if (shouldExclude) return;
// Replace reserved characters in filenames. // Replace reserved characters in filenames.
configName = configName.replace(/:/g, "#").replace(/\//g, "$"); configName = configName.replace(/:/g, "#").replace(/\//g, "$");
// Check if the JSON content should be minified. // Check if the JSON content should be minified.
const json = !strapi.config.get('plugin.config-sync').minify const json = !strapi.config.get('plugin::config-sync').minify
? JSON.stringify(fileContents, null, 2) ? JSON.stringify(fileContents, null, 2)
: JSON.stringify(fileContents); : JSON.stringify(fileContents);
if (!fs.existsSync(strapi.config.get('plugin.config-sync.syncDir'))) { if (!fs.existsSync(strapi.config.get('plugin::config-sync.syncDir'))) {
fs.mkdirSync(strapi.config.get('plugin.config-sync.syncDir'), { recursive: true }); fs.mkdirSync(strapi.config.get('plugin::config-sync.syncDir'), { recursive: true });
} }
const writeFile = util.promisify(fs.writeFile); const writeFile = util.promisify(fs.writeFile);
await writeFile(`${strapi.config.get('plugin.config-sync.syncDir')}${configType}.${configName}.json`, json) await writeFile(`${strapi.config.get('plugin::config-sync.syncDir')}${configType}.${configName}.json`, json)
.then(() => { .then(() => {
// @TODO: // @TODO:
// Add logging for successfull config export. // Add logging for successfull config export.
@ -56,13 +56,13 @@ module.exports = () => ({
*/ */
deleteConfigFile: async (configName) => { deleteConfigFile: async (configName) => {
// Check if the config should be excluded. // Check if the config should be excluded.
const shouldExclude = !isEmpty(strapi.config.get('plugin.config-sync.excludedConfig').filter((option) => configName.startsWith(option))); const shouldExclude = !isEmpty(strapi.config.get('plugin::config-sync.excludedConfig').filter((option) => configName.startsWith(option)));
if (shouldExclude) return; if (shouldExclude) return;
// Replace reserved characters in filenames. // Replace reserved characters in filenames.
configName = configName.replace(/:/g, "#").replace(/\//g, "$"); configName = configName.replace(/:/g, "#").replace(/\//g, "$");
fs.unlinkSync(`${strapi.config.get('plugin.config-sync.syncDir')}${configName}.json`); fs.unlinkSync(`${strapi.config.get('plugin::config-sync.syncDir')}${configName}.json`);
}, },
/** /**
@ -77,7 +77,7 @@ module.exports = () => ({
configName = configName.replace(/:/g, "#").replace(/\//g, "$"); configName = configName.replace(/:/g, "#").replace(/\//g, "$");
const readFile = util.promisify(fs.readFile); const readFile = util.promisify(fs.readFile);
return readFile(`${strapi.config.get('plugin.config-sync.syncDir')}${configType}.${configName}.json`) return readFile(`${strapi.config.get('plugin::config-sync.syncDir')}${configType}.${configName}.json`)
.then((data) => { .then((data) => {
return JSON.parse(data); return JSON.parse(data);
}) })
@ -94,11 +94,11 @@ module.exports = () => ({
* @returns {object} Object with key value pairs of configs. * @returns {object} Object with key value pairs of configs.
*/ */
getAllConfigFromFiles: async (configType = null) => { getAllConfigFromFiles: async (configType = null) => {
if (!fs.existsSync(strapi.config.get('plugin.config-sync.syncDir'))) { if (!fs.existsSync(strapi.config.get('plugin::config-sync.syncDir'))) {
return {}; return {};
} }
const configFiles = fs.readdirSync(strapi.config.get('plugin.config-sync.syncDir')); const configFiles = fs.readdirSync(strapi.config.get('plugin::config-sync.syncDir'));
const getConfigs = async () => { const getConfigs = async () => {
const fileConfigs = {}; const fileConfigs = {};
@ -113,7 +113,7 @@ module.exports = () => ({
if ( if (
configType && configType !== type configType && configType !== type
|| !strapi.plugin('config-sync').types[type] || !strapi.plugin('config-sync').types[type]
|| !isEmpty(strapi.config.get('plugin.config-sync.excludedConfig').filter((option) => `${type}.${name}`.startsWith(option))) || !isEmpty(strapi.config.get('plugin::config-sync.excludedConfig').filter((option) => `${type}.${name}`.startsWith(option)))
) { ) {
return; return;
} }
@ -219,7 +219,7 @@ module.exports = () => ({
*/ */
importSingleConfig: async (configName, onSuccess, force) => { importSingleConfig: async (configName, onSuccess, force) => {
// Check if the config should be excluded. // Check if the config should be excluded.
const shouldExclude = !isEmpty(strapi.config.get('plugin.config-sync.excludedConfig').filter((option) => configName.startsWith(option))); const shouldExclude = !isEmpty(strapi.config.get('plugin::config-sync.excludedConfig').filter((option) => configName.startsWith(option)));
if (shouldExclude) return; if (shouldExclude) return;
const type = configName.split('.')[0]; // Grab the first part of the filename. const type = configName.split('.')[0]; // Grab the first part of the filename.
@ -244,7 +244,7 @@ module.exports = () => ({
*/ */
exportSingleConfig: async (configName, onSuccess) => { exportSingleConfig: async (configName, onSuccess) => {
// Check if the config should be excluded. // Check if the config should be excluded.
const shouldExclude = !isEmpty(strapi.config.get('plugin.config-sync.excludedConfig').filter((option) => configName.startsWith(option))); const shouldExclude = !isEmpty(strapi.config.get('plugin::config-sync.excludedConfig').filter((option) => configName.startsWith(option)));
if (shouldExclude) return; if (shouldExclude) return;
const type = configName.split('.')[0]; // Grab the first part of the filename. const type = configName.split('.')[0]; // Grab the first part of the filename.

View File

@ -51,6 +51,7 @@ const sanitizeConfig = (config, relation, relationSortFields) => {
delete config.id; delete config.id;
delete config.updatedAt; delete config.updatedAt;
delete config.createdAt; delete config.createdAt;
delete config.publishedAt;
if (relation) { if (relation) {
const formattedRelations = []; const formattedRelations = [];
@ -59,6 +60,7 @@ const sanitizeConfig = (config, relation, relationSortFields) => {
delete relationEntity._id; delete relationEntity._id;
delete relationEntity.id; delete relationEntity.id;
delete relationEntity.updatedAt; delete relationEntity.updatedAt;
delete config.publishedAt;
delete relationEntity.createdAt; delete relationEntity.createdAt;
relationEntity = sortByKeys(relationEntity); relationEntity = sortByKeys(relationEntity);

View File

@ -1,3 +1,3 @@
'use strict'; import admin from './admin/src';
module.exports = require('./admin/src').default; export default admin;

7955
yarn.lock

File diff suppressed because it is too large Load Diff