@strapi/strapi 4.3.4 → 4.3.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/README.md +18 -9
- package/bin/strapi.js +29 -26
- package/lib/Strapi.js +9 -9
- package/lib/commands/admin-create.js +2 -5
- package/lib/commands/admin-reset.js +1 -1
- package/lib/commands/build.js +1 -1
- package/lib/commands/builders/admin.js +1 -1
- package/lib/commands/builders/typescript.js +2 -2
- package/lib/commands/configurationDump.js +3 -3
- 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 +12 -13
- package/lib/commands/opt-out-telemetry.js +3 -3
- 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 +3 -3
- package/lib/core/bootstrap.js +1 -1
- package/lib/core/domain/component/validator.js +3 -9
- package/lib/core/domain/content-type/index.js +2 -2
- 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 +22 -30
- package/lib/core/loaders/components.js +2 -2
- package/lib/core/loaders/middlewares.js +1 -1
- package/lib/core/loaders/plugins/get-enabled-plugins.js +7 -7
- package/lib/core/loaders/plugins/index.js +7 -8
- package/lib/core/loaders/sanitizers.js +1 -1
- package/lib/core/loaders/src-index.js +2 -2
- package/lib/core/registries/apis.js +1 -1
- package/lib/core/registries/config.js +1 -1
- package/lib/core/registries/content-types.js +1 -1
- package/lib/core/registries/modules.js +1 -1
- package/lib/core/registries/plugins.js +1 -1
- package/lib/core/registries/services.js +1 -1
- package/lib/core/utils.js +3 -6
- package/lib/core-api/controller/transform.js +4 -4
- 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/factories.js +5 -5
- package/lib/load/filepath-to-prop-path.js +2 -2
- package/lib/load/load-files.js +1 -1
- 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/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 +1 -3
- package/lib/services/core-store.js +4 -4
- package/lib/services/entity-service/components.js +34 -20
- package/lib/services/entity-service/index.js +73 -52
- package/lib/services/entity-validator/index.js +134 -127
- package/lib/services/entity-validator/validators.js +18 -15
- package/lib/services/errors.js +6 -10
- package/lib/services/event-hub.js +1 -0
- package/lib/services/fs.js +1 -1
- package/lib/services/metrics/index.js +6 -9
- package/lib/services/metrics/is-truthy.js +1 -1
- package/lib/services/metrics/sender.js +6 -6
- package/lib/services/metrics/stringify-deep.js +1 -1
- 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 +4 -4
- package/lib/services/server/koa.js +9 -12
- package/lib/services/server/middleware.js +1 -1
- package/lib/services/server/policy.js +1 -1
- package/lib/services/server/register-middlewares.js +6 -8
- package/lib/services/server/register-routes.js +11 -11
- package/lib/services/server/routing.js +11 -26
- package/lib/services/utils/upload-files.js +3 -3
- package/lib/services/webhook-runner.js +8 -7
- package/lib/services/webhook-store.js +3 -2
- package/lib/services/worker-queue.js +1 -0
- package/lib/types/core/strapi/index.d.ts +4 -3
- package/lib/types/factories.d.ts +3 -3
- package/lib/utils/addSlash.js +3 -3
- package/lib/utils/ee.js +1 -1
- package/lib/utils/import-default.js +1 -1
- 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 +1 -1
- package/lib/utils/update-notifier/index.js +4 -4
- package/package.json +15 -15
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>
|
|
@@ -79,15 +86,17 @@ Complete installation requirements can be found in the documentation under <a hr
|
|
|
79
86
|
|
|
80
87
|
**Node:**
|
|
81
88
|
|
|
82
|
-
- NodeJS >=
|
|
89
|
+
- NodeJS >= 14 <= 16
|
|
83
90
|
- NPM >= 6.x
|
|
84
91
|
|
|
85
92
|
**Database:**
|
|
86
93
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
94
|
+
| Database | Minimum | Recommended |
|
|
95
|
+
| ---------- | ------- | ----------- |
|
|
96
|
+
| MySQL | 5.7.8 | 8.0 |
|
|
97
|
+
| MariaDB | 10.3 | 10.6 |
|
|
98
|
+
| PostgreSQL | 11.0 | 14.0 |
|
|
99
|
+
| SQLite | 3 | 3 |
|
|
91
100
|
|
|
92
101
|
**We recommend always using the latest version of Strapi to start your new projects**.
|
|
93
102
|
|
|
@@ -114,7 +123,7 @@ For general help using Strapi, please refer to [the official Strapi documentatio
|
|
|
114
123
|
- [Discord](https://discord.strapi.io) (For live discussion with the Community and Strapi team)
|
|
115
124
|
- [GitHub](https://github.com/strapi/strapi) (Bug reports, Contributions)
|
|
116
125
|
- [Community Forum](https://forum.strapi.io) (Questions and Discussions)
|
|
117
|
-
- [
|
|
126
|
+
- [Feedback section](https://feedback.strapi.io) (Roadmap, Feature requests)
|
|
118
127
|
- [Twitter](https://twitter.com/strapijs) (Get the news fast)
|
|
119
128
|
- [Facebook](https://www.facebook.com/Strapi-616063331867161)
|
|
120
129
|
- [YouTube Channel](https://www.youtube.com/strapi) (Learn from Video Tutorials)
|
|
@@ -125,7 +134,7 @@ Follow our [migration guides](https://docs.strapi.io/developer-docs/latest/updat
|
|
|
125
134
|
|
|
126
135
|
## Roadmap
|
|
127
136
|
|
|
128
|
-
Check out our [roadmap](https://feedback.strapi.io
|
|
137
|
+
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
138
|
|
|
130
139
|
## Documentation
|
|
131
140
|
|
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
|
@@ -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
|
-
|
|
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) {
|
package/lib/commands/build.js
CHANGED
|
@@ -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
|
|
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
|
}
|
|
@@ -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/new.js
CHANGED
|
@@ -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
|
|