@simplysm/sd-cli 6.0.19 → 6.0.27

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 (99) hide show
  1. package/.eslintrc.js +1 -2
  2. package/dist-node/bin/sd-cli.js +25 -8
  3. package/dist-node/bin/sd-cli.js.map +1 -1
  4. package/dist-node/build-tools/SdCliIndexFileGenerator.js +51 -0
  5. package/dist-node/build-tools/SdCliIndexFileGenerator.js.map +1 -0
  6. package/dist-node/build-tools/SdCliNgModuleFilesGenerator.js +621 -0
  7. package/dist-node/build-tools/SdCliNgModuleFilesGenerator.js.map +1 -0
  8. package/dist-node/build-tools/metadata/SdAotMetadataReader.js +270 -0
  9. package/dist-node/build-tools/metadata/SdAotMetadataReader.js.map +1 -0
  10. package/dist-node/build-tools/metadata/SdIvyMetadataReader.js +101 -0
  11. package/dist-node/build-tools/metadata/SdIvyMetadataReader.js.map +1 -0
  12. package/dist-node/build-tools/metadata/SdMyMetadataReader.js +298 -0
  13. package/dist-node/build-tools/metadata/SdMyMetadataReader.js.map +1 -0
  14. package/dist-node/{build-tools → builders}/SdCliJavascriptLinter.js +1 -1
  15. package/dist-node/builders/SdCliJavascriptLinter.js.map +1 -0
  16. package/dist-node/{build-tools → builders}/SdCliNgClientBuilder.js +176 -102
  17. package/dist-node/builders/SdCliNgClientBuilder.js.map +1 -0
  18. package/dist-node/builders/SdCliNgLibraryBuilder.js +238 -0
  19. package/dist-node/builders/SdCliNgLibraryBuilder.js.map +1 -0
  20. package/dist-node/{build-tools → builders}/SdCliPublisher.js +0 -0
  21. package/dist-node/builders/SdCliPublisher.js.map +1 -0
  22. package/dist-node/{build-tools → builders}/SdCliServerBuilder.js +8 -6
  23. package/dist-node/builders/SdCliServerBuilder.js.map +1 -0
  24. package/dist-node/builders/SdCliTypescriptBuilder.js +304 -0
  25. package/dist-node/builders/SdCliTypescriptBuilder.js.map +1 -0
  26. package/dist-node/entry-points/SdCliLocalUpdater.js +9 -8
  27. package/dist-node/entry-points/SdCliLocalUpdater.js.map +1 -1
  28. package/dist-node/entry-points/SdCliProject.js +11 -9
  29. package/dist-node/entry-points/SdCliProject.js.map +1 -1
  30. package/dist-node/packages/SdCliClientPackage.js +12 -2
  31. package/dist-node/packages/SdCliClientPackage.js.map +1 -1
  32. package/dist-node/packages/SdCliLibraryPackage.js +17 -9
  33. package/dist-node/packages/SdCliLibraryPackage.js.map +1 -1
  34. package/dist-node/packages/SdCliServerPackage.js +2 -2
  35. package/dist-node/packages/SdCliServerPackage.js.map +1 -1
  36. package/dist-node/utils/SdCliFileCrypto.js +76 -0
  37. package/dist-node/utils/SdCliFileCrypto.js.map +1 -0
  38. package/dist-node/utils/SdProjectConfigUtil.js +1 -1
  39. package/dist-node/utils/SdProjectConfigUtil.js.map +1 -1
  40. package/dist-node/utils/SdWebpackUtil.js +12 -3
  41. package/dist-node/utils/SdWebpackUtil.js.map +1 -1
  42. package/dist-node/workers/lib-build-worker.js +7 -6
  43. package/dist-node/workers/lib-build-worker.js.map +1 -1
  44. package/dist-types/build-tools/SdCliIndexFileGenerator.d.ts +12 -0
  45. package/dist-types/build-tools/SdCliNgModuleFilesGenerator.d.ts +42 -0
  46. package/dist-types/build-tools/metadata/SdAotMetadataReader.d.ts +57 -0
  47. package/dist-types/build-tools/metadata/SdIvyMetadataReader.d.ts +41 -0
  48. package/dist-types/build-tools/metadata/SdMyMetadataReader.d.ts +57 -0
  49. package/dist-types/{build-tools → builders}/SdCliJavascriptLinter.d.ts +0 -0
  50. package/dist-types/{build-tools → builders}/SdCliNgClientBuilder.d.ts +1 -1
  51. package/dist-types/builders/SdCliNgLibraryBuilder.d.ts +27 -0
  52. package/dist-types/{build-tools → builders}/SdCliPublisher.d.ts +0 -0
  53. package/dist-types/{build-tools → builders}/SdCliServerBuilder.d.ts +0 -0
  54. package/dist-types/builders/SdCliTypescriptBuilder.d.ts +46 -0
  55. package/dist-types/commons.d.ts +11 -3
  56. package/dist-types/packages/SdCliClientPackage.d.ts +1 -1
  57. package/dist-types/utils/SdCliFileCrypto.d.ts +7 -0
  58. package/dist-types/utils/SdWebpackUtil.d.ts +1 -0
  59. package/package.json +10 -7
  60. package/schema/schema.json +247 -0
  61. package/src/bin/sd-cli.ts +37 -14
  62. package/src/build-tools/SdCliIndexFileGenerator.ts +61 -0
  63. package/src/build-tools/SdCliNgModuleFilesGenerator.ts +837 -0
  64. package/src/build-tools/metadata/SdAotMetadataReader.ts +368 -0
  65. package/src/build-tools/metadata/SdIvyMetadataReader.ts +152 -0
  66. package/src/build-tools/metadata/SdMyMetadataReader.ts +379 -0
  67. package/src/{build-tools → builders}/SdCliJavascriptLinter.ts +1 -1
  68. package/src/{build-tools → builders}/SdCliNgClientBuilder.ts +209 -111
  69. package/src/builders/SdCliNgLibraryBuilder.ts +336 -0
  70. package/src/{build-tools → builders}/SdCliPublisher.ts +0 -0
  71. package/src/{build-tools → builders}/SdCliServerBuilder.ts +14 -8
  72. package/src/builders/SdCliTypescriptBuilder.ts +488 -0
  73. package/src/commons.ts +11 -3
  74. package/src/entry-points/SdCliLocalUpdater.ts +9 -8
  75. package/src/entry-points/SdCliProject.ts +12 -9
  76. package/src/packages/SdCliClientPackage.ts +14 -3
  77. package/src/packages/SdCliLibraryPackage.ts +19 -11
  78. package/src/packages/SdCliServerPackage.ts +2 -2
  79. package/src/utils/SdCliFileCrypto.ts +87 -0
  80. package/src/utils/SdCliUtils.ts +56 -0
  81. package/src/utils/SdProjectConfigUtil.ts +1 -1
  82. package/src/utils/SdWebpackUtil.ts +13 -3
  83. package/src/workers/lib-build-worker.ts +8 -7
  84. package/dist-node/build-tools/SdCliJavascriptLinter.js.map +0 -1
  85. package/dist-node/build-tools/SdCliNgClientBuilder.js.map +0 -1
  86. package/dist-node/build-tools/SdCliNgLibraryBuilder.js +0 -164
  87. package/dist-node/build-tools/SdCliNgLibraryBuilder.js.map +0 -1
  88. package/dist-node/build-tools/SdCliPublisher.js.map +0 -1
  89. package/dist-node/build-tools/SdCliServerBuilder.js.map +0 -1
  90. package/dist-node/build-tools/SdCliTypescriptBuilder.js +0 -316
  91. package/dist-node/build-tools/SdCliTypescriptBuilder.js.map +0 -1
  92. package/dist-node/build-tools/SdCliTypescriptIndexFileGenerator.js +0 -75
  93. package/dist-node/build-tools/SdCliTypescriptIndexFileGenerator.js.map +0 -1
  94. package/dist-types/build-tools/SdCliNgLibraryBuilder.d.ts +0 -23
  95. package/dist-types/build-tools/SdCliTypescriptBuilder.d.ts +0 -37
  96. package/dist-types/build-tools/SdCliTypescriptIndexFileGenerator.d.ts +0 -12
  97. package/src/build-tools/SdCliNgLibraryBuilder.ts +0 -225
  98. package/src/build-tools/SdCliTypescriptBuilder.ts +0 -424
  99. package/src/build-tools/SdCliTypescriptIndexFileGenerator.ts +0 -93
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@simplysm/sd-cli",
3
- "version": "6.0.19",
3
+ "version": "6.0.27",
4
4
  "description": "심플리즘 패키지 - CLI",
