@strapi/strapi 4.10.0-beta.1 → 4.10.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.
Files changed (69) hide show
  1. package/bin/strapi.js +2 -468
  2. package/ee/LICENSE.txt +21 -0
  3. package/ee/index.js +3 -1
  4. package/ee/license.js +8 -7
  5. package/lib/Strapi.js +3 -0
  6. package/lib/commands/{admin-create.js → actions/admin/create-user/action.js} +2 -2
  7. package/lib/commands/actions/admin/create-user/command.js +19 -0
  8. package/lib/commands/{admin-reset.js → actions/admin/reset-user-password/action.js} +2 -2
  9. package/lib/commands/actions/admin/reset-user-password/command.js +17 -0
  10. package/lib/commands/{configurationDump.js → actions/configuration/dump/action.js} +1 -1
  11. package/lib/commands/actions/configuration/dump/command.js +17 -0
  12. package/lib/commands/{configurationRestore.js → actions/configuration/restore/action.js} +1 -1
  13. package/lib/commands/actions/configuration/restore/command.js +17 -0
  14. package/lib/commands/{console.js → actions/console/action.js} +2 -2
  15. package/lib/commands/actions/console/command.js +14 -0
  16. package/lib/commands/{content-types/list.js → actions/content-types/list/action.js} +2 -2
  17. package/lib/commands/actions/content-types/list/command.js +14 -0
  18. package/lib/commands/{controllers/list.js → actions/controllers/list/action.js} +2 -2
  19. package/lib/commands/actions/controllers/list/command.js +14 -0
  20. package/lib/commands/{develop.js → actions/develop/action.js} +3 -3
  21. package/lib/commands/actions/develop/command.js +19 -0
  22. package/lib/commands/{transfer/export.js → actions/export/action.js} +3 -2
  23. package/lib/commands/actions/export/command.js +45 -0
  24. package/lib/commands/actions/generate/command.js +18 -0
  25. package/lib/commands/{hooks/list.js → actions/hooks/list/action.js} +2 -2
  26. package/lib/commands/actions/hooks/list/command.js +14 -0
  27. package/lib/commands/{transfer/import.js → actions/import/action.js} +2 -2
  28. package/lib/commands/actions/import/command.js +97 -0
  29. package/lib/commands/{install.js → actions/install/action.js} +1 -1
  30. package/lib/commands/actions/install/command.js +14 -0
  31. package/lib/commands/{middlewares/list.js → actions/middlewares/list/action.js} +2 -2
  32. package/lib/commands/actions/middlewares/list/command.js +14 -0
  33. package/lib/commands/{new.js → actions/new/action.js} +1 -1
  34. package/lib/commands/actions/new/command.js +35 -0
  35. package/lib/commands/{policies/list.js → actions/policies/list/action.js} +2 -2
  36. package/lib/commands/actions/policies/list/command.js +14 -0
  37. package/lib/commands/{report.js → actions/report/action.js} +1 -1
  38. package/lib/commands/actions/report/command.js +17 -0
  39. package/lib/commands/{routes/list.js → actions/routes/list/action.js} +2 -2
  40. package/lib/commands/actions/routes/list/command.js +14 -0
  41. package/lib/commands/{services/list.js → actions/services/list/action.js} +2 -2
  42. package/lib/commands/actions/services/list/command.js +14 -0
  43. package/lib/commands/{start.js → actions/start/action.js} +1 -1
  44. package/lib/commands/actions/start/command.js +14 -0
  45. package/lib/commands/{opt-out-telemetry.js → actions/telemetry/disable/action.js} +1 -1
  46. package/lib/commands/actions/telemetry/disable/command.js +14 -0
  47. package/lib/commands/{opt-in-telemetry.js → actions/telemetry/enable/action.js} +1 -1
  48. package/lib/commands/actions/telemetry/enable/command.js +14 -0
  49. package/lib/commands/actions/templates/generate/command.js +14 -0
  50. package/lib/commands/{transfer/transfer.js → actions/transfer/action.js} +2 -2
  51. package/lib/commands/actions/transfer/command.js +115 -0
  52. package/lib/commands/{ts/generate-types.js → actions/ts/generate-types/action.js} +2 -2
  53. package/lib/commands/actions/ts/generate-types/command.js +21 -0
  54. package/lib/commands/{uninstall.js → actions/uninstall/action.js} +1 -1
  55. package/lib/commands/actions/uninstall/command.js +15 -0
  56. package/lib/commands/actions/version/command.js +19 -0
  57. package/lib/commands/{watchAdmin.js → actions/watch-admin/action.js} +4 -4
  58. package/lib/commands/actions/watch-admin/command.js +15 -0
  59. package/lib/commands/index.js +66 -0
  60. package/lib/commands/{transfer/utils.js → utils/data-transfer.js} +2 -2
  61. package/lib/commands/utils/helpers.js +54 -3
  62. package/lib/core/registries/custom-fields.js +19 -2
  63. package/lib/services/metrics/sender.js +1 -2
  64. package/lib/services/webhook-runner.js +4 -4
  65. package/lib/types/core/commands/index.d.ts +6 -0
  66. package/lib/utils/fetch.js +23 -0
  67. package/package.json +17 -16
  68. package/lib/commands/build.js +0 -18
  69. /package/lib/commands/{generate-template.js → actions/templates/generate/action.js} +0 -0
