@eziapp-org/builder 0.0.0-beta.2 → 0.0.0-beta.4
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/bin/eziapp-npm-dev-winx64.exe +0 -0
- package/dist/bin/{eziapp-release.exe → eziapp-npm-release-winx64.exe} +0 -0
- package/dist/bin/{eziapp-packager-windows.exe → eziapp-packager-winx64.exe} +0 -0
- package/dist/packagers/windows/main.d.ts +6 -0
- package/dist/packagers/windows/main.js +91 -3
- package/dist/src/builder.d.ts +0 -1
- package/dist/src/builder.js +27 -20
- package/package.json +2 -1
- package/dist/bin/eziapp-dev.exe +0 -0
- package/dist/src/colorf.d.ts +0 -5
- package/dist/src/colorf.js +0 -22
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
type Sizes = {
|
|
2
|
+
name: string;
|
|
3
|
+
size: number;
|
|
4
|
+
color?: string;
|
|
5
|
+
}[];
|
|
1
6
|
declare class windowsPackager {
|
|
2
7
|
private packagerBinPath;
|
|
3
8
|
private eziappBinPath;
|
|
@@ -11,5 +16,6 @@ declare class windowsPackager {
|
|
|
11
16
|
tempDir: string;
|
|
12
17
|
});
|
|
13
18
|
package(): Promise<void>;
|
|
19
|
+
printBuildReport(Sizes: Sizes, outAppPath?: string): void;
|
|
14
20
|
}
|
|
15
21
|
export default windowsPackager;
|
|
@@ -32,14 +32,18 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
32
32
|
return result;
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
35
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
39
|
const fs = __importStar(require("fs"));
|
|
37
40
|
const path = __importStar(require("path"));
|
|
38
41
|
const child_process_1 = require("child_process");
|
|
42
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
39
43
|
class windowsPackager {
|
|
40
44
|
constructor({ eziConfig, outDir, tempDir }) {
|
|
41
|
-
this.packagerBinPath = path.join(__dirname, "../../bin/eziapp-packager-
|
|
42
|
-
this.eziappBinPath = path.join(__dirname, "../../bin/eziapp-release.exe");
|
|
45
|
+
this.packagerBinPath = path.join(__dirname, "../../bin/eziapp-packager-winx64.exe");
|
|
46
|
+
this.eziappBinPath = path.join(__dirname, "../../bin/eziapp-npm-release-winx64.exe");
|
|
43
47
|
this.argv = [];
|
|
44
48
|
this.eziConfig = eziConfig;
|
|
45
49
|
this.outDir = outDir;
|
|
@@ -82,13 +86,97 @@ class windowsPackager {
|
|
|
82
86
|
// 开始打包
|
|
83
87
|
const packagerCmd = `"${this.packagerBinPath}" --update-version true ${this.argv.join(' ')}`;
|
|
84
88
|
(0, child_process_1.execSync)(packagerCmd, { stdio: 'inherit' });
|
|
85
|
-
console.log("Packaging completed
|
|
89
|
+
console.log(chalk_1.default.green("✓ Packaging completed:\n" + outAppPath));
|
|
86
90
|
}
|
|
87
91
|
catch (error) {
|
|
88
92
|
console.error(error);
|
|
89
93
|
fs.unlinkSync(outAppPath);
|
|
90
94
|
process.exit(1);
|
|
91
95
|
}
|
|
96
|
+
// Build Report
|
|
97
|
+
const Sizes = [
|
|
98
|
+
{
|
|
99
|
+
name: 'eziapp-core',
|
|
100
|
+
size: fs.statSync(this.eziappBinPath).size
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
name: 'fontend-assets',
|
|
104
|
+
size: fs.statSync(path.join(this.tempDir, 'ezi.assets.binary')).size
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
name: 'exe-icon',
|
|
108
|
+
size: fs.existsSync(iconPath) ? fs.statSync(iconPath).size : 0
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
name: 'extensions',
|
|
112
|
+
size: 0
|
|
113
|
+
}
|
|
114
|
+
];
|
|
115
|
+
const appRelativePath = path.relative(process.cwd(), outAppPath);
|
|
116
|
+
this.printBuildReport(Sizes, appRelativePath);
|
|
117
|
+
}
|
|
118
|
+
printBuildReport(Sizes, outAppPath) {
|
|
119
|
+
// 由大到小排序
|
|
120
|
+
Sizes.sort((a, b) => b.size - a.size);
|
|
121
|
+
// 随机设置颜色
|
|
122
|
+
const presetColors = [
|
|
123
|
+
'#e63946',
|
|
124
|
+
'#f1a208',
|
|
125
|
+
'#2a9d8f',
|
|
126
|
+
'#118ab2',
|
|
127
|
+
'#9900a7'
|
|
128
|
+
];
|
|
129
|
+
function assignColors(Sizes) {
|
|
130
|
+
const shuffled = presetColors
|
|
131
|
+
.map(c => ({ c, r: Math.random() }))
|
|
132
|
+
.sort((a, b) => a.r - b.r)
|
|
133
|
+
.map(x => x.c);
|
|
134
|
+
Sizes.forEach((item, idx) => {
|
|
135
|
+
item.color = shuffled[idx % shuffled.length];
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
assignColors(Sizes);
|
|
139
|
+
const totalSize = Sizes.reduce((sum, m) => sum + m.size, 0);
|
|
140
|
+
const puts = (str) => {
|
|
141
|
+
process.stdout.write(str);
|
|
142
|
+
};
|
|
143
|
+
// 打印标题
|
|
144
|
+
puts(chalk_1.default.bold('\n═ Build Report ════════════════════\n\n'));
|
|
145
|
+
puts('Platform: Windows x64\n');
|
|
146
|
+
puts('Build Date: ' + new Date().toLocaleString() + '\n');
|
|
147
|
+
puts('Status: ' + chalk_1.default.green.bold('0 error(s), 0 warning(s)\n'));
|
|
148
|
+
if (outAppPath) {
|
|
149
|
+
puts(`Output: ` + chalk_1.default.bold(outAppPath) + `\n`);
|
|
150
|
+
}
|
|
151
|
+
// 绘制占比进度条
|
|
152
|
+
const barLength = 35;
|
|
153
|
+
puts(chalk_1.default.bold('─'.repeat(barLength)));
|
|
154
|
+
puts('\n');
|
|
155
|
+
Sizes.forEach(m => {
|
|
156
|
+
const percent = m.size / totalSize;
|
|
157
|
+
const blocks = Math.round(percent * barLength);
|
|
158
|
+
puts(chalk_1.default.hex(m.color || '#ffffff').bold('█'.repeat(blocks)));
|
|
159
|
+
});
|
|
160
|
+
puts('\n');
|
|
161
|
+
// 打印模块表格
|
|
162
|
+
const header = '─ Module '.padEnd(19, '─') +
|
|
163
|
+
' Size '.padEnd(12, '─') +
|
|
164
|
+
' Pct ';
|
|
165
|
+
puts(chalk_1.default.bold(header) + '\n');
|
|
166
|
+
Sizes.forEach(m => {
|
|
167
|
+
const percent = ((m.size / totalSize) * 100).toFixed(0) + '%';
|
|
168
|
+
const sizeKB = (m.size / 1024).toFixed(0) + 'KB';
|
|
169
|
+
const line = chalk_1.default.hex(m.color || '#ffffff').bold(('■ ' + m.name).padEnd(20)) +
|
|
170
|
+
sizeKB.padEnd(12) +
|
|
171
|
+
percent;
|
|
172
|
+
puts(line + '\n');
|
|
173
|
+
});
|
|
174
|
+
puts(chalk_1.default.bold('─'.repeat(barLength)));
|
|
175
|
+
puts('\n');
|
|
176
|
+
puts((`Total size: `) + chalk_1.default.bold(`${(totalSize / 1024).toFixed(0)}KB\n`));
|
|
177
|
+
puts(`UPX: ` + chalk_1.default.bold('disabled') + ` (↓ 0%)\n`);
|
|
178
|
+
puts(chalk_1.default.bold('─'.repeat(barLength)));
|
|
179
|
+
puts('\n');
|
|
92
180
|
}
|
|
93
181
|
}
|
|
94
182
|
exports.default = windowsPackager;
|
package/dist/src/builder.d.ts
CHANGED
package/dist/src/builder.js
CHANGED
|
@@ -38,7 +38,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
39
|
exports.Builder = void 0;
|
|
40
40
|
const child_process_1 = require("child_process");
|
|
41
|
-
const colorf_1 = require("./colorf");
|
|
42
41
|
const utils_1 = require("./utils");
|
|
43
42
|
const fs = __importStar(require("fs"));
|
|
44
43
|
const path = __importStar(require("path"));
|
|
@@ -46,12 +45,16 @@ const vite_1 = require("vite");
|
|
|
46
45
|
const zstd_1 = require("@mongodb-js/zstd");
|
|
47
46
|
const sharp_1 = __importDefault(require("sharp"));
|
|
48
47
|
const png_to_ico_1 = __importDefault(require("png-to-ico"));
|
|
48
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
49
|
+
const { red, green, yellow, blue, bold } = chalk_1.default;
|
|
49
50
|
const packagers = {
|
|
50
51
|
windows: "../packagers/windows/main"
|
|
51
52
|
};
|
|
53
|
+
const eziDevExePaths = {
|
|
54
|
+
windows: path.join(__dirname, "../bin/eziapp-npm-dev-winx64.exe")
|
|
55
|
+
};
|
|
52
56
|
class Builder {
|
|
53
57
|
constructor(config) {
|
|
54
|
-
this.eziDevExePath = path.join(__dirname, "../bin/eziapp-dev.exe");
|
|
55
58
|
this.mode = config.mode || (0, utils_1.getArg)("--mode") || 'debug';
|
|
56
59
|
this.platform = config.platform || (0, utils_1.getArg)("--platform") || (0, utils_1.getCurrentPlatformName)();
|
|
57
60
|
this.viteConfigPath = path.join(process.cwd(), config.viteConfigPath ?? "vite.config.js");
|
|
@@ -69,7 +72,7 @@ class Builder {
|
|
|
69
72
|
}
|
|
70
73
|
}
|
|
71
74
|
catch (e) {
|
|
72
|
-
console.log(
|
|
75
|
+
console.log(yellow("! no vite.config.js found, using default config."));
|
|
73
76
|
}
|
|
74
77
|
this.viteConfig = viteConfig;
|
|
75
78
|
// ezi config
|
|
@@ -81,7 +84,7 @@ class Builder {
|
|
|
81
84
|
}
|
|
82
85
|
}
|
|
83
86
|
catch (e) {
|
|
84
|
-
console.log(
|
|
87
|
+
console.log(yellow("! no ezi.config.ts found, using default config."));
|
|
85
88
|
eziConfig = {
|
|
86
89
|
application: {
|
|
87
90
|
name: "EziApplication",
|
|
@@ -137,7 +140,7 @@ class Builder {
|
|
|
137
140
|
fs.mkdirSync(this.genTempFilePath, { recursive: true });
|
|
138
141
|
}
|
|
139
142
|
fs.writeFileSync(path.join(this.genTempFilePath, 'ezi.assets.binary'), Buffer.concat(assetsBinarys));
|
|
140
|
-
console.log(
|
|
143
|
+
console.log(green("✓ assets generated."));
|
|
141
144
|
}
|
|
142
145
|
async genIcon() {
|
|
143
146
|
const iconPath = "public/" + this.eziConfig.application.icon;
|
|
@@ -151,7 +154,7 @@ class Builder {
|
|
|
151
154
|
.toBuffer();
|
|
152
155
|
const icoBuffer = await (0, png_to_ico_1.default)(resizedPngBuffer);
|
|
153
156
|
fs.writeFileSync(path.join(this.genTempFilePath, 'eziapp.ico'), icoBuffer);
|
|
154
|
-
console.log(
|
|
157
|
+
console.log(green("✓ icon generated."));
|
|
155
158
|
}
|
|
156
159
|
catch (err) {
|
|
157
160
|
console.error('Error generating icon:', err);
|
|
@@ -161,7 +164,7 @@ class Builder {
|
|
|
161
164
|
async build() {
|
|
162
165
|
const packagerPath = packagers[this.platform];
|
|
163
166
|
if (!packagerPath) {
|
|
164
|
-
console.error(
|
|
167
|
+
console.error(red(`✗ Unsupported platform: ${this.platform}`));
|
|
165
168
|
process.exit(1);
|
|
166
169
|
}
|
|
167
170
|
if (!this.eziConfig.application.buildEntry) {
|
|
@@ -178,9 +181,13 @@ class Builder {
|
|
|
178
181
|
tempDir: this.genTempFilePath,
|
|
179
182
|
});
|
|
180
183
|
await packager.package();
|
|
181
|
-
console.log((0, colorf_1.green)("✓ build completed."));
|
|
182
184
|
}
|
|
183
185
|
async dev() {
|
|
186
|
+
const devExePath = eziDevExePaths[this.platform];
|
|
187
|
+
if (!devExePath) {
|
|
188
|
+
console.error(red(`✗ Unsupported platform: ${this.platform}`));
|
|
189
|
+
process.exit(1);
|
|
190
|
+
}
|
|
184
191
|
const startTime = Date.now();
|
|
185
192
|
const server = await (0, vite_1.createServer)();
|
|
186
193
|
await server.listen();
|
|
@@ -202,7 +209,7 @@ class Builder {
|
|
|
202
209
|
}
|
|
203
210
|
fs.writeFileSync(eziConfigJsonPath, JSON.stringify(devEziConfig, null, 4), { encoding: "utf-8" });
|
|
204
211
|
const appName = devEziConfig?.application?.name || "EziApplication";
|
|
205
|
-
const child = (0, child_process_1.spawn)(
|
|
212
|
+
const child = (0, child_process_1.spawn)(devExePath, [
|
|
206
213
|
'--configpath',
|
|
207
214
|
eziConfigJsonPath,
|
|
208
215
|
'--cwd',
|
|
@@ -212,15 +219,15 @@ class Builder {
|
|
|
212
219
|
windowsHide: false
|
|
213
220
|
});
|
|
214
221
|
child.stdout?.on("data", (data) => {
|
|
215
|
-
process.stdout.write((0, utils_1.getCurrentTimeString)() +
|
|
222
|
+
process.stdout.write((0, utils_1.getCurrentTimeString)() + bold(blue(` [${appName}] `)) + data);
|
|
216
223
|
});
|
|
217
224
|
const srcDir = path.join(process.cwd(), this.viteConfig?.root || "");
|
|
218
225
|
child.stderr?.on("data", (data) => {
|
|
219
226
|
const errorMsg = data.toString().replace("LOCATION_ORIGIN", srcDir.replaceAll("\\", "/"));
|
|
220
|
-
process.stderr.write(
|
|
227
|
+
process.stderr.write(red(errorMsg));
|
|
221
228
|
});
|
|
222
229
|
child.on("exit", (code) => {
|
|
223
|
-
console.log((0, utils_1.getCurrentTimeString)() +
|
|
230
|
+
console.log((0, utils_1.getCurrentTimeString)() + bold(blue(` [${appName}] `)) + yellow(`process [pid:${child.pid}] exited with code ${code ?? 0}.`));
|
|
224
231
|
process.exit(0);
|
|
225
232
|
});
|
|
226
233
|
function printBoxedMessage(lines) {
|
|
@@ -235,12 +242,12 @@ class Builder {
|
|
|
235
242
|
}
|
|
236
243
|
const viteVersion = require("vite/package.json").version;
|
|
237
244
|
printBoxedMessage([
|
|
238
|
-
`${
|
|
245
|
+
`${bold(green('VITE')) + green(' v' + viteVersion)} ready in ${bold((Date.now() - startTime).toString())} ms`,
|
|
239
246
|
``,
|
|
240
|
-
` ${
|
|
241
|
-
` ${
|
|
242
|
-
` ${
|
|
243
|
-
` ${
|
|
247
|
+
` ${green('➜')} ${bold('devEntry')}: ${blue(bold(devEziConfig.application.devEntry))}`,
|
|
248
|
+
` ${green("➜")} ${bold("EziApp")}: ${bold(blue(appName))} ${green("running")} [pid:${bold("" + child.pid)}]`,
|
|
249
|
+
` ${green("➜")} ${bold("Package")}: ${green(devEziConfig?.application?.package ?? "com.ezi.app")}`,
|
|
250
|
+
` ${green("➜")} ${bold("Started")}: ${blue(new Date().toLocaleString())}`,
|
|
244
251
|
]);
|
|
245
252
|
const cleanup = () => {
|
|
246
253
|
if (!child.killed) {
|
|
@@ -253,8 +260,8 @@ class Builder {
|
|
|
253
260
|
process.on("exit", cleanup);
|
|
254
261
|
}
|
|
255
262
|
async main() {
|
|
256
|
-
console.log(
|
|
257
|
-
console.log(
|
|
263
|
+
console.log(yellow("! EziApp 正在快速迭代中,当前 API 尚未稳定,请不要用于生产环境。"));
|
|
264
|
+
console.log(yellow("! EziApp is rapidly evolving, the API is not yet stable, please do not use it in production."));
|
|
258
265
|
await this.LoadConfig();
|
|
259
266
|
switch (this.mode) {
|
|
260
267
|
case 'debug':
|
|
@@ -264,7 +271,7 @@ class Builder {
|
|
|
264
271
|
await this.build();
|
|
265
272
|
break;
|
|
266
273
|
default:
|
|
267
|
-
console.error(
|
|
274
|
+
console.error(red(`✗ Unsupported build mode: ${this.mode}`));
|
|
268
275
|
process.exit(1);
|
|
269
276
|
}
|
|
270
277
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eziapp-org/builder",
|
|
3
|
-
"version": "0.0.0-beta.
|
|
3
|
+
"version": "0.0.0-beta.4",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@mongodb-js/zstd": "^7.0.0",
|
|
30
|
+
"chalk": "^5.6.2",
|
|
30
31
|
"png-to-ico": "^3.0.1",
|
|
31
32
|
"sharp": "^0.34.5"
|
|
32
33
|
}
|
package/dist/bin/eziapp-dev.exe
DELETED
|
Binary file
|
package/dist/src/colorf.d.ts
DELETED
package/dist/src/colorf.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.bold = bold;
|
|
4
|
-
exports.blue = blue;
|
|
5
|
-
exports.green = green;
|
|
6
|
-
exports.red = red;
|
|
7
|
-
exports.yellow = yellow;
|
|
8
|
-
function bold(text) {
|
|
9
|
-
return `\x1b[1m${text}\x1b[0m`;
|
|
10
|
-
}
|
|
11
|
-
function blue(text) {
|
|
12
|
-
return `\x1b[34m${text}\x1b[0m`;
|
|
13
|
-
}
|
|
14
|
-
function green(text) {
|
|
15
|
-
return `\x1b[32m${text}\x1b[0m`;
|
|
16
|
-
}
|
|
17
|
-
function red(text) {
|
|
18
|
-
return `\x1b[31m${text}\x1b[0m`;
|
|
19
|
-
}
|
|
20
|
-
function yellow(text) {
|
|
21
|
-
return `\x1b[33m${text}\x1b[0m`;
|
|
22
|
-
}
|