@strapi/strapi 4.10.0-beta.1 → 4.10.1-experimental.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/bin/strapi.js +2 -468
- package/coverage/clover.xml +1613 -0
- package/coverage/coverage-final.json +48 -0
- package/coverage/lcov-report/base.css +224 -0
- package/coverage/lcov-report/block-navigation.js +87 -0
- package/coverage/lcov-report/commands/__tests__/data-transfer/shared/index.html +116 -0
- package/coverage/lcov-report/commands/__tests__/data-transfer/shared/transfer.test.utils.js.html +133 -0
- package/coverage/lcov-report/commands/admin-create.js.html +424 -0
- package/coverage/lcov-report/commands/admin-reset.js.html +241 -0
- package/coverage/lcov-report/commands/generate-template.js.html +373 -0
- package/coverage/lcov-report/commands/index.html +146 -0
- package/coverage/lcov-report/commands/transfer/export.js.html +619 -0
- package/coverage/lcov-report/commands/transfer/import.js.html +562 -0
- package/coverage/lcov-report/commands/transfer/index.html +146 -0
- package/coverage/lcov-report/commands/transfer/transfer.js.html +532 -0
- package/coverage/lcov-report/commands/utils/helpers.js.html +430 -0
- package/coverage/lcov-report/commands/utils/index.html +116 -0
- package/coverage/lcov-report/core/registries/custom-fields.js.html +301 -0
- package/coverage/lcov-report/core/registries/index.html +116 -0
- package/coverage/lcov-report/core-api/controller/collection-type.js.html +418 -0
- package/coverage/lcov-report/core-api/controller/index.html +161 -0
- package/coverage/lcov-report/core-api/controller/index.js.html +220 -0
- package/coverage/lcov-report/core-api/controller/single-type.js.html +274 -0
- package/coverage/lcov-report/core-api/controller/transform.js.html +376 -0
- package/coverage/lcov-report/core-api/service/collection-type.js.html +325 -0
- package/coverage/lcov-report/core-api/service/index.html +161 -0
- package/coverage/lcov-report/core-api/service/index.js.html +220 -0
- package/coverage/lcov-report/core-api/service/pagination.js.html +460 -0
- package/coverage/lcov-report/core-api/service/single-type.js.html +301 -0
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +386 -0
- package/coverage/lcov-report/load/filepath-to-prop-path.js.html +151 -0
- package/coverage/lcov-report/load/index.html +116 -0
- package/coverage/lcov-report/prettify.css +1 -0
- package/coverage/lcov-report/prettify.js +2 -0
- package/coverage/lcov-report/services/content-api/index.html +116 -0
- package/coverage/lcov-report/services/content-api/index.js.html +307 -0
- package/coverage/lcov-report/services/content-api/permissions/engine.js.html +100 -0
- package/coverage/lcov-report/services/content-api/permissions/index.html +131 -0
- package/coverage/lcov-report/services/content-api/permissions/index.js.html +529 -0
- package/coverage/lcov-report/services/content-api/permissions/providers/action.js.html +142 -0
- package/coverage/lcov-report/services/content-api/permissions/providers/condition.js.html +142 -0
- package/coverage/lcov-report/services/content-api/permissions/providers/index.html +146 -0
- package/coverage/lcov-report/services/content-api/permissions/providers/index.js.html +112 -0
- package/coverage/lcov-report/services/core-store.js.html +520 -0
- package/coverage/lcov-report/services/entity-service/attributes/index.html +131 -0
- package/coverage/lcov-report/services/entity-service/attributes/index.js.html +178 -0
- package/coverage/lcov-report/services/entity-service/attributes/transforms.js.html +145 -0
- package/coverage/lcov-report/services/entity-service/components.js.html +1246 -0
- package/coverage/lcov-report/services/entity-service/index.html +146 -0
- package/coverage/lcov-report/services/entity-service/index.js.html +1120 -0
- package/coverage/lcov-report/services/entity-service/params.js.html +112 -0
- package/coverage/lcov-report/services/entity-validator/__tests__/relations/utils/index.html +116 -0
- package/coverage/lcov-report/services/entity-validator/__tests__/relations/utils/relations.testdata.js.html +544 -0
- package/coverage/lcov-report/services/entity-validator/index.html +131 -0
- package/coverage/lcov-report/services/entity-validator/index.js.html +1231 -0
- package/coverage/lcov-report/services/entity-validator/validators.js.html +733 -0
- package/coverage/lcov-report/services/event-hub.js.html +319 -0
- package/coverage/lcov-report/services/fs.js.html +259 -0
- package/coverage/lcov-report/services/index.html +161 -0
- package/coverage/lcov-report/services/metrics/admin-user-hash.js.html +148 -0
- package/coverage/lcov-report/services/metrics/index.html +206 -0
- package/coverage/lcov-report/services/metrics/index.js.html +265 -0
- package/coverage/lcov-report/services/metrics/is-truthy.js.html +112 -0
- package/coverage/lcov-report/services/metrics/middleware.js.html +184 -0
- package/coverage/lcov-report/services/metrics/rate-limiter.js.html +166 -0
- package/coverage/lcov-report/services/metrics/sender.js.html +394 -0
- package/coverage/lcov-report/services/metrics/stringify-deep.js.html +151 -0
- package/coverage/lcov-report/services/utils/index.html +116 -0
- package/coverage/lcov-report/services/utils/upload-files.js.html +322 -0
- package/coverage/lcov-report/services/worker-queue.js.html +262 -0
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +196 -0
- package/coverage/lcov-report/utils/convert-custom-field-type.js.html +151 -0
- package/coverage/lcov-report/utils/index.html +146 -0
- package/coverage/lcov-report/utils/machine-id.js.html +127 -0
- package/coverage/lcov-report/utils/url-from-segments.js.html +121 -0
- package/ee/LICENSE.txt +21 -0
- package/ee/index.js +3 -1
- package/ee/license.js +8 -7
- package/lib/Strapi.js +3 -0
- package/lib/commands/__tests__/commands.test.js +20 -0
- package/lib/commands/__tests__/commands.test.utils.js +16 -0
- package/lib/commands/actions/admin/create-user/__tests__/admin.create-user.test.js +450 -0
- package/lib/commands/{admin-create.js → actions/admin/create-user/action.js} +2 -2
- package/lib/commands/actions/admin/create-user/command.js +19 -0
- package/lib/commands/actions/admin/reset-user-password/__tests__/admin.reset-user-password.test.js +145 -0
- package/lib/commands/{admin-reset.js → actions/admin/reset-user-password/action.js} +2 -2
- package/lib/commands/actions/admin/reset-user-password/command.js +17 -0
- package/lib/commands/{build.js → actions/build/action.js} +2 -2
- package/lib/commands/actions/build/command.js +15 -0
- package/lib/commands/{configurationDump.js → actions/configuration/dump/action.js} +1 -1
- package/lib/commands/actions/configuration/dump/command.js +17 -0
- package/lib/commands/{configurationRestore.js → actions/configuration/restore/action.js} +1 -1
- package/lib/commands/actions/configuration/restore/command.js +17 -0
- package/lib/commands/{console.js → actions/console/action.js} +2 -2
- package/lib/commands/actions/console/command.js +14 -0
- package/lib/commands/{content-types/list.js → actions/content-types/list/action.js} +2 -2
- package/lib/commands/actions/content-types/list/command.js +14 -0
- package/lib/commands/{controllers/list.js → actions/controllers/list/action.js} +2 -2
- package/lib/commands/actions/controllers/list/command.js +14 -0
- package/lib/commands/{develop.js → actions/develop/action.js} +3 -3
- package/lib/commands/actions/develop/command.js +19 -0
- package/lib/commands/actions/export/__tests__/export.test.js +175 -0
- package/lib/commands/{transfer/export.js → actions/export/action.js} +3 -2
- package/lib/commands/actions/export/command.js +45 -0
- package/lib/commands/actions/generate/command.js +18 -0
- package/lib/commands/{hooks/list.js → actions/hooks/list/action.js} +2 -2
- package/lib/commands/actions/hooks/list/command.js +14 -0
- package/lib/commands/actions/import/__tests__/import.test.js +143 -0
- package/lib/commands/{transfer/import.js → actions/import/action.js} +2 -2
- package/lib/commands/actions/import/command.js +97 -0
- package/lib/commands/{install.js → actions/install/action.js} +1 -1
- package/lib/commands/actions/install/command.js +14 -0
- package/lib/commands/{middlewares/list.js → actions/middlewares/list/action.js} +2 -2
- package/lib/commands/actions/middlewares/list/command.js +14 -0
- package/lib/commands/{new.js → actions/new/action.js} +1 -1
- package/lib/commands/actions/new/command.js +35 -0
- package/lib/commands/{policies/list.js → actions/policies/list/action.js} +2 -2
- package/lib/commands/actions/policies/list/command.js +14 -0
- package/lib/commands/{report.js → actions/report/action.js} +1 -1
- package/lib/commands/actions/report/command.js +17 -0
- package/lib/commands/{routes/list.js → actions/routes/list/action.js} +2 -2
- package/lib/commands/actions/routes/list/command.js +14 -0
- package/lib/commands/{services/list.js → actions/services/list/action.js} +2 -2
- package/lib/commands/actions/services/list/command.js +14 -0
- package/lib/commands/{start.js → actions/start/action.js} +1 -1
- package/lib/commands/actions/start/command.js +14 -0
- package/lib/commands/{opt-out-telemetry.js → actions/telemetry/disable/action.js} +1 -1
- package/lib/commands/actions/telemetry/disable/command.js +14 -0
- package/lib/commands/{opt-in-telemetry.js → actions/telemetry/enable/action.js} +1 -1
- package/lib/commands/actions/telemetry/enable/command.js +14 -0
- package/lib/commands/actions/templates/generate/__tests__/templates.generate.js +118 -0
- package/lib/commands/actions/templates/generate/command.js +14 -0
- package/lib/commands/actions/transfer/__tests__/transfer.test.js +178 -0
- package/lib/commands/{transfer/transfer.js → actions/transfer/action.js} +2 -2
- package/lib/commands/actions/transfer/command.js +115 -0
- package/lib/commands/{ts/generate-types.js → actions/ts/generate-types/action.js} +2 -2
- package/lib/commands/actions/ts/generate-types/command.js +21 -0
- package/lib/commands/{uninstall.js → actions/uninstall/action.js} +1 -1
- package/lib/commands/actions/uninstall/command.js +15 -0
- package/lib/commands/actions/version/command.js +19 -0
- package/lib/commands/{watchAdmin.js → actions/watch-admin/action.js} +4 -4
- package/lib/commands/actions/watch-admin/command.js +15 -0
- package/lib/commands/index.js +66 -0
- package/lib/commands/{transfer/utils.js → utils/data-transfer.js} +2 -2
- package/lib/commands/utils/helpers.js +54 -3
- package/lib/core/registries/__tests__/custom-fields.test.js +152 -0
- package/lib/core/registries/custom-fields.js +19 -2
- package/lib/core-api/__tests__/controller.test.js +39 -0
- package/lib/core-api/controller/__tests__/transform.test.js +226 -0
- package/lib/core-api/service/__tests__/index.test.js +127 -0
- package/lib/core-api/service/__tests__/pagination.test.js +275 -0
- package/lib/load/__tests__/filepath-to-prop-path.test.js +30 -0
- package/lib/middlewares/__tests__/errors.test.js +21 -0
- package/lib/services/__tests__/content-api-permissions.test.js +291 -0
- package/lib/services/__tests__/core-store.test.js +148 -0
- package/lib/services/__tests__/event-hub.test.js +126 -0
- package/lib/services/__tests__/fs.test.js +78 -0
- package/lib/services/__tests__/worker-queue.test.js +47 -0
- package/lib/services/entity-service/__tests__/entity-service-events.test.js +117 -0
- package/lib/services/entity-service/__tests__/entity-service.test.js +587 -0
- package/lib/services/entity-validator/__tests__/biginteger-validators.test.js +220 -0
- package/lib/services/entity-validator/__tests__/date-validators.test.js +183 -0
- package/lib/services/entity-validator/__tests__/datetime-validators.test.js +183 -0
- package/lib/services/entity-validator/__tests__/email-validators.test.js +56 -0
- package/lib/services/entity-validator/__tests__/enumeration-validators.test.js +43 -0
- package/lib/services/entity-validator/__tests__/float-validators.test.js +278 -0
- package/lib/services/entity-validator/__tests__/index.test.js +609 -0
- package/lib/services/entity-validator/__tests__/integer-validators.test.js +278 -0
- package/lib/services/entity-validator/__tests__/relations/attribute-level.test.js +123 -0
- package/lib/services/entity-validator/__tests__/relations/component-level.test.js +275 -0
- package/lib/services/entity-validator/__tests__/relations/dynamic-zone-level.test.js +159 -0
- package/lib/services/entity-validator/__tests__/relations/media-level.test.js +74 -0
- package/lib/services/entity-validator/__tests__/relations/utils/relations.testdata.js +153 -0
- package/lib/services/entity-validator/__tests__/string-validators.test.js +374 -0
- package/lib/services/entity-validator/__tests__/time-validators.test.js +183 -0
- package/lib/services/entity-validator/__tests__/timestamp-validators.test.js +204 -0
- package/lib/services/entity-validator/__tests__/uid-validators.test.js +229 -0
- package/lib/services/metrics/__tests__/admin-user-hash.test.js +41 -0
- package/lib/services/metrics/__tests__/index.test.js +157 -0
- package/lib/services/metrics/__tests__/is-truthy.js +33 -0
- package/lib/services/metrics/__tests__/middleware.test.js +60 -0
- package/lib/services/metrics/__tests__/rate-limiter.test.js +50 -0
- package/lib/services/metrics/__tests__/stringify-deep.test.js +27 -0
- package/lib/services/metrics/sender.js +1 -2
- package/lib/services/webhook-runner.js +4 -4
- package/lib/types/core/commands/index.d.ts +6 -0
- package/lib/utils/__tests__/convert-custom-field-type.test.js +69 -0
- package/lib/utils/__tests__/url-from-segments.test.js +40 -0
- package/lib/utils/fetch.js +23 -0
- package/package.json +17 -16
- /package/lib/commands/{generate-template.js → actions/templates/generate/action.js} +0 -0
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const { Option } = require('commander');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
const inquirer = require('inquirer');
|
|
6
|
+
const {
|
|
7
|
+
excludeOption,
|
|
8
|
+
onlyOption,
|
|
9
|
+
throttleOption,
|
|
10
|
+
validateExcludeOnly,
|
|
11
|
+
} = require('../../utils/data-transfer');
|
|
12
|
+
const { confirmMessage, forceOption } = require('../../utils/commander');
|
|
13
|
+
const { getLocalScript, exitWith } = require('../../utils/helpers');
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* `$ strapi import`
|
|
17
|
+
* @param {import('../../../types/core/commands').AddCommandOptions} options
|
|
18
|
+
*/
|
|
19
|
+
module.exports = ({ command }) => {
|
|
20
|
+
command
|
|
21
|
+
.command('import')
|
|
22
|
+
.description('Import data from file to Strapi')
|
|
23
|
+
.allowExcessArguments(false)
|
|
24
|
+
.requiredOption(
|
|
25
|
+
'-f, --file <file>',
|
|
26
|
+
'path and filename for the Strapi export file you want to import'
|
|
27
|
+
)
|
|
28
|
+
.addOption(
|
|
29
|
+
new Option(
|
|
30
|
+
'-k, --key <string>',
|
|
31
|
+
'Provide encryption key in command instead of using the prompt'
|
|
32
|
+
)
|
|
33
|
+
)
|
|
34
|
+
.addOption(forceOption)
|
|
35
|
+
.addOption(excludeOption)
|
|
36
|
+
.addOption(onlyOption)
|
|
37
|
+
.addOption(throttleOption)
|
|
38
|
+
.hook('preAction', validateExcludeOnly)
|
|
39
|
+
.hook('preAction', async (thisCommand) => {
|
|
40
|
+
const opts = thisCommand.opts();
|
|
41
|
+
const ext = path.extname(String(opts.file));
|
|
42
|
+
|
|
43
|
+
// check extension to guess if we should prompt for key
|
|
44
|
+
if (ext === '.enc') {
|
|
45
|
+
if (!opts.key) {
|
|
46
|
+
const answers = await inquirer.prompt([
|
|
47
|
+
{
|
|
48
|
+
type: 'password',
|
|
49
|
+
message: 'Please enter your decryption key',
|
|
50
|
+
name: 'key',
|
|
51
|
+
},
|
|
52
|
+
]);
|
|
53
|
+
if (!answers.key?.length) {
|
|
54
|
+
exitWith(1, 'No key entered, aborting import.');
|
|
55
|
+
}
|
|
56
|
+
opts.key = answers.key;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
})
|
|
60
|
+
// set decrypt and decompress options based on filename
|
|
61
|
+
.hook('preAction', (thisCommand) => {
|
|
62
|
+
const opts = thisCommand.opts();
|
|
63
|
+
|
|
64
|
+
const { extname, parse } = path;
|
|
65
|
+
|
|
66
|
+
let file = opts.file;
|
|
67
|
+
|
|
68
|
+
if (extname(file) === '.enc') {
|
|
69
|
+
file = parse(file).name; // trim the .enc extension
|
|
70
|
+
thisCommand.opts().decrypt = true;
|
|
71
|
+
} else {
|
|
72
|
+
thisCommand.opts().decrypt = false;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
if (extname(file) === '.gz') {
|
|
76
|
+
file = parse(file).name; // trim the .gz extension
|
|
77
|
+
thisCommand.opts().decompress = true;
|
|
78
|
+
} else {
|
|
79
|
+
thisCommand.opts().decompress = false;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if (extname(file) !== '.tar') {
|
|
83
|
+
exitWith(
|
|
84
|
+
1,
|
|
85
|
+
`The file '${opts.file}' does not appear to be a valid Strapi data file. It must have an extension ending in .tar[.gz][.enc]`
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
})
|
|
89
|
+
.hook(
|
|
90
|
+
'preAction',
|
|
91
|
+
confirmMessage(
|
|
92
|
+
'The import will delete all assets and data in your database. Are you sure you want to proceed?',
|
|
93
|
+
{ failMessage: 'Import process aborted' }
|
|
94
|
+
)
|
|
95
|
+
)
|
|
96
|
+
.action(getLocalScript('import'));
|
|
97
|
+
};
|
|
@@ -4,7 +4,7 @@ const { join } = require('path');
|
|
|
4
4
|
const { existsSync } = require('fs-extra');
|
|
5
5
|
const ora = require('ora');
|
|
6
6
|
const execa = require('execa');
|
|
7
|
-
const findPackagePath = require('
|
|
7
|
+
const findPackagePath = require('../../../load/package-path');
|
|
8
8
|
|
|
9
9
|
module.exports = async (plugins) => {
|
|
10
10
|
const loader = ora();
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const { getLocalScript } = require('../../utils/helpers');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* `$ strapi install`
|
|
7
|
+
* @param {import('../../../types/core/commands').AddCommandOptions} options
|
|
8
|
+
*/
|
|
9
|
+
module.exports = ({ command }) => {
|
|
10
|
+
command
|
|
11
|
+
.command('install [plugins...]')
|
|
12
|
+
.description('Install a Strapi plugin')
|
|
13
|
+
.action(getLocalScript('install'));
|
|
14
|
+
};
|
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
const CLITable = require('cli-table3');
|
|
4
4
|
const chalk = require('chalk');
|
|
5
5
|
|
|
6
|
-
const strapi = require('
|
|
6
|
+
const strapi = require('../../../../index');
|
|
7
7
|
|
|
8
|
-
module.exports = async
|
|
8
|
+
module.exports = async () => {
|
|
9
9
|
const appContext = await strapi.compile();
|
|
10
10
|
const app = await strapi(appContext).register();
|
|
11
11
|
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const { getLocalScript } = require('../../../utils/helpers');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* `$ strapi middlewares:list`
|
|
7
|
+
* @param {import('../../../../types/core/commands').AddCommandOptions} options
|
|
8
|
+
*/
|
|
9
|
+
module.exports = ({ command }) => {
|
|
10
|
+
command
|
|
11
|
+
.command('middlewares:list')
|
|
12
|
+
.description('List all the application middlewares')
|
|
13
|
+
.action(getLocalScript('middlewares/list'));
|
|
14
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const { yellow } = require('chalk');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* `$ strapi new`
|
|
7
|
+
* @param {import('../../../types/core/commands').AddCommandOptions} options
|
|
8
|
+
*/
|
|
9
|
+
module.exports = ({ command }) => {
|
|
10
|
+
command
|
|
11
|
+
.command('new <directory>')
|
|
12
|
+
.option('--no-run', 'Do not start the application after it is created')
|
|
13
|
+
.option('--use-npm', 'Force usage of npm instead of yarn to create the project')
|
|
14
|
+
.option('--debug', 'Display database connection errors')
|
|
15
|
+
.option('--quickstart', 'Create quickstart app')
|
|
16
|
+
.option('--dbclient <dbclient>', 'Database client')
|
|
17
|
+
.option('--dbhost <dbhost>', 'Database host')
|
|
18
|
+
.option('--dbport <dbport>', 'Database port')
|
|
19
|
+
.option('--dbname <dbname>', 'Database name')
|
|
20
|
+
.option('--dbusername <dbusername>', 'Database username')
|
|
21
|
+
.option('--dbpassword <dbpassword>', 'Database password')
|
|
22
|
+
.option('--dbssl <dbssl>', 'Database SSL')
|
|
23
|
+
.option('--dbfile <dbfile>', 'Database file path for sqlite')
|
|
24
|
+
.option('--dbforce', 'Allow overwriting existing database content')
|
|
25
|
+
.option('-ts, --typescript', 'Create a typescript project')
|
|
26
|
+
.description('Create a new application')
|
|
27
|
+
.hook('preAction', () => {
|
|
28
|
+
console.warn(
|
|
29
|
+
yellow(
|
|
30
|
+
'The `strapi new` command has been deprecated in v4 and will be removed in v5. `create-strapi-app` should be used to create a new Strapi project.'
|
|
31
|
+
)
|
|
32
|
+
);
|
|
33
|
+
})
|
|
34
|
+
.action(require('./action'));
|
|
35
|
+
};
|
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
const CLITable = require('cli-table3');
|
|
4
4
|
const chalk = require('chalk');
|
|
5
5
|
|
|
6
|
-
const strapi = require('
|
|
6
|
+
const strapi = require('../../../../index');
|
|
7
7
|
|
|
8
|
-
module.exports = async
|
|
8
|
+
module.exports = async () => {
|
|
9
9
|
const appContext = await strapi.compile();
|
|
10
10
|
const app = await strapi(appContext).register();
|
|
11
11
|
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const { getLocalScript } = require('../../../utils/helpers');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* `$ strapi policies:list`
|
|
7
|
+
* @param {import('../../../../types/core/commands').AddCommandOptions} options
|
|
8
|
+
*/
|
|
9
|
+
module.exports = ({ command }) => {
|
|
10
|
+
command
|
|
11
|
+
.command('policies:list')
|
|
12
|
+
.description('List all the application policies')
|
|
13
|
+
.action(getLocalScript('policies/list'));
|
|
14
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const { getLocalScript } = require('../../utils/helpers');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* `$ strapi report`
|
|
7
|
+
* @param {import('../../../types/core/commands').AddCommandOptions} options
|
|
8
|
+
*/
|
|
9
|
+
module.exports = ({ command }) => {
|
|
10
|
+
command
|
|
11
|
+
.command('report')
|
|
12
|
+
.description('Get system stats for debugging and submitting issues')
|
|
13
|
+
.option('-u, --uuid', 'Include Project UUID')
|
|
14
|
+
.option('-d, --dependencies', 'Include Project Dependencies')
|
|
15
|
+
.option('--all', 'Include All Information')
|
|
16
|
+
.action(getLocalScript('report'));
|
|
17
|
+
};
|
|
@@ -4,9 +4,9 @@ const CLITable = require('cli-table3');
|
|
|
4
4
|
const chalk = require('chalk');
|
|
5
5
|
const { toUpper } = require('lodash/fp');
|
|
6
6
|
|
|
7
|
-
const strapi = require('
|
|
7
|
+
const strapi = require('../../../../index');
|
|
8
8
|
|
|
9
|
-
module.exports = async
|
|
9
|
+
module.exports = async () => {
|
|
10
10
|
const appContext = await strapi.compile();
|
|
11
11
|
const app = await strapi(appContext).load();
|
|
12
12
|
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const { getLocalScript } = require('../../../utils/helpers');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* `$ strapi routes:list``
|
|
7
|
+
* @param {import('../../../../types/core/commands').AddCommandOptions} options
|
|
8
|
+
*/
|
|
9
|
+
module.exports = ({ command }) => {
|
|
10
|
+
command
|
|
11
|
+
.command('routes:list')
|
|
12
|
+
.description('List all the application routes')
|
|
13
|
+
.action(getLocalScript('routes/list'));
|
|
14
|
+
};
|
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
const CLITable = require('cli-table3');
|
|
4
4
|
const chalk = require('chalk');
|
|
5
5
|
|
|
6
|
-
const strapi = require('
|
|
6
|
+
const strapi = require('../../../../index');
|
|
7
7
|
|
|
8
|
-
module.exports = async
|
|
8
|
+
module.exports = async () => {
|
|
9
9
|
const appContext = await strapi.compile();
|
|
10
10
|
const app = await strapi(appContext).register();
|
|
11
11
|
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const { getLocalScript } = require('../../../utils/helpers');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* `$ strapi services:list`
|
|
7
|
+
* @param {import('../../../../types/core/commands').AddCommandOptions} options
|
|
8
|
+
*/
|
|
9
|
+
module.exports = ({ command }) => {
|
|
10
|
+
command
|
|
11
|
+
.command('services:list')
|
|
12
|
+
.description('List all the application services')
|
|
13
|
+
.action(getLocalScript('services/list'));
|
|
14
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const { getLocalScript } = require('../../utils/helpers');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* `$ strapi start`
|
|
7
|
+
* @param {import('../../../types/core/commands').AddCommandOptions} options
|
|
8
|
+
*/
|
|
9
|
+
module.exports = ({ command }) => {
|
|
10
|
+
command
|
|
11
|
+
.command('start')
|
|
12
|
+
.description('Start your Strapi application')
|
|
13
|
+
.action(getLocalScript('start'));
|
|
14
|
+
};
|
|
@@ -4,7 +4,7 @@ const { resolve } = require('path');
|
|
|
4
4
|
const fse = require('fs-extra');
|
|
5
5
|
const chalk = require('chalk');
|
|
6
6
|
const fetch = require('node-fetch');
|
|
7
|
-
const machineID = require('
|
|
7
|
+
const machineID = require('../../../../utils/machine-id');
|
|
8
8
|
|
|
9
9
|
const readPackageJSON = async (path) => {
|
|
10
10
|
try {
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const { getLocalScript } = require('../../../utils/helpers');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* `$ strapi telemetry:disable`
|
|
7
|
+
* @param {import('../../../../types/core/commands').AddCommandOptions} options
|
|
8
|
+
*/
|
|
9
|
+
module.exports = ({ command }) => {
|
|
10
|
+
command
|
|
11
|
+
.command('telemetry:disable')
|
|
12
|
+
.description('Disable anonymous telemetry and metadata sending to Strapi analytics')
|
|
13
|
+
.action(getLocalScript('telemetry/disable'));
|
|
14
|
+
};
|
|
@@ -5,7 +5,7 @@ const fse = require('fs-extra');
|
|
|
5
5
|
const chalk = require('chalk');
|
|
6
6
|
const fetch = require('node-fetch');
|
|
7
7
|
const { v4: uuidv4 } = require('uuid');
|
|
8
|
-
const machineID = require('
|
|
8
|
+
const machineID = require('../../../../utils/machine-id');
|
|
9
9
|
|
|
10
10
|
const readPackageJSON = async (path) => {
|
|
11
11
|
try {
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const { getLocalScript } = require('../../../utils/helpers');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* `$ strapi telemetry:enable`
|
|
7
|
+
* @param {import('../../../../types/core/commands').AddCommandOptions} options
|
|
8
|
+
*/
|
|
9
|
+
module.exports = ({ command }) => {
|
|
10
|
+
command
|
|
11
|
+
.command('telemetry:enable')
|
|
12
|
+
.description('Enable anonymous telemetry and metadata sending to Strapi analytics')
|
|
13
|
+
.action(getLocalScript('telemetry/enable'));
|
|
14
|
+
};
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
jest.mock('fs-extra', () => ({
|
|
4
|
+
ensureDir: jest.fn(() => Promise.resolve()),
|
|
5
|
+
copy: jest.fn(() => Promise.resolve()),
|
|
6
|
+
pathExists: jest.fn(() => Promise.resolve()),
|
|
7
|
+
writeJSON: jest.fn(() => Promise.resolve()),
|
|
8
|
+
}));
|
|
9
|
+
|
|
10
|
+
const { resolve, join } = require('path');
|
|
11
|
+
const fse = require('fs-extra');
|
|
12
|
+
const inquirer = require('inquirer');
|
|
13
|
+
|
|
14
|
+
const exportTemplate = require('../action');
|
|
15
|
+
|
|
16
|
+
describe('templates:generate command', () => {
|
|
17
|
+
beforeEach(() => {
|
|
18
|
+
jest.spyOn(console, 'log').mockImplementation(() => {});
|
|
19
|
+
jest.clearAllMocks();
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it('creates a new template directory', async () => {
|
|
23
|
+
fse.pathExists.mockReturnValue(false);
|
|
24
|
+
const directory = '../test-dir';
|
|
25
|
+
const rootPath = resolve(directory);
|
|
26
|
+
const templatePath = join(rootPath, 'template');
|
|
27
|
+
|
|
28
|
+
await exportTemplate(directory);
|
|
29
|
+
|
|
30
|
+
expect(fse.pathExists).toHaveBeenCalledWith(templatePath);
|
|
31
|
+
expect(fse.ensureDir).toHaveBeenCalledWith(templatePath);
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it.each(['src', 'data'])('copies folder %s', async (item) => {
|
|
35
|
+
// Mock the empty directory arg
|
|
36
|
+
fse.pathExists.mockReturnValueOnce(false);
|
|
37
|
+
// Mock the folder exists
|
|
38
|
+
fse.pathExists.mockReturnValue(true);
|
|
39
|
+
const directory = '../test-dir';
|
|
40
|
+
const rootPath = resolve(directory);
|
|
41
|
+
const templatePath = join(rootPath, 'template');
|
|
42
|
+
|
|
43
|
+
await exportTemplate(directory);
|
|
44
|
+
|
|
45
|
+
expect(fse.pathExists).toHaveBeenCalledWith(join(process.cwd(), item));
|
|
46
|
+
expect(fse.copy).toHaveBeenCalledWith(join(process.cwd(), item), join(templatePath, item));
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
it('creates a json config file', async () => {
|
|
50
|
+
fse.pathExists.mockReturnValue(false);
|
|
51
|
+
const directory = '../test-dir';
|
|
52
|
+
const rootPath = resolve(directory);
|
|
53
|
+
|
|
54
|
+
await exportTemplate(directory);
|
|
55
|
+
|
|
56
|
+
expect(fse.pathExists).toHaveBeenCalledWith(join(rootPath, 'template.json'));
|
|
57
|
+
expect(fse.writeJSON).toHaveBeenCalledWith(join(rootPath, 'template.json'), {});
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
describe('handles prompt input', () => {
|
|
61
|
+
it('replaces directory if confirmed', async () => {
|
|
62
|
+
fse.pathExists.mockReturnValue(true);
|
|
63
|
+
const mockInquiry = jest
|
|
64
|
+
.spyOn(inquirer, 'prompt')
|
|
65
|
+
.mockImplementationOnce(() => ({ confirm: true }));
|
|
66
|
+
const directory = '../test-dir';
|
|
67
|
+
const rootPath = resolve(directory);
|
|
68
|
+
const templatePath = join(rootPath, 'template');
|
|
69
|
+
|
|
70
|
+
await exportTemplate(directory);
|
|
71
|
+
|
|
72
|
+
expect(fse.pathExists).toHaveBeenCalledWith(templatePath);
|
|
73
|
+
expect(mockInquiry).toHaveBeenLastCalledWith(
|
|
74
|
+
expect.objectContaining({ message: expect.any(String), name: 'confirm', type: 'confirm' })
|
|
75
|
+
);
|
|
76
|
+
expect(fse.ensureDir).toHaveBeenCalled();
|
|
77
|
+
expect(fse.copy).toHaveBeenCalled();
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
it('does not replace existing config file', async () => {
|
|
81
|
+
fse.pathExists.mockReturnValue(true);
|
|
82
|
+
jest.spyOn(inquirer, 'prompt').mockImplementationOnce(() => ({ confirm: true }));
|
|
83
|
+
const directory = '../test-dir';
|
|
84
|
+
const rootPath = resolve(directory);
|
|
85
|
+
|
|
86
|
+
await exportTemplate(directory);
|
|
87
|
+
expect(fse.pathExists).toHaveBeenCalledWith(join(rootPath, 'template.json'));
|
|
88
|
+
expect(fse.writeJSON).not.toHaveBeenCalled();
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
it('exits if not confirmed', async () => {
|
|
92
|
+
fse.pathExists.mockReturnValue(true);
|
|
93
|
+
jest.spyOn(console, 'error').mockImplementation(() => {});
|
|
94
|
+
const mockInquiry = jest
|
|
95
|
+
.spyOn(inquirer, 'prompt')
|
|
96
|
+
.mockImplementationOnce(() => ({ confirm: false }));
|
|
97
|
+
|
|
98
|
+
const mockExit = jest.spyOn(process, 'exit').mockImplementation(() => {
|
|
99
|
+
throw new Error('exit');
|
|
100
|
+
});
|
|
101
|
+
const directory = '../test-dir';
|
|
102
|
+
const rootPath = resolve(directory);
|
|
103
|
+
const templatePath = join(rootPath, 'template');
|
|
104
|
+
|
|
105
|
+
await exportTemplate(directory).catch((err) => {
|
|
106
|
+
expect(err).toEqual(new Error('exit'));
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
expect(fse.pathExists).toHaveBeenCalledWith(templatePath);
|
|
110
|
+
expect(mockInquiry).toHaveBeenLastCalledWith(
|
|
111
|
+
expect.objectContaining({ message: expect.any(String), name: 'confirm', type: 'confirm' })
|
|
112
|
+
);
|
|
113
|
+
expect(mockExit).toHaveBeenCalledWith(0);
|
|
114
|
+
expect(fse.ensureDir).not.toHaveBeenCalled();
|
|
115
|
+
expect(fse.copy).not.toHaveBeenCalled();
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const { getLocalScript } = require('../../../utils/helpers');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
*`$ strapi templates:generate <directory>`
|
|
7
|
+
* @param {import('../../../../types/core/commands').AddCommandOptions} options
|
|
8
|
+
*/
|
|
9
|
+
module.exports = ({ command }) => {
|
|
10
|
+
command
|
|
11
|
+
.command('templates:generate <directory>')
|
|
12
|
+
.description('Generate template from Strapi project')
|
|
13
|
+
.action(getLocalScript('templates/generate'));
|
|
14
|
+
};
|