package/bin/strapi.js CHANGED
@@ -2,472 +2,6 @@
2
2
 
3
3
  'use strict';
4
4
 
5
- // FIXME
6
- /* eslint-disable import/extensions */
7
- const _ = require('lodash');
8
- const path = require('path');
9
- const resolveCwd = require('resolve-cwd');
10
- const { yellow } = require('chalk');
11
- const { Command, Option } = require('commander');
12
- const inquirer = require('inquirer');
5
+ const { runStrapiCommand } = require('../lib/commands');
13
6
 
14
- const program = new Command();
15
-
16
- const packageJSON = require('../package.json');
17
- const {
18
- promptEncryptionKey,
19
- confirmMessage,
20
- forceOption,
21
- parseURL,
22
- } = require('../lib/commands/utils/commander');
23
- const { exitWith, ifOptions, assertUrlHasProtocol } = require('../lib/commands/utils/helpers');
24
- const {
25
- excludeOption,
26
- onlyOption,
27
- throttleOption,
28
- validateExcludeOnly,
29
- } = require('../lib/commands/transfer/utils');
30
-
31
- const checkCwdIsStrapiApp = (name) => {
32
- const logErrorAndExit = () => {
33
- console.log(
34
- `You need to run ${yellow(
35
- `strapi ${name}`
36
- )} in a Strapi project. Make sure you are in the right directory.`
37
- );
38
- process.exit(1);
39
- };
40
-
41
- try {
42
- const pkgJSON = require(`${process.cwd()}/package.json`);
43
- if (!_.has(pkgJSON, 'dependencies.@strapi/strapi')) {
44
- logErrorAndExit(name);
45
- }
46
- } catch (err) {
47
- logErrorAndExit(name);
48
- }
49
- };
50
-
51
- const getLocalScript =
52
- (name) =>
53
- (...args) => {
54
- checkCwdIsStrapiApp(name);
55
-
56
- const cmdPath = resolveCwd.silent(`@strapi/strapi/lib/commands/${name}`);
57
- if (!cmdPath) {
58
- console.log(
59
- `Error loading the local ${yellow(
60
- name
61
- )} command. Strapi might not be installed in your "node_modules". You may need to run "yarn install".`
62
- );
63
- process.exit(1);
64
- }
65
-
66
- const script = require(cmdPath);
67
-
68
- Promise.resolve()
69
- .then(() => {
70
- return script(...args);
71
- })
72
- .catch((error) => {
73
- console.error(error);
74
- process.exit(1);
75
- });
76
- };
77
-
78
- // Initial program setup
79
- program.storeOptionsAsProperties(false).allowUnknownOption(true);
80
-
81
- program.helpOption('-h, --help', 'Display help for command');
82
- program.addHelpCommand('help [command]', 'Display help for command');
83
-
84
- // `$ strapi version` (--version synonym)
85
- program.version(packageJSON.version, '-v, --version', 'Output the version number');
86
- program
87
- .command('version')
88
- .description('Output the version of Strapi')
89
- .action(() => {
90
- process.stdout.write(`${packageJSON.version}\n`);
91
- process.exit(0);
92
- });
93
-
94
- // `$ strapi console`
95
- program
96
- .command('console')
97
- .description('Open the Strapi framework console')
98
- .action(getLocalScript('console'));
99
-
100
- // `$ strapi new`
101
- program
102
- .command('new <directory>')
103
- .option('--no-run', 'Do not start the application after it is created')
104
- .option('--use-npm', 'Force usage of npm instead of yarn to create the project')
105
- .option('--debug', 'Display database connection errors')
106
- .option('--quickstart', 'Create quickstart app')
107
- .option('--dbclient <dbclient>', 'Database client')
108
- .option('--dbhost <dbhost>', 'Database host')
109
- .option('--dbport <dbport>', 'Database port')
110
- .option('--dbname <dbname>', 'Database name')
111
- .option('--dbusername <dbusername>', 'Database username')
112
- .option('--dbpassword <dbpassword>', 'Database password')
113
- .option('--dbssl <dbssl>', 'Database SSL')
114
- .option('--dbfile <dbfile>', 'Database file path for sqlite')
115
- .option('--dbforce', 'Allow overwriting existing database content')
116
- .option('-ts, --typescript', 'Create a typescript project')
117
- .description('Create a new application')
118
- .action(require('../lib/commands/new'));
119
-
120
- // `$ strapi start`
121
- program
122
- .command('start')
123
- .description('Start your Strapi application')
124
- .action(getLocalScript('start'));
125
-
126
- // `$ strapi develop`
127
- program
128
- .command('develop')
129
- .alias('dev')
130
- .option('--no-build', 'Disable build')
131
- .option('--watch-admin', 'Enable watch', false)
132
- .option('--polling', 'Watch for file changes in network directories', false)
133
- .option('--browser <name>', 'Open the browser', true)
134
- .description('Start your Strapi application in development mode')
135
- .action(getLocalScript('develop'));
136
-
137
- // $ strapi generate
138
- program
139
- .command('generate')
140
- .description('Launch the interactive API generator')
141
- .action(() => {
142
- checkCwdIsStrapiApp('generate');
143
- process.argv.splice(2, 1);
144
- require('@strapi/generators').runCLI();
145
- });
146
-
147
- // `$ strapi generate:template <directory>`
148
- program
149
- .command('templates:generate <directory>')
150
- .description('Generate template from Strapi project')
151
- .action(getLocalScript('generate-template'));
152
-
153
- program
154
- .command('build')
155
- .option('--no-optimization', 'Build the admin app without optimizing assets')
156
- .description('Build the strapi admin app')
157
- .action(getLocalScript('build'));
158
-
159
- // `$ strapi install`
160
- program
161
- .command('install [plugins...]')
162
- .description('Install a Strapi plugin')
163
- .action(getLocalScript('install'));
164
-
165
- // `$ strapi uninstall`
166
- program
167
- .command('uninstall [plugins...]')
168
- .description('Uninstall a Strapi plugin')
169
- .option('-d, --delete-files', 'Delete files', false)
170
- .action(getLocalScript('uninstall'));
171
-
172
- // `$ strapi watch-admin`
173
- program
174
- .command('watch-admin')
175
- .option('--browser <name>', 'Open the browser', true)
176
- .description('Start the admin development server')
177
- .action(getLocalScript('watchAdmin'));
178
-
179
- program
180
- .command('configuration:dump')
181
- .alias('config:dump')
182
- .description('Dump configurations of your application')
183
- .option('-f, --file <file>', 'Output file, default output is stdout')
184
- .option('-p, --pretty', 'Format the output JSON with indentation and line breaks', false)
185
- .action(getLocalScript('configurationDump'));
186
-
187
- program
188
- .command('configuration:restore')
189
- .alias('config:restore')
190
- .description('Restore configurations of your application')
191
- .option('-f, --file <file>', 'Input file, default input is stdin')
192
- .option('-s, --strategy <strategy>', 'Strategy name, one of: "replace", "merge", "keep"')
193
- .action(getLocalScript('configurationRestore'));
194
-
195
- // Admin
196
- program
197
- .command('admin:create-user')
198
- .alias('admin:create')
199
- .description('Create a new admin')
200
- .option('-e, --email <email>', 'Email of the new admin')
201
- .option('-p, --password <password>', 'Password of the new admin')
202
- .option('-f, --firstname <first name>', 'First name of the new admin')
203
- .option('-l, --lastname <last name>', 'Last name of the new admin')
204
- .action(getLocalScript('admin-create'));
205
-
206
- program
207
- .command('admin:reset-user-password')
208
- .alias('admin:reset-password')
209
- .description("Reset an admin user's password")
210
- .option('-e, --email <email>', 'The user email')
211
- .option('-p, --password <password>', 'New password for the user')
212
- .action(getLocalScript('admin-reset'));
213
-
214
- program
215
- .command('routes:list')
216
- .description('List all the application routes')
217
- .action(getLocalScript('routes/list'));
218
-
219
- program
220
- .command('middlewares:list')
221
- .description('List all the application middlewares')
222
- .action(getLocalScript('middlewares/list'));
223
-
224
- program
225
- .command('policies:list')
226
- .description('List all the application policies')
227
- .action(getLocalScript('policies/list'));
228
-
229
- program
230
- .command('content-types:list')
231
- .description('List all the application content-types')
232
- .action(getLocalScript('content-types/list'));
233
-
234
- program
235
- .command('hooks:list')
236
- .description('List all the application hooks')
237
- .action(getLocalScript('hooks/list'));
238
-
239
- program
240
- .command('services:list')
241
- .description('List all the application services')
242
- .action(getLocalScript('services/list'));
243
-
244
- program
245
- .command('controllers:list')
246
- .description('List all the application controllers')
247
- .action(getLocalScript('controllers/list'));
248
-
249
- // `$ strapi opt-out-telemetry`
250
- program
251
- .command('telemetry:disable')
252
- .description('Disable anonymous telemetry and metadata sending to Strapi analytics')
253
- .action(getLocalScript('opt-out-telemetry'));
254
-
255
- // `$ strapi opt-in-telemetry`
256
- program
257
- .command('telemetry:enable')
258
- .description('Enable anonymous telemetry and metadata sending to Strapi analytics')
259
- .action(getLocalScript('opt-in-telemetry'));
260
-
261
- program
262
- .command('report')
263
- .description('Get system stats for debugging and submitting issues')
264
- .option('-u, --uuid', 'Include Project UUID')
265
- .option('-d, --dependencies', 'Include Project Dependencies')
266
- .option('--all', 'Include All Information')
267
- .action(getLocalScript('report'));
268
-
269
- program
270
- .command('ts:generate-types')
271
- .description(`Generate TypeScript typings for your schemas`)
272
- .option(
273
- '-o, --out-dir <outDir>',
274
- 'Specify a relative directory in which the schemas definitions will be generated'
275
- )
276
- .option('-f, --file <file>', 'Specify a filename to store the schemas definitions')
277
- .option('--verbose', `Display more information about the types generation`, false)
278
- .option('-s, --silent', `Run the generation silently, without any output`, false)
279
- .action(getLocalScript('ts/generate-types'));
280
-
281
- // `$ strapi transfer`
282
- program
283
- .command('transfer')
284
- .description('Transfer data from one source to another')
285
- .allowExcessArguments(false)
286
- .addOption(
287
- new Option(
288
- '--from <sourceURL>',
289
- `URL of the remote Strapi instance to get data from`
290
- ).argParser(parseURL)
291
- )
292
- .addOption(new Option('--from-token <token>', `Transfer token for the remote Strapi source`))
293
- .addOption(
294
- new Option(
295
- '--to <destinationURL>',
296
- `URL of the remote Strapi instance to send data to`
297
- ).argParser(parseURL)
298
- )
299
- .addOption(new Option('--to-token <token>', `Transfer token for the remote Strapi destination`))
300
- .addOption(forceOption)
301
- .addOption(excludeOption)
302
- .addOption(onlyOption)
303
- .addOption(throttleOption)
304
- .hook('preAction', validateExcludeOnly)
305
- .hook(
306
- 'preAction',
307
- ifOptions(
308
- (opts) => !(opts.from || opts.to) || (opts.from && opts.to),
309
- () =>
310
- exitWith(1, 'Exactly one remote source (from) or destination (to) option must be provided')
311
- )
312
- )
313
- // If --from is used, validate the URL and token
314
- .hook(
315
- 'preAction',
316
- ifOptions(
317
- (opts) => opts.from,
318
- async (thisCommand) => {
319
- assertUrlHasProtocol(thisCommand.opts().from, ['https:', 'http:']);
320
- if (!thisCommand.opts().fromToken) {
321
- const answers = await inquirer.prompt([
322
- {
323
- type: 'password',
324
- message: 'Please enter your transfer token for the remote Strapi source',
325
- name: 'fromToken',
326
- },
327
- ]);
328
- if (!answers.fromToken?.length) {
329
- exitWith(1, 'No token provided for remote source, aborting transfer.');
330
- }
331
- thisCommand.opts().fromToken = answers.fromToken;
332
- }
333
-
334
- await confirmMessage(
335
- 'The transfer will delete all the local Strapi assets and its database. Are you sure you want to proceed?',
336
- { failMessage: 'Transfer process aborted' }
337
- )(thisCommand);
338
- }
339
- )
340
- )
341
- // If --to is used, validate the URL, token, and confirm restore
342
- .hook(
343
- 'preAction',
344
- ifOptions(
345
- (opts) => opts.to,
346
- async (thisCommand) => {
347
- assertUrlHasProtocol(thisCommand.opts().to, ['https:', 'http:']);
348
- if (!thisCommand.opts().toToken) {
349
- const answers = await inquirer.prompt([
350
- {
351
- type: 'password',
352
- message: 'Please enter your transfer token for the remote Strapi destination',
353
- name: 'toToken',
354
- },
355
- ]);
356
- if (!answers.toToken?.length) {
357
- exitWith(1, 'No token provided for remote destination, aborting transfer.');
358
- }
359
- thisCommand.opts().toToken = answers.toToken;
360
- }
361
-
362
- await confirmMessage(
363
- 'The transfer will delete all the remote Strapi assets and its database. Are you sure you want to proceed?',
364
- { failMessage: 'Transfer process aborted' }
365
- )(thisCommand);
366
- }
367
- )
368
- )
369
- .action(getLocalScript('transfer/transfer'));
370
-
371
- // `$ strapi export`
372
- program
373
- .command('export')
374
- .description('Export data from Strapi to file')
375
- .allowExcessArguments(false)
376
- .addOption(
377
- new Option('--no-encrypt', `Disables 'aes-128-ecb' encryption of the output file`).default(true)
378
- )
379
- .addOption(new Option('--no-compress', 'Disables gzip compression of output file').default(true))
380
- .addOption(
381
- new Option(
382
- '-k, --key <string>',
383
- 'Provide encryption key in command instead of using the prompt'
384
- )
385
- )
386
- .addOption(new Option('-f, --file <file>', 'name to use for exported file (without extensions)'))
387
- .addOption(excludeOption)
388
- .addOption(onlyOption)
389
- .addOption(throttleOption)
390
- .hook('preAction', validateExcludeOnly)
391
- .hook('preAction', promptEncryptionKey)
392
- .action(getLocalScript('transfer/export'));
393
-
394
- // `$ strapi import`
395
- program
396
- .command('import')
397
- .description('Import data from file to Strapi')
398
- .allowExcessArguments(false)
399
- .requiredOption(
400
- '-f, --file <file>',
401
- 'path and filename for the Strapi export file you want to import'
402
- )
403
- .addOption(
404
- new Option(
405
- '-k, --key <string>',
406
- 'Provide encryption key in command instead of using the prompt'
407
- )
408
- )
409
- .addOption(forceOption)
410
- .addOption(excludeOption)
411
- .addOption(onlyOption)
412
- .addOption(throttleOption)
413
- .hook('preAction', validateExcludeOnly)
414
- .hook('preAction', async (thisCommand) => {
415
- const opts = thisCommand.opts();
416
- const ext = path.extname(String(opts.file));
417
-
418
- // check extension to guess if we should prompt for key
419
- if (ext === '.enc') {
420
- if (!opts.key) {
421
- const answers = await inquirer.prompt([
422
- {
423
- type: 'password',
424
- message: 'Please enter your decryption key',
425
- name: 'key',
426
- },
427
- ]);
428
- if (!answers.key?.length) {
429
- exitWith(1, 'No key entered, aborting import.');
430
- }
431
- opts.key = answers.key;
432
- }
433
- }
434
- })
435
- // set decrypt and decompress options based on filename
436
- .hook('preAction', (thisCommand) => {
437
- const opts = thisCommand.opts();
438
-
439
- const { extname, parse } = path;
440
-
441
- let file = opts.file;
442
-
443
- if (extname(file) === '.enc') {
444
- file = parse(file).name; // trim the .enc extension
445
- thisCommand.opts().decrypt = true;
446
- } else {
447
- thisCommand.opts().decrypt = false;
448
- }
449
-
450
- if (extname(file) === '.gz') {
451
- file = parse(file).name; // trim the .gz extension
452
- thisCommand.opts().decompress = true;
453
- } else {
454
- thisCommand.opts().decompress = false;
455
- }
456
-
457
- if (extname(file) !== '.tar') {
458
- exitWith(
459
- 1,
460
- `The file '${opts.file}' does not appear to be a valid Strapi data file. It must have an extension ending in .tar[.gz][.enc]`
461
- );
462
- }
463
- })
464
- .hook(
465
- 'preAction',
466
- confirmMessage(
467
- 'The import will delete all assets and data in your database. Are you sure you want to proceed?',
468
- { failMessage: 'Import process aborted' }
469
- )
470
- )
471
- .action(getLocalScript('transfer/import'));
472
-
473
- program.parseAsync(process.argv);
7
+ runStrapiCommand(process.argv);
package/ee/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ This Strapi Enterprise Edition (EE) supplemental license (this “EE Supplemental License”) governs the use of this software and documentation (collectively, the “EE Software”) by you and any entity you represent (collectively, “You”). If You have separately entered into the Strapi, Inc. Enterprise Agreement (the “Enterprise Agreement”), then this EE Supplemental License hereby incorporates by reference the Enterprise Agreement and modifies the Enterprise Agreement solely to the extent set forth herein. If You have separately entered into the Strapi, Inc. Subscription Agreement (the “Subscription Agreement”), then this EE Supplemental License hereby incorporates by reference the Agreement and modifies the Subscription Agreement solely to the extent set forth herein. If You have not entered into either the Enterprise Agreement or the Subscription Agreement, then You may use the EE Software solely as set forth in Section 2 below.
2
+
3
+ In the event of a direct conflict between the terms of this EE Supplemental License and the terms of the Enterprise Agreement or the Subscription Agreement, as applicable, the terms of this EE Supplemental License will control. Except to the extent modified by this EE Supplemental License, the Enterprise Agreement or the Subscription Agreement, as applicable, remain in full force and effect in accordance with its terms.
4
+
5
+ By using the EE Software, You hereby agree to the below terms and conditions.
6
+
7
+ 1. Notwithstanding any terms to the contrary in the Enterprise Agreement or Subscription Agreement, You may copy, modify and publish patches to the EE Software in a production environment (such copies, “Production Copies,” such modifications, “Production Modifications” and such patches, “Production Patches”) if and only if (a) You have agreed to, and are in full compliance with, the Enterprise Agreement or Subscription Agreement, as applicable, and (b) You have a valid license to the EE Software for the correct number of projects. You agree that Strapi and/or its licensors (as applicable) will own all right, title and interest in and to all such Production Copies, Production Modifications and Production Patches. You may display and/or distribute such Production Copies, Production Modifications and Production Patches if and only if (i) You have a valid license to the EE Software for the correct number of projects and (ii) You are in compliance with the Enterprise Agreement or Subscription Agreement, as applicable. You hereby assign to Strapi all right, title and interest in and to all Production Copies, Production Modifications and Production Patches, including all intellectual property rights embodied in or related to the foregoing.
8
+
9
+ 2. Notwithstanding the foregoing, You may copy and modify the EE Software solely for development and testing purposes (such copies, “Development Copies” and such modifications, “Development Modifications”) with or without a license to the EE Software if your use is in compliance with this Section 2. You agree that Strapi and/or its licensors (as applicable) will own all right, title and interest in and to all Development Copies and Development Modifications and You hereby assign to Strapi all right, title and interest in and to all Development Copies and Development Modifications, including all intellectual property rights embodied in or related to the foregoing. If You do not have a license to the EE Software, then You further agree as follows:
10
+
11
+ Other than as expressly set forth in this Section 2, You may not (a) copy or modify the EE Software, (b) create derivative works of the EE Software, (c) remove or modify any notice of any patent, copyright, trademark, or other proprietary rights that appear on or in the EE Software, (d) reverse engineer, decompile, translate, disassemble, or discover the source code of all or any portion of the EE Software, (e) publicly display all or any part of the EE Software, (f) distribute, disclose, market, lease, publish, merge, resell, assign, loan, sublicense, rent, or transfer the EE Software to any third party, (g) use the EE Software for any dial-up, remote access, interactive, or other on-line or hosted service, or to provide a service bureau, time share, or other services to third parties, (h) merge the EE Software into another product, (i) disclose the results of any EE Software performance benchmarks or test results to any third party without Strapi’s prior written consent, (j) use any trademarks, logos, service marks, trade names of Strapi, or any portion thereof, without Strapi’s prior written consent, (k) use the EE Software, or any portion thereof, in a manner that does not comply with applicable law, regulations, or governmental orders, or (l) use or store the EE Software on equipment not owned or controlled by Customer.
12
+
13
+ THE EE SOFTWARE IS PROVIDED ON AN “AS IS” BASIS WITHOUT ANY REPRESENTATIONS, WARRANTIES, COVENANTS, OR CONDITIONS OF ANY KIND (EXPRESS OR IMPLIED, STATUTORY OR OTHERWISE), INCLUDING, BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, TITLE, FITNESS FOR A PARTICULAR PURPOSE, OR NONINFRINGEMENT. FURTHER, STRAPI DOES NOT REPRESENT OR WARRANT THAT (A) THE ACCESS TO OR USE OF THE EE SOFTWARE WILL BE SECURE, TIMELY, UNINTERRUPTED, ERROR-FREE, OR OPERATE IN COMBINATION WITH ANY OTHER HARDWARE, SOFTWARE, SYSTEM, OR DATA, (B) THE EE SOFTWARE WILL MEET YOUR REQUIREMENTS OR EXPECTATIONS, OR OTHERWISE PRODUCE ANY PARTICULAR RESULTS, (C) ERRORS OR DEFECTS WILL BE CORRECTED, PATCHES OR WORKAROUNDS WILL BE PROVIDED, OR STRAPI WILL DETECT ANY BUG IN THE EE SOFTWARE, (D) THE SOFTWARE IS FREE OF VIRUSES OR OTHER HARMFUL COMPONENTS, OR (E) THIRD-PARTY DISRUPTIONS OR SECURITY BREACHES OF THE EE SOFTWARE WILL BE PREVENTED.
14
+
15
+ STRAPI WILL NOT BE LIABLE FOR ANY LOSS OF PROFITS OR ANY INDIRECT, SPECIAL, INCIDENTAL, RELIANCE, OR CONSEQUENTIAL DAMAGES OF ANY KIND, REGARDLESS OF THE FORM OF ACTION, WHETHER IN CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY, OR OTHERWISE, EVEN IF INFORMED OF THE POSSIBILITY OF SUCH DAMAGES IN ADVANCE.
16
+
17
+ STRAPI’S ENTIRE LIABILITY TO YOU FOR USE OF THE EE SOFTWARE WILL NOT EXCEED $100.
18
+
19
+ 3. You are not granted any other rights beyond what is expressly stated herein and in the Enterprise Agreement or Subscription Agreement, as applicable.
20
+
21
+ 4. This EE Supplemental License does not apply to Strapi software that is distributed as part of the Strapi Community Edition (CE) (the “CE Software”).
package/ee/index.js CHANGED
@@ -105,7 +105,9 @@ const onlineUpdate = async ({ strapi }) => {
105
105
  };
