@simplysm/sd-cli 6.4.5 → 7.0.9

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 (185) hide show
  1. package/.eslintrc.cjs +11 -0
  2. package/dist/bin/sd-cli.d.ts +1 -0
  3. package/dist/bin/sd-cli.mjs +86 -0
  4. package/dist/build-tool/SdCliCacheCompilerHost.d.ts +10 -0
  5. package/dist/build-tool/SdCliCacheCompilerHost.mjs +44 -0
  6. package/dist/build-tool/SdCliNgCacheCompilerHost.d.ts +11 -0
  7. package/dist/build-tool/SdCliNgCacheCompilerHost.mjs +36 -0
  8. package/dist/build-tool/SdCliPackageLinter.d.ts +8 -0
  9. package/dist/build-tool/SdCliPackageLinter.mjs +41 -0
  10. package/dist/builder/SdCliJsLibBuilder.d.ts +14 -0
  11. package/dist/builder/SdCliJsLibBuilder.mjs +50 -0
  12. package/dist/builder/SdCliTsLibBuilder.d.ts +27 -0
  13. package/dist/builder/SdCliTsLibBuilder.mjs +226 -0
  14. package/dist/commons.d.ts +46 -0
  15. package/dist/commons.mjs +2 -0
  16. package/dist/entry-points/SdCliWorkspace.d.ts +18 -0
  17. package/dist/entry-points/SdCliWorkspace.mjs +193 -0
  18. package/dist/packages/SdCliPackage.d.ts +19 -0
  19. package/dist/packages/SdCliPackage.mjs +89 -0
  20. package/dist/utils/SdCliBuildResultUtil.d.ts +6 -0
  21. package/dist/utils/SdCliBuildResultUtil.mjs +38 -0
  22. package/dist/utils/SdCliConfigUtil.d.ts +7 -0
  23. package/dist/utils/SdCliConfigUtil.mjs +69 -0
  24. package/lib/ts-node-esm-paths.mjs +15 -0
  25. package/package.json +27 -59
  26. package/src/bin/sd-cli.ts +86 -214
  27. package/src/build-tool/SdCliCacheCompilerHost.ts +71 -0
  28. package/src/build-tool/SdCliNgCacheCompilerHost.ts +50 -0
  29. package/src/build-tool/SdCliPackageLinter.ts +54 -0
  30. package/src/builder/SdCliJsLibBuilder.ts +66 -0
  31. package/src/builder/SdCliTsLibBuilder.ts +335 -0
  32. package/src/commons.ts +17 -122
  33. package/src/entry-points/SdCliWorkspace.ts +229 -0
  34. package/src/packages/SdCliPackage.ts +111 -0
  35. package/src/utils/SdCliBuildResultUtil.ts +43 -0
  36. package/src/utils/SdCliConfigUtil.ts +94 -0
  37. package/tsconfig-build.json +9 -0
  38. package/tsconfig.json +7 -18
  39. package/.eslintrc.js +0 -19
  40. package/dist-node/bin/sd-cli.js +0 -197
  41. package/dist-node/bin/sd-cli.js.map +0 -1
  42. package/dist-node/build-tools/SdCliCordova.js +0 -144
  43. package/dist-node/build-tools/SdCliCordova.js.map +0 -1
  44. package/dist-node/build-tools/SdCliIndexFileGenerator.js +0 -51
  45. package/dist-node/build-tools/SdCliIndexFileGenerator.js.map +0 -1
  46. package/dist-node/build-tools/SdCliNgModuleFilesGenerator.js +0 -675
  47. package/dist-node/build-tools/SdCliNgModuleFilesGenerator.js.map +0 -1
  48. package/dist-node/build-tools/metadata/SdAotMetadataReader.js +0 -274
  49. package/dist-node/build-tools/metadata/SdAotMetadataReader.js.map +0 -1
  50. package/dist-node/build-tools/metadata/SdIvyMetadataReader.js +0 -124
  51. package/dist-node/build-tools/metadata/SdIvyMetadataReader.js.map +0 -1
  52. package/dist-node/build-tools/metadata/SdMetadataError.js +0 -13
  53. package/dist-node/build-tools/metadata/SdMetadataError.js.map +0 -1
  54. package/dist-node/build-tools/metadata/SdMyMetadataReader.js +0 -321
  55. package/dist-node/build-tools/metadata/SdMyMetadataReader.js.map +0 -1
  56. package/dist-node/builders/SdCliJavascriptLinter.js +0 -65
  57. package/dist-node/builders/SdCliJavascriptLinter.js.map +0 -1
  58. package/dist-node/builders/SdCliNgClientBuilder.js +0 -636
  59. package/dist-node/builders/SdCliNgClientBuilder.js.map +0 -1
  60. package/dist-node/builders/SdCliNgLibraryBuilder.js +0 -217
  61. package/dist-node/builders/SdCliNgLibraryBuilder.js.map +0 -1
  62. package/dist-node/builders/SdCliPublisher.js +0 -129
  63. package/dist-node/builders/SdCliPublisher.js.map +0 -1
  64. package/dist-node/builders/SdCliServerBuilder.js +0 -452
  65. package/dist-node/builders/SdCliServerBuilder.js.map +0 -1
  66. package/dist-node/builders/SdCliTypescriptBuilder.js +0 -347
  67. package/dist-node/builders/SdCliTypescriptBuilder.js.map +0 -1
  68. package/dist-node/commons.js +0 -3
  69. package/dist-node/commons.js.map +0 -1
  70. package/dist-node/entry-points/SdCliLocalUpdater.js +0 -88
  71. package/dist-node/entry-points/SdCliLocalUpdater.js.map +0 -1
  72. package/dist-node/entry-points/SdCliPrepare.js +0 -56
  73. package/dist-node/entry-points/SdCliPrepare.js.map +0 -1
  74. package/dist-node/entry-points/SdCliProject.js +0 -302
  75. package/dist-node/entry-points/SdCliProject.js.map +0 -1
  76. package/dist-node/packages/SdCliClientPackage.js +0 -91
  77. package/dist-node/packages/SdCliClientPackage.js.map +0 -1
  78. package/dist-node/packages/SdCliLibraryPackage.js +0 -99
  79. package/dist-node/packages/SdCliLibraryPackage.js.map +0 -1
  80. package/dist-node/packages/SdCliPackageBase.js +0 -33
  81. package/dist-node/packages/SdCliPackageBase.js.map +0 -1
  82. package/dist-node/packages/SdCliServerPackage.js +0 -69
  83. package/dist-node/packages/SdCliServerPackage.js.map +0 -1
  84. package/dist-node/packages/SdCliUnknownPackage.js +0 -15
  85. package/dist-node/packages/SdCliUnknownPackage.js.map +0 -1
  86. package/dist-node/utils/SdCliFileCrypto.js +0 -76
  87. package/dist-node/utils/SdCliFileCrypto.js.map +0 -1
  88. package/dist-node/utils/SdProjectConfigUtil.js +0 -62
  89. package/dist-node/utils/SdProjectConfigUtil.js.map +0 -1
  90. package/dist-node/utils/SdTsDiagnosticUtil.js +0 -45
  91. package/dist-node/utils/SdTsDiagnosticUtil.js.map +0 -1
  92. package/dist-node/utils/SdWebpackUtil.js +0 -63
  93. package/dist-node/utils/SdWebpackUtil.js.map +0 -1
  94. package/dist-node/workers/client-ng-gen-worker.js +0 -57
  95. package/dist-node/workers/client-ng-gen-worker.js.map +0 -1
  96. package/dist-node/workers/lib-build-worker.js +0 -88
  97. package/dist-node/workers/lib-build-worker.js.map +0 -1
  98. package/dist-types/bin/sd-cli.d.ts +0 -3
  99. package/dist-types/bin/sd-cli.d.ts.map +0 -1
  100. package/dist-types/build-tools/SdCliCordova.d.ts +0 -15
  101. package/dist-types/build-tools/SdCliCordova.d.ts.map +0 -1
  102. package/dist-types/build-tools/SdCliIndexFileGenerator.d.ts +0 -13
  103. package/dist-types/build-tools/SdCliIndexFileGenerator.d.ts.map +0 -1
  104. package/dist-types/build-tools/SdCliNgModuleFilesGenerator.d.ts +0 -43
  105. package/dist-types/build-tools/SdCliNgModuleFilesGenerator.d.ts.map +0 -1
  106. package/dist-types/build-tools/metadata/SdAotMetadataReader.d.ts +0 -58
  107. package/dist-types/build-tools/metadata/SdAotMetadataReader.d.ts.map +0 -1
  108. package/dist-types/build-tools/metadata/SdIvyMetadataReader.d.ts +0 -43
  109. package/dist-types/build-tools/metadata/SdIvyMetadataReader.d.ts.map +0 -1
  110. package/dist-types/build-tools/metadata/SdMetadataError.d.ts +0 -7
  111. package/dist-types/build-tools/metadata/SdMetadataError.d.ts.map +0 -1
  112. package/dist-types/build-tools/metadata/SdMyMetadataReader.d.ts +0 -59
  113. package/dist-types/build-tools/metadata/SdMyMetadataReader.d.ts.map +0 -1
  114. package/dist-types/builders/SdCliJavascriptLinter.d.ts +0 -14
  115. package/dist-types/builders/SdCliJavascriptLinter.d.ts.map +0 -1
  116. package/dist-types/builders/SdCliNgClientBuilder.d.ts +0 -29
  117. package/dist-types/builders/SdCliNgClientBuilder.d.ts.map +0 -1
  118. package/dist-types/builders/SdCliNgLibraryBuilder.d.ts +0 -30
  119. package/dist-types/builders/SdCliNgLibraryBuilder.d.ts.map +0 -1
  120. package/dist-types/builders/SdCliPublisher.d.ts +0 -9
  121. package/dist-types/builders/SdCliPublisher.d.ts.map +0 -1
  122. package/dist-types/builders/SdCliServerBuilder.d.ts +0 -31
  123. package/dist-types/builders/SdCliServerBuilder.d.ts.map +0 -1
  124. package/dist-types/builders/SdCliTypescriptBuilder.d.ts +0 -56
  125. package/dist-types/builders/SdCliTypescriptBuilder.d.ts.map +0 -1
  126. package/dist-types/commons.d.ts +0 -134
  127. package/dist-types/commons.d.ts.map +0 -1
  128. package/dist-types/entry-points/SdCliLocalUpdater.d.ts +0 -12
  129. package/dist-types/entry-points/SdCliLocalUpdater.d.ts.map +0 -1
  130. package/dist-types/entry-points/SdCliPrepare.d.ts +0 -6
  131. package/dist-types/entry-points/SdCliPrepare.d.ts.map +0 -1
  132. package/dist-types/entry-points/SdCliProject.d.ts +0 -32
  133. package/dist-types/entry-points/SdCliProject.d.ts.map +0 -1
  134. package/dist-types/packages/SdCliClientPackage.d.ts +0 -17
  135. package/dist-types/packages/SdCliClientPackage.d.ts.map +0 -1
  136. package/dist-types/packages/SdCliLibraryPackage.d.ts +0 -20
  137. package/dist-types/packages/SdCliLibraryPackage.d.ts.map +0 -1
  138. package/dist-types/packages/SdCliPackageBase.d.ts +0 -11
  139. package/dist-types/packages/SdCliPackageBase.d.ts.map +0 -1
  140. package/dist-types/packages/SdCliServerPackage.d.ts +0 -16
  141. package/dist-types/packages/SdCliServerPackage.d.ts.map +0 -1
  142. package/dist-types/packages/SdCliUnknownPackage.d.ts +0 -9
  143. package/dist-types/packages/SdCliUnknownPackage.d.ts.map +0 -1
  144. package/dist-types/utils/SdCliFileCrypto.d.ts +0 -8
  145. package/dist-types/utils/SdCliFileCrypto.d.ts.map +0 -1
  146. package/dist-types/utils/SdProjectConfigUtil.d.ts +0 -7
  147. package/dist-types/utils/SdProjectConfigUtil.d.ts.map +0 -1
  148. package/dist-types/utils/SdTsDiagnosticUtil.d.ts +0 -6
  149. package/dist-types/utils/SdTsDiagnosticUtil.d.ts.map +0 -1
  150. package/dist-types/utils/SdWebpackUtil.d.ts +0 -7
  151. package/dist-types/utils/SdWebpackUtil.d.ts.map +0 -1
  152. package/dist-types/workers/client-ng-gen-worker.d.ts +0 -2
  153. package/dist-types/workers/client-ng-gen-worker.d.ts.map +0 -1
  154. package/dist-types/workers/lib-build-worker.d.ts +0 -2
  155. package/dist-types/workers/lib-build-worker.d.ts.map +0 -1
  156. package/schema/schema.json +0 -447
  157. package/sd-tsconfig.node.json +0 -18
  158. package/src/build-tools/SdCliCordova.ts +0 -240
  159. package/src/build-tools/SdCliIndexFileGenerator.ts +0 -61
  160. package/src/build-tools/SdCliNgModuleFilesGenerator.ts +0 -894
  161. package/src/build-tools/metadata/SdAotMetadataReader.ts +0 -374
  162. package/src/build-tools/metadata/SdIvyMetadataReader.ts +0 -183
  163. package/src/build-tools/metadata/SdMetadataError.ts +0 -7
  164. package/src/build-tools/metadata/SdMyMetadataReader.ts +0 -407
  165. package/src/builders/SdCliJavascriptLinter.ts +0 -81
  166. package/src/builders/SdCliNgClientBuilder.ts +0 -793
  167. package/src/builders/SdCliNgLibraryBuilder.ts +0 -301
  168. package/src/builders/SdCliPublisher.ts +0 -144
  169. package/src/builders/SdCliServerBuilder.ts +0 -555
  170. package/src/builders/SdCliTypescriptBuilder.ts +0 -552
  171. package/src/entry-points/SdCliLocalUpdater.ts +0 -114
  172. package/src/entry-points/SdCliPrepare.ts +0 -104
  173. package/src/entry-points/SdCliProject.ts +0 -405
  174. package/src/packages/SdCliClientPackage.ts +0 -111
  175. package/src/packages/SdCliLibraryPackage.ts +0 -118
  176. package/src/packages/SdCliPackageBase.ts +0 -34
  177. package/src/packages/SdCliServerPackage.ts +0 -85
  178. package/src/packages/SdCliUnknownPackage.ts +0 -14
  179. package/src/utils/SdCliFileCrypto.ts +0 -87
  180. package/src/utils/SdCliUtils.ts +0 -56
  181. package/src/utils/SdProjectConfigUtil.ts +0 -145
  182. package/src/utils/SdTsDiagnosticUtil.ts +0 -46
  183. package/src/utils/SdWebpackUtil.ts +0 -71
  184. package/src/workers/client-ng-gen-worker.ts +0 -63
  185. package/src/workers/lib-build-worker.ts +0 -97
