@strapi/admin 4.2.0-beta.4 → 4.2.2
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 +4 -7
- package/admin/src/components/OverlayBlocker/index.js +4 -0
- package/admin/src/content-manager/components/Wysiwyg/EditorStylesContainer.js +1 -1
- package/admin/src/hooks/{useFetchInstalledPlugins → useFetchEnabledPlugins}/index.js +4 -4
- package/admin/src/hooks/{useFetchInstalledPlugins → useFetchEnabledPlugins}/utils/api.js +2 -2
- package/admin/src/hooks/useFetchMarketplaceProviders/index.js +23 -0
- package/admin/src/hooks/useFetchMarketplaceProviders/utils/api.js +11 -0
- package/admin/src/pages/Admin/index.js +5 -15
- package/admin/src/pages/App/index.js +3 -17
- package/admin/src/pages/InstalledPluginsPage/Plugins.js +2 -2
- package/admin/src/pages/MarketplacePage/components/{EmptyPluginSearch/EmptyPluginGrid.js → EmptyNpmPackageSearch/EmptyNpmPackageGrid.js} +1 -1
- package/admin/src/pages/MarketplacePage/components/{EmptyPluginSearch → EmptyNpmPackageSearch}/index.js +6 -4
- package/admin/src/pages/MarketplacePage/components/{PluginCard → NpmPackageCard}/InstallPluginButton.js +0 -0
- package/admin/src/pages/MarketplacePage/components/{PluginCard → NpmPackageCard}/index.js +22 -11
- package/admin/src/pages/MarketplacePage/components/NpmPackagesGrid/index.js +48 -0
- package/admin/src/pages/MarketplacePage/components/PageHeader/index.js +12 -5
- package/admin/src/pages/MarketplacePage/index.js +91 -59
- package/admin/src/reducers.js +2 -4
- package/admin/src/translations/en.json +7 -3
- package/admin/src/translations/hi.json +699 -0
- package/admin/src/translations/languageNativeNames.js +1 -0
- package/admin/src/translations/pl.json +335 -78
- package/admin/src/translations/vi.json +17 -17
- package/admin/src/translations/zh-Hans.json +28 -1
- package/build/1856.6a94980b.chunk.js +172 -0
- package/build/2077.5456ccd1.chunk.js +194 -0
- package/build/2758.9475712b.chunk.js +162 -0
- package/build/2912.dd031292.chunk.js +253 -0
- package/build/4715.a6e62860.chunk.js +385 -0
- package/build/4982.c57c5675.chunk.js +308 -0
- package/build/7197.74d81c4c.chunk.js +113 -0
- package/build/{6229.a5cca9f2.chunk.js → 7589.77ef4fbf.chunk.js} +2 -2
- package/build/{472.0350a5bd.chunk.js → 7757.f6eb5e92.chunk.js} +58 -58
- package/build/7841.9e9cf739.chunk.js +253 -0
- package/build/8681.2fd4020a.chunk.js +163 -0
- package/build/9066.2847fdff.chunk.js +101 -0
- package/build/{4073.e144a91a.chunk.js → 9115.623dc4f7.chunk.js} +1 -1
- package/build/9158.c5f772d6.chunk.js +503 -0
- package/build/{9298.aff28744.chunk.js → 9298.cb3b6bc1.chunk.js} +93 -93
- package/build/9420.ba035f29.chunk.js +508 -0
- package/build/Admin-authenticatedApp.2a22d6f4.chunk.js +80 -0
- package/build/{Admin_homePage.0ac648e8.chunk.js → Admin_homePage.447df176.chunk.js} +1 -1
- package/build/Admin_marketplace.0724f650.chunk.js +11 -0
- package/build/Admin_pluginsPage.6f1187fe.chunk.js +1 -0
- package/build/{Admin_profilePage.27191ed2.chunk.js → Admin_profilePage.249cbfc9.chunk.js} +2 -2
- package/build/Admin_settingsPage.0d138832.chunk.js +180 -0
- package/build/{admin-edit-roles-page.fb374555.chunk.js → admin-edit-roles-page.7c2c9752.chunk.js} +1 -1
- package/build/admin-edit-users.b835bc48.chunk.js +11 -0
- package/build/admin-users.19900b75.chunk.js +12 -0
- package/build/{api-tokens-create-page.698f132d.chunk.js → api-tokens-create-page.8d299dde.chunk.js} +1 -1
- package/build/{api-tokens-edit-page.afece2fe.chunk.js → api-tokens-edit-page.3e453fc1.chunk.js} +1 -1
- package/build/{api-tokens-list-page.46d96dee.chunk.js → api-tokens-list-page.872c3800.chunk.js} +1 -1
- package/build/{codemirror-css.b467b1de.chunk.js → codemirror-css.98490df3.chunk.js} +2 -2
- package/build/{codemirror-javacript.41bdefda.chunk.js → codemirror-javacript.cafbda9c.chunk.js} +1 -1
- package/build/codemirror-theme.b3c64617.chunk.js +34 -0
- package/build/{content-manager.7cd28f84.chunk.js → content-manager.18834aa8.chunk.js} +10 -10
- package/build/content-type-builder-translation-pl-json.4a42349b.chunk.js +1 -0
- package/build/content-type-builder.55dd9554.chunk.js +142 -0
- package/build/{cropper-css.ecc0d670.chunk.js → cropper-css.0055cd53.chunk.js} +2 -2
- package/build/email-settings-page.1f235173.chunk.js +103 -0
- package/build/email-translation-pl-json.a03bcf98.chunk.js +1 -0
- package/build/en-json.0a5ba154.chunk.js +1 -0
- package/build/{fontawesome-css-all.04f33619.chunk.js → fontawesome-css-all.b88d464e.chunk.js} +3 -3
- package/build/{fontawesome-css.477ba714.chunk.js → fontawesome-css.a92a7b6c.chunk.js} +2 -2
- package/build/hi-json.b4ae16d1.chunk.js +1 -0
- package/build/highlight.js.9d8ef460.chunk.js +86 -0
- package/build/i18n-settings-page.06e88cf2.chunk.js +101 -0
- package/build/i18n-translation-pl-json.cea5bf23.chunk.js +1 -0
- package/build/index.html +1 -1
- package/build/main.fcb539e3.js +8406 -0
- package/build/pl-json.4d11f53d.chunk.js +1 -0
- package/build/runtime~main.ade14a85.js +2 -0
- package/build/sso-settings-page.a7c2e854.chunk.js +1 -0
- package/build/upload-settings.4ee2f135.chunk.js +101 -0
- package/build/upload-translation-pl-json.bb2aa937.chunk.js +1 -0
- package/build/upload.0d4153e8.chunk.js +105 -0
- package/build/users-advanced-settings-page.583c5dda.chunk.js +101 -0
- package/build/users-email-settings-page.8b9a266d.chunk.js +1 -0
- package/build/users-permissions-translation-en-json.765abf48.chunk.js +1 -0
- package/build/users-permissions-translation-pl-json.1dbdd4a1.chunk.js +1 -0
- package/build/users-providers-settings-page.fc9d8f9d.chunk.js +1 -0
- package/build/{users-roles-settings-page.988ebc3b.chunk.js → users-roles-settings-page.1bf4ffc5.chunk.js} +2 -2
- package/build/vi-json.bf3424be.chunk.js +1 -0
- package/build/{webhook-edit-page.a7ae6e3b.chunk.js → webhook-edit-page.142b23ac.chunk.js} +2 -2
- package/build/webhook-list-page.671582a0.chunk.js +133 -0
- package/build/zh-Hans-json.562f3b6f.chunk.js +1 -0
- package/index.js +239 -53
- package/package.json +9 -11
- package/scripts/build.js +3 -17
- package/server/controllers/admin.js +2 -15
- package/server/policies/index.js +0 -1
- package/server/routes/admin.js +0 -9
- package/server/routes/serve-admin-panel.js +1 -1
- package/webpack.alias.js +30 -19
- package/webpack.config.js +9 -29
- package/admin/src/pages/App/constants.js +0 -1
- package/admin/src/pages/App/reducer.js +0 -22
- package/admin/src/pages/MarketplacePage/utils/api.js +0 -9
- package/admin/src/tsconfig.json +0 -10
- package/build/1541.6c1c96f9.chunk.js +0 -307
- package/build/1856.521a99fd.chunk.js +0 -172
- package/build/2077.51485bfb.chunk.js +0 -194
- package/build/2912.79c2b3c8.chunk.js +0 -253
- package/build/3214.9196aeff.chunk.js +0 -235
- package/build/3865.21cec9de.chunk.js +0 -310
- package/build/4715.77e04177.chunk.js +0 -385
- package/build/4982.f53b78a4.chunk.js +0 -308
- package/build/7351.b95e65ae.chunk.js +0 -428
- package/build/7418.6db737ce.chunk.js +0 -112
- package/build/7841.f0e7d629.chunk.js +0 -253
- package/build/8826.58e236d4.chunk.js +0 -1057
- package/build/9066.118ecccd.chunk.js +0 -101
- package/build/9420.cb0b75e8.chunk.js +0 -508
- package/build/9988.f84412d9.chunk.js +0 -162
- package/build/Admin-authenticatedApp.162a5805.chunk.js +0 -80
- package/build/Admin_marketplace.0bb91ec8.chunk.js +0 -11
- package/build/Admin_pluginsPage.788fb2f6.chunk.js +0 -1
- package/build/Admin_settingsPage.23e873f0.chunk.js +0 -178
- package/build/admin-edit-users.a360deaf.chunk.js +0 -10
- package/build/admin-users.47d06d24.chunk.js +0 -11
- package/build/codemirror-theme.cf9f9eb6.chunk.js +0 -34
- package/build/content-type-builder-translation-pl-json.a866acda.chunk.js +0 -1
- package/build/content-type-builder.7456cabe.chunk.js +0 -141
- package/build/email-settings-page.f67d13b2.chunk.js +0 -103
- package/build/email-translation-pl-json.6da50d0f.chunk.js +0 -1
- package/build/en-json.40ee00aa.chunk.js +0 -1
- package/build/highlight.js.3381ffc3.chunk.js +0 -86
- package/build/i18n-settings-page.6b67cb75.chunk.js +0 -101
- package/build/main.b632a0d6.js +0 -11625
- package/build/pl-json.94f05d2c.chunk.js +0 -1
- package/build/runtime~main.38d418e9.js +0 -2
- package/build/sso-settings-page.dfb0b917.chunk.js +0 -1
- package/build/upload-settings.3db55de0.chunk.js +0 -101
- package/build/upload-translation-pl-json.6071e38c.chunk.js +0 -1
- package/build/upload.070c189b.chunk.js +0 -105
- package/build/users-advanced-settings-page.a23cda17.chunk.js +0 -101
- package/build/users-email-settings-page.0a096388.chunk.js +0 -1
- package/build/users-permissions-translation-en-json.3fe86528.chunk.js +0 -1
- package/build/users-permissions-translation-pl-json.3c4fe81c.chunk.js +0 -1
- package/build/users-providers-settings-page.bfe7755a.chunk.js +0 -1
- package/build/vi-json.3d14e91e.chunk.js +0 -1
- package/build/webhook-list-page.83297d98.chunk.js +0 -133
- package/build/zh-Hans-json.c84ce330.chunk.js +0 -1
- package/server/policies/isTelemetryEnabled.js +0 -16
- package/utils/create-cache-dir.js +0 -161
- package/utils/get-custom-app-config-file.js +0 -23
- package/utils/get-custom-webpack-config.js +0 -38
- package/utils/get-plugins-path.js +0 -26
- package/utils/index.js +0 -13
- package/utils/should-build-admin.js +0 -52
- package/utils/watch-admin-files.js +0 -59
package/index.js
CHANGED
|
@@ -1,37 +1,66 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const path = require('path');
|
|
4
|
+
const _ = require('lodash');
|
|
4
5
|
const fs = require('fs-extra');
|
|
5
6
|
const webpack = require('webpack');
|
|
6
7
|
const WebpackDevServer = require('webpack-dev-server');
|
|
7
|
-
const { isUsingTypeScript } = require('@strapi/typescript-utils');
|
|
8
8
|
const chalk = require('chalk');
|
|
9
|
+
const chokidar = require('chokidar');
|
|
10
|
+
const getWebpackConfig = require('./webpack.config');
|
|
9
11
|
|
|
10
|
-
const {
|
|
11
|
-
createCacheDir,
|
|
12
|
-
getCustomWebpackConfig,
|
|
13
|
-
shouldBuildAdmin,
|
|
14
|
-
watchAdminFiles,
|
|
15
|
-
} = require('./utils');
|
|
12
|
+
const getPkgPath = name => path.dirname(require.resolve(`${name}/package.json`));
|
|
16
13
|
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
const DEFAULT_PLUGINS = [
|
|
15
|
+
'content-type-builder',
|
|
16
|
+
'content-manager',
|
|
17
|
+
'upload',
|
|
18
|
+
'email',
|
|
19
|
+
'i18n',
|
|
20
|
+
'users-permissions',
|
|
21
|
+
];
|
|
19
22
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
);
|
|
23
|
+
function getCustomWebpackConfig(dir, config) {
|
|
24
|
+
const adminConfigPath = path.join(dir, 'src', 'admin', 'webpack.config.js');
|
|
25
|
+
|
|
26
|
+
let webpackConfig = getWebpackConfig(config);
|
|
27
|
+
|
|
28
|
+
if (fs.existsSync(adminConfigPath)) {
|
|
29
|
+
const webpackAdminConfig = require(path.resolve(adminConfigPath));
|
|
30
|
+
|
|
31
|
+
if (_.isFunction(webpackAdminConfig)) {
|
|
32
|
+
// Expose the devServer configuration
|
|
33
|
+
if (config.devServer) {
|
|
34
|
+
webpackConfig.devServer = config.devServer;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
webpackConfig = webpackAdminConfig(webpackConfig, webpack);
|
|
38
|
+
|
|
39
|
+
if (!webpackConfig) {
|
|
40
|
+
console.error(
|
|
41
|
+
`${chalk.red('Error:')} Nothing was returned from your custom webpack configuration`
|
|
42
|
+
);
|
|
43
|
+
process.exit(1);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return webpackConfig;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
async function build({ plugins, dir, env, options, optimize, forceBuild }) {
|
|
52
|
+
const buildAdmin = await shouldBuildAdmin({ dir, plugins });
|
|
24
53
|
|
|
25
54
|
if (!buildAdmin && !forceBuild) {
|
|
26
55
|
return;
|
|
27
56
|
}
|
|
28
57
|
|
|
29
58
|
// Create the cache dir containing the front-end files.
|
|
30
|
-
await createCacheDir({
|
|
59
|
+
await createCacheDir({ dir, plugins });
|
|
31
60
|
|
|
32
|
-
const cacheDir = path.resolve(
|
|
61
|
+
const cacheDir = path.resolve(dir, '.cache');
|
|
33
62
|
const entry = path.resolve(cacheDir, 'admin', 'src');
|
|
34
|
-
const dest = path.resolve(
|
|
63
|
+
const dest = path.resolve(dir, 'build');
|
|
35
64
|
|
|
36
65
|
// Roots for the @strapi/babel-plugin-switch-ee-ce
|
|
37
66
|
const roots = {
|
|
@@ -41,23 +70,15 @@ async function build({ appDir, buildDestDir, env, forceBuild, optimize, options,
|
|
|
41
70
|
|
|
42
71
|
const pluginsPath = Object.keys(plugins).map(pluginName => plugins[pluginName].pathToPlugin);
|
|
43
72
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
? path.join(appDir, 'src', 'admin', 'tsconfig.json')
|
|
48
|
-
: path.resolve(entry, 'tsconfig.json');
|
|
49
|
-
|
|
50
|
-
const config = getCustomWebpackConfig(appDir, {
|
|
51
|
-
appDir,
|
|
73
|
+
const config = getCustomWebpackConfig(dir, {
|
|
74
|
+
entry,
|
|
75
|
+
pluginsPath,
|
|
52
76
|
cacheDir,
|
|
53
77
|
dest,
|
|
54
|
-
entry,
|
|
55
78
|
env,
|
|
56
|
-
optimize,
|
|
57
79
|
options,
|
|
58
|
-
|
|
80
|
+
optimize,
|
|
59
81
|
roots,
|
|
60
|
-
tsConfigFilePath,
|
|
61
82
|
});
|
|
62
83
|
|
|
63
84
|
const compiler = webpack(config);
|
|
@@ -88,27 +109,115 @@ async function build({ appDir, buildDestDir, env, forceBuild, optimize, options,
|
|
|
88
109
|
});
|
|
89
110
|
}
|
|
90
111
|
|
|
91
|
-
async function
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
112
|
+
async function createPluginsJs(plugins, dest) {
|
|
113
|
+
const pluginsArray = plugins.map(({ pathToPlugin, name }) => {
|
|
114
|
+
const shortName = _.camelCase(name);
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* path.join, on windows, it uses backslashes to resolve path.
|
|
118
|
+
* The problem is that Webpack does not windows paths
|
|
119
|
+
* With this tool, we need to rely on "/" and not "\".
|
|
120
|
+
* This is the reason why '..\\..\\..\\node_modules\\@strapi\\plugin-content-type-builder/strapi-admin.js' was not working.
|
|
121
|
+
* The regexp at line 105 aims to replace the windows backslashes by standard slash so that webpack can deal with them.
|
|
122
|
+
* Backslash looks to work only for absolute paths with webpack => https://webpack.js.org/concepts/module-resolution/#absolute-paths
|
|
123
|
+
*/
|
|
124
|
+
const realPath = path
|
|
125
|
+
.join(path.relative(path.resolve(dest, 'admin', 'src'), pathToPlugin), 'strapi-admin.js')
|
|
126
|
+
.replace(/\\/g, '/');
|
|
127
|
+
|
|
128
|
+
return {
|
|
129
|
+
name,
|
|
130
|
+
pathToPlugin: realPath,
|
|
131
|
+
shortName,
|
|
132
|
+
};
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
const content = `
|
|
136
|
+
${pluginsArray
|
|
137
|
+
.map(({ pathToPlugin, shortName }) => {
|
|
138
|
+
const req = `'${pathToPlugin}'`;
|
|
139
|
+
|
|
140
|
+
return `import ${shortName} from ${req};`;
|
|
141
|
+
})
|
|
142
|
+
.join('\n')}
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
const plugins = {
|
|
146
|
+
${[...pluginsArray]
|
|
147
|
+
.map(({ name, shortName }) => {
|
|
148
|
+
return ` '${name}': ${shortName},`;
|
|
149
|
+
})
|
|
150
|
+
.join('\n')}
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
export default plugins;
|
|
154
|
+
`;
|
|
155
|
+
|
|
156
|
+
return fs.writeFile(path.resolve(dest, 'admin', 'src', 'plugins.js'), content);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
async function clean({ dir }) {
|
|
160
|
+
const buildDir = path.join(dir, 'build');
|
|
161
|
+
const cacheDir = path.join(dir, '.cache');
|
|
96
162
|
|
|
97
163
|
fs.removeSync(buildDir);
|
|
98
164
|
fs.removeSync(cacheDir);
|
|
99
165
|
}
|
|
100
166
|
|
|
101
|
-
async function
|
|
102
|
-
const
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
);
|
|
167
|
+
async function copyAdmin(dest) {
|
|
168
|
+
const adminPath = getPkgPath('@strapi/admin');
|
|
169
|
+
|
|
170
|
+
// TODO copy ee folders for plugins
|
|
171
|
+
await fs.copy(path.resolve(adminPath, 'ee', 'admin'), path.resolve(dest, 'ee', 'admin'));
|
|
172
|
+
|
|
173
|
+
await fs.ensureDir(path.resolve(dest, 'config'));
|
|
174
|
+
await fs.copy(path.resolve(adminPath, 'admin'), path.resolve(dest, 'admin'));
|
|
175
|
+
|
|
176
|
+
// Copy package.json
|
|
177
|
+
await fs.copy(path.resolve(adminPath, 'package.json'), path.resolve(dest, 'package.json'));
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
async function createCacheDir({ dir, plugins }) {
|
|
181
|
+
const cacheDir = path.resolve(dir, '.cache');
|
|
182
|
+
|
|
183
|
+
const pluginsWithFront = Object.keys(plugins)
|
|
184
|
+
.filter(pluginName => {
|
|
185
|
+
const pluginInfo = plugins[pluginName];
|
|
186
|
+
return fs.existsSync(path.resolve(pluginInfo.pathToPlugin, 'strapi-admin.js'));
|
|
187
|
+
})
|
|
188
|
+
.map(name => ({ name, ...plugins[name] }));
|
|
189
|
+
|
|
190
|
+
// create .cache dir
|
|
191
|
+
await fs.emptyDir(cacheDir);
|
|
192
|
+
|
|
193
|
+
// copy admin core code
|
|
194
|
+
await copyAdmin(cacheDir);
|
|
195
|
+
|
|
196
|
+
// Copy app.js
|
|
197
|
+
const customAdminConfigFilePath = path.join(dir, 'src', 'admin', 'app.js');
|
|
198
|
+
|
|
199
|
+
if (fs.existsSync(customAdminConfigFilePath)) {
|
|
200
|
+
await fs.copy(customAdminConfigFilePath, path.resolve(cacheDir, 'admin', 'src', 'app.js'));
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
// Copy admin extensions folder
|
|
204
|
+
const adminExtensionFolder = path.join(dir, 'src', 'admin', 'extensions');
|
|
205
|
+
|
|
206
|
+
if (fs.existsSync(adminExtensionFolder)) {
|
|
207
|
+
await fs.copy(adminExtensionFolder, path.resolve(cacheDir, 'admin', 'src', 'extensions'));
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
// create plugins.js with plugins requires
|
|
211
|
+
await createPluginsJs(pluginsWithFront, cacheDir);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
async function watchAdmin({ plugins, dir, host, port, browser, options }) {
|
|
106
215
|
// Create the cache dir containing the front-end files.
|
|
107
|
-
const cacheDir = path.join(
|
|
108
|
-
await createCacheDir({
|
|
216
|
+
const cacheDir = path.join(dir, '.cache');
|
|
217
|
+
await createCacheDir({ dir, plugins });
|
|
109
218
|
|
|
110
219
|
const entry = path.join(cacheDir, 'admin', 'src');
|
|
111
|
-
const dest = path.join(
|
|
220
|
+
const dest = path.join(dir, 'build');
|
|
112
221
|
const env = 'development';
|
|
113
222
|
|
|
114
223
|
// Roots for the @strapi/babel-plugin-switch-ee-ce
|
|
@@ -119,20 +228,14 @@ async function watchAdmin({ appDir, browser, buildDestDir, host, options, plugin
|
|
|
119
228
|
|
|
120
229
|
const pluginsPath = Object.keys(plugins).map(pluginName => plugins[pluginName].pathToPlugin);
|
|
121
230
|
|
|
122
|
-
// Either use the tsconfig file from the generated app or the one inside the .cache folder
|
|
123
|
-
// so we can develop plugins in TS while being in a JS app
|
|
124
|
-
const tsConfigFilePath = useTypeScript
|
|
125
|
-
? path.join(appDir, 'src', 'admin', 'tsconfig.json')
|
|
126
|
-
: path.resolve(entry, 'tsconfig.json');
|
|
127
|
-
|
|
128
231
|
const args = {
|
|
129
|
-
|
|
232
|
+
entry,
|
|
130
233
|
cacheDir,
|
|
234
|
+
pluginsPath,
|
|
131
235
|
dest,
|
|
132
|
-
entry,
|
|
133
236
|
env,
|
|
237
|
+
port,
|
|
134
238
|
options,
|
|
135
|
-
pluginsPath,
|
|
136
239
|
roots,
|
|
137
240
|
devServer: {
|
|
138
241
|
port,
|
|
@@ -143,6 +246,7 @@ async function watchAdmin({ appDir, browser, buildDestDir, host, options, plugin
|
|
|
143
246
|
warnings: false,
|
|
144
247
|
},
|
|
145
248
|
},
|
|
249
|
+
|
|
146
250
|
open: browser === 'true' ? true : browser,
|
|
147
251
|
devMiddleware: {
|
|
148
252
|
publicPath: options.adminPath,
|
|
@@ -152,10 +256,9 @@ async function watchAdmin({ appDir, browser, buildDestDir, host, options, plugin
|
|
|
152
256
|
disableDotRule: true,
|
|
153
257
|
},
|
|
154
258
|
},
|
|
155
|
-
tsConfigFilePath,
|
|
156
259
|
};
|
|
157
260
|
|
|
158
|
-
const webpackConfig = getCustomWebpackConfig(
|
|
261
|
+
const webpackConfig = getCustomWebpackConfig(dir, args);
|
|
159
262
|
|
|
160
263
|
const compiler = webpack(webpackConfig);
|
|
161
264
|
|
|
@@ -176,7 +279,90 @@ async function watchAdmin({ appDir, browser, buildDestDir, host, options, plugin
|
|
|
176
279
|
|
|
177
280
|
runServer();
|
|
178
281
|
|
|
179
|
-
|
|
282
|
+
watchFiles(dir);
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
/**
|
|
286
|
+
* Listen to files change and copy the changed files in the .cache/admin folder
|
|
287
|
+
* when using the dev mode
|
|
288
|
+
* @param {string} dir
|
|
289
|
+
*/
|
|
290
|
+
async function watchFiles(dir) {
|
|
291
|
+
const cacheDir = path.join(dir, '.cache');
|
|
292
|
+
const appExtensionFile = path.join(dir, 'src', 'admin', 'app.js');
|
|
293
|
+
const extensionsPath = path.join(dir, 'src', 'admin', 'extensions');
|
|
294
|
+
|
|
295
|
+
// Only watch the admin/app.js file and the files that are in the ./admin/extensions/folder
|
|
296
|
+
const filesToWatch = [appExtensionFile, extensionsPath];
|
|
297
|
+
|
|
298
|
+
const watcher = chokidar.watch(filesToWatch, {
|
|
299
|
+
ignoreInitial: true,
|
|
300
|
+
ignorePermissionErrors: true,
|
|
301
|
+
});
|
|
302
|
+
|
|
303
|
+
watcher.on('all', async (event, filePath) => {
|
|
304
|
+
const isAppFile = filePath.includes(appExtensionFile);
|
|
305
|
+
|
|
306
|
+
// The app.js file needs to be copied in the .cache/admin/src/app.js and the other ones needs to
|
|
307
|
+
// be copied in the .cache/admin/src/extensions folder
|
|
308
|
+
const targetPath = isAppFile
|
|
309
|
+
? path.join(path.normalize(filePath.split(appExtensionFile)[1]), 'app.js')
|
|
310
|
+
: path.join('extensions', path.normalize(filePath.split(extensionsPath)[1]));
|
|
311
|
+
|
|
312
|
+
const destFolder = path.join(cacheDir, 'admin', 'src');
|
|
313
|
+
|
|
314
|
+
if (event === 'unlink' || event === 'unlinkDir') {
|
|
315
|
+
// Remove the file or folder
|
|
316
|
+
// We need to copy the original files when deleting an override one
|
|
317
|
+
try {
|
|
318
|
+
fs.removeSync(path.join(destFolder, targetPath));
|
|
319
|
+
} catch (err) {
|
|
320
|
+
console.log('An error occured while deleting the file', err);
|
|
321
|
+
}
|
|
322
|
+
} else {
|
|
323
|
+
// In any other case just copy the file into the .cache/admin/src folder
|
|
324
|
+
try {
|
|
325
|
+
await fs.copy(filePath, path.join(destFolder, targetPath));
|
|
326
|
+
} catch (err) {
|
|
327
|
+
console.log(err);
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
});
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
const hasCustomAdminCode = async dir => {
|
|
334
|
+
const customAdminPath = path.join(dir, 'src', 'admin');
|
|
335
|
+
const customAdminConfigFile = path.join(customAdminPath, 'app.js');
|
|
336
|
+
const customAdminWebpackFile = path.join(customAdminPath, 'webpack.config.js');
|
|
337
|
+
|
|
338
|
+
const hasCustomConfigFile = await fs.pathExists(customAdminConfigFile);
|
|
339
|
+
const hasCustomWebpackFile = await fs.pathExists(customAdminWebpackFile);
|
|
340
|
+
|
|
341
|
+
return hasCustomConfigFile || hasCustomWebpackFile;
|
|
342
|
+
};
|
|
343
|
+
|
|
344
|
+
/**
|
|
345
|
+
* Checks if the project's installed plugins are not the same as a default one.
|
|
346
|
+
* @param {Object} plugins
|
|
347
|
+
* @returns {boolean}
|
|
348
|
+
*/
|
|
349
|
+
const hasNonDefaultPlugins = plugins => {
|
|
350
|
+
// List of plugins that are not the ones installed in a generated app
|
|
351
|
+
const installedPlugins = Object.keys(plugins).filter(x => !DEFAULT_PLUGINS.includes(x));
|
|
352
|
+
|
|
353
|
+
// List of default plugins uninstalled from a generated app
|
|
354
|
+
const missingPlugins = DEFAULT_PLUGINS.filter(x => !Object.keys(plugins).includes(x));
|
|
355
|
+
|
|
356
|
+
const diff = [...installedPlugins, ...missingPlugins];
|
|
357
|
+
|
|
358
|
+
return diff.length > 0;
|
|
359
|
+
};
|
|
360
|
+
|
|
361
|
+
async function shouldBuildAdmin({ dir, plugins }) {
|
|
362
|
+
const appHasCustomAdminCode = await hasCustomAdminCode(dir);
|
|
363
|
+
const appHasNonDefaultPlugins = hasNonDefaultPlugins(plugins);
|
|
364
|
+
|
|
365
|
+
return appHasCustomAdminCode || appHasNonDefaultPlugins;
|
|
180
366
|
}
|
|
181
367
|
|
|
182
368
|
module.exports = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@strapi/admin",
|
|
3
|
-
"version": "4.2.
|
|
3
|
+
"version": "4.2.2",
|
|
4
4
|
"description": "Strapi Admin",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -28,7 +28,6 @@
|
|
|
28
28
|
"develop:webpack": "cross-env NODE_ENV=development webpack serve --config webpack.config.dev.js --progress profile",
|
|
29
29
|
"prepublishOnly": "yarn build",
|
|
30
30
|
"build": "rimraf build && node ./scripts/build.js",
|
|
31
|
-
"build:mesure": "rimraf build && cross-env MESURE_BUILD_SPEED=true node ./scripts/build.js",
|
|
32
31
|
"test": "echo \"no tests yet\"",
|
|
33
32
|
"test:unit": "jest --verbose",
|
|
34
33
|
"test:front": "cross-env IS_EE=true jest --config ./jest.config.front.js",
|
|
@@ -50,12 +49,12 @@
|
|
|
50
49
|
"@fortawesome/free-brands-svg-icons": "^5.15.3",
|
|
51
50
|
"@fortawesome/free-solid-svg-icons": "^5.15.3",
|
|
52
51
|
"@fortawesome/react-fontawesome": "^0.1.14",
|
|
53
|
-
"@
|
|
54
|
-
"@strapi/
|
|
55
|
-
"@strapi/
|
|
56
|
-
"@strapi/
|
|
57
|
-
"@strapi/
|
|
58
|
-
"@strapi/utils": "4.2.
|
|
52
|
+
"@pmmmwh/react-refresh-webpack-plugin": "0.5.4",
|
|
53
|
+
"@strapi/babel-plugin-switch-ee-ce": "4.2.2",
|
|
54
|
+
"@strapi/design-system": "1.2.0",
|
|
55
|
+
"@strapi/helper-plugin": "4.2.2",
|
|
56
|
+
"@strapi/icons": "1.2.0",
|
|
57
|
+
"@strapi/utils": "4.2.2",
|
|
59
58
|
"axios": "0.24.0",
|
|
60
59
|
"babel-loader": "8.2.3",
|
|
61
60
|
"babel-plugin-styled-components": "2.0.2",
|
|
@@ -71,7 +70,6 @@
|
|
|
71
70
|
"execa": "^1.0.0",
|
|
72
71
|
"fast-deep-equal": "3.1.3",
|
|
73
72
|
"font-awesome": "^4.7.0",
|
|
74
|
-
"fork-ts-checker-webpack-plugin": "7.2.1",
|
|
75
73
|
"formik": "^2.2.6",
|
|
76
74
|
"fs-extra": "10.0.0",
|
|
77
75
|
"highlight.js": "^10.4.1",
|
|
@@ -116,6 +114,7 @@
|
|
|
116
114
|
"react-intl": "5.20.2",
|
|
117
115
|
"react-query": "3.24.3",
|
|
118
116
|
"react-redux": "7.2.3",
|
|
117
|
+
"react-refresh": "0.11.0",
|
|
119
118
|
"react-router": "5.2.0",
|
|
120
119
|
"react-router-dom": "5.2.0",
|
|
121
120
|
"react-select": "^4.0.2",
|
|
@@ -137,12 +136,11 @@
|
|
|
137
136
|
},
|
|
138
137
|
"devDependencies": {
|
|
139
138
|
"duplicate-dependencies-webpack-plugin": "0.2.0",
|
|
140
|
-
"speed-measure-webpack-plugin": "1.5.0",
|
|
141
139
|
"webpack-bundle-analyzer": "4.4.1"
|
|
142
140
|
},
|
|
143
141
|
"engines": {
|
|
144
142
|
"node": ">=14.19.1 <=16.x.x",
|
|
145
143
|
"npm": ">=6.0.0"
|
|
146
144
|
},
|
|
147
|
-
"gitHead": "
|
|
145
|
+
"gitHead": "376ff3133c13f6eb10d0c90f4b5eb701592aff97"
|
|
148
146
|
}
|
package/scripts/build.js
CHANGED
|
@@ -3,11 +3,7 @@
|
|
|
3
3
|
const path = require('path');
|
|
4
4
|
const webpack = require('webpack');
|
|
5
5
|
const { isObject } = require('lodash');
|
|
6
|
-
// eslint-disable-next-line node/no-extraneous-require
|
|
7
|
-
const SpeedMeasurePlugin = require('speed-measure-webpack-plugin');
|
|
8
|
-
|
|
9
6
|
const webpackConfig = require('../webpack.config');
|
|
10
|
-
const getPluginsPath = require('../utils/get-plugins-path');
|
|
11
7
|
const {
|
|
12
8
|
getCorePluginsPath,
|
|
13
9
|
getPluginToInstallPath,
|
|
@@ -16,39 +12,29 @@ const {
|
|
|
16
12
|
|
|
17
13
|
const PLUGINS_TO_INSTALL = ['i18n', 'users-permissions'];
|
|
18
14
|
|
|
19
|
-
// Wrapper that outputs the webpack speed
|
|
20
|
-
const smp = new SpeedMeasurePlugin();
|
|
21
|
-
|
|
22
15
|
const buildAdmin = async () => {
|
|
23
16
|
const entry = path.join(__dirname, '..', 'admin', 'src');
|
|
24
17
|
const dest = path.join(__dirname, '..', 'build');
|
|
25
|
-
const tsConfigFilePath = path.join(__dirname, '..', 'admin', 'src', 'tsconfig.json');
|
|
26
|
-
|
|
27
18
|
const corePlugins = getCorePluginsPath();
|
|
28
19
|
const plugins = getPluginToInstallPath(PLUGINS_TO_INSTALL);
|
|
29
20
|
const allPlugins = { ...corePlugins, ...plugins };
|
|
30
|
-
const pluginsPath = getPluginsPath();
|
|
31
21
|
|
|
32
22
|
await createPluginsFile(allPlugins);
|
|
33
23
|
|
|
34
24
|
const args = {
|
|
35
25
|
entry,
|
|
36
26
|
dest,
|
|
37
|
-
cacheDir: path.
|
|
38
|
-
pluginsPath,
|
|
27
|
+
cacheDir: path.resolve(__dirname, '..'),
|
|
28
|
+
pluginsPath: [path.resolve(__dirname, '../../../../packages')],
|
|
39
29
|
env: 'production',
|
|
40
30
|
optimize: true,
|
|
41
31
|
options: {
|
|
42
32
|
backend: 'http://localhost:1337',
|
|
43
33
|
adminPath: '/admin/',
|
|
44
34
|
},
|
|
45
|
-
tsConfigFilePath,
|
|
46
35
|
};
|
|
47
36
|
|
|
48
|
-
const
|
|
49
|
-
process.env.MESURE_BUILD_SPEED === 'true' ? smp.wrap(webpackConfig(args)) : webpackConfig(args);
|
|
50
|
-
|
|
51
|
-
const compiler = webpack(config);
|
|
37
|
+
const compiler = webpack(webpackConfig(args));
|
|
52
38
|
|
|
53
39
|
console.log('Building the admin panel');
|
|
54
40
|
|
|
@@ -5,7 +5,6 @@ const execa = require('execa');
|
|
|
5
5
|
const _ = require('lodash');
|
|
6
6
|
const { exists } = require('fs-extra');
|
|
7
7
|
const { ValidationError } = require('@strapi/utils').errors;
|
|
8
|
-
const { isUsingTypeScript } = require('@strapi/typescript-utils');
|
|
9
8
|
// eslint-disable-next-line node/no-extraneous-require
|
|
10
9
|
const ee = require('@strapi/strapi/lib/utils/ee');
|
|
11
10
|
|
|
@@ -82,24 +81,11 @@ module.exports = {
|
|
|
82
81
|
return projectSettingsService.updateProjectSettings({ ...body, ...formatedFiles });
|
|
83
82
|
},
|
|
84
83
|
|
|
85
|
-
async telemetryProperties() {
|
|
86
|
-
const useTypescriptOnServer = await isUsingTypeScript(strapi.dirs.app.root);
|
|
87
|
-
const useTypescriptOnAdmin = await isUsingTypeScript(
|
|
88
|
-
path.join(strapi.dirs.app.root, 'src', 'admin')
|
|
89
|
-
);
|
|
90
|
-
|
|
91
|
-
return {
|
|
92
|
-
data: {
|
|
93
|
-
useTypescriptOnServer,
|
|
94
|
-
useTypescriptOnAdmin,
|
|
95
|
-
},
|
|
96
|
-
};
|
|
97
|
-
},
|
|
98
|
-
|
|
99
84
|
async information() {
|
|
100
85
|
const currentEnvironment = strapi.config.get('environment');
|
|
101
86
|
const autoReload = strapi.config.get('autoReload', false);
|
|
102
87
|
const strapiVersion = strapi.config.get('info.strapi', null);
|
|
88
|
+
const dependencies = strapi.config.get('info.dependencies', {});
|
|
103
89
|
const nodeVersion = process.version;
|
|
104
90
|
const communityEdition = !strapi.EE;
|
|
105
91
|
const useYarn = await exists(path.join(process.cwd(), 'yarn.lock'));
|
|
@@ -109,6 +95,7 @@ module.exports = {
|
|
|
109
95
|
currentEnvironment,
|
|
110
96
|
autoReload,
|
|
111
97
|
strapiVersion,
|
|
98
|
+
dependencies,
|
|
112
99
|
nodeVersion,
|
|
113
100
|
communityEdition,
|
|
114
101
|
useYarn,
|
package/server/policies/index.js
CHANGED
package/server/routes/admin.js
CHANGED
|
@@ -49,15 +49,6 @@ module.exports = [
|
|
|
49
49
|
policies: ['admin::isAuthenticatedAdmin'],
|
|
50
50
|
},
|
|
51
51
|
},
|
|
52
|
-
{
|
|
53
|
-
method: 'GET',
|
|
54
|
-
path: '/telemetry-properties',
|
|
55
|
-
handler: 'admin.telemetryProperties',
|
|
56
|
-
config: {
|
|
57
|
-
auth: false,
|
|
58
|
-
policies: ['admin::isTelemetryEnabled'],
|
|
59
|
-
},
|
|
60
|
-
},
|
|
61
52
|
{
|
|
62
53
|
method: 'GET',
|
|
63
54
|
path: '/plugins',
|
|
@@ -5,7 +5,7 @@ const fse = require('fs-extra');
|
|
|
5
5
|
const koaStatic = require('koa-static');
|
|
6
6
|
|
|
7
7
|
const registerAdminPanelRoute = ({ strapi }) => {
|
|
8
|
-
let buildDir = resolve(strapi.dirs.
|
|
8
|
+
let buildDir = resolve(strapi.dirs.root, 'build');
|
|
9
9
|
|
|
10
10
|
if (!fse.pathExistsSync(buildDir)) {
|
|
11
11
|
buildDir = resolve(__dirname, '../../build');
|
package/webpack.alias.js
CHANGED
|
@@ -2,18 +2,19 @@
|
|
|
2
2
|
|
|
3
3
|
const path = require('path');
|
|
4
4
|
|
|
5
|
-
const
|
|
6
|
-
'
|
|
7
|
-
'
|
|
5
|
+
const aliasExactMatch = [
|
|
6
|
+
'@strapi/design-system',
|
|
7
|
+
'@strapi/helper-plugin',
|
|
8
|
+
'@strapi/icons',
|
|
8
9
|
'@fortawesome/fontawesome-svg-core',
|
|
9
10
|
'@fortawesome/free-solid-svg-icons',
|
|
11
|
+
'date-fns',
|
|
12
|
+
'formik',
|
|
10
13
|
'history',
|
|
11
|
-
'hoist-non-react-statics',
|
|
12
14
|
'immer',
|
|
13
|
-
'
|
|
15
|
+
'qs',
|
|
14
16
|
'lodash',
|
|
15
17
|
'moment',
|
|
16
|
-
'qs',
|
|
17
18
|
'react',
|
|
18
19
|
'react-copy-to-clipboard',
|
|
19
20
|
'react-dnd',
|
|
@@ -24,6 +25,7 @@ const alias = [
|
|
|
24
25
|
'react-helmet',
|
|
25
26
|
'react-is',
|
|
26
27
|
'react-intl',
|
|
28
|
+
'react-query',
|
|
27
29
|
'react-redux',
|
|
28
30
|
'react-router',
|
|
29
31
|
'react-router-dom',
|
|
@@ -32,20 +34,29 @@ const alias = [
|
|
|
32
34
|
'redux',
|
|
33
35
|
'reselect',
|
|
34
36
|
'styled-components',
|
|
37
|
+
'whatwg-fetch',
|
|
35
38
|
'yup',
|
|
36
39
|
];
|
|
37
40
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
+
const alias = [
|
|
42
|
+
'react-select/animated',
|
|
43
|
+
'react-select/async',
|
|
44
|
+
'react-select/async-creatable',
|
|
45
|
+
'react-select/base',
|
|
46
|
+
'react-select/creatable',
|
|
47
|
+
];
|
|
48
|
+
|
|
49
|
+
// See https://webpack.js.org/configuration/resolve/
|
|
50
|
+
module.exports = {
|
|
51
|
+
...alias.reduce((acc, name) => {
|
|
52
|
+
acc[name] = require.resolve(name);
|
|
41
53
|
return acc;
|
|
42
|
-
},
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
);
|
|
54
|
+
}, {}),
|
|
55
|
+
|
|
56
|
+
...aliasExactMatch.reduce((acc, name) => {
|
|
57
|
+
acc[`${name}$`] = require.resolve(name);
|
|
58
|
+
return acc;
|
|
59
|
+
}, {}),
|
|
60
|
+
|
|
61
|
+
ee_else_ce: path.resolve(__dirname),
|
|
62
|
+
};
|