arui-scripts 22.0.1 → 22.1.1

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.
@@ -1,21 +1,22 @@
1
1
  ts-jest[versions] (WARN) Version 6.0.2 of typescript installed has not been tested with ts-jest. If you're experiencing issues, consider using a supported version (>=4.3.0 <6.0.0-0). Please do not report issues in ts-jest if you are using unsupported versions.
2
2
  ts-jest[versions] (WARN) Version 6.0.2 of typescript installed has not been tested with ts-jest. If you're experiencing issues, consider using a supported version (>=4.3.0 <6.0.0-0). Please do not report issues in ts-jest if you are using unsupported versions.
3
3
  ts-jest[versions] (WARN) Version 6.0.2 of typescript installed has not been tested with ts-jest. If you're experiencing issues, consider using a supported version (>=4.3.0 <6.0.0-0). Please do not report issues in ts-jest if you are using unsupported versions.
4
- PASS src/configs/app-configs/__tests__/update-with-presets.tests.ts (21.575 s)
4
+ PASS src/configs/app-configs/__tests__/update-with-presets.tests.ts (25.631 s)
5
5
  PASS src/configs/util/__tests__/create-watch-ignore-regex.tests.ts
6
6
  PASS src/configs/util/__tests__/apply-overrides.tests.ts
7
7
  PASS src/configs/app-configs/__tests__/update-with-env.tests.ts
8
+ PASS src/plugins/postcss-global-variables/utils/__tests__/add-global-variable.tests.ts (26.664 s)
8
9
  PASS src/configs/app-configs/__tests__/update-with-package.tests.ts
9
- PASS src/plugins/postcss-global-variables/utils/__tests__/add-global-variable.tests.ts (22.634 s)
10
10
  PASS src/configs/util/__tests__/get-polyfills.tests.ts
11
- PASS src/configs/util/__tests__/compress-with-dcb.test.ts
12
11
  PASS src/plugins/postcss-global-variables/utils/__tests__/parse-variables.tests.ts
12
+ PASS src/configs/util/__tests__/compress-with-dcb.test.ts
13
13
  PASS src/plugins/postcss-global-variables/utils/__tests__/get-media-query-name.tests.ts
14
14
  PASS src/configs/app-configs/__tests__/validate-settings-keys.tests.ts
15
- PASS src/configs/util/__tests__/find-plugin.tests.ts (30.504 s)
15
+ PASS src/configs/util/__tests__/find-plugin.tests.ts (35.293 s)
16
+ A worker process has failed to exit gracefully and has been force exited. This is likely caused by tests leaking due to improper teardown. Try running with --detectOpenHandles to find leaks. Active timers can also cause this, ensure that .unref() was called on them.
16
17
 
17
18
  Test Suites: 12 passed, 12 total
18
19
  Tests: 30 passed, 30 total
19
20
  Snapshots: 0 total
20
- Time: 31.39 s
21
+ Time: 36.262 s
21
22
  Ran all test suites.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # arui-scripts
2
2
 