package/package.json CHANGED
@@ -1,73 +1,41 @@
1
1
  {
2
2
  "name": "@simplysm/sd-cli",
3
- "version": "6.4.5",
3
+ "version": "7.0.9",
4
4
  "description": "심플리즘 패키지 - CLI",
5
5
  "author": "김석래",
6
- "repository": "github:kslhunter/simplysm6",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/kslhunter/simplysm7.git",
9
+ "directory": "packages/sd-cli"
10
+ },
7
11
  "license": "MIT",
8
12
  "bin": {
9
- "sd-cli": "./dist-node/bin/sd-cli.js"
13
+ "sd-cli": "./dist/bin/sd-cli.mjs"
14
+ },
15
+ "exports": {
16
+ "./ts-node-esm-paths": "./lib/ts-node-esm-paths.mjs"
10
17
  },
11
- "main": "./dist-node/index.js",
12
- "types": "./dist-types/index.d.ts",
13
- "sideEffects": false,
18
+ "type": "module",
14
19
  "engines": {
15
- "node": "^14"
20
+ "node": "^16"
16
21
  },
17
22
  "dependencies": {
18
- "yargs": "^17.1.1",
19
- "@simplysm/sd-core-common": "6.4.5",
20
- "@simplysm/sd-core-node": "6.4.5",
21
- "@simplysm/sd-service-node": "6.4.5",
22
- "eslint": "^7.32.0",
23
- "@typescript-eslint/parser": "4.28.2",
24
- "@typescript-eslint/typescript-estree": "4.28.2",
25
- "typescript": "~4.3.5",
26
- "ng-packagr": "^12.2.1",
27
- "@angular/compiler-cli": "^12.2.2",
28
- "@angular/compiler": "^12.2.2",
29
- "@angular-devkit/build-angular": "^12.2.2",
30
- "@angular-devkit/core": "^12.2.2",
31
- "tslib": "^2.3.1",
32
- "webpack": "^5.54.0",
33
- "node-sass": "^6.0.1",
34
- "css-minimizer-webpack-plugin": "3.0.2",
35
- "esbuild": "^0.13.4",
36
- "license-webpack-plugin": "^4.0.0",
37
- "mini-css-extract-plugin": "^2.2.0",
38
- "@ngtools/webpack": "^12.2.2",
39
- "copy-webpack-plugin": "^10.0.0",
40
- "webpack-dev-middleware": "^5.0.0",
41
- "ts-loader": "^9.2.5",
42
- "eslint-webpack-plugin": "^3.0.1",
43
- "decache": "^4.6.0",
44
- "sass-loader": "^12.1.0",
45
- "resolve-url-loader": "^4.0.0",
46
- "style-loader": "^3.2.1",
47
- "css-loader": "^6.2.0",
48
- "semver": "^7.3.5",
49
- "source-map-loader": "^3.0.0",
50
- "buffer": "^6.0.3",
51
- "browserslist": "^4.16.8",
52
- "@simplysm/sd-storage": "6.4.5",
53
- "webpack-hot-middleware": "^2.25.0",
54
- "jsdom": "^18.1.0",
55
- "cordova": "^10.0.0",
56
- "@azure/arm-appservice": "^9.0.0",
57
- "@azure/ms-rest-nodeauth": "^3.1.0",
58
- "xml2js": "^0.4.23",
59
- "jszip": "^3.7.1",
60
- "node-polyfill-webpack-plugin": "^1.1.4"
23
+ "ts-node": "^10.4.0",
24
+ "tsconfig-paths": "^3.12.0",
25
+ "yargs": "^17.3.1",
26
+ "chokidar": "^3.5.3",
27
+ "typescript": "~4.5.5",
28
+ "eslint": "^8.7.0",
29
+ "@angular/compiler-cli": "^13.2.0",
30
+ "sass": "^1.49.0",
31
+ "semver": "^7.3.5"
61
32
  },
