@strapi/admin 4.2.0 → 4.3.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/admin/src/app.js +7 -4
- package/admin/src/content-manager/components/EditViewDataManagerProvider/index.js +3 -3
- package/admin/src/content-manager/components/SelectMany/index.js +2 -4
- package/admin/src/content-manager/components/SelectWrapper/index.js +1 -13
- package/admin/src/hooks/useFetchMarketplaceProviders/index.js +1 -1
- package/admin/src/pages/Admin/index.js +15 -5
- package/admin/src/pages/App/constants.js +1 -0
- package/admin/src/pages/App/index.js +17 -3
- package/admin/src/pages/App/reducer.js +22 -0
- package/admin/src/pages/MarketplacePage/components/NpmPackagesGrid/index.js +1 -1
- package/admin/src/pages/SettingsPage/pages/ApplicationInfosPage/components/LogoModalStepper/FromUrlForm.js +7 -3
- package/admin/src/reducers.js +4 -2
- package/admin/src/tsconfig.json +10 -0
- package/build/{9158.e48d88af.chunk.js → 1820.ca954075.chunk.js} +31 -31
- package/build/20.9e5a98b6.chunk.js +308 -0
- package/build/3531.231e0eb6.chunk.js +10 -0
- package/build/{9115.abdf4e3b.chunk.js → 4073.e144a91a.chunk.js} +1 -1
- package/build/413.d5986568.chunk.js +284 -0
- package/build/{7757.f6eb5e92.chunk.js → 472.d43be8bb.chunk.js} +2 -2
- package/build/5250.24040688.chunk.js +11 -0
- package/build/6229.53b33cf0.chunk.js +194 -0
- package/build/7418.6db737ce.chunk.js +112 -0
- package/build/8773.54a26ded.chunk.js +327 -0
- package/build/9262.25aa12a5.chunk.js +1 -0
- package/build/Admin-authenticatedApp.52f3c150.chunk.js +80 -0
- package/build/{Admin_homePage.8c00145e.chunk.js → Admin_homePage.0ac648e8.chunk.js} +1 -1
- package/build/{Admin_marketplace.a88d5bda.chunk.js → Admin_marketplace.71c66b49.chunk.js} +2 -2
- package/build/Admin_pluginsPage.788fb2f6.chunk.js +1 -0
- package/build/{Admin_profilePage.33cfed9b.chunk.js → Admin_profilePage.27191ed2.chunk.js} +2 -2
- package/build/Admin_settingsPage.021da806.chunk.js +178 -0
- package/build/{admin-edit-roles-page.e77a2acc.chunk.js → admin-edit-roles-page.fb374555.chunk.js} +1 -1
- package/build/admin-edit-users.a360deaf.chunk.js +10 -0
- package/build/admin-users.47d06d24.chunk.js +11 -0
- package/build/{api-tokens-create-page.618b3e40.chunk.js → api-tokens-create-page.698f132d.chunk.js} +1 -1
- package/build/{api-tokens-edit-page.8d19dfe1.chunk.js → api-tokens-edit-page.afece2fe.chunk.js} +1 -1
- package/build/{api-tokens-list-page.274e1c80.chunk.js → api-tokens-list-page.46d96dee.chunk.js} +1 -1
- package/build/{codemirror-css.98490df3.chunk.js → codemirror-css.b467b1de.chunk.js} +2 -2
- package/build/{codemirror-javacript.cafbda9c.chunk.js → codemirror-javacript.41bdefda.chunk.js} +1 -1
- package/build/codemirror-theme.cf9f9eb6.chunk.js +34 -0
- package/build/content-manager.afcc3624.chunk.js +1182 -0
- package/build/content-type-builder.e73879b9.chunk.js +141 -0
- package/build/{cropper-css.0055cd53.chunk.js → cropper-css.ecc0d670.chunk.js} +2 -2
- package/build/{email-settings-page.4ae595f6.chunk.js → email-settings-page.8871dfe8.chunk.js} +2 -2
- package/build/{fontawesome-css-all.b88d464e.chunk.js → fontawesome-css-all.04f33619.chunk.js} +3 -3
- package/build/{fontawesome-css.59dc4459.chunk.js → fontawesome-css.477ba714.chunk.js} +2 -2
- package/build/highlight.js.3381ffc3.chunk.js +86 -0
- package/build/{i18n-settings-page.bdac3c7b.chunk.js → i18n-settings-page.dfb4eb01.chunk.js} +1 -1
- package/build/index.html +1 -1
- package/build/main.ca3856ed.js +8640 -0
- package/build/{runtime~main.de49adfd.js → runtime~main.48a46dd2.js} +1 -1
- package/build/sso-settings-page.dfb0b917.chunk.js +1 -0
- package/build/{upload-settings.cadfd452.chunk.js → upload-settings.8d8c672a.chunk.js} +1 -1
- package/build/upload-translation-de-json.745613c0.chunk.js +1 -0
- package/build/upload-translation-dk-json.cb25dcf0.chunk.js +1 -0
- package/build/upload-translation-en-json.e78688a0.chunk.js +1 -0
- package/build/upload-translation-es-json.1f344b53.chunk.js +1 -0
- package/build/upload-translation-fr-json.e21c0c7a.chunk.js +1 -0
- package/build/upload-translation-he-json.4ce77b7b.chunk.js +1 -0
- package/build/upload-translation-it-json.5ce11e0b.chunk.js +1 -0
- package/build/upload-translation-ja-json.22afae44.chunk.js +1 -0
- package/build/upload-translation-ko-json.9a2c21cb.chunk.js +1 -0
- package/build/upload-translation-ms-json.0605d6da.chunk.js +1 -0
- package/build/upload-translation-pl-json.e534b676.chunk.js +1 -0
- package/build/upload-translation-pt-BR-json.95686cfb.chunk.js +1 -0
- package/build/upload-translation-ru-json.37bd1546.chunk.js +1 -0
- package/build/upload-translation-sk-json.b03d4904.chunk.js +1 -0
- package/build/upload-translation-th-json.64dd70ce.chunk.js +1 -0
- package/build/upload-translation-uk-json.1328cb3e.chunk.js +1 -0
- package/build/{upload-translation-zh-Hans-json.c9622577.chunk.js → upload-translation-zh-Hans-json.6832ff81.chunk.js} +1 -1
- package/build/upload-translation-zh-json.ee8fba96.chunk.js +1 -0
- package/build/upload.5622b777.chunk.js +7 -0
- package/build/{users-advanced-settings-page.646b6f29.chunk.js → users-advanced-settings-page.4af9e241.chunk.js} +1 -1
- package/build/users-email-settings-page.d69c0d87.chunk.js +101 -0
- package/build/users-providers-settings-page.fc1fda6d.chunk.js +101 -0
- package/build/{users-roles-settings-page.28bf6bdc.chunk.js → users-roles-settings-page.988ebc3b.chunk.js} +2 -2
- package/build/{webhook-edit-page.ca670f8d.chunk.js → webhook-edit-page.a7ae6e3b.chunk.js} +2 -2
- package/build/{webhook-list-page.7057f1e8.chunk.js → webhook-list-page.057f396c.chunk.js} +1 -1
- package/index.js +47 -239
- package/package.json +10 -5
- package/scripts/build.js +19 -3
- package/server/controllers/admin.js +21 -0
- package/server/policies/index.js +1 -0
- package/server/policies/isTelemetryEnabled.js +16 -0
- package/server/routes/admin.js +8 -0
- package/server/routes/serve-admin-panel.js +1 -1
- package/utils/create-cache-dir.js +131 -0
- package/utils/get-custom-app-config-file.js +28 -0
- package/utils/get-custom-webpack-config.js +38 -0
- package/utils/get-plugins-path.js +26 -0
- package/utils/index.js +13 -0
- package/utils/should-build-admin.js +52 -0
- package/utils/watch-admin-files.js +59 -0
- package/webpack.config.js +28 -5
- package/admin/src/content-manager/components/SelectWrapper/ClearIndicator.js +0 -18
- package/admin/src/content-manager/components/SelectWrapper/DropdownIndicator.js +0 -24
- package/admin/src/content-manager/components/SelectWrapper/IconBox.js +0 -20
- package/admin/src/content-manager/components/SelectWrapper/IndicatorSeparator.js +0 -3
- package/admin/src/content-manager/components/SelectWrapper/utils/getSelectStyles.js +0 -92
- package/build/2758.9475712b.chunk.js +0 -162
- package/build/2912.dd031292.chunk.js +0 -253
- package/build/4982.c57c5675.chunk.js +0 -308
- package/build/7197.ed8d6752.chunk.js +0 -113
- package/build/7589.577cf729.chunk.js +0 -194
- package/build/7841.9e9cf739.chunk.js +0 -253
- package/build/8681.aec05472.chunk.js +0 -163
- package/build/9298.cb3b6bc1.chunk.js +0 -334
- package/build/948.d64fb515.chunk.js +0 -2
- package/build/Admin-authenticatedApp.e7ed0550.chunk.js +0 -80
- package/build/Admin_pluginsPage.e895d79f.chunk.js +0 -1
- package/build/Admin_settingsPage.fe33e0a2.chunk.js +0 -180
- package/build/admin-edit-users.4c49fe98.chunk.js +0 -11
- package/build/admin-users.b89adf82.chunk.js +0 -12
- package/build/codemirror-theme.b3c64617.chunk.js +0 -34
- package/build/content-manager.04b93497.chunk.js +0 -1204
- package/build/content-type-builder.b3139cb1.chunk.js +0 -141
- package/build/highlight.js.9d8ef460.chunk.js +0 -86
- package/build/main.3257934a.js +0 -8404
- package/build/sso-settings-page.0b4d2106.chunk.js +0 -1
- package/build/upload-translation-de-json.b642da08.chunk.js +0 -1
- package/build/upload-translation-dk-json.fc61df13.chunk.js +0 -1
- package/build/upload-translation-en-json.59269508.chunk.js +0 -1
- package/build/upload-translation-es-json.8ec935ef.chunk.js +0 -1
- package/build/upload-translation-fr-json.eb9b4f84.chunk.js +0 -1
- package/build/upload-translation-he-json.c226f2dc.chunk.js +0 -1
- package/build/upload-translation-it-json.8e58456e.chunk.js +0 -1
- package/build/upload-translation-ja-json.1378a2e7.chunk.js +0 -1
- package/build/upload-translation-ko-json.5e06e112.chunk.js +0 -1
- package/build/upload-translation-ms-json.dc3bf0d7.chunk.js +0 -1
- package/build/upload-translation-pl-json.6071e38c.chunk.js +0 -1
- package/build/upload-translation-pt-BR-json.7e8d9550.chunk.js +0 -1
- package/build/upload-translation-ru-json.da2529f3.chunk.js +0 -1
- package/build/upload-translation-sk-json.bfdf4f09.chunk.js +0 -1
- package/build/upload-translation-th-json.6a48b826.chunk.js +0 -1
- package/build/upload-translation-uk-json.6fb09148.chunk.js +0 -1
- package/build/upload-translation-zh-json.711f804b.chunk.js +0 -1
- package/build/upload.fbc65439.chunk.js +0 -105
- package/build/users-email-settings-page.8b561ea3.chunk.js +0 -1
- package/build/users-providers-settings-page.82141ace.chunk.js +0 -1
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const path = require('path');
|
|
4
|
+
const _ = require('lodash');
|
|
5
|
+
const fs = require('fs-extra');
|
|
6
|
+
const tsUtils = require('@strapi/typescript-utils');
|
|
7
|
+
const getCustomAppConfigFile = require('./get-custom-app-config-file');
|
|
8
|
+
|
|
9
|
+
const getPkgPath = name => path.dirname(require.resolve(`${name}/package.json`));
|
|
10
|
+
|
|
11
|
+
async function createPluginsJs(plugins, dest) {
|
|
12
|
+
const pluginsArray = plugins.map(({ pathToPlugin, name }) => {
|
|
13
|
+
const shortName = _.camelCase(name);
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* path.join, on windows, it uses backslashes to resolve path.
|
|
17
|
+
* The problem is that Webpack does not windows paths
|
|
18
|
+
* With this tool, we need to rely on "/" and not "\".
|
|
19
|
+
* This is the reason why '..\\..\\..\\node_modules\\@strapi\\plugin-content-type-builder/strapi-admin.js' was not working.
|
|
20
|
+
* The regexp at line 105 aims to replace the windows backslashes by standard slash so that webpack can deal with them.
|
|
21
|
+
* Backslash looks to work only for absolute paths with webpack => https://webpack.js.org/concepts/module-resolution/#absolute-paths
|
|
22
|
+
*/
|
|
23
|
+
const realPath = path
|
|
24
|
+
.join(path.relative(path.resolve(dest, 'admin', 'src'), pathToPlugin), 'strapi-admin.js')
|
|
25
|
+
.replace(/\\/g, '/');
|
|
26
|
+
|
|
27
|
+
return {
|
|
28
|
+
name,
|
|
29
|
+
pathToPlugin: realPath,
|
|
30
|
+
shortName,
|
|
31
|
+
};
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
const content = `
|
|
35
|
+
${pluginsArray
|
|
36
|
+
.map(({ pathToPlugin, shortName }) => {
|
|
37
|
+
const req = `'${pathToPlugin}'`;
|
|
38
|
+
|
|
39
|
+
return `import ${shortName} from ${req};`;
|
|
40
|
+
})
|
|
41
|
+
.join('\n')}
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
const plugins = {
|
|
45
|
+
${[...pluginsArray]
|
|
46
|
+
.map(({ name, shortName }) => {
|
|
47
|
+
return ` '${name}': ${shortName},`;
|
|
48
|
+
})
|
|
49
|
+
.join('\n')}
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export default plugins;
|
|
53
|
+
`;
|
|
54
|
+
|
|
55
|
+
return fs.writeFile(path.resolve(dest, 'admin', 'src', 'plugins.js'), content);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
async function copyAdmin(dest) {
|
|
59
|
+
const adminPath = getPkgPath('@strapi/admin');
|
|
60
|
+
|
|
61
|
+
// TODO copy ee folders for plugins
|
|
62
|
+
await fs.copy(path.resolve(adminPath, 'ee', 'admin'), path.resolve(dest, 'ee', 'admin'));
|
|
63
|
+
|
|
64
|
+
await fs.ensureDir(path.resolve(dest, 'config'));
|
|
65
|
+
await fs.copy(path.resolve(adminPath, 'admin'), path.resolve(dest, 'admin'));
|
|
66
|
+
|
|
67
|
+
// Copy package.json
|
|
68
|
+
await fs.copy(path.resolve(adminPath, 'package.json'), path.resolve(dest, 'package.json'));
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
async function createCacheDir({ appDir, plugins }) {
|
|
72
|
+
const cacheDir = path.resolve(appDir, '.cache');
|
|
73
|
+
|
|
74
|
+
const useTypeScript = await tsUtils.isUsingTypeScript(
|
|
75
|
+
path.join(appDir, 'src', 'admin'),
|
|
76
|
+
'tsconfig.json'
|
|
77
|
+
);
|
|
78
|
+
|
|
79
|
+
const pluginsWithFront = Object.keys(plugins)
|
|
80
|
+
.filter(pluginName => {
|
|
81
|
+
const pluginInfo = plugins[pluginName];
|
|
82
|
+
return fs.existsSync(path.resolve(pluginInfo.pathToPlugin, 'strapi-admin.js'));
|
|
83
|
+
})
|
|
84
|
+
.map(name => ({ name, ...plugins[name] }));
|
|
85
|
+
|
|
86
|
+
// create .cache dir
|
|
87
|
+
await fs.emptyDir(cacheDir);
|
|
88
|
+
|
|
89
|
+
// copy admin core code
|
|
90
|
+
await copyAdmin(cacheDir);
|
|
91
|
+
|
|
92
|
+
// Retrieve the custom config file extension
|
|
93
|
+
const customAdminAppConfigFile = await getCustomAppConfigFile(appDir, useTypeScript);
|
|
94
|
+
|
|
95
|
+
if (customAdminAppConfigFile) {
|
|
96
|
+
const defaultAdminConfigFilePath = path.resolve(cacheDir, 'admin', 'src', 'app.js');
|
|
97
|
+
const customAdminAppConfigFilePath = path.join(
|
|
98
|
+
appDir,
|
|
99
|
+
'src',
|
|
100
|
+
'admin',
|
|
101
|
+
customAdminAppConfigFile
|
|
102
|
+
);
|
|
103
|
+
const dest = path.resolve(cacheDir, 'admin', 'src', customAdminAppConfigFile);
|
|
104
|
+
|
|
105
|
+
if (useTypeScript) {
|
|
106
|
+
// Remove the default config file
|
|
107
|
+
await fs.remove(defaultAdminConfigFilePath);
|
|
108
|
+
// Copy the custom one
|
|
109
|
+
await fs.copy(customAdminAppConfigFilePath, dest);
|
|
110
|
+
} else {
|
|
111
|
+
await fs.copy(customAdminAppConfigFilePath, dest);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// Copy admin extensions folder
|
|
116
|
+
const adminExtensionFolder = path.join(appDir, 'src', 'admin', 'extensions');
|
|
117
|
+
|
|
118
|
+
if (fs.existsSync(adminExtensionFolder)) {
|
|
119
|
+
await fs.copy(adminExtensionFolder, path.resolve(cacheDir, 'admin', 'src', 'extensions'));
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// create plugins.js with plugins requires
|
|
123
|
+
await createPluginsJs(pluginsWithFront, cacheDir);
|
|
124
|
+
|
|
125
|
+
// create the tsconfig.json file so we can develop plugins in ts while being in a JS project
|
|
126
|
+
if (!useTypeScript) {
|
|
127
|
+
await tsUtils.admin.createTSConfigFile(cacheDir);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
module.exports = createCacheDir;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const { join } = require('path');
|
|
4
|
+
const fse = require('fs-extra');
|
|
5
|
+
const { isUsingTypeScript } = require('@strapi/typescript-utils');
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Retrieve the custom admin entry file name
|
|
9
|
+
* @param {String} dir - Directory of the admin panel
|
|
10
|
+
* @returns String
|
|
11
|
+
*/
|
|
12
|
+
const getCustomAppConfigFile = async dir => {
|
|
13
|
+
const adminSrcPath = join(dir, 'src', 'admin');
|
|
14
|
+
const useTypeScript = await isUsingTypeScript(adminSrcPath, 'tsconfig.json');
|
|
15
|
+
|
|
16
|
+
const files = await fse.readdir(adminSrcPath);
|
|
17
|
+
|
|
18
|
+
const appJsx = files.find(file => /^app.jsx?$/.test(file));
|
|
19
|
+
const appTsx = files.find(file => /^app.tsx?$/.test(file));
|
|
20
|
+
|
|
21
|
+
if (useTypeScript) {
|
|
22
|
+
return appTsx || appJsx;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return appJsx;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
module.exports = getCustomAppConfigFile;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const path = require('path');
|
|
4
|
+
const chalk = require('chalk');
|
|
5
|
+
const _ = require('lodash');
|
|
6
|
+
const webpack = require('webpack');
|
|
7
|
+
const fs = require('fs-extra');
|
|
8
|
+
const getWebpackConfig = require('../webpack.config');
|
|
9
|
+
|
|
10
|
+
const getCustomWebpackConfig = (dir, config) => {
|
|
11
|
+
const adminConfigPath = path.join(dir, 'src', 'admin', 'webpack.config.js');
|
|
12
|
+
|
|
13
|
+
let webpackConfig = getWebpackConfig(config);
|
|
14
|
+
|
|
15
|
+
if (fs.existsSync(adminConfigPath)) {
|
|
16
|
+
const webpackAdminConfig = require(path.resolve(adminConfigPath));
|
|
17
|
+
|
|
18
|
+
if (_.isFunction(webpackAdminConfig)) {
|
|
19
|
+
// Expose the devServer configuration
|
|
20
|
+
if (config.devServer) {
|
|
21
|
+
webpackConfig.devServer = config.devServer;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
webpackConfig = webpackAdminConfig(webpackConfig, webpack);
|
|
25
|
+
|
|
26
|
+
if (!webpackConfig) {
|
|
27
|
+
console.error(
|
|
28
|
+
`${chalk.red('Error:')} Nothing was returned from your custom webpack configuration`
|
|
29
|
+
);
|
|
30
|
+
process.exit(1);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return webpackConfig;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
module.exports = getCustomWebpackConfig;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const { join, resolve } = require('path');
|
|
4
|
+
const fs = require('fs-extra');
|
|
5
|
+
const glob = require('glob');
|
|
6
|
+
|
|
7
|
+
// Only for dev environement
|
|
8
|
+
const getPluginsPath = () => {
|
|
9
|
+
const rootPath = resolve(__dirname, '..', join('..', '..', '..', 'packages'));
|
|
10
|
+
const corePath = join(rootPath, 'core', '*');
|
|
11
|
+
const pluginsPath = join(rootPath, 'plugins', '*');
|
|
12
|
+
const corePackageDirs = glob.sync(corePath);
|
|
13
|
+
const pluginsPackageDirs = glob.sync(pluginsPath);
|
|
14
|
+
|
|
15
|
+
const packageDirs = [...corePackageDirs, ...pluginsPackageDirs].filter(dir => {
|
|
16
|
+
const isCoreAdmin = dir.includes('packages/core/admin');
|
|
17
|
+
const pathToEntryPoint = join(dir, 'admin', 'src', 'index.js');
|
|
18
|
+
const doesAdminFolderExist = fs.pathExistsSync(pathToEntryPoint);
|
|
19
|
+
|
|
20
|
+
return !isCoreAdmin && doesAdminFolderExist;
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
return packageDirs.map(dir => resolve(__dirname, '..', join(dir, 'admin', 'src')));
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
module.exports = getPluginsPath;
|
package/utils/index.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const createCacheDir = require('./create-cache-dir');
|
|
4
|
+
const getCustomWebpackConfig = require('./get-custom-webpack-config');
|
|
5
|
+
const shouldBuildAdmin = require('./should-build-admin');
|
|
6
|
+
const watchAdminFiles = require('./watch-admin-files');
|
|
7
|
+
|
|
8
|
+
module.exports = {
|
|
9
|
+
createCacheDir,
|
|
10
|
+
getCustomWebpackConfig,
|
|
11
|
+
shouldBuildAdmin,
|
|
12
|
+
watchAdminFiles,
|
|
13
|
+
};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const path = require('path');
|
|
4
|
+
const fs = require('fs-extra');
|
|
5
|
+
const getCustomAppConfigFile = require('./get-custom-app-config-file');
|
|
6
|
+
|
|
7
|
+
const DEFAULT_PLUGINS = [
|
|
8
|
+
'content-type-builder',
|
|
9
|
+
'content-manager',
|
|
10
|
+
'upload',
|
|
11
|
+
'email',
|
|
12
|
+
'i18n',
|
|
13
|
+
'users-permissions',
|
|
14
|
+
];
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Checks if the project's installed plugins are not the same as a default one.
|
|
18
|
+
* @param {Object} plugins
|
|
19
|
+
* @returns {boolean}
|
|
20
|
+
*/
|
|
21
|
+
const hasNonDefaultPlugins = plugins => {
|
|
22
|
+
// List of plugins that are not the ones installed in a generated app
|
|
23
|
+
const installedPlugins = Object.keys(plugins).filter(x => !DEFAULT_PLUGINS.includes(x));
|
|
24
|
+
|
|
25
|
+
// List of default plugins uninstalled from a generated app
|
|
26
|
+
const missingPlugins = DEFAULT_PLUGINS.filter(x => !Object.keys(plugins).includes(x));
|
|
27
|
+
|
|
28
|
+
const diff = [...installedPlugins, ...missingPlugins];
|
|
29
|
+
|
|
30
|
+
return diff.length > 0;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const hasCustomAdminCode = async dir => {
|
|
34
|
+
const customAdminPath = path.join(dir, 'src', 'admin');
|
|
35
|
+
|
|
36
|
+
const customAdminAppConfigFile = await getCustomAppConfigFile(dir);
|
|
37
|
+
const customAdminWebpackFile = path.join(customAdminPath, 'webpack.config.js');
|
|
38
|
+
|
|
39
|
+
const hasCustomConfigFile = !!customAdminAppConfigFile;
|
|
40
|
+
const hasCustomWebpackFile = await fs.pathExists(customAdminWebpackFile);
|
|
41
|
+
|
|
42
|
+
return hasCustomConfigFile || hasCustomWebpackFile;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
const shouldBuildAdmin = async ({ appDir, plugins }) => {
|
|
46
|
+
const appHasCustomAdminCode = await hasCustomAdminCode(appDir);
|
|
47
|
+
const appHasNonDefaultPlugins = hasNonDefaultPlugins(plugins);
|
|
48
|
+
|
|
49
|
+
return appHasCustomAdminCode || appHasNonDefaultPlugins;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
module.exports = shouldBuildAdmin;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const path = require('path');
|
|
4
|
+
const fs = require('fs-extra');
|
|
5
|
+
const chokidar = require('chokidar');
|
|
6
|
+
const { isUsingTypeScript } = require('@strapi/typescript-utils');
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Listen to files change and copy the changed files in the .cache/admin folder
|
|
10
|
+
* when using the dev mode
|
|
11
|
+
* @param {string} dir
|
|
12
|
+
*/
|
|
13
|
+
async function watchAdminFiles(dir) {
|
|
14
|
+
const useTypeScript = await isUsingTypeScript(path.join(dir, 'src', 'admin'), 'tsconfig.json');
|
|
15
|
+
|
|
16
|
+
const cacheDir = path.join(dir, '.cache');
|
|
17
|
+
const targetExtensionFile = useTypeScript ? 'app.tsx' : 'app.js';
|
|
18
|
+
const appExtensionFile = path.join(dir, 'src', 'admin', targetExtensionFile);
|
|
19
|
+
const extensionsPath = path.join(dir, 'src', 'admin', 'extensions');
|
|
20
|
+
|
|
21
|
+
// Only watch the admin/app.js file and the files that are in the ./admin/extensions/folder
|
|
22
|
+
const filesToWatch = [appExtensionFile, extensionsPath];
|
|
23
|
+
|
|
24
|
+
const watcher = chokidar.watch(filesToWatch, {
|
|
25
|
+
ignoreInitial: true,
|
|
26
|
+
ignorePermissionErrors: true,
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
watcher.on('all', async (event, filePath) => {
|
|
30
|
+
const isAppFile = filePath.includes(appExtensionFile);
|
|
31
|
+
|
|
32
|
+
// The app.js file needs to be copied in the .cache/admin/src/app.js and the other ones needs to
|
|
33
|
+
// be copied in the .cache/admin/src/extensions folder
|
|
34
|
+
const targetPath = isAppFile
|
|
35
|
+
? path.join(path.normalize(filePath.split(appExtensionFile)[1]), targetExtensionFile)
|
|
36
|
+
: path.join('extensions', path.normalize(filePath.split(extensionsPath)[1]));
|
|
37
|
+
|
|
38
|
+
const destFolder = path.join(cacheDir, 'admin', 'src');
|
|
39
|
+
|
|
40
|
+
if (event === 'unlink' || event === 'unlinkDir') {
|
|
41
|
+
// Remove the file or folder
|
|
42
|
+
// We need to copy the original files when deleting an override one
|
|
43
|
+
try {
|
|
44
|
+
fs.removeSync(path.join(destFolder, targetPath));
|
|
45
|
+
} catch (err) {
|
|
46
|
+
console.log('An error occured while deleting the file', err);
|
|
47
|
+
}
|
|
48
|
+
} else {
|
|
49
|
+
// In any other case just copy the file into the .cache/admin/src folder
|
|
50
|
+
try {
|
|
51
|
+
await fs.copy(filePath, path.join(destFolder, targetPath));
|
|
52
|
+
} catch (err) {
|
|
53
|
+
console.log(err);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
module.exports = watchAdminFiles;
|
package/webpack.config.js
CHANGED
|
@@ -4,6 +4,7 @@ const path = require('path');
|
|
|
4
4
|
const fse = require('fs-extra');
|
|
5
5
|
const webpack = require('webpack');
|
|
6
6
|
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
|
7
|
+
const ForkTsCheckerPlugin = require('fork-ts-checker-webpack-plugin');
|
|
7
8
|
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
|
8
9
|
const { ESBuildMinifyPlugin } = require('esbuild-loader');
|
|
9
10
|
const WebpackBar = require('webpackbar');
|
|
@@ -14,12 +15,12 @@ const getClientEnvironment = require('./env');
|
|
|
14
15
|
const EE_REGEX = /from.* ['"]ee_else_ce\//;
|
|
15
16
|
|
|
16
17
|
module.exports = ({
|
|
17
|
-
entry,
|
|
18
18
|
cacheDir,
|
|
19
|
-
pluginsPath,
|
|
20
19
|
dest,
|
|
20
|
+
entry,
|
|
21
21
|
env,
|
|
22
22
|
optimize,
|
|
23
|
+
pluginsPath,
|
|
23
24
|
options = {
|
|
24
25
|
backend: 'http://localhost:1337',
|
|
25
26
|
adminPath: '/admin/',
|
|
@@ -29,6 +30,7 @@ module.exports = ({
|
|
|
29
30
|
eeRoot: './ee/admin',
|
|
30
31
|
ceRoot: './admin/src',
|
|
31
32
|
},
|
|
33
|
+
tsConfigFilePath,
|
|
32
34
|
}) => {
|
|
33
35
|
const isProduction = env === 'production';
|
|
34
36
|
|
|
@@ -49,6 +51,9 @@ module.exports = ({
|
|
|
49
51
|
]
|
|
50
52
|
: [];
|
|
51
53
|
|
|
54
|
+
// Directly inject a polyfill in the webpack entry point before the entry point
|
|
55
|
+
// FIXME: I have noticed a bug regarding the helper-plugin and esbuild-loader
|
|
56
|
+
// The only I could fix it was to inject the babel polyfill
|
|
52
57
|
const babelPolyfill = '@babel/polyfill/dist/polyfill.min.js';
|
|
53
58
|
|
|
54
59
|
return {
|
|
@@ -79,6 +84,16 @@ module.exports = ({
|
|
|
79
84
|
},
|
|
80
85
|
module: {
|
|
81
86
|
rules: [
|
|
87
|
+
{
|
|
88
|
+
test: /\.tsx?$/,
|
|
89
|
+
loader: require.resolve('esbuild-loader'),
|
|
90
|
+
include: [cacheDir, ...pluginsPath],
|
|
91
|
+
exclude: /node_modules/,
|
|
92
|
+
options: {
|
|
93
|
+
loader: 'tsx',
|
|
94
|
+
target: 'es2015',
|
|
95
|
+
},
|
|
96
|
+
},
|
|
82
97
|
{
|
|
83
98
|
test: /\.m?jsx?$/,
|
|
84
99
|
include: cacheDir,
|
|
@@ -94,6 +109,10 @@ module.exports = ({
|
|
|
94
109
|
try {
|
|
95
110
|
const fileContent = fse.readFileSync(filePath).toString();
|
|
96
111
|
|
|
112
|
+
if (fileContent.match(/from.* ['"]ee_else_ce\//)) {
|
|
113
|
+
return true;
|
|
114
|
+
}
|
|
115
|
+
|
|
97
116
|
return EE_REGEX.test(fileContent);
|
|
98
117
|
} catch (e) {
|
|
99
118
|
return false;
|
|
@@ -190,7 +209,7 @@ module.exports = ({
|
|
|
190
209
|
resolve: {
|
|
191
210
|
alias,
|
|
192
211
|
symlinks: false,
|
|
193
|
-
extensions: ['.js', '.jsx', '.react.js'],
|
|
212
|
+
extensions: ['.js', '.jsx', '.react.js', '.ts', '.tsx'],
|
|
194
213
|
mainFields: ['browser', 'jsnext:main', 'main'],
|
|
195
214
|
modules: ['node_modules', path.resolve(__dirname, 'node_modules')],
|
|
196
215
|
},
|
|
@@ -198,12 +217,16 @@ module.exports = ({
|
|
|
198
217
|
new HtmlWebpackPlugin({
|
|
199
218
|
inject: true,
|
|
200
219
|
template: path.resolve(__dirname, 'index.html'),
|
|
201
|
-
// FIXME
|
|
202
|
-
// favicon: path.resolve(__dirname, 'admin/src/favicon.ico'),
|
|
203
220
|
}),
|
|
204
221
|
new webpack.DefinePlugin(envVariables),
|
|
205
222
|
|
|
206
223
|
new NodePolyfillPlugin(),
|
|
224
|
+
|
|
225
|
+
new ForkTsCheckerPlugin({
|
|
226
|
+
typescript: {
|
|
227
|
+
configFile: tsConfigFilePath,
|
|
228
|
+
},
|
|
229
|
+
}),
|
|
207
230
|
...webpackPlugins,
|
|
208
231
|
],
|
|
209
232
|
};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { components } from 'react-select';
|
|
3
|
-
import Cross from '@strapi/icons/Cross';
|
|
4
|
-
import IconBox from './IconBox';
|
|
5
|
-
|
|
6
|
-
const ClearIndicator = props => {
|
|
7
|
-
const Component = components.ClearIndicator;
|
|
8
|
-
|
|
9
|
-
return (
|
|
10
|
-
<Component {...props}>
|
|
11
|
-
<IconBox as="button" type="button">
|
|
12
|
-
<Cross />
|
|
13
|
-
</IconBox>
|
|
14
|
-
</Component>
|
|
15
|
-
);
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
export default ClearIndicator;
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import styled from 'styled-components';
|
|
3
|
-
import CarretDown from '@strapi/icons/CarretDown';
|
|
4
|
-
import IconBox from './IconBox';
|
|
5
|
-
|
|
6
|
-
export const CarretBox = styled(IconBox)`
|
|
7
|
-
display: flex;
|
|
8
|
-
background: none;
|
|
9
|
-
border: none;
|
|
10
|
-
|
|
11
|
-
svg {
|
|
12
|
-
width: ${6 / 16}rem;
|
|
13
|
-
}
|
|
14
|
-
`;
|
|
15
|
-
|
|
16
|
-
const DropdownIndicator = () => {
|
|
17
|
-
return (
|
|
18
|
-
<CarretBox as="button" type="button" paddingRight={3}>
|
|
19
|
-
<CarretDown />
|
|
20
|
-
</CarretBox>
|
|
21
|
-
);
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
export default DropdownIndicator;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import styled from 'styled-components';
|
|
2
|
-
import { Box } from '@strapi/design-system/Box';
|
|
3
|
-
|
|
4
|
-
export const IconBox = styled(Box)`
|
|
5
|
-
background: transparent;
|
|
6
|
-
border: none;
|
|
7
|
-
position: relative;
|
|
8
|
-
z-index: 1;
|
|
9
|
-
|
|
10
|
-
svg {
|
|
11
|
-
height: ${11 / 16}rem;
|
|
12
|
-
width: ${11 / 16}rem;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
svg path {
|
|
16
|
-
fill: ${({ theme }) => theme.colors.neutral600};
|
|
17
|
-
}
|
|
18
|
-
`;
|
|
19
|
-
|
|
20
|
-
export default IconBox;
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
const getSelectStyles = theme => {
|
|
2
|
-
return {
|
|
3
|
-
clearIndicator: base => ({ ...base, padding: 0, paddingRight: theme.spaces[3] }),
|
|
4
|
-
container: base => ({
|
|
5
|
-
...base,
|
|
6
|
-
background: theme.colors.neutral0,
|
|
7
|
-
fontFamily: 'Arial',
|
|
8
|
-
lineHeight: 'normal',
|
|
9
|
-
}),
|
|
10
|
-
control: (base, state) => {
|
|
11
|
-
let border;
|
|
12
|
-
let borderBottom;
|
|
13
|
-
let backgroundColor;
|
|
14
|
-
|
|
15
|
-
if (state.isFocused) {
|
|
16
|
-
border = `1px solid ${theme.colors.primary600} !important`;
|
|
17
|
-
} else {
|
|
18
|
-
border = `1px solid ${theme.colors.neutral200} !important`;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
if (state.menuIsOpen === true) {
|
|
22
|
-
borderBottom = `1px solid ${theme.colors.primary600} !important`;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
if (state.isDisabled) {
|
|
26
|
-
backgroundColor = '#fafafb !important';
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
return {
|
|
30
|
-
...base,
|
|
31
|
-
fontSize: 14,
|
|
32
|
-
height: 40,
|
|
33
|
-
border,
|
|
34
|
-
outline: 0,
|
|
35
|
-
boxShadow: 0,
|
|
36
|
-
borderRadius: '2px !important',
|
|
37
|
-
borderBottom,
|
|
38
|
-
backgroundColor,
|
|
39
|
-
borderTopLeftRadius: '4px !important',
|
|
40
|
-
borderTopRightRadius: '4px !important',
|
|
41
|
-
borderBottomLeftRadius: '4px !important',
|
|
42
|
-
borderBottomRightRadius: '4px !important',
|
|
43
|
-
};
|
|
44
|
-
},
|
|
45
|
-
indicatorContainer: base => ({ ...base, padding: 0, paddingRight: theme.spaces[3] }),
|
|
46
|
-
input: base => ({ ...base, margin: 0, padding: 0, color: theme.colors.neutral800 }),
|
|
47
|
-
menu: base => {
|
|
48
|
-
return {
|
|
49
|
-
...base,
|
|
50
|
-
width: '100%',
|
|
51
|
-
marginTop: theme.spaces[1],
|
|
52
|
-
backgroundColor: theme.colors.neutral0,
|
|
53
|
-
color: theme.colors.neutral800,
|
|
54
|
-
borderRadius: '4px !important',
|
|
55
|
-
borderTopLeftRadius: '4px !important',
|
|
56
|
-
borderTopRightRadius: '4px !important',
|
|
57
|
-
border: `1px solid ${theme.colors.neutral200} !important`,
|
|
58
|
-
boxShadow: 0,
|
|
59
|
-
fontSize: '14px',
|
|
60
|
-
fontFamily: 'Arial',
|
|
61
|
-
zIndex: 2,
|
|
62
|
-
};
|
|
63
|
-
},
|
|
64
|
-
menuList: base => ({
|
|
65
|
-
...base,
|
|
66
|
-
paddingLeft: theme.spaces[1],
|
|
67
|
-
paddingTop: theme.spaces[1],
|
|
68
|
-
paddingRight: theme.spaces[1],
|
|
69
|
-
paddingBottom: theme.spaces[1],
|
|
70
|
-
}),
|
|
71
|
-
option: (base, state) => {
|
|
72
|
-
let backgroundColor = base.backgroundColor;
|
|
73
|
-
|
|
74
|
-
if (state.isFocused) {
|
|
75
|
-
backgroundColor = theme.colors.primary100;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
return { ...base, lineHeight: theme.spaces[5], backgroundColor, borderRadius: 4 };
|
|
79
|
-
},
|
|
80
|
-
placeholder: base => ({ ...base, marginLeft: 0 }),
|
|
81
|
-
singleValue: base => ({ ...base, marginLeft: 0, color: theme.colors.neutral800 }),
|
|
82
|
-
valueContainer: base => ({
|
|
83
|
-
...base,
|
|
84
|
-
padding: 0,
|
|
85
|
-
paddingLeft: theme.spaces[4],
|
|
86
|
-
marginLeft: 0,
|
|
87
|
-
marginRight: 0,
|
|
88
|
-
}),
|
|
89
|
-
};
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
export default getSelectStyles;
|