5
5
  "author": "김석래",
6
6
  "repository": "github:kslhunter/simplysm",
@@ -13,9 +13,9 @@
13
13
  "sideEffects": false,
14
14
  "dependencies": {
15
15
  "yargs": "^17.1.1",
16
- "@simplysm/sd-core-common": "6.0.19",
17
- "@simplysm/sd-core-node": "6.0.19",
18
- "@simplysm/sd-service-node": "6.0.19",
16
+ "@simplysm/sd-core-common": "6.0.27",
17
+ "@simplysm/sd-core-node": "6.0.27",
18
+ "@simplysm/sd-service-node": "6.0.27",
19
19
  "eslint": "^7.32.0",
20
20
  "@typescript-eslint/parser": "4.28.2",
21
21
  "@typescript-eslint/typescript-estree": "4.28.2",
@@ -44,10 +44,11 @@
44
44
  "css-loader": "^6.2.0",
45
45
  "semver": "^7.3.5",
46
46
  "source-map-loader": "^3.0.0",
47
- "os-browserify": "^0.3.0",
48
47
  "buffer": "^6.0.3",
49
48
  "browserslist": "^4.16.8",
50
- "@simplysm/sd-storage": "6.0.19"
49
+ "@simplysm/sd-storage": "6.0.27",
50
+ "webpack-hot-middleware": "^2.25.0",
51
+ "jsdom": "^17.0.0"
51
52
  },
