@strapi/strapi 4.4.5 → 4.4.7

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/lib/Strapi.js CHANGED
@@ -127,7 +127,7 @@ class Strapi {
127
127
  }
128
128
 
129
129
  get EE() {
130
- return ee({ dir: this.dirs.dist.root, logger: this.log });
130
+ return ee({ dir: this.dirs.app.root, logger: this.log });
131
131
  }
132
132
 
133
133
  get services() {
@@ -44,6 +44,7 @@ module.exports = async ({ buildDestDir, forceBuild = true, optimization, srcDir
44
44
  options: {
45
45
  backend: serverUrl,
46
46
  adminPath: addSlash(adminPath),
47
+ telemetryIsDisabled: strapiInstance.telemetry.isDisabled,
47
48
  },
48
49
  })
49
50
  .then(() => {
@@ -2,9 +2,7 @@
2
2
 
3
3
  const path = require('path');
4
4
  const fs = require('fs');
5
- const { templateConfiguration, env } = require('@strapi/utils');
6
-
7
- const importDefault = require('../../utils/import-default');
5
+ const { templateConfiguration, env, importDefault } = require('@strapi/utils');
8
6
 
9
7
  const loadJsFile = (file) => {
10
8
  try {
@@ -4,8 +4,7 @@ const { join, extname, basename } = require('path');
4
4
  const { existsSync } = require('fs-extra');
5
5
  const _ = require('lodash');
6
6
  const fse = require('fs-extra');
7
- const { isKebabCase } = require('@strapi/utils');
8
- const { importDefault } = require('../../utils');
7
+ const { isKebabCase, importDefault } = require('@strapi/utils');
9
8
 
10
9
  const DEFAULT_CONTENT_TYPE = {
11
10
  schema: {},
@@ -2,8 +2,7 @@
2
2
 
3
3
  const { join, extname, basename } = require('path');
4
4
  const fse = require('fs-extra');
5
-
6
- const { importDefault } = require('../../utils');
5
+ const { importDefault } = require('@strapi/utils');
7
6
 
8
7
  // TODO:: allow folders with index.js inside for bigger policies
9
8
  module.exports = async function loadMiddlewares(strapi) {
@@ -2,8 +2,7 @@
2
2
 
3
3
  const { join, extname, basename } = require('path');
4
4
  const fse = require('fs-extra');
5
-
6
- const { importDefault } = require('../../utils');
5
+ const { importDefault } = require('@strapi/utils');
7
6
 
8
7
  // TODO:: allow folders with index.js inside for bigger policies
9
8
  module.exports = async function loadPolicies(strapi) {
@@ -2,9 +2,7 @@
2
2
 
3
3
  const { resolve } = require('path');
4
4
  const { statSync, existsSync } = require('fs');
5
- const { yup } = require('@strapi/utils');
6
-
7
- const { importDefault } = require('../../utils');
5
+ const { yup, importDefault } = require('@strapi/utils');
8
6
 
9
7
  const srcSchema = yup
10
8
  .object()
@@ -4,7 +4,7 @@ const path = require('path');
4
4
  const _ = require('lodash');
5
5
  const fse = require('fs-extra');
6
6
 
7
- const { importDefault } = require('../utils');
7
+ const { importDefault } = require('@strapi/utils');
8
8
  const glob = require('./glob');
9
9
  const filePathToPath = require('./filepath-to-prop-path');
10
10
 
@@ -1,5 +1,6 @@
1
1
  'use strict';
2
2
 
3
+ const { existsSync } = require('fs');
3
4
  const { resolve } = require('path');
4
5
  const { defaultsDeep } = require('lodash/fp');
5
6
  const favicon = require('koa-favicon');
@@ -13,7 +14,19 @@ const defaults = {
13
14
  * @type {import('./').MiddlewareFactory}
14
15
  */
15
16
  module.exports = (config, { strapi }) => {
16
- const { maxAge, path: faviconPath } = defaultsDeep(defaults, config);
17
+ const { maxAge, path: faviconDefaultPath } = defaultsDeep(defaults, config);
18
+ const { root: appRoot } = strapi.dirs.app;
19
+ let faviconPath = faviconDefaultPath;
17
20
 
18
- return favicon(resolve(strapi.dirs.app.root, faviconPath), { maxAge });
21
+ /** TODO (v5): Updating the favicon to use a png caused
22
+ * https://github.com/strapi/strapi/issues/14693
23
+ *
24
+ * This check ensures backwards compatibility until
25
+ * the next major version
26
+ */
27
+ if (!existsSync(resolve(appRoot, faviconPath))) {
28
+ faviconPath = 'favicon.ico';
29
+ }
30
+
31
+ return favicon(resolve(appRoot, faviconPath), { maxAge });
19
32
  };
@@ -274,44 +274,34 @@ const deleteOldDZComponents = async (uid, entityToUpdate, attributeName, dynamic
274
274
  }
275
275
  };
276
276
 
277
- const deleteComponents = async (uid, entityToDelete) => {
277
+ const deleteComponents = async (uid, entityToDelete, { loadComponents = true } = {}) => {
278
278
  const { attributes = {} } = strapi.getModel(uid);
279
279
 
280
280
  for (const attributeName of Object.keys(attributes)) {
281
281
  const attribute = attributes[attributeName];
282
282
 
283
- if (attribute.type === 'component') {
284
- const { component: componentUID } = attribute;
285
-
286
- // Load attribute value if it's not already loaded
287
- const value =
288
- entityToDelete[attributeName] ||
289
- (await strapi.query(uid).load(entityToDelete, attributeName));
290
-
291
- if (!value) {
292
- continue;
293
- }
294
-
295
- if (Array.isArray(value)) {
296
- await Promise.all(value.map((subValue) => deleteComponent(componentUID, subValue)));
283
+ if (attribute.type === 'component' || attribute.type === 'dynamiczone') {
284
+ let value;
285
+ if (loadComponents) {
286
+ value = await strapi.query(uid).load(entityToDelete, attributeName);
297
287
  } else {
298
- await deleteComponent(componentUID, value);
288
+ value = entityToDelete[attributeName];
299
289
  }
300
290
 
301
- continue;
302
- }
303
-
304
- if (attribute.type === 'dynamiczone') {
305
- const value =
306
- entityToDelete[attributeName] ||
307
- (await strapi.query(uid).load(entityToDelete, attributeName));
308
-
309
291
  if (!value) {
310
292
  continue;
311
293
  }
312
294
 
313
- if (Array.isArray(value)) {
314
- await Promise.all(value.map((subValue) => deleteComponent(subValue.__component, subValue)));
295
+ if (attribute.type === 'component') {
296
+ const { component: componentUID } = attribute;
297
+ await Promise.all(
298
+ _.castArray(value).map((subValue) => deleteComponent(componentUID, subValue))
299
+ );
300
+ } else {
301
+ // delete dynamic zone components
302
+ await Promise.all(
303
+ _.castArray(value).map((subValue) => deleteComponent(subValue.__component, subValue))
304
+ );
315
305
  }
316
306
 
317
307
  continue;
@@ -217,7 +217,7 @@ const createDefaultImplementation = ({ strapi, db, eventHub, entityValidator })
217
217
  const componentsToDelete = await getComponents(uid, entityToDelete);
218
218
 
219
219
  await db.query(uid).delete({ where: { id: entityToDelete.id } });
220
- await deleteComponents(uid, { ...entityToDelete, ...componentsToDelete });
220
+ await deleteComponents(uid, componentsToDelete, { loadComponents: false });
221
221
 
222
222
  await this.emitEvent(uid, ENTRY_DELETE, entityToDelete);
223
223
 
@@ -242,7 +242,9 @@ const createDefaultImplementation = ({ strapi, db, eventHub, entityValidator })
242
242
  );
243
243
 
244
244
  const deletedEntities = await db.query(uid).deleteMany(query);
245
- await Promise.all(componentsToDelete.map((compos) => deleteComponents(uid, compos)));
245
+ await Promise.all(
246
+ componentsToDelete.map((compos) => deleteComponents(uid, compos, { loadComponents: false }))
247
+ );
246
248
 
247
249
  // Trigger webhooks. One for each entity
248
250
  await Promise.all(entitiesToDelete.map((entity) => this.emitEvent(uid, ENTRY_DELETE, entity)));
@@ -2,6 +2,7 @@
2
2
 
3
3
  const path = require('path');
4
4
  const { propOr, isArray, isNil } = require('lodash/fp');
5
+ const { importDefault } = require('@strapi/utils');
5
6
 
6
7
  const getMiddlewareConfig = propOr([], 'config.middlewares');
7
8
 
@@ -119,7 +120,7 @@ const resolveCustomMiddleware = (resolve, strapi) => {
119
120
  }
120
121
 
121
122
  try {
122
- return require(modulePath);
123
+ return importDefault(modulePath);
123
124
  } catch (err) {
124
125
  throw new Error(`Could not load middleware "${modulePath}".`);
125
126
  }
@@ -3,11 +3,9 @@
3
3
  const openBrowser = require('./open-browser');
4
4
  const isInitialized = require('./is-initialized');
5
5
  const getDirs = require('./get-dirs');
6
- const importDefault = require('./import-default');
7
6
 
8
7
  module.exports = {
9
8
  isInitialized,
10
9
  openBrowser,
11
10
  getDirs,
12
- importDefault,
13
11
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@strapi/strapi",
3
- "version": "4.4.5",
3
+ "version": "4.4.7",
4
4
  "description": "An open source headless CMS solution to create and manage your own API. It provides a powerful dashboard and features to make your life easier. Databases supported: MySQL, MariaDB, PostgreSQL, SQLite",
5
5
  "keywords": [
6
6
  "strapi",
@@ -80,18 +80,18 @@
80
80
  "dependencies": {
81
81
  "@koa/cors": "3.4.3",
82
82
  "@koa/router": "10.1.1",
83
- "@strapi/admin": "4.4.5",
84
- "@strapi/database": "4.4.5",
85
- "@strapi/generate-new": "4.4.5",
86
- "@strapi/generators": "4.4.5",
87
- "@strapi/logger": "4.4.5",
88
- "@strapi/permissions": "4.4.5",
89
- "@strapi/plugin-content-manager": "4.4.5",
90
- "@strapi/plugin-content-type-builder": "4.4.5",
91
- "@strapi/plugin-email": "4.4.5",
92
- "@strapi/plugin-upload": "4.4.5",
93
- "@strapi/typescript-utils": "4.4.5",
94
- "@strapi/utils": "4.4.5",
83
+ "@strapi/admin": "4.4.7",
84
+ "@strapi/database": "4.4.7",
85
+ "@strapi/generate-new": "4.4.7",
86
+ "@strapi/generators": "4.4.7",
87
+ "@strapi/logger": "4.4.7",
88
+ "@strapi/permissions": "4.4.7",
89
+ "@strapi/plugin-content-manager": "4.4.7",
90
+ "@strapi/plugin-content-type-builder": "4.4.7",
91
+ "@strapi/plugin-email": "4.4.7",
92
+ "@strapi/plugin-upload": "4.4.7",
93
+ "@strapi/typescript-utils": "4.4.7",
94
+ "@strapi/utils": "4.4.7",
95
95
  "bcryptjs": "2.4.3",
96
96
  "boxen": "5.1.2",
97
97
  "chalk": "4.1.2",
@@ -140,5 +140,5 @@
140
140
  "node": ">=14.19.1 <=18.x.x",
141
141
  "npm": ">=6.0.0"
142
142
  },
143
- "gitHead": "65feb971b86e91c06a0b3c7aec1fae21346bb7de"
143
+ "gitHead": "2a7549f5df12ac54adbc1cd6a3a773d53965a137"
144
144
  }
@@ -1,10 +0,0 @@
1
- 'use strict';
2
-
3
- const importDefault =
4
- (this && this.importDefault) ||
5
- function (modName) {
6
- const mod = require(modName);
7
- return mod && mod.__esModule ? mod.default : mod;
8
- };
9
-
10
- module.exports = importDefault;