62
33
  "devDependencies": {
63
- "@types/yargs": "^17.0.2",
64
- "@types/node-sass": "^4.11.2",
65
- "@types/css-minimizer-webpack-plugin": "3.0.2",
66
- "@types/mini-css-extract-plugin": "^2.2.0",
67
- "@types/copy-webpack-plugin": "^8.0.1",
68
- "@types/webpack-dev-middleware": "^5.0.2",
69
- "@types/webpack-hot-middleware": "^2.25.5",
70
- "@types/semver": "^7.3.8",
71
- "@types/jsdom": "^16.2.13"
34
+ "@types/yargs": "^17.0.8",
35
+ "@types/semver": "^7.3.9"
36
+ },
37
+ "peerDependencies": {
38
+ "@simplysm/sd-core-common": "7.0.9",
39
+ "@simplysm/sd-core-node": "7.0.9"
72
40
  }
73
41
  }
package/src/bin/sd-cli.ts CHANGED
@@ -1,235 +1,107 @@
1
- #!/usr/bin/env node
2
-
3
- process.setMaxListeners(0);
4
-
5
- import * as os from "os";
6
- import * as yargs from "yargs";
7
- import { EventEmitter } from "events";
1
+ import yargs from "yargs";
2
+ import { hideBin } from "yargs/helpers";
8
3
  import { Logger, LoggerSeverity } from "@simplysm/sd-core-node";
