@simplysm/sd-cli 7.0.303 → 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 (46) hide show
  1. package/README.md +4 -4
  2. package/dist/builder/SdCliClientBuilder.mjs +65 -7
  3. package/dist/builder/SdCliTsLibBuilder.mjs +2 -2
  4. package/dist/commons.d.ts +2 -0
  5. package/dist/entry-points/SdCliPrepare.mjs +53 -22
  6. package/dist/entry-points/SdCliProjectGenerator.mjs +34 -26
  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/entry-points/file/server/fc_package_server_main.d.ts +1 -0
  13. package/dist/entry-points/file/server/fc_package_server_main.mjs +2 -2
  14. package/dist/index.d.ts +1 -0
  15. package/dist/index.mjs +2 -1
  16. package/dist/ng-tools/SdCliNgModuleGenerator.d.ts +2 -1
  17. package/dist/ng-tools/SdCliNgModuleGenerator.mjs +41 -21
  18. package/dist/ng-tools/babel/SdCliBbFileMetadata.mjs +33 -13
  19. package/dist/ng-tools/babel/SdCliBbRootMetadata.d.ts +2 -2
  20. package/dist/ng-tools/babel/SdCliBbRootMetadata.mjs +66 -19
  21. package/dist/ng-tools/babel/SdCliBbUtil.d.ts +2 -2
  22. package/dist/ng-tools/babel/SdCliBbUtil.mjs +3 -3
  23. package/dist/ng-tools/babel/TSdCliBbTypeMetadata.d.ts +13 -2
  24. package/dist/ng-tools/babel/TSdCliBbTypeMetadata.mjs +25 -1
  25. package/dist/ng-tools/typescript/SdCliTsFileMetadata.mjs +3 -3
  26. package/dist/utils/SdCliBuildResultUtil.mjs +3 -3
  27. package/docs/conf-orm.md +1 -1
  28. package/package.json +46 -41
  29. package/src/builder/SdCliClientBuilder.ts +71 -6
  30. package/src/builder/SdCliTsLibBuilder.ts +1 -1
  31. package/src/commons.ts +2 -0
  32. package/src/entry-points/SdCliPrepare.ts +52 -21
  33. package/src/entry-points/SdCliProjectGenerator.ts +36 -26
  34. package/src/entry-points/file/base/fc_package_npmconfig.ts +1 -0
  35. package/src/entry-points/file/project/fc_project_gitignore.ts +11 -1
  36. package/src/entry-points/file/project/fc_project_npmconfig.ts +8 -6
  37. package/src/entry-points/file/project/fc_project_yarnrc.ts +18 -0
  38. package/src/entry-points/file/server/fc_package_server_main.ts +2 -2
  39. package/src/index.ts +1 -0
  40. package/src/ng-tools/SdCliNgModuleGenerator.ts +53 -20
  41. package/src/ng-tools/babel/SdCliBbFileMetadata.ts +32 -10
  42. package/src/ng-tools/babel/SdCliBbRootMetadata.ts +74 -21
  43. package/src/ng-tools/babel/SdCliBbUtil.ts +4 -4
  44. package/src/ng-tools/babel/TSdCliBbTypeMetadata.ts +36 -1
  45. package/src/ng-tools/typescript/SdCliTsFileMetadata.ts +2 -2
  46. package/src/utils/SdCliBuildResultUtil.ts +3 -2
@@ -33,6 +33,7 @@ import electronBuilder from "electron-builder";
33
33
  import { fileURLToPath } from "url";
34
34
  import { Entrypoint } from "@angular-devkit/build-angular/src/utils/index-file/augment-index-html";
35
35
  import { StringUtil } from "@simplysm/sd-core-common";
36
+ import mf from "@angular-architects/module-federation/webpack";
36
37
  import LintResult = ESLint.LintResult;
37
38
 
