@strapi/strapi 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.
Files changed (57) hide show
  1. package/bin/strapi.js +1 -0
  2. package/lib/Strapi.js +37 -8
  3. package/lib/commands/admin-create.js +2 -1
  4. package/lib/commands/admin-reset.js +2 -1
  5. package/lib/commands/build.js +8 -46
  6. package/lib/commands/builders/admin.js +56 -0
  7. package/lib/commands/builders/index.js +9 -0
  8. package/lib/commands/builders/typescript.js +32 -0
  9. package/lib/commands/configurationDump.js +2 -1
  10. package/lib/commands/configurationRestore.js +3 -1
  11. package/lib/commands/console.js +4 -3
  12. package/lib/commands/content-types/list.js +2 -1
  13. package/lib/commands/controllers/list.js +2 -1
  14. package/lib/commands/develop.js +111 -74
  15. package/lib/commands/hooks/list.js +2 -1
  16. package/lib/commands/middlewares/list.js +2 -1
  17. package/lib/commands/policies/list.js +2 -1
  18. package/lib/commands/routes/list.js +2 -1
  19. package/lib/commands/services/list.js +2 -1
  20. package/lib/commands/start.js +18 -2
  21. package/lib/commands/watchAdmin.js +5 -10
  22. package/lib/compile.js +20 -0
  23. package/lib/core/app-configuration/index.js +4 -3
  24. package/lib/core/app-configuration/load-config-file.js +3 -1
  25. package/lib/core/bootstrap.js +2 -2
  26. package/lib/core/loaders/apis.js +6 -5
  27. package/lib/core/loaders/components.js +5 -4
  28. package/lib/core/loaders/middlewares.js +4 -2
  29. package/lib/core/loaders/plugins/get-enabled-plugins.js +2 -1
  30. package/lib/core/loaders/plugins/get-user-plugins-config.js +2 -2
  31. package/lib/core/loaders/plugins/index.js +1 -1
  32. package/lib/core/loaders/policies.js +4 -2
  33. package/lib/core/loaders/src-index.js +6 -4
  34. package/lib/core/registries/policies.d.ts +1 -1
  35. package/lib/core-api/controller/index.d.ts +16 -14
  36. package/lib/core-api/service/index.d.ts +10 -9
  37. package/lib/factories.d.ts +22 -18
  38. package/lib/index.d.ts +7 -6
  39. package/lib/index.js +1 -0
  40. package/lib/load/load-files.js +3 -1
  41. package/lib/middlewares/favicon.js +1 -1
  42. package/lib/middlewares/public/index.js +1 -1
  43. package/lib/services/entity-service/index.d.ts +7 -1
  44. package/lib/services/entity-service/index.js +11 -1
  45. package/lib/services/fs.js +1 -1
  46. package/lib/services/metrics/index.js +5 -1
  47. package/lib/services/metrics/sender.js +7 -0
  48. package/lib/services/server/middleware.js +1 -1
  49. package/lib/services/utils/upload-files.js +1 -1
  50. package/lib/types/strapi.d.ts +370 -0
  51. package/lib/types/utils.d.ts +1 -0
  52. package/lib/utils/get-dirs.js +24 -10
  53. package/lib/utils/import-default.js +10 -0
  54. package/lib/utils/index.js +2 -0
  55. package/lib/utils/lifecycles.js +15 -0
  56. package/lib/utils/update-notifier/index.js +1 -1
  57. package/package.json +15 -13
package/bin/strapi.js CHANGED
@@ -95,6 +95,7 @@ program
95
95
  .option('--dbssl <dbssl>', 'Database SSL')
96
96
  .option('--dbfile <dbfile>', 'Database file path for sqlite')
97
97
  .option('--dbforce', 'Allow overwriting existing database content')
98
+ .option('-ts, --typescript', 'Create a typescript project')
98
99
  .description('Create a new application')
99
100
  .action(require('../lib/commands/new'));
100
101
 
package/lib/Strapi.js CHANGED
@@ -1,5 +1,6 @@
1
1
  'use strict';
2
2
 
3
+ const path = require('path');
3
4
  const _ = require('lodash');
4
5
  const { isFunction } = require('lodash/fp');
5
6
  const { createLogger } = require('@strapi/logger');
@@ -23,6 +24,7 @@ const createTelemetry = require('./services/metrics');
23
24
  const createAuth = require('./services/auth');
