@simplysm/sd-cli 7.0.235 → 7.0.238
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-tool/SdCliCordova.mjs +4 -2
- package/dist/builder/SdCliClientBuilder.mjs +31 -22
- package/dist/entry-points/SdCliLocalUpdate.mjs +2 -2
- package/dist/entry-points/SdCliWorkspace.mjs +2 -2
- package/lib/cordova-entry.js +18 -0
- package/package.json +6 -6
- package/src/build-tool/SdCliCordova.ts +236 -234
- package/src/builder/SdCliClientBuilder.ts +31 -21
- package/src/entry-points/SdCliLocalUpdate.ts +121 -121
- package/src/entry-points/SdCliWorkspace.ts +455 -455
- package/tsconfig.json +38 -38
|
@@ -1,234 +1,236 @@
|
|
|
1
|
-
import { INpmConfig, ISdCliClientBuilderCordovaConfig } from "../commons";
|
|
2
|
-
import * as path from "path";
|
|
3
|
-
import { FsUtil, Logger, SdProcess } from "@simplysm/sd-core-node";
|
|
4
|
-
import JSZip from "jszip";
|
|
5
|
-
import xml2js from "xml2js";
|
|
6
|
-
|
|
7
|
-
export class SdCliCordova {
|
|
8
|
-
protected readonly _logger: Logger;
|
|
9
|
-
|
|
10
|
-
private readonly _npmConfig: INpmConfig;
|
|
11
|
-
|
|
12
|
-
public readonly cordovaPath = path.resolve(this._rootPath, ".cordova");
|
|
13
|
-
private readonly _binPath = path.resolve(process.cwd(), "node_modules/.bin/cordova.cmd");
|
|
14
|
-
|
|
15
|
-
public get platforms(): ("browser" | "android")[] {
|
|
16
|
-
return [
|
|
17
|
-
...this._config.target?.browser ? ["browser" as const] : [],
|
|
18
|
-
...this._config.target?.android ? ["android" as const] : []
|
|
19
|
-
];
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
public constructor(private readonly _rootPath: string, private readonly _config: ISdCliClientBuilderCordovaConfig) {
|
|
23
|
-
this._npmConfig = FsUtil.readJson(path.resolve(this._rootPath, "package.json"));
|
|
24
|
-
this._logger = Logger.get(["simplysm", "sd-cli", this.constructor.name, this._npmConfig.name]);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
private async _execAsync(cmd: string, cwd: string): Promise<void> {
|
|
28
|
-
this._logger.debug(cmd);
|
|
29
|
-
const msg = await SdProcess.spawnAsync(cmd, { cwd });
|
|
30
|
-
this._logger.debug(msg);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
public async initializeAsync(): Promise<void> {
|
|
34
|
-
if (FsUtil.exists(this.cordovaPath)) {
|
|
35
|
-
this._logger.log("이미 생성되어있는 '.cordova'를 사용합니다.");
|
|
36
|
-
}
|
|
37
|
-
else {
|
|
38
|
-
await this._execAsync(`${this._binPath} telemetry on`, this._rootPath);
|
|
39
|
-
|
|
40
|
-
// 프로젝트 생성
|
|
41
|
-
await this._execAsync(`${this._binPath} create "${this.cordovaPath}" "${this._config.appId}" "${this._config.appName}"`, process.cwd());
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
// platforms 폴더 혹시 없으면 생성
|
|
45
|
-
await FsUtil.mkdirsAsync(path.resolve(this.cordovaPath, "platforms"));
|
|
46
|
-
|
|
47
|
-
// www 폴더 혹시 없으면 생성
|
|
48
|
-
await FsUtil.mkdirsAsync(path.resolve(this.cordovaPath, "www"));
|
|
49
|
-
|
|
50
|
-
// 미설치 빌드 플랫폼 신규 생성
|
|
51
|
-
const alreadyPlatforms = await FsUtil.readdirAsync(path.resolve(this.cordovaPath, "platforms"));
|
|
52
|
-
for (const platform of this.platforms) {
|
|
53
|
-
if (!alreadyPlatforms.includes(platform)) {
|
|
54
|
-
await this._execAsync(`${this._binPath} platform add ${platform}`, this.cordovaPath);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
// 설치 미빌드 플랫폼 삭제
|
|
59
|
-
for (const alreadyPlatform of alreadyPlatforms) {
|
|
60
|
-
if (this._config.target?.[alreadyPlatform] == null) {
|
|
61
|
-
await this._execAsync(`${this._binPath} platform remove ${alreadyPlatform}`, this.cordovaPath);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
// 미설치 플러그인들 설치
|
|
66
|
-
const pluginsFetch = FsUtil.exists(path.resolve(this.cordovaPath, "plugins/fetch.json"))
|
|
67
|
-
? await FsUtil.readJsonAsync(path.resolve(this.cordovaPath, "plugins/fetch.json"))
|
|
68
|
-
: undefined;
|
|
69
|
-
const alreadyPlugins = pluginsFetch != undefined
|
|
70
|
-
? Object.values(pluginsFetch)
|
|
71
|
-
.map((item: any) => (item.source.id !== undefined ? item.source.id.replace(/@.*$/, "") : item.source.url))
|
|
72
|
-
: [];
|
|
73
|
-
|
|
74
|
-
for (const plugin of this._config.plugins?.distinct() ?? []) {
|
|
75
|
-
if (!alreadyPlugins.includes(plugin)) {
|
|
76
|
-
await this._execAsync(`${this._binPath} plugin add ${plugin}`, this.cordovaPath);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
// 설치된 미사용 플러그인 삭제
|
|
81
|
-
for (const alreadyPlugin of alreadyPlugins) {
|
|
82
|
-
if (!(this._config.plugins?.distinct() ?? []).includes(alreadyPlugin)) {
|
|
83
|
-
await this._execAsync(`${this._binPath} plugin remove ${alreadyPlugin}`, this.cordovaPath);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
// ANDROID SIGN 파일 복사
|
|
88
|
-
if (this._config.target?.android?.sign) {
|
|
89
|
-
await FsUtil.copyAsync(
|
|
90
|
-
path.resolve(this._rootPath, this._config.target.android.sign.keystore),
|
|
91
|
-
path.resolve(this.cordovaPath, "android.keystore")
|
|
92
|
-
);
|
|
93
|
-
}
|
|
94
|
-
else {
|
|
95
|
-
await FsUtil.removeAsync(path.resolve(this.cordovaPath, "android.keystore"));
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
// 빌드 옵션 파일 생성
|
|
99
|
-
await FsUtil.writeJsonAsync(
|
|
100
|
-
path.resolve(this.cordovaPath, "build.json"),
|
|
101
|
-
{
|
|
102
|
-
...this._config.target?.android ? {
|
|
103
|
-
android: {
|
|
104
|
-
release: {
|
|
105
|
-
packageType: this._config.target.android.bundle ? "bundle" : "apk",
|
|
106
|
-
...this._config.target.android.sign ? {
|
|
107
|
-
keystore: path.resolve(this.cordovaPath, "android.keystore"),
|
|
108
|
-
storePassword: this._config.target.android.sign.storePassword,
|
|
109
|
-
alias: this._config.target.android.sign.alias,
|
|
110
|
-
password: this._config.target.android.sign.password,
|
|
111
|
-
keystoreType: this._config.target.android.sign.keystoreType
|
|
112
|
-
} : {}
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
} : {}
|
|
116
|
-
}
|
|
117
|
-
);
|
|
118
|
-
|
|
119
|
-
// ICON 파일 복사
|
|
120
|
-
if (this._config.icon !== undefined) {
|
|
121
|
-
await FsUtil.copyAsync(path.resolve(this._rootPath, this._config.icon), path.resolve(this.cordovaPath, "res", "icon.png"));
|
|
122
|
-
}
|
|
123
|
-
else {
|
|
124
|
-
await FsUtil.removeAsync(path.resolve(this.cordovaPath, "res", "icon.png"));
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
// CONFIG: 초기값 백업
|
|
128
|
-
const configFilePath = path.resolve(this.cordovaPath, "config.xml");
|
|
129
|
-
const configBackFilePath = path.resolve(this.cordovaPath, "config.xml.bak");
|
|
130
|
-
if (!FsUtil.exists(configBackFilePath)) {
|
|
131
|
-
await FsUtil.copyAsync(configFilePath, configBackFilePath);
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
// CONFIG: 초기값 읽기
|
|
135
|
-
const configFileContent = await FsUtil.readFileAsync(configBackFilePath);
|
|
136
|
-
const configXml = await xml2js.parseStringPromise(configFileContent);
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
// CONFIG: 버전 설정
|
|
140
|
-
configXml.widget.$.version = this._npmConfig.version;
|
|
141
|
-
|
|
142
|
-
// CONFIG: ICON 설정
|
|
143
|
-
if (this._config.icon !== undefined) {
|
|
144
|
-
configXml["widget"]["icon"] = [{ "$": { "src": "res/icon.png" } }];
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
// CONFIG: 접근허용 세팅
|
|
148
|
-
configXml["widget"]["allow-navigation"] = [{ "$": { "href": "*://*/*" } }];
|
|
149
|
-
|
|
150
|
-
// CONFIG: ANDROID usesCleartextTraffic 설정
|
|
151
|
-
if (this._config.target?.android) {
|
|
152
|
-
configXml.widget.$["xmlns:android"] = "http://schemas.android.com/apk/res/android";
|
|
153
|
-
|
|
154
|
-
configXml["widget"]["platform"] = configXml["widget"]["platform"] ?? [];
|
|
155
|
-
configXml["widget"]["platform"].push({
|
|
156
|
-
"$": {
|
|
157
|
-
"name": "android"
|
|
158
|
-
},
|
|
159
|
-
"edit-config": [{
|
|
160
|
-
"$": {
|
|
161
|
-
"file": "app/src/main/AndroidManifest.xml",
|
|
162
|
-
"mode": "merge",
|
|
163
|
-
"target": "/manifest/application"
|
|
164
|
-
},
|
|
165
|
-
"application": [{
|
|
166
|
-
"
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
const
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
//
|
|
197
|
-
// )
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
await
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
await FsUtil.
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
}
|
|
1
|
+
import { INpmConfig, ISdCliClientBuilderCordovaConfig } from "../commons";
|
|
2
|
+
import * as path from "path";
|
|
3
|
+
import { FsUtil, Logger, SdProcess } from "@simplysm/sd-core-node";
|
|
4
|
+
import JSZip from "jszip";
|
|
5
|
+
import xml2js from "xml2js";
|
|
6
|
+
|
|
7
|
+
export class SdCliCordova {
|
|
8
|
+
protected readonly _logger: Logger;
|
|
9
|
+
|
|
10
|
+
private readonly _npmConfig: INpmConfig;
|
|
11
|
+
|
|
12
|
+
public readonly cordovaPath = path.resolve(this._rootPath, ".cordova");
|
|
13
|
+
private readonly _binPath = path.resolve(process.cwd(), "node_modules/.bin/cordova.cmd");
|
|
14
|
+
|
|
15
|
+
public get platforms(): ("browser" | "android")[] {
|
|
16
|
+
return [
|
|
17
|
+
...this._config.target?.browser ? ["browser" as const] : [],
|
|
18
|
+
...this._config.target?.android ? ["android" as const] : []
|
|
19
|
+
];
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
public constructor(private readonly _rootPath: string, private readonly _config: ISdCliClientBuilderCordovaConfig) {
|
|
23
|
+
this._npmConfig = FsUtil.readJson(path.resolve(this._rootPath, "package.json"));
|
|
24
|
+
this._logger = Logger.get(["simplysm", "sd-cli", this.constructor.name, this._npmConfig.name]);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
private async _execAsync(cmd: string, cwd: string): Promise<void> {
|
|
28
|
+
this._logger.debug(cmd);
|
|
29
|
+
const msg = await SdProcess.spawnAsync(cmd, { cwd });
|
|
30
|
+
this._logger.debug(msg);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
public async initializeAsync(): Promise<void> {
|
|
34
|
+
if (FsUtil.exists(this.cordovaPath)) {
|
|
35
|
+
this._logger.log("이미 생성되어있는 '.cordova'를 사용합니다.");
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
await this._execAsync(`${this._binPath} telemetry on`, this._rootPath);
|
|
39
|
+
|
|
40
|
+
// 프로젝트 생성
|
|
41
|
+
await this._execAsync(`${this._binPath} create "${this.cordovaPath}" "${this._config.appId}" "${this._config.appName}"`, process.cwd());
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// platforms 폴더 혹시 없으면 생성
|
|
45
|
+
await FsUtil.mkdirsAsync(path.resolve(this.cordovaPath, "platforms"));
|
|
46
|
+
|
|
47
|
+
// www 폴더 혹시 없으면 생성
|
|
48
|
+
await FsUtil.mkdirsAsync(path.resolve(this.cordovaPath, "www"));
|
|
49
|
+
|
|
50
|
+
// 미설치 빌드 플랫폼 신규 생성
|
|
51
|
+
const alreadyPlatforms = await FsUtil.readdirAsync(path.resolve(this.cordovaPath, "platforms"));
|
|
52
|
+
for (const platform of this.platforms) {
|
|
53
|
+
if (!alreadyPlatforms.includes(platform)) {
|
|
54
|
+
await this._execAsync(`${this._binPath} platform add ${platform}`, this.cordovaPath);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// 설치 미빌드 플랫폼 삭제
|
|
59
|
+
for (const alreadyPlatform of alreadyPlatforms) {
|
|
60
|
+
if (this._config.target?.[alreadyPlatform] == null) {
|
|
61
|
+
await this._execAsync(`${this._binPath} platform remove ${alreadyPlatform}`, this.cordovaPath);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// 미설치 플러그인들 설치
|
|
66
|
+
const pluginsFetch = FsUtil.exists(path.resolve(this.cordovaPath, "plugins/fetch.json"))
|
|
67
|
+
? await FsUtil.readJsonAsync(path.resolve(this.cordovaPath, "plugins/fetch.json"))
|
|
68
|
+
: undefined;
|
|
69
|
+
const alreadyPlugins = pluginsFetch != undefined
|
|
70
|
+
? Object.values(pluginsFetch)
|
|
71
|
+
.map((item: any) => (item.source.id !== undefined ? item.source.id.replace(/@.*$/, "") : item.source.url))
|
|
72
|
+
: [];
|
|
73
|
+
|
|
74
|
+
for (const plugin of this._config.plugins?.distinct() ?? []) {
|
|
75
|
+
if (!alreadyPlugins.includes(plugin)) {
|
|
76
|
+
await this._execAsync(`${this._binPath} plugin add ${plugin}`, this.cordovaPath);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// 설치된 미사용 플러그인 삭제
|
|
81
|
+
for (const alreadyPlugin of alreadyPlugins) {
|
|
82
|
+
if (!(this._config.plugins?.distinct() ?? []).includes(alreadyPlugin)) {
|
|
83
|
+
await this._execAsync(`${this._binPath} plugin remove ${alreadyPlugin}`, this.cordovaPath);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// ANDROID SIGN 파일 복사
|
|
88
|
+
if (this._config.target?.android?.sign) {
|
|
89
|
+
await FsUtil.copyAsync(
|
|
90
|
+
path.resolve(this._rootPath, this._config.target.android.sign.keystore),
|
|
91
|
+
path.resolve(this.cordovaPath, "android.keystore")
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
await FsUtil.removeAsync(path.resolve(this.cordovaPath, "android.keystore"));
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// 빌드 옵션 파일 생성
|
|
99
|
+
await FsUtil.writeJsonAsync(
|
|
100
|
+
path.resolve(this.cordovaPath, "build.json"),
|
|
101
|
+
{
|
|
102
|
+
...this._config.target?.android ? {
|
|
103
|
+
android: {
|
|
104
|
+
release: {
|
|
105
|
+
packageType: this._config.target.android.bundle ? "bundle" : "apk",
|
|
106
|
+
...this._config.target.android.sign ? {
|
|
107
|
+
keystore: path.resolve(this.cordovaPath, "android.keystore"),
|
|
108
|
+
storePassword: this._config.target.android.sign.storePassword,
|
|
109
|
+
alias: this._config.target.android.sign.alias,
|
|
110
|
+
password: this._config.target.android.sign.password,
|
|
111
|
+
keystoreType: this._config.target.android.sign.keystoreType
|
|
112
|
+
} : {}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
} : {}
|
|
116
|
+
}
|
|
117
|
+
);
|
|
118
|
+
|
|
119
|
+
// ICON 파일 복사
|
|
120
|
+
if (this._config.icon !== undefined) {
|
|
121
|
+
await FsUtil.copyAsync(path.resolve(this._rootPath, this._config.icon), path.resolve(this.cordovaPath, "res", "icon.png"));
|
|
122
|
+
}
|
|
123
|
+
else {
|
|
124
|
+
await FsUtil.removeAsync(path.resolve(this.cordovaPath, "res", "icon.png"));
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// CONFIG: 초기값 백업
|
|
128
|
+
const configFilePath = path.resolve(this.cordovaPath, "config.xml");
|
|
129
|
+
const configBackFilePath = path.resolve(this.cordovaPath, "config.xml.bak");
|
|
130
|
+
if (!FsUtil.exists(configBackFilePath)) {
|
|
131
|
+
await FsUtil.copyAsync(configFilePath, configBackFilePath);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// CONFIG: 초기값 읽기
|
|
135
|
+
const configFileContent = await FsUtil.readFileAsync(configBackFilePath);
|
|
136
|
+
const configXml = await xml2js.parseStringPromise(configFileContent);
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
// CONFIG: 버전 설정
|
|
140
|
+
configXml.widget.$.version = this._npmConfig.version;
|
|
141
|
+
|
|
142
|
+
// CONFIG: ICON 설정
|
|
143
|
+
if (this._config.icon !== undefined) {
|
|
144
|
+
configXml["widget"]["icon"] = [{ "$": { "src": "res/icon.png" } }];
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// CONFIG: 접근허용 세팅
|
|
148
|
+
configXml["widget"]["allow-navigation"] = [{ "$": { "href": "*://*/*" } }];
|
|
149
|
+
|
|
150
|
+
// CONFIG: ANDROID usesCleartextTraffic 설정
|
|
151
|
+
if (this._config.target?.android) {
|
|
152
|
+
configXml.widget.$["xmlns:android"] = "http://schemas.android.com/apk/res/android";
|
|
153
|
+
|
|
154
|
+
configXml["widget"]["platform"] = configXml["widget"]["platform"] ?? [];
|
|
155
|
+
configXml["widget"]["platform"].push({
|
|
156
|
+
"$": {
|
|
157
|
+
"name": "android"
|
|
158
|
+
},
|
|
159
|
+
"edit-config": [{
|
|
160
|
+
"$": {
|
|
161
|
+
"file": "app/src/main/AndroidManifest.xml",
|
|
162
|
+
"mode": "merge",
|
|
163
|
+
"target": "/manifest/application"
|
|
164
|
+
},
|
|
165
|
+
"application": [{
|
|
166
|
+
"$": {
|
|
167
|
+
"android:usesCleartextTraffic": "true"
|
|
168
|
+
}
|
|
169
|
+
}]
|
|
170
|
+
}]
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
// CONFIG: 파일 새로 쓰기
|
|
175
|
+
const configResultContent = new xml2js.Builder().buildObject(configXml);
|
|
176
|
+
await FsUtil.writeFileAsync(configFilePath, configResultContent);
|
|
177
|
+
|
|
178
|
+
// 각 플랫폼 www 준비
|
|
179
|
+
await this._execAsync(`${this._binPath} prepare`, this.cordovaPath);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
public async buildAsync(outPath: string): Promise<void> {
|
|
183
|
+
// 실행
|
|
184
|
+
const buildType = this._config.debug ? "debug" : "release";
|
|
185
|
+
for (const platform of this.platforms) {
|
|
186
|
+
await this._execAsync(`${this._binPath} build ${platform} --${buildType}`, this.cordovaPath);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
// 결과물 복사: ANDROID
|
|
190
|
+
if (this._config.target?.android) {
|
|
191
|
+
const targetOutPath = path.resolve(outPath, "android");
|
|
192
|
+
const apkFileName = this._config.target.android.sign ? `app-${buildType}.apk` : `app-${buildType}-unsigned.apk`;
|
|
193
|
+
// const distApkFileName = path.basename(`${this._config.appName}${this._config.target.android.sign ? "" : "-unsigned"}-v${this._npmConfig.version}.apk`);
|
|
194
|
+
const latestDistApkFileName = path.basename(`${this._config.appName}${this._config.target.android.sign ? "" : "-unsigned"}-latest.apk`);
|
|
195
|
+
await FsUtil.mkdirsAsync(targetOutPath);
|
|
196
|
+
// await FsUtil.copyAsync(
|
|
197
|
+
// path.resolve(this.cordovaPath, "platforms/android/app/build/outputs/apk", buildType, apkFileName),
|
|
198
|
+
// path.resolve(targetOutPath, distApkFileName)
|
|
199
|
+
// );
|
|
200
|
+
await FsUtil.copyAsync(
|
|
201
|
+
path.resolve(this.cordovaPath, "platforms/android/app/build/outputs/apk", buildType, apkFileName),
|
|
202
|
+
path.resolve(targetOutPath, latestDistApkFileName)
|
|
203
|
+
);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
if (this._config.target?.android) {
|
|
207
|
+
// 자동업데이트를 위한 zip 파일 쓰기
|
|
208
|
+
const zip = new JSZip();
|
|
209
|
+
const resultFiles = await FsUtil.globAsync(path.resolve(this.cordovaPath, "platforms", "android", "app", "src", "main", "assets", "www", "**/*"), {
|
|
210
|
+
dot: true,
|
|
211
|
+
nodir: true
|
|
212
|
+
});
|
|
213
|
+
for (const resultFile of resultFiles) {
|
|
214
|
+
const contentBuffer = await FsUtil.readFileBufferAsync(resultFile);
|
|
215
|
+
const relativePath = path.relative(path.resolve(this.cordovaPath, "www"), resultFile);
|
|
216
|
+
zip.file("/" + relativePath, contentBuffer);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
const zipFileName = path.basename(`${this._npmConfig.version}.zip`);
|
|
220
|
+
const resultBuffer = await zip.generateAsync({ type: "nodebuffer" });
|
|
221
|
+
|
|
222
|
+
await FsUtil.writeFileAsync(path.resolve(outPath, "android/updates/", zipFileName), resultBuffer);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
public static async runWebviewOnDeviceAsync(rootPath: string, platform: "browser" | "android", pkgName: string, url: string): Promise<void> {
|
|
227
|
+
const cordovaPath = path.resolve(rootPath, `packages/${pkgName}/.cordova/`);
|
|
228
|
+
|
|
229
|
+
await FsUtil.removeAsync(path.resolve(cordovaPath, "www"));
|
|
230
|
+
await FsUtil.mkdirsAsync(path.resolve(cordovaPath, "www"));
|
|
231
|
+
await FsUtil.writeFileAsync(path.resolve(cordovaPath, "www/index.html"), `'${url}'로 이동중... <script>setTimeout(function () {window.location.href = "${url.replace(/\/$/, "")}/${pkgName}/cordova/"}, 3000);</script>`.trim());
|
|
232
|
+
|
|
233
|
+
const binPath = path.resolve(process.cwd(), "node_modules/.bin/cordova.cmd");
|
|
234
|
+
await SdProcess.spawnAsync(`${binPath} run ${platform} --device`, { cwd: cordovaPath }, true);
|
|
235
|
+
}
|
|
236
|
+
}
|
|
@@ -31,6 +31,8 @@ import { SdCliCordova } from "../build-tool/SdCliCordova";
|
|
|
31
31
|
import { SdCliNpmConfigUtil } from "../utils/SdCliNpmConfigUtil";
|
|
32
32
|
import electronBuilder from "electron-builder";
|
|
33
33
|
import LintResult = ESLint.LintResult;
|
|
34
|
+
import { fileURLToPath } from "url";
|
|
35
|
+
import { Entrypoint } from "@angular-devkit/build-angular/src/utils/index-file/augment-index-html";
|
|
34
36
|
|
|
35
37
|
export class SdCliClientBuilder extends EventEmitter {
|
|
36
38
|
private readonly _logger: Logger;
|
|
@@ -213,7 +215,7 @@ export class SdCliClientBuilder extends EventEmitter {
|
|
|
213
215
|
// CORDOVA 빌드
|
|
214
216
|
if (this._cordova) {
|
|
215
217
|
this._logger.debug("CORDOVA 빌드...");
|
|
216
|
-
await this._cordova.buildAsync(
|
|
218
|
+
await this._cordova.buildAsync(this._parsedTsconfig.options.outDir!);
|
|
217
219
|
}
|
|
218
220
|
|
|
219
221
|
// ELECTRON
|
|
@@ -356,7 +358,8 @@ export class SdCliClientBuilder extends EventEmitter {
|
|
|
356
358
|
entry: {
|
|
357
359
|
main: [mainFilePath],
|
|
358
360
|
...FsUtil.exists(polyfillsFilePath) ? { polyfills: [polyfillsFilePath] } : {},
|
|
359
|
-
...FsUtil.exists(stylesFilePath) ? { styles: [stylesFilePath] } : {}
|
|
361
|
+
...FsUtil.exists(stylesFilePath) ? { styles: [stylesFilePath] } : {},
|
|
362
|
+
...builderType === "cordova" ? { "cordova-entry": path.resolve(path.dirname(fileURLToPath(import.meta.url)), `../../lib/cordova-entry.js`) } : {}
|
|
360
363
|
},
|
|
361
364
|
output: {
|
|
362
365
|
uniqueName: pkgKey,
|
|
@@ -385,19 +388,19 @@ export class SdCliClientBuilder extends EventEmitter {
|
|
|
385
388
|
experiments: { backCompat: false, syncWebAssembly: true, asyncWebAssembly: true },
|
|
386
389
|
infrastructureLogging: { level: "error" },
|
|
387
390
|
stats: "errors-warnings",
|
|
388
|
-
cache: {
|
|
389
|
-
type: "filesystem",
|
|
390
|
-
profile: watch ? undefined : false,
|
|
391
|
-
cacheDirectory: path.resolve(cacheBasePath, "angular-webpack"),
|
|
392
|
-
maxMemoryGenerations: 1,
|
|
393
|
-
name: createHash("sha1")
|
|
394
|
-
.update(workspacePkgLockContent)
|
|
395
|
-
.update(JSON.stringify(this._parsedTsconfig.options))
|
|
396
|
-
.update(JSON.stringify(this._config))
|
|
397
|
-
.update(watch.toString())
|
|
398
|
-
.digest("hex")
|
|
399
|
-
},
|
|
400
391
|
...watch ? {
|
|
392
|
+
cache: {
|
|
393
|
+
type: "filesystem",
|
|
394
|
+
profile: undefined,
|
|
395
|
+
cacheDirectory: path.resolve(cacheBasePath, "angular-webpack"),
|
|
396
|
+
maxMemoryGenerations: 1,
|
|
397
|
+
name: createHash("sha1")
|
|
398
|
+
.update(workspacePkgLockContent)
|
|
399
|
+
.update(JSON.stringify(this._parsedTsconfig.options))
|
|
400
|
+
.update(JSON.stringify(this._config))
|
|
401
|
+
.update(watch.toString())
|
|
402
|
+
.digest("hex")
|
|
403
|
+
},
|
|
401
404
|
snapshot: {
|
|
402
405
|
immutablePaths: internalModuleCachePaths,
|
|
403
406
|
managedPaths: internalModuleCachePaths
|
|
@@ -477,7 +480,9 @@ export class SdCliClientBuilder extends EventEmitter {
|
|
|
477
480
|
{
|
|
478
481
|
loader: "@angular-devkit/build-angular/src/babel/webpack-loader",
|
|
479
482
|
options: {
|
|
480
|
-
|
|
483
|
+
...watch ? {
|
|
484
|
+
cacheDirectory: path.resolve(cacheBasePath, "babel-webpack"),
|
|
485
|
+
} : {},
|
|
481
486
|
scriptTarget: ts.ScriptTarget.ES2017,
|
|
482
487
|
aot: true,
|
|
483
488
|
optimize: !watch,
|
|
@@ -675,15 +680,20 @@ export class SdCliClientBuilder extends EventEmitter {
|
|
|
675
680
|
["polyfills", true],
|
|
676
681
|
["styles", false],
|
|
677
682
|
["vendor", true],
|
|
678
|
-
["main", true]
|
|
683
|
+
["main", true],
|
|
684
|
+
...builderType === "cordova" ? [
|
|
685
|
+
["cordova-entry", false] as Entrypoint
|
|
686
|
+
] : []
|
|
679
687
|
],
|
|
680
688
|
deployUrl: undefined,
|
|
681
689
|
sri: false,
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
690
|
+
...watch ? {
|
|
691
|
+
cache: {
|
|
692
|
+
enabled: true,
|
|
693
|
+
basePath: cacheBasePath,
|
|
694
|
+
path: path.resolve(cacheBasePath, "index-webpack")
|
|
695
|
+
}
|
|
696
|
+
} : {},
|
|
687
697
|
postTransform: undefined,
|
|
688
698
|
optimization: {
|
|
689
699
|
scripts: !watch,
|