diff --git a/package.json b/package.json
index 7d51fc76ce..ecbaab422e 100644
--- a/package.json
+++ b/package.json
@@ -36,7 +36,6 @@
"format": "yarn format:code && yarn format:other",
"format:code": "yarn prettier:code --write",
"format:other": "yarn prettier:other --write",
- "generate": "plop --plopfile ./packages/generators/admin/plopfile.js",
"lint": "nx run-many --target=lint --nx-ignore-cycles && yarn lint:other",
"lint:fix": "nx run-many --target=lint --nx-ignore-cycles -- --fix",
"lint:other": "npm run prettier:other -- --check",
diff --git a/packages/generators/admin/component/index.js b/packages/generators/admin/component/index.js
deleted file mode 100644
index 7d9f1e769f..0000000000
--- a/packages/generators/admin/component/index.js
+++ /dev/null
@@ -1,82 +0,0 @@
-'use strict';
-
-const { join } = require('path');
-const { flow, camelCase, upperFirst, lowerCase } = require('lodash');
-const fileExistsInPackages = require('../utils/fileExistsInPackages');
-const getPluginList = require('../utils/getPluginList');
-const packagesFolder = require('../utils/packagesFolder');
-
-const pascalCase = flow(camelCase, upperFirst);
-
-const prompts = [
- {
- type: 'list',
- name: 'plugin',
- message: 'Which plugin should be targeted?',
- choices: getPluginList,
- },
- {
- type: 'input',
- name: 'name',
- message: 'What should be the name of the component?',
- async validate(name, answers) {
- if (!name) {
- return 'The name cannot be empty.';
- }
-
- return (await fileExistsInPackages(`${answers.plugin}/admin/src/components/${name}`))
- ? 'This component already exists.'
- : true;
- },
- filter: pascalCase,
- },
- {
- type: 'confirm',
- name: 'styled',
- message: 'Is this a styled component?',
- },
- {
- type: 'input',
- name: 'htmlTag',
- message: 'Which HTML tag should be used as a base?',
- when: (answers) => answers.styled,
- validate: (htmlTag) => (!htmlTag ? 'The HTML tag cannot be empty.' : true),
- filter: lowerCase,
- },
- {
- type: 'confirm',
- name: 'useI18n',
- message: 'Will it use i18n?',
- when: (answers) => !answers.styled,
- },
- {
- type: 'confirm',
- name: 'useRedux',
- message: 'Will it use Redux?',
- when: (answers) => !answers.styled,
- },
-];
-
-const actions = (answers) => {
- const { useRedux } = answers;
- const [pluginFolder, plugin] = answers.plugin.split('/');
- answers.plugin = plugin;
- const templatesFolder = 'component/templates';
- const pattern = useRedux ? '**/**.hbs' : '**/index.*.hbs';
- const path = join(packagesFolder, pluginFolder, '{{ plugin }}/admin/src/components/{{ name }}');
- return [
- {
- type: 'addMany',
- destination: path,
- templateFiles: [`${templatesFolder}/${pattern}`],
- base: templatesFolder,
- },
- // TODO: If redux will be used then 'append' created reducer inside 'reducers.js'
- {
- type: 'lint',
- files: [path],
- },
- ];
-};
-
-module.exports = { prompts, actions };
diff --git a/packages/generators/admin/component/templates/actions.js.hbs b/packages/generators/admin/component/templates/actions.js.hbs
deleted file mode 100644
index f25e95086b..0000000000
--- a/packages/generators/admin/component/templates/actions.js.hbs
+++ /dev/null
@@ -1,14 +0,0 @@
-/**
- *
- * {{ name }} actions
- *
- */
-
-import { DEFAULT_ACTION } from './constants';
-
-// eslint-disable-next-line import/prefer-default-export
-export const defaultAction = () => {
- return {
- type: DEFAULT_ACTION,
- };
-};
diff --git a/packages/generators/admin/component/templates/constants.js.hbs b/packages/generators/admin/component/templates/constants.js.hbs
deleted file mode 100644
index 8cf89519b1..0000000000
--- a/packages/generators/admin/component/templates/constants.js.hbs
+++ /dev/null
@@ -1,8 +0,0 @@
-/**
- *
- * {{ name }} constants
- *
- */
-
-// eslint-disable-next-line import/prefer-default-export
-export const DEFAULT_ACTION = '{{ plugin }}/{{ name }}/DEFAULT_ACTION';
diff --git a/packages/generators/admin/component/templates/index.js.hbs b/packages/generators/admin/component/templates/index.js.hbs
deleted file mode 100644
index caa5980e5e..0000000000
--- a/packages/generators/admin/component/templates/index.js.hbs
+++ /dev/null
@@ -1,61 +0,0 @@
-{{#if styled}}
- import styled from 'styled-components'
-{{else}}
- /**
- *
- * {{ name }}
- *
- */
-
- // import PropTypes from 'prop-types';
- import React from 'react';
- {{#if useI18n}}
- import { useIntl } from 'react-intl';
- {{#unless plugin "===" "admin"}}
- import { getTrad } from '../../utils';
- {{/unless}}
- {{/if}}
- {{#if useRedux}}
- import { useDispatch, useSelector } from 'react-redux';
- import { select{{ name }}Domain } from './selectors';
- import { defaultAction } from './actions';
- {{/if}}
-{{/if}}
-
-{{#if styled}}
- const {{ name }} = styled.{{ htmlTag }}``;
-{{else}}
- const {{ name }} = () => {
- {{#if useI18n}}
- const { formatMessage } = useIntl();
- {{/if}}
- {{#if useRedux}}
- const dispatch = useDispatch();
- // eslint-disable-next-line no-unused-vars
- const state = useSelector(select{{ name }}Domain);
-
- const handleClick = () => dispatch(defaultAction())
- {{/if}}
- {{#if useI18n "||" useRedux}}
-
- {{/if}}
- return (
-
- {{#if useRedux}}
-
- {{/if}}
- {{#if useI18n}}
-
{formatMessage({ id: {{#if plugin "===" "admin"~}}
- 'component.name'
- {{~else~}}
- getTrad('component.name')
- {{~/if}}, defaultMessage: '{{titleCase name}}' })}
- {{/if}}
-
- );
- };
-
- {{ name }}.propTypes = {};
-{{/if}}
-
-export default {{ name }};
diff --git a/packages/generators/admin/component/templates/reducer.js.hbs b/packages/generators/admin/component/templates/reducer.js.hbs
deleted file mode 100644
index 874dd6c699..0000000000
--- a/packages/generators/admin/component/templates/reducer.js.hbs
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- *
- * {{ name }} reducer
- *
- */
-
-import produce from 'immer';
-import { DEFAULT_ACTION } from './constants';
-
-export const initialState = {};
-
-const {{ camelCase name }}Reducer = (state = initialState, action) =>
- // eslint-disable-next-line consistent-return
- produce(state, draftState => {
- switch (action.type) {
- case DEFAULT_ACTION: {
- break;
- }
- default:
- return draftState;
- }
- });
-
-export default {{ camelCase name }}Reducer;
diff --git a/packages/generators/admin/component/templates/selectors.js.hbs b/packages/generators/admin/component/templates/selectors.js.hbs
deleted file mode 100644
index f3bd345663..0000000000
--- a/packages/generators/admin/component/templates/selectors.js.hbs
+++ /dev/null
@@ -1,17 +0,0 @@
-import { initialState } from './reducer';
-{{#unless plugin "===" "admin"}}
- import pluginId from '../../pluginId'
-{{/unless}}
-
-/**
- * Direct selector to the {{ name }} state domain
- */
-
-// eslint-disable-next-line import/prefer-default-export
-export const select{{ name }}Domain = state => state[`
-{{~#if plugin "===" "admin"~}}
- {{ plugin }}
-{{~else~}}
- ${pluginId}
-{{~/if~}}
-_{{ camelCase name }}`] || initialState;
diff --git a/packages/generators/admin/component/templates/tests/actions.test.js.hbs b/packages/generators/admin/component/templates/tests/actions.test.js.hbs
deleted file mode 100644
index b8d5b4b602..0000000000
--- a/packages/generators/admin/component/templates/tests/actions.test.js.hbs
+++ /dev/null
@@ -1,13 +0,0 @@
-import { defaultAction } from '../actions';
-import { DEFAULT_ACTION } from '../constants';
-
-describe('{{ plugin }} | components | {{ name }} actions', () => {
- describe('Default Action', () => {
- it('has a type of DEFAULT_ACTION', () => {
- const expected = {
- type: DEFAULT_ACTION,
- };
- expect(defaultAction()).toEqual(expected);
- });
- });
-});
diff --git a/packages/generators/admin/component/templates/tests/index.test.js.hbs b/packages/generators/admin/component/templates/tests/index.test.js.hbs
deleted file mode 100644
index 4554f2e324..0000000000
--- a/packages/generators/admin/component/templates/tests/index.test.js.hbs
+++ /dev/null
@@ -1,67 +0,0 @@
-/**
- *
- * Tests for {{ name }}
- *
- */
-
-import React from 'react';
-import { render {{~#if useRedux}} as tlRender {{~/if}} } from '@testing-library/react';
-import { ThemeProvider, lightTheme } from '@strapi/design-system';
-{{#if useRedux}}
- import { Provider } from 'react-redux';
- import { createStore, combineReducers } from 'redux';
- import { initialState } from '../reducer';
- import reducers from '../../../reducers';
-{{/if}}
-{{#if useI18n}}
- import { IntlProvider } from 'react-intl';
-{{/if}}
-import {{ name }} from '../index';
-
-{{#if useRedux}}
- const rootReducer = combineReducers(reducers);
-
- const render = (
- ui,
- {
- preloadedState = initialState,
- store = createStore(rootReducer, { '{{ plugin }}_{{ camelCase name }}': preloadedState }),
- ...renderOptions
- } = {},
- ) => {
- // eslint-disable-next-line react/prop-types
- const Wrapper = ({ children }) => (
- {children}
- );
-
- return tlRender(ui, { wrapper: Wrapper, ...renderOptions });
- };
-
-{{/if}}
-{{#if useI18n}}
- const messages = {
- '{{ plugin }}.component.name': '{{titleCase name}}',
- };
-
-{{/if}}
-describe('<{{ name }} />', () => {
- it('renders and matches the snapshot', () => {
- const {
- container: { firstChild },
- } = render(
- {{#if useI18n}}
-
-
- <{{ name }} />
-
-
- {{else}}
-
- <{{ name }} />
-
- {{/if}}
- );
-
- expect(firstChild).toMatchInlineSnapshot();
- });
-});
diff --git a/packages/generators/admin/component/templates/tests/reducer.test.js.hbs b/packages/generators/admin/component/templates/tests/reducer.test.js.hbs
deleted file mode 100644
index 4deb3d781a..0000000000
--- a/packages/generators/admin/component/templates/tests/reducer.test.js.hbs
+++ /dev/null
@@ -1,21 +0,0 @@
-// import produce from 'immer';
-import {{ camelCase name }}Reducer, { initialState } from '../reducer';
-import { fixtures } from '../../../../../../../admin-test-utils';
-// import { someAction } from '../actions';
-
-/* eslint-disable default-case, no-param-reassign */
-describe('{{ camelCase name }}Reducer', () => {
- let state;
- beforeEach(() => {
- state = {
- ...fixtures.store.state,
- '{{ plugin }}_{{ camelCase name }}': initialState,
- };
- });
-
- it('returns the initial state', () => {
- const expectedResult = state['{{ plugin }}_{{ camelCase name }}'];
-
- expect({{ camelCase name }}Reducer(undefined, {})).toEqual(expectedResult);
- });
-});
diff --git a/packages/generators/admin/component/templates/tests/selectors.test.js.hbs b/packages/generators/admin/component/templates/tests/selectors.test.js.hbs
deleted file mode 100644
index 9ea620841d..0000000000
--- a/packages/generators/admin/component/templates/tests/selectors.test.js.hbs
+++ /dev/null
@@ -1,17 +0,0 @@
-import { fixtures } from '../../../../../../../admin-test-utils';
-import { select{{ name }}Domain } from '../selectors';
-
-describe('select{{ name }}Domain', () => {
- let store;
-
- beforeEach(() => {
- store = { ...fixtures.store.state, '{{ plugin }}_{{ camelCase name }}': {} };
- });
-
- it('expects to have unit tests specified', () => {
- const actual = select{{ name }}Domain(store);
-
- // TBC
- expect(actual).toEqual(store['{{ plugin }}_{{ camelCase name }}']);
- });
-});
diff --git a/packages/generators/admin/plopfile.js b/packages/generators/admin/plopfile.js
deleted file mode 100644
index 4aee0f43d4..0000000000
--- a/packages/generators/admin/plopfile.js
+++ /dev/null
@@ -1,81 +0,0 @@
-'use strict';
-
-/* eslint-disable eqeqeq */
-
-const { ESLint } = require('eslint');
-const componentGenerator = require('./component');
-
-// This is used to be able to indent block inside Handlebars helpers and improve templates visibility.
-// It's not very robust, and forces you to use 2 spaces indentation inside for your blocks.
-// If it become a pain don't hesitate to remove it.
-const leftShift = (str) => str.replace(/^ {2}/gm, '');
-
-const evaluateExpression = (a, operator, b) => {
- switch (operator) {
- case '==':
- return a == b;
- case '===':
- return a === b;
- case '!=':
- return a != b;
- case '!==':
- return a !== b;
- case '<':
- return a < b;
- case '<=':
- return a <= b;
- case '>':
- return a > b;
- case '>=':
- return a >= b;
- case '&&':
- return a && b;
- case '||':
- return a || b;
- default:
- return false;
- }
-};
-
-/**
- * @param {import('plop').NodePlopAPI} plop
- */
-module.exports = function generator(plop) {
- plop.setHelper('if', (...args) => {
- const end = args.length - 1;
- const { fn, inverse } = args[end];
- if (args.length === 2) {
- const condition = args[0];
- return leftShift(condition ? fn(this) : inverse(this));
- }
- const [a, operator, b] = Array.from(args).slice(0, end);
- return leftShift(evaluateExpression(a, operator, b) ? fn(this) : inverse(this));
- });
-
- plop.setHelper('unless', (...args) => {
- const end = args.length - 1;
- const { fn, inverse } = args[end];
- if (args.length === 2) {
- const condition = args[0];
- return leftShift(!condition ? fn(this) : inverse(this));
- }
- const [a, operator, b] = Array.from(args).slice(0, end);
- return leftShift(!evaluateExpression(a, operator, b) ? fn(this) : inverse(this));
- });
-
- plop.setHelper('else', (_, { fn }) => {
- return leftShift(fn(this));
- });
-
- plop.setActionType('lint', async (answers, config, plopfileApi) => {
- const { files } = config;
- const patterns = files.map((file) => plopfileApi.renderString(file, answers));
-
- const eslint = new ESLint({ fix: true });
- const results = await eslint.lintFiles(patterns);
- await ESLint.outputFixes(results);
- return 'Linting errors autofixed.';
- });
-
- plop.setGenerator('component', componentGenerator);
-};
diff --git a/packages/generators/admin/utils/fileExistsInPackages.js b/packages/generators/admin/utils/fileExistsInPackages.js
deleted file mode 100644
index c23023d2cc..0000000000
--- a/packages/generators/admin/utils/fileExistsInPackages.js
+++ /dev/null
@@ -1,13 +0,0 @@
-'use strict';
-
-const fs = require('fs');
-const { join } = require('path');
-const packagesFolder = require('./packagesFolder');
-
-const fileExistsInPackages = (path) =>
- fs.promises
- .access(join(packagesFolder, path))
- .then(() => true)
- .catch(() => false);
-
-module.exports = fileExistsInPackages;
diff --git a/packages/generators/admin/utils/getPluginList.js b/packages/generators/admin/utils/getPluginList.js
deleted file mode 100644
index c74fafacf2..0000000000
--- a/packages/generators/admin/utils/getPluginList.js
+++ /dev/null
@@ -1,30 +0,0 @@
-'use strict';
-
-const glob = require('glob');
-const fileExistsInPackages = require('./fileExistsInPackages');
-const packagesFolder = require('./packagesFolder');
-
-const asyncFilter = async (array, predicate) => {
- const results = await Promise.all(array.map(predicate));
- return array.filter((_, index) => results[index]);
-};
-
-const getPluginList = () => {
- return new Promise((resolve, reject) => {
- glob(
- '{core,plugins}/*',
- { ignore: ['**/node_modules'], cwd: packagesFolder },
- async (err, matches) => {
- if (err) {
- reject(err);
- }
-
- const extendsAdmin = (match) => fileExistsInPackages(`${match}/admin/src`);
-
- resolve(await asyncFilter(matches, extendsAdmin));
- }
- );
- });
-};
-
-module.exports = getPluginList;
diff --git a/packages/generators/admin/utils/packagesFolder.js b/packages/generators/admin/utils/packagesFolder.js
deleted file mode 100644
index 94a631dd12..0000000000
--- a/packages/generators/admin/utils/packagesFolder.js
+++ /dev/null
@@ -1,7 +0,0 @@
-'use strict';
-
-const { join } = require('path');
-
-const packagesFolder = join(__dirname, '../../..');
-
-module.exports = packagesFolder;