electronup 0.2.1 → 0.2.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.
@@ -5,7 +5,7 @@ import { cac } from "cac";
5
5
  import process from "node:process";
6
6
  import * as prompts from "@clack/prompts";
7
7
  import { Arch, Platform, build } from "electron-builder";
8
- import { pathExists, readJSON, writeFile } from "fs-extra";
8
+ import fsExtra from "fs-extra";
9
9
  import { blue, green, red, yellow } from "kolorist";
10
10
  import { build as build$1, createServer } from "vite";
11
11
  import { stringify } from "yaml";
@@ -16,10 +16,10 @@ import electron from "electron";
16
16
  import { getPortPromise } from "portfinder";
17
17
 
18
18
  //#region package.json
19
- var version = "0.2.1";
19
+ var version = "0.2.3";
20
20
 
21
21
  //#endregion
22
- //#region utils/dirs.ts
22
+ //#region src/utils/dirs.ts
23
23
  let DefaultDirs = /* @__PURE__ */ function(DefaultDirs) {
24
24
  DefaultDirs["renderDir"] = "render";
25
25
  DefaultDirs["mainDir"] = "main";
@@ -31,7 +31,7 @@ let DefaultDirs = /* @__PURE__ */ function(DefaultDirs) {
31
31
  }({});
32
32
 
33
33
  //#endregion
34
- //#region utils/store.ts
34
+ //#region src/utils/store.ts
35
35
  var Store = class Store {
36
36
  static instance;
37
37
  command;
@@ -75,10 +75,11 @@ var Store = class Store {
75
75
  const store = Store.getInstance();
76
76
 
77
77
  //#endregion
78
- //#region transform/getConfig.ts
78
+ //#region src/transform/getConfig.ts
79
79
  const NOT_FOUND = "找不到 electronup.config.ts | electronup.config.js | electronup.config.json , 请在根目录下添加配置文件 , 或显式的指定配置文件路径(相对于根目录)";
80
80
  const PARSING_FAILED = "找到了配置文件,但解析配置文件失败!";
81
81
  async function configPath(filePath) {
82
+ const { pathExists } = fsExtra;
82
83
  const { root } = store;
83
84
  if (filePath) return join(root, filePath);
84
85
  const configList = [
@@ -102,11 +103,12 @@ async function getConfig(filePath) {
102
103
  }
103
104
 
104
105
  //#endregion
105
- //#region configs/builder.ts
106
+ //#region src/configs/builder.ts
106
107
  /**
107
108
  * CliOptions 配置直接
108
109
  */
109
110
  async function getBuilderConfig(config, allConfig) {
111
+ const { readJSON } = fsExtra;
110
112
  const packages = await readJSON(resolve(store.root, "package.json"));
111
113
  const defaultConfig = {
112
114
  asar: store.asar,
@@ -139,7 +141,7 @@ async function getBuilderConfig(config, allConfig) {
139
141
  }
140
142
 
141
143
  //#endregion
142
- //#region configs/tsdown.ts
144
+ //#region src/configs/tsdown.ts
143
145
  /**
144
146
  * Description 全局的环境变量路径
145
147
  * @param {any} store.root
@@ -222,7 +224,11 @@ function startElectron(mainPath) {
222
224
  manualRestart = false;
223
225
  }, 5e3);
224
226
  }
225
- electronProcess = spawn(electron, [mainPath]);
227
+ const env = {
228
+ ...process.env,
229
+ ...injectEnv()
230
+ };
231
+ electronProcess = spawn(electron, [mainPath], { env });
226
232
  electronProcess.stdout.on("data", removeJunk);
227
233
  electronProcess.stderr.on("data", removeJunk);
228
234
  electronProcess.on("close", () => {
@@ -242,7 +248,7 @@ function removeJunk(chunk) {
242
248
  }
243
249
 
244
250
  //#endregion
245
- //#region configs/vite.ts
251
+ //#region src/configs/vite.ts
246
252
  function getViteConfig(config, allConfig) {
247
253
  const { root, minify } = store;
248
254
  return {
@@ -259,7 +265,7 @@ function getViteConfig(config, allConfig) {
259
265
  }
260
266
 
261
267
  //#endregion
262
- //#region configs/electronup.ts
268
+ //#region src/configs/electronup.ts
263
269
  async function getElectronupConfig(config) {
264
270
  const { viteConfig, tsdownConfig, preload, builderConfig, ...dirConfig } = config;
265
271
  const initConfig = {
@@ -275,7 +281,7 @@ async function getElectronupConfig(config) {
275
281
  }
276
282
 
277
283
  //#endregion
278
- //#region transform/getExportConfig.ts
284
+ //#region src/transform/getExportConfig.ts
279
285
  /**
280
286
  * Description 解析用户自定义配置···
281
287
  * @param {any} config:ElectronupConfigExport
@@ -293,7 +299,7 @@ async function exportElectronupConfig(config) {
293
299
  const electronupConfig = async (config) => getElectronupConfig(await exportElectronupConfig(config));
294
300
 
295
301
  //#endregion
296
- //#region runner/build.ts
302
+ //#region src/runner/build.ts
297
303
  const platformSelect = [
298
304
  {
299
305
  name: "Windows",
@@ -378,6 +384,7 @@ const platformSelect = [
378
384
  }
379
385
  ];
380
386
  async function build$2(options) {
387
+ const { writeFile } = fsExtra;
381
388
  if (store.option) try {
382
389
  const isMinify = await prompts.confirm({ message: green("是否压缩代码?") });
383
390
  if (prompts.isCancel(isMinify)) throw new Error(`${red("✖")} Operation cancelled`);
@@ -434,7 +441,7 @@ async function build$2(options) {
434
441
  }
435
442
 
436
443
  //#endregion
437
- //#region runner/watch.ts
444
+ //#region src/runner/watch.ts
438
445
  async function watch(options) {
439
446
  const p = await getPortPromise({ port: Number(store.port) });
440
447
  store.port = p;
@@ -449,7 +456,7 @@ async function watch(options) {
449
456
  }
450
457
 
451
458
  //#endregion
452
- //#region cli.ts
459
+ //#region src/cli.ts
453
460
  const cli = cac("electronup");
454
461
  cli.option("-m , --mode <mode>", "[development | production | test | staging | ...] 环境模式 ");
455
462
  cli.option("--no-minify", "使主进程和渲染进程代码不进行压缩 ");
@@ -2,7 +2,7 @@ import { Configuration } from "electron-builder";
2
2
  import { UserConfig } from "tsdown";
3
3
  import { UserConfig as UserConfig$1 } from "vite";
4
4
 
5
- //#region typings/electronup.d.ts
5
+ //#region src/typings/electronup.d.ts
6
6
  interface ViteConfig extends Omit<UserConfig$1, 'publicDir' | 'ssr'> {}
7
7
  interface TsdownConfig {
8
8
  external?: (string | RegExp)[];
@@ -54,7 +54,7 @@ type ElectronupConfigFnPromise = (env: ConfigEnv) => Promise<ElectronupConfig>;
54
54
  type ElectronupConfigFn = (env: ConfigEnv) => ElectronupConfig | Promise<ElectronupConfig>;
55
55
  type ElectronupConfigExport = ElectronupConfig | Promise<ElectronupConfig> | ElectronupConfigFnObject | ElectronupConfigFnPromise | ElectronupConfigFn;
56
56
  //#endregion
57
- //#region index.d.ts
57
+ //#region src/index.d.ts
58
58
  declare function defineConfig(config: ElectronupConfig): ElectronupConfig;
59
59
  declare function defineConfig(config: Promise<ElectronupConfig>): Promise<ElectronupConfig>;
60
60
  declare function defineConfig(config: ElectronupConfigFnObject): ElectronupConfigFnObject;
@@ -1,7 +1,8 @@
1
- //#region index.ts
1
+ //#region src/index.ts
2
2
  function defineConfig(config) {
3
3
  return config;
4
4
  }
5
+ console.log("test :>> ");
5
6
 
6
7
  //#endregion
7
8
  export { defineConfig };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "electronup",
3
- "version": "0.2.1",
3
+ "version": "0.2.3",
4
4
  "description": "融合构建 electron 应用需要的构建工具,保留原有配置习惯的命令行工具 ",
5
5
  "author": "quiteer",
6
6
  "license": "MIT",