@strapi/strapi 4.2.0-beta.2 → 4.2.0
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/bin/strapi.js +1 -2
- package/lib/Strapi.js +15 -37
- package/lib/commands/admin-create.js +1 -8
- package/lib/commands/admin-reset.js +1 -8
- package/lib/commands/build.js +44 -18
- package/lib/commands/configurationDump.js +1 -8
- package/lib/commands/configurationRestore.js +1 -9
- package/lib/commands/console.js +2 -10
- package/lib/commands/develop.js +74 -113
- package/lib/commands/routes/list.js +1 -8
- package/lib/commands/start.js +2 -8
- package/lib/commands/watchAdmin.js +10 -10
- package/lib/core/app-configuration/index.js +3 -4
- package/lib/core/app-configuration/load-config-file.js +1 -3
- package/lib/core/bootstrap.js +2 -2
- package/lib/core/loaders/apis.js +16 -13
- package/lib/core/loaders/components.js +4 -5
- package/lib/core/loaders/index.js +1 -0
- package/lib/core/loaders/middlewares.js +3 -5
- package/lib/core/loaders/plugins/get-enabled-plugins.js +1 -2
- package/lib/core/loaders/plugins/get-user-plugins-config.js +2 -2
- package/lib/core/loaders/plugins/index.js +1 -1
- package/lib/core/loaders/policies.js +2 -4
- package/lib/core/loaders/sanitizers.js +5 -0
- package/lib/core/loaders/src-index.js +4 -6
- package/lib/core/registries/sanitizers.js +26 -0
- package/lib/factories.d.ts +3 -3
- package/lib/index.d.ts +1 -1
- package/lib/load/load-files.js +1 -3
- package/lib/middlewares/body.js +38 -10
- package/lib/middlewares/favicon.js +1 -1
- package/lib/middlewares/public/index.js +1 -2
- package/lib/services/entity-validator/validators.js +3 -1
- package/lib/services/fs.js +1 -1
- package/lib/services/metrics/index.js +1 -5
- package/lib/services/metrics/sender.js +0 -7
- package/lib/services/server/middleware.js +1 -1
- package/lib/utils/get-dirs.js +10 -24
- package/lib/utils/index.js +0 -2
- package/lib/utils/update-notifier/index.js +3 -3
- package/package.json +15 -16
- package/lib/commands/builders/admin.js +0 -59
- package/lib/commands/builders/index.js +0 -9
- package/lib/commands/builders/typescript.js +0 -32
- package/lib/utils/import-default.js +0 -9
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const { green } = require('chalk');
|
|
4
|
-
|
|
5
|
-
const strapiAdmin = require('@strapi/admin');
|
|
6
|
-
const { getConfigUrls } = require('@strapi/utils');
|
|
7
|
-
|
|
8
|
-
const ee = require('../../utils/ee');
|
|
9
|
-
const addSlash = require('../../utils/addSlash');
|
|
10
|
-
const strapi = require('../../index');
|
|
11
|
-
const getEnabledPlugins = require('../../core/loaders/plugins/get-enabled-plugins');
|
|
12
|
-
|
|
13
|
-
module.exports = async ({ buildDestDir, forceBuild = true, optimization, srcDir }) => {
|
|
14
|
-
const strapiInstance = strapi({
|
|
15
|
-
// Directories
|
|
16
|
-
appDir: srcDir,
|
|
17
|
-
distDir: buildDestDir,
|
|
18
|
-
// Options
|
|
19
|
-
autoReload: true,
|
|
20
|
-
serveAdminPanel: false,
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
const plugins = await getEnabledPlugins(strapiInstance);
|
|
24
|
-
|
|
25
|
-
const env = strapiInstance.config.get('environment');
|
|
26
|
-
const { serverUrl, adminPath } = getConfigUrls(strapiInstance.config, true);
|
|
27
|
-
|
|
28
|
-
console.log(`Building your admin UI with ${green(env)} configuration...`);
|
|
29
|
-
|
|
30
|
-
// Always remove the .cache and build folders
|
|
31
|
-
// FIXME the BE should remove the build dir and the admin should only
|
|
32
|
-
// be responsible of removing the .cache dir.
|
|
33
|
-
await strapiAdmin.clean({ appDir: srcDir, buildDestDir });
|
|
34
|
-
|
|
35
|
-
// @convly shouldn't we use the app dir here?
|
|
36
|
-
ee({ dir: buildDestDir });
|
|
37
|
-
|
|
38
|
-
return strapiAdmin
|
|
39
|
-
.build({
|
|
40
|
-
appDir: srcDir,
|
|
41
|
-
buildDestDir,
|
|
42
|
-
// front end build env is always production for now
|
|
43
|
-
env: 'production',
|
|
44
|
-
forceBuild,
|
|
45
|
-
plugins,
|
|
46
|
-
optimize: optimization,
|
|
47
|
-
options: {
|
|
48
|
-
backend: serverUrl,
|
|
49
|
-
adminPath: addSlash(adminPath),
|
|
50
|
-
},
|
|
51
|
-
})
|
|
52
|
-
.then(() => {
|
|
53
|
-
console.log('Admin UI built successfully');
|
|
54
|
-
})
|
|
55
|
-
.catch(err => {
|
|
56
|
-
console.error(err);
|
|
57
|
-
process.exit(1);
|
|
58
|
-
});
|
|
59
|
-
};
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const path = require('path');
|
|
4
|
-
const fs = require('fs-extra');
|
|
5
|
-
const tsUtils = require('@strapi/typescript-utils');
|
|
6
|
-
|
|
7
|
-
const cleanupDistDirectory = async distDir => {
|
|
8
|
-
if (!(await fs.pathExists(distDir))) {
|
|
9
|
-
return;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
const dirContent = await fs.readdir(distDir);
|
|
13
|
-
const validFilenames = dirContent
|
|
14
|
-
// Ignore the admin build folder
|
|
15
|
-
.filter(filename => filename !== 'build');
|
|
16
|
-
|
|
17
|
-
for (const filename of validFilenames) {
|
|
18
|
-
await fs.remove(path.resolve(distDir, filename));
|
|
19
|
-
}
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
module.exports = async ({ srcDir, distDir, watch = false }) => {
|
|
23
|
-
const isTSProject = await tsUtils.isUsingTypeScript(srcDir);
|
|
24
|
-
|
|
25
|
-
if (!isTSProject) {
|
|
26
|
-
throw new Error(`tsconfig file not found in ${srcDir}`);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
await cleanupDistDirectory(distDir);
|
|
30
|
-
|
|
31
|
-
return tsUtils.compile(srcDir, { watch });
|
|
32
|
-
};
|