52
53
  "devDependencies": {
53
54
  "@types/yargs": "^17.0.2",
@@ -56,6 +57,8 @@
56
57
  "@types/mini-css-extract-plugin": "^2.2.0",
57
58
  "@types/copy-webpack-plugin": "^8.0.1",
58
59
  "@types/webpack-dev-middleware": "^5.0.2",
59
- "@types/semver": "^7.3.8"
60
+ "@types/webpack-hot-middleware": "^2.25.5",
61
+ "@types/semver": "^7.3.8",
62
+ "@types/jsdom": "^16.2.13"
60
63
  }
61
64
  }
@@ -0,0 +1,247 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft-07/schema",
3
+ "type": "object",
4
+ "additionalProperties": false,
5
+ "definitions": {
6
+ "schemaPackage": {
7
+ "type": "object",
8
+ "additionalProperties": false,
9
+ "properties": {
10
+ "overrides": {
11
+ "type": "array",
12
+ "uniqueItems": true,
13
+ "items": {
14
+ "type": "string"
15
+ }
16
+ },
17
+ "production": {
18
+ "$ref": "#/definitions/schemaPackage"
19
+ },
20
+ "development": {
21
+ "$ref": "#/definitions/schemaPackage"
22
+ }
23
+ },
24
+ "oneOf": [
25
+ {
26
+ "properties": {
27
+ "type": {
28
+ "enum": [
29
+ "library"
30
+ ]
31
+ },
32
+ "targets": {
33
+ "type": "array",
34
+ "uniqueItems": true,
35
+ "items": {
36
+ "enum": [
37
+ "browser",
38
+ "node",
39
+ "angular"
40
+ ]
41
+ }
42
+ },
43
+ "autoIndex": {
44
+ "oneOf": [
45
+ {
46
+ "type": "object",
47
+ "additionalProperties": false,
48
+ "properties": {
49
+ "polyfills": {
50
+ "type": "array",
51
+ "uniqueItems": true,
52
+ "items": {
53
+ "type": "string"
54
+ }
55
+ }
56
+ }
57
+ },
58
+ {
59
+ "type": "boolean"
60
+ }
61
+ ]
62
+ },
63
+ "publish": {
64
+ "enum": [
65
+ "npm"
66
+ ]
67
+ }
68
+ }
69
+ },
70
+ {
71
+ "properties": {
72
+ "type": {
73
+ "enum": [
74
+ "client"
75
+ ]
76
+ },
77
+ "server": {
78
+ "type": "string",
79
+ },
80
+ "resolveFallback": {
81
+ "type": "object",
82
+ "additionalProperties": {
83
+ "type": "string"
84
+ }
85
+ }
86
+ }
87
+ },
88
+ {
89
+ "properties": {
90
+ "type": {
91
+ "enum": [
92
+ "server"
93
+ ]
94
+ },
95
+ "pm2": {
96
+ "type": "object"
97
+ },
98
+ "iis": {
99
+ "type": "boolean"
100
+ },
101
+ "configs": {
102
+ "type": "object",
103
+ "properties": {
104
+ "orm": {
105
+ "type": "object",
106
+ "additionalProperties": {
107
+ "type": "object",
108
+ "additionalProperties": false,
109
+ "properties": {
110
+ "host": {
111
+ "type": "string"
112
+ },
113
+ "port": {
114
+ "type": "number"
115
+ },
116
+ "username": {
117
+ "type": "string"
118
+ },
119
+ "password": {
120
+ "type": "string"
121
+ },
122
+ "defaultIsolationLevel": {
123
+ "enum": [
124
+ "READ_UNCOMMITTED",
125
+ "READ_COMMITTED",
126
+ "REPEATABLE_READ",
127
+ "SERIALIZABLE"
128
+ ]
129
+ }
130
+ },
131
+ "oneOf": [
132
+ {
133
+ "properties": {
134
+ "dialect": {
135
+ "enum": [
136
+ "mssql"
137
+ ]
138
+ },
139
+ "database": {
140
+ "type": "string"
141
+ }
142
+ }
143
+ },
144
+ {
145
+ "properties": {
146
+ "dialect": {
147
+ "enum": [
148
+ "mssql-azure"
149
+ ]
150
+ },
151
+ "database": {
152
+ "type": "string"
153
+ }
154
+ },
155
+ "required": [
156
+ "database"
157
+ ]
158
+ }
159
+ ],
160
+ "required": [
161
+ "username",
162
+ "password"
163
+ ]
164
+ }
165
+ },
166
+ "smtp": {
167
+ "type": "object",
168
+ "additionalProperties": {
169
+ "type": "object",
170
+ "additionalProperties": false,
171
+ "properties": {
172
+ "name": {
173
+ "type": "string"
174
+ },
175
+ "email": {
176
+ "type": "string"
177
+ },
178
+ "user": {
179
+ "type": "string"
180
+ },
181
+ "pass": {
182
+ "type": "string"
183
+ },
184
+ "host": {
185
+ "type": "string"
186
+ },
187
+ "port": {
188
+ "type": "number"
189
+ },
190
+ "secure": {
191
+ "type": "boolean"
192
+ }
193
+ },
194
+ "required": [
195
+ "name",
196
+ "email",
197
+ "user",
198
+ "pass",
199
+ "host"
200
+ ]
201
+ }
202
+ },
203
+ "crypto": {
204
+ "type": "object",
205
+ "additionalProperties": false,
206
+ "properties": {
207
+ "key": {
208
+ "type": "string"
209
+ }
210
+ },
211
+ "required": [
212
+ "key"
213
+ ]
214
+ }
215
+ },
216
+ "additionalProperties": {
217
+ }
218
+ }
219
+ }
220
+ }
221
+ ]
222
+ }
223
+ },
224
+ "properties": {
225
+ "$schema": {
226
+ "type": "string"
227
+ },
228
+ "extends": {
229
+ "type": "string"
230
+ },
231
+ "packages": {
232
+ "type": "object",
233
+ "additionalProperties": {
234
+ "$ref": "#/definitions/schemaPackage",
235
+ "required": [
236
+ "type"
237
+ ]
238
+ }
239
+ },
240
+ "overrides": {
241
+ "type": "object",
242
+ "additionalProperties": {
243
+ "$ref": "#/definitions/schemaPackage"
244
+ }
245
+ }
246
+ }
247
+ }
package/src/bin/sd-cli.ts CHANGED
@@ -6,14 +6,13 @@ import { EventEmitter } from "events";
6
6
  import { Logger, LoggerSeverity } from "@simplysm/sd-core-node";
