@simplysm/sd-cli 7.0.65 → 7.0.75
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/SdCliBuildResultError.d.ts +5 -0
- package/dist/bin/sd-cli.d.ts +2 -0
- package/dist/bin/sd-cli.mjs +27 -6
- package/dist/build-tool/SdCliCacheCompilerHost.d.ts +10 -0
- package/dist/build-tool/SdCliCordova.d.ts +16 -0
- package/dist/build-tool/SdCliCordova.mjs +176 -0
- package/dist/build-tool/SdCliIndexFileGenerator.d.ts +13 -0
- package/dist/{entry-points → build-tool}/SdCliIndexFileGenerator.mjs +4 -3
- package/dist/build-tool/SdCliNgCacheCompilerHost.d.ts +11 -0
- package/dist/build-tool/SdCliPackageLinter.d.ts +8 -0
- package/dist/build-tool/SdCliPackageLinter.mjs +19 -2
- package/dist/builder/SdCliClientBuilder.d.ts +23 -0
- package/dist/builder/SdCliClientBuilder.mjs +69 -6
- package/dist/builder/SdCliJsLibBuilder.d.ts +14 -0
- package/dist/builder/SdCliServerBuilder.d.ts +25 -0
- package/dist/builder/SdCliServerBuilder.mjs +19 -10
- package/dist/builder/SdCliTsLibBuilder.d.ts +34 -0
- package/dist/builder/SdCliTsLibBuilder.mjs +84 -37
- package/dist/commons.d.ts +101 -0
- package/dist/entry-points/SdCliLocalUpdate.d.ts +13 -0
- package/dist/entry-points/SdCliNpm.d.ts +6 -0
- package/dist/entry-points/SdCliPrepare.d.ts +5 -0
- package/dist/entry-points/SdCliPrepare.mjs +2 -2
- package/dist/entry-points/SdCliWorkspace.d.ts +31 -0
- package/dist/entry-points/SdCliWorkspace.mjs +67 -51
- package/dist/index.d.ts +29 -0
- package/dist/index.mjs +5 -3
- package/dist/ng-tools/SdCliNgModuleGenerator.d.ts +28 -0
- package/dist/ng-tools/SdCliNgModuleGenerator.mjs +486 -0
- package/dist/ng-tools/babel/SdCliBbFileMetadata.d.ts +23 -0
- package/dist/ng-tools/babel/SdCliBbFileMetadata.mjs +187 -36
- package/dist/ng-tools/babel/SdCliBbRootMetadata.d.ts +22 -0
- package/dist/ng-tools/babel/SdCliBbRootMetadata.mjs +10 -7
- package/dist/ng-tools/babel/SdCliBbUtil.d.ts +5 -0
- package/dist/ng-tools/babel/SdCliBbUtil.mjs +2 -2
- package/dist/ng-tools/babel/TSdCliBbNgMetadata.d.ts +42 -0
- package/dist/ng-tools/babel/TSdCliBbNgMetadata.mjs +107 -76
- package/dist/ng-tools/babel/TSdCliBbTypeMetadata.d.ts +44 -0
- package/dist/ng-tools/commons.d.ts +9 -0
- package/dist/ng-tools/typescript/SdCliTsFileMetadata.d.ts +61 -0
- package/dist/ng-tools/typescript/SdCliTsFileMetadata.mjs +12 -12
- package/dist/ng-tools/typescript/SdCliTsRootMetadata.d.ts +8 -0
- package/dist/ng-tools/typescript/SdCliTsUtil.d.ts +5 -0
- package/dist/ng-tools/typescript/SdCliTsUtil.mjs +28 -0
- package/dist/packages/SdCliPackage.d.ts +23 -0
- package/dist/packages/SdCliPackage.mjs +53 -7
- package/dist/utils/SdCliBuildResultUtil.d.ts +9 -0
- package/dist/utils/SdCliConfigUtil.d.ts +7 -0
- package/dist/utils/SdCliNpmConfigUtil.d.ts +7 -0
- package/package.json +11 -8
- package/src/bin/sd-cli.ts +26 -5
- package/src/build-tool/SdCliCordova.ts +224 -0
- package/src/{entry-points → build-tool}/SdCliIndexFileGenerator.ts +3 -2
- package/src/build-tool/SdCliPackageLinter.ts +18 -2
- package/src/builder/SdCliClientBuilder.ts +84 -5
- package/src/builder/SdCliServerBuilder.ts +20 -9
- package/src/builder/SdCliTsLibBuilder.ts +101 -45
- package/src/commons.ts +43 -0
- package/src/entry-points/SdCliPrepare.ts +1 -1
- package/src/entry-points/SdCliWorkspace.ts +71 -56
- package/src/index.ts +4 -2
- package/src/ng-tools/SdCliNgModuleGenerator.ts +643 -0
- package/src/ng-tools/babel/SdCliBbFileMetadata.ts +234 -38
- package/src/ng-tools/babel/SdCliBbRootMetadata.ts +10 -6
- package/src/ng-tools/babel/SdCliBbUtil.ts +1 -1
- package/src/ng-tools/babel/TSdCliBbNgMetadata.ts +36 -22
- package/src/ng-tools/commons.ts +1 -1
- package/src/ng-tools/typescript/SdCliTsFileMetadata.ts +12 -12
- package/src/ng-tools/typescript/SdCliTsUtil.ts +29 -0
- package/src/packages/SdCliPackage.ts +56 -6
- package/tsconfig-build.json +1 -1
- package/tsconfig.json +3 -0
- package/dist/ng-tools/NgModuleGenerator.mjs +0 -278
- package/src/ng-tools/NgModuleGenerator.ts +0 -361
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import path from "path";
|
|
2
|
-
import { FsUtil, SdProcess } from "@simplysm/sd-core-node";
|
|
2
|
+
import { FsUtil, PathUtil, SdProcess } from "@simplysm/sd-core-node";
|
|
3
3
|
import { EventEmitter } from "events";
|
|
4
|
-
import { ObjectUtil } from "@simplysm/sd-core-common";
|
|
4
|
+
import { NeverEntryError, ObjectUtil, StringUtil } from "@simplysm/sd-core-common";
|
|
5
5
|
import { SdCliTsLibBuilder } from "../builder/SdCliTsLibBuilder";
|
|
6
6
|
import { SdCliJsLibBuilder } from "../builder/SdCliJsLibBuilder";
|
|
7
7
|
import { SdCliServerBuilder } from "../builder/SdCliServerBuilder";
|
|
8
8
|
import { SdCliNpmConfigUtil } from "../utils/SdCliNpmConfigUtil";
|
|
9
9
|
import { SdCliClientBuilder } from "../builder/SdCliClientBuilder";
|
|
10
|
+
import { SdStorage } from "@simplysm/sd-storage";
|
|
11
|
+
import ts from "typescript";
|
|
10
12
|
export class SdCliPackage extends EventEmitter {
|
|
11
13
|
constructor(_workspaceRootPath, rootPath, config) {
|
|
12
14
|
super();
|
|
@@ -66,8 +68,53 @@ export class SdCliPackage extends EventEmitter {
|
|
|
66
68
|
return await (await this._createBuilderAsync()).buildAsync();
|
|
67
69
|
}
|
|
68
70
|
async publishAsync() {
|
|
69
|
-
if (this.config.
|
|
70
|
-
|
|
71
|
+
if (this.config.publish !== undefined) {
|
|
72
|
+
if (this.config.type === "library") {
|
|
73
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
74
|
+
if (this.config.publish === "npm") {
|
|
75
|
+
await SdProcess.spawnAsync("npm publish --quiet --access public", { cwd: this.rootPath });
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
throw new NeverEntryError();
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
if (this.config.publish.type === "ftp" || this.config.publish.type === "ftps" || this.config.publish.type === "sftp") {
|
|
83
|
+
const tsconfigPath = path.resolve(this.rootPath, "tsconfig-build.json");
|
|
84
|
+
const tsconfig = FsUtil.readJson(tsconfigPath);
|
|
85
|
+
const parsedTsconfig = ts.parseJsonConfigFileContent(tsconfig, ts.sys, this.rootPath, tsconfig.angularCompilerOptions);
|
|
86
|
+
const ftp = await SdStorage.connectAsync(this.config.publish.type, {
|
|
87
|
+
host: this.config.publish.host,
|
|
88
|
+
port: this.config.publish.port,
|
|
89
|
+
user: this.config.publish.user,
|
|
90
|
+
pass: this.config.publish.pass
|
|
91
|
+
});
|
|
92
|
+
await ftp.uploadDirAsync(parsedTsconfig.options.outDir, this.config.publish.path);
|
|
93
|
+
await ftp.closeAsync();
|
|
94
|
+
}
|
|
95
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
96
|
+
else if (this.config.publish.type === "local-directory") {
|
|
97
|
+
const tsconfigPath = path.resolve(this.rootPath, "tsconfig-build.json");
|
|
98
|
+
const tsconfig = FsUtil.readJson(tsconfigPath);
|
|
99
|
+
const parsedTsconfig = ts.parseJsonConfigFileContent(tsconfig, ts.sys, this.rootPath, tsconfig.angularCompilerOptions);
|
|
100
|
+
const targetRootPath = this.config.publish.path.replace(/%([^%]*)%/g, (item) => {
|
|
101
|
+
const envName = item.replace(/%/g, "");
|
|
102
|
+
if (!StringUtil.isNullOrEmpty(this._npmConfig.version) && envName === "SD_VERSION") {
|
|
103
|
+
return this._npmConfig.version;
|
|
104
|
+
}
|
|
105
|
+
return process.env[envName] ?? item;
|
|
106
|
+
});
|
|
107
|
+
const filePaths = await FsUtil.globAsync(path.resolve(this.rootPath, "**", "*"), {
|
|
108
|
+
dot: true,
|
|
109
|
+
nodir: true
|
|
110
|
+
});
|
|
111
|
+
await filePaths.parallelAsync(async (filePath) => {
|
|
112
|
+
const relativeFilePath = path.relative(parsedTsconfig.options.outDir, filePath);
|
|
113
|
+
const targetPath = PathUtil.posix(targetRootPath, relativeFilePath);
|
|
114
|
+
await FsUtil.copyAsync(filePath, targetPath);
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
}
|
|
71
118
|
}
|
|
72
119
|
}
|
|
73
120
|
async _createBuilderAsync() {
|
|
@@ -76,8 +123,7 @@ export class SdCliPackage extends EventEmitter {
|
|
|
76
123
|
await this._genBuildTsconfigAsync();
|
|
77
124
|
}
|
|
78
125
|
if (this.config.type === "library") {
|
|
79
|
-
|
|
80
|
-
return isTs ? new SdCliTsLibBuilder(this.rootPath) : new SdCliJsLibBuilder(this.rootPath);
|
|
126
|
+
return isTs ? new SdCliTsLibBuilder(this.rootPath, this.config, this._workspaceRootPath) : new SdCliJsLibBuilder(this.rootPath);
|
|
81
127
|
}
|
|
82
128
|
else if (this.config.type === "server") {
|
|
83
129
|
return new SdCliServerBuilder(this.rootPath, this.config, this._workspaceRootPath);
|
|
@@ -98,4 +144,4 @@ export class SdCliPackage extends EventEmitter {
|
|
|
98
144
|
await FsUtil.writeJsonAsync(buildTsconfigFilePath, buildTsconfig, { space: 2 });
|
|
99
145
|
}
|
|
100
146
|
}
|
|
101
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
147
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiU2RDbGlQYWNrYWdlLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3BhY2thZ2VzL1NkQ2xpUGFja2FnZS50cyJdLCJu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1,9 @@
|
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
import { ISdCliPackageBuildResult } from "../commons";
|
|
3
|
+
import webpack from "webpack";
|
|
4
|
+
export declare class SdCliBuildResultUtil {
|
|
5
|
+
static convertFromTsDiag(diag: ts.Diagnostic): ISdCliPackageBuildResult | undefined;
|
|
6
|
+
static convertFromWebpackStats(stats: webpack.Stats): ISdCliPackageBuildResult[];
|
|
7
|
+
private static _convertFromWebpackError;
|
|
8
|
+
static getMessage(result: ISdCliPackageBuildResult): string;
|
|
9
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ISdCliConfig } from "../commons";
|
|
2
|
+
export declare class SdCliConfigUtil {
|
|
3
|
+
static loadConfigAsync(confFilePath: string, isDev: boolean, opts?: string[]): Promise<ISdCliConfig>;
|
|
4
|
+
private static _getConfigFromFileContent;
|
|
5
|
+
private static _getPkgConfigFromFileContent;
|
|
6
|
+
private static _mergeObj;
|
|
7
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@simplysm/sd-cli",
|
|
3
|
-
"version": "7.0.
|
|
3
|
+
"version": "7.0.75",
|
|
4
4
|
"description": "심플리즘 패키지 - CLI",
|
|
5
5
|
"author": "김석래",
|
|
6
6
|
"repository": {
|
|
@@ -12,6 +12,8 @@
|
|
|
12
12
|
"bin": {
|
|
13
13
|
"sd-cli": "./dist/bin/sd-cli.mjs"
|
|
14
14
|
},
|
|
15
|
+
"main": "./dist/index.mjs",
|
|
16
|
+
"types": "./dist/index.d.ts",
|
|
15
17
|
"type": "module",
|
|
16
18
|
"engines": {
|
|
17
19
|
"node": "^16"
|
|
@@ -47,7 +49,14 @@
|
|
|
47
49
|
"chokidar": "^3.5.3",
|
|
48
50
|
"@babel/parser": "^7.17.0",
|
|
49
51
|
"@babel/types": "^7.17.0",
|
|
50
|
-
"jsdom": "^19.0.0"
|
|
52
|
+
"jsdom": "^19.0.0",
|
|
53
|
+
"cordova": "^11.0.0",
|
|
54
|
+
"jszip": "^3.7.1",
|
|
55
|
+
"@simplysm/sd-core-common": "7.0.75",
|
|
56
|
+
"@simplysm/sd-core-node": "7.0.75",
|
|
57
|
+
"@simplysm/sd-service-common": "7.0.75",
|
|
58
|
+
"@simplysm/sd-service-server": "7.0.75",
|
|
59
|
+
"@simplysm/sd-storage": "7.0.75"
|
|
51
60
|
},
|
|
52
61
|
"devDependencies": {
|
|
53
62
|
"@types/semver": "^7.3.9",
|
|
@@ -56,11 +65,5 @@
|
|
|
56
65
|
"@types/connect": "^3.4.35",
|
|
57
66
|
"@types/source-map-support": "^0.5.4",
|
|
58
67
|
"@types/jsdom": "^16.2.14"
|
|
59
|
-
},
|
|
60
|
-
"peerDependencies": {
|
|
61
|
-
"@simplysm/sd-core-common": "7.0.65",
|
|
62
|
-
"@simplysm/sd-core-node": "7.0.65",
|
|
63
|
-
"@simplysm/sd-service-common": "7.0.65",
|
|
64
|
-
"@simplysm/sd-service-server": "7.0.65"
|
|
65
68
|
}
|
|
66
69
|
}
|
package/src/bin/sd-cli.ts
CHANGED
|
@@ -5,11 +5,11 @@ import { hideBin } from "yargs/helpers";
|
|
|
5
5
|
import { Logger, LoggerSeverity } from "@simplysm/sd-core-node";
|
|
6
6
|
import { SdCliWorkspace } from "../entry-points/SdCliWorkspace";
|
|
7
7
|
import { SdCliLocalUpdate } from "../entry-points/SdCliLocalUpdate";
|
|
8
|
-
import sourceMapSupport from "source-map-support";
|
|
8
|
+
// import sourceMapSupport from "source-map-support";
|
|
9
9
|
import { SdCliNpm } from "../entry-points/SdCliNpm";
|
|
10
10
|
import { SdCliPrepare } from "../entry-points/SdCliPrepare";
|
|
11
11
|
|
|
12
|
-
sourceMapSupport.install();
|
|
12
|
+
// sourceMapSupport.install();
|
|
13
13
|
|
|
14
14
|
Error.stackTraceLimit = Infinity;
|
|
15
15
|
|
|
@@ -58,6 +58,11 @@ const argv = yargs(hideBin(process.argv))
|
|
|
58
58
|
type: "string",
|
|
59
59
|
array: true,
|
|
60
60
|
describe: "옵션 설정 (설정파일에서 @로 시작하는 부분)"
|
|
61
|
+
},
|
|
62
|
+
packages: {
|
|
63
|
+
type: "string",
|
|
64
|
+
array: true,
|
|
65
|
+
describe: "수행할 패키지 설정"
|
|
61
66
|
}
|
|
62
67
|
})
|
|
63
68
|
)
|
|
@@ -74,6 +79,11 @@ const argv = yargs(hideBin(process.argv))
|
|
|
74
79
|
type: "string",
|
|
75
80
|
array: true,
|
|
76
81
|
describe: "옵션 설정 (설정파일에서 @로 시작하는 부분)"
|
|
82
|
+
},
|
|
83
|
+
packages: {
|
|
84
|
+
type: "string",
|
|
85
|
+
array: true,
|
|
86
|
+
describe: "수행할 패키지 설정"
|
|
77
87
|
}
|
|
78
88
|
})
|
|
79
89
|
)
|
|
@@ -95,6 +105,11 @@ const argv = yargs(hideBin(process.argv))
|
|
|
95
105
|
type: "string",
|
|
96
106
|
array: true,
|
|
97
107
|
describe: "옵션 설정 (설정파일에서 @로 시작하는 부분)"
|
|
108
|
+
},
|
|
109
|
+
packages: {
|
|
110
|
+
type: "string",
|
|
111
|
+
array: true,
|
|
112
|
+
describe: "수행할 패키지 설정"
|
|
98
113
|
}
|
|
99
114
|
})
|
|
100
115
|
)
|
|
@@ -136,14 +151,16 @@ const logger = Logger.get(["simplysm", "sd-cli", "bin", "sd-cli"]);
|
|
|
136
151
|
await new SdCliWorkspace(process.cwd())
|
|
137
152
|
.watchAsync({
|
|
138
153
|
confFileRelPath: argv.config ?? "simplysm.json",
|
|
139
|
-
optNames: argv.options ?? []
|
|
154
|
+
optNames: argv.options ?? [],
|
|
155
|
+
pkgs: argv.packages ?? []
|
|
140
156
|
});
|
|
141
157
|
}
|
|
142
158
|
else if (argv._[0] === "build") {
|
|
143
159
|
await new SdCliWorkspace(process.cwd())
|
|
144
160
|
.buildAsync({
|
|
145
161
|
confFileRelPath: argv.config ?? "simplysm.json",
|
|
146
|
-
optNames: argv.options ?? []
|
|
162
|
+
optNames: argv.options ?? [],
|
|
163
|
+
pkgs: argv.packages ?? []
|
|
147
164
|
});
|
|
148
165
|
process.exit(0);
|
|
149
166
|
}
|
|
@@ -152,8 +169,12 @@ const logger = Logger.get(["simplysm", "sd-cli", "bin", "sd-cli"]);
|
|
|
152
169
|
.publishAsync({
|
|
153
170
|
noBuild: argv.noBuild,
|
|
154
171
|
confFileRelPath: argv.config ?? "simplysm.json",
|
|
155
|
-
optNames: argv.options ?? []
|
|
172
|
+
optNames: argv.options ?? [],
|
|
173
|
+
pkgs: argv.packages ?? []
|
|
156
174
|
});
|
|
175
|
+
if (!argv.noBuild) {
|
|
176
|
+
process.exit(0);
|
|
177
|
+
}
|
|
157
178
|
}
|
|
158
179
|
else {
|
|
159
180
|
throw new Error(`명령어가 잘못 되었습니다.\n\t${argv._[0]}\n`);
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
import { INpmConfig, ISdCliClientPackageCordovaConfig, TSdCliCordovaPlatform } from "../commons";
|
|
2
|
+
import * as path from "path";
|
|
3
|
+
import { FsUtil, Logger, SdProcess } from "@simplysm/sd-core-node";
|
|
4
|
+
import { NotImplementError } from "@simplysm/sd-core-common";
|
|
5
|
+
import JSZip from "jszip";
|
|
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(): TSdCliCordovaPlatform[] {
|
|
16
|
+
return this._config.platforms;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
public constructor(private readonly _rootPath: string, private readonly _config: ISdCliClientPackageCordovaConfig) {
|
|
20
|
+
this._npmConfig = FsUtil.readJson(path.resolve(this._rootPath, "package.json"));
|
|
21
|
+
this._logger = Logger.get(["simplysm", "sd-cli", this.constructor.name, this._npmConfig.name]);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
private async _execAsync(cmd: string, cwd: string): Promise<void> {
|
|
25
|
+
this._logger.debug(cmd);
|
|
26
|
+
const msg = await SdProcess.spawnAsync(cmd, { cwd });
|
|
27
|
+
this._logger.debug(msg);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
public async initializeAsync(): Promise<void> {
|
|
31
|
+
if (FsUtil.exists(this.cordovaPath)) {
|
|
32
|
+
this._logger.log("이미 생성되어있는 '.cordova'를 사용합니다.");
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
await this._execAsync(`${this._binPath} telemetry on`, this._rootPath);
|
|
36
|
+
|
|
37
|
+
// 프로젝트 생성
|
|
38
|
+
await this._execAsync(`${this._binPath} create "${this.cordovaPath}" "${this._config.appId}" "${this._config.appName}"`, process.cwd());
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// platforms 폴더 혹시 없으면 생성
|
|
42
|
+
await FsUtil.mkdirsAsync(path.resolve(this.cordovaPath, "platforms"));
|
|
43
|
+
|
|
44
|
+
// www 폴더 혹시 없으면 생성
|
|
45
|
+
await FsUtil.mkdirsAsync(path.resolve(this.cordovaPath, "www"));
|
|
46
|
+
|
|
47
|
+
// 미설치 빌드 플랫폼 신규 생성
|
|
48
|
+
const alreadyPlatforms = await FsUtil.readdirAsync(path.resolve(this.cordovaPath, "platforms"));
|
|
49
|
+
for (const platform of this.platforms) {
|
|
50
|
+
if (!alreadyPlatforms.includes(platform)) {
|
|
51
|
+
await this._execAsync(`${this._binPath} platform add ${platform}`, this.cordovaPath);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// 미설치 플러그인들 설치
|
|
56
|
+
if (this._config.plugins) {
|
|
57
|
+
const pluginsFetch = FsUtil.exists(path.resolve(this.cordovaPath, "plugins/fetch.json"))
|
|
58
|
+
? await FsUtil.readJsonAsync(path.resolve(this.cordovaPath, "plugins/fetch.json"))
|
|
59
|
+
: undefined;
|
|
60
|
+
const alreadyPlugins = pluginsFetch != undefined
|
|
61
|
+
? Object.values(pluginsFetch)
|
|
62
|
+
.map((item: any) => (item.source.id !== undefined ? item.source.id.replace(/@.*$/, "") : item.source.url))
|
|
63
|
+
: [];
|
|
64
|
+
|
|
65
|
+
for (const plugin of this._config.plugins.distinct()) {
|
|
66
|
+
if (!alreadyPlugins.includes(plugin)) {
|
|
67
|
+
await this._execAsync(`${this._binPath} plugin add ${plugin}`, this.cordovaPath);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// ICON 파일 복사
|
|
73
|
+
if (this._config.icon !== undefined) {
|
|
74
|
+
await FsUtil.copyAsync(path.resolve(this._rootPath, this._config.icon), path.resolve(this.cordovaPath, "res", "icon", "icon.png"));
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// ANDROID GRADLE 오류 강제 수정
|
|
78
|
+
// if (this._config.targets.includes("android")) {
|
|
79
|
+
// const gradleFilePath = path.resolve(this._cordovaPath, "platforms/android/app/build.gradle");
|
|
80
|
+
// let gradleFileContent = await FsUtil.readFileAsync(gradleFilePath);
|
|
81
|
+
// gradleFileContent = gradleFileContent.replace(/lintOptions {/g, "lintOptions {\r\n checkReleaseBuilds false;");
|
|
82
|
+
// await FsUtil.writeFileAsync(gradleFilePath, gradleFileContent);
|
|
83
|
+
// }
|
|
84
|
+
|
|
85
|
+
// CONFIG
|
|
86
|
+
const configFilePath = path.resolve(this.cordovaPath, "config.xml");
|
|
87
|
+
let configFileContent = await FsUtil.readFileAsync(configFilePath);
|
|
88
|
+
|
|
89
|
+
// CONFIG: 버전 설정
|
|
90
|
+
configFileContent = configFileContent.replace(/version="[^"]*"/g, `version="${this._npmConfig.version}"`);
|
|
91
|
+
|
|
92
|
+
// CONFIG: ICON 설정
|
|
93
|
+
if (this._config.icon !== undefined && !configFileContent.includes("<icon")) {
|
|
94
|
+
configFileContent = configFileContent.replace("</widget>", " <icon src=\"res/icon/icon.png\" />\r\n</widget>");
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// CONFIG: ANDROID usesCleartextTraffic 설정
|
|
98
|
+
// if (this._config.targets.includes("android")) {
|
|
99
|
+
// if (!configFileContent.includes("xmlns:android=\"http://schemas.android.com/apk/res/android\"")) {
|
|
100
|
+
// configFileContent = configFileContent.replace(
|
|
101
|
+
// "xmlns=\"http://www.w3.org/ns/widgets\"",
|
|
102
|
+
// `xmlns="http://www.w3.org/ns/widgets" xmlns:android="http://schemas.android.com/apk/res/android"`
|
|
103
|
+
// );
|
|
104
|
+
// }
|
|
105
|
+
// if (!configFileContent.includes("application android:usesCleartextTraffic=\"true\" />")) {
|
|
106
|
+
// configFileContent = configFileContent.replace("<platform name=\"android\">", `<platform name="android">
|
|
107
|
+
// <edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application">
|
|
108
|
+
// <application android:usesCleartextTraffic="true" />
|
|
109
|
+
// </edit-config>`);
|
|
110
|
+
// }
|
|
111
|
+
// }
|
|
112
|
+
|
|
113
|
+
// CONFIG: 파일쓰기
|
|
114
|
+
await FsUtil.writeFileAsync(configFilePath, configFileContent);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
public async buildAsync(outPath: string): Promise<void> {
|
|
118
|
+
// ANDROID 서명 처리
|
|
119
|
+
if (this._config.buildOption?.sign?.android) {
|
|
120
|
+
await FsUtil.copyAsync(
|
|
121
|
+
path.resolve(this._rootPath, this._config.buildOption.sign.android.keystore),
|
|
122
|
+
path.resolve(this.cordovaPath, path.basename(this._config.buildOption.sign.android.keystore))
|
|
123
|
+
);
|
|
124
|
+
await FsUtil.writeJsonAsync(
|
|
125
|
+
path.resolve(this.cordovaPath, "build.json"),
|
|
126
|
+
{
|
|
127
|
+
android: {
|
|
128
|
+
release: {
|
|
129
|
+
keystore: path.basename(this._config.buildOption.sign.android.keystore),
|
|
130
|
+
storePassword: this._config.buildOption.sign.android.storePassword,
|
|
131
|
+
alias: this._config.buildOption.sign.android.alias,
|
|
132
|
+
password: this._config.buildOption.sign.android.password,
|
|
133
|
+
keystoreType: this._config.buildOption.sign.android.keystoreType
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// CONFIG
|
|
141
|
+
const configFilePath = path.resolve(this.cordovaPath, "config.xml");
|
|
142
|
+
let configFileContent = await FsUtil.readFileAsync(configFilePath);
|
|
143
|
+
|
|
144
|
+
// CONFIG: 접근허용 일단 모두 지우기
|
|
145
|
+
configFileContent = configFileContent.replace(/ {4}<allow-navigation href="[^"]*" \/>\n/g, "");
|
|
146
|
+
|
|
147
|
+
// CONFIG: 접근허용 등록
|
|
148
|
+
// configFileContent = configFileContent.replace("</widget>", ` <allow-navigation href="file://data/user/*" />\n</widget>`);
|
|
149
|
+
configFileContent = configFileContent.replace("</widget>", ` <allow-navigation href="*://*/*" />\n</widget>`);
|
|
150
|
+
|
|
151
|
+
// CONFIG: 파일쓰기
|
|
152
|
+
await FsUtil.writeFileAsync(configFilePath, configFileContent);
|
|
153
|
+
|
|
154
|
+
// 실행
|
|
155
|
+
const buildType = this._config.buildOption?.debug ? "debug" : "release";
|
|
156
|
+
const packageType = this._config.buildOption?.bundle ? "bundle" : "apk";
|
|
157
|
+
for (const platform of this.platforms) {
|
|
158
|
+
await this._execAsync(`${this._binPath} build ${platform} --${buildType} --packageType=${packageType}`, this.cordovaPath);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
// 결과물 복사
|
|
162
|
+
for (const platform of this.platforms) {
|
|
163
|
+
if (platform === "android") {
|
|
164
|
+
const targetOutPath = path.resolve(outPath, platform);
|
|
165
|
+
const apkFileName = this._config.buildOption?.sign?.android ? `app-${buildType}.apk` : `app-${buildType}-unsigned.apk`;
|
|
166
|
+
const distApkFileName = path.basename(`${this._config.appName}${this._config.buildOption?.sign?.android ? "" : "-unsigned"}-v${this._npmConfig.version}.apk`);
|
|
167
|
+
const latestDistApkFileName = path.basename(`${this._config.appName}${this._config.buildOption?.sign?.android ? "" : "-unsigned"}-latest.apk`);
|
|
168
|
+
await FsUtil.mkdirsAsync(targetOutPath);
|
|
169
|
+
await FsUtil.copyAsync(
|
|
170
|
+
path.resolve(this.cordovaPath, "platforms/android/app/build/outputs/apk", buildType, apkFileName),
|
|
171
|
+
path.resolve(targetOutPath, distApkFileName)
|
|
172
|
+
);
|
|
173
|
+
await FsUtil.copyAsync(
|
|
174
|
+
path.resolve(this.cordovaPath, "platforms/android/app/build/outputs/apk", buildType, apkFileName),
|
|
175
|
+
path.resolve(targetOutPath, latestDistApkFileName)
|
|
176
|
+
);
|
|
177
|
+
}
|
|
178
|
+
else {
|
|
179
|
+
throw new NotImplementError();
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
// 자동업데이트를 위한 zip 파일 쓰기
|
|
184
|
+
const zip = new JSZip();
|
|
185
|
+
const resultFiles = await FsUtil.globAsync(path.resolve(this.cordovaPath, "www", "**/*"), {
|
|
186
|
+
dot: true,
|
|
187
|
+
nodir: true
|
|
188
|
+
});
|
|
189
|
+
for (const resultFile of resultFiles) {
|
|
190
|
+
const contentBuffer = await FsUtil.readFileBufferAsync(resultFile);
|
|
191
|
+
const relativePath = path.relative(path.resolve(this.cordovaPath, "www"), resultFile);
|
|
192
|
+
zip.file("/" + relativePath, contentBuffer);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
const zipFileName = path.basename(`${this._config.appName}-v${this._npmConfig.version}.zip`);
|
|
196
|
+
const resultBuffer = await zip.generateAsync({ type: "nodebuffer" });
|
|
197
|
+
|
|
198
|
+
await FsUtil.writeFileAsync(path.resolve(outPath, "updates/", zipFileName), resultBuffer);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
public static async runWebviewOnDeviceAsync(cordovaPath: string, platform: TSdCliCordovaPlatform, url: string): Promise<void> {
|
|
202
|
+
await FsUtil.removeAsync(path.resolve(cordovaPath, "www"));
|
|
203
|
+
await FsUtil.mkdirsAsync(path.resolve(cordovaPath, "www"));
|
|
204
|
+
await FsUtil.writeFileAsync(path.resolve(cordovaPath, "www/index.html"), `'${url}'로 이동중... <script>setTimeout(function () {window.location.href = "${url}"}, 3000);</script>`.trim());
|
|
205
|
+
|
|
206
|
+
// CONFIG
|
|
207
|
+
const configFilePath = path.resolve(cordovaPath, "config.xml");
|
|
208
|
+
let configFileContent = await FsUtil.readFileAsync(configFilePath);
|
|
209
|
+
|
|
210
|
+
// CONFIG: 접근허용 일단 모두 지우기
|
|
211
|
+
configFileContent = configFileContent.replace(/ {4}<allow-navigation href="[^"]*" \/>\n/g, "");
|
|
212
|
+
|
|
213
|
+
// CONFIG: 접근허용 등록
|
|
214
|
+
// configFileContent = configFileContent.replace("</widget>", ` <allow-navigation href="${url}" />\n</widget>`);
|
|
215
|
+
// configFileContent = configFileContent.replace("</widget>", ` <allow-navigation href="${url}/*" />\n</widget>`);
|
|
216
|
+
configFileContent = configFileContent.replace("</widget>", ` <allow-navigation href="*://*/*" />\n</widget>`);
|
|
217
|
+
|
|
218
|
+
// CONFIG: 파일쓰기
|
|
219
|
+
await FsUtil.writeFileAsync(configFilePath, configFileContent);
|
|
220
|
+
|
|
221
|
+
const binPath = path.resolve(process.cwd(), "node_modules/.bin/cordova.cmd");
|
|
222
|
+
await SdProcess.spawnAsync(`${binPath} run ${platform} --device`, { cwd: cordovaPath });
|
|
223
|
+
}
|
|
224
|
+
}
|
|
@@ -10,6 +10,7 @@ export class SdCliIndexFileGenerator {
|
|
|
10
10
|
|
|
11
11
|
public constructor(public readonly rootPath: string,
|
|
12
12
|
public readonly config: ISdAutoIndexConfig) {
|
|
13
|
+
this._contentCache = FsUtil.exists(this._indexFilePath) ? FsUtil.readFile(this._indexFilePath) : undefined;
|
|
13
14
|
}
|
|
14
15
|
|
|
15
16
|
public async watchAsync(): Promise<void> {
|
|
@@ -55,9 +56,9 @@ export class SdCliIndexFileGenerator {
|
|
|
55
56
|
}
|
|
56
57
|
|
|
57
58
|
const content = importTexts.join(os.EOL) + os.EOL;
|
|
58
|
-
const prevContent = this._contentCache
|
|
59
|
+
const prevContent = this._contentCache;
|
|
59
60
|
this._contentCache = content;
|
|
60
|
-
if (content !== prevContent) {
|
|
61
|
+
if (content.trim() !== prevContent?.trim()) {
|
|
61
62
|
await FsUtil.writeFileAsync(this._indexFilePath, content);
|
|
62
63
|
}
|
|
63
64
|
}
|
|
@@ -16,7 +16,24 @@ export class SdCliPackageLinter {
|
|
|
16
16
|
const linter = new ESLint(
|
|
17
17
|
program && filePaths.some((item) => item.endsWith(".ts")) ? {
|
|
18
18
|
overrideConfig: {
|
|
19
|
-
|
|
19
|
+
overrides: [
|
|
20
|
+
{
|
|
21
|
+
files: ["*.ts"],
|
|
22
|
+
parserOptions: {
|
|
23
|
+
programs: [program],
|
|
24
|
+
tsconfigRootDir: null,
|
|
25
|
+
project: null
|
|
26
|
+
},
|
|
27
|
+
settings: {
|
|
28
|
+
"import/resolver": {
|
|
29
|
+
"typescript": {
|
|
30
|
+
programs: [program],
|
|
31
|
+
project: null
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
]
|
|
20
37
|
}
|
|
21
38
|
} : {}
|
|
22
39
|
);
|
|
@@ -32,7 +49,6 @@ export class SdCliPackageLinter {
|
|
|
32
49
|
|
|
33
50
|
const lintResults = await linter.lintFiles(lintFilePaths);
|
|
34
51
|
|
|
35
|
-
|
|
36
52
|
const result = lintResults.map((lintResult) => ({
|
|
37
53
|
filePath: lintResult.filePath,
|
|
38
54
|
results: lintResult.messages.map((msg) => ({
|