@strapi/strapi 4.3.3 → 4.3.6

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 (112) hide show
  1. package/README.md +1 -1
  2. package/bin/strapi.js +29 -26
  3. package/lib/Strapi.js +9 -9
  4. package/lib/commands/admin-create.js +2 -5
  5. package/lib/commands/admin-reset.js +1 -1
  6. package/lib/commands/build.js +1 -1
  7. package/lib/commands/builders/admin.js +1 -1
  8. package/lib/commands/builders/typescript.js +2 -2
  9. package/lib/commands/configurationDump.js +3 -3
  10. package/lib/commands/configurationRestore.js +5 -4
  11. package/lib/commands/console.js +1 -1
  12. package/lib/commands/content-types/list.js +2 -2
  13. package/lib/commands/controllers/list.js +2 -2
  14. package/lib/commands/develop.js +16 -10
  15. package/lib/commands/hooks/list.js +2 -2
  16. package/lib/commands/install.js +4 -4
  17. package/lib/commands/middlewares/list.js +2 -2
  18. package/lib/commands/new.js +1 -1
  19. package/lib/commands/opt-in-telemetry.js +12 -13
  20. package/lib/commands/opt-out-telemetry.js +3 -3
  21. package/lib/commands/policies/list.js +2 -2
  22. package/lib/commands/routes/list.js +3 -3
  23. package/lib/commands/services/list.js +2 -2
  24. package/lib/commands/start.js +1 -0
  25. package/lib/commands/ts/generate-types.js +1 -1
  26. package/lib/commands/uninstall.js +4 -4
  27. package/lib/commands/watchAdmin.js +1 -1
  28. package/lib/compile.js +1 -1
  29. package/lib/container.js +1 -1
  30. package/lib/core/app-configuration/config-loader.js +2 -2
  31. package/lib/core/app-configuration/load-config-file.js +3 -3
  32. package/lib/core/bootstrap.js +1 -1
  33. package/lib/core/domain/component/validator.js +3 -9
  34. package/lib/core/domain/content-type/index.js +2 -2
  35. package/lib/core/domain/content-type/validator.js +9 -23
  36. package/lib/core/domain/module/index.js +1 -1
  37. package/lib/core/domain/module/validation.js +3 -4
  38. package/lib/core/loaders/admin.js +1 -1
  39. package/lib/core/loaders/apis.js +22 -30
  40. package/lib/core/loaders/components.js +2 -2
  41. package/lib/core/loaders/middlewares.js +1 -1
  42. package/lib/core/loaders/plugins/get-enabled-plugins.js +7 -7
  43. package/lib/core/loaders/plugins/index.js +7 -8
  44. package/lib/core/loaders/sanitizers.js +1 -1
  45. package/lib/core/loaders/src-index.js +2 -2
  46. package/lib/core/registries/apis.js +1 -1
  47. package/lib/core/registries/config.js +1 -1
  48. package/lib/core/registries/content-types.js +1 -1
  49. package/lib/core/registries/modules.js +1 -1
  50. package/lib/core/registries/plugins.js +1 -1
  51. package/lib/core/registries/services.js +1 -1
  52. package/lib/core/utils.js +3 -6
  53. package/lib/core-api/controller/transform.js +4 -4
  54. package/lib/core-api/service/collection-type.js +1 -1
  55. package/lib/core-api/service/index.d.ts +6 -3
  56. package/lib/core-api/service/pagination.js +5 -5
  57. package/lib/factories.js +5 -5
  58. package/lib/load/filepath-to-prop-path.js +2 -2
  59. package/lib/load/load-files.js +1 -1
  60. package/lib/load/package-path.js +1 -1
  61. package/lib/middlewares/body.js +10 -3
  62. package/lib/middlewares/compression.js +1 -1
  63. package/lib/middlewares/cors.js +3 -10
  64. package/lib/middlewares/ip.js +1 -1
  65. package/lib/middlewares/logger.js +4 -1
  66. package/lib/middlewares/powered-by.js +1 -1
  67. package/lib/middlewares/query.js +8 -2
  68. package/lib/middlewares/response-time.js +1 -1
  69. package/lib/middlewares/responses.js +1 -1
  70. package/lib/middlewares/security.js +22 -16
  71. package/lib/middlewares/session.js +2 -2
  72. package/lib/migrations/draft-publish.js +1 -5
  73. package/lib/services/auth/index.js +1 -3
  74. package/lib/services/core-store.js +4 -4
  75. package/lib/services/entity-service/components.js +12 -18
  76. package/lib/services/entity-service/index.js +65 -51
  77. package/lib/services/entity-validator/index.js +134 -127
  78. package/lib/services/entity-validator/validators.js +18 -15
  79. package/lib/services/errors.js +6 -10
  80. package/lib/services/event-hub.js +1 -0
  81. package/lib/services/fs.js +1 -1
  82. package/lib/services/metrics/index.js +6 -9
  83. package/lib/services/metrics/is-truthy.js +1 -1
  84. package/lib/services/metrics/sender.js +4 -4
  85. package/lib/services/metrics/stringify-deep.js +1 -1
  86. package/lib/services/server/admin-api.js +1 -1
  87. package/lib/services/server/compose-endpoint.js +7 -7
  88. package/lib/services/server/content-api.js +1 -1
  89. package/lib/services/server/http-server.js +9 -9
  90. package/lib/services/server/index.js +4 -4
  91. package/lib/services/server/koa.js +9 -12
  92. package/lib/services/server/middleware.js +1 -1
  93. package/lib/services/server/policy.js +1 -1
  94. package/lib/services/server/register-middlewares.js +6 -8
  95. package/lib/services/server/register-routes.js +11 -11
  96. package/lib/services/server/routing.js +11 -26
  97. package/lib/services/utils/upload-files.js +3 -3
  98. package/lib/services/webhook-runner.js +8 -7
  99. package/lib/services/webhook-store.js +3 -2
  100. package/lib/services/worker-queue.js +1 -0
  101. package/lib/types/core/strapi/index.d.ts +4 -3
  102. package/lib/types/factories.d.ts +3 -3
  103. package/lib/utils/addSlash.js +3 -3
  104. package/lib/utils/ee.js +1 -1
  105. package/lib/utils/import-default.js +1 -1
  106. package/lib/utils/open-browser.js +1 -1
  107. package/lib/utils/run-checks.js +4 -4
  108. package/lib/utils/signals.js +2 -2
  109. package/lib/utils/startup-logger.js +2 -2
  110. package/lib/utils/success.js +1 -1
  111. package/lib/utils/update-notifier/index.js +4 -4
  112. package/package.json +14 -14
