@simplysm/sd-cli 7.3.2 → 10.0.4
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 +18 -0
- package/dist/build-cluster.js +75 -0
- package/dist/build-cluster.js.map +1 -0
- package/dist/builders/SdCliJsLibLinter.d.ts +18 -0
- package/dist/builders/SdCliJsLibLinter.js +69 -0
- package/dist/builders/SdCliJsLibLinter.js.map +1 -0
- package/dist/builders/SdCliTsLibBuilder.d.ts +20 -0
- package/dist/builders/SdCliTsLibBuilder.js +205 -0
- package/dist/builders/SdCliTsLibBuilder.js.map +1 -0
- package/dist/commons.d.ts +3 -117
- package/dist/commons.js +2 -0
- package/dist/commons.js.map +1 -0
- package/dist/entry/SdCliProject.d.ts +28 -0
- package/dist/entry/SdCliProject.js +269 -0
- package/dist/entry/SdCliProject.js.map +1 -0
- package/dist/sd-cli.js +118 -0
- package/dist/sd-cli.js.map +1 -0
- package/dist/utils/SdCliBuildResultUtil.d.ts +1 -4
- package/dist/utils/SdCliBuildResultUtil.js +37 -0
- package/dist/utils/SdCliBuildResultUtil.js.map +1 -0
- package/dist/utils/SdCliConfigUtil.js +69 -0
- package/dist/utils/SdCliConfigUtil.js.map +1 -0
- package/package.json +10 -59
- package/src/build-cluster.ts +82 -0
- package/src/builders/SdCliJsLibLinter.ts +84 -0
- package/src/builders/SdCliTsLibBuilder.ts +265 -0
- package/src/commons.ts +3 -123
- package/src/entry/SdCliProject.ts +351 -0
- package/src/sd-cli.ts +135 -0
- package/src/utils/SdCliBuildResultUtil.ts +5 -38
- package/tsconfig.json +18 -0
- package/README.md +0 -105
- package/assets/client-files/assets/icons/icon-128x128.png +0 -0
- package/assets/client-files/assets/icons/icon-144x144.png +0 -0
- package/assets/client-files/assets/icons/icon-152x152.png +0 -0
- package/assets/client-files/assets/icons/icon-192x192.png +0 -0
- package/assets/client-files/assets/icons/icon-384x384.png +0 -0
- package/assets/client-files/assets/icons/icon-512x512.png +0 -0
- package/assets/client-files/assets/icons/icon-72x72.png +0 -0
- package/assets/client-files/assets/icons/icon-96x96.png +0 -0
- package/assets/client-files/favicon.ico +0 -0
- package/dist/SdCliBuildResultError.d.ts +0 -5
- package/dist/SdCliBuildResultError.mjs +0 -8
- package/dist/bin/sd-cli.d.ts +0 -2
- package/dist/bin/sd-cli.mjs +0 -410
- package/dist/build-tool/SdCliCacheCompilerHost.d.ts +0 -10
- package/dist/build-tool/SdCliCacheCompilerHost.mjs +0 -51
- package/dist/build-tool/SdCliCordova.d.ts +0 -16
- package/dist/build-tool/SdCliCordova.mjs +0 -212
- package/dist/build-tool/SdCliElectron.d.ts +0 -9
- package/dist/build-tool/SdCliElectron.mjs +0 -71
- package/dist/build-tool/SdCliGithubApi.d.ts +0 -13
- package/dist/build-tool/SdCliGithubApi.mjs +0 -92
- package/dist/build-tool/SdCliIndexFileGenerator.d.ts +0 -13
- package/dist/build-tool/SdCliIndexFileGenerator.mjs +0 -62
- package/dist/build-tool/SdCliNgCacheCompilerHost.d.ts +0 -12
- package/dist/build-tool/SdCliNgCacheCompilerHost.mjs +0 -43
- package/dist/build-tool/SdCliPackageLinter.d.ts +0 -8
- package/dist/build-tool/SdCliPackageLinter.mjs +0 -62
- package/dist/builder/SdCliClientBuilder.d.ts +0 -26
- package/dist/builder/SdCliClientBuilder.mjs +0 -761
- package/dist/builder/SdCliJsLibBuilder.d.ts +0 -14
- package/dist/builder/SdCliJsLibBuilder.mjs +0 -54
- package/dist/builder/SdCliServerBuilder.d.ts +0 -28
- package/dist/builder/SdCliServerBuilder.mjs +0 -482
- package/dist/builder/SdCliTsLibBuilder.d.ts +0 -35
- package/dist/builder/SdCliTsLibBuilder.mjs +0 -317
- package/dist/commons.mjs +0 -2
- package/dist/entry-points/SdCliFileCrypto.d.ts +0 -7
- package/dist/entry-points/SdCliFileCrypto.mjs +0 -72
- package/dist/entry-points/SdCliLocalUpdate.d.ts +0 -13
- package/dist/entry-points/SdCliLocalUpdate.mjs +0 -100
- package/dist/entry-points/SdCliPrepare.d.ts +0 -5
- package/dist/entry-points/SdCliPrepare.mjs +0 -86
- package/dist/entry-points/SdCliProject.d.ts +0 -34
- package/dist/entry-points/SdCliProject.mjs +0 -416
- package/dist/entry-points/SdCliProjectGenerator.d.ts +0 -44
- package/dist/entry-points/SdCliProjectGenerator.mjs +0 -326
- package/dist/entry-points/file/base/fc_package_eslintrc.d.ts +0 -3
- package/dist/entry-points/file/base/fc_package_eslintrc.mjs +0 -31
- package/dist/entry-points/file/base/fc_package_npmconfig.d.ts +0 -9
- package/dist/entry-points/file/base/fc_package_npmconfig.mjs +0 -32
- package/dist/entry-points/file/base/fc_package_tsconfig.d.ts +0 -5
- package/dist/entry-points/file/base/fc_package_tsconfig.mjs +0 -13
- package/dist/entry-points/file/client/fc_package_AppModule.d.ts +0 -1
- package/dist/entry-points/file/client/fc_package_AppModule.mjs +0 -37
- package/dist/entry-points/file/client/fc_package_AppPage.d.ts +0 -1
- package/dist/entry-points/file/client/fc_package_AppPage.mjs +0 -14
- package/dist/entry-points/file/client/fc_package_Page.d.ts +0 -4
- package/dist/entry-points/file/client/fc_package_Page.mjs +0 -19
- package/dist/entry-points/file/client/fc_package_client_main.d.ts +0 -1
- package/dist/entry-points/file/client/fc_package_client_main.mjs +0 -19
- package/dist/entry-points/file/client/fc_package_index.d.ts +0 -3
- package/dist/entry-points/file/client/fc_package_index.mjs +0 -88
- package/dist/entry-points/file/client/fc_package_manifest.d.ts +0 -5
- package/dist/entry-points/file/client/fc_package_manifest.mjs +0 -54
- package/dist/entry-points/file/client/fc_package_polyfills.d.ts +0 -1
- package/dist/entry-points/file/client/fc_package_polyfills.mjs +0 -11
- package/dist/entry-points/file/client/fc_package_styles.d.ts +0 -1
- package/dist/entry-points/file/client/fc_package_styles.mjs +0 -7
- package/dist/entry-points/file/db/fc_package_DbContext.d.ts +0 -3
- package/dist/entry-points/file/db/fc_package_DbContext.mjs +0 -14
- package/dist/entry-points/file/db/fc_package_DbModel.d.ts +0 -4
- package/dist/entry-points/file/db/fc_package_DbModel.mjs +0 -12
- package/dist/entry-points/file/project/fc_project_editor_config.d.ts +0 -1
- package/dist/entry-points/file/project/fc_project_editor_config.mjs +0 -22
- package/dist/entry-points/file/project/fc_project_eslintrc.d.ts +0 -1
- package/dist/entry-points/file/project/fc_project_eslintrc.mjs +0 -30
- package/dist/entry-points/file/project/fc_project_gitattributes.d.ts +0 -1
- package/dist/entry-points/file/project/fc_project_gitattributes.mjs +0 -6
- package/dist/entry-points/file/project/fc_project_gitignore.d.ts +0 -1
- package/dist/entry-points/file/project/fc_project_gitignore.mjs +0 -27
- package/dist/entry-points/file/project/fc_project_npmconfig.d.ts +0 -7
- package/dist/entry-points/file/project/fc_project_npmconfig.mjs +0 -37
- package/dist/entry-points/file/project/fc_project_readme.d.ts +0 -3
- package/dist/entry-points/file/project/fc_project_readme.mjs +0 -13
- package/dist/entry-points/file/project/fc_project_simplysm.d.ts +0 -1
- package/dist/entry-points/file/project/fc_project_simplysm.mjs +0 -2
- package/dist/entry-points/file/project/fc_project_tsconfig.d.ts +0 -1
- package/dist/entry-points/file/project/fc_project_tsconfig.mjs +0 -25
- package/dist/entry-points/file/server/fc_package_server_main.d.ts +0 -5
- package/dist/entry-points/file/server/fc_package_server_main.mjs +0 -60
- package/dist/index.d.ts +0 -54
- package/dist/index.mjs +0 -55
- package/dist/ng-tools/SdCliNgModuleGenerator.d.ts +0 -29
- package/dist/ng-tools/SdCliNgModuleGenerator.mjs +0 -502
- package/dist/ng-tools/babel/SdCliBbFileMetadata.d.ts +0 -25
- package/dist/ng-tools/babel/SdCliBbFileMetadata.mjs +0 -539
- package/dist/ng-tools/babel/SdCliBbRootMetadata.d.ts +0 -23
- package/dist/ng-tools/babel/SdCliBbRootMetadata.mjs +0 -247
- package/dist/ng-tools/babel/SdCliBbUtil.d.ts +0 -5
- package/dist/ng-tools/babel/SdCliBbUtil.mjs +0 -14
- package/dist/ng-tools/babel/TSdCliBbNgMetadata.d.ts +0 -42
- package/dist/ng-tools/babel/TSdCliBbNgMetadata.mjs +0 -216
- package/dist/ng-tools/babel/TSdCliBbTypeMetadata.d.ts +0 -55
- package/dist/ng-tools/babel/TSdCliBbTypeMetadata.mjs +0 -151
- package/dist/ng-tools/commons.d.ts +0 -9
- package/dist/ng-tools/commons.mjs +0 -2
- package/dist/ng-tools/typescript/SdCliTsFileMetadata.d.ts +0 -61
- package/dist/ng-tools/typescript/SdCliTsFileMetadata.mjs +0 -325
- package/dist/ng-tools/typescript/SdCliTsRootMetadata.d.ts +0 -8
- package/dist/ng-tools/typescript/SdCliTsRootMetadata.mjs +0 -28
- package/dist/ng-tools/typescript/SdCliTsUtil.d.ts +0 -5
- package/dist/ng-tools/typescript/SdCliTsUtil.mjs +0 -28
- package/dist/packages/SdCliPackage.d.ts +0 -22
- package/dist/packages/SdCliPackage.mjs +0 -206
- package/dist/utils/SdCliBuildResultUtil.mjs +0 -63
- package/dist/utils/SdCliConfigUtil.mjs +0 -69
- package/dist/utils/SdCliNpmConfigUtil.d.ts +0 -7
- package/dist/utils/SdCliNpmConfigUtil.mjs +0 -15
- package/dist/worker/build-worker.mjs +0 -67
- package/dist/worker/server-worker.mjs +0 -67
- package/docs/client-add-page.md +0 -8
- package/docs/client-router.md +0 -85
- package/docs/client-sw.md +0 -101
- package/docs/conf-orm.md +0 -81
- package/docs/conf-usage.md +0 -5
- package/docs/lib-local-update.md +0 -50
- package/docs/lib-ts-paths.md +0 -25
- package/lib/cordova-entry.js +0 -22
- package/src/SdCliBuildResultError.ts +0 -9
- package/src/bin/sd-cli.ts +0 -493
- package/src/build-tool/SdCliCacheCompilerHost.ts +0 -79
- package/src/build-tool/SdCliCordova.ts +0 -263
- package/src/build-tool/SdCliElectron.ts +0 -84
- package/src/build-tool/SdCliGithubApi.ts +0 -111
- package/src/build-tool/SdCliIndexFileGenerator.ts +0 -79
- package/src/build-tool/SdCliNgCacheCompilerHost.ts +0 -58
- package/src/build-tool/SdCliPackageLinter.ts +0 -74
- package/src/builder/SdCliClientBuilder.ts +0 -871
- package/src/builder/SdCliJsLibBuilder.ts +0 -70
- package/src/builder/SdCliServerBuilder.ts +0 -552
- package/src/builder/SdCliTsLibBuilder.ts +0 -450
- package/src/entry-points/SdCliFileCrypto.ts +0 -87
- package/src/entry-points/SdCliLocalUpdate.ts +0 -121
- package/src/entry-points/SdCliPrepare.ts +0 -86
- package/src/entry-points/SdCliProject.ts +0 -491
- package/src/entry-points/SdCliProjectGenerator.ts +0 -402
- package/src/entry-points/file/base/fc_package_eslintrc.ts +0 -30
- package/src/entry-points/file/base/fc_package_npmconfig.ts +0 -43
- package/src/entry-points/file/base/fc_package_tsconfig.ts +0 -12
- package/src/entry-points/file/client/fc_package_AppModule.ts +0 -36
- package/src/entry-points/file/client/fc_package_AppPage.ts +0 -13
- package/src/entry-points/file/client/fc_package_Page.ts +0 -19
- package/src/entry-points/file/client/fc_package_client_main.ts +0 -18
- package/src/entry-points/file/client/fc_package_index.ts +0 -87
- package/src/entry-points/file/client/fc_package_manifest.ts +0 -53
- package/src/entry-points/file/client/fc_package_polyfills.ts +0 -10
- package/src/entry-points/file/client/fc_package_styles.ts +0 -6
- package/src/entry-points/file/db/fc_package_DbContext.ts +0 -14
- package/src/entry-points/file/db/fc_package_DbModel.ts +0 -11
- package/src/entry-points/file/project/fc_project_editor_config.ts +0 -21
- package/src/entry-points/file/project/fc_project_eslintrc.ts +0 -29
- package/src/entry-points/file/project/fc_project_gitattributes.ts +0 -5
- package/src/entry-points/file/project/fc_project_gitignore.ts +0 -26
- package/src/entry-points/file/project/fc_project_npmconfig.ts +0 -36
- package/src/entry-points/file/project/fc_project_readme.ts +0 -12
- package/src/entry-points/file/project/fc_project_simplysm.ts +0 -1
- package/src/entry-points/file/project/fc_project_tsconfig.ts +0 -24
- package/src/entry-points/file/server/fc_package_server_main.ts +0 -62
- package/src/index.ts +0 -54
- package/src/ng-tools/SdCliNgModuleGenerator.ts +0 -672
- package/src/ng-tools/babel/SdCliBbFileMetadata.ts +0 -629
- package/src/ng-tools/babel/SdCliBbRootMetadata.ts +0 -292
- package/src/ng-tools/babel/SdCliBbUtil.ts +0 -15
- package/src/ng-tools/babel/TSdCliBbNgMetadata.ts +0 -251
- package/src/ng-tools/babel/TSdCliBbTypeMetadata.ts +0 -212
- package/src/ng-tools/commons.ts +0 -3
- package/src/ng-tools/typescript/SdCliTsFileMetadata.ts +0 -384
- package/src/ng-tools/typescript/SdCliTsRootMetadata.ts +0 -32
- package/src/ng-tools/typescript/SdCliTsUtil.ts +0 -29
- package/src/packages/SdCliPackage.ts +0 -259
- package/src/utils/SdCliNpmConfigUtil.ts +0 -16
- package/src/worker/build-worker.ts +0 -73
- package/src/worker/server-worker.ts +0 -72
- /package/dist/{worker/build-worker.d.ts → build-cluster.d.ts} +0 -0
- /package/dist/{worker/server-worker.d.ts → sd-cli.d.ts} +0 -0
|
@@ -1,259 +0,0 @@
|
|
|
1
|
-
import { INpmConfig, ISdCliPackageBuildResult, ITsconfig, TSdCliPackageConfig } from "../commons";
|
|
2
|
-
import path from "path";
|
|
3
|
-
import { FsUtil, PathUtil, SdProcess } from "@simplysm/sd-core-node";
|
|
4
|
-
import { EventEmitter } from "events";
|
|
5
|
-
import { JsonConvert, NeverEntryError, ObjectUtil, StringUtil } from "@simplysm/sd-core-common";
|
|
6
|
-
import { SdCliNpmConfigUtil } from "../utils/SdCliNpmConfigUtil";
|
|
7
|
-
import { SdStorage } from "@simplysm/sd-storage";
|
|
8
|
-
import ts from "typescript";
|
|
9
|
-
import { SdCliGithubApi } from "../build-tool/SdCliGithubApi";
|
|
10
|
-
import cp from "child_process";
|
|
11
|
-
import { fileURLToPath } from "url";
|
|
12
|
-
|
|
13
|
-
export class SdCliPackage extends EventEmitter {
|
|
14
|
-
private readonly _npmConfig: INpmConfig;
|
|
15
|
-
|
|
16
|
-
public get basename(): string {
|
|
17
|
-
return path.basename(this._projRootPath);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
public get name(): string {
|
|
21
|
-
return this._npmConfig.name;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
public get main(): string | undefined {
|
|
25
|
-
return this._npmConfig.main;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
public get allDependencies(): string[] {
|
|
29
|
-
return [
|
|
30
|
-
...SdCliNpmConfigUtil.getDependencies(this._npmConfig).defaults,
|
|
31
|
-
...SdCliNpmConfigUtil.getDependencies(this._npmConfig).optionals
|
|
32
|
-
].distinct();
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
public constructor(private readonly _projRootPath: string,
|
|
36
|
-
public readonly rootPath: string,
|
|
37
|
-
public readonly config: TSdCliPackageConfig) {
|
|
38
|
-
super();
|
|
39
|
-
|
|
40
|
-
const npmConfigFilePath = path.resolve(this.rootPath, "package.json");
|
|
41
|
-
this._npmConfig = FsUtil.readJson(npmConfigFilePath);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
public override on(event: "change", listener: () => void): this;
|
|
45
|
-
public override on(event: "complete", listener: (results: ISdCliPackageBuildResult[]) => void): this;
|
|
46
|
-
public override on(event: string | symbol, listener: (...args: any[]) => void): this {
|
|
47
|
-
return super.on(event, listener);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
public async setNewVersionAsync(newVersion: string, pkgNames: string[]): Promise<void> {
|
|
51
|
-
this._npmConfig.version = newVersion;
|
|
52
|
-
|
|
53
|
-
const updateDepVersion = (deps: Record<string, string> | undefined): void => {
|
|
54
|
-
if (!deps) return;
|
|
55
|
-
for (const depName of Object.keys(deps)) {
|
|
56
|
-
if (pkgNames.includes(depName)) {
|
|
57
|
-
deps[depName] = newVersion;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
};
|
|
61
|
-
updateDepVersion(this._npmConfig.dependencies);
|
|
62
|
-
updateDepVersion(this._npmConfig.optionalDependencies);
|
|
63
|
-
updateDepVersion(this._npmConfig.devDependencies);
|
|
64
|
-
updateDepVersion(this._npmConfig.peerDependencies);
|
|
65
|
-
|
|
66
|
-
const npmConfigFilePath = path.resolve(this.rootPath, "package.json");
|
|
67
|
-
await FsUtil.writeJsonAsync(npmConfigFilePath, this._npmConfig, { space: 2 });
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
public async watchAsync(): Promise<void> {
|
|
71
|
-
const isTs = FsUtil.exists(path.resolve(this.rootPath, "tsconfig.json"));
|
|
72
|
-
|
|
73
|
-
if (isTs) {
|
|
74
|
-
await this._genBuildTsconfigAsync();
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
await this._runBuildWorkerAsync(
|
|
78
|
-
"watch",
|
|
79
|
-
(message) => {
|
|
80
|
-
const msg = JsonConvert.parse(message);
|
|
81
|
-
if (msg.event === "ready") {
|
|
82
|
-
return true;
|
|
83
|
-
}
|
|
84
|
-
else if (msg.event === "change") {
|
|
85
|
-
this.emit("change");
|
|
86
|
-
return undefined;
|
|
87
|
-
}
|
|
88
|
-
else if (msg.event === "complete") {
|
|
89
|
-
this.emit("complete", msg.body);
|
|
90
|
-
return undefined;
|
|
91
|
-
}
|
|
92
|
-
else {
|
|
93
|
-
return new NeverEntryError();
|
|
94
|
-
}
|
|
95
|
-
},
|
|
96
|
-
(err) => err
|
|
97
|
-
);
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
public async buildAsync(): Promise<ISdCliPackageBuildResult[]> {
|
|
101
|
-
const isTs = FsUtil.exists(path.resolve(this.rootPath, "tsconfig.json"));
|
|
102
|
-
|
|
103
|
-
if (isTs) {
|
|
104
|
-
await this._genBuildTsconfigAsync();
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
let result: ISdCliPackageBuildResult[] = [];
|
|
108
|
-
|
|
109
|
-
await this._runBuildWorkerAsync(
|
|
110
|
-
"build",
|
|
111
|
-
(message) => {
|
|
112
|
-
result = JsonConvert.parse(message);
|
|
113
|
-
return undefined;
|
|
114
|
-
},
|
|
115
|
-
err => err
|
|
116
|
-
);
|
|
117
|
-
|
|
118
|
-
return result;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
public async publishAsync(): Promise<void> {
|
|
122
|
-
if (this.config.publish !== undefined) {
|
|
123
|
-
if (this.config.type === "library") {
|
|
124
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
125
|
-
if (this.config.publish === "npm") {
|
|
126
|
-
await SdProcess.spawnAsync("yarn npm publish --access public", { cwd: this.rootPath });
|
|
127
|
-
}
|
|
128
|
-
else {
|
|
129
|
-
throw new NeverEntryError();
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
else {
|
|
133
|
-
if (this.config.publish.type === "github") {
|
|
134
|
-
if (!this._npmConfig.repository) {
|
|
135
|
-
throw new Error("패키지의 package.json에 repository가 설정되지 않아 github로 배포할 수 없습니다.");
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
const repoUrl = this._npmConfig.repository.url;
|
|
139
|
-
const repoOwner = repoUrl.split("/").slice(-2)[0];
|
|
140
|
-
const repoName = repoUrl.split("/").slice(-2)[1].replace(/\..*/g, "");
|
|
141
|
-
|
|
142
|
-
const github = new SdCliGithubApi(
|
|
143
|
-
this.config.publish.apiKey,
|
|
144
|
-
repoOwner,
|
|
145
|
-
repoName
|
|
146
|
-
);
|
|
147
|
-
|
|
148
|
-
await github.uploadAsync(this._npmConfig.version, this.config.publish.files.map((item) => ({
|
|
149
|
-
buffer: FsUtil.readFileBuffer(path.resolve(this.rootPath, "dist", item.from)),
|
|
150
|
-
name: item.to
|
|
151
|
-
})));
|
|
152
|
-
}
|
|
153
|
-
else if (this.config.publish.type === "ftp" || this.config.publish.type === "ftps" || this.config.publish.type === "sftp") {
|
|
154
|
-
const tsconfigPath = path.resolve(this.rootPath, "tsconfig-build.json");
|
|
155
|
-
const tsconfig = FsUtil.readJson(tsconfigPath);
|
|
156
|
-
const parsedTsconfig = ts.parseJsonConfigFileContent(tsconfig, ts.sys, this.rootPath, tsconfig.angularCompilerOptions);
|
|
157
|
-
|
|
158
|
-
const ftp = await SdStorage.connectAsync(this.config.publish.type, {
|
|
159
|
-
host: this.config.publish.host,
|
|
160
|
-
port: this.config.publish.port,
|
|
161
|
-
user: this.config.publish.user,
|
|
162
|
-
pass: this.config.publish.pass
|
|
163
|
-
});
|
|
164
|
-
await ftp.uploadDirAsync(parsedTsconfig.options.outDir!, this.config.publish.path);
|
|
165
|
-
await ftp.closeAsync();
|
|
166
|
-
}
|
|
167
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
168
|
-
else if (this.config.publish.type === "local-directory") {
|
|
169
|
-
const tsconfigPath = path.resolve(this.rootPath, "tsconfig-build.json");
|
|
170
|
-
const tsconfig = FsUtil.readJson(tsconfigPath);
|
|
171
|
-
const parsedTsconfig = ts.parseJsonConfigFileContent(tsconfig, ts.sys, this.rootPath, tsconfig.angularCompilerOptions);
|
|
172
|
-
|
|
173
|
-
const targetRootPath = this.config.publish.path.replace(/%([^%]*)%/g, (item) => {
|
|
174
|
-
const envName = item.replace(/%/g, "");
|
|
175
|
-
if (!StringUtil.isNullOrEmpty(this._npmConfig.version) && envName === "SD_VERSION") {
|
|
176
|
-
return this._npmConfig.version;
|
|
177
|
-
}
|
|
178
|
-
return process.env[envName] ?? item;
|
|
179
|
-
});
|
|
180
|
-
|
|
181
|
-
const filePaths = await FsUtil.globAsync(path.resolve(parsedTsconfig.options.outDir!, "**", "*"), {
|
|
182
|
-
dot: true,
|
|
183
|
-
nodir: true
|
|
184
|
-
});
|
|
185
|
-
|
|
186
|
-
await filePaths.parallelAsync(async (filePath) => {
|
|
187
|
-
const relativeFilePath = path.relative(parsedTsconfig.options.outDir!, filePath);
|
|
188
|
-
const targetPath = PathUtil.posix(targetRootPath, relativeFilePath);
|
|
189
|
-
await FsUtil.copyAsync(filePath, targetPath);
|
|
190
|
-
});
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
private async _genBuildTsconfigAsync(): Promise<void> {
|
|
197
|
-
const baseTsconfigFilePath = path.resolve(this.rootPath, "tsconfig.json");
|
|
198
|
-
const baseTsconfig: ITsconfig = await FsUtil.readJsonAsync(baseTsconfigFilePath);
|
|
199
|
-
|
|
200
|
-
const buildTsconfig: ITsconfig = ObjectUtil.clone(baseTsconfig);
|
|
201
|
-
buildTsconfig.compilerOptions = buildTsconfig.compilerOptions ?? {};
|
|
202
|
-
delete buildTsconfig.compilerOptions.baseUrl;
|
|
203
|
-
delete buildTsconfig.compilerOptions.paths;
|
|
204
|
-
|
|
205
|
-
buildTsconfig.compilerOptions.declaration = Boolean(this._npmConfig.types);
|
|
206
|
-
|
|
207
|
-
const buildTsconfigFilePath = path.resolve(this.rootPath, "tsconfig-build.json");
|
|
208
|
-
await FsUtil.writeJsonAsync(buildTsconfigFilePath, buildTsconfig, { space: 2 });
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
private async _runBuildWorkerAsync(cmd: string, success: (message: string) => undefined | true | Error, error: (err: Error) => undefined | true | Error): Promise<void> {
|
|
212
|
-
return await new Promise<void>(async (resolve, reject) => {
|
|
213
|
-
const worker = cp.fork(
|
|
214
|
-
fileURLToPath(await import.meta.resolve!("../worker/build-worker")),
|
|
215
|
-
[
|
|
216
|
-
cmd,
|
|
217
|
-
this.rootPath,
|
|
218
|
-
JsonConvert.stringify(this.config),
|
|
219
|
-
this._projRootPath
|
|
220
|
-
],
|
|
221
|
-
{
|
|
222
|
-
stdio: ["pipe", "pipe", "pipe", "ipc"],
|
|
223
|
-
env: process.env
|
|
224
|
-
});
|
|
225
|
-
|
|
226
|
-
worker.on("error", (err) => {
|
|
227
|
-
const r = error(err);
|
|
228
|
-
if (r === true) {
|
|
229
|
-
resolve();
|
|
230
|
-
}
|
|
231
|
-
else if (r != null) {
|
|
232
|
-
reject(r);
|
|
233
|
-
}
|
|
234
|
-
});
|
|
235
|
-
|
|
236
|
-
worker.stdout!.pipe(process.stdout);
|
|
237
|
-
worker.stderr!.pipe(process.stderr);
|
|
238
|
-
|
|
239
|
-
worker.on("message", (json: string) => {
|
|
240
|
-
const r = success(json);
|
|
241
|
-
if (r === true) {
|
|
242
|
-
resolve();
|
|
243
|
-
}
|
|
244
|
-
else if (r != null) {
|
|
245
|
-
reject(r);
|
|
246
|
-
}
|
|
247
|
-
});
|
|
248
|
-
|
|
249
|
-
worker.on("exit", (code) => {
|
|
250
|
-
if (code !== 0) {
|
|
251
|
-
reject(new Error(`오류와 함께 닫힘 (${code})`));
|
|
252
|
-
return;
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
resolve();
|
|
256
|
-
});
|
|
257
|
-
});
|
|
258
|
-
}
|
|
259
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { INpmConfig } from "../commons";
|
|
2
|
-
|
|
3
|
-
export class SdCliNpmConfigUtil {
|
|
4
|
-
public static getDependencies(npmConfig: INpmConfig): { defaults: string[]; optionals: string[] } {
|
|
5
|
-
return {
|
|
6
|
-
defaults: [
|
|
7
|
-
...Object.keys(npmConfig.dependencies ?? {}),
|
|
8
|
-
...Object.keys(npmConfig.peerDependencies ?? {}).filter((item) => !npmConfig.peerDependenciesMeta?.[item]?.optional)
|
|
9
|
-
].distinct(),
|
|
10
|
-
optionals: [
|
|
11
|
-
...Object.keys(npmConfig.optionalDependencies ?? {}),
|
|
12
|
-
...Object.keys(npmConfig.peerDependencies ?? {}).filter((item) => npmConfig.peerDependenciesMeta?.[item]?.optional)
|
|
13
|
-
].distinct()
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
}
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import { SdCliTsLibBuilder } from "../builder/SdCliTsLibBuilder";
|
|
2
|
-
import { SdCliJsLibBuilder } from "../builder/SdCliJsLibBuilder";
|
|
3
|
-
import { SdCliServerBuilder } from "../builder/SdCliServerBuilder";
|
|
4
|
-
import { SdCliClientBuilder } from "../builder/SdCliClientBuilder";
|
|
5
|
-
import { FsUtil, Logger, LoggerSeverity } from "@simplysm/sd-core-node";
|
|
6
|
-
import path from "path";
|
|
7
|
-
import { JsonConvert } from "@simplysm/sd-core-common";
|
|
8
|
-
import { TSdCliPackageConfig } from "../commons";
|
|
9
|
-
|
|
10
|
-
if (process.env["SD_CLI_LOGGER_SEVERITY"] === "DEBUG") {
|
|
11
|
-
Logger.setConfig({
|
|
12
|
-
console: {
|
|
13
|
-
level: LoggerSeverity.debug
|
|
14
|
-
}
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
else {
|
|
18
|
-
Logger.setConfig({
|
|
19
|
-
dot: true
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
const type = process.argv[2] as ("build" | "watch");
|
|
24
|
-
const rootPath = process.argv[3];
|
|
25
|
-
const config = JsonConvert.parse(process.argv[4]) as TSdCliPackageConfig;
|
|
26
|
-
const projRootPath = process.argv[5];
|
|
27
|
-
|
|
28
|
-
function createBuilder(): SdCliJsLibBuilder | SdCliTsLibBuilder | SdCliServerBuilder | SdCliClientBuilder {
|
|
29
|
-
const isTs = FsUtil.exists(path.resolve(rootPath, "tsconfig.json"));
|
|
30
|
-
|
|
31
|
-
if (config.type === "library") {
|
|
32
|
-
return isTs ? new SdCliTsLibBuilder(rootPath, config, projRootPath) : new SdCliJsLibBuilder(rootPath);
|
|
33
|
-
}
|
|
34
|
-
else if (config.type === "server") {
|
|
35
|
-
return new SdCliServerBuilder(rootPath, config, projRootPath);
|
|
36
|
-
}
|
|
37
|
-
else {
|
|
38
|
-
return new SdCliClientBuilder(rootPath, config, projRootPath);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
const builder = createBuilder();
|
|
43
|
-
|
|
44
|
-
if (type === "build") {
|
|
45
|
-
builder.buildAsync()
|
|
46
|
-
.then((result) => {
|
|
47
|
-
process.send!(JsonConvert.stringify(result));
|
|
48
|
-
process.exit(0);
|
|
49
|
-
})
|
|
50
|
-
.catch((err) => {
|
|
51
|
-
// eslint-disable-next-line no-console
|
|
52
|
-
console.error(err);
|
|
53
|
-
process.exit(1);
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
else {
|
|
57
|
-
builder
|
|
58
|
-
.on("change", () => {
|
|
59
|
-
process.send!(JsonConvert.stringify({ event: "change" }));
|
|
60
|
-
})
|
|
61
|
-
.on("complete", (results) => {
|
|
62
|
-
process.send!(JsonConvert.stringify({ event: "complete", body: results }));
|
|
63
|
-
})
|
|
64
|
-
.watchAsync()
|
|
65
|
-
.then(() => {
|
|
66
|
-
process.send!(JsonConvert.stringify({ event: "ready" }));
|
|
67
|
-
})
|
|
68
|
-
.catch((err) => {
|
|
69
|
-
// eslint-disable-next-line no-console
|
|
70
|
-
console.error(err);
|
|
71
|
-
process.exit(1);
|
|
72
|
-
});
|
|
73
|
-
}
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import { Logger, LoggerSeverity } from "@simplysm/sd-core-node";
|
|
2
|
-
import { JsonConvert } from "@simplysm/sd-core-common";
|
|
3
|
-
import { SdServiceServer } from "@simplysm/sd-service-server";
|
|
4
|
-
|
|
5
|
-
if (process.env["SD_CLI_LOGGER_SEVERITY"] === "DEBUG") {
|
|
6
|
-
Logger.setConfig({
|
|
7
|
-
console: {
|
|
8
|
-
level: LoggerSeverity.debug
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
}
|
|
12
|
-
else {
|
|
13
|
-
Logger.setConfig({
|
|
14
|
-
dot: true
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
const filePathOrOpt = JsonConvert.parse(process.argv[2]) as (string | { port: number });
|
|
19
|
-
|
|
20
|
-
let runningServer: SdServiceServer | undefined;
|
|
21
|
-
|
|
22
|
-
if (typeof filePathOrOpt === "string") {
|
|
23
|
-
import(`file:///${filePathOrOpt}`)
|
|
24
|
-
.then((serverModule) => {
|
|
25
|
-
const server = serverModule.default as SdServiceServer | undefined;
|
|
26
|
-
if (server === undefined) {
|
|
27
|
-
// eslint-disable-next-line no-console
|
|
28
|
-
console.error(`${filePathOrOpt}(0, 0): 'SdServiceServer'를 'export'해야 합니다.`);
|
|
29
|
-
process.exit(1);
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
const protocolStr = server.options.ssl ? "https" : "http";
|
|
33
|
-
const portStr = server.options.port.toString();
|
|
34
|
-
|
|
35
|
-
runningServer = server;
|
|
36
|
-
process.send!(`${protocolStr}://localhost:${portStr}`);
|
|
37
|
-
})
|
|
38
|
-
.catch((err) => {
|
|
39
|
-
// eslint-disable-next-line no-console
|
|
40
|
-
console.error(err);
|
|
41
|
-
process.exit(1);
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
// DEV SERVER
|
|
45
|
-
else {
|
|
46
|
-
const server = new SdServiceServer({
|
|
47
|
-
rootPath: process.cwd(),
|
|
48
|
-
services: [],
|
|
49
|
-
port: filePathOrOpt.port
|
|
50
|
-
});
|
|
51
|
-
server.listenAsync()
|
|
52
|
-
.then(() => {
|
|
53
|
-
runningServer = server;
|
|
54
|
-
process.send!(`http://localhost:${filePathOrOpt.port}`);
|
|
55
|
-
})
|
|
56
|
-
.catch((err) => {
|
|
57
|
-
// eslint-disable-next-line no-console
|
|
58
|
-
console.error(err);
|
|
59
|
-
process.exit(1);
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
process.on("message", (msg: string) => {
|
|
64
|
-
if (!runningServer) return;
|
|
65
|
-
|
|
66
|
-
if (msg === "broadcastReload") {
|
|
67
|
-
runningServer.broadcastReload();
|
|
68
|
-
}
|
|
69
|
-
else {
|
|
70
|
-
runningServer.pathProxy = JsonConvert.parse(msg);
|
|
71
|
-
}
|
|
72
|
-
});
|
|
File without changes
|
|
File without changes
|