@strapi/strapi 4.2.0-beta.4 → 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.
Files changed (45) hide show
  1. package/bin/strapi.js +1 -2
  2. package/lib/Strapi.js +4 -42
  3. package/lib/commands/admin-create.js +1 -15
  4. package/lib/commands/admin-reset.js +1 -15
  5. package/lib/commands/build.js +44 -18
  6. package/lib/commands/configurationDump.js +1 -14
  7. package/lib/commands/configurationRestore.js +1 -16
  8. package/lib/commands/console.js +2 -16
  9. package/lib/commands/develop.js +74 -114
  10. package/lib/commands/routes/list.js +1 -15
  11. package/lib/commands/start.js +2 -12
  12. package/lib/commands/watchAdmin.js +10 -10
  13. package/lib/core/app-configuration/index.js +3 -4
  14. package/lib/core/app-configuration/load-config-file.js +1 -3
  15. package/lib/core/bootstrap.js +2 -2
  16. package/lib/core/loaders/apis.js +5 -6
  17. package/lib/core/loaders/components.js +4 -5
  18. package/lib/core/loaders/middlewares.js +3 -5
  19. package/lib/core/loaders/plugins/get-enabled-plugins.js +1 -2
  20. package/lib/core/loaders/plugins/get-user-plugins-config.js +2 -2
  21. package/lib/core/loaders/plugins/index.js +1 -1
  22. package/lib/core/loaders/policies.js +2 -4
  23. package/lib/core/loaders/src-index.js +4 -6
  24. package/lib/core/registries/policies.d.ts +1 -1
  25. package/lib/core-api/controller/index.d.ts +9 -14
  26. package/lib/core-api/service/index.d.ts +9 -10
  27. package/lib/factories.d.ts +18 -22
  28. package/lib/index.d.ts +6 -7
  29. package/lib/load/load-files.js +1 -3
  30. package/lib/middlewares/favicon.js +1 -1
  31. package/lib/middlewares/public/index.js +1 -2
  32. package/lib/services/fs.js +1 -1
  33. package/lib/services/metrics/index.js +1 -5
  34. package/lib/services/metrics/sender.js +0 -7
  35. package/lib/services/server/middleware.js +1 -1
  36. package/lib/utils/get-dirs.js +10 -24
  37. package/lib/utils/index.js +0 -2
  38. package/lib/utils/update-notifier/index.js +1 -1
  39. package/package.json +13 -15
  40. package/lib/commands/builders/admin.js +0 -59
  41. package/lib/commands/builders/index.js +0 -9
  42. package/lib/commands/builders/typescript.js +0 -32
  43. package/lib/types/strapi.d.ts +0 -291
  44. package/lib/types/utils.d.ts +0 -1
  45. package/lib/utils/import-default.js +0 -9
@@ -31,13 +31,12 @@ const defaultConfig = {
31
31
  },
32
32
  };
33
33
 
34
- module.exports = (dirs, initialConfig = {}) => {
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(appDir, 'package.json'));
37
+ const pkgJSON = require(path.resolve(dir, 'package.json'));
39
38
 
40
- const configDir = path.resolve(distDir || process.cwd(), 'config');
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 = __importDefault(require(file)).default;
9
+ const jsModule = require(file);
12
10
 
13
11
  // call if function
