@strapi/strapi 4.10.0-beta.0 → 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 (85) hide show
  1. package/.eslintignore +2 -0
  2. package/.eslintrc.js +4 -0
  3. package/bin/strapi.js +2 -455
  4. package/ee/LICENSE.txt +21 -0
  5. package/ee/index.js +42 -5
  6. package/ee/license.js +11 -8
  7. package/lib/Strapi.js +14 -7
  8. package/lib/commands/{admin-create.js → actions/admin/create-user/action.js} +2 -2
  9. package/lib/commands/actions/admin/create-user/command.js +19 -0
  10. package/lib/commands/{admin-reset.js → actions/admin/reset-user-password/action.js} +2 -2
  11. package/lib/commands/actions/admin/reset-user-password/command.js +17 -0
  12. package/lib/commands/{configurationDump.js → actions/configuration/dump/action.js} +1 -1
  13. package/lib/commands/actions/configuration/dump/command.js +17 -0
  14. package/lib/commands/{configurationRestore.js → actions/configuration/restore/action.js} +1 -1
  15. package/lib/commands/actions/configuration/restore/command.js +17 -0
  16. package/lib/commands/{console.js → actions/console/action.js} +2 -2
  17. package/lib/commands/actions/console/command.js +14 -0
  18. package/lib/commands/{content-types/list.js → actions/content-types/list/action.js} +2 -2
  19. package/lib/commands/actions/content-types/list/command.js +14 -0
  20. package/lib/commands/{controllers/list.js → actions/controllers/list/action.js} +2 -2
  21. package/lib/commands/actions/controllers/list/command.js +14 -0
  22. package/lib/commands/{develop.js → actions/develop/action.js} +3 -3
  23. package/lib/commands/actions/develop/command.js +19 -0
  24. package/lib/commands/{transfer/export.js → actions/export/action.js} +27 -19
  25. package/lib/commands/actions/export/command.js +45 -0
  26. package/lib/commands/actions/generate/command.js +18 -0
  27. package/lib/commands/{hooks/list.js → actions/hooks/list/action.js} +2 -2
  28. package/lib/commands/actions/hooks/list/command.js +14 -0
  29. package/lib/commands/{transfer/import.js → actions/import/action.js} +39 -18
  30. package/lib/commands/actions/import/command.js +97 -0
  31. package/lib/commands/{install.js → actions/install/action.js} +1 -1
  32. package/lib/commands/actions/install/command.js +14 -0
  33. package/lib/commands/{middlewares/list.js → actions/middlewares/list/action.js} +2 -2
  34. package/lib/commands/actions/middlewares/list/command.js +14 -0
  35. package/lib/commands/{new.js → actions/new/action.js} +1 -1
  36. package/lib/commands/actions/new/command.js +35 -0
  37. package/lib/commands/{policies/list.js → actions/policies/list/action.js} +2 -2
  38. package/lib/commands/actions/policies/list/command.js +14 -0
  39. package/lib/commands/actions/report/action.js +35 -0
  40. package/lib/commands/actions/report/command.js +17 -0
  41. package/lib/commands/{routes/list.js → actions/routes/list/action.js} +2 -2
  42. package/lib/commands/actions/routes/list/command.js +14 -0
  43. package/lib/commands/{services/list.js → actions/services/list/action.js} +2 -2
  44. package/lib/commands/actions/services/list/command.js +14 -0
  45. package/lib/commands/{start.js → actions/start/action.js} +1 -1
  46. package/lib/commands/actions/start/command.js +14 -0
  47. package/lib/commands/{opt-out-telemetry.js → actions/telemetry/disable/action.js} +1 -1
  48. package/lib/commands/actions/telemetry/disable/command.js +14 -0
  49. package/lib/commands/{opt-in-telemetry.js → actions/telemetry/enable/action.js} +1 -1
  50. package/lib/commands/actions/telemetry/enable/command.js +14 -0
  51. package/lib/commands/actions/templates/generate/command.js +14 -0
  52. package/lib/commands/{transfer/transfer.js → actions/transfer/action.js} +61 -14
  53. package/lib/commands/actions/transfer/command.js +115 -0
  54. package/lib/commands/{ts/generate-types.js → actions/ts/generate-types/action.js} +2 -2
  55. package/lib/commands/actions/ts/generate-types/command.js +21 -0
  56. package/lib/commands/{uninstall.js → actions/uninstall/action.js} +1 -1
  57. package/lib/commands/actions/uninstall/command.js +15 -0
  58. package/lib/commands/actions/version/command.js +19 -0
  59. package/lib/commands/{watchAdmin.js → actions/watch-admin/action.js} +4 -4
  60. package/lib/commands/actions/watch-admin/command.js +15 -0
  61. package/lib/commands/index.js +66 -0
  62. package/lib/commands/utils/commander.js +14 -0
  63. package/lib/commands/{transfer/utils.js → utils/data-transfer.js} +54 -5
  64. package/lib/commands/utils/helpers.js +54 -3
  65. package/lib/core/domain/content-type/validator.js +1 -1
  66. package/lib/core/loaders/plugins/index.js +7 -2
  67. package/lib/core/registries/custom-fields.js +19 -2
  68. package/lib/core/registries/policies.d.ts +3 -3
  69. package/lib/core-api/controller/collection-type.js +0 -1
  70. package/lib/core-api/controller/index.js +1 -1
  71. package/lib/factories.js +3 -4
  72. package/lib/middlewares/logger.js +1 -17
  73. package/lib/middlewares/security.js +1 -1
  74. package/lib/services/event-hub.js +6 -1
  75. package/lib/services/metrics/index.js +1 -0
  76. package/lib/services/metrics/sender.js +1 -14
  77. package/lib/services/server/index.js +2 -2
  78. package/lib/services/server/register-routes.js +1 -1
  79. package/lib/services/utils/dynamic-zones.js +13 -0
  80. package/lib/services/webhook-runner.js +4 -4
  81. package/lib/types/core/commands/index.d.ts +6 -0
  82. package/lib/utils/fetch.js +23 -0
  83. package/package.json +22 -21
  84. package/lib/commands/build.js +0 -18
  85. /package/lib/commands/{generate-template.js → actions/templates/generate/action.js} +0 -0
