From f379a8cd7aec7928662c4214df631f2bc8b1f34c Mon Sep 17 00:00:00 2001 From: Josh <37798644+joshuaellis@users.noreply.github.com> Date: Tue, 23 Jan 2024 11:21:20 +0000 Subject: [PATCH] chore: make vite the default bundler for the admin (#19283) --- .../01-core/admin/04-commands/00-overview.md | 21 -- .../01-core/admin/04-commands/01-build.md | 189 ------------------ .../01-core/admin/04-commands/02-develop.md | 90 --------- .../01-core/admin/04-commands/_category_.json | 5 - .../_category_.json | 0 .../authentication.md | 0 .../hooks/_category_.json | 0 .../hooks/use-admin-roles.mdx | 0 .../hooks/use-enterprise.mdx | 0 .../admin/{05-features => 04-features}/nps.md | 0 .../docs/01-core/strapi/commands/01-build.md | 159 ++++++++++++++- .../01-core/strapi/commands/02-develop.md | 65 +++++- packages/core/admin/tsconfig.json | 8 +- .../admin/tsconfig.build.json | 7 +- packages/core/content-releases/package.json | 13 +- .../server/src/controllers/release-action.ts | 8 +- .../server/src/controllers/release.ts | 4 +- .../server/tsconfig.build.json | 9 +- .../content-releases/server/tsconfig.json | 4 +- packages/core/strapi/src/admin.ts | 2 +- .../core/strapi/src/cli/commands/build.ts | 47 +---- .../core/strapi/src/cli/commands/develop.ts | 47 +---- yarn.lock | 2 - 23 files changed, 254 insertions(+), 426 deletions(-) delete mode 100644 docs/docs/docs/01-core/admin/04-commands/00-overview.md delete mode 100644 docs/docs/docs/01-core/admin/04-commands/01-build.md delete mode 100644 docs/docs/docs/01-core/admin/04-commands/02-develop.md delete mode 100644 docs/docs/docs/01-core/admin/04-commands/_category_.json rename docs/docs/docs/01-core/admin/{05-features => 04-features}/_category_.json (100%) rename docs/docs/docs/01-core/admin/{05-features => 04-features}/authentication.md (100%) rename docs/docs/docs/01-core/admin/{05-features => 04-features}/hooks/_category_.json (100%) rename docs/docs/docs/01-core/admin/{05-features => 04-features}/hooks/use-admin-roles.mdx (100%) rename docs/docs/docs/01-core/admin/{05-features => 04-features}/hooks/use-enterprise.mdx (100%) rename docs/docs/docs/01-core/admin/{05-features => 04-features}/nps.md (100%) diff --git a/docs/docs/docs/01-core/admin/04-commands/00-overview.md b/docs/docs/docs/01-core/admin/04-commands/00-overview.md deleted file mode 100644 index b537882b14..0000000000 --- a/docs/docs/docs/01-core/admin/04-commands/00-overview.md +++ /dev/null @@ -1,21 +0,0 @@ ---- -title: Overview -tags: - - commands - - admin ---- - -The following commands are exported from the `@strapi/admin` package and are contained under the `_internal` folder: - -- [`build`](build) -- [`develop`](develop) - -Each CLI command also has a node API equivalent. These can be imported from `@strapi/admin/_internal`: - -```ts -import { build } from '@strapi/admin/_internal'; - -await build({ - // ... -}); -``` diff --git a/docs/docs/docs/01-core/admin/04-commands/01-build.md b/docs/docs/docs/01-core/admin/04-commands/01-build.md deleted file mode 100644 index 350fe79bab..0000000000 --- a/docs/docs/docs/01-core/admin/04-commands/01-build.md +++ /dev/null @@ -1,189 +0,0 @@ ---- -title: Build -tags: - - commands - - admin - - build ---- - -## How it works - -The build process for the admin panel is designed to be bundler agnostic, this means we can easily experiment and perhaps transition to new bundlers as they become available in the ecosystem. This is facilitated by the use of a [`BuildContext`](#buildcontext) that contains all the information needed to build the admin panel – if it's found more information is required this context can be tweaked to provide it. - -### Dependencies - -The first step of running the build command is to check if the required dependencies are installed at the root of the project. This provides better DX for: - -- miss-installed project -- monorepos -- incorrect/incompatible versions of packages for _certain_ packages like `styled-components` or `react`. - -The list of packages we explicity check for are: - -- `react` -- `react-dom` -- `styled-components` -- `react-router-dom` - -This is because there should only be one instance of these packages installed and used by the project at any one time, failure to do so can and most likely will, lead to bugs. This also means an incompatible version of these packages could cause unintended side effects e.g. if `react@19` was suddenly released but we had not tested it against the admin panel. - -We run a prompt to encourage the user to install these deps – however, this functionality has not yet been built. - -### BuildContext - -The build context is the heart of how the admin builds, as said above it's agnostic, it doesn't care if we're using webpack or vite or parcel. It's an object of data that can be used to preapre any bundler. It's shape looks like: - -```ts -interface BuildContext { - /** - * The absolute path to the app directory defined by the Strapi instance - */ - appDir: string; - /** - * If a user is deploying the project under a nested public path, we use - * this path so all asset paths will be rewritten accordingly - */ - basePath: string; - /** - * The customisations defined by the user in their app.js file - */ - customisations?: AppFile; - /** - * The current working directory - */ - cwd: string; - /** - * The absolute path to the dist directory - */ - distPath: string; - /** - * The relative path to the dist directory - */ - distDir: string; - /** - * The absolute path to the entry file - */ - entry: string; - /** - * The environment variables to be included in the JS bundle - */ - env: Record; - logger: CLIContext['logger']; - /** - * The build options - */ - options: Pick & Pick; - /** - * The plugins to be included in the JS bundle - * incl. internal plugins, third party plugins & local plugins - */ - plugins: Array<{ - path: string; - name: string; - importName: string; - }>; - /** - * The absolute path to the runtime directory - */ - runtimeDir: string; - /** - * The Strapi instance - */ - strapi: Strapi; - /** - * The browserslist target either loaded from the user's workspace or falling back to the default - */ - target: string[]; - tsconfig?: CLIContext['tsconfig']; -} -``` - -### Static Files - -The next step is to create a `runtime` folder in the root of the strapi project, a generic name `.strapi` is used and the build specifically uses a subfolder called `client`. This leaves more space for us to expand as and when we require it. We only generate two files for this – an `index.html` which is a static rendered React Component from the `@strapi/admin` package (DefaultDocument) & an `entry.js` file which calls the `renderAdmin` function & provides a mount point & plugin object. - -### Bundling - -We currently only support the `webpack` bundler. Because there is no global `strapi.config` file we don't have an already existing API to pass your own bundler. In the future we may decide to do this if there is a need. The current future plan is to add the `vite` bundler as an option. Each bundler supplies a build function & a develop function. We don't need a serve function because they're expected to produce the same `index.html` output defined by the static files step described above. - -## CLI Usage - -```bash -strapi build -``` - -### Options - -```bash -Build the strapi admin app - -Options: - -d, --debug Enable debugging mode with verbose logs (default: false) - --minify Minify the output (default: true) - --no-optimization [deprecated]: use minify instead - --silent Don't log anything (default: false) - --sourcemap Produce sourcemaps (default: false) - --stats Print build statistics to the console (default: false) - -h, --help Display help for command -``` - -## Node Usage - -```ts -import { build, BuildOptions } from '@strapi/admin/_internal'; - -const args: BuildOptions = { - // ... -}; - -await build(args); -``` - -### Options - -```ts -interface BuildOptions extends CLIContext { - /** - * The directory to build the command was ran from - */ - cwd: string; - /** - * The logger to use. - */ - logger: Logger; - /** - * Minify the output - * - * @default true - */ - minify?: boolean; - /** - * Generate sourcemaps – useful for debugging bugs in the admin panel UI. - */ - sourcemaps?: boolean; - /** - * Print stats for build - */ - stats?: boolean; - /** - * The tsconfig to use for the build. If undefined, this is not a TS project. - */ - tsconfig?: TsConfig; -} - -interface Logger { - warnings: number; - errors: number; - debug: (...args: unknown[]) => void; - info: (...args: unknown[]) => void; - warn: (...args: unknown[]) => void; - error: (...args: unknown[]) => void; - log: (...args: unknown[]) => void; - spinner: (text: string) => Pick; -} - -interface TsConfig { - config: ts.ParsedCommandLine; - path: string; -} -``` diff --git a/docs/docs/docs/01-core/admin/04-commands/02-develop.md b/docs/docs/docs/01-core/admin/04-commands/02-develop.md deleted file mode 100644 index f5d50cd165..0000000000 --- a/docs/docs/docs/01-core/admin/04-commands/02-develop.md +++ /dev/null @@ -1,90 +0,0 @@ ---- -title: Develop -tags: - - commands - - admin - - develop ---- - -## How it works - -The develop command sets itself up much like the [build](build) command. Once we've injected our middlewares, we load the strapi instance and then generate the types based off the user's instance as well as potentially compiling any TS server code if we're in a TS project. The final step is to watch the project directory so we can restart the strapi instance in real-time as a user is developing their project & being the actual strapi instance. - -## CLI Usage - -```bash -strapi develop -``` - -### Options - -```bash -Start your Strapi application in development mode - -Options: - --polling Watch for file changes (default: false) – Whether to use fs.watchFile (backed by polling), or fs.watch, this is passed directly to chokidar - --no-build [deprecated]: there is middleware for the server, it is no longer a separate process - --watch-admin Watch the admin for changes (default: false) - --browser [deprecated]: use open instead - --open Open the admin in your browser (default: true) - -h, --help Display help for command -``` - -## Node Usage - -```ts -import { develop, DevelopOptions } from '@strapi/admin/_internal'; - -const args: DevelopOptions = { - // ... -}; - -await develop(args); -``` - -### Options - -```ts -interface DevelopOptions extends CLIContext { - /** - * The directory to build the command was ran from - */ - cwd: string; - /** - * The logger to use. - */ - logger: Logger; - /** - * Whether or not to open the browser after the build is complete. - */ - open?: boolean; - /** - * Watch for file changes in network directories - */ - polling?: boolean; - /** - * The tsconfig to use for the build. If undefined, this is not a TS project. - */ - tsconfig?: TsConfig; - /** - * Watch the admin for changes - */ - watchAdmin?: boolean; -} - -interface Logger { - warnings: number; - errors: number; - debug: (...args: unknown[]) => void; - info: (...args: unknown[]) => void; - warn: (...args: unknown[]) => void; - error: (...args: unknown[]) => void; - log: (...args: unknown[]) => void; - spinner: (text: string) => Pick; -} - -interface TsConfig { - config: ts.ParsedCommandLine; - path: string; -} -``` diff --git a/docs/docs/docs/01-core/admin/04-commands/_category_.json b/docs/docs/docs/01-core/admin/04-commands/_category_.json deleted file mode 100644 index 4dc754d38d..0000000000 --- a/docs/docs/docs/01-core/admin/04-commands/_category_.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "label": "Commands", - "collapsible": true, - "collapsed": true -} diff --git a/docs/docs/docs/01-core/admin/05-features/_category_.json b/docs/docs/docs/01-core/admin/04-features/_category_.json similarity index 100% rename from docs/docs/docs/01-core/admin/05-features/_category_.json rename to docs/docs/docs/01-core/admin/04-features/_category_.json diff --git a/docs/docs/docs/01-core/admin/05-features/authentication.md b/docs/docs/docs/01-core/admin/04-features/authentication.md similarity index 100% rename from docs/docs/docs/01-core/admin/05-features/authentication.md rename to docs/docs/docs/01-core/admin/04-features/authentication.md diff --git a/docs/docs/docs/01-core/admin/05-features/hooks/_category_.json b/docs/docs/docs/01-core/admin/04-features/hooks/_category_.json similarity index 100% rename from docs/docs/docs/01-core/admin/05-features/hooks/_category_.json rename to docs/docs/docs/01-core/admin/04-features/hooks/_category_.json diff --git a/docs/docs/docs/01-core/admin/05-features/hooks/use-admin-roles.mdx b/docs/docs/docs/01-core/admin/04-features/hooks/use-admin-roles.mdx similarity index 100% rename from docs/docs/docs/01-core/admin/05-features/hooks/use-admin-roles.mdx rename to docs/docs/docs/01-core/admin/04-features/hooks/use-admin-roles.mdx diff --git a/docs/docs/docs/01-core/admin/05-features/hooks/use-enterprise.mdx b/docs/docs/docs/01-core/admin/04-features/hooks/use-enterprise.mdx similarity index 100% rename from docs/docs/docs/01-core/admin/05-features/hooks/use-enterprise.mdx rename to docs/docs/docs/01-core/admin/04-features/hooks/use-enterprise.mdx diff --git a/docs/docs/docs/01-core/admin/05-features/nps.md b/docs/docs/docs/01-core/admin/04-features/nps.md similarity index 100% rename from docs/docs/docs/01-core/admin/05-features/nps.md rename to docs/docs/docs/01-core/admin/04-features/nps.md diff --git a/docs/docs/docs/01-core/strapi/commands/01-build.md b/docs/docs/docs/01-core/strapi/commands/01-build.md index 0edeceabec..034f5e32a6 100644 --- a/docs/docs/docs/01-core/strapi/commands/01-build.md +++ b/docs/docs/docs/01-core/strapi/commands/01-build.md @@ -32,4 +32,161 @@ Options: ## How it works -See [Admin build pipeline](/docs/core/admin/commands/build) for more information. +The build process for the admin panel is designed to be bundler agnostic, this means we can easily experiment and perhaps transition to new bundlers as they become available in the ecosystem. This is facilitated by the use of a [`BuildContext`](#buildcontext) that contains all the information needed to build the admin panel – if it's found more information is required this context can be tweaked to provide it. + +### Dependencies + +The first step of running the build command is to check if the required dependencies are installed at the root of the project. This provides better DX for: + +- miss-installed project +- monorepos +- incorrect/incompatible versions of packages for _certain_ packages like `styled-components` or `react`. + +The list of packages we explicity check for are: + +- `react` +- `react-dom` +- `styled-components` +- `react-router-dom` + +This is because there should only be one instance of these packages installed and used by the project at any one time, failure to do so can and most likely will, lead to bugs. This also means an incompatible version of these packages could cause unintended side effects e.g. if `react@19` was suddenly released but we had not tested it against the admin panel. + +We run a prompt to encourage the user to install these deps – however, this functionality has not yet been built. + +### BuildContext + +The build context is the heart of how the admin builds, as said above it's agnostic, it doesn't care if we're using webpack or vite or parcel. It's an object of data that can be used to preapre any bundler. It's shape looks like: + +```ts +interface BuildContext { + /** + * The absolute path to the app directory defined by the Strapi instance + */ + appDir: string; + /** + * If a user is deploying the project under a nested public path, we use + * this path so all asset paths will be rewritten accordingly + */ + basePath: string; + /** + * The customisations defined by the user in their app.js file + */ + customisations?: AppFile; + /** + * The current working directory + */ + cwd: string; + /** + * The absolute path to the dist directory + */ + distPath: string; + /** + * The relative path to the dist directory + */ + distDir: string; + /** + * The absolute path to the entry file + */ + entry: string; + /** + * The environment variables to be included in the JS bundle + */ + env: Record; + logger: CLIContext['logger']; + /** + * The build options + */ + options: Pick & Pick; + /** + * The plugins to be included in the JS bundle + * incl. internal plugins, third party plugins & local plugins + */ + plugins: Array<{ + path: string; + name: string; + importName: string; + }>; + /** + * The absolute path to the runtime directory + */ + runtimeDir: string; + /** + * The Strapi instance + */ + strapi: Strapi; + /** + * The browserslist target either loaded from the user's workspace or falling back to the default + */ + target: string[]; + tsconfig?: CLIContext['tsconfig']; +} +``` + +### Static Files + +The next step is to create a `runtime` folder in the root of the strapi project, a generic name `.strapi` is used and the build specifically uses a subfolder called `client`. This leaves more space for us to expand as and when we require it. We only generate two files for this – an `index.html` which is a static rendered React Component from the `@strapi/admin` package (DefaultDocument) & an `entry.js` file which calls the `renderAdmin` function & provides a mount point & plugin object. + +### Bundling + +We currently support both `webpack` & `vite` bundlers, with `vite` being the default. Because there is no global `strapi.config` file we don't have an already existing API to pass your own bundler. In the future we may decide to do this if there is a need. Each bundler supplies a build function & a develop function. We don't need a serve function because they're expected to produce the same `index.html` output defined by the static files step described above. + +## Node Usage + +```ts +import { build, BuildOptions } from '@strapi/admin/_internal'; + +const args: BuildOptions = { + // ... +}; + +await build(args); +``` + +### Options + +```ts +interface BuildOptions extends CLIContext { + /** + * The directory to build the command was ran from + */ + cwd: string; + /** + * The logger to use. + */ + logger: Logger; + /** + * Minify the output + * + * @default true + */ + minify?: boolean; + /** + * Generate sourcemaps – useful for debugging bugs in the admin panel UI. + */ + sourcemaps?: boolean; + /** + * Print stats for build + */ + stats?: boolean; + /** + * The tsconfig to use for the build. If undefined, this is not a TS project. + */ + tsconfig?: TsConfig; +} + +interface Logger { + warnings: number; + errors: number; + debug: (...args: unknown[]) => void; + info: (...args: unknown[]) => void; + warn: (...args: unknown[]) => void; + error: (...args: unknown[]) => void; + log: (...args: unknown[]) => void; + spinner: (text: string) => Pick; +} + +interface TsConfig { + config: ts.ParsedCommandLine; + path: string; +} +``` diff --git a/docs/docs/docs/01-core/strapi/commands/02-develop.md b/docs/docs/docs/01-core/strapi/commands/02-develop.md index 6dcded704a..e14ffcde6e 100644 --- a/docs/docs/docs/01-core/strapi/commands/02-develop.md +++ b/docs/docs/docs/01-core/strapi/commands/02-develop.md @@ -22,13 +22,70 @@ Start your Strapi application in development mode Options: --polling Watch for file changes in network directories (default: false) - --no-build [deprecated]: there is middleware for the server, it is no longer a separate process - --watch-admin [deprecated]: there is now middleware for watching, it is no longer a separate process - --browser [deprecated]: use open instead + --watch-admin Watch the admin panel for hot changes --open Open the admin in your browser (default: true) -h, --help Display help for command ``` ## How it works -See [Admin development pipeline](/docs/core/admin/commands/develop) for more information. +The develop command sets itself up much like the [build](build) command. Once we've injected our middlewares, we load the strapi instance and then generate the types based off the user's instance as well as potentially compiling any TS server code if we're in a TS project. The final step is to watch the project directory so we can restart the strapi instance in real-time as a user is developing their project & being the actual strapi instance. + +## Node Usage + +```ts +import { develop, DevelopOptions } from '@strapi/admin/_internal'; + +const args: DevelopOptions = { + // ... +}; + +await develop(args); +``` + +### Options + +```ts +interface DevelopOptions extends CLIContext { + /** + * The directory to build the command was ran from + */ + cwd: string; + /** + * The logger to use. + */ + logger: Logger; + /** + * Whether or not to open the browser after the build is complete. + */ + open?: boolean; + /** + * Watch for file changes in network directories + */ + polling?: boolean; + /** + * The tsconfig to use for the build. If undefined, this is not a TS project. + */ + tsconfig?: TsConfig; + /** + * Watch the admin for changes + */ + watchAdmin?: boolean; +} + +interface Logger { + warnings: number; + errors: number; + debug: (...args: unknown[]) => void; + info: (...args: unknown[]) => void; + warn: (...args: unknown[]) => void; + error: (...args: unknown[]) => void; + log: (...args: unknown[]) => void; + spinner: (text: string) => Pick; +} + +interface TsConfig { + config: ts.ParsedCommandLine; + path: string; +} +``` diff --git a/packages/core/admin/tsconfig.json b/packages/core/admin/tsconfig.json index bbcacec867..d692225263 100644 --- a/packages/core/admin/tsconfig.json +++ b/packages/core/admin/tsconfig.json @@ -3,10 +3,8 @@ "compilerOptions": { "module": "ESNext", "moduleResolution": "Bundler", - "noEmit": true - }, - "include": ["_internal", "packup.config.ts"], - "compilerOptions": { + "noEmit": true, "outDir": "./dist/cli" - } + }, + "include": ["_internal", "packup.config.ts"] } diff --git a/packages/core/content-releases/admin/tsconfig.build.json b/packages/core/content-releases/admin/tsconfig.build.json index 51afa7aa63..b3900e16c8 100644 --- a/packages/core/content-releases/admin/tsconfig.build.json +++ b/packages/core/content-releases/admin/tsconfig.build.json @@ -1,9 +1,10 @@ { - "extends": "./admin/tsconfig.json", - "include": ["./admin/src", "./admin/custom.d.ts", "./shared"], + "extends": "./tsconfig.json", + "include": ["./src", "./custom.d.ts", "../shared"], "exclude": ["tests", "**/*.test.*"], "compilerOptions": { - "rootDir": ".", + "rootDir": "../", + "baseUrl": ".", "outDir": "./dist" } } diff --git a/packages/core/content-releases/package.json b/packages/core/content-releases/package.json index 8e9ab8ba8d..0426e2076c 100644 --- a/packages/core/content-releases/package.json +++ b/packages/core/content-releases/package.json @@ -21,14 +21,14 @@ ], "exports": { "./strapi-admin": { - "types": "./dist/admin/index.d.ts", + "types": "./dist/admin/src/index.d.ts", "source": "./admin/src/index.ts", "import": "./dist/admin/index.mjs", "require": "./dist/admin/index.js", "default": "./dist/admin/index.js" }, "./strapi-server": { - "types": "./dist/server/index.d.ts", + "types": "./dist/server/src/index.d.ts", "source": "./server/src/index.ts", "import": "./dist/server/index.mjs", "require": "./dist/server/index.js", @@ -37,7 +37,7 @@ "./package.json": "./package.json" }, "files": [ - "./dist", + "dist/", "strapi-server.js" ], "scripts": { @@ -71,7 +71,6 @@ "@strapi/admin": "4.17.1", "@strapi/admin-test-utils": "4.17.1", "@strapi/pack-up": "workspace:*", - "@strapi/strapi": "4.17.1", "@testing-library/react": "14.0.0", "@testing-library/user-event": "14.4.3", "@types/koa": "2.13.4", @@ -86,7 +85,6 @@ }, "peerDependencies": { "@strapi/admin": "^4.19.0", - "@strapi/strapi": "^4.15.1", "react": "^17.0.0 || ^18.0.0", "react-dom": "^17.0.0 || ^18.0.0", "react-router-dom": "^6.0.0", @@ -96,11 +94,6 @@ "node": ">=16.0.0 <=20.x.x", "npm": ">=6.0.0" }, - "nx": { - "implicitDependencies": [ - "!@strapi/strapi" - ] - }, "strapi": { "name": "content-releases", "description": "Organize and release content", diff --git a/packages/core/content-releases/server/src/controllers/release-action.ts b/packages/core/content-releases/server/src/controllers/release-action.ts index f79af4f80c..f51ac2b2e9 100644 --- a/packages/core/content-releases/server/src/controllers/release-action.ts +++ b/packages/core/content-releases/server/src/controllers/release-action.ts @@ -17,7 +17,7 @@ import { RELEASE_ACTION_MODEL_UID } from '../constants'; const releaseActionController = { async create(ctx: Koa.Context) { const releaseId: CreateReleaseAction.Request['params']['releaseId'] = ctx.params.releaseId; - const releaseActionArgs: CreateReleaseAction.Request['body'] = ctx.request.body; + const releaseActionArgs = ctx.request.body as CreateReleaseAction.Request['body']; await validateReleaseAction(releaseActionArgs); @@ -48,7 +48,7 @@ const releaseActionController = { * We need to sanitize the entry output according to that content type. * So, we group the sanitized output function by content type. */ - const contentTypeOutputSanitizers = results.reduce((acc, action) => { + const contentTypeOutputSanitizers = results.reduce((acc: Record, action: any) => { if (acc[action.contentType]) { return acc; } @@ -68,7 +68,7 @@ const releaseActionController = { * sanitizeOutput doesn't work if you use it directly on the Release Action model, it doesn't sanitize the entries * So, we need to sanitize manually each entry inside a Release Action */ - const sanitizedResults = await mapAsync(results, async (action) => ({ + const sanitizedResults = await mapAsync(results, async (action: any) => ({ ...action, entry: await contentTypeOutputSanitizers[action.contentType](action.entry), })); @@ -91,7 +91,7 @@ const releaseActionController = { async update(ctx: Koa.Context) { const actionId: UpdateReleaseAction.Request['params']['actionId'] = ctx.params.actionId; const releaseId: UpdateReleaseAction.Request['params']['releaseId'] = ctx.params.releaseId; - const releaseActionUpdateArgs: UpdateReleaseAction.Request['body'] = ctx.request.body; + const releaseActionUpdateArgs = ctx.request.body as UpdateReleaseAction.Request['body']; await validateReleaseActionUpdateSchema(releaseActionUpdateArgs); diff --git a/packages/core/content-releases/server/src/controllers/release.ts b/packages/core/content-releases/server/src/controllers/release.ts index 77e630faa0..5209e11a0a 100644 --- a/packages/core/content-releases/server/src/controllers/release.ts +++ b/packages/core/content-releases/server/src/controllers/release.ts @@ -103,7 +103,7 @@ const releaseController = { async create(ctx: Koa.Context) { const user: UserInfo = ctx.state.user; - const releaseArgs: CreateRelease.Request['body'] = ctx.request.body; + const releaseArgs = ctx.request.body as CreateRelease.Request['body']; await validateRelease(releaseArgs); @@ -122,7 +122,7 @@ const releaseController = { async update(ctx: Koa.Context) { const user: UserInfo = ctx.state.user; - const releaseArgs: UpdateRelease.Request['body'] = ctx.request.body; + const releaseArgs = ctx.request.body as UpdateRelease.Request['body']; const id: UpdateRelease.Request['params']['id'] = ctx.params.id; await validateRelease(releaseArgs); diff --git a/packages/core/content-releases/server/tsconfig.build.json b/packages/core/content-releases/server/tsconfig.build.json index af350c397a..f42da676d0 100644 --- a/packages/core/content-releases/server/tsconfig.build.json +++ b/packages/core/content-releases/server/tsconfig.build.json @@ -1,9 +1,10 @@ { - "extends": "./server/tsconfig.json", - "include": ["./server/src", "./server/custom.d.ts", "./shared"], - "exclude": ["./server/src/**/*.test.ts"], + "extends": "./tsconfig.json", + "include": ["./src", "./custom.d.ts", "../shared"], + "exclude": ["**/*.test.ts"], "compilerOptions": { - "rootDir": ".", + "rootDir": "../", + "baseUrl": ".", "outDir": "./dist" } } diff --git a/packages/core/content-releases/server/tsconfig.json b/packages/core/content-releases/server/tsconfig.json index 1a6f18c5a7..3f23ff4503 100644 --- a/packages/core/content-releases/server/tsconfig.json +++ b/packages/core/content-releases/server/tsconfig.json @@ -1,8 +1,10 @@ { "extends": "tsconfig/base.json", - "include": ["src", "custom.d.ts"], + "include": ["src", "custom.d.ts", "../shared"], "exclude": ["node_modules"], "compilerOptions": { + "rootDir": "../", + "baseUrl": ".", "esModuleInterop": true } } diff --git a/packages/core/strapi/src/admin.ts b/packages/core/strapi/src/admin.ts index 04d12fbaf6..ea012da607 100644 --- a/packages/core/strapi/src/admin.ts +++ b/packages/core/strapi/src/admin.ts @@ -3,7 +3,6 @@ import contentTypeBuilder from '@strapi/plugin-content-type-builder/strapi-admin import email from '@strapi/plugin-email/strapi-admin'; // @ts-expect-error – No types, yet. import upload from '@strapi/plugin-upload/strapi-admin'; -// @ts-expect-error – No types, yet. import contentReleases from '@strapi/content-releases/strapi-admin'; const render = (mountNode: HTMLElement | null, { plugins, ...restArgs }: RenderAdminArgs) => { @@ -14,6 +13,7 @@ const render = (mountNode: HTMLElement | null, { plugins, ...restArgs }: RenderA // @ts-expect-error – TODO: fix this email, upload, + // @ts-expect-error – TODO: fix this, the "types" folder has it wrong. contentReleases, ...plugins, }, diff --git a/packages/core/strapi/src/cli/commands/build.ts b/packages/core/strapi/src/cli/commands/build.ts index f14c5dc00d..c224eeb6eb 100644 --- a/packages/core/strapi/src/cli/commands/build.ts +++ b/packages/core/strapi/src/cli/commands/build.ts @@ -1,50 +1,18 @@ -import boxen from 'boxen'; import { createCommand } from 'commander'; -import chalk from 'chalk'; import type { StrapiCommand } from '../types'; import { build as nodeBuild, BuildOptions } from '../../node/build'; import { handleUnexpectedError } from '../../node/core/errors'; -interface BuildCLIOptions extends BuildOptions { - /** - * @deprecated use `minify` instead - */ - optimization?: boolean; -} +interface BuildCLIOptions extends BuildOptions {} const action = async (options: BuildCLIOptions) => { try { - if (typeof process.env.STRAPI_ENFORCE_SOURCEMAPS !== 'undefined') { + if (options.bundler === 'webpack') { options.logger.warn( - "[@strapi/strapi]: STRAPI_ENFORCE_SOURCEMAPS is now deprecated. You can enable sourcemaps by passing '--sourcemaps' to the build command." + '[@strapi/strapi]: Using webpack as a bundler is deprecated. You should migrate to vite.' ); } - if (typeof options.optimization !== 'undefined' && options.optimization !== true) { - options.logger.warn( - "[@strapi/strapi]: The optimization argument is now deprecated. Use '--minify' instead." - ); - } - - if (options.bundler !== 'webpack') { - options.logger.log( - boxen( - `Using ${chalk.bold( - chalk.underline(options.bundler) - )} as a bundler is considered experimental, use at your own risk. If you do experience bugs, open a new issue on Github – https://github.com/strapi/strapi/issues/new?template=BUG_REPORT.md`, - { - title: 'Warning', - padding: 1, - margin: 1, - align: 'center', - borderColor: 'yellow', - borderStyle: 'bold', - } - ) - ); - } - - const envSourceMaps = process.env.STRAPI_ENFORCE_SOURCEMAPS === 'true'; /** * ENFORCE NODE_ENV to production when building @@ -57,11 +25,7 @@ const action = async (options: BuildCLIOptions) => { ); } - await nodeBuild({ - ...options, - minify: options.optimization ?? options.minify, - sourcemaps: options.sourcemaps || envSourceMaps, - }); + await nodeBuild(options); } catch (err) { handleUnexpectedError(err); } @@ -72,11 +36,10 @@ const action = async (options: BuildCLIOptions) => { */ const command: StrapiCommand = ({ ctx }) => { return createCommand('build') - .option('--bundler [bundler]', 'Bundler to use (webpack or vite)', 'webpack') + .option('--bundler [bundler]', 'Bundler to use (webpack or vite)', 'vite') .option('-d, --debug', 'Enable debugging mode with verbose logs', false) .option('--ignore-prompts', 'Ignore all prompts', false) .option('--minify', 'Minify the output', true) - .option('--no-optimization', '[deprecated]: use minify instead') .option('--silent', "Don't log anything", false) .option('--sourcemap', 'Produce sourcemaps', false) .option('--stats', 'Print build statistics to the console', false) diff --git a/packages/core/strapi/src/cli/commands/develop.ts b/packages/core/strapi/src/cli/commands/develop.ts index 86d0ab932e..c8f003c771 100644 --- a/packages/core/strapi/src/cli/commands/develop.ts +++ b/packages/core/strapi/src/cli/commands/develop.ts @@ -1,50 +1,22 @@ import { createCommand } from 'commander'; -import boxen from 'boxen'; -import chalk from 'chalk'; import cluster from 'node:cluster'; import type { StrapiCommand } from '../types'; import { develop as nodeDevelop, DevelopOptions } from '../../node/develop'; import { handleUnexpectedError } from '../../node/core/errors'; -interface DevelopCLIOptions extends DevelopOptions { - /** - * @deprecated - */ - browser?: boolean; -} +interface DevelopCLIOptions extends DevelopOptions {} const action = async (options: DevelopCLIOptions) => { try { if (cluster.isPrimary) { - if (typeof options.browser !== 'undefined') { + if (options.bundler === 'webpack') { options.logger.warn( - "[@strapi/strapi]: The browser argument, this is now deprecated. Use '--open' instead." - ); - } - - if (options.bundler !== 'webpack') { - options.logger.log( - boxen( - `Using ${chalk.bold( - chalk.underline(options.bundler) - )} as a bundler is considered experimental, use at your own risk. If you do experience bugs, open a new issue on Github – https://github.com/strapi/strapi/issues/new?template=BUG_REPORT.md`, - { - title: 'Warning', - padding: 1, - margin: 1, - align: 'center', - borderColor: 'yellow', - borderStyle: 'bold', - } - ) + '[@strapi/strapi]: Using webpack as a bundler is deprecated. You should migrate to vite.' ); } } - await nodeDevelop({ - ...options, - open: options.browser ?? options.open, - }); + await nodeDevelop(options); } catch (err) { handleUnexpectedError(err); } @@ -56,21 +28,12 @@ const action = async (options: DevelopCLIOptions) => { const command: StrapiCommand = ({ ctx }) => { return createCommand('develop') .alias('dev') - .option('--bundler [bundler]', 'Bundler to use (webpack or vite)', 'webpack') + .option('--bundler [bundler]', 'Bundler to use (webpack or vite)', 'vite') .option('-d, --debug', 'Enable debugging mode with verbose logs', false) .option('--silent', "Don't log anything", false) .option('--ignore-prompts', 'Ignore all prompts', false) .option('--polling', 'Watch for file changes in network directories', false) .option('--watch-admin', 'Watch the admin panel for hot changes', false) - .option( - '--no-build', - '[deprecated]: there is middleware for the server, it is no longer a separate process' - ) - .option( - '--watch-admin', - '[deprecated]: there is now middleware for watching, it is no longer a separate process' - ) - .option('--browser ', '[deprecated]: use open instead') .option('--open', 'Open the admin in your browser', true) .description('Start your Strapi application in development mode') .action(async (options: DevelopCLIOptions) => { diff --git a/yarn.lock b/yarn.lock index d08417240e..43dac8f49c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -9330,7 +9330,6 @@ __metadata: "@strapi/helper-plugin": "npm:4.17.1" "@strapi/icons": "npm:1.14.1" "@strapi/pack-up": "workspace:*" - "@strapi/strapi": "npm:4.17.1" "@strapi/types": "workspace:*" "@strapi/utils": "npm:4.17.1" "@testing-library/react": "npm:14.0.0" @@ -9352,7 +9351,6 @@ __metadata: yup: "npm:0.32.9" peerDependencies: "@strapi/admin": ^4.19.0 - "@strapi/strapi": ^4.15.1 react: ^17.0.0 || ^18.0.0 react-dom: ^17.0.0 || ^18.0.0 react-router-dom: ^6.0.0