@simplysm/sd-cli 7.0.224 → 7.0.231

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.
@@ -1,81 +1,81 @@
1
- import { FsUtil, Logger, SdProcess } from "@simplysm/sd-core-node";
2
- import { INpmConfig, ISdCliClientPackageConfig } from "../commons";
3
- import path from "path";
4
- import { SdCliConfigUtil } from "../utils/SdCliConfigUtil";
5
- import ts from "typescript";
6
-
7
- export class SdCliElectron {
8
- private readonly _logger = Logger.get(["simplysm", "sd-cli", this.constructor.name]);
9
-
10
- public constructor(private readonly _rootPath: string) {
11
- }
12
-
13
- public async runWebviewOnDeviceAsync(pkgName: string, url: string, opt: { confFileRelPath: string; optNames: string[] }): Promise<void> {
14
- this._logger.debug("프로젝트 설정 가져오기...");
15
- const config = await SdCliConfigUtil.loadConfigAsync(path.resolve(this._rootPath, opt.confFileRelPath), true, opt.optNames);
16
- const pkgConfig = config.packages[pkgName] as ISdCliClientPackageConfig | undefined;
17
- if (!pkgConfig) throw new Error("패키지 설정을 찾을 수 없습니다.");
18
-
19
- const electronConfig = pkgConfig.builder?.electron;
20
- if (!electronConfig) throw new Error("ELECTRON 설정을 찾을 수 없습니다.");
21
-
22
- const pkgRootPath = path.resolve(this._rootPath, `packages/${pkgName}`);
23
- const electronSrcPath = path.resolve(pkgRootPath, `.electron/src`);
24
-
25
- await FsUtil.removeAsync(electronSrcPath);
26
-
27
- const npmConfig = (await FsUtil.readJsonAsync(path.resolve(pkgRootPath, `package.json`))) as INpmConfig;
28
- const electronVersion = npmConfig.dependencies?.["electron"];
29
- if (electronVersion === undefined) {
30
- throw new Error("ELECTRON 빌드 패키지의 'dependencies'에는 'electron'이 반드시 포함되어야 합니다.");
31
- }
32
-
33
- const dotenvVersion = npmConfig.dependencies?.["dotenv"];
34
- if (dotenvVersion === undefined) {
35
- throw new Error("ELECTRON 빌드 패키지의 'dependencies'에는 'dotenv'가 반드시 포함되어야 합니다.");
36
- }
37
-
38
- const remoteVersion = npmConfig.dependencies?.["@electron/remote"];
39
-
40
- await FsUtil.writeJsonAsync(path.resolve(electronSrcPath, `package.json`), {
41
- name: npmConfig.name,
42
- version: npmConfig.version,
43
- description: npmConfig.description,
44
- main: "electron.js",
45
- author: npmConfig.author,
46
- license: npmConfig.license,
47
- devDependencies: {
48
- "electron": electronVersion.replace("^", "")
49
- },
50
- dependencies: {
51
- "dotenv": dotenvVersion,
52
- ...remoteVersion !== undefined ? {
53
- "@electron/remote": remoteVersion
54
- } : {}
55
- }
56
- });
57
-
58
- if (FsUtil.exists(path.resolve(pkgRootPath, "src/favicon.ico"))) {
59
- await FsUtil.copyAsync(path.resolve(pkgRootPath, "src/favicon.ico"), path.resolve(electronSrcPath, "favicon.ico"));
60
- }
61
- if (FsUtil.exists(path.resolve(pkgRootPath, "src/assets"))) {
62
- await FsUtil.copyAsync(path.resolve(pkgRootPath, "src/assets"), path.resolve(electronSrcPath, "assets"));
63
- }
64
-
65
- await FsUtil.writeFileAsync(path.resolve(electronSrcPath, `.env`), [
66
- "NODE_ENV=development",
67
- `SD_TITLE=${npmConfig.description}`,
68
- `SD_VERSION=${npmConfig.version}`,
69
- `SD_ELECTRON_DEV_URL=${url.replace(/\/$/, "")}/${pkgName}/electron/`,
70
- (electronConfig.icon !== undefined) ? `SD_ELECTRON_ICON=${electronConfig.icon}` : `SD_ELECTRON_ICON=favicon.ico`,
71
- ...(pkgConfig.env !== undefined) ? Object.keys(pkgConfig.env).map((key) => `${key}=${pkgConfig.env![key]}`) : []
72
- ].filterExists().join("\n"));
73
-
74
- let electronTsFileContent = await FsUtil.readFileAsync(path.resolve(pkgRootPath, `src/electron.ts`));
75
- electronTsFileContent = "require(\"dotenv\").config({ path: `${__dirname}\\\\.env` });\n" + electronTsFileContent;
76
- const result = ts.transpileModule(electronTsFileContent, { compilerOptions: { module: ts.ModuleKind.CommonJS } });
77
- await FsUtil.writeFileAsync(path.resolve(electronSrcPath, "electron.js"), result.outputText);
78
-
79
- await SdProcess.spawnAsync(`electron ${electronSrcPath}`, { cwd: this._rootPath }, true);
80
- }
81
- }
1
+ import { FsUtil, Logger, SdProcess } from "@simplysm/sd-core-node";
2
+ import { INpmConfig, ISdCliClientPackageConfig } from "../commons";
3
+ import path from "path";
4
+ import { SdCliConfigUtil } from "../utils/SdCliConfigUtil";
5
+ import ts from "typescript";
6
+
7
+ export class SdCliElectron {
8
+ private readonly _logger = Logger.get(["simplysm", "sd-cli", this.constructor.name]);
9
+
10
+ public constructor(private readonly _rootPath: string) {
11
+ }
12
+
13
+ public async runWebviewOnDeviceAsync(pkgName: string, url: string, opt: { confFileRelPath: string; optNames: string[] }): Promise<void> {
14
+ this._logger.debug("프로젝트 설정 가져오기...");
15
+ const config = await SdCliConfigUtil.loadConfigAsync(path.resolve(this._rootPath, opt.confFileRelPath), true, opt.optNames);
16
+ const pkgConfig = config.packages[pkgName] as ISdCliClientPackageConfig | undefined;
17
+ if (!pkgConfig) throw new Error("패키지 설정을 찾을 수 없습니다.");
18
+
19
+ const electronConfig = pkgConfig.builder?.electron;
20
+ if (!electronConfig) throw new Error("ELECTRON 설정을 찾을 수 없습니다.");
21
+
22
+ const pkgRootPath = path.resolve(this._rootPath, `packages/${pkgName}`);
23
+ const electronSrcPath = path.resolve(pkgRootPath, `.electron/src`);
24
+
25
+ await FsUtil.removeAsync(electronSrcPath);
26
+
27
+ const npmConfig = (await FsUtil.readJsonAsync(path.resolve(pkgRootPath, `package.json`))) as INpmConfig;
28
+ const electronVersion = npmConfig.dependencies?.["electron"];
29
+ if (electronVersion === undefined) {
30
+ throw new Error("ELECTRON 빌드 패키지의 'dependencies'에는 'electron'이 반드시 포함되어야 합니다.");
31
+ }
32
+
33
+ const dotenvVersion = npmConfig.dependencies?.["dotenv"];
34
+ if (dotenvVersion === undefined) {
35
+ throw new Error("ELECTRON 빌드 패키지의 'dependencies'에는 'dotenv'가 반드시 포함되어야 합니다.");
36
+ }
37
+
38
+ const remoteVersion = npmConfig.dependencies?.["@electron/remote"];
39
+
40
+ await FsUtil.writeJsonAsync(path.resolve(electronSrcPath, `package.json`), {
41
+ name: npmConfig.name,
42
+ version: npmConfig.version,
43
+ description: npmConfig.description,
44
+ main: "electron.js",
45
+ author: npmConfig.author,
46
+ license: npmConfig.license,
47
+ devDependencies: {
48
+ "electron": electronVersion.replace("^", "")
49
+ },
50
+ dependencies: {
51
+ "dotenv": dotenvVersion,
52
+ ...remoteVersion !== undefined ? {
53
+ "@electron/remote": remoteVersion
54
+ } : {}
55
+ }
56
+ });
57
+
58
+ if (FsUtil.exists(path.resolve(pkgRootPath, "src/favicon.ico"))) {
59
+ await FsUtil.copyAsync(path.resolve(pkgRootPath, "src/favicon.ico"), path.resolve(electronSrcPath, "favicon.ico"));
60
+ }
61
+ if (FsUtil.exists(path.resolve(pkgRootPath, "src/assets"))) {
62
+ await FsUtil.copyAsync(path.resolve(pkgRootPath, "src/assets"), path.resolve(electronSrcPath, "assets"));
63
+ }
64
+
65
+ await FsUtil.writeFileAsync(path.resolve(electronSrcPath, `.env`), [
66
+ "NODE_ENV=development",
67
+ `SD_TITLE=${npmConfig.description}`,
68
+ `SD_VERSION=${npmConfig.version}`,
69
+ `SD_ELECTRON_DEV_URL=${url.replace(/\/$/, "")}/${pkgName}/electron/`,
70
+ (electronConfig.icon !== undefined) ? `SD_ELECTRON_ICON=${electronConfig.icon}` : `SD_ELECTRON_ICON=favicon.ico`,
71
+ ...(pkgConfig.env !== undefined) ? Object.keys(pkgConfig.env).map((key) => `${key}=${pkgConfig.env![key]}`) : []
72
+ ].filterExists().join("\n"));
73
+
74
+ let electronTsFileContent = await FsUtil.readFileAsync(path.resolve(pkgRootPath, `src/electron.ts`));
75
+ electronTsFileContent = "require(\"dotenv\").config({ path: `${__dirname}\\\\.env` });\n" + electronTsFileContent;
76
+ const result = ts.transpileModule(electronTsFileContent, { compilerOptions: { module: ts.ModuleKind.CommonJS } });
77
+ await FsUtil.writeFileAsync(path.resolve(electronSrcPath, "electron.js"), result.outputText);
78
+
79
+ await SdProcess.spawnAsync(`electron ${electronSrcPath}`, { cwd: this._rootPath }, true);
80
+ }
81
+ }