@strapi/strapi 4.0.0-next.7 → 4.0.1
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 +14 -14
- package/bin/strapi.js +46 -60
- package/lib/Strapi.js +193 -98
- package/lib/commands/build.js +19 -8
- package/lib/commands/console.js +1 -1
- package/lib/commands/content-types/list.js +22 -0
- package/lib/commands/controllers/list.js +22 -0
- package/lib/commands/develop.js +22 -27
- package/lib/commands/generate-template.js +4 -5
- package/lib/commands/hooks/list.js +22 -0
- package/lib/commands/middlewares/list.js +22 -0
- package/lib/commands/new.js +3 -1
- package/lib/commands/policies/list.js +22 -0
- package/lib/commands/routes/list.js +28 -0
- package/lib/commands/services/list.js +22 -0
- package/lib/commands/watchAdmin.js +18 -9
- package/lib/core/app-configuration/index.js +3 -36
- package/lib/core/bootstrap.js +25 -0
- package/lib/core/domain/content-type/index.js +26 -29
- package/lib/core/domain/content-type/validator.js +22 -3
- package/lib/core/domain/module/index.js +42 -11
- package/lib/core/domain/module/validation.js +16 -19
- package/lib/core/loaders/admin.js +16 -0
- package/lib/core/loaders/apis.js +159 -0
- package/lib/core/loaders/{load-components.js → components.js} +5 -6
- package/lib/core/loaders/index.js +11 -0
- package/lib/core/loaders/middlewares.js +36 -0
- package/lib/core/{load-plugins → loaders/plugins}/get-enabled-plugins.js +55 -19
- package/lib/core/loaders/plugins/get-user-plugins-config.js +37 -0
- package/lib/core/{load-plugins → loaders/plugins}/index.js +35 -19
- package/lib/core/loaders/policies.js +28 -0
- package/lib/core/loaders/src-index.js +39 -0
- package/lib/core/registries/apis.js +29 -0
- package/lib/core/registries/content-types.js +66 -10
- package/lib/core/registries/controllers.d.ts +7 -0
- package/lib/core/registries/controllers.js +92 -7
- package/lib/core/registries/hooks.d.ts +20 -0
- package/lib/core/registries/hooks.js +87 -0
- package/lib/core/registries/middlewares.d.ts +5 -0
- package/lib/core/registries/middlewares.js +65 -5
- package/lib/core/registries/modules.js +3 -3
- package/lib/core/registries/plugins.js +2 -2
- package/lib/core/registries/policies.d.ts +9 -0
- package/lib/core/registries/policies.js +65 -5
- package/lib/core/registries/services.d.ts +7 -0
- package/lib/core/registries/services.js +88 -17
- package/lib/core/utils.js +35 -0
- package/lib/core-api/controller/collection-type.js +45 -26
- package/lib/core-api/controller/index.d.ts +25 -0
- package/lib/core-api/controller/index.js +33 -11
- package/lib/core-api/controller/single-type.js +29 -15
- package/lib/core-api/controller/transform.js +62 -6
- package/lib/core-api/routes/index.js +71 -0
- package/lib/core-api/service/collection-type.js +43 -21
- package/lib/core-api/service/index.d.ts +21 -0
- package/lib/core-api/service/index.js +8 -67
- package/lib/core-api/service/pagination.js +125 -0
- package/lib/core-api/service/single-type.js +17 -19
- package/lib/factories.d.ts +48 -0
- package/lib/factories.js +84 -0
- package/lib/index.d.ts +10 -31
- package/lib/index.js +5 -1
- package/lib/middlewares/body.js +33 -0
- package/lib/middlewares/compression.js +8 -0
- package/lib/middlewares/cors.js +58 -0
- package/lib/middlewares/errors.js +40 -0
- package/lib/middlewares/favicon.js +19 -0
- package/lib/middlewares/index.d.ts +5 -0
- package/lib/middlewares/index.js +30 -116
- package/lib/middlewares/ip.js +8 -0
- package/lib/middlewares/logger.js +27 -0
- package/lib/middlewares/powered-by.js +20 -0
- package/lib/middlewares/public/index.js +72 -77
- package/lib/middlewares/query.js +46 -0
- package/lib/middlewares/response-time.js +15 -0
- package/lib/middlewares/responses.js +19 -0
- package/lib/middlewares/security.js +51 -0
- package/lib/middlewares/session/index.js +6 -6
- package/lib/migrations/draft-publish.js +57 -0
- package/lib/services/auth/index.js +87 -0
- package/lib/services/core-store.js +64 -51
- package/lib/services/cron.js +54 -0
- package/lib/services/entity-service/attributes/index.js +31 -0
- package/lib/services/entity-service/attributes/transforms.js +20 -0
- package/lib/services/entity-service/components.js +39 -15
- package/lib/services/entity-service/index.d.ts +91 -0
- package/lib/services/entity-service/index.js +120 -59
- package/lib/services/entity-service/params.js +52 -94
- package/lib/services/entity-validator/index.js +76 -43
- package/lib/services/entity-validator/validators.js +131 -43
- package/lib/services/errors.js +77 -0
- package/lib/{core → services}/fs.js +1 -1
- package/lib/services/metrics/index.js +38 -36
- package/lib/services/server/admin-api.js +14 -0
- package/lib/services/server/api.js +36 -0
- package/lib/services/server/compose-endpoint.js +141 -0
- package/lib/services/server/content-api.js +16 -0
- package/lib/{server.js → services/server/http-server.js} +0 -0
- package/lib/services/server/index.js +127 -0
- package/lib/services/server/koa.js +64 -0
- package/lib/services/server/middleware.js +122 -0
- package/lib/services/server/policy.js +32 -0
- package/lib/services/server/register-middlewares.js +110 -0
- package/lib/services/server/register-routes.js +106 -0
- package/lib/services/server/routing.js +120 -0
- package/lib/services/webhook-runner.js +1 -1
- package/lib/utils/ee.js +3 -3
- package/lib/utils/get-dirs.js +17 -0
- package/lib/utils/index.js +2 -0
- package/lib/utils/is-initialized.js +1 -1
- package/lib/utils/signals.js +24 -0
- package/lib/utils/startup-logger.js +2 -2
- package/lib/utils/update-notifier/index.js +3 -2
- package/package.json +94 -97
- package/lib/commands/generate.js +0 -76
- package/lib/core/loaders/bootstrap.js +0 -176
- package/lib/core/loaders/load-apis.js +0 -20
- package/lib/core/loaders/load-functions.js +0 -21
- package/lib/core/loaders/load-middlewares.js +0 -136
- package/lib/core/loaders/load-modules.js +0 -21
- package/lib/core/loaders/load-policies.js +0 -36
- package/lib/core/loaders/walk.js +0 -27
- package/lib/core-api/index.js +0 -39
- package/lib/load/check-reserved-filename.js +0 -10
- package/lib/load/load-config-files.js +0 -22
- package/lib/load/require-file-parse.js +0 -15
- package/lib/middlewares/boom/defaults.json +0 -5
- package/lib/middlewares/boom/index.js +0 -147
- package/lib/middlewares/cors/index.js +0 -66
- package/lib/middlewares/cron/defaults.json +0 -5
- package/lib/middlewares/cron/index.js +0 -43
- package/lib/middlewares/favicon/defaults.json +0 -7
- package/lib/middlewares/favicon/index.js +0 -32
- package/lib/middlewares/gzip/defaults.json +0 -6
- package/lib/middlewares/gzip/index.js +0 -19
- package/lib/middlewares/helmet/defaults.json +0 -18
- package/lib/middlewares/helmet/index.js +0 -9
- package/lib/middlewares/ip/defaults.json +0 -7
- package/lib/middlewares/ip/index.js +0 -25
- package/lib/middlewares/language/defaults.json +0 -9
- package/lib/middlewares/language/index.js +0 -40
- package/lib/middlewares/logger/defaults.json +0 -5
- package/lib/middlewares/logger/index.js +0 -37
- package/lib/middlewares/parser/defaults.json +0 -11
- package/lib/middlewares/parser/index.js +0 -71
- package/lib/middlewares/poweredBy/defaults.json +0 -5
- package/lib/middlewares/poweredBy/index.js +0 -16
- package/lib/middlewares/public/defaults.json +0 -8
- package/lib/middlewares/responseTime/defaults.json +0 -5
- package/lib/middlewares/responseTime/index.js +0 -25
- package/lib/middlewares/responses/defaults.json +0 -5
- package/lib/middlewares/responses/index.js +0 -18
- package/lib/middlewares/router/defaults.json +0 -7
- package/lib/middlewares/router/index.js +0 -56
- package/lib/middlewares/router/utils/composeEndpoint.js +0 -25
- package/lib/middlewares/router/utils/routerChecker.js +0 -96
- package/lib/utils/get-prefixed-dependencies.js +0 -7
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const _ = require('lodash');
|
|
4
|
+
|
|
5
|
+
const createRouteScopeGenerator = namespace => route => {
|
|
6
|
+
const prefix = namespace.endsWith('::') ? namespace : `${namespace}.`;
|
|
7
|
+
|
|
8
|
+
if (typeof route.handler === 'string') {
|
|
9
|
+
_.defaultsDeep(route, {
|
|
10
|
+
config: {
|
|
11
|
+
auth: {
|
|
12
|
+
scope: [`${route.handler.startsWith(prefix) ? '' : prefix}${route.handler}`],
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Register all routes
|
|
21
|
+
* @param {import('../../').Strapi} strapi
|
|
22
|
+
*/
|
|
23
|
+
module.exports = strapi => {
|
|
24
|
+
registerAdminRoutes(strapi);
|
|
25
|
+
registerAPIRoutes(strapi);
|
|
26
|
+
registerPluginRoutes(strapi);
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Register admin routes
|
|
31
|
+
* @param {import('../../').Strapi} strapi
|
|
32
|
+
*/
|
|
33
|
+
const registerAdminRoutes = strapi => {
|
|
34
|
+
const generateRouteScope = createRouteScopeGenerator(`admin::`);
|
|
35
|
+
|
|
36
|
+
strapi.admin.routes.forEach(route => {
|
|
37
|
+
generateRouteScope(route);
|
|
38
|
+
route.info = { pluginName: 'admin' };
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
strapi.server.routes({
|
|
42
|
+
type: 'admin',
|
|
43
|
+
prefix: '/admin',
|
|
44
|
+
routes: strapi.admin.routes,
|
|
45
|
+
});
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Register plugin routes
|
|
50
|
+
* @param {import('../../').Strapi} strapi
|
|
51
|
+
*/
|
|
52
|
+
const registerPluginRoutes = strapi => {
|
|
53
|
+
for (const pluginName in strapi.plugins) {
|
|
54
|
+
const plugin = strapi.plugins[pluginName];
|
|
55
|
+
|
|
56
|
+
const generateRouteScope = createRouteScopeGenerator(`plugin::${pluginName}`);
|
|
57
|
+
|
|
58
|
+
if (Array.isArray(plugin.routes)) {
|
|
59
|
+
plugin.routes.forEach(route => {
|
|
60
|
+
generateRouteScope(route);
|
|
61
|
+
route.info = { pluginName };
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
strapi.server.routes({
|
|
65
|
+
type: 'admin',
|
|
66
|
+
prefix: `/${pluginName}`,
|
|
67
|
+
routes: plugin.routes,
|
|
68
|
+
});
|
|
69
|
+
} else {
|
|
70
|
+
_.forEach(plugin.routes, router => {
|
|
71
|
+
router.type = router.type || 'admin';
|
|
72
|
+
router.prefix = `/${pluginName}`;
|
|
73
|
+
router.routes.forEach(route => {
|
|
74
|
+
generateRouteScope(route);
|
|
75
|
+
route.info = { pluginName };
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
strapi.server.routes(router);
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Register api routes
|
|
86
|
+
* @param {import('../../').Strapi} strapi
|
|
87
|
+
*/
|
|
88
|
+
const registerAPIRoutes = strapi => {
|
|
89
|
+
for (const apiName in strapi.api) {
|
|
90
|
+
const api = strapi.api[apiName];
|
|
91
|
+
|
|
92
|
+
const generateRouteScope = createRouteScopeGenerator(`api::${apiName}`);
|
|
93
|
+
|
|
94
|
+
_.forEach(api.routes, router => {
|
|
95
|
+
// TODO: remove once auth setup
|
|
96
|
+
// pass meta down to compose endpoint
|
|
97
|
+
router.type = 'content-api';
|
|
98
|
+
router.routes.forEach(route => {
|
|
99
|
+
generateRouteScope(route);
|
|
100
|
+
route.info = { apiName };
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
return strapi.server.routes(router);
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
};
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const Router = require('@koa/router');
|
|
4
|
+
const _ = require('lodash');
|
|
5
|
+
const { has } = require('lodash/fp');
|
|
6
|
+
const { yup } = require('@strapi/utils');
|
|
7
|
+
|
|
8
|
+
const createEndpointComposer = require('./compose-endpoint');
|
|
9
|
+
|
|
10
|
+
const policyOrMiddlewareSchema = yup.lazy(value => {
|
|
11
|
+
if (typeof value === 'string') {
|
|
12
|
+
return yup.string().required();
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
if (typeof value === 'function') {
|
|
16
|
+
return yup.mixed().isFunction();
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return yup.object({
|
|
20
|
+
name: yup.string().required(),
|
|
21
|
+
options: yup.object().notRequired(), // any options
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
const routeSchema = yup.object({
|
|
26
|
+
method: yup
|
|
27
|
+
.string()
|
|
28
|
+
.oneOf(['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'ALL'])
|
|
29
|
+
.required(),
|
|
30
|
+
path: yup.string().required(),
|
|
31
|
+
handler: yup.lazy(value => {
|
|
32
|
+
if (typeof value === 'string') {
|
|
33
|
+
return yup.string().required();
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if (Array.isArray(value)) {
|
|
37
|
+
return yup.array().required();
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return yup
|
|
41
|
+
.mixed()
|
|
42
|
+
.isFunction()
|
|
43
|
+
.required();
|
|
44
|
+
}),
|
|
45
|
+
config: yup
|
|
46
|
+
.object({
|
|
47
|
+
auth: yup.lazy(value => {
|
|
48
|
+
if (value === false) {
|
|
49
|
+
return yup.boolean().required();
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return yup.object({
|
|
53
|
+
scope: yup
|
|
54
|
+
.array()
|
|
55
|
+
.of(yup.string())
|
|
56
|
+
.required(),
|
|
57
|
+
});
|
|
58
|
+
}),
|
|
59
|
+
policies: yup
|
|
60
|
+
.array()
|
|
61
|
+
.of(policyOrMiddlewareSchema)
|
|
62
|
+
.notRequired(),
|
|
63
|
+
middlewares: yup
|
|
64
|
+
.array()
|
|
65
|
+
.of(policyOrMiddlewareSchema)
|
|
66
|
+
.notRequired(),
|
|
67
|
+
})
|
|
68
|
+
.notRequired(),
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
const validateRouteConfig = routeConfig => {
|
|
72
|
+
try {
|
|
73
|
+
return routeSchema.validateSync(routeConfig, {
|
|
74
|
+
strict: true,
|
|
75
|
+
abortEarly: false,
|
|
76
|
+
stripUnknown: true,
|
|
77
|
+
});
|
|
78
|
+
} catch (error) {
|
|
79
|
+
throw new Error('Invalid route config', error.message);
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
const createRouteManager = (strapi, opts = {}) => {
|
|
84
|
+
const { type } = opts;
|
|
85
|
+
|
|
86
|
+
const composeEndpoint = createEndpointComposer(strapi);
|
|
87
|
+
|
|
88
|
+
const createRoute = (route, router) => {
|
|
89
|
+
validateRouteConfig(route);
|
|
90
|
+
|
|
91
|
+
// NOTE: the router type is used to tag controller actions and for authentication / authorization so we need to pass this info down to the route level
|
|
92
|
+
_.set(route, 'info.type', type || 'admin');
|
|
93
|
+
|
|
94
|
+
composeEndpoint(route, { router });
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
const addRoutes = (routes, router) => {
|
|
98
|
+
if (Array.isArray(routes)) {
|
|
99
|
+
routes.forEach(route => createRoute(route, router));
|
|
100
|
+
} else if (routes.routes) {
|
|
101
|
+
const subRouter = new Router({ prefix: routes.prefix });
|
|
102
|
+
|
|
103
|
+
routes.routes.forEach(route => {
|
|
104
|
+
const hasPrefix = has('prefix', route.config);
|
|
105
|
+
createRoute(route, hasPrefix ? router : subRouter);
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
return router.use(subRouter.routes(), subRouter.allowedMethods());
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
return {
|
|
113
|
+
addRoutes,
|
|
114
|
+
};
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
module.exports = {
|
|
118
|
+
validateRouteConfig,
|
|
119
|
+
createRouteManager,
|
|
120
|
+
};
|
package/lib/utils/ee.js
CHANGED
|
@@ -78,7 +78,7 @@ module.exports = ({ dir, logger = noLog }) => {
|
|
|
78
78
|
};
|
|
79
79
|
|
|
80
80
|
Object.defineProperty(module.exports, 'licenseInfo', {
|
|
81
|
-
get
|
|
81
|
+
get() {
|
|
82
82
|
mustHaveKey('licenseInfo');
|
|
83
83
|
return internals.licenseInfo;
|
|
84
84
|
},
|
|
@@ -87,7 +87,7 @@ Object.defineProperty(module.exports, 'licenseInfo', {
|
|
|
87
87
|
});
|
|
88
88
|
|
|
89
89
|
Object.defineProperty(module.exports, 'isEE', {
|
|
90
|
-
get
|
|
90
|
+
get() {
|
|
91
91
|
mustHaveKey('isEE');
|
|
92
92
|
return internals.isEE;
|
|
93
93
|
},
|
|
@@ -96,7 +96,7 @@ Object.defineProperty(module.exports, 'isEE', {
|
|
|
96
96
|
});
|
|
97
97
|
|
|
98
98
|
Object.defineProperty(module.exports, 'features', {
|
|
99
|
-
get
|
|
99
|
+
get() {
|
|
100
100
|
mustHaveKey('licenseInfo');
|
|
101
101
|
|
|
102
102
|
const { type: licenseType } = module.exports.licenseInfo;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const { join } = require('path');
|
|
4
|
+
|
|
5
|
+
const getDirs = root => ({
|
|
6
|
+
root,
|
|
7
|
+
src: join(root, 'src'),
|
|
8
|
+
api: join(root, 'src', 'api'),
|
|
9
|
+
components: join(root, 'src', 'components'),
|
|
10
|
+
extensions: join(root, 'src', 'extensions'),
|
|
11
|
+
policies: join(root, 'src', 'policies'),
|
|
12
|
+
middlewares: join(root, 'src', 'middlewares'),
|
|
13
|
+
config: join(root, 'config'),
|
|
14
|
+
public: join(root, 'public'),
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
module.exports = getDirs;
|
package/lib/utils/index.js
CHANGED
|
@@ -14,7 +14,7 @@ module.exports = async function isInitialized(strapi) {
|
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
// test if there is at least one admin
|
|
17
|
-
const anyAdministrator = await strapi.query('
|
|
17
|
+
const anyAdministrator = await strapi.query('admin::user').findOne({ select: ['id'] });
|
|
18
18
|
|
|
19
19
|
return !isNil(anyAdministrator);
|
|
20
20
|
} catch (err) {
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const destroyOnSignal = strapi => {
|
|
4
|
+
let signalReceived = false;
|
|
5
|
+
|
|
6
|
+
// For unknown reasons, we receive signals 2 times.
|
|
7
|
+
// As a temporary fix, we ignore the signals received after the first one.
|
|
8
|
+
|
|
9
|
+
const terminateStrapi = async () => {
|
|
10
|
+
if (!signalReceived) {
|
|
11
|
+
signalReceived = true;
|
|
12
|
+
await strapi.destroy();
|
|
13
|
+
process.exit();
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
['SIGTERM', 'SIGINT'].forEach(signal => {
|
|
18
|
+
process.on(signal, terminateStrapi);
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
module.exports = {
|
|
23
|
+
destroyOnSignal,
|
|
24
|
+
};
|
|
@@ -72,7 +72,7 @@ module.exports = app => {
|
|
|
72
72
|
console.log();
|
|
73
73
|
},
|
|
74
74
|
|
|
75
|
-
logStartupMessage(isInitialized) {
|
|
75
|
+
logStartupMessage({ isInitialized } = {}) {
|
|
76
76
|
// Should the startup message be displayed?
|
|
77
77
|
const hideStartupMessage = process.env.STRAPI_HIDE_STARTUP_MESSAGE
|
|
78
78
|
? process.env.STRAPI_HIDE_STARTUP_MESSAGE === 'true'
|
|
@@ -82,7 +82,7 @@ module.exports = app => {
|
|
|
82
82
|
if (!isInitialized) {
|
|
83
83
|
this.logFirstStartupMessage();
|
|
84
84
|
} else {
|
|
85
|
-
this.
|
|
85
|
+
this.logDefaultStartupMessage();
|
|
86
86
|
}
|
|
87
87
|
}
|
|
88
88
|
},
|
|
@@ -27,7 +27,7 @@ const geUpdatetMessage = (newVersion, currentVersion) => {
|
|
|
27
27
|
|
|
28
28
|
return `
|
|
29
29
|
A new version of Strapi is available ${currentVersionLog} → ${newVersionLog}
|
|
30
|
-
Check out the new
|
|
30
|
+
Check out the new releases at: ${releaseLink}
|
|
31
31
|
`.trim();
|
|
32
32
|
};
|
|
33
33
|
|
|
@@ -38,7 +38,7 @@ const createUpdateNotifier = strapi => {
|
|
|
38
38
|
config = new Configstore(
|
|
39
39
|
pkg.name,
|
|
40
40
|
{},
|
|
41
|
-
{ configPath: path.join(strapi.
|
|
41
|
+
{ configPath: path.join(strapi.dirs.root, '.strapi-updater.json') }
|
|
42
42
|
);
|
|
43
43
|
} catch {
|
|
44
44
|
// we don't have write access to the file system
|
|
@@ -67,6 +67,7 @@ const createUpdateNotifier = strapi => {
|
|
|
67
67
|
const now = Date.now();
|
|
68
68
|
const latestVersion = config.get('latest');
|
|
69
69
|
const lastNotification = config.get('lastNotification') || 0;
|
|
70
|
+
|
|
70
71
|
if (
|
|
71
72
|
!process.stdout.isTTY ||
|
|
72
73
|
lastNotification + notifInterval > now ||
|
package/package.json
CHANGED
|
@@ -1,101 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@strapi/strapi",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.1",
|
|
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
|
-
"homepage": "https://strapi.io",
|
|
6
|
-
"directories": {
|
|
7
|
-
"lib": "./lib",
|
|
8
|
-
"bin": "./bin"
|
|
9
|
-
},
|
|
10
|
-
"main": "./lib",
|
|
11
|
-
"bin": {
|
|
12
|
-
"strapi": "./bin/strapi.js"
|
|
13
|
-
},
|
|
14
|
-
"dependencies": {
|
|
15
|
-
"@koa/cors": "^3.0.0",
|
|
16
|
-
"@strapi/admin": "4.0.0-next.7",
|
|
17
|
-
"@strapi/database": "4.0.0-next.7",
|
|
18
|
-
"@strapi/generate": "4.0.0-next.7",
|
|
19
|
-
"@strapi/generate-api": "4.0.0-next.7",
|
|
20
|
-
"@strapi/generate-controller": "4.0.0-next.7",
|
|
21
|
-
"@strapi/generate-model": "4.0.0-next.7",
|
|
22
|
-
"@strapi/generate-new": "4.0.0-next.7",
|
|
23
|
-
"@strapi/generate-plugin": "4.0.0-next.7",
|
|
24
|
-
"@strapi/generate-policy": "4.0.0-next.7",
|
|
25
|
-
"@strapi/generate-service": "4.0.0-next.7",
|
|
26
|
-
"@strapi/logger": "4.0.0-next.7",
|
|
27
|
-
"@strapi/utils": "4.0.0-next.7",
|
|
28
|
-
"async": "^2.1.2",
|
|
29
|
-
"boom": "^7.3.0",
|
|
30
|
-
"boxen": "4.2.0",
|
|
31
|
-
"chalk": "^4.1.1",
|
|
32
|
-
"chokidar": "3.5.1",
|
|
33
|
-
"ci-info": "3.1.1",
|
|
34
|
-
"cli-table3": "^0.6.0",
|
|
35
|
-
"commander": "6.1.0",
|
|
36
|
-
"configstore": "5.0.1",
|
|
37
|
-
"cross-spawn": "^7.0.3",
|
|
38
|
-
"debug": "^4.1.1",
|
|
39
|
-
"delegates": "^1.0.0",
|
|
40
|
-
"dotenv": "8.2.0",
|
|
41
|
-
"execa": "^1.0.0",
|
|
42
|
-
"fs-extra": "^9.1.0",
|
|
43
|
-
"glob": "^7.1.2",
|
|
44
|
-
"inquirer": "^6.2.1",
|
|
45
|
-
"is-docker": "2.2.1",
|
|
46
|
-
"koa": "^2.13.1",
|
|
47
|
-
"koa-body": "^4.2.0",
|
|
48
|
-
"koa-compose": "^4.1.0",
|
|
49
|
-
"koa-compress": "^5.0.1",
|
|
50
|
-
"koa-convert": "^2.0.0",
|
|
51
|
-
"koa-favicon": "^2.0.0",
|
|
52
|
-
"koa-helmet": "6.1.0",
|
|
53
|
-
"koa-i18n": "^2.1.0",
|
|
54
|
-
"koa-ip": "^2.0.0",
|
|
55
|
-
"koa-locale": "~1.3.0",
|
|
56
|
-
"koa-router": "^7.4.0",
|
|
57
|
-
"koa-session": "^6.2.0",
|
|
58
|
-
"koa-static": "^5.0.0",
|
|
59
|
-
"lodash": "4.17.21",
|
|
60
|
-
"node-fetch": "2.6.1",
|
|
61
|
-
"node-machine-id": "1.1.12",
|
|
62
|
-
"node-schedule": "1.3.2",
|
|
63
|
-
"open": "8.2.1",
|
|
64
|
-
"ora": "^5.4.0",
|
|
65
|
-
"package-json": "6.5.0",
|
|
66
|
-
"pluralize": "8.0.0",
|
|
67
|
-
"qs": "^6.10.1",
|
|
68
|
-
"resolve-cwd": "^3.0.0",
|
|
69
|
-
"rimraf": "^3.0.2",
|
|
70
|
-
"semver": "7.3.5"
|
|
71
|
-
},
|
|
72
|
-
"scripts": {
|
|
73
|
-
"postinstall": "node lib/utils/success.js"
|
|
74
|
-
},
|
|
75
|
-
"author": {
|
|
76
|
-
"email": "hi@strapi.io",
|
|
77
|
-
"name": "Strapi team",
|
|
78
|
-
"url": "https://strapi.io"
|
|
79
|
-
},
|
|
80
|
-
"maintainers": [
|
|
81
|
-
{
|
|
82
|
-
"name": "Strapi team",
|
|
83
|
-
"email": "hi@strapi.io",
|
|
84
|
-
"url": "https://strapi.io"
|
|
85
|
-
}
|
|
86
|
-
],
|
|
87
|
-
"repository": {
|
|
88
|
-
"type": "git",
|
|
89
|
-
"url": "git://github.com/strapi/strapi.git"
|
|
90
|
-
},
|
|
91
|
-
"bugs": {
|
|
92
|
-
"url": "https://github.com/strapi/strapi/issues"
|
|
93
|
-
},
|
|
94
|
-
"engines": {
|
|
95
|
-
"node": ">=12.x.x <=16.x.x",
|
|
96
|
-
"npm": ">=6.0.0"
|
|
97
|
-
},
|
|
98
|
-
"license": "SEE LICENSE IN LICENSE",
|
|
99
5
|
"keywords": [
|
|
100
6
|
"strapi",
|
|
101
7
|
"cms",
|
|
@@ -132,11 +38,102 @@
|
|
|
132
38
|
"backend",
|
|
133
39
|
"open source",
|
|
134
40
|
"self hosted",
|
|
135
|
-
"javascript",
|
|
136
41
|
"lerna",
|
|
137
42
|
"lernajs",
|
|
138
43
|
"react",
|
|
139
44
|
"reactjs"
|
|
140
45
|
],
|
|
141
|
-
"
|
|
46
|
+
"homepage": "https://strapi.io",
|
|
47
|
+
"bugs": {
|
|
48
|
+
"url": "https://github.com/strapi/strapi/issues"
|
|
49
|
+
},
|
|
50
|
+
"repository": {
|
|
51
|
+
"type": "git",
|
|
52
|
+
"url": "git://github.com/strapi/strapi.git"
|
|
53
|
+
},
|
|
54
|
+
"license": "SEE LICENSE IN LICENSE",
|
|
55
|
+
"author": {
|
|
56
|
+
"name": "Strapi Solutions SAS",
|
|
57
|
+
"email": "hi@strapi.io",
|
|
58
|
+
"url": "https://strapi.io"
|
|
59
|
+
},
|
|
60
|
+
"maintainers": [
|
|
61
|
+
{
|
|
62
|
+
"name": "Strapi Solutions SAS",
|
|
63
|
+
"email": "hi@strapi.io",
|
|
64
|
+
"url": "https://strapi.io"
|
|
65
|
+
}
|
|
66
|
+
],
|
|
67
|
+
"main": "./lib",
|
|
68
|
+
"types": "./lib/index.d.ts",
|
|
69
|
+
"bin": {
|
|
70
|
+
"strapi": "./bin/strapi.js"
|
|
71
|
+
},
|
|
72
|
+
"directories": {
|
|
73
|
+
"lib": "./lib",
|
|
74
|
+
"bin": "./bin"
|
|
75
|
+
},
|
|
76
|
+
"scripts": {
|
|
77
|
+
"postinstall": "node lib/utils/success.js",
|
|
78
|
+
"test:unit": "jest --verbose"
|
|
79
|
+
},
|
|
80
|
+
"dependencies": {
|
|
81
|
+
"@koa/cors": "3.1.0",
|
|
82
|
+
"@koa/router": "10.1.1",
|
|
83
|
+
"@strapi/admin": "4.0.1",
|
|
84
|
+
"@strapi/database": "4.0.1",
|
|
85
|
+
"@strapi/generate-new": "4.0.1",
|
|
86
|
+
"@strapi/generators": "4.0.1",
|
|
87
|
+
"@strapi/logger": "4.0.1",
|
|
88
|
+
"@strapi/plugin-content-manager": "4.0.1",
|
|
89
|
+
"@strapi/plugin-content-type-builder": "4.0.1",
|
|
90
|
+
"@strapi/plugin-email": "4.0.1",
|
|
91
|
+
"@strapi/plugin-upload": "4.0.1",
|
|
92
|
+
"@strapi/utils": "4.0.1",
|
|
93
|
+
"bcryptjs": "2.4.3",
|
|
94
|
+
"boxen": "5.1.2",
|
|
95
|
+
"chalk": "4.1.2",
|
|
96
|
+
"chokidar": "3.5.2",
|
|
97
|
+
"ci-info": "3.2.0",
|
|
98
|
+
"cli-table3": "0.6.0",
|
|
99
|
+
"commander": "8.2.0",
|
|
100
|
+
"configstore": "5.0.1",
|
|
101
|
+
"debug": "4.3.2",
|
|
102
|
+
"delegates": "1.0.0",
|
|
103
|
+
"dotenv": "10.0.0",
|
|
104
|
+
"execa": "5.1.1",
|
|
105
|
+
"fs-extra": "10.0.0",
|
|
106
|
+
"glob": "7.2.0",
|
|
107
|
+
"http-errors": "1.8.0",
|
|
108
|
+
"inquirer": "8.2.0",
|
|
109
|
+
"is-docker": "2.2.1",
|
|
110
|
+
"koa": "2.13.3",
|
|
111
|
+
"koa-body": "4.2.0",
|
|
112
|
+
"koa-compose": "4.1.0",
|
|
113
|
+
"koa-compress": "5.1.0",
|
|
114
|
+
"koa-favicon": "2.1.0",
|
|
115
|
+
"koa-helmet": "6.1.0",
|
|
116
|
+
"koa-ip": "2.1.0",
|
|
117
|
+
"koa-session": "6.2.0",
|
|
118
|
+
"koa-static": "5.0.0",
|
|
119
|
+
"lodash": "4.17.21",
|
|
120
|
+
"node-fetch": "2.6.5",
|
|
121
|
+
"node-machine-id": "1.1.12",
|
|
122
|
+
"node-schedule": "2.0.0",
|
|
123
|
+
"open": "8.2.1",
|
|
124
|
+
"ora": "5.4.1",
|
|
125
|
+
"package-json": "7.0.0",
|
|
126
|
+
"qs": "6.10.1",
|
|
127
|
+
"resolve-cwd": "3.0.0",
|
|
128
|
+
"semver": "7.3.5",
|
|
129
|
+
"statuses": "2.0.1"
|
|
130
|
+
},
|
|
131
|
+
"devDependencies": {
|
|
132
|
+
"supertest": "^6.1.6"
|
|
133
|
+
},
|
|
134
|
+
"engines": {
|
|
135
|
+
"node": ">=12.x.x <=16.x.x",
|
|
136
|
+
"npm": ">=6.0.0"
|
|
137
|
+
},
|
|
138
|
+
"gitHead": "e2cd01e8c6cbfeba15ad7787e38b6eebcbb92221"
|
|
142
139
|
}
|
package/lib/commands/generate.js
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Module dependencies
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
// FIXME
|
|
8
|
-
/* eslint-disable import/extensions */
|
|
9
|
-
|
|
10
|
-
// Node.js core.
|
|
11
|
-
const path = require('path');
|
|
12
|
-
|
|
13
|
-
// Master of ceremonies for generators.
|
|
14
|
-
const generate = require('@strapi/generate');
|
|
15
|
-
|
|
16
|
-
// Logger.
|
|
17
|
-
const { createLogger } = require('@strapi/logger');
|
|
18
|
-
|
|
19
|
-
// Configuration
|
|
20
|
-
const loadConfiguration = require('../core/app-configuration');
|
|
21
|
-
|
|
22
|
-
// Local Strapi dependencies.
|
|
23
|
-
const packageJSON = require('../../package.json');
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* `$ strapi generate`
|
|
27
|
-
*
|
|
28
|
-
* Scaffolding for the application in our working directory.
|
|
29
|
-
*/
|
|
30
|
-
|
|
31
|
-
module.exports = function(id, cliArguments) {
|
|
32
|
-
const dir = process.cwd();
|
|
33
|
-
const config = loadConfiguration(dir);
|
|
34
|
-
const logger = createLogger(config.get('logger', {}));
|
|
35
|
-
|
|
36
|
-
// Build initial scope.
|
|
37
|
-
const scope = {
|
|
38
|
-
rootPath: process.cwd(),
|
|
39
|
-
strapiRoot: path.resolve(__dirname, '..'),
|
|
40
|
-
id: id,
|
|
41
|
-
args: cliArguments,
|
|
42
|
-
strapiPackageJSON: packageJSON,
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
scope.generatorType = process.argv[2].split(':')[1];
|
|
46
|
-
|
|
47
|
-
// Show usage if no generator type is defined.
|
|
48
|
-
if (!scope.generatorType) {
|
|
49
|
-
return logger.error('Write `$ strapi generate:something` instead.');
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
return generate(scope, {
|
|
53
|
-
// Log and exit the REPL in case there is an error
|
|
54
|
-
// while we were trying to generate the requested generator.
|
|
55
|
-
error(msg) {
|
|
56
|
-
logger.error(msg);
|
|
57
|
-
process.exit(1);
|
|
58
|
-
},
|
|
59
|
-
|
|
60
|
-
// Log and exit the REPL in case of success
|
|
61
|
-
// but first make sure we have all the info we need.
|
|
62
|
-
success() {
|
|
63
|
-
if (!scope.outputPath && scope.filename && scope.destDir) {
|
|
64
|
-
scope.outputPath = scope.destDir + scope.filename;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
if (scope.generatorType !== 'new') {
|
|
68
|
-
logger.info(
|
|
69
|
-
`Generated a new ${scope.generatorType} \`${scope.name}\` at \`${scope.filePath}\`.`
|
|
70
|
-
);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
process.exit(0);
|
|
74
|
-
},
|
|
75
|
-
});
|
|
76
|
-
};
|