14
12
  if (typeof jsModule === 'function') {
@@ -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.static.public))) {
28
+ if (!(await fse.pathExists(strapi.dirs.public))) {
29
29
  throw new Error(
30
- `The public folder (${strapi.dirs.static.public}) doesn't exist or is not accessible. Please make sure it exists.`
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
  };
@@ -5,7 +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
8
 
10
9
  const DEFAULT_CONTENT_TYPE = {
11
10
  schema: {},
@@ -20,11 +19,11 @@ const isDirectory = fd => fd.isDirectory();
20
19
  const isDotFile = fd => fd.name.startsWith('.');
21
20
 
22
21
  module.exports = async strapi => {
23
- if (!existsSync(strapi.dirs.dist.api)) {
24
- return;
22
+ if (!existsSync(strapi.dirs.api)) {
23
+ throw new Error('Missing api folder. Please create one at `./src/api`');
25
24
  }
26
25
 
27
- const apisFDs = await (await fse.readdir(strapi.dirs.dist.api, { withFileTypes: true }))
26
+ const apisFDs = await (await fse.readdir(strapi.dirs.api, { withFileTypes: true }))
28
27
  .filter(isDirectory)
29
28
  .filter(_.negate(isDotFile));
30
29
 
@@ -33,7 +32,7 @@ module.exports = async strapi => {
33
32
  // only load folders
34
33
  for (const apiFD of apisFDs) {
35
34
  const apiName = normalizeName(apiFD.name);
36
- const api = await loadAPI(join(strapi.dirs.dist.api, apiFD.name));
35
+ const api = await loadAPI(join(strapi.dirs.api, apiFD.name));
37
36
 
38
37
  apis[apiName] = api;
39
38
  }
@@ -155,7 +154,7 @@ const loadFile = file => {
155
154
 
156
155
  switch (ext) {
157
156
  case '.js':
158
- return importDefault(require(file)).default;
157
+ return require(file);
159
158
  case '.json':
160
159
  return fse.readJSON(file);
161
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.dist.components))) {
9
+ if (!(await pathExists(strapi.dirs.components))) {
10
10
  return {};
11
11
  }
12
12
 
13
- const map = await loadFiles(strapi.dirs.dist.components, '*/*.*(js|json)');
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
- if (!schema.collectionName) {
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 = importDefault(require('../../middlewares')).default;
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.dist.middlewares;
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] = importDefault(require(fullPath)).default;
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.app.root, declaration.resolve);
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.dist.config, 'plugins.js');
15
+ const globalUserConfigPath = join(strapi.dirs.config, 'plugins.js');
16
16
  const currentEnvUserConfigPath = join(
17
- strapi.dirs.dist.config,
17
+ strapi.dirs.config,
18
18
  'env',
19
19
  process.env.NODE_ENV,
20
20
  'plugins.js'
@@ -26,7 +26,7 @@ const defaultPlugin = {
26
26
  };
27
27
 
28
28
  const applyUserExtension = async plugins => {
29
- const extensionsDir = strapi.dirs.dist.extensions;
29
+ const extensionsDir = strapi.dirs.extensions;
30
30
  if (!(await fse.pathExists(extensionsDir))) {
31
31
  return;
32
32
  }
@@ -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.dist.policies;
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] = importDefault(require(fullPath)).default;
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.dist.src)) {
24
- return;
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.dist.src, 'index.js');
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 = importDefault(require(pathToSrcIndex)).default;
30
+ const srcIndex = require(pathToSrcIndex);
33
31
 
34
32
  try {
35
33
  validateSrcIndex(srcIndex);
@@ -6,4 +6,4 @@ interface PolicyContext extends BaseContext {
6
6
  is(name): boolean;
7
7
  }
8
8
 
9
- export type Policy<T=unknown> = (ctx: PolicyContext,cfg:T, { strapi: Strapi }) => boolean | undefined;
9
+ export type Policy = (ctx: PolicyContext, { strapi: Strapi }) => boolean | undefined;
@@ -1,6 +1,6 @@
1
1
  import { Context } from 'koa';
2
2
 
3
- type ControllerResponse <T=unknown> = T | Promise<T>;
3
+ type Response = object;
4
4
 
5
5
  interface BaseController {
6
6
  transformResponse(data: object, meta: object): object;
@@ -9,22 +9,17 @@ interface BaseController {
9
9
  }
10
10
 
11
11
  export interface SingleTypeController extends BaseController {
12
- find(ctx: Context): ControllerResponse;
13
- update(ctx: Context): ControllerResponse;
14
- delete(ctx: Context): ControllerResponse;
12
+ find(ctx: Context): Promise<Response>;
13
+ update(ctx: Context): Promise<Response>;
14
+ delete(ctx: Context): Promise<Response>;
15
15
  }
16
16
 
17
17
  export interface CollectionTypeController extends BaseController {
18
- find(ctx: Context): ControllerResponse;
19
- findOne(ctx: Context): ControllerResponse
20
- create(ctx: Context): ControllerResponse;
21
- update(ctx: Context): ControllerResponse;
22
- delete(ctx: Context): ControllerResponse;
18
+ find(ctx: Context): Promise<Response>;
19
+ findOne(ctx: Context): Promise<Response>;
20
+ create(ctx: Context): Promise<Response>;
21
+ update(ctx: Context): Promise<Response>;
22
+ delete(ctx: Context): Promise<Response>;
23
23
  }
24
24
 
25
25
  export type Controller = SingleTypeController | CollectionTypeController;
26
-
27
- export type GenericController = Partial<Controller> & {
28
- [method: string | number | symbol]: (ctx: Context) => unknown
29
- }
30
-
@@ -1,22 +1,21 @@
1
1
  type Entity = object;
2
2
 
3
3
  interface BaseService {
4
- getFetchParams?(params: object): object;
4
+ getFetchParams(params: object): object;
5
5
  }
6
6
 
7
7
  export interface SingleTypeService extends BaseService {
8
- find?(params: object): Promise<Entity> | Entity;
9
- createOrUpdate?(params: object): Promise<Entity> | Entity;
10
- delete?(params: object): Promise<Entity> | Entity;
8
+ find(params: object): Promise<Entity>;
9
+ createOrUpdate(params: object): Promise<Entity>;
10
+ delete(params: object): Promise<Entity>;
11
11
  }
12
12
 
13
13
  export interface CollectionTypeService extends BaseService {
14
- find?(params: object): Promise<Entity[]> | Entity;
15
- findOne?(entityId: string,params: object): Promise<Entity> | Entity;
16
- create?(params: object): Promise<Entity> | Entity;
17
- update?(entityId: string,params: object): Promise<Entity> | Entity;
18
- delete?(entityId: string,params: object): Promise<Entity> | Entity;
14
+ find(params: object): Promise<Entity[]>;
15
+ findOne(params: object): Promise<Entity>;
16
+ create(params: object): Promise<Entity>;
17
+ update(params: object): Promise<Entity>;
18
+ delete(params: object): Promise<Entity>;
19
19
  }
20
20
 
21
21
  export type Service = SingleTypeService | CollectionTypeService;
22
-
@@ -1,37 +1,36 @@
1
1
  import { Service } from './core-api/service';
2
- import { Controller, GenericController } from './core-api/controller';
2
+ import { Controller } from './core-api/controller';
3
3
  import { Middleware } from './middlewares';
4
4
  import { Policy } from './core/registries/policies';
5
- import { Strapi } from '@strapi/strapi'
6
5
 
7
- type ControllerConfig<T extends Controller = Controller> = T;
6
+ type ControllerConfig = Controller;
8
7
 
9
8
  type ServiceConfig = Service;
10
9
 
11
10
  type HandlerConfig = {
12
- auth?: false | { scope: string[] };
13
- policies?: Array<string | Policy>;
14
- middlewares?: Array<string | Middleware>;
11
+ auth: false | { scope: string[] };
12
+ policies: Array<string | Policy>;
13
+ middlewares: Array<string | Middleware>;
15
14
  };
16
15
 
17
16
  type SingleTypeRouterConfig = {
18
- find?: HandlerConfig;
19
- update?: HandlerConfig;
20
- delete?: HandlerConfig;
17
+ find: HandlerConfig;
18
+ update: HandlerConfig;
19
+ delete: HandlerConfig;
21
20
  };
22
21
 
23
22
  type CollectionTypeRouterConfig = {
24
- find?: HandlerConfig;
25
- findOne?: HandlerConfig;
26
- create?: HandlerConfig;
27
- update?: HandlerConfig;
28
- delete?: HandlerConfig;
23
+ find: HandlerConfig;
24
+ findOne: HandlerConfig;
25
+ create: HandlerConfig;
26
+ update: HandlerConfig;
27
+ delete: HandlerConfig;
29
28
  };
30
29
 
31
30
  type RouterConfig = {
32
- prefix?: string;
31
+ prefix: string;
33
32
  only: string[];
34
- except?: string[];
33
+ except: string[];
35
34
  config: SingleTypeRouterConfig | CollectionTypeRouterConfig;
36
35
  };
37
36
 
@@ -44,9 +43,6 @@ interface Router {
44
43
  routes: Route[];
45
44
  }
46
45
 
47
- type ControllerCallback <T extends GenericController = GenericController> = (params:{strapi:Strapi}) => T;
48
- type ServiceCallback <T extends Service = Sevice> = (params:{strapi:Strapi}) => T
49
-
50
- export function createCoreRouter(uid: string, cfg?: RouterConfig = {}): () => Router;
51
- export function createCoreController<T extends GenericController = GenericController>(uid: string, cfg?: ControllerCallback<T> | T = {}): () => T & Controller;
52
- export function createCoreService<T extends Service = Service>(uid: string, cfg?: ServiceCallback<T> | T = {}): () => T ;
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
@@ -1,15 +1,14 @@
1
1
  import { Database } from '@strapi/database';
2
2
  import { EntityService } from './services/entity-service';
3
+ import { Strapi as StrapiClass } from './Strapi';
3
4
 
4
- import * as Core from './types/strapi';
5
5
  export * as factories from './factories';
6
+ interface StrapiInterface extends StrapiClass {
7
+ query: Database['query'];
8
+ entityService: EntityService;
9
+ }
6
10
 
7
- export type { Core };
8
-
9
- // Alias to resolve the Strapi global type easily
10
- export type Strapi = Core.Strapi;
11
-
12
- export interface StrapiInterface extends Core.Strapi {};
11
+ export type Strapi = StrapiInterface;
13
12
 
14
13
  declare global {
15
14
  interface AllTypes {}
@@ -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 = importDefault(requireFn(absolutePath)).default;
37
+ mod = requireFn(absolutePath);
40
38
  }
41
39
 
42
40
  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.app.root, faviconPath), { maxAge });
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.static.public, {
83
+ handler: koaStatic(strapi.dirs.public, {
85
84
  maxage: maxAge,
86
85
  defer: true,
87
86
  }),
@@ -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.app.root, normalizedPath);
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.app.root, 'README.md');
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.dist.root, resolve);
115
+ modulePath = path.resolve(strapi.dirs.root, resolve);
116
116
  } else {
117
117
  throw error;
118
118
  }
