electronup 0.1.1 → 0.2.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/README.md +3 -3
- package/dist/bin/electronup.d.mts +1 -0
- package/dist/bin/electronup.mjs +494 -0
- package/dist/client/index.d.mts +36 -51
- package/dist/client/index.mjs +5 -5
- package/package.json +29 -24
- package/dist/bin/electronup.js +0 -510
- package/dist/client/index.d.ts +0 -78
- package/dist/client/index.js +0 -32
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# electronup
|
|
2
2
|
[](./LICENSE)  
|
|
3
3
|
|
|
4
|
-
> electronup 是一个集成 Vite4.x、
|
|
4
|
+
> electronup 是一个集成 Vite4.x、tsdown、electron-builder24.x 的桌面端构建工具,一个配置文件完成多环境多目标的构建包。
|
|
5
5
|
|
|
6
6
|
## 文档地址
|
|
7
7
|
|
|
@@ -24,7 +24,7 @@ pnpm add electronup -D
|
|
|
24
24
|
## 特性
|
|
25
25
|
|
|
26
26
|
- **多框架支持** : 使用 `create-electronup` 询问式创建项目模板 , 内置 `vue3` , `react` ,`solid` 等项目模板。
|
|
27
|
-
- **Vite +
|
|
27
|
+
- **Vite + tsdown** : 双进程热更新 , 快速开发(主进程代码修改会触发软件重启)。
|
|
28
28
|
- **统一的环境变量** : `dotenv` 加载 , 构建时注入 , 双进程拥有相同的环境变量。
|
|
29
29
|
- **模式构建** : 默认识别当前代码运行的平台输出打包程序 。
|
|
30
30
|
- **可选构建功能提示** : 你将获得可选范围内支持的功能提示 , 选项式自定义构建输出。
|
|
@@ -41,7 +41,7 @@ pnpm add electronup -D
|
|
|
41
41
|
> 已安装 18.0 或更高版本的 Node.js
|
|
42
42
|
|
|
43
43
|
|
|
44
|
-
因为使用了
|
|
44
|
+
因为使用了 tsdown 构建主进程代码,所以该命令行及脚手架只支持 TypeScript ,不支持 JavaScript。
|
|
45
45
|
|
|
46
46
|
## 示例
|
|
47
47
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1,494 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import path, { join, resolve } from "node:path";
|
|
4
|
+
import { cac } from "cac";
|
|
5
|
+
import process from "node:process";
|
|
6
|
+
import * as prompts from "@clack/prompts";
|
|
7
|
+
import { Arch, Platform, build } from "electron-builder";
|
|
8
|
+
import { pathExists, readJSON, writeFile } from "fs-extra";
|
|
9
|
+
import { blue, green, red, yellow } from "kolorist";
|
|
10
|
+
import { build as build$1, createServer } from "vite";
|
|
11
|
+
import { stringify } from "yaml";
|
|
12
|
+
import { parserConfig } from "@quiteer/parser-config";
|
|
13
|
+
import { spawn } from "node:child_process";
|
|
14
|
+
import { config } from "dotenv";
|
|
15
|
+
import electron from "electron";
|
|
16
|
+
import { getPortPromise } from "portfinder";
|
|
17
|
+
|
|
18
|
+
//#region package.json
|
|
19
|
+
var version = "0.2.1";
|
|
20
|
+
|
|
21
|
+
//#endregion
|
|
22
|
+
//#region utils/dirs.ts
|
|
23
|
+
let DefaultDirs = /* @__PURE__ */ function(DefaultDirs) {
|
|
24
|
+
DefaultDirs["renderDir"] = "render";
|
|
25
|
+
DefaultDirs["mainDir"] = "main";
|
|
26
|
+
DefaultDirs["publicDir"] = "public";
|
|
27
|
+
DefaultDirs["libDir"] = "lib";
|
|
28
|
+
DefaultDirs["resourceDir"] = "dist/resource";
|
|
29
|
+
DefaultDirs["outDir"] = "dist/out";
|
|
30
|
+
return DefaultDirs;
|
|
31
|
+
}({});
|
|
32
|
+
|
|
33
|
+
//#endregion
|
|
34
|
+
//#region utils/store.ts
|
|
35
|
+
var Store = class Store {
|
|
36
|
+
static instance;
|
|
37
|
+
command;
|
|
38
|
+
config;
|
|
39
|
+
mode;
|
|
40
|
+
minify;
|
|
41
|
+
port;
|
|
42
|
+
option;
|
|
43
|
+
win;
|
|
44
|
+
mac;
|
|
45
|
+
linux;
|
|
46
|
+
dir;
|
|
47
|
+
asar;
|
|
48
|
+
targets;
|
|
49
|
+
static getInstance() {
|
|
50
|
+
if (this.instance) return this.instance;
|
|
51
|
+
return this.instance = new Store();
|
|
52
|
+
}
|
|
53
|
+
get root() {
|
|
54
|
+
return process.cwd();
|
|
55
|
+
}
|
|
56
|
+
get isWin() {
|
|
57
|
+
return process.platform === "win32";
|
|
58
|
+
}
|
|
59
|
+
get isMac() {
|
|
60
|
+
return process.platform === "darwin";
|
|
61
|
+
}
|
|
62
|
+
get isLinux() {
|
|
63
|
+
return process.platform === "linux";
|
|
64
|
+
}
|
|
65
|
+
get currentArch() {
|
|
66
|
+
switch (process.arch) {
|
|
67
|
+
case "ia32": return Arch.ia32;
|
|
68
|
+
case "x64": return Arch.x64;
|
|
69
|
+
case "arm64": return Arch.arm64;
|
|
70
|
+
case "arm": return Arch.armv7l;
|
|
71
|
+
default: return Arch.x64;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
const store = Store.getInstance();
|
|
76
|
+
|
|
77
|
+
//#endregion
|
|
78
|
+
//#region transform/getConfig.ts
|
|
79
|
+
const NOT_FOUND = "找不到 electronup.config.ts | electronup.config.js | electronup.config.json , 请在根目录下添加配置文件 , 或显式的指定配置文件路径(相对于根目录)";
|
|
80
|
+
const PARSING_FAILED = "找到了配置文件,但解析配置文件失败!";
|
|
81
|
+
async function configPath(filePath) {
|
|
82
|
+
const { root } = store;
|
|
83
|
+
if (filePath) return join(root, filePath);
|
|
84
|
+
const configList = [
|
|
85
|
+
"ts",
|
|
86
|
+
"mjs",
|
|
87
|
+
"cjs",
|
|
88
|
+
"js"
|
|
89
|
+
].map((suffix) => `${join(root, "electronup.config")}.${suffix}`);
|
|
90
|
+
const index = (await Promise.all(configList.map((path) => pathExists(path)))).findIndex((flag) => flag);
|
|
91
|
+
if (index > -1) return configList[index];
|
|
92
|
+
throw new Error(NOT_FOUND);
|
|
93
|
+
}
|
|
94
|
+
async function getConfig(filePath) {
|
|
95
|
+
const path = await configPath(filePath);
|
|
96
|
+
try {
|
|
97
|
+
return await parserConfig(path, "electronup.config");
|
|
98
|
+
} catch (error) {
|
|
99
|
+
console.error("error :>> ", error);
|
|
100
|
+
throw new Error(PARSING_FAILED);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
//#endregion
|
|
105
|
+
//#region configs/builder.ts
|
|
106
|
+
/**
|
|
107
|
+
* CliOptions 配置直接
|
|
108
|
+
*/
|
|
109
|
+
async function getBuilderConfig(config, allConfig) {
|
|
110
|
+
const packages = await readJSON(resolve(store.root, "package.json"));
|
|
111
|
+
const defaultConfig = {
|
|
112
|
+
asar: store.asar,
|
|
113
|
+
appId: "org.quiteer.electronup",
|
|
114
|
+
productName: packages.name,
|
|
115
|
+
protocols: {
|
|
116
|
+
name: packages.name,
|
|
117
|
+
schemes: ["deeplink"]
|
|
118
|
+
},
|
|
119
|
+
nsis: {
|
|
120
|
+
oneClick: false,
|
|
121
|
+
language: "2052",
|
|
122
|
+
perMachine: true,
|
|
123
|
+
allowElevation: true,
|
|
124
|
+
allowToChangeInstallationDirectory: true,
|
|
125
|
+
runAfterFinish: true,
|
|
126
|
+
createDesktopShortcut: true,
|
|
127
|
+
createStartMenuShortcut: true,
|
|
128
|
+
artifactName: `${packages.name} \${arch} Setup ${packages.version}.\${ext}`
|
|
129
|
+
},
|
|
130
|
+
files: [`${allConfig.resourceDir || DefaultDirs.resourceDir}/**/*`],
|
|
131
|
+
extraFiles: [allConfig.libDir || DefaultDirs.libDir],
|
|
132
|
+
directories: { output: allConfig.outDir || config.directories?.output || DefaultDirs.outDir },
|
|
133
|
+
...config
|
|
134
|
+
};
|
|
135
|
+
return {
|
|
136
|
+
targets: store.targets,
|
|
137
|
+
config: defaultConfig
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
//#endregion
|
|
142
|
+
//#region configs/tsdown.ts
|
|
143
|
+
/**
|
|
144
|
+
* Description 全局的环境变量路径
|
|
145
|
+
* @param {any} store.root
|
|
146
|
+
* @param {any} '.env'
|
|
147
|
+
* @returns {any}
|
|
148
|
+
*/
|
|
149
|
+
const defaultEnvPath = resolve(store.root, ".env");
|
|
150
|
+
/**
|
|
151
|
+
* Description 加载环境变量
|
|
152
|
+
* @param {any} {path:defaultEnvPath}
|
|
153
|
+
* @returns {any}
|
|
154
|
+
*/
|
|
155
|
+
const { parsed: defaultEnv } = config({ path: defaultEnvPath });
|
|
156
|
+
/**
|
|
157
|
+
* Description 加载默认环境变量及mode下的环境变量
|
|
158
|
+
* @returns {any}
|
|
159
|
+
*/
|
|
160
|
+
function getModeDev() {
|
|
161
|
+
const { parsed, error } = config({ path: `${defaultEnvPath}.${store.mode}` });
|
|
162
|
+
if (error) throw new Error(`未能加载 .env.${store.mode} 下的环境变量,检查文件是否存在!`);
|
|
163
|
+
return {
|
|
164
|
+
...defaultEnv,
|
|
165
|
+
...parsed
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Description 插入环境变量
|
|
170
|
+
* @returns {any}
|
|
171
|
+
*/
|
|
172
|
+
function injectEnv() {
|
|
173
|
+
const { command, port } = store;
|
|
174
|
+
const env = getModeDev();
|
|
175
|
+
if (command === "serve") return {
|
|
176
|
+
...env,
|
|
177
|
+
NODE_ENV: "development",
|
|
178
|
+
RENDER_PORT: String(port)
|
|
179
|
+
};
|
|
180
|
+
return {
|
|
181
|
+
...env,
|
|
182
|
+
NODE_ENV: "production"
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Description 主进程代码编译配置
|
|
187
|
+
* @param {any} config:TsdownConfig
|
|
188
|
+
* @param {any} allConfig:ElectronupConfig
|
|
189
|
+
* @returns {any}
|
|
190
|
+
*/
|
|
191
|
+
function getTsdownConfig(config, allConfig) {
|
|
192
|
+
const { command, root, minify } = store;
|
|
193
|
+
const isServe = command === "serve";
|
|
194
|
+
return {
|
|
195
|
+
minify: minify === false ? false : isServe,
|
|
196
|
+
external: ["electron", ...config.external ?? []],
|
|
197
|
+
noExternal: config.noExternal,
|
|
198
|
+
entry: { electron: resolve(root, allConfig.mainDir || DefaultDirs.mainDir, "index.ts") },
|
|
199
|
+
outDir: allConfig.resourceDir || DefaultDirs.resourceDir,
|
|
200
|
+
watch: isServe,
|
|
201
|
+
dts: false,
|
|
202
|
+
clean: false,
|
|
203
|
+
env: injectEnv(),
|
|
204
|
+
async onSuccess() {
|
|
205
|
+
if (isServe) return startElectron(resolve(root, allConfig.resourceDir || DefaultDirs.resourceDir, "electron.mjs"));
|
|
206
|
+
}
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
let electronProcess;
|
|
210
|
+
let manualRestart = false;
|
|
211
|
+
/**
|
|
212
|
+
* Description 启动electron
|
|
213
|
+
* @param {any} mainPath:string
|
|
214
|
+
* @returns {any}
|
|
215
|
+
*/
|
|
216
|
+
function startElectron(mainPath) {
|
|
217
|
+
if (electronProcess) {
|
|
218
|
+
manualRestart = true;
|
|
219
|
+
electronProcess.pid && process.kill(electronProcess.pid);
|
|
220
|
+
electronProcess = null;
|
|
221
|
+
setTimeout(() => {
|
|
222
|
+
manualRestart = false;
|
|
223
|
+
}, 5e3);
|
|
224
|
+
}
|
|
225
|
+
electronProcess = spawn(electron, [mainPath]);
|
|
226
|
+
electronProcess.stdout.on("data", removeJunk);
|
|
227
|
+
electronProcess.stderr.on("data", removeJunk);
|
|
228
|
+
electronProcess.on("close", () => {
|
|
229
|
+
manualRestart || process.exit();
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
function removeJunk(chunk) {
|
|
233
|
+
if (/\d+-\d+-\d+ \d+:\d+:\d+\.\d+ Electron(?: Helper)?\[\d+:\d+\] /.test(chunk)) return false;
|
|
234
|
+
if (/\[\d+:\d+\/|\d+\.\d+:ERROR:CONSOLE\(\d+\)\]/.test(chunk)) return false;
|
|
235
|
+
if (/ALSA lib [a-z]+\.c:\d+:\([a-z_]+\)/.test(chunk)) return false;
|
|
236
|
+
const data = chunk.toString().split(/\r?\n/);
|
|
237
|
+
let log = "";
|
|
238
|
+
data.forEach((line) => {
|
|
239
|
+
log += ` ${line}\n`;
|
|
240
|
+
});
|
|
241
|
+
console.info(log);
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
//#endregion
|
|
245
|
+
//#region configs/vite.ts
|
|
246
|
+
function getViteConfig(config, allConfig) {
|
|
247
|
+
const { root, minify } = store;
|
|
248
|
+
return {
|
|
249
|
+
base: "./",
|
|
250
|
+
...config,
|
|
251
|
+
build: {
|
|
252
|
+
...config?.build,
|
|
253
|
+
minify: !!minify,
|
|
254
|
+
outDir: resolve(root, allConfig.resourceDir || DefaultDirs.resourceDir)
|
|
255
|
+
},
|
|
256
|
+
root: allConfig.renderDir || DefaultDirs.renderDir,
|
|
257
|
+
publicDir: resolve(root, allConfig.publicDir || DefaultDirs.publicDir)
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
//#endregion
|
|
262
|
+
//#region configs/electronup.ts
|
|
263
|
+
async function getElectronupConfig(config) {
|
|
264
|
+
const { viteConfig, tsdownConfig, preload, builderConfig, ...dirConfig } = config;
|
|
265
|
+
const initConfig = {
|
|
266
|
+
vite: getViteConfig(viteConfig || {}, config),
|
|
267
|
+
tsdown: getTsdownConfig(tsdownConfig || {}, config)
|
|
268
|
+
};
|
|
269
|
+
if (store.command === "build") initConfig.builder = await getBuilderConfig(builderConfig, config);
|
|
270
|
+
preload && (initConfig.preload = preload);
|
|
271
|
+
return {
|
|
272
|
+
...dirConfig,
|
|
273
|
+
...initConfig
|
|
274
|
+
};
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
//#endregion
|
|
278
|
+
//#region transform/getExportConfig.ts
|
|
279
|
+
/**
|
|
280
|
+
* Description 解析用户自定义配置···
|
|
281
|
+
* @param {any} config:ElectronupConfigExport
|
|
282
|
+
* @returns {any}
|
|
283
|
+
*/
|
|
284
|
+
async function exportElectronupConfig(config) {
|
|
285
|
+
const typeStr = typeof config;
|
|
286
|
+
if (typeStr === "function") return await config({
|
|
287
|
+
command: store.command,
|
|
288
|
+
root: store.root
|
|
289
|
+
});
|
|
290
|
+
if (typeStr === "object") return config;
|
|
291
|
+
throw new Error("electronup 配置错误,解析失败!");
|
|
292
|
+
}
|
|
293
|
+
const electronupConfig = async (config) => getElectronupConfig(await exportElectronupConfig(config));
|
|
294
|
+
|
|
295
|
+
//#endregion
|
|
296
|
+
//#region runner/build.ts
|
|
297
|
+
const platformSelect = [
|
|
298
|
+
{
|
|
299
|
+
name: "Windows",
|
|
300
|
+
platform: "win32",
|
|
301
|
+
createTarget: (archs) => {
|
|
302
|
+
if (archs.length) return Platform.WINDOWS.createTarget(store.dir, ...archs);
|
|
303
|
+
return Platform.WINDOWS.createTarget(store.dir, Arch.ia32, Arch.x64);
|
|
304
|
+
},
|
|
305
|
+
color: blue,
|
|
306
|
+
disabled: !(store.isMac || store.isWin),
|
|
307
|
+
archs: [{
|
|
308
|
+
name: "x64",
|
|
309
|
+
arch: Arch.x64,
|
|
310
|
+
disabled: store.currentArch === Arch.ia32,
|
|
311
|
+
color: blue
|
|
312
|
+
}, {
|
|
313
|
+
name: "ia32",
|
|
314
|
+
arch: Arch.ia32,
|
|
315
|
+
color: blue,
|
|
316
|
+
disabled: false
|
|
317
|
+
}]
|
|
318
|
+
},
|
|
319
|
+
{
|
|
320
|
+
name: "MacOS",
|
|
321
|
+
platform: "darwin",
|
|
322
|
+
createTarget: (archs) => {
|
|
323
|
+
if (archs.length) return Platform.MAC.createTarget(store.dir, store.currentArch);
|
|
324
|
+
return Platform.MAC.createTarget(store.dir, ...archs);
|
|
325
|
+
},
|
|
326
|
+
disabled: !store.isMac,
|
|
327
|
+
color: green,
|
|
328
|
+
archs: [
|
|
329
|
+
{
|
|
330
|
+
name: "x64",
|
|
331
|
+
arch: Arch.x64,
|
|
332
|
+
disabled: false,
|
|
333
|
+
color: green
|
|
334
|
+
},
|
|
335
|
+
{
|
|
336
|
+
name: "arm64",
|
|
337
|
+
arch: Arch.arm64,
|
|
338
|
+
disabled: false,
|
|
339
|
+
color: green
|
|
340
|
+
},
|
|
341
|
+
{
|
|
342
|
+
name: "universal",
|
|
343
|
+
arch: Arch.universal,
|
|
344
|
+
disabled: false,
|
|
345
|
+
color: green
|
|
346
|
+
}
|
|
347
|
+
]
|
|
348
|
+
},
|
|
349
|
+
{
|
|
350
|
+
name: "Linux",
|
|
351
|
+
platform: "linux",
|
|
352
|
+
disabled: !(store.isMac || store.isLinux),
|
|
353
|
+
createTarget: (archs) => {
|
|
354
|
+
if (archs.length) return Platform.LINUX.createTarget(store.dir, store.currentArch);
|
|
355
|
+
return Platform.LINUX.createTarget(store.dir, ...archs);
|
|
356
|
+
},
|
|
357
|
+
color: yellow,
|
|
358
|
+
archs: [
|
|
359
|
+
{
|
|
360
|
+
name: "x64",
|
|
361
|
+
arch: Arch.x64,
|
|
362
|
+
disabled: false,
|
|
363
|
+
color: yellow
|
|
364
|
+
},
|
|
365
|
+
{
|
|
366
|
+
name: "arm64",
|
|
367
|
+
arch: Arch.arm64,
|
|
368
|
+
disabled: false,
|
|
369
|
+
color: yellow
|
|
370
|
+
},
|
|
371
|
+
{
|
|
372
|
+
name: "armv7l",
|
|
373
|
+
arch: Arch.armv7l,
|
|
374
|
+
disabled: false,
|
|
375
|
+
color: yellow
|
|
376
|
+
}
|
|
377
|
+
]
|
|
378
|
+
}
|
|
379
|
+
];
|
|
380
|
+
async function build$2(options) {
|
|
381
|
+
if (store.option) try {
|
|
382
|
+
const isMinify = await prompts.confirm({ message: green("是否压缩代码?") });
|
|
383
|
+
if (prompts.isCancel(isMinify)) throw new Error(`${red("✖")} Operation cancelled`);
|
|
384
|
+
const isPackage = await prompts.confirm({ message: blue("是否生成安装包?") });
|
|
385
|
+
if (prompts.isCancel(isPackage)) throw new Error(`${red("✖")} Operation cancelled`);
|
|
386
|
+
const platform = await prompts.select({
|
|
387
|
+
message: "请选择构建模式 ~",
|
|
388
|
+
options: platformSelect.map((item) => ({
|
|
389
|
+
label: item.color(item.name),
|
|
390
|
+
value: item,
|
|
391
|
+
disabled: item.disabled
|
|
392
|
+
}))
|
|
393
|
+
});
|
|
394
|
+
if (prompts.isCancel(platform)) throw new Error(`${red("✖")} Operation cancelled`);
|
|
395
|
+
const selectedPlatform = platform;
|
|
396
|
+
const arch = await prompts.multiselect({
|
|
397
|
+
message: "请选择打包架构~",
|
|
398
|
+
options: selectedPlatform.archs?.map((item) => ({
|
|
399
|
+
label: item.color(item.name),
|
|
400
|
+
value: item.arch,
|
|
401
|
+
disabled: item.disabled
|
|
402
|
+
})) || []
|
|
403
|
+
});
|
|
404
|
+
if (prompts.isCancel(arch)) throw new Error(`${red("✖")} Operation cancelled`);
|
|
405
|
+
store.minify = isMinify;
|
|
406
|
+
store.dir = isPackage ? null : "dir";
|
|
407
|
+
store.targets = selectedPlatform.createTarget(arch);
|
|
408
|
+
} catch (cancelled) {
|
|
409
|
+
console.error("err: ", cancelled.message);
|
|
410
|
+
process.exit(1);
|
|
411
|
+
}
|
|
412
|
+
else {
|
|
413
|
+
if (store.isWin) if (store.win === "ia32") store.targets = Platform.WINDOWS.createTarget(store.dir, Arch.ia32);
|
|
414
|
+
else if (store.win === "x64") store.targets = Platform.WINDOWS.createTarget(store.dir, Arch.x64);
|
|
415
|
+
else store.targets = Platform.WINDOWS.createTarget(store.dir, store.currentArch);
|
|
416
|
+
if (store.isMac) if (store.win) if (store.win === "ia32") store.targets = Platform.WINDOWS.createTarget(store.dir, Arch.ia32);
|
|
417
|
+
else if (store.win === "x64") store.targets = Platform.WINDOWS.createTarget(store.dir, Arch.x64);
|
|
418
|
+
else store.targets = Platform.WINDOWS.createTarget(store.dir, store.currentArch);
|
|
419
|
+
else if (store.mac) if (store.mac === "x64") store.targets = Platform.MAC.createTarget(store.dir, Arch.x64);
|
|
420
|
+
else if (store.mac === "arm64") store.targets = Platform.MAC.createTarget(store.dir, Arch.arm64);
|
|
421
|
+
else if (store.mac === "universal") store.targets = Platform.MAC.createTarget(store.dir, Arch.universal);
|
|
422
|
+
else store.targets = Platform.MAC.createTarget(store.dir, store.currentArch);
|
|
423
|
+
else if (store.linux) if (store.linux === true) store.targets = Platform.LINUX.createTarget(store.dir);
|
|
424
|
+
else store.targets = Platform.LINUX.createTarget(store.dir, store.currentArch);
|
|
425
|
+
else store.targets = Platform.MAC.createTarget(store.dir, store.currentArch);
|
|
426
|
+
else if (store.isLinux) store.targets = Platform.LINUX.createTarget(store.dir, Arch.armv7l);
|
|
427
|
+
}
|
|
428
|
+
const initConfig = await electronupConfig(options);
|
|
429
|
+
await build$1(initConfig.vite);
|
|
430
|
+
const { build: tsBuild } = await import("tsdown");
|
|
431
|
+
await tsBuild(initConfig.tsdown);
|
|
432
|
+
await build(initConfig.builder);
|
|
433
|
+
await writeFile(path.resolve(store.root, options.outDir || DefaultDirs.outDir, "electronup-effective-config.yaml"), stringify(JSON.parse(JSON.stringify(initConfig))));
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
//#endregion
|
|
437
|
+
//#region runner/watch.ts
|
|
438
|
+
async function watch(options) {
|
|
439
|
+
const p = await getPortPromise({ port: Number(store.port) });
|
|
440
|
+
store.port = p;
|
|
441
|
+
const initConfig = await electronupConfig(options);
|
|
442
|
+
const viteDevServer = await createServer({
|
|
443
|
+
configFile: false,
|
|
444
|
+
...initConfig.vite
|
|
445
|
+
});
|
|
446
|
+
viteDevServer.listen(p).then(viteDevServer.printUrls);
|
|
447
|
+
const { build } = await import("tsdown");
|
|
448
|
+
build(initConfig.tsdown);
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
//#endregion
|
|
452
|
+
//#region cli.ts
|
|
453
|
+
const cli = cac("electronup");
|
|
454
|
+
cli.option("-m , --mode <mode>", "[development | production | test | staging | ...] 环境模式 ");
|
|
455
|
+
cli.option("--no-minify", "使主进程和渲染进程代码不进行压缩 ");
|
|
456
|
+
cli.command("[config-file]", "等同于electronup dev ,启动开发环境热更新").alias("dev").option("-p , --port <port>", "[number] 渲染进程的端口号 ,如果占用会切换非占用的端口 ").action(async (configFile, options) => {
|
|
457
|
+
const { mode, port, minify } = options;
|
|
458
|
+
const option = await getConfig(configFile);
|
|
459
|
+
emptyDir(resolve(store.root, option.resourceDir || DefaultDirs.resourceDir));
|
|
460
|
+
store.command = "serve";
|
|
461
|
+
store.mode = mode || "development";
|
|
462
|
+
store.port = port || 8090;
|
|
463
|
+
store.minify = !!minify;
|
|
464
|
+
watch(option);
|
|
465
|
+
});
|
|
466
|
+
cli.command("build [root]", "开始构建服务 , 若不指定平台则默认当前操作系统的架构类型").option("-o , --option", "自定义 , 自定义构建选项 ").option("--dir", "只生成目录").option("--no-asar", "asar false").option("--win [arch]", "[ia32 | x64] 构建 win 平台下的输出包 , 不指定架构则输出 ia32 和 x64的两个包").option("--mac [arch]", "[x64 | arm64 | universal] 构建 mac 平台下的输出包 , 若不指定架构则默认当前操作系统的架构类型").option("--linux", "[x64 | arm64 | armv7l] 构建 linux 平台下的输出包 , 若不指定架构则默认当前操作系统的架构类型").action(async (configFile, options) => {
|
|
467
|
+
const { mode, minify, option, win, mac, linux, dir, asar } = options;
|
|
468
|
+
const configOption = await getConfig(configFile);
|
|
469
|
+
emptyDir(resolve(store.root, configOption.resourceDir || DefaultDirs.resourceDir));
|
|
470
|
+
emptyDir(resolve(store.root, configOption.outDir || DefaultDirs.outDir));
|
|
471
|
+
store.command = "build";
|
|
472
|
+
store.mode = mode || "production";
|
|
473
|
+
store.minify = minify;
|
|
474
|
+
store.option = !!option;
|
|
475
|
+
store.dir = dir ? "dir" : null;
|
|
476
|
+
store.asar = asar;
|
|
477
|
+
store.win = win;
|
|
478
|
+
store.mac = mac;
|
|
479
|
+
store.linux = linux;
|
|
480
|
+
build$2(configOption);
|
|
481
|
+
});
|
|
482
|
+
cli.help();
|
|
483
|
+
cli.version(version);
|
|
484
|
+
cli.parse();
|
|
485
|
+
function emptyDir(dir) {
|
|
486
|
+
if (!fs.existsSync(dir)) return;
|
|
487
|
+
for (const file of fs.readdirSync(dir)) fs.rmSync(resolve(dir, file), {
|
|
488
|
+
recursive: true,
|
|
489
|
+
force: true
|
|
490
|
+
});
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
//#endregion
|
|
494
|
+
export { };
|
package/dist/client/index.d.mts
CHANGED
|
@@ -1,78 +1,63 @@
|
|
|
1
|
-
import { Configuration } from
|
|
2
|
-
import { UserConfig } from
|
|
3
|
-
import {
|
|
1
|
+
import { Configuration } from "electron-builder";
|
|
2
|
+
import { UserConfig } from "tsdown";
|
|
3
|
+
import { UserConfig as UserConfig$1 } from "vite";
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
interface
|
|
5
|
+
//#region typings/electronup.d.ts
|
|
6
|
+
interface ViteConfig extends Omit<UserConfig$1, 'publicDir' | 'ssr'> {}
|
|
7
|
+
interface TsdownConfig {
|
|
8
8
|
external?: (string | RegExp)[];
|
|
9
9
|
noExternal?: (string | RegExp)[];
|
|
10
10
|
}
|
|
11
|
-
|
|
12
|
-
interface BuilderConfig extends Configuration { }
|
|
13
|
-
|
|
11
|
+
interface BuilderConfig extends Configuration {}
|
|
14
12
|
interface ElectronupConfig {
|
|
15
|
-
viteConfig?: ViteConfig
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
builderConfig: BuilderConfig
|
|
19
|
-
|
|
13
|
+
viteConfig?: ViteConfig;
|
|
14
|
+
tsdownConfig?: TsdownConfig;
|
|
15
|
+
preload?: UserConfig | UserConfig[];
|
|
16
|
+
builderConfig: BuilderConfig;
|
|
20
17
|
/**
|
|
21
18
|
* 渲染进程入口目录
|
|
22
19
|
* @default 'render'
|
|
23
20
|
*/
|
|
24
|
-
renderDir?: string
|
|
25
|
-
|
|
21
|
+
renderDir?: string;
|
|
26
22
|
/**
|
|
27
23
|
* 主进程入口目录
|
|
28
24
|
* @default 'main'
|
|
29
25
|
*/
|
|
30
|
-
mainDir?: string
|
|
31
|
-
|
|
26
|
+
mainDir?: string;
|
|
32
27
|
/**
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
publicDir?: string
|
|
37
|
-
|
|
28
|
+
* 静态资源目录
|
|
29
|
+
* @default 'public'
|
|
30
|
+
*/
|
|
31
|
+
publicDir?: string;
|
|
38
32
|
/**
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
libDir?: string
|
|
43
|
-
|
|
33
|
+
* 动态库目录
|
|
34
|
+
* @default 'lib'
|
|
35
|
+
*/
|
|
36
|
+
libDir?: string;
|
|
44
37
|
/**
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
resourceDir?: string
|
|
49
|
-
|
|
38
|
+
* 资源构建输出目录
|
|
39
|
+
* @default 'dist'
|
|
40
|
+
*/
|
|
41
|
+
resourceDir?: string;
|
|
50
42
|
/**
|
|
51
43
|
* electron-builder 输出目录
|
|
52
44
|
* @default 'out'
|
|
53
45
|
*/
|
|
54
|
-
outDir?: string
|
|
46
|
+
outDir?: string;
|
|
55
47
|
}
|
|
56
|
-
|
|
57
48
|
interface ConfigEnv {
|
|
58
|
-
command: 'build' | 'serve'
|
|
59
|
-
root: string
|
|
49
|
+
command: 'build' | 'serve';
|
|
50
|
+
root: string;
|
|
60
51
|
}
|
|
61
|
-
|
|
62
|
-
type
|
|
63
|
-
type
|
|
64
|
-
type
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
| ElectronupConfig
|
|
68
|
-
| Promise<ElectronupConfig>
|
|
69
|
-
| ElectronupConfigFnObject
|
|
70
|
-
| ElectronupConfigFnPromise
|
|
71
|
-
| ElectronupConfigFn
|
|
72
|
-
|
|
52
|
+
type ElectronupConfigFnObject = (env: ConfigEnv) => ElectronupConfig;
|
|
53
|
+
type ElectronupConfigFnPromise = (env: ConfigEnv) => Promise<ElectronupConfig>;
|
|
54
|
+
type ElectronupConfigFn = (env: ConfigEnv) => ElectronupConfig | Promise<ElectronupConfig>;
|
|
55
|
+
type ElectronupConfigExport = ElectronupConfig | Promise<ElectronupConfig> | ElectronupConfigFnObject | ElectronupConfigFnPromise | ElectronupConfigFn;
|
|
56
|
+
//#endregion
|
|
57
|
+
//#region index.d.ts
|
|
73
58
|
declare function defineConfig(config: ElectronupConfig): ElectronupConfig;
|
|
74
59
|
declare function defineConfig(config: Promise<ElectronupConfig>): Promise<ElectronupConfig>;
|
|
75
60
|
declare function defineConfig(config: ElectronupConfigFnObject): ElectronupConfigFnObject;
|
|
76
61
|
declare function defineConfig(config: ElectronupConfigExport): ElectronupConfigExport;
|
|
77
|
-
|
|
78
|
-
export { type BuilderConfig, type ConfigEnv, type ElectronupConfig, type
|
|
62
|
+
//#endregion
|
|
63
|
+
export { type BuilderConfig, type ConfigEnv, type ElectronupConfig, type TsdownConfig, type ViteConfig, defineConfig };
|
package/dist/client/index.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "electronup",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "融合构建 electron 应用需要的构建工具,保留原有配置习惯的命令行工具 ",
|
|
5
5
|
"author": "quiteer",
|
|
6
6
|
"license": "MIT",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
},
|
|
15
15
|
"keywords": [
|
|
16
16
|
"vite",
|
|
17
|
-
"
|
|
17
|
+
"tsdown",
|
|
18
18
|
"electron-builder",
|
|
19
19
|
"electron"
|
|
20
20
|
],
|
|
@@ -22,38 +22,43 @@
|
|
|
22
22
|
"access": "public",
|
|
23
23
|
"registry": "https://registry.npmjs.org/"
|
|
24
24
|
},
|
|
25
|
-
"
|
|
25
|
+
"exports": {
|
|
26
|
+
".": {
|
|
27
|
+
"types": "./dist/client/index.d.mts",
|
|
28
|
+
"import": "./dist/client/index.mjs"
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
"main": "dist/client/index.mjs",
|
|
26
32
|
"module": "dist/client/index.mjs",
|
|
27
|
-
"types": "dist/client/index.d.
|
|
33
|
+
"types": "dist/client/index.d.mts",
|
|
28
34
|
"bin": {
|
|
29
|
-
"electronup": "dist/bin/electronup.
|
|
35
|
+
"electronup": "dist/bin/electronup.mjs"
|
|
30
36
|
},
|
|
31
37
|
"files": [
|
|
32
38
|
"dist"
|
|
33
39
|
],
|
|
34
|
-
"scripts": {
|
|
35
|
-
"dev": "tsup --watch",
|
|
36
|
-
"build": "tsup",
|
|
37
|
-
"update-version": "bumpp package.json"
|
|
38
|
-
},
|
|
39
40
|
"peerDependencies": {
|
|
40
|
-
"@types/node": ">=
|
|
41
|
-
"node": ">=
|
|
41
|
+
"@types/node": ">= 22",
|
|
42
|
+
"node": ">= 22",
|
|
42
43
|
"vue": ">= 3"
|
|
43
44
|
},
|
|
44
45
|
"dependencies": {
|
|
46
|
+
"@clack/prompts": "^1.1.0",
|
|
45
47
|
"@quiteer/parser-config": "^1.0.3",
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"electron": "^
|
|
50
|
-
"
|
|
51
|
-
"fs-extra": "^11.2.0",
|
|
48
|
+
"cac": "^7.0.0",
|
|
49
|
+
"dotenv": "^17.3.1",
|
|
50
|
+
"electron": "^40.6.1",
|
|
51
|
+
"electron-builder": "^26.8.1",
|
|
52
|
+
"fs-extra": "^11.3.3",
|
|
52
53
|
"kolorist": "^1.8.0",
|
|
53
|
-
"portfinder": "^1.0.
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
"
|
|
57
|
-
|
|
54
|
+
"portfinder": "^1.0.38",
|
|
55
|
+
"tsdown": "^0.20.3",
|
|
56
|
+
"vite": "^8.0.0-beta.13",
|
|
57
|
+
"yaml": "^2.8.2"
|
|
58
|
+
},
|
|
59
|
+
"scripts": {
|
|
60
|
+
"dev": "tsdown --watch",
|
|
61
|
+
"build": "tsdown",
|
|
62
|
+
"release": "qui r --tag-prefix electronup && tsdown && pnpm publish"
|
|
58
63
|
}
|
|
59
|
-
}
|
|
64
|
+
}
|
package/dist/bin/electronup.js
DELETED
|
@@ -1,510 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
"use strict";
|
|
3
|
-
var __create = Object.create;
|
|
4
|
-
var __defProp = Object.defineProperty;
|
|
5
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
18
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
19
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
20
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
21
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
22
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
23
|
-
mod
|
|
24
|
-
));
|
|
25
|
-
|
|
26
|
-
// cli.ts
|
|
27
|
-
var import_node_path = require("path");
|
|
28
|
-
var import_node_fs = __toESM(require("fs"));
|
|
29
|
-
var import_cac = require("cac");
|
|
30
|
-
|
|
31
|
-
// package.json
|
|
32
|
-
var version = "0.1.1";
|
|
33
|
-
|
|
34
|
-
// transform/getConfig.ts
|
|
35
|
-
var import_path = require("path");
|
|
36
|
-
var import_fs_extra = require("fs-extra");
|
|
37
|
-
var import_parser_config = require("@quiteer/parser-config");
|
|
38
|
-
|
|
39
|
-
// utils/store.ts
|
|
40
|
-
var Store = class _Store {
|
|
41
|
-
static instance;
|
|
42
|
-
command;
|
|
43
|
-
config;
|
|
44
|
-
mode;
|
|
45
|
-
minify;
|
|
46
|
-
port;
|
|
47
|
-
option;
|
|
48
|
-
win;
|
|
49
|
-
mac;
|
|
50
|
-
linux;
|
|
51
|
-
dir;
|
|
52
|
-
asar;
|
|
53
|
-
targets;
|
|
54
|
-
static getInstance() {
|
|
55
|
-
if (this.instance)
|
|
56
|
-
return this.instance;
|
|
57
|
-
return this.instance = new _Store();
|
|
58
|
-
}
|
|
59
|
-
get root() {
|
|
60
|
-
return process.cwd();
|
|
61
|
-
}
|
|
62
|
-
get isWin() {
|
|
63
|
-
return process.platform === "win32";
|
|
64
|
-
}
|
|
65
|
-
get isMac() {
|
|
66
|
-
return process.platform === "darwin";
|
|
67
|
-
}
|
|
68
|
-
get isLinux() {
|
|
69
|
-
return process.platform === "linux";
|
|
70
|
-
}
|
|
71
|
-
get currentArch() {
|
|
72
|
-
return process.arch;
|
|
73
|
-
}
|
|
74
|
-
};
|
|
75
|
-
var store = Store.getInstance();
|
|
76
|
-
|
|
77
|
-
// transform/getConfig.ts
|
|
78
|
-
var NOT_FOUND = "\u627E\u4E0D\u5230 electronup.config.ts | electronup.config.js | electronup.config.json , \u8BF7\u5728\u6839\u76EE\u5F55\u4E0B\u6DFB\u52A0\u914D\u7F6E\u6587\u4EF6 , \u6216\u663E\u5F0F\u7684\u6307\u5B9A\u914D\u7F6E\u6587\u4EF6\u8DEF\u5F84\uFF08\u76F8\u5BF9\u4E8E\u6839\u76EE\u5F55\uFF09";
|
|
79
|
-
var PARSING_FAILED = "\u627E\u5230\u4E86\u914D\u7F6E\u6587\u4EF6,\u4F46\u89E3\u6790\u914D\u7F6E\u6587\u4EF6\u5931\u8D25\uFF01";
|
|
80
|
-
var configPath = async (filePath) => {
|
|
81
|
-
const { root } = store;
|
|
82
|
-
if (filePath)
|
|
83
|
-
return (0, import_path.join)(root, filePath);
|
|
84
|
-
const configList = ["ts", "mjs", "cjs", "js"].map((suffix) => `${(0, import_path.join)(root, "electronup.config")}.${suffix}`);
|
|
85
|
-
const index = (await Promise.all(configList.map((path2) => (0, import_fs_extra.pathExists)(path2)))).findIndex((flag) => flag);
|
|
86
|
-
if (index > -1)
|
|
87
|
-
return configList[index];
|
|
88
|
-
throw new Error(NOT_FOUND);
|
|
89
|
-
};
|
|
90
|
-
var getConfig = async (filePath) => {
|
|
91
|
-
const path2 = await configPath(filePath);
|
|
92
|
-
try {
|
|
93
|
-
const option = await (0, import_parser_config.parserConfig)(path2, "electronup.config");
|
|
94
|
-
return option;
|
|
95
|
-
} catch (error) {
|
|
96
|
-
console.error("error :>> ", error);
|
|
97
|
-
throw new Error(PARSING_FAILED);
|
|
98
|
-
}
|
|
99
|
-
};
|
|
100
|
-
|
|
101
|
-
// configs/builder.ts
|
|
102
|
-
var import_path2 = require("path");
|
|
103
|
-
var import_fs_extra2 = require("fs-extra");
|
|
104
|
-
async function getBuilderConfig(config, allConfig) {
|
|
105
|
-
const packages = await (0, import_fs_extra2.readJSON)((0, import_path2.resolve)(store.root, "package.json"));
|
|
106
|
-
const defaultConfig = {
|
|
107
|
-
asar: store.asar,
|
|
108
|
-
appId: "org.quiteer.electronup",
|
|
109
|
-
productName: packages.name,
|
|
110
|
-
protocols: {
|
|
111
|
-
name: packages.name,
|
|
112
|
-
schemes: ["deeplink"]
|
|
113
|
-
},
|
|
114
|
-
nsis: {
|
|
115
|
-
oneClick: false,
|
|
116
|
-
language: "2052",
|
|
117
|
-
perMachine: true,
|
|
118
|
-
allowElevation: true,
|
|
119
|
-
allowToChangeInstallationDirectory: true,
|
|
120
|
-
runAfterFinish: true,
|
|
121
|
-
createDesktopShortcut: true,
|
|
122
|
-
createStartMenuShortcut: true,
|
|
123
|
-
artifactName: `${packages.name} \${arch} Setup ${packages.version}.\${ext}`
|
|
124
|
-
},
|
|
125
|
-
files: [`${allConfig.resourceDir || "dist/resource" /* resourceDir */}/**/*`],
|
|
126
|
-
extraFiles: [allConfig.libDir || "lib" /* libDir */],
|
|
127
|
-
directories: {
|
|
128
|
-
output: allConfig.outDir || config.directories?.output || "dist/out" /* outDir */
|
|
129
|
-
},
|
|
130
|
-
...config
|
|
131
|
-
};
|
|
132
|
-
return { targets: store.targets, config: defaultConfig };
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
// configs/tsup.ts
|
|
136
|
-
var import_path3 = require("path");
|
|
137
|
-
var import_child_process = require("child_process");
|
|
138
|
-
var import_dotenv = require("dotenv");
|
|
139
|
-
var import_electron = __toESM(require("electron"));
|
|
140
|
-
var defaultEnvPath = (0, import_path3.resolve)(store.root, ".env");
|
|
141
|
-
var { parsed: defaultEnv } = (0, import_dotenv.config)({ path: defaultEnvPath });
|
|
142
|
-
var getModeDev = () => {
|
|
143
|
-
const path2 = `${defaultEnvPath}.${store.mode}`;
|
|
144
|
-
const { parsed, error } = (0, import_dotenv.config)({ path: path2 });
|
|
145
|
-
if (error)
|
|
146
|
-
throw new Error(`\u672A\u80FD\u52A0\u8F7D .env.${store.mode} \u4E0B\u7684\u73AF\u5883\u53D8\u91CF,\u68C0\u67E5\u6587\u4EF6\u662F\u5426\u5B58\u5728\uFF01`);
|
|
147
|
-
return {
|
|
148
|
-
...defaultEnv,
|
|
149
|
-
...parsed
|
|
150
|
-
};
|
|
151
|
-
};
|
|
152
|
-
var injectEnv = () => {
|
|
153
|
-
const { command, port } = store;
|
|
154
|
-
const env = getModeDev();
|
|
155
|
-
if (command === "serve") {
|
|
156
|
-
return {
|
|
157
|
-
...env,
|
|
158
|
-
NODE_ENV: "development",
|
|
159
|
-
RENDER_PORT: String(port)
|
|
160
|
-
};
|
|
161
|
-
}
|
|
162
|
-
return {
|
|
163
|
-
...env,
|
|
164
|
-
NODE_ENV: "production"
|
|
165
|
-
};
|
|
166
|
-
};
|
|
167
|
-
function getTsupConfig(config, allConfig) {
|
|
168
|
-
const { command, root, minify } = store;
|
|
169
|
-
const isServe = command === "serve";
|
|
170
|
-
const defaultConfig = {
|
|
171
|
-
minify: minify === false ? false : isServe,
|
|
172
|
-
external: ["electron", ...config.external ?? []],
|
|
173
|
-
noExternal: config.noExternal,
|
|
174
|
-
entry: { electron: (0, import_path3.resolve)(root, allConfig.mainDir || "main" /* mainDir */, "index.ts") },
|
|
175
|
-
outDir: allConfig.resourceDir || "dist/resource" /* resourceDir */,
|
|
176
|
-
watch: isServe,
|
|
177
|
-
format: "cjs",
|
|
178
|
-
dts: false,
|
|
179
|
-
clean: false,
|
|
180
|
-
env: injectEnv(),
|
|
181
|
-
async onSuccess() {
|
|
182
|
-
if (isServe)
|
|
183
|
-
return startElectron((0, import_path3.resolve)(root, allConfig.resourceDir || "dist/resource" /* resourceDir */, "electron.js"));
|
|
184
|
-
}
|
|
185
|
-
};
|
|
186
|
-
return { ...defaultConfig };
|
|
187
|
-
}
|
|
188
|
-
var electronProcess;
|
|
189
|
-
var manualRestart = false;
|
|
190
|
-
function startElectron(mainPath) {
|
|
191
|
-
if (electronProcess) {
|
|
192
|
-
manualRestart = true;
|
|
193
|
-
electronProcess.pid && process.kill(electronProcess.pid);
|
|
194
|
-
electronProcess = null;
|
|
195
|
-
setTimeout(() => {
|
|
196
|
-
manualRestart = false;
|
|
197
|
-
}, 5e3);
|
|
198
|
-
}
|
|
199
|
-
electronProcess = (0, import_child_process.spawn)(import_electron.default, [mainPath, "--inspect=9528"]);
|
|
200
|
-
electronProcess.stdout.on("data", removeJunk);
|
|
201
|
-
electronProcess.stderr.on("data", removeJunk);
|
|
202
|
-
electronProcess.on("close", () => {
|
|
203
|
-
manualRestart || process.exit();
|
|
204
|
-
});
|
|
205
|
-
}
|
|
206
|
-
function removeJunk(chunk) {
|
|
207
|
-
if (/\d+-\d+-\d+ \d+:\d+:\d+\.\d+ Electron(?: Helper)?\[\d+:\d+] /.test(chunk))
|
|
208
|
-
return false;
|
|
209
|
-
if (/\[\d+:\d+\/|\d+\.\d+:ERROR:CONSOLE\(\d+\)\]/.test(chunk))
|
|
210
|
-
return false;
|
|
211
|
-
if (/ALSA lib [a-z]+\.c:\d+:\([a-z_]+\)/.test(chunk))
|
|
212
|
-
return false;
|
|
213
|
-
const data = chunk.toString().split(/\r?\n/);
|
|
214
|
-
let log = "";
|
|
215
|
-
data.forEach((line) => {
|
|
216
|
-
log += ` ${line}
|
|
217
|
-
`;
|
|
218
|
-
});
|
|
219
|
-
console.info(log);
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
// configs/vite.ts
|
|
223
|
-
var import_path4 = require("path");
|
|
224
|
-
function getViteConfig(config, allConfig) {
|
|
225
|
-
const { root, minify } = store;
|
|
226
|
-
const defaultConfig = {
|
|
227
|
-
base: "./",
|
|
228
|
-
...config,
|
|
229
|
-
build: {
|
|
230
|
-
...config?.build,
|
|
231
|
-
minify: minify && "esbuild",
|
|
232
|
-
outDir: (0, import_path4.resolve)(root, allConfig.resourceDir || "dist/resource" /* resourceDir */)
|
|
233
|
-
},
|
|
234
|
-
root: allConfig.renderDir || "render" /* renderDir */,
|
|
235
|
-
publicDir: (0, import_path4.resolve)(root, allConfig.publicDir || "public" /* publicDir */)
|
|
236
|
-
};
|
|
237
|
-
return defaultConfig;
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
// configs/electronup.ts
|
|
241
|
-
async function getElectronupConfig(config) {
|
|
242
|
-
const { viteConfig, tsupConfig, preloadTsup, builderConfig, ...dirConfig } = config;
|
|
243
|
-
const vite = getViteConfig(viteConfig || {}, config);
|
|
244
|
-
const tsup = getTsupConfig(tsupConfig || {}, config);
|
|
245
|
-
const initConfig = { vite, tsup };
|
|
246
|
-
if (store.command === "build") {
|
|
247
|
-
const builder2 = await getBuilderConfig(builderConfig, config);
|
|
248
|
-
initConfig.builder = builder2;
|
|
249
|
-
}
|
|
250
|
-
preloadTsup && (initConfig.preload = preloadTsup);
|
|
251
|
-
return { ...dirConfig, ...initConfig };
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
// transform/getExportConfig.ts
|
|
255
|
-
var exportElectronupConfig = async (config) => {
|
|
256
|
-
const typeStr = typeof config;
|
|
257
|
-
if (typeStr === "function") {
|
|
258
|
-
const option = await config({ command: store.command, root: store.root });
|
|
259
|
-
return option;
|
|
260
|
-
}
|
|
261
|
-
if (typeStr === "object")
|
|
262
|
-
return config;
|
|
263
|
-
throw new Error("electronup \u914D\u7F6E\u9519\u8BEF,\u89E3\u6790\u5931\u8D25\uFF01");
|
|
264
|
-
};
|
|
265
|
-
var electronupConfig = async (config) => getElectronupConfig(await exportElectronupConfig(config));
|
|
266
|
-
|
|
267
|
-
// runner/watch.ts
|
|
268
|
-
var import_portfinder = require("portfinder");
|
|
269
|
-
var import_vite2 = require("vite");
|
|
270
|
-
var import_tsup2 = require("tsup");
|
|
271
|
-
async function watch(options) {
|
|
272
|
-
const p = await (0, import_portfinder.getPortPromise)({
|
|
273
|
-
port: Number(store.port)
|
|
274
|
-
});
|
|
275
|
-
store.port = p;
|
|
276
|
-
const initConfig = await electronupConfig(options);
|
|
277
|
-
const viteDevServer = await (0, import_vite2.createServer)({ configFile: false, ...initConfig.vite });
|
|
278
|
-
viteDevServer.listen(p).then(viteDevServer.printUrls);
|
|
279
|
-
(0, import_tsup2.build)(initConfig.tsup);
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
// runner/build.ts
|
|
283
|
-
var import_path5 = __toESM(require("path"));
|
|
284
|
-
var import_electron_builder = require("electron-builder");
|
|
285
|
-
var import_vite3 = require("vite");
|
|
286
|
-
var import_tsup3 = require("tsup");
|
|
287
|
-
var import_prompts = __toESM(require("prompts"));
|
|
288
|
-
var import_kolorist = require("kolorist");
|
|
289
|
-
var import_yaml = require("yaml");
|
|
290
|
-
var import_fs_extra3 = require("fs-extra");
|
|
291
|
-
var platformSelect = [
|
|
292
|
-
{
|
|
293
|
-
name: "Windows",
|
|
294
|
-
platform: "win32",
|
|
295
|
-
createTarget: (archs) => {
|
|
296
|
-
if (archs.length)
|
|
297
|
-
return import_electron_builder.Platform.WINDOWS.createTarget(store.dir, ...archs);
|
|
298
|
-
return import_electron_builder.Platform.WINDOWS.createTarget(store.dir, import_electron_builder.Arch.ia32, import_electron_builder.Arch.x64);
|
|
299
|
-
},
|
|
300
|
-
color: import_kolorist.blue,
|
|
301
|
-
disabled: !(store.isMac || store.isWin),
|
|
302
|
-
archs: [{
|
|
303
|
-
name: "x64",
|
|
304
|
-
arch: import_electron_builder.Arch.x64,
|
|
305
|
-
disabled: store.currentArch === "ia32",
|
|
306
|
-
color: import_kolorist.blue
|
|
307
|
-
}, {
|
|
308
|
-
name: "ia32",
|
|
309
|
-
arch: import_electron_builder.Arch.ia32,
|
|
310
|
-
color: import_kolorist.blue,
|
|
311
|
-
disabled: false
|
|
312
|
-
}]
|
|
313
|
-
},
|
|
314
|
-
{
|
|
315
|
-
name: "MacOS",
|
|
316
|
-
platform: "darwin",
|
|
317
|
-
createTarget: (archs) => {
|
|
318
|
-
if (archs.length)
|
|
319
|
-
return import_electron_builder.Platform.MAC.createTarget(store.dir, import_electron_builder.Arch[store.currentArch]);
|
|
320
|
-
return import_electron_builder.Platform.MAC.createTarget(store.dir, ...archs);
|
|
321
|
-
},
|
|
322
|
-
disabled: !store.isMac,
|
|
323
|
-
color: import_kolorist.green,
|
|
324
|
-
archs: [{
|
|
325
|
-
name: "x64",
|
|
326
|
-
arch: import_electron_builder.Arch.x64,
|
|
327
|
-
disabled: false,
|
|
328
|
-
color: import_kolorist.green
|
|
329
|
-
}, {
|
|
330
|
-
name: "arm64",
|
|
331
|
-
arch: import_electron_builder.Arch.arm64,
|
|
332
|
-
disabled: false,
|
|
333
|
-
color: import_kolorist.green
|
|
334
|
-
}, {
|
|
335
|
-
name: "universal",
|
|
336
|
-
arch: import_electron_builder.Arch.universal,
|
|
337
|
-
disabled: false,
|
|
338
|
-
color: import_kolorist.green
|
|
339
|
-
}]
|
|
340
|
-
},
|
|
341
|
-
{
|
|
342
|
-
name: "Linux",
|
|
343
|
-
platform: "linux",
|
|
344
|
-
disabled: !(store.isMac || store.isLinux),
|
|
345
|
-
createTarget: (archs) => {
|
|
346
|
-
if (archs.length)
|
|
347
|
-
return import_electron_builder.Platform.LINUX.createTarget(store.dir, import_electron_builder.Arch[store.currentArch]);
|
|
348
|
-
return import_electron_builder.Platform.LINUX.createTarget(store.dir, ...archs);
|
|
349
|
-
},
|
|
350
|
-
color: import_kolorist.yellow,
|
|
351
|
-
archs: [{
|
|
352
|
-
name: "x64",
|
|
353
|
-
arch: import_electron_builder.Arch.x64,
|
|
354
|
-
disabled: false,
|
|
355
|
-
color: import_kolorist.yellow
|
|
356
|
-
}, {
|
|
357
|
-
name: "arm64",
|
|
358
|
-
arch: import_electron_builder.Arch.arm64,
|
|
359
|
-
disabled: false,
|
|
360
|
-
color: import_kolorist.yellow
|
|
361
|
-
}, {
|
|
362
|
-
name: "armv7l",
|
|
363
|
-
arch: import_electron_builder.Arch.armv7l,
|
|
364
|
-
disabled: false,
|
|
365
|
-
color: import_kolorist.yellow
|
|
366
|
-
}]
|
|
367
|
-
}
|
|
368
|
-
];
|
|
369
|
-
async function build2(options) {
|
|
370
|
-
if (store.option) {
|
|
371
|
-
let result;
|
|
372
|
-
try {
|
|
373
|
-
result = await (0, import_prompts.default)([
|
|
374
|
-
{
|
|
375
|
-
type: "confirm",
|
|
376
|
-
name: "isMinify",
|
|
377
|
-
message: (0, import_kolorist.green)("\u662F\u5426\u538B\u7F29\u4EE3\u7801?")
|
|
378
|
-
},
|
|
379
|
-
{
|
|
380
|
-
type: "confirm",
|
|
381
|
-
name: "isPackage",
|
|
382
|
-
message: (0, import_kolorist.blue)("\u662F\u5426\u751F\u6210\u5B89\u88C5\u5305?")
|
|
383
|
-
},
|
|
384
|
-
{
|
|
385
|
-
type: "select",
|
|
386
|
-
name: "platform",
|
|
387
|
-
message: "\u8BF7\u9009\u62E9\u6784\u5EFA\u6A21\u5F0F ~",
|
|
388
|
-
choices: platformSelect.map((item) => ({ title: item.color(item.name), value: item, disabled: item.disabled }))
|
|
389
|
-
},
|
|
390
|
-
{
|
|
391
|
-
type: "multiselect",
|
|
392
|
-
name: "arch",
|
|
393
|
-
message: "\u8BF7\u9009\u62E9\u6253\u5305\u67B6\u6784\uFF5E",
|
|
394
|
-
choices: (platformSelect2) => {
|
|
395
|
-
return platformSelect2.archs?.map((item) => ({ title: item.color(item.name), value: item.arch, disabled: item.disabled }));
|
|
396
|
-
}
|
|
397
|
-
}
|
|
398
|
-
], {
|
|
399
|
-
onCancel: () => {
|
|
400
|
-
throw new Error(`${(0, import_kolorist.red)("\u2716")} Operation cancelled`);
|
|
401
|
-
}
|
|
402
|
-
});
|
|
403
|
-
} catch (cancelled) {
|
|
404
|
-
console.error("err: ", cancelled.message);
|
|
405
|
-
process.exit(1);
|
|
406
|
-
}
|
|
407
|
-
const { isMinify, isPackage, platform, arch } = result;
|
|
408
|
-
console.log("isMinify: ", isMinify);
|
|
409
|
-
console.log("isPackage: ", isPackage);
|
|
410
|
-
console.log("platform: ", platform);
|
|
411
|
-
console.log("arch: ", arch);
|
|
412
|
-
store.minify = isMinify;
|
|
413
|
-
store.dir = isPackage ? null : "dir";
|
|
414
|
-
store.targets = platform.createTarget(arch);
|
|
415
|
-
} else {
|
|
416
|
-
if (store.isWin) {
|
|
417
|
-
if (store.win === "ia32")
|
|
418
|
-
store.targets = import_electron_builder.Platform.WINDOWS.createTarget(store.dir, import_electron_builder.Arch.ia32);
|
|
419
|
-
else if (store.win === "x64")
|
|
420
|
-
store.targets = import_electron_builder.Platform.WINDOWS.createTarget(store.dir, import_electron_builder.Arch.x64);
|
|
421
|
-
else
|
|
422
|
-
store.targets = import_electron_builder.Platform.WINDOWS.createTarget(store.dir, import_electron_builder.Arch[store.currentArch]);
|
|
423
|
-
}
|
|
424
|
-
if (store.isMac) {
|
|
425
|
-
if (store.win) {
|
|
426
|
-
if (store.win === "ia32")
|
|
427
|
-
store.targets = import_electron_builder.Platform.WINDOWS.createTarget(store.dir, import_electron_builder.Arch.ia32);
|
|
428
|
-
else if (store.win === "x64")
|
|
429
|
-
store.targets = import_electron_builder.Platform.WINDOWS.createTarget(store.dir, import_electron_builder.Arch.x64);
|
|
430
|
-
else
|
|
431
|
-
store.targets = import_electron_builder.Platform.WINDOWS.createTarget(store.dir, import_electron_builder.Arch[store.currentArch]);
|
|
432
|
-
} else if (store.mac) {
|
|
433
|
-
if (store.mac === "x64")
|
|
434
|
-
store.targets = import_electron_builder.Platform.MAC.createTarget(store.dir, import_electron_builder.Arch.x64);
|
|
435
|
-
else if (store.mac === "arm64")
|
|
436
|
-
store.targets = import_electron_builder.Platform.MAC.createTarget(store.dir, import_electron_builder.Arch.arm64);
|
|
437
|
-
else if (store.mac === "universal")
|
|
438
|
-
store.targets = import_electron_builder.Platform.MAC.createTarget(store.dir, import_electron_builder.Arch.universal);
|
|
439
|
-
else
|
|
440
|
-
store.targets = import_electron_builder.Platform.MAC.createTarget(store.dir, import_electron_builder.Arch[store.currentArch]);
|
|
441
|
-
} else if (store.linux) {
|
|
442
|
-
if (store.linux === true)
|
|
443
|
-
store.targets = import_electron_builder.Platform.LINUX.createTarget(store.dir);
|
|
444
|
-
else
|
|
445
|
-
store.targets = import_electron_builder.Platform.LINUX.createTarget(store.dir, import_electron_builder.Arch[store.currentArch]);
|
|
446
|
-
} else {
|
|
447
|
-
store.targets = import_electron_builder.Platform.MAC.createTarget(store.dir, import_electron_builder.Arch[store.currentArch]);
|
|
448
|
-
}
|
|
449
|
-
} else if (store.isLinux) {
|
|
450
|
-
store.targets = import_electron_builder.Platform.LINUX.createTarget(store.dir, import_electron_builder.Arch.armv7l);
|
|
451
|
-
}
|
|
452
|
-
}
|
|
453
|
-
const initConfig = await electronupConfig(options);
|
|
454
|
-
await (0, import_vite3.build)(initConfig.vite);
|
|
455
|
-
await (0, import_tsup3.build)(initConfig.tsup);
|
|
456
|
-
await (0, import_electron_builder.build)(initConfig.builder);
|
|
457
|
-
await (0, import_fs_extra3.writeFile)(
|
|
458
|
-
import_path5.default.resolve(store.root, options.outDir || "dist/out" /* outDir */, "electronup-effective-config.yaml"),
|
|
459
|
-
(0, import_yaml.stringify)(JSON.parse(JSON.stringify(initConfig)))
|
|
460
|
-
);
|
|
461
|
-
}
|
|
462
|
-
|
|
463
|
-
// cli.ts
|
|
464
|
-
var cli = (0, import_cac.cac)("electronup");
|
|
465
|
-
cli.option("-m , --mode <mode>", "[development | production | test | staging | ...] \u73AF\u5883\u6A21\u5F0F ");
|
|
466
|
-
cli.option("--no-minify", "\u4F7F\u4E3B\u8FDB\u7A0B\u548C\u6E32\u67D3\u8FDB\u7A0B\u4EE3\u7801\u4E0D\u8FDB\u884C\u538B\u7F29 ");
|
|
467
|
-
cli.command("[config-file]", "\u7B49\u540C\u4E8Eelectronup dev ,\u542F\u52A8\u5F00\u53D1\u73AF\u5883\u70ED\u66F4\u65B0").alias("dev").option("-p , --port <port>", "[number] \u6E32\u67D3\u8FDB\u7A0B\u7684\u7AEF\u53E3\u53F7 \uFF0C\u5982\u679C\u5360\u7528\u4F1A\u5207\u6362\u975E\u5360\u7528\u7684\u7AEF\u53E3 ").action(async (configFile, options) => {
|
|
468
|
-
const { mode, port, minify } = options;
|
|
469
|
-
const option = await getConfig(configFile);
|
|
470
|
-
emptyDir((0, import_node_path.resolve)(store.root, option.resourceDir || "dist/resource" /* resourceDir */));
|
|
471
|
-
store.command = "serve";
|
|
472
|
-
store.mode = mode || "development";
|
|
473
|
-
store.port = port || 8090;
|
|
474
|
-
store.minify = !!minify;
|
|
475
|
-
watch(option);
|
|
476
|
-
});
|
|
477
|
-
cli.command("build [root]", "\u5F00\u59CB\u6784\u5EFA\u670D\u52A1 , \u82E5\u4E0D\u6307\u5B9A\u5E73\u53F0\u5219\u9ED8\u8BA4\u5F53\u524D\u64CD\u4F5C\u7CFB\u7EDF\u7684\u67B6\u6784\u7C7B\u578B").option("-o , --option", "\u81EA\u5B9A\u4E49 , \u81EA\u5B9A\u4E49\u6784\u5EFA\u9009\u9879 ").option("--dir", "\u53EA\u751F\u6210\u76EE\u5F55").option("--no-asar", "asar false").option("--win [arch]", "[ia32 | x64] \u6784\u5EFA win \u5E73\u53F0\u4E0B\u7684\u8F93\u51FA\u5305 , \u4E0D\u6307\u5B9A\u67B6\u6784\u5219\u8F93\u51FA ia32 \u548C x64\u7684\u4E24\u4E2A\u5305").option("--mac [arch]", "[x64 | arm64 | universal] \u6784\u5EFA mac \u5E73\u53F0\u4E0B\u7684\u8F93\u51FA\u5305 , \u82E5\u4E0D\u6307\u5B9A\u67B6\u6784\u5219\u9ED8\u8BA4\u5F53\u524D\u64CD\u4F5C\u7CFB\u7EDF\u7684\u67B6\u6784\u7C7B\u578B").option("--linux", "[x64 | arm64 | armv7l] \u6784\u5EFA linux \u5E73\u53F0\u4E0B\u7684\u8F93\u51FA\u5305 , \u82E5\u4E0D\u6307\u5B9A\u67B6\u6784\u5219\u9ED8\u8BA4\u5F53\u524D\u64CD\u4F5C\u7CFB\u7EDF\u7684\u67B6\u6784\u7C7B\u578B").action(async (configFile, options) => {
|
|
478
|
-
const {
|
|
479
|
-
mode,
|
|
480
|
-
minify,
|
|
481
|
-
option,
|
|
482
|
-
win,
|
|
483
|
-
mac,
|
|
484
|
-
linux,
|
|
485
|
-
dir,
|
|
486
|
-
asar
|
|
487
|
-
} = options;
|
|
488
|
-
const configOption = await getConfig(configFile);
|
|
489
|
-
emptyDir((0, import_node_path.resolve)(store.root, configOption.resourceDir || "dist/resource" /* resourceDir */));
|
|
490
|
-
emptyDir((0, import_node_path.resolve)(store.root, configOption.outDir || "dist/out" /* outDir */));
|
|
491
|
-
store.command = "build";
|
|
492
|
-
store.mode = mode || "production";
|
|
493
|
-
store.minify = minify;
|
|
494
|
-
store.option = !!option;
|
|
495
|
-
store.dir = dir ? "dir" : null;
|
|
496
|
-
store.asar = asar;
|
|
497
|
-
store.win = win;
|
|
498
|
-
store.mac = mac;
|
|
499
|
-
store.linux = linux;
|
|
500
|
-
build2(configOption);
|
|
501
|
-
});
|
|
502
|
-
cli.help();
|
|
503
|
-
cli.version(version);
|
|
504
|
-
cli.parse();
|
|
505
|
-
function emptyDir(dir) {
|
|
506
|
-
if (!import_node_fs.default.existsSync(dir))
|
|
507
|
-
return;
|
|
508
|
-
for (const file of import_node_fs.default.readdirSync(dir))
|
|
509
|
-
import_node_fs.default.rmSync((0, import_node_path.resolve)(dir, file), { recursive: true, force: true });
|
|
510
|
-
}
|
package/dist/client/index.d.ts
DELETED
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import { Configuration } from 'electron-builder';
|
|
2
|
-
import { UserConfig } from 'vite';
|
|
3
|
-
import { Options } from 'tsup';
|
|
4
|
-
|
|
5
|
-
interface ViteConfig extends Omit<UserConfig, 'publicDir' | 'ssr'> { }
|
|
6
|
-
|
|
7
|
-
interface TsupConfig {
|
|
8
|
-
external?: (string | RegExp)[];
|
|
9
|
-
noExternal?: (string | RegExp)[];
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
interface BuilderConfig extends Configuration { }
|
|
13
|
-
|
|
14
|
-
interface ElectronupConfig {
|
|
15
|
-
viteConfig?: ViteConfig
|
|
16
|
-
tsupConfig?: TsupConfig
|
|
17
|
-
preloadTsup?: Options | Options[]
|
|
18
|
-
builderConfig: BuilderConfig
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* 渲染进程入口目录
|
|
22
|
-
* @default 'render'
|
|
23
|
-
*/
|
|
24
|
-
renderDir?: string
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* 主进程入口目录
|
|
28
|
-
* @default 'main'
|
|
29
|
-
*/
|
|
30
|
-
mainDir?: string
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* 静态资源目录
|
|
34
|
-
* @default 'public'
|
|
35
|
-
*/
|
|
36
|
-
publicDir?: string
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* 动态库目录
|
|
40
|
-
* @default 'lib'
|
|
41
|
-
*/
|
|
42
|
-
libDir?: string
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* 资源构建输出目录
|
|
46
|
-
* @default 'dist'
|
|
47
|
-
*/
|
|
48
|
-
resourceDir?: string
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* electron-builder 输出目录
|
|
52
|
-
* @default 'out'
|
|
53
|
-
*/
|
|
54
|
-
outDir?: string
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
interface ConfigEnv {
|
|
58
|
-
command: 'build' | 'serve'
|
|
59
|
-
root: string
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
type ElectronupConfigFnObject = (env: ConfigEnv) => ElectronupConfig
|
|
63
|
-
type ElectronupConfigFnPromise = (env: ConfigEnv) => Promise<ElectronupConfig>
|
|
64
|
-
type ElectronupConfigFn = (env: ConfigEnv) => ElectronupConfig | Promise<ElectronupConfig>
|
|
65
|
-
|
|
66
|
-
type ElectronupConfigExport =
|
|
67
|
-
| ElectronupConfig
|
|
68
|
-
| Promise<ElectronupConfig>
|
|
69
|
-
| ElectronupConfigFnObject
|
|
70
|
-
| ElectronupConfigFnPromise
|
|
71
|
-
| ElectronupConfigFn
|
|
72
|
-
|
|
73
|
-
declare function defineConfig(config: ElectronupConfig): ElectronupConfig;
|
|
74
|
-
declare function defineConfig(config: Promise<ElectronupConfig>): Promise<ElectronupConfig>;
|
|
75
|
-
declare function defineConfig(config: ElectronupConfigFnObject): ElectronupConfigFnObject;
|
|
76
|
-
declare function defineConfig(config: ElectronupConfigExport): ElectronupConfigExport;
|
|
77
|
-
|
|
78
|
-
export { type BuilderConfig, type ConfigEnv, type ElectronupConfig, type TsupConfig, type ViteConfig, defineConfig };
|
package/dist/client/index.js
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// index.ts
|
|
21
|
-
var electronup_exports = {};
|
|
22
|
-
__export(electronup_exports, {
|
|
23
|
-
defineConfig: () => defineConfig
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(electronup_exports);
|
|
26
|
-
function defineConfig(config) {
|
|
27
|
-
return config;
|
|
28
|
-
}
|
|
29
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
30
|
-
0 && (module.exports = {
|
|
31
|
-
defineConfig
|
|
32
|
-
});
|