@gravity-ui/app-builder 0.10.0 → 0.11.0
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/dist/cli.js +3 -5
- package/dist/commands/build/build-lib.js +23 -20
- package/dist/commands/build/build-service/client.js +1 -2
- package/dist/commands/build/build-service/index.js +1 -1
- package/dist/commands/build/build-service/server.js +23 -21
- package/dist/commands/build/index.js +1 -1
- package/dist/commands/dev/client.js +31 -33
- package/dist/commands/dev/index.js +3 -3
- package/dist/commands/dev/server.d.ts +1 -1
- package/dist/commands/dev/server.js +3 -4
- package/dist/common/babel/index.js +1 -2
- package/dist/common/child-process/controllable-script.d.ts +2 -4
- package/dist/common/child-process/controllable-script.js +4 -4
- package/dist/common/child-process/utils.js +1 -2
- package/dist/common/config.js +61 -36
- package/dist/common/library/babel-plugin-replace-paths.js +1 -0
- package/dist/common/library/index.js +1 -2
- package/dist/common/logger/colors.d.ts +2 -2
- package/dist/common/logger/index.d.ts +4 -6
- package/dist/common/logger/index.js +9 -6
- package/dist/common/logger/log-config.js +2 -2
- package/dist/common/logger/pretty-time.js +2 -3
- package/dist/common/models/index.d.ts +13 -18
- package/dist/common/models/index.js +3 -4
- package/dist/common/s3-upload/compress.js +2 -3
- package/dist/common/s3-upload/s3-client.d.ts +0 -1
- package/dist/common/s3-upload/s3-client.js +8 -14
- package/dist/common/s3-upload/upload.js +9 -6
- package/dist/common/typescript/compile.js +2 -3
- package/dist/common/typescript/diagnostic.js +1 -2
- package/dist/common/typescript/transformers.js +4 -3
- package/dist/common/typescript/utils.d.ts +4 -1
- package/dist/common/typescript/utils.js +31 -7
- package/dist/common/typescript/watch.js +2 -2
- package/dist/common/utils.d.ts +1 -1
- package/dist/common/utils.js +7 -8
- package/dist/common/webpack/compile.js +1 -2
- package/dist/common/webpack/config.d.ts +2 -7
- package/dist/common/webpack/config.js +14 -57
- package/dist/common/webpack/lazy-client.js +4 -4
- package/dist/common/webpack/progress-plugin.js +1 -0
- package/dist/common/webpack/storybook.js +2 -3
- package/dist/common/webpack/utils.js +3 -4
- package/dist/common/webpack/worker/web-worker.d.mts +1 -1
- package/dist/common/webpack/worker/web-worker.mjs +0 -1
- package/dist/common/webpack/worker/worker-loader.js +5 -1
- package/dist/create-cli.d.ts +2 -2
- package/dist/create-cli.js +17 -25
- package/package.json +67 -72
- package/dist/common/links/link.d.ts +0 -1
- package/dist/common/links/link.js +0 -132
- package/dist/common/links/unlink.d.ts +0 -3
- package/dist/common/links/unlink.js +0 -95
- package/dist/common/package.d.ts +0 -19
- package/dist/common/package.js +0 -65
- package/dist/common/tempData.d.ts +0 -13
- package/dist/common/tempData.js +0 -67
|
@@ -88,12 +88,15 @@ class Logger {
|
|
|
88
88
|
};
|
|
89
89
|
logError = (errorMeta, error) => {
|
|
90
90
|
this.error(errorMeta);
|
|
91
|
-
if (error) {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
if (
|
|
96
|
-
this.error(
|
|
91
|
+
if (error && typeof error === 'object') {
|
|
92
|
+
if ('name' in error && typeof error.name === 'string') {
|
|
93
|
+
this.error(error.name);
|
|
94
|
+
}
|
|
95
|
+
if ('message' in error && typeof error.message === 'string') {
|
|
96
|
+
this.error(error.message);
|
|
97
|
+
}
|
|
98
|
+
if ('stack' in error && typeof error.stack === 'string') {
|
|
99
|
+
this.error(error.stack);
|
|
97
100
|
}
|
|
98
101
|
}
|
|
99
102
|
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.logConfig =
|
|
3
|
+
exports.logConfig = logConfig;
|
|
4
|
+
/* eslint-disable no-console */
|
|
4
5
|
const colors_1 = require("./colors");
|
|
5
6
|
function logConfig(caption, config) {
|
|
6
7
|
console.log(colors_1.colors.cyan(caption));
|
|
7
8
|
console.dir(config, { depth: Infinity });
|
|
8
9
|
}
|
|
9
|
-
exports.logConfig = logConfig;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.elapsedTime = elapsedTime;
|
|
4
|
+
exports.prettyTime = prettyTime;
|
|
4
5
|
const scale = {
|
|
5
6
|
w: BigInt(6048e11),
|
|
6
7
|
d: BigInt(864e11),
|
|
@@ -15,7 +16,6 @@ function elapsedTime(time, smallest = 'ms') {
|
|
|
15
16
|
const elapsed = process.hrtime.bigint() - time;
|
|
16
17
|
return prettyTime(elapsed, smallest);
|
|
17
18
|
}
|
|
18
|
-
exports.elapsedTime = elapsedTime;
|
|
19
19
|
function prettyTime(time, smallest = 'ms') {
|
|
20
20
|
let elapsed = time;
|
|
21
21
|
let res = '';
|
|
@@ -48,4 +48,3 @@ function prettyTime(time, smallest = 'ms') {
|
|
|
48
48
|
}
|
|
49
49
|
return res || '0ms';
|
|
50
50
|
}
|
|
51
|
-
exports.prettyTime = prettyTime;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
1
|
import type { EditorLanguage } from 'monaco-editor-webpack-plugin/out/languages';
|
|
3
2
|
import type { EditorFeature } from 'monaco-editor-webpack-plugin/out/features';
|
|
4
3
|
import type { IFeatureDefinition } from 'monaco-editor-webpack-plugin/out/types';
|
|
@@ -18,20 +17,13 @@ export interface Entities<T> {
|
|
|
18
17
|
data: Record<string, T>;
|
|
19
18
|
keys: string[];
|
|
20
19
|
}
|
|
21
|
-
export interface LinkedPackage {
|
|
22
|
-
name: string;
|
|
23
|
-
location: string;
|
|
24
|
-
nodeModules: string[];
|
|
25
|
-
package?: string;
|
|
26
|
-
restorePackageFrom?: string;
|
|
27
|
-
typescript?: boolean;
|
|
28
|
-
}
|
|
29
20
|
interface DevServerConfig {
|
|
30
21
|
ipc?: string;
|
|
31
22
|
port?: number | true;
|
|
32
23
|
webSocketPath?: string;
|
|
33
24
|
type?: 'https';
|
|
34
25
|
options?: import('https').ServerOptions;
|
|
26
|
+
writeToDisk?: boolean | ((targetPath: string) => boolean);
|
|
35
27
|
}
|
|
36
28
|
interface ContextReplacement {
|
|
37
29
|
'highlight.js'?: string[];
|
|
@@ -211,8 +203,8 @@ export interface ServerConfig {
|
|
|
211
203
|
port?: number | true;
|
|
212
204
|
watch?: string[];
|
|
213
205
|
watchThrottle?: number;
|
|
214
|
-
inspect?: number;
|
|
215
|
-
inspectBrk?: number;
|
|
206
|
+
inspect?: number | true;
|
|
207
|
+
inspectBrk?: number | true;
|
|
216
208
|
}
|
|
217
209
|
export interface ServiceConfig {
|
|
218
210
|
target?: 'client' | 'server';
|
|
@@ -221,14 +213,14 @@ export interface ServiceConfig {
|
|
|
221
213
|
lib?: never;
|
|
222
214
|
verbose?: boolean;
|
|
223
215
|
}
|
|
224
|
-
export type NormalizedClientConfig = Omit<ClientConfig, 'publicPathPrefix' | 'hiddenSourceMap' | 'svgr' | 'lazyCompilation' | 'devServer'> & {
|
|
216
|
+
export type NormalizedClientConfig = Omit<ClientConfig, 'publicPathPrefix' | 'hiddenSourceMap' | 'svgr' | 'lazyCompilation' | 'devServer' | 'disableForkTsChecker'> & {
|
|
225
217
|
publicPathPrefix: string;
|
|
226
218
|
hiddenSourceMap: boolean;
|
|
227
219
|
svgr: NonNullable<ClientConfig['svgr']>;
|
|
228
220
|
lazyCompilation?: LazyCompilationConfig;
|
|
229
|
-
devServer
|
|
221
|
+
devServer?: Omit<DevServerConfig, 'port' | 'type' | 'options'> & {
|
|
230
222
|
port?: number;
|
|
231
|
-
server
|
|
223
|
+
server?: ServerConfiguration;
|
|
232
224
|
};
|
|
233
225
|
verbose?: boolean;
|
|
234
226
|
webpack: (config: Configuration, options: {
|
|
@@ -239,17 +231,20 @@ export type NormalizedClientConfig = Omit<ClientConfig, 'publicPathPrefix' | 'hi
|
|
|
239
231
|
configType: `${WebpackMode}`;
|
|
240
232
|
}) => Babel.TransformOptions | Promise<Babel.TransformOptions>;
|
|
241
233
|
};
|
|
242
|
-
export type NormalizedServerConfig = Omit<ServerConfig, '
|
|
243
|
-
|
|
234
|
+
export type NormalizedServerConfig = Omit<ServerConfig, 'port' | 'inspect' | 'inspectBrk'> & {
|
|
235
|
+
port?: number;
|
|
244
236
|
verbose?: boolean;
|
|
237
|
+
inspect?: number;
|
|
238
|
+
inspectBrk?: number;
|
|
245
239
|
};
|
|
246
240
|
export type NormalizedServiceConfig = Omit<ServiceConfig, 'client' | 'server'> & {
|
|
247
241
|
client: NormalizedClientConfig;
|
|
248
242
|
server: NormalizedServerConfig;
|
|
249
243
|
};
|
|
250
|
-
export type ProjectConfig =
|
|
244
|
+
export type ProjectConfig = ServiceConfig | LibraryConfig;
|
|
245
|
+
export type NormalizedConfig = NormalizedServiceConfig | LibraryConfig;
|
|
251
246
|
export type AppBuilderConfigPackage = (options?: unknown) => ProjectConfig;
|
|
252
|
-
export type ProjectFileConfig = ProjectConfig | ((mode: 'dev' | 'build', env?: Record<string,
|
|
247
|
+
export type ProjectFileConfig = ProjectConfig | ((mode: 'dev' | 'build', env?: Record<string, string | boolean | {} | undefined>) => ProjectConfig | Promise<ProjectConfig>);
|
|
253
248
|
export declare function isServiceConfig(config: ProjectConfig): config is ServiceConfig;
|
|
254
249
|
export declare function isLibraryConfig(config: ProjectConfig): config is LibraryConfig;
|
|
255
250
|
export declare function defineConfig(config: ProjectFileConfig): ProjectFileConfig;
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.isServiceConfig = isServiceConfig;
|
|
4
|
+
exports.isLibraryConfig = isLibraryConfig;
|
|
5
|
+
exports.defineConfig = defineConfig;
|
|
4
6
|
function isServiceConfig(config) {
|
|
5
7
|
return !('lib' in config);
|
|
6
8
|
}
|
|
7
|
-
exports.isServiceConfig = isServiceConfig;
|
|
8
9
|
function isLibraryConfig(config) {
|
|
9
10
|
return 'lib' in config;
|
|
10
11
|
}
|
|
11
|
-
exports.isLibraryConfig = isLibraryConfig;
|
|
12
12
|
function defineConfig(config) {
|
|
13
13
|
return config;
|
|
14
14
|
}
|
|
15
|
-
exports.defineConfig = defineConfig;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.gzip = gzip;
|
|
4
|
+
exports.brotli = brotli;
|
|
4
5
|
const node_fs_1 = require("node:fs");
|
|
5
6
|
const zlib_1 = require("zlib");
|
|
6
7
|
function compressor(sourcePath, destinationPath, transformer) {
|
|
@@ -16,8 +17,6 @@ function compressor(sourcePath, destinationPath, transformer) {
|
|
|
16
17
|
function gzip(sourcePath) {
|
|
17
18
|
return compressor(sourcePath, `${sourcePath}.gz`, (0, zlib_1.createGzip)({}));
|
|
18
19
|
}
|
|
19
|
-
exports.gzip = gzip;
|
|
20
20
|
function brotli(sourcePath) {
|
|
21
21
|
return compressor(sourcePath, `${sourcePath}.br`, (0, zlib_1.createBrotliCompress)());
|
|
22
22
|
}
|
|
23
|
-
exports.brotli = brotli;
|
|
@@ -22,17 +22,12 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
22
22
|
__setModuleDefault(result, mod);
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
-
};
|
|
28
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.getS3Client =
|
|
26
|
+
exports.getS3Client = getS3Client;
|
|
30
27
|
const fs = __importStar(require("fs/promises"));
|
|
31
28
|
const path = __importStar(require("node:path"));
|
|
32
29
|
const client_s3_1 = require("@aws-sdk/client-s3");
|
|
33
|
-
const file_type_1 = require("file-type");
|
|
34
30
|
const mime = __importStar(require("mime-types"));
|
|
35
|
-
const p_map_1 = __importDefault(require("p-map"));
|
|
36
31
|
const fast_glob_1 = require("fast-glob");
|
|
37
32
|
function getS3Client(options) {
|
|
38
33
|
const s3Client = new client_s3_1.S3Client(options);
|
|
@@ -69,9 +64,10 @@ function getS3Client(options) {
|
|
|
69
64
|
}
|
|
70
65
|
return s3Client.send(new client_s3_1.PutObjectCommand(params));
|
|
71
66
|
},
|
|
72
|
-
uploadDir(bucket, dirPath, keyPrefix = '', { concurrency = 512, ...opts } = {}) {
|
|
67
|
+
async uploadDir(bucket, dirPath, keyPrefix = '', { concurrency = 512, ...opts } = {}) {
|
|
73
68
|
const files = (0, fast_glob_1.globSync)('**', { cwd: dirPath });
|
|
74
|
-
|
|
69
|
+
const { default: pMap } = await import('p-map');
|
|
70
|
+
return pMap(files, (filePath) => {
|
|
75
71
|
const sourcePath = path.join(dirPath, filePath);
|
|
76
72
|
return this.uploadFile(bucket, sourcePath, keyPrefix + filePath, opts);
|
|
77
73
|
}, { concurrency });
|
|
@@ -81,9 +77,9 @@ function getS3Client(options) {
|
|
|
81
77
|
},
|
|
82
78
|
};
|
|
83
79
|
}
|
|
84
|
-
exports.getS3Client = getS3Client;
|
|
85
80
|
async function detectContentTypeFromBuffer(buffer) {
|
|
86
|
-
const
|
|
81
|
+
const { fileTypeFromBuffer } = await import('file-type');
|
|
82
|
+
const type = await fileTypeFromBuffer(buffer);
|
|
87
83
|
if (!type) {
|
|
88
84
|
throw Error('Cannot detect content type for buffer');
|
|
89
85
|
}
|
|
@@ -97,10 +93,8 @@ async function detectContentTypeFromBuffer(buffer) {
|
|
|
97
93
|
}
|
|
98
94
|
function detectContentTypeFromExt(filePath) {
|
|
99
95
|
// Compressed file Content-type must be the same as original file Content-type
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
}
|
|
103
|
-
let contentType = mime.lookup(filePath);
|
|
96
|
+
const filename = filePath.endsWith('.br') || filePath.endsWith('.gz') ? filePath.slice(0, -3) : filePath;
|
|
97
|
+
let contentType = mime.lookup(filename);
|
|
104
98
|
if (!contentType) {
|
|
105
99
|
throw Error(`Cannot detect content type for file ${filePath}`);
|
|
106
100
|
}
|
|
@@ -26,16 +26,16 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.uploadFiles =
|
|
29
|
+
exports.uploadFiles = uploadFiles;
|
|
30
30
|
const path = __importStar(require("node:path"));
|
|
31
|
-
const p_queue_1 = __importDefault(require("p-queue"));
|
|
32
31
|
const index_js_1 = __importDefault(require("../logger/index.js"));
|
|
33
32
|
const s3_client_js_1 = require("./s3-client.js");
|
|
34
33
|
const compress_js_1 = require("./compress.js");
|
|
35
|
-
function uploadFiles(files, config) {
|
|
34
|
+
async function uploadFiles(files, config) {
|
|
36
35
|
const s3Client = (0, s3_client_js_1.getS3Client)(config.s3);
|
|
37
36
|
const log = config.logger ?? index_js_1.default;
|
|
38
|
-
const
|
|
37
|
+
const { default: PQueue } = await import('p-queue');
|
|
38
|
+
const queue = new PQueue({
|
|
39
39
|
concurrency: config.concurrency ?? 512,
|
|
40
40
|
});
|
|
41
41
|
const processFile = fileProcessor(config.options);
|
|
@@ -95,7 +95,11 @@ function uploadFiles(files, config) {
|
|
|
95
95
|
};
|
|
96
96
|
}
|
|
97
97
|
function compress(sourcePath) {
|
|
98
|
-
|
|
98
|
+
// throwOnTimeout is only used to get the correct type and does not change behavior since we are not setting a timeout.
|
|
99
|
+
return [
|
|
100
|
+
queue.add(() => (0, compress_js_1.gzip)(sourcePath), { throwOnTimeout: true }),
|
|
101
|
+
queue.add(() => (0, compress_js_1.brotli)(sourcePath), { throwOnTimeout: true }),
|
|
102
|
+
];
|
|
99
103
|
}
|
|
100
104
|
function fileProcessor(options) {
|
|
101
105
|
return (relativeFilePath) => {
|
|
@@ -114,7 +118,6 @@ function uploadFiles(files, config) {
|
|
|
114
118
|
};
|
|
115
119
|
}
|
|
116
120
|
}
|
|
117
|
-
exports.uploadFiles = uploadFiles;
|
|
118
121
|
const NOT_COMPRESS = ['png', 'zip', 'gz', 'br'];
|
|
119
122
|
function shouldCompress(filePath) {
|
|
120
123
|
const fileName = path.basename(filePath);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.compile =
|
|
3
|
+
exports.compile = compile;
|
|
4
4
|
const utils_1 = require("./utils");
|
|
5
5
|
const transformers_1 = require("./transformers");
|
|
6
6
|
const pretty_time_1 = require("../logger/pretty-time");
|
|
@@ -24,7 +24,7 @@ function compile(ts, { projectPath, configFileName = 'tsconfig.json', optionsToE
|
|
|
24
24
|
readFile: ts.sys.readFile,
|
|
25
25
|
onUnRecoverableConfigFileDiagnostic: reportDiagnostic,
|
|
26
26
|
};
|
|
27
|
-
const parsedConfig = ts.getParsedCommandLineOfConfigFile(configPath, { noEmitOnError: true, ...optionsToExtend }, parseConfigFileHost);
|
|
27
|
+
const parsedConfig = ts.getParsedCommandLineOfConfigFile(configPath, { noEmit: false, noEmitOnError: true, ...optionsToExtend }, parseConfigFileHost);
|
|
28
28
|
if (!parsedConfig) {
|
|
29
29
|
throw new Error(`Invalid '${configFileName}'`);
|
|
30
30
|
}
|
|
@@ -69,4 +69,3 @@ function compile(ts, { projectPath, configFileName = 'tsconfig.json', optionsToE
|
|
|
69
69
|
return diagnostics.some(({ category }) => category === ts.DiagnosticCategory.Error);
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
|
-
exports.compile = compile;
|
|
@@ -23,7 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.formatDiagnosticBrief =
|
|
26
|
+
exports.formatDiagnosticBrief = formatDiagnosticBrief;
|
|
27
27
|
const path = __importStar(require("node:path"));
|
|
28
28
|
const colors_1 = require("../logger/colors");
|
|
29
29
|
function formatDiagnosticBrief(ts, diagnostic, host) {
|
|
@@ -63,4 +63,3 @@ function formatDiagnosticBrief(ts, diagnostic, host) {
|
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
|
-
exports.formatDiagnosticBrief = formatDiagnosticBrief;
|
|
@@ -23,7 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.createTransformPathsToLocalModules =
|
|
26
|
+
exports.createTransformPathsToLocalModules = createTransformPathsToLocalModules;
|
|
27
27
|
const path = __importStar(require("node:path"));
|
|
28
28
|
const semver = __importStar(require("semver"));
|
|
29
29
|
function createTransformPathsToLocalModules(ts) {
|
|
@@ -112,7 +112,6 @@ function createTransformPathsToLocalModules(ts) {
|
|
|
112
112
|
};
|
|
113
113
|
};
|
|
114
114
|
}
|
|
115
|
-
exports.createTransformPathsToLocalModules = createTransformPathsToLocalModules;
|
|
116
115
|
function updateImportDeclaration(ts, node, context, resolvedPath) {
|
|
117
116
|
if (semver.lt(ts.version, '5.0.0')) {
|
|
118
117
|
// for versions before 5.0.0
|
|
@@ -142,5 +141,7 @@ function updateImportTypeNode(ts, node, context, resolvedPath) {
|
|
|
142
141
|
// @ts-expect-error
|
|
143
142
|
node.qualifier, node.typeArguments, node.isTypeOf);
|
|
144
143
|
}
|
|
145
|
-
return context.factory.updateImportTypeNode(node, context.factory.createLiteralTypeNode(context.factory.createStringLiteral(resolvedPath)),
|
|
144
|
+
return context.factory.updateImportTypeNode(node, context.factory.createLiteralTypeNode(context.factory.createStringLiteral(resolvedPath)),
|
|
145
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
146
|
+
node.attributes || node.assertions, node.qualifier, node.typeArguments, node.isTypeOf);
|
|
146
147
|
}
|
|
@@ -7,4 +7,7 @@ export declare function displayFilename(originalFunc: (path: string, encoding?:
|
|
|
7
7
|
enableDisplay(): void;
|
|
8
8
|
disableDisplay(): number;
|
|
9
9
|
};
|
|
10
|
-
export declare function onHostEvent
|
|
10
|
+
export declare function onHostEvent<F extends string, T extends {
|
|
11
|
+
[key in F]?: (...args: any[]) => any;
|
|
12
|
+
}>(host: T, functionName: F, before?: (...args: Parameters<NonNullable<T[F]>>) => void, after?: (res: ReturnType<NonNullable<T[F]>>) => void): void;
|
|
13
|
+
export declare function resolveTypescript(): string;
|
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
6
|
+
exports.getProjectConfig = getProjectConfig;
|
|
7
|
+
exports.displayFilename = displayFilename;
|
|
8
|
+
exports.onHostEvent = onHostEvent;
|
|
9
|
+
exports.resolveTypescript = resolveTypescript;
|
|
10
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
11
|
+
const paths_1 = __importDefault(require("../paths"));
|
|
4
12
|
function getProjectConfig(ts, projectPath, filename = 'tsconfig.json') {
|
|
5
13
|
const configPath = ts.findConfigFile(projectPath, ts.sys.fileExists, filename);
|
|
6
14
|
if (!configPath) {
|
|
@@ -8,7 +16,6 @@ function getProjectConfig(ts, projectPath, filename = 'tsconfig.json') {
|
|
|
8
16
|
}
|
|
9
17
|
return configPath;
|
|
10
18
|
}
|
|
11
|
-
exports.getProjectConfig = getProjectConfig;
|
|
12
19
|
function displayFilename(originalFunc, operationName, logger) {
|
|
13
20
|
let displayEnabled = false;
|
|
14
21
|
let count = 0;
|
|
@@ -36,18 +43,35 @@ function displayFilename(originalFunc, operationName, logger) {
|
|
|
36
43
|
};
|
|
37
44
|
return displayFunction;
|
|
38
45
|
}
|
|
39
|
-
|
|
46
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
40
47
|
function onHostEvent(host, functionName, before, after) {
|
|
41
48
|
const originalFunction = host[functionName];
|
|
42
|
-
|
|
49
|
+
// eslint-disable-next-line no-param-reassign
|
|
50
|
+
host[functionName] = ((...args) => {
|
|
43
51
|
if (before) {
|
|
44
52
|
before(...args);
|
|
45
53
|
}
|
|
46
|
-
|
|
54
|
+
let result;
|
|
55
|
+
if (typeof originalFunction === 'function') {
|
|
56
|
+
result = originalFunction(...args);
|
|
57
|
+
}
|
|
47
58
|
if (after) {
|
|
48
59
|
after(result);
|
|
49
60
|
}
|
|
50
61
|
return result;
|
|
51
|
-
};
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
function resolveTypescript() {
|
|
65
|
+
try {
|
|
66
|
+
return require.resolve(node_path_1.default.resolve(paths_1.default.appNodeModules, 'typescript'));
|
|
67
|
+
}
|
|
68
|
+
catch (err) {
|
|
69
|
+
if (!err ||
|
|
70
|
+
typeof err !== 'object' ||
|
|
71
|
+
!('code' in err) ||
|
|
72
|
+
err.code !== 'MODULE_NOT_FOUND') {
|
|
73
|
+
throw err;
|
|
74
|
+
}
|
|
75
|
+
return require.resolve('typescript');
|
|
76
|
+
}
|
|
52
77
|
}
|
|
53
|
-
exports.onHostEvent = onHostEvent;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.watch =
|
|
3
|
+
exports.watch = watch;
|
|
4
4
|
const transformers_1 = require("./transformers");
|
|
5
5
|
const utils_1 = require("./utils");
|
|
6
6
|
const diagnostic_1 = require("./diagnostic");
|
|
@@ -15,6 +15,7 @@ function watch(ts, projectPath, { logger, onAfterFilesEmitted, enableSourceMap,
|
|
|
15
15
|
getNewLine: () => ts.sys.newLine,
|
|
16
16
|
};
|
|
17
17
|
const host = ts.createWatchCompilerHost(configPath, {
|
|
18
|
+
noEmit: false,
|
|
18
19
|
noEmitOnError: false,
|
|
19
20
|
inlineSourceMap: enableSourceMap,
|
|
20
21
|
inlineSources: enableSourceMap,
|
|
@@ -62,4 +63,3 @@ function watch(ts, projectPath, { logger, onAfterFilesEmitted, enableSourceMap,
|
|
|
62
63
|
}
|
|
63
64
|
}
|
|
64
65
|
}
|
|
65
|
-
exports.watch = watch;
|
package/dist/common/utils.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export declare function createRunFolder(): void;
|
|
2
2
|
export declare function shouldCompileTarget(target: 'client' | 'server' | undefined, targetName: string): boolean;
|
|
3
|
-
export declare function getCacheDir(): string
|
|
3
|
+
export declare function getCacheDir(): Promise<string>;
|
|
4
4
|
export declare function getPort({ port }: {
|
|
5
5
|
port: number;
|
|
6
6
|
}): Promise<number>;
|
package/dist/common/utils.js
CHANGED
|
@@ -3,10 +3,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.createRunFolder = createRunFolder;
|
|
7
|
+
exports.shouldCompileTarget = shouldCompileTarget;
|
|
8
|
+
exports.getCacheDir = getCacheDir;
|
|
9
|
+
exports.getPort = getPort;
|
|
7
10
|
const node_fs_1 = __importDefault(require("node:fs"));
|
|
8
11
|
const node_os_1 = __importDefault(require("node:os"));
|
|
9
|
-
const find_cache_dir_1 = __importDefault(require("find-cache-dir"));
|
|
10
12
|
const paths_1 = __importDefault(require("./paths"));
|
|
11
13
|
function createRunFolder() {
|
|
12
14
|
const runPath = paths_1.default.appRun;
|
|
@@ -14,17 +16,14 @@ function createRunFolder() {
|
|
|
14
16
|
node_fs_1.default.mkdirSync(runPath, { recursive: true });
|
|
15
17
|
}
|
|
16
18
|
}
|
|
17
|
-
exports.createRunFolder = createRunFolder;
|
|
18
19
|
function shouldCompileTarget(target, targetName) {
|
|
19
20
|
return target === undefined || target === targetName;
|
|
20
21
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
return (
|
|
22
|
+
async function getCacheDir() {
|
|
23
|
+
const { default: findCacheDirectory } = await import('find-cache-dir');
|
|
24
|
+
return findCacheDirectory({ name: '@gravity-ui/app-builder', create: true }) || node_os_1.default.tmpdir();
|
|
24
25
|
}
|
|
25
|
-
exports.getCacheDir = getCacheDir;
|
|
26
26
|
async function getPort({ port }) {
|
|
27
27
|
const { default: getPortDefault, portNumbers } = await import('get-port');
|
|
28
28
|
return getPortDefault({ port: portNumbers(port, port + 100) });
|
|
29
29
|
}
|
|
30
|
-
exports.getPort = getPort;
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.webpackCompile =
|
|
6
|
+
exports.webpackCompile = webpackCompile;
|
|
7
7
|
const webpack_1 = __importDefault(require("webpack"));
|
|
8
8
|
const logger_1 = require("../logger");
|
|
9
9
|
const config_1 = require("./config");
|
|
@@ -28,4 +28,3 @@ async function webpackCompile(config) {
|
|
|
28
28
|
});
|
|
29
29
|
});
|
|
30
30
|
}
|
|
31
|
-
exports.webpackCompile = webpackCompile;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as webpack from 'webpack';
|
|
2
|
-
import type {
|
|
2
|
+
import type { NormalizedClientConfig } from '../models';
|
|
3
3
|
import type { Logger } from '../logger';
|
|
4
4
|
export interface HelperOptions {
|
|
5
5
|
config: NormalizedClientConfig;
|
|
@@ -7,11 +7,6 @@ export interface HelperOptions {
|
|
|
7
7
|
isEnvDevelopment: boolean;
|
|
8
8
|
isEnvProduction: boolean;
|
|
9
9
|
configType: `${WebpackMode}`;
|
|
10
|
-
updateIncludes?: (values: string[], options?: {
|
|
11
|
-
includeRootAssets?: boolean;
|
|
12
|
-
includeRootStyles?: boolean;
|
|
13
|
-
}) => string[];
|
|
14
|
-
tsLinkedPackages?: LinkedPackage[];
|
|
15
10
|
}
|
|
16
11
|
export declare const enum WebpackMode {
|
|
17
12
|
Prod = "production",
|
|
@@ -21,7 +16,7 @@ export declare function webpackConfigFactory(webpackMode: WebpackMode, config: N
|
|
|
21
16
|
logger?: Logger;
|
|
22
17
|
}): Promise<webpack.Configuration>;
|
|
23
18
|
export declare function configureModuleRules(helperOptions: HelperOptions, additionalRules?: NonNullable<webpack.RuleSetRule['oneOf']>): webpack.RuleSetRule[];
|
|
24
|
-
export declare function configureResolve({ isEnvProduction, config
|
|
19
|
+
export declare function configureResolve({ isEnvProduction, config }: HelperOptions): webpack.ResolveOptions;
|
|
25
20
|
type Optimization = NonNullable<webpack.Configuration['optimization']>;
|
|
26
21
|
export declare function configureOptimization({ config }: HelperOptions): Optimization;
|
|
27
22
|
export {};
|