@simplysm/sd-cli 12.5.21 → 12.5.22
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/dist/{build-tools → entry}/SdCliCordova.d.ts +5 -6
- package/dist/{build-tools → entry}/SdCliCordova.js +117 -99
- package/dist/entry/SdCliCordova.js.map +1 -0
- package/dist/entry/SdCliElectron.d.ts +2 -2
- package/dist/entry/SdCliElectron.js +50 -40
- package/dist/entry/SdCliElectron.js.map +1 -1
- package/dist/entry/SdCliLocalUpdate.d.ts +1 -2
- package/dist/entry/SdCliLocalUpdate.js +26 -27
- package/dist/entry/SdCliLocalUpdate.js.map +1 -1
- package/dist/entry/SdCliProject.d.ts +1 -5
- package/dist/entry/SdCliProject.js +62 -288
- package/dist/entry/SdCliProject.js.map +1 -1
- package/dist/index.d.ts +23 -20
- package/dist/index.js +23 -20
- package/dist/index.js.map +1 -1
- package/dist/pkg-builders/SdMultiBuildRunner.d.ts +21 -0
- package/dist/pkg-builders/SdMultiBuildRunner.js +174 -0
- package/dist/pkg-builders/SdMultiBuildRunner.js.map +1 -0
- package/dist/pkg-builders/client/SdCliNgRoutesFileGenerator.d.ts +4 -0
- package/dist/{build-tools → pkg-builders/client}/SdCliNgRoutesFileGenerator.js +7 -7
- package/dist/pkg-builders/client/SdCliNgRoutesFileGenerator.js.map +1 -0
- package/dist/pkg-builders/client/SdClientBuildRunner.d.ts +20 -0
- package/dist/pkg-builders/client/SdClientBuildRunner.js +135 -0
- package/dist/pkg-builders/client/SdClientBuildRunner.js.map +1 -0
- package/dist/pkg-builders/client/SdNgBundler.d.ts +29 -0
- package/dist/{build-tools → pkg-builders/client}/SdNgBundler.js +100 -95
- package/dist/pkg-builders/client/SdNgBundler.js.map +1 -0
- package/dist/{build-tools → pkg-builders/client}/SdNgBundlerContext.d.ts +1 -2
- package/dist/{build-tools → pkg-builders/client}/SdNgBundlerContext.js +19 -45
- package/dist/pkg-builders/client/SdNgBundlerContext.js.map +1 -0
- package/dist/pkg-builders/client/createSdNgPlugin.d.ts +10 -0
- package/dist/{bundle-plugins/sdNgPlugin.js → pkg-builders/client/createSdNgPlugin.js} +32 -33
- package/dist/pkg-builders/client/createSdNgPlugin.js.map +1 -0
- package/dist/pkg-builders/lib/SdCliIndexFileGenerator.d.ts +5 -0
- package/dist/{build-tools → pkg-builders/lib}/SdCliIndexFileGenerator.js +11 -11
- package/dist/pkg-builders/lib/SdCliIndexFileGenerator.js.map +1 -0
- package/dist/pkg-builders/lib/SdJsLibBuildRunner.d.ts +16 -0
- package/dist/pkg-builders/lib/SdJsLibBuildRunner.js +81 -0
- package/dist/pkg-builders/lib/SdJsLibBuildRunner.js.map +1 -0
- package/dist/pkg-builders/lib/SdTsLibBuildRunner.d.ts +13 -0
- package/dist/pkg-builders/lib/SdTsLibBuildRunner.js +89 -0
- package/dist/pkg-builders/lib/SdTsLibBuildRunner.js.map +1 -0
- package/dist/pkg-builders/lib/SdTsLibBuilder.d.ts +14 -0
- package/dist/pkg-builders/lib/SdTsLibBuilder.js +54 -0
- package/dist/pkg-builders/lib/SdTsLibBuilder.js.map +1 -0
- package/dist/pkg-builders/server/SdServerBuildRunner.d.ts +17 -0
- package/dist/{builders/SdCliServerBuilder.js → pkg-builders/server/SdServerBuildRunner.js} +48 -53
- package/dist/pkg-builders/server/SdServerBuildRunner.js.map +1 -0
- package/dist/pkg-builders/server/SdServerBundler.d.ts +19 -0
- package/dist/{build-tools → pkg-builders/server}/SdServerBundler.js +25 -30
- package/dist/pkg-builders/server/SdServerBundler.js.map +1 -0
- package/dist/pkg-builders/server/createSdServerPlugin.d.ts +10 -0
- package/dist/pkg-builders/server/createSdServerPlugin.js +53 -0
- package/dist/pkg-builders/server/createSdServerPlugin.js.map +1 -0
- package/dist/sd-cli.js +61 -54
- package/dist/sd-cli.js.map +1 -1
- package/dist/ts-builder/SdTsCompileWorker.d.ts +9 -0
- package/dist/ts-builder/SdTsCompileWorker.js +16 -0
- package/dist/ts-builder/SdTsCompileWorker.js.map +1 -0
- package/dist/ts-builder/SdTsCompiler.d.ts +7 -0
- package/dist/{build-tools → ts-builder}/SdTsCompiler.js +226 -212
- package/dist/ts-builder/SdTsCompiler.js.map +1 -0
- package/dist/types/build-plugin.type.d.ts +14 -0
- package/dist/types/build-plugin.type.js +2 -0
- package/dist/types/build-plugin.type.js.map +1 -0
- package/dist/types/build.type.d.ts +15 -0
- package/dist/types/build.type.js +2 -0
- package/dist/types/build.type.js.map +1 -0
- package/dist/types/common-configs.type.d.ts +22 -0
- package/dist/types/common-configs.type.js +2 -0
- package/dist/types/common-configs.type.js.map +1 -0
- package/dist/types/sd-configs.type.d.ts +99 -0
- package/dist/types/sd-configs.type.js +2 -0
- package/dist/types/sd-configs.type.js.map +1 -0
- package/dist/types/ts-compiler.type.d.ts +29 -0
- package/dist/types/ts-compiler.type.js +2 -0
- package/dist/types/ts-compiler.type.js.map +1 -0
- package/dist/types/workers.type.d.ts +49 -0
- package/dist/types/workers.type.js +2 -0
- package/dist/types/workers.type.js.map +1 -0
- package/dist/utils/SdCliConvertMessageUtil.d.ts +21 -0
- package/dist/utils/SdCliConvertMessageUtil.js +137 -0
- package/dist/utils/SdCliConvertMessageUtil.js.map +1 -0
- package/dist/workers/compile-worker.js +27 -0
- package/dist/workers/compile-worker.js.map +1 -0
- package/dist/workers/lint-worker.js +36 -0
- package/dist/workers/lint-worker.js.map +1 -0
- package/dist/workers/server-worker.d.ts +1 -0
- package/dist/workers/server-worker.js +49 -0
- package/dist/workers/server-worker.js.map +1 -0
- package/lib/dev-worker.cjs +5 -0
- package/package.json +7 -10
- package/src/entry/SdCliCordova.ts +363 -0
- package/src/entry/SdCliElectron.ts +96 -69
- package/src/entry/SdCliLocalUpdate.ts +43 -44
- package/src/entry/SdCliProject.ts +72 -417
- package/src/index.ts +23 -20
- package/src/pkg-builders/SdMultiBuildRunner.ts +250 -0
- package/src/{build-tools → pkg-builders/client}/SdCliNgRoutesFileGenerator.ts +7 -7
- package/src/pkg-builders/client/SdClientBuildRunner.ts +191 -0
- package/src/{build-tools → pkg-builders/client}/SdNgBundler.ts +125 -121
- package/src/pkg-builders/client/SdNgBundlerContext.ts +111 -0
- package/src/{bundle-plugins/sdNgPlugin.ts → pkg-builders/client/createSdNgPlugin.ts} +43 -46
- package/src/{build-tools → pkg-builders/lib}/SdCliIndexFileGenerator.ts +11 -11
- package/src/pkg-builders/lib/SdJsLibBuildRunner.ts +105 -0
- package/src/pkg-builders/lib/SdTsLibBuildRunner.ts +128 -0
- package/src/pkg-builders/lib/SdTsLibBuilder.ts +69 -0
- package/src/{builders/SdCliServerBuilder.ts → pkg-builders/server/SdServerBuildRunner.ts} +66 -78
- package/src/{build-tools → pkg-builders/server}/SdServerBundler.ts +40 -41
- package/src/pkg-builders/server/createSdServerPlugin.ts +77 -0
- package/src/sd-cli.ts +197 -211
- package/src/ts-builder/SdTsCompileWorker.ts +21 -0
- package/src/ts-builder/SdTsCompiler.ts +758 -0
- package/src/types/build-plugin.type.ts +16 -0
- package/src/types/build.type.ts +17 -0
- package/src/types/common-configs.type.ts +27 -0
- package/src/types/sd-configs.type.ts +114 -0
- package/src/types/ts-compiler.type.ts +29 -0
- package/src/types/workers.type.ts +27 -0
- package/src/utils/SdCliConvertMessageUtil.ts +177 -0
- package/src/workers/compile-worker.ts +31 -0
- package/src/workers/lint-worker.ts +44 -0
- package/src/workers/server-worker.ts +52 -0
- package/tsconfig.json +7 -1
- package/dist/build-cluster.js +0 -201
- package/dist/build-cluster.js.map +0 -1
- package/dist/build-tools/SdCliCordova.js.map +0 -1
- package/dist/build-tools/SdCliIndexFileGenerator.d.ts +0 -5
- package/dist/build-tools/SdCliIndexFileGenerator.js.map +0 -1
- package/dist/build-tools/SdCliNgRoutesFileGenerator.d.ts +0 -4
- package/dist/build-tools/SdCliNgRoutesFileGenerator.js.map +0 -1
- package/dist/build-tools/SdLinter.d.ts +0 -5
- package/dist/build-tools/SdLinter.js +0 -49
- package/dist/build-tools/SdLinter.js.map +0 -1
- package/dist/build-tools/SdNgBundler.d.ts +0 -29
- package/dist/build-tools/SdNgBundler.js.map +0 -1
- package/dist/build-tools/SdNgBundlerContext.js.map +0 -1
- package/dist/build-tools/SdReactBundler.d.ts +0 -25
- package/dist/build-tools/SdReactBundler.js +0 -295
- package/dist/build-tools/SdReactBundler.js.map +0 -1
- package/dist/build-tools/SdReactBundlerContext.d.ts +0 -14
- package/dist/build-tools/SdReactBundlerContext.js +0 -59
- package/dist/build-tools/SdReactBundlerContext.js.map +0 -1
- package/dist/build-tools/SdServerBundler.d.ts +0 -20
- package/dist/build-tools/SdServerBundler.js.map +0 -1
- package/dist/build-tools/SdTsCompiler.d.ts +0 -34
- package/dist/build-tools/SdTsCompiler.js.map +0 -1
- package/dist/build-tools/SdTsLibBundler.d.ts +0 -13
- package/dist/build-tools/SdTsLibBundler.js +0 -58
- package/dist/build-tools/SdTsLibBundler.js.map +0 -1
- package/dist/builders/SdCliClientBuilder.d.ts +0 -18
- package/dist/builders/SdCliClientBuilder.js +0 -172
- package/dist/builders/SdCliClientBuilder.js.map +0 -1
- package/dist/builders/SdCliJsLibLinter.d.ts +0 -13
- package/dist/builders/SdCliJsLibLinter.js +0 -60
- package/dist/builders/SdCliJsLibLinter.js.map +0 -1
- package/dist/builders/SdCliServerBuilder.d.ts +0 -15
- package/dist/builders/SdCliServerBuilder.js.map +0 -1
- package/dist/builders/SdCliTsLibBuilder.d.ts +0 -12
- package/dist/builders/SdCliTsLibBuilder.js +0 -90
- package/dist/builders/SdCliTsLibBuilder.js.map +0 -1
- package/dist/bundle-plugins/sdNgPlugin.d.ts +0 -16
- package/dist/bundle-plugins/sdNgPlugin.js.map +0 -1
- package/dist/bundle-plugins/sdReactPlugin.d.ts +0 -16
- package/dist/bundle-plugins/sdReactPlugin.js +0 -117
- package/dist/bundle-plugins/sdReactPlugin.js.map +0 -1
- package/dist/bundle-plugins/sdServerPlugin.d.ts +0 -16
- package/dist/bundle-plugins/sdServerPlugin.js +0 -63
- package/dist/bundle-plugins/sdServerPlugin.js.map +0 -1
- package/dist/commons.d.ts +0 -145
- package/dist/commons.js +0 -2
- package/dist/commons.js.map +0 -1
- package/dist/server-worker.js +0 -57
- package/dist/server-worker.js.map +0 -1
- package/dist/utils/SdCliBuildResultUtil.d.ts +0 -16
- package/dist/utils/SdCliBuildResultUtil.js +0 -54
- package/dist/utils/SdCliBuildResultUtil.js.map +0 -1
- package/src/build-cluster.ts +0 -212
- package/src/build-tools/SdCliCordova.ts +0 -340
- package/src/build-tools/SdLinter.ts +0 -65
- package/src/build-tools/SdNgBundlerContext.ts +0 -137
- package/src/build-tools/SdReactBundler.ts +0 -372
- package/src/build-tools/SdReactBundlerContext.ts +0 -71
- package/src/build-tools/SdTsCompiler.ts +0 -754
- package/src/build-tools/SdTsLibBundler.ts +0 -72
- package/src/builders/SdCliClientBuilder.ts +0 -233
- package/src/builders/SdCliJsLibLinter.ts +0 -72
- package/src/builders/SdCliTsLibBuilder.ts +0 -126
- package/src/bundle-plugins/sdReactPlugin.ts +0 -164
- package/src/bundle-plugins/sdServerPlugin.ts +0 -94
- package/src/commons.ts +0 -171
- package/src/server-worker.ts +0 -65
- package/src/utils/SdCliBuildResultUtil.ts +0 -63
- /package/dist/{build-cluster.d.ts → workers/compile-worker.d.ts} +0 -0
- /package/dist/{server-worker.d.ts → workers/lint-worker.d.ts} +0 -0
|
@@ -1,64 +1,69 @@
|
|
|
1
|
-
import {FsUtil, Logger, SdProcess} from "@simplysm/sd-core-node";
|
|
2
|
-
import {pathToFileURL} from "url";
|
|
1
|
+
import { FsUtil, Logger, SdProcess } from "@simplysm/sd-core-node";
|
|
2
|
+
import { pathToFileURL } from "url";
|
|
3
3
|
import path from "path";
|
|
4
|
-
import {INpmConfig, ISdCliClientBuilderElectronConfig, ISdCliConfig} from "../commons";
|
|
5
4
|
import electronBuilder from "electron-builder";
|
|
5
|
+
import { ISdClientBuilderElectronConfig, ISdProjectConfig } from "../types/sd-configs.type";
|
|
6
|
+
import { INpmConfig } from "../types/common-configs.type";
|
|
6
7
|
|
|
7
8
|
export class SdCliElectron {
|
|
8
|
-
|
|
9
|
-
confFileRelPath: string;
|
|
10
|
-
optNames: string[];
|
|
11
|
-
pkgName: string;
|
|
12
|
-
}): Promise<void> {
|
|
9
|
+
static async runAsync(opt: { confFileRelPath: string; optNames: string[]; pkgName: string }): Promise<void> {
|
|
13
10
|
const logger = Logger.get(["simplysm", "sd-cli", "SdCliElectron", "runAsync"]);
|
|
14
11
|
|
|
15
12
|
const pkgPath = path.resolve(process.cwd(), `packages/${opt.pkgName}`);
|
|
16
13
|
const electronPath = path.resolve(pkgPath, "dist/electron");
|
|
17
14
|
|
|
18
15
|
logger.log("설정 가져오기...");
|
|
19
|
-
const projConf = (await import(pathToFileURL(path.resolve(process.cwd(), opt.confFileRelPath)).href)).default(
|
|
16
|
+
const projConf = (await import(pathToFileURL(path.resolve(process.cwd(), opt.confFileRelPath)).href)).default(
|
|
17
|
+
true,
|
|
18
|
+
opt.optNames,
|
|
19
|
+
) as ISdProjectConfig;
|
|
20
20
|
const pkgConf = projConf.packages[opt.pkgName];
|
|
21
21
|
if (pkgConf?.type !== "client" || pkgConf.builder?.electron === undefined) {
|
|
22
22
|
throw new Error();
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
logger.log("package.json 파일 쓰기...");
|
|
26
|
-
const npmConfig =
|
|
26
|
+
const npmConfig = FsUtil.readJson(path.resolve(pkgPath, `package.json`)) as INpmConfig;
|
|
27
27
|
|
|
28
28
|
const externalPkgNames = pkgConf.builder.electron.reinstallDependencies ?? [];
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
FsUtil.writeJson(path.resolve(electronPath, `package.json`), {
|
|
31
31
|
name: npmConfig.name.replace(/^@/, "").replace(/\//, "-"),
|
|
32
32
|
version: npmConfig.version,
|
|
33
33
|
description: npmConfig.description,
|
|
34
34
|
main: "electron-main.js",
|
|
35
|
-
...pkgConf.builder.electron.postInstallScript !== undefined
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
35
|
+
...(pkgConf.builder.electron.postInstallScript !== undefined
|
|
36
|
+
? {
|
|
37
|
+
scripts: {
|
|
38
|
+
postinstall: pkgConf.builder.electron.postInstallScript,
|
|
39
|
+
},
|
|
40
|
+
}
|
|
41
|
+
: {}),
|
|
42
|
+
dependencies: externalPkgNames.toObject(
|
|
43
|
+
(item) => item,
|
|
44
|
+
(item) => npmConfig.dependencies![item],
|
|
45
|
+
),
|
|
41
46
|
});
|
|
42
47
|
|
|
43
48
|
logger.log("npm install...");
|
|
44
|
-
await SdProcess.spawnAsync(`npm install`, {cwd: electronPath}, true);
|
|
49
|
+
await SdProcess.spawnAsync(`npm install`, { cwd: electronPath }, true);
|
|
45
50
|
|
|
46
51
|
for (const externalPkgName of externalPkgNames) {
|
|
47
52
|
if (FsUtil.exists(path.resolve(electronPath, "node_modules", externalPkgName, "binding.gyp"))) {
|
|
48
53
|
logger.log(`electron rebuild (${externalPkgName})...`);
|
|
49
|
-
await SdProcess.spawnAsync(
|
|
54
|
+
await SdProcess.spawnAsync(
|
|
55
|
+
`electron-rebuild -m ./node_modules/${externalPkgName}`,
|
|
56
|
+
{ cwd: electronPath },
|
|
57
|
+
true,
|
|
58
|
+
);
|
|
50
59
|
}
|
|
51
60
|
}
|
|
52
61
|
|
|
53
62
|
logger.log("electron...");
|
|
54
|
-
await SdProcess.spawnAsync(`electron .`, {cwd: electronPath}, true);
|
|
63
|
+
await SdProcess.spawnAsync(`electron .`, { cwd: electronPath }, true);
|
|
55
64
|
}
|
|
56
65
|
|
|
57
|
-
|
|
58
|
-
confFileRelPath: string;
|
|
59
|
-
optNames: string[];
|
|
60
|
-
pkgName: string;
|
|
61
|
-
}): Promise<void> {
|
|
66
|
+
static async buildForDevAsync(opt: { confFileRelPath: string; optNames: string[]; pkgName: string }): Promise<void> {
|
|
62
67
|
const logger = Logger.get(["simplysm", "sd-cli", "SdCliElectron", "buildForDevAsync"]);
|
|
63
68
|
|
|
64
69
|
const pkgPath = path.resolve(process.cwd(), `packages/${opt.pkgName}`);
|
|
@@ -66,37 +71,49 @@ export class SdCliElectron {
|
|
|
66
71
|
const electronDistPath = path.resolve(pkgPath, ".electron/dist");
|
|
67
72
|
|
|
68
73
|
logger.log("설정 가져오기...");
|
|
69
|
-
const projConf = (await import(pathToFileURL(path.resolve(process.cwd(), opt.confFileRelPath)).href)).default(
|
|
74
|
+
const projConf = (await import(pathToFileURL(path.resolve(process.cwd(), opt.confFileRelPath)).href)).default(
|
|
75
|
+
true,
|
|
76
|
+
opt.optNames,
|
|
77
|
+
) as ISdProjectConfig;
|
|
70
78
|
const pkgConf = projConf.packages[opt.pkgName];
|
|
71
79
|
if (pkgConf?.type !== "client" || pkgConf.builder?.electron === undefined) {
|
|
72
80
|
throw new Error();
|
|
73
81
|
}
|
|
74
82
|
|
|
75
83
|
logger.log("package.json 파일 쓰기...");
|
|
76
|
-
const npmConfig =
|
|
84
|
+
const npmConfig = FsUtil.readJson(path.resolve(pkgPath, `package.json`)) as INpmConfig;
|
|
77
85
|
|
|
78
86
|
const externalPkgNames = pkgConf.builder.electron.reinstallDependencies ?? [];
|
|
79
87
|
|
|
80
|
-
|
|
88
|
+
FsUtil.writeJson(path.resolve(electronPath, `package.json`), {
|
|
81
89
|
name: npmConfig.name.replace(/^@/, "").replace(/\//, "-"),
|
|
82
90
|
version: npmConfig.version,
|
|
83
91
|
description: npmConfig.description,
|
|
84
92
|
main: "electron-main.js",
|
|
85
|
-
...pkgConf.builder.electron.postInstallScript !== undefined
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
93
|
+
...(pkgConf.builder.electron.postInstallScript !== undefined
|
|
94
|
+
? {
|
|
95
|
+
scripts: {
|
|
96
|
+
postinstall: pkgConf.builder.electron.postInstallScript,
|
|
97
|
+
},
|
|
98
|
+
}
|
|
99
|
+
: {}),
|
|
100
|
+
dependencies: externalPkgNames.toObject(
|
|
101
|
+
(item) => item,
|
|
102
|
+
(item) => npmConfig.dependencies![item],
|
|
103
|
+
),
|
|
91
104
|
});
|
|
92
105
|
|
|
93
106
|
logger.log("npm install...");
|
|
94
|
-
await SdProcess.spawnAsync(`npm install`, {cwd: electronPath}, true);
|
|
107
|
+
await SdProcess.spawnAsync(`npm install`, { cwd: electronPath }, true);
|
|
95
108
|
|
|
96
109
|
for (const externalPkgName of externalPkgNames) {
|
|
97
110
|
if (FsUtil.exists(path.resolve(electronPath, "node_modules", externalPkgName, "binding.gyp"))) {
|
|
98
111
|
logger.log(`electron rebuild (${externalPkgName})...`);
|
|
99
|
-
await SdProcess.spawnAsync(
|
|
112
|
+
await SdProcess.spawnAsync(
|
|
113
|
+
`electron-rebuild -m ./node_modules/${externalPkgName}`,
|
|
114
|
+
{ cwd: electronPath },
|
|
115
|
+
true,
|
|
116
|
+
);
|
|
100
117
|
}
|
|
101
118
|
}
|
|
102
119
|
|
|
@@ -109,60 +126,68 @@ export class SdCliElectron {
|
|
|
109
126
|
productName: npmConfig.description,
|
|
110
127
|
asar: false,
|
|
111
128
|
win: {
|
|
112
|
-
target: "nsis"
|
|
129
|
+
target: "nsis",
|
|
113
130
|
},
|
|
114
131
|
nsis: {},
|
|
115
132
|
directories: {
|
|
116
133
|
app: electronPath,
|
|
117
|
-
output: electronDistPath
|
|
134
|
+
output: electronDistPath,
|
|
118
135
|
},
|
|
119
|
-
...pkgConf.builder.electron.installerIcon !== undefined
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
136
|
+
...(pkgConf.builder.electron.installerIcon !== undefined
|
|
137
|
+
? {
|
|
138
|
+
icon: path.resolve(pkgPath, "src", pkgConf.builder.electron.installerIcon),
|
|
139
|
+
}
|
|
140
|
+
: {}),
|
|
141
|
+
removePackageScripts: false,
|
|
142
|
+
},
|
|
124
143
|
});
|
|
125
144
|
|
|
126
|
-
|
|
145
|
+
FsUtil.copy(
|
|
127
146
|
path.resolve(electronDistPath, `${npmConfig.description} Setup ${npmConfig.version}.exe`),
|
|
128
|
-
path.resolve(pkgPath, `dist/electron/${npmConfig.description}-dev.exe`)
|
|
147
|
+
path.resolve(pkgPath, `dist/electron/${npmConfig.description}-dev.exe`),
|
|
129
148
|
);
|
|
130
149
|
}
|
|
131
150
|
|
|
132
|
-
|
|
133
|
-
pkgPath: string;
|
|
134
|
-
config: ISdCliClientBuilderElectronConfig;
|
|
135
|
-
}): Promise<void> {
|
|
151
|
+
static async buildAsync(opt: { pkgPath: string; config: ISdClientBuilderElectronConfig }): Promise<void> {
|
|
136
152
|
const logger = Logger.get(["simplysm", "sd-cli", "SdCliElectron", "buildAsync"]);
|
|
137
153
|
|
|
138
154
|
const electronSrcPath = path.resolve(opt.pkgPath, ".electron/src");
|
|
139
155
|
const electronDistPath = path.resolve(opt.pkgPath, ".electron/dist");
|
|
140
156
|
|
|
141
157
|
logger.log("package.json 파일 쓰기...");
|
|
142
|
-
const npmConfig =
|
|
158
|
+
const npmConfig = FsUtil.readJson(path.resolve(opt.pkgPath, `package.json`)) as INpmConfig;
|
|
143
159
|
|
|
144
160
|
const externalPkgNames = opt.config.reinstallDependencies ?? [];
|
|
145
161
|
|
|
146
|
-
|
|
162
|
+
FsUtil.writeJson(path.resolve(electronSrcPath, `package.json`), {
|
|
147
163
|
name: npmConfig.name.replace(/^@/, "").replace(/\//, "-"),
|
|
148
164
|
version: npmConfig.version,
|
|
149
165
|
description: npmConfig.description,
|
|
150
166
|
main: "electron-main.js",
|
|
151
|
-
...opt.config.postInstallScript !== undefined
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
167
|
+
...(opt.config.postInstallScript !== undefined
|
|
168
|
+
? {
|
|
169
|
+
scripts: {
|
|
170
|
+
postinstall: opt.config.postInstallScript,
|
|
171
|
+
},
|
|
172
|
+
}
|
|
173
|
+
: {}),
|
|
174
|
+
dependencies: externalPkgNames.toObject(
|
|
175
|
+
(item) => item,
|
|
176
|
+
(item) => npmConfig.dependencies![item],
|
|
177
|
+
),
|
|
157
178
|
});
|
|
158
179
|
|
|
159
180
|
logger.log("npm install...");
|
|
160
|
-
await SdProcess.spawnAsync(`npm install`, {cwd: electronSrcPath}, true);
|
|
181
|
+
await SdProcess.spawnAsync(`npm install`, { cwd: electronSrcPath }, true);
|
|
161
182
|
|
|
162
183
|
for (const externalPkgName of externalPkgNames) {
|
|
163
184
|
if (FsUtil.exists(path.resolve(electronSrcPath, "node_modules", externalPkgName, "binding.gyp"))) {
|
|
164
185
|
logger.log(`electron rebuild (${externalPkgName})...`);
|
|
165
|
-
await SdProcess.spawnAsync(
|
|
186
|
+
await SdProcess.spawnAsync(
|
|
187
|
+
`electron-rebuild -m ./node_modules/${externalPkgName}`,
|
|
188
|
+
{ cwd: electronSrcPath },
|
|
189
|
+
true,
|
|
190
|
+
);
|
|
166
191
|
}
|
|
167
192
|
}
|
|
168
193
|
|
|
@@ -175,23 +200,25 @@ export class SdCliElectron {
|
|
|
175
200
|
productName: npmConfig.description,
|
|
176
201
|
asar: false,
|
|
177
202
|
win: {
|
|
178
|
-
target: "nsis"
|
|
203
|
+
target: "nsis",
|
|
179
204
|
},
|
|
180
205
|
nsis: {},
|
|
181
206
|
directories: {
|
|
182
207
|
app: electronSrcPath,
|
|
183
|
-
output: electronDistPath
|
|
208
|
+
output: electronDistPath,
|
|
184
209
|
},
|
|
185
|
-
...opt.config.installerIcon !== undefined
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
210
|
+
...(opt.config.installerIcon !== undefined
|
|
211
|
+
? {
|
|
212
|
+
icon: path.resolve(opt.pkgPath, "src", opt.config.installerIcon),
|
|
213
|
+
}
|
|
214
|
+
: {}),
|
|
215
|
+
removePackageScripts: false,
|
|
216
|
+
},
|
|
190
217
|
});
|
|
191
218
|
|
|
192
|
-
|
|
219
|
+
FsUtil.copy(
|
|
193
220
|
path.resolve(electronDistPath, `${npmConfig.description} Setup ${npmConfig.version}.exe`),
|
|
194
|
-
path.resolve(opt.pkgPath, `dist/electron/${npmConfig.description}-latest.exe`)
|
|
221
|
+
path.resolve(opt.pkgPath, `dist/electron/${npmConfig.description}-latest.exe`),
|
|
195
222
|
);
|
|
196
223
|
}
|
|
197
|
-
}
|
|
224
|
+
}
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import {FsUtil, Logger, PathUtil, SdFsWatcher} from "@simplysm/sd-core-node";
|
|
1
|
+
import { FsUtil, Logger, PathUtil, SdFsWatcher } from "@simplysm/sd-core-node";
|
|
2
2
|
import path from "path";
|
|
3
|
-
import {pathToFileURL} from "url";
|
|
4
|
-
import {
|
|
3
|
+
import { pathToFileURL } from "url";
|
|
4
|
+
import { ISdProjectConfig } from "../types/sd-configs.type";
|
|
5
5
|
|
|
6
6
|
export class SdCliLocalUpdate {
|
|
7
|
-
|
|
8
|
-
confFileRelPath: string;
|
|
9
|
-
optNames: string[];
|
|
10
|
-
}): Promise<void> {
|
|
7
|
+
static async runAsync(opt: { confFileRelPath: string; optNames: string[] }): Promise<void> {
|
|
11
8
|
const logger = Logger.get(["simplysm", "sd-cli", "SdCliLocalUpdate", "runAsync"]);
|
|
12
9
|
|
|
13
10
|
logger.debug("프로젝트 설정 가져오기...");
|
|
14
|
-
const projConf = (await import(pathToFileURL(path.resolve(process.cwd(), opt.confFileRelPath)).href)).default(
|
|
11
|
+
const projConf = (await import(pathToFileURL(path.resolve(process.cwd(), opt.confFileRelPath)).href)).default(
|
|
12
|
+
true,
|
|
13
|
+
opt.optNames,
|
|
14
|
+
) as ISdProjectConfig;
|
|
15
15
|
if (!projConf.localUpdates) return;
|
|
16
16
|
|
|
17
|
-
const updatePathInfos =
|
|
17
|
+
const updatePathInfos = this.#getUpdatePathInfos(projConf.localUpdates);
|
|
18
18
|
logger.debug("로컬 업데이트 구성", updatePathInfos);
|
|
19
19
|
|
|
20
20
|
logger.log("로컬 라이브러리 업데이트 시작...");
|
|
@@ -25,94 +25,93 @@ export class SdCliLocalUpdate {
|
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
// 소스경로에서 대상경로로 파일 복사
|
|
28
|
-
|
|
28
|
+
FsUtil.copy(updatePathInfo.source, updatePathInfo.target, (src) => {
|
|
29
29
|
return !src.includes("node_modules") && !src.endsWith("package.json");
|
|
30
30
|
});
|
|
31
31
|
}
|
|
32
32
|
logger.info("로컬 라이브러리 업데이트 완료");
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
|
|
36
|
-
confFileRelPath: string;
|
|
37
|
-
optNames: string[];
|
|
38
|
-
}): Promise<void> {
|
|
35
|
+
static async watchAsync(opt: { confFileRelPath: string; optNames: string[] }): Promise<void> {
|
|
39
36
|
const logger = Logger.get(["simplysm", "sd-cli", "SdCliLocalUpdate", "watchAsync"]);
|
|
40
37
|
|
|
41
38
|
logger.debug("프로젝트 설정 가져오기...");
|
|
42
|
-
const projConf = (await import(pathToFileURL(path.resolve(process.cwd(), opt.confFileRelPath)).href)).default(
|
|
39
|
+
const projConf = (await import(pathToFileURL(path.resolve(process.cwd(), opt.confFileRelPath)).href)).default(
|
|
40
|
+
true,
|
|
41
|
+
opt.optNames,
|
|
42
|
+
) as ISdProjectConfig;
|
|
43
43
|
if (!projConf.localUpdates) return;
|
|
44
44
|
|
|
45
|
-
const updatePathInfos =
|
|
45
|
+
const updatePathInfos = this.#getUpdatePathInfos(projConf.localUpdates);
|
|
46
46
|
logger.debug("로컬 업데이트 구성");
|
|
47
47
|
|
|
48
|
-
const watchPaths =
|
|
48
|
+
const watchPaths = updatePathInfos.mapMany((item) => this.#getWatchPaths(item.source)).distinct();
|
|
49
49
|
|
|
50
50
|
const watcher = SdFsWatcher.watch(watchPaths);
|
|
51
|
-
watcher.onChange({delay: 1000},
|
|
52
|
-
const
|
|
53
|
-
if (
|
|
51
|
+
watcher.onChange({ delay: 1000 }, (changedInfos) => {
|
|
52
|
+
const changedFileInfos = changedInfos.filter((item) => ["add", "change", "unlink"].includes(item.event));
|
|
53
|
+
if (changedFileInfos.length === 0) return;
|
|
54
54
|
|
|
55
55
|
logger.log("로컬 라이브러리 변경감지...");
|
|
56
|
-
for (const changedFilePath of changeFilePaths) {
|
|
57
|
-
if (!FsUtil.exists(changedFilePath)) continue;
|
|
58
56
|
|
|
57
|
+
for (const changedFileInfo of changedFileInfos) {
|
|
59
58
|
for (const updatePathInfo of updatePathInfos) {
|
|
60
|
-
if (!PathUtil.isChildPath(
|
|
61
|
-
|
|
62
|
-
const sourceRelPath = path.relative(updatePathInfo.source, changedFilePath);
|
|
63
|
-
// if (sourceRelPath.includes("node_modules")) continue;
|
|
64
|
-
// if (sourceRelPath.includes("package.json")) continue;
|
|
59
|
+
if (!PathUtil.isChildPath(changedFileInfo.path, updatePathInfo.source)) continue;
|
|
65
60
|
|
|
61
|
+
const sourceRelPath = path.relative(updatePathInfo.source, changedFileInfo.path);
|
|
66
62
|
const targetFilePath = path.resolve(updatePathInfo.target, sourceRelPath);
|
|
67
63
|
|
|
68
|
-
|
|
69
|
-
|
|
64
|
+
if (changedFileInfo.event === "unlink") {
|
|
65
|
+
logger.debug(`변경파일감지(삭제): ${targetFilePath}`);
|
|
66
|
+
FsUtil.remove(targetFilePath);
|
|
67
|
+
} else {
|
|
68
|
+
logger.debug(`변경파일감지(복사): ${changedFileInfo.path} => ${targetFilePath}`);
|
|
69
|
+
FsUtil.copy(changedFileInfo.path, targetFilePath);
|
|
70
|
+
}
|
|
70
71
|
}
|
|
71
72
|
}
|
|
72
73
|
|
|
73
|
-
const watchFileSet = new Set(
|
|
74
|
-
|
|
74
|
+
const watchFileSet = new Set(updatePathInfos.mapMany((item) => this.#getWatchPaths(item.source)));
|
|
75
|
+
|
|
76
|
+
watcher.replaceWatchPaths(watchFileSet);
|
|
75
77
|
|
|
76
78
|
logger.info("로컬 라이브러리 복사 완료");
|
|
77
79
|
});
|
|
78
80
|
}
|
|
79
81
|
|
|
80
|
-
|
|
82
|
+
static #getUpdatePathInfos(record: Record<string, string>): IUpdatePathInfo[] {
|
|
81
83
|
const result: IUpdatePathInfo[] = [];
|
|
82
84
|
for (const pkgGlobPath of Object.keys(record)) {
|
|
83
85
|
// "node_modules'에서 로컬업데이트 설정에 맞는 패키지를 "glob"하여 대상 패키지경로 목록 가져오기
|
|
84
86
|
const targetPaths = [
|
|
85
|
-
...
|
|
86
|
-
...
|
|
87
|
+
...FsUtil.glob(path.resolve(process.cwd(), "node_modules", pkgGlobPath)),
|
|
88
|
+
...FsUtil.glob(path.resolve(process.cwd(), "packages", "*", "node_modules", pkgGlobPath)),
|
|
87
89
|
];
|
|
88
90
|
|
|
89
91
|
result.push(
|
|
90
92
|
...targetPaths
|
|
91
93
|
.map((targetPath) => {
|
|
92
94
|
// 대상의 명칭 추출
|
|
93
|
-
const regexpText = pkgGlobPath.replace(/[\\/.*]/g, (item) =>
|
|
94
|
-
item === "/" ? "[\\\\\\/]"
|
|
95
|
-
|
|
96
|
-
: item === "*" ? "(.*)"
|
|
97
|
-
: item
|
|
98
|
-
));
|
|
95
|
+
const regexpText = pkgGlobPath.replace(/[\\/.*]/g, (item) =>
|
|
96
|
+
item === "/" ? "[\\\\\\/]" : item === "." ? "\\." : item === "*" ? "(.*)" : item,
|
|
97
|
+
);
|
|
99
98
|
const targetNameMatch = new RegExp(regexpText).exec(targetPath);
|
|
100
99
|
if (!targetNameMatch || typeof targetNameMatch[1] === "undefined") return undefined;
|
|
101
100
|
const targetName = targetNameMatch[1];
|
|
102
101
|
|
|
103
102
|
// 가져올 소스 경로 추출
|
|
104
103
|
const sourcePath = path.resolve(record[pkgGlobPath].replace(/\*/g, targetName));
|
|
105
|
-
return {source: sourcePath, target: targetPath};
|
|
104
|
+
return { source: sourcePath, target: targetPath };
|
|
106
105
|
})
|
|
107
|
-
.filterExists()
|
|
106
|
+
.filterExists(),
|
|
108
107
|
);
|
|
109
108
|
}
|
|
110
109
|
|
|
111
110
|
return result;
|
|
112
111
|
}
|
|
113
112
|
|
|
114
|
-
|
|
115
|
-
return
|
|
113
|
+
static #getWatchPaths(sourcePath: string): string[] {
|
|
114
|
+
return FsUtil.glob(path.resolve(sourcePath, "**"));
|
|
116
115
|
}
|
|
117
116
|
}
|
|
118
117
|
|