@gravity-ui/app-builder 0.0.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.
- package/CHANGELOG.md +14 -0
- package/LICENSE +21 -0
- package/README.md +9 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.js +46 -0
- package/dist/commands/build/build-lib.d.ts +2 -0
- package/dist/commands/build/build-lib.js +39 -0
- package/dist/commands/build/build-service/client.d.ts +2 -0
- package/dist/commands/build/build-service/client.js +8 -0
- package/dist/commands/build/build-service/index.d.ts +2 -0
- package/dist/commands/build/build-service/index.js +46 -0
- package/dist/commands/build/build-service/server.d.ts +2 -0
- package/dist/commands/build/build-service/server.js +44 -0
- package/dist/commands/build/index.d.ts +2 -0
- package/dist/commands/build/index.js +33 -0
- package/dist/commands/dev/client.d.ts +3 -0
- package/dist/commands/dev/client.js +98 -0
- package/dist/commands/dev/index.d.ts +2 -0
- package/dist/commands/dev/index.js +101 -0
- package/dist/commands/dev/server.d.ts +3 -0
- package/dist/commands/dev/server.js +38 -0
- package/dist/common/babel/index.d.ts +15 -0
- package/dist/common/babel/index.js +17 -0
- package/dist/common/babel/ui-preset.d.ts +1 -0
- package/dist/common/babel/ui-preset.js +71 -0
- package/dist/common/child-process/controllable-script.d.ts +19 -0
- package/dist/common/child-process/controllable-script.js +125 -0
- package/dist/common/child-process/utils.d.ts +1 -0
- package/dist/common/child-process/utils.js +68 -0
- package/dist/common/command.d.ts +4 -0
- package/dist/common/command.js +2 -0
- package/dist/common/config.d.ts +5 -0
- package/dist/common/config.js +155 -0
- package/dist/common/env.d.ts +1 -0
- package/dist/common/env.js +5 -0
- package/dist/common/library/index.d.ts +2 -0
- package/dist/common/library/index.js +302 -0
- package/dist/common/links/link.d.ts +1 -0
- package/dist/common/links/link.js +109 -0
- package/dist/common/links/unlink.d.ts +3 -0
- package/dist/common/links/unlink.js +72 -0
- package/dist/common/logger/colors.d.ts +12 -0
- package/dist/common/logger/colors.js +8 -0
- package/dist/common/logger/index.d.ts +47 -0
- package/dist/common/logger/index.js +120 -0
- package/dist/common/logger/pretty-time.d.ts +2 -0
- package/dist/common/logger/pretty-time.js +51 -0
- package/dist/common/models/index.d.ts +184 -0
- package/dist/common/models/index.js +11 -0
- package/dist/common/package.d.ts +19 -0
- package/dist/common/package.js +42 -0
- package/dist/common/paths.d.ts +20 -0
- package/dist/common/paths.js +28 -0
- package/dist/common/s3-upload/compress.d.ts +2 -0
- package/dist/common/s3-upload/compress.js +23 -0
- package/dist/common/s3-upload/index.d.ts +3 -0
- package/dist/common/s3-upload/index.js +7 -0
- package/dist/common/s3-upload/s3-client.d.ts +20 -0
- package/dist/common/s3-upload/s3-client.js +111 -0
- package/dist/common/s3-upload/upload.d.ts +14 -0
- package/dist/common/s3-upload/upload.js +117 -0
- package/dist/common/s3-upload/webpack-plugin.d.ts +18 -0
- package/dist/common/s3-upload/webpack-plugin.js +53 -0
- package/dist/common/tempData.d.ts +13 -0
- package/dist/common/tempData.js +43 -0
- package/dist/common/typescript/compile.d.ts +5 -0
- package/dist/common/typescript/compile.js +72 -0
- package/dist/common/typescript/diagnostic.d.ts +2 -0
- package/dist/common/typescript/diagnostic.js +46 -0
- package/dist/common/typescript/transformers.d.ts +2 -0
- package/dist/common/typescript/transformers.js +114 -0
- package/dist/common/typescript/utils.d.ts +10 -0
- package/dist/common/typescript/utils.js +53 -0
- package/dist/common/typescript/watch.d.ts +7 -0
- package/dist/common/typescript/watch.js +60 -0
- package/dist/common/utils.d.ts +2 -0
- package/dist/common/utils.js +19 -0
- package/dist/common/webpack/compile.d.ts +2 -0
- package/dist/common/webpack/compile.js +31 -0
- package/dist/common/webpack/config.d.ts +23 -0
- package/dist/common/webpack/config.js +662 -0
- package/dist/common/webpack/progress-plugin.d.ts +11 -0
- package/dist/common/webpack/progress-plugin.js +64 -0
- package/dist/common/webpack/public-path.d.ts +1 -0
- package/dist/common/webpack/public-path.js +2 -0
- package/dist/common/webpack/storybook.d.ts +13 -0
- package/dist/common/webpack/storybook.js +86 -0
- package/dist/common/webpack/utils.d.ts +7 -0
- package/dist/common/webpack/utils.js +71 -0
- package/dist/create-cli.d.ts +54 -0
- package/dist/create-cli.js +221 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +8 -0
- package/package.json +154 -0
|
@@ -0,0 +1,120 @@
|
|
|
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.Logger = void 0;
|
|
7
|
+
const colors_1 = require("./colors");
|
|
8
|
+
const pretty_time_1 = require("./pretty-time");
|
|
9
|
+
const strip_ansi_1 = __importDefault(require("strip-ansi"));
|
|
10
|
+
const allColors = [
|
|
11
|
+
colors_1.colors.cyan.bold,
|
|
12
|
+
colors_1.colors.blue.bold,
|
|
13
|
+
colors_1.colors.yellow.bold,
|
|
14
|
+
colors_1.colors.magenta.bold,
|
|
15
|
+
colors_1.colors.green.bold,
|
|
16
|
+
colors_1.colors.grey.bold,
|
|
17
|
+
];
|
|
18
|
+
function selectColor(namespace) {
|
|
19
|
+
var _a;
|
|
20
|
+
let hash = 0;
|
|
21
|
+
for (let i = 0; i < namespace.length; i++) {
|
|
22
|
+
/* eslint-disable no-bitwise */
|
|
23
|
+
hash = (hash << 5) - hash + namespace.charCodeAt(i);
|
|
24
|
+
hash |= 0; // Convert to 32bit integer
|
|
25
|
+
/* eslint-enable no-bitwise */
|
|
26
|
+
}
|
|
27
|
+
return (_a = allColors[Math.abs(hash) % allColors.length]) !== null && _a !== void 0 ? _a : colors_1.colors.green.bold;
|
|
28
|
+
}
|
|
29
|
+
class Logger {
|
|
30
|
+
constructor(namespace = '', verbose = false) {
|
|
31
|
+
this.colors = colors_1.colors;
|
|
32
|
+
this._verbose = false;
|
|
33
|
+
this._namespace = '';
|
|
34
|
+
this._timestamp = BigInt(0);
|
|
35
|
+
this._color = colors_1.colors.black;
|
|
36
|
+
this.print = (message, { verbose = false, wrap = false } = {}) => {
|
|
37
|
+
if (verbose && !this._verbose) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
const prefix = this._namespace ? this._color(`[${this._namespace}]`) + ' ' : '';
|
|
41
|
+
const postfix = this._timestamp > 0 ? ' ' + this._color(`+${(0, pretty_time_1.elapsedTime)(this._timestamp)}`) : '';
|
|
42
|
+
let output = prefix + message + postfix;
|
|
43
|
+
if (wrap) {
|
|
44
|
+
const width = process.stdout.columns || (process.stdout.isTTY ? 80 : 200);
|
|
45
|
+
if ((0, strip_ansi_1.default)(output).length > width) {
|
|
46
|
+
output =
|
|
47
|
+
prefix + message.slice(0, width - (0, strip_ansi_1.default)(prefix + postfix).length) + postfix;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
process.stdout.write(output);
|
|
51
|
+
};
|
|
52
|
+
this.printLn = (message, { verbose = false } = {}) => {
|
|
53
|
+
if (verbose && !this._verbose) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
this.clearLine();
|
|
57
|
+
this.print(message);
|
|
58
|
+
process.stdout.write('\n');
|
|
59
|
+
this._timestamp = process.hrtime.bigint();
|
|
60
|
+
};
|
|
61
|
+
this.clearLine = () => {
|
|
62
|
+
if (process.stdout.isTTY) {
|
|
63
|
+
process.stdout.clearLine(0);
|
|
64
|
+
process.stdout.cursorTo(0);
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
this.status = (msg) => {
|
|
68
|
+
if (process.stdout.isTTY) {
|
|
69
|
+
this.clearLine();
|
|
70
|
+
this.print(msg, { wrap: true });
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
this.message = (...args) => {
|
|
74
|
+
this.printLn(args.join(' '));
|
|
75
|
+
};
|
|
76
|
+
this.success = (...args) => {
|
|
77
|
+
this.printLn(this.colors.green(...args));
|
|
78
|
+
};
|
|
79
|
+
this.warning = (...args) => {
|
|
80
|
+
this.printLn(this.colors.yellow(...args));
|
|
81
|
+
};
|
|
82
|
+
this.error = (...args) => {
|
|
83
|
+
this.printLn(this.colors.red(...args));
|
|
84
|
+
};
|
|
85
|
+
this.logError = (errorMeta, error) => {
|
|
86
|
+
this.error(errorMeta);
|
|
87
|
+
if (error) {
|
|
88
|
+
const { name, message, stack } = error;
|
|
89
|
+
this.error(name);
|
|
90
|
+
this.error(message);
|
|
91
|
+
if (stack) {
|
|
92
|
+
this.error(stack);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
this.panic = (errorMeta, error) => {
|
|
97
|
+
this.logError(errorMeta, error);
|
|
98
|
+
process.exit(1);
|
|
99
|
+
};
|
|
100
|
+
this.setVerbose = (verbose) => {
|
|
101
|
+
this._verbose = verbose;
|
|
102
|
+
};
|
|
103
|
+
this.verbose = (...args) => {
|
|
104
|
+
this.printLn(this.colors.dim(...args), { verbose: true });
|
|
105
|
+
};
|
|
106
|
+
this.setNamespace = (namespace) => {
|
|
107
|
+
this._namespace = namespace;
|
|
108
|
+
this._color = selectColor(namespace);
|
|
109
|
+
};
|
|
110
|
+
this._verbose = verbose;
|
|
111
|
+
if (namespace) {
|
|
112
|
+
this.setNamespace(namespace);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
get isVerbose() {
|
|
116
|
+
return this._verbose;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
exports.Logger = Logger;
|
|
120
|
+
exports.default = new Logger();
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.prettyTime = exports.elapsedTime = void 0;
|
|
4
|
+
const scale = {
|
|
5
|
+
w: BigInt(6048e11),
|
|
6
|
+
d: BigInt(864e11),
|
|
7
|
+
h: BigInt(36e11),
|
|
8
|
+
m: BigInt(6e10),
|
|
9
|
+
s: BigInt(1e9),
|
|
10
|
+
ms: BigInt(1e6),
|
|
11
|
+
μs: BigInt(1e3),
|
|
12
|
+
ns: BigInt(1),
|
|
13
|
+
};
|
|
14
|
+
function elapsedTime(time, smallest = 'ms') {
|
|
15
|
+
const elapsed = process.hrtime.bigint() - time;
|
|
16
|
+
return prettyTime(elapsed, smallest);
|
|
17
|
+
}
|
|
18
|
+
exports.elapsedTime = elapsedTime;
|
|
19
|
+
function prettyTime(time, smallest = 'ms') {
|
|
20
|
+
let elapsed = time;
|
|
21
|
+
let res = '';
|
|
22
|
+
let count = 0;
|
|
23
|
+
for (const [uom, step] of Object.entries(scale)) {
|
|
24
|
+
if (count === 3) {
|
|
25
|
+
break;
|
|
26
|
+
}
|
|
27
|
+
let inc = elapsed / step;
|
|
28
|
+
if (inc === BigInt(0)) {
|
|
29
|
+
if (smallest === uom) {
|
|
30
|
+
break;
|
|
31
|
+
}
|
|
32
|
+
if (count > 0) {
|
|
33
|
+
count++;
|
|
34
|
+
}
|
|
35
|
+
continue;
|
|
36
|
+
}
|
|
37
|
+
count++;
|
|
38
|
+
elapsed -= inc * step;
|
|
39
|
+
if (count === 3 || smallest === uom) {
|
|
40
|
+
if (inc < BigInt(999) && (elapsed * BigInt(10)) / step >= BigInt(5)) {
|
|
41
|
+
inc = inc + BigInt(1);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
res += inc + uom + ' ';
|
|
45
|
+
if (smallest === uom) {
|
|
46
|
+
break;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return res || '0ms';
|
|
50
|
+
}
|
|
51
|
+
exports.prettyTime = prettyTime;
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import type { EditorLanguage } from 'monaco-editor-webpack-plugin/out/languages';
|
|
2
|
+
import type { EditorFeature } from 'monaco-editor-webpack-plugin/out/features';
|
|
3
|
+
import type { IFeatureDefinition } from 'monaco-editor-webpack-plugin/out/types';
|
|
4
|
+
import type { Options as MomentTzOptions } from 'moment-timezone-data-webpack-plugin';
|
|
5
|
+
import type { Configuration, ResolveOptions, DefinePlugin } from 'webpack';
|
|
6
|
+
import type { ServerConfiguration } from 'webpack-dev-server';
|
|
7
|
+
import type { Options as CircularDependenciesOptions } from 'circular-dependency-plugin';
|
|
8
|
+
export interface Entities<T> {
|
|
9
|
+
data: Record<string, T>;
|
|
10
|
+
keys: string[];
|
|
11
|
+
}
|
|
12
|
+
export interface LinkedPackage {
|
|
13
|
+
name: string;
|
|
14
|
+
location: string;
|
|
15
|
+
nodeModules: string[];
|
|
16
|
+
package?: string;
|
|
17
|
+
restorePackageFrom?: string;
|
|
18
|
+
typescript?: boolean;
|
|
19
|
+
}
|
|
20
|
+
interface DevServerConfig {
|
|
21
|
+
ipc?: string;
|
|
22
|
+
port?: number | true;
|
|
23
|
+
webSocketPath?: string;
|
|
24
|
+
type?: 'https';
|
|
25
|
+
options?: import('https').ServerOptions;
|
|
26
|
+
}
|
|
27
|
+
interface ContextReplacement {
|
|
28
|
+
'highlight.js'?: string[];
|
|
29
|
+
moment?: string[];
|
|
30
|
+
}
|
|
31
|
+
export interface LibraryConfig {
|
|
32
|
+
lib?: {
|
|
33
|
+
internalDirs?: string[];
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Use new JSX Transform
|
|
37
|
+
*/
|
|
38
|
+
newJsxTransform?: boolean;
|
|
39
|
+
verbose?: boolean;
|
|
40
|
+
}
|
|
41
|
+
export interface ClientConfig {
|
|
42
|
+
modules?: string[];
|
|
43
|
+
/**
|
|
44
|
+
* Resolve [alias](https://webpack.js.org/configuration/resolve/#resolvealias)
|
|
45
|
+
*/
|
|
46
|
+
alias?: Record<string, string>;
|
|
47
|
+
/**
|
|
48
|
+
* Additional compilation paths
|
|
49
|
+
*/
|
|
50
|
+
includes?: string[];
|
|
51
|
+
/**
|
|
52
|
+
* Additional paths fro images
|
|
53
|
+
*/
|
|
54
|
+
images?: string[];
|
|
55
|
+
/**
|
|
56
|
+
* Additional paths for svg icons
|
|
57
|
+
*/
|
|
58
|
+
icons?: string[];
|
|
59
|
+
devServer?: DevServerConfig;
|
|
60
|
+
contextReplacement?: ContextReplacement;
|
|
61
|
+
/**
|
|
62
|
+
* publicPath prefix, will be added to '/build/'
|
|
63
|
+
*/
|
|
64
|
+
publicPathPrefix?: string;
|
|
65
|
+
/**
|
|
66
|
+
* Add monaco-editor support
|
|
67
|
+
*/
|
|
68
|
+
monaco?: {
|
|
69
|
+
filename?: string;
|
|
70
|
+
languages?: EditorLanguage[];
|
|
71
|
+
features?: EditorFeature[];
|
|
72
|
+
customLanguages?: IFeatureDefinition[];
|
|
73
|
+
};
|
|
74
|
+
/**
|
|
75
|
+
* if false - source maps will be generated for prod builds,
|
|
76
|
+
*/
|
|
77
|
+
hiddenSourceMap?: boolean;
|
|
78
|
+
/**
|
|
79
|
+
* additional libraries for vendor chunk
|
|
80
|
+
*/
|
|
81
|
+
vendors?: string[];
|
|
82
|
+
/**
|
|
83
|
+
* [settings](https://www.npmjs.com/package/moment-timezone-data-webpack-plugin) for moment-timezone (by default data is truncated)
|
|
84
|
+
*/
|
|
85
|
+
momentTz?: MomentTzOptions;
|
|
86
|
+
/**
|
|
87
|
+
* Specify dependencies that shouldn't be resolved by webpack, but should become dependencies of the resulting bundle. The kind of the dependency depends on `output.libraryTarget`.
|
|
88
|
+
*/
|
|
89
|
+
externals?: Configuration['externals'];
|
|
90
|
+
/**
|
|
91
|
+
* Include polyfills or mocks for various node stuff.
|
|
92
|
+
*/
|
|
93
|
+
node?: Configuration['node'];
|
|
94
|
+
/**
|
|
95
|
+
* Redirect module requests when normal resolving fails.
|
|
96
|
+
*/
|
|
97
|
+
fallback?: ResolveOptions['fallback'];
|
|
98
|
+
/**
|
|
99
|
+
* Follow symbolic links while looking for a file. [more](https://webpack.js.org/configuration/resolve/#resolvesymlinks)
|
|
100
|
+
*/
|
|
101
|
+
symlinks?: boolean;
|
|
102
|
+
/**
|
|
103
|
+
* Enables `safari10` terser's option. [Terser options](https://github.com/terser/terser#minify-options)
|
|
104
|
+
*/
|
|
105
|
+
safari10?: boolean;
|
|
106
|
+
/**
|
|
107
|
+
* svgr plugin options.
|
|
108
|
+
*/
|
|
109
|
+
svgr?: Object;
|
|
110
|
+
entryFilter?: string[];
|
|
111
|
+
excludeFromClean?: string[];
|
|
112
|
+
analyzeBundle?: 'true' | 'statoscope';
|
|
113
|
+
reactProfiling?: boolean;
|
|
114
|
+
/**
|
|
115
|
+
* Disable react-refresh in dev mode
|
|
116
|
+
*/
|
|
117
|
+
disableReactRefresh?: boolean;
|
|
118
|
+
/**
|
|
119
|
+
* Detect modules with circular dependencies
|
|
120
|
+
*/
|
|
121
|
+
detectCircularDependencies?: true | CircularDependenciesOptions;
|
|
122
|
+
/**
|
|
123
|
+
* use new JSX Transform
|
|
124
|
+
*/
|
|
125
|
+
newJsxTransform?: boolean;
|
|
126
|
+
disableForkTsChecker?: boolean;
|
|
127
|
+
disableSourceMapGeneration?: boolean;
|
|
128
|
+
lazyCompilation?: boolean | {
|
|
129
|
+
port?: number;
|
|
130
|
+
};
|
|
131
|
+
polyfill?: {
|
|
132
|
+
process?: boolean;
|
|
133
|
+
};
|
|
134
|
+
definitions?: DefinePlugin['definitions'];
|
|
135
|
+
watchOptions?: Configuration['watchOptions'];
|
|
136
|
+
cdn?: {
|
|
137
|
+
bucket: string;
|
|
138
|
+
prefix?: string;
|
|
139
|
+
region?: string;
|
|
140
|
+
endpoint?: string;
|
|
141
|
+
compress?: boolean;
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
export interface ServerConfig {
|
|
145
|
+
port?: number | true;
|
|
146
|
+
watch?: string[];
|
|
147
|
+
watchThrottle?: number;
|
|
148
|
+
inspect?: number;
|
|
149
|
+
inspectBrk?: number;
|
|
150
|
+
}
|
|
151
|
+
export interface ServiceConfig {
|
|
152
|
+
target?: 'client' | 'server';
|
|
153
|
+
client?: ClientConfig;
|
|
154
|
+
server?: ServerConfig;
|
|
155
|
+
link?: string;
|
|
156
|
+
verbose?: boolean;
|
|
157
|
+
}
|
|
158
|
+
export type NormalizedClientConfig = Omit<ClientConfig, 'publicPathPrefix' | 'hiddenSourceMap' | 'svgr' | 'lazyCompilation' | 'devServer'> & {
|
|
159
|
+
publicPathPrefix: string;
|
|
160
|
+
hiddenSourceMap: boolean;
|
|
161
|
+
svgr: NonNullable<ClientConfig['svgr']>;
|
|
162
|
+
lazyCompilation?: {
|
|
163
|
+
port: number;
|
|
164
|
+
};
|
|
165
|
+
devServer: Omit<DevServerConfig, 'port' | 'type' | 'options'> & {
|
|
166
|
+
port?: number;
|
|
167
|
+
server: ServerConfiguration;
|
|
168
|
+
};
|
|
169
|
+
verbose?: boolean;
|
|
170
|
+
};
|
|
171
|
+
export type NormalizedServerConfig = Omit<ServerConfig, 'serverPort'> & {
|
|
172
|
+
serverPort?: number;
|
|
173
|
+
verbose?: boolean;
|
|
174
|
+
};
|
|
175
|
+
export type NormalizedServiceConfig = Omit<ServiceConfig, 'client' | 'server'> & {
|
|
176
|
+
client: NormalizedClientConfig;
|
|
177
|
+
server: NormalizedServerConfig;
|
|
178
|
+
};
|
|
179
|
+
export type ProjectConfig = {} & (ServiceConfig | LibraryConfig);
|
|
180
|
+
export type AppBuilderConfigPackage = (options?: unknown) => ProjectConfig;
|
|
181
|
+
export type ProjectFileConfig = ProjectConfig | ((mode: 'dev' | 'build', env?: Record<string, any>) => ProjectConfig);
|
|
182
|
+
export declare function isServiceConfig(config: ProjectConfig): config is ServiceConfig;
|
|
183
|
+
export declare function isLibraryConfig(config: ProjectConfig): config is LibraryConfig;
|
|
184
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isLibraryConfig = exports.isServiceConfig = void 0;
|
|
4
|
+
function isServiceConfig(config) {
|
|
5
|
+
return !('lib' in config);
|
|
6
|
+
}
|
|
7
|
+
exports.isServiceConfig = isServiceConfig;
|
|
8
|
+
function isLibraryConfig(config) {
|
|
9
|
+
return 'lib' in config;
|
|
10
|
+
}
|
|
11
|
+
exports.isLibraryConfig = isLibraryConfig;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Entities, ProjectConfig } from './models';
|
|
2
|
+
interface PackageInfo {
|
|
3
|
+
name: string;
|
|
4
|
+
version: string;
|
|
5
|
+
peerDependencies: Record<string, string>;
|
|
6
|
+
devDependencies: Record<string, string>;
|
|
7
|
+
location: string;
|
|
8
|
+
'app-builder'?: ProjectConfig;
|
|
9
|
+
}
|
|
10
|
+
export declare function readPackage(location: string): {
|
|
11
|
+
location: string;
|
|
12
|
+
name: string;
|
|
13
|
+
version: string;
|
|
14
|
+
peerDependencies: Record<string, string>;
|
|
15
|
+
devDependencies: Record<string, string>;
|
|
16
|
+
'app-builder'?: ProjectConfig | undefined;
|
|
17
|
+
};
|
|
18
|
+
export declare function readNodeModules(location: string): Entities<PackageInfo>;
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,42 @@
|
|
|
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.readNodeModules = exports.readPackage = void 0;
|
|
7
|
+
const fs_1 = __importDefault(require("fs"));
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
function readPackage(location) {
|
|
10
|
+
const packageJsonLocation = path_1.default.resolve(location, 'package.json');
|
|
11
|
+
if (!fs_1.default.existsSync(packageJsonLocation)) {
|
|
12
|
+
throw new Error(`package.json not found in ${location}`);
|
|
13
|
+
}
|
|
14
|
+
try {
|
|
15
|
+
const packageJson = fs_1.default.readFileSync(packageJsonLocation, 'utf-8');
|
|
16
|
+
return Object.assign(Object.assign({}, JSON.parse(packageJson)), { location });
|
|
17
|
+
}
|
|
18
|
+
catch (e) {
|
|
19
|
+
throw new Error(`Couldn't read package.json at ${location}`);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
exports.readPackage = readPackage;
|
|
23
|
+
function readNodeModules(location) {
|
|
24
|
+
const dirContents = fs_1.default.readdirSync(location);
|
|
25
|
+
return dirContents.reduce((acc, nodeModule) => {
|
|
26
|
+
if (!nodeModule.startsWith('.')) {
|
|
27
|
+
const nodeModulePath = path_1.default.resolve(location, nodeModule);
|
|
28
|
+
if (fs_1.default.existsSync(path_1.default.resolve(nodeModulePath, 'package.json'))) {
|
|
29
|
+
const packageInfo = readPackage(nodeModulePath);
|
|
30
|
+
acc.data[packageInfo.name] = packageInfo;
|
|
31
|
+
acc.keys.push(packageInfo.name);
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
const { data, keys } = readNodeModules(nodeModulePath);
|
|
35
|
+
acc.data = Object.assign(Object.assign({}, acc.data), data);
|
|
36
|
+
acc.keys = [...acc.keys, ...keys];
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return acc;
|
|
40
|
+
}, { data: {}, keys: [] });
|
|
41
|
+
}
|
|
42
|
+
exports.readNodeModules = readNodeModules;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
declare const _default: {
|
|
2
|
+
app: string;
|
|
3
|
+
appNodeModules: string;
|
|
4
|
+
appClient: string;
|
|
5
|
+
appServer: string;
|
|
6
|
+
appEntry: string;
|
|
7
|
+
appDist: string;
|
|
8
|
+
appRun: string;
|
|
9
|
+
appBuild: string;
|
|
10
|
+
src: string;
|
|
11
|
+
libBuild: string;
|
|
12
|
+
libBuildEsm: string;
|
|
13
|
+
libBuildCjs: string;
|
|
14
|
+
libAssets: string;
|
|
15
|
+
libGlobalStyles: string;
|
|
16
|
+
libCompiledGlobalStyles: string;
|
|
17
|
+
libCompiledAssetsEsm: string;
|
|
18
|
+
libCompiledAssetsCjs: string;
|
|
19
|
+
};
|
|
20
|
+
export default _default;
|
|
@@ -0,0 +1,28 @@
|
|
|
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
|
+
const fs_1 = __importDefault(require("fs"));
|
|
7
|
+
const path_1 = __importDefault(require("path"));
|
|
8
|
+
const appDirectory = fs_1.default.realpathSync(process.cwd());
|
|
9
|
+
const resolveApp = (relativePath) => path_1.default.resolve(appDirectory, relativePath);
|
|
10
|
+
exports.default = {
|
|
11
|
+
app: resolveApp('.'),
|
|
12
|
+
appNodeModules: resolveApp('node_modules'),
|
|
13
|
+
appClient: resolveApp('src/ui'),
|
|
14
|
+
appServer: resolveApp('src/server'),
|
|
15
|
+
appEntry: resolveApp('src/ui/entries'),
|
|
16
|
+
appDist: resolveApp('dist'),
|
|
17
|
+
appRun: resolveApp('dist/run'),
|
|
18
|
+
appBuild: resolveApp('dist/public/build'),
|
|
19
|
+
src: resolveApp('src'),
|
|
20
|
+
libBuild: resolveApp('build'),
|
|
21
|
+
libBuildEsm: resolveApp('build/esm'),
|
|
22
|
+
libBuildCjs: resolveApp('build/cjs'),
|
|
23
|
+
libAssets: resolveApp('assets'),
|
|
24
|
+
libGlobalStyles: resolveApp('styles'),
|
|
25
|
+
libCompiledGlobalStyles: resolveApp('build/styles'),
|
|
26
|
+
libCompiledAssetsEsm: resolveApp('build/esm/assets'),
|
|
27
|
+
libCompiledAssetsCjs: resolveApp('build/cjs/assets'),
|
|
28
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.brotli = exports.gzip = void 0;
|
|
4
|
+
const fs_1 = require("fs");
|
|
5
|
+
const zlib_1 = require("zlib");
|
|
6
|
+
function compressor(sourcePath, destinationPath, transformer) {
|
|
7
|
+
return new Promise((resolve, reject) => {
|
|
8
|
+
const sourceStream = (0, fs_1.createReadStream)(sourcePath);
|
|
9
|
+
sourceStream.on('error', reject);
|
|
10
|
+
const destinationStream = (0, fs_1.createWriteStream)(destinationPath);
|
|
11
|
+
destinationStream.on('finish', () => resolve(destinationPath));
|
|
12
|
+
destinationStream.on('error', reject);
|
|
13
|
+
sourceStream.pipe(transformer).pipe(destinationStream);
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
function gzip(sourcePath) {
|
|
17
|
+
return compressor(sourcePath, `${sourcePath}.gz`, (0, zlib_1.createGzip)({}));
|
|
18
|
+
}
|
|
19
|
+
exports.gzip = gzip;
|
|
20
|
+
function brotli(sourcePath) {
|
|
21
|
+
return compressor(sourcePath, `${sourcePath}.br`, (0, zlib_1.createBrotliCompress)());
|
|
22
|
+
}
|
|
23
|
+
exports.brotli = brotli;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.uploadFiles = exports.S3UploadPlugin = void 0;
|
|
4
|
+
var webpack_plugin_1 = require("./webpack-plugin");
|
|
5
|
+
Object.defineProperty(exports, "S3UploadPlugin", { enumerable: true, get: function () { return webpack_plugin_1.S3UploadPlugin; } });
|
|
6
|
+
var upload_1 = require("./upload");
|
|
7
|
+
Object.defineProperty(exports, "uploadFiles", { enumerable: true, get: function () { return upload_1.uploadFiles; } });
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { S3ClientConfig, PutObjectCommandInput } from '@aws-sdk/client-s3';
|
|
2
|
+
export type S3ClientOptions = S3ClientConfig;
|
|
3
|
+
export declare function getS3Client(options: S3ClientOptions): {
|
|
4
|
+
headObject(bucket: string, key: string): Promise<import("@aws-sdk/client-s3").HeadObjectCommandOutput>;
|
|
5
|
+
uploadFile(bucket: string, localFileOrPath: string | Buffer, key: string, opts?: S3UploadFileOptions): Promise<import("@aws-sdk/client-s3").PutObjectCommandOutput>;
|
|
6
|
+
uploadDir(bucket: string, dirPath: string, keyPrefix?: string, { concurrency, ...opts }?: S3UploadDirOptions): Promise<import("@aws-sdk/client-s3").PutObjectCommandOutput[]>;
|
|
7
|
+
deleteObject(bucket: string, key: string): Promise<import("@aws-sdk/client-s3").DeleteObjectCommandOutput>;
|
|
8
|
+
};
|
|
9
|
+
interface UploadOptionsCommon {
|
|
10
|
+
expires?: PutObjectCommandInput['Expires'];
|
|
11
|
+
meta?: PutObjectCommandInput['Metadata'];
|
|
12
|
+
}
|
|
13
|
+
export interface S3UploadDirOptions extends UploadOptionsCommon {
|
|
14
|
+
concurrency?: number;
|
|
15
|
+
}
|
|
16
|
+
export interface S3UploadFileOptions extends UploadOptionsCommon {
|
|
17
|
+
contentType?: string;
|
|
18
|
+
contentEncoding?: string;
|
|
19
|
+
}
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
26
|
+
var t = {};
|
|
27
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
28
|
+
t[p] = s[p];
|
|
29
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
30
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
31
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
32
|
+
t[p[i]] = s[p[i]];
|
|
33
|
+
}
|
|
34
|
+
return t;
|
|
35
|
+
};
|
|
36
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
37
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
38
|
+
};
|
|
39
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
|
+
exports.getS3Client = void 0;
|
|
41
|
+
const fs = __importStar(require("fs/promises"));
|
|
42
|
+
const path = __importStar(require("path"));
|
|
43
|
+
const client_s3_1 = require("@aws-sdk/client-s3");
|
|
44
|
+
const file_type_1 = require("file-type");
|
|
45
|
+
const mime = __importStar(require("mime-types"));
|
|
46
|
+
const p_map_1 = __importDefault(require("p-map"));
|
|
47
|
+
const fast_glob_1 = __importDefault(require("fast-glob"));
|
|
48
|
+
function getS3Client(options) {
|
|
49
|
+
const s3Client = new client_s3_1.S3Client(options);
|
|
50
|
+
return {
|
|
51
|
+
headObject(bucket, key) {
|
|
52
|
+
return s3Client.send(new client_s3_1.HeadObjectCommand({ Bucket: bucket, Key: key }));
|
|
53
|
+
},
|
|
54
|
+
async uploadFile(bucket, localFileOrPath, key, opts = {}) {
|
|
55
|
+
const isBuffer = Buffer.isBuffer(localFileOrPath);
|
|
56
|
+
const bodyBuffer = isBuffer ? localFileOrPath : await fs.readFile(localFileOrPath);
|
|
57
|
+
let contentType = opts.contentType;
|
|
58
|
+
if (!contentType) {
|
|
59
|
+
contentType = isBuffer
|
|
60
|
+
? await detectContentTypeFromBuffer(localFileOrPath)
|
|
61
|
+
: detectContentTypeFromExt(localFileOrPath);
|
|
62
|
+
}
|
|
63
|
+
const meta = opts.meta;
|
|
64
|
+
const expires = opts.expires;
|
|
65
|
+
const contentEncoding = opts.contentEncoding;
|
|
66
|
+
const params = {
|
|
67
|
+
Bucket: bucket,
|
|
68
|
+
Key: key,
|
|
69
|
+
Body: bodyBuffer,
|
|
70
|
+
Metadata: meta,
|
|
71
|
+
Expires: expires,
|
|
72
|
+
ContentEncoding: contentEncoding,
|
|
73
|
+
ContentType: contentType,
|
|
74
|
+
};
|
|
75
|
+
if (expires) {
|
|
76
|
+
params.Metadata = Object.assign(Object.assign({}, params.Metadata), { Expires: expires.toString() });
|
|
77
|
+
}
|
|
78
|
+
return s3Client.send(new client_s3_1.PutObjectCommand(params));
|
|
79
|
+
},
|
|
80
|
+
uploadDir(bucket, dirPath, keyPrefix = '', _a = {}) {
|
|
81
|
+
var { concurrency = 512 } = _a, opts = __rest(_a, ["concurrency"]);
|
|
82
|
+
const files = fast_glob_1.default.sync('**', { cwd: dirPath });
|
|
83
|
+
return (0, p_map_1.default)(files, (filePath) => {
|
|
84
|
+
const sourcePath = path.join(dirPath, filePath);
|
|
85
|
+
return this.uploadFile(bucket, sourcePath, keyPrefix + filePath, opts);
|
|
86
|
+
}, { concurrency });
|
|
87
|
+
},
|
|
88
|
+
deleteObject(bucket, key) {
|
|
89
|
+
return s3Client.send(new client_s3_1.DeleteObjectCommand({ Bucket: bucket, Key: key }));
|
|
90
|
+
},
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
exports.getS3Client = getS3Client;
|
|
94
|
+
async function detectContentTypeFromBuffer(buffer) {
|
|
95
|
+
const type = await (0, file_type_1.fromBuffer)(buffer);
|
|
96
|
+
if (!type) {
|
|
97
|
+
throw Error('Cannot detect content type for buffer');
|
|
98
|
+
}
|
|
99
|
+
return type.mime;
|
|
100
|
+
}
|
|
101
|
+
function detectContentTypeFromExt(filePath) {
|
|
102
|
+
// Compressed file Content-type must be the same as original file Content-type
|
|
103
|
+
if (filePath.endsWith('.br') || filePath.endsWith('.gz')) {
|
|
104
|
+
filePath = filePath.slice(0, -3);
|
|
105
|
+
}
|
|
106
|
+
const type = mime.lookup(filePath);
|
|
107
|
+
if (!type) {
|
|
108
|
+
throw Error(`Cannot detect content type for file ${filePath}`);
|
|
109
|
+
}
|
|
110
|
+
return type;
|
|
111
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { S3ClientOptions } from './s3-client.js';
|
|
2
|
+
export interface UploadOptions {
|
|
3
|
+
bucket: string;
|
|
4
|
+
sourcePath: string;
|
|
5
|
+
targetPath?: string;
|
|
6
|
+
existsBehavior?: 'overwrite' | 'throw' | 'ignore';
|
|
7
|
+
}
|
|
8
|
+
export interface UploadFilesOptions {
|
|
9
|
+
s3: S3ClientOptions;
|
|
10
|
+
concurrency?: number;
|
|
11
|
+
compress?: boolean;
|
|
12
|
+
options: UploadOptions;
|
|
13
|
+
}
|
|
14
|
+
export declare function uploadFiles(files: string[], config: UploadFilesOptions): Promise<string[]>;
|