@strapi/strapi 4.2.0-beta.2 → 4.2.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 +1 -2
- package/lib/Strapi.js +15 -37
- package/lib/commands/admin-create.js +1 -8
- package/lib/commands/admin-reset.js +1 -8
- package/lib/commands/build.js +44 -18
- package/lib/commands/configurationDump.js +1 -8
- package/lib/commands/configurationRestore.js +1 -9
- package/lib/commands/console.js +2 -10
- package/lib/commands/develop.js +74 -113
- package/lib/commands/routes/list.js +1 -8
- package/lib/commands/start.js +2 -8
- package/lib/commands/watchAdmin.js +10 -10
- package/lib/core/app-configuration/index.js +3 -4
- package/lib/core/app-configuration/load-config-file.js +1 -3
- package/lib/core/bootstrap.js +2 -2
- package/lib/core/loaders/apis.js +16 -13
- package/lib/core/loaders/components.js +4 -5
- package/lib/core/loaders/index.js +1 -0
- package/lib/core/loaders/middlewares.js +3 -5
- package/lib/core/loaders/plugins/get-enabled-plugins.js +1 -2
- package/lib/core/loaders/plugins/get-user-plugins-config.js +2 -2
- package/lib/core/loaders/plugins/index.js +1 -1
- package/lib/core/loaders/policies.js +2 -4
- package/lib/core/loaders/sanitizers.js +5 -0
- package/lib/core/loaders/src-index.js +4 -6
- package/lib/core/registries/sanitizers.js +26 -0
- package/lib/factories.d.ts +3 -3
- package/lib/index.d.ts +1 -1
- package/lib/load/load-files.js +1 -3
- package/lib/middlewares/body.js +38 -10
- package/lib/middlewares/favicon.js +1 -1
- package/lib/middlewares/public/index.js +1 -2
- package/lib/services/entity-validator/validators.js +3 -1
- package/lib/services/fs.js +1 -1
- package/lib/services/metrics/index.js +1 -5
- package/lib/services/metrics/sender.js +0 -7
- package/lib/services/server/middleware.js +1 -1
- package/lib/utils/get-dirs.js +10 -24
- package/lib/utils/index.js +0 -2
- package/lib/utils/update-notifier/index.js +3 -3
- package/package.json +15 -16
- package/lib/commands/builders/admin.js +0 -59
- package/lib/commands/builders/index.js +0 -9
- package/lib/commands/builders/typescript.js +0 -32
- package/lib/utils/import-default.js +0 -9
|
@@ -31,13 +31,12 @@ const defaultConfig = {
|
|
|
31
31
|
},
|
|
32
32
|
};
|
|
33
33
|
|
|
34
|
-
module.exports = (
|
|
35
|
-
const { appDir, distDir } = dirs;
|
|
34
|
+
module.exports = (dir, initialConfig = {}) => {
|
|
36
35
|
const { autoReload = false, serveAdminPanel = true } = initialConfig;
|
|
37
36
|
|
|
38
|
-
const pkgJSON = require(path.resolve(
|
|
37
|
+
const pkgJSON = require(path.resolve(dir, 'package.json'));
|
|
39
38
|
|
|
40
|
-
const configDir = path.resolve(
|
|
39
|
+
const configDir = path.resolve(dir || process.cwd(), 'config');
|
|
41
40
|
|
|
42
41
|
const rootConfig = {
|
|
43
42
|
launchedAt: Date.now(),
|
|
@@ -4,11 +4,9 @@ const path = require('path');
|
|
|
4
4
|
const fs = require('fs');
|
|
5
5
|
const { templateConfiguration, env } = require('@strapi/utils');
|
|
6
6
|
|
|
7
|
-
const __importDefault = require('../../utils/import-default');
|
|
8
|
-
|
|
9
7
|
const loadJsFile = file => {
|
|
10
8
|
try {
|
|
11
|
-
const jsModule =
|
|
9
|
+
const jsModule = require(file);
|
|
12
10
|
|
|
13
11
|
// call if function
|
|
14
12
|
if (typeof jsModule === 'function') {
|
package/lib/core/bootstrap.js
CHANGED
|
@@ -25,9 +25,9 @@ module.exports = async function({ strapi }) {
|
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
// ensure public repository exists
|
|
28
|
-
if (!(await fse.pathExists(strapi.dirs.
|
|
28
|
+
if (!(await fse.pathExists(strapi.dirs.public))) {
|
|
29
29
|
throw new Error(
|
|
30
|
-
`The public folder (${strapi.dirs.
|
|
30
|
+
`The public folder (${strapi.dirs.public}) doesn't exist or is not accessible. Please make sure it exists.`
|
|
31
31
|
);
|
|
32
32
|
}
|
|
33
33
|
};
|
package/lib/core/loaders/apis.js
CHANGED
|
@@ -5,10 +5,6 @@ const { existsSync } = require('fs-extra');
|
|
|
5
5
|
const _ = require('lodash');
|
|
6
6
|
const fse = require('fs-extra');
|
|
7
7
|
const { isKebabCase } = require('@strapi/utils');
|
|
8
|
-
const { importDefault } = require('../../utils');
|
|
9
|
-
|
|
10
|
-
// to handle names with numbers in it we first check if it is already in kebabCase
|
|
11
|
-
const normalizeName = name => (isKebabCase(name) ? name : _.kebabCase(name));
|
|
12
8
|
|
|
13
9
|
const DEFAULT_CONTENT_TYPE = {
|
|
14
10
|
schema: {},
|
|
@@ -16,22 +12,29 @@ const DEFAULT_CONTENT_TYPE = {
|
|
|
16
12
|
lifecycles: {},
|
|
17
13
|
};
|
|
18
14
|
|
|
15
|
+
// to handle names with numbers in it we first check if it is already in kebabCase
|
|
16
|
+
const normalizeName = name => (isKebabCase(name) ? name : _.kebabCase(name));
|
|
17
|
+
|
|
18
|
+
const isDirectory = fd => fd.isDirectory();
|
|
19
|
+
const isDotFile = fd => fd.name.startsWith('.');
|
|
20
|
+
|
|
19
21
|
module.exports = async strapi => {
|
|
20
|
-
if (!existsSync(strapi.dirs.
|
|
21
|
-
|
|
22
|
+
if (!existsSync(strapi.dirs.api)) {
|
|
23
|
+
throw new Error('Missing api folder. Please create one at `./src/api`');
|
|
22
24
|
}
|
|
23
25
|
|
|
24
|
-
const apisFDs = await fse.readdir(strapi.dirs.
|
|
26
|
+
const apisFDs = await (await fse.readdir(strapi.dirs.api, { withFileTypes: true }))
|
|
27
|
+
.filter(isDirectory)
|
|
28
|
+
.filter(_.negate(isDotFile));
|
|
29
|
+
|
|
25
30
|
const apis = {};
|
|
26
31
|
|
|
27
32
|
// only load folders
|
|
28
33
|
for (const apiFD of apisFDs) {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
const api = await loadAPI(join(strapi.dirs.dist.api, apiFD.name));
|
|
34
|
+
const apiName = normalizeName(apiFD.name);
|
|
35
|
+
const api = await loadAPI(join(strapi.dirs.api, apiFD.name));
|
|
32
36
|
|
|
33
|
-
|
|
34
|
-
}
|
|
37
|
+
apis[apiName] = api;
|
|
35
38
|
}
|
|
36
39
|
|
|
37
40
|
validateContentTypesUnicity(apis);
|
|
@@ -151,7 +154,7 @@ const loadFile = file => {
|
|
|
151
154
|
|
|
152
155
|
switch (ext) {
|
|
153
156
|
case '.js':
|
|
154
|
-
return
|
|
157
|
+
return require(file);
|
|
155
158
|
case '.json':
|
|
156
159
|
return fse.readJSON(file);
|
|
157
160
|
default:
|
|
@@ -6,20 +6,19 @@ const { pathExists } = require('fs-extra');
|
|
|
6
6
|
const loadFiles = require('../../load/load-files');
|
|
7
7
|
|
|
8
8
|
module.exports = async strapi => {
|
|
9
|
-
if (!(await pathExists(strapi.dirs.
|
|
9
|
+
if (!(await pathExists(strapi.dirs.components))) {
|
|
10
10
|
return {};
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
const map = await loadFiles(strapi.dirs.
|
|
13
|
+
const map = await loadFiles(strapi.dirs.components, '*/*.*(js|json)');
|
|
14
14
|
|
|
15
15
|
return Object.keys(map).reduce((acc, category) => {
|
|
16
16
|
Object.keys(map[category]).forEach(key => {
|
|
17
17
|
const schema = map[category][key];
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
// NOTE: We're using the filepath from the app directory instead of the dist for information purpose
|
|
21
|
-
const filePath = join(strapi.dirs.app.components, category, schema.__filename__);
|
|
19
|
+
const filePath = join(strapi.dirs.components, category, schema.__filename__);
|
|
22
20
|
|
|
21
|
+
if (!schema.collectionName) {
|
|
23
22
|
return strapi.stopWithError(
|
|
24
23
|
`Component ${key} is missing a "collectionName" property.\nVerify file ${filePath}.`
|
|
25
24
|
);
|
|
@@ -3,19 +3,17 @@
|
|
|
3
3
|
const { join, extname, basename } = require('path');
|
|
4
4
|
const fse = require('fs-extra');
|
|
5
5
|
|
|
6
|
-
const { importDefault } = require('../../utils');
|
|
7
|
-
|
|
8
6
|
// TODO:: allow folders with index.js inside for bigger policies
|
|
9
7
|
module.exports = async function loadMiddlewares(strapi) {
|
|
10
8
|
const localMiddlewares = await loadLocalMiddlewares(strapi);
|
|
11
|
-
const internalMiddlewares =
|
|
9
|
+
const internalMiddlewares = require('../../middlewares');
|
|
12
10
|
|
|
13
11
|
strapi.container.get('middlewares').add(`global::`, localMiddlewares);
|
|
14
12
|
strapi.container.get('middlewares').add(`strapi::`, internalMiddlewares);
|
|
15
13
|
};
|
|
16
14
|
|
|
17
15
|
const loadLocalMiddlewares = async strapi => {
|
|
18
|
-
const dir = strapi.dirs.
|
|
16
|
+
const dir = strapi.dirs.middlewares;
|
|
19
17
|
|
|
20
18
|
if (!(await fse.pathExists(dir))) {
|
|
21
19
|
return {};
|
|
@@ -30,7 +28,7 @@ const loadLocalMiddlewares = async strapi => {
|
|
|
30
28
|
|
|
31
29
|
if (fd.isFile() && extname(name) === '.js') {
|
|
32
30
|
const key = basename(name, '.js');
|
|
33
|
-
middlewares[key] =
|
|
31
|
+
middlewares[key] = require(fullPath);
|
|
34
32
|
}
|
|
35
33
|
}
|
|
36
34
|
|
|
@@ -29,11 +29,10 @@ const toDetailedDeclaration = declaration => {
|
|
|
29
29
|
let detailedDeclaration = pick(['enabled'], declaration);
|
|
30
30
|
if (has('resolve', declaration)) {
|
|
31
31
|
let pathToPlugin = '';
|
|
32
|
-
|
|
33
32
|
try {
|
|
34
33
|
pathToPlugin = dirname(require.resolve(declaration.resolve));
|
|
35
34
|
} catch (e) {
|
|
36
|
-
pathToPlugin = resolve(strapi.dirs.
|
|
35
|
+
pathToPlugin = resolve(strapi.dirs.root, declaration.resolve);
|
|
37
36
|
|
|
38
37
|
if (!existsSync(pathToPlugin) || !statSync(pathToPlugin).isDirectory()) {
|
|
39
38
|
throw new Error(`${declaration.resolve} couldn't be resolved`);
|
|
@@ -12,9 +12,9 @@ const loadConfigFile = require('../../app-configuration/load-config-file');
|
|
|
12
12
|
* @return {Promise<{}>}
|
|
13
13
|
*/
|
|
14
14
|
const getUserPluginsConfig = async () => {
|
|
15
|
-
const globalUserConfigPath = join(strapi.dirs.
|
|
15
|
+
const globalUserConfigPath = join(strapi.dirs.config, 'plugins.js');
|
|
16
16
|
const currentEnvUserConfigPath = join(
|
|
17
|
-
strapi.dirs.
|
|
17
|
+
strapi.dirs.config,
|
|
18
18
|
'env',
|
|
19
19
|
process.env.NODE_ENV,
|
|
20
20
|
'plugins.js'
|
|
@@ -3,11 +3,9 @@
|
|
|
3
3
|
const { join, extname, basename } = require('path');
|
|
4
4
|
const fse = require('fs-extra');
|
|
5
5
|
|
|
6
|
-
const { importDefault } = require('../../utils');
|
|
7
|
-
|
|
8
6
|
// TODO:: allow folders with index.js inside for bigger policies
|
|
9
7
|
module.exports = async function loadPolicies(strapi) {
|
|
10
|
-
const dir = strapi.dirs.
|
|
8
|
+
const dir = strapi.dirs.policies;
|
|
11
9
|
|
|
12
10
|
if (!(await fse.pathExists(dir))) {
|
|
13
11
|
return;
|
|
@@ -22,7 +20,7 @@ module.exports = async function loadPolicies(strapi) {
|
|
|
22
20
|
|
|
23
21
|
if (fd.isFile() && extname(name) === '.js') {
|
|
24
22
|
const key = basename(name, '.js');
|
|
25
|
-
policies[key] =
|
|
23
|
+
policies[key] = require(fullPath);
|
|
26
24
|
}
|
|
27
25
|
}
|
|
28
26
|
|
|
@@ -4,8 +4,6 @@ const { resolve } = require('path');
|
|
|
4
4
|
const { statSync, existsSync } = require('fs');
|
|
5
5
|
const { yup } = require('@strapi/utils');
|
|
6
6
|
|
|
7
|
-
const { importDefault } = require('../../utils');
|
|
8
|
-
|
|
9
7
|
const srcSchema = yup
|
|
10
8
|
.object()
|
|
11
9
|
.shape({
|
|
@@ -20,16 +18,16 @@ const validateSrcIndex = srcIndex => {
|
|
|
20
18
|
};
|
|
21
19
|
|
|
22
20
|
module.exports = strapi => {
|
|
23
|
-
if (!existsSync(strapi.dirs.
|
|
24
|
-
|
|
21
|
+
if (!existsSync(strapi.dirs.src)) {
|
|
22
|
+
throw new Error('Missing src folder. Please create one at `./src`');
|
|
25
23
|
}
|
|
26
24
|
|
|
27
|
-
const pathToSrcIndex = resolve(strapi.dirs.
|
|
25
|
+
const pathToSrcIndex = resolve(strapi.dirs.src, 'index.js');
|
|
28
26
|
if (!existsSync(pathToSrcIndex) || statSync(pathToSrcIndex).isDirectory()) {
|
|
29
27
|
return {};
|
|
30
28
|
}
|
|
31
29
|
|
|
32
|
-
const srcIndex =
|
|
30
|
+
const srcIndex = require(pathToSrcIndex);
|
|
33
31
|
|
|
34
32
|
try {
|
|
35
33
|
validateSrcIndex(srcIndex);
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const _ = require('lodash');
|
|
4
|
+
|
|
5
|
+
const sanitizersRegistry = () => {
|
|
6
|
+
const sanitizers = {};
|
|
7
|
+
|
|
8
|
+
return {
|
|
9
|
+
get(path) {
|
|
10
|
+
return _.get(sanitizers, path, []);
|
|
11
|
+
},
|
|
12
|
+
add(path, sanitizer) {
|
|
13
|
+
this.get(path).push(sanitizer);
|
|
14
|
+
return this;
|
|
15
|
+
},
|
|
16
|
+
set(path, value = []) {
|
|
17
|
+
_.set(sanitizers, path, value);
|
|
18
|
+
return this;
|
|
19
|
+
},
|
|
20
|
+
has(path) {
|
|
21
|
+
return _.has(sanitizers, path);
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
module.exports = sanitizersRegistry;
|
package/lib/factories.d.ts
CHANGED
|
@@ -43,6 +43,6 @@ interface Router {
|
|
|
43
43
|
routes: Route[];
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
export function createCoreRouter(uid: string, cfg
|
|
47
|
-
export function createCoreController(uid: string, cfg
|
|
48
|
-
export function createCoreService(uid: string, cfg
|
|
46
|
+
export function createCoreRouter(uid: string, cfg: RouterConfig): () => Router;
|
|
47
|
+
export function createCoreController(uid: string, cfg: ControllerConfig): () => Controller;
|
|
48
|
+
export function createCoreService(uid: string, cfg: ServiceConfig): () => Service;
|
package/lib/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { EntityService } from './services/entity-service';
|
|
|
3
3
|
import { Strapi as StrapiClass } from './Strapi';
|
|
4
4
|
|
|
5
5
|
export * as factories from './factories';
|
|
6
|
-
|
|
6
|
+
interface StrapiInterface extends StrapiClass {
|
|
7
7
|
query: Database['query'];
|
|
8
8
|
entityService: EntityService;
|
|
9
9
|
}
|
package/lib/load/load-files.js
CHANGED
|
@@ -3,8 +3,6 @@
|
|
|
3
3
|
const path = require('path');
|
|
4
4
|
const _ = require('lodash');
|
|
5
5
|
const fse = require('fs-extra');
|
|
6
|
-
|
|
7
|
-
const { importDefault } = require('../utils');
|
|
8
6
|
const glob = require('./glob');
|
|
9
7
|
const filePathToPath = require('./filepath-to-prop-path');
|
|
10
8
|
|
|
@@ -36,7 +34,7 @@ const loadFiles = async (
|
|
|
36
34
|
if (path.extname(absolutePath) === '.json') {
|
|
37
35
|
mod = await fse.readJson(absolutePath);
|
|
38
36
|
} else {
|
|
39
|
-
mod =
|
|
37
|
+
mod = requireFn(absolutePath);
|
|
40
38
|
}
|
|
41
39
|
|
|
42
40
|
Object.defineProperty(mod, '__filename__', {
|
package/lib/middlewares/body.js
CHANGED
|
@@ -3,12 +3,23 @@
|
|
|
3
3
|
const fse = require('fs-extra');
|
|
4
4
|
const { defaultsDeep, get } = require('lodash/fp');
|
|
5
5
|
const body = require('koa-body');
|
|
6
|
+
const mime = require('mime-types');
|
|
6
7
|
|
|
7
8
|
const defaults = {
|
|
8
9
|
multipart: true,
|
|
9
10
|
patchKoa: true,
|
|
10
11
|
};
|
|
11
12
|
|
|
13
|
+
function ensureFileMimeType(file) {
|
|
14
|
+
if (!file.type) {
|
|
15
|
+
file.type = mime.lookup(file.name) || 'application/octet-stream';
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function getFiles(ctx) {
|
|
20
|
+
return get('request.files.files', ctx);
|
|
21
|
+
}
|
|
22
|
+
|
|
12
23
|
/**
|
|
13
24
|
* @type {import('./').MiddlewareFactory}
|
|
14
25
|
*/
|
|
@@ -18,21 +29,38 @@ module.exports = config => {
|
|
|
18
29
|
return async (ctx, next) => {
|
|
19
30
|
// TODO: find a better way later
|
|
20
31
|
if (ctx.url === '/graphql') {
|
|
21
|
-
|
|
22
|
-
}
|
|
32
|
+
await next();
|
|
33
|
+
} else {
|
|
34
|
+
try {
|
|
35
|
+
await body({ patchKoa: true, ...bodyConfig })(ctx, () => {});
|
|
23
36
|
|
|
24
|
-
|
|
25
|
-
await body({ patchKoa: true, ...bodyConfig })(ctx, next);
|
|
26
|
-
} catch (e) {
|
|
27
|
-
if ((e || {}).message && e.message.includes('maxFileSize exceeded')) {
|
|
28
|
-
return ctx.payloadTooLarge('FileTooBig');
|
|
29
|
-
}
|
|
37
|
+
const files = getFiles(ctx);
|
|
30
38
|
|
|
31
|
-
|
|
39
|
+
/**
|
|
40
|
+
* in case the mime-type wasn't sent, Strapi tries to guess it
|
|
41
|
+
* from the file extension, to avoid a corrupt database state
|
|
42
|
+
*/
|
|
43
|
+
if (files) {
|
|
44
|
+
if (Array.isArray(files)) {
|
|
45
|
+
files.forEach(ensureFileMimeType);
|
|
46
|
+
} else {
|
|
47
|
+
ensureFileMimeType(files);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
await next();
|
|
52
|
+
} catch (e) {
|
|
53
|
+
if ((e || {}).message && e.message.includes('maxFileSize exceeded')) {
|
|
54
|
+
return ctx.payloadTooLarge('FileTooBig');
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
throw e;
|
|
58
|
+
}
|
|
32
59
|
}
|
|
33
60
|
|
|
61
|
+
const files = getFiles(ctx);
|
|
62
|
+
|
|
34
63
|
// clean any file that was uploaded
|
|
35
|
-
const files = get('request.files.files', ctx);
|
|
36
64
|
if (files) {
|
|
37
65
|
if (Array.isArray(files)) {
|
|
38
66
|
// not awaiting to not slow the request
|
|
@@ -15,5 +15,5 @@ const defaults = {
|
|
|
15
15
|
module.exports = (config, { strapi }) => {
|
|
16
16
|
const { maxAge, path: faviconPath } = defaultsDeep(defaults, config);
|
|
17
17
|
|
|
18
|
-
return favicon(resolve(strapi.dirs.
|
|
18
|
+
return favicon(resolve(strapi.dirs.root, faviconPath), { maxAge });
|
|
19
19
|
};
|
|
@@ -71,7 +71,6 @@ module.exports = (config, { strapi }) => {
|
|
|
71
71
|
{
|
|
72
72
|
method: 'GET',
|
|
73
73
|
path: '/assets/images/(.*)',
|
|
74
|
-
// Why do we use the __dirname and not strapi.dirs here? @alexandrebodin
|
|
75
74
|
handler: serveStatic(path.resolve(__dirname, 'assets/images'), {
|
|
76
75
|
maxage: maxAge,
|
|
77
76
|
defer: true,
|
|
@@ -81,7 +80,7 @@ module.exports = (config, { strapi }) => {
|
|
|
81
80
|
{
|
|
82
81
|
method: 'GET',
|
|
83
82
|
path: '/(.*)',
|
|
84
|
-
handler: koaStatic(strapi.dirs.
|
|
83
|
+
handler: koaStatic(strapi.dirs.public, {
|
|
85
84
|
maxage: maxAge,
|
|
86
85
|
defer: true,
|
|
87
86
|
}),
|
|
@@ -166,7 +166,9 @@ const stringValidator = composeValidators(
|
|
|
166
166
|
addUniqueValidator
|
|
167
167
|
);
|
|
168
168
|
|
|
169
|
-
const emailValidator = composeValidators(stringValidator, validator =>
|
|
169
|
+
const emailValidator = composeValidators(stringValidator, validator =>
|
|
170
|
+
validator.email().min(1, '${path} cannot be empty')
|
|
171
|
+
);
|
|
170
172
|
|
|
171
173
|
const uidValidator = composeValidators(stringValidator, validator =>
|
|
172
174
|
validator.matches(new RegExp('^[A-Za-z0-9-_.~]*$'))
|
package/lib/services/fs.js
CHANGED
|
@@ -12,7 +12,7 @@ module.exports = strapi => {
|
|
|
12
12
|
|
|
13
13
|
const normalizedPath = path.normalize(filePath).replace(/^\/?(\.\/|\.\.\/)+/, '');
|
|
14
14
|
|
|
15
|
-
return path.resolve(strapi.dirs.
|
|
15
|
+
return path.resolve(strapi.dirs.root, normalizedPath);
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
const strapiFS = {
|
|
@@ -33,10 +33,6 @@ const createTelemetryInstance = strapi => {
|
|
|
33
33
|
const sendEvent = wrapWithRateLimit(sender, { limitedEvents: LIMITED_EVENTS });
|
|
34
34
|
|
|
35
35
|
return {
|
|
36
|
-
get isDisabled() {
|
|
37
|
-
return isDisabled;
|
|
38
|
-
},
|
|
39
|
-
|
|
40
36
|
register() {
|
|
41
37
|
if (!isDisabled) {
|
|
42
38
|
const pingCron = scheduleJob('0 0 12 * * *', () => sendEvent('ping'));
|
|
@@ -96,7 +92,7 @@ const hashProject = strapi =>
|
|
|
96
92
|
|
|
97
93
|
const hashDep = strapi => {
|
|
98
94
|
const depStr = JSON.stringify(strapi.config.info.dependencies);
|
|
99
|
-
const readmePath = path.join(strapi.dirs.
|
|
95
|
+
const readmePath = path.join(strapi.dirs.root, 'README.md');
|
|
100
96
|
|
|
101
97
|
try {
|
|
102
98
|
if (fs.existsSync(readmePath)) {
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const os = require('os');
|
|
4
|
-
const path = require('path');
|
|
5
4
|
const _ = require('lodash');
|
|
6
5
|
const isDocker = require('is-docker');
|
|
7
6
|
const fetch = require('node-fetch');
|
|
8
7
|
const ciEnv = require('ci-info');
|
|
9
|
-
const { isUsingTypeScriptSync } = require('@strapi/typescript-utils');
|
|
10
8
|
const ee = require('../../utils/ee');
|
|
11
9
|
const machineID = require('../../utils/machine-id');
|
|
12
10
|
const stringifyDeep = require('./stringify-deep');
|
|
@@ -38,9 +36,6 @@ module.exports = strapi => {
|
|
|
38
36
|
const deviceId = machineID();
|
|
39
37
|
const isEE = strapi.EE === true && ee.isEE === true;
|
|
40
38
|
|
|
41
|
-
const serverRootPath = strapi.dirs.app.root;
|
|
42
|
-
const adminRootPath = path.join(strapi.dirs.app.root, 'src', 'admin');
|
|
43
|
-
|
|
44
39
|
const anonymous_metadata = {
|
|
45
40
|
environment: strapi.config.environment,
|
|
46
41
|
os: os.type(),
|
|
@@ -52,8 +47,6 @@ module.exports = strapi => {
|
|
|
52
47
|
version: strapi.config.get('info.strapi'),
|
|
53
48
|
strapiVersion: strapi.config.get('info.strapi'),
|
|
54
49
|
projectType: isEE ? 'Enterprise' : 'Community',
|
|
55
|
-
useTypescriptOnServer: isUsingTypeScriptSync(serverRootPath),
|
|
56
|
-
useTypescriptOnAdmin: isUsingTypeScriptSync(adminRootPath),
|
|
57
50
|
};
|
|
58
51
|
|
|
59
52
|
addPackageJsonStrapiMetadata(anonymous_metadata, strapi);
|
|
@@ -112,7 +112,7 @@ const resolveCustomMiddleware = (resolve, strapi) => {
|
|
|
112
112
|
modulePath = require.resolve(resolve);
|
|
113
113
|
} catch (error) {
|
|
114
114
|
if (error.code === 'MODULE_NOT_FOUND') {
|
|
115
|
-
modulePath = path.resolve(strapi.dirs.
|
|
115
|
+
modulePath = path.resolve(strapi.dirs.root, resolve);
|
|
116
116
|
} else {
|
|
117
117
|
throw error;
|
|
118
118
|
}
|
package/lib/utils/get-dirs.js
CHANGED
|
@@ -2,30 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
const { join, resolve } = require('path');
|
|
4
4
|
|
|
5
|
-
const getDirs = (
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
},
|
|
16
|
-
app: {
|
|
17
|
-
root: appDir,
|
|
18
|
-
src: join(appDir, 'src'),
|
|
19
|
-
api: join(appDir, 'src', 'api'),
|
|
20
|
-
components: join(appDir, 'src', 'components'),
|
|
21
|
-
extensions: join(appDir, 'src', 'extensions'),
|
|
22
|
-
policies: join(appDir, 'src', 'policies'),
|
|
23
|
-
middlewares: join(appDir, 'src', 'middlewares'),
|
|
24
|
-
config: join(appDir, 'config'),
|
|
25
|
-
},
|
|
26
|
-
static: {
|
|
27
|
-
public: resolve(appDir, strapi.config.get('server.dirs.public')),
|
|
28
|
-
},
|
|
5
|
+
const getDirs = (root, { strapi }) => ({
|
|
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: resolve(root, strapi.config.get('server.dirs.public')),
|
|
29
15
|
});
|
|
30
16
|
|
|
31
17
|
module.exports = getDirs;
|
package/lib/utils/index.js
CHANGED
|
@@ -3,11 +3,9 @@
|
|
|
3
3
|
const openBrowser = require('./open-browser');
|
|
4
4
|
const isInitialized = require('./is-initialized');
|
|
5
5
|
const getDirs = require('./get-dirs');
|
|
6
|
-
const importDefault = require('./import-default');
|
|
7
6
|
|
|
8
7
|
module.exports = {
|
|
9
8
|
isInitialized,
|
|
10
9
|
openBrowser,
|
|
11
10
|
getDirs,
|
|
12
|
-
importDefault,
|
|
13
11
|
};
|
|
@@ -20,7 +20,7 @@ const boxenOptions = {
|
|
|
20
20
|
borderStyle: 'round',
|
|
21
21
|
};
|
|
22
22
|
|
|
23
|
-
const
|
|
23
|
+
const getUpdateMessage = (newVersion, currentVersion) => {
|
|
24
24
|
const currentVersionLog = chalk.dim(currentVersion);
|
|
25
25
|
const newVersionLog = chalk.green(newVersion);
|
|
26
26
|
const releaseLink = chalk.bold('https://github.com/strapi/strapi/releases');
|
|
@@ -38,7 +38,7 @@ const createUpdateNotifier = strapi => {
|
|
|
38
38
|
config = new Configstore(
|
|
39
39
|
pkg.name,
|
|
40
40
|
{},
|
|
41
|
-
{ configPath: path.join(strapi.dirs.
|
|
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
|
|
@@ -78,7 +78,7 @@ const createUpdateNotifier = strapi => {
|
|
|
78
78
|
return;
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
-
const message = boxen(
|
|
81
|
+
const message = boxen(getUpdateMessage(latestVersion, pkg.version), boxenOptions);
|
|
82
82
|
config.set('lastNotification', now);
|
|
83
83
|
console.log(message);
|
|
84
84
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@strapi/strapi",
|
|
3
|
-
"version": "4.2.0
|
|
3
|
+
"version": "4.2.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",
|
|
@@ -80,17 +80,16 @@
|
|
|
80
80
|
"dependencies": {
|
|
81
81
|
"@koa/cors": "3.1.0",
|
|
82
82
|
"@koa/router": "10.1.1",
|
|
83
|
-
"@strapi/admin": "4.2.0
|
|
84
|
-
"@strapi/database": "4.2.0
|
|
85
|
-
"@strapi/generate-new": "4.2.0
|
|
86
|
-
"@strapi/generators": "4.2.0
|
|
87
|
-
"@strapi/logger": "4.2.0
|
|
88
|
-
"@strapi/plugin-content-manager": "4.2.0
|
|
89
|
-
"@strapi/plugin-content-type-builder": "4.2.0
|
|
90
|
-
"@strapi/plugin-email": "4.2.0
|
|
91
|
-
"@strapi/plugin-upload": "4.2.0
|
|
92
|
-
"@strapi/
|
|
93
|
-
"@strapi/utils": "4.2.0-beta.2",
|
|
83
|
+
"@strapi/admin": "4.2.0",
|
|
84
|
+
"@strapi/database": "4.2.0",
|
|
85
|
+
"@strapi/generate-new": "4.2.0",
|
|
86
|
+
"@strapi/generators": "4.2.0",
|
|
87
|
+
"@strapi/logger": "4.2.0",
|
|
88
|
+
"@strapi/plugin-content-manager": "4.2.0",
|
|
89
|
+
"@strapi/plugin-content-type-builder": "4.2.0",
|
|
90
|
+
"@strapi/plugin-email": "4.2.0",
|
|
91
|
+
"@strapi/plugin-upload": "4.2.0",
|
|
92
|
+
"@strapi/utils": "4.2.0",
|
|
94
93
|
"bcryptjs": "2.4.3",
|
|
95
94
|
"boxen": "5.1.2",
|
|
96
95
|
"chalk": "4.1.2",
|
|
@@ -118,6 +117,7 @@
|
|
|
118
117
|
"koa-session": "6.2.0",
|
|
119
118
|
"koa-static": "5.0.0",
|
|
120
119
|
"lodash": "4.17.21",
|
|
120
|
+
"mime-types": "2.1.35",
|
|
121
121
|
"node-fetch": "2.6.7",
|
|
122
122
|
"node-machine-id": "1.1.12",
|
|
123
123
|
"node-schedule": "2.0.0",
|
|
@@ -131,12 +131,11 @@
|
|
|
131
131
|
"uuid": "^3.3.2"
|
|
132
132
|
},
|
|
133
133
|
"devDependencies": {
|
|
134
|
-
"supertest": "^6.1.6"
|
|
135
|
-
"typescript": "4.6.2"
|
|
134
|
+
"supertest": "^6.1.6"
|
|
136
135
|
},
|
|
137
136
|
"engines": {
|
|
138
|
-
"node": ">=
|
|
137
|
+
"node": ">=14.19.1 <=16.x.x",
|
|
139
138
|
"npm": ">=6.0.0"
|
|
140
139
|
},
|
|
141
|
-
"gitHead": "
|
|
140
|
+
"gitHead": "12c8ee3b2d95fe417de4d939db0311a0513bd8da"
|
|
142
141
|
}
|