@simplysm/sd-cli 7.0.305 → 7.1.11
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 +24 -18
- package/dist/bin/sd-cli.d.ts +1 -1
- package/dist/bin/sd-cli.mjs +2 -8
- package/dist/builder/SdCliClientBuilder.d.ts +1 -1
- package/dist/builder/SdCliClientBuilder.mjs +75 -23
- package/dist/builder/SdCliServerBuilder.d.ts +1 -1
- package/dist/builder/SdCliServerBuilder.mjs +8 -7
- package/dist/builder/SdCliTsLibBuilder.mjs +2 -2
- package/dist/commons.d.ts +2 -1
- package/dist/entry-points/SdCliPrepare.mjs +53 -22
- package/dist/entry-points/SdCliProjectGenerator.mjs +37 -27
- package/dist/entry-points/file/base/fc_package_npmconfig.mjs +2 -1
- package/dist/entry-points/file/project/fc_project_gitignore.mjs +12 -2
- package/dist/entry-points/file/project/fc_project_npmconfig.mjs +13 -11
- package/dist/entry-points/file/project/fc_project_readme.mjs +1 -1
- package/dist/entry-points/file/project/fc_project_tsconfig.mjs +2 -2
- package/dist/entry-points/file/project/fc_project_yarnrc.d.ts +1 -0
- package/dist/entry-points/file/project/fc_project_yarnrc.mjs +15 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +2 -2
- package/dist/ng-tools/SdCliNgModuleGenerator.d.ts +2 -1
- package/dist/ng-tools/SdCliNgModuleGenerator.mjs +41 -21
- package/dist/ng-tools/babel/SdCliBbFileMetadata.mjs +17 -5
- package/dist/ng-tools/babel/SdCliBbRootMetadata.mjs +19 -7
- package/dist/ng-tools/babel/SdCliBbUtil.d.ts +2 -2
- package/dist/ng-tools/babel/SdCliBbUtil.mjs +3 -3
- package/dist/ng-tools/babel/TSdCliBbTypeMetadata.d.ts +13 -2
- package/dist/ng-tools/babel/TSdCliBbTypeMetadata.mjs +25 -1
- package/dist/packages/SdCliPackage.mjs +2 -2
- package/dist/utils/SdCliBuildResultUtil.mjs +3 -3
- package/docs/client-router.md +1 -1
- package/docs/client-sw.md +1 -1
- package/docs/conf-orm.md +1 -1
- package/docs/lib-local-update.md +5 -5
- package/package.json +46 -42
- package/src/bin/sd-cli.ts +1 -11
- package/src/builder/SdCliClientBuilder.ts +81 -22
- package/src/builder/SdCliServerBuilder.ts +7 -6
- package/src/builder/SdCliTsLibBuilder.ts +1 -1
- package/src/commons.ts +2 -1
- package/src/entry-points/SdCliPrepare.ts +52 -21
- package/src/entry-points/SdCliProjectGenerator.ts +40 -27
- package/src/entry-points/file/base/fc_package_npmconfig.ts +1 -0
- package/src/entry-points/file/project/fc_project_gitignore.ts +11 -1
- package/src/entry-points/file/project/fc_project_npmconfig.ts +12 -10
- package/src/entry-points/file/project/fc_project_readme.ts +1 -1
- package/src/entry-points/file/project/fc_project_tsconfig.ts +1 -1
- package/src/entry-points/file/project/fc_project_yarnrc.ts +14 -0
- package/src/index.ts +1 -1
- package/src/ng-tools/SdCliNgModuleGenerator.ts +53 -20
- package/src/ng-tools/babel/SdCliBbFileMetadata.ts +16 -2
- package/src/ng-tools/babel/SdCliBbRootMetadata.ts +22 -6
- package/src/ng-tools/babel/SdCliBbUtil.ts +4 -4
- package/src/ng-tools/babel/TSdCliBbTypeMetadata.ts +36 -1
- package/src/packages/SdCliPackage.ts +1 -1
- package/src/utils/SdCliBuildResultUtil.ts +3 -2
- package/.eslintrc.cjs +0 -21
- package/dist/entry-points/SdCliNpm.d.ts +0 -6
- package/dist/entry-points/SdCliNpm.mjs +0 -24
- package/src/entry-points/SdCliNpm.ts +0 -28
- package/tsconfig-build.json +0 -16
- package/tsconfig.json +0 -39
|
@@ -15,6 +15,7 @@ import CopyWebpackPlugin from "copy-webpack-plugin";
|
|
|
15
15
|
import { LicenseWebpackPlugin } from "license-webpack-plugin";
|
|
16
16
|
import { SdCliNpmConfigUtil } from "../utils/SdCliNpmConfigUtil";
|
|
17
17
|
import { createHash } from "crypto";
|
|
18
|
+
import { fileURLToPath } from "url";
|
|
18
19
|
import LintResult = ESLint.LintResult;
|
|
19
20
|
|
|
20
21
|
export class SdCliServerBuilder extends EventEmitter {
|
|
@@ -44,7 +45,7 @@ export class SdCliServerBuilder extends EventEmitter {
|
|
|
44
45
|
}
|
|
45
46
|
|
|
46
47
|
private async _checkCacheAsync(watch: boolean): Promise<void> {
|
|
47
|
-
const projPkgLockContent = await FsUtil.readFileAsync(path.resolve(this._projRootPath, "
|
|
48
|
+
const projPkgLockContent = await FsUtil.readFileAsync(path.resolve(this._projRootPath, "yarn.lock"));
|
|
48
49
|
|
|
49
50
|
// const cachePath = path.resolve(cacheBasePath, pkgVersion);
|
|
50
51
|
|
|
@@ -77,7 +78,7 @@ export class SdCliServerBuilder extends EventEmitter {
|
|
|
77
78
|
|
|
78
79
|
// 빌드 준비
|
|
79
80
|
const extModules = this._getExternalModules();
|
|
80
|
-
const webpackConfig = this.
|
|
81
|
+
const webpackConfig = await this._getWebpackConfigAsync(true, extModules);
|
|
81
82
|
const compiler = webpack(webpackConfig);
|
|
82
83
|
await new Promise<void>((resolve, reject) => {
|
|
83
84
|
compiler.hooks.watchRun.tapAsync(this.constructor.name, (args, callback) => {
|
|
@@ -119,7 +120,7 @@ export class SdCliServerBuilder extends EventEmitter {
|
|
|
119
120
|
// 빌드
|
|
120
121
|
this._logger.debug("Webpack 빌드 수행...");
|
|
121
122
|
const extModules = this._getExternalModules();
|
|
122
|
-
const webpackConfig = this.
|
|
123
|
+
const webpackConfig = await this._getWebpackConfigAsync(false, extModules);
|
|
123
124
|
const compiler = webpack(webpackConfig);
|
|
124
125
|
const buildResults = await new Promise<ISdCliPackageBuildResult[]>((resolve, reject) => {
|
|
125
126
|
compiler.run((err, stats) => {
|
|
@@ -254,7 +255,7 @@ export class SdCliServerBuilder extends EventEmitter {
|
|
|
254
255
|
].map((p) => path.dirname(p));
|
|
255
256
|
}
|
|
256
257
|
|
|
257
|
-
private
|
|
258
|
+
private async _getWebpackConfigAsync(watch: boolean, extModules: { name: string; exists: boolean }[]): Promise<webpack.Configuration> {
|
|
258
259
|
const projNpmConfig = this._getNpmConfig(this._projRootPath)!;
|
|
259
260
|
const projName = projNpmConfig.name;
|
|
260
261
|
|
|
@@ -367,7 +368,7 @@ export class SdCliServerBuilder extends EventEmitter {
|
|
|
367
368
|
{
|
|
368
369
|
test: /\.[cm]?jsx?$/,
|
|
369
370
|
enforce: "pre" as const,
|
|
370
|
-
loader: "source-map-loader",
|
|
371
|
+
loader: fileURLToPath(await import.meta.resolve!("source-map-loader")),
|
|
371
372
|
options: {
|
|
372
373
|
filterSourceMappingUrl: (mapUri: string, resourcePath: string) => {
|
|
373
374
|
const projRegex = new RegExp(`node_modules[\\\\/]@${projName}[\\\\/]`);
|
|
@@ -381,7 +382,7 @@ export class SdCliServerBuilder extends EventEmitter {
|
|
|
381
382
|
{
|
|
382
383
|
test: /\.[cm]?tsx?$/,
|
|
383
384
|
exclude: /node_modules/,
|
|
384
|
-
loader: "ts-loader",
|
|
385
|
+
loader: fileURLToPath(await import.meta.resolve!("ts-loader")),
|
|
385
386
|
options: {
|
|
386
387
|
configFile: this._tsconfigFilePath,
|
|
387
388
|
errorFormatter: (msg: ErrorInfo) => {
|
|
@@ -52,7 +52,7 @@ export class SdCliTsLibBuilder extends EventEmitter {
|
|
|
52
52
|
this._logger = Logger.get(["simplysm", "sd-cli", this.constructor.name, npmConfig.name]);
|
|
53
53
|
|
|
54
54
|
// isAngular
|
|
55
|
-
this._isAngular =
|
|
55
|
+
this._isAngular = !!this._config.angular;
|
|
56
56
|
this._hasAngularRoute = SdCliNpmConfigUtil.getDependencies(npmConfig).defaults.includes("@angular/router");
|
|
57
57
|
|
|
58
58
|
// tsconfig
|
package/src/commons.ts
CHANGED
|
@@ -56,6 +56,7 @@ export type TSdCliPackageConfig = ISdCliLibPackageConfig | ISdCliServerPackageCo
|
|
|
56
56
|
|
|
57
57
|
export interface ISdCliLibPackageConfig {
|
|
58
58
|
type: "library";
|
|
59
|
+
angular?: boolean;
|
|
59
60
|
autoIndex?: {
|
|
60
61
|
polyfills?: string[];
|
|
61
62
|
};
|
|
@@ -74,7 +75,7 @@ export interface ISdCliServerPackageConfig {
|
|
|
74
75
|
|
|
75
76
|
export interface ISdCliClientPackageConfig {
|
|
76
77
|
type: "client";
|
|
77
|
-
moduleFederation?:
|
|
78
|
+
moduleFederation?: "host" | "remote";
|
|
78
79
|
builder?: {
|
|
79
80
|
web?: ISdCliClientBuilderWebConfig;
|
|
80
81
|
cordova?: ISdCliClientBuilderCordovaConfig;
|
|
@@ -24,30 +24,61 @@ export class SdCliPrepare {
|
|
|
24
24
|
currentNode = saveCurrentNode;
|
|
25
25
|
}
|
|
26
26
|
}`, `
|
|
27
|
+
|
|
27
28
|
function checkSourceElement(node) {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
29
|
+
if (node) {
|
|
30
|
+
const prevUsage = process.cpuUsage();
|
|
31
|
+
|
|
32
|
+
var saveCurrentNode = currentNode;
|
|
33
|
+
currentNode = node;
|
|
34
|
+
instantiationCount = 0;
|
|
35
|
+
checkSourceElementWorker(node);
|
|
36
|
+
currentNode = saveCurrentNode;
|
|
37
|
+
|
|
38
|
+
const usage = process.cpuUsage(prevUsage);
|
|
39
|
+
const usageMs = Math.round((usage.user + usage.system) / 1000);
|
|
40
|
+
node.parent.childrenUsages = [...node.parent.childrenUsages ?? [], {
|
|
41
|
+
node,
|
|
42
|
+
usageMs,
|
|
43
|
+
childrenUsages: node.childrenUsages
|
|
44
|
+
}];
|
|
45
|
+
if (node.hasChildPerformanceWarning) {
|
|
46
|
+
node.parent.hasChildPerformanceWarning = true;
|
|
47
|
+
}
|
|
48
|
+
else if (usageMs > 1000 && node.kind !== 253) {
|
|
49
|
+
const sf = ts.getSourceFileOfNode(node);
|
|
50
|
+
|
|
51
|
+
const fn = (children, depth) => {
|
|
52
|
+
let result = "";
|
|
53
|
+
|
|
54
|
+
const largeChildren = children
|
|
55
|
+
.filter((item) => item.usageMs > 50)
|
|
56
|
+
.sort((p, n) => p.usageMs > n.usageMs ? -1 : p.usageMs < n.usageMs ? 1 : 0);
|
|
57
|
+
for (const child of largeChildren) {
|
|
58
|
+
const pos = sf.getLineAndCharacterOfPosition(child.node.getStart());
|
|
59
|
+
for(let i = 0 ; i < depth; i++){
|
|
60
|
+
result += " ";
|
|
61
|
+
}
|
|
62
|
+
result += sf.fileName.replace(/\\//g, "\\\\") + "(" + (pos.line + 1) + ", " + (pos.character + 1) + "): " + child.usageMs + "ms/cpu\\n";
|
|
63
|
+
|
|
64
|
+
result += fn(child.childrenUsages ?? [], depth + 1);
|
|
49
65
|
}
|
|
66
|
+
|
|
67
|
+
return result;
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
const tree = fn(node.childrenUsages ?? [], 1);
|
|
71
|
+
|
|
72
|
+
error(node, {
|
|
73
|
+
code: 9000,
|
|
74
|
+
category: ts.DiagnosticCategory.Warning,
|
|
75
|
+
key: "simplysm_check_source_element_performance_slow",
|
|
76
|
+
message: ("소스코드 타입분석에 너무 오랜 시간이 소요됩니다. [" + usageMs + "ms/cpu]\\n" + tree).trim()
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
node.parent.hasChildPerformanceWarning = true;
|
|
50
80
|
}
|
|
81
|
+
}
|
|
51
82
|
}`);
|
|
52
83
|
await FsUtil.writeFileAsync(filePath, modifiedFileContent);
|
|
53
84
|
return modifiedFileContent.includes("const prevUsage = process.cpuUsage();");
|
|
@@ -26,6 +26,7 @@ import { fc_package_polyfills } from "./file/client/fc_package_polyfills";
|
|
|
26
26
|
import { fc_package_styles } from "./file/client/fc_package_styles";
|
|
27
27
|
import { ISdAutoIndexConfig } from "../build-tool/SdCliIndexFileGenerator";
|
|
28
28
|
import { fc_package_Page } from "./file/client/fc_package_Page";
|
|
29
|
+
import { fc_project_yarnrc } from "./file/project/fc_project_yarnrc";
|
|
29
30
|
|
|
30
31
|
export class SdCliProjectGenerator {
|
|
31
32
|
private readonly _logger = Logger.get(["simplysm", "sd-cli", this.constructor.name]);
|
|
@@ -34,8 +35,8 @@ export class SdCliProjectGenerator {
|
|
|
34
35
|
}
|
|
35
36
|
|
|
36
37
|
public async initAsync(opt: { name?: string; description: string; author: string; gitUrl: string }): Promise<void> {
|
|
37
|
-
if ((await FsUtil.readdirAsync(this._rootPath)).filter((item) => ![".idea", "package.json", "
|
|
38
|
-
throw new Error("빈 디렉토리가 아닙니다. (
|
|
38
|
+
if ((await FsUtil.readdirAsync(this._rootPath)).filter((item) => ![".idea", "yarn.lock", "package.json", ".yarn", ".yarnrc.yml", "node_modules"].includes(path.basename(item))).length > 0) {
|
|
39
|
+
throw new Error("빈 디렉토리가 아닙니다. (.idea, yarn.lock, package.json, .yarn, .yarnrc.yml, node_modules 외의 파일/폴더가 존재하는 경우, 초기화할 수 없습니다.)");
|
|
39
40
|
}
|
|
40
41
|
|
|
41
42
|
const projName = opt.name ?? path.basename(this._rootPath);
|
|
@@ -52,6 +53,9 @@ export class SdCliProjectGenerator {
|
|
|
52
53
|
this._logger.log(`[${projName}] '.gitignore' 파일 생성`);
|
|
53
54
|
await FsUtil.writeFileAsync(path.resolve(this._rootPath, ".gitignore"), fc_project_gitignore());
|
|
54
55
|
|
|
56
|
+
this._logger.log(`[${projName}] '.yarnrc.yml' 파일 생성`);
|
|
57
|
+
await FsUtil.writeFileAsync(path.resolve(this._rootPath, ".yarnrc.yml"), fc_project_yarnrc());
|
|
58
|
+
|
|
55
59
|
this._logger.log(`[${projName}] 'package.json' 파일 생성`);
|
|
56
60
|
let cliVersion: string | undefined;
|
|
57
61
|
if (FsUtil.exists(path.resolve(this._rootPath, "package.json"))) {
|
|
@@ -77,11 +81,17 @@ export class SdCliProjectGenerator {
|
|
|
77
81
|
this._logger.log(`[${projName}] 'tsconfig.json' 파일 생성`);
|
|
78
82
|
await FsUtil.writeFileAsync(path.resolve(this._rootPath, "tsconfig.json"), fc_project_tsconfig());
|
|
79
83
|
|
|
84
|
+
this._logger.log(`[${projName}] 'yarn.lock' 파일 생성`);
|
|
85
|
+
await FsUtil.writeFileAsync(path.resolve(this._rootPath, "yarn.lock"), "");
|
|
86
|
+
|
|
80
87
|
this._logger.log(`[${projName}] 'packages' 디렉토리 생성`);
|
|
81
88
|
await FsUtil.mkdirsAsync(path.resolve(this._rootPath, "packages"));
|
|
82
89
|
|
|
83
|
-
this._logger.log(`[${projName}]
|
|
84
|
-
await SdProcess.spawnAsync("
|
|
90
|
+
this._logger.log(`[${projName}] yarn plugin import interactive-tools`);
|
|
91
|
+
await SdProcess.spawnAsync("yarn plugin import interactive-tools", { cwd: this._rootPath }, true);
|
|
92
|
+
|
|
93
|
+
this._logger.log(`[${projName}] yarn install`);
|
|
94
|
+
await SdProcess.spawnAsync("yarn install", { cwd: this._rootPath }, true);
|
|
85
95
|
}
|
|
86
96
|
|
|
87
97
|
public async addTsLibAsync(opt: { name: string; description: string; useDom: boolean; isForAngular: boolean }): Promise<void> {
|
|
@@ -105,6 +115,7 @@ export class SdCliProjectGenerator {
|
|
|
105
115
|
await this._addPackageToSimplysmJson({
|
|
106
116
|
name: opt.name,
|
|
107
117
|
type: "library",
|
|
118
|
+
...opt.isForAngular ? { angular: true } : {},
|
|
108
119
|
autoIndex: {
|
|
109
120
|
...opt.isForAngular ? {
|
|
110
121
|
polyfills: [
|
|
@@ -115,8 +126,8 @@ export class SdCliProjectGenerator {
|
|
|
115
126
|
},
|
|
116
127
|
});
|
|
117
128
|
|
|
118
|
-
this._logger.log(`[${projName}]
|
|
119
|
-
await SdProcess.spawnAsync("
|
|
129
|
+
this._logger.log(`[${projName}] yarn install`);
|
|
130
|
+
await SdProcess.spawnAsync("yarn install", { cwd: this._rootPath }, true);
|
|
120
131
|
}
|
|
121
132
|
|
|
122
133
|
public async addDbLibAsync(opt: { name: string }): Promise<void> {
|
|
@@ -134,8 +145,8 @@ export class SdCliProjectGenerator {
|
|
|
134
145
|
types: "dist/index.d.ts",
|
|
135
146
|
main: "dist/index.cjs",
|
|
136
147
|
dependencies: {
|
|
137
|
-
"@simplysm/sd-core-common": "~7.
|
|
138
|
-
"@simplysm/sd-orm-common": "~7.
|
|
148
|
+
"@simplysm/sd-core-common": "~7.1.0",
|
|
149
|
+
"@simplysm/sd-orm-common": "~7.1.0"
|
|
139
150
|
},
|
|
140
151
|
tsconfigOptions: {}
|
|
141
152
|
});
|
|
@@ -155,8 +166,8 @@ export class SdCliProjectGenerator {
|
|
|
155
166
|
autoIndex: {}
|
|
156
167
|
});
|
|
157
168
|
|
|
158
|
-
this._logger.log(`[${projName}]
|
|
159
|
-
await SdProcess.spawnAsync("
|
|
169
|
+
this._logger.log(`[${projName}] yarn install`);
|
|
170
|
+
await SdProcess.spawnAsync("yarn install", { cwd: this._rootPath }, true);
|
|
160
171
|
}
|
|
161
172
|
|
|
162
173
|
public async addDbLibModelAsync(opt: { dbPkgName: string; category: string; name: string; description: string }): Promise<void> {
|
|
@@ -214,10 +225,10 @@ export class SdCliProjectGenerator {
|
|
|
214
225
|
isForAngular: false,
|
|
215
226
|
main: "dist/main.js",
|
|
216
227
|
dependencies: {
|
|
217
|
-
"@simplysm/sd-core-common": "~7.
|
|
218
|
-
"@simplysm/sd-core-node": "~7.
|
|
219
|
-
"@simplysm/sd-service-common": "~7.
|
|
220
|
-
"@simplysm/sd-service-server": "~7.
|
|
228
|
+
"@simplysm/sd-core-common": "~7.1.0",
|
|
229
|
+
"@simplysm/sd-core-node": "~7.1.0",
|
|
230
|
+
"@simplysm/sd-service-common": "~7.1.0",
|
|
231
|
+
"@simplysm/sd-service-server": "~7.1.0"
|
|
221
232
|
},
|
|
222
233
|
tsconfigOptions: {}
|
|
223
234
|
});
|
|
@@ -235,8 +246,8 @@ export class SdCliProjectGenerator {
|
|
|
235
246
|
type: "server"
|
|
236
247
|
});
|
|
237
248
|
|
|
238
|
-
this._logger.log(`[${projName}]
|
|
239
|
-
await SdProcess.spawnAsync("
|
|
249
|
+
this._logger.log(`[${projName}] yarn install`);
|
|
250
|
+
await SdProcess.spawnAsync("yarn install", { cwd: this._rootPath }, true);
|
|
240
251
|
}
|
|
241
252
|
|
|
242
253
|
public async addClientAsync(opt: { name: string; description: string; serverName: string }): Promise<void> {
|
|
@@ -253,8 +264,9 @@ export class SdCliProjectGenerator {
|
|
|
253
264
|
isModule: true,
|
|
254
265
|
isForAngular: true,
|
|
255
266
|
dependencies: {
|
|
256
|
-
"@angular/platform-browser": "^
|
|
257
|
-
"@angular/platform-browser-dynamic": "^
|
|
267
|
+
"@angular/platform-browser": "^14.1.1",
|
|
268
|
+
"@angular/platform-browser-dynamic": "^14.1.1",
|
|
269
|
+
"@angular/compiler": "^14.1.1"
|
|
258
270
|
},
|
|
259
271
|
tsconfigOptions: {
|
|
260
272
|
angularCompilerOptions: {
|
|
@@ -307,8 +319,8 @@ export class SdCliProjectGenerator {
|
|
|
307
319
|
serverName: opt.serverName
|
|
308
320
|
});
|
|
309
321
|
|
|
310
|
-
this._logger.log(`[${projName}]
|
|
311
|
-
await SdProcess.spawnAsync("
|
|
322
|
+
this._logger.log(`[${projName}] yarn install`);
|
|
323
|
+
await SdProcess.spawnAsync("yarn install", { cwd: this._rootPath }, true);
|
|
312
324
|
}
|
|
313
325
|
|
|
314
326
|
public async addPageAsync(opt: { pkgName: string; category?: string; name: string; isRouteParent: boolean }): Promise<void> {
|
|
@@ -348,12 +360,12 @@ export class SdCliProjectGenerator {
|
|
|
348
360
|
dependencies: {
|
|
349
361
|
...opt.dependencies,
|
|
350
362
|
...opt.isForAngular ? {
|
|
351
|
-
"@angular/common": "^
|
|
352
|
-
"@angular/core": "^
|
|
353
|
-
"@simplysm/sd-angular": "~7.
|
|
354
|
-
"@simplysm/sd-core-common": "~7.
|
|
355
|
-
"@simplysm/sd-core-browser": "~7.
|
|
356
|
-
"rxjs": "^
|
|
363
|
+
"@angular/common": "^14.1.1",
|
|
364
|
+
"@angular/core": "^14.1.1",
|
|
365
|
+
"@simplysm/sd-angular": "~7.1.0",
|
|
366
|
+
"@simplysm/sd-core-common": "~7.1.0",
|
|
367
|
+
"@simplysm/sd-core-browser": "~7.1.0",
|
|
368
|
+
"rxjs": "^7.5.6",
|
|
357
369
|
"zone.js": "~0.11.4"
|
|
358
370
|
} : {}
|
|
359
371
|
}
|
|
@@ -370,12 +382,13 @@ export class SdCliProjectGenerator {
|
|
|
370
382
|
await FsUtil.mkdirsAsync(path.resolve(pkgPath, "src"));
|
|
371
383
|
}
|
|
372
384
|
|
|
373
|
-
private async _addPackageToSimplysmJson(opt: { name: string; type: string; autoIndex?: ISdAutoIndexConfig; serverName?: string }): Promise<void> {
|
|
385
|
+
private async _addPackageToSimplysmJson(opt: { name: string; type: string; angular?: boolean; autoIndex?: ISdAutoIndexConfig; serverName?: string }): Promise<void> {
|
|
374
386
|
const config = await FsUtil.readJsonAsync(path.resolve(this._rootPath, "simplysm.json"));
|
|
375
387
|
config.packages = config.packages ?? {};
|
|
376
388
|
config.packages[opt.name] = {
|
|
377
389
|
type: opt.type,
|
|
378
390
|
...opt.autoIndex ? { autoIndex: opt.autoIndex } : {},
|
|
391
|
+
...opt.angular ? { angular: true } : {},
|
|
379
392
|
...opt.serverName !== undefined ? { server: opt.serverName } : {}
|
|
380
393
|
};
|
|
381
394
|
await FsUtil.writeJsonAsync(path.resolve(this._rootPath, "simplysm.json"), config, { space: 2 });
|
|
@@ -2,6 +2,16 @@ export const fc_project_gitignore = (): string => /* language=gitignore */ `
|
|
|
2
2
|
|
|
3
3
|
.idea/**/workspace.xml
|
|
4
4
|
.idea/shelf
|
|
5
|
+
|
|
6
|
+
.yarn/*
|
|
7
|
+
!.yarn/patches
|
|
8
|
+
!.yarn/plugins
|
|
9
|
+
!.yarn/releases
|
|
10
|
+
!.yarn/sdks
|
|
11
|
+
!.yarn/versions
|
|
12
|
+
!.yarn/cache
|
|
13
|
+
#.pnp.*
|
|
14
|
+
|
|
5
15
|
node_modules
|
|
6
16
|
tsconfig-build.json
|
|
7
17
|
dist
|
|
@@ -10,7 +20,7 @@ dist
|
|
|
10
20
|
_logs
|
|
11
21
|
_modules
|
|
12
22
|
_routes.ts
|
|
13
|
-
|
|
23
|
+
~$*
|
|
14
24
|
.*/
|
|
15
25
|
|
|
16
26
|
`.trim();
|
|
@@ -10,25 +10,27 @@ export const fc_project_npmconfig = (opt: { name: string; description: string; a
|
|
|
10
10
|
type: "module",
|
|
11
11
|
license: "UNLICENSED",
|
|
12
12
|
private: true,
|
|
13
|
+
packageManager: "yarn@3.2.2",
|
|
13
14
|
engines: {
|
|
14
15
|
node: "^16"
|
|
15
16
|
},
|
|
16
17
|
workspaces: [
|
|
17
|
-
"packages/*"
|
|
18
|
+
"packages/*",
|
|
19
|
+
"test"
|
|
18
20
|
],
|
|
19
21
|
scripts: {
|
|
20
|
-
"watch": "sd-cli watch",
|
|
21
|
-
"build": "sd-cli build",
|
|
22
|
-
"publish": "sd-cli publish",
|
|
22
|
+
"watch": "npx sd-cli watch",
|
|
23
|
+
"build": "npx sd-cli build",
|
|
24
|
+
"publish": "npx sd-cli publish",
|
|
23
25
|
"----- utils": "",
|
|
24
|
-
"postinstall": "sd-cli prepare"
|
|
26
|
+
"postinstall": "npx sd-cli prepare"
|
|
25
27
|
},
|
|
26
28
|
devDependencies: {
|
|
27
|
-
"@simplysm/eslint-plugin": "~7.
|
|
28
|
-
"@simplysm/sd-cli": opt.cliVersion ?? "~7.
|
|
29
|
-
"@types/node": "^
|
|
29
|
+
"@simplysm/eslint-plugin": "~7.1.0",
|
|
30
|
+
"@simplysm/sd-cli": opt.cliVersion ?? "~7.1.0",
|
|
31
|
+
"@types/node": "^16.11.47",
|
|
30
32
|
"cross-env": "^7.0.3",
|
|
31
|
-
"eslint": "^8.
|
|
32
|
-
"typescript": "~4.
|
|
33
|
+
"eslint": "^8.21.0",
|
|
34
|
+
"typescript": "~4.7.4"
|
|
33
35
|
}
|
|
34
36
|
}, undefined, 2);
|
|
@@ -13,7 +13,7 @@ export const fc_project_tsconfig = (): string => JSON.stringify({
|
|
|
13
13
|
noImplicitAny: false,
|
|
14
14
|
useUnknownInCatchVariables: false,
|
|
15
15
|
noFallthroughCasesInSwitch: true,
|
|
16
|
-
|
|
16
|
+
sourceMap: true,
|
|
17
17
|
skipDefaultLibCheck: true,
|
|
18
18
|
skipLibCheck: true,
|
|
19
19
|
forceConsistentCasingInFileNames: true,
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export const fc_project_yarnrc = (): string => /* language=yml */ `
|
|
2
|
+
nodeLinker: node-modules
|
|
3
|
+
|
|
4
|
+
packageExtensions:
|
|
5
|
+
"@angular-architects/module-federation-runtime@*":
|
|
6
|
+
dependencies:
|
|
7
|
+
"@angular/common": ^14.0.0
|
|
8
|
+
"@angular/core": ^14.0.0
|
|
9
|
+
rxjs: ^7.4.0
|
|
10
|
+
zone.js: ~0.11.4
|
|
11
|
+
|
|
12
|
+
yarnPath: .yarn/releases/yarn-3.2.2.cjs
|
|
13
|
+
|
|
14
|
+
`.trim();
|
package/src/index.ts
CHANGED
|
@@ -31,10 +31,10 @@ export * from "./entry-points/file/project/fc_project_npmconfig";
|
|
|
31
31
|
export * from "./entry-points/file/project/fc_project_readme";
|
|
32
32
|
export * from "./entry-points/file/project/fc_project_simplysm";
|
|
33
33
|
export * from "./entry-points/file/project/fc_project_tsconfig";
|
|
34
|
+
export * from "./entry-points/file/project/fc_project_yarnrc";
|
|
34
35
|
export * from "./entry-points/file/server/fc_package_server_main";
|
|
35
36
|
export * from "./entry-points/SdCliFileCrypto";
|
|
36
37
|
export * from "./entry-points/SdCliLocalUpdate";
|
|
37
|
-
export * from "./entry-points/SdCliNpm";
|
|
38
38
|
export * from "./entry-points/SdCliPrepare";
|
|
39
39
|
export * from "./entry-points/SdCliProject";
|
|
40
40
|
export * from "./entry-points/SdCliProjectGenerator";
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { SdCliTsRootMetadata } from "./typescript/SdCliTsRootMetadata";
|
|
2
2
|
import { SdCliBbRootMetadata, TSdCliBbMetadata } from "./babel/SdCliBbRootMetadata";
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
SdCliBbArrayMetadata,
|
|
5
|
+
SdCliBbClassMetadata,
|
|
6
|
+
SdCliBbConditionMetadata,
|
|
7
|
+
SdCliBbObjectMetadata
|
|
8
|
+
} from "./babel/TSdCliBbTypeMetadata";
|
|
4
9
|
import {
|
|
5
10
|
SdCliBbNgComponentMetadata,
|
|
6
11
|
SdCliBbNgDirectiveMetadata,
|
|
@@ -177,6 +182,48 @@ export class SdCliNgModuleGenerator {
|
|
|
177
182
|
return metaTmp instanceof Array ? metaTmp : [metaTmp];
|
|
178
183
|
}
|
|
179
184
|
|
|
185
|
+
private _getBbNgModuleProvClass(modProvMeta: TSdCliBbMetadata): { moduleName: string; name: string }[] {
|
|
186
|
+
const result: { moduleName: string; name: string }[] = [];
|
|
187
|
+
|
|
188
|
+
if (modProvMeta instanceof SdCliBbObjectMetadata) {
|
|
189
|
+
// 무시
|
|
190
|
+
}
|
|
191
|
+
else if (modProvMeta instanceof SdCliBbClassMetadata) {
|
|
192
|
+
const ref = this._bbMeta.findExportRef({
|
|
193
|
+
filePath: modProvMeta.filePath,
|
|
194
|
+
name: modProvMeta.name
|
|
195
|
+
});
|
|
196
|
+
if (ref) {
|
|
197
|
+
result.push(ref);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
else if (modProvMeta instanceof SdCliBbConditionMetadata) {
|
|
201
|
+
if (modProvMeta.consequent !== undefined) {
|
|
202
|
+
result.push(
|
|
203
|
+
...this._getBbNgModuleProvClass(modProvMeta.consequent)
|
|
204
|
+
);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
if (modProvMeta.alternate !== undefined) {
|
|
208
|
+
result.push(
|
|
209
|
+
...this._getBbNgModuleProvClass(modProvMeta.alternate)
|
|
210
|
+
);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
else if (modProvMeta instanceof SdCliBbArrayMetadata) {
|
|
214
|
+
for (const modProvMetaValue of modProvMeta.value) {
|
|
215
|
+
if (modProvMetaValue !== undefined) {
|
|
216
|
+
result.push(...this._getBbNgModuleProvClass(modProvMetaValue));
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
else {
|
|
221
|
+
throw new NeverEntryError();
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
return result;
|
|
225
|
+
}
|
|
226
|
+
|
|
180
227
|
private _getBbNgModuleDefs(): IBbNgModuleDef[] {
|
|
181
228
|
const entryRecord = this._bbMeta.getEntryFileMetaRecord();
|
|
182
229
|
const result: IBbNgModuleDef[] = [];
|
|
@@ -206,21 +253,7 @@ export class SdCliNgModuleGenerator {
|
|
|
206
253
|
}
|
|
207
254
|
|
|
208
255
|
for (const modProvMeta of modProvMetas) {
|
|
209
|
-
|
|
210
|
-
const ref = this._bbMeta.findExportRef({
|
|
211
|
-
filePath: modProvMeta.filePath,
|
|
212
|
-
name: modProvMeta.name
|
|
213
|
-
});
|
|
214
|
-
if (ref) {
|
|
215
|
-
resultItem.providers.push(ref);
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
else if (modProvMeta instanceof SdCliBbObjectMetadata) {
|
|
219
|
-
// 무시
|
|
220
|
-
}
|
|
221
|
-
else {
|
|
222
|
-
throw new NeverEntryError();
|
|
223
|
-
}
|
|
256
|
+
resultItem.providers.push(...this._getBbNgModuleProvClass(modProvMeta));
|
|
224
257
|
}
|
|
225
258
|
}
|
|
226
259
|
|
|
@@ -469,7 +502,7 @@ export class SdCliNgModuleGenerator {
|
|
|
469
502
|
fnResult += " {\n";
|
|
470
503
|
fnResult += ` path: "${child.path}",\n`;
|
|
471
504
|
if ("target" in child) {
|
|
472
|
-
fnResult += ` loadChildren:
|
|
505
|
+
fnResult += ` loadChildren: () => import("${this._getFileImportModuleName(def.filePath, child.target.filePath)}").then((m) => m.${child.target.name})\n`;
|
|
473
506
|
}
|
|
474
507
|
else {
|
|
475
508
|
fnResult += ` children: ${fn(child.children).replace(/\n/g, "\n ")}\n`;
|
|
@@ -486,7 +519,7 @@ export class SdCliNgModuleGenerator {
|
|
|
486
519
|
import { NgModule } from "@angular/core";
|
|
487
520
|
import { RouterModule } from "@angular/router";
|
|
488
521
|
import { SdCanDeactivateGuard } from "@simplysm/sd-angular";
|
|
489
|
-
import { ${def.component.name} } from "${this.
|
|
522
|
+
import { ${def.component.name} } from "${this._getFileImportModuleName(def.filePath, def.component.filePath)}";
|
|
490
523
|
|
|
491
524
|
@NgModule({
|
|
492
525
|
imports: [
|
|
@@ -520,7 +553,7 @@ export const routes: Routes = ${fn(def.children)};
|
|
|
520
553
|
for (const mod of mods) {
|
|
521
554
|
const importMap = [...mod.imports, ...mod.exports, ...mod.providers]
|
|
522
555
|
.map((item) => ({
|
|
523
|
-
moduleName: "moduleName" in item ? item.moduleName : this.
|
|
556
|
+
moduleName: "moduleName" in item ? item.moduleName : this._getFileImportModuleName(mod.filePath, item.filePath),
|
|
524
557
|
name: item.name
|
|
525
558
|
}))
|
|
526
559
|
.groupBy((item) => item.moduleName)
|
|
@@ -580,7 +613,7 @@ export class ${mod.name} {
|
|
|
580
613
|
}
|
|
581
614
|
}
|
|
582
615
|
|
|
583
|
-
private
|
|
616
|
+
private _getFileImportModuleName(mainFilePath: string, importFilePath: string): string {
|
|
584
617
|
const filePath = PathUtil.posix(path.relative(path.dirname(mainFilePath), importFilePath).replace(/\.ts$/, ""));
|
|
585
618
|
return filePath.startsWith(".") ? filePath : "./" + filePath;
|
|
586
619
|
}
|
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
isAssignmentExpression,
|
|
7
7
|
isCallExpression,
|
|
8
8
|
isClassDeclaration,
|
|
9
|
+
isConditionalExpression,
|
|
9
10
|
isExportDeclaration,
|
|
10
11
|
isExportDefaultDeclaration,
|
|
11
12
|
isExportNamedDeclaration,
|
|
@@ -34,6 +35,7 @@ import { TSdCliBbMetadata } from "./SdCliBbRootMetadata";
|
|
|
34
35
|
import {
|
|
35
36
|
SdCliBbArrayMetadata,
|
|
36
37
|
SdCliBbClassMetadata,
|
|
38
|
+
SdCliBbConditionMetadata,
|
|
37
39
|
SdCliBbFunctionMetadata,
|
|
38
40
|
SdCliBbObjectMetadata,
|
|
39
41
|
SdCliBbVariableMetadata
|
|
@@ -58,7 +60,12 @@ export class SdCliBbFileMetadata {
|
|
|
58
60
|
}
|
|
59
61
|
|
|
60
62
|
const fileContent = FsUtil.readFile(realFilePath);
|
|
61
|
-
|
|
63
|
+
try {
|
|
64
|
+
this.ast = babelParser.parse(fileContent, { sourceType: "module" });
|
|
65
|
+
}
|
|
66
|
+
catch (err) {
|
|
67
|
+
throw SdCliBbUtil.error(err.message, this.filePath, err.loc);
|
|
68
|
+
}
|
|
62
69
|
this.rawMetas = this.ast.program.body;
|
|
63
70
|
}
|
|
64
71
|
|
|
@@ -167,7 +174,11 @@ export class SdCliBbFileMetadata {
|
|
|
167
174
|
});
|
|
168
175
|
}
|
|
169
176
|
else {
|
|
170
|
-
|
|
177
|
+
const moduleName = rawMeta.source.value;
|
|
178
|
+
result.push({
|
|
179
|
+
exportedName: "*",
|
|
180
|
+
target: { moduleName, name: "*", __TSdCliMetaRef__: "__TSdCliMetaRef__" }
|
|
181
|
+
});
|
|
171
182
|
}
|
|
172
183
|
}
|
|
173
184
|
}
|
|
@@ -484,6 +495,9 @@ export class SdCliBbFileMetadata {
|
|
|
484
495
|
else if (isSpreadElement(rawMeta)) {
|
|
485
496
|
return this.getMetaFromRaw(rawMeta.argument);
|
|
486
497
|
}
|
|
498
|
+
else if (isConditionalExpression(rawMeta)) {
|
|
499
|
+
return new SdCliBbConditionMetadata(this, rawMeta);
|
|
500
|
+
}
|
|
487
501
|
|
|
488
502
|
throw SdCliBbUtil.error("예상치 못한 방식의 코드가 발견되었습니다.", this.filePath, rawMeta);
|
|
489
503
|
}
|