@simplysm/sd-cli 7.0.305 → 7.1.1

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.
Files changed (40) hide show
  1. package/README.md +1 -1
  2. package/dist/builder/SdCliClientBuilder.mjs +62 -10
  3. package/dist/builder/SdCliTsLibBuilder.mjs +2 -2
  4. package/dist/commons.d.ts +2 -1
  5. package/dist/entry-points/SdCliPrepare.mjs +53 -22
  6. package/dist/entry-points/SdCliProjectGenerator.mjs +32 -25
  7. package/dist/entry-points/file/base/fc_package_npmconfig.mjs +2 -1
  8. package/dist/entry-points/file/project/fc_project_gitignore.mjs +12 -2
  9. package/dist/entry-points/file/project/fc_project_npmconfig.mjs +9 -7
  10. package/dist/entry-points/file/project/fc_project_yarnrc.d.ts +1 -0
  11. package/dist/entry-points/file/project/fc_project_yarnrc.mjs +19 -0
  12. package/dist/index.d.ts +1 -0
  13. package/dist/index.mjs +2 -1
  14. package/dist/ng-tools/SdCliNgModuleGenerator.d.ts +2 -1
  15. package/dist/ng-tools/SdCliNgModuleGenerator.mjs +41 -21
  16. package/dist/ng-tools/babel/SdCliBbFileMetadata.mjs +17 -5
  17. package/dist/ng-tools/babel/SdCliBbRootMetadata.mjs +19 -7
  18. package/dist/ng-tools/babel/SdCliBbUtil.d.ts +2 -2
  19. package/dist/ng-tools/babel/SdCliBbUtil.mjs +3 -3
  20. package/dist/ng-tools/babel/TSdCliBbTypeMetadata.d.ts +13 -2
  21. package/dist/ng-tools/babel/TSdCliBbTypeMetadata.mjs +25 -1
  22. package/dist/utils/SdCliBuildResultUtil.mjs +3 -3
  23. package/docs/conf-orm.md +1 -1
  24. package/package.json +46 -42
  25. package/src/builder/SdCliClientBuilder.ts +68 -9
  26. package/src/builder/SdCliTsLibBuilder.ts +1 -1
  27. package/src/commons.ts +2 -1
  28. package/src/entry-points/SdCliPrepare.ts +52 -21
  29. package/src/entry-points/SdCliProjectGenerator.ts +34 -25
  30. package/src/entry-points/file/base/fc_package_npmconfig.ts +1 -0
  31. package/src/entry-points/file/project/fc_project_gitignore.ts +11 -1
  32. package/src/entry-points/file/project/fc_project_npmconfig.ts +8 -6
  33. package/src/entry-points/file/project/fc_project_yarnrc.ts +18 -0
  34. package/src/index.ts +1 -0
  35. package/src/ng-tools/SdCliNgModuleGenerator.ts +53 -20
  36. package/src/ng-tools/babel/SdCliBbFileMetadata.ts +16 -2
  37. package/src/ng-tools/babel/SdCliBbRootMetadata.ts +22 -6
  38. package/src/ng-tools/babel/SdCliBbUtil.ts +4 -4
  39. package/src/ng-tools/babel/TSdCliBbTypeMetadata.ts +36 -1
  40. package/src/utils/SdCliBuildResultUtil.ts +3 -2
@@ -10,11 +10,13 @@ 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
22
  "watch": "sd-cli watch",
@@ -24,11 +26,11 @@ export const fc_project_npmconfig = (opt: { name: string; description: string; a
24
26
  "postinstall": "sd-cli prepare"
25
27
  },
26
28
  devDependencies: {
27
- "@simplysm/eslint-plugin": "~7.0.0",
28
- "@simplysm/sd-cli": opt.cliVersion ?? "~7.0.0",
29
- "@types/node": "^17.0.12",
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.7.0",
32
- "typescript": "~4.5.5"
33
+ "eslint": "^8.21.0",
34
+ "typescript": "~4.7.4"
33
35
  }
34
36
  }, undefined, 2);
