@eziapp-org/builder 0.0.0-beta.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 eziapp-org
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1 @@
1
+ # eziapp-builder
Binary file
Binary file
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
package/dist/index.js ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ const builder_1 = require("./src/builder");
5
+ if (require.main === module) {
6
+ const builder = new builder_1.Builder({});
7
+ builder.main();
8
+ }
@@ -0,0 +1,15 @@
1
+ declare class windowsPackager {
2
+ private packagerBinPath;
3
+ private eziappBinPath;
4
+ private argv;
5
+ private eziConfig;
6
+ private outDir;
7
+ private tempDir;
8
+ constructor({ eziConfig, outDir, tempDir }: {
9
+ eziConfig: any;
10
+ outDir: string;
11
+ tempDir: string;
12
+ });
13
+ package(): Promise<void>;
14
+ }
15
+ export default windowsPackager;
@@ -0,0 +1,94 @@
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 () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ const fs = __importStar(require("fs"));
37
+ const path = __importStar(require("path"));
38
+ const child_process_1 = require("child_process");
39
+ class windowsPackager {
40
+ constructor({ eziConfig, outDir, tempDir }) {
41
+ this.packagerBinPath = path.join(__dirname, "../../bin/eziapp-packager-windows.exe");
42
+ this.eziappBinPath = path.join(__dirname, "../../bin/eziapp-release.exe");
43
+ this.argv = [];
44
+ this.eziConfig = eziConfig;
45
+ this.outDir = outDir;
46
+ this.tempDir = tempDir;
47
+ }
48
+ async package() {
49
+ console.log("packaging for Windows...");
50
+ const appName = this.eziConfig?.application?.name || "EziApp";
51
+ // 复制到输出目录
52
+ const outAppPath = path.join(this.outDir, `${appName}_winx64.exe`);
53
+ if (!fs.existsSync(this.outDir)) {
54
+ fs.mkdirSync(this.outDir, { recursive: true });
55
+ }
56
+ fs.copyFileSync(this.eziappBinPath, outAppPath);
57
+ // 输入程序参数
58
+ this.argv.push(...['--input', outAppPath]);
59
+ // 打包ezi资源参数
60
+ this.argv.push(...['--ezi-asset', path.join(this.tempDir, 'ezi.assets.binary')]);
61
+ // 打包图标参数
62
+ const iconPath = path.join(this.tempDir, 'eziapp.ico');
63
+ if (fs.existsSync(iconPath)) {
64
+ this.argv.push(...['--icon', iconPath]);
65
+ }
66
+ // 打包版本参数
67
+ this.argv.push(...['--ver-productName', appName]);
68
+ const version = this.eziConfig?.application?.version;
69
+ if (version) {
70
+ this.argv.push(...['--ver-productVersion', version]);
71
+ this.argv.push(...['--ver-fileVersion', version]);
72
+ }
73
+ const companyName = this.eziConfig?.application?.author;
74
+ if (companyName) {
75
+ this.argv.push(...['--ver-companyName', companyName]);
76
+ }
77
+ const description = this.eziConfig?.application?.description;
78
+ if (description) {
79
+ this.argv.push(...['--ver-fileDescription', description]);
80
+ }
81
+ try {
82
+ // 开始打包
83
+ const packagerCmd = `"${this.packagerBinPath}" --update-version true ${this.argv.join(' ')}`;
84
+ (0, child_process_1.execSync)(packagerCmd, { stdio: 'inherit' });
85
+ console.log("Packaging completed:", outAppPath);
86
+ }
87
+ catch (error) {
88
+ console.error(error);
89
+ fs.unlinkSync(outAppPath);
90
+ process.exit(1);
91
+ }
92
+ }
93
+ }
94
+ exports.default = windowsPackager;
@@ -0,0 +1,28 @@
1
+ type BuildMode = 'debug' | 'release';
2
+ type Platform = 'windows' | 'linux' | 'macos';
3
+ export declare class Builder {
4
+ private viteConfigPath;
5
+ private eziConfigPath;
6
+ private genTempFilePath;
7
+ private outDir;
8
+ private viteConfig;
9
+ private eziConfig;
10
+ private mode;
11
+ private platform;
12
+ private eziDevExePath;
13
+ constructor(config: {
14
+ viteConfigPath?: string;
15
+ eziConfigPath?: string;
16
+ outDir?: string;
17
+ mode?: BuildMode;
18
+ platform?: Platform;
19
+ genTempFilePath?: string;
20
+ });
21
+ LoadConfig(): Promise<void>;
22
+ genAssets(): Promise<void>;
23
+ genIcon(): Promise<void>;
24
+ build(): Promise<void>;
25
+ dev(): Promise<void>;
26
+ main(): Promise<void>;
27
+ }
28
+ export {};
@@ -0,0 +1,272 @@
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 () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __importDefault = (this && this.__importDefault) || function (mod) {
36
+ return (mod && mod.__esModule) ? mod : { "default": mod };
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.Builder = void 0;
40
+ const child_process_1 = require("child_process");
41
+ const colorf_1 = require("./colorf");
42
+ const utils_1 = require("./utils");
43
+ const fs = __importStar(require("fs"));
44
+ const path = __importStar(require("path"));
45
+ const vite_1 = require("vite");
46
+ const zstd_1 = require("@mongodb-js/zstd");
47
+ const sharp_1 = __importDefault(require("sharp"));
48
+ const png_to_ico_1 = __importDefault(require("png-to-ico"));
49
+ const packagers = {
50
+ windows: "../packagers/windows/main"
51
+ };
52
+ class Builder {
53
+ constructor(config) {
54
+ this.eziDevExePath = path.join(__dirname, "../bin/eziapp-dev.exe");
55
+ this.mode = config.mode || (0, utils_1.getArg)("--mode") || 'debug';
56
+ this.platform = config.platform || (0, utils_1.getArg)("--platform") || (0, utils_1.getCurrentPlatformName)();
57
+ this.viteConfigPath = path.join(process.cwd(), config.viteConfigPath ?? "vite.config.js");
58
+ this.eziConfigPath = path.join(process.cwd(), config.eziConfigPath ?? "ezi.config.ts");
59
+ this.outDir = path.join(process.cwd(), config.outDir ?? "build");
60
+ this.genTempFilePath = path.join(process.cwd(), config.genTempFilePath ?? "temp");
61
+ }
62
+ async LoadConfig() {
63
+ // vite config
64
+ let viteConfig = {};
65
+ try {
66
+ viteConfig = await Promise.resolve(`${this.viteConfigPath}`).then(s => __importStar(require(s)));
67
+ if (viteConfig.default) {
68
+ viteConfig = viteConfig.default;
69
+ }
70
+ }
71
+ catch (e) {
72
+ console.log((0, colorf_1.yellow)("! no vite.config.ts found, using default config."));
73
+ }
74
+ this.viteConfig = viteConfig;
75
+ // ezi config
76
+ let eziConfig = {};
77
+ try {
78
+ eziConfig = await Promise.resolve(`${this.eziConfigPath}`).then(s => __importStar(require(s)));
79
+ if (eziConfig.default) {
80
+ eziConfig = eziConfig.default;
81
+ }
82
+ }
83
+ catch (e) {
84
+ console.log((0, colorf_1.yellow)("! no ezi.config.ts found, using default config."));
85
+ eziConfig = {
86
+ application: {
87
+ name: "EziApplication",
88
+ package: "com.ezi.app",
89
+ },
90
+ window: {
91
+ title: "Ezi Application"
92
+ }
93
+ };
94
+ }
95
+ this.eziConfig = eziConfig;
96
+ }
97
+ async genAssets() {
98
+ const assetsMatas = {};
99
+ const assetsBinarys = [];
100
+ let offset = 0;
101
+ // 打包ezi配置文件
102
+ const configBuffer = await (0, zstd_1.compress)(Buffer.from(JSON.stringify(this.eziConfig), "utf-8"));
103
+ const configSize = configBuffer.length;
104
+ assetsMatas["ezi.config.manifest"] = { offset, size: configSize };
105
+ assetsBinarys.push(configBuffer);
106
+ offset += configSize;
107
+ // 打包资源文件
108
+ const assetsDir = path.join(process.cwd(), this.eziConfig.application.buildEntry || "dist");
109
+ console.log(`asset directory: ${this.eziConfig.application.buildEntry || "dist"}`);
110
+ const files = (0, utils_1.getAllFiles)(assetsDir);
111
+ for (const file of files) {
112
+ const filePath = path.join(assetsDir, file);
113
+ const stat = fs.statSync(filePath);
114
+ if (stat.isFile()) {
115
+ const packageName = this.eziConfig?.application?.package || "com.ezi.app";
116
+ const fileBuffer = await (0, zstd_1.compress)(fs.readFileSync(filePath));
117
+ const assetsId = `https://${packageName}/${file.split(path.sep).join("/")}`;
118
+ const size = fileBuffer.length;
119
+ assetsMatas[assetsId] = { offset, size };
120
+ assetsBinarys.push(fileBuffer);
121
+ offset += size;
122
+ }
123
+ }
124
+ // 打包清单文件
125
+ const manifestBuffer = await (0, zstd_1.compress)(Buffer.from(JSON.stringify(assetsMatas), "utf-8"));
126
+ const manifestSize = manifestBuffer.length;
127
+ if (manifestSize > 4294967295) {
128
+ throw new Error("Manifest size exceeds 4GB limit.");
129
+ }
130
+ assetsBinarys.push(manifestBuffer);
131
+ // 写入清单头
132
+ const manifestSizeFlag = 4;
133
+ const headerBuffer = Buffer.alloc(manifestSizeFlag);
134
+ headerBuffer.writeUInt32LE(manifestSize, 0);
135
+ assetsBinarys.push(headerBuffer);
136
+ if (!fs.existsSync(this.genTempFilePath)) {
137
+ fs.mkdirSync(this.genTempFilePath, { recursive: true });
138
+ }
139
+ fs.writeFileSync(path.join(this.genTempFilePath, 'ezi.assets.binary'), Buffer.concat(assetsBinarys));
140
+ console.log((0, colorf_1.green)("✓ assets generated."));
141
+ }
142
+ async genIcon() {
143
+ const iconPath = "public/" + this.eziConfig.application.icon;
144
+ if (!iconPath) {
145
+ return;
146
+ }
147
+ try {
148
+ const resizedPngBuffer = await (0, sharp_1.default)(iconPath)
149
+ .resize(256, 256, { fit: 'cover' })
150
+ .png()
151
+ .toBuffer();
152
+ const icoBuffer = await (0, png_to_ico_1.default)(resizedPngBuffer);
153
+ fs.writeFileSync(path.join(this.genTempFilePath, 'eziapp.ico'), icoBuffer);
154
+ console.log((0, colorf_1.green)("✓ icon generated."));
155
+ }
156
+ catch (err) {
157
+ console.error('Error generating icon:', err);
158
+ process.exit(1);
159
+ }
160
+ }
161
+ async build() {
162
+ const packagerPath = packagers[this.platform];
163
+ if (!packagerPath) {
164
+ console.error((0, colorf_1.red)(`✗ Unsupported platform: ${this.platform}`));
165
+ process.exit(1);
166
+ }
167
+ if (!this.eziConfig.application.buildEntry) {
168
+ this.eziConfig.application.buildEntry = this.viteConfig?.build?.outDir || "dist";
169
+ }
170
+ await (0, vite_1.build)(this.viteConfig);
171
+ await this.genAssets();
172
+ await this.genIcon();
173
+ const packagerModule = await Promise.resolve(`${path.join(__dirname, packagerPath)}`).then(s => __importStar(require(s)));
174
+ const PackagerClass = packagerModule.default;
175
+ const packager = new PackagerClass({
176
+ eziConfig: this.eziConfig,
177
+ outDir: this.outDir,
178
+ tempDir: this.genTempFilePath,
179
+ });
180
+ await packager.package();
181
+ console.log((0, colorf_1.green)("✓ build completed."));
182
+ }
183
+ async dev() {
184
+ const startTime = Date.now();
185
+ const server = await (0, vite_1.createServer)();
186
+ await server.listen();
187
+ const devEziConfig = structuredClone(this.eziConfig);
188
+ devEziConfig.application.package += ".debug";
189
+ if (!devEziConfig.application.devEntry) {
190
+ const info = server.httpServer?.address();
191
+ if (info && typeof info === "object") {
192
+ const port = info.port;
193
+ devEziConfig.application.devEntry = `http://localhost:${port}/`;
194
+ }
195
+ else {
196
+ throw new Error("Failed to get server address.");
197
+ }
198
+ }
199
+ const eziConfigJsonPath = path.join(this.genTempFilePath, "ezi.config.json");
200
+ if (!fs.existsSync(this.genTempFilePath)) {
201
+ fs.mkdirSync(this.genTempFilePath, { recursive: true });
202
+ }
203
+ fs.writeFileSync(eziConfigJsonPath, JSON.stringify(devEziConfig, null, 4), { encoding: "utf-8" });
204
+ const appName = devEziConfig?.application?.name || "EziApplication";
205
+ const child = (0, child_process_1.spawn)(this.eziDevExePath, [
206
+ '--configpath',
207
+ eziConfigJsonPath,
208
+ '--cwd',
209
+ process.cwd()
210
+ ], {
211
+ stdio: ["ignore", "pipe", "pipe"],
212
+ windowsHide: false
213
+ });
214
+ child.stdout?.on("data", (data) => {
215
+ process.stdout.write((0, utils_1.getCurrentTimeString)() + (0, colorf_1.bold)((0, colorf_1.blue)(` [${appName}] `)) + data);
216
+ });
217
+ const srcDir = path.join(process.cwd(), this.viteConfig?.root || "");
218
+ child.stderr?.on("data", (data) => {
219
+ const errorMsg = data.toString().replace("LOCATION_ORIGIN", srcDir.replaceAll("\\", "/"));
220
+ process.stderr.write((0, colorf_1.red)(errorMsg));
221
+ });
222
+ child.on("exit", (code) => {
223
+ console.log((0, utils_1.getCurrentTimeString)() + (0, colorf_1.bold)((0, colorf_1.blue)(` [${appName}] `)) + (0, colorf_1.yellow)(`process [pid:${child.pid}] exited with code ${code ?? 0}.`));
224
+ process.exit(0);
225
+ });
226
+ function printBoxedMessage(lines) {
227
+ const stripAnsi = (str) => str.replace(/\u001b\[[0-9;]*m/g, '');
228
+ const width = Math.max(...lines.map(line => stripAnsi(line).length));
229
+ const top = `╔${"═".repeat(width + 2)}╗`;
230
+ const bottom = `╚${"═".repeat(width + 2)}╝`;
231
+ const content = lines.map(line => `║ ${line.padEnd(width + (line.length - stripAnsi(line).length))} ║`);
232
+ console.log(top);
233
+ content.forEach(line => console.log(line));
234
+ console.log(bottom);
235
+ }
236
+ const viteVersion = require("vite/package.json").version;
237
+ printBoxedMessage([
238
+ `${(0, colorf_1.bold)((0, colorf_1.green)('VITE')) + (0, colorf_1.green)(' v' + viteVersion)} ready in ${(0, colorf_1.bold)((Date.now() - startTime).toString())} ms`,
239
+ ``,
240
+ ` ${(0, colorf_1.green)('➜')} ${(0, colorf_1.bold)('devEntry')}: ${(0, colorf_1.blue)((0, colorf_1.bold)(devEziConfig.application.devEntry))}`,
241
+ ` ${(0, colorf_1.green)("➜")} ${(0, colorf_1.bold)("EziApp")}: ${(0, colorf_1.bold)((0, colorf_1.blue)(appName))} ${(0, colorf_1.green)("running")} [pid:${(0, colorf_1.bold)("" + child.pid)}]`,
242
+ ` ${(0, colorf_1.green)("➜")} ${(0, colorf_1.bold)("Package")}: ${(0, colorf_1.green)(devEziConfig?.application?.package ?? "com.ezi.app")}`,
243
+ ` ${(0, colorf_1.green)("➜")} ${(0, colorf_1.bold)("Started")}: ${(0, colorf_1.blue)(new Date().toLocaleString())}`,
244
+ ]);
245
+ const cleanup = () => {
246
+ if (!child.killed) {
247
+ child.kill("SIGTERM");
248
+ }
249
+ server.close();
250
+ };
251
+ process.on("SIGINT", cleanup);
252
+ process.on("SIGTERM", cleanup);
253
+ process.on("exit", cleanup);
254
+ }
255
+ async main() {
256
+ console.log((0, colorf_1.yellow)("! EziApp 正在快速迭代中,当前 API 尚未稳定,请不要用于生产环境。"));
257
+ console.log((0, colorf_1.yellow)("! EziApp is rapidly evolving, the API is not yet stable, please do not use it in production."));
258
+ await this.LoadConfig();
259
+ switch (this.mode) {
260
+ case 'debug':
261
+ await this.dev();
262
+ break;
263
+ case 'release':
264
+ await this.build();
265
+ break;
266
+ default:
267
+ console.error((0, colorf_1.red)(`✗ Unsupported build mode: ${this.mode}`));
268
+ process.exit(1);
269
+ }
270
+ }
271
+ }
272
+ exports.Builder = Builder;
@@ -0,0 +1,5 @@
1
+ export declare function bold(text: string): string;
2
+ export declare function blue(text: string): string;
3
+ export declare function green(text: string): string;
4
+ export declare function red(text: string): string;
5
+ export declare function yellow(text: string): string;
@@ -0,0 +1,22 @@
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
+ }
@@ -0,0 +1,4 @@
1
+ export declare function getArg(key: string): string | null;
2
+ export declare function getCurrentTimeString(): string;
3
+ export declare function getAllFiles(dir: string, baseDir?: string): string[];
4
+ export declare function getCurrentPlatformName(): "linux" | "windows" | "macos";
@@ -0,0 +1,83 @@
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 () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.getArg = getArg;
37
+ exports.getCurrentTimeString = getCurrentTimeString;
38
+ exports.getAllFiles = getAllFiles;
39
+ exports.getCurrentPlatformName = getCurrentPlatformName;
40
+ const fs = __importStar(require("fs"));
41
+ const path = __importStar(require("path"));
42
+ function getArg(key) {
43
+ const argv = process.argv;
44
+ for (let i = 0; i < argv.length; i++) {
45
+ if (argv[i] === key && i + 1 < argv.length) {
46
+ return argv[i + 1];
47
+ }
48
+ }
49
+ return null;
50
+ }
51
+ function getCurrentTimeString() {
52
+ const now = new Date();
53
+ const pad = (n) => n.toString().padStart(2, "0");
54
+ return `${pad(now.getHours())}:${pad(now.getMinutes())}:${pad(now.getSeconds())}`;
55
+ }
56
+ function getAllFiles(dir, baseDir = dir) {
57
+ let results = [];
58
+ const list = fs.readdirSync(dir);
59
+ for (const file of list) {
60
+ const fullPath = path.join(dir, file);
61
+ const stat = fs.statSync(fullPath);
62
+ if (stat.isDirectory()) {
63
+ results = results.concat(getAllFiles(fullPath, baseDir));
64
+ }
65
+ else {
66
+ const relativePath = path.relative(baseDir, fullPath);
67
+ results.push(relativePath);
68
+ }
69
+ }
70
+ return results;
71
+ }
72
+ function getCurrentPlatformName() {
73
+ switch (process.platform) {
74
+ case "win32":
75
+ return "windows";
76
+ case "darwin":
77
+ return "macos";
78
+ case "linux":
79
+ return "linux";
80
+ default:
81
+ throw new Error(`Unsupported platform: ${process.platform}`);
82
+ }
83
+ }
package/package.json ADDED
@@ -0,0 +1,33 @@
1
+ {
2
+ "name": "@eziapp-org/builder",
3
+ "version": "0.0.0-beta.1",
4
+ "license": "MIT",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "https://github.com/eziapp-org/builder.git"
8
+ },
9
+ "main": "dist/index.js",
10
+ "types": "dist/index.d.ts",
11
+ "files": [
12
+ "dist/"
13
+ ],
14
+ "bin": {
15
+ "eziapp-builder": "dist/index.js"
16
+ },
17
+ "scripts": {
18
+ "build": "tsc",
19
+ "pack": "npm run build && npm pack && shx mv *.tgz packed/builder-latest.tgz",
20
+ "prepublishOnly": "npm run build"
21
+ },
22
+ "devDependencies": {
23
+ "@types/node": "^24.10.0",
24
+ "shx": "^0.4.0",
25
+ "typescript": "^5.9.3",
26
+ "vite": "^7.2.2"
27
+ },
28
+ "dependencies": {
29
+ "@mongodb-js/zstd": "^7.0.0",
30
+ "png-to-ico": "^3.0.1",
31
+ "sharp": "^0.34.5"
32
+ }
33
+ }