38
39
  export class SdCliClientBuilder extends EventEmitter {
@@ -402,6 +403,16 @@ export class SdCliClientBuilder extends EventEmitter {
402
403
  // 버전쓰기
403
404
  FsUtil.writeFile(path.resolve(this._cacheBasePath, "version"), versionHash);
404
405
 
406
+ // ModuleFederation 관련
407
+ const sharedMappings = new mf.SharedMappings();
408
+ sharedMappings.register(this._tsconfigFilePath, []);
409
+
410
+ const deps = SdCliNpmConfigUtil.getDependencies(npmConfig);
411
+ const shared = deps.defaults
412
+ .concat(deps.optionals)
413
+ .distinct()
414
+ .toObject((item) => item, () => ({ singleton: true, strictVersion: true, requiredVersion: "auto" }));
415
+
405
416
  let prevProgressMessage = "";
406
417
  return {
407
418
  mode: watch ? "development" : "production",
@@ -413,8 +424,12 @@ export class SdCliClientBuilder extends EventEmitter {
413
424
  extensions: [".ts", ".tsx", ".mjs", ".cjs", ".js", ".jsx"],
414
425
  symlinks: true,
415
426
  modules: [this._projRootPath, "node_modules"],
416
- mainFields: ["es2015", "browser", "module", "main"],
417
- conditionNames: ["es2015", "..."],
427
+ mainFields: ["es2020", "es2015", "browser", "module", "main"],
428
+ conditionNames: ["es2020", "es2015", "..."],
429
+
430
+ ...this._config.moduleFederation ? {
431
+ alias: sharedMappings.getAliases()
432
+ } : {}
418
433
  },
419
434
  resolveLoader: {
420
435
  symlinks: true
@@ -437,7 +452,11 @@ export class SdCliClientBuilder extends EventEmitter {
437
452
  libraryTarget: undefined,
438
453
  crossOriginLoading: false,
439
454
  trustedTypes: "angular#bundler",
440
- scriptType: "module"
455
+ scriptType: "module",
456
+
457
+ ...this._config.moduleFederation ? {
458
+ publicPath: "auto"
459
+ } : {}
441
460
  },
442
461
  watch: false,
443
462
  watchOptions: {
@@ -450,7 +469,12 @@ export class SdCliClientBuilder extends EventEmitter {
450
469
  /Add postcss as project dependency/,
451
470
  /"@charset" must be the first rule in the file/
452
471
  ],
453
- experiments: { backCompat: false, syncWebAssembly: true, asyncWebAssembly: true },
472
+ experiments: {
473
+ backCompat: false,
474
+ syncWebAssembly: true,
475
+ asyncWebAssembly: true,
476
+ ...this._config.moduleFederation ? { outputModule: true } : {}
477
+ },
454
478
  infrastructureLogging: { level: "error" },
455
479
  stats: "errors-warnings",
456
480
  // externals: extModules.toObject((item) => item.name, (item) => item.exists ? "commonjs2 " + item.name : `var {name: '${item.name}'}`),
@@ -517,7 +541,11 @@ export class SdCliClientBuilder extends EventEmitter {
517
541
  test: /[\\/]node_modules[\\/]/
518
542
  } : false
519
543
  }
520
- }
544
+ },
545
+
546
+ ...this._config.moduleFederation ? {
547
+ runtimeChunk: false
548
+ } : {}
521
549
  },
522
550
  module: {
523
551
  strictExportPresence: true,
@@ -790,7 +818,44 @@ export class SdCliClientBuilder extends EventEmitter {
790
818
  }
791
819
  return resultMessages.join(os.EOL);
792
820
  }
793
- })
821
+ }),
822
+ ...this._config.moduleFederation === "remote" ? [
823
+ new webpack.container.ModuleFederationPlugin({
824
+ library: { type: "module" },
825
+ name: npmConfig.name.replace(/[^0-9A-z]/g, "_"),
826
+ filename: "remoteEntry.js",
827
+ exposes: {
828
+ "./AppMfeModule": path.resolve(this._rootPath, "src/AppMfeModule")
829
+ },
830
+ shared: mf.share({
831
+ /*"@angular/core": { singleton: true, strictVersion: true, requiredVersion: "auto" },
832
+ "@angular/common": { singleton: true, strictVersion: true, requiredVersion: "auto" },
833
+ "@angular/common/http": { singleton: true, strictVersion: true, requiredVersion: "auto" },
834
+ "@angular/router": { singleton: true, strictVersion: true, requiredVersion: "auto" },
835
+ "@simplysm/sd-angular": { singleton: true, strictVersion: true, requiredVersion: "auto" },*/
836
+
837
+ ...shared,
838
+ ...sharedMappings.getDescriptors()
839
+ } as any, path.resolve(this._rootPath, "package.json"))
840
+ }),
841
+ sharedMappings.getPlugin()
842
+ ] : this._config.moduleFederation === "host" ? [
843
+ new webpack.container.ModuleFederationPlugin({
844
+ library: { type: "module" },
845
+ remotes: {},
846
+ shared: mf.share({
847
+ /*"@angular/core": { singleton: true, strictVersion: true, requiredVersion: "auto" },
848
+ "@angular/common": { singleton: true, strictVersion: true, requiredVersion: "auto" },
849
+ "@angular/common/http": { singleton: true, strictVersion: true, requiredVersion: "auto" },
850
+ "@angular/router": { singleton: true, strictVersion: true, requiredVersion: "auto" },
851
+ "@simplysm/sd-angular": { singleton: true, strictVersion: true, requiredVersion: "auto" },*/
852
+
853
+ ...shared,
854
+ ...sharedMappings.getDescriptors()
855
+ } as any, path.resolve(this._rootPath, "package.json"))
856
+ }),
857
+ sharedMappings.getPlugin()
858
+ ] : []
794
859
  ] as any[]
