@simplysm/sd-cli 7.0.247 → 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 +33 -35
- package/dist/builder/SdCliServerBuilder.d.ts +1 -0
- package/dist/builder/SdCliServerBuilder.mjs +58 -22
- package/dist/builder/SdCliTsLibBuilder.mjs +18 -12
- package/dist/commons.d.ts +9 -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 -3
- package/dist/entry-points/SdCliWorkspace.mjs +147 -120
- 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/dist/worker/server-worker.d.ts +1 -0
- package/dist/worker/server-worker.mjs +67 -0
- 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 +36 -36
- package/src/builder/SdCliJsLibBuilder.ts +70 -70
- package/src/builder/SdCliServerBuilder.ts +58 -20
- package/src/builder/SdCliTsLibBuilder.ts +450 -445
- package/src/commons.ts +7 -1
- package/src/entry-points/SdCliProjectGenerator.ts +353 -0
- package/src/entry-points/SdCliWorkspace.ts +171 -137
- 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/worker/server-worker.ts +72 -0
- package/tsconfig-build.json +2 -1
- package/tsconfig.json +2 -1
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[]>;
|
|
@@ -65,6 +67,7 @@ export interface ISdCliServerPackageConfig {
|
|
|
65
67
|
env?: Record<string, string>;
|
|
66
68
|
configs?: Record<string, any>;
|
|
67
69
|
pm2?: Record<string, any> | boolean;
|
|
70
|
+
iis?: boolean | { serverExeFilePath?: string };
|
|
68
71
|
externalNodeModules?: string[];
|
|
69
72
|
publish?: TSdCliPublishConfig;
|
|
70
73
|
}
|
|
@@ -108,9 +111,11 @@ export interface ISdCliGithubPublishConfig {
|
|
|
108
111
|
}
|
|
109
112
|
|
|
110
113
|
export interface ISdCliClientBuilderWebConfig {
|
|
114
|
+
env?: Record<string, string>;
|
|
111
115
|
}
|
|
112
116
|
|
|
113
117
|
export interface ISdCliClientBuilderCordovaConfig {
|
|
118
|
+
env?: Record<string, string>;
|
|
114
119
|
appId: string;
|
|
115
120
|
appName: string;
|
|
116
121
|
plugins?: string[];
|
|
@@ -135,4 +140,5 @@ export interface ISdCliClientBuilderElectronConfig {
|
|
|
135
140
|
appId: string;
|
|
136
141
|
icon?: string;
|
|
137
142
|
installerIcon?: string;
|
|
143
|
+
env?: Record<string, string>;
|
|
138
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
|
+
}
|