@strapi/strapi 4.2.0-alpha.O → 4.2.0-beta.2
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 +2 -3
- package/bin/strapi.js +18 -1
- package/lib/Strapi.js +38 -4
- package/lib/commands/admin-create.js +122 -0
- package/lib/commands/admin-reset.js +8 -1
- package/lib/commands/build.js +18 -44
- package/lib/commands/builders/admin.js +59 -0
- package/lib/commands/builders/index.js +9 -0
- package/lib/commands/builders/typescript.js +32 -0
- package/lib/commands/configurationDump.js +8 -1
- package/lib/commands/configurationRestore.js +9 -1
- package/lib/commands/console.js +10 -2
- package/lib/commands/develop.js +113 -71
- package/lib/commands/opt-out-telemetry.js +83 -0
- package/lib/commands/routes/list.js +8 -1
- package/lib/commands/start.js +8 -2
- package/lib/commands/watchAdmin.js +10 -10
- package/lib/core/app-configuration/index.js +5 -3
- package/lib/core/app-configuration/load-config-file.js +3 -1
- package/lib/core/bootstrap.js +9 -1
- package/lib/core/loaders/apis.js +6 -5
- package/lib/core/loaders/components.js +5 -4
- package/lib/core/loaders/middlewares.js +5 -3
- package/lib/core/loaders/plugins/get-enabled-plugins.js +6 -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 +4 -2
- package/lib/core/loaders/src-index.js +6 -4
- package/lib/factories.d.ts +3 -3
- package/lib/index.d.ts +1 -1
- package/lib/load/load-files.js +3 -1
- package/lib/middlewares/favicon.js +1 -1
- package/lib/middlewares/public/index.js +2 -1
- package/lib/middlewares/security.js +1 -1
- package/lib/middlewares/session.js +3 -1
- package/lib/services/fs.js +1 -1
- package/lib/services/metrics/index.js +8 -2
- package/lib/services/metrics/sender.js +7 -0
- package/lib/services/server/index.js +1 -1
- package/lib/services/server/middleware.js +1 -1
- package/lib/utils/get-dirs.js +25 -11
- package/lib/utils/import-default.js +9 -0
- package/lib/utils/index.js +2 -0
- package/lib/utils/update-notifier/index.js +1 -1
- package/package.json +15 -13
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
|
-
interface StrapiInterface extends StrapiClass {
|
|
6
|
+
export interface StrapiInterface extends StrapiClass {
|
|
7
7
|
query: Database['query'];
|
|
8
8
|
entityService: EntityService;
|
|
9
9
|
}
|
package/lib/load/load-files.js
CHANGED
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
const path = require('path');
|
|
4
4
|
const _ = require('lodash');
|
|
5
5
|
const fse = require('fs-extra');
|
|
6
|
+
|
|
7
|
+
const { importDefault } = require('../utils');
|
|
6
8
|
const glob = require('./glob');
|
|
7
9
|
const filePathToPath = require('./filepath-to-prop-path');
|
|
8
10
|
|
|
@@ -34,7 +36,7 @@ const loadFiles = async (
|
|
|
34
36
|
if (path.extname(absolutePath) === '.json') {
|
|
35
37
|
mod = await fse.readJson(absolutePath);
|
|
36
38
|
} else {
|
|
37
|
-
mod = requireFn(absolutePath);
|
|
39
|
+
mod = importDefault(requireFn(absolutePath)).default;
|
|
38
40
|
}
|
|
39
41
|
|
|
40
42
|
Object.defineProperty(mod, '__filename__', {
|
|
@@ -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.root, faviconPath), { maxAge });
|
|
18
|
+
return favicon(resolve(strapi.dirs.app.root, faviconPath), { maxAge });
|
|
19
19
|
};
|
|
@@ -71,6 +71,7 @@ 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
|
|
74
75
|
handler: serveStatic(path.resolve(__dirname, 'assets/images'), {
|
|
75
76
|
maxage: maxAge,
|
|
76
77
|
defer: true,
|
|
@@ -80,7 +81,7 @@ module.exports = (config, { strapi }) => {
|
|
|
80
81
|
{
|
|
81
82
|
method: 'GET',
|
|
82
83
|
path: '/(.*)',
|
|
83
|
-
handler: koaStatic(strapi.dirs.public, {
|
|
84
|
+
handler: koaStatic(strapi.dirs.static.public, {
|
|
84
85
|
maxage: maxAge,
|
|
85
86
|
defer: true,
|
|
86
87
|
}),
|
|
@@ -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:'],
|
|
15
|
+
'img-src': ["'self'", 'data:', 'blob:', 'https://dl.airtable.com'],
|
|
16
16
|
'media-src': ["'self'", 'data:', 'blob:'],
|
|
17
17
|
upgradeInsecureRequests: null,
|
|
18
18
|
},
|
|
@@ -19,7 +19,9 @@ const defaultConfig = {
|
|
|
19
19
|
module.exports = (userConfig, { strapi }) => {
|
|
20
20
|
const keys = strapi.server.app.keys;
|
|
21
21
|
if (!isArray(keys) || isEmpty(keys) || keys.some(isEmpty)) {
|
|
22
|
-
throw new Error(
|
|
22
|
+
throw new Error(
|
|
23
|
+
`App keys are required. Please set app.keys in config/server.js (ex: keys: ['myKeyA', 'myKeyB'])`
|
|
24
|
+
);
|
|
23
25
|
}
|
|
24
26
|
|
|
25
27
|
const config = defaultsDeep(defaultConfig, userConfig);
|
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.root, normalizedPath);
|
|
15
|
+
return path.resolve(strapi.dirs.app.root, normalizedPath);
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
const strapiFS = {
|
|
@@ -24,13 +24,19 @@ const LIMITED_EVENTS = [
|
|
|
24
24
|
|
|
25
25
|
const createTelemetryInstance = strapi => {
|
|
26
26
|
const uuid = strapi.config.get('uuid');
|
|
27
|
-
const
|
|
27
|
+
const telemetryDisabled = strapi.config.get('packageJsonStrapi.telemetryDisabled');
|
|
28
|
+
const isDisabled =
|
|
29
|
+
!uuid || isTruthy(process.env.STRAPI_TELEMETRY_DISABLED) || isTruthy(telemetryDisabled);
|
|
28
30
|
|
|
29
31
|
const crons = [];
|
|
30
32
|
const sender = createSender(strapi);
|
|
31
33
|
const sendEvent = wrapWithRateLimit(sender, { limitedEvents: LIMITED_EVENTS });
|
|
32
34
|
|
|
33
35
|
return {
|
|
36
|
+
get isDisabled() {
|
|
37
|
+
return isDisabled;
|
|
38
|
+
},
|
|
39
|
+
|
|
34
40
|
register() {
|
|
35
41
|
if (!isDisabled) {
|
|
36
42
|
const pingCron = scheduleJob('0 0 12 * * *', () => sendEvent('ping'));
|
|
@@ -90,7 +96,7 @@ const hashProject = strapi =>
|
|
|
90
96
|
|
|
91
97
|
const hashDep = strapi => {
|
|
92
98
|
const depStr = JSON.stringify(strapi.config.info.dependencies);
|
|
93
|
-
const readmePath = path.join(strapi.dirs.root, 'README.md');
|
|
99
|
+
const readmePath = path.join(strapi.dirs.app.root, 'README.md');
|
|
94
100
|
|
|
95
101
|
try {
|
|
96
102
|
if (fs.existsSync(readmePath)) {
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const os = require('os');
|
|
4
|
+
const path = require('path');
|
|
4
5
|
const _ = require('lodash');
|
|
5
6
|
const isDocker = require('is-docker');
|
|
6
7
|
const fetch = require('node-fetch');
|
|
7
8
|
const ciEnv = require('ci-info');
|
|
9
|
+
const { isUsingTypeScriptSync } = require('@strapi/typescript-utils');
|
|
8
10
|
const ee = require('../../utils/ee');
|
|
9
11
|
const machineID = require('../../utils/machine-id');
|
|
10
12
|
const stringifyDeep = require('./stringify-deep');
|
|
@@ -36,6 +38,9 @@ module.exports = strapi => {
|
|
|
36
38
|
const deviceId = machineID();
|
|
37
39
|
const isEE = strapi.EE === true && ee.isEE === true;
|
|
38
40
|
|
|
41
|
+
const serverRootPath = strapi.dirs.app.root;
|
|
42
|
+
const adminRootPath = path.join(strapi.dirs.app.root, 'src', 'admin');
|
|
43
|
+
|
|
39
44
|
const anonymous_metadata = {
|
|
40
45
|
environment: strapi.config.environment,
|
|
41
46
|
os: os.type(),
|
|
@@ -47,6 +52,8 @@ module.exports = strapi => {
|
|
|
47
52
|
version: strapi.config.get('info.strapi'),
|
|
48
53
|
strapiVersion: strapi.config.get('info.strapi'),
|
|
49
54
|
projectType: isEE ? 'Enterprise' : 'Community',
|
|
55
|
+
useTypescriptOnServer: isUsingTypeScriptSync(serverRootPath),
|
|
56
|
+
useTypescriptOnAdmin: isUsingTypeScriptSync(adminRootPath),
|
|
50
57
|
};
|
|
51
58
|
|
|
52
59
|
addPackageJsonStrapiMetadata(anonymous_metadata, strapi);
|
|
@@ -30,7 +30,7 @@ const healthCheck = async ctx => {
|
|
|
30
30
|
const createServer = strapi => {
|
|
31
31
|
const app = createKoaApp({
|
|
32
32
|
proxy: strapi.config.get('server.proxy'),
|
|
33
|
-
keys:
|
|
33
|
+
keys: strapi.config.get('server.app.keys'),
|
|
34
34
|
});
|
|
35
35
|
|
|
36
36
|
const router = new Router();
|
|
@@ -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.root, resolve);
|
|
115
|
+
modulePath = path.resolve(strapi.dirs.dist.root, resolve);
|
|
116
116
|
} else {
|
|
117
117
|
throw error;
|
|
118
118
|
}
|
package/lib/utils/get-dirs.js
CHANGED
|
@@ -1,17 +1,31 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const { join } = require('path');
|
|
3
|
+
const { join, resolve } = require('path');
|
|
4
4
|
|
|
5
|
-
const getDirs =
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
5
|
+
const getDirs = ({ app: appDir, dist: distDir }, { strapi }) => ({
|
|
6
|
+
dist: {
|
|
7
|
+
root: distDir,
|
|
8
|
+
src: join(distDir, 'src'),
|
|
9
|
+
api: join(distDir, 'src', 'api'),
|
|
10
|
+
components: join(distDir, 'src', 'components'),
|
|
11
|
+
extensions: join(distDir, 'src', 'extensions'),
|
|
12
|
+
policies: join(distDir, 'src', 'policies'),
|
|
13
|
+
middlewares: join(distDir, 'src', 'middlewares'),
|
|
14
|
+
config: join(distDir, 'config'),
|
|
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
|
+
},
|
|
15
29
|
});
|
|
16
30
|
|
|
17
31
|
module.exports = getDirs;
|
package/lib/utils/index.js
CHANGED
|
@@ -3,9 +3,11 @@
|
|
|
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');
|
|
6
7
|
|
|
7
8
|
module.exports = {
|
|
8
9
|
isInitialized,
|
|
9
10
|
openBrowser,
|
|
10
11
|
getDirs,
|
|
12
|
+
importDefault,
|
|
11
13
|
};
|
|
@@ -38,7 +38,7 @@ const createUpdateNotifier = strapi => {
|
|
|
38
38
|
config = new Configstore(
|
|
39
39
|
pkg.name,
|
|
40
40
|
{},
|
|
41
|
-
{ configPath: path.join(strapi.dirs.root, '.strapi-updater.json') }
|
|
41
|
+
{ configPath: path.join(strapi.dirs.app.root, '.strapi-updater.json') }
|
|
42
42
|
);
|
|
43
43
|
} catch {
|
|
44
44
|
// we don't have write access to the file system
|
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-beta.2",
|
|
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,16 +80,17 @@
|
|
|
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/utils": "4.2.0-
|
|
83
|
+
"@strapi/admin": "4.2.0-beta.2",
|
|
84
|
+
"@strapi/database": "4.2.0-beta.2",
|
|
85
|
+
"@strapi/generate-new": "4.2.0-beta.2",
|
|
86
|
+
"@strapi/generators": "4.2.0-beta.2",
|
|
87
|
+
"@strapi/logger": "4.2.0-beta.2",
|
|
88
|
+
"@strapi/plugin-content-manager": "4.2.0-beta.2",
|
|
89
|
+
"@strapi/plugin-content-type-builder": "4.2.0-beta.2",
|
|
90
|
+
"@strapi/plugin-email": "4.2.0-beta.2",
|
|
91
|
+
"@strapi/plugin-upload": "4.2.0-beta.2",
|
|
92
|
+
"@strapi/typescript-utils": "4.2.0-beta.2",
|
|
93
|
+
"@strapi/utils": "4.2.0-beta.2",
|
|
93
94
|
"bcryptjs": "2.4.3",
|
|
94
95
|
"boxen": "5.1.2",
|
|
95
96
|
"chalk": "4.1.2",
|
|
@@ -130,11 +131,12 @@
|
|
|
130
131
|
"uuid": "^3.3.2"
|
|
131
132
|
},
|
|
132
133
|
"devDependencies": {
|
|
133
|
-
"supertest": "^6.1.6"
|
|
134
|
+
"supertest": "^6.1.6",
|
|
135
|
+
"typescript": "4.6.2"
|
|
134
136
|
},
|
|
135
137
|
"engines": {
|
|
136
138
|
"node": ">=12.22.0 <=16.x.x",
|
|
137
139
|
"npm": ">=6.0.0"
|
|
138
140
|
},
|
|
139
|
-
"gitHead": "
|
|
141
|
+
"gitHead": "bff73257e7695d6f361c91dda8cc810a2bb70b6e"
|
|
140
142
|
}
|