7
7
  import { SdCliProject } from "../entry-points/SdCliProject";
8
8
  import { SdCliLocalUpdater } from "../entry-points/SdCliLocalUpdater";
9
+ import { SdCliFileCrypto } from "../utils/SdCliFileCrypto";
9
10
 
10
11
  EventEmitter.defaultMaxListeners = 0;
11
12
  process.setMaxListeners(0);
12
13
 
13
14
  const logger = Logger.get(["simplysm", "sd-cli"]);
14
15
 
15
-
16
- // TODO: 모든 LOGGER에 PACKAGE_NAME과 TARGET 추가 (CONSTRUCTOR사용, npmConfig 및 target INPUT이 필요할 수 있음)
17
16
  (async (): Promise<void> => {
18
17
  const argv = await yargs.version(false)
19
18
  .help("help", "도움말")
@@ -67,17 +66,6 @@ const logger = Logger.get(["simplysm", "sd-cli"]);
67
66
  }
68
67
  })
69
68
  )
70
- .command(
71
- "local-update",
72
- "로컬 라이브러리 업데이트를 수행합니다.",
73
- (cmd) => cmd.version(false)
74
- .options({
75
- config: {
76
- type: "string",
77
- describe: "simplysm.json 파일 경로"
78
- }
79
- })
80
- )
81
69
  .command(
82
70
  "publish",
83
71
  "프로젝트의 각 패키지를 배포합니다.",
@@ -104,6 +92,35 @@ const logger = Logger.get(["simplysm", "sd-cli"]);
104
92
  }
