@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.
Files changed (45) hide show
  1. package/bin/strapi.js +1 -2
  2. package/lib/Strapi.js +15 -37
  3. package/lib/commands/admin-create.js +1 -8
  4. package/lib/commands/admin-reset.js +1 -8
  5. package/lib/commands/build.js +44 -18
  6. package/lib/commands/configurationDump.js +1 -8
  7. package/lib/commands/configurationRestore.js +1 -9
  8. package/lib/commands/console.js +2 -10
  9. package/lib/commands/develop.js +74 -113
  10. package/lib/commands/routes/list.js +1 -8
  11. package/lib/commands/start.js +2 -8
  12. package/lib/commands/watchAdmin.js +10 -10
  13. package/lib/core/app-configuration/index.js +3 -4
  14. package/lib/core/app-configuration/load-config-file.js +1 -3
  15. package/lib/core/bootstrap.js +2 -2
  16. package/lib/core/loaders/apis.js +16 -13
  17. package/lib/core/loaders/components.js +4 -5
  18. package/lib/core/loaders/index.js +1 -0
  19. package/lib/core/loaders/middlewares.js +3 -5
  20. package/lib/core/loaders/plugins/get-enabled-plugins.js +1 -2
  21. package/lib/core/loaders/plugins/get-user-plugins-config.js +2 -2
  22. package/lib/core/loaders/plugins/index.js +1 -1
  23. package/lib/core/loaders/policies.js +2 -4
  24. package/lib/core/loaders/sanitizers.js +5 -0
  25. package/lib/core/loaders/src-index.js +4 -6
  26. package/lib/core/registries/sanitizers.js +26 -0
  27. package/lib/factories.d.ts +3 -3
  28. package/lib/index.d.ts +1 -1
  29. package/lib/load/load-files.js +1 -3
  30. package/lib/middlewares/body.js +38 -10
  31. package/lib/middlewares/favicon.js +1 -1
  32. package/lib/middlewares/public/index.js +1 -2
  33. package/lib/services/entity-validator/validators.js +3 -1
  34. package/lib/services/fs.js +1 -1
  35. package/lib/services/metrics/index.js +1 -5
  36. package/lib/services/metrics/sender.js +0 -7
  37. package/lib/services/server/middleware.js +1 -1
  38. package/lib/utils/get-dirs.js +10 -24
  39. package/lib/utils/index.js +0 -2
  40. package/lib/utils/update-notifier/index.js +3 -3
  41. package/package.json +15 -16
  42. package/lib/commands/builders/admin.js +0 -59
  43. package/lib/commands/builders/index.js +0 -9
  44. package/lib/commands/builders/typescript.js +0 -32
  45. 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,9 +0,0 @@
1
- 'use strict';
2
-
3
- const buildAdmin = require('./admin');
4
- const buildTypeScript = require('./typescript');
5
-
6
- module.exports = {
7
- buildAdmin,
8
- buildTypeScript,
9
- };
@@ -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
- };
@@ -1,9 +0,0 @@
1
- 'use strict';
2
-
3
- const __importDefault =
4
- (this && this.__importDefault) ||
5
- function(mod) {
6
- return mod && mod.__esModule ? mod : { default: mod };
7
- };
8
-
9
- module.exports = __importDefault;