@simplysm/sd-cli 7.0.249 → 7.0.263
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/README.md +48 -0
- package/dist/bin/sd-cli.mjs +171 -13
- package/dist/build-tool/SdCliElectron.mjs +3 -2
- package/dist/builder/SdCliClientBuilder.mjs +11 -7
- package/dist/builder/SdCliTsLibBuilder.mjs +18 -12
- package/dist/commons.d.ts +6 -1
- package/dist/entry-points/SdCliProjectGenerator.d.ts +37 -0
- package/dist/entry-points/SdCliProjectGenerator.mjs +288 -0
- package/dist/entry-points/SdCliWorkspace.d.ts +6 -6
- package/dist/entry-points/SdCliWorkspace.mjs +61 -107
- package/dist/entry-points/file/base/fc_package_eslintrc.d.ts +3 -0
- package/dist/entry-points/file/base/fc_package_eslintrc.mjs +31 -0
- package/dist/entry-points/file/base/fc_package_npmconfig.d.ts +9 -0
- package/dist/entry-points/file/base/fc_package_npmconfig.mjs +32 -0
- package/dist/entry-points/file/base/fc_package_tsconfig.d.ts +4 -0
- package/dist/entry-points/file/base/fc_package_tsconfig.mjs +12 -0
- package/dist/entry-points/file/client/fc_package_AppModule.d.ts +1 -0
- package/dist/entry-points/file/client/fc_package_AppModule.mjs +37 -0
- package/dist/entry-points/file/client/fc_package_AppPage.d.ts +1 -0
- package/dist/entry-points/file/client/fc_package_AppPage.mjs +34 -0
- package/dist/entry-points/file/client/fc_package_appicons.d.ts +1 -0
- package/dist/entry-points/file/client/fc_package_appicons.mjs +6 -0
- package/dist/entry-points/file/client/fc_package_client_main.d.ts +1 -0
- package/dist/entry-points/file/client/fc_package_client_main.mjs +19 -0
- package/dist/entry-points/file/client/fc_package_index.d.ts +3 -0
- package/dist/entry-points/file/client/fc_package_index.mjs +88 -0
- package/dist/entry-points/file/client/fc_package_manifest.d.ts +5 -0
- package/dist/entry-points/file/client/fc_package_manifest.mjs +54 -0
- package/dist/entry-points/file/client/fc_package_polyfills.d.ts +1 -0
- package/dist/entry-points/file/client/fc_package_polyfills.mjs +11 -0
- package/dist/entry-points/file/client/fc_package_styles.d.ts +1 -0
- package/dist/entry-points/file/client/fc_package_styles.mjs +7 -0
- package/dist/entry-points/file/db/fc_package_DbContext.d.ts +3 -0
- package/dist/entry-points/file/db/fc_package_DbContext.mjs +14 -0
- package/dist/entry-points/file/db/fc_package_DbModel.d.ts +4 -0
- package/dist/entry-points/file/db/fc_package_DbModel.mjs +12 -0
- package/dist/entry-points/file/project/fc_project_editor_config.d.ts +1 -0
- package/dist/entry-points/file/project/fc_project_editor_config.mjs +22 -0
- package/dist/entry-points/file/project/fc_project_eslintrc.d.ts +1 -0
- package/dist/entry-points/file/project/fc_project_eslintrc.mjs +30 -0
- package/dist/entry-points/file/project/fc_project_gitattributes.d.ts +1 -0
- package/dist/entry-points/file/project/fc_project_gitattributes.mjs +6 -0
- package/dist/entry-points/file/project/fc_project_gitignore.d.ts +1 -0
- package/dist/entry-points/file/project/fc_project_gitignore.mjs +17 -0
- package/dist/entry-points/file/project/fc_project_npmconfig.d.ts +7 -0
- package/dist/entry-points/file/project/fc_project_npmconfig.mjs +35 -0
- package/dist/entry-points/file/project/fc_project_readme.d.ts +3 -0
- package/dist/entry-points/file/project/fc_project_readme.mjs +12 -0
- package/dist/entry-points/file/project/fc_project_simplysm.d.ts +1 -0
- package/dist/entry-points/file/project/fc_project_simplysm.mjs +2 -0
- package/dist/entry-points/file/project/fc_project_tsconfig.d.ts +1 -0
- package/dist/entry-points/file/project/fc_project_tsconfig.mjs +26 -0
- package/dist/entry-points/file/server/fc_package_server_main.d.ts +4 -0
- package/dist/entry-points/file/server/fc_package_server_main.mjs +60 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.mjs +24 -1
- package/dist/packages/SdCliPackage.d.ts +1 -0
- package/dist/packages/SdCliPackage.mjs +68 -62
- package/dist/utils/SdCliBuildResultUtil.mjs +2 -2
- package/package.json +10 -8
- package/src/bin/sd-cli.ts +198 -12
- package/src/build-tool/SdCliElectron.ts +2 -1
- package/src/builder/SdCliClientBuilder.ts +13 -7
- package/src/builder/SdCliJsLibBuilder.ts +70 -70
- package/src/builder/SdCliTsLibBuilder.ts +450 -445
- package/src/commons.ts +6 -1
- package/src/entry-points/SdCliProjectGenerator.ts +353 -0
- package/src/entry-points/SdCliWorkspace.ts +74 -122
- package/src/entry-points/file/assets/assets/icons/icon-128x128.png +0 -0
- package/src/entry-points/file/assets/assets/icons/icon-144x144.png +0 -0
- package/src/entry-points/file/assets/assets/icons/icon-152x152.png +0 -0
- package/src/entry-points/file/assets/assets/icons/icon-192x192.png +0 -0
- package/src/entry-points/file/assets/assets/icons/icon-384x384.png +0 -0
- package/src/entry-points/file/assets/assets/icons/icon-512x512.png +0 -0
- package/src/entry-points/file/assets/assets/icons/icon-72x72.png +0 -0
- package/src/entry-points/file/assets/assets/icons/icon-96x96.png +0 -0
- package/src/entry-points/file/assets/favicon.ico +0 -0
- package/src/entry-points/file/base/fc_package_eslintrc.ts +30 -0
- package/src/entry-points/file/base/fc_package_npmconfig.ts +43 -0
- package/src/entry-points/file/base/fc_package_tsconfig.ts +11 -0
- package/src/entry-points/file/client/fc_package_AppModule.ts +36 -0
- package/src/entry-points/file/client/fc_package_AppPage.ts +33 -0
- package/src/entry-points/file/client/fc_package_appicons.ts +5 -0
- package/src/entry-points/file/client/fc_package_client_main.ts +18 -0
- package/src/entry-points/file/client/fc_package_index.ts +87 -0
- package/src/entry-points/file/client/fc_package_manifest.ts +53 -0
- package/src/entry-points/file/client/fc_package_polyfills.ts +10 -0
- package/src/entry-points/file/client/fc_package_styles.ts +6 -0
- package/src/entry-points/file/db/fc_package_DbContext.ts +14 -0
- package/src/entry-points/file/db/fc_package_DbModel.ts +11 -0
- package/src/entry-points/file/project/fc_project_editor_config.ts +21 -0
- package/src/entry-points/file/project/fc_project_eslintrc.ts +29 -0
- package/src/entry-points/file/project/fc_project_gitattributes.ts +5 -0
- package/src/entry-points/file/project/fc_project_gitignore.ts +16 -0
- package/src/entry-points/file/project/fc_project_npmconfig.ts +34 -0
- package/src/entry-points/file/project/fc_project_readme.ts +11 -0
- package/src/entry-points/file/project/fc_project_simplysm.ts +1 -0
- package/src/entry-points/file/project/fc_project_tsconfig.ts +25 -0
- package/src/entry-points/file/server/fc_package_server_main.ts +62 -0
- package/src/index.ts +23 -0
- package/src/packages/SdCliPackage.ts +75 -58
- package/src/utils/SdCliBuildResultUtil.ts +76 -76
package/src/commons.ts
CHANGED
|
@@ -4,7 +4,7 @@ export interface INpmConfig {
|
|
|
4
4
|
description?: string;
|
|
5
5
|
author?: string;
|
|
6
6
|
license?: string;
|
|
7
|
-
repository
|
|
7
|
+
repository?: {
|
|
8
8
|
type: string;
|
|
9
9
|
url: string;
|
|
10
10
|
directory?: string;
|
|
@@ -27,6 +27,8 @@ export interface INpmConfig {
|
|
|
27
27
|
|
|
28
28
|
export interface ITsconfig {
|
|
29
29
|
compilerOptions?: {
|
|
30
|
+
module?: string;
|
|
31
|
+
lib?: string[];
|
|
30
32
|
outDir?: string;
|
|
31
33
|
baseUrl?: string;
|
|
32
34
|
paths?: Record<string, string[]>;
|
|
@@ -109,9 +111,11 @@ export interface ISdCliGithubPublishConfig {
|
|
|
109
111
|
}
|
|
110
112
|
|
|
111
113
|
export interface ISdCliClientBuilderWebConfig {
|
|
114
|
+
env?: Record<string, string>;
|
|
112
115
|
}
|
|
113
116
|
|
|
114
117
|
export interface ISdCliClientBuilderCordovaConfig {
|
|
118
|
+
env?: Record<string, string>;
|
|
115
119
|
appId: string;
|
|
116
120
|
appName: string;
|
|
117
121
|
plugins?: string[];
|
|
@@ -136,4 +140,5 @@ export interface ISdCliClientBuilderElectronConfig {
|
|
|
136
140
|
appId: string;
|
|
137
141
|
icon?: string;
|
|
138
142
|
installerIcon?: string;
|
|
143
|
+
env?: Record<string, string>;
|
|
139
144
|
}
|
|
@@ -0,0 +1,353 @@
|
|
|
1
|
+
import { FsUtil, Logger, SdProcess } from "@simplysm/sd-core-node";
|
|
2
|
+
import path from "path";
|
|
3
|
+
import { StringUtil } from "@simplysm/sd-core-common";
|
|
4
|
+
import { fc_project_editor_config } from "./file/project/fc_project_editor_config";
|
|
5
|
+
import { fc_project_eslintrc } from "./file/project/fc_project_eslintrc";
|
|
6
|
+
import { fc_project_gitignore } from "./file/project/fc_project_gitignore";
|
|
7
|
+
import { fc_project_gitattributes } from "./file/project/fc_project_gitattributes";
|
|
8
|
+
import { fc_project_npmconfig } from "./file/project/fc_project_npmconfig";
|
|
9
|
+
import { fc_project_readme } from "./file/project/fc_project_readme";
|
|
10
|
+
import { fc_project_simplysm } from "./file/project/fc_project_simplysm";
|
|
11
|
+
import { fc_project_tsconfig } from "./file/project/fc_project_tsconfig";
|
|
12
|
+
import { fc_package_eslintrc } from "./file/base/fc_package_eslintrc";
|
|
13
|
+
import { fc_package_npmconfig } from "./file/base/fc_package_npmconfig";
|
|
14
|
+
import { fc_package_tsconfig } from "./file/base/fc_package_tsconfig";
|
|
15
|
+
import { fc_package_DbContext } from "./file/db/fc_package_DbContext";
|
|
16
|
+
import { fc_package_DbModel } from "./file/db/fc_package_DbModel";
|
|
17
|
+
import { fc_package_server_main } from "./file/server/fc_package_server_main";
|
|
18
|
+
import { fc_package_appicons } from "./file/client/fc_package_appicons";
|
|
19
|
+
import { fc_package_AppModule } from "./file/client/fc_package_AppModule";
|
|
20
|
+
import { fc_package_AppPage } from "./file/client/fc_package_AppPage";
|
|
21
|
+
import { fileURLToPath } from "url";
|
|
22
|
+
import { fc_package_index } from "./file/client/fc_package_index";
|
|
23
|
+
import { fc_package_client_main } from "./file/client/fc_package_client_main";
|
|
24
|
+
import { fc_package_manifest } from "./file/client/fc_package_manifest";
|
|
25
|
+
import { INpmConfig } from "../commons";
|
|
26
|
+
import { fc_package_polyfills } from "./file/client/fc_package_polyfills";
|
|
27
|
+
import { fc_package_styles } from "./file/client/fc_package_styles";
|
|
28
|
+
|
|
29
|
+
export class SdCliProjectGenerator {
|
|
30
|
+
private readonly _logger = Logger.get(["simplysm", "sd-cli", this.constructor.name]);
|
|
31
|
+
|
|
32
|
+
public constructor(private readonly _rootPath: string) {
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
public async initAsync(opt: { name?: string; description: string; author: string; gitUrl: string }): Promise<void> {
|
|
36
|
+
if ((await FsUtil.readdirAsync(this._rootPath)).filter((item) => ![".idea", "package.json", "node_modules", "package-lock.json"].includes(path.basename(item))).length > 0) {
|
|
37
|
+
throw new Error("빈 디렉토리가 아닙니다. (package-lock.json, package.json, node_modules 외의 파일/폴더가 존재하는 경우, 초기화할 수 없습니다.)");
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const projName = opt.name ?? path.basename(this._rootPath);
|
|
41
|
+
|
|
42
|
+
this._logger.log("'.editorconfig' 파일 생성");
|
|
43
|
+
await FsUtil.writeFileAsync(path.resolve(this._rootPath, ".editorconfig"), fc_project_editor_config());
|
|
44
|
+
|
|
45
|
+
this._logger.log(`[${projName}] '.eslintrc.cjs' 파일 생성`);
|
|
46
|
+
await FsUtil.writeFileAsync(path.resolve(this._rootPath, ".eslintrc.cjs"), fc_project_eslintrc());
|
|
47
|
+
|
|
48
|
+
this._logger.log(`[${projName}]'.gitattributes' 파일 생성`);
|
|
49
|
+
await FsUtil.writeFileAsync(path.resolve(this._rootPath, ".gitattributes"), fc_project_gitattributes());
|
|
50
|
+
|
|
51
|
+
this._logger.log(`[${projName}] '.gitignore' 파일 생성`);
|
|
52
|
+
await FsUtil.writeFileAsync(path.resolve(this._rootPath, ".gitignore"), fc_project_gitignore());
|
|
53
|
+
|
|
54
|
+
this._logger.log(`[${projName}] 'package.json' 파일 생성`);
|
|
55
|
+
let cliVersion: string | undefined;
|
|
56
|
+
if (FsUtil.exists(path.resolve(this._rootPath, "package.json"))) {
|
|
57
|
+
const npmConfig = await FsUtil.readJsonAsync(path.resolve(this._rootPath, "package.json")) as INpmConfig;
|
|
58
|
+
cliVersion = npmConfig.dependencies?.["@simplysm/sd-cli"];
|
|
59
|
+
}
|
|
60
|
+
await FsUtil.writeFileAsync(path.resolve(this._rootPath, "package.json"), fc_project_npmconfig({
|
|
61
|
+
name: projName,
|
|
62
|
+
description: opt.description,
|
|
63
|
+
author: opt.author,
|
|
64
|
+
gitUrl: opt.gitUrl,
|
|
65
|
+
cliVersion
|
|
66
|
+
}));
|
|
67
|
+
|
|
68
|
+
this._logger.log(`[${projName}] 'README.md' 파일 생성`);
|
|
69
|
+
await FsUtil.writeFileAsync(path.resolve(this._rootPath, "README.md"), fc_project_readme({
|
|
70
|
+
description: opt.description
|
|
71
|
+
}));
|
|
72
|
+
|
|
73
|
+
this._logger.log(`[${projName}] 'simplysm.json' 파일 생성`);
|
|
74
|
+
await FsUtil.writeFileAsync(path.resolve(this._rootPath, "simplysm.json"), fc_project_simplysm());
|
|
75
|
+
|
|
76
|
+
this._logger.log(`[${projName}] 'tsconfig.json' 파일 생성`);
|
|
77
|
+
await FsUtil.writeFileAsync(path.resolve(this._rootPath, "tsconfig.json"), fc_project_tsconfig());
|
|
78
|
+
|
|
79
|
+
this._logger.log(`[${projName}] 'packages' 디렉토리 생성`);
|
|
80
|
+
await FsUtil.mkdirsAsync(path.resolve(this._rootPath, "packages"));
|
|
81
|
+
|
|
82
|
+
this._logger.log(`[${projName}] npm install`);
|
|
83
|
+
await SdProcess.spawnAsync("npm install", { cwd: this._rootPath }, true);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
public async addTsLibAsync(opt: { name: string; description: string; useDom: boolean }): Promise<void> {
|
|
87
|
+
await this._addPackageBaseTemplate({
|
|
88
|
+
...opt,
|
|
89
|
+
isModule: true,
|
|
90
|
+
isForAngular: false,
|
|
91
|
+
types: "dist/index.d.ts",
|
|
92
|
+
main: "dist/index.mjs",
|
|
93
|
+
dependencies: {}
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
this._logger.log(`[${opt.name}] 'simplysm.json' 파일에 등록`);
|
|
97
|
+
|
|
98
|
+
await this._addPackageToSimplysmJson({
|
|
99
|
+
name: opt.name,
|
|
100
|
+
type: "library",
|
|
101
|
+
useAutoIndex: true
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
public async addDbLibAsync(opt: { name: string }): Promise<void> {
|
|
106
|
+
const pkgName = "db-" + opt.name;
|
|
107
|
+
const pkgPath = path.resolve(this._rootPath, "packages", pkgName);
|
|
108
|
+
const projNpmConfig = await this._getProjNpmConfigAsync();
|
|
109
|
+
const projName = projNpmConfig.name;
|
|
110
|
+
|
|
111
|
+
await this._addPackageBaseTemplate({
|
|
112
|
+
name: pkgName,
|
|
113
|
+
description: "DB " + opt.name.toUpperCase(),
|
|
114
|
+
useDom: false,
|
|
115
|
+
isModule: false,
|
|
116
|
+
isForAngular: false,
|
|
117
|
+
types: "dist/index.d.ts",
|
|
118
|
+
main: "dist/index.cjs",
|
|
119
|
+
dependencies: {
|
|
120
|
+
"@simplysm/sd-core-common": "~7.0.0",
|
|
121
|
+
"@simplysm/sd-orm-common": "~7.0.0"
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
this._logger.log(`[${pkgName}] 'src/${StringUtil.toPascalCase(opt.name)}DbContext.ts' 파일 생성`);
|
|
126
|
+
await FsUtil.writeFileAsync(path.resolve(pkgPath, `src/${StringUtil.toPascalCase(opt.name)}DbContext.ts`), fc_package_DbContext({
|
|
127
|
+
name: opt.name
|
|
128
|
+
}));
|
|
129
|
+
|
|
130
|
+
this._logger.log(`[${pkgName}] 'src/models' 디렉토리 생성`);
|
|
131
|
+
await FsUtil.mkdirsAsync(path.resolve(pkgPath, "src/models"));
|
|
132
|
+
|
|
133
|
+
this._logger.log(`[${pkgName}] 'simplysm.json' 파일에 등록`);
|
|
134
|
+
await this._addPackageToSimplysmJson({
|
|
135
|
+
name: pkgName,
|
|
136
|
+
type: "library",
|
|
137
|
+
useAutoIndex: true
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
this._logger.log(`[${projName}] npm install`);
|
|
141
|
+
await SdProcess.spawnAsync("npm install", { cwd: this._rootPath }, true);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
public async addDbLibModelAsync(opt: { dbPkgName: string; category: string; name: string; description: string }): Promise<void> {
|
|
145
|
+
const pkgName = "db-" + opt.dbPkgName;
|
|
146
|
+
const pkgPath = path.resolve(this._rootPath, "packages", pkgName);
|
|
147
|
+
|
|
148
|
+
this._logger.log(`[${pkgName}] 'src/models/${opt.category}/${opt.name}.ts' 파일 생성`);
|
|
149
|
+
|
|
150
|
+
await FsUtil.writeFileAsync(
|
|
151
|
+
path.resolve(pkgPath, `src/models/${opt.category}/${opt.name}.ts`), fc_package_DbModel({
|
|
152
|
+
name: opt.name,
|
|
153
|
+
description: opt.description
|
|
154
|
+
}));
|
|
155
|
+
|
|
156
|
+
this._logger.log(`[${pkgName}] DbContext 파일에 등록`);
|
|
157
|
+
let dbContextContent = await FsUtil.readFileAsync(path.resolve(pkgPath, `src/${StringUtil.toPascalCase(opt.dbPkgName)}DbContext.ts`));
|
|
158
|
+
|
|
159
|
+
if (!dbContextContent.includes(`Queryable`)) {
|
|
160
|
+
this._logger.log(`[${pkgName}] DbContext 파일에 등록: import: Queryable`);
|
|
161
|
+
dbContextContent = dbContextContent.replace(/ } from "@simplysm\/sd-orm-common";/, `, Queryable } from "@simplysm/sd-orm-common";`);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
this._logger.log(`[${pkgName}] DbContext 파일에 등록: import: MODEL`);
|
|
165
|
+
dbContextContent = `import { ${opt.name} } from "./models/${opt.category}/${opt.name}";\n` + dbContextContent;
|
|
166
|
+
|
|
167
|
+
if (!dbContextContent.includes(`//-- ${opt.category}\n`)) {
|
|
168
|
+
this._logger.log(`[${opt.name}] DbContext 파일에 등록: CATEGORY`);
|
|
169
|
+
|
|
170
|
+
dbContextContent = dbContextContent.replace(/\n}/, `\n\n //-- ${opt.category}\n}`);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
this._logger.log(`[${pkgName}] DbContext 파일에 등록: MODEL`);
|
|
174
|
+
|
|
175
|
+
dbContextContent = dbContextContent.replace(new RegExp(`//-- ${opt.category}\n`), `
|
|
176
|
+
//-- ${opt.category}
|
|
177
|
+
public readonly ${StringUtil.toCamelCase(opt.name)} = new Queryable(this, ${opt.name});
|
|
178
|
+
`.trim() + "\n");
|
|
179
|
+
|
|
180
|
+
await FsUtil.writeFileAsync(path.resolve(pkgPath, `src/${StringUtil.toPascalCase(opt.dbPkgName)}DbContext.ts`), dbContextContent);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
public async addServerAsync(opt: { name?: string; description?: string }): Promise<void> {
|
|
184
|
+
const pkgName = "server" + (opt.name === undefined ? "" : `-${opt.name}`);
|
|
185
|
+
const pkgPath = path.resolve(this._rootPath, "packages", pkgName);
|
|
186
|
+
const projNpmConfig = await this._getProjNpmConfigAsync();
|
|
187
|
+
const projName = projNpmConfig.name;
|
|
188
|
+
|
|
189
|
+
await this._addPackageBaseTemplate({
|
|
190
|
+
name: pkgName,
|
|
191
|
+
description: (opt.description === undefined ? "" : `${opt.description.toUpperCase()} `) + "서버",
|
|
192
|
+
useDom: false,
|
|
193
|
+
isModule: false,
|
|
194
|
+
isForAngular: false,
|
|
195
|
+
main: "dist/main.js",
|
|
196
|
+
dependencies: {
|
|
197
|
+
"@simplysm/sd-core-common": "~7.0.0",
|
|
198
|
+
"@simplysm/sd-core-node": "~7.0.0",
|
|
199
|
+
"@simplysm/sd-service-common": "~7.0.0",
|
|
200
|
+
"@simplysm/sd-service-server": "~7.0.0"
|
|
201
|
+
}
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
this._logger.log(`[${pkgName}] 'src/main.ts' 파일 등록`);
|
|
205
|
+
await FsUtil.writeFileAsync(path.resolve(pkgPath, `src/main.ts`), fc_package_server_main({
|
|
206
|
+
projPath: this._rootPath,
|
|
207
|
+
pkgName: pkgName
|
|
208
|
+
}));
|
|
209
|
+
|
|
210
|
+
this._logger.log(`[${pkgName}] 'simplysm.json' 파일에 등록`);
|
|
211
|
+
await this._addPackageToSimplysmJson({
|
|
212
|
+
name: pkgName,
|
|
213
|
+
type: "server",
|
|
214
|
+
useAutoIndex: false
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
this._logger.log(`[${projName}] npm install`);
|
|
218
|
+
await SdProcess.spawnAsync("npm install", { cwd: this._rootPath }, true);
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
public async addClientAsync(opt: { name: string; description: string; serverName: string }): Promise<void> {
|
|
222
|
+
const pkgName = `client-${opt.name}`;
|
|
223
|
+
const pkgPath = path.resolve(this._rootPath, "packages", pkgName);
|
|
224
|
+
|
|
225
|
+
const projNpmConfig = await this._getProjNpmConfigAsync();
|
|
226
|
+
const projName = projNpmConfig.name;
|
|
227
|
+
|
|
228
|
+
await this._addPackageBaseTemplate({
|
|
229
|
+
name: pkgName,
|
|
230
|
+
description: `${opt.description} 클라이언트`,
|
|
231
|
+
useDom: true,
|
|
232
|
+
isModule: true,
|
|
233
|
+
isForAngular: true,
|
|
234
|
+
dependencies: {
|
|
235
|
+
"@angular/common": "^13.2.0",
|
|
236
|
+
"@angular/core": "^13.2.0",
|
|
237
|
+
"@angular/platform-browser": "^13.2.0",
|
|
238
|
+
"@angular/platform-browser-dynamic": "^13.2.0",
|
|
239
|
+
"@fortawesome/angular-fontawesome": "^0.10.2",
|
|
240
|
+
"@fortawesome/fontawesome-svg-core": "^6.1.0",
|
|
241
|
+
"@fortawesome/free-brands-svg-icons": "^6.1.0",
|
|
242
|
+
"@fortawesome/pro-duotone-svg-icons": "^6.1.0",
|
|
243
|
+
"@fortawesome/pro-light-svg-icons": "^6.1.0",
|
|
244
|
+
"@fortawesome/pro-regular-svg-icons": "^6.1.0",
|
|
245
|
+
"@fortawesome/pro-solid-svg-icons": "^6.1.0",
|
|
246
|
+
"@simplysm/sd-angular": "~7.0.0",
|
|
247
|
+
"@simplysm/sd-core-browser": "~7.0.0",
|
|
248
|
+
"@simplysm/sd-core-common": "~7.0.0",
|
|
249
|
+
"rxjs": "^6.6.7",
|
|
250
|
+
"zone.js": "~0.11.4"
|
|
251
|
+
}
|
|
252
|
+
});
|
|
253
|
+
|
|
254
|
+
this._logger.log(`[${pkgName}] 'src/app-icons.ts' 파일 등록`);
|
|
255
|
+
await FsUtil.writeFileAsync(path.resolve(pkgPath, "src/app-icons.ts"), fc_package_appicons());
|
|
256
|
+
|
|
257
|
+
this._logger.log(`[${pkgName}] 'src/AppModule.ts' 파일 등록`);
|
|
258
|
+
await FsUtil.writeFileAsync(path.resolve(pkgPath, "src/AppModule.ts"), fc_package_AppModule());
|
|
259
|
+
|
|
260
|
+
this._logger.log(`[${pkgName}] 'src/AppPage.ts' 파일 등록`);
|
|
261
|
+
await FsUtil.writeFileAsync(path.resolve(pkgPath, "src/AppPage.ts"), fc_package_AppPage());
|
|
262
|
+
|
|
263
|
+
this._logger.log(`[${pkgName}] 'src/index.html' 파일 등록`);
|
|
264
|
+
await FsUtil.writeFileAsync(path.resolve(pkgPath, "src/index.html"), fc_package_index({
|
|
265
|
+
description: opt.description
|
|
266
|
+
}));
|
|
267
|
+
|
|
268
|
+
this._logger.log(`[${pkgName}] 'src/main.ts' 파일 등록`);
|
|
269
|
+
await FsUtil.writeFileAsync(path.resolve(pkgPath, "src/main.ts"), fc_package_client_main());
|
|
270
|
+
|
|
271
|
+
this._logger.log(`[${pkgName}] 'src/manifest.json' 파일 등록`);
|
|
272
|
+
await FsUtil.writeFileAsync(path.resolve(pkgPath, "src/manifest.json"), fc_package_manifest({
|
|
273
|
+
description: projNpmConfig.description,
|
|
274
|
+
author: projNpmConfig.author,
|
|
275
|
+
version: projNpmConfig.version
|
|
276
|
+
}));
|
|
277
|
+
|
|
278
|
+
this._logger.log(`[${pkgName}] 'src/polyfills.ts' 파일 등록`);
|
|
279
|
+
await FsUtil.writeFileAsync(path.resolve(pkgPath, "src/polyfills.ts"), fc_package_polyfills());
|
|
280
|
+
|
|
281
|
+
this._logger.log(`[${pkgName}] 'src/styles.scss' 파일 등록`);
|
|
282
|
+
await FsUtil.writeFileAsync(path.resolve(pkgPath, "src/styles.scss"), fc_package_styles());
|
|
283
|
+
|
|
284
|
+
this._logger.log(`[${pkgName}] 'src/assets' 파일 복사`);
|
|
285
|
+
await FsUtil.copyAsync(
|
|
286
|
+
path.resolve(path.dirname(fileURLToPath(import.meta.url)), "file/assets"),
|
|
287
|
+
path.resolve(pkgPath, "src")
|
|
288
|
+
);
|
|
289
|
+
|
|
290
|
+
await this._addPackageToSimplysmJson({
|
|
291
|
+
name: pkgName,
|
|
292
|
+
type: "client",
|
|
293
|
+
useAutoIndex: false,
|
|
294
|
+
serverName: opt.serverName
|
|
295
|
+
});
|
|
296
|
+
|
|
297
|
+
this._logger.log(`[${projName}] npm install`);
|
|
298
|
+
await SdProcess.spawnAsync("npm install", { cwd: this._rootPath }, true);
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
private async _addPackageBaseTemplate(opt: { name: string; description: string; useDom: boolean; isModule: boolean; isForAngular: boolean; main?: string; types?: string; dependencies: Record<string, string> }): Promise<void> {
|
|
302
|
+
const pkgPath = path.resolve(this._rootPath, "packages", opt.name);
|
|
303
|
+
|
|
304
|
+
this._logger.log(`[${opt.name}] '.eslintrc.cjs' 파일 생성`);
|
|
305
|
+
await FsUtil.writeFileAsync(path.resolve(pkgPath, ".eslintrc.cjs"), fc_package_eslintrc({
|
|
306
|
+
isForAngular: opt.isForAngular
|
|
307
|
+
}));
|
|
308
|
+
|
|
309
|
+
this._logger.log(`[${opt.name}] 'package.json' 파일 생성`);
|
|
310
|
+
await FsUtil.writeFileAsync(path.resolve(pkgPath, "package.json"), fc_package_npmconfig({
|
|
311
|
+
projPath: this._rootPath,
|
|
312
|
+
name: opt.name,
|
|
313
|
+
description: opt.description,
|
|
314
|
+
isModule: opt.isModule,
|
|
315
|
+
main: opt.main,
|
|
316
|
+
types: opt.types,
|
|
317
|
+
dependencies: opt.dependencies
|
|
318
|
+
}));
|
|
319
|
+
|
|
320
|
+
this._logger.log(`[${opt.name}] 'tsconfig.json' 파일 생성`);
|
|
321
|
+
await FsUtil.writeFileAsync(path.resolve(pkgPath, "tsconfig.json"), fc_package_tsconfig({
|
|
322
|
+
isModule: opt.isModule,
|
|
323
|
+
useDom: opt.useDom
|
|
324
|
+
}));
|
|
325
|
+
|
|
326
|
+
this._logger.log(`[${opt.name}] 'src' 디렉토리 생성`);
|
|
327
|
+
await FsUtil.mkdirsAsync(path.resolve(pkgPath, "src"));
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
private async _addPackageToSimplysmJson(opt: { name: string; type: string; useAutoIndex: boolean; serverName?: string }): Promise<void> {
|
|
331
|
+
const config = await FsUtil.readJsonAsync(path.resolve(this._rootPath, "simplysm.json"));
|
|
332
|
+
config.packages = config.packages ?? {};
|
|
333
|
+
config.packages[opt.name] = {
|
|
334
|
+
type: opt.type,
|
|
335
|
+
...opt.useAutoIndex ? { autoIndex: {} } : {},
|
|
336
|
+
...opt.serverName !== undefined ? { server: opt.serverName } : {}
|
|
337
|
+
};
|
|
338
|
+
await FsUtil.writeJsonAsync(path.resolve(this._rootPath, "simplysm.json"), config, { space: 2 });
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
private async _getProjNpmConfigAsync(): Promise<INpmConfig & { description: string; author: string }> {
|
|
342
|
+
const projNpmConfig = await FsUtil.readJsonAsync(path.resolve(this._rootPath, "package.json")) as INpmConfig;
|
|
343
|
+
|
|
344
|
+
if (projNpmConfig.description === undefined) {
|
|
345
|
+
throw new Error("프로젝트 package.json 파일에 description 이 설정되어있지 않습니다.");
|
|
346
|
+
}
|
|
347
|
+
if (projNpmConfig.author === undefined) {
|
|
348
|
+
throw new Error("프로젝트 package.json 파일에 author 가 설정되어있지 않습니다.");
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
return projNpmConfig as any;
|
|
352
|
+
}
|
|
353
|
+
}
|
|
@@ -32,7 +32,8 @@ export class SdCliWorkspace {
|
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
this._logger.debug("패키지 목록 구성...");
|
|
35
|
-
const
|
|
35
|
+
const allPkgs = await this._getPackagesAsync(config);
|
|
36
|
+
const pkgs = allPkgs.filter((pkg) => opt.pkgs.length === 0 || opt.pkgs.includes(path.basename(pkg.rootPath)));
|
|
36
37
|
|
|
37
38
|
this._logger.debug("패키지 이벤트 설정...");
|
|
38
39
|
let changeCount = 0;
|
|
@@ -102,32 +103,6 @@ export class SdCliWorkspace {
|
|
|
102
103
|
if (pkg.config.type === "client") {
|
|
103
104
|
await pkg.watchAsync();
|
|
104
105
|
|
|
105
|
-
/*const pkgMiddleware: NextHandleFunction = (req, res, next) => {
|
|
106
|
-
if (req.method === "GET") {
|
|
107
|
-
const urlObj = url.parse(req.url!, true, false);
|
|
108
|
-
const urlPathChain = decodeURI(urlObj.pathname!.slice(1)).split("/");
|
|
109
|
-
if (urlPathChain[0] === pkg.name.split("/").last()!) {
|
|
110
|
-
let targetFilePath = path.resolve(pkg.rootPath, "dist", ...urlPathChain.slice(1));
|
|
111
|
-
targetFilePath = FsUtil.exists(targetFilePath) && FsUtil.stat(targetFilePath).isDirectory() ? path.resolve(targetFilePath, "index.html") : targetFilePath;
|
|
112
|
-
|
|
113
|
-
if (FsUtil.exists(targetFilePath) && !path.basename(targetFilePath).startsWith(".")) {
|
|
114
|
-
const fileStream = FsUtil.createReadStream(targetFilePath);
|
|
115
|
-
const targetFileSize = FsUtil.lstat(targetFilePath).size;
|
|
116
|
-
|
|
117
|
-
fileStream.on("open", () => {
|
|
118
|
-
res.setHeader("Content-Length", targetFileSize);
|
|
119
|
-
res.setHeader("Content-Type", mime.getType(targetFilePath)!);
|
|
120
|
-
res.writeHead(200);
|
|
121
|
-
});
|
|
122
|
-
fileStream.pipe(res);
|
|
123
|
-
return;
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
next();
|
|
129
|
-
};*/
|
|
130
|
-
|
|
131
106
|
if (typeof pkg.config.server === "string") {
|
|
132
107
|
const serverInfo = this._serverInfoMap.getOrCreate(pkg.config.server, { pathProxy: [], clientInfos: [] });
|
|
133
108
|
|
|
@@ -164,20 +139,6 @@ export class SdCliWorkspace {
|
|
|
164
139
|
platforms: pkg.config.builder ? Object.keys(pkg.config.builder) : ["web"],
|
|
165
140
|
cordovaTargets: pkg.config.builder?.cordova?.target ? Object.keys(pkg.config.builder.cordova.target) : ["browser"]
|
|
166
141
|
});
|
|
167
|
-
|
|
168
|
-
/*const server = new SdServiceServer({
|
|
169
|
-
rootPath: process.cwd(),
|
|
170
|
-
services: [],
|
|
171
|
-
port: pkg.config.server.port
|
|
172
|
-
});
|
|
173
|
-
await server.listenAsync();
|
|
174
|
-
serverInfo.server = server;
|
|
175
|
-
serverInfo.server.devMiddlewares = [pkgMiddleware];
|
|
176
|
-
serverInfo.clientInfos.push({
|
|
177
|
-
pkgKey: pkg.name.split("/").last()!,
|
|
178
|
-
platforms: pkg.config.builder ? Object.keys(pkg.config.builder) : ["web"],
|
|
179
|
-
cordovaTargets: pkg.config.builder?.cordova?.target ? Object.keys(pkg.config.builder.cordova.target) : ["browser"]
|
|
180
|
-
});*/
|
|
181
142
|
}
|
|
182
143
|
}
|
|
183
144
|
}
|
|
@@ -201,6 +162,76 @@ export class SdCliWorkspace {
|
|
|
201
162
|
}
|
|
202
163
|
}
|
|
203
164
|
|
|
165
|
+
public async buildAsync(opt: { confFileRelPath: string; optNames: string[]; pkgs: string[] }): Promise<void> {
|
|
166
|
+
this._logger.debug("프로젝트 설정 가져오기...");
|
|
167
|
+
const config = await SdCliConfigUtil.loadConfigAsync(path.resolve(this._rootPath, opt.confFileRelPath), false, opt.optNames);
|
|
168
|
+
|
|
169
|
+
this._logger.debug("패키지 목록 구성...");
|
|
170
|
+
const allPkgs = await this._getPackagesAsync(config);
|
|
171
|
+
const pkgs = allPkgs.filter((pkg) => opt.pkgs.length === 0 || opt.pkgs.includes(path.basename(pkg.rootPath)));
|
|
172
|
+
|
|
173
|
+
this._logger.debug("프로젝트 및 패키지 버전 설정...");
|
|
174
|
+
await this._upgradeVersionAsync(allPkgs);
|
|
175
|
+
|
|
176
|
+
// 빌드
|
|
177
|
+
await this._buildPkgsAsync(pkgs);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
public async publishAsync(opt: { noBuild: boolean; confFileRelPath: string; optNames: string[]; pkgs: string[] }): Promise<void> {
|
|
181
|
+
this._logger.debug("프로젝트 설정 가져오기...");
|
|
182
|
+
const config = await SdCliConfigUtil.loadConfigAsync(path.resolve(this._rootPath, opt.confFileRelPath), false, opt.optNames);
|
|
183
|
+
|
|
184
|
+
if (opt.noBuild) {
|
|
185
|
+
this._logger.warn("빌드하지 않고, 배포하는것은 상당히 위험합니다.");
|
|
186
|
+
await this._waitSecMessageAsync("프로세스를 중지하려면, 'CTRL+C'를 누르세요.", 5);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
// GIT 사용중일 경우, 커밋되지 않은 수정사항이 있는지 확인
|
|
190
|
+
if (FsUtil.exists(path.resolve(process.cwd(), ".git"))) {
|
|
191
|
+
this._logger.debug("GIT 커밋여부 확인...");
|
|
192
|
+
const gitStatusResult = await SdProcess.spawnAsync("git status");
|
|
193
|
+
if (gitStatusResult.includes("Changes") || gitStatusResult.includes("Untracked")) {
|
|
194
|
+
throw new Error("커밋되지 않은 정보가 있습니다.\n" + gitStatusResult);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
this._logger.debug("패키지 목록 구성...");
|
|
199
|
+
const allPkgs = await this._getPackagesAsync(config);
|
|
200
|
+
const pkgs = allPkgs.filter((pkg) => opt.pkgs.length === 0 || opt.pkgs.includes(path.basename(pkg.rootPath)));
|
|
201
|
+
|
|
202
|
+
this._logger.debug("프로젝트 및 패키지 버전 설정...");
|
|
203
|
+
await this._upgradeVersionAsync(allPkgs);
|
|
204
|
+
|
|
205
|
+
// 빌드
|
|
206
|
+
if (!opt.noBuild) {
|
|
207
|
+
// this._logger.debug("노드패키지 업데이트...");
|
|
208
|
+
// await new SdCliNpm(this._rootPath).updateAsync();
|
|
209
|
+
|
|
210
|
+
this._logger.debug("빌드를 시작합니다...");
|
|
211
|
+
await this._buildPkgsAsync(pkgs);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
// GIT 사용중일경우, 새 버전 커밋 및 TAG 생성
|
|
215
|
+
if (FsUtil.exists(path.resolve(process.cwd(), ".git"))) {
|
|
216
|
+
this._logger.debug("새 버전 커밋 및 TAG 생성...");
|
|
217
|
+
await SdProcess.spawnAsync("git add .");
|
|
218
|
+
await SdProcess.spawnAsync(`git commit -m "v${this._npmConfig.version}"`);
|
|
219
|
+
await SdProcess.spawnAsync(`git tag -a "v${this._npmConfig.version}" -m "v${this._npmConfig.version}"`);
|
|
220
|
+
|
|
221
|
+
this._logger.debug("새 버전 푸쉬...");
|
|
222
|
+
await SdProcess.spawnAsync("git push");
|
|
223
|
+
await SdProcess.spawnAsync("git push --tags");
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
this._logger.debug("배포 시작...");
|
|
227
|
+
await pkgs.parallelAsync(async (pkg) => {
|
|
228
|
+
this._logger.debug(`[${pkg.name}] 배포를 시작합니다...`);
|
|
229
|
+
await pkg.publishAsync();
|
|
230
|
+
this._logger.debug(`[${pkg.name}] 배포가 완료되었습니다.`);
|
|
231
|
+
});
|
|
232
|
+
this._logger.info(`모든 배포가 완료되었습니다. (v${this._npmConfig.version})`);
|
|
233
|
+
}
|
|
234
|
+
|
|
204
235
|
private async _runServerWorkerAsync(filePathOrOpt: string | { port: number }): Promise<{ worker: cp.ChildProcess; url: string }> {
|
|
205
236
|
const workerPath = fileURLToPath(await import.meta.resolve!("../worker/server-worker"));
|
|
206
237
|
return await new Promise<{ worker: cp.ChildProcess; url: string }>((resolve, reject) => {
|
|
@@ -285,17 +316,6 @@ export class SdCliWorkspace {
|
|
|
285
316
|
serverInfo.url = serverWorkerInfo.url;
|
|
286
317
|
await this._reloadServerWorkerPathProxyAsync(serverInfo);
|
|
287
318
|
|
|
288
|
-
/*const serverMainPath = "file:///" + PathUtil.posix(entryFilePath) + "?update=" + Uuid.new().toString().replace(/-/g, "");
|
|
289
|
-
const serverModule = await import(serverMainPath);
|
|
290
|
-
serverInfo.server = serverModule.default as SdServiceServer | undefined;
|
|
291
|
-
if (!serverInfo.server) {
|
|
292
|
-
this._logger.error(`${entryFilePath}(0, 0): 'SdServiceServer'를 'export'해야 합니다.`);
|
|
293
|
-
this._isServerRestarting = false;
|
|
294
|
-
return;
|
|
295
|
-
}
|
|
296
|
-
serverInfo.server.devMiddlewares = serverInfo.middlewares;
|
|
297
|
-
await Wait.until(() => serverInfo.server!.isOpen);*/
|
|
298
|
-
|
|
299
319
|
this._logger.log(`[${pkg.name}] 서버가 시작되었습니다.`);
|
|
300
320
|
}
|
|
301
321
|
catch (err) {
|
|
@@ -305,20 +325,6 @@ export class SdCliWorkspace {
|
|
|
305
325
|
this._isServerRestarting = false;
|
|
306
326
|
}
|
|
307
327
|
|
|
308
|
-
public async buildAsync(opt: { confFileRelPath: string; optNames: string[]; pkgs: string[] }): Promise<void> {
|
|
309
|
-
this._logger.debug("프로젝트 설정 가져오기...");
|
|
310
|
-
const config = await SdCliConfigUtil.loadConfigAsync(path.resolve(this._rootPath, opt.confFileRelPath), false, opt.optNames);
|
|
311
|
-
|
|
312
|
-
this._logger.debug("패키지 목록 구성...");
|
|
313
|
-
const pkgs = await this._getPackagesAsync(config, opt.pkgs);
|
|
314
|
-
|
|
315
|
-
this._logger.debug("프로젝트 및 패키지 버전 설정...");
|
|
316
|
-
await this._upgradeVersionAsync(pkgs);
|
|
317
|
-
|
|
318
|
-
// 빌드
|
|
319
|
-
await this._buildPkgsAsync(pkgs);
|
|
320
|
-
}
|
|
321
|
-
|
|
322
328
|
private async _buildPkgsAsync(pkgs: SdCliPackage[]): Promise<void> {
|
|
323
329
|
this._logger.debug("빌드를 시작합니다...");
|
|
324
330
|
const pkgNames = pkgs.map((item) => item.name);
|
|
@@ -349,60 +355,6 @@ export class SdCliWorkspace {
|
|
|
349
355
|
}
|
|
350
356
|
}
|
|
351
357
|
|
|
352
|
-
public async publishAsync(opt: { noBuild: boolean; confFileRelPath: string; optNames: string[]; pkgs: string[] }): Promise<void> {
|
|
353
|
-
this._logger.debug("프로젝트 설정 가져오기...");
|
|
354
|
-
const config = await SdCliConfigUtil.loadConfigAsync(path.resolve(this._rootPath, opt.confFileRelPath), false, opt.optNames);
|
|
355
|
-
|
|
356
|
-
if (opt.noBuild) {
|
|
357
|
-
this._logger.warn("빌드하지 않고, 배포하는것은 상당히 위험합니다.");
|
|
358
|
-
await this._waitSecMessageAsync("프로세스를 중지하려면, 'CTRL+C'를 누르세요.", 5);
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
// GIT 사용중일 경우, 커밋되지 않은 수정사항이 있는지 확인
|
|
362
|
-
if (FsUtil.exists(path.resolve(process.cwd(), ".git"))) {
|
|
363
|
-
this._logger.debug("GIT 커밋여부 확인...");
|
|
364
|
-
const gitStatusResult = await SdProcess.spawnAsync("git status");
|
|
365
|
-
if (gitStatusResult.includes("Changes") || gitStatusResult.includes("Untracked")) {
|
|
366
|
-
throw new Error("커밋되지 않은 정보가 있습니다.\n" + gitStatusResult);
|
|
367
|
-
}
|
|
368
|
-
}
|
|
369
|
-
|
|
370
|
-
this._logger.debug("패키지 목록 구성...");
|
|
371
|
-
const pkgs = await this._getPackagesAsync(config, opt.pkgs);
|
|
372
|
-
|
|
373
|
-
this._logger.debug("프로젝트 및 패키지 버전 설정...");
|
|
374
|
-
await this._upgradeVersionAsync(pkgs);
|
|
375
|
-
|
|
376
|
-
// 빌드
|
|
377
|
-
if (!opt.noBuild) {
|
|
378
|
-
// this._logger.debug("노드패키지 업데이트...");
|
|
379
|
-
// await new SdCliNpm(this._rootPath).updateAsync();
|
|
380
|
-
|
|
381
|
-
this._logger.debug("빌드를 시작합니다...");
|
|
382
|
-
await this._buildPkgsAsync(pkgs);
|
|
383
|
-
}
|
|
384
|
-
|
|
385
|
-
// GIT 사용중일경우, 새 버전 커밋 및 TAG 생성
|
|
386
|
-
if (FsUtil.exists(path.resolve(process.cwd(), ".git"))) {
|
|
387
|
-
this._logger.debug("새 버전 커밋 및 TAG 생성...");
|
|
388
|
-
await SdProcess.spawnAsync("git add .");
|
|
389
|
-
await SdProcess.spawnAsync(`git commit -m "v${this._npmConfig.version}"`);
|
|
390
|
-
await SdProcess.spawnAsync(`git tag -a "v${this._npmConfig.version}" -m "v${this._npmConfig.version}"`);
|
|
391
|
-
|
|
392
|
-
this._logger.debug("새 버전 푸쉬...");
|
|
393
|
-
await SdProcess.spawnAsync("git push");
|
|
394
|
-
await SdProcess.spawnAsync("git push --tags");
|
|
395
|
-
}
|
|
396
|
-
|
|
397
|
-
this._logger.debug("배포 시작...");
|
|
398
|
-
await pkgs.parallelAsync(async (pkg) => {
|
|
399
|
-
this._logger.debug(`[${pkg.name}] 배포를 시작합니다...`);
|
|
400
|
-
await pkg.publishAsync();
|
|
401
|
-
this._logger.debug(`[${pkg.name}] 배포가 완료되었습니다.`);
|
|
402
|
-
});
|
|
403
|
-
this._logger.info(`모든 배포가 완료되었습니다. (v${this._npmConfig.version})`);
|
|
404
|
-
}
|
|
405
|
-
|
|
406
358
|
private async _upgradeVersionAsync(pkgs: SdCliPackage[]): Promise<void> {
|
|
407
359
|
// 작업공간 package.json 버전 설정
|
|
408
360
|
const newVersion = semver.inc(this._npmConfig.version, "patch")!;
|
|
@@ -445,14 +397,14 @@ export class SdCliWorkspace {
|
|
|
445
397
|
process.stdout.clearLine(0);
|
|
446
398
|
}
|
|
447
399
|
|
|
448
|
-
private async _getPackagesAsync(conf: ISdCliConfig
|
|
400
|
+
private async _getPackagesAsync(conf: ISdCliConfig): Promise<SdCliPackage[]> {
|
|
449
401
|
const pkgRootPaths = await this._npmConfig.workspaces?.mapManyAsync(async (item) => await FsUtil.globAsync(item));
|
|
450
402
|
if (!pkgRootPaths) {
|
|
451
403
|
throw new Error("최상위 'package.json'에서 'workspaces'를 찾을 수 없습니다.");
|
|
452
404
|
}
|
|
453
405
|
|
|
454
406
|
return pkgRootPaths.map((pkgRootPath) => {
|
|
455
|
-
if (pkgs.length > 0 && !pkgs.includes(path.basename(pkgRootPath))) return undefined;
|
|
407
|
+
// if (pkgs.length > 0 && !pkgs.includes(path.basename(pkgRootPath))) return undefined;
|
|
456
408
|
const pkgConfig = conf.packages[path.basename(pkgRootPath)];
|
|
457
409
|
if (!pkgConfig) return undefined;
|
|
458
410
|
return new SdCliPackage(this._rootPath, pkgRootPath, pkgConfig);
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|