electronup 0.0.1 → 0.0.3
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 +2 -2
- package/dist/bin/electronup.js +14 -50
- package/dist/client/index.d.ts +3 -11
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#
|
|
1
|
+
# electronup
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
> 融合构建 electron 应用需要的构建工具,保留原有配置习惯的命令行工具
|
|
@@ -81,7 +81,7 @@ pnpm add @quiteer/electronup -D
|
|
|
81
81
|
```json
|
|
82
82
|
{
|
|
83
83
|
"dependencies": {
|
|
84
|
-
"@quiteer/
|
|
84
|
+
"@quiteer/parser-config": "^1.0.3",
|
|
85
85
|
"cac": "^6.7.14",
|
|
86
86
|
"dotenv": "^16.0.3",
|
|
87
87
|
"electron-builder": "^23.6.0",
|
package/dist/bin/electronup.js
CHANGED
|
@@ -7,9 +7,6 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
|
7
7
|
var __getProtoOf = Object.getPrototypeOf;
|
|
8
8
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
9
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
10
|
-
var __commonJS = (cb, mod) => function __require() {
|
|
11
|
-
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
12
|
-
};
|
|
13
10
|
var __copyProps = (to, from, except, desc) => {
|
|
14
11
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
12
|
for (let key of __getOwnPropNames(from))
|
|
@@ -31,37 +28,13 @@ var __publicField = (obj, key, value) => {
|
|
|
31
28
|
return value;
|
|
32
29
|
};
|
|
33
30
|
|
|
34
|
-
// node_modules/.pnpm/electron@22.3.14/node_modules/electron/index.js
|
|
35
|
-
var require_electron = __commonJS({
|
|
36
|
-
"node_modules/.pnpm/electron@22.3.14/node_modules/electron/index.js"(exports, module2) {
|
|
37
|
-
var fs = require("fs");
|
|
38
|
-
var path2 = require("path");
|
|
39
|
-
var pathFile = path2.join(__dirname, "path.txt");
|
|
40
|
-
function getElectronPath() {
|
|
41
|
-
let executablePath;
|
|
42
|
-
if (fs.existsSync(pathFile)) {
|
|
43
|
-
executablePath = fs.readFileSync(pathFile, "utf-8");
|
|
44
|
-
}
|
|
45
|
-
if (process.env.ELECTRON_OVERRIDE_DIST_PATH) {
|
|
46
|
-
return path2.join(process.env.ELECTRON_OVERRIDE_DIST_PATH, executablePath || "electron");
|
|
47
|
-
}
|
|
48
|
-
if (executablePath) {
|
|
49
|
-
return path2.join(__dirname, "dist", executablePath);
|
|
50
|
-
} else {
|
|
51
|
-
throw new Error("Electron failed to install correctly, please delete node_modules/electron and try installing again");
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
module2.exports = getElectronPath();
|
|
55
|
-
}
|
|
56
|
-
});
|
|
57
|
-
|
|
58
31
|
// src/cli.ts
|
|
59
32
|
var import_path6 = require("path");
|
|
60
33
|
var import_cac = require("cac");
|
|
61
34
|
var import_rimraf = require("rimraf");
|
|
62
35
|
|
|
63
36
|
// package.json
|
|
64
|
-
var version = "0.0.
|
|
37
|
+
var version = "0.0.3";
|
|
65
38
|
|
|
66
39
|
// src/transform/getConfig.ts
|
|
67
40
|
var import_path = require("path");
|
|
@@ -185,7 +158,7 @@ async function getBuilderConfig(config, allConfig) {
|
|
|
185
158
|
var import_path3 = require("path");
|
|
186
159
|
var import_child_process = require("child_process");
|
|
187
160
|
var import_dotenv = require("dotenv");
|
|
188
|
-
var import_electron = __toESM(
|
|
161
|
+
var import_electron = __toESM(require("electron"));
|
|
189
162
|
var defaultEnvPath = (0, import_path3.resolve)(store.root, ".env");
|
|
190
163
|
var { parsed: defaultEnv } = (0, import_dotenv.config)({ path: defaultEnvPath });
|
|
191
164
|
var getModeDev = () => {
|
|
@@ -216,11 +189,9 @@ var injectEnv = () => {
|
|
|
216
189
|
function getTsupConfig(config, allConfig) {
|
|
217
190
|
const { command, root, minify } = store;
|
|
218
191
|
const isServe = command === "serve";
|
|
219
|
-
const userConfig = {
|
|
220
|
-
minify: minify === false ? false : isServe,
|
|
221
|
-
...config
|
|
222
|
-
};
|
|
223
192
|
const defaultConfig = {
|
|
193
|
+
target: "es5",
|
|
194
|
+
minify: minify === false ? false : isServe,
|
|
224
195
|
external: ["electron", ...config.external ?? []],
|
|
225
196
|
noExternal: config.noExternal,
|
|
226
197
|
entry: { electron: (0, import_path3.resolve)(root, allConfig.mainDir || "main" /* mainDir */, "index.ts") },
|
|
@@ -234,8 +205,7 @@ function getTsupConfig(config, allConfig) {
|
|
|
234
205
|
return startElectron((0, import_path3.resolve)(root, allConfig.resourceDir || "dist/resource" /* resourceDir */, "electron.js"));
|
|
235
206
|
}
|
|
236
207
|
};
|
|
237
|
-
config
|
|
238
|
-
return { ...userConfig, ...defaultConfig };
|
|
208
|
+
return { ...config, ...defaultConfig };
|
|
239
209
|
}
|
|
240
210
|
var electronProcess;
|
|
241
211
|
var manualRestart = false;
|
|
@@ -277,21 +247,15 @@ function getViteConfig(config, allConfig) {
|
|
|
277
247
|
const { root, minify } = store;
|
|
278
248
|
const defaultConfig = {
|
|
279
249
|
base: "./",
|
|
280
|
-
|
|
281
|
-
server: { host: "0.0.0.0" },
|
|
250
|
+
...config,
|
|
282
251
|
build: {
|
|
283
|
-
|
|
284
|
-
target: "esnext",
|
|
252
|
+
...config?.build,
|
|
285
253
|
minify: minify && "esbuild",
|
|
286
|
-
|
|
287
|
-
emptyOutDir: true,
|
|
288
|
-
...config?.build
|
|
254
|
+
outDir: (0, import_path4.resolve)(root, allConfig.resourceDir || "dist/resource" /* resourceDir */)
|
|
289
255
|
},
|
|
290
|
-
|
|
256
|
+
root: allConfig.renderDir || "render" /* renderDir */,
|
|
257
|
+
publicDir: (0, import_path4.resolve)(root, allConfig.publicDir || "public" /* publicDir */)
|
|
291
258
|
};
|
|
292
|
-
config?.resolve && (defaultConfig.resolve = config.resolve);
|
|
293
|
-
config?.plugins && (defaultConfig.plugins = config.plugins);
|
|
294
|
-
defaultConfig.publicDir = (0, import_path4.resolve)(root, allConfig.publicDir || "public" /* publicDir */);
|
|
295
259
|
return defaultConfig;
|
|
296
260
|
}
|
|
297
261
|
|
|
@@ -310,17 +274,17 @@ async function getElectronupConfig(config) {
|
|
|
310
274
|
}
|
|
311
275
|
|
|
312
276
|
// src/transform/getExportConfig.ts
|
|
313
|
-
var exportElectronupConfig = (config) => {
|
|
277
|
+
var exportElectronupConfig = async (config) => {
|
|
314
278
|
const typeStr = typeof config;
|
|
315
279
|
if (typeStr === "function") {
|
|
316
|
-
const option = config({ command: store.command, root: store.root });
|
|
280
|
+
const option = await config({ command: store.command, root: store.root });
|
|
317
281
|
return option;
|
|
318
282
|
}
|
|
319
283
|
if (typeStr === "object")
|
|
320
284
|
return config;
|
|
321
285
|
throw new Error("electronup \u914D\u7F6E\u9519\u8BEF,\u89E3\u6790\u5931\u8D25\uFF01");
|
|
322
286
|
};
|
|
323
|
-
var electronupConfig = (config) => getElectronupConfig(exportElectronupConfig(config));
|
|
287
|
+
var electronupConfig = async (config) => getElectronupConfig(await exportElectronupConfig(config));
|
|
324
288
|
|
|
325
289
|
// src/runner/watch.ts
|
|
326
290
|
var import_portfinder = require("portfinder");
|
|
@@ -472,7 +436,7 @@ cli.command("[config-file]", "start dev server").alias("dev").option("-p , --por
|
|
|
472
436
|
store.minify = !!minify;
|
|
473
437
|
watch(option);
|
|
474
438
|
});
|
|
475
|
-
cli.command("build [root]", "\u6784\u5EFA").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", " \u6784\u5EFA win \u4E0B\u8F93\u51FA\u5305").option("--mac", " \u6784\u5EFA mac \u4E0B\u8F93\u51FA\u5305").option("--linux", " \u6784\u5EFA linux \u8F93\u51FA\u5305").option("--ia32", " \u6784\u5EFA ia32 \
|
|
439
|
+
cli.command("build [root]", "\u6784\u5EFA").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", " \u6784\u5EFA win \u5E73\u53F0\u4E0B\u7684\u8F93\u51FA\u5305").option("--mac", " \u6784\u5EFA mac \u5E73\u53F0\u4E0B\u7684\u8F93\u51FA\u5305").option("--linux", " \u6784\u5EFA linux \u5E73\u53F0\u4E0B\u7684\u8F93\u51FA\u5305").option("--ia32", " \u6784\u5EFA ia32 \u67B6\u6784").option("--x64", " \u6784\u5EFA x64 \u67B6\u6784").option("--arm64", " \u6784\u5EFA arm64 \u67B6\u6784").option("--armv7l", " \u6784\u5EFA armv7l \u67B6\u6784").option("--universal", " \u6784\u5EFA universal \u5E73\u53F0\u5305").action(async (configFile, options) => {
|
|
476
440
|
const {
|
|
477
441
|
mode,
|
|
478
442
|
minify,
|
package/dist/client/index.d.ts
CHANGED
|
@@ -1,18 +1,10 @@
|
|
|
1
1
|
import { Configuration } from 'electron-builder';
|
|
2
|
-
import {
|
|
2
|
+
import { UserConfig } from 'vite';
|
|
3
3
|
import { Options } from 'tsup';
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
resolve?: ResolveOptions & {
|
|
7
|
-
alias?: AliasOptions;
|
|
8
|
-
}
|
|
9
|
-
plugins?: PluginOption[]
|
|
10
|
-
build?:UserConfig['build']
|
|
11
|
-
viteOptions?: Omit<UserConfig, 'plugins' | 'resolve' | 'publicDir'| 'build'>
|
|
12
|
-
}
|
|
5
|
+
type ViteConfig = Omit<UserConfig, 'publicDir'>
|
|
13
6
|
|
|
14
7
|
interface TsupConfig {
|
|
15
|
-
target?: Options['target'];
|
|
16
8
|
external?: (string | RegExp)[];
|
|
17
9
|
noExternal?: (string | RegExp)[];
|
|
18
10
|
}
|
|
@@ -67,7 +59,7 @@ interface ConfigEnv {
|
|
|
67
59
|
root: string
|
|
68
60
|
}
|
|
69
61
|
|
|
70
|
-
type ElectronupConfigFn = (env: ConfigEnv) => ElectronupConfig
|
|
62
|
+
type ElectronupConfigFn = (env: ConfigEnv) => ElectronupConfig | Promise<ElectronupConfig>
|
|
71
63
|
type UserElectronupConfig = ElectronupConfig | ElectronupConfigFn
|
|
72
64
|
|
|
73
65
|
declare const defineConfig: (config: UserElectronupConfig) => UserElectronupConfig;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "electronup",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
4
4
|
"description": "融合构建 electron 应用需要的构建工具,保留原有配置习惯的命令行工具 ",
|
|
5
5
|
"author": "quiteer",
|
|
6
6
|
"license": "MIT",
|
|
@@ -38,6 +38,7 @@
|
|
|
38
38
|
},
|
|
39
39
|
"peerDependencies": {
|
|
40
40
|
"@types/node": ">= 16",
|
|
41
|
+
"electron": ">= 20",
|
|
41
42
|
"node": ">= 16",
|
|
42
43
|
"vue": ">= 3"
|
|
43
44
|
},
|