mirror of
https://github.com/strapi/strapi.git
synced 2025-11-02 19:04:38 +00:00
chore: make vite the default bundler for the admin (#19283)
This commit is contained in:
parent
778e8fb175
commit
f379a8cd7a
@ -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({
|
||||
// ...
|
||||
});
|
||||
```
|
||||
@ -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<string, string>;
|
||||
logger: CLIContext['logger'];
|
||||
/**
|
||||
* The build options
|
||||
*/
|
||||
options: Pick<BuildOptions, 'minify' | 'sourcemaps' | 'stats'> & Pick<DevelopOptions, 'open'>;
|
||||
/**
|
||||
* 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<ora.Ora, 'succeed' | 'fail' | 'start' | 'text'>;
|
||||
}
|
||||
|
||||
interface TsConfig {
|
||||
config: ts.ParsedCommandLine;
|
||||
path: string;
|
||||
}
|
||||
```
|
||||
@ -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 <name> [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<ora.Ora, 'succeed' | 'fail' | 'start' | 'text'>;
|
||||
}
|
||||
|
||||
interface TsConfig {
|
||||
config: ts.ParsedCommandLine;
|
||||
path: string;
|
||||
}
|
||||
```
|
||||
@ -1,5 +0,0 @@
|
||||
{
|
||||
"label": "Commands",
|
||||
"collapsible": true,
|
||||
"collapsed": true
|
||||
}
|
||||
@ -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<string, string>;
|
||||
logger: CLIContext['logger'];
|
||||
/**
|
||||
* The build options
|
||||
*/
|
||||
options: Pick<BuildOptions, 'minify' | 'sourcemaps' | 'stats'> & Pick<DevelopOptions, 'open'>;
|
||||
/**
|
||||
* 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<ora.Ora, 'succeed' | 'fail' | 'start' | 'text'>;
|
||||
}
|
||||
|
||||
interface TsConfig {
|
||||
config: ts.ParsedCommandLine;
|
||||
path: string;
|
||||
}
|
||||
```
|
||||
|
||||
@ -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 <name> [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<ora.Ora, 'succeed' | 'fail' | 'start' | 'text'>;
|
||||
}
|
||||
|
||||
interface TsConfig {
|
||||
config: ts.ParsedCommandLine;
|
||||
path: string;
|
||||
}
|
||||
```
|
||||
|
||||
@ -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"]
|
||||
}
|
||||
|
||||
@ -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"
|
||||
}
|
||||
}
|
||||
|
||||
@ -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",
|
||||
|
||||
@ -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<string, any>, 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);
|
||||
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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"
|
||||
}
|
||||
}
|
||||
|
||||
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
@ -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,
|
||||
},
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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 <name>', '[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) => {
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user