106
106
 
107
107
  const license = shouldContactRegistry
108
- ? await fetchLicense(ee.licenseInfo.licenseKey, strapi.config.get('uuid')).catch(fallback)
108
+ ? await fetchLicense({ strapi }, ee.licenseInfo.licenseKey, strapi.config.get('uuid')).catch(
109
+ fallback
110
+ )
109
111
  : storedInfo.license;
110
112
 
111
113
  if (license) {
package/ee/license.js CHANGED
@@ -3,7 +3,6 @@
3
3
  const fs = require('fs');
4
4
  const { join } = require('path');
5
5
  const crypto = require('crypto');
6
- const fetch = require('node-fetch');
7
6
 
8
7
  const machineId = require('../lib/utils/machine-id');
9
8
 
@@ -69,12 +68,14 @@ const throwError = () => {
69
68
  throw new LicenseCheckError('Could not proceed to the online validation of your license.', true);
70
69
  };
71
70
 
72
- const fetchLicense = async (key, projectId) => {
73
- const response = await fetch(`https://license.strapi.io/api/licenses/validate`, {
74
- method: 'POST',
75
- headers: { 'Content-Type': 'application/json' },
76
- body: JSON.stringify({ key, projectId, deviceId: machineId() }),
77
- }).catch(throwError);
71
+ const fetchLicense = async ({ strapi }, key, projectId) => {
72
+ const response = await strapi
73
+ .fetch(`https://license.strapi.io/api/licenses/validate`, {
74
+ method: 'POST',
75
+ headers: { 'Content-Type': 'application/json' },
76
+ body: JSON.stringify({ key, projectId, deviceId: machineId() }),
77
+ })
78
+ .catch(throwError);
78
79
 
79
80
  const contentType = response.headers.get('Content-Type');
80
81
 
package/lib/Strapi.js CHANGED
@@ -27,6 +27,7 @@ const createCustomFields = require('./services/custom-fields');
27
27
  const createContentAPI = require('./services/content-api');
28
28
  const createUpdateNotifier = require('./utils/update-notifier');
29
29
  const createStartupLogger = require('./utils/startup-logger');
30
+ const createStrapiFetch = require('./utils/fetch');
30
31
  const { LIFECYCLES } = require('./utils/lifecycles');
31
32
  const ee = require('./utils/ee');
32
33
  const contentTypesRegistry = require('./core/registries/content-types');
@@ -118,6 +119,7 @@ class Strapi {
118
119
  this.telemetry = createTelemetry(this);
119
120
  this.requestContext = requestContext;
120
121
  this.customFields = createCustomFields(this);
122
+ this.fetch = createStrapiFetch(this);
121
123
 
122
124
  createUpdateNotifier(this).notify();
123
125
 
@@ -393,6 +395,7 @@ class Strapi {
393
395
  eventHub: this.eventHub,
394
396
  logger: this.log,
395
397
  configuration: this.config.get('server.webhooks', {}),
398
+ fetch: this.fetch,
396
399
  });
397
400
 
398
401
  this.registerInternalHooks();
@@ -3,7 +3,7 @@
3
3
  const { yup } = require('@strapi/utils');
4
4
  const _ = require('lodash');
5
5
  const inquirer = require('inquirer');
6
- const strapi = require('../index');
6
+ const strapi = require('../../../../index');
7
7
 
8
8
  const emailValidator = yup.string().email('Invalid email address').lowercase();
9
9
 
@@ -57,7 +57,7 @@ const promptQuestions = [
57
57
  * @param {string} cmdOptions.firstname - new admin's first name
58
58
  * @param {string} [cmdOptions.lastname] - new admin's last name
59
59
  */
60
- module.exports = async function (cmdOptions = {}) {
60
+ module.exports = async (cmdOptions = {}) => {
61
61
  let { email, password, firstname, lastname } = cmdOptions;
62
62
 
63
63
  if (
@@ -0,0 +1,19 @@
1
+ 'use strict';
2
+
3
+ const { getLocalScript } = require('../../../utils/helpers');
4
+
5
+ /**
6
+ * `$ strapi admin:create-user`
7
+ * @param {import('../../../../types/core/commands').AddCommandOptions} options
8
+ */
9
+ module.exports = ({ command }) => {
10
+ command
11
+ .command('admin:create-user')
12
+ .alias('admin:create')
13
+ .description('Create a new admin')
14
+ .option('-e, --email <email>', 'Email of the new admin')
15
+ .option('-p, --password <password>', 'Password of the new admin')
16
+ .option('-f, --firstname <first name>', 'First name of the new admin')
17
+ .option('-l, --lastname <last name>', 'Last name of the new admin')
18
+ .action(getLocalScript('admin/create-user'));
19
+ };
@@ -2,7 +2,7 @@
2
2
 
3
3
  const _ = require('lodash');
4
4
  const inquirer = require('inquirer');
5
- const strapi = require('../index');
5
+ const strapi = require('../../../../index');
6
6
 
7
7
  const promptQuestions = [
8
8
  { type: 'input', name: 'email', message: 'User email?' },
@@ -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 (cmdOptions = {}) => {
24
24
  const { email, password } = cmdOptions;
25
25
 
26
26
  if (_.isEmpty(email) && _.isEmpty(password) && process.stdin.isTTY) {
@@ -0,0 +1,17 @@
1
+ 'use strict';
2
+
3
+ const { getLocalScript } = require('../../../utils/helpers');
4
+
5
+ /**
6
+ * `$ strapi admin:reset-user-password`
7
+ * @param {import('../../../../types/core/commands').AddCommandOptions} options
8
+ */
9
+ module.exports = ({ command }) => {
10
+ command
11
+ .command('admin:reset-user-password')
12
+ .alias('admin:reset-password')
13
+ .description("Reset an admin user's password")
14
+ .option('-e, --email <email>', 'The user email')
15
+ .option('-p, --password <password>', 'New password for the user')
16
+ .action(getLocalScript('admin/reset-user-password'));
17
+ };
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  const fs = require('fs');
4
- const strapi = require('../index');
4
+ const strapi = require('../../../../index');
5
5
 
6
6
  const CHUNK_SIZE = 100;
7
7
 
@@ -0,0 +1,17 @@
1
+ 'use strict';
2
+
3
+ const { getLocalScript } = require('../../../utils/helpers');
4
+
5
+ /**
6
+ * `$ strapi configuration:dump`
7
+ * @param {import('../../../../types/core/commands').AddCommandOptions} options
8
+ */
9
+ module.exports = ({ command }) => {
10
+ command
11
+ .command('configuration:dump')
12
+ .alias('config:dump')
13
+ .description('Dump configurations of your application')
14
+ .option('-f, --file <file>', 'Output file, default output is stdout')
15
+ .option('-p, --pretty', 'Format the output JSON with indentation and line breaks', false)
16
+ .action(getLocalScript('configuration/dump'));
17
+ };