@nocobase/test 2.1.0-alpha.3 → 2.1.0-alpha.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -661
- package/README.md +79 -10
- package/lib/client/index.js +4 -2
- package/lib/client/renderAppOptions.js +1 -1
- package/lib/client/renderSettings.js +29 -4
- package/lib/scripts/test-db-creator.js +30 -2
- package/lib/server/mock-isolated-cluster.js +2 -13
- package/lib/server/mock-server.js +1 -3
- package/package.json +5 -4
- package/perf/scenarios/import/init.ts +2 -1
- package/setup/server.ts +1 -1
- package/vitest.mjs +25 -4
package/README.md
CHANGED
|
@@ -1,17 +1,24 @@
|
|
|
1
1
|
# NocoBase
|
|
2
2
|
|
|
3
3
|
<video width="100%" controls>
|
|
4
|
-
|
|
4
|
+
<source src="https://github.com/user-attachments/assets/4d11a87b-00e2-48f3-9bf7-389d21072d13" type="video/mp4">
|
|
5
5
|
</video>
|
|
6
6
|
|
|
7
|
+
<p align="center">
|
|
8
|
+
<a href="https://trendshift.io/repositories/4112" target="_blank"><img src="https://trendshift.io/api/badge/repositories/4112" alt="nocobase%2Fnocobase | Trendshift" style="width: 250px; height: 55px;" width="250" height="55"/></a>
|
|
9
|
+
<a href="https://www.producthunt.com/posts/nocobase?embed=true&utm_source=badge-top-post-topic-badge&utm_medium=badge&utm_souce=badge-nocobase" target="_blank"><img src="https://api.producthunt.com/widgets/embed-image/v1/top-post-topic-badge.svg?post_id=456520&theme=light&period=weekly&topic_id=267" alt="NocoBase - Scalability-first, open-source no-code platform | Product Hunt" style="width: 250px; height: 54px;" width="250" height="54" /></a>
|
|
10
|
+
</p>
|
|
7
11
|
|
|
8
12
|
## What is NocoBase
|
|
9
13
|
|
|
10
|
-
NocoBase is
|
|
11
|
-
|
|
14
|
+
NocoBase is the most extensible AI-powered no-code platform.
|
|
15
|
+
Total control. Infinite extensibility. AI collaboration.
|
|
16
|
+
Enable your team to adapt quickly and cut costs dramatically.
|
|
17
|
+
No years of development. No millions wasted.
|
|
18
|
+
Deploy NocoBase in minutes — and take control of everything.
|
|
12
19
|
|
|
13
20
|
Homepage:
|
|
14
|
-
https://www.nocobase.com/
|
|
21
|
+
https://www.nocobase.com/
|
|
15
22
|
|
|
16
23
|
Online Demo:
|
|
17
24
|
https://demo.nocobase.com/new
|
|
@@ -19,12 +26,74 @@ https://demo.nocobase.com/new
|
|
|
19
26
|
Documents:
|
|
20
27
|
https://docs.nocobase.com/
|
|
21
28
|
|
|
22
|
-
|
|
23
|
-
https://
|
|
29
|
+
Forum:
|
|
30
|
+
https://forum.nocobase.com/
|
|
24
31
|
|
|
25
|
-
|
|
26
|
-
https://www.nocobase.com/en/
|
|
32
|
+
Use Cases:
|
|
33
|
+
https://www.nocobase.com/en/blog/tags/customer-stories
|
|
27
34
|
|
|
35
|
+
## Release Notes
|
|
28
36
|
|
|
29
|
-
|
|
30
|
-
|
|
37
|
+
Our [blog](https://www.nocobase.com/en/blog/timeline) is regularly updated with release notes and provides a weekly summary.
|
|
38
|
+
|
|
39
|
+
## Distinctive features
|
|
40
|
+
|
|
41
|
+
### 1. Data model-driven, not form/table–driven
|
|
42
|
+
|
|
43
|
+
Instead of being constrained by forms or tables, NocoBase adopts a data model–driven approach, separating data structure from user interface to unlock unlimited possibilities.
|
|
44
|
+
|
|
45
|
+
- UI and data structure are fully decoupled
|
|
46
|
+
- Multiple blocks and actions can be created for the same table or record in any quantity or form
|
|
47
|
+
- Supports the main database, external databases, and third-party APIs as data sources
|
|
48
|
+
|
|
49
|
+

|
|
50
|
+
|
|
51
|
+
### 2. AI employees, integrated into your business systems
|
|
52
|
+
Unlike standalone AI demos, NocoBase allows you to embed AI capabilities seamlessly into your interfaces, workflows, and data context, making AI truly useful in real business scenarios.
|
|
53
|
+
|
|
54
|
+
- Define AI employees for roles such as translator, analyst, researcher, or assistant
|
|
55
|
+
- Seamless AI–human collaboration in interfaces and workflows
|
|
56
|
+
- Ensure AI usage is secure, transparent, and customizable for your business needs
|
|
57
|
+
|
|
58
|
+

|
|
59
|
+
|
|
60
|
+
### 3. What you see is what you get, incredibly easy to use
|
|
61
|
+
|
|
62
|
+
While enabling the development of complex business systems, NocoBase keeps the experience simple and intuitive.
|
|
63
|
+
|
|
64
|
+
- One-click switch between usage mode and configuration mode
|
|
65
|
+
- Pages serve as a canvas to arrange blocks and actions, similar to Notion
|
|
66
|
+
- Configuration mode is designed for ordinary users, not just programmers
|
|
67
|
+
|
|
68
|
+

|
|
69
|
+
|
|
70
|
+
### 4. Everything is a plugin, designed for extension
|
|
71
|
+
Adding more no-code features will never cover every business case. NocoBase is built for extension through its plugin-based microkernel architecture.
|
|
72
|
+
|
|
73
|
+
- All functionalities are plugins, similar to WordPress
|
|
74
|
+
- Plugins are ready to use upon installation
|
|
75
|
+
- Pages, blocks, actions, APIs, and data sources can all be extended through custom plugins
|
|
76
|
+
|
|
77
|
+

|
|
78
|
+
|
|
79
|
+
## Installation
|
|
80
|
+
|
|
81
|
+
NocoBase supports three installation methods:
|
|
82
|
+
|
|
83
|
+
- <a target="_blank" href="https://docs.nocobase.com/welcome/getting-started/installation/docker-compose">Installing With Docker (👍Recommended)</a>
|
|
84
|
+
|
|
85
|
+
Suitable for no-code scenarios, no code to write. When upgrading, just download the latest image and reboot.
|
|
86
|
+
|
|
87
|
+
- <a target="_blank" href="https://docs.nocobase.com/welcome/getting-started/installation/create-nocobase-app">Installing from create-nocobase-app CLI</a>
|
|
88
|
+
|
|
89
|
+
The business code of the project is completely independent and supports low-code development.
|
|
90
|
+
|
|
91
|
+
- <a target="_blank" href="https://docs.nocobase.com/welcome/getting-started/installation/git-clone">Installing from Git source code</a>
|
|
92
|
+
|
|
93
|
+
If you want to experience the latest unreleased version, or want to participate in the contribution, you need to make changes and debug on the source code, it is recommended to choose this installation method, which requires a high level of development skills, and if the code has been updated, you can git pull the latest code.
|
|
94
|
+
|
|
95
|
+
## How NocoBase works
|
|
96
|
+
|
|
97
|
+
<video width="100%" controls>
|
|
98
|
+
<source src="https://github.com/user-attachments/assets/8d183b44-9bb5-4792-b08f-bc08fe8dfaaf" type="video/mp4">
|
|
99
|
+
</video>
|
package/lib/client/index.js
CHANGED
|
@@ -46,7 +46,9 @@ __export(client_exports, {
|
|
|
46
46
|
waitForApp: () => waitForApp
|
|
47
47
|
});
|
|
48
48
|
module.exports = __toCommonJS(client_exports);
|
|
49
|
+
var import_react = __toESM(require("react"));
|
|
49
50
|
var import_react2 = require("@testing-library/react");
|
|
51
|
+
var import_flow_engine = require("@nocobase/flow-engine");
|
|
50
52
|
var import_web = require("../web");
|
|
51
53
|
__reExport(client_exports, require("./utils"), module.exports);
|
|
52
54
|
var import_react_hooks = require("@testing-library/react-hooks");
|
|
@@ -59,9 +61,9 @@ __reExport(client_exports, require("./renderSingleSettings"), module.exports);
|
|
|
59
61
|
__reExport(client_exports, require("./settingsChecker"), module.exports);
|
|
60
62
|
__reExport(client_exports, require("./commonSettingsChecker"), module.exports);
|
|
61
63
|
function customRender(ui, options = {}) {
|
|
64
|
+
const flowEngine = new import_flow_engine.FlowEngine();
|
|
62
65
|
return (0, import_react2.render)(ui, {
|
|
63
|
-
|
|
64
|
-
wrapper: /* @__PURE__ */ __name(({ children }) => children, "wrapper"),
|
|
66
|
+
wrapper: /* @__PURE__ */ __name(({ children }) => /* @__PURE__ */ import_react.default.createElement(import_flow_engine.FlowEngineProvider, { engine: flowEngine }, children), "wrapper"),
|
|
65
67
|
...options
|
|
66
68
|
});
|
|
67
69
|
}
|
|
@@ -42,8 +42,8 @@ __export(renderAppOptions_exports, {
|
|
|
42
42
|
});
|
|
43
43
|
module.exports = __toCommonJS(renderAppOptions_exports);
|
|
44
44
|
var import_react = __toESM(require("react"));
|
|
45
|
-
var import__ = require(".");
|
|
46
45
|
var import_web = require("../web");
|
|
46
|
+
var import__ = require(".");
|
|
47
47
|
var import_utils = require("./utils");
|
|
48
48
|
const renderAppOptions = /* @__PURE__ */ __name(async (options) => {
|
|
49
49
|
const App = (0, import_web.getAppComponent)(options);
|
|
@@ -35,15 +35,40 @@ module.exports = __toCommonJS(renderSettings_exports);
|
|
|
35
35
|
var import_react = require("@testing-library/react");
|
|
36
36
|
var import_renderAppOptions = require("./renderAppOptions");
|
|
37
37
|
var import_utils = require("./utils");
|
|
38
|
+
const querySettingsButton = /* @__PURE__ */ __name((container) => {
|
|
39
|
+
return container.querySelector('[aria-label^="designer-schema-settings-"]');
|
|
40
|
+
}, "querySettingsButton");
|
|
41
|
+
const querySettingsTrigger = /* @__PURE__ */ __name((container) => {
|
|
42
|
+
const button = querySettingsButton(container);
|
|
43
|
+
if (!button) {
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
return button.closest(".ant-dropdown-trigger") || button;
|
|
47
|
+
}, "querySettingsTrigger");
|
|
48
|
+
const revealSchemaToolbar = /* @__PURE__ */ __name((container) => {
|
|
49
|
+
const blockItem = container.querySelector('[aria-label^="block-item-"]');
|
|
50
|
+
if (!blockItem) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
import_react.fireEvent.mouseEnter(blockItem);
|
|
54
|
+
import_react.fireEvent.mouseOver(blockItem);
|
|
55
|
+
}, "revealSchemaToolbar");
|
|
38
56
|
async function showSettingsMenu(container = document) {
|
|
39
57
|
await (0, import_react.waitFor)(() => {
|
|
40
|
-
|
|
58
|
+
if (!querySettingsButton(container)) {
|
|
59
|
+
revealSchemaToolbar(container);
|
|
60
|
+
}
|
|
61
|
+
return (0, import_utils.expectNoTsError)(querySettingsButton(container)).toBeInTheDocument();
|
|
41
62
|
});
|
|
42
63
|
const button = await (0, import_react.waitFor)(() => {
|
|
43
|
-
|
|
64
|
+
if (!querySettingsButton(container)) {
|
|
65
|
+
revealSchemaToolbar(container);
|
|
66
|
+
}
|
|
67
|
+
return querySettingsButton(container);
|
|
44
68
|
});
|
|
45
|
-
|
|
46
|
-
import_react.fireEvent.
|
|
69
|
+
const trigger = querySettingsTrigger(container) || button;
|
|
70
|
+
import_react.fireEvent.mouseEnter(trigger);
|
|
71
|
+
import_react.fireEvent.mouseOver(trigger);
|
|
47
72
|
await (0, import_react.waitFor)(() => {
|
|
48
73
|
return (0, import_utils.expectNoTsError)(import_react.screen.queryByTestId("schema-settings-menu")).toBeInTheDocument();
|
|
49
74
|
});
|
|
@@ -80,6 +80,18 @@ const _BaseClient = class _BaseClient {
|
|
|
80
80
|
};
|
|
81
81
|
__name(_BaseClient, "BaseClient");
|
|
82
82
|
let BaseClient = _BaseClient;
|
|
83
|
+
function escapeMysqlIdentifier(name) {
|
|
84
|
+
return `\`${String(name).replace(/`/g, "``")}\``;
|
|
85
|
+
}
|
|
86
|
+
__name(escapeMysqlIdentifier, "escapeMysqlIdentifier");
|
|
87
|
+
function escapeMysqlString(value) {
|
|
88
|
+
return `'${String(value).replace(/\\/g, "\\\\").replace(/'/g, "\\'")}'`;
|
|
89
|
+
}
|
|
90
|
+
__name(escapeMysqlString, "escapeMysqlString");
|
|
91
|
+
function mysqlAppUser() {
|
|
92
|
+
return String(process.env["DB_APP_USER"] || process.env["DB_USER"] || "").trim();
|
|
93
|
+
}
|
|
94
|
+
__name(mysqlAppUser, "mysqlAppUser");
|
|
83
95
|
const _PostgresClient = class _PostgresClient extends BaseClient {
|
|
84
96
|
async _removeDB(name) {
|
|
85
97
|
await this._client.query(`DROP DATABASE IF EXISTS ${name}`);
|
|
@@ -107,7 +119,15 @@ const _MySQLClient = class _MySQLClient extends BaseClient {
|
|
|
107
119
|
await this._client.query(`DROP DATABASE IF EXISTS ${name}`);
|
|
108
120
|
}
|
|
109
121
|
async _createDB(name) {
|
|
110
|
-
|
|
122
|
+
const database = escapeMysqlIdentifier(name);
|
|
123
|
+
const appUser = mysqlAppUser();
|
|
124
|
+
if (!appUser) {
|
|
125
|
+
throw new Error("DB_APP_USER or DB_USER is required for MySQL test database grants.");
|
|
126
|
+
}
|
|
127
|
+
const user = escapeMysqlString(appUser);
|
|
128
|
+
await this._client.query(`CREATE DATABASE IF NOT EXISTS ${database}`);
|
|
129
|
+
await this._client.query(`GRANT ALL PRIVILEGES ON ${database}.* TO ${user}@'%'`);
|
|
130
|
+
await this._client.query("FLUSH PRIVILEGES");
|
|
111
131
|
}
|
|
112
132
|
async _createConnection() {
|
|
113
133
|
return import_promise.default.createConnection({
|
|
@@ -126,7 +146,15 @@ const _MariaDBClient = class _MariaDBClient extends BaseClient {
|
|
|
126
146
|
await this._client.query(`DROP DATABASE IF EXISTS ${name}`);
|
|
127
147
|
}
|
|
128
148
|
async _createDB(name) {
|
|
129
|
-
|
|
149
|
+
const database = escapeMysqlIdentifier(name);
|
|
150
|
+
const appUser = mysqlAppUser();
|
|
151
|
+
if (!appUser) {
|
|
152
|
+
throw new Error("DB_APP_USER or DB_USER is required for MariaDB test database grants.");
|
|
153
|
+
}
|
|
154
|
+
const user = escapeMysqlString(appUser);
|
|
155
|
+
await this._client.query(`CREATE DATABASE IF NOT EXISTS ${database}`);
|
|
156
|
+
await this._client.query(`GRANT ALL PRIVILEGES ON ${database}.* TO ${user}@'%'`);
|
|
157
|
+
await this._client.query("FLUSH PRIVILEGES");
|
|
130
158
|
}
|
|
131
159
|
async _createConnection() {
|
|
132
160
|
return await import_mariadb.default.createConnection({
|
|
@@ -7,11 +7,9 @@
|
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
var __create = Object.create;
|
|
11
10
|
var __defProp = Object.defineProperty;
|
|
12
11
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
13
12
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
14
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
15
13
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
16
14
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
17
15
|
var __export = (target, all) => {
|
|
@@ -26,21 +24,12 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
26
24
|
}
|
|
27
25
|
return to;
|
|
28
26
|
};
|
|
29
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
30
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
31
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
32
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
33
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
34
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
35
|
-
mod
|
|
36
|
-
));
|
|
37
27
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
38
28
|
var mock_isolated_cluster_exports = {};
|
|
39
29
|
__export(mock_isolated_cluster_exports, {
|
|
40
30
|
MockIsolatedCluster: () => MockIsolatedCluster
|
|
41
31
|
});
|
|
42
32
|
module.exports = __toCommonJS(mock_isolated_cluster_exports);
|
|
43
|
-
var import_node_path = __toESM(require("node:path"));
|
|
44
33
|
var import_node_child_process = require("node:child_process");
|
|
45
34
|
var import_portfinder = require("portfinder");
|
|
46
35
|
var import_utils = require("@nocobase/utils");
|
|
@@ -69,8 +58,8 @@ const _MockIsolatedCluster = class _MockIsolatedCluster {
|
|
|
69
58
|
...this.options.env,
|
|
70
59
|
APP_PORT: `${port}`,
|
|
71
60
|
APPEND_PRESET_BUILT_IN_PLUGINS: (this.options.plugins ?? []).join(","),
|
|
72
|
-
SOCKET_PATH: `
|
|
73
|
-
PM2_HOME:
|
|
61
|
+
SOCKET_PATH: (0, import_utils.storagePathJoin)("tests", `gateway-cluster-${(0, import_utils.uid)()}.sock`),
|
|
62
|
+
PM2_HOME: (0, import_utils.storagePathJoin)("tests", `.pm2-${(0, import_utils.uid)()}`)
|
|
74
63
|
}
|
|
75
64
|
});
|
|
76
65
|
await new Promise((resolve, reject) => {
|
|
@@ -53,8 +53,6 @@ var import_qs = __toESM(require("qs"));
|
|
|
53
53
|
var import_supertest = __toESM(require("supertest"));
|
|
54
54
|
var import_memory_pub_sub_adapter = require("./memory-pub-sub-adapter");
|
|
55
55
|
var import_mock_data_source = require("./mock-data-source");
|
|
56
|
-
var import_path = __toESM(require("path"));
|
|
57
|
-
var import_node_process = __toESM(require("node:process"));
|
|
58
56
|
var import_fs = require("fs");
|
|
59
57
|
const _MockServer = class _MockServer extends import_server.Application {
|
|
60
58
|
registerMockDataSource() {
|
|
@@ -264,7 +262,7 @@ async function createMockCluster({
|
|
|
264
262
|
}
|
|
265
263
|
__name(createMockCluster, "createMockCluster");
|
|
266
264
|
async function createMockServer(options = {}) {
|
|
267
|
-
const cachePath =
|
|
265
|
+
const cachePath = (0, import_utils.storagePathJoin)("cache");
|
|
268
266
|
try {
|
|
269
267
|
await import_fs.promises.rm(cachePath, { recursive: true, force: true });
|
|
270
268
|
await import_fs.promises.mkdir(cachePath, { recursive: true });
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/test",
|
|
3
|
-
"version": "2.1.0-alpha.
|
|
3
|
+
"version": "2.1.0-alpha.31",
|
|
4
4
|
"main": "lib/index.js",
|
|
5
5
|
"module": "./src/index.ts",
|
|
6
6
|
"types": "./lib/index.d.ts",
|
|
7
|
-
"license": "
|
|
7
|
+
"license": "Apache-2.0",
|
|
8
8
|
"exports": {
|
|
9
9
|
".": {
|
|
10
10
|
"require": {
|
|
@@ -51,7 +51,8 @@
|
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
53
|
"@faker-js/faker": "8.1.0",
|
|
54
|
-
"@nocobase/server": "2.1.0-alpha.
|
|
54
|
+
"@nocobase/server": "2.1.0-alpha.31",
|
|
55
|
+
"@nocobase/utils": "2.1.0-alpha.31",
|
|
55
56
|
"@playwright/test": "^1.45.3",
|
|
56
57
|
"@testing-library/jest-dom": "^6.4.2",
|
|
57
58
|
"@testing-library/react": "^14.0.0",
|
|
@@ -76,5 +77,5 @@
|
|
|
76
77
|
"vitest-dom": "^0.1.1",
|
|
77
78
|
"ws": "^8.13.0"
|
|
78
79
|
},
|
|
79
|
-
"gitHead": "
|
|
80
|
+
"gitHead": "e2bc6b461a9bfd336043069c3211c9c5b01ebcc3"
|
|
80
81
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { createMockServer } from '@nocobase/test';
|
|
2
2
|
import { CollectionRepository } from '@nocobase/plugin-data-source-main';
|
|
3
|
+
import { storagePathJoin } from '@nocobase/utils';
|
|
3
4
|
import fs from 'fs';
|
|
4
5
|
import path from 'path';
|
|
5
6
|
import os from 'os';
|
|
@@ -7,7 +8,7 @@ import ExcelJS from 'exceljs';
|
|
|
7
8
|
import { faker } from '@faker-js/faker';
|
|
8
9
|
import request from 'superagent';
|
|
9
10
|
|
|
10
|
-
const storagePath =
|
|
11
|
+
const storagePath = storagePathJoin('perf', 'importDataTest');
|
|
11
12
|
|
|
12
13
|
export default async function main() {
|
|
13
14
|
const app = await createMockServer({
|
package/setup/server.ts
CHANGED
package/vitest.mjs
CHANGED
|
@@ -10,6 +10,13 @@ const __filename = fileURLToPath(import.meta.url);
|
|
|
10
10
|
const __dirname = dirname(__filename);
|
|
11
11
|
|
|
12
12
|
const CORE_CLIENT_PACKAGES = ['sdk', 'client', 'client-v2', 'flow-engine'];
|
|
13
|
+
const PLUGIN_CLIENT_PACKAGES = ['client', 'client-v2'];
|
|
14
|
+
// 按路径填写要跳过服务端测试的插件目录(相对仓库根目录)
|
|
15
|
+
const skipPluginPaths = [
|
|
16
|
+
'packages/plugins/@nocobase/plugin-audit-logs',
|
|
17
|
+
'packages/plugins/@nocobase/plugin-backup-restore',
|
|
18
|
+
'packages/plugins/@nocobase/plugin-multi-app-share-collections',
|
|
19
|
+
];
|
|
13
20
|
|
|
14
21
|
const relativePathToAbsolute = (relativePath) => {
|
|
15
22
|
return path.resolve(process.cwd(), relativePath);
|
|
@@ -108,19 +115,27 @@ const defineCommonConfig = () => {
|
|
|
108
115
|
function getExclude(isServer) {
|
|
109
116
|
return [
|
|
110
117
|
`packages/core/${isServer ? '' : '!'}(${CORE_CLIENT_PACKAGES.join('|')})/**/*`,
|
|
111
|
-
|
|
118
|
+
...(isServer ? PLUGIN_CLIENT_PACKAGES : ['server']).map((dir) => `packages/**/src/${dir}/**/*`),
|
|
112
119
|
];
|
|
113
120
|
}
|
|
114
121
|
|
|
122
|
+
function getSkipPluginExcludes(isServer) {
|
|
123
|
+
if (!isServer) return [];
|
|
124
|
+
return skipPluginPaths
|
|
125
|
+
.map((p) => p.replace(/\\/g, '/').replace(/\/$/, ''))
|
|
126
|
+
.filter(Boolean)
|
|
127
|
+
.map((p) => `${p}/src/server/**`);
|
|
128
|
+
}
|
|
129
|
+
|
|
115
130
|
const defineServerConfig = () => {
|
|
116
131
|
return vitestConfig({
|
|
117
132
|
test: {
|
|
118
133
|
setupFiles: resolve(__dirname, './setup/server.ts'),
|
|
119
|
-
exclude: getExclude(true),
|
|
134
|
+
exclude: [...getExclude(true), ...getSkipPluginExcludes(true)],
|
|
120
135
|
retry: process.env.CI ? 2 : 0,
|
|
121
136
|
},
|
|
122
137
|
coverage: {
|
|
123
|
-
exclude: getExclude(true),
|
|
138
|
+
exclude: [...getExclude(true), ...getSkipPluginExcludes(true)],
|
|
124
139
|
},
|
|
125
140
|
});
|
|
126
141
|
};
|
|
@@ -167,6 +182,10 @@ export const getFilterInclude = (isServer, isCoverage) => {
|
|
|
167
182
|
return false;
|
|
168
183
|
});
|
|
169
184
|
|
|
185
|
+
if (argv[0] === 'run' || argv[0] === 'watch') {
|
|
186
|
+
argv = argv.slice(1);
|
|
187
|
+
}
|
|
188
|
+
|
|
170
189
|
let filterFileOrDir = argv[0];
|
|
171
190
|
|
|
172
191
|
if (!filterFileOrDir) return {};
|
|
@@ -202,7 +221,9 @@ export const getFilterInclude = (isServer, isCoverage) => {
|
|
|
202
221
|
|
|
203
222
|
// 插件目录,区分 client 和 server
|
|
204
223
|
return {
|
|
205
|
-
include:
|
|
224
|
+
include: isServer
|
|
225
|
+
? [`${filterFileOrDir}/src/server/${suffix}`]
|
|
226
|
+
: PLUGIN_CLIENT_PACKAGES.map((dir) => `${filterFileOrDir}/src/${dir}/${suffix}`),
|
|
206
227
|
};
|
|
207
228
|
};
|
|
208
229
|
|