@@ -0,0 +1,18 @@
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
+ plugins:
13
+ - path: .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs
14
+ spec: "@yarnpkg/plugin-interactive-tools"
15
+
16
+ yarnPath: .yarn/releases/yarn-3.2.2.cjs
17
+
18
+ `.trim();
package/src/index.ts CHANGED
@@ -31,6 +31,7 @@ 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";
@@ -1,6 +1,11 @@
1
1
  import { SdCliTsRootMetadata } from "./typescript/SdCliTsRootMetadata";
2
2
  import { SdCliBbRootMetadata, TSdCliBbMetadata } from "./babel/SdCliBbRootMetadata";
3
- import { SdCliBbClassMetadata, SdCliBbObjectMetadata } from "./babel/TSdCliBbTypeMetadata";
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
- if (modProvMeta instanceof SdCliBbClassMetadata) {
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: async () => await import("${this._getImportModuleName(def.filePath, child.target.filePath)}").then((m) => m.${child.target.name})\n`;
505
+ fnResult += ` loadChildren: async () => await 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._getImportModuleName(def.filePath, def.component.filePath)}";
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._getImportModuleName(mod.filePath, item.filePath),
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 _getImportModuleName(mainFilePath: string, importFilePath: string): string {
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
- this.ast = babelParser.parse(fileContent, { sourceType: "module" });
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
- throw SdCliBbUtil.error("예상치 못한 방식의 코드가 발견되었습니다.", this.filePath, rawMeta);
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
  }
@@ -158,7 +158,7 @@ export class SdCliBbRootMetadata {
158
158
  for (const ngDepPath of ngDepPaths) {
159
159
  const npmConfig = FsUtil.readJson(path.resolve(ngDepPath, "package.json")) as INpmConfig;
160
160
 
161
- const entryFilePath = npmConfig["es2015"] ?? npmConfig["browser"] ?? npmConfig["module"] ?? npmConfig["main"] ?? npmConfig["default"];
161
+ const entryFilePath = npmConfig["es2020"] ?? npmConfig["es2015"] ?? npmConfig["browser"] ?? npmConfig["module"] ?? npmConfig["main"] ?? npmConfig["default"];
162
162
  if (entryFilePath === undefined) {
163
163
  entryMap.set(npmConfig.name, {
164
164
  rootPath: ngDepPath,
@@ -167,6 +167,10 @@ export class SdCliBbRootMetadata {
167
167
  }
168
168
  else if (typeof entryFilePath === "string") {
169
169
  const realPath = this._getRealFilePath(path.resolve(ngDepPath, entryFilePath));
170
+ if (realPath?.endsWith(".json")) {
171
+ continue;
172
+ }
173
+
170
174
  entryMap.set(npmConfig.name, {
171
175
  rootPath: ngDepPath,
172
176
  entryFilePath: realPath
@@ -178,6 +182,10 @@ export class SdCliBbRootMetadata {
178
182
  const exportResult = this._getGlobExportResult(PathUtil.posix(npmConfig.name, key), exportPath);
179
183
  for (const exportResultItem of exportResult) {
180
184
  const exportRealPath = this._getRealFilePath(exportResultItem.target);
185
+ if (exportResultItem.target.endsWith(".json")) {
186
+ continue;
187
+ }
188
+
181
189
  entryMap.set(exportResultItem.name, {
182
190
  rootPath: ngDepPath,
183
191
  entryFilePath: exportRealPath
@@ -190,23 +198,31 @@ export class SdCliBbRootMetadata {
190
198
  const exportKeys = Object.keys(npmConfig.exports);
191
199
  for (const exportKey of exportKeys) {
192
200
  if (
193
- exportKey.includes("/locales") ||
194
- exportKey.endsWith(".json") ||
195
- exportKey.endsWith("/testing") ||
196
- exportKey.endsWith("/upgrade")
201
+ exportKey.startsWith("./locales") ||
202
+ exportKey.startsWith("./testing") ||
203
+ exportKey.startsWith("./upgrade")
197
204
  ) {
198
205
  continue;
199
206
  }
200
207
 
201
- const expEntryFilePath = npmConfig.exports[exportKey]["es2015"] ??
208
+ const expEntryFilePath = npmConfig.exports[exportKey]["es2020"] ??
209
+ npmConfig.exports[exportKey]["es2015"] ??
202
210
  npmConfig.exports[exportKey]["browser"] ??
203
211
  npmConfig.exports[exportKey]["module"] ??
204
212
  npmConfig.exports[exportKey]["main"] ??
205
213
  npmConfig.exports[exportKey]["default"];
206
214
  if (typeof expEntryFilePath === "string") {
215
+ if (expEntryFilePath.endsWith(".json")) {
216
+ continue;
217
+ }
218
+
207
219
  const exportPath = path.resolve(ngDepPath, expEntryFilePath);
208
220
  const exportResult = this._getGlobExportResult(PathUtil.posix(npmConfig.name, exportKey), exportPath);
209
221
  for (const exportResultItem of exportResult) {
222
+ if (exportResultItem.target.endsWith(".json")) {
223
+ continue;
224
+ }
225
+
210
226
  const exportRealPath = this._getRealFilePath(exportResultItem.target);
211
227
  entryMap.set(exportResultItem.name, {
212
228
  rootPath: ngDepPath,
@@ -1,12 +1,12 @@
1
- import { Node } from "@babel/types";
1
+ import { Node, SourceLocation } from "@babel/types";
2
2
  import { SdCliBuildResultError } from "../../SdCliBuildResultError";
3
3
 
4
4
  export class SdCliBbUtil {
5
- public static error(message: string, filePath?: string, meta?: Node): SdCliBuildResultError {
5
+ public static error(message: string, filePath?: string, meta?: Node | SourceLocation["start"]): SdCliBuildResultError {
6
6
  return new SdCliBuildResultError({
7
7
  filePath,
8
- line: meta?.loc?.start.line,
9
- char: meta?.loc?.start.column,
8
+ line: meta && "loc" in meta ? meta.loc?.start.line : meta && "line" in meta ? meta.line : undefined,
9
+ char: meta && "loc" in meta ? meta.loc?.start.column : meta && "column" in meta ? meta.column : undefined,
10
10
  code: undefined,
11
11
  severity: "error",
12
12
  message: message
@@ -1,6 +1,7 @@
1
1
  import {
2
2
  ArrayExpression,
3
3
  ClassDeclaration,
4
+ ConditionalExpression,
4
5
  FunctionDeclaration,
5
6
  isAssignmentExpression,
6
7
  isExpressionStatement,
@@ -26,7 +27,8 @@ export type TSdCliBbTypeMetadata = SdCliBbClassMetadata |
26
27
  SdCliBbVariableMetadata |
27
28
  SdCliBbFunctionMetadata |
28
29
  SdCliBbObjectMetadata |
29
- SdCliBbArrayMetadata;
30
+ SdCliBbArrayMetadata |
31
+ SdCliBbConditionMetadata;
30
32
 
31
33
  export class SdCliBbClassMetadata {
32
34
  public constructor(private readonly _fileMeta: SdCliBbFileMetadata,
@@ -175,3 +177,36 @@ export class SdCliBbArrayMetadata {
175
177
  return this._valueCache;
176
178
  }
177
179
  }
180
+
181
+ export class SdCliBbConditionMetadata {
182
+ public constructor(private readonly _fileMeta: SdCliBbFileMetadata,
183
+ private readonly _metadata: ConditionalExpression) {
184
+ }
185
+
186
+ private _testCache?: TSdCliBbMetadata | undefined;
187
+
188
+ public get test(): TSdCliBbMetadata | undefined {
189
+ if (this._testCache === undefined) {
190
+ this._testCache = this._fileMeta.getMetaFromRaw(this._metadata.test);
191
+ }
192
+ return this._testCache;
193
+ }
194
+
195
+ private _consequentCache?: TSdCliBbMetadata | undefined;
196
+
197
+ public get consequent(): TSdCliBbMetadata | undefined {
198
+ if (this._consequentCache === undefined) {
199
+ this._consequentCache = this._fileMeta.getMetaFromRaw(this._metadata.consequent);
200
+ }
201
+ return this._consequentCache;
202
+ }
203
+
204
+ private _alternateCache?: TSdCliBbMetadata | undefined;
205
+
206
+ public get alternate(): TSdCliBbMetadata | undefined {
207
+ if (this._alternateCache === undefined) {
208
+ this._alternateCache = this._fileMeta.getMetaFromRaw(this._metadata.alternate);
209
+ }
210
+ return this._alternateCache;
211
+ }
212
+ }
@@ -49,8 +49,8 @@ export class SdCliBuildResultUtil {
49
49
  private static _convertFromWebpackError(severity: "warning" | "error", err: webpack.WebpackError): ISdCliPackageBuildResult {
50
50
  return {
51
51
  filePath: (err.file as string | undefined) ?? (err.module as webpack.Module | undefined)?.["request"],
52
- line: err.file ? err.loc["start"]?.line : undefined,
53
- char: err.file ? err.loc["start"]?.column : undefined,
52
+ line: err.file ? err.loc?.["start"]?.line : undefined, // eslint-disable-line
53
+ char: err.file ? err.loc?.["start"]?.column : undefined, // eslint-disable-line
54
54
  code: err.name,
55
55
  severity,
56
56
  message: err.message
@@ -71,6 +71,7 @@ export class SdCliBuildResultUtil {
71
71
  str += `${result.code}: `;
72
72
  }
73
73
  str += `${result.severity} ${result.message}`;
74
+
74
75
  return str;
75
76
  }
76
77
  }