@simplysm/sd-cli 6.4.6 → 7.0.12

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 -145
  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 -242
  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
@@ -1,118 +0,0 @@
1
- import { ISdAutoIndexConfig, ISdLibraryPackageConfig, ISdPackageBuildResult, ITsconfig } from "../commons";
2
- import { ObjectUtil } from "@simplysm/sd-core-common";
3
- import * as path from "path";
4
- import { FsUtil, Logger, SdProcessManager, SdProcessWorkManager } from "@simplysm/sd-core-node";
5
- import { SdCliPackageBase } from "./SdCliPackageBase";
6
-
7
- export class SdCliLibraryPackage extends SdCliPackageBase {
8
- private readonly _logger: Logger;
9
-
10
- public on(event: "change", listener: (target: "node" | "browser" | undefined) => void): this;
11
- public on(event: "complete", listener: (target: "node" | "browser" | undefined, results: ISdPackageBuildResult[]) => void): this;
12
- public on(event: string | symbol, listener: (...args: any[]) => void): this {
13
- return super.on(event, listener);
14
- }
15
-
16
- public constructor(public readonly rootPath: string,
17
- public readonly config: ISdLibraryPackageConfig,
18
- private readonly _skipProcesses: ("emit" | "check" | "lint" | "genIndex")[],
19
- private readonly _processWorkManager: SdProcessWorkManager) {
20
- super(rootPath);
21
- this._logger = Logger.get(["simplysm", "sd-cli", this.constructor.name, this.npmConfig.name]);
22
- }
23
-
24
- public async buildAsync(): Promise<void> {
25
- await this._runBuildAsync(false);
26
- }
27
-
28
- public async watchAsync(): Promise<void> {
29
- await this._runBuildAsync(true);
30
- }
31
-
32
- public async publishAsync(): Promise<void> {
33
- if (this.config.publish === "npm") {
34
- await SdProcessManager.spawnAsync(
35
- "yarn publish --access public",
36
- { cwd: this.rootPath },
37
- false
38
- );
39
- }
40
- }
41
-
42
- private async _runBuildAsync(watch: boolean): Promise<void> {
43
- await this._genBuildTsconfigAsync();
44
-
45
- if (!this.config.targets || this.config.targets.length < 1) {
46
- await this._runWorkerAsync(undefined, watch, undefined);
47
- }
48
- else {
49
- const autoIndexConfig = this.config.autoIndex === undefined || this.config.autoIndex === false ? undefined : this.config.autoIndex === true ? {} : this.config.autoIndex;
50
- await this.config.targets.parallelAsync(async (target) => {
51
- await this._runWorkerAsync(target, watch, autoIndexConfig);
52
- });
53
- }
54
- }
55
-
56
- private async _runWorkerAsync(target: "node" | "browser" | "angular" | undefined, watch: boolean, autoIndexConfig: ISdAutoIndexConfig | undefined): Promise<void> {
57
- const worker = await this._processWorkManager.getNextWorkerAsync();
58
- worker.on("error", (err) => {
59
- this._logger.error(err, target ?? "none-target");
60
- });
61
-
62
- const sender = worker.createWorkSender();
63
- await sender
64
- .on("change", () => {
65
- this.emit("change", target);
66
- })
67
- .on("complete", (results) => {
68
- this.emit("complete", target, results);
69
- })
70
- .sendAsync(this.rootPath, target, watch, this._skipProcesses, autoIndexConfig);
71
- }
72
-
73
- private async _genBuildTsconfigAsync(): Promise<void> {
74
- if (!this.config.targets || this.config.targets.length < 1) {
75
- return;
76
- }
77
-
78
- const baseTsconfigFilePath = path.resolve(this.rootPath, "tsconfig.json");
79
- const baseTsconfig: ITsconfig = await FsUtil.readJsonAsync(baseTsconfigFilePath);
80
-
81
- await this.config.targets.parallelAsync(async (target, i) => {
82
- const buildTsconfig: ITsconfig = ObjectUtil.clone(baseTsconfig);
83
-
84
- buildTsconfig.compilerOptions = buildTsconfig.compilerOptions ?? {};
85
- delete buildTsconfig.compilerOptions.baseUrl;
86
- delete buildTsconfig.compilerOptions.paths;
87
-
88
- buildTsconfig.compilerOptions.target = target === "node" ? "es2020" : "es2015";
89
- buildTsconfig.compilerOptions.lib = target === "node" ? ["es2020"] : ["es2015", "dom"];
90
- buildTsconfig.compilerOptions.outDir = `dist-${target}`;
91
- if (i === 0) {
92
- buildTsconfig.compilerOptions.declaration = true;
93
- buildTsconfig.compilerOptions.declarationDir = "dist-types";
94
- buildTsconfig.compilerOptions.declarationMap = true;
95
- }
96
- else {
97
- buildTsconfig.compilerOptions.declaration = false;
98
- delete buildTsconfig.compilerOptions.declarationDir;
99
- }
100
-
101
- if (target === "angular") {
102
- buildTsconfig.compilerOptions.baseUrl = this.rootPath;
103
- buildTsconfig.angularCompilerOptions = {
104
- ...buildTsconfig.angularCompilerOptions ?? {},
105
- enableI18nLegacyMessageIdFormat: false,
106
- strictInjectionParameters: true,
107
- strictInputAccessModifiers: true,
108
- strictTemplates: true,
109
- strictInputTypes: false,
110
- strictOutputEventTypes: false
111
- };
112
- }
113
-
114
- const buildTsconfigFilePath = path.resolve(this.rootPath, `sd-tsconfig.${target}.json`);
115
- await FsUtil.writeJsonAsync(buildTsconfigFilePath, buildTsconfig, { space: 2 });
116
- });
117
- }
118
- }
@@ -1,34 +0,0 @@
1
- import { INpmConfig } from "../commons";
2
- import * as path from "path";
3
- import { FsUtil } from "@simplysm/sd-core-node";
4
- import { EventEmitter } from "events";
5
-
6
- export abstract class SdCliPackageBase extends EventEmitter {
7
- public readonly npmConfigFilePath: string;
8
- public readonly npmConfig: INpmConfig;
9
-
10
- protected constructor(public readonly rootPath: string) {
11
- super();
12
- this.npmConfigFilePath = path.resolve(this.rootPath, "package.json");
13
- this.npmConfig = FsUtil.readJson(this.npmConfigFilePath);
14
- }
15
-
16
- public async setNewVersionAsync(projectName: string, version: string): Promise<void> {
17
- this.npmConfig.version = version;
18
-
19
- const updateDepVersion = (deps: Record<string, string> | undefined): void => {
20
- if (!deps) return;
21
- for (const dependencyName of Object.keys(deps)) {
22
- if (dependencyName.startsWith("@" + projectName + "/")) {
23
- deps[dependencyName] = version;
24
- }
25
- }
26
- };
27
- updateDepVersion(this.npmConfig.dependencies);
28
- updateDepVersion(this.npmConfig.optionalDependencies);
29
- updateDepVersion(this.npmConfig.devDependencies);
30
- updateDepVersion(this.npmConfig.peerDependencies);
31
-
32
- await FsUtil.writeJsonAsync(this.npmConfigFilePath, this.npmConfig, { space: 2 });
33
- }
34
- }
@@ -1,85 +0,0 @@
1
- import { ISdPackageBuildResult, ISdServerPackageConfig, ITsconfig } from "../commons";
2
- import { ObjectUtil } from "@simplysm/sd-core-common";
3
- import * as path from "path";
4
- import { FsUtil } from "@simplysm/sd-core-node";
5
- import { SdCliServerBuilder } from "../builders/SdCliServerBuilder";
6
- import { SdServiceServer } from "@simplysm/sd-service-node";
7
- import { SdCliPackageBase } from "./SdCliPackageBase";
8
- import { SdCliPublisher } from "../builders/SdCliPublisher";
9
-
10
- export class SdCliServerPackage extends SdCliPackageBase {
11
- public on(event: "change", listener: (target: "node" | "browser" | undefined) => void): this;
12
- public on(event: "complete", listener: (target: "node" | "browser" | undefined, results: ISdPackageBuildResult[], server?: SdServiceServer) => void): this;
13
- public on(event: string | symbol, listener: (...args: any[]) => void): this {
14
- return super.on(event, listener);
15
- }
16
-
17
- public constructor(public readonly rootPath: string,
18
- public readonly config: ISdServerPackageConfig,
19
- public readonly skipProcesses: "lint"[]) {
20
- super(rootPath);
21
- }
22
-
23
- public async buildAsync(): Promise<void> {
24
- await this._genBuildTsconfigAsync();
25
-
26
- const buildTsconfigFilePath = path.resolve(this.rootPath, `sd-tsconfig.json`);
27
- const builder = new SdCliServerBuilder(this.rootPath, buildTsconfigFilePath, process.cwd(), this.config, this.skipProcesses);
28
-
29
- await builder
30
- .on("change", () => {
31
- this.emit("change", undefined);
32
- })
33
- .on("complete", (results) => {
34
- this.emit("complete", undefined, results);
35
- })
36
- .buildAsync();
37
- }
38
-
39
- public async publishAsync(): Promise<void> {
40
- if (this.config.publish) {
41
- const publisher = new SdCliPublisher(
42
- this.config.publish,
43
- path.resolve(this.rootPath, "dist"),
44
- this.npmConfig.version
45
- );
46
- await publisher.runAsync();
47
- }
48
- }
49
-
50
- public async watchAsync(): Promise<void> {
51
- await this._genBuildTsconfigAsync();
52
-
53
- const buildTsconfigFilePath = path.resolve(this.rootPath, `sd-tsconfig.json`);
54
- const builder = new SdCliServerBuilder(this.rootPath, buildTsconfigFilePath, process.cwd(), this.config, this.skipProcesses);
55
-
56
- await builder
57
- .on("change", () => {
58
- this.emit("change", undefined);
59
- })
60
- .on("complete", (results, server) => {
61
- this.emit("complete", undefined, results, server);
62
- })
63
- .watchAsync();
64
- }
65
-
66
- private async _genBuildTsconfigAsync(): Promise<void> {
67
- const baseTsconfigFilePath = path.resolve(this.rootPath, "tsconfig.json");
68
- const baseTsconfig: ITsconfig = await FsUtil.readJsonAsync(baseTsconfigFilePath);
69
-
70
- const buildTsconfig: ITsconfig = ObjectUtil.clone(baseTsconfig);
71
-
72
- buildTsconfig.compilerOptions = buildTsconfig.compilerOptions ?? {};
73
- delete buildTsconfig.compilerOptions.baseUrl;
74
- delete buildTsconfig.compilerOptions.paths;
75
- buildTsconfig.compilerOptions.target = "es2020";
76
- buildTsconfig.compilerOptions.lib = ["es2020"];
77
- buildTsconfig.compilerOptions.outDir = "dist";
78
-
79
- buildTsconfig.compilerOptions.declaration = false;
80
- delete buildTsconfig.compilerOptions.declarationDir;
81
-
82
- const buildTsconfigFilePath = path.resolve(this.rootPath, `sd-tsconfig.json`);
83
- await FsUtil.writeJsonAsync(buildTsconfigFilePath, buildTsconfig, { space: 2 });
84
- }
85
- }
@@ -1,14 +0,0 @@
1
- import { ISdPackageBuildResult } from "../commons";
2
- import { SdCliPackageBase } from "./SdCliPackageBase";
3
-
4
- export class SdCliUnknownPackage extends SdCliPackageBase {
5
- public on(event: "change", listener: (target: "node" | "browser" | undefined) => void): this;
6
- public on(event: "complete", listener: (target: "node" | "browser" | undefined, results: ISdPackageBuildResult[]) => void): this;
7
- public on(event: string | symbol, listener: (...args: any[]) => void): this {
8
- return super.on(event, listener);
9
- }
10
-
11
- public constructor(public readonly rootPath: string) {
12
- super(rootPath);
13
- }
14
- }
@@ -1,87 +0,0 @@
1
- import * as readline from "readline";
2
- import { Writable } from "stream";
3
- import * as crypto from "crypto";
4
- import { FsUtil } from "@simplysm/sd-core-node";
5
- import * as os from "os";
6
-
7
- export class SdCliFileCrypto {
8
- public async encryptAsync(filePath: string): Promise<void> {
9
- if (!FsUtil.exists(filePath)) {
10
- throw new Error(`파일 '${filePath}'을 찾을 수 없습니다.`);
11
- }
12
-
13
- const key = await this._readKeyAsync("password: ");
14
- if (!key) {
15
- throw new Error("암호화키를 반드시 입력해야 합니다.");
16
- }
17
-
18
- const confirmKey = await this._readKeyAsync("confirm password: ");
19
- if (key !== confirmKey) {
20
- throw new Error("암호화키가 서로 다릅니다.");
21
- }
22
-
23
- this._encryptFile(filePath, key, filePath + ".enc");
24
- }
25
-
26
- public async decryptAsync(encFilePath: string): Promise<void> {
27
- if (!FsUtil.exists(encFilePath)) {
28
- throw new Error(`파일 '${encFilePath}'을 찾을 수 없습니다.`);
29
- }
30
-
31
- if (!encFilePath.endsWith(".enc")) {
32
- throw new Error(`파일 ${encFilePath}의 확장자가 '.enc'가 아닙니다.`);
33
- }
34
-
35
- const resultFilePath = encFilePath.slice(0, -4);
36
- if (FsUtil.exists(resultFilePath)) {
37
- process.stdout.write(`복호화 시, 현재 존재하는 '${resultFilePath}'파일을 덮어씁니다.${os.EOL}`, "utf-8");
38
- }
39
-
40
- const key = await this._readKeyAsync("password: ");
41
- if (!key) {
42
- throw new Error("암호화키를 반드시 입력해야 합니다.");
43
- }
44
-
45
- this._decryptFile(encFilePath, key, resultFilePath);
46
- }
47
-
48
- private _encryptFile(filePath: string, key: string, encFilePath: string): void {
49
- const iv = Buffer.alloc(16, 0);
50
- const cipheriv = crypto.createCipheriv("aes-192-cbc", crypto.scryptSync(key, "salt", 24), iv);
51
-
52
- const input = FsUtil.createReadStream(filePath);
53
- const output = FsUtil.createWriteStream(encFilePath);
54
- input.pipe(cipheriv).pipe(output);
55
- }
56
-
57
- private _decryptFile(encFilePath: string, key: string, filePath: string): void {
58
- const iv = Buffer.alloc(16, 0);
59
- const cipheriv = crypto.createDecipheriv("aes-192-cbc", crypto.scryptSync(key, "salt", 24), iv);
60
-
61
- const input = FsUtil.createReadStream(encFilePath);
62
- const output = FsUtil.createWriteStream(filePath);
63
- input.pipe(cipheriv).pipe(output);
64
- }
65
-
66
- private async _readKeyAsync(message: string): Promise<string> {
67
- process.stdout.write(message, "utf-8");
68
-
69
- return await new Promise((resolve) => {
70
- const rl = readline.createInterface({
71
- input: process.stdin,
72
- output: new Writable({
73
- write: (chunk, encoding, callback) => {
74
- callback();
75
- }
76
- }),
77
- terminal: true
78
- });
79
-
80
- rl.question(message, (answer) => {
81
- process.stdout.write(os.EOL, "utf-8");
82
- resolve(answer);
83
- rl.close();
84
- });
85
- });
86
- }
87
- }
@@ -1,56 +0,0 @@
1
- import * as path from "path";
2
- import { FsUtil } from "@simplysm/sd-core-node";
3
- import { StringUtil } from "@simplysm/sd-core-common";
4
-
5
- export class SdCliUtils {
6
- public static findNpmConfigFilePathForSourceFile(filePath: string, rootPath?: string): string | undefined {
7
- let current = path.dirname(filePath);
8
- while (current) {
9
- const potential = path.resolve(current, "package.json");
10
- if (FsUtil.exists(potential) && !FsUtil.isDirectory(potential)) {
11
- return potential;
12
- }
13
-
14
- if (!StringUtil.isNullOrEmpty(rootPath) && current === rootPath) break;
15
-
16
- const next = path.dirname(current);
17
- if (next === current) break;
18
- current = next;
19
- }
20
-
21
- return undefined;
22
- }
23
-
24
- public static findModulePath(moduleName: string, currentPath: string, rootPath: string): string | undefined {
25
- const nodeModulesPaths = this.findAllNodeModulesPaths(currentPath, rootPath);
26
-
27
- for (const nodeModulePath of nodeModulesPaths) {
28
- const potential = path.join(nodeModulePath, moduleName);
29
- if (FsUtil.exists(potential)) {
30
- return potential;
31
- }
32
- }
33
-
34
- return undefined;
35
- }
36
-
37
- public static findAllNodeModulesPaths(fromPath: string, rootPath: string): string[] {
38
- const nodeModules: string[] = [];
39
-
40
- let current = fromPath;
41
- while (current) {
42
- const potential = path.join(current, "node_modules");
43
- if (FsUtil.exists(potential) && FsUtil.isDirectory(potential)) {
44
- nodeModules.push(potential);
45
- }
46
-
47
- if (current === rootPath) break;
48
-
49
- const next = path.dirname(current);
50
- if (next === current) break;
51
- current = next;
52
- }
53
-
54
- return nodeModules;
55
- }
56
- }
@@ -1,145 +0,0 @@
1
- import { ISdProjectConfig, TSdPackageConfig } from "../commons";
2
- import * as path from "path";
3
- import { FsUtil } from "@simplysm/sd-core-node";
4
- import { ObjectUtil } from "@simplysm/sd-core-common";
5
-
6
- export class SdProjectConfigUtil {
7
- /*public static async loadConfigAsync(rootPath: string, isDevMode?: boolean, options?: string[], configFilePath?: string): Promise<ISdProjectConfig> {
8
- const config = await this._loadConfigFileContentAsync(path.resolve(rootPath, configFilePath ?? "simplysm.json"));
9
-
10
- if (config.packages !== undefined) {
11
- const mode = isDevMode ? "development" : "production";
12
-
13
- for (const packageName of Object.keys(config.packages)) {
14
- // override 처리
15
- if (config.packages[packageName].overrides !== undefined) {
16
- for (const overrideKey of config.packages[packageName].overrides!) {
17
- const overrideObj = config.overrides![overrideKey];
18
- config.packages[packageName] = this._mergeObj(config.packages[packageName], overrideObj);
19
- }
20
- delete config.packages[packageName].overrides;
21
- }
22
-
23
- // mode 처리
24
- if (config.packages[packageName][mode] !== undefined) {
25
- config.packages[packageName] = this._mergeObj(config.packages[packageName], config.packages[packageName][mode]);
26
- }
27
- delete config.packages[packageName].development;
28
- delete config.packages[packageName].production;
29
-
30
- // options 처리
31
- if (options && options.length > 0) {
32
- const pkgOpts = Object.keys(config.packages[packageName])
33
- .filter((key) => key.startsWith("@") && options.some((opt) => opt === key.slice(1)));
34
-
35
- for (const pkgOpt of pkgOpts) {
36
- config.packages[packageName] = this._mergeObj(config.packages[packageName], config.packages[packageName][pkgOpt]);
37
- }
38
- }
39
-
40
- for (const optKey of Object.keys(config.packages[packageName]).filter((item) => item.startsWith("@"))) {
41
- delete config.packages[packageName][optKey];
42
- }
43
- }
44
- }
45
-
46
- return config as ISdProjectConfig;
47
- }
48
-
49
- private static async _loadConfigFileContentAsync(filePath: string): Promise<Omit<ISdProjectConfigFileContent, "extends">> {
50
- const orgConfig = await FsUtil.readJsonAsync(filePath) as ISdProjectConfigFileContent;
51
-
52
- let mergedConfig: ISdProjectConfigFileContent | undefined;
53
- if (orgConfig.extends) {
54
- for (const extConfigFilePath of orgConfig.extends) {
55
- const extConfigFileFullPath = path.resolve(path.dirname(filePath), extConfigFilePath);
56
- const extConfig = await this._loadConfigFileContentAsync(extConfigFileFullPath);
57
- mergedConfig = this._mergeObj(mergedConfig, extConfig);
58
- }
59
- }
60
- mergedConfig = this._mergeObj(mergedConfig, orgConfig);
61
-
62
- delete mergedConfig!.extends;
63
-
64
- return mergedConfig!;
65
- }*/
66
-
67
- public static async loadConfigAsync(rootPath: string, isDevMode?: boolean, options?: string[], configFilePath?: string): Promise<ISdProjectConfig> {
68
- const configFileFullPath = path.resolve(rootPath, configFilePath ?? "simplysm.json");
69
- const configFileContent = await FsUtil.readJsonAsync(configFileFullPath) as ISdProjectConfigFileContent;
70
- const orgConfig = this._loadConfig(configFileContent, isDevMode, options);
71
-
72
- let resultConfig: ISdProjectConfig | undefined;
73
- if (orgConfig.extends) {
74
- for (const extConfigFilePath of orgConfig.extends) {
75
- const extConfig = await this.loadConfigAsync(path.dirname(configFileFullPath), isDevMode, options, extConfigFilePath);
76
- resultConfig = this._mergeObj(resultConfig, extConfig);
77
- }
78
- }
79
- resultConfig = this._mergeObj(resultConfig, orgConfig);
80
-
81
- delete resultConfig!["extends"];
82
-
83
- return resultConfig!;
84
- }
85
-
86
- private static _loadConfig(configFileContent: ISdProjectConfigFileContent, isDevMode?: boolean, options?: string[]): (ISdProjectConfig & { extends?: string[] }) {
87
- const config = configFileContent;
88
-
89
- if (config.packages !== undefined) {
90
- const mode = isDevMode ? "development" : "production";
91
-
92
- for (const packageName of Object.keys(config.packages)) {
93
- // override 처리
94
- if (config.packages[packageName].overrides !== undefined) {
95
- for (const overrideKey of config.packages[packageName].overrides!) {
96
- const overrideObj = config.overrides![overrideKey];
97
- config.packages[packageName] = this._mergeObj(config.packages[packageName], overrideObj);
98
- }
99
- delete config.packages[packageName].overrides;
100
- }
101
-
102
- // mode 처리
103
- if (config.packages[packageName][mode] !== undefined) {
104
- config.packages[packageName] = this._mergeObj(config.packages[packageName], config.packages[packageName][mode]);
105
- }
106
- delete config.packages[packageName].development;
107
- delete config.packages[packageName].production;
108
-
109
- // options 처리
110
- if (options && options.length > 0) {
111
- const pkgOpts = Object.keys(config.packages[packageName])
112
- .filter((key) => key.startsWith("@") && options.some((opt) => opt === key.slice(1)));
113
-
114
- for (const pkgOpt of pkgOpts) {
115
- config.packages[packageName] = this._mergeObj(config.packages[packageName], config.packages[packageName][pkgOpt]);
116
- }
117
- }
118
-
119
- for (const optKey of Object.keys(config.packages[packageName]).filter((item) => item.startsWith("@"))) {
120
- delete config.packages[packageName][optKey];
121
- }
122
- }
123
- }
124
-
125
- return config as any;
126
- }
127
-
128
- private static _mergeObj<T>(org: T, target: Partial<T>): T {
129
- return ObjectUtil.merge(org, target, {
130
- arrayProcess: "replace",
131
- useDelTargetUndefined: true
132
- });
133
- }
134
- }
135
-
136
- interface ISdProjectConfigFileContent {
137
- packages?: Record<string, TSdPackageConfigFileContent>;
138
- extends?: string[];
139
- overrides?: Record<string, TSdPackageConfigFileContent>;
140
- }
141
-
142
- type TSdPackageConfigFileContent =
143
- Partial<TSdPackageConfig>
144
- & { overrides?: string[] }
145
- & Record<string, any>;
@@ -1,46 +0,0 @@
1
- import * as ts from "typescript";
2
- import * as os from "os";
3
- import * as path from "path";
4
- import { ISdPackageBuildResult } from "../commons";
5
-
6
- export class SdTsDiagnosticUtil {
7
- public static convertDiagnosticsToResult(diag: ts.Diagnostic): ISdPackageBuildResult | undefined {
8
- const severity = ts.DiagnosticCategory[diag.category].toLowerCase();
9
- if (severity !== "error" && severity !== "warning") {
10
- return undefined;
11
- }
12
-
13
- const code = "TS" + diag.code;
14
- const messageText = ts.flattenDiagnosticMessageText(diag.messageText, os.EOL);
15
-
16
- if (diag.file?.fileName !== undefined) {
17
- const filePath = path.resolve(diag.file.fileName);
18
-
19
- if (diag.start !== undefined) {
20
- const position = diag.file.getLineAndCharacterOfPosition(diag.start);
21
- const line = position.line + 1;
22
- const char = position.character + 1;
23
-
24
- return {
25
- filePath,
26
- severity,
27
- message: `${filePath}(${line}, ${char}): ${code}: ${severity} ${messageText}`
28
- };
29
- }
30
- else {
31
- return {
32
- filePath,
33
- severity,
34
- message: `${filePath}(0, 0): ${code}: ${severity} ${messageText}`
35
- };
36
- }
37
- }
38
- else {
39
- return {
40
- filePath: undefined,
41
- severity,
42
- message: `${code}: ${severity} ${messageText}`
43
- };
44
- }
45
- }
46
- }
@@ -1,71 +0,0 @@
1
- import { ISdPackageBuildResult } from "../commons";
2
- import * as webpack from "webpack";
3
- import { NeverEntryError } from "@simplysm/sd-core-common";
4
-
5
- export class SdWebpackUtil {
6
- public static getWebpackResults(stats: Error | webpack.Stats): ISdPackageBuildResult[] {
7
- if (stats instanceof Error) {
8
- return [{
9
- filePath: undefined,
10
- severity: "error",
11
- message: stats.stack ?? stats.message
12
- }];
13
- }
14
-
15
- const results: ISdPackageBuildResult[] = [];
16
-
17
- for (const warn of stats.compilation.warnings) {
18
- if (stats.compilation.options.ignoreWarnings?.some((ignoreWarning) => ignoreWarning(warn, stats.compilation))) continue;
19
-
20
- results.push({
21
- filePath: undefined,
22
- severity: "warning",
23
- message: this._errorToMessage(warn)
24
- });
25
- }
26
-
27
- for (const err of stats.compilation.errors) {
28
- results.push({
29
- filePath: undefined,
30
- severity: "error",
31
- message: this._errorToMessage(err)
32
- });
33
- }
34
-
35
- return results;
36
- }
37
-
38
- private static _errorToMessage(err: Partial<webpack.WebpackError>): string {
39
- let result = "";
40
-
41
- if ("error" in err && "originalSassError" in err["error"]) {
42
- const sassError = err["error"]["originalSassError"];
43
- result += sassError.file.replace(/^\.\//, "");
44
- // result += `(${sassError.line as number}${sassError.column !== undefined ? `, ${sassError.column as number}` : ""})`;
45
- result += ": ";
46
- result += err.name + ": ";
47
- result += err.message;
48
- }
49
- else {
50
- const filePath = err.file ?? err.module?.nameForCondition();
51
- if (filePath != null) {
52
- result += filePath.replace(/^\.\//, "");
53
- if (err.loc !== undefined) {
54
- if ("start" in err.loc) {
55
- result += `(${err.loc.start.line}${err.loc.start.column !== undefined ? `, ${err.loc.start.column}` : ""})`;
56
- }
57
- else {
58
- throw new NeverEntryError();
59
- }
60
- }
61
- result += ": ";
62
-
63
- result += err.name + ": ";
64
- }
65
-
66
- result += err.message;
67
- }
68
-
69
- return result;
70
- }
71
- }