@strapi/strapi 0.0.0-d0fee44d6f → 0.0.0-d36609ff26fb4e00a41a7e2b657f16c7466203fe
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 +25 -12
- package/bin/strapi.js +29 -26
- package/lib/Strapi.js +37 -16
- package/lib/commands/admin-create.js +3 -6
- package/lib/commands/admin-reset.js +1 -1
- package/lib/commands/build.js +1 -1
- package/lib/commands/builders/admin.js +2 -1
- package/lib/commands/builders/typescript.js +2 -2
- package/lib/commands/configurationDump.js +4 -4
- package/lib/commands/configurationRestore.js +5 -4
- package/lib/commands/console.js +1 -1
- package/lib/commands/content-types/list.js +2 -2
- package/lib/commands/controllers/list.js +2 -2
- package/lib/commands/develop.js +16 -10
- package/lib/commands/hooks/list.js +2 -2
- package/lib/commands/install.js +4 -4
- package/lib/commands/middlewares/list.js +2 -2
- package/lib/commands/new.js +1 -1
- package/lib/commands/opt-in-telemetry.js +14 -15
- package/lib/commands/opt-out-telemetry.js +5 -5
- package/lib/commands/policies/list.js +2 -2
- package/lib/commands/routes/list.js +3 -3
- package/lib/commands/services/list.js +2 -2
- package/lib/commands/start.js +1 -0
- package/lib/commands/ts/generate-types.js +1 -1
- package/lib/commands/uninstall.js +4 -4
- package/lib/commands/watchAdmin.js +1 -1
- package/lib/compile.js +1 -1
- package/lib/container.js +1 -1
- package/lib/core/app-configuration/config-loader.js +2 -2
- package/lib/core/app-configuration/load-config-file.js +4 -6
- package/lib/core/bootstrap.js +1 -1
- package/lib/core/domain/component/validator.js +3 -9
- package/lib/core/domain/content-type/index.js +3 -3
- package/lib/core/domain/content-type/validator.js +9 -23
- package/lib/core/domain/module/index.js +1 -1
- package/lib/core/domain/module/validation.js +3 -4
- package/lib/core/loaders/admin.js +1 -1
- package/lib/core/loaders/apis.js +26 -34
- package/lib/core/loaders/components.js +2 -2
- package/lib/core/loaders/middlewares.js +2 -3
- package/lib/core/loaders/plugins/get-enabled-plugins.js +10 -8
- package/lib/core/loaders/plugins/index.js +12 -13
- package/lib/core/loaders/policies.js +1 -2
- package/lib/core/loaders/sanitizers.js +1 -1
- package/lib/core/loaders/src-index.js +3 -5
- package/lib/core/registries/apis.js +1 -1
- package/lib/core/registries/config.js +1 -1
- package/lib/core/registries/content-types.js +3 -3
- package/lib/core/registries/controllers.js +2 -2
- package/lib/core/registries/custom-fields.js +72 -0
- package/lib/core/registries/hooks.js +1 -1
- package/lib/core/registries/middlewares.js +2 -2
- package/lib/core/registries/modules.js +1 -1
- package/lib/core/registries/plugins.js +1 -1
- package/lib/core/registries/policies.js +1 -1
- package/lib/core/registries/services.js +3 -3
- package/lib/core/utils.js +3 -6
- package/lib/core-api/controller/transform.js +5 -5
- package/lib/core-api/service/collection-type.js +1 -1
- package/lib/core-api/service/index.d.ts +6 -3
- package/lib/core-api/service/pagination.js +5 -5
- package/lib/core-api/service/single-type.js +14 -1
- package/lib/factories.js +5 -5
- package/lib/load/filepath-to-prop-path.js +2 -2
- package/lib/load/load-files.js +2 -2
- package/lib/load/package-path.js +1 -1
- package/lib/middlewares/body.js +10 -3
- package/lib/middlewares/compression.js +1 -1
- package/lib/middlewares/cors.js +3 -10
- package/lib/middlewares/favicon.js +16 -3
- package/lib/middlewares/ip.js +1 -1
- package/lib/middlewares/logger.js +4 -1
- package/lib/middlewares/powered-by.js +1 -1
- package/lib/middlewares/query.js +8 -2
- package/lib/middlewares/response-time.js +1 -1
- package/lib/middlewares/responses.js +1 -1
- package/lib/middlewares/security.js +22 -16
- package/lib/middlewares/session.js +2 -2
- package/lib/migrations/draft-publish.js +1 -5
- package/lib/services/auth/index.js +5 -4
- package/lib/services/content-api/index.js +74 -0
- package/lib/services/content-api/permissions/engine.js +5 -0
- package/lib/services/content-api/permissions/index.js +148 -0
- package/lib/services/content-api/permissions/providers/action.js +19 -0
- package/lib/services/content-api/permissions/providers/condition.js +19 -0
- package/lib/services/content-api/permissions/providers/index.js +9 -0
- package/lib/services/core-store.js +4 -4
- package/lib/services/cron.js +1 -1
- package/lib/services/custom-fields.js +11 -0
- package/lib/services/entity-service/components.js +51 -54
- package/lib/services/entity-service/index.js +117 -93
- package/lib/services/entity-service/params.js +1 -87
- package/lib/services/entity-validator/index.js +284 -122
- package/lib/services/entity-validator/validators.js +18 -15
- package/lib/services/errors.js +10 -10
- package/lib/services/event-hub.js +1 -0
- package/lib/services/fs.js +1 -1
- package/lib/services/metrics/admin-user-hash.js +15 -0
- package/lib/services/metrics/index.js +12 -13
- package/lib/services/metrics/is-truthy.js +1 -1
- package/lib/services/metrics/middleware.js +2 -2
- package/lib/services/metrics/sender.js +22 -12
- package/lib/services/metrics/stringify-deep.js +1 -1
- package/lib/services/request-context.js +17 -0
- package/lib/services/server/admin-api.js +1 -1
- package/lib/services/server/compose-endpoint.js +7 -7
- package/lib/services/server/content-api.js +1 -1
- package/lib/services/server/http-server.js +9 -9
- package/lib/services/server/index.js +7 -4
- package/lib/services/server/koa.js +9 -12
- package/lib/services/server/middleware.js +3 -2
- package/lib/services/server/policy.js +1 -1
- package/lib/services/server/register-middlewares.js +6 -8
- package/lib/services/server/register-routes.js +13 -13
- package/lib/services/server/routing.js +11 -26
- package/lib/services/utils/upload-files.js +4 -4
- package/lib/services/webhook-runner.js +8 -7
- package/lib/services/webhook-store.js +3 -2
- package/lib/services/worker-queue.js +3 -2
- package/lib/types/core/attributes/common.d.ts +3 -0
- package/lib/types/core/strapi/index.d.ts +50 -10
- package/lib/types/factories.d.ts +4 -4
- package/lib/utils/addSlash.js +7 -6
- package/lib/utils/convert-custom-field-type.js +22 -0
- package/lib/utils/ee.js +1 -1
- package/lib/utils/index.js +0 -2
- package/lib/utils/open-browser.js +1 -1
- package/lib/utils/run-checks.js +4 -4
- package/lib/utils/signals.js +2 -2
- package/lib/utils/startup-logger.js +2 -2
- package/lib/utils/success.js +2 -2
- package/lib/utils/update-notifier/index.js +4 -4
- package/package.json +21 -20
- package/lib/utils/import-default.js +0 -10
package/README.md
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
<p align="center">
|
|
2
|
-
<a href="https://strapi.io">
|
|
2
|
+
<a href="https://strapi.io/#gh-light-mode-only">
|
|
3
3
|
<img src="https://strapi.io/assets/strapi-logo-dark.svg" width="318px" alt="Strapi logo" />
|
|
4
4
|
</a>
|
|
5
|
+
<a href="https://strapi.io/#gh-dark-mode-only">
|
|
6
|
+
<img src="https://strapi.io/assets/strapi-logo-light.svg" width="318px" alt="Strapi logo" />
|
|
7
|
+
</a>
|
|
5
8
|
</p>
|
|
9
|
+
|
|
6
10
|
<h3 align="center">API creation made simple, secure and fast.</h3>
|
|
7
11
|
<p align="center">The most advanced open-source headless CMS to build powerful APIs with no effort.</p>
|
|
8
12
|
<p align="center"><a href="https://strapi.io/demo">Try live demo</a></p>
|
|
@@ -13,11 +17,14 @@
|
|
|
13
17
|
<img src="https://img.shields.io/npm/v/@strapi/strapi/latest.svg" alt="NPM Version" />
|
|
14
18
|
</a>
|
|
15
19
|
<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=
|
|
20
|
+
<img src="https://github.com/strapi/strapi/actions/workflows/tests.yml/badge.svg?branch=main" alt="Tests" />
|
|
17
21
|
</a>
|
|
18
22
|
<a href="https://discord.strapi.io">
|
|
19
23
|
<img src="https://img.shields.io/discord/811989166782021633?label=Discord" alt="Strapi on Discord" />
|
|
20
24
|
</a>
|
|
25
|
+
<a href="https://github.com/strapi/strapi/actions/workflows/nightly.yml">
|
|
26
|
+
<img src="https://github.com/strapi/strapi/actions/workflows/nightly.yml/badge.svg" alt="Strapi Nightly Release Build Status" />
|
|
27
|
+
</a>
|
|
21
28
|
</p>
|
|
22
29
|
|
|
23
30
|
<br>
|
|
@@ -73,23 +80,29 @@ Complete installation requirements can be found in the documentation under <a hr
|
|
|
73
80
|
- CentOS/RHEL 8
|
|
74
81
|
- macOS Mojave
|
|
75
82
|
- Windows 10
|
|
76
|
-
- Docker
|
|
83
|
+
- Docker
|
|
77
84
|
|
|
78
85
|
(Please note that Strapi may work on other operating systems, but these are not tested nor officially supported at this time.)
|
|
79
86
|
|
|
80
87
|
**Node:**
|
|
81
88
|
|
|
82
|
-
|
|
83
|
-
|
|
89
|
+
Strapi only supports maintenance and LTS versions of Node.js. Please refer to the <a href="https://nodejs.org/en/about/releases/">Node.js release schedule</a> for more information. NPM versions installed by default with Node.js are supported. Generally it's recommended to use yarn over npm where possible.
|
|
90
|
+
|
|
91
|
+
| Strapi Version | Recommended | Minimum |
|
|
92
|
+
| -------------- | ----------- | ------- |
|
|
93
|
+
| 4.3.9 and up | 18.x | 14.x |
|
|
94
|
+
| 4.0.x to 4.3.8 | 16.x | 14.x |
|
|
84
95
|
|
|
85
96
|
**Database:**
|
|
86
97
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
98
|
+
| Database | Minimum | Recommended |
|
|
99
|
+
| ---------- | ------- | ----------- |
|
|
100
|
+
| MySQL | 5.7.8 | 8.0 |
|
|
101
|
+
| MariaDB | 10.3 | 10.6 |
|
|
102
|
+
| PostgreSQL | 11.0 | 14.0 |
|
|
103
|
+
| SQLite | 3 | 3 |
|
|
91
104
|
|
|
92
|
-
**We recommend always using the latest version of Strapi to start your new projects**.
|
|
105
|
+
**We recommend always using the latest version of Strapi stable to start your new projects**.
|
|
93
106
|
|
|
94
107
|
## Features
|
|
95
108
|
|
|
@@ -114,7 +127,7 @@ For general help using Strapi, please refer to [the official Strapi documentatio
|
|
|
114
127
|
- [Discord](https://discord.strapi.io) (For live discussion with the Community and Strapi team)
|
|
115
128
|
- [GitHub](https://github.com/strapi/strapi) (Bug reports, Contributions)
|
|
116
129
|
- [Community Forum](https://forum.strapi.io) (Questions and Discussions)
|
|
117
|
-
- [
|
|
130
|
+
- [Feedback section](https://feedback.strapi.io) (Roadmap, Feature requests)
|
|
118
131
|
- [Twitter](https://twitter.com/strapijs) (Get the news fast)
|
|
119
132
|
- [Facebook](https://www.facebook.com/Strapi-616063331867161)
|
|
120
133
|
- [YouTube Channel](https://www.youtube.com/strapi) (Learn from Video Tutorials)
|
|
@@ -125,7 +138,7 @@ Follow our [migration guides](https://docs.strapi.io/developer-docs/latest/updat
|
|
|
125
138
|
|
|
126
139
|
## Roadmap
|
|
127
140
|
|
|
128
|
-
Check out our [roadmap](https://feedback.strapi.io
|
|
141
|
+
Check out our [roadmap](https://feedback.strapi.io) to get informed of the latest features released and the upcoming ones. You may also give us insights and vote for a specific feature.
|
|
129
142
|
|
|
130
143
|
## Documentation
|
|
131
144
|
|
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
|
-
|
|
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()
|
|
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 =
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
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
|
-
|
|
51
|
+
const script = require(cmdPath);
|
|
49
52
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
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
|
|
75
|
+
process.stdout.write(`${packageJSON.version}\n`);
|
|
73
76
|
process.exit(0);
|
|
74
77
|
});
|
|
75
78
|
|
package/lib/Strapi.js
CHANGED
|
@@ -21,7 +21,10 @@ const createEntityService = require('./services/entity-service');
|
|
|
21
21
|
const createCronService = require('./services/cron');
|
|
22
22
|
const entityValidator = require('./services/entity-validator');
|
|
23
23
|
const createTelemetry = require('./services/metrics');
|
|
24
|
+
const requestContext = require('./services/request-context');
|
|
24
25
|
const createAuth = require('./services/auth');
|
|
26
|
+
const createCustomFields = require('./services/custom-fields');
|
|
27
|
+
const createContentAPI = require('./services/content-api');
|
|
25
28
|
const createUpdateNotifier = require('./utils/update-notifier');
|
|
26
29
|
const createStartupLogger = require('./utils/startup-logger');
|
|
27
30
|
const { LIFECYCLES } = require('./utils/lifecycles');
|
|
@@ -34,12 +37,14 @@ const hooksRegistry = require('./core/registries/hooks');
|
|
|
34
37
|
const controllersRegistry = require('./core/registries/controllers');
|
|
35
38
|
const modulesRegistry = require('./core/registries/modules');
|
|
36
39
|
const pluginsRegistry = require('./core/registries/plugins');
|
|
40
|
+
const customFieldsRegistry = require('./core/registries/custom-fields');
|
|
37
41
|
const createConfigProvider = require('./core/registries/config');
|
|
38
42
|
const apisRegistry = require('./core/registries/apis');
|
|
39
43
|
const bootstrap = require('./core/bootstrap');
|
|
40
44
|
const loaders = require('./core/loaders');
|
|
41
45
|
const { destroyOnSignal } = require('./utils/signals');
|
|
42
46
|
const sanitizersRegistry = require('./core/registries/sanitizers');
|
|
47
|
+
const convertCustomFieldType = require('./utils/convert-custom-field-type');
|
|
43
48
|
|
|
44
49
|
// TODO: move somewhere else
|
|
45
50
|
const draftAndPublishSync = require('./migrations/draft-publish');
|
|
@@ -55,7 +60,7 @@ const draftAndPublishSync = require('./migrations/draft-publish');
|
|
|
55
60
|
* - If `appDir` is `undefined`, it'll be set to `process.cwd()`
|
|
56
61
|
* - If `distDir` is `undefined`, it'll be set to `appDir`
|
|
57
62
|
*/
|
|
58
|
-
const resolveWorkingDirectories = opts => {
|
|
63
|
+
const resolveWorkingDirectories = (opts) => {
|
|
59
64
|
const cwd = process.cwd();
|
|
60
65
|
|
|
61
66
|
const appDir = opts.appDir ? path.resolve(cwd, opts.appDir) : cwd;
|
|
@@ -74,7 +79,7 @@ class Strapi {
|
|
|
74
79
|
// Load the app configuration from the dist directory
|
|
75
80
|
const appConfig = loadConfiguration({ appDir: rootDirs.app, distDir: rootDirs.dist }, opts);
|
|
76
81
|
|
|
77
|
-
//
|
|
82
|
+
// Instantiate the Strapi container
|
|
78
83
|
this.container = createContainer(this);
|
|
79
84
|
|
|
80
85
|
// Register every Strapi registry in the container
|
|
@@ -87,8 +92,10 @@ class Strapi {
|
|
|
87
92
|
this.container.register('controllers', controllersRegistry(this));
|
|
88
93
|
this.container.register('modules', modulesRegistry(this));
|
|
89
94
|
this.container.register('plugins', pluginsRegistry(this));
|
|
95
|
+
this.container.register('custom-fields', customFieldsRegistry(this));
|
|
90
96
|
this.container.register('apis', apisRegistry(this));
|
|
91
97
|
this.container.register('auth', createAuth(this));
|
|
98
|
+
this.container.register('content-api', createContentAPI(this));
|
|
92
99
|
this.container.register('sanitizers', sanitizersRegistry(this));
|
|
93
100
|
|
|
94
101
|
// Create a mapping of every useful directory (for the app, dist and static directories)
|
|
@@ -98,7 +105,7 @@ class Strapi {
|
|
|
98
105
|
this.isLoaded = false;
|
|
99
106
|
this.reload = this.reload();
|
|
100
107
|
|
|
101
|
-
//
|
|
108
|
+
// Instantiate the Koa app & the HTTP server
|
|
102
109
|
this.server = createServer(this);
|
|
103
110
|
|
|
104
111
|
// Strapi utils instanciation
|
|
@@ -108,6 +115,9 @@ class Strapi {
|
|
|
108
115
|
this.log = createLogger(this.config.get('logger', {}));
|
|
109
116
|
this.cron = createCronService();
|
|
110
117
|
this.telemetry = createTelemetry(this);
|
|
118
|
+
this.requestContext = requestContext;
|
|
119
|
+
|
|
120
|
+
this.customFields = createCustomFields(this);
|
|
111
121
|
|
|
112
122
|
createUpdateNotifier(this).notify();
|
|
113
123
|
}
|
|
@@ -117,7 +127,7 @@ class Strapi {
|
|
|
117
127
|
}
|
|
118
128
|
|
|
119
129
|
get EE() {
|
|
120
|
-
return ee({ dir: this.dirs.
|
|
130
|
+
return ee({ dir: this.dirs.app.root, logger: this.log });
|
|
121
131
|
}
|
|
122
132
|
|
|
123
133
|
get services() {
|
|
@@ -188,6 +198,10 @@ class Strapi {
|
|
|
188
198
|
return this.container.get('auth');
|
|
189
199
|
}
|
|
190
200
|
|
|
201
|
+
get contentAPI() {
|
|
202
|
+
return this.container.get('content-api');
|
|
203
|
+
}
|
|
204
|
+
|
|
191
205
|
get sanitizers() {
|
|
192
206
|
return this.container.get('sanitizers');
|
|
193
207
|
}
|
|
@@ -228,11 +242,14 @@ class Strapi {
|
|
|
228
242
|
sendStartupTelemetry() {
|
|
229
243
|
// Emit started event.
|
|
230
244
|
// do not await to avoid slower startup
|
|
245
|
+
// This event is anonymous
|
|
231
246
|
this.telemetry.send('didStartServer', {
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
247
|
+
groupProperties: {
|
|
248
|
+
database: strapi.config.get('database.connection.client'),
|
|
249
|
+
plugins: Object.keys(strapi.plugins),
|
|
250
|
+
// TODO: to add back
|
|
251
|
+
// providers: this.config.installedProviders,
|
|
252
|
+
},
|
|
236
253
|
});
|
|
237
254
|
}
|
|
238
255
|
|
|
@@ -265,7 +282,7 @@ class Strapi {
|
|
|
265
282
|
*/
|
|
266
283
|
async listen() {
|
|
267
284
|
return new Promise((resolve, reject) => {
|
|
268
|
-
const onListen = async error => {
|
|
285
|
+
const onListen = async (error) => {
|
|
269
286
|
if (error) {
|
|
270
287
|
return reject(error);
|
|
271
288
|
}
|
|
@@ -282,11 +299,11 @@ class Strapi {
|
|
|
282
299
|
const listenSocket = this.config.get('server.socket');
|
|
283
300
|
|
|
284
301
|
if (listenSocket) {
|
|
285
|
-
|
|
302
|
+
this.server.listen(listenSocket, onListen);
|
|
303
|
+
} else {
|
|
304
|
+
const { host, port } = this.config.get('server');
|
|
305
|
+
this.server.listen(port, host, onListen);
|
|
286
306
|
}
|
|
287
|
-
|
|
288
|
-
const { host, port } = this.config.get('server');
|
|
289
|
-
return this.server.listen(port, host, onListen);
|
|
290
307
|
});
|
|
291
308
|
}
|
|
292
309
|
|
|
@@ -377,6 +394,8 @@ class Strapi {
|
|
|
377
394
|
this.telemetry.register();
|
|
378
395
|
|
|
379
396
|
await this.runLifecyclesFunctions(LIFECYCLES.REGISTER);
|
|
397
|
+
// NOTE: Swap type customField for underlying data type
|
|
398
|
+
convertCustomFieldType(this);
|
|
380
399
|
|
|
381
400
|
return this;
|
|
382
401
|
}
|
|
@@ -445,6 +464,8 @@ class Strapi {
|
|
|
445
464
|
await this.server.initMiddlewares();
|
|
446
465
|
await this.server.initRouting();
|
|
447
466
|
|
|
467
|
+
await this.contentAPI.permissions.registerActions();
|
|
468
|
+
|
|
448
469
|
await this.runLifecyclesFunctions(LIFECYCLES.BOOTSTRAP);
|
|
449
470
|
|
|
450
471
|
this.cron.start();
|
|
@@ -463,7 +484,7 @@ class Strapi {
|
|
|
463
484
|
|
|
464
485
|
async startWebhooks() {
|
|
465
486
|
const webhooks = await this.webhookStore.findWebhooks();
|
|
466
|
-
webhooks.forEach(webhook => this.webhookRunner.add(webhook));
|
|
487
|
+
webhooks.forEach((webhook) => this.webhookRunner.add(webhook));
|
|
467
488
|
}
|
|
468
489
|
|
|
469
490
|
reload() {
|
|
@@ -471,7 +492,7 @@ class Strapi {
|
|
|
471
492
|
shouldReload: 0,
|
|
472
493
|
};
|
|
473
494
|
|
|
474
|
-
const reload = function() {
|
|
495
|
+
const reload = function () {
|
|
475
496
|
if (state.shouldReload > 0) {
|
|
476
497
|
// Reset the reloading state
|
|
477
498
|
state.shouldReload -= 1;
|
|
@@ -535,7 +556,7 @@ class Strapi {
|
|
|
535
556
|
}
|
|
536
557
|
}
|
|
537
558
|
|
|
538
|
-
module.exports = options => {
|
|
559
|
+
module.exports = (options) => {
|
|
539
560
|
const strapi = new Strapi(options);
|
|
540
561
|
global.strapi = strapi;
|
|
541
562
|
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()
|
|
@@ -20,7 +17,7 @@ const passwordValidator = yup
|
|
|
20
17
|
const adminCreateSchema = yup.object().shape({
|
|
21
18
|
email: emailValidator,
|
|
22
19
|
password: passwordValidator,
|
|
23
|
-
firstname: yup.string().required('First name is required'),
|
|
20
|
+
firstname: yup.string().trim().required('First name is required'),
|
|
24
21
|
lastname: yup.string(),
|
|
25
22
|
});
|
|
26
23
|
|
|
@@ -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) {
|
package/lib/commands/build.js
CHANGED
|
@@ -44,12 +44,13 @@ 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(() => {
|
|
50
51
|
console.log('Admin UI built successfully');
|
|
51
52
|
})
|
|
52
|
-
.catch(err => {
|
|
53
|
+
.catch((err) => {
|
|
53
54
|
console.error(err);
|
|
54
55
|
process.exit(1);
|
|
55
56
|
});
|
|
@@ -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
|
|
12
|
+
module.exports = async ({ file: filePath, pretty }) => {
|
|
13
13
|
const output = filePath ? fs.createWriteStream(filePath) : process.stdout;
|
|
14
14
|
|
|
15
15
|
const appContext = await strapi.compile();
|
|
@@ -21,14 +21,14 @@ module.exports = async function({ file: filePath, pretty }) {
|
|
|
21
21
|
|
|
22
22
|
const pageCount = Math.ceil(count / CHUNK_SIZE);
|
|
23
23
|
|
|
24
|
-
for (let page = 0; page < pageCount; page
|
|
24
|
+
for (let page = 0; page < pageCount; page += 1) {
|
|
25
25
|
const results = await app
|
|
26
26
|
.query('strapi::core-store')
|
|
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
|
|
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,
|
package/lib/commands/console.js
CHANGED
|
@@ -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
|
|
package/lib/commands/develop.js
CHANGED
|
@@ -18,7 +18,7 @@ const { buildTypeScript, buildAdmin } = require('./builders');
|
|
|
18
18
|
*
|
|
19
19
|
*/
|
|
20
20
|
|
|
21
|
-
module.exports = async
|
|
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
|
-
|
|
100
|
-
|
|
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
|
|
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
|
-
|
|
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
|
|
package/lib/commands/install.js
CHANGED
|
@@ -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 (
|
|
32
|
-
|
|
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
|
}
|