@strapi/strapi 4.4.5 → 4.4.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.
- package/lib/Strapi.js +1 -1
- package/lib/commands/builders/admin.js +1 -0
- package/lib/core/app-configuration/load-config-file.js +1 -3
- package/lib/core/loaders/apis.js +1 -2
- package/lib/core/loaders/middlewares.js +1 -2
- package/lib/core/loaders/policies.js +1 -2
- package/lib/core/loaders/src-index.js +1 -3
- package/lib/load/load-files.js +1 -1
- package/lib/middlewares/favicon.js +15 -2
- package/lib/services/entity-service/components.js +16 -26
- package/lib/services/entity-service/index.js +4 -2
- package/lib/services/server/middleware.js +2 -1
- package/lib/utils/index.js +0 -2
- package/package.json +14 -14
- package/lib/utils/import-default.js +0 -10
package/lib/Strapi.js
CHANGED
|
@@ -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 {
|
package/lib/core/loaders/apis.js
CHANGED
|
@@ -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()
|
package/lib/load/load-files.js
CHANGED
|
@@ -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('
|
|
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:
|
|
17
|
+
const { maxAge, path: faviconDefaultPath } = defaultsDeep(defaults, config);
|
|
18
|
+
const { root: appRoot } = strapi.dirs.app;
|
|
19
|
+
let faviconPath = faviconDefaultPath;
|
|
17
20
|
|
|
18
|
-
|
|
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
|
-
|
|
285
|
-
|
|
286
|
-
|
|
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
|
-
|
|
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 (
|
|
314
|
-
|
|
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, {
|
|
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(
|
|
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
|
|
123
|
+
return importDefault(modulePath);
|
|
123
124
|
} catch (err) {
|
|
124
125
|
throw new Error(`Could not load middleware "${modulePath}".`);
|
|
125
126
|
}
|
package/lib/utils/index.js
CHANGED
|
@@ -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.
|
|
3
|
+
"version": "4.4.6",
|
|
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.
|
|
84
|
-
"@strapi/database": "4.4.
|
|
85
|
-
"@strapi/generate-new": "4.4.
|
|
86
|
-
"@strapi/generators": "4.4.
|
|
87
|
-
"@strapi/logger": "4.4.
|
|
88
|
-
"@strapi/permissions": "4.4.
|
|
89
|
-
"@strapi/plugin-content-manager": "4.4.
|
|
90
|
-
"@strapi/plugin-content-type-builder": "4.4.
|
|
91
|
-
"@strapi/plugin-email": "4.4.
|
|
92
|
-
"@strapi/plugin-upload": "4.4.
|
|
93
|
-
"@strapi/typescript-utils": "4.4.
|
|
94
|
-
"@strapi/utils": "4.4.
|
|
83
|
+
"@strapi/admin": "4.4.6",
|
|
84
|
+
"@strapi/database": "4.4.6",
|
|
85
|
+
"@strapi/generate-new": "4.4.6",
|
|
86
|
+
"@strapi/generators": "4.4.6",
|
|
87
|
+
"@strapi/logger": "4.4.6",
|
|
88
|
+
"@strapi/permissions": "4.4.6",
|
|
89
|
+
"@strapi/plugin-content-manager": "4.4.6",
|
|
90
|
+
"@strapi/plugin-content-type-builder": "4.4.6",
|
|
91
|
+
"@strapi/plugin-email": "4.4.6",
|
|
92
|
+
"@strapi/plugin-upload": "4.4.6",
|
|
93
|
+
"@strapi/typescript-utils": "4.4.6",
|
|
94
|
+
"@strapi/utils": "4.4.6",
|
|
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": "
|
|
143
|
+
"gitHead": "788ea22ba6fc367f4d260e21e04e345bda0a12d9"
|
|
144
144
|
}
|