package/README.md CHANGED
@@ -13,7 +13,7 @@
13
13
  <img src="https://img.shields.io/npm/v/@strapi/strapi/latest.svg" alt="NPM Version" />
14
14
  </a>
15
15
  <a href="https://github.com/strapi/strapi/actions/workflows/tests.yml">
16
- <img src="https://github.com/strapi/strapi/actions/workflows/tests.yml/badge.svg?branch=master" alt="Tests" />
16
+ <img src="https://github.com/strapi/strapi/actions/workflows/tests.yml/badge.svg?branch=main" alt="Tests" />
17
17
  </a>
18
18
  <a href="https://discord.strapi.io">
19
19
  <img src="https://img.shields.io/discord/811989166782021633?label=Discord" alt="Strapi on Discord" />
package/bin/strapi.js CHANGED
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env node
2
+
2
3
  'use strict';
3
4
 
4
5
  // FIXME
@@ -12,8 +13,8 @@ const program = new Command();
12
13
 
13
14
  const packageJSON = require('../package.json');
14
15
 
15
- const checkCwdIsStrapiApp = name => {
16
- let logErrorAndExit = () => {
16
+ const checkCwdIsStrapiApp = (name) => {
17
+ const logErrorAndExit = () => {
17
18
  console.log(
18
19
  `You need to run ${yellow(
19
20
  `strapi ${name}`
@@ -23,7 +24,7 @@ const checkCwdIsStrapiApp = name => {
23
24
  };
24
25
 
25
26
  try {
26
- const pkgJSON = require(process.cwd() + '/package.json');
27
+ const pkgJSON = require(`${process.cwd()}/package.json`);
27
28
  if (!_.has(pkgJSON, 'dependencies.@strapi/strapi')) {
28
29
  logErrorAndExit(name);
29
30
  }
@@ -32,30 +33,32 @@ const checkCwdIsStrapiApp = name => {
32
33
  }
33
34
  };
34
35
 
35
- const getLocalScript = name => (...args) => {
36
- checkCwdIsStrapiApp(name);
37
-
38
- const cmdPath = resolveCwd.silent(`@strapi/strapi/lib/commands/${name}`);
39
- if (!cmdPath) {
40
- console.log(
41
- `Error loading the local ${yellow(
42
- name
43
- )} command. Strapi might not be installed in your "node_modules". You may need to run "yarn install".`
44
- );
45
- process.exit(1);
46
- }
36
+ const getLocalScript =
37
+ (name) =>
38
+ (...args) => {
39
+ checkCwdIsStrapiApp(name);
40
+
41
+ const cmdPath = resolveCwd.silent(`@strapi/strapi/lib/commands/${name}`);
42
+ if (!cmdPath) {
43
+ console.log(
44
+ `Error loading the local ${yellow(
45
+ name
46
+ )} command. Strapi might not be installed in your "node_modules". You may need to run "yarn install".`
47
+ );
48
+ process.exit(1);
49
+ }
47
50
 
48
- const script = require(cmdPath);
51
+ const script = require(cmdPath);
49
52
 
50
- Promise.resolve()
51
- .then(() => {
52
- return script(...args);
53
- })
54
- .catch(error => {
55
- console.error(error);
56
- process.exit(1);
57
- });
58
- };
53
+ Promise.resolve()
54
+ .then(() => {
55
+ return script(...args);
56
+ })
57
+ .catch((error) => {
58
+ console.error(error);
59
+ process.exit(1);
60
+ });
61
+ };
59
62
 
60
63
  // Initial program setup
61
64
  program.storeOptionsAsProperties(false).allowUnknownOption(true);
@@ -69,7 +72,7 @@ program
69
72
  .command('version')
70
73
  .description('Output the version of Strapi')
71
74
  .action(() => {
72
- process.stdout.write(packageJSON.version + '\n');
75
+ process.stdout.write(`${packageJSON.version}\n`);
73
76
  process.exit(0);
74
77
  });
75
78
 
package/lib/Strapi.js CHANGED
@@ -55,7 +55,7 @@ const draftAndPublishSync = require('./migrations/draft-publish');
55
55
  * - If `appDir` is `undefined`, it'll be set to `process.cwd()`
56
56
  * - If `distDir` is `undefined`, it'll be set to `appDir`
57
57
  */
58
- const resolveWorkingDirectories = opts => {
58
+ const resolveWorkingDirectories = (opts) => {
59
59
  const cwd = process.cwd();
60
60
 
61
61
  const appDir = opts.appDir ? path.resolve(cwd, opts.appDir) : cwd;
@@ -265,7 +265,7 @@ class Strapi {
265
265
  */
266
266
  async listen() {
267
267
  return new Promise((resolve, reject) => {
268
- const onListen = async error => {
268
+ const onListen = async (error) => {
269
269
  if (error) {
270
270
  return reject(error);
271
271
  }
@@ -282,11 +282,11 @@ class Strapi {
282
282
  const listenSocket = this.config.get('server.socket');
283
283
 
284
284
  if (listenSocket) {
285
- return this.server.listen(listenSocket, onListen);
285
+ this.server.listen(listenSocket, onListen);
286
+ } else {
287
+ const { host, port } = this.config.get('server');
288
+ this.server.listen(port, host, onListen);
286
289
  }
287
-
288
- const { host, port } = this.config.get('server');
289
- return this.server.listen(port, host, onListen);
290
290
  });
291
291
  }
292
292
 
@@ -463,7 +463,7 @@ class Strapi {
463
463
 
464
464
  async startWebhooks() {
465
465
  const webhooks = await this.webhookStore.findWebhooks();
466
- webhooks.forEach(webhook => this.webhookRunner.add(webhook));
466
+ webhooks.forEach((webhook) => this.webhookRunner.add(webhook));
467
467
  }
468
468
 
469
469
  reload() {
@@ -471,7 +471,7 @@ class Strapi {
471
471
  shouldReload: 0,
472
472
  };
473
473
 
474
- const reload = function() {
474
+ const reload = function () {
475
475
  if (state.shouldReload > 0) {
476
476
  // Reset the reloading state
477
477
  state.shouldReload -= 1;
@@ -535,7 +535,7 @@ class Strapi {
535
535
  }
536
536
  }
537
537
 
538
- module.exports = options => {
538
+ module.exports = (options) => {
539
539
  const strapi = new Strapi(options);
540
540
  global.strapi = strapi;
541
541
  return strapi;
@@ -5,10 +5,7 @@ const _ = require('lodash');
5
5
  const inquirer = require('inquirer');
6
6
  const strapi = require('../index');
7
7
 
8
- const emailValidator = yup
9
- .string()
10
- .email('Invalid email address')
11
- .lowercase();
8
+ const emailValidator = yup.string().email('Invalid email address').lowercase();
12
9
 
13
10
  const passwordValidator = yup
14
11
  .string()
@@ -60,7 +57,7 @@ const promptQuestions = [
60
57
  * @param {string} cmdOptions.firstname - new admin's first name
61
58
  * @param {string} [cmdOptions.lastname] - new admin's last name
62
59
  */
63
- module.exports = async function(cmdOptions = {}) {
60
+ module.exports = async function (cmdOptions = {}) {
64
61
  let { email, password, firstname, lastname } = cmdOptions;
65
62
 
66
63
  if (
@@ -20,7 +20,7 @@ const promptQuestions = [
20
20
  * @param {string} cmdOptions.email - user's email
21
21
  * @param {string} cmdOptions.password - user's new password
22
22
  */
23
- module.exports = async function(cmdOptions = {}) {
23
+ module.exports = async function (cmdOptions = {}) {
24
24
  const { email, password } = cmdOptions;
25
25
 
26
26
  if (_.isEmpty(email) && _.isEmpty(password) && process.stdin.isTTY) {
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const strapi = require('../');
3
+ const strapi = require('..');
4
4
  const { buildAdmin } = require('./builders');
5
5
 
6
6
  /**
@@ -49,7 +49,7 @@ module.exports = async ({ buildDestDir, forceBuild = true, optimization, srcDir
49
49
  .then(() => {
50
50
  console.log('Admin UI built successfully');
51
51
  })
52
- .catch(err => {
52
+ .catch((err) => {
53
53
  console.error(err);
54
54
  process.exit(1);
55
55
  });
@@ -4,7 +4,7 @@ const path = require('path');
4
4
  const fs = require('fs-extra');
5
5
  const tsUtils = require('@strapi/typescript-utils');
6
6
 
7
- const cleanupDistDirectory = async distDir => {
7
+ const cleanupDistDirectory = async (distDir) => {
8
8
  if (!(await fs.pathExists(distDir))) {
9
9
  return;
10
10
  }
@@ -12,7 +12,7 @@ const cleanupDistDirectory = async distDir => {
12
12
  const dirContent = await fs.readdir(distDir);
13
13
  const validFilenames = dirContent
14
14
  // Ignore the admin build folder
15
- .filter(filename => filename !== 'build');
15
+ .filter((filename) => filename !== 'build');
16
16
 
17
17
  for (const filename of validFilenames) {
18
18
  await fs.remove(path.resolve(distDir, filename));
@@ -9,7 +9,7 @@ const CHUNK_SIZE = 100;
9
9
  * Will dump configurations to a file or stdout
10
10
  * @param {string} file filepath to use as output
11
11
  */
12
- module.exports = async function({ file: filePath, pretty }) {
12
+ module.exports = async function ({ file: filePath, pretty }) {
13
13
  const output = filePath ? fs.createWriteStream(filePath) : process.stdout;
14
14
 
15
15
  const appContext = await strapi.compile();
@@ -27,8 +27,8 @@ module.exports = async function({ file: filePath, pretty }) {
27
27
  .findMany({ limit: CHUNK_SIZE, offset: page * CHUNK_SIZE, orderBy: 'key' });
28
28
 
29
29
  results
30
- .filter(result => result.key.startsWith('plugin_'))
31
- .forEach(result => {
30
+ .filter((result) => result.key.startsWith('plugin_'))
31
+ .forEach((result) => {
32
32
  exportData.push({
33
33
  key: result.key,
34
34
  value: result.value,
@@ -10,7 +10,7 @@ const strapi = require('../index');
10
10
  * @param {string} file filepath to use as input
11
11
  * @param {string} strategy import strategy. one of (replace, merge, keep, default: replace)
12
12
  */
13
- module.exports = async function({ file: filePath, strategy = 'replace' }) {
13
+ module.exports = async ({ file: filePath, strategy = 'replace' }) => {
14
14
  const input = filePath ? fs.readFileSync(filePath) : await readStdin(process.stdin);
15
15
 
16
16
  const appContext = await strapi.compile();
@@ -50,6 +50,7 @@ const readStdin = () => {
50
50
  stdin.setEncoding('utf8');
51
51
  stdin.on('readable', () => {
52
52
  let chunk;
53
+ // eslint-disable-next-line no-cond-assign
53
54
  while ((chunk = stdin.read())) {
54
55
  result += chunk;
55
56
  }
@@ -80,7 +81,7 @@ const createImporter = (db, strategy) => {
80
81
  * Replace importer. Will replace the keys that already exist and create the new ones
81
82
  * @param {Object} db - DatabaseManager instance
82
83
  */
83
- const createReplaceImporter = db => {
84
+ const createReplaceImporter = (db) => {
84
85
  const stats = {
85
86
  created: 0,
86
87
  replaced: 0,
@@ -111,7 +112,7 @@ const createReplaceImporter = db => {
111
112
  * Merge importer. Will merge the keys that already exist with their new value and create the new ones
112
113
  * @param {Object} db - DatabaseManager instance
113
114
  */
114
- const createMergeImporter = db => {
115
+ const createMergeImporter = (db) => {
115
116
  const stats = {
116
117
  created: 0,
117
118
  merged: 0,
@@ -145,7 +146,7 @@ const createMergeImporter = db => {
145
146
  * Merge importer. Will keep the keys that already exist without changing them and create the new ones
146
147
  * @param {Object} db - DatabaseManager instance
147
148
  */
148
- const createKeepImporter = db => {
149
+ const createKeepImporter = (db) => {
149
150
  const stats = {
150
151
  created: 0,
151
152
  untouched: 0,
@@ -14,7 +14,7 @@ module.exports = async () => {
14
14
  app.start().then(() => {
15
15
  const repl = REPL.start(app.config.info.name + ' > ' || 'strapi > '); // eslint-disable-line prefer-template
16
16
 
17
- repl.on('exit', function(err) {
17
+ repl.on('exit', function (err) {
18
18
  if (err) {
19
19
  app.log.error(err);
20
20
  process.exit(1);
@@ -5,7 +5,7 @@ const chalk = require('chalk');
5
5
 
6
6
  const strapi = require('../../index');
7
7
 
8
- module.exports = async function() {
8
+ module.exports = async function () {
9
9
  const appContext = await strapi.compile();
10
10
  const app = await strapi(appContext).register();
11
11
 
@@ -15,7 +15,7 @@ module.exports = async function() {
15
15
  head: [chalk.blue('Name')],
16
16
  });
17
17
 
18
- list.forEach(name => infoTable.push([name]));
18
+ list.forEach((name) => infoTable.push([name]));
19
19
 
20
20
  console.log(infoTable.toString());
21
21
 
@@ -5,7 +5,7 @@ const chalk = require('chalk');
5
5
 
6
6
  const strapi = require('../../index');
7
7
 
8
- module.exports = async function() {
8
+ module.exports = async function () {
9
9
  const appContext = await strapi.compile();
10
10
  const app = await strapi(appContext).register();
11
11
 
@@ -15,7 +15,7 @@ module.exports = async function() {
15
15
  head: [chalk.blue('Name')],
16
16
  });
17
17
 
18
- list.forEach(name => infoTable.push([name]));
18
+ list.forEach((name) => infoTable.push([name]));
19
19
 
20
20
  console.log(infoTable.toString());
21
21
 
@@ -18,7 +18,7 @@ const { buildTypeScript, buildAdmin } = require('./builders');
18
18
  *
19
19
  */
20
20
 
21
- module.exports = async function({ build, watchAdmin, polling, browser }) {
21
+ module.exports = async ({ build, watchAdmin, polling, browser }) => {
22
22
  const appDir = process.cwd();
23
23
 
24
24
  const isTSProject = await tsUtils.isUsingTypeScript(appDir);
@@ -96,8 +96,10 @@ const primaryProcess = async ({ distDir, appDir, build, isTSProject, watchAdmin,
96
96
  break;
97
97
  case 'stop':
98
98
  process.exit(1);
99
- default:
100
- return;
99
+ break;
100
+ default: {
101
+ break;
102
+ }
101
103
  }
102
104
  });
103
105
 
@@ -108,7 +110,7 @@ const workerProcess = ({ appDir, distDir, watchAdmin, polling, isTSProject }) =>
108
110
  const strapiInstance = strapi({
109
111
  distDir,
110
112
  autoReload: true,
111
- serveAdminPanel: watchAdmin ? false : true,
113
+ serveAdminPanel: !watchAdmin,
112
114
  });
113
115
 
114
116
  const adminWatchIgnoreFiles = strapiInstance.config.get('admin.watchIgnoreFiles', []);
@@ -120,13 +122,17 @@ const workerProcess = ({ appDir, distDir, watchAdmin, polling, isTSProject }) =>
120
122
  isTSProject,
121
123
  });
122
124
 
123
- process.on('message', async message => {
125
+ process.on('message', async (message) => {
124
126
  switch (message) {
125
- case 'kill':
127
+ case 'kill': {
126
128
  await strapiInstance.destroy();
127
129
  process.send('killed');
128
130
  process.exit();
129
- default:
131
+ break;
132
+ }
133
+ default: {
134
+ break;
135
+ }
130
136
  // Do nothing.
131
137
  }
132
138
  });
@@ -178,15 +184,15 @@ function watchFileChanges({ appDir, strapiInstance, watchIgnoreFiles, polling })
178
184
  });
179
185
 
180
186
  watcher
181
- .on('add', path => {
187
+ .on('add', (path) => {
182
188
  strapiInstance.log.info(`File created: ${path}`);
183
189
  restart();
184
190
  })
185
- .on('change', path => {
191
+ .on('change', (path) => {
186
192
  strapiInstance.log.info(`File changed: ${path}`);
187
193
  restart();
188
194
  })
189
- .on('unlink', path => {
195
+ .on('unlink', (path) => {
190
196
  strapiInstance.log.info(`File deleted: ${path}`);
191
197
  restart();
192
198
  });
@@ -5,7 +5,7 @@ const chalk = require('chalk');
5
5
 
6
6
  const strapi = require('../../index');
7
7
 
8
- module.exports = async function() {
8
+ module.exports = async function () {
9
9
  const appContext = await strapi.compile();
10
10
  const app = await strapi(appContext).register();
11
11
 
@@ -15,7 +15,7 @@ module.exports = async function() {
15
15
  head: [chalk.blue('Name')],
16
16
  });
17
17
 
18
- list.forEach(name => infoTable.push([name]));
18
+ list.forEach((name) => infoTable.push([name]));
19
19
 
20
20
  console.log(infoTable.toString());
21
21
 
@@ -6,13 +6,13 @@ const ora = require('ora');
6
6
  const execa = require('execa');
7
7
  const findPackagePath = require('../load/package-path');
8
8
 
9
- module.exports = async plugins => {
9
+ module.exports = async (plugins) => {
10
10
  const loader = ora();
11
11
  const dir = process.cwd();
12
12
 
13
13
  const version = require(join(dir, 'package.json')).dependencies['@strapi/strapi'];
14
14
 
15
- const pluginArgs = plugins.map(name => `@strapi/plugin-${name}@${version}`);
15
+ const pluginArgs = plugins.map((name) => `@strapi/plugin-${name}@${version}`);
16
16
 
17
17
  try {
18
18
  loader.start(`Installing dependencies`);
@@ -28,8 +28,8 @@ module.exports = async plugins => {
28
28
 
29
29
  // check if rebuild is necessary
30
30
  let shouldRebuild = false;
31
- for (let name of plugins) {
32
- let pkgPath = findPackagePath(`@strapi/plugin-${name}`);
31
+ for (const name of plugins) {
32
+ const pkgPath = findPackagePath(`@strapi/plugin-${name}`);
33
33
  if (existsSync(join(pkgPath, 'admin', 'src', 'index.js'))) {
34
34
  shouldRebuild = true;
35
35
  }
@@ -5,7 +5,7 @@ const chalk = require('chalk');
5
5
 
6
6
  const strapi = require('../../index');
7
7
 
8
- module.exports = async function() {
8
+ module.exports = async function () {
9
9
  const appContext = await strapi.compile();
10
10
  const app = await strapi(appContext).register();
11
11
 
@@ -15,7 +15,7 @@ module.exports = async function() {
15
15
  head: [chalk.blue('Name')],
16
16
  });
17
17
 
18
- list.forEach(name => infoTable.push([name]));
18
+ list.forEach((name) => infoTable.push([name]));
19
19
 
20
20
  console.log(infoTable.toString());
21
21
 
@@ -8,6 +8,6 @@ const { generateNewApp } = require('@strapi/generate-new');
8
8
  * Generate a new Strapi application.
9
9
  */
10
10
 
11
- module.exports = function(...args) {
11
+ module.exports = function (...args) {
12
12
  return generateNewApp(...args);
13
13
  };
@@ -7,7 +7,7 @@ const fetch = require('node-fetch');
7
7
  const { v4: uuidv4 } = require('uuid');
8
8
  const machineID = require('../utils/machine-id');
9
9
 
10
- const readPackageJSON = async path => {
10
+ const readPackageJSON = async (path) => {
11
11
  try {
12
12
  const packageObj = await fse.readJson(path);
13
13
  return packageObj;
@@ -31,7 +31,7 @@ const writePackageJSON = async (path, file, spacing) => {
31
31
  }
32
32
  };
33
33
 
34
- const generateNewPackageJSON = packageObj => {
34
+ const generateNewPackageJSON = (packageObj) => {
35
35
  if (!packageObj.strapi) {
36
36
  return {
37
37
  ...packageObj,
@@ -40,19 +40,18 @@ const generateNewPackageJSON = packageObj => {
40
40
  telemetryDisabled: false,
41
41
  },
42
42
  };
43
- } else {
44
- return {
45
- ...packageObj,
46
- strapi: {
47
- ...packageObj.strapi,
48
- uuid: packageObj.strapi.uuid ? packageObj.strapi.uuid : uuidv4(),
49
- telemetryDisabled: false,
50
- },
51
- };
52
43
  }
44
+ return {
45
+ ...packageObj,
46
+ strapi: {
47
+ ...packageObj.strapi,
48
+ uuid: packageObj.strapi.uuid ? packageObj.strapi.uuid : uuidv4(),
49
+ telemetryDisabled: false,
50
+ },
51
+ };
53
52
  };
54
53
 
55
- const sendEvent = async uuid => {
54
+ const sendEvent = async (uuid) => {
56
55
  try {
57
56
  await fetch('https://analytics.strapi.io/track', {
58
57
  method: 'POST',
@@ -64,7 +63,7 @@ const sendEvent = async uuid => {
64
63
  headers: { 'Content-Type': 'application/json' },
65
64
  });
66
65
  } catch (e) {
67
- //...
66
+ // ...
68
67
  }
69
68
  };
70
69
 
@@ -6,7 +6,7 @@ const chalk = require('chalk');
6
6
  const fetch = require('node-fetch');
7
7
  const machineID = require('../utils/machine-id');
8
8
 
9
- const readPackageJSON = async path => {
9
+ const readPackageJSON = async (path) => {
10
10
  try {
11
11
  const packageObj = await fse.readJson(path);
12
12
  const uuid = packageObj.strapi ? packageObj.strapi.uuid : null;
@@ -26,7 +26,7 @@ const writePackageJSON = async (path, file, spacing) => {
26
26
  }
27
27
  };
28
28
 
29
- const sendEvent = async uuid => {
29
+ const sendEvent = async (uuid) => {
30
30
  try {
31
31
  await fetch('https://analytics.strapi.io/track', {
32
32
  method: 'POST',
@@ -38,7 +38,7 @@ const sendEvent = async uuid => {
38
38
  headers: { 'Content-Type': 'application/json' },
39
39
  });
40
40
  } catch (e) {
41
- //...
41
+ // ...
42
42
  }
43
43
  };
44
44
 
@@ -5,7 +5,7 @@ const chalk = require('chalk');
5
5
 
6
6
  const strapi = require('../../index');
7
7
 
8
- module.exports = async function() {
8
+ module.exports = async function () {
9
9
  const appContext = await strapi.compile();
10
10
  const app = await strapi(appContext).register();
11
11
 
@@ -15,7 +15,7 @@ module.exports = async function() {
15
15
  head: [chalk.blue('Name')],
16
16
  });
17
17
 
18
- list.forEach(name => infoTable.push([name]));
18
+ list.forEach((name) => infoTable.push([name]));
19
19
 
20
20
  console.log(infoTable.toString());
21
21
 
@@ -6,7 +6,7 @@ const { toUpper } = require('lodash/fp');
6
6
 
7
7
  const strapi = require('../../index');
8
8
 
9
- module.exports = async function() {
9
+ module.exports = async function () {
10
10
  const appContext = await strapi.compile();
11
11
  const app = await strapi(appContext).load();
12
12
 
@@ -18,8 +18,8 @@ module.exports = async function() {
18
18
  });
19
19
 
20
20
  list
21
- .filter(route => route.methods.length)
22
- .forEach(route => {
21
+ .filter((route) => route.methods.length)
22
+ .forEach((route) => {
23
23
  infoTable.push([route.methods.map(toUpper).join('|'), route.path]);
24
24
  });
25
25
 
@@ -5,7 +5,7 @@ const chalk = require('chalk');
5
5
 
6
6
  const strapi = require('../../index');
7
7
 
8
- module.exports = async function() {
8
+ module.exports = async function () {
9
9
  const appContext = await strapi.compile();
10
10
  const app = await strapi(appContext).register();
11
11
 
@@ -15,7 +15,7 @@ module.exports = async function() {
15
15
  head: [chalk.blue('Name')],
16
16
  });
17
17
 
18
- list.forEach(name => infoTable.push([name]));
18
+ list.forEach((name) => infoTable.push([name]));
19
19
 
20
20
  console.log(infoTable.toString());
21
21
 
@@ -1,4 +1,5 @@
1
1
  'use strict';
2
+
2
3
  const fs = require('fs');
3
4
  const tsUtils = require('@strapi/typescript-utils');
4
5
  const strapi = require('../index');
@@ -4,7 +4,7 @@ const tsUtils = require('@strapi/typescript-utils');
4
4
 
5
5
  const strapi = require('../../index');
6
6
 
7
- module.exports = async function({ outDir, file, verbose, silent }) {
7
+ module.exports = async function ({ outDir, file, verbose, silent }) {
8
8
  if (verbose && silent) {
9
9
  console.error('You cannot enable verbose and silent flags at the same time, exiting...');
10
10
  process.exit(1);
@@ -21,13 +21,13 @@ module.exports = async (plugins, { deleteFiles }) => {
21
21
  const loader = ora();
22
22
  const dir = process.cwd();
23
23
 
24
- const pluginArgs = plugins.map(name => `@strapi/plugin-${name}`);
24
+ const pluginArgs = plugins.map((name) => `@strapi/plugin-${name}`);
25
25
 
26
26
  try {
27
27
  // verify should rebuild before removing the pacakge
28
28
  let shouldRebuild = false;
29
- for (let name of plugins) {
30
- let pkgPath = findPackagePath(`@strapi/plugin-${name}`);
29
+ for (const name of plugins) {
30
+ const pkgPath = findPackagePath(`@strapi/plugin-${name}`);
31
31
  if (existsSync(join(pkgPath, 'admin', 'src', 'index.js'))) {
32
32
  shouldRebuild = true;
33
33
  }
@@ -46,7 +46,7 @@ module.exports = async (plugins, { deleteFiles }) => {
46
46
 
47
47
  if (deleteFiles === true || answers.deleteFiles === true) {
48
48
  loader.start('Deleting old files');
49
- for (let name of plugins) {
49
+ for (const name of plugins) {
50
50
  const pluginDir = join(dir, 'extensions', name);
51
51
  if (existsSync(pluginDir)) {
52
52
  removeSync(pluginDir);