24
25
  const createUpdateNotifier = require('./utils/update-notifier');
25
26
  const createStartupLogger = require('./utils/startup-logger');
27
+ const { LIFECYCLES } = require('./utils/lifecycles');
26
28
  const ee = require('./utils/ee');
27
29
  const contentTypesRegistry = require('./core/registries/content-types');
28
30
  const servicesRegistry = require('./core/registries/services');
@@ -42,18 +44,40 @@ const sanitizersRegistry = require('./core/registries/sanitizers');
42
44
  // TODO: move somewhere else
43
45
  const draftAndPublishSync = require('./migrations/draft-publish');
44
46
 
45
- const LIFECYCLES = {
46
- REGISTER: 'register',
47
- BOOTSTRAP: 'bootstrap',
48
- DESTROY: 'destroy',
47
+ /**
48
+ * Resolve the working directories based on the instance options.
49
+ *
50
+ * Behavior:
51
+ * - `appDir` is the directory where Strapi will write every file (schemas, generated APIs, controllers or services)
52
+ * - `distDir` is the directory where Strapi will read configurations, schemas and any compiled code
53
+ *
54
+ * Default values:
55
+ * - If `appDir` is `undefined`, it'll be set to `process.cwd()`
56
+ * - If `distDir` is `undefined`, it'll be set to `appDir`
57
+ */
58
+ const resolveWorkingDirectories = opts => {
59
+ const cwd = process.cwd();
60
+
61
+ const appDir = opts.appDir ? path.resolve(cwd, opts.appDir) : cwd;
62
+ const distDir = opts.distDir ? path.resolve(cwd, opts.distDir) : appDir;
63
+
64
+ return { app: appDir, dist: distDir };
49
65
  };
50
66
 
67
+ /** @implements {import('@strapi/strapi').Strapi} */
51
68
  class Strapi {
52
69
  constructor(opts = {}) {
53
70
  destroyOnSignal(this);
54
- const rootDir = opts.dir || process.cwd();
55
- const appConfig = loadConfiguration(rootDir, opts);
71
+
72
+ const rootDirs = resolveWorkingDirectories(opts);
73
+
74
+ // Load the app configuration from the dist directory
75
+ const appConfig = loadConfiguration({ appDir: rootDirs.app, distDir: rootDirs.dist }, opts);
76
+
77
+ // Instanciate the Strapi container
56
78
  this.container = createContainer(this);
79
+
80
+ // Register every Strapi registry in the container
57
81
  this.container.register('config', createConfigProvider(appConfig));
58
82
  this.container.register('content-types', contentTypesRegistry(this));
59
83
  this.container.register('services', servicesRegistry(this));
@@ -67,12 +91,17 @@ class Strapi {
67
91
  this.container.register('auth', createAuth(this));
68
92
  this.container.register('sanitizers', sanitizersRegistry(this));
69
93
 
70
- this.dirs = utils.getDirs(rootDir, { strapi: this });
94
+ // Create a mapping of every useful directory (for the app, dist and static directories)
95
+ this.dirs = utils.getDirs(rootDirs, { strapi: this });
71
96
 
97
+ // Strapi state management variables
72
98
  this.isLoaded = false;
73
99
  this.reload = this.reload();
100
+
101
+ // Instanciate the Koa app & the HTTP server
74
102
  this.server = createServer(this);
75
103
 
104
+ // Strapi utils instanciation
76
105
  this.fs = createStrapiFs(this);
77
106
  this.eventHub = createEventHub();
78
107
  this.startupLogger = createStartupLogger(this);
@@ -88,7 +117,7 @@ class Strapi {
88
117
  }
89
118
 
90
119
  get EE() {
91
- return ee({ dir: this.dirs.root, logger: this.log });
120
+ return ee({ dir: this.dirs.dist.root, logger: this.log });
92
121
  }
93
122
 
94
123
  get services() {
@@ -90,7 +90,8 @@ module.exports = async function(cmdOptions = {}) {
90
90
  };
91
91
 
92
92
  async function createAdmin({ email, password, firstname, lastname }) {
93
- const app = await strapi().load();
93
+ const appContext = await strapi.compile();
94
+ const app = await strapi(appContext).load();
94
95
 
95
96
  const user = await app.admin.services.user.exists({ email });
96
97
 
@@ -42,7 +42,8 @@ module.exports = async function(cmdOptions = {}) {
42
42
  };
43
43
 
44
44
  async function changePassword({ email, password }) {
45
- const app = await strapi().load();
45
+ const appContext = await strapi.compile();
46
+ const app = await strapi(appContext).load();
46
47
 
47
48
  await app.admin.services.user.resetPasswordByEmail(email, password);
48
49
 
@@ -1,56 +1,18 @@
1
1
  'use strict';
2
- const { green } = require('chalk');
3
2
 
4
- const strapiAdmin = require('@strapi/admin');
5
- const { getConfigUrls } = require('@strapi/utils');
6
-
7
- const ee = require('../utils/ee');
8
- const addSlash = require('../utils/addSlash');
9
- const strapi = require('../index');
10
- const getEnabledPlugins = require('../core/loaders/plugins/get-enabled-plugins');
3
+ const strapi = require('../');
4
+ const { buildAdmin } = require('./builders');
11
5
 
12
6
  /**
13
7
  * `$ strapi build`
14
8
  */
15
9
  module.exports = async ({ optimization, forceBuild = true }) => {
16
- const dir = process.cwd();
10
+ const { appDir, distDir } = await strapi.compile();
17
11
 
18
- const strapiInstance = strapi({
19
- dir,
20
- autoReload: true,
21
- serveAdminPanel: false,
12
+ await buildAdmin({
13
+ forceBuild,
14
+ optimization,
15
+ buildDestDir: distDir,
16
+ srcDir: appDir,
22
17
  });
23
-
24
- const plugins = await getEnabledPlugins(strapiInstance);
25
-
26
- const env = strapiInstance.config.get('environment');
27
- const { serverUrl, adminPath } = getConfigUrls(strapiInstance.config, true);
28
-
29
- console.log(`Building your admin UI with ${green(env)} configuration ...`);
30
-
31
- // Always remove the .cache and build folders
32
- await strapiAdmin.clean({ dir });
33
-
34
- ee({ dir });
35
-
36
- return strapiAdmin
37
- .build({
38
- forceBuild,
39
- dir,
40
- plugins,
41
- // front end build env is always production for now
42
- env: 'production',
43
- optimize: optimization,
44
- options: {
45
- backend: serverUrl,
46
- adminPath: addSlash(adminPath),
47
- },
48
- })
49
- .then(() => {
50
- console.log('Admin UI built successfully');
51
- })
52
- .catch(err => {
53
- console.error(err);
54
- process.exit(1);
55
- });
56
18
  };
@@ -0,0 +1,56 @@
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
+ await strapiAdmin.clean({ appDir: srcDir, buildDestDir });
32
+
33
+ ee({ dir: srcDir });
34
+
35
+ return strapiAdmin
36
+ .build({
37
+ appDir: srcDir,
38
+ buildDestDir,
39
+ // front end build env is always production for now
40
+ env: 'production',
41
+ forceBuild,
42
+ plugins,
43
+ optimize: optimization,
44
+ options: {
45
+ backend: serverUrl,
46
+ adminPath: addSlash(adminPath),
47
+ },
48
+ })
49
+ .then(() => {
50
+ console.log('Admin UI built successfully');
51
+ })
52
+ .catch(err => {
53
+ console.error(err);
54
+ process.exit(1);
55
+ });
56
+ };
@@ -0,0 +1,9 @@
1
+ 'use strict';
2
+
3
+ const buildAdmin = require('./admin');
4
+ const buildTypeScript = require('./typescript');
5
+
6
+ module.exports = {
7
+ buildAdmin,
8
+ buildTypeScript,
9
+ };
@@ -0,0 +1,32 @@
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
+ };
@@ -12,7 +12,8 @@ const CHUNK_SIZE = 100;
12
12
  module.exports = async function({ file: filePath, pretty }) {
13
13
  const output = filePath ? fs.createWriteStream(filePath) : process.stdout;
14
14
 
15
- const app = await strapi().load();
15
+ const appContext = await strapi.compile();
16
+ const app = await strapi(appContext).load();
16
17
 
17
18
  const count = await app.query('strapi::core-store').count();
18
19
 
@@ -2,6 +2,7 @@
2
2
 
3
3
  const fs = require('fs');
4
4
  const _ = require('lodash');
5
+
5
6
  const strapi = require('../index');
6
7
 
7
8
  /**
@@ -12,7 +13,8 @@ const strapi = require('../index');
12
13
  module.exports = async function({ file: filePath, strategy = 'replace' }) {
13
14
  const input = filePath ? fs.readFileSync(filePath) : await readStdin(process.stdin);
14
15
 
15
- const app = await strapi().load();
16
+ const appContext = await strapi.compile();
17
+ const app = await strapi(appContext).load();
16
18
 
17
19
  let dataToImport;
18
20
  try {
@@ -1,14 +1,15 @@
1
1
  'use strict';
2
2
 
3
3
  const REPL = require('repl');
4
+
4
5
  const strapi = require('../index');
5
6
 
6
7
  /**
7
8
  * `$ strapi console`
8
9
  */
9
- module.exports = () => {
10
- // Now load up the Strapi framework for real.
11
- const app = strapi();
10
+ module.exports = async () => {
11
+ const appContext = await strapi.compile();
12
+ const app = await strapi(appContext).load();
12
13
 
13
14
  app.start().then(() => {
14
15
  const repl = REPL.start(app.config.info.name + ' > ' || 'strapi > '); // eslint-disable-line prefer-template
@@ -6,7 +6,8 @@ const chalk = require('chalk');
6
6
  const strapi = require('../../index');
7
7
 
8
8
  module.exports = async function() {
9
- const app = await strapi().register();
9
+ const appContext = await strapi.compile();
10
+ const app = await strapi(appContext).register();
10
11
 
11
12
  const list = app.container.get('content-types').keys();
12
13
 
@@ -6,7 +6,8 @@ const chalk = require('chalk');
6
6
  const strapi = require('../../index');
7
7
 
8
8
  module.exports = async function() {
9
- const app = await strapi().register();
9
+ const appContext = await strapi.compile();
10
+ const app = await strapi(appContext).register();
10
11
 
11
12
  const list = app.container.get('controllers').keys();
12
13
 
@@ -6,115 +6,150 @@ const fs = require('fs-extra');
6
6
  const chokidar = require('chokidar');
7
7
  const execa = require('execa');
8
8
  const { getOr } = require('lodash/fp');
9
-
10
- const { createLogger } = require('@strapi/logger');
11
9
  const { joinBy } = require('@strapi/utils');
10
+ const tsUtils = require('@strapi/typescript-utils');
11
+
12
12
  const loadConfiguration = require('../core/app-configuration');
13
13
  const strapi = require('../index');
14
- const buildAdmin = require('./build');
14
+ const { buildTypeScript, buildAdmin } = require('./builders');
15
15
 
16
16
  /**
17
17
  * `$ strapi develop`
18
18
  *
19
19
  */
20
+
20
21
  module.exports = async function({ build, watchAdmin, polling, browser }) {
21
- const dir = process.cwd();
22
- const config = loadConfiguration(dir);
23
- const logger = createLogger(config.logger, {});
22
+ const appDir = process.cwd();
23
+
24
+ const isTSProject = await tsUtils.isUsingTypeScript(appDir);
25
+ const outDir = await tsUtils.resolveOutDir(appDir);
26
+ const distDir = isTSProject ? outDir : appDir;
24
27
 
25
28
  try {
26
29
  if (cluster.isMaster || cluster.isPrimary) {
27
- const serveAdminPanel = getOr(true, 'admin.serveAdminPanel')(config);
28
-
29
- const buildExists = fs.existsSync(path.join(dir, 'build'));
30
- // Don't run the build process if the admin is in watch mode
31
- if (build && !watchAdmin && serveAdminPanel && !buildExists) {
32
- try {
33
- await buildAdmin({ optimization: false, forceBuild: false });
34
- } catch (err) {
35
- process.exit(1);
36
- }
37
- }
38
-
39
- if (watchAdmin) {
40
- try {
41
- execa('npm', ['run', '-s', 'strapi', 'watch-admin', '--', '--browser', browser], {
42
- stdio: 'inherit',
43
- });
44
- } catch (err) {
45
- process.exit(1);
46
- }
47
- }
48
-
49
- cluster.on('message', (worker, message) => {
50
- switch (message) {
51
- case 'reload':
52
- logger.info('The server is restarting\n');
53
- worker.send('kill');
54
- break;
55
- case 'killed':
56
- cluster.fork();
57
- break;
58
- case 'stop':
59
- process.exit(1);
60
- default:
61
- return;
62
- }
30
+ return primaryProcess({
31
+ distDir,
32
+ appDir,
33
+ build,
34
+ browser,
35
+ isTSProject,
36
+ watchAdmin,
63
37
  });
64
-
65
- cluster.fork();
66
38
  }
67
39
 
68
40
  if (cluster.isWorker) {
69
- const strapiInstance = strapi({
70
- dir,
71
- autoReload: true,
72
- serveAdminPanel: watchAdmin ? false : true,
41
+ return workerProcess({ appDir, distDir, watchAdmin, polling, isTSProject });
42
+ }
43
+ } catch (e) {
44
+ console.error(e);
45
+ process.exit(1);
46
+ }
47
+ };
48
+
49
+ const primaryProcess = async ({ distDir, appDir, build, isTSProject, watchAdmin, browser }) => {
50
+ if (isTSProject) {
51
+ await buildTypeScript({ srcDir: appDir, distDir, watch: false });
52
+ }
53
+
54
+ const config = loadConfiguration({ appDir, distDir });
55
+ const serveAdminPanel = getOr(true, 'admin.serveAdminPanel')(config);
56
+
57
+ const buildExists = fs.existsSync(path.join(distDir, 'build'));
58
+
59
+ // Don't run the build process if the admin is in watch mode
60
+ if (build && !watchAdmin && serveAdminPanel && !buildExists) {
61
+ try {
62
+ await buildAdmin({
63
+ buildDestDir: distDir,
64
+ forceBuild: false,
65
+ optimization: false,
66
+ srcDir: appDir,
73
67
  });
68
+ } catch (err) {
69
+ process.exit(1);
70
+ }
71
+ }
74
72
 
75
- const adminWatchIgnoreFiles = getOr([], 'admin.watchIgnoreFiles')(config);
76
- watchFileChanges({
77
- dir,
78
- strapiInstance,
79
- watchIgnoreFiles: adminWatchIgnoreFiles,
80
- polling,
73
+ if (watchAdmin) {
74
+ try {
75
+ execa('npm', ['run', '-s', 'strapi', 'watch-admin', '--', '--browser', browser], {
76
+ stdio: 'inherit',
81
77
  });
78
+ } catch (err) {
79
+ process.exit(1);
80
+ }
81
+ }
82
82
 
83
- process.on('message', async message => {
84
- switch (message) {
85
- case 'kill':
86
- await strapiInstance.destroy();
87
- process.send('killed');
88
- process.exit();
89
- default:
90
- // Do nothing.
83
+ cluster.on('message', async (worker, message) => {
84
+ switch (message) {
85
+ case 'reload':
86
+ if (isTSProject) {
87
+ await buildTypeScript({ srcDir: appDir, distDir, watch: false });
91
88
  }
92
- });
93
89
 
94
- return strapiInstance.start();
90
+ console.info('The server is restarting\n');
91
+
92
+ worker.send('kill');
93
+ break;
94
+ case 'killed':
95
+ cluster.fork();
96
+ break;
97
+ case 'stop':
98
+ process.exit(1);
99
+ default:
100
+ return;
95
101
  }
96
- } catch (e) {
97
- logger.error(e);
98
- process.exit(1);
99
- }
102
+ });
103
+
104
+ cluster.fork();
105
+ };
106
+
107
+ const workerProcess = ({ appDir, distDir, watchAdmin, polling, isTSProject }) => {
108
+ const strapiInstance = strapi({
109
+ distDir,
110
+ autoReload: true,
111
+ serveAdminPanel: watchAdmin ? false : true,
112
+ });
113
+
114
+ const adminWatchIgnoreFiles = strapiInstance.config.get('admin.watchIgnoreFiles', []);
115
+ watchFileChanges({
116
+ appDir,
117
+ strapiInstance,
118
+ watchIgnoreFiles: adminWatchIgnoreFiles,
119
+ polling,
120
+ isTSProject,
121
+ });
122
+
123
+ process.on('message', async message => {
124
+ switch (message) {
125
+ case 'kill':
126
+ await strapiInstance.destroy();
127
+ process.send('killed');
128
+ process.exit();
129
+ default:
130
+ // Do nothing.
131
+ }
132
+ });
133
+
134
+ return strapiInstance.start();
100
135
  };
101
136
 
102
137
  /**
103
138
  * Init file watching to auto restart strapi app
104
139
  * @param {Object} options - Options object
105
- * @param {string} options.dir - This is the path where the app is located, the watcher will watch the files under this folder
140
+ * @param {string} options.appDir - This is the path where the app is located, the watcher will watch the files under this folder
106
141
  * @param {Strapi} options.strapi - Strapi instance
107
142
  * @param {array} options.watchIgnoreFiles - Array of custom file paths that should not be watched
108
143
  */
109
- function watchFileChanges({ dir, strapiInstance, watchIgnoreFiles, polling }) {
110
- const restart = () => {
144
+ function watchFileChanges({ appDir, strapiInstance, watchIgnoreFiles, polling }) {
145
+ const restart = async () => {
111
146
  if (strapiInstance.reload.isWatching && !strapiInstance.reload.isReloading) {
112
147
  strapiInstance.reload.isReloading = true;
113
148
  strapiInstance.reload();
114
149
  }
115
150
  };
116
151
 
117
- const watcher = chokidar.watch(dir, {
152
+ const watcher = chokidar.watch(appDir, {
118
153
  ignoreInitial: true,
119
154
  usePolling: polling,
120
155
  ignored: [
@@ -122,6 +157,7 @@ function watchFileChanges({ dir, strapiInstance, watchIgnoreFiles, polling }) {
122
157
  /tmp/,
123
158
  '**/src/admin/**',
124
159
  '**/src/plugins/**/admin/**',
160
+ '**/dist/src/plugins/test/admin/**',
125
161
  '**/documentation',
126
162
  '**/documentation/**',
127
163
  '**/node_modules',
@@ -132,10 +168,11 @@ function watchFileChanges({ dir, strapiInstance, watchIgnoreFiles, polling }) {
132
168
  '**/index.html',
133
169
  '**/public',
134
170
  '**/public/**',
135
- strapiInstance.dirs.public,
136
- joinBy('/', strapiInstance.dirs.public, '**'),
171
+ strapiInstance.dirs.static.public,
172
+ joinBy('/', strapiInstance.dirs.static.public, '**'),
137
173
  '**/*.db*',
138
174
  '**/exports/**',
175
+ '**/dist/**',
139
176
  ...watchIgnoreFiles,
140
177
  ],
141
178
  });
@@ -6,7 +6,8 @@ const chalk = require('chalk');
6
6
  const strapi = require('../../index');
7
7
 
8
8
  module.exports = async function() {
9
- const app = await strapi().register();
9
+ const appContext = await strapi.compile();
10
+ const app = await strapi(appContext).register();
10
11
 
11
12
  const list = app.container.get('hooks').keys();
12
13
 
@@ -6,7 +6,8 @@ const chalk = require('chalk');
6
6
  const strapi = require('../../index');
7
7
 
8
8
  module.exports = async function() {
9
- const app = await strapi().register();
9
+ const appContext = await strapi.compile();
10
+ const app = await strapi(appContext).register();
10
11
 
11
12
  const list = app.container.get('middlewares').keys();
12
13
 
@@ -6,7 +6,8 @@ const chalk = require('chalk');
6
6
  const strapi = require('../../index');
7
7
 
8
8
  module.exports = async function() {
9
- const app = await strapi().register();
9
+ const appContext = await strapi.compile();
10
+ const app = await strapi(appContext).register();
10
11
 
11
12
  const list = app.container.get('policies').keys();
12
13
 
@@ -7,7 +7,8 @@ const { toUpper } = require('lodash/fp');
7
7
  const strapi = require('../../index');
8
8
 
9
9
  module.exports = async function() {
10
- const app = await strapi().load();
10
+ const appContext = await strapi.compile();
11
+ const app = await strapi(appContext).load();
11
12
 
12
13
  const list = app.server.listRoutes();
13
14
 
@@ -6,7 +6,8 @@ const chalk = require('chalk');
6
6
  const strapi = require('../../index');
7
7
 
8
8
  module.exports = async function() {
9
- const app = await strapi().register();
9
+ const appContext = await strapi.compile();
10
+ const app = await strapi(appContext).register();
10
11
 
11
12
  const list = app.container.get('services').keys();
12
13