@strapi/strapi 4.0.0-next.6 → 4.0.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.
- package/README.md +12 -12
- package/bin/strapi.js +41 -60
- package/lib/Strapi.js +234 -114
- package/lib/commands/build.js +16 -6
- package/lib/commands/console.js +1 -1
- package/lib/commands/content-types/list.js +22 -0
- package/lib/commands/develop.js +17 -18
- package/lib/commands/generate-template.js +4 -5
- package/lib/commands/hooks/list.js +22 -0
- package/lib/commands/middlewares/list.js +22 -0
- package/lib/commands/new.js +3 -1
- package/lib/commands/policies/list.js +22 -0
- package/lib/commands/routes/list.js +28 -0
- package/lib/commands/services/list.js +22 -0
- package/lib/commands/watchAdmin.js +18 -8
- package/lib/container.js +6 -6
- package/lib/core/app-configuration/config-loader.js +1 -37
- package/lib/core/app-configuration/index.js +6 -46
- package/lib/core/app-configuration/load-config-file.js +43 -0
- package/lib/core/bootstrap.js +5 -117
- package/lib/core/domain/component/index.js +24 -0
- package/lib/core/domain/component/validator.js +29 -0
- package/lib/core/domain/content-type/index.js +140 -0
- package/lib/core/domain/content-type/validator.js +64 -0
- package/lib/core/domain/module/index.js +108 -0
- package/lib/core/domain/module/validation.js +33 -0
- package/lib/core/loaders/admin.js +16 -0
- package/lib/core/loaders/apis.js +159 -0
- package/lib/core/{load-components.js → loaders/components.js} +5 -7
- package/lib/core/loaders/index.js +11 -0
- package/lib/core/loaders/middlewares.js +36 -0
- package/lib/core/loaders/plugins/get-enabled-plugins.js +116 -0
- package/lib/core/loaders/plugins/index.js +123 -0
- package/lib/core/loaders/policies.js +28 -0
- package/lib/core/loaders/src-index.js +39 -0
- package/lib/core/registries/apis.js +29 -0
- package/lib/core/{app-configuration/config-provider.js → registries/config.js} +4 -11
- package/lib/core/registries/content-types.js +97 -0
- package/lib/core/registries/controllers.d.ts +7 -0
- package/lib/core/registries/controllers.js +114 -0
- package/lib/core/registries/hooks.d.ts +20 -0
- package/lib/core/registries/hooks.js +87 -0
- package/lib/core/registries/middlewares.d.ts +5 -0
- package/lib/core/registries/middlewares.js +89 -0
- package/lib/core/registries/modules.js +44 -0
- package/lib/core/registries/plugins.js +28 -0
- package/lib/core/registries/policies.d.ts +9 -0
- package/lib/core/registries/policies.js +89 -0
- package/lib/core/registries/services.d.ts +7 -0
- package/lib/core/registries/services.js +114 -0
- package/lib/core/utils.js +35 -0
- package/lib/core-api/controller/collection-type.js +45 -26
- package/lib/core-api/controller/index.d.ts +25 -0
- package/lib/core-api/controller/index.js +33 -11
- package/lib/core-api/controller/single-type.js +29 -15
- package/lib/core-api/controller/transform.js +62 -6
- package/lib/core-api/routes/index.js +71 -0
- package/lib/core-api/service/collection-type.js +43 -21
- package/lib/core-api/service/index.d.ts +21 -0
- package/lib/core-api/service/index.js +8 -67
- package/lib/core-api/service/pagination.js +130 -0
- package/lib/core-api/service/single-type.js +17 -19
- package/lib/factories.d.ts +48 -0
- package/lib/factories.js +84 -0
- package/lib/index.d.ts +10 -31
- package/lib/index.js +5 -1
- package/lib/middlewares/body.js +33 -0
- package/lib/middlewares/compression.js +8 -0
- package/lib/middlewares/cors.js +58 -0
- package/lib/middlewares/errors.js +40 -0
- package/lib/middlewares/favicon.js +19 -0
- package/lib/middlewares/index.d.ts +5 -0
- package/lib/middlewares/index.js +30 -117
- package/lib/middlewares/ip.js +8 -0
- package/lib/middlewares/logger.js +27 -0
- package/lib/middlewares/powered-by.js +20 -0
- package/lib/middlewares/public/index.js +98 -73
- package/lib/middlewares/query.js +46 -0
- package/lib/middlewares/response-time.js +15 -0
- package/lib/middlewares/responses.js +19 -0
- package/lib/middlewares/security.js +51 -0
- package/lib/middlewares/session/index.js +6 -6
- package/lib/migrations/draft-publish.js +57 -0
- package/lib/services/auth/index.js +87 -0
- package/lib/services/core-store.js +64 -51
- package/lib/services/cron.js +54 -0
- package/lib/services/entity-service/attributes/index.js +31 -0
- package/lib/services/entity-service/attributes/transforms.js +20 -0
- package/lib/services/entity-service/components.js +39 -15
- package/lib/services/entity-service/index.d.ts +91 -0
- package/lib/services/entity-service/index.js +120 -59
- package/lib/services/entity-service/params.js +52 -94
- package/lib/services/entity-validator/index.js +76 -43
- package/lib/services/entity-validator/validators.js +129 -43
- package/lib/services/errors.js +77 -0
- package/lib/{core → services}/fs.js +10 -2
- package/lib/services/metrics/index.js +41 -38
- package/lib/services/metrics/sender.js +2 -2
- package/lib/services/server/admin-api.js +14 -0
- package/lib/services/server/api.js +36 -0
- package/lib/services/server/compose-endpoint.js +141 -0
- package/lib/services/server/content-api.js +16 -0
- package/lib/{server.js → services/server/http-server.js} +0 -0
- package/lib/services/server/index.js +127 -0
- package/lib/services/server/koa.js +64 -0
- package/lib/services/server/middleware.js +122 -0
- package/lib/services/server/policy.js +32 -0
- package/lib/services/server/register-middlewares.js +110 -0
- package/lib/services/server/register-routes.js +106 -0
- package/lib/services/server/routing.js +120 -0
- package/lib/services/utils/upload-files.js +1 -1
- package/lib/services/webhook-runner.js +1 -1
- package/lib/utils/ee.js +3 -3
- package/lib/utils/get-dirs.js +17 -0
- package/lib/utils/index.js +2 -0
- package/lib/utils/is-initialized.js +1 -1
- package/lib/utils/run-checks.js +0 -15
- package/lib/utils/signals.js +24 -0
- package/lib/utils/startup-logger.js +2 -2
- package/lib/utils/update-notifier/index.js +3 -2
- package/package.json +93 -96
- package/lib/commands/generate.js +0 -76
- package/lib/core/index.js +0 -17
- package/lib/core/load-apis.js +0 -20
- package/lib/core/load-extensions.js +0 -71
- package/lib/core/load-functions.js +0 -21
- package/lib/core/load-middlewares.js +0 -130
- package/lib/core/load-modules.js +0 -55
- package/lib/core/load-plugins.js +0 -68
- package/lib/core/load-policies.js +0 -36
- package/lib/core/walk.js +0 -27
- package/lib/core-api/index.js +0 -39
- package/lib/load/check-reserved-filename.js +0 -10
- package/lib/load/load-config-files.js +0 -22
- package/lib/load/require-file-parse.js +0 -15
- package/lib/middlewares/boom/defaults.json +0 -5
- package/lib/middlewares/boom/index.js +0 -147
- package/lib/middlewares/cors/index.js +0 -66
- package/lib/middlewares/cron/defaults.json +0 -5
- package/lib/middlewares/cron/index.js +0 -43
- package/lib/middlewares/favicon/defaults.json +0 -7
- package/lib/middlewares/favicon/index.js +0 -32
- package/lib/middlewares/gzip/defaults.json +0 -6
- package/lib/middlewares/gzip/index.js +0 -19
- package/lib/middlewares/helmet/defaults.json +0 -18
- package/lib/middlewares/helmet/index.js +0 -9
- package/lib/middlewares/ip/defaults.json +0 -7
- package/lib/middlewares/ip/index.js +0 -25
- package/lib/middlewares/language/defaults.json +0 -9
- package/lib/middlewares/language/index.js +0 -40
- package/lib/middlewares/logger/defaults.json +0 -5
- package/lib/middlewares/logger/index.js +0 -37
- package/lib/middlewares/parser/defaults.json +0 -11
- package/lib/middlewares/parser/index.js +0 -71
- package/lib/middlewares/poweredBy/defaults.json +0 -5
- package/lib/middlewares/poweredBy/index.js +0 -16
- package/lib/middlewares/public/defaults.json +0 -8
- package/lib/middlewares/responseTime/defaults.json +0 -5
- package/lib/middlewares/responseTime/index.js +0 -25
- package/lib/middlewares/responses/defaults.json +0 -5
- package/lib/middlewares/responses/index.js +0 -18
- package/lib/middlewares/router/defaults.json +0 -7
- package/lib/middlewares/router/index.js +0 -64
- package/lib/middlewares/router/utils/composeEndpoint.js +0 -25
- package/lib/middlewares/router/utils/routerChecker.js +0 -92
- package/lib/utils/get-prefixed-dependencies.js +0 -7
package/package.json
CHANGED
|
@@ -1,100 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@strapi/strapi",
|
|
3
|
-
"version": "4.0.0
|
|
3
|
+
"version": "4.0.0",
|
|
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
|
-
"homepage": "https://strapi.io",
|
|
6
|
-
"directories": {
|
|
7
|
-
"lib": "./lib",
|
|
8
|
-
"bin": "./bin"
|
|
9
|
-
},
|
|
10
|
-
"main": "./lib",
|
|
11
|
-
"bin": {
|
|
12
|
-
"strapi": "./bin/strapi.js"
|
|
13
|
-
},
|
|
14
|
-
"dependencies": {
|
|
15
|
-
"@koa/cors": "^3.0.0",
|
|
16
|
-
"@strapi/admin": "4.0.0-next.6",
|
|
17
|
-
"@strapi/database": "4.0.0-next.6",
|
|
18
|
-
"@strapi/generate": "4.0.0-next.6",
|
|
19
|
-
"@strapi/generate-api": "4.0.0-next.6",
|
|
20
|
-
"@strapi/generate-controller": "4.0.0-next.6",
|
|
21
|
-
"@strapi/generate-model": "4.0.0-next.6",
|
|
22
|
-
"@strapi/generate-new": "4.0.0-next.6",
|
|
23
|
-
"@strapi/generate-plugin": "4.0.0-next.6",
|
|
24
|
-
"@strapi/generate-policy": "4.0.0-next.6",
|
|
25
|
-
"@strapi/generate-service": "4.0.0-next.6",
|
|
26
|
-
"@strapi/logger": "4.0.0-next.6",
|
|
27
|
-
"@strapi/utils": "4.0.0-next.6",
|
|
28
|
-
"async": "^2.1.2",
|
|
29
|
-
"boom": "^7.3.0",
|
|
30
|
-
"boxen": "4.2.0",
|
|
31
|
-
"chalk": "^4.1.1",
|
|
32
|
-
"chokidar": "3.5.1",
|
|
33
|
-
"ci-info": "3.1.1",
|
|
34
|
-
"cli-table3": "^0.6.0",
|
|
35
|
-
"commander": "6.1.0",
|
|
36
|
-
"configstore": "5.0.1",
|
|
37
|
-
"cross-spawn": "^7.0.3",
|
|
38
|
-
"debug": "^4.1.1",
|
|
39
|
-
"delegates": "^1.0.0",
|
|
40
|
-
"dotenv": "8.2.0",
|
|
41
|
-
"execa": "^1.0.0",
|
|
42
|
-
"fs-extra": "^9.1.0",
|
|
43
|
-
"glob": "^7.1.2",
|
|
44
|
-
"inquirer": "^6.2.1",
|
|
45
|
-
"is-docker": "2.2.1",
|
|
46
|
-
"koa": "^2.13.1",
|
|
47
|
-
"koa-body": "^4.2.0",
|
|
48
|
-
"koa-compose": "^4.1.0",
|
|
49
|
-
"koa-compress": "^5.0.1",
|
|
50
|
-
"koa-convert": "^2.0.0",
|
|
51
|
-
"koa-favicon": "^2.0.0",
|
|
52
|
-
"koa-helmet": "6.1.0",
|
|
53
|
-
"koa-i18n": "^2.1.0",
|
|
54
|
-
"koa-ip": "^2.0.0",
|
|
55
|
-
"koa-locale": "~1.3.0",
|
|
56
|
-
"koa-router": "^7.4.0",
|
|
57
|
-
"koa-session": "^6.2.0",
|
|
58
|
-
"koa-static": "^5.0.0",
|
|
59
|
-
"lodash": "4.17.21",
|
|
60
|
-
"node-fetch": "2.6.1",
|
|
61
|
-
"node-machine-id": "1.1.12",
|
|
62
|
-
"node-schedule": "1.3.2",
|
|
63
|
-
"open": "8.2.1",
|
|
64
|
-
"ora": "^5.4.0",
|
|
65
|
-
"package-json": "6.5.0",
|
|
66
|
-
"qs": "^6.10.1",
|
|
67
|
-
"resolve-cwd": "^3.0.0",
|
|
68
|
-
"rimraf": "^3.0.2",
|
|
69
|
-
"semver": "7.3.5"
|
|
70
|
-
},
|
|
71
|
-
"scripts": {
|
|
72
|
-
"postinstall": "node lib/utils/success.js"
|
|
73
|
-
},
|
|
74
|
-
"author": {
|
|
75
|
-
"email": "hi@strapi.io",
|
|
76
|
-
"name": "Strapi team",
|
|
77
|
-
"url": "https://strapi.io"
|
|
78
|
-
},
|
|
79
|
-
"maintainers": [
|
|
80
|
-
{
|
|
81
|
-
"name": "Strapi team",
|
|
82
|
-
"email": "hi@strapi.io",
|
|
83
|
-
"url": "https://strapi.io"
|
|
84
|
-
}
|
|
85
|
-
],
|
|
86
|
-
"repository": {
|
|
87
|
-
"type": "git",
|
|
88
|
-
"url": "git://github.com/strapi/strapi.git"
|
|
89
|
-
},
|
|
90
|
-
"bugs": {
|
|
91
|
-
"url": "https://github.com/strapi/strapi/issues"
|
|
92
|
-
},
|
|
93
|
-
"engines": {
|
|
94
|
-
"node": ">=12.x.x <=16.x.x",
|
|
95
|
-
"npm": ">=6.0.0"
|
|
96
|
-
},
|
|
97
|
-
"license": "SEE LICENSE IN LICENSE",
|
|
98
5
|
"keywords": [
|
|
99
6
|
"strapi",
|
|
100
7
|
"cms",
|
|
@@ -131,11 +38,101 @@
|
|
|
131
38
|
"backend",
|
|
132
39
|
"open source",
|
|
133
40
|
"self hosted",
|
|
134
|
-
"javascript",
|
|
135
41
|
"lerna",
|
|
136
42
|
"lernajs",
|
|
137
43
|
"react",
|
|
138
44
|
"reactjs"
|
|
139
45
|
],
|
|
140
|
-
"
|
|
46
|
+
"homepage": "https://strapi.io",
|
|
47
|
+
"bugs": {
|
|
48
|
+
"url": "https://github.com/strapi/strapi/issues"
|
|
49
|
+
},
|
|
50
|
+
"repository": {
|
|
51
|
+
"type": "git",
|
|
52
|
+
"url": "git://github.com/strapi/strapi.git"
|
|
53
|
+
},
|
|
54
|
+
"license": "SEE LICENSE IN LICENSE",
|
|
55
|
+
"author": {
|
|
56
|
+
"name": "Strapi Solutions SAS",
|
|
57
|
+
"email": "hi@strapi.io",
|
|
58
|
+
"url": "https://strapi.io"
|
|
59
|
+
},
|
|
60
|
+
"maintainers": [
|
|
61
|
+
{
|
|
62
|
+
"name": "Strapi Solutions SAS",
|
|
63
|
+
"email": "hi@strapi.io",
|
|
64
|
+
"url": "https://strapi.io"
|
|
65
|
+
}
|
|
66
|
+
],
|
|
67
|
+
"main": "./lib",
|
|
68
|
+
"types": "./lib/index.d.ts",
|
|
69
|
+
"bin": {
|
|
70
|
+
"strapi": "./bin/strapi.js"
|
|
71
|
+
},
|
|
72
|
+
"directories": {
|
|
73
|
+
"lib": "./lib",
|
|
74
|
+
"bin": "./bin"
|
|
75
|
+
},
|
|
76
|
+
"scripts": {
|
|
77
|
+
"postinstall": "node lib/utils/success.js"
|
|
78
|
+
},
|
|
79
|
+
"dependencies": {
|
|
80
|
+
"@koa/cors": "3.1.0",
|
|
81
|
+
"@koa/router": "10.1.1",
|
|
82
|
+
"@strapi/admin": "4.0.0",
|
|
83
|
+
"@strapi/database": "4.0.0",
|
|
84
|
+
"@strapi/generate-new": "4.0.0",
|
|
85
|
+
"@strapi/generators": "4.0.0",
|
|
86
|
+
"@strapi/logger": "4.0.0",
|
|
87
|
+
"@strapi/plugin-content-manager": "4.0.0",
|
|
88
|
+
"@strapi/plugin-content-type-builder": "4.0.0",
|
|
89
|
+
"@strapi/plugin-email": "4.0.0",
|
|
90
|
+
"@strapi/plugin-upload": "4.0.0",
|
|
91
|
+
"@strapi/utils": "4.0.0",
|
|
92
|
+
"bcryptjs": "2.4.3",
|
|
93
|
+
"boxen": "5.1.2",
|
|
94
|
+
"chalk": "4.1.2",
|
|
95
|
+
"chokidar": "3.5.2",
|
|
96
|
+
"ci-info": "3.2.0",
|
|
97
|
+
"cli-table3": "0.6.0",
|
|
98
|
+
"commander": "8.2.0",
|
|
99
|
+
"configstore": "5.0.1",
|
|
100
|
+
"debug": "4.3.2",
|
|
101
|
+
"delegates": "1.0.0",
|
|
102
|
+
"dotenv": "10.0.0",
|
|
103
|
+
"execa": "5.1.1",
|
|
104
|
+
"fs-extra": "10.0.0",
|
|
105
|
+
"glob": "7.2.0",
|
|
106
|
+
"http-errors": "1.8.0",
|
|
107
|
+
"inquirer": "8.2.0",
|
|
108
|
+
"is-docker": "2.2.1",
|
|
109
|
+
"koa": "2.13.3",
|
|
110
|
+
"koa-body": "4.2.0",
|
|
111
|
+
"koa-compose": "4.1.0",
|
|
112
|
+
"koa-compress": "5.1.0",
|
|
113
|
+
"koa-favicon": "2.1.0",
|
|
114
|
+
"koa-helmet": "6.1.0",
|
|
115
|
+
"koa-ip": "2.1.0",
|
|
116
|
+
"koa-session": "6.2.0",
|
|
117
|
+
"koa-static": "5.0.0",
|
|
118
|
+
"lodash": "4.17.21",
|
|
119
|
+
"node-fetch": "2.6.5",
|
|
120
|
+
"node-machine-id": "1.1.12",
|
|
121
|
+
"node-schedule": "2.0.0",
|
|
122
|
+
"open": "8.2.1",
|
|
123
|
+
"ora": "5.4.1",
|
|
124
|
+
"package-json": "7.0.0",
|
|
125
|
+
"qs": "6.10.1",
|
|
126
|
+
"resolve-cwd": "3.0.0",
|
|
127
|
+
"semver": "7.3.5",
|
|
128
|
+
"statuses": "2.0.1"
|
|
129
|
+
},
|
|
130
|
+
"devDependencies": {
|
|
131
|
+
"supertest": "^6.1.6"
|
|
132
|
+
},
|
|
133
|
+
"engines": {
|
|
134
|
+
"node": ">=12.x.x <=16.x.x",
|
|
135
|
+
"npm": ">=6.0.0"
|
|
136
|
+
},
|
|
137
|
+
"gitHead": "b181702f0202b2c6d645d42b195a831f25cd0b03"
|
|
141
138
|
}
|
package/lib/commands/generate.js
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Module dependencies
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
// FIXME
|
|
8
|
-
/* eslint-disable import/extensions */
|
|
9
|
-
|
|
10
|
-
// Node.js core.
|
|
11
|
-
const path = require('path');
|
|
12
|
-
|
|
13
|
-
// Master of ceremonies for generators.
|
|
14
|
-
const generate = require('@strapi/generate');
|
|
15
|
-
|
|
16
|
-
// Logger.
|
|
17
|
-
const { createLogger } = require('@strapi/logger');
|
|
18
|
-
|
|
19
|
-
// Configuration
|
|
20
|
-
const loadConfiguration = require('../core/app-configuration');
|
|
21
|
-
|
|
22
|
-
// Local Strapi dependencies.
|
|
23
|
-
const packageJSON = require('../../package.json');
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* `$ strapi generate`
|
|
27
|
-
*
|
|
28
|
-
* Scaffolding for the application in our working directory.
|
|
29
|
-
*/
|
|
30
|
-
|
|
31
|
-
module.exports = function(id, cliArguments) {
|
|
32
|
-
const dir = process.cwd();
|
|
33
|
-
const config = loadConfiguration(dir);
|
|
34
|
-
const logger = createLogger(config.get('logger', {}));
|
|
35
|
-
|
|
36
|
-
// Build initial scope.
|
|
37
|
-
const scope = {
|
|
38
|
-
rootPath: process.cwd(),
|
|
39
|
-
strapiRoot: path.resolve(__dirname, '..'),
|
|
40
|
-
id: id,
|
|
41
|
-
args: cliArguments,
|
|
42
|
-
strapiPackageJSON: packageJSON,
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
scope.generatorType = process.argv[2].split(':')[1];
|
|
46
|
-
|
|
47
|
-
// Show usage if no generator type is defined.
|
|
48
|
-
if (!scope.generatorType) {
|
|
49
|
-
return logger.error('Write `$ strapi generate:something` instead.');
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
return generate(scope, {
|
|
53
|
-
// Log and exit the REPL in case there is an error
|
|
54
|
-
// while we were trying to generate the requested generator.
|
|
55
|
-
error(msg) {
|
|
56
|
-
logger.error(msg);
|
|
57
|
-
process.exit(1);
|
|
58
|
-
},
|
|
59
|
-
|
|
60
|
-
// Log and exit the REPL in case of success
|
|
61
|
-
// but first make sure we have all the info we need.
|
|
62
|
-
success() {
|
|
63
|
-
if (!scope.outputPath && scope.filename && scope.destDir) {
|
|
64
|
-
scope.outputPath = scope.destDir + scope.filename;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
if (scope.generatorType !== 'new') {
|
|
68
|
-
logger.info(
|
|
69
|
-
`Generated a new ${scope.generatorType} \`${scope.name}\` at \`${scope.filePath}\`.`
|
|
70
|
-
);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
process.exit(0);
|
|
74
|
-
},
|
|
75
|
-
});
|
|
76
|
-
};
|
package/lib/core/index.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const loadApis = require('./load-apis');
|
|
4
|
-
const loadPlugins = require('./load-plugins');
|
|
5
|
-
const loadMiddlewares = require('./load-middlewares');
|
|
6
|
-
const loadExtensions = require('./load-extensions');
|
|
7
|
-
const bootstrap = require('./bootstrap');
|
|
8
|
-
const loadComponents = require('./load-components');
|
|
9
|
-
|
|
10
|
-
module.exports = {
|
|
11
|
-
loadApis,
|
|
12
|
-
loadPlugins,
|
|
13
|
-
loadMiddlewares,
|
|
14
|
-
loadExtensions,
|
|
15
|
-
loadComponents,
|
|
16
|
-
bootstrap,
|
|
17
|
-
};
|
package/lib/core/load-apis.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const { join } = require('path');
|
|
4
|
-
const { existsSync } = require('fs-extra');
|
|
5
|
-
const _ = require('lodash');
|
|
6
|
-
const loadFiles = require('../load/load-files');
|
|
7
|
-
const loadConfig = require('../load/load-config-files');
|
|
8
|
-
|
|
9
|
-
module.exports = async ({ dir }) => {
|
|
10
|
-
const apiDir = join(dir, 'api');
|
|
11
|
-
|
|
12
|
-
if (!existsSync(apiDir)) {
|
|
13
|
-
throw new Error(`Missing api folder. Please create one in your app root directory`);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
const apis = await loadFiles(apiDir, '*/!(config)/**/*.*(js|json)');
|
|
17
|
-
const apiConfigs = await loadConfig(apiDir, '*/config/**/*.*(js|json)');
|
|
18
|
-
|
|
19
|
-
return _.merge(apis, apiConfigs);
|
|
20
|
-
};
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const path = require('path');
|
|
4
|
-
const { existsSync } = require('fs-extra');
|
|
5
|
-
const fse = require('fs-extra');
|
|
6
|
-
const _ = require('lodash');
|
|
7
|
-
const loadConfig = require('../load/load-config-files');
|
|
8
|
-
const loadFiles = require('../load/load-files');
|
|
9
|
-
const glob = require('../load/glob');
|
|
10
|
-
const filePathToPath = require('../load/filepath-to-prop-path');
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Loads the extensions folder
|
|
14
|
-
*/
|
|
15
|
-
module.exports = async function({ appPath }) {
|
|
16
|
-
const extensionsDir = path.resolve(appPath, 'extensions');
|
|
17
|
-
|
|
18
|
-
if (!existsSync(extensionsDir)) {
|
|
19
|
-
throw new Error(`Missing extensions folder. Please create one in your app root directory`);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
const configs = await loadConfig(extensionsDir, '*/config/**/*.+(js|json)');
|
|
23
|
-
const controllersAndServices = await loadFiles(
|
|
24
|
-
extensionsDir,
|
|
25
|
-
'*/{controllers,services}/*.+(js|json)'
|
|
26
|
-
);
|
|
27
|
-
|
|
28
|
-
const overwrites = await loadOverwrites(extensionsDir);
|
|
29
|
-
|
|
30
|
-
return {
|
|
31
|
-
overwrites,
|
|
32
|
-
merges: _.merge({}, configs, controllersAndServices),
|
|
33
|
-
};
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
const OVERWRITABLE_FOLDERS_GLOB = 'models';
|
|
37
|
-
// returns a list of path and module to overwrite
|
|
38
|
-
const loadOverwrites = async extensionsDir => {
|
|
39
|
-
const files = await glob(`*/${OVERWRITABLE_FOLDERS_GLOB}/*.*(js|json)`, {
|
|
40
|
-
cwd: extensionsDir,
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
const overwrites = {};
|
|
44
|
-
files.forEach(file => {
|
|
45
|
-
const absolutePath = path.resolve(extensionsDir, file);
|
|
46
|
-
|
|
47
|
-
// load module
|
|
48
|
-
delete require.cache[absolutePath];
|
|
49
|
-
let mod;
|
|
50
|
-
|
|
51
|
-
if (path.extname(absolutePath) === '.json') {
|
|
52
|
-
mod = fse.readJsonSync(absolutePath);
|
|
53
|
-
} else {
|
|
54
|
-
mod = require(absolutePath);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
const propPath = filePathToPath(file);
|
|
58
|
-
const strPath = propPath.join('.');
|
|
59
|
-
|
|
60
|
-
if (overwrites[strPath]) {
|
|
61
|
-
_.merge(overwrites[strPath], mod);
|
|
62
|
-
} else {
|
|
63
|
-
overwrites[strPath] = mod;
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
return Object.keys(overwrites).map(strPath => ({
|
|
68
|
-
path: strPath.split('.'),
|
|
69
|
-
mod: overwrites[strPath],
|
|
70
|
-
}));
|
|
71
|
-
};
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const fse = require('fs-extra');
|
|
4
|
-
|
|
5
|
-
const walk = require('./walk');
|
|
6
|
-
|
|
7
|
-
const loadFunctions = dir => {
|
|
8
|
-
if (!fse.existsSync(dir)) return {};
|
|
9
|
-
|
|
10
|
-
return walk(dir, { loader: loadFunction });
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
const loadFunction = file => {
|
|
14
|
-
try {
|
|
15
|
-
return require(file);
|
|
16
|
-
} catch (error) {
|
|
17
|
-
throw `Could not load function ${file}: ${error.message}`;
|
|
18
|
-
}
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
module.exports = loadFunctions;
|
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
// Dependencies.
|
|
4
|
-
const path = require('path');
|
|
5
|
-
const fs = require('fs-extra');
|
|
6
|
-
const _ = require('lodash');
|
|
7
|
-
const glob = require('../load/glob');
|
|
8
|
-
const findPackagePath = require('../load/package-path');
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Load middlewares
|
|
12
|
-
*/
|
|
13
|
-
module.exports = async function(strapi) {
|
|
14
|
-
const { installedMiddlewares, installedPlugins, appPath } = strapi.config;
|
|
15
|
-
|
|
16
|
-
let middlewares = {};
|
|
17
|
-
|
|
18
|
-
const loaders = createLoaders(strapi);
|
|
19
|
-
|
|
20
|
-
await loaders.loadMiddlewareDependencies(installedMiddlewares, middlewares);
|
|
21
|
-
// internal middlewares
|
|
22
|
-
await loaders.loadInternalMiddlewares(middlewares);
|
|
23
|
-
// local middleware
|
|
24
|
-
await loaders.loadLocalMiddlewares(appPath, middlewares);
|
|
25
|
-
// plugins middlewares
|
|
26
|
-
await loaders.loadPluginsMiddlewares(installedPlugins, middlewares);
|
|
27
|
-
// local plugin middlewares
|
|
28
|
-
await loaders.loadLocalPluginsMiddlewares(appPath, middlewares);
|
|
29
|
-
// load admin middlwares
|
|
30
|
-
await loaders.loadAdminMiddlewares(middlewares);
|
|
31
|
-
|
|
32
|
-
return middlewares;
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Build loader functions
|
|
37
|
-
* @param {*} strapi - strapi instance
|
|
38
|
-
*/
|
|
39
|
-
const createLoaders = strapi => {
|
|
40
|
-
const loadMiddlewaresInDir = async (dir, middlewares) => {
|
|
41
|
-
const files = await glob('*/*(index|defaults).*(js|json)', {
|
|
42
|
-
cwd: dir,
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
files.forEach(f => {
|
|
46
|
-
const name = f.split('/')[0];
|
|
47
|
-
mountMiddleware(name, [path.resolve(dir, f)], middlewares);
|
|
48
|
-
});
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
const loadInternalMiddlewares = middlewares =>
|
|
52
|
-
loadMiddlewaresInDir(path.resolve(__dirname, '..', 'middlewares'), middlewares);
|
|
53
|
-
|
|
54
|
-
const loadLocalMiddlewares = (appPath, middlewares) =>
|
|
55
|
-
loadMiddlewaresInDir(path.resolve(appPath, 'middlewares'), middlewares);
|
|
56
|
-
|
|
57
|
-
const loadPluginsMiddlewares = async (plugins, middlewares) => {
|
|
58
|
-
for (let pluginName of plugins) {
|
|
59
|
-
const dir = path.resolve(findPackagePath(`@strapi/plugin-${pluginName}`), 'middlewares');
|
|
60
|
-
await loadMiddlewaresInDir(dir, middlewares);
|
|
61
|
-
}
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
const loadLocalPluginsMiddlewares = async (appPath, middlewares) => {
|
|
65
|
-
const pluginsDir = path.resolve(appPath, 'plugins');
|
|
66
|
-
if (!fs.existsSync(pluginsDir)) return;
|
|
67
|
-
|
|
68
|
-
const pluginsNames = await fs.readdir(pluginsDir);
|
|
69
|
-
|
|
70
|
-
for (let pluginFolder of pluginsNames) {
|
|
71
|
-
// ignore files
|
|
72
|
-
const stat = await fs.stat(path.resolve(pluginsDir, pluginFolder));
|
|
73
|
-
if (!stat.isDirectory()) continue;
|
|
74
|
-
|
|
75
|
-
const dir = path.resolve(pluginsDir, pluginFolder, 'middlewares');
|
|
76
|
-
await loadMiddlewaresInDir(dir, middlewares);
|
|
77
|
-
}
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
const loadAdminMiddlewares = async middlewares => {
|
|
81
|
-
const middlewaresDir = 'middlewares';
|
|
82
|
-
const dir = path.resolve(findPackagePath(`@strapi/admin`), middlewaresDir);
|
|
83
|
-
await loadMiddlewaresInDir(dir, middlewares);
|
|
84
|
-
|
|
85
|
-
// load ee admin middlewares if they exist
|
|
86
|
-
if (process.env.STRAPI_DISABLE_EE !== 'true' && strapi.EE) {
|
|
87
|
-
await loadMiddlewaresInDir(`${dir}/../ee/${middlewaresDir}`, middlewares);
|
|
88
|
-
}
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
const loadMiddlewareDependencies = async (packages, middlewares) => {
|
|
92
|
-
for (let packageName of packages) {
|
|
93
|
-
const baseDir = path.dirname(require.resolve(`@strapi/middleware-${packageName}`));
|
|
94
|
-
const files = await glob('*(index|defaults).*(js|json)', {
|
|
95
|
-
cwd: baseDir,
|
|
96
|
-
absolute: true,
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
mountMiddleware(packageName, files, middlewares);
|
|
100
|
-
}
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
const mountMiddleware = (name, files, middlewares) => {
|
|
104
|
-
files.forEach(file => {
|
|
105
|
-
middlewares[name] = middlewares[name] || { loaded: false };
|
|
106
|
-
|
|
107
|
-
if (_.endsWith(file, 'index.js') && !middlewares[name].load) {
|
|
108
|
-
return Object.defineProperty(middlewares[name], 'load', {
|
|
109
|
-
configurable: false,
|
|
110
|
-
enumerable: true,
|
|
111
|
-
get: () => require(file)(strapi),
|
|
112
|
-
});
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
if (_.endsWith(file, 'defaults.json')) {
|
|
116
|
-
middlewares[name].defaults = require(file);
|
|
117
|
-
return;
|
|
118
|
-
}
|
|
119
|
-
});
|
|
120
|
-
};
|
|
121
|
-
|
|
122
|
-
return {
|
|
123
|
-
loadInternalMiddlewares,
|
|
124
|
-
loadLocalMiddlewares,
|
|
125
|
-
loadPluginsMiddlewares,
|
|
126
|
-
loadLocalPluginsMiddlewares,
|
|
127
|
-
loadMiddlewareDependencies,
|
|
128
|
-
loadAdminMiddlewares,
|
|
129
|
-
};
|
|
130
|
-
};
|
package/lib/core/load-modules.js
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Load Modules is the root module loader.
|
|
3
|
-
* This is where all the strapi enviornment is laoded
|
|
4
|
-
* - APIs
|
|
5
|
-
* - Plugins
|
|
6
|
-
* - Hooks
|
|
7
|
-
* - Middlewres
|
|
8
|
-
* - Components
|
|
9
|
-
* - ContentTypes
|
|
10
|
-
*/
|
|
11
|
-
'use strict';
|
|
12
|
-
|
|
13
|
-
const _ = require('lodash');
|
|
14
|
-
|
|
15
|
-
const loadApis = require('./load-apis');
|
|
16
|
-
const loadPlugins = require('./load-plugins');
|
|
17
|
-
const loadMiddlewares = require('./load-middlewares');
|
|
18
|
-
const loadExtensions = require('./load-extensions');
|
|
19
|
-
const loadComponents = require('./load-components');
|
|
20
|
-
|
|
21
|
-
module.exports = async strapi => {
|
|
22
|
-
const [api, plugins, middlewares, extensions, components] = await Promise.all([
|
|
23
|
-
loadApis(strapi),
|
|
24
|
-
loadPlugins(strapi),
|
|
25
|
-
loadMiddlewares(strapi),
|
|
26
|
-
loadExtensions(strapi.config),
|
|
27
|
-
loadComponents(strapi),
|
|
28
|
-
]);
|
|
29
|
-
|
|
30
|
-
// TODO: move this into the appropriate loaders
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Handle plugin extensions
|
|
34
|
-
*/
|
|
35
|
-
// merge extensions config folders
|
|
36
|
-
_.mergeWith(plugins, extensions.merges, (objValue, srcValue, key) => {
|
|
37
|
-
// concat routes
|
|
38
|
-
if (_.isArray(srcValue) && _.isArray(objValue) && key === 'routes') {
|
|
39
|
-
return srcValue.concat(objValue);
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
// overwrite plugins with extensions overwrites
|
|
44
|
-
extensions.overwrites.forEach(({ path, mod }) => {
|
|
45
|
-
_.assign(_.get(plugins, path), mod);
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
return {
|
|
49
|
-
api,
|
|
50
|
-
plugins,
|
|
51
|
-
middlewares,
|
|
52
|
-
extensions,
|
|
53
|
-
components,
|
|
54
|
-
};
|
|
55
|
-
};
|
package/lib/core/load-plugins.js
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const { join } = require('path');
|
|
4
|
-
const { existsSync } = require('fs-extra');
|
|
5
|
-
const _ = require('lodash');
|
|
6
|
-
const findPackagePath = require('../load/package-path');
|
|
7
|
-
const loadFiles = require('../load/load-files');
|
|
8
|
-
const loadConfig = require('../load/load-config-files');
|
|
9
|
-
|
|
10
|
-
module.exports = async ({ dir, config }) => {
|
|
11
|
-
const localPlugins = await loadLocalPlugins({ dir, config });
|
|
12
|
-
const plugins = await loadPlugins({
|
|
13
|
-
installedPlugins: config.installedPlugins,
|
|
14
|
-
config,
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
const pluginsIntersection = _.intersection(Object.keys(localPlugins), Object.keys(plugins));
|
|
18
|
-
|
|
19
|
-
if (pluginsIntersection.length > 0) {
|
|
20
|
-
throw new Error(
|
|
21
|
-
`You have some local plugins with the same name as npm installed plugins:\n${pluginsIntersection
|
|
22
|
-
.map(p => `- ${p}`)
|
|
23
|
-
.join('\n')}`
|
|
24
|
-
);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
// check for conflicts
|
|
28
|
-
return _.merge(plugins, localPlugins);
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
const loadLocalPlugins = async ({ dir, config }) => {
|
|
32
|
-
const pluginsDir = join(dir, 'plugins');
|
|
33
|
-
|
|
34
|
-
if (!existsSync(pluginsDir)) return {};
|
|
35
|
-
|
|
36
|
-
const [files, configs] = await Promise.all([
|
|
37
|
-
loadFiles(pluginsDir, '{*/!(config)/*.*(js|json),*/package.json}'),
|
|
38
|
-
loadConfig(pluginsDir, '*/config/**/*.+(js|json)'),
|
|
39
|
-
]);
|
|
40
|
-
const userConfigs = Object.keys(files).reduce((acc, plugin) => {
|
|
41
|
-
acc[plugin] = { config: config.get(['plugins', plugin], {}) };
|
|
42
|
-
return acc;
|
|
43
|
-
}, {});
|
|
44
|
-
return _.merge(files, configs, userConfigs);
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
const loadPlugins = async ({ installedPlugins, config }) => {
|
|
48
|
-
let plugins = {};
|
|
49
|
-
|
|
50
|
-
for (let plugin of installedPlugins) {
|
|
51
|
-
const pluginPath = findPackagePath(`@strapi/plugin-${plugin}`);
|
|
52
|
-
|
|
53
|
-
const files = await loadFiles(
|
|
54
|
-
pluginPath,
|
|
55
|
-
'{!(config|node_modules|tests)/*.*(js|json),package.json}'
|
|
56
|
-
);
|
|
57
|
-
|
|
58
|
-
const { config: pluginConfig } = await loadConfig(pluginPath);
|
|
59
|
-
|
|
60
|
-
const userConfig = config.get(['plugins', plugin], {});
|
|
61
|
-
|
|
62
|
-
const mergedConfig = _.merge(pluginConfig, userConfig);
|
|
63
|
-
|
|
64
|
-
_.set(plugins, plugin, _.assign({}, files, { config: mergedConfig }));
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
return plugins;
|
|
68
|
-
};
|