@@ -12,7 +12,7 @@ const defaults = {
12
12
  useDefaults: true,
13
13
  directives: {
14
14
  'connect-src': ["'self'", 'https:'],
15
- 'img-src': ["'self'", 'data:', 'blob:', 'https://dl.airtable.com'],
15
+ 'img-src': ["'self'", 'data:', 'blob:', 'https://market-assets.strapi.io'],
16
16
  'media-src': ["'self'", 'data:', 'blob:'],
17
17
  upgradeInsecureRequests: null,
18
18
  },
@@ -35,7 +35,12 @@ module.exports = function createEventHub() {
35
35
  },
36
36
 
37
37
  unsubscribe(subscriber) {
38
- subscribers.splice(subscribers.indexOf(subscriber), 1);
38
+ const subscriberIndex = subscribers.indexOf(subscriber);
39
+
40
+ // Only remove the subscriber if it exists
41
+ if (subscriberIndex >= 0) {
42
+ subscribers.splice(subscriberIndex, 1);
43
+ }
39
44
  },
40
45
 
41
46
  on(eventName, listener) {
@@ -17,6 +17,7 @@ const LIMITED_EVENTS = [
17
17
  'didSaveMediaWithCaption',
18
18
  'didDisableResponsiveDimensions',
19
19
  'didEnableResponsiveDimensions',
20
+ 'didInitializePluginUpload',
20
21
  ];
21
22
 
22
23
  const createTelemetryInstance = (strapi) => {
@@ -3,9 +3,7 @@
3
3
  const os = require('os');
4
4
  const path = require('path');
5
5
  const _ = require('lodash');
6
- const { map, values, sumBy, pipe, flatMap, propEq } = require('lodash/fp');
7
6
  const isDocker = require('is-docker');
8
- const fetch = require('node-fetch');
9
7
  const ciEnv = require('ci-info');
10
8
  const { isUsingTypeScriptSync } = require('@strapi/typescript-utils');
11
9
  const { env } = require('@strapi/utils');
@@ -41,14 +39,6 @@ module.exports = (strapi) => {
41
39
  const serverRootPath = strapi.dirs.app.root;
42
40
  const adminRootPath = path.join(strapi.dirs.app.root, 'src', 'admin');
43
41
 
44
- const getNumberOfDynamicZones = () => {
45
- return pipe(
46
- map('attributes'),
47
- flatMap(values),
48
- sumBy(propEq('type', 'dynamiczone'))
49
- )(strapi.contentTypes);
50
- };
51
-
52
42
  const anonymousUserProperties = {
53
43
  environment: strapi.config.environment,
54
44
  os: os.type(),
@@ -66,9 +56,6 @@ module.exports = (strapi) => {
66
56
  useTypescriptOnAdmin: isUsingTypeScriptSync(adminRootPath),
67
57
  projectId: uuid,
68
58
  isHostedOnStrapiCloud: env('STRAPI_HOSTING', null) === 'strapi.cloud',
69
- numberOfAllContentTypes: _.size(strapi.contentTypes), // TODO: V5: This event should be renamed numberOfContentTypes in V5 as the name is already taken to describe the number of content types using i18n.
70
- numberOfComponents: _.size(strapi.components),
71
- numberOfDynamicZones: getNumberOfDynamicZones(),
72
59
  };
73
60
 
74
61
  addPackageJsonStrapiMetadata(anonymousGroupProperties, strapi);
@@ -94,7 +81,7 @@ module.exports = (strapi) => {
94
81
  };
95
82
 
96
83
  try {
97
- const res = await fetch(`${ANALYTICS_URI}/api/v2/track`, reqParams);
84
+ const res = await strapi.fetch(`${ANALYTICS_URI}/api/v2/track`, reqParams);
98
85
  return res.ok;
99
86
  } catch (err) {
100
87
  return false;
@@ -92,8 +92,8 @@ const createServer = (strapi) => {
92
92
  return this;
93
93
  },
94
94
 
95
- async initRouting() {
96
- await registerAllRoutes(strapi);
95
+ initRouting() {
96
+ registerAllRoutes(strapi);
97
97
 
98
98
  return this;
99
99
  },
@@ -69,7 +69,7 @@ const registerPluginRoutes = (strapi) => {
69
69
  } else {
70
70
  _.forEach(plugin.routes, (router) => {
71
71
  router.type = router.type || 'admin';
72
- router.prefix = `/${pluginName}`;
72
+ router.prefix = router.prefix || `/${pluginName}`;
73
73
  router.routes.forEach((route) => {
74
74
  generateRouteScope(route);
75
75
  route.info = { pluginName };
@@ -0,0 +1,13 @@
1
+ 'use strict';
2
+
3
+ const { map, values, sumBy, pipe, flatMap, propEq } = require('lodash/fp');
4
+
5
+ const getNumberOfDynamicZones = () => {
6
+ return pipe(
7
+ map('attributes'),
8
+ flatMap(values),
9
+ sumBy(propEq('type', 'dynamiczone'))
10
+ )(strapi.contentTypes);
11
+ };
12
+
13
+ module.exports = getNumberOfDynamicZones;
@@ -6,7 +6,6 @@
6
6
 
7
7
  const debug = require('debug')('strapi:webhook');
8
8
  const _ = require('lodash');
9
- const fetch = require('node-fetch');
10
9
 
11
10
  const WorkerQueue = require('./worker-queue');
12
11
 
@@ -15,12 +14,13 @@ const defaultConfiguration = {
15
14
  };
16
15
 
17
16
  class WebhookRunner {
18
- constructor({ eventHub, logger, configuration = {} }) {
19
- debug('Initialized webhook runer');
17
+ constructor({ eventHub, logger, configuration = {}, fetch }) {
18
+ debug('Initialized webhook runner');
20
19
  this.eventHub = eventHub;
21
20
  this.logger = logger;
22
21
  this.webhooksMap = new Map();
23
22
  this.listeners = new Map();
23
+ this.fetch = fetch;
24
24
 
25
25
  if (typeof configuration !== 'object') {
26
26
  throw new Error(
@@ -76,7 +76,7 @@ class WebhookRunner {
76
76
  run(webhook, event, info = {}) {
77
77
  const { url, headers } = webhook;
78
78
 
79
- return fetch(url, {
79
+ return this.fetch(url, {
80
80
  method: 'post',
81
81
  body: JSON.stringify({
82
82
  event,
@@ -0,0 +1,6 @@
1
+ import { Command } from 'commander';
2
+
3
+ export type AddCommandOptions = {
4
+ command: Command;
5
+ argv: Record<number, string>;
6
+ };
@@ -0,0 +1,23 @@
1
+ 'use strict';
2
+
3
+ const nodeFetch = require('node-fetch');
4
+ const HttpsProxyAgent = require('https-proxy-agent');
5
+
6
+ function createStrapiFetch(strapi) {
7
+ function fetch(url, options) {
8
+ return nodeFetch(url, {
9
+ ...(fetch.agent ? { agent: fetch.agent } : {}),
10
+ ...options,
11
+ });
12
+ }
13
+
14
+ const { globalProxy: proxy } = strapi.config.get('server');
15
+
16
+ if (proxy) {
17
+ fetch.agent = new HttpsProxyAgent(proxy);
18
+ }
19
+
20
+ return fetch;
21
+ }
22
+
23
+ module.exports = createStrapiFetch;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@strapi/strapi",
3
- "version": "4.10.0-beta.0",
3
+ "version": "4.10.0",
4
4
  "description": "An open source headless CMS solution to create and manage your own API. It provides a powerful dashboard and features to make your life easier. Databases supported: MySQL, MariaDB, PostgreSQL, SQLite",
5
5
  "keywords": [
6
6
  "strapi",
@@ -66,9 +66,7 @@
66
66
  ],
67
67
  "main": "./lib",
68
68
  "types": "./lib/index.d.ts",
69
- "bin": {
70
- "strapi": "./bin/strapi.js"
71
- },
69
+ "bin": "./bin/strapi.js",
72
70
  "directories": {
73
71
  "lib": "./lib",
74
72
  "bin": "./bin",
@@ -76,24 +74,26 @@
76
74
  },
77
75
  "scripts": {
78
76
  "postinstall": "node lib/utils/success.js",
79
- "test:unit": "jest --verbose"
77
+ "test:unit": "run -T jest",
78
+ "test:unit:watch": "run -T jest --watch",
79
+ "lint": "run -T eslint ."
80
80
  },
81
81
  "dependencies": {
82
82
  "@koa/cors": "3.4.3",
83
83
  "@koa/router": "10.1.1",
84
- "@strapi/admin": "4.10.0-beta.0",
85
- "@strapi/data-transfer": "4.10.0-beta.0",
86
- "@strapi/database": "4.10.0-beta.0",
87
- "@strapi/generate-new": "4.10.0-beta.0",
88
- "@strapi/generators": "4.10.0-beta.0",
89
- "@strapi/logger": "4.10.0-beta.0",
90
- "@strapi/permissions": "4.10.0-beta.0",
91
- "@strapi/plugin-content-manager": "4.10.0-beta.0",
92
- "@strapi/plugin-content-type-builder": "4.10.0-beta.0",
93
- "@strapi/plugin-email": "4.10.0-beta.0",
94
- "@strapi/plugin-upload": "4.10.0-beta.0",
95
- "@strapi/typescript-utils": "4.10.0-beta.0",
96
- "@strapi/utils": "4.10.0-beta.0",
84
+ "@strapi/admin": "4.10.0",
85
+ "@strapi/data-transfer": "4.10.0",
86
+ "@strapi/database": "4.10.0",
87
+ "@strapi/generate-new": "4.10.0",
88
+ "@strapi/generators": "4.10.0",
89
+ "@strapi/logger": "4.10.0",
90
+ "@strapi/permissions": "4.10.0",
91
+ "@strapi/plugin-content-manager": "4.10.0",
92
+ "@strapi/plugin-content-type-builder": "4.10.0",
93
+ "@strapi/plugin-email": "4.10.0",
94
+ "@strapi/plugin-upload": "4.10.0",
95
+ "@strapi/typescript-utils": "4.10.0",
96
+ "@strapi/utils": "4.10.0",
97
97
  "bcryptjs": "2.4.3",
98
98
  "boxen": "5.1.2",
99
99
  "chalk": "4.1.2",
@@ -109,6 +109,7 @@
109
109
  "fs-extra": "10.0.0",
110
110
  "glob": "7.2.0",
111
111
  "http-errors": "1.8.1",
112
+ "https-proxy-agent": "5.0.1",
112
113
  "inquirer": "8.2.5",
113
114
  "is-docker": "2.2.1",
114
115
  "koa": "2.13.4",
@@ -128,7 +129,7 @@
128
129
  "open": "8.4.0",
129
130
  "ora": "5.4.1",
130
131
  "package-json": "7.0.0",
131
- "qs": "6.11.0",
132
+ "qs": "6.11.1",
132
133
  "resolve-cwd": "3.0.0",
133
134
  "semver": "7.3.8",
134
135
  "statuses": "2.0.1",
@@ -136,11 +137,11 @@
136
137
  },
137
138
  "devDependencies": {
138
139
  "supertest": "6.3.3",
139
- "typescript": "4.6.2"
140
+ "typescript": "5.0.4"
140
141
  },
141
142
  "engines": {
142
143
  "node": ">=14.19.1 <=18.x.x",
143
144
  "npm": ">=6.0.0"
144
145
  },
145
- "gitHead": "1519ef0e56d27b738f24fc88223797651ad47aaf"
146
+ "gitHead": "9b5519778faaedfb837879f9c6f7e28fdfd6750d"
146
147
  }
@@ -1,18 +0,0 @@
1
- 'use strict';
2
-
3
- const strapi = require('..');
4
- const { buildAdmin } = require('./builders');
5
-
6
- /**
7
- * `$ strapi build`
8
- */
9
- module.exports = async ({ optimization, forceBuild = true }) => {
10
- const { appDir, distDir } = await strapi.compile();
11
-
12
- await buildAdmin({
13
- forceBuild,
14
- optimization,
15
- buildDestDir: distDir,
16
- srcDir: appDir,
17
- });
18
- };