795
860
  };
796
861
  }
@@ -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 = SdCliNpmConfigUtil.getDependencies(npmConfig).defaults.includes("@angular/core");
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,6 +75,7 @@ export interface ISdCliServerPackageConfig {
74
75
 
75
76
  export interface ISdCliClientPackageConfig {
76
77
  type: "client";
78
+ moduleFederation?: "host" | "remote";
77
79
  builder?: {
78
80
  web?: ISdCliClientBuilderWebConfig;
79
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
- if (node) {
29
- const prevUsage = process.cpuUsage();
30
-
31
- var saveCurrentNode = currentNode;
32
- currentNode = node;
33
- instantiationCount = 0;
34
- checkSourceElementWorker(node);
35
- currentNode = saveCurrentNode;
36
-
37
- const usage = process.cpuUsage(prevUsage);
38
- if (node.hasChildPerformanceWarning) {
39
- node.parent.hasChildPerformanceWarning = true;
40
- }
41
- else if (usage.user + usage.system > 1000 * 1000 && node.kind !== 253) {
42
- error(node, {
43
- code: 9000,
44
- category: ts.DiagnosticCategory.Warning,
45
- key: "simplysm_check_source_element_performance_slow",
46
- message: "소스코드 타입분석에 너무 오랜 시간이 소요됩니다. [" + Math.round((usage.user + usage.system) / 1000) + "ms/cpu, KIND: " + node.kind + "]"
47
- });
48
- node.parent.hasChildPerformanceWarning = true;
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", "node_modules", "package-lock.json"].includes(path.basename(item))).length > 0) {
38
- throw new Error("빈 디렉토리가 아닙니다. (package-lock.json, package.json, node_modules 외의 파일/폴더가 존재하는 경우, 초기화할 수 없습니다.)");
38
+ if ((await FsUtil.readdirAsync(this._rootPath)).filter((item) => ![".idea", "yarn.lock", "package.json", ".yarn"].includes(path.basename(item))).length > 0) {
39
+ throw new Error("빈 디렉토리가 아닙니다. (.idea, yarn.lock, package.json, .yarn 외의 파일/폴더가 존재하는 경우, 초기화할 수 없습니다.)");
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, ".gitignore"), 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,14 @@ 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}] npm install`);
84
- await SdProcess.spawnAsync("npm install", { cwd: this._rootPath }, true);
90
+ this._logger.log(`[${projName}] yarn install`);
91
+ await SdProcess.spawnAsync("yarn install", { cwd: this._rootPath }, true);
85
92
  }
86
93
 
87
94
  public async addTsLibAsync(opt: { name: string; description: string; useDom: boolean; isForAngular: boolean }): Promise<void> {
@@ -105,6 +112,7 @@ export class SdCliProjectGenerator {
105
112
  await this._addPackageToSimplysmJson({
106
113
  name: opt.name,
107
114
  type: "library",
115
+ ...opt.isForAngular ? { angular: true } : {},
108
116
  autoIndex: {
109
117
  ...opt.isForAngular ? {
110
118
  polyfills: [
@@ -134,8 +142,8 @@ export class SdCliProjectGenerator {
134
142
  types: "dist/index.d.ts",
135
143
  main: "dist/index.cjs",
136
144
  dependencies: {
137
- "@simplysm/sd-core-common": "~7.0.0",
138
- "@simplysm/sd-orm-common": "~7.0.0"
145
+ "@simplysm/sd-core-common": "~7.1.0",
146
+ "@simplysm/sd-orm-common": "~7.1.0"
139
147
  },
140
148
  tsconfigOptions: {}
141
149
  });
@@ -155,8 +163,8 @@ export class SdCliProjectGenerator {
155
163
  autoIndex: {}
156
164
  });
157
165
 
158
- this._logger.log(`[${projName}] npm install`);
159
- await SdProcess.spawnAsync("npm install", { cwd: this._rootPath }, true);
166
+ this._logger.log(`[${projName}] yarn install`);
167
+ await SdProcess.spawnAsync("yarn install", { cwd: this._rootPath }, true);
160
168
  }
161
169
 
162
170
  public async addDbLibModelAsync(opt: { dbPkgName: string; category: string; name: string; description: string }): Promise<void> {
@@ -214,10 +222,10 @@ export class SdCliProjectGenerator {
214
222
  isForAngular: false,
215
223
  main: "dist/main.js",
216
224
  dependencies: {
217
- "@simplysm/sd-core-common": "~7.0.0",
218
- "@simplysm/sd-core-node": "~7.0.0",
219
- "@simplysm/sd-service-common": "~7.0.0",
220
- "@simplysm/sd-service-server": "~7.0.0"
225
+ "@simplysm/sd-core-common": "~7.1.0",
226
+ "@simplysm/sd-core-node": "~7.1.0",
227
+ "@simplysm/sd-service-common": "~7.1.0",
228
+ "@simplysm/sd-service-server": "~7.1.0"
221
229
  },
222
230
  tsconfigOptions: {}
223
231
  });
@@ -225,7 +233,8 @@ export class SdCliProjectGenerator {
225
233
  this._logger.log(`[${pkgName}] 'src/main.ts' 파일 등록`);
226
234
  await FsUtil.writeFileAsync(path.resolve(pkgPath, `src/main.ts`), fc_package_server_main({
227
235
  projPath: this._rootPath,
228
- pkgName: pkgName
236
+ pkgName: pkgName,
237
+ port: Math.floor(Math.random() * 10000) + 50000
229
238
  }));
230
239
 
231
240
  this._logger.log(`[${pkgName}] 'simplysm.json' 파일에 등록`);
@@ -234,8 +243,8 @@ export class SdCliProjectGenerator {
234
243
  type: "server"
235
244
  });
236
245
 
237
- this._logger.log(`[${projName}] npm install`);
238
- await SdProcess.spawnAsync("npm install", { cwd: this._rootPath }, true);
246
+ this._logger.log(`[${projName}] yarn install`);
247
+ await SdProcess.spawnAsync("yarn install", { cwd: this._rootPath }, true);
239
248
  }
240
249
 
241
250
  public async addClientAsync(opt: { name: string; description: string; serverName: string }): Promise<void> {
@@ -252,8 +261,8 @@ export class SdCliProjectGenerator {
252
261
  isModule: true,
253
262
  isForAngular: true,
254
263
  dependencies: {
255
- "@angular/platform-browser": "^13.2.0",
256
- "@angular/platform-browser-dynamic": "^13.2.0"
264
+ "@angular/platform-browser": "^14.1.1",
265
+ "@angular/platform-browser-dynamic": "^14.1.1"
257
266
  },
258
267
  tsconfigOptions: {
259
268
  angularCompilerOptions: {
@@ -306,8 +315,8 @@ export class SdCliProjectGenerator {
306
315
  serverName: opt.serverName
307
316
  });
308
317
 
309
- this._logger.log(`[${projName}] npm install`);
310
- await SdProcess.spawnAsync("npm install", { cwd: this._rootPath }, true);
318
+ this._logger.log(`[${projName}] yarn install`);
319
+ await SdProcess.spawnAsync("yarn install", { cwd: this._rootPath }, true);
311
320
  }
312
321
 
313
322
  public async addPageAsync(opt: { pkgName: string; category?: string; name: string; isRouteParent: boolean }): Promise<void> {
@@ -347,12 +356,12 @@ export class SdCliProjectGenerator {
347
356
  dependencies: {
348
357
  ...opt.dependencies,
349
358
  ...opt.isForAngular ? {
350
- "@angular/common": "^13.2.0",
351
- "@angular/core": "^13.2.0",
352
- "@simplysm/sd-angular": "~7.0.0",
353
- "@simplysm/sd-core-common": "~7.0.0",
354
- "@simplysm/sd-core-browser": "~7.0.0",
355
- "rxjs": "^6.6.7",
359
+ "@angular/common": "^14.1.1",
360
+ "@angular/core": "^14.1.1",
361
+ "@simplysm/sd-angular": "~7.1.0",
362
+ "@simplysm/sd-core-common": "~7.1.0",
363
+ "@simplysm/sd-core-browser": "~7.1.0",
364
+ "rxjs": "^7.5.6",
356
365
  "zone.js": "~0.11.4"
357
366
  } : {}
358
367
  }
@@ -369,12 +378,13 @@ export class SdCliProjectGenerator {
369
378
  await FsUtil.mkdirsAsync(path.resolve(pkgPath, "src"));
370
379
  }
371
380
 
372
- private async _addPackageToSimplysmJson(opt: { name: string; type: string; autoIndex?: ISdAutoIndexConfig; serverName?: string }): Promise<void> {
381
+ private async _addPackageToSimplysmJson(opt: { name: string; type: string; angular?: boolean; autoIndex?: ISdAutoIndexConfig; serverName?: string }): Promise<void> {
373
382
  const config = await FsUtil.readJsonAsync(path.resolve(this._rootPath, "simplysm.json"));
374
383
  config.packages = config.packages ?? {};
375
384
  config.packages[opt.name] = {
376
385
  type: opt.type,
377
386
  ...opt.autoIndex ? { autoIndex: opt.autoIndex } : {},
387
+ ...opt.angular ? { angular: true } : {},
378
388
  ...opt.serverName !== undefined ? { server: opt.serverName } : {}
379
389
  };
380
390
  await FsUtil.writeJsonAsync(path.resolve(this._rootPath, "simplysm.json"), config, { space: 2 });
@@ -33,6 +33,7 @@ export const fc_package_npmconfig = (opt: {
33
33
  } : {},
34
34
  private: true,
35
35
  sideEffects: false,
36
+ packageManager: "yarn@3.2.2",
36
37
  engines: {
37
38
  node: "^16"
38
39
  },
@@ -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
- ~$*.xlsx
23
+ ~$*
14
24
  .*/
15
25
 
16
26
  `.trim();
@@ -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();
@@ -2,7 +2,7 @@ import path from "path";
2
2
  import { INpmConfig } from "../../../commons";
3
3
  import { FsUtil } from "@simplysm/sd-core-node";
4
4
 
5
- export const fc_package_server_main = (opt: { projPath: string; pkgName: string }): string => {
5
+ export const fc_package_server_main = (opt: { projPath: string; pkgName: string; port: number }): string => {
6
6
  const projNpmConfig = FsUtil.readJson(path.resolve(opt.projPath, "package.json")) as INpmConfig;
7
7
 
8
8
  return /* language=ts */ `
@@ -46,7 +46,7 @@ else {
46
46
  const server = new SdServiceServer({
47
47
  rootPath: __dirname,
48
48
  services: [],
49
- port: 50180
49
+ port: ${opt.port}
50
50
  });
51
51
 
52
52
  const logger = Logger.get(["${projNpmConfig.name}", "${opt.pkgName}"]);
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
  }