@simplysm/sd-cli 7.0.304 → 7.1.10

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 (55) hide show
  1. package/README.md +4 -4
  2. package/dist/bin/sd-cli.mjs +1 -7
  3. package/dist/builder/SdCliClientBuilder.mjs +65 -7
  4. package/dist/builder/SdCliTsLibBuilder.mjs +2 -2
  5. package/dist/commons.d.ts +2 -0
  6. package/dist/entry-points/SdCliPrepare.mjs +53 -22
  7. package/dist/entry-points/SdCliProjectGenerator.mjs +36 -28
  8. package/dist/entry-points/file/base/fc_package_npmconfig.mjs +2 -1
  9. package/dist/entry-points/file/project/fc_project_gitignore.mjs +12 -2
  10. package/dist/entry-points/file/project/fc_project_npmconfig.mjs +9 -7
  11. package/dist/entry-points/file/project/fc_project_readme.mjs +1 -1
  12. package/dist/entry-points/file/project/fc_project_yarnrc.d.ts +1 -0
  13. package/dist/entry-points/file/project/fc_project_yarnrc.mjs +19 -0
  14. package/dist/entry-points/file/server/fc_package_server_main.d.ts +1 -0
  15. package/dist/entry-points/file/server/fc_package_server_main.mjs +2 -2
  16. package/dist/index.d.ts +1 -1
  17. package/dist/index.mjs +2 -2
  18. package/dist/ng-tools/SdCliNgModuleGenerator.d.ts +2 -1
  19. package/dist/ng-tools/SdCliNgModuleGenerator.mjs +41 -21
  20. package/dist/ng-tools/babel/SdCliBbFileMetadata.mjs +17 -5
  21. package/dist/ng-tools/babel/SdCliBbRootMetadata.mjs +19 -7
  22. package/dist/ng-tools/babel/SdCliBbUtil.d.ts +2 -2
  23. package/dist/ng-tools/babel/SdCliBbUtil.mjs +3 -3
  24. package/dist/ng-tools/babel/TSdCliBbTypeMetadata.d.ts +13 -2
  25. package/dist/ng-tools/babel/TSdCliBbTypeMetadata.mjs +25 -1
  26. package/dist/packages/SdCliPackage.mjs +2 -2
  27. package/dist/utils/SdCliBuildResultUtil.mjs +3 -3
  28. package/docs/conf-orm.md +1 -1
  29. package/package.json +46 -41
  30. package/src/bin/sd-cli.ts +0 -10
  31. package/src/builder/SdCliClientBuilder.ts +71 -6
  32. package/src/builder/SdCliTsLibBuilder.ts +1 -1
  33. package/src/commons.ts +2 -0
  34. package/src/entry-points/SdCliPrepare.ts +52 -21
  35. package/src/entry-points/SdCliProjectGenerator.ts +38 -28
  36. package/src/entry-points/file/base/fc_package_npmconfig.ts +1 -0
  37. package/src/entry-points/file/project/fc_project_gitignore.ts +11 -1
  38. package/src/entry-points/file/project/fc_project_npmconfig.ts +8 -6
  39. package/src/entry-points/file/project/fc_project_readme.ts +1 -1
  40. package/src/entry-points/file/project/fc_project_yarnrc.ts +18 -0
  41. package/src/entry-points/file/server/fc_package_server_main.ts +2 -2
  42. package/src/index.ts +1 -1
  43. package/src/ng-tools/SdCliNgModuleGenerator.ts +53 -20
  44. package/src/ng-tools/babel/SdCliBbFileMetadata.ts +16 -2
  45. package/src/ng-tools/babel/SdCliBbRootMetadata.ts +22 -6
  46. package/src/ng-tools/babel/SdCliBbUtil.ts +4 -4
  47. package/src/ng-tools/babel/TSdCliBbTypeMetadata.ts +36 -1
  48. package/src/packages/SdCliPackage.ts +1 -1
  49. package/src/utils/SdCliBuildResultUtil.ts +3 -2
  50. package/.eslintrc.cjs +0 -21
  51. package/dist/entry-points/SdCliNpm.d.ts +0 -6
  52. package/dist/entry-points/SdCliNpm.mjs +0 -24
  53. package/src/entry-points/SdCliNpm.ts +0 -28
  54. package/tsconfig-build.json +0 -16
  55. package/tsconfig.json +0 -39
@@ -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: [
@@ -115,8 +123,8 @@ export class SdCliProjectGenerator {
115
123
  },
116
124
  });
117
125
 
118
- this._logger.log(`[${projName}] npm install`);
119
- await SdProcess.spawnAsync("npm install", { cwd: this._rootPath }, true);
126
+ this._logger.log(`[${projName}] yarn install`);
127
+ await SdProcess.spawnAsync("yarn install", { cwd: this._rootPath }, true);
120
128
  }
121
129
 
122
130
  public async addDbLibAsync(opt: { name: string }): Promise<void> {
@@ -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);
@@ -7,6 +7,6 @@ export const fc_project_readme = (opt: { description: string }): string => /* la
7
7
 
8
8
  ## Installation
9
9
 
10
- npm install
10
+ yarn install
11
11
 
12
12
  `.trim();
@@ -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,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 { 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
+ }
@@ -123,7 +123,7 @@ export class SdCliPackage extends EventEmitter {
123
123
  if (this.config.type === "library") {
124
124
  // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
125
125
  if (this.config.publish === "npm") {
126
- await SdProcess.spawnAsync("npm publish --access public", { cwd: this.rootPath });
126
+ await SdProcess.spawnAsync("yarn npm publish --access public", { cwd: this.rootPath });
127
127
  }
128
128
  else {
129
129
  throw new NeverEntryError();
@@ -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
  }
package/.eslintrc.cjs DELETED
@@ -1,21 +0,0 @@
1
- module.exports = {
2
- overrides: [
3
- {
4
- files: ["*.ts"],
5
- parserOptions: {
6
- tsconfigRootDir: __dirname,
7
- project: "tsconfig.json"
8
- },
9
- settings: {
10
- "import/resolver": {
11
- "typescript": {
12
- project: "tsconfig.json"
13
- }
14
- }
15
- },
16
- rules: {
17
- "@simplysm/ts-no-throw-not-implement-error": "off"
18
- }
19
- }
20
- ]
21
- };