9
- import { SdCliProject } from "../entry-points/SdCliProject";
10
- import { SdCliLocalUpdater } from "../entry-points/SdCliLocalUpdater";
11
- import { SdCliFileCrypto } from "../utils/SdCliFileCrypto";
12
- import { SdCliCordova } from "../build-tools/SdCliCordova";
13
- import { SdCliPrepare } from "../entry-points/SdCliPrepare";
4
+ import { SdCliWorkspace } from "../entry-points/SdCliWorkspace";
14
5
 
15
- EventEmitter.defaultMaxListeners = 0;
6
+ Error.stackTraceLimit = Infinity;
16
7
 
17
- const logger = Logger.get(["simplysm", "sd-cli"]);
18
-
19
- (async (): Promise<void> => {
20
- const argv = await yargs.version(false)
21
- .help("help", "도움말")
22
- .alias("help", "h")
23
- .options({
24
- debug: {
25
- type: "boolean",
26
- describe: "디버그 로그를 표시할 것인지 여부",
27
- default: false
28
- }
29
- })
30
- .command(
31
- "watch",
32
- "프로젝트의 각 패키지에 대한 변경감지 빌드를 수행합니다.",
33
- (cmd) => cmd
34
- .options({
35
- packages: {
36
- type: "string",
37
- describe: "수행할 패키지 설정",
38
- array: true
39
- },
40
- config: {
41
- type: "string",
42
- describe: "simplysm.json 파일 경로"
43
- },
44
- noLint: {
45
- type: "boolean",
46
- describe: `lint 작업을 수행하지 않음`
47
- },
48
- options: {
49
- type: "string",
50
- describe: "옵션 설정 (설정파일에서 @로 시작하는 부분)",
51
- array: true
52
- }
53
- })
54
- )
55
- .command(
56
- "run-device <cordovaPath> <target> <url>",
57
- "변경감지중인 플랫폼을 디바이스에 앱 형태로 띄웁니다.",
58
- (cmd) => cmd
59
- .positional("cordovaPath", {
60
- type: "string",
61
- describe: "CORDOVA 프로젝트 경로",
62
- demandOption: true
63
- })
64
- .positional("target", {
8
+ const argv = yargs(hideBin(process.argv))
9
+ .version(false)
10
+ .help("help", "도움말")
11
+ .alias("help", "h")
12
+ .options({
13
+ debug: {
14
+ type: "boolean",
15
+ describe: "디버그 로그를 표시할 것인지 여부",
16
+ default: false
17
+ }
18
+ })
19
+ .command(
20
+ "local-update",
21
+ "로컬 라이브러리 업데이트를 수행합니다.",
22
+ (cmd) => cmd.version(false)
23
+ .options({
24
+ config: {
65
25
  type: "string",
66
- describe: "빌드타겟(android,...)",
67
- demandOption: true
68
- })
69
- .positional("url", {
26
+ describe: "simplysm.json 파일 경로"
27
+ }
28
+ })
29
+ )
30
+ .command(
31
+ "watch",
32
+ "프로젝트의 각 패키지에 대한 변경감지 빌드를 수행합니다.",
33
+ (cmd) => cmd.version(false)
34
+ .options({
35
+ config: {
70
36
  type: "string",
71
- describe: "Webview로 오픈할 URL",
72
- demandOption: true
73
- })
74
- )
75
- .command(
76
- "build",
77
- "프로젝트의 각 패키지에 대한 빌드를 수행합니다.",
78
- (cmd) => cmd
79
- .options({
80
- packages: {
81
- type: "string",
82
- describe: "수행할 패키지 설정",
83
- array: true
84
- },
85
- config: {
86
- type: "string",
87
- describe: "simplysm.json 파일 경로"
88
- },
89
- noLint: {
90
- type: "boolean",
91
- describe: `lint 작업을 수행하지 않음`
92
- },
93
- options: {
94
- type: "string",
95
- describe: "옵션 설정 (설정파일에서 @로 시작하는 부분)",
96
- array: true
97
- }
98
- })
99
- )
100
- .command(
101
- "publish",
102
- "프로젝트의 각 패키지를 배포합니다.",
103
- (cmd) => cmd.version(false)
104
- .options({
105
- build: {
106
- type: "boolean",
107
- describe: "새로 빌드한 후에 배포합니다",
108
- default: false
109
- },
110
- noLint: {
111
- type: "boolean",
112
- describe: `빌드시, lint 작업을 수행하지 않음`
113
- },
114
- packages: {
115
- type: "string",
116
- describe: "수행할 패키지 설정",
117
- array: true
118
- },
119
- config: {
120
- type: "string",
121
- describe: "simplysm.json 파일 경로"
122
- },
123
- options: {
124
- type: "string",
125
- describe: "옵션 설정 (설정파일에서 @로 시작하는 부분)",
126
- array: true
127
- }
128
- })
129
- )
130
- .command(
131
- "local-update",
132
- "로컬 라이브러리 업데이트를 수행합니다.",
133
- (cmd) => cmd.version(false)
134
- .options({
135
- config: {
136
- type: "string",
137
- describe: "simplysm.json 파일 경로"
138
- }
139
- })
140
- )
141
- .command(
142
- "enc-file <file>",
143
- "파일을 암호화 합니다.",
144
- (cmd) => cmd.version(false)
145
- .positional("file", {
37
+ describe: "simplysm.json 파일 경로"
38
+ }
39
+ })
40
+ )
41
+ .command(
42
+ "build",
43
+ "프로젝트의 각 패키지에 대한 빌드를 수행합니다.",
44
+ (cmd) => cmd.version(false)
45
+ .options({
46
+ config: {
146
47
  type: "string",
147
- describe: "암호화할 파일명"
148
- })
149
- )
150
- .command(
151
- "dec-file <file>",
152
- "파일을 복호화 합니다.",
153
- (cmd) => cmd.version(false)
154
- .positional("file", {
48
+ describe: "simplysm.json 파일 경로"
49
+ }
50
+ })
51
+ )
52
+ .command(
53
+ "publish",
54
+ "프로젝트의 패키지를 배포합니다.",
55
+ (cmd) => cmd.version(false)
56
+ .options({
57
+ config: {
155
58
  type: "string",
156
- describe: "암호화된 파일명"
157
- })
158
- )
159
- .command(
160
- "prepare",
161
- "sd-cli 준비"
162
- )
163
- .parse();
59
+ describe: "simplysm.json 파일 경로"
60
+ },
61
+ "noBuild": {
62
+ type: "boolean",
63
+ describe: "빌드를 하지않고 배포합니다.",
64
+ default: false
65
+ }
66
+ })
67
+ )
68
+ .parseSync();
164
69
 
165
- if (argv.debug) {
166
- Error.stackTraceLimit = 100; //Infinity;
70
+ if (argv.debug) {
71
+ process.env["SD_CLI_LOGGER_SEVERITY"] = "DEBUG";
167
72
 
168
- process.env.SD_CLI_LOGGER_SEVERITY = "DEBUG";
169
-
170
- Logger.setConfig(["simplysm", "sd-cli"], {
171
- console: {
172
- level: LoggerSeverity.debug
173
- }
174
- });
175
- }
176
- else {
177
- Logger.setConfig(["simplysm", "sd-cli"], {
178
- dot: true
179
- });
180
- }
73
+ Logger.setConfig({
74
+ console: {
75
+ level: LoggerSeverity.debug
76
+ }
77
+ });
78
+ }
79
+ else {
80
+ Logger.setConfig({
81
+ dot: true
82
+ });
83
+ }
181
84
 
182
- const args = argv._;
85
+ const logger = Logger.get(["simplysm", "sd-cli", "bin", "sd-cli"]);
183
86
 
184
- if (args[0] === "build") {
185
- await new SdCliProject(process.cwd())
186
- .buildAsync({
187
- packages: argv.packages,
188
- config: argv.config,
189
- options: argv.options,
190
- skipProcesses: argv.noLint ? ["lint"] : undefined
191
- });
192
- process.exit(0);
193
- }
194
- else if (args[0] === "watch") {
195
- await new SdCliProject(process.cwd())
196
- .buildAsync({
197
- watch: true,
198
- packages: argv.packages,
199
- config: argv.config,
200
- options: argv.options,
201
- skipProcesses: argv.noLint ? ["lint"] : undefined
202
- });
203
- }
204
- else if (args[0] === "run-device") {
205
- await SdCliCordova.runWebviewOnDeviceAsync(argv.cordovaPath, argv.target, argv.url);
87
+ (async () => {
88
+ if (argv._[0] === "watch") {
89
+ await new SdCliWorkspace(process.cwd(), argv.config)
90
+ .watchAsync();
206
91
  }
207
- else if (args[0] === "local-update") {
208
- await new SdCliLocalUpdater(process.cwd()).localUpdateAsync(false, { config: argv.config });
92
+ else if (argv._[0] === "build") {
93
+ await new SdCliWorkspace(process.cwd(), argv.config)
94
+ .buildAsync();
209
95
  }
210
- else if (args[0] === "publish") {
211
- await new SdCliProject(process.cwd())
96
+ else if (argv._[0] === "publish") {
97
+ await new SdCliWorkspace(process.cwd(), argv.config)
212
98
  .publishAsync({
213
- build: argv.build,
214
- packages: argv.packages,
215
- config: argv.config,
216
- options: argv.options
99
+ noBuild: argv.noBuild
217
100
  });
218
- process.exit(0);
219
- }
220
- else if (args[0] === "enc-file") {
221
- await new SdCliFileCrypto().encryptAsync(argv.file!);
222
- }
223
- else if (args[0] === "dec-file") {
224
- await new SdCliFileCrypto().decryptAsync(argv.file!);
225
- }
226
- else if (args[0] === "prepare") {
227
- await new SdCliPrepare().prepareAsync();
228
101
  }
229
102
  else {
230
- throw new Error(`명령어가 잘못되었습니다.${os.EOL + os.EOL}\t${argv._[0]}${os.EOL}`);
103
+ throw new Error(`명령어가 잘못 되었습니다.\n\t${argv._[0]}\n`);
231
104
  }
232
105
  })().catch((err) => {
233
106
  logger.error(err);
234
- process.exit(1);
235
107
  });
@@ -0,0 +1,71 @@
1
+ import ts from "typescript";
2
+ import { PathUtil } from "@simplysm/sd-core-node";
3
+
4
+ export class SdCliCacheCompilerHost {
5
+ public static create(parsedTsconfig: ts.ParsedCommandLine,
6
+ moduleResolutionCache: ts.ModuleResolutionCache,
7
+ sourceFileCache: Map<string, IFileCache>,
8
+ outputFileCache: Map<string, string>): ts.CompilerHost {
9
+ const compilerHost = ts.createIncrementalCompilerHost(parsedTsconfig.options);
10
+
11
+ const cacheCompilerHost = { ...compilerHost };
12
+
13
+ cacheCompilerHost.fileExists = (fileName: string) => {
14
+ const cache = sourceFileCache.getOrCreate(PathUtil.posix(fileName), {});
15
+ if (cache.exists === undefined) {
16
+ cache.exists = compilerHost.fileExists.call(cacheCompilerHost, fileName);
17
+ }
18
+ return cache.exists;
19
+ };
20
+
21
+ cacheCompilerHost.getSourceFile = (fileName: string, languageVersion: ts.ScriptTarget) => {
22
+ const cache = sourceFileCache.getOrCreate(PathUtil.posix(fileName), {});
23
+ if (!cache.sourceFile) {
24
+ cache.sourceFile = compilerHost.getSourceFile.call(cacheCompilerHost, fileName, languageVersion);
25
+ }
26
+ return cache.sourceFile;
27
+ };
28
+
29
+ cacheCompilerHost.writeFile = (fileName: string,
30
+ data: string,
31
+ writeByteOrderMark: boolean,
32
+ onError?: (message: string) => void,
33
+ sourceFiles?: readonly ts.SourceFile[]) => {
34
+ fileName = fileName.replace(/\.js(\.map)?$/, ".mjs$1");
35
+
36
+ const writeCache = outputFileCache.get(PathUtil.posix(fileName));
37
+ if (writeCache !== data) {
38
+ outputFileCache.set(PathUtil.posix(fileName), data);
39
+ compilerHost.writeFile.call(cacheCompilerHost, fileName, data, writeByteOrderMark, onError, sourceFiles);
40
+ }
41
+ };
42
+
43
+ cacheCompilerHost.readFile = (fileName: string) => {
44
+ const cache = sourceFileCache.getOrCreate(PathUtil.posix(fileName), {});
45
+ if (cache.content === undefined) {
46
+ cache.content = compilerHost.readFile.call(cacheCompilerHost, fileName);
47
+ }
48
+ return cache.content;
49
+ };
50
+
51
+ cacheCompilerHost.resolveModuleNames = (moduleNames: string[], containingFile: string) => {
52
+ return moduleNames.map((moduleName) => {
53
+ return ts.resolveModuleName(
54
+ moduleName,
55
+ PathUtil.posix(containingFile),
56
+ parsedTsconfig.options,
57
+ compilerHost,
58
+ moduleResolutionCache
59
+ ).resolvedModule;
60
+ });
61
+ };
62
+
63
+ return cacheCompilerHost;
64
+ }
65
+ }
66
+
67
+ interface IFileCache {
68
+ exists?: boolean;
69
+ sourceFile?: ts.SourceFile;
70
+ content?: string;
71
+ }
@@ -0,0 +1,50 @@
1
+ import ts from "typescript";
2
+ import { PathUtil } from "@simplysm/sd-core-node";
3
+ import sass from "sass";
4
+ import { pathToFileURL, URL } from "url";
5
+
6
+ export class SdCliNgCacheCompilerHost {
7
+ public static wrap(compilerHost: ts.CompilerHost,
8
+ sourceFileCache: Map<string, IFileCache>): ts.CompilerHost {
9
+ const cacheCompilerHost = { ...compilerHost };
10
+
11
+ cacheCompilerHost["readResource"] = (fileName: string) => {
12
+ const cache = sourceFileCache.getOrCreate(PathUtil.posix(fileName), {});
13
+ if (cache.content === undefined) {
14
+ cache.content = compilerHost.readFile.call(cacheCompilerHost, fileName);
15
+ }
16
+ return cache.content;
17
+ };
18
+
19
+ cacheCompilerHost["transformResource"] = async (data, context) => {
20
+ if (context.resourceFile || context.type !== "style") {
21
+ return null;
22
+ }
23
+
24
+ const cache = sourceFileCache.getOrCreate(PathUtil.posix(context.containingFile), {});
25
+ if (cache.styleContent === undefined) {
26
+ cache.styleContent = (
27
+ await sass.compileStringAsync(data, {
28
+ url: new URL(context.containingFile + ".sd.scss"),
29
+ importer: {
30
+ findFileUrl: (url) => {
31
+ if (!url.startsWith("~")) return undefined;
32
+ return new URL(url.substring(1), pathToFileURL("node_modules"));
33
+ }
34
+ }
35
+ })
36
+ ).css.toString();
37
+ }
38
+ return { content: cache.styleContent };
39
+ };
40
+
41
+ return cacheCompilerHost;
42
+ }
43
+ }
44
+
45
+ interface IFileCache {
46
+ exists?: boolean;
47
+ sourceFile?: ts.SourceFile;
48
+ content?: string;
49
+ styleContent?: string;
50
+ }
@@ -0,0 +1,54 @@
1
+ import { ISdCliPackageBuildResult } from "../commons";
2
+ import ts from "typescript";
3
+ import { FsUtil } from "@simplysm/sd-core-node";
4
+ import path from "path";
5
+ import { ESLint } from "eslint";
6
+
7
+ export class SdCliPackageLinter {
8
+ private readonly _lintResultCache = new Map<string, ISdCliPackageBuildResult[]>();
9
+
10
+ public constructor(private readonly _rootPath: string) {
11
+ }
12
+
13
+ public async lintAsync(filePaths: string[], program?: ts.Program): Promise<ISdCliPackageBuildResult[]> {
14
+ if (!FsUtil.exists(path.resolve(this._rootPath, ".eslintrc.cjs"))) return [];
15
+
16
+ const linter = new ESLint(
17
+ program && filePaths.some((item) => item.endsWith(".ts")) ? {
18
+ overrideConfig: {
19
+ parserOptions: { program }
20
+ }
21
+ } : {}
22
+ );
23
+
24
+ const lintFilePaths = await filePaths
25
+ .filterAsync(async (filePath) => (
26
+ !filePath.endsWith(".d.ts") &&
27
+ !(await linter.isPathIgnored(filePath))
28
+ ));
29
+ for (const lintFilePath of lintFilePaths) {
30
+ this._lintResultCache.delete(lintFilePath);
31
+ }
32
+
33
+ const lintResults = await linter.lintFiles(lintFilePaths);
34
+
35
+
36
+ const result = lintResults.map((lintResult) => ({
37
+ filePath: lintResult.filePath,
38
+ results: lintResult.messages.map((msg) => ({
39
+ filePath: lintResult.filePath,
40
+ line: msg.line,
41
+ char: msg.column,
42
+ code: msg.ruleId ?? undefined,
43
+ severity: msg.severity === 1 ? "warning" as const : "error" as const,
44
+ message: msg.message
45
+ }))
46
+ }));
47
+
48
+ for (const resultItem of result) {
49
+ this._lintResultCache.set(resultItem.filePath, resultItem.results);
50
+ }
51
+
52
+ return Array.from(this._lintResultCache.values()).mapMany();
53
+ }
54
+ }
@@ -0,0 +1,66 @@
1
+ import { ISdCliPackageBuildResult } from "../commons";
2
+ import { EventEmitter } from "events";
3
+ import { FsUtil, Logger, SdFsWatcher } from "@simplysm/sd-core-node";
4
+ import * as path from "path";
5
+ import { SdCliPackageLinter } from "../build-tool/SdCliPackageLinter";
6
+
7
+ export class SdCliJsLibBuilder extends EventEmitter {
8
+ private readonly _logger = Logger.get(["simplysm", "sd-cli", this.constructor.name]);
9
+
10
+ private readonly _linter: SdCliPackageLinter;
11
+
12
+ public constructor(private readonly _rootPath: string) {
13
+ super();
14
+ this._linter = new SdCliPackageLinter(this._rootPath);
15
+ }
16
+
17
+ public override on(event: "change", listener: () => void): this;
18
+ public override on(event: "complete", listener: (results: ISdCliPackageBuildResult[]) => void): this;
19
+ public override on(event: string | symbol, listener: (...args: any[]) => void): this {
20
+ return super.on(event, listener);
21
+ }
22
+
23
+ public async watchAsync(): Promise<void> {
24
+ this.emit("change");
25
+
26
+ const relatedPaths = await this.getRelatedPathsAsync();
27
+ const watcher = SdFsWatcher.watch(relatedPaths);
28
+ watcher.onChange(async (changeInfos) => {
29
+ const changeFilePaths = changeInfos.filter((item) => ["add", "change", "unlink"].includes(item.event)).map((item) => item.path);
30
+ if(changeFilePaths.length === 0) return;
31
+
32
+ this._logger.debug("파일 변경 감지", changeInfos);
33
+ this.emit("change");
34
+
35
+ const watchBuildResults = await this._linter.lintAsync(changeFilePaths);
36
+
37
+ const watchRelatedPaths = await this.getRelatedPathsAsync();
38
+ watcher.add(watchRelatedPaths);
39
+
40
+ this.emit("complete", watchBuildResults);
41
+ });
42
+
43
+ // 빌드
44
+ const buildResults = await this._linter.lintAsync(relatedPaths);
45
+
46
+ this.emit("complete", buildResults);
47
+ }
48
+
49
+ public async buildAsync(): Promise<ISdCliPackageBuildResult[]> {
50
+ const relatedPaths = await this.getRelatedPathsAsync();
51
+ return await this._linter.lintAsync(relatedPaths);
52
+ }
53
+
54
+ private async getRelatedPathsAsync(): Promise<string[]> {
55
+ const mySourceGlobPath = path.resolve(this._rootPath, "**", "+(*.js|*.cjs|*.mjs|*.ts)");
56
+ const mySourceFilePaths = await FsUtil.globAsync(mySourceGlobPath, {
57
+ ignore: [
58
+ "**/node_modules/**",
59
+ "**/dist/**",
60
+ "**/.*/**"
61
+ ]
62
+ });
63
+
64
+ return [...mySourceFilePaths, path.resolve(this._rootPath, ".eslintrc.cjs")].distinct();
65
+ }
66
+ }