diff --git a/cli-tests/scripts/dts-export.js b/cli-tests/scripts/dts-export.js index 95fa5c1157..ce27b21498 100644 --- a/cli-tests/scripts/dts-export.js +++ b/cli-tests/scripts/dts-export.js @@ -9,7 +9,7 @@ const { }, engine: { createTransferEngine }, } = require('@strapi/data-transfer'); -const { strapiFactory } = require('@strapi/strapi'); +const { createStrapi, compileStrapi } = require('@strapi/strapi'); const path = require('path'); /** @@ -77,8 +77,8 @@ const createDestinationProvider = (datasetPath) => { }; const createStrapiInstance = async (logLevel = 'error') => { - const appContext = await strapiFactory.compile(); - const app = strapiFactory(appContext); + const appContext = await compileStrapi(); + const app = createStrapi(appContext); app.log.level = logLevel; return app.load(); diff --git a/e2e/scripts/dts-export.js b/e2e/scripts/dts-export.js index 9d19084f98..e4aedda96c 100755 --- a/e2e/scripts/dts-export.js +++ b/e2e/scripts/dts-export.js @@ -7,7 +7,7 @@ const { }, engine: { createTransferEngine }, } = require('@strapi/data-transfer'); -const { strapiFactory } = require('@strapi/strapi'); +const { createStrapi, compileStrapi } = require('@strapi/strapi'); const { ALLOWED_CONTENT_TYPES } = require('../constants'); /** @@ -83,8 +83,8 @@ const createDestinationProvider = (filePath) => }); const createStrapiInstance = async (logLevel = 'error') => { - const appContext = await strapiFactory.compile(); - const app = strapiFactory(appContext); + const appContext = await compileStrapi(); + const app = createStrapi(appContext); app.log.level = logLevel; const loadedApp = await app.load(); diff --git a/packages/core/core/package.json b/packages/core/core/package.json index cba6205b2d..d7e677293a 100644 --- a/packages/core/core/package.json +++ b/packages/core/core/package.json @@ -42,7 +42,7 @@ "resources/" ], "scripts": { - "build": "run pack-up build && run copy-files", + "build": "pack-up build && run copy-files", "clean": "run -T rimraf ./dist", "copy-files": "copyfiles -u 1 -a 'src/**/*.html' 'src/**/*.png' dist", "lint": "run -T eslint .", diff --git a/packages/core/core/src/Strapi.ts b/packages/core/core/src/Strapi.ts index 2065e74cd3..c47be23b21 100644 --- a/packages/core/core/src/Strapi.ts +++ b/packages/core/core/src/Strapi.ts @@ -1,6 +1,3 @@ -/* eslint-disable @typescript-eslint/no-namespace */ -/* eslint-disable vars-on-top */ -/* eslint-disable no-var */ import path from 'path'; import _ from 'lodash'; import { isFunction } from 'lodash/fp'; @@ -12,7 +9,6 @@ import type { Core, Modules, UID, Schema } from '@strapi/types'; import loadConfiguration from './configuration'; import * as factories from './factories'; -import compile from './compile'; import * as utils from './utils'; import * as registries from './registries'; @@ -625,25 +621,11 @@ class Strapi extends Container implements Core.Strapi { } } -interface StrapiOptions { +export interface StrapiOptions { appDir?: string; distDir?: string; autoReload?: boolean; serveAdminPanel?: boolean; } -interface Init { - (options?: StrapiOptions): Core.Strapi; - factories: typeof factories; - compile: typeof compile; -} - -const initFn = (options: StrapiOptions = {}): Core.Strapi => { - const strapi = new Strapi(options); - global.strapi = strapi as LoadedStrapi; - return strapi; -}; - -const init: Init = Object.assign(initFn, { factories, compile }); - -export default init; +export default Strapi; diff --git a/packages/core/core/src/index.ts b/packages/core/core/src/index.ts index f3663e12ef..b7742ba823 100644 --- a/packages/core/core/src/index.ts +++ b/packages/core/core/src/index.ts @@ -1,5 +1,15 @@ -import strapiFactory from './Strapi'; +import type { Core } from '@strapi/types'; +import Strapi, { type StrapiOptions } from './Strapi'; + +export { default as compileStrapi } from './compile'; export * as factories from './factories'; -export { strapiFactory }; +export const createStrapi = (options: StrapiOptions = {}): Core.Strapi => { + const strapi = new Strapi(options); + + // TODO: deprecate and remove in next major + global.strapi = strapi as Core.LoadedStrapi; + + return strapi; +}; diff --git a/packages/core/data-transfer/src/strapi/providers/local-destination/__tests__/assets.test.ts b/packages/core/data-transfer/src/strapi/providers/local-destination/__tests__/assets.test.ts index 37facc37c9..1b5b6519f2 100644 --- a/packages/core/data-transfer/src/strapi/providers/local-destination/__tests__/assets.test.ts +++ b/packages/core/data-transfer/src/strapi/providers/local-destination/__tests__/assets.test.ts @@ -24,7 +24,7 @@ const transaction = jest.fn(async (cb) => { await cb({ trx, rollback }); }); -const strapiFactory = getStrapiFactory({ +const createStrapi = getStrapiFactory({ dirs: { static: { public: 'static/public/assets', @@ -57,7 +57,7 @@ describe('Local Strapi Destination Provider - Get Assets Stream', () => { test('Returns a stream when assets restore is true', async () => { const provider = createLocalStrapiDestinationProvider({ - getStrapi: () => strapiFactory(), + getStrapi: () => createStrapi(), strategy: 'restore', restore: { assets: true, @@ -72,7 +72,7 @@ describe('Local Strapi Destination Provider - Get Assets Stream', () => { test('Throw an error if attempting to create stream while restore assets is false', async () => { const provider = createLocalStrapiDestinationProvider({ - getStrapi: () => strapiFactory(), + getStrapi: () => createStrapi(), strategy: 'restore', restore: { assets: false, @@ -96,7 +96,7 @@ describe('Local Strapi Destination Provider - Get Assets Stream', () => { }; const provider = createLocalStrapiDestinationProvider({ getStrapi: () => - strapiFactory({ + createStrapi({ dirs: { static: { public: assetsDirectory, diff --git a/packages/core/strapi/packup.config.ts b/packages/core/strapi/packup.config.ts index f82d223dd3..0a66c06b82 100644 --- a/packages/core/strapi/packup.config.ts +++ b/packages/core/strapi/packup.config.ts @@ -13,7 +13,9 @@ export default defineConfig({ }, { source: './src/cli/index.ts', + import: './dist/cli/index.ts', require: './dist/cli/index.js', + types: './dist/cli/index.d.ts', runtime: 'node', }, { diff --git a/packages/core/strapi/src/cli/commands/admin/__tests__/create-user.test.ts b/packages/core/strapi/src/cli/commands/admin/__tests__/create-user.test.ts index e4a8e6eadd..c8c82d1701 100644 --- a/packages/core/strapi/src/cli/commands/admin/__tests__/create-user.test.ts +++ b/packages/core/strapi/src/cli/commands/admin/__tests__/create-user.test.ts @@ -26,11 +26,10 @@ const mock = { }; jest.mock('@strapi/core', () => { - const strapiFactory: any = jest.fn(() => mock); + const createStrapi: any = jest.fn(() => mock); + const compileStrapi = jest.fn(); - strapiFactory.compile = jest.fn(); - - return { strapiFactory }; + return { createStrapi, compileStrapi }; }); describe('admin:create command', () => { diff --git a/packages/core/strapi/src/cli/commands/admin/__tests__/reset-user-password.test.ts b/packages/core/strapi/src/cli/commands/admin/__tests__/reset-user-password.test.ts index 1d66ed9e3f..29b6b86541 100644 --- a/packages/core/strapi/src/cli/commands/admin/__tests__/reset-user-password.test.ts +++ b/packages/core/strapi/src/cli/commands/admin/__tests__/reset-user-password.test.ts @@ -17,13 +17,11 @@ const mock = { }; jest.mock('@strapi/core', () => { - const strapiFactory = jest.fn(() => mock); + const createStrapi = jest.fn(() => mock); - Object.assign(strapiFactory, { - compile: jest.fn(), - }); + const compileStrapi = jest.fn(); - return { strapiFactory }; + return { createStrapi, compileStrapi }; }); describe('admin:reset-password command', () => { diff --git a/packages/core/strapi/src/cli/commands/admin/create-user.ts b/packages/core/strapi/src/cli/commands/admin/create-user.ts index 0c463d9d68..438f3287b6 100644 --- a/packages/core/strapi/src/cli/commands/admin/create-user.ts +++ b/packages/core/strapi/src/cli/commands/admin/create-user.ts @@ -2,7 +2,7 @@ import { createCommand } from 'commander'; import { yup } from '@strapi/utils'; import _ from 'lodash'; import inquirer from 'inquirer'; -import { strapiFactory } from '@strapi/core'; +import { createStrapi, compileStrapi } from '@strapi/core'; import { runAction } from '../../utils/helpers'; import type { StrapiCommand } from '../../types'; @@ -73,8 +73,8 @@ const promptQuestions: inquirer.QuestionCollection = [ ]; async function createAdmin({ email, password, firstname, lastname }: CmdOptions) { - const appContext = await strapiFactory.compile(); - const app = await strapiFactory(appContext).load(); + const appContext = await compileStrapi(); + const app = await createStrapi(appContext).load(); const user = await app.admin.services.user.exists({ email }); diff --git a/packages/core/strapi/src/cli/commands/admin/reset-user-password.ts b/packages/core/strapi/src/cli/commands/admin/reset-user-password.ts index e17c75d256..621a10e4c6 100644 --- a/packages/core/strapi/src/cli/commands/admin/reset-user-password.ts +++ b/packages/core/strapi/src/cli/commands/admin/reset-user-password.ts @@ -1,7 +1,7 @@ import _ from 'lodash'; import inquirer from 'inquirer'; import { createCommand } from 'commander'; -import { strapiFactory } from '@strapi/core'; +import { createStrapi, compileStrapi } from '@strapi/core'; import type { StrapiCommand } from '../../types'; import { runAction } from '../../utils/helpers'; @@ -28,8 +28,8 @@ const promptQuestions: ReadonlyArray> = [ ]; async function changePassword({ email, password }: CmdOptions) { - const appContext = await strapiFactory.compile(); - const app = await strapiFactory(appContext).load(); + const appContext = await compileStrapi(); + const app = await createStrapi(appContext).load(); await app.admin.services.user.resetPasswordByEmail(email, password); diff --git a/packages/core/strapi/src/cli/commands/components/list.ts b/packages/core/strapi/src/cli/commands/components/list.ts index 02731f3108..70bca55273 100644 --- a/packages/core/strapi/src/cli/commands/components/list.ts +++ b/packages/core/strapi/src/cli/commands/components/list.ts @@ -1,14 +1,14 @@ import { createCommand } from 'commander'; import CLITable from 'cli-table3'; import chalk from 'chalk'; -import { strapiFactory } from '@strapi/core'; +import { createStrapi, compileStrapi } from '@strapi/core'; import type { StrapiCommand } from '../../types'; import { runAction } from '../../utils/helpers'; const action = async () => { - const appContext = await strapiFactory.compile(); - const app = await strapiFactory(appContext).register(); + const appContext = await compileStrapi(); + const app = await createStrapi(appContext).register(); const list = Object.keys(app.components); diff --git a/packages/core/strapi/src/cli/commands/configuration/dump.ts b/packages/core/strapi/src/cli/commands/configuration/dump.ts index 442f303a60..2b581a3660 100644 --- a/packages/core/strapi/src/cli/commands/configuration/dump.ts +++ b/packages/core/strapi/src/cli/commands/configuration/dump.ts @@ -1,6 +1,6 @@ import fs from 'fs'; import { createCommand } from 'commander'; -import { strapiFactory } from '@strapi/core'; +import { createStrapi, compileStrapi } from '@strapi/core'; import type { StrapiCommand } from '../../types'; import { runAction } from '../../utils/helpers'; @@ -32,8 +32,8 @@ const CHUNK_SIZE = 100; const action = async ({ file: filePath, pretty }: CmdOptions) => { const output: Output = filePath ? fs.createWriteStream(filePath) : process.stdout; - const appContext = await strapiFactory.compile(); - const app = await strapiFactory(appContext).load(); + const appContext = await compileStrapi(); + const app = await createStrapi(appContext).load(); const count = await app.query('strapi::core-store').count(); diff --git a/packages/core/strapi/src/cli/commands/configuration/restore.ts b/packages/core/strapi/src/cli/commands/configuration/restore.ts index 4bfff0383a..97a8eecab2 100644 --- a/packages/core/strapi/src/cli/commands/configuration/restore.ts +++ b/packages/core/strapi/src/cli/commands/configuration/restore.ts @@ -1,7 +1,7 @@ import { createCommand } from 'commander'; import fs from 'fs'; import _ from 'lodash'; -import { strapiFactory } from '@strapi/core'; +import { createStrapi, compileStrapi } from '@strapi/core'; import type { Database } from '@strapi/database'; import type { StrapiCommand } from '../../types'; @@ -20,8 +20,8 @@ interface CmdOptions { const action = async ({ file: filePath, strategy = 'replace' }: CmdOptions) => { const input = filePath ? fs.readFileSync(filePath) : await readStdin(); - const appContext = await strapiFactory.compile(); - const app = await strapiFactory(appContext).load(); + const appContext = await compileStrapi(); + const app = await createStrapi(appContext).load(); let dataToImport; try { diff --git a/packages/core/strapi/src/cli/commands/console.ts b/packages/core/strapi/src/cli/commands/console.ts index 63a2cd24fb..6f329c2d9e 100644 --- a/packages/core/strapi/src/cli/commands/console.ts +++ b/packages/core/strapi/src/cli/commands/console.ts @@ -1,13 +1,13 @@ import REPL from 'repl'; import { createCommand } from 'commander'; -import { strapiFactory } from '@strapi/core'; +import { createStrapi, compileStrapi } from '@strapi/core'; import type { StrapiCommand } from '../types'; import { runAction } from '../utils/helpers'; const action = async () => { - const appContext = await strapiFactory.compile(); - const app = await strapiFactory(appContext).load(); + const appContext = await compileStrapi(); + const app = await createStrapi(appContext).load(); app.start().then(() => { const repl = REPL.start(app.config.info.name + ' > ' || 'strapi > '); // eslint-disable-line prefer-template diff --git a/packages/core/strapi/src/cli/commands/content-types/list.ts b/packages/core/strapi/src/cli/commands/content-types/list.ts index 20b8f42239..944f684ced 100644 --- a/packages/core/strapi/src/cli/commands/content-types/list.ts +++ b/packages/core/strapi/src/cli/commands/content-types/list.ts @@ -2,14 +2,14 @@ import { createCommand } from 'commander'; import CLITable from 'cli-table3'; import chalk from 'chalk'; -import { strapiFactory } from '@strapi/core'; +import { createStrapi, compileStrapi } from '@strapi/core'; import type { StrapiCommand } from '../../types'; import { runAction } from '../../utils/helpers'; const action = async () => { - const appContext = await strapiFactory.compile(); - const app = await strapiFactory(appContext).register(); + const appContext = await compileStrapi(); + const app = await createStrapi(appContext).register(); const list = app.get('content-types').keys(); diff --git a/packages/core/strapi/src/cli/commands/controllers/list.ts b/packages/core/strapi/src/cli/commands/controllers/list.ts index 25c6780480..1c41af546c 100644 --- a/packages/core/strapi/src/cli/commands/controllers/list.ts +++ b/packages/core/strapi/src/cli/commands/controllers/list.ts @@ -2,14 +2,14 @@ import { createCommand } from 'commander'; import CLITable from 'cli-table3'; import chalk from 'chalk'; -import { strapiFactory } from '@strapi/core'; +import { createStrapi, compileStrapi } from '@strapi/core'; import type { StrapiCommand } from '../../types'; import { runAction } from '../../utils/helpers'; const action = async () => { - const appContext = await strapiFactory.compile(); - const app = await strapiFactory(appContext).register(); + const appContext = await compileStrapi(); + const app = await createStrapi(appContext).register(); const list = app.get('controllers').keys(); diff --git a/packages/core/strapi/src/cli/commands/hooks/list.ts b/packages/core/strapi/src/cli/commands/hooks/list.ts index 58052c8b48..ba3cbd39a4 100644 --- a/packages/core/strapi/src/cli/commands/hooks/list.ts +++ b/packages/core/strapi/src/cli/commands/hooks/list.ts @@ -1,14 +1,14 @@ import { createCommand } from 'commander'; import CLITable from 'cli-table3'; import chalk from 'chalk'; -import { strapiFactory } from '@strapi/core'; +import { createStrapi, compileStrapi } from '@strapi/core'; import type { StrapiCommand } from '../../types'; import { runAction } from '../../utils/helpers'; const action = async () => { - const appContext = await strapiFactory.compile(); - const app = await strapiFactory(appContext).register(); + const appContext = await compileStrapi(); + const app = await createStrapi(appContext).register(); const list = app.get('hooks').keys(); diff --git a/packages/core/strapi/src/cli/commands/middlewares/list.ts b/packages/core/strapi/src/cli/commands/middlewares/list.ts index a1892e603c..5161cf0109 100644 --- a/packages/core/strapi/src/cli/commands/middlewares/list.ts +++ b/packages/core/strapi/src/cli/commands/middlewares/list.ts @@ -1,14 +1,14 @@ import { createCommand } from 'commander'; import CLITable from 'cli-table3'; import chalk from 'chalk'; -import { strapiFactory } from '@strapi/core'; +import { createStrapi, compileStrapi } from '@strapi/core'; import type { StrapiCommand } from '../../types'; import { runAction } from '../../utils/helpers'; const action = async () => { - const appContext = await strapiFactory.compile(); - const app = await strapiFactory(appContext).register(); + const appContext = await compileStrapi(); + const app = await createStrapi(appContext).register(); const list = app.get('middlewares').keys(); diff --git a/packages/core/strapi/src/cli/commands/policies/list.ts b/packages/core/strapi/src/cli/commands/policies/list.ts index 3a04d379ed..f1f99809d3 100644 --- a/packages/core/strapi/src/cli/commands/policies/list.ts +++ b/packages/core/strapi/src/cli/commands/policies/list.ts @@ -1,14 +1,14 @@ import { createCommand } from 'commander'; import CLITable from 'cli-table3'; import chalk from 'chalk'; -import { strapiFactory } from '@strapi/core'; +import { createStrapi, compileStrapi } from '@strapi/core'; import type { StrapiCommand } from '../../types'; import { runAction } from '../../utils/helpers'; const action = async () => { - const appContext = await strapiFactory.compile(); - const app = await strapiFactory(appContext).register(); + const appContext = await compileStrapi(); + const app = await createStrapi(appContext).register(); const list = app.get('policies').keys(); diff --git a/packages/core/strapi/src/cli/commands/report.ts b/packages/core/strapi/src/cli/commands/report.ts index 0fa8711183..6f0653cc2f 100644 --- a/packages/core/strapi/src/cli/commands/report.ts +++ b/packages/core/strapi/src/cli/commands/report.ts @@ -1,6 +1,6 @@ import { createCommand } from 'commander'; import { EOL } from 'os'; -import { strapiFactory } from '@strapi/core'; +import { createStrapi, compileStrapi } from '@strapi/core'; import type { StrapiCommand } from '../types'; import { runAction } from '../utils/helpers'; @@ -16,8 +16,8 @@ const action = async ({ uuid, dependencies, all }: CmdOptions) => { reportDependencies: Boolean(all || dependencies), }; - const appContext = await strapiFactory.compile(); - const app = await strapiFactory(appContext).register(); + const appContext = await compileStrapi(); + const app = await createStrapi(appContext).register(); let debugInfo = `Launched In: ${Date.now() - app.config.launchedAt} ms Environment: ${app.config.environment} diff --git a/packages/core/strapi/src/cli/commands/routes/list.ts b/packages/core/strapi/src/cli/commands/routes/list.ts index 2934569278..1308603da7 100644 --- a/packages/core/strapi/src/cli/commands/routes/list.ts +++ b/packages/core/strapi/src/cli/commands/routes/list.ts @@ -3,14 +3,14 @@ import CLITable from 'cli-table3'; import chalk from 'chalk'; import { toUpper } from 'lodash/fp'; -import { strapiFactory } from '@strapi/core'; +import { createStrapi, compileStrapi } from '@strapi/core'; import type { StrapiCommand } from '../../types'; import { runAction } from '../../utils/helpers'; const action = async () => { - const appContext = await strapiFactory.compile(); - const app = await strapiFactory(appContext).load(); + const appContext = await compileStrapi(); + const app = await createStrapi(appContext).load(); const list = app.server.mount().listRoutes(); diff --git a/packages/core/strapi/src/cli/commands/services/list.ts b/packages/core/strapi/src/cli/commands/services/list.ts index afed6e428b..e898edeb7b 100644 --- a/packages/core/strapi/src/cli/commands/services/list.ts +++ b/packages/core/strapi/src/cli/commands/services/list.ts @@ -1,14 +1,14 @@ import { createCommand } from 'commander'; import CLITable from 'cli-table3'; import chalk from 'chalk'; -import { strapiFactory } from '@strapi/core'; +import { createStrapi, compileStrapi } from '@strapi/core'; import type { StrapiCommand } from '../../types'; import { runAction } from '../../utils/helpers'; const action = async () => { - const appContext = await strapiFactory.compile(); - const app = await strapiFactory(appContext).register(); + const appContext = await compileStrapi(); + const app = await createStrapi(appContext).register(); const list = app.get('services').keys(); diff --git a/packages/core/strapi/src/cli/commands/start.ts b/packages/core/strapi/src/cli/commands/start.ts index 64ee6c18e5..93c14c0d87 100644 --- a/packages/core/strapi/src/cli/commands/start.ts +++ b/packages/core/strapi/src/cli/commands/start.ts @@ -1,7 +1,7 @@ import { createCommand } from 'commander'; import fs from 'fs'; import tsUtils from '@strapi/typescript-utils'; -import { strapiFactory } from '@strapi/core'; +import { createStrapi } from '@strapi/core'; import type { StrapiCommand } from '../types'; import { runAction } from '../utils/helpers'; @@ -20,7 +20,7 @@ const action = async () => { `${outDir} directory not found. Please run the build command before starting your application` ); - strapiFactory({ appDir, distDir }).start(); + createStrapi({ appDir, distDir }).start(); }; /** diff --git a/packages/core/strapi/src/cli/commands/ts/generate-types.ts b/packages/core/strapi/src/cli/commands/ts/generate-types.ts index 44bc07effc..d1680b271e 100644 --- a/packages/core/strapi/src/cli/commands/ts/generate-types.ts +++ b/packages/core/strapi/src/cli/commands/ts/generate-types.ts @@ -1,6 +1,6 @@ import { createCommand } from 'commander'; import tsUtils from '@strapi/typescript-utils'; -import { strapiFactory } from '@strapi/core'; +import { createStrapi, compileStrapi } from '@strapi/core'; import type { StrapiCommand } from '../../types'; import { runAction } from '../../utils/helpers'; @@ -18,8 +18,8 @@ const action = async ({ debug, silent, verbose, outDir }: CmdOptions) => { process.exit(1); } - const appContext = await strapiFactory.compile({ ignoreDiagnostics: true }); - const app = await strapiFactory(appContext).register(); + const appContext = await compileStrapi({ ignoreDiagnostics: true }); + const app = await createStrapi(appContext).register(); await tsUtils.generators.generate({ strapi: app, diff --git a/packages/core/strapi/src/cli/utils/data-transfer.ts b/packages/core/strapi/src/cli/utils/data-transfer.ts index 6fcad9aa2e..fc787fc133 100644 --- a/packages/core/strapi/src/cli/utils/data-transfer.ts +++ b/packages/core/strapi/src/cli/utils/data-transfer.ts @@ -2,7 +2,7 @@ import chalk from 'chalk'; import Table from 'cli-table3'; import { Command, Option } from 'commander'; import { configs, createLogger } from '@strapi/logger'; -import { strapiFactory } from '@strapi/core'; +import { createStrapi, compileStrapi } from '@strapi/core'; import ora from 'ora'; import { merge } from 'lodash/fp'; import type { Core } from '@strapi/types'; @@ -153,8 +153,8 @@ const createStrapiInstance = async ( opts: { logLevel?: string } = {} ): Promise> => { try { - const appContext = await strapiFactory.compile(); - const app = strapiFactory({ ...opts, ...appContext }); + const appContext = await compileStrapi(); + const app = createStrapi({ ...opts, ...appContext }); app.log.level = opts.logLevel || 'error'; return await app.load(); diff --git a/packages/core/strapi/src/node/create-build-context.ts b/packages/core/strapi/src/node/create-build-context.ts index dfc8499db5..bbdc4a4cd9 100644 --- a/packages/core/strapi/src/node/create-build-context.ts +++ b/packages/core/strapi/src/node/create-build-context.ts @@ -2,7 +2,7 @@ import os from 'node:os'; import path from 'node:path'; import fs from 'node:fs/promises'; import browserslist from 'browserslist'; -import { strapiFactory } from '@strapi/core'; +import { createStrapi } from '@strapi/core'; import { Core, Modules } from '@strapi/types'; import type { CLIContext } from '../cli/types'; @@ -66,7 +66,7 @@ const createBuildContext = async ({ */ const strapiInstance = strapi ?? - strapiFactory({ + createStrapi({ // Directories appDir: cwd, distDir: tsconfig?.config.options.outDir ?? '', diff --git a/packages/core/strapi/src/node/develop.ts b/packages/core/strapi/src/node/develop.ts index 1cf6429801..56e44a3366 100644 --- a/packages/core/strapi/src/node/develop.ts +++ b/packages/core/strapi/src/node/develop.ts @@ -4,7 +4,7 @@ import chokidar from 'chokidar'; import fs from 'node:fs/promises'; import path from 'node:path'; import cluster from 'node:cluster'; -import { strapiFactory } from '@strapi/core'; +import { createStrapi } from '@strapi/core'; import type { CLIContext } from '../cli/types'; import { checkRequiredDependencies } from './core/dependencies'; @@ -166,7 +166,7 @@ const develop = async ({ timer.start('loadStrapi'); const loadStrapiSpinner = logger.spinner(`Loading Strapi`).start(); - const strapi = strapiFactory({ + const strapi = createStrapi({ appDir: cwd, distDir: tsconfig?.config.options.outDir ?? '', autoReload: true, diff --git a/packages/utils/api-tests/strapi.js b/packages/utils/api-tests/strapi.js index 2d63b3296f..675956f528 100644 --- a/packages/utils/api-tests/strapi.js +++ b/packages/utils/api-tests/strapi.js @@ -3,7 +3,7 @@ const path = require('path'); const _ = require('lodash'); const dotenv = require('dotenv'); -const { strapiFactory } = require('../../core/strapi'); +const { createStrapi } = require('../../core/strapi'); const { createUtils } = require('./utils'); const superAdminCredentials = { @@ -30,7 +30,7 @@ const createStrapiInstance = async ({ appDir: baseDir, distDir: baseDir, }; - const instance = strapiFactory(options); + const instance = createStrapi(options); if (bypassAuth) { instance.get('auth').register('content-api', {