@simplysm/sd-cli 6.4.3 → 7.0.6
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/.eslintrc.cjs +11 -0
- package/dist/bin/sd-cli.d.ts +1 -0
- package/dist/bin/sd-cli.mjs +60 -0
- package/dist/build-tool/SdCliCacheCompilerHost.d.ts +10 -0
- package/dist/build-tool/SdCliCacheCompilerHost.mjs +44 -0
- package/dist/build-tool/SdCliNgCacheCompilerHost.d.ts +11 -0
- package/dist/build-tool/SdCliNgCacheCompilerHost.mjs +36 -0
- package/dist/build-tool/SdCliPackageLinter.d.ts +8 -0
- package/dist/build-tool/SdCliPackageLinter.mjs +41 -0
- package/dist/builder/SdCliJsLibBuilder.d.ts +14 -0
- package/dist/builder/SdCliJsLibBuilder.mjs +50 -0
- package/dist/builder/SdCliTsLibBuilder.d.ts +27 -0
- package/dist/builder/SdCliTsLibBuilder.mjs +226 -0
- package/dist/commons.d.ts +43 -0
- package/dist/commons.mjs +2 -0
- package/dist/entry-points/SdCliWorkspace.d.ts +17 -0
- package/dist/entry-points/SdCliWorkspace.mjs +186 -0
- package/dist/packages/SdCliPackage.d.ts +19 -0
- package/dist/packages/SdCliPackage.mjs +89 -0
- package/dist/utils/SdBuildResultUtil.d.ts +6 -0
- package/dist/utils/SdBuildResultUtil.mjs +38 -0
- package/lib/ts-node-esm-paths.mjs +15 -0
- package/package.json +27 -58
- package/src/bin/sd-cli.ts +54 -220
- package/src/build-tool/SdCliCacheCompilerHost.ts +71 -0
- package/src/build-tool/SdCliNgCacheCompilerHost.ts +50 -0
- package/src/build-tool/SdCliPackageLinter.ts +54 -0
- package/src/builder/SdCliJsLibBuilder.ts +66 -0
- package/src/builder/SdCliTsLibBuilder.ts +335 -0
- package/src/commons.ts +15 -124
- package/src/entry-points/SdCliWorkspace.ts +222 -0
- package/src/packages/SdCliPackage.ts +111 -0
- package/src/utils/SdBuildResultUtil.ts +43 -0
- package/tsconfig-build.json +9 -0
- package/tsconfig.json +7 -18
- package/.eslintrc.js +0 -19
- package/dist-node/bin/sd-cli.js +0 -197
- package/dist-node/bin/sd-cli.js.map +0 -1
- package/dist-node/build-tools/SdCliCordova.js +0 -144
- package/dist-node/build-tools/SdCliCordova.js.map +0 -1
- package/dist-node/build-tools/SdCliIndexFileGenerator.js +0 -51
- package/dist-node/build-tools/SdCliIndexFileGenerator.js.map +0 -1
- package/dist-node/build-tools/SdCliNgModuleFilesGenerator.js +0 -675
- package/dist-node/build-tools/SdCliNgModuleFilesGenerator.js.map +0 -1
- package/dist-node/build-tools/metadata/SdAotMetadataReader.js +0 -274
- package/dist-node/build-tools/metadata/SdAotMetadataReader.js.map +0 -1
- package/dist-node/build-tools/metadata/SdIvyMetadataReader.js +0 -124
- package/dist-node/build-tools/metadata/SdIvyMetadataReader.js.map +0 -1
- package/dist-node/build-tools/metadata/SdMetadataError.js +0 -13
- package/dist-node/build-tools/metadata/SdMetadataError.js.map +0 -1
- package/dist-node/build-tools/metadata/SdMyMetadataReader.js +0 -321
- package/dist-node/build-tools/metadata/SdMyMetadataReader.js.map +0 -1
- package/dist-node/builders/SdCliJavascriptLinter.js +0 -65
- package/dist-node/builders/SdCliJavascriptLinter.js.map +0 -1
- package/dist-node/builders/SdCliNgClientBuilder.js +0 -637
- package/dist-node/builders/SdCliNgClientBuilder.js.map +0 -1
- package/dist-node/builders/SdCliNgLibraryBuilder.js +0 -217
- package/dist-node/builders/SdCliNgLibraryBuilder.js.map +0 -1
- package/dist-node/builders/SdCliPublisher.js +0 -129
- package/dist-node/builders/SdCliPublisher.js.map +0 -1
- package/dist-node/builders/SdCliServerBuilder.js +0 -452
- package/dist-node/builders/SdCliServerBuilder.js.map +0 -1
- package/dist-node/builders/SdCliTypescriptBuilder.js +0 -347
- package/dist-node/builders/SdCliTypescriptBuilder.js.map +0 -1
- package/dist-node/commons.js +0 -3
- package/dist-node/commons.js.map +0 -1
- package/dist-node/entry-points/SdCliLocalUpdater.js +0 -88
- package/dist-node/entry-points/SdCliLocalUpdater.js.map +0 -1
- package/dist-node/entry-points/SdCliPrepare.js +0 -56
- package/dist-node/entry-points/SdCliPrepare.js.map +0 -1
- package/dist-node/entry-points/SdCliProject.js +0 -302
- package/dist-node/entry-points/SdCliProject.js.map +0 -1
- package/dist-node/packages/SdCliClientPackage.js +0 -91
- package/dist-node/packages/SdCliClientPackage.js.map +0 -1
- package/dist-node/packages/SdCliLibraryPackage.js +0 -99
- package/dist-node/packages/SdCliLibraryPackage.js.map +0 -1
- package/dist-node/packages/SdCliPackageBase.js +0 -33
- package/dist-node/packages/SdCliPackageBase.js.map +0 -1
- package/dist-node/packages/SdCliServerPackage.js +0 -69
- package/dist-node/packages/SdCliServerPackage.js.map +0 -1
- package/dist-node/packages/SdCliUnknownPackage.js +0 -15
- package/dist-node/packages/SdCliUnknownPackage.js.map +0 -1
- package/dist-node/utils/SdCliFileCrypto.js +0 -76
- package/dist-node/utils/SdCliFileCrypto.js.map +0 -1
- package/dist-node/utils/SdProjectConfigUtil.js +0 -62
- package/dist-node/utils/SdProjectConfigUtil.js.map +0 -1
- package/dist-node/utils/SdTsDiagnosticUtil.js +0 -45
- package/dist-node/utils/SdTsDiagnosticUtil.js.map +0 -1
- package/dist-node/utils/SdWebpackUtil.js +0 -63
- package/dist-node/utils/SdWebpackUtil.js.map +0 -1
- package/dist-node/workers/client-ng-gen-worker.js +0 -57
- package/dist-node/workers/client-ng-gen-worker.js.map +0 -1
- package/dist-node/workers/lib-build-worker.js +0 -88
- package/dist-node/workers/lib-build-worker.js.map +0 -1
- package/dist-types/bin/sd-cli.d.ts +0 -3
- package/dist-types/bin/sd-cli.d.ts.map +0 -1
- package/dist-types/build-tools/SdCliCordova.d.ts +0 -15
- package/dist-types/build-tools/SdCliCordova.d.ts.map +0 -1
- package/dist-types/build-tools/SdCliIndexFileGenerator.d.ts +0 -13
- package/dist-types/build-tools/SdCliIndexFileGenerator.d.ts.map +0 -1
- package/dist-types/build-tools/SdCliNgModuleFilesGenerator.d.ts +0 -43
- package/dist-types/build-tools/SdCliNgModuleFilesGenerator.d.ts.map +0 -1
- package/dist-types/build-tools/metadata/SdAotMetadataReader.d.ts +0 -58
- package/dist-types/build-tools/metadata/SdAotMetadataReader.d.ts.map +0 -1
- package/dist-types/build-tools/metadata/SdIvyMetadataReader.d.ts +0 -43
- package/dist-types/build-tools/metadata/SdIvyMetadataReader.d.ts.map +0 -1
- package/dist-types/build-tools/metadata/SdMetadataError.d.ts +0 -7
- package/dist-types/build-tools/metadata/SdMetadataError.d.ts.map +0 -1
- package/dist-types/build-tools/metadata/SdMyMetadataReader.d.ts +0 -59
- package/dist-types/build-tools/metadata/SdMyMetadataReader.d.ts.map +0 -1
- package/dist-types/builders/SdCliJavascriptLinter.d.ts +0 -14
- package/dist-types/builders/SdCliJavascriptLinter.d.ts.map +0 -1
- package/dist-types/builders/SdCliNgClientBuilder.d.ts +0 -29
- package/dist-types/builders/SdCliNgClientBuilder.d.ts.map +0 -1
- package/dist-types/builders/SdCliNgLibraryBuilder.d.ts +0 -30
- package/dist-types/builders/SdCliNgLibraryBuilder.d.ts.map +0 -1
- package/dist-types/builders/SdCliPublisher.d.ts +0 -9
- package/dist-types/builders/SdCliPublisher.d.ts.map +0 -1
- package/dist-types/builders/SdCliServerBuilder.d.ts +0 -31
- package/dist-types/builders/SdCliServerBuilder.d.ts.map +0 -1
- package/dist-types/builders/SdCliTypescriptBuilder.d.ts +0 -56
- package/dist-types/builders/SdCliTypescriptBuilder.d.ts.map +0 -1
- package/dist-types/commons.d.ts +0 -134
- package/dist-types/commons.d.ts.map +0 -1
- package/dist-types/entry-points/SdCliLocalUpdater.d.ts +0 -12
- package/dist-types/entry-points/SdCliLocalUpdater.d.ts.map +0 -1
- package/dist-types/entry-points/SdCliPrepare.d.ts +0 -6
- package/dist-types/entry-points/SdCliPrepare.d.ts.map +0 -1
- package/dist-types/entry-points/SdCliProject.d.ts +0 -32
- package/dist-types/entry-points/SdCliProject.d.ts.map +0 -1
- package/dist-types/packages/SdCliClientPackage.d.ts +0 -17
- package/dist-types/packages/SdCliClientPackage.d.ts.map +0 -1
- package/dist-types/packages/SdCliLibraryPackage.d.ts +0 -20
- package/dist-types/packages/SdCliLibraryPackage.d.ts.map +0 -1
- package/dist-types/packages/SdCliPackageBase.d.ts +0 -11
- package/dist-types/packages/SdCliPackageBase.d.ts.map +0 -1
- package/dist-types/packages/SdCliServerPackage.d.ts +0 -16
- package/dist-types/packages/SdCliServerPackage.d.ts.map +0 -1
- package/dist-types/packages/SdCliUnknownPackage.d.ts +0 -9
- package/dist-types/packages/SdCliUnknownPackage.d.ts.map +0 -1
- package/dist-types/utils/SdCliFileCrypto.d.ts +0 -8
- package/dist-types/utils/SdCliFileCrypto.d.ts.map +0 -1
- package/dist-types/utils/SdProjectConfigUtil.d.ts +0 -7
- package/dist-types/utils/SdProjectConfigUtil.d.ts.map +0 -1
- package/dist-types/utils/SdTsDiagnosticUtil.d.ts +0 -6
- package/dist-types/utils/SdTsDiagnosticUtil.d.ts.map +0 -1
- package/dist-types/utils/SdWebpackUtil.d.ts +0 -7
- package/dist-types/utils/SdWebpackUtil.d.ts.map +0 -1
- package/dist-types/workers/client-ng-gen-worker.d.ts +0 -2
- package/dist-types/workers/client-ng-gen-worker.d.ts.map +0 -1
- package/dist-types/workers/lib-build-worker.d.ts +0 -2
- package/dist-types/workers/lib-build-worker.d.ts.map +0 -1
- package/schema/schema.json +0 -447
- package/sd-tsconfig.node.json +0 -18
- package/src/build-tools/SdCliCordova.ts +0 -240
- package/src/build-tools/SdCliIndexFileGenerator.ts +0 -61
- package/src/build-tools/SdCliNgModuleFilesGenerator.ts +0 -894
- package/src/build-tools/metadata/SdAotMetadataReader.ts +0 -374
- package/src/build-tools/metadata/SdIvyMetadataReader.ts +0 -183
- package/src/build-tools/metadata/SdMetadataError.ts +0 -7
- package/src/build-tools/metadata/SdMyMetadataReader.ts +0 -407
- package/src/builders/SdCliJavascriptLinter.ts +0 -81
- package/src/builders/SdCliNgClientBuilder.ts +0 -794
- package/src/builders/SdCliNgLibraryBuilder.ts +0 -301
- package/src/builders/SdCliPublisher.ts +0 -144
- package/src/builders/SdCliServerBuilder.ts +0 -555
- package/src/builders/SdCliTypescriptBuilder.ts +0 -552
- package/src/entry-points/SdCliLocalUpdater.ts +0 -114
- package/src/entry-points/SdCliPrepare.ts +0 -104
- package/src/entry-points/SdCliProject.ts +0 -405
- package/src/packages/SdCliClientPackage.ts +0 -111
- package/src/packages/SdCliLibraryPackage.ts +0 -118
- package/src/packages/SdCliPackageBase.ts +0 -34
- package/src/packages/SdCliServerPackage.ts +0 -85
- package/src/packages/SdCliUnknownPackage.ts +0 -14
- package/src/utils/SdCliFileCrypto.ts +0 -87
- package/src/utils/SdCliUtils.ts +0 -56
- package/src/utils/SdProjectConfigUtil.ts +0 -145
- package/src/utils/SdTsDiagnosticUtil.ts +0 -46
- package/src/utils/SdWebpackUtil.ts +0 -71
- package/src/workers/client-ng-gen-worker.ts +0 -63
- package/src/workers/lib-build-worker.ts +0 -97
|
@@ -1,240 +0,0 @@
|
|
|
1
|
-
import { INpmConfig, ISdClientCordovaPlatformConfig } from "../commons";
|
|
2
|
-
import * as path from "path";
|
|
3
|
-
import { FsUtil, Logger, SdProcessManager } from "@simplysm/sd-core-node";
|
|
4
|
-
import { NeverEntryError } from "@simplysm/sd-core-common";
|
|
5
|
-
|
|
6
|
-
export class SdCliCordova {
|
|
7
|
-
protected readonly _logger: Logger;
|
|
8
|
-
|
|
9
|
-
private readonly _npmConfig: INpmConfig;
|
|
10
|
-
|
|
11
|
-
private readonly _cordovaPath = path.resolve(this._rootPath, ".cordova");
|
|
12
|
-
private readonly _binPath = path.resolve(process.cwd(), "node_modules/.bin/cordova.cmd");
|
|
13
|
-
|
|
14
|
-
public constructor(private readonly _rootPath: string, private readonly _config: ISdClientCordovaPlatformConfig) {
|
|
15
|
-
this._npmConfig = FsUtil.readJson(path.resolve(this._rootPath, "package.json"));
|
|
16
|
-
this._logger = Logger.get(["simplysm", "sd-cli", this.constructor.name, this._npmConfig.name]);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
public async initializeAsync(): Promise<void> {
|
|
20
|
-
if (FsUtil.exists(this._cordovaPath)) {
|
|
21
|
-
this._logger.log("미리 생성되어있는 '.cordova'를 사용합니다.");
|
|
22
|
-
}
|
|
23
|
-
else {
|
|
24
|
-
await SdProcessManager.spawnAsync(
|
|
25
|
-
`${this._binPath} telemetry on`,
|
|
26
|
-
{ cwd: this._rootPath },
|
|
27
|
-
(message) => {
|
|
28
|
-
this._logger.debug("CORDOVA: " + message);
|
|
29
|
-
}
|
|
30
|
-
);
|
|
31
|
-
|
|
32
|
-
// 프로젝트 삭제
|
|
33
|
-
/*if (FsUtil.exists(this._cordovaPath)) {
|
|
34
|
-
this._logger.debug(`CORDOVA 기존 프로젝트 삭제`);
|
|
35
|
-
await FsUtil.removeAsync(this._cordovaPath);
|
|
36
|
-
}*/
|
|
37
|
-
|
|
38
|
-
// 프로젝트 생성
|
|
39
|
-
this._logger.debug(`CORDOVA 프로젝트 생성`);
|
|
40
|
-
await SdProcessManager.spawnAsync(
|
|
41
|
-
`${this._binPath} create "${this._cordovaPath}" "${this._config.appId}" "${this._config.appName}"`,
|
|
42
|
-
{ cwd: process.cwd() },
|
|
43
|
-
(message) => {
|
|
44
|
-
this._logger.debug("CORDOVA: " + message);
|
|
45
|
-
}
|
|
46
|
-
);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
// platforms 폴더 혹시 없으면 생성
|
|
50
|
-
await FsUtil.mkdirsAsync(path.resolve(this._cordovaPath, "platforms"));
|
|
51
|
-
|
|
52
|
-
// www 폴더 혹시 없으면 생성
|
|
53
|
-
await FsUtil.mkdirsAsync(path.resolve(this._cordovaPath, "www"));
|
|
54
|
-
|
|
55
|
-
// BROWSER 플랫폼 미설치시 신규 생성
|
|
56
|
-
const alreadyPlatforms = await FsUtil.readdirAsync(path.resolve(this._cordovaPath, "platforms"));
|
|
57
|
-
if (!alreadyPlatforms.includes("browser")) {
|
|
58
|
-
this._logger.debug(`CORDOVA 플랫폼 생성: browser`);
|
|
59
|
-
await SdProcessManager.spawnAsync(
|
|
60
|
-
`${this._binPath} platform add browser`,
|
|
61
|
-
{ cwd: this._cordovaPath },
|
|
62
|
-
(message) => {
|
|
63
|
-
this._logger.debug("CORDOVA: " + message);
|
|
64
|
-
}
|
|
65
|
-
);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
// 미설치 빌드 플랫폼 신규 생성
|
|
69
|
-
for (const target of this._config.targets) {
|
|
70
|
-
if (!alreadyPlatforms.includes(target)) {
|
|
71
|
-
this._logger.debug(`CORDOVA 플랫폼 생성: ${target}`);
|
|
72
|
-
await SdProcessManager.spawnAsync(
|
|
73
|
-
`${this._binPath} platform add ${target}`,
|
|
74
|
-
{ cwd: this._cordovaPath },
|
|
75
|
-
(message) => {
|
|
76
|
-
this._logger.debug(`CORDOVA: ${target}: ${message}`);
|
|
77
|
-
}
|
|
78
|
-
);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
// 미설치 플러그인들 설치
|
|
83
|
-
if (this._config.plugins) {
|
|
84
|
-
const pluginsFetch = await FsUtil.readJsonAsync(path.resolve(this._cordovaPath, "plugins/fetch.json"));
|
|
85
|
-
const alreadyPlugins = Object.values(pluginsFetch)
|
|
86
|
-
.map((item: any) => (item.source.id !== undefined ? item.source.id.replace(/@.*$/, "") : item.source.url));
|
|
87
|
-
|
|
88
|
-
for (const plugin of this._config.plugins.distinct()) {
|
|
89
|
-
if (!alreadyPlugins.includes(plugin)) {
|
|
90
|
-
this._logger.debug(`CORDOVA 플러그인 설치 ${plugin}`);
|
|
91
|
-
await SdProcessManager.spawnAsync(
|
|
92
|
-
`${this._binPath} plugin add ${plugin}`,
|
|
93
|
-
{ cwd: this._cordovaPath },
|
|
94
|
-
(message) => {
|
|
95
|
-
this._logger.debug("CORDOVA: " + message);
|
|
96
|
-
}
|
|
97
|
-
);
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
// 서명 처리
|
|
103
|
-
if (this._config.sign) {
|
|
104
|
-
await FsUtil.copyAsync(
|
|
105
|
-
path.resolve(this._rootPath, this._config.sign.keystore),
|
|
106
|
-
path.resolve(this._cordovaPath, path.basename(this._config.sign.keystore))
|
|
107
|
-
);
|
|
108
|
-
await FsUtil.writeJsonAsync(
|
|
109
|
-
path.resolve(this._cordovaPath, "build.json"),
|
|
110
|
-
{
|
|
111
|
-
android: {
|
|
112
|
-
release: {
|
|
113
|
-
keystore: path.basename(this._config.sign.keystore),
|
|
114
|
-
storePassword: this._config.sign.storePassword,
|
|
115
|
-
alias: this._config.sign.alias,
|
|
116
|
-
password: this._config.sign.password,
|
|
117
|
-
keystoreType: this._config.sign.keystoreType
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
);
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
// ICON 파일 복사
|
|
125
|
-
if (this._config.icon !== undefined) {
|
|
126
|
-
await FsUtil.copyAsync(path.resolve(this._rootPath, this._config.icon), path.resolve(this._cordovaPath, "res", "icon", "icon.png"));
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
// ANDROID GRADLE 오류 강제 수정
|
|
130
|
-
if (this._config.targets.includes("android")) {
|
|
131
|
-
const gradleFilePath = path.resolve(this._cordovaPath, "platforms/android/app/build.gradle");
|
|
132
|
-
let gradleFileContent = await FsUtil.readFileAsync(gradleFilePath);
|
|
133
|
-
gradleFileContent = gradleFileContent.replace(/lintOptions {/g, "lintOptions {\r\n checkReleaseBuilds false;");
|
|
134
|
-
await FsUtil.writeFileAsync(gradleFilePath, gradleFileContent);
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
// CONFIG
|
|
138
|
-
const configFilePath = path.resolve(this._cordovaPath, "config.xml");
|
|
139
|
-
let configFileContent = await FsUtil.readFileAsync(configFilePath);
|
|
140
|
-
|
|
141
|
-
// CONFIG: 버전 설정
|
|
142
|
-
configFileContent = configFileContent.replace(/version="[^"]*"/g, `version="${this._npmConfig.version}"`);
|
|
143
|
-
|
|
144
|
-
// CONFIG: ICON 설정
|
|
145
|
-
if (this._config.icon !== undefined && !configFileContent.includes("<icon")) {
|
|
146
|
-
configFileContent = configFileContent.replace("</widget>", " <icon src=\"res/icon/icon.png\" />\r\n</widget>");
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
// CONFIG: ANDROID usesCleartextTraffic 설정
|
|
150
|
-
if (this._config.targets.includes("android")) {
|
|
151
|
-
if (!configFileContent.includes("xmlns:android=\"http://schemas.android.com/apk/res/android\"")) {
|
|
152
|
-
configFileContent = configFileContent.replace(
|
|
153
|
-
"xmlns=\"http://www.w3.org/ns/widgets\"",
|
|
154
|
-
`xmlns="http://www.w3.org/ns/widgets" xmlns:android="http://schemas.android.com/apk/res/android"`
|
|
155
|
-
);
|
|
156
|
-
}
|
|
157
|
-
if (!configFileContent.includes("application android:usesCleartextTraffic=\"true\" />")) {
|
|
158
|
-
configFileContent = configFileContent.replace("<platform name=\"android\">", `<platform name="android">
|
|
159
|
-
<edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application">
|
|
160
|
-
<application android:usesCleartextTraffic="true" />
|
|
161
|
-
</edit-config>`);
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
// CONFIG: 파일쓰기
|
|
166
|
-
await FsUtil.writeFileAsync(configFilePath, configFileContent);
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
public async buildAsync(outPath: string): Promise<void> {
|
|
170
|
-
// CONFIG
|
|
171
|
-
const configFilePath = path.resolve(this._cordovaPath, "config.xml");
|
|
172
|
-
let configFileContent = await FsUtil.readFileAsync(configFilePath);
|
|
173
|
-
|
|
174
|
-
// CONFIG: 외부접근 허용 비우기
|
|
175
|
-
configFileContent = configFileContent.replace(/ {4}<allow-navigation href="[^"]*" \/>\n/g, "");
|
|
176
|
-
|
|
177
|
-
/*// CONFIG: 내부파일접근 허용 등록
|
|
178
|
-
configFileContent = configFileContent.replace("</widget>", ` <allow-navigation href="file://data/user/!*" />\n</widget>`);*/
|
|
179
|
-
configFileContent = configFileContent.replace("</widget>", ` <allow-navigation href="*://*/*" />\n</widget>`);
|
|
180
|
-
|
|
181
|
-
// CONFIG: 파일쓰기
|
|
182
|
-
await FsUtil.writeFileAsync(configFilePath, configFileContent);
|
|
183
|
-
|
|
184
|
-
// 실행
|
|
185
|
-
const buildType = "debug";
|
|
186
|
-
for (const target of this._config.targets) {
|
|
187
|
-
await SdProcessManager.spawnAsync(`${this._binPath} build ${target} --${buildType}`, { cwd: this._cordovaPath }, (message) => {
|
|
188
|
-
this._logger.debug(`CORDOVA: ${target}: ${message}`);
|
|
189
|
-
});
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
// 결과물 복사
|
|
193
|
-
for (const target of this._config.targets) {
|
|
194
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
195
|
-
if (target === "android") {
|
|
196
|
-
const targetOutPath = path.resolve(outPath, target);
|
|
197
|
-
const apkFileName = this._config.sign !== undefined ? `app-${buildType}.apk` : `app-${buildType}-unsigned.apk`;
|
|
198
|
-
const distApkFileName = path.basename(`${this._config.appName}${this._config.sign !== undefined ? "" : "-unsigned"}-v${this._npmConfig.version}.apk`);
|
|
199
|
-
const latestDistApkFileName = path.basename(`${this._config.appName}${this._config.sign !== undefined ? "" : "-unsigned"}-latest.apk`);
|
|
200
|
-
await FsUtil.mkdirsAsync(targetOutPath);
|
|
201
|
-
await FsUtil.copyAsync(
|
|
202
|
-
path.resolve(this._cordovaPath, "platforms/android/app/build/outputs/apk", buildType, apkFileName),
|
|
203
|
-
path.resolve(targetOutPath, distApkFileName)
|
|
204
|
-
);
|
|
205
|
-
await FsUtil.copyAsync(
|
|
206
|
-
path.resolve(this._cordovaPath, "platforms/android/app/build/outputs/apk", buildType, apkFileName),
|
|
207
|
-
path.resolve(targetOutPath, latestDistApkFileName)
|
|
208
|
-
);
|
|
209
|
-
}
|
|
210
|
-
else {
|
|
211
|
-
throw new NeverEntryError();
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
public static async runWebviewOnDeviceAsync(cordovaPath: string, target: string, url: string): Promise<void> {
|
|
217
|
-
await FsUtil.removeAsync(path.resolve(cordovaPath, "www"));
|
|
218
|
-
await FsUtil.mkdirsAsync(path.resolve(cordovaPath, "www"));
|
|
219
|
-
await FsUtil.writeFileAsync(path.resolve(cordovaPath, "www/index.html"), `'${url}'로 이동중... <script>setTimeout(function () {window.location.href = "${url}"}, 3000);</script>`.trim());
|
|
220
|
-
|
|
221
|
-
// CONFIG
|
|
222
|
-
const configFilePath = path.resolve(cordovaPath, "config.xml");
|
|
223
|
-
let configFileContent = await FsUtil.readFileAsync(configFilePath);
|
|
224
|
-
|
|
225
|
-
// CONFIG: 외부접근 허용 비우기
|
|
226
|
-
configFileContent = configFileContent.replace(/ {4}<allow-navigation href="[^"]*" \/>\n/g, "");
|
|
227
|
-
|
|
228
|
-
// CONFIG: 외부 접근 허용 등록
|
|
229
|
-
configFileContent = configFileContent.replace("</widget>", ` <allow-navigation href="${url}" />\n</widget>`);
|
|
230
|
-
configFileContent = configFileContent.replace("</widget>", ` <allow-navigation href="${url}/*" />\n</widget>`);
|
|
231
|
-
configFileContent = configFileContent.replace("</widget>", ` <allow-navigation href="*://*/*" />\n</widget>`);
|
|
232
|
-
// configFileContent = configFileContent.replace("</widget>", ` <allow-navigation href="*://*/*" />\n</widget>`);
|
|
233
|
-
|
|
234
|
-
// CONFIG: 파일쓰기
|
|
235
|
-
await FsUtil.writeFileAsync(configFilePath, configFileContent);
|
|
236
|
-
|
|
237
|
-
const binPath = path.resolve(process.cwd(), "node_modules/.bin/cordova.cmd");
|
|
238
|
-
await SdProcessManager.spawnAsync(`${binPath} run ${target} --device`, { cwd: cordovaPath });
|
|
239
|
-
}
|
|
240
|
-
}
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { ISdAutoIndexConfig, ISdPackageBuildResult, ITsconfig } from "../commons";
|
|
2
|
-
import * as path from "path";
|
|
3
|
-
import { FsUtil, PathUtil } from "@simplysm/sd-core-node";
|
|
4
|
-
import * as os from "os";
|
|
5
|
-
|
|
6
|
-
export class SdCliIndexFileGenerator {
|
|
7
|
-
public readonly indexFilePath = PathUtil.posix(this.rootPath, "src/index.ts");
|
|
8
|
-
|
|
9
|
-
public constructor(public readonly rootPath: string,
|
|
10
|
-
public readonly config: ISdAutoIndexConfig) {
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
public async generateAsync(): Promise<{ result: ISdPackageBuildResult[]; changed: boolean }> {
|
|
15
|
-
const importTexts: string[] = [];
|
|
16
|
-
|
|
17
|
-
// simplysm.json 에 등록된 polyfills 를 모두 import
|
|
18
|
-
if (this.config.polyfills) {
|
|
19
|
-
for (const polyfill of this.config.polyfills) {
|
|
20
|
-
importTexts.push(`import "${polyfill}";`);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
// 파일들 import
|
|
25
|
-
const filePaths = await this._getFilePathsAsync();
|
|
26
|
-
for (const filePath of filePaths) {
|
|
27
|
-
const requirePath = PathUtil.posix(path.relative(path.dirname(this.indexFilePath), filePath))
|
|
28
|
-
.replace(/\.ts$/, "")
|
|
29
|
-
.replace(/\/index$/, "");
|
|
30
|
-
|
|
31
|
-
const sourceTsFileContent = await FsUtil.readFileAsync(filePath);
|
|
32
|
-
if (sourceTsFileContent.split("\n").some((line) => line.startsWith("export "))) {
|
|
33
|
-
importTexts.push(`export * from "./${requirePath}";`);
|
|
34
|
-
}
|
|
35
|
-
else {
|
|
36
|
-
importTexts.push(`import "./${requirePath}";`);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
let changed = false;
|
|
41
|
-
const content = importTexts.join(os.EOL) + os.EOL;
|
|
42
|
-
const prevContent = FsUtil.exists(this.indexFilePath) ? FsUtil.readFile(this.indexFilePath) : undefined;
|
|
43
|
-
if (content !== prevContent) {
|
|
44
|
-
await FsUtil.writeFileAsync(this.indexFilePath, content);
|
|
45
|
-
changed = true;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
return { result: [], changed };
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
private async _getFilePathsAsync(): Promise<string[]> {
|
|
52
|
-
const tsconfig: ITsconfig = await FsUtil.readJsonAsync(path.resolve(this.rootPath, "tsconfig.json"));
|
|
53
|
-
const entryFilePaths = tsconfig.files?.map((item) => path.resolve(this.rootPath, item)) ?? [];
|
|
54
|
-
|
|
55
|
-
return (await FsUtil.globAsync(path.resolve(this.rootPath, "src/**/*.ts"), { nodir: true }))
|
|
56
|
-
.filter((item) => (
|
|
57
|
-
!entryFilePaths.includes(item)
|
|
58
|
-
&& item !== this.indexFilePath
|
|
59
|
-
));
|
|
60
|
-
}
|
|
61
|
-
}
|