@simplysm/sd-cli 12.15.39 → 12.15.41
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/entry/SdCliCordova.d.ts +33 -1
- package/dist/entry/SdCliCordova.js +84 -88
- package/dist/entry/SdCliElectron.d.ts +5 -1
- package/dist/entry/SdCliElectron.js +21 -21
- package/dist/entry/SdCliLocalUpdate.d.ts +1 -1
- package/dist/entry/SdCliLocalUpdate.js +3 -3
- package/dist/entry/SdCliProject.d.ts +4 -1
- package/dist/entry/SdCliProject.js +11 -11
- package/dist/pkg-builders/SdProjectBuildRunner.d.ts +6 -1
- package/dist/pkg-builders/SdProjectBuildRunner.js +27 -27
- package/dist/pkg-builders/client/SdClientBuildRunner.d.ts +2 -1
- package/dist/pkg-builders/client/SdClientBuildRunner.js +8 -10
- package/dist/pkg-builders/client/SdNgBundler.d.ts +22 -1
- package/dist/pkg-builders/client/SdNgBundler.js +70 -80
- package/dist/pkg-builders/client/SdNgBundlerContext.d.ts +3 -1
- package/dist/pkg-builders/client/SdNgBundlerContext.js +9 -10
- package/dist/pkg-builders/lib/SdCliIndexFileGenerator.d.ts +2 -1
- package/dist/pkg-builders/lib/SdCliIndexFileGenerator.js +5 -5
- package/dist/pkg-builders/lib/SdJsLibBuildRunner.d.ts +1 -1
- package/dist/pkg-builders/lib/SdJsLibBuildRunner.js +2 -2
- package/dist/pkg-builders/lib/SdTsLibBuildRunner.d.ts +1 -1
- package/dist/pkg-builders/lib/SdTsLibBuildRunner.js +2 -3
- package/dist/pkg-builders/lib/SdTsLibBuilder.d.ts +2 -1
- package/dist/pkg-builders/lib/SdTsLibBuilder.js +7 -8
- package/dist/pkg-builders/server/SdServerBuildRunner.d.ts +3 -1
- package/dist/pkg-builders/server/SdServerBuildRunner.js +6 -7
- package/dist/pkg-builders/server/SdServerBundler.d.ts +6 -1
- package/dist/pkg-builders/server/SdServerBundler.js +21 -23
- package/dist/ts-compiler/ScopePathSet.d.ts +1 -1
- package/dist/ts-compiler/ScopePathSet.js +3 -4
- package/dist/ts-compiler/SdDepCache.d.ts +45 -1
- package/dist/ts-compiler/SdDepCache.js +71 -69
- package/dist/ts-compiler/SdStyleBundler.d.ts +5 -1
- package/dist/ts-compiler/SdStyleBundler.js +25 -26
- package/dist/ts-compiler/SdTsCompiler.d.ts +20 -1
- package/dist/ts-compiler/SdTsCompiler.js +122 -129
- package/dist/utils/SdCliPerformanceTimer.d.ts +2 -1
- package/dist/utils/SdCliPerformanceTimer.js +9 -9
- package/package.json +8 -8
- package/src/entry/SdCliCordova.ts +89 -89
- package/src/entry/SdCliElectron.ts +21 -21
- package/src/entry/SdCliLocalUpdate.ts +3 -3
- package/src/entry/SdCliProject.ts +11 -11
- package/src/pkg-builders/SdProjectBuildRunner.ts +27 -27
- package/src/pkg-builders/client/SdClientBuildRunner.ts +10 -10
- package/src/pkg-builders/client/SdNgBundler.ts +78 -78
- package/src/pkg-builders/client/SdNgBundlerContext.ts +10 -10
- package/src/pkg-builders/lib/SdCliIndexFileGenerator.ts +5 -5
- package/src/pkg-builders/lib/SdJsLibBuildRunner.ts +2 -2
- package/src/pkg-builders/lib/SdTsLibBuildRunner.ts +3 -3
- package/src/pkg-builders/lib/SdTsLibBuilder.ts +8 -8
- package/src/pkg-builders/server/SdServerBuildRunner.ts +7 -7
- package/src/pkg-builders/server/SdServerBundler.ts +23 -23
- package/src/ts-compiler/ScopePathSet.ts +4 -4
- package/src/ts-compiler/SdDepCache.ts +47 -47
- package/src/ts-compiler/SdStyleBundler.ts +26 -26
- package/src/ts-compiler/SdTsCompiler.ts +130 -130
- package/src/utils/SdCliPerformanceTimer.ts +9 -9
|
@@ -6,75 +6,75 @@ import { INpmConfig } from "../types/common-config/INpmConfig";
|
|
|
6
6
|
|
|
7
7
|
export class SdCliCordova {
|
|
8
8
|
// 상수 정의
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
9
|
+
private readonly _CORDOVA_DIR_NAME = ".cordova";
|
|
10
|
+
private readonly _PLATFORMS_DIR_NAME = "platforms";
|
|
11
|
+
private readonly _WWW_DIR_NAME = "www";
|
|
12
|
+
|
|
13
|
+
private readonly _PLUGINS_DIR_NAME = "plugins";
|
|
14
|
+
private readonly _PLUGINS_FETCH_FILE = "fetch.json";
|
|
15
|
+
private readonly _ANDROID_SDK_VERSION = "35"; //cordova-android@14
|
|
16
|
+
private readonly _KEYSTORE_FILE_NAME = "android.keystore";
|
|
17
|
+
private readonly _CONFIG_XML_FILE_NAME = "config.xml";
|
|
18
|
+
private readonly _CONFIG_XML_BACKUP_FILE_NAME = "config.xml.bak";
|
|
19
|
+
private readonly _BUILD_JSON_FILE_NAME = "build.json";
|
|
20
|
+
private readonly _ANDROID_SIGNING_PROP_PATH = "platforms/android/release-signing.properties";
|
|
21
|
+
private readonly _ICON_DIR_PATH = "res/icons";
|
|
22
|
+
private readonly _SPLASH_SCREEN_DIR_PATH = "res/screen/android";
|
|
23
|
+
private readonly _SPLASH_SCREEN_XML_FILE = "splashscreen.xml";
|
|
24
|
+
|
|
25
|
+
private readonly _platforms: string[];
|
|
26
|
+
private readonly _npmConfig: INpmConfig;
|
|
27
27
|
|
|
28
28
|
constructor(private readonly _opt: { pkgPath: string; config: ISdClientBuilderCordovaConfig }) {
|
|
29
|
-
this
|
|
30
|
-
this
|
|
29
|
+
this._platforms = Object.keys(this._opt.config.platform ?? { browser: {} });
|
|
30
|
+
this._npmConfig = FsUtils.readJson(path.resolve(this._opt.pkgPath, "package.json"));
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
static
|
|
33
|
+
private static readonly _logger = SdLogger.get(["simplysm", "sd-cli", "SdCliCordova"]);
|
|
34
34
|
|
|
35
|
-
static async
|
|
36
|
-
this
|
|
35
|
+
private static async _execAsync(cmd: string, args: string[], cwd: string): Promise<void> {
|
|
36
|
+
this._logger.debug(`실행 명령: ${cmd + " " + args.join(" ")}`);
|
|
37
37
|
const msg = await SdProcess.spawnAsync(cmd, args, { cwd });
|
|
38
|
-
this
|
|
38
|
+
this._logger.debug(`실행 결과: ${msg}`);
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
async initializeAsync(): Promise<void> {
|
|
42
|
-
const cordovaPath = path.resolve(this._opt.pkgPath, this
|
|
42
|
+
const cordovaPath = path.resolve(this._opt.pkgPath, this._CORDOVA_DIR_NAME);
|
|
43
43
|
|
|
44
44
|
// 1. Cordova 프로젝트 초기화
|
|
45
|
-
await this
|
|
45
|
+
await this._initializeCordovaProjectAsync(cordovaPath);
|
|
46
46
|
|
|
47
47
|
// 2. 플랫폼 관리
|
|
48
|
-
await this
|
|
48
|
+
await this._managePlatformsAsync(cordovaPath);
|
|
49
49
|
|
|
50
50
|
// 3. 플러그인 관리
|
|
51
|
-
await this
|
|
51
|
+
await this._managePluginsAsync(cordovaPath);
|
|
52
52
|
|
|
53
53
|
// 4. 안드로이드 서명 설정
|
|
54
|
-
this
|
|
54
|
+
this._setupAndroidSign(cordovaPath);
|
|
55
55
|
|
|
56
56
|
// 5. 빌드 설정 파일 생성
|
|
57
|
-
this
|
|
57
|
+
this._createBuildConfig(cordovaPath);
|
|
58
58
|
|
|
59
59
|
// 6. 아이콘 및 스플래시 스크린 설정
|
|
60
|
-
this
|
|
60
|
+
this._setupIconAndSplashScreen(cordovaPath);
|
|
61
61
|
|
|
62
62
|
// 7. XML 설정 구성
|
|
63
|
-
this
|
|
63
|
+
this._configureXml(cordovaPath);
|
|
64
64
|
|
|
65
65
|
// 8. 각 플랫폼 www 준비
|
|
66
|
-
await SdCliCordova
|
|
66
|
+
await SdCliCordova._execAsync("npx", ["cordova", "prepare"], cordovaPath);
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
// 1. Cordova 프로젝트 초기화
|
|
70
|
-
async
|
|
70
|
+
private async _initializeCordovaProjectAsync(cordovaPath: string): Promise<void> {
|
|
71
71
|
if (FsUtils.exists(cordovaPath)) {
|
|
72
|
-
SdCliCordova
|
|
72
|
+
SdCliCordova._logger.log("이미 생성되어있는 '.cordova'를 사용합니다.");
|
|
73
73
|
} else {
|
|
74
74
|
// await SdCliCordova.#execAsync("npx", ["cordova", "telemetry", "on"], this._opt.pkgPath);
|
|
75
75
|
|
|
76
76
|
// 프로젝트 생성
|
|
77
|
-
await SdCliCordova
|
|
77
|
+
await SdCliCordova._execAsync(
|
|
78
78
|
"npx",
|
|
79
79
|
["cordova", "create", cordovaPath, this._opt.config.appId, this._opt.config.appName],
|
|
80
80
|
process.cwd(),
|
|
@@ -82,30 +82,30 @@ export class SdCliCordova {
|
|
|
82
82
|
}
|
|
83
83
|
|
|
84
84
|
// platforms 폴더 혹시 없으면 생성
|
|
85
|
-
FsUtils.mkdirs(path.resolve(cordovaPath, this
|
|
85
|
+
FsUtils.mkdirs(path.resolve(cordovaPath, this._PLATFORMS_DIR_NAME));
|
|
86
86
|
|
|
87
87
|
// www 폴더 혹시 없으면 생성
|
|
88
|
-
FsUtils.mkdirs(path.resolve(cordovaPath, this
|
|
88
|
+
FsUtils.mkdirs(path.resolve(cordovaPath, this._WWW_DIR_NAME));
|
|
89
89
|
}
|
|
90
90
|
|
|
91
91
|
// 2. 플랫폼 관리
|
|
92
|
-
async
|
|
93
|
-
const alreadyPlatforms = FsUtils.readdir(path.resolve(cordovaPath, this
|
|
92
|
+
private async _managePlatformsAsync(cordovaPath: string): Promise<void> {
|
|
93
|
+
const alreadyPlatforms = FsUtils.readdir(path.resolve(cordovaPath, this._PLATFORMS_DIR_NAME));
|
|
94
94
|
|
|
95
95
|
// 미설치 빌드 플랫폼 신규 생성
|
|
96
|
-
for (const platform of this
|
|
96
|
+
for (const platform of this._platforms) {
|
|
97
97
|
if (alreadyPlatforms.includes(platform)) continue;
|
|
98
98
|
|
|
99
|
-
await SdCliCordova
|
|
99
|
+
await SdCliCordova._execAsync("npx", ["cordova", "platform", "add", platform], cordovaPath);
|
|
100
100
|
}
|
|
101
101
|
}
|
|
102
102
|
|
|
103
103
|
// 3. 플러그인 관리
|
|
104
|
-
async
|
|
104
|
+
private async _managePluginsAsync(cordovaPath: string): Promise<void> {
|
|
105
105
|
const pluginsFetchPath = path.resolve(
|
|
106
106
|
cordovaPath,
|
|
107
|
-
this
|
|
108
|
-
this
|
|
107
|
+
this._PLUGINS_DIR_NAME,
|
|
108
|
+
this._PLUGINS_FETCH_FILE,
|
|
109
109
|
);
|
|
110
110
|
const pluginsFetch = FsUtils.exists(pluginsFetchPath) ? FsUtils.readJson(pluginsFetchPath) : {};
|
|
111
111
|
|
|
@@ -122,11 +122,11 @@ export class SdCliCordova {
|
|
|
122
122
|
const usePlugins = (this._opt.config.plugins ?? []).distinct();
|
|
123
123
|
|
|
124
124
|
// 사용하지 않는 플러그인 제거 및 새 플러그인 설치 - 의존성 때문에 순차 처리
|
|
125
|
-
await this
|
|
126
|
-
await this
|
|
125
|
+
await this._removeUnusedPluginsAsync(cordovaPath, alreadyPlugins, usePlugins);
|
|
126
|
+
await this._installNewPluginsAsync(cordovaPath, alreadyPlugins, usePlugins);
|
|
127
127
|
}
|
|
128
128
|
|
|
129
|
-
async
|
|
129
|
+
private async _removeUnusedPluginsAsync(
|
|
130
130
|
cordovaPath: string,
|
|
131
131
|
alreadyPlugins: Array<{ name: string; id: string; dependencies?: string[] }>,
|
|
132
132
|
usePlugins: string[],
|
|
@@ -134,7 +134,7 @@ export class SdCliCordova {
|
|
|
134
134
|
for (const alreadyPlugin of alreadyPlugins) {
|
|
135
135
|
if (!usePlugins.includes(alreadyPlugin.id) && !usePlugins.includes(alreadyPlugin.name)) {
|
|
136
136
|
try {
|
|
137
|
-
await SdCliCordova
|
|
137
|
+
await SdCliCordova._execAsync(
|
|
138
138
|
"npx",
|
|
139
139
|
["cordova", "plugin", "remove", alreadyPlugin.name],
|
|
140
140
|
cordovaPath,
|
|
@@ -150,7 +150,7 @@ export class SdCliCordova {
|
|
|
150
150
|
}
|
|
151
151
|
}
|
|
152
152
|
|
|
153
|
-
async
|
|
153
|
+
private async _installNewPluginsAsync(
|
|
154
154
|
cordovaPath: string,
|
|
155
155
|
alreadyPlugins: Array<{ name: string; id: string; dependencies?: string[] }>,
|
|
156
156
|
usePlugins: string[],
|
|
@@ -162,15 +162,15 @@ export class SdCliCordova {
|
|
|
162
162
|
);
|
|
163
163
|
|
|
164
164
|
if (!isPluginAlreadyInstalled) {
|
|
165
|
-
await SdCliCordova
|
|
165
|
+
await SdCliCordova._execAsync("npx", ["cordova", "plugin", "add", usePlugin], cordovaPath);
|
|
166
166
|
}
|
|
167
167
|
}
|
|
168
168
|
}
|
|
169
169
|
|
|
170
170
|
// 4. 안드로이드 서명 설정
|
|
171
|
-
|
|
172
|
-
const keystorePath = path.resolve(cordovaPath, this
|
|
173
|
-
const signingPropsPath = path.resolve(cordovaPath, this
|
|
171
|
+
private _setupAndroidSign(cordovaPath: string): void {
|
|
172
|
+
const keystorePath = path.resolve(cordovaPath, this._KEYSTORE_FILE_NAME);
|
|
173
|
+
const signingPropsPath = path.resolve(cordovaPath, this._ANDROID_SIGNING_PROP_PATH);
|
|
174
174
|
|
|
175
175
|
if (this._opt.config.platform?.android?.sign) {
|
|
176
176
|
FsUtils.copy(
|
|
@@ -185,9 +185,9 @@ export class SdCliCordova {
|
|
|
185
185
|
}
|
|
186
186
|
|
|
187
187
|
// 5. 빌드 설정 파일 생성
|
|
188
|
-
|
|
189
|
-
const buildJsonPath = path.resolve(cordovaPath, this
|
|
190
|
-
const keystorePath = path.resolve(cordovaPath, this
|
|
188
|
+
private _createBuildConfig(cordovaPath: string): void {
|
|
189
|
+
const buildJsonPath = path.resolve(cordovaPath, this._BUILD_JSON_FILE_NAME);
|
|
190
|
+
const keystorePath = path.resolve(cordovaPath, this._KEYSTORE_FILE_NAME);
|
|
191
191
|
|
|
192
192
|
const androidConfig = this._opt.config.platform?.android
|
|
193
193
|
? {
|
|
@@ -212,10 +212,10 @@ export class SdCliCordova {
|
|
|
212
212
|
}
|
|
213
213
|
|
|
214
214
|
// 6. 아이콘 및 스플래시 스크린 설정
|
|
215
|
-
|
|
216
|
-
const iconDirPath = path.resolve(cordovaPath, this
|
|
217
|
-
const splashScreenPath = path.resolve(cordovaPath, this
|
|
218
|
-
const splashScreenXmlPath = path.resolve(splashScreenPath, this
|
|
215
|
+
private _setupIconAndSplashScreen(cordovaPath: string): void {
|
|
216
|
+
const iconDirPath = path.resolve(cordovaPath, this._ICON_DIR_PATH);
|
|
217
|
+
const splashScreenPath = path.resolve(cordovaPath, this._SPLASH_SCREEN_DIR_PATH);
|
|
218
|
+
const splashScreenXmlPath = path.resolve(splashScreenPath, this._SPLASH_SCREEN_XML_FILE);
|
|
219
219
|
|
|
220
220
|
// ICON 파일 복사
|
|
221
221
|
if (this._opt.config.icon != null) {
|
|
@@ -247,10 +247,10 @@ export class SdCliCordova {
|
|
|
247
247
|
}
|
|
248
248
|
|
|
249
249
|
// 7. XML 설정 구성
|
|
250
|
-
|
|
250
|
+
private _configureXml(cordovaPath: string) {
|
|
251
251
|
// CONFIG: 초기값 백업
|
|
252
|
-
const configFilePath = path.resolve(cordovaPath, this
|
|
253
|
-
const configBackFilePath = path.resolve(cordovaPath, this
|
|
252
|
+
const configFilePath = path.resolve(cordovaPath, this._CONFIG_XML_FILE_NAME);
|
|
253
|
+
const configBackFilePath = path.resolve(cordovaPath, this._CONFIG_XML_BACKUP_FILE_NAME);
|
|
254
254
|
|
|
255
255
|
if (!FsUtils.exists(configBackFilePath)) {
|
|
256
256
|
FsUtils.copy(configFilePath, configBackFilePath);
|
|
@@ -261,11 +261,11 @@ export class SdCliCordova {
|
|
|
261
261
|
const configXml = XmlConvert.parse(configFileContent);
|
|
262
262
|
|
|
263
263
|
// CONFIG: 기본 설정
|
|
264
|
-
this
|
|
264
|
+
this._configureBasicXmlSettings(configXml);
|
|
265
265
|
|
|
266
266
|
// CONFIG: 안드로이드 설정
|
|
267
267
|
if (this._opt.config.platform?.android) {
|
|
268
|
-
this
|
|
268
|
+
this._configureAndroidXmlSettings(configXml);
|
|
269
269
|
}
|
|
270
270
|
|
|
271
271
|
// CONFIG: 파일 새로 쓰기
|
|
@@ -275,16 +275,16 @@ export class SdCliCordova {
|
|
|
275
275
|
FsUtils.writeFile(configFilePath, configResultContent);
|
|
276
276
|
}
|
|
277
277
|
|
|
278
|
-
|
|
278
|
+
private _configureBasicXmlSettings(configXml: any): void {
|
|
279
279
|
// 버전 설정
|
|
280
|
-
configXml.widget.$.version = this
|
|
280
|
+
configXml.widget.$.version = this._npmConfig.version;
|
|
281
281
|
|
|
282
282
|
// ICON 설정
|
|
283
283
|
if (this._opt.config.icon != null) {
|
|
284
284
|
configXml.widget.icon = [
|
|
285
285
|
{
|
|
286
286
|
$: {
|
|
287
|
-
src: `${this
|
|
287
|
+
src: `${this._ICON_DIR_PATH}/${path.basename(this._opt.config.icon)}`,
|
|
288
288
|
},
|
|
289
289
|
},
|
|
290
290
|
];
|
|
@@ -298,7 +298,7 @@ export class SdCliCordova {
|
|
|
298
298
|
configXml.widget.preference = [{ $: { name: "MixedContentMode", value: "1" } }];
|
|
299
299
|
}
|
|
300
300
|
|
|
301
|
-
|
|
301
|
+
private _configureAndroidXmlSettings(configXml: any) {
|
|
302
302
|
configXml.widget.$["xmlns:android"] = "http://schemas.android.com/apk/res/android";
|
|
303
303
|
configXml.widget.$["xmlns:tools"] = "http://schemas.android.com/tools";
|
|
304
304
|
|
|
@@ -312,7 +312,7 @@ export class SdCliCordova {
|
|
|
312
312
|
{
|
|
313
313
|
$: {
|
|
314
314
|
name: "AndroidWindowSplashScreenAnimatedIcon",
|
|
315
|
-
value: `${this
|
|
315
|
+
value: `${this._SPLASH_SCREEN_DIR_PATH}/${this._SPLASH_SCREEN_XML_FILE}`,
|
|
316
316
|
},
|
|
317
317
|
},
|
|
318
318
|
],
|
|
@@ -379,7 +379,7 @@ export class SdCliCordova {
|
|
|
379
379
|
{
|
|
380
380
|
$: {
|
|
381
381
|
name: "android-compileSdkVersion",
|
|
382
|
-
value: this
|
|
382
|
+
value: this._ANDROID_SDK_VERSION,
|
|
383
383
|
},
|
|
384
384
|
},
|
|
385
385
|
],
|
|
@@ -416,15 +416,15 @@ export class SdCliCordova {
|
|
|
416
416
|
}
|
|
417
417
|
|
|
418
418
|
async buildAsync(outPath: string): Promise<void> {
|
|
419
|
-
const cordovaPath = path.resolve(this._opt.pkgPath, this
|
|
419
|
+
const cordovaPath = path.resolve(this._opt.pkgPath, this._CORDOVA_DIR_NAME);
|
|
420
420
|
|
|
421
421
|
// 빌드 실행 - 병렬 처리로 개선
|
|
422
422
|
const buildType = this._opt.config.debug ? "debug" : "release";
|
|
423
423
|
|
|
424
424
|
// 모든 플랫폼 동시에 빌드
|
|
425
425
|
await Promise.all(
|
|
426
|
-
this
|
|
427
|
-
SdCliCordova
|
|
426
|
+
this._platforms.map((platform) =>
|
|
427
|
+
SdCliCordova._execAsync(
|
|
428
428
|
"npx",
|
|
429
429
|
["cordova", "build", platform, `--${buildType}`],
|
|
430
430
|
cordovaPath,
|
|
@@ -435,12 +435,12 @@ export class SdCliCordova {
|
|
|
435
435
|
// 결과물 복사 및 ZIP 파일 생성 - 병렬 처리
|
|
436
436
|
await Promise.all(
|
|
437
437
|
Object.keys(this._opt.config.platform ?? {}).map(async (platform) => {
|
|
438
|
-
await this
|
|
438
|
+
await this._processBuildOutputAsync(cordovaPath, outPath, platform, buildType);
|
|
439
439
|
}),
|
|
440
440
|
);
|
|
441
441
|
}
|
|
442
442
|
|
|
443
|
-
async
|
|
443
|
+
private async _processBuildOutputAsync(
|
|
444
444
|
cordovaPath: string,
|
|
445
445
|
outPath: string,
|
|
446
446
|
platform: string,
|
|
@@ -450,14 +450,14 @@ export class SdCliCordova {
|
|
|
450
450
|
|
|
451
451
|
// 결과물 복사: ANDROID
|
|
452
452
|
if (platform === "android") {
|
|
453
|
-
this
|
|
453
|
+
this._copyAndroidBuildOutput(cordovaPath, targetOutPath, buildType);
|
|
454
454
|
}
|
|
455
455
|
|
|
456
456
|
// 자동업데이트를 위한 파일 생성
|
|
457
|
-
await this
|
|
457
|
+
await this._createUpdateZipAsync(cordovaPath, outPath, platform);
|
|
458
458
|
}
|
|
459
459
|
|
|
460
|
-
|
|
460
|
+
private _copyAndroidBuildOutput(cordovaPath: string, targetOutPath: string, buildType: string) {
|
|
461
461
|
const apkFileName = this._opt.config.platform!.android!.sign
|
|
462
462
|
? `app-${buildType}.apk`
|
|
463
463
|
: `app-${buildType}-unsigned.apk`;
|
|
@@ -475,37 +475,37 @@ export class SdCliCordova {
|
|
|
475
475
|
// 업데이트파일
|
|
476
476
|
FsUtils.copy(
|
|
477
477
|
path.resolve(cordovaPath, "platforms/android/app/build/outputs/apk", buildType, apkFileName),
|
|
478
|
-
path.resolve(targetOutPath, "updates", `${this
|
|
478
|
+
path.resolve(targetOutPath, "updates", `${this._npmConfig.version}.apk`),
|
|
479
479
|
);
|
|
480
480
|
}
|
|
481
481
|
|
|
482
|
-
async
|
|
482
|
+
private async _createUpdateZipAsync(
|
|
483
483
|
cordovaPath: string,
|
|
484
484
|
outPath: string,
|
|
485
485
|
platform: string,
|
|
486
486
|
): Promise<void> {
|
|
487
487
|
const zip = new SdZip();
|
|
488
|
-
const wwwPath = path.resolve(cordovaPath, this
|
|
488
|
+
const wwwPath = path.resolve(cordovaPath, this._WWW_DIR_NAME);
|
|
489
489
|
const platformWwwPath = path.resolve(
|
|
490
490
|
cordovaPath,
|
|
491
|
-
this
|
|
491
|
+
this._PLATFORMS_DIR_NAME,
|
|
492
492
|
platform,
|
|
493
493
|
"platform_www",
|
|
494
494
|
);
|
|
495
495
|
|
|
496
|
-
this
|
|
497
|
-
this
|
|
496
|
+
this._addFilesToZip(zip, wwwPath);
|
|
497
|
+
this._addFilesToZip(zip, platformWwwPath);
|
|
498
498
|
|
|
499
499
|
// ZIP 파일 생성
|
|
500
500
|
const updateDirPath = path.resolve(outPath, platform, "updates");
|
|
501
501
|
FsUtils.mkdirs(updateDirPath);
|
|
502
502
|
FsUtils.writeFile(
|
|
503
|
-
path.resolve(updateDirPath, this
|
|
503
|
+
path.resolve(updateDirPath, this._npmConfig.version + ".zip"),
|
|
504
504
|
await zip.compressAsync(),
|
|
505
505
|
);
|
|
506
506
|
}
|
|
507
507
|
|
|
508
|
-
|
|
508
|
+
private _addFilesToZip(zip: SdZip, dirPath: string) {
|
|
509
509
|
const files = FsUtils.glob(path.resolve(dirPath, "**/*"), { nodir: true });
|
|
510
510
|
for (const file of files) {
|
|
511
511
|
const relFilePath = path.relative(dirPath, file);
|
|
@@ -544,6 +544,6 @@ export class SdCliCordova {
|
|
|
544
544
|
);
|
|
545
545
|
}
|
|
546
546
|
|
|
547
|
-
await this
|
|
547
|
+
await this._execAsync("npx", ["cordova", "run", opt.platform, "--device"], cordovaPath);
|
|
548
548
|
}
|
|
549
549
|
}
|
|
@@ -8,42 +8,42 @@ import electronBuilder from "electron-builder";
|
|
|
8
8
|
import { INpmConfig } from "../types/common-config/INpmConfig";
|
|
9
9
|
|
|
10
10
|
export class SdCliElectron {
|
|
11
|
-
static
|
|
11
|
+
private static readonly _logger = SdLogger.get(["simplysm", "sd-cli", "SdCliElectron"]);
|
|
12
12
|
|
|
13
13
|
static async runAsync(opt: { package: string; config: string; options?: string[] }) {
|
|
14
|
-
this
|
|
15
|
-
const { pkgPath, electronPath, electronConfig } = await this
|
|
14
|
+
this._logger.log("설정 가져오기...");
|
|
15
|
+
const { pkgPath, electronPath, electronConfig } = await this._loadDevConfig(opt);
|
|
16
16
|
|
|
17
|
-
this
|
|
18
|
-
await this
|
|
17
|
+
this._logger.log("준비...");
|
|
18
|
+
await this._prepareAsync({ pkgPath, electronPath, electronConfig });
|
|
19
19
|
|
|
20
|
-
this
|
|
20
|
+
this._logger.log("실행...");
|
|
21
21
|
await SdProcess.spawnAsync("npx", ["electron", "."], { cwd: electronPath, showMessage: true });
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
static async buildForDevAsync(opt: { package: string; config: string; options?: string[] }) {
|
|
25
|
-
this
|
|
26
|
-
const { pkgPath, electronPath, electronConfig } = await this
|
|
25
|
+
this._logger.log("설정 가져오기...");
|
|
26
|
+
const { pkgPath, electronPath, electronConfig } = await this._loadDevConfig(opt);
|
|
27
27
|
|
|
28
|
-
this
|
|
29
|
-
const { npmConfig } = await this
|
|
28
|
+
this._logger.log("준비...");
|
|
29
|
+
const { npmConfig } = await this._prepareAsync({ pkgPath, electronPath, electronConfig });
|
|
30
30
|
|
|
31
|
-
this
|
|
31
|
+
this._logger.log("빌드...");
|
|
32
32
|
const electronDistPath = path.resolve(pkgPath, ".electron/dist");
|
|
33
|
-
await this
|
|
33
|
+
await this._buildAsync({ pkgPath, electronPath, electronDistPath, npmConfig, electronConfig });
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
static async buildAsync(opt: {
|
|
37
37
|
pkgPath: string;
|
|
38
38
|
electronConfig: ISdClientBuilderElectronConfig;
|
|
39
39
|
}) {
|
|
40
|
-
this
|
|
40
|
+
this._logger.log("준비...");
|
|
41
41
|
const electronPath = path.resolve(opt.pkgPath, ".electron/src");
|
|
42
|
-
const { npmConfig } = await this
|
|
42
|
+
const { npmConfig } = await this._prepareAsync({ ...opt, electronPath });
|
|
43
43
|
|
|
44
|
-
this
|
|
44
|
+
this._logger.log("빌드...");
|
|
45
45
|
const electronDistPath = path.resolve(opt.pkgPath, ".electron/dist");
|
|
46
|
-
await this
|
|
46
|
+
await this._buildAsync({
|
|
47
47
|
pkgPath: opt.pkgPath,
|
|
48
48
|
electronPath,
|
|
49
49
|
electronDistPath,
|
|
@@ -52,7 +52,7 @@ export class SdCliElectron {
|
|
|
52
52
|
});
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
static async
|
|
55
|
+
private static async _loadDevConfig(opt: { package: string; config: string; options?: string[] }) {
|
|
56
56
|
const projConf = await loadProjConfAsync(process.cwd(), true, opt);
|
|
57
57
|
const pkgConf = projConf.packages[opt.package];
|
|
58
58
|
if (pkgConf?.type !== "client" || pkgConf.builder?.electron === undefined) {
|
|
@@ -68,7 +68,7 @@ export class SdCliElectron {
|
|
|
68
68
|
};
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
-
static async
|
|
71
|
+
private static async _prepareAsync(opt: {
|
|
72
72
|
pkgPath: string;
|
|
73
73
|
electronPath: string;
|
|
74
74
|
electronConfig: ISdClientBuilderElectronConfig;
|
|
@@ -105,14 +105,14 @@ export class SdCliElectron {
|
|
|
105
105
|
return { npmConfig };
|
|
106
106
|
}
|
|
107
107
|
|
|
108
|
-
static async
|
|
108
|
+
private static async _buildAsync(opt: {
|
|
109
109
|
pkgPath: string;
|
|
110
110
|
electronPath: string;
|
|
111
111
|
electronDistPath: string;
|
|
112
112
|
npmConfig: INpmConfig;
|
|
113
113
|
electronConfig: ISdClientBuilderElectronConfig;
|
|
114
114
|
}) {
|
|
115
|
-
if (!this
|
|
115
|
+
if (!this._canCreateSymlink()) {
|
|
116
116
|
throw new Error(
|
|
117
117
|
"'Electron 빌드'를 위해서는 'Symlink 생성' 권한이 필요합니다. 윈도우의 개발자모드를 활성화하세요.",
|
|
118
118
|
);
|
|
@@ -170,7 +170,7 @@ export class SdCliElectron {
|
|
|
170
170
|
);
|
|
171
171
|
}
|
|
172
172
|
|
|
173
|
-
static
|
|
173
|
+
private static _canCreateSymlink() {
|
|
174
174
|
const tmpDir = os.tmpdir();
|
|
175
175
|
const testTarget = path.join(tmpDir, "symlink-test-target.txt");
|
|
176
176
|
const testLink = path.join(tmpDir, "symlink-test-link.txt");
|
|
@@ -10,7 +10,7 @@ export class SdCliLocalUpdate {
|
|
|
10
10
|
const projConf = await loadProjConfAsync(process.cwd(), true, opt);
|
|
11
11
|
if (!projConf.localUpdates) return;
|
|
12
12
|
|
|
13
|
-
const updatePathInfos = this
|
|
13
|
+
const updatePathInfos = this._getUpdatePathInfos(projConf.localUpdates);
|
|
14
14
|
logger.debug("로컬 업데이트 구성");
|
|
15
15
|
|
|
16
16
|
logger.log("로컬 라이브러리 업데이트 시작...");
|
|
@@ -35,7 +35,7 @@ export class SdCliLocalUpdate {
|
|
|
35
35
|
const projConf = await loadProjConfAsync(process.cwd(), true, opt);
|
|
36
36
|
if (!projConf.localUpdates) return;
|
|
37
37
|
|
|
38
|
-
const updatePathInfos = this
|
|
38
|
+
const updatePathInfos = this._getUpdatePathInfos(projConf.localUpdates);
|
|
39
39
|
logger.debug("로컬 업데이트 구성");
|
|
40
40
|
|
|
41
41
|
const watcher = await SdFsWatcher.watchAsync(updatePathInfos.map((item) => item.source));
|
|
@@ -68,7 +68,7 @@ export class SdCliLocalUpdate {
|
|
|
68
68
|
});
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
-
static
|
|
71
|
+
private static _getUpdatePathInfos(record: Record<string, string>): IUpdatePathInfo[] {
|
|
72
72
|
const result: IUpdatePathInfo[] = [];
|
|
73
73
|
for (const pkgGlobPath of Object.keys(record)) {
|
|
74
74
|
// "node_modules'에서 로컬업데이트 설정에 맞는 패키지를 "glob"하여 대상 패키지경로 목록 가져오기
|
|
@@ -68,7 +68,7 @@ export class SdCliProject {
|
|
|
68
68
|
logger.debug("빌드를 시작합니다...");
|
|
69
69
|
},
|
|
70
70
|
onComplete: (messages) => {
|
|
71
|
-
this
|
|
71
|
+
this._logging(messages, logger);
|
|
72
72
|
},
|
|
73
73
|
});
|
|
74
74
|
}
|
|
@@ -111,7 +111,7 @@ export class SdCliProject {
|
|
|
111
111
|
}
|
|
112
112
|
|
|
113
113
|
logger.debug("프로젝트 및 패키지 버전 설정...");
|
|
114
|
-
this
|
|
114
|
+
this._upgradeVersion(projNpmConf, allPkgPaths);
|
|
115
115
|
|
|
116
116
|
logger.debug("빌드 프로세스 시작...");
|
|
117
117
|
const messages = await SdProjectBuildRunner.buildAsync({
|
|
@@ -119,7 +119,7 @@ export class SdCliProject {
|
|
|
119
119
|
pkgPaths,
|
|
120
120
|
projConf,
|
|
121
121
|
});
|
|
122
|
-
this
|
|
122
|
+
this._logging(messages, logger);
|
|
123
123
|
}
|
|
124
124
|
|
|
125
125
|
static async publishAsync(opt: {
|
|
@@ -138,7 +138,7 @@ export class SdCliProject {
|
|
|
138
138
|
|
|
139
139
|
if (opt.noBuild) {
|
|
140
140
|
logger.warn("빌드하지 않고, 배포하는것은 상당히 위험합니다.");
|
|
141
|
-
await this
|
|
141
|
+
await this._waitSecMessageAsync("프로세스를 중지하려면, 'CTRL+C'를 누르세요.", 5);
|
|
142
142
|
} else {
|
|
143
143
|
// GIT 사용중일 경우, 커밋되지 않은 수정사항이 있는지 확인
|
|
144
144
|
if (FsUtils.exists(path.resolve(process.cwd(), ".git"))) {
|
|
@@ -184,7 +184,7 @@ export class SdCliProject {
|
|
|
184
184
|
|
|
185
185
|
if (!opt.noBuild) {
|
|
186
186
|
logger.debug("프로젝트 및 패키지 버전 설정...");
|
|
187
|
-
this
|
|
187
|
+
this._upgradeVersion(projNpmConf, allPkgPaths);
|
|
188
188
|
|
|
189
189
|
// 빌드
|
|
190
190
|
try {
|
|
@@ -195,7 +195,7 @@ export class SdCliProject {
|
|
|
195
195
|
projConf,
|
|
196
196
|
});
|
|
197
197
|
|
|
198
|
-
this
|
|
198
|
+
this._logging(messages, logger);
|
|
199
199
|
} catch (err) {
|
|
200
200
|
await SdProcess.spawnAsync("git", ["checkout", "."]);
|
|
201
201
|
throw err;
|
|
@@ -227,7 +227,7 @@ export class SdCliProject {
|
|
|
227
227
|
if (pkgConf?.publish == null) return;
|
|
228
228
|
|
|
229
229
|
logger.debug(`[${pkgName}] 배포 시작...`);
|
|
230
|
-
await this
|
|
230
|
+
await this._publishPkgAsync(pkgPath, pkgConf.publish);
|
|
231
231
|
logger.debug(`[${pkgName}] 배포 완료`);
|
|
232
232
|
});
|
|
233
233
|
|
|
@@ -260,7 +260,7 @@ export class SdCliProject {
|
|
|
260
260
|
logger.info(`모든 배포가 완료되었습니다. (v${projNpmConf.version})`);
|
|
261
261
|
}
|
|
262
262
|
|
|
263
|
-
static async
|
|
263
|
+
private static async _publishPkgAsync(
|
|
264
264
|
pkgPath: string,
|
|
265
265
|
pkgPubConf: TSdPackageConfig["publish"],
|
|
266
266
|
): Promise<void> {
|
|
@@ -314,7 +314,7 @@ export class SdCliProject {
|
|
|
314
314
|
}
|
|
315
315
|
}
|
|
316
316
|
|
|
317
|
-
static async
|
|
317
|
+
private static async _waitSecMessageAsync(msg: string, sec: number): Promise<void> {
|
|
318
318
|
for (let i = sec; i > 0; i--) {
|
|
319
319
|
if (i !== sec) {
|
|
320
320
|
process.stdout.cursorTo(0);
|
|
@@ -327,7 +327,7 @@ export class SdCliProject {
|
|
|
327
327
|
process.stdout.clearLine(0);
|
|
328
328
|
}
|
|
329
329
|
|
|
330
|
-
static
|
|
330
|
+
private static _upgradeVersion(projNpmConf: INpmConfig, allPkgPaths: string[]) {
|
|
331
331
|
// 작업공간 package.json 버전 설정
|
|
332
332
|
const newVersion = semver.inc(projNpmConf.version, "patch")!;
|
|
333
333
|
projNpmConf.version = newVersion;
|
|
@@ -379,7 +379,7 @@ export class SdCliProject {
|
|
|
379
379
|
}
|
|
380
380
|
}
|
|
381
381
|
|
|
382
|
-
static
|
|
382
|
+
private static _logging(buildResults: ISdBuildMessage[], logger: SdLogger): void {
|
|
383
383
|
const messageMap = buildResults.toSetMap(
|
|
384
384
|
(item) => item.severity,
|
|
385
385
|
(item) => SdCliConvertMessageUtils.getBuildMessageString(item),
|