105
93
  })
106
94
  )
95
+ .command(
96
+ "local-update",
97
+ "로컬 라이브러리 업데이트를 수행합니다.",
98
+ (cmd) => cmd.version(false)
99
+ .options({
100
+ config: {
101
+ type: "string",
102
+ describe: "simplysm.json 파일 경로"
103
+ }
104
+ })
105
+ )
106
+ .command(
107
+ "enc-file <file>",
108
+ "파일을 암호화 합니다.",
109
+ (cmd) => cmd.version(false)
110
+ .positional("file", {
111
+ type: "string",
112
+ describe: "암호화할 파일명"
113
+ })
114
+ )
115
+ .command(
116
+ "dec-file <file>",
117
+ "파일을 복호화 합니다.",
118
+ (cmd) => cmd.version(false)
119
+ .positional("file", {
120
+ type: "string",
121
+ describe: "암호화된 파일명"
122
+ })
123
+ )
107
124
  .parse();
108
125
 
109
126
  if (argv.debug) {
@@ -146,7 +163,7 @@ const logger = Logger.get(["simplysm", "sd-cli"]);
146
163
  else if (args[0] === "local-update") {
147
164
  await new SdCliLocalUpdater(process.cwd()).localUpdateAsync(false, { config: argv.config });
148
165
  }
149
- else if (argv._[0] === "publish") {
166
+ else if (args[0] === "publish") {
150
167
  await new SdCliProject(process.cwd())
151
168
  .publishAsync({
152
169
  build: argv.build,
@@ -156,6 +173,12 @@ const logger = Logger.get(["simplysm", "sd-cli"]);
156
173
  });
157
174
  process.exit(0);
158
175
  }
176
+ else if (args[0] === "enc-file") {
177
+ await new SdCliFileCrypto().encryptAsync(argv.file!);
178
+ }
179
+ else if (args[0] === "dec-file") {
180
+ await new SdCliFileCrypto().decryptAsync(argv.file!);
181
+ }
159
182
  else {
160
183
  throw new Error(`명령어가 잘못되었습니다.${os.EOL + os.EOL}\t${argv._[0]}${os.EOL}`);
161
184
  }
@@ -0,0 +1,61 @@
1
+ import { ISdAutoIndexConfig, ISdPackageBuildResult, ITsconfig } from "../commons";
2
+ import * as path from "path";
3
+ import { FsUtil, PathUtil } from "@simplysm/sd-core-node";
4
+ import * as os from "os";
5
+
6
+ export class SdCliIndexFileGenerator {
7
+ public readonly indexFilePath = PathUtil.posix(this.rootPath, "src/index.ts");
8
+
9
+ public constructor(public readonly rootPath: string,
10
+ public readonly config: ISdAutoIndexConfig) {
11
+ }
12
+
13
+
14
+ public async generateAsync(): Promise<{ result: ISdPackageBuildResult[]; changed: boolean }> {
15
+ const importTexts: string[] = [];
16
+
17
+ // simplysm.json 에 등록된 polyfills 를 모두 import
18
+ if (this.config.polyfills) {
19
+ for (const polyfill of this.config.polyfills) {
20
+ importTexts.push(`import "${polyfill}";`);
21
+ }
22
+ }
23
+
24
+ // 파일들 import
25
+ const filePaths = await this._getFilePathsAsync();
26
+ for (const filePath of filePaths) {
27
+ const requirePath = PathUtil.posix(path.relative(path.dirname(this.indexFilePath), filePath))
28
+ .replace(/\.ts$/, "")
29
+ .replace(/\/index$/, "");
30
+
31
+ const sourceTsFileContent = await FsUtil.readFileAsync(filePath);
32
+ if (sourceTsFileContent.split("\n").some((line) => line.startsWith("export "))) {
33
+ importTexts.push(`export * from "./${requirePath}";`);
34
+ }
35
+ else {
36
+ importTexts.push(`import "./${requirePath}";`);
37
+ }
38
+ }
39
+
40
+ let changed = false;
41
+ const content = importTexts.join(os.EOL) + os.EOL;
42
+ const prevContent = FsUtil.exists(this.indexFilePath) ? FsUtil.readFile(this.indexFilePath) : undefined;
43
+ if (content !== prevContent) {
44
+ await FsUtil.writeFileAsync(this.indexFilePath, content);
45
+ changed = true;
46
+ }
47
+
48
+ return { result: [], changed };
49
+ }
50
+
51
+ private async _getFilePathsAsync(): Promise<string[]> {
52
+ const tsconfig: ITsconfig = await FsUtil.readJsonAsync(path.resolve(this.rootPath, "tsconfig.json"));
53
+ const entryFilePaths = tsconfig.files?.map((item) => path.resolve(this.rootPath, item)) ?? [];
54
+
55
+ return (await FsUtil.globAsync(path.resolve(this.rootPath, "src/**/*.ts"), { nodir: true }))
56
+ .filter((item) => (
57
+ !entryFilePaths.includes(item)
58
+ && item !== this.indexFilePath
59
+ ));
60
+ }
61
+ }