@@ -2,30 +2,16 @@
2
2
 
3
3
  const { join, resolve } = require('path');
4
4
 
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
- },
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;
@@ -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
  };
@@ -38,7 +38,7 @@ const createUpdateNotifier = strapi => {
38
38
  config = new Configstore(
39
39
  pkg.name,
40
40
  {},
41
- { configPath: path.join(strapi.dirs.app.root, '.strapi-updater.json') }
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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@strapi/strapi",
3
- "version": "4.2.0-beta.4",
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-beta.4",
84
- "@strapi/database": "4.2.0-beta.4",
85
- "@strapi/generate-new": "4.2.0-beta.4",
86
- "@strapi/generators": "4.2.0-beta.4",
87
- "@strapi/logger": "4.2.0-beta.4",
88
- "@strapi/plugin-content-manager": "4.2.0-beta.4",
89
- "@strapi/plugin-content-type-builder": "4.2.0-beta.4",
90
- "@strapi/plugin-email": "4.2.0-beta.4",
91
- "@strapi/plugin-upload": "4.2.0-beta.4",
92
- "@strapi/typescript-utils": "4.2.0-beta.4",
93
- "@strapi/utils": "4.2.0-beta.4",
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",
@@ -132,12 +131,11 @@
132
131
  "uuid": "^3.3.2"
133
132
  },
134
133
  "devDependencies": {
135
- "supertest": "^6.1.6",
136
- "typescript": "4.6.2"
134
+ "supertest": "^6.1.6"
137
135
  },
138
136
  "engines": {
139
137
  "node": ">=14.19.1 <=16.x.x",
140
138
  "npm": ">=6.0.0"
141
139
  },
142
- "gitHead": "5caff35a30e33b7a660eb946299f9e3d2d35b2b8"
140
+ "gitHead": "12c8ee3b2d95fe417de4d939db0311a0513bd8da"
143
141
  }