@simplysm/sd-cli 12.11.6 → 12.11.8
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/sd-cli-cordova.d.ts +2 -34
- package/dist/entry/sd-cli-cordova.js +89 -85
- package/dist/entry/sd-cli-cordova.js.map +1 -1
- package/dist/entry/sd-cli-electron.d.ts +1 -5
- package/dist/entry/sd-cli-electron.js +21 -21
- package/dist/entry/sd-cli-electron.js.map +1 -1
- package/dist/entry/sd-cli-local-update.d.ts +1 -1
- package/dist/entry/sd-cli-local-update.js +3 -3
- package/dist/entry/sd-cli-local-update.js.map +1 -1
- package/dist/entry/sd-cli-project.d.ts +1 -4
- package/dist/entry/sd-cli-project.js +11 -11
- package/dist/entry/sd-cli-project.js.map +1 -1
- package/dist/fix/convert-private-to-hash.d.ts +1 -0
- package/dist/fix/convert-private-to-hash.js +59 -0
- package/dist/fix/convert-private-to-hash.js.map +1 -0
- package/dist/pkg-builders/client/sd-client.build-runner.d.ts +1 -2
- package/dist/pkg-builders/client/sd-client.build-runner.js +11 -9
- package/dist/pkg-builders/client/sd-client.build-runner.js.map +1 -1
- package/dist/pkg-builders/client/sd-ng.bundler-context.d.ts +3 -5
- package/dist/pkg-builders/client/sd-ng.bundler-context.js +10 -9
- package/dist/pkg-builders/client/sd-ng.bundler-context.js.map +1 -1
- package/dist/pkg-builders/client/sd-ng.bundler.d.ts +2 -22
- package/dist/pkg-builders/client/sd-ng.bundler.js +76 -67
- package/dist/pkg-builders/client/sd-ng.bundler.js.map +1 -1
- package/dist/pkg-builders/commons/scope-path.d.ts +1 -1
- package/dist/pkg-builders/commons/scope-path.js +4 -3
- package/dist/pkg-builders/commons/scope-path.js.map +1 -1
- package/dist/pkg-builders/lib/sd-cli-index.file-generator.d.ts +1 -1
- package/dist/pkg-builders/lib/sd-cli-index.file-generator.js +2 -2
- package/dist/pkg-builders/lib/sd-cli-index.file-generator.js.map +1 -1
- package/dist/pkg-builders/lib/sd-js-lib.build-runner.d.ts +1 -1
- package/dist/pkg-builders/lib/sd-js-lib.build-runner.js +2 -2
- package/dist/pkg-builders/lib/sd-js-lib.build-runner.js.map +1 -1
- package/dist/pkg-builders/lib/sd-ts-lib.build-runner.d.ts +1 -1
- package/dist/pkg-builders/lib/sd-ts-lib.build-runner.js +3 -2
- package/dist/pkg-builders/lib/sd-ts-lib.build-runner.js.map +1 -1
- package/dist/pkg-builders/lib/sd-ts-lib.builder.d.ts +2 -2
- package/dist/pkg-builders/lib/sd-ts-lib.builder.js +3 -2
- package/dist/pkg-builders/lib/sd-ts-lib.builder.js.map +1 -1
- package/dist/pkg-builders/sd-multi.build-runner.d.ts +1 -6
- package/dist/pkg-builders/sd-multi.build-runner.js +27 -30
- package/dist/pkg-builders/sd-multi.build-runner.js.map +1 -1
- package/dist/pkg-builders/server/sd-server.build-runner.d.ts +1 -4
- package/dist/pkg-builders/server/sd-server.build-runner.js +11 -9
- package/dist/pkg-builders/server/sd-server.build-runner.js.map +1 -1
- package/dist/pkg-builders/server/sd-server.bundler.d.ts +2 -6
- package/dist/pkg-builders/server/sd-server.bundler.js +19 -18
- package/dist/pkg-builders/server/sd-server.bundler.js.map +1 -1
- package/dist/sd-cli-entry.js +17 -7
- package/dist/sd-cli-entry.js.map +1 -1
- package/dist/ts-compiler/sd-dependency-cache.d.ts +1 -8
- package/dist/ts-compiler/sd-dependency-cache.js +37 -39
- package/dist/ts-compiler/sd-dependency-cache.js.map +1 -1
- package/dist/ts-compiler/sd-ts-compiler.d.ts +1 -19
- package/dist/ts-compiler/sd-ts-compiler.js +112 -107
- package/dist/ts-compiler/sd-ts-compiler.js.map +1 -1
- package/dist/utils/sd-cli-performance-time.d.ts +2 -3
- package/dist/utils/sd-cli-performance-time.js +9 -9
- package/dist/utils/sd-cli-performance-time.js.map +1 -1
- package/package.json +8 -8
- package/src/entry/sd-cli-cordova.ts +92 -92
- package/src/entry/sd-cli-electron.ts +21 -21
- package/src/entry/sd-cli-local-update.ts +3 -3
- package/src/entry/sd-cli-project.ts +11 -11
- package/src/fix/convert-private-to-hash.ts +72 -0
- package/src/pkg-builders/client/sd-client.build-runner.ts +11 -11
- package/src/pkg-builders/client/sd-ng.bundler-context.ts +12 -12
- package/src/pkg-builders/client/sd-ng.bundler.ts +75 -75
- package/src/pkg-builders/commons/scope-path.ts +4 -4
- package/src/pkg-builders/lib/sd-cli-index.file-generator.ts +2 -2
- package/src/pkg-builders/lib/sd-js-lib.build-runner.ts +2 -2
- package/src/pkg-builders/lib/sd-ts-lib.build-runner.ts +3 -3
- package/src/pkg-builders/lib/sd-ts-lib.builder.ts +4 -4
- package/src/pkg-builders/sd-multi.build-runner.ts +27 -27
- package/src/pkg-builders/server/sd-server.build-runner.ts +11 -11
- package/src/pkg-builders/server/sd-server.bundler.ts +20 -20
- package/src/sd-cli-entry.ts +19 -8
- package/src/ts-compiler/sd-dependency-cache.ts +37 -37
- package/src/ts-compiler/sd-ts-compiler.ts +117 -117
- package/src/utils/sd-cli-performance-time.ts +10 -10
- package/dist/fix/convert-ecma-private-to-ts-private.d.ts +0 -1
- package/dist/fix/convert-ecma-private-to-ts-private.js +0 -59
- package/dist/fix/convert-ecma-private-to-ts-private.js.map +0 -1
- package/dist/fix/prefix-underscore-for-access-modifiers.d.ts +0 -1
- package/dist/fix/prefix-underscore-for-access-modifiers.js +0 -52
- package/dist/fix/prefix-underscore-for-access-modifiers.js.map +0 -1
- package/src/fix/convert-ecma-private-to-ts-private.ts +0 -71
- package/src/fix/prefix-underscore-for-access-modifiers.ts +0 -68
|
@@ -6,36 +6,36 @@ import { SdZip, XmlConvert } from "@simplysm/sd-core-common";
|
|
|
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
|
-
|
|
27
|
-
|
|
28
|
-
constructor(private _opt: { pkgPath: string; config: ISdClientBuilderCordovaConfig }) {
|
|
29
|
-
this
|
|
30
|
-
this
|
|
9
|
+
#CORDOVA_DIR_NAME = ".cordova";
|
|
10
|
+
#PLATFORMS_DIR_NAME = "platforms";
|
|
11
|
+
#WWW_DIR_NAME = "www";
|
|
12
|
+
|
|
13
|
+
#PLUGINS_DIR_NAME = "plugins";
|
|
14
|
+
#PLUGINS_FETCH_FILE = "fetch.json";
|
|
15
|
+
#ANDROID_SDK_VERSION = "33";
|
|
16
|
+
#KEYSTORE_FILE_NAME = "android.keystore";
|
|
17
|
+
#CONFIG_XML_FILE_NAME = "config.xml";
|
|
18
|
+
#CONFIG_XML_BACKUP_FILE_NAME = "config.xml.bak";
|
|
19
|
+
#BUILD_JSON_FILE_NAME = "build.json";
|
|
20
|
+
#ANDROID_SIGNING_PROP_PATH = "platforms/android/release-signing.properties";
|
|
21
|
+
#ICON_DIR_PATH = "res/icons";
|
|
22
|
+
#SPLASH_SCREEN_DIR_PATH = "res/screen/android";
|
|
23
|
+
#SPLASH_SCREEN_XML_FILE = "splashscreen.xml";
|
|
24
|
+
|
|
25
|
+
#platforms: string[];
|
|
26
|
+
#npmConfig: INpmConfig;
|
|
27
|
+
|
|
28
|
+
constructor(private readonly _opt: { pkgPath: string; config: ISdClientBuilderCordovaConfig }) {
|
|
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
|
-
|
|
33
|
+
static #logger = SdLogger.get(["simplysm", "sd-cli", "SdCliCordova"]);
|
|
34
34
|
|
|
35
|
-
|
|
36
|
-
this.
|
|
35
|
+
static async #execAsync(cmd: string, cwd: string): Promise<void> {
|
|
36
|
+
this.#logger.debug(`실행 명령: ${cmd}`);
|
|
37
37
|
const msg = await SdProcess.spawnAsync(cmd, { cwd });
|
|
38
|
-
this.
|
|
38
|
+
this.#logger.debug(`실행 결과: ${msg}`);
|
|
39
39
|
|
|
40
40
|
/*try {
|
|
41
41
|
this._logger.debug(`실행 명령: ${cmd}`);
|
|
@@ -50,72 +50,72 @@ export class SdCliCordova {
|
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
async initializeAsync(): Promise<void> {
|
|
53
|
-
const cordovaPath = path.resolve(this._opt.pkgPath, this
|
|
53
|
+
const cordovaPath = path.resolve(this._opt.pkgPath, this.#CORDOVA_DIR_NAME);
|
|
54
54
|
|
|
55
55
|
// 1. Cordova 프로젝트 초기화
|
|
56
|
-
await this
|
|
56
|
+
await this.#initializeCordovaProjectAsync(cordovaPath);
|
|
57
57
|
|
|
58
58
|
// 2. 플랫폼 관리
|
|
59
|
-
await this
|
|
59
|
+
await this.#managePlatformsAsync(cordovaPath);
|
|
60
60
|
|
|
61
61
|
// 3. 플러그인 관리
|
|
62
|
-
await this
|
|
62
|
+
await this.#managePluginsAsync(cordovaPath);
|
|
63
63
|
|
|
64
64
|
// 4. 안드로이드 서명 설정
|
|
65
|
-
this
|
|
65
|
+
this.#setupAndroidSign(cordovaPath);
|
|
66
66
|
|
|
67
67
|
// 5. 빌드 설정 파일 생성
|
|
68
|
-
this
|
|
68
|
+
this.#createBuildConfig(cordovaPath);
|
|
69
69
|
|
|
70
70
|
// 6. 아이콘 및 스플래시 스크린 설정
|
|
71
|
-
this
|
|
71
|
+
this.#setupIconAndSplashScreen(cordovaPath);
|
|
72
72
|
|
|
73
73
|
// 7. XML 설정 구성
|
|
74
|
-
this
|
|
74
|
+
this.#configureXml(cordovaPath);
|
|
75
75
|
|
|
76
76
|
// 8. 각 플랫폼 www 준비
|
|
77
|
-
await SdCliCordova
|
|
77
|
+
await SdCliCordova.#execAsync(`npx cordova prepare`, cordovaPath);
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
// 1. Cordova 프로젝트 초기화
|
|
81
|
-
|
|
81
|
+
async #initializeCordovaProjectAsync(cordovaPath: string): Promise<void> {
|
|
82
82
|
if (FsUtils.exists(cordovaPath)) {
|
|
83
|
-
SdCliCordova.
|
|
83
|
+
SdCliCordova.#logger.log("이미 생성되어있는 '.cordova'를 사용합니다.");
|
|
84
84
|
} else {
|
|
85
|
-
await SdCliCordova
|
|
85
|
+
await SdCliCordova.#execAsync(`npx cordova telemetry on`, this._opt.pkgPath);
|
|
86
86
|
|
|
87
87
|
// 프로젝트 생성
|
|
88
|
-
await SdCliCordova
|
|
88
|
+
await SdCliCordova.#execAsync(
|
|
89
89
|
`npx cordova create "${cordovaPath}" "${this._opt.config.appId}" "${this._opt.config.appName}"`,
|
|
90
90
|
process.cwd(),
|
|
91
91
|
);
|
|
92
92
|
}
|
|
93
93
|
|
|
94
94
|
// platforms 폴더 혹시 없으면 생성
|
|
95
|
-
FsUtils.mkdirs(path.resolve(cordovaPath, this
|
|
95
|
+
FsUtils.mkdirs(path.resolve(cordovaPath, this.#PLATFORMS_DIR_NAME));
|
|
96
96
|
|
|
97
97
|
// www 폴더 혹시 없으면 생성
|
|
98
|
-
FsUtils.mkdirs(path.resolve(cordovaPath, this
|
|
98
|
+
FsUtils.mkdirs(path.resolve(cordovaPath, this.#WWW_DIR_NAME));
|
|
99
99
|
}
|
|
100
100
|
|
|
101
101
|
// 2. 플랫폼 관리
|
|
102
|
-
|
|
103
|
-
const alreadyPlatforms = FsUtils.readdir(path.resolve(cordovaPath, this
|
|
102
|
+
async #managePlatformsAsync(cordovaPath: string): Promise<void> {
|
|
103
|
+
const alreadyPlatforms = FsUtils.readdir(path.resolve(cordovaPath, this.#PLATFORMS_DIR_NAME));
|
|
104
104
|
|
|
105
105
|
// 미설치 빌드 플랫폼 신규 생성
|
|
106
|
-
for (const platform of this
|
|
106
|
+
for (const platform of this.#platforms) {
|
|
107
107
|
if (alreadyPlatforms.includes(platform)) continue;
|
|
108
108
|
|
|
109
|
-
await SdCliCordova
|
|
109
|
+
await SdCliCordova.#execAsync(`npx cordova platform add ${platform}`, cordovaPath);
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
112
|
|
|
113
113
|
// 3. 플러그인 관리
|
|
114
|
-
|
|
114
|
+
async #managePluginsAsync(cordovaPath: string): Promise<void> {
|
|
115
115
|
const pluginsFetchPath = path.resolve(
|
|
116
116
|
cordovaPath,
|
|
117
|
-
this
|
|
118
|
-
this
|
|
117
|
+
this.#PLUGINS_DIR_NAME,
|
|
118
|
+
this.#PLUGINS_FETCH_FILE,
|
|
119
119
|
);
|
|
120
120
|
const pluginsFetch = FsUtils.exists(pluginsFetchPath) ? FsUtils.readJson(pluginsFetchPath) : {};
|
|
121
121
|
|
|
@@ -132,11 +132,11 @@ export class SdCliCordova {
|
|
|
132
132
|
const usePlugins = (this._opt.config.plugins ?? []).distinct();
|
|
133
133
|
|
|
134
134
|
// 사용하지 않는 플러그인 제거 및 새 플러그인 설치 - 의존성 때문에 순차 처리
|
|
135
|
-
await this
|
|
136
|
-
await this
|
|
135
|
+
await this.#removeUnusedPluginsAsync(cordovaPath, alreadyPlugins, usePlugins);
|
|
136
|
+
await this.#installNewPluginsAsync(cordovaPath, alreadyPlugins, usePlugins);
|
|
137
137
|
}
|
|
138
138
|
|
|
139
|
-
|
|
139
|
+
async #removeUnusedPluginsAsync(
|
|
140
140
|
cordovaPath: string,
|
|
141
141
|
alreadyPlugins: Array<{ name: string; id: string; dependencies?: string[] }>,
|
|
142
142
|
usePlugins: string[],
|
|
@@ -144,7 +144,7 @@ export class SdCliCordova {
|
|
|
144
144
|
for (const alreadyPlugin of alreadyPlugins) {
|
|
145
145
|
if (!usePlugins.includes(alreadyPlugin.id) && !usePlugins.includes(alreadyPlugin.name)) {
|
|
146
146
|
try {
|
|
147
|
-
await SdCliCordova
|
|
147
|
+
await SdCliCordova.#execAsync(
|
|
148
148
|
`npx cordova plugin remove ${alreadyPlugin.name}`,
|
|
149
149
|
cordovaPath,
|
|
150
150
|
);
|
|
@@ -159,7 +159,7 @@ export class SdCliCordova {
|
|
|
159
159
|
}
|
|
160
160
|
}
|
|
161
161
|
|
|
162
|
-
|
|
162
|
+
async #installNewPluginsAsync(
|
|
163
163
|
cordovaPath: string,
|
|
164
164
|
alreadyPlugins: Array<{ name: string; id: string; dependencies?: string[] }>,
|
|
165
165
|
usePlugins: string[],
|
|
@@ -171,15 +171,15 @@ export class SdCliCordova {
|
|
|
171
171
|
);
|
|
172
172
|
|
|
173
173
|
if (!isPluginAlreadyInstalled) {
|
|
174
|
-
await SdCliCordova
|
|
174
|
+
await SdCliCordova.#execAsync(`npx cordova plugin add ${usePlugin}`, cordovaPath);
|
|
175
175
|
}
|
|
176
176
|
}
|
|
177
177
|
}
|
|
178
178
|
|
|
179
179
|
// 4. 안드로이드 서명 설정
|
|
180
|
-
|
|
181
|
-
const keystorePath = path.resolve(cordovaPath, this
|
|
182
|
-
const signingPropsPath = path.resolve(cordovaPath, this
|
|
180
|
+
#setupAndroidSign(cordovaPath: string): void {
|
|
181
|
+
const keystorePath = path.resolve(cordovaPath, this.#KEYSTORE_FILE_NAME);
|
|
182
|
+
const signingPropsPath = path.resolve(cordovaPath, this.#ANDROID_SIGNING_PROP_PATH);
|
|
183
183
|
|
|
184
184
|
if (this._opt.config.platform?.android?.sign) {
|
|
185
185
|
FsUtils.copy(
|
|
@@ -194,9 +194,9 @@ export class SdCliCordova {
|
|
|
194
194
|
}
|
|
195
195
|
|
|
196
196
|
// 5. 빌드 설정 파일 생성
|
|
197
|
-
|
|
198
|
-
const buildJsonPath = path.resolve(cordovaPath, this
|
|
199
|
-
const keystorePath = path.resolve(cordovaPath, this
|
|
197
|
+
#createBuildConfig(cordovaPath: string): void {
|
|
198
|
+
const buildJsonPath = path.resolve(cordovaPath, this.#BUILD_JSON_FILE_NAME);
|
|
199
|
+
const keystorePath = path.resolve(cordovaPath, this.#KEYSTORE_FILE_NAME);
|
|
200
200
|
|
|
201
201
|
const androidConfig = this._opt.config.platform?.android
|
|
202
202
|
? {
|
|
@@ -221,10 +221,10 @@ export class SdCliCordova {
|
|
|
221
221
|
}
|
|
222
222
|
|
|
223
223
|
// 6. 아이콘 및 스플래시 스크린 설정
|
|
224
|
-
|
|
225
|
-
const iconDirPath = path.resolve(cordovaPath, this
|
|
226
|
-
const splashScreenPath = path.resolve(cordovaPath, this
|
|
227
|
-
const splashScreenXmlPath = path.resolve(splashScreenPath, this
|
|
224
|
+
#setupIconAndSplashScreen(cordovaPath: string): void {
|
|
225
|
+
const iconDirPath = path.resolve(cordovaPath, this.#ICON_DIR_PATH);
|
|
226
|
+
const splashScreenPath = path.resolve(cordovaPath, this.#SPLASH_SCREEN_DIR_PATH);
|
|
227
|
+
const splashScreenXmlPath = path.resolve(splashScreenPath, this.#SPLASH_SCREEN_XML_FILE);
|
|
228
228
|
|
|
229
229
|
// ICON 파일 복사
|
|
230
230
|
if (this._opt.config.icon != null) {
|
|
@@ -256,10 +256,10 @@ export class SdCliCordova {
|
|
|
256
256
|
}
|
|
257
257
|
|
|
258
258
|
// 7. XML 설정 구성
|
|
259
|
-
|
|
259
|
+
#configureXml(cordovaPath: string) {
|
|
260
260
|
// CONFIG: 초기값 백업
|
|
261
|
-
const configFilePath = path.resolve(cordovaPath, this
|
|
262
|
-
const configBackFilePath = path.resolve(cordovaPath, this
|
|
261
|
+
const configFilePath = path.resolve(cordovaPath, this.#CONFIG_XML_FILE_NAME);
|
|
262
|
+
const configBackFilePath = path.resolve(cordovaPath, this.#CONFIG_XML_BACKUP_FILE_NAME);
|
|
263
263
|
|
|
264
264
|
if (!FsUtils.exists(configBackFilePath)) {
|
|
265
265
|
FsUtils.copy(configFilePath, configBackFilePath);
|
|
@@ -270,11 +270,11 @@ export class SdCliCordova {
|
|
|
270
270
|
const configXml = XmlConvert.parse(configFileContent);
|
|
271
271
|
|
|
272
272
|
// CONFIG: 기본 설정
|
|
273
|
-
this
|
|
273
|
+
this.#configureBasicXmlSettings(configXml);
|
|
274
274
|
|
|
275
275
|
// CONFIG: 안드로이드 설정
|
|
276
276
|
if (this._opt.config.platform?.android) {
|
|
277
|
-
this
|
|
277
|
+
this.#configureAndroidXmlSettings(configXml);
|
|
278
278
|
}
|
|
279
279
|
|
|
280
280
|
// CONFIG: 파일 새로 쓰기
|
|
@@ -284,16 +284,16 @@ export class SdCliCordova {
|
|
|
284
284
|
FsUtils.writeFile(configFilePath, configResultContent);
|
|
285
285
|
}
|
|
286
286
|
|
|
287
|
-
|
|
287
|
+
#configureBasicXmlSettings(configXml: any): void {
|
|
288
288
|
// 버전 설정
|
|
289
|
-
configXml.widget.$.version = this.
|
|
289
|
+
configXml.widget.$.version = this.#npmConfig.version;
|
|
290
290
|
|
|
291
291
|
// ICON 설정
|
|
292
292
|
if (this._opt.config.icon != null) {
|
|
293
293
|
configXml.widget.icon = [
|
|
294
294
|
{
|
|
295
295
|
$: {
|
|
296
|
-
src: `${this
|
|
296
|
+
src: `${this.#ICON_DIR_PATH}/${path.basename(this._opt.config.icon)}`,
|
|
297
297
|
},
|
|
298
298
|
},
|
|
299
299
|
];
|
|
@@ -307,7 +307,7 @@ export class SdCliCordova {
|
|
|
307
307
|
configXml.widget.preference = [{ $: { name: "MixedContentMode", value: "1" } }];
|
|
308
308
|
}
|
|
309
309
|
|
|
310
|
-
|
|
310
|
+
#configureAndroidXmlSettings(configXml: any) {
|
|
311
311
|
configXml.widget.$["xmlns:android"] = "http://schemas.android.com/apk/res/android";
|
|
312
312
|
configXml.widget.$["xmlns:tools"] = "http://schemas.android.com/tools";
|
|
313
313
|
|
|
@@ -321,7 +321,7 @@ export class SdCliCordova {
|
|
|
321
321
|
{
|
|
322
322
|
$: {
|
|
323
323
|
name: "AndroidWindowSplashScreenAnimatedIcon",
|
|
324
|
-
value: `${this
|
|
324
|
+
value: `${this.#SPLASH_SCREEN_DIR_PATH}/${this.#SPLASH_SCREEN_XML_FILE}`,
|
|
325
325
|
},
|
|
326
326
|
},
|
|
327
327
|
],
|
|
@@ -388,7 +388,7 @@ export class SdCliCordova {
|
|
|
388
388
|
{
|
|
389
389
|
$: {
|
|
390
390
|
name: "android-compileSdkVersion",
|
|
391
|
-
value: this
|
|
391
|
+
value: this.#ANDROID_SDK_VERSION,
|
|
392
392
|
},
|
|
393
393
|
},
|
|
394
394
|
],
|
|
@@ -425,27 +425,27 @@ export class SdCliCordova {
|
|
|
425
425
|
}
|
|
426
426
|
|
|
427
427
|
async buildAsync(outPath: string): Promise<void> {
|
|
428
|
-
const cordovaPath = path.resolve(this._opt.pkgPath, this
|
|
428
|
+
const cordovaPath = path.resolve(this._opt.pkgPath, this.#CORDOVA_DIR_NAME);
|
|
429
429
|
|
|
430
430
|
// 빌드 실행 - 병렬 처리로 개선
|
|
431
431
|
const buildType = this._opt.config.debug ? "debug" : "release";
|
|
432
432
|
|
|
433
433
|
// 모든 플랫폼 동시에 빌드
|
|
434
434
|
await Promise.all(
|
|
435
|
-
this.
|
|
436
|
-
SdCliCordova
|
|
435
|
+
this.#platforms.map((platform) =>
|
|
436
|
+
SdCliCordova.#execAsync(`npx cordova build ${platform} --${buildType}`, cordovaPath),
|
|
437
437
|
),
|
|
438
438
|
);
|
|
439
439
|
|
|
440
440
|
// 결과물 복사 및 ZIP 파일 생성 - 병렬 처리
|
|
441
441
|
await Promise.all(
|
|
442
442
|
Object.keys(this._opt.config.platform ?? {}).map(async (platform) => {
|
|
443
|
-
await this
|
|
443
|
+
await this.#processBuildOutputAsync(cordovaPath, outPath, platform, buildType);
|
|
444
444
|
}),
|
|
445
445
|
);
|
|
446
446
|
}
|
|
447
447
|
|
|
448
|
-
|
|
448
|
+
async #processBuildOutputAsync(
|
|
449
449
|
cordovaPath: string,
|
|
450
450
|
outPath: string,
|
|
451
451
|
platform: string,
|
|
@@ -455,14 +455,14 @@ export class SdCliCordova {
|
|
|
455
455
|
|
|
456
456
|
// 결과물 복사: ANDROID
|
|
457
457
|
if (platform === "android") {
|
|
458
|
-
this
|
|
458
|
+
this.#copyAndroidBuildOutput(cordovaPath, targetOutPath, buildType);
|
|
459
459
|
}
|
|
460
460
|
|
|
461
461
|
// 자동업데이트를 위한 파일 생성
|
|
462
|
-
await this
|
|
462
|
+
await this.#createUpdateZipAsync(cordovaPath, outPath, platform);
|
|
463
463
|
}
|
|
464
464
|
|
|
465
|
-
|
|
465
|
+
#copyAndroidBuildOutput(cordovaPath: string, targetOutPath: string, buildType: string) {
|
|
466
466
|
const apkFileName = this._opt.config.platform!.android!.sign
|
|
467
467
|
? `app-${buildType}.apk`
|
|
468
468
|
: `app-${buildType}-unsigned.apk`;
|
|
@@ -482,37 +482,37 @@ export class SdCliCordova {
|
|
|
482
482
|
// 업데이트파일
|
|
483
483
|
FsUtils.copy(
|
|
484
484
|
path.resolve(cordovaPath, "platforms/android/app/build/outputs/apk", buildType, apkFileName),
|
|
485
|
-
path.resolve(targetOutPath, "updates", `${this.
|
|
485
|
+
path.resolve(targetOutPath, "updates", `${this.#npmConfig.version}.apk`),
|
|
486
486
|
);
|
|
487
487
|
}
|
|
488
488
|
|
|
489
|
-
|
|
489
|
+
async #createUpdateZipAsync(
|
|
490
490
|
cordovaPath: string,
|
|
491
491
|
outPath: string,
|
|
492
492
|
platform: string,
|
|
493
493
|
): Promise<void> {
|
|
494
494
|
const zip = new SdZip();
|
|
495
|
-
const wwwPath = path.resolve(cordovaPath, this
|
|
495
|
+
const wwwPath = path.resolve(cordovaPath, this.#WWW_DIR_NAME);
|
|
496
496
|
const platformWwwPath = path.resolve(
|
|
497
497
|
cordovaPath,
|
|
498
|
-
this
|
|
498
|
+
this.#PLATFORMS_DIR_NAME,
|
|
499
499
|
platform,
|
|
500
500
|
"platform_www",
|
|
501
501
|
);
|
|
502
502
|
|
|
503
|
-
this
|
|
504
|
-
this
|
|
503
|
+
this.#addFilesToZip(zip, wwwPath);
|
|
504
|
+
this.#addFilesToZip(zip, platformWwwPath);
|
|
505
505
|
|
|
506
506
|
// ZIP 파일 생성
|
|
507
507
|
const updateDirPath = path.resolve(outPath, platform, "updates");
|
|
508
508
|
FsUtils.mkdirs(updateDirPath);
|
|
509
509
|
FsUtils.writeFile(
|
|
510
|
-
path.resolve(updateDirPath, this.
|
|
510
|
+
path.resolve(updateDirPath, this.#npmConfig.version + ".zip"),
|
|
511
511
|
await zip.compressAsync(),
|
|
512
512
|
);
|
|
513
513
|
}
|
|
514
514
|
|
|
515
|
-
|
|
515
|
+
#addFilesToZip(zip: SdZip, dirPath: string) {
|
|
516
516
|
const files = FsUtils.glob(path.resolve(dirPath, "**/*"), { nodir: true });
|
|
517
517
|
for (const file of files) {
|
|
518
518
|
const relFilePath = path.relative(dirPath, file);
|
|
@@ -551,6 +551,6 @@ export class SdCliCordova {
|
|
|
551
551
|
);
|
|
552
552
|
}
|
|
553
553
|
|
|
554
|
-
await
|
|
554
|
+
await this.#execAsync(`npx cordova run ${opt.platform} --device`, cordovaPath);
|
|
555
555
|
}
|
|
556
556
|
}
|
|
@@ -8,42 +8,42 @@ import { loadProjConfAsync } from "./utils/loadProjConfAsync";
|
|
|
8
8
|
import electronBuilder from "electron-builder";
|
|
9
9
|
|
|
10
10
|
export class SdCliElectron {
|
|
11
|
-
|
|
11
|
+
static #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
|
-
|
|
55
|
+
static async #loadDevConfig(opt: {
|
|
56
56
|
package: string;
|
|
57
57
|
config: string;
|
|
58
58
|
options?: string[];
|
|
@@ -72,7 +72,7 @@ export class SdCliElectron {
|
|
|
72
72
|
};
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
-
|
|
75
|
+
static async #prepareAsync(opt: {
|
|
76
76
|
pkgPath: string;
|
|
77
77
|
electronPath: string;
|
|
78
78
|
electronConfig: ISdClientBuilderElectronConfig;
|
|
@@ -109,14 +109,14 @@ export class SdCliElectron {
|
|
|
109
109
|
return { npmConfig };
|
|
110
110
|
}
|
|
111
111
|
|
|
112
|
-
|
|
112
|
+
static async #buildAsync(opt: {
|
|
113
113
|
pkgPath: string;
|
|
114
114
|
electronPath: string;
|
|
115
115
|
electronDistPath: string;
|
|
116
116
|
npmConfig: INpmConfig;
|
|
117
117
|
electronConfig: ISdClientBuilderElectronConfig;
|
|
118
118
|
}) {
|
|
119
|
-
if (!this
|
|
119
|
+
if (!this.#canCreateSymlink()) {
|
|
120
120
|
throw new Error(
|
|
121
121
|
"'Electron 빌드'를 위해서는 'Symlink 생성' 권한이 필요합니다. 윈도우의 개발자모드를 활성화하세요.",
|
|
122
122
|
);
|
|
@@ -173,7 +173,7 @@ export class SdCliElectron {
|
|
|
173
173
|
);
|
|
174
174
|
}
|
|
175
175
|
|
|
176
|
-
|
|
176
|
+
static #canCreateSymlink() {
|
|
177
177
|
const tmpDir = os.tmpdir();
|
|
178
178
|
const testTarget = path.join(tmpDir, "symlink-test-target.txt");
|
|
179
179
|
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("로컬 업데이트 구성", updatePathInfos);
|
|
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("로컬 업데이트 구성", updatePathInfos);
|
|
40
40
|
|
|
41
41
|
const watcher = SdFsWatcher.watch(updatePathInfos.map((item) => item.source));
|
|
@@ -68,7 +68,7 @@ export class SdCliLocalUpdate {
|
|
|
68
68
|
});
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
-
|
|
71
|
+
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"하여 대상 패키지경로 목록 가져오기
|
|
@@ -58,7 +58,7 @@ export class SdCliProject {
|
|
|
58
58
|
logger.debug("빌드를 시작합니다...");
|
|
59
59
|
})
|
|
60
60
|
.on("complete", (messages) => {
|
|
61
|
-
this
|
|
61
|
+
this.#logging(messages, logger);
|
|
62
62
|
});
|
|
63
63
|
|
|
64
64
|
await pkgPaths.parallelAsync(async (pkgPath) => {
|
|
@@ -97,7 +97,7 @@ export class SdCliProject {
|
|
|
97
97
|
}
|
|
98
98
|
|
|
99
99
|
logger.debug("프로젝트 및 패키지 버전 설정...");
|
|
100
|
-
this
|
|
100
|
+
this.#upgradeVersion(projNpmConf, allPkgPaths);
|
|
101
101
|
|
|
102
102
|
logger.debug("빌드 프로세스 시작...");
|
|
103
103
|
const multiBuildRunner = new SdMultiBuildRunner();
|
|
@@ -110,7 +110,7 @@ export class SdCliProject {
|
|
|
110
110
|
workspaces: projNpmConf.workspaces!,
|
|
111
111
|
});
|
|
112
112
|
});
|
|
113
|
-
this
|
|
113
|
+
this.#logging(messages.mapMany(), logger);
|
|
114
114
|
}
|
|
115
115
|
|
|
116
116
|
static async publishAsync(opt: {
|
|
@@ -129,7 +129,7 @@ export class SdCliProject {
|
|
|
129
129
|
|
|
130
130
|
if (opt.noBuild) {
|
|
131
131
|
logger.warn("빌드하지 않고, 배포하는것은 상당히 위험합니다.");
|
|
132
|
-
await this
|
|
132
|
+
await this.#waitSecMessageAsync("프로세스를 중지하려면, 'CTRL+C'를 누르세요.", 5);
|
|
133
133
|
} else {
|
|
134
134
|
// GIT 사용중일 경우, 커밋되지 않은 수정사항이 있는지 확인
|
|
135
135
|
if (FsUtils.exists(path.resolve(process.cwd(), ".git"))) {
|
|
@@ -156,7 +156,7 @@ export class SdCliProject {
|
|
|
156
156
|
|
|
157
157
|
if (!opt.noBuild) {
|
|
158
158
|
logger.debug("프로젝트 및 패키지 버전 설정...");
|
|
159
|
-
this
|
|
159
|
+
this.#upgradeVersion(projNpmConf, allPkgPaths);
|
|
160
160
|
|
|
161
161
|
// 빌드
|
|
162
162
|
try {
|
|
@@ -172,7 +172,7 @@ export class SdCliProject {
|
|
|
172
172
|
});
|
|
173
173
|
});
|
|
174
174
|
|
|
175
|
-
this
|
|
175
|
+
this.#logging(messages.mapMany(), logger);
|
|
176
176
|
} catch (err) {
|
|
177
177
|
await SdProcess.spawnAsync("git checkout .");
|
|
178
178
|
throw err;
|
|
@@ -200,7 +200,7 @@ export class SdCliProject {
|
|
|
200
200
|
if (pkgConf?.publish == null) return;
|
|
201
201
|
|
|
202
202
|
logger.debug(`[${pkgName}] 배포 시작...`);
|
|
203
|
-
await this
|
|
203
|
+
await this.#publishPkgAsync(pkgPath, pkgConf.publish);
|
|
204
204
|
logger.debug(`[${pkgName}] 배포 완료`);
|
|
205
205
|
});
|
|
206
206
|
|
|
@@ -229,7 +229,7 @@ export class SdCliProject {
|
|
|
229
229
|
logger.info(`모든 배포가 완료되었습니다. (v${projNpmConf.version})`);
|
|
230
230
|
}
|
|
231
231
|
|
|
232
|
-
|
|
232
|
+
static async #publishPkgAsync(
|
|
233
233
|
pkgPath: string,
|
|
234
234
|
pkgPubConf: TSdPackageConfig["publish"],
|
|
235
235
|
): Promise<void> {
|
|
@@ -281,7 +281,7 @@ export class SdCliProject {
|
|
|
281
281
|
}
|
|
282
282
|
}
|
|
283
283
|
|
|
284
|
-
|
|
284
|
+
static async #waitSecMessageAsync(msg: string, sec: number): Promise<void> {
|
|
285
285
|
for (let i = sec; i > 0; i--) {
|
|
286
286
|
if (i !== sec) {
|
|
287
287
|
process.stdout.cursorTo(0);
|
|
@@ -294,7 +294,7 @@ export class SdCliProject {
|
|
|
294
294
|
process.stdout.clearLine(0);
|
|
295
295
|
}
|
|
296
296
|
|
|
297
|
-
|
|
297
|
+
static #upgradeVersion(projNpmConf: INpmConfig, allPkgPaths: string[]) {
|
|
298
298
|
// 작업공간 package.json 버전 설정
|
|
299
299
|
const newVersion = semver.inc(projNpmConf.version, "patch")!;
|
|
300
300
|
projNpmConf.version = newVersion;
|
|
@@ -346,7 +346,7 @@ export class SdCliProject {
|
|
|
346
346
|
}
|
|
347
347
|
}
|
|
348
348
|
|
|
349
|
-
|
|
349
|
+
static #logging(buildResults: ISdBuildMessage[], logger: SdLogger): void {
|
|
350
350
|
const messageMap = buildResults.toSetMap(
|
|
351
351
|
(item) => item.severity,
|
|
352
352
|
(item) => SdCliConvertMessageUtils.getBuildMessageString(item),
|