3
+ ## 22.1.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#495](https://github.com/core-ds/arui-scripts/pull/495) [`3a00087`](https://github.com/core-ds/arui-scripts/commit/3a00087aa6e8ade68f9e5d2781641f33caca50d7) Thanks [@dmitrbrvsk](https://github.com/dmitrbrvsk)! - удален неиспользуемый импорт get-port в файле run-client-dev-server.ts
8
+
9
+ ## 22.1.0
10
+
11
+ ### Minor Changes
12
+
13
+ - [#426](https://github.com/core-ds/arui-scripts/pull/426) [`48ff487`](https://github.com/core-ds/arui-scripts/commit/48ff487b52a98c8d5d5118c0338bcbd888c6ce55) Thanks [@dmitrbrvsk](https://github.com/dmitrbrvsk)! - добавлена возможность запускать тесты c помощью vitest
14
+
3
15
  ## 22.0.1
4
16
 
5
17
  ### Patch Changes
@@ -10,6 +10,7 @@ const commands = {
10
10
  'docker-build': () => require('../commands/docker-build'),
11
11
  'docker-build:compiled': () => require('../commands/docker-build-compiled'),
12
12
  test: () => require('../commands/test'),
13
+ 'test:vitest': () => require('../commands/test-vitest'),
13
14
  'ensure-yarn': () => require('../commands/ensure-yarn'),
14
15
  'archive-build': () => require('../commands/archive-build'),
15
16
  'bundle-analyze': () => require('../commands/bundle-analyze'),
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const run_vitest_1 = require("../util/run-vitest");
4
+ process.env.BABEL_ENV = 'test';
5
+ process.env.NODE_ENV = 'test';
6
+ process.env.PUBLIC_URL = '';
7
+ const args = process.argv.slice(3);
8
+ (0, run_vitest_1.runVitest)({ args })
9
+ .then((code) => {
10
+ process.exit(code);
11
+ })
12
+ .catch((error) => {
13
+ console.error('Error running Vitest:', error);
14
+ process.exit(1);
15
+ });
@@ -0,0 +1,7 @@
1
+ export declare function hasProjectVitestConfig(cwd: string): boolean;
2
+ type RunVitestParams = {
3
+ args: string[];
4
+ cwd?: string;
5
+ };
6
+ export declare function runVitest({ args, cwd }: RunVitestParams): Promise<number>;
7
+ export {};
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.hasProjectVitestConfig = hasProjectVitestConfig;
7
+ exports.runVitest = runVitest;
8
+ const child_process_1 = require("child_process");
9
+ const fs_1 = __importDefault(require("fs"));
10
+ const path_1 = __importDefault(require("path"));
11
+ const VITEST_CONFIG_FILES = [
12
+ 'vitest.config.js',
13
+ 'vitest.config.mjs',
14
+ 'vitest.config.ts',
15
+ 'vitest.config.cjs',
16
+ 'vitest.config.mts',
17
+ 'vitest.config.cts',
18
+ ];
19
+ function hasProjectVitestConfig(cwd) {
20
+ return VITEST_CONFIG_FILES.some((file) => fs_1.default.existsSync(path_1.default.join(cwd, file)));
21
+ }
22
+ function runVitest({ args, cwd = process.cwd() }) {
23
+ const aruiVitestConfigPath = path_1.default.resolve(__dirname, '../../configs/vitest/config.js');
24
+ const vitestArgs = hasProjectVitestConfig(cwd)
25
+ ? ['run', ...args]
26
+ : ['run', '--config', aruiVitestConfigPath, ...args];
27
+ const vitestDir = path_1.default.dirname(require.resolve('vitest/package.json'));
28
+ const vitestBin = path_1.default.join(vitestDir, 'vitest.mjs');
29
+ return new Promise((resolve, reject) => {
30
+ const vitestProcess = (0, child_process_1.spawn)(process.execPath, [vitestBin, ...vitestArgs], {
31
+ stdio: 'inherit',
32
+ shell: false,
33
+ });
34
+ vitestProcess.on('close', (code) => {
35
+ resolve(code !== null && code !== void 0 ? code : 0);
36
+ });
37
+ vitestProcess.on('error', (error) => {
38
+ reject(error);
39
+ });
40
+ });
41
+ }
@@ -0,0 +1,2 @@
1
+ declare const _default: import("vite", { with: { "resolution-mode": "import" } }).UserConfig;
2
+ export default _default;
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const config_1 = require("vitest/config");
4
+ const settings_1 = require("./settings");
5
+ exports.default = (0, config_1.defineConfig)((0, settings_1.getVitestConfig)());
@@ -0,0 +1,30 @@
1
+ export declare function getVitestConfig(): {
2
+ plugins: ({
3
+ name: string;
4
+ enforce: "pre";
5
+ load(id: string): string | undefined;
6
+ } | {
7
+ readonly name: "vite-tsconfig-paths";
8
+ readonly enforce: "pre";
9
+ readonly configResolved: (config: Pick<import("vite", { with: { "resolution-mode": "import" } }).ResolvedConfig, "logger" | "root">) => void;
10
+ readonly configureServer: (server: Pick<import("vite", { with: { "resolution-mode": "import" } }).ViteDevServer, "watcher">) => void;
11
+ readonly buildStart: () => void;
12
+ readonly resolveId: (this: Pick<import("rolldown", { with: { "resolution-mode": "import" } }).PluginContext, "resolve">, id: string, importer: string | undefined, options: {}) => Promise<string | undefined>;
13
+ })[];
14
+ test: {
15
+ environment: "jsdom";
16
+ setupFiles: string[];
17
+ include: string[];
18
+ exclude: string[];
19
+ coverage: {
20
+ provider: "v8";
21
+ include: string[];
22
+ exclude: string[];
23
+ };
24
+ environmentOptions: {
25
+ jsdom: {
26
+ url: string;
27
+ };
28
+ };
29
+ };
30
+ };
@@ -0,0 +1,77 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.getVitestConfig = getVitestConfig;
7
+ const fs_1 = __importDefault(require("fs"));
8
+ const path_1 = __importDefault(require("path"));
9
+ const vite_tsconfig_paths_1 = __importDefault(require("vite-tsconfig-paths"));
10
+ function getSetupFiles(cwd) {
11
+ var _a, _b;
12
+ const packagePath = path_1.default.join(cwd, 'package.json');
13
+ let setupFiles = [];
14
+ if (fs_1.default.existsSync(packagePath)) {
15
+ const pkg = JSON.parse(fs_1.default.readFileSync(packagePath, 'utf8'));
16
+ setupFiles = (_b = (_a = pkg.jest) === null || _a === void 0 ? void 0 : _a.setupFiles) !== null && _b !== void 0 ? _b : [];
17
+ }
18
+ return setupFiles.map((file) => path_1.default.resolve(cwd, file.replace('<rootDir>', '.')));
19
+ }
20
+ const ASSET_EXTENSIONS = [
21
+ '.svg',
22
+ '.png',
23
+ '.jpg',
24
+ '.jpeg',
25
+ '.gif',
26
+ '.webp',
27
+ '.ico',
28
+ '.bmp',
29
+ '.woff',
30
+ '.woff2',
31
+ '.ttf',
32
+ '.eot',
33
+ ];
34
+ function isAsset(id) {
35
+ return ASSET_EXTENSIONS.some((extension) => id.endsWith(extension));
36
+ }
37
+ const staticFilesMockPlugin = {
38
+ name: 'arui-scripts-static-files-mock',
39
+ enforce: 'pre',
40
+ load(id) {
41
+ if (id.endsWith('.css')) {
42
+ return 'export default {}';
43
+ }
44
+ if (isAsset(id)) {
45
+ const filename = path_1.default.basename(id);
46
+ return `export default ${JSON.stringify(filename)}`;
47
+ }
48
+ return undefined;
49
+ },
50
+ };
51
+ function getVitestConfig() {
52
+ const cwd = process.cwd();
53
+ const setupFiles = getSetupFiles(cwd);
54
+ return {
55
+ plugins: [(0, vite_tsconfig_paths_1.default)({ root: cwd }), staticFilesMockPlugin],
56
+ test: {
57
+ environment: 'jsdom',
58
+ setupFiles,
59
+ include: [
60
+ 'src/**/__tests__/**/*.{ts,tsx,js,jsx}',
61
+ 'src/**/__test__/**/*.{ts,tsx,js,jsx}',
62
+ 'src/**/*.{test,spec,tests}.{ts,tsx,js,jsx}',
63
+ ],
64
+ exclude: ['**/node_modules/**', '**/build/**', '**/.build/**'],
65
+ coverage: {
66
+ provider: 'v8',
67
+ include: ['src/**/*.{js,jsx,ts,tsx}'],
68
+ exclude: ['**/*.d.ts', '**/__tests__/**'],
69
+ },
70
+ environmentOptions: {
71
+ jsdom: {
72
+ url: 'http://localhost',
73
+ },
74
+ },
75
+ },
76
+ };
77
+ }
package/docs/commands.md CHANGED
@@ -57,6 +57,40 @@ _package.json_
57
57
  arui-scripts test
58
58
  ```
59
59
 
60
+ ### test:vitest
61
+ Команда `arui-scripts test:vitest` запускает unit тесты через [Vitest](https://vitest.dev/).
62
+
63
+ Если в корне проекта есть `vitest.config.ts` (или `.js`, `.mjs`, `.cjs`), то используется он.
64
+ Иначе применяется конфигурация arui-scripts.
65
+
66
+ **Рекомендуемый способ настройки** - создать `vitest.config.js` с `mergeConfig`:
67
+
68
+ ```javascript
69
+ import { defineConfig, mergeConfig } from 'vitest/config';
70
+ import aruiConfig from 'arui-scripts/vitest';
71
+
72
+ export default mergeConfig(aruiConfig, defineConfig({
73
+ test: {
74
+ setupFiles: ['./__tests__/setup.js'],
75
+ // другие настройки Vitest
76
+ },
77
+ }));
78
+ ```
79
+
80
+ Базовый конфиг arui-scripts включает:
81
+ - API Vitest - используйте явные импорты: `import { describe, it, expect } from 'vitest'` (без глобальных переменных)
82
+ - Замену импортов `.css` на пустые модули, ассетов (svg, png, шрифты и др.) - на строку с именем файла
83
+ - Маппинг путей из `tsconfig.json` (paths) через [vite-tsconfig-paths](https://www.npmjs.com/package/vite-tsconfig-paths)
84
+ - Маски для тестов: `src/**/__tests__/**/*`, `src/**/__test__/**/*`, `src/**/*.{test,spec,tests}.*`
85
+
86
+ **Обратная совместимость**: при отсутствии `vitest.config.*` по-прежнему читается `jest.setupFiles` из `package.json`.
87
+
88
+ **Как запустить?**
89
+
90
+ ```bash
91
+ arui-scripts test:vitest
92
+ ```
93
+
60
94
  ### docker-build
61
95
  Собирает клиентский и серверный код в production-режиме, создает docker-образ и пушит его в docker-репозиторий.
62
96
 
package/package.json CHANGED
@@ -1,8 +1,15 @@
1
1
  {
2
2
  "name": "arui-scripts",
3
- "version": "22.0.1",
3
+ "version": "22.1.1",
4
4
  "main": "./build/index.js",
5
5
  "typings": "./build/index.d.ts",
6
+ "exports": {
7
+ ".": "./build/index.js",
8
+ "./vitest": "./build/configs/vitest/config.js",
9
+ "./jest-preset": "./jest-preset.js",
10
+ "./jest-preset.js": "./jest-preset.js",
11
+ "./tsconfig.json": "./tsconfig.json"
12
+ },
6
13
  "license": "MPL-2.0",
7
14
  "repository": {
8
15
  "type": "git",
@@ -115,6 +122,8 @@
115
122
  "ts-jest": "29.1.0",
116
123
  "ts-loader": "9.4.4",
117
124
  "ts-node": "10.9.2",
125
+ "vite-tsconfig-paths": "^6.1.1",
126
+ "vitest": "^4.1.5",
118
127
  "webpack-bundle-analyzer": "4.10.2",
119
128
  "webpack-deduplication-plugin": "^0.0.8",
120
129
  "webpack-manifest-plugin": "3.2.0",
@@ -149,6 +158,7 @@
149
158
  "scripts": {
150
159
  "build": "sh bin/build.sh",
151
160
  "test": "jest",
161
+ "test:vitest": "vitest",
152
162
  "lint:scripts": "arui-presets-lint scripts",
153
163
  "format": "arui-presets-lint format",
154
164
  "format:check": "arui-presets-lint format:check",