@strapi/strapi 4.3.4 → 4.4.0-alpha.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 +1 -1
- package/bin/strapi.js +29 -26
- package/lib/Strapi.js +17 -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/custom-fields.js +54 -0
- 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/custom-fields.js +11 -0
- package/lib/services/entity-service/components.js +12 -18
- package/lib/services/entity-service/index.js +65 -51
- 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 +4 -4
- 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/convert-custom-field-type.js +22 -0
- 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
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
<img src="https://img.shields.io/npm/v/@strapi/strapi/latest.svg" alt="NPM Version" />
|
|
14
14
|
</a>
|
|
15
15
|
<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=
|
|
16
|
+
<img src="https://github.com/strapi/strapi/actions/workflows/tests.yml/badge.svg?branch=main" alt="Tests" />
|
|
17
17
|
</a>
|
|
18
18
|
<a href="https://discord.strapi.io">
|
|
19
19
|
<img src="https://img.shields.io/discord/811989166782021633?label=Discord" alt="Strapi on Discord" />
|
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
|
@@ -22,6 +22,7 @@ const createCronService = require('./services/cron');
|
|
|
22
22
|
const entityValidator = require('./services/entity-validator');
|
|
23
23
|
const createTelemetry = require('./services/metrics');
|
|
24
24
|
const createAuth = require('./services/auth');
|
|
25
|
+
const createCustomFields = require('./services/custom-fields');
|
|
25
26
|
const createUpdateNotifier = require('./utils/update-notifier');
|
|
26
27
|
const createStartupLogger = require('./utils/startup-logger');
|
|
27
28
|
const { LIFECYCLES } = require('./utils/lifecycles');
|
|
@@ -34,12 +35,14 @@ const hooksRegistry = require('./core/registries/hooks');
|
|
|
34
35
|
const controllersRegistry = require('./core/registries/controllers');
|
|
35
36
|
const modulesRegistry = require('./core/registries/modules');
|
|
36
37
|
const pluginsRegistry = require('./core/registries/plugins');
|
|
38
|
+
const customFieldsRegistry = require('./core/registries/custom-fields');
|
|
37
39
|
const createConfigProvider = require('./core/registries/config');
|
|
38
40
|
const apisRegistry = require('./core/registries/apis');
|
|
39
41
|
const bootstrap = require('./core/bootstrap');
|
|
40
42
|
const loaders = require('./core/loaders');
|
|
41
43
|
const { destroyOnSignal } = require('./utils/signals');
|
|
42
44
|
const sanitizersRegistry = require('./core/registries/sanitizers');
|
|
45
|
+
const convertCustomFieldType = require('./utils/convert-custom-field-type');
|
|
43
46
|
|
|
44
47
|
// TODO: move somewhere else
|
|
45
48
|
const draftAndPublishSync = require('./migrations/draft-publish');
|
|
@@ -55,7 +58,7 @@ const draftAndPublishSync = require('./migrations/draft-publish');
|
|
|
55
58
|
* - If `appDir` is `undefined`, it'll be set to `process.cwd()`
|
|
56
59
|
* - If `distDir` is `undefined`, it'll be set to `appDir`
|
|
57
60
|
*/
|
|
58
|
-
const resolveWorkingDirectories = opts => {
|
|
61
|
+
const resolveWorkingDirectories = (opts) => {
|
|
59
62
|
const cwd = process.cwd();
|
|
60
63
|
|
|
61
64
|
const appDir = opts.appDir ? path.resolve(cwd, opts.appDir) : cwd;
|
|
@@ -87,6 +90,7 @@ class Strapi {
|
|
|
87
90
|
this.container.register('controllers', controllersRegistry(this));
|
|
88
91
|
this.container.register('modules', modulesRegistry(this));
|
|
89
92
|
this.container.register('plugins', pluginsRegistry(this));
|
|
93
|
+
this.container.register('custom-fields', customFieldsRegistry(this));
|
|
90
94
|
this.container.register('apis', apisRegistry(this));
|
|
91
95
|
this.container.register('auth', createAuth(this));
|
|
92
96
|
this.container.register('sanitizers', sanitizersRegistry(this));
|
|
@@ -109,6 +113,8 @@ class Strapi {
|
|
|
109
113
|
this.cron = createCronService();
|
|
110
114
|
this.telemetry = createTelemetry(this);
|
|
111
115
|
|
|
116
|
+
this.customFields = createCustomFields(this);
|
|
117
|
+
|
|
112
118
|
createUpdateNotifier(this).notify();
|
|
113
119
|
}
|
|
114
120
|
|
|
@@ -265,7 +271,7 @@ class Strapi {
|
|
|
265
271
|
*/
|
|
266
272
|
async listen() {
|
|
267
273
|
return new Promise((resolve, reject) => {
|
|
268
|
-
const onListen = async error => {
|
|
274
|
+
const onListen = async (error) => {
|
|
269
275
|
if (error) {
|
|
270
276
|
return reject(error);
|
|
271
277
|
}
|
|
@@ -282,11 +288,11 @@ class Strapi {
|
|
|
282
288
|
const listenSocket = this.config.get('server.socket');
|
|
283
289
|
|
|
284
290
|
if (listenSocket) {
|
|
285
|
-
|
|
291
|
+
this.server.listen(listenSocket, onListen);
|
|
292
|
+
} else {
|
|
293
|
+
const { host, port } = this.config.get('server');
|
|
294
|
+
this.server.listen(port, host, onListen);
|
|
286
295
|
}
|
|
287
|
-
|
|
288
|
-
const { host, port } = this.config.get('server');
|
|
289
|
-
return this.server.listen(port, host, onListen);
|
|
290
296
|
});
|
|
291
297
|
}
|
|
292
298
|
|
|
@@ -454,6 +460,8 @@ class Strapi {
|
|
|
454
460
|
|
|
455
461
|
async load() {
|
|
456
462
|
await this.register();
|
|
463
|
+
// Swap type customField for underlying data type
|
|
464
|
+
convertCustomFieldType(this);
|
|
457
465
|
await this.bootstrap();
|
|
458
466
|
|
|
459
467
|
this.isLoaded = true;
|
|
@@ -463,7 +471,7 @@ class Strapi {
|
|
|
463
471
|
|
|
464
472
|
async startWebhooks() {
|
|
465
473
|
const webhooks = await this.webhookStore.findWebhooks();
|
|
466
|
-
webhooks.forEach(webhook => this.webhookRunner.add(webhook));
|
|
474
|
+
webhooks.forEach((webhook) => this.webhookRunner.add(webhook));
|
|
467
475
|
}
|
|
468
476
|
|
|
469
477
|
reload() {
|
|
@@ -471,7 +479,7 @@ class Strapi {
|
|
|
471
479
|
shouldReload: 0,
|
|
472
480
|
};
|
|
473
481
|
|
|
474
|
-
const reload = function() {
|
|
482
|
+
const reload = function () {
|
|
475
483
|
if (state.shouldReload > 0) {
|
|
476
484
|
// Reset the reloading state
|
|
477
485
|
state.shouldReload -= 1;
|
|
@@ -535,7 +543,7 @@ class Strapi {
|
|
|
535
543
|
}
|
|
536
544
|
}
|
|
537
545
|
|
|
538
|
-
module.exports = options => {
|
|
546
|
+
module.exports = (options) => {
|
|
539
547
|
const strapi = new Strapi(options);
|
|
540
548
|
global.strapi = strapi;
|
|
541
549
|
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
|
|
|
@@ -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
|
|