@webiny/cli-core 0.0.0-unstable.6844005670 → 0.0.0-unstable.7be00a75a9

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 (268) hide show
  1. package/Cli.js +12 -11
  2. package/Cli.js.map +1 -1
  3. package/abstractions/createAbstraction.js +3 -2
  4. package/abstractions/createAbstraction.js.map +1 -1
  5. package/abstractions/features/CliCommand.d.ts +3 -0
  6. package/abstractions/features/CliCommand.js +2 -1
  7. package/abstractions/features/CliCommand.js.map +1 -1
  8. package/abstractions/features/ErrorHandler.js +2 -1
  9. package/abstractions/features/ErrorHandler.js.map +1 -1
  10. package/abstractions/features/GlobalCliOption.js +2 -1
  11. package/abstractions/features/GlobalCliOption.js.map +1 -1
  12. package/abstractions/features/IsCi.js +2 -1
  13. package/abstractions/features/IsCi.js.map +1 -1
  14. package/abstractions/features/index.js +0 -2
  15. package/abstractions/features/types.js +0 -3
  16. package/abstractions/index.js +0 -2
  17. package/abstractions/services/ArgvParserService.js +2 -1
  18. package/abstractions/services/ArgvParserService.js.map +1 -1
  19. package/abstractions/services/CliParamsService.js +2 -1
  20. package/abstractions/services/CliParamsService.js.map +1 -1
  21. package/abstractions/services/CommandsRegistryService.js +2 -1
  22. package/abstractions/services/CommandsRegistryService.js.map +1 -1
  23. package/abstractions/services/GetArgvService.js +2 -1
  24. package/abstractions/services/GetArgvService.js.map +1 -1
  25. package/abstractions/services/GetCliRunnerService.js +2 -1
  26. package/abstractions/services/GetCliRunnerService.js.map +1 -1
  27. package/abstractions/services/GetIsCiService.js +2 -1
  28. package/abstractions/services/GetIsCiService.js.map +1 -1
  29. package/abstractions/services/GetProjectSdkService.js +2 -1
  30. package/abstractions/services/GetProjectSdkService.js.map +1 -1
  31. package/abstractions/services/GlobalOptionsRegistryService.js +2 -1
  32. package/abstractions/services/GlobalOptionsRegistryService.js.map +1 -1
  33. package/abstractions/services/LoggerService.js +2 -1
  34. package/abstractions/services/LoggerService.js.map +1 -1
  35. package/abstractions/services/RunCliRunnerService.js +2 -1
  36. package/abstractions/services/RunCliRunnerService.js.map +1 -1
  37. package/abstractions/services/StdioService.js +2 -1
  38. package/abstractions/services/StdioService.js.map +1 -1
  39. package/abstractions/services/UiService.js +2 -1
  40. package/abstractions/services/UiService.js.map +1 -1
  41. package/abstractions/services/index.js +0 -2
  42. package/createCliContainer.js +89 -118
  43. package/createCliContainer.js.map +1 -1
  44. package/decorators/CommandsWithGracefulErrorHandling.js +34 -32
  45. package/decorators/CommandsWithGracefulErrorHandling.js.map +1 -1
  46. package/decorators/DeployCommandWithTelemetry.js +72 -82
  47. package/decorators/DeployCommandWithTelemetry.js.map +1 -1
  48. package/decorators/index.js +0 -2
  49. package/exports/cli/command.js +0 -2
  50. package/exports/cli.d.ts +2 -0
  51. package/exports/cli.js +2 -0
  52. package/extensions/CliCommand.d.ts +3 -7
  53. package/extensions/CliCommand.js +15 -18
  54. package/extensions/CliCommand.js.map +1 -1
  55. package/extensions/CliCommandDecorator.d.ts +3 -7
  56. package/extensions/CliCommandDecorator.js +15 -18
  57. package/extensions/CliCommandDecorator.js.map +1 -1
  58. package/extensions/index.d.ts +2 -6
  59. package/extensions/index.js +5 -2
  60. package/extensions/index.js.map +1 -1
  61. package/features/AboutCommand.js +80 -86
  62. package/features/AboutCommand.js.map +1 -1
  63. package/features/BuildCommand/BuildCommand.js +46 -36
  64. package/features/BuildCommand/BuildCommand.js.map +1 -1
  65. package/features/BuildCommand/buildRunners/BaseBuildRunner.js +10 -13
  66. package/features/BuildCommand/buildRunners/BaseBuildRunner.js.map +1 -1
  67. package/features/BuildCommand/buildRunners/BuildRunner.js +18 -21
  68. package/features/BuildCommand/buildRunners/BuildRunner.js.map +1 -1
  69. package/features/BuildCommand/buildRunners/MultipleBuildsRunner.js +20 -19
  70. package/features/BuildCommand/buildRunners/MultipleBuildsRunner.js.map +1 -1
  71. package/features/BuildCommand/buildRunners/SingleBuildRunner.js +15 -14
  72. package/features/BuildCommand/buildRunners/SingleBuildRunner.js.map +1 -1
  73. package/features/BuildCommand/buildRunners/ZeroBuildsRunner.js +3 -4
  74. package/features/BuildCommand/buildRunners/ZeroBuildsRunner.js.map +1 -1
  75. package/features/BuildCommand/index.js +0 -2
  76. package/features/ConfigCommand.js +55 -56
  77. package/features/ConfigCommand.js.map +1 -1
  78. package/features/DeployCommand/DeployCommand.d.ts +1 -1
  79. package/features/DeployCommand/DeployCommand.js +164 -156
  80. package/features/DeployCommand/DeployCommand.js.map +1 -1
  81. package/features/DeployCommand/deployOutputs/BaseDeployOutput.js +12 -17
  82. package/features/DeployCommand/deployOutputs/BaseDeployOutput.js.map +1 -1
  83. package/features/DeployCommand/deployOutputs/DeployOutput.js +16 -17
  84. package/features/DeployCommand/deployOutputs/DeployOutput.js.map +1 -1
  85. package/features/DeployCommand/deployOutputs/NoDeploymentLogsDeployOutput.js +89 -54
  86. package/features/DeployCommand/deployOutputs/NoDeploymentLogsDeployOutput.js.map +1 -1
  87. package/features/DeployCommand/deployOutputs/WithDeploymentLogsDeployOutput.js +24 -37
  88. package/features/DeployCommand/deployOutputs/WithDeploymentLogsDeployOutput.js.map +1 -1
  89. package/features/DeployCommand/index.js +0 -2
  90. package/features/DepsSync/BuildDependencyTree.js +16 -21
  91. package/features/DepsSync/BuildDependencyTree.js.map +1 -1
  92. package/features/DepsSync/DependencyTree.js +108 -119
  93. package/features/DepsSync/DependencyTree.js.map +1 -1
  94. package/features/DepsSync/ListAllPackageJsonFiles.js +19 -14
  95. package/features/DepsSync/ListAllPackageJsonFiles.js.map +1 -1
  96. package/features/DepsSync/ListAllPackages.js +7 -9
  97. package/features/DepsSync/ListAllPackages.js.map +1 -1
  98. package/features/DepsSync/commands/SyncDepsCommand.js +30 -24
  99. package/features/DepsSync/commands/SyncDepsCommand.js.map +1 -1
  100. package/features/DepsSync/commands/VerifyDepsCommand.js +69 -70
  101. package/features/DepsSync/commands/VerifyDepsCommand.js.map +1 -1
  102. package/features/DepsSync/createDependencyTree.js +25 -18
  103. package/features/DepsSync/createDependencyTree.js.map +1 -1
  104. package/features/DepsSync/createReferenceFile.js +21 -25
  105. package/features/DepsSync/createReferenceFile.js.map +1 -1
  106. package/features/DepsSync/index.js +0 -2
  107. package/features/DepsSync/paths.js +3 -6
  108. package/features/DepsSync/paths.js.map +1 -1
  109. package/features/DepsSync/types.js +7 -6
  110. package/features/DepsSync/types.js.map +1 -1
  111. package/features/DestroyCommand/DestroyCommand.js +71 -67
  112. package/features/DestroyCommand/DestroyCommand.js.map +1 -1
  113. package/features/DestroyCommand/index.js +0 -2
  114. package/features/DisableTelemetryCommand.js +28 -25
  115. package/features/DisableTelemetryCommand.js.map +1 -1
  116. package/features/EnableTelemetryCommand.js +28 -25
  117. package/features/EnableTelemetryCommand.js.map +1 -1
  118. package/features/ExtensionCommand/ExtensionCommand.js +60 -63
  119. package/features/ExtensionCommand/ExtensionCommand.js.map +1 -1
  120. package/features/ExtensionCommand/index.js +0 -2
  121. package/features/InfoCommand/InfoCommand.js +54 -56
  122. package/features/InfoCommand/InfoCommand.js.map +1 -1
  123. package/features/InfoCommand/PrintInfoForEnv.js +31 -47
  124. package/features/InfoCommand/PrintInfoForEnv.js.map +1 -1
  125. package/features/InfoCommand/index.js +0 -2
  126. package/features/IsCi/IsCi.js +14 -11
  127. package/features/IsCi/IsCi.js.map +1 -1
  128. package/features/IsCi/index.js +1 -3
  129. package/features/OpenCommand.js +48 -47
  130. package/features/OpenCommand.js.map +1 -1
  131. package/features/OutputCommand.js +56 -69
  132. package/features/OutputCommand.js.map +1 -1
  133. package/features/PulumiCommand/PulumiCommand.js +48 -41
  134. package/features/PulumiCommand/PulumiCommand.js.map +1 -1
  135. package/features/PulumiCommand/index.js +0 -2
  136. package/features/RefreshCommand/RefreshCommand.js +42 -36
  137. package/features/RefreshCommand/RefreshCommand.js.map +1 -1
  138. package/features/RefreshCommand/index.js +0 -2
  139. package/features/UpgradeCommand/UpgradeCommand.d.ts +29 -0
  140. package/features/UpgradeCommand/UpgradeCommand.js +123 -0
  141. package/features/UpgradeCommand/UpgradeCommand.js.map +1 -0
  142. package/features/UpgradeCommand/UpgradeCommandHandler.d.ts +11 -0
  143. package/features/UpgradeCommand/UpgradeCommandHandler.js +102 -0
  144. package/features/UpgradeCommand/UpgradeCommandHandler.js.map +1 -0
  145. package/features/UpgradeCommand/abstraction.d.ts +23 -0
  146. package/features/UpgradeCommand/abstraction.js +5 -0
  147. package/features/UpgradeCommand/abstraction.js.map +1 -0
  148. package/features/UpgradeCommand/feature.d.ts +4 -0
  149. package/features/UpgradeCommand/feature.js +13 -0
  150. package/features/UpgradeCommand/feature.js.map +1 -0
  151. package/features/UpgradeCommand/index.d.ts +2 -0
  152. package/features/UpgradeCommand/index.js +2 -0
  153. package/features/WatchCommand/WatchCommand.js +131 -131
  154. package/features/WatchCommand/WatchCommand.js.map +1 -1
  155. package/features/WatchCommand/createPrefixer.js +11 -15
  156. package/features/WatchCommand/createPrefixer.js.map +1 -1
  157. package/features/WatchCommand/getRandomColorForString.js +86 -8
  158. package/features/WatchCommand/getRandomColorForString.js.map +1 -1
  159. package/features/WatchCommand/index.js +0 -2
  160. package/features/Wcp/LinkProjectCommand.js +119 -138
  161. package/features/Wcp/LinkProjectCommand.js.map +1 -1
  162. package/features/Wcp/LoginCommand.js +104 -118
  163. package/features/Wcp/LoginCommand.js.map +1 -1
  164. package/features/Wcp/LogoutCommand.js +29 -23
  165. package/features/Wcp/LogoutCommand.js.map +1 -1
  166. package/features/Wcp/WhoAmICommand.js +33 -29
  167. package/features/Wcp/WhoAmICommand.js.map +1 -1
  168. package/features/common/index.js +0 -2
  169. package/features/common/options.js +41 -50
  170. package/features/common/options.js.map +1 -1
  171. package/features/globalOptions/LogLevelGlobalOption.js +25 -16
  172. package/features/globalOptions/LogLevelGlobalOption.js.map +1 -1
  173. package/features/globalOptions/ShowLogsGlobalOption.js +16 -15
  174. package/features/globalOptions/ShowLogsGlobalOption.js.map +1 -1
  175. package/features/globalOptions/StackTraceGlobalOption.js +16 -15
  176. package/features/globalOptions/StackTraceGlobalOption.js.map +1 -1
  177. package/features/globalOptions/index.js +0 -2
  178. package/features/gracefulErrorHandlers/DdbPutItemConditionalCheckFailedGracefulErrorHandler.js +17 -16
  179. package/features/gracefulErrorHandlers/DdbPutItemConditionalCheckFailedGracefulErrorHandler.js.map +1 -1
  180. package/features/gracefulErrorHandlers/MissingFilesInBuildGracefulErrorHandler.js +12 -18
  181. package/features/gracefulErrorHandlers/MissingFilesInBuildGracefulErrorHandler.js.map +1 -1
  182. package/features/gracefulErrorHandlers/PendingOperationsGracefulErrorHandler.js +19 -19
  183. package/features/gracefulErrorHandlers/PendingOperationsGracefulErrorHandler.js.map +1 -1
  184. package/features/gracefulErrorHandlers/index.js +0 -2
  185. package/features/index.d.ts +1 -0
  186. package/features/index.js +1 -2
  187. package/features/utils/index.js +0 -2
  188. package/features/utils/measureDuration.js +7 -8
  189. package/features/utils/measureDuration.js.map +1 -1
  190. package/index.js +0 -2
  191. package/package.json +29 -24
  192. package/services/ArgvParserService/ArgvParserService.js +27 -33
  193. package/services/ArgvParserService/ArgvParserService.js.map +1 -1
  194. package/services/ArgvParserService/index.js +0 -2
  195. package/services/CliParamsService/CliParamsService.js +18 -15
  196. package/services/CliParamsService/CliParamsService.js.map +1 -1
  197. package/services/CliParamsService/index.js +0 -2
  198. package/services/CommandsRegistryService/CommandsRegistryService.js +19 -13
  199. package/services/CommandsRegistryService/CommandsRegistryService.js.map +1 -1
  200. package/services/CommandsRegistryService/index.js +0 -2
  201. package/services/GetArgvService/GetArgvService.js +14 -11
  202. package/services/GetArgvService/GetArgvService.js.map +1 -1
  203. package/services/GetArgvService/index.js +0 -2
  204. package/services/GetCliRunnerService/GetCliRunnerService.js +119 -148
  205. package/services/GetCliRunnerService/GetCliRunnerService.js.map +1 -1
  206. package/services/GetCliRunnerService/index.js +0 -2
  207. package/services/GetIsCiService/GetIsCiService.js +9 -8
  208. package/services/GetIsCiService/GetIsCiService.js.map +1 -1
  209. package/services/GetIsCiService/index.js +1 -3
  210. package/services/GetProjectSdkService/GetProjectSdkService.js +25 -24
  211. package/services/GetProjectSdkService/GetProjectSdkService.js.map +1 -1
  212. package/services/GetProjectSdkService/index.js +0 -2
  213. package/services/GlobalOptionsRegistryService/GlobalOptionsRegistryService.js +19 -13
  214. package/services/GlobalOptionsRegistryService/GlobalOptionsRegistryService.js.map +1 -1
  215. package/services/GlobalOptionsRegistryService/index.js +0 -2
  216. package/services/LoggerService/LoggerService.js +76 -88
  217. package/services/LoggerService/LoggerService.js.map +1 -1
  218. package/services/LoggerService/index.js +0 -2
  219. package/services/RunCliRunnerService/RunCliRunnerService.js +15 -13
  220. package/services/RunCliRunnerService/RunCliRunnerService.js.map +1 -1
  221. package/services/RunCliRunnerService/index.js +0 -2
  222. package/services/StdioService/StdioService.js +15 -14
  223. package/services/StdioService/StdioService.js.map +1 -1
  224. package/services/StdioService/index.js +0 -2
  225. package/services/UiService/UiService.js +55 -58
  226. package/services/UiService/UiService.js.map +1 -1
  227. package/services/UiService/index.js +0 -2
  228. package/services/index.js +0 -2
  229. package/utils/ManuallyReportedError.js +7 -6
  230. package/utils/ManuallyReportedError.js.map +1 -1
  231. package/abstractions/features/index.js.map +0 -1
  232. package/abstractions/features/types.js.map +0 -1
  233. package/abstractions/index.js.map +0 -1
  234. package/abstractions/services/index.js.map +0 -1
  235. package/decorators/index.js.map +0 -1
  236. package/exports/cli/command.js.map +0 -1
  237. package/exports/cli/index.d.ts +0 -2
  238. package/exports/cli/index.js +0 -4
  239. package/exports/cli/index.js.map +0 -1
  240. package/features/BuildCommand/index.js.map +0 -1
  241. package/features/DeployCommand/index.js.map +0 -1
  242. package/features/DepsSync/index.js.map +0 -1
  243. package/features/DestroyCommand/index.js.map +0 -1
  244. package/features/ExtensionCommand/index.js.map +0 -1
  245. package/features/InfoCommand/index.js.map +0 -1
  246. package/features/IsCi/index.js.map +0 -1
  247. package/features/PulumiCommand/index.js.map +0 -1
  248. package/features/RefreshCommand/index.js.map +0 -1
  249. package/features/WatchCommand/index.js.map +0 -1
  250. package/features/common/index.js.map +0 -1
  251. package/features/globalOptions/index.js.map +0 -1
  252. package/features/gracefulErrorHandlers/index.js.map +0 -1
  253. package/features/index.js.map +0 -1
  254. package/features/utils/index.js.map +0 -1
  255. package/index.js.map +0 -1
  256. package/services/ArgvParserService/index.js.map +0 -1
  257. package/services/CliParamsService/index.js.map +0 -1
  258. package/services/CommandsRegistryService/index.js.map +0 -1
  259. package/services/GetArgvService/index.js.map +0 -1
  260. package/services/GetCliRunnerService/index.js.map +0 -1
  261. package/services/GetIsCiService/index.js.map +0 -1
  262. package/services/GetProjectSdkService/index.js.map +0 -1
  263. package/services/GlobalOptionsRegistryService/index.js.map +0 -1
  264. package/services/LoggerService/index.js.map +0 -1
  265. package/services/RunCliRunnerService/index.js.map +0 -1
  266. package/services/StdioService/index.js.map +0 -1
  267. package/services/UiService/index.js.map +0 -1
  268. package/services/index.js.map +0 -1
@@ -1,131 +1,120 @@
1
1
  import semver from "semver";
2
2
  import { PackageType } from "./types.js";
3
- const keys = [PackageType.dependencies, PackageType.devDependencies, PackageType.peerDependencies, PackageType.resolutions];
4
- const sortByName = (a, b) => {
5
- return a.name.localeCompare(b.name);
6
- };
7
- export class DependencyTree {
8
- packages = {
9
- resolutions: [],
10
- dependencies: [],
11
- devDependencies: [],
12
- peerDependencies: []
13
- };
14
- references = [];
15
- get dependencies() {
16
- return this.packages.dependencies.sort(sortByName);
17
- }
18
- get devDependencies() {
19
- return this.packages.devDependencies.sort(sortByName);
20
- }
21
- get peerDependencies() {
22
- return this.packages.peerDependencies.sort(sortByName);
23
- }
24
- get resolutions() {
25
- return this.packages.resolutions.sort(sortByName);
26
- }
27
- get duplicates() {
28
- return this.references.filter(reference => {
29
- return reference.versions.length > 1;
30
- }).sort(sortByName);
31
- }
32
- push(params) {
33
- const {
34
- file,
35
- json,
36
- ignore
37
- } = params;
38
- for (const key of keys) {
39
- const dependencies = json[key];
40
- if (!dependencies) {
41
- continue;
42
- }
43
- for (const name in dependencies) {
44
- if (ignore && name.match(ignore) !== null) {
45
- continue;
46
- }
47
- let version = dependencies[name];
48
- if (!version) {
49
- continue;
50
- }
51
- const semverVersion = semver.validRange(version) || version === "beta" ? version : null;
52
- if (!semverVersion) {
53
- process.env.DEBUG === "true" && console.debug(`${version} is not a valid SemVer value in ${file}, package ${name}.`);
54
- continue;
55
- }
56
- version = version.replace(/\^/g, "").replace(/~/g, "").replace(/>/g, "").replace(/</g, "").replace(/=/g, "");
57
- const existing = this.packages[key].find(item => {
58
- return item.name === name && item.version === version;
59
- });
60
- if (existing) {
61
- existing.files.push(file);
62
- this.addReference({
63
- name,
64
- version,
65
- file,
66
- type: key
67
- });
68
- continue;
3
+ const keys = [
4
+ PackageType.dependencies,
5
+ PackageType.devDependencies,
6
+ PackageType.peerDependencies,
7
+ PackageType.resolutions
8
+ ];
9
+ const sortByName = (a, b)=>a.name.localeCompare(b.name);
10
+ class DependencyTree {
11
+ get dependencies() {
12
+ return this.packages.dependencies.sort(sortByName);
13
+ }
14
+ get devDependencies() {
15
+ return this.packages.devDependencies.sort(sortByName);
16
+ }
17
+ get peerDependencies() {
18
+ return this.packages.peerDependencies.sort(sortByName);
19
+ }
20
+ get resolutions() {
21
+ return this.packages.resolutions.sort(sortByName);
22
+ }
23
+ get duplicates() {
24
+ return this.references.filter((reference)=>reference.versions.length > 1).sort(sortByName);
25
+ }
26
+ push(params) {
27
+ const { file, json, ignore } = params;
28
+ for (const key of keys){
29
+ const dependencies = json[key];
30
+ if (dependencies) for(const name in dependencies){
31
+ if (ignore && null !== name.match(ignore)) continue;
32
+ let version = dependencies[name];
33
+ if (!version) continue;
34
+ const semverVersion = semver.validRange(version) || "beta" === version ? version : null;
35
+ if (!semverVersion) {
36
+ "true" === process.env.DEBUG && console.debug(`${version} is not a valid SemVer value in ${file}, package ${name}.`);
37
+ continue;
38
+ }
39
+ if (version.startsWith(">=") || version.startsWith("<=")) {
40
+ "true" === process.env.DEBUG && console.debug(`${version} is not an exact version in ${file}, package ${name}. Skipping.`);
41
+ continue;
42
+ }
43
+ version = version.replace(/\^/g, "").replace(/~/g, "").replace(/>/g, "").replace(/</g, "").replace(/=/g, "");
44
+ const existing = this.packages[key].find((item)=>item.name === name && item.version === version);
45
+ if (existing) {
46
+ existing.files.push(file);
47
+ this.addReference({
48
+ name,
49
+ version,
50
+ file,
51
+ type: key
52
+ });
53
+ continue;
54
+ }
55
+ this.packages[key].push({
56
+ name,
57
+ version,
58
+ files: [
59
+ file
60
+ ]
61
+ });
62
+ this.addReference({
63
+ name,
64
+ version,
65
+ file,
66
+ type: key
67
+ });
68
+ }
69
69
  }
70
- this.packages[key].push({
71
- name,
72
- version,
73
- files: [file]
70
+ }
71
+ addReference(ref) {
72
+ const existing = this.references.find((item)=>item.name === ref.name);
73
+ const types = [
74
+ ref.type
75
+ ];
76
+ if (!existing) return void this.references.push({
77
+ name: ref.name,
78
+ versions: [
79
+ {
80
+ version: ref.version,
81
+ files: [
82
+ {
83
+ file: ref.file,
84
+ types
85
+ }
86
+ ]
87
+ }
88
+ ]
74
89
  });
75
- this.addReference({
76
- name,
77
- version,
78
- file,
79
- type: key
90
+ const existingVersion = existing.versions.find((item)=>item.version === ref.version);
91
+ if (!existingVersion) return void existing.versions.push({
92
+ version: ref.version,
93
+ files: [
94
+ {
95
+ file: ref.file,
96
+ types
97
+ }
98
+ ]
80
99
  });
81
- }
82
- }
83
- }
84
- addReference(ref) {
85
- const existing = this.references.find(item => {
86
- return item.name === ref.name;
87
- });
88
- const types = [ref.type];
89
- if (!existing) {
90
- this.references.push({
91
- name: ref.name,
92
- versions: [{
93
- version: ref.version,
94
- files: [{
100
+ const existingFile = existingVersion.files.find((item)=>item.file === ref.file);
101
+ if (!existingFile) return void existingVersion.files.push({
95
102
  file: ref.file,
96
103
  types
97
- }]
98
- }]
99
- });
100
- return;
101
- }
102
- const existingVersion = existing.versions.find(item => {
103
- return item.version === ref.version;
104
- });
105
- if (!existingVersion) {
106
- existing.versions.push({
107
- version: ref.version,
108
- files: [{
109
- file: ref.file,
110
- types
111
- }]
112
- });
113
- return;
104
+ });
105
+ if (existingFile.types.includes(ref.type)) return;
106
+ existingFile.types.push(ref.type);
114
107
  }
115
- const existingFile = existingVersion.files.find(item => {
116
- return item.file === ref.file;
117
- });
118
- if (!existingFile) {
119
- existingVersion.files.push({
120
- file: ref.file,
121
- types
122
- });
123
- return;
124
- } else if (existingFile.types.includes(ref.type)) {
125
- return;
108
+ constructor(){
109
+ this.packages = {
110
+ resolutions: [],
111
+ dependencies: [],
112
+ devDependencies: [],
113
+ peerDependencies: []
114
+ };
115
+ this.references = [];
126
116
  }
127
- existingFile.types.push(ref.type);
128
- }
129
117
  }
118
+ export { DependencyTree };
130
119
 
131
120
  //# sourceMappingURL=DependencyTree.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["semver","PackageType","keys","dependencies","devDependencies","peerDependencies","resolutions","sortByName","a","b","name","localeCompare","DependencyTree","packages","references","sort","duplicates","filter","reference","versions","length","push","params","file","json","ignore","key","match","version","semverVersion","validRange","process","env","DEBUG","console","debug","replace","existing","find","item","files","addReference","type","ref","types","existingVersion","existingFile","includes"],"sources":["DependencyTree.ts"],"sourcesContent":["import semver from \"semver\";\nimport type {\n IDependency,\n IDependencyTree,\n IDependencyTreePushParams,\n IReference\n} from \"./types.js\";\nimport { PackageType } from \"./types.js\";\n\nconst keys = [\n PackageType.dependencies,\n PackageType.devDependencies,\n PackageType.peerDependencies,\n PackageType.resolutions\n];\n\ninterface IAddReferenceParams {\n name: string;\n version: string;\n file: string;\n type: PackageType;\n}\n\ninterface ISortItem {\n name: string;\n}\n\nconst sortByName = (a: ISortItem, b: ISortItem) => {\n return a.name.localeCompare(b.name);\n};\n\nexport class DependencyTree implements IDependencyTree {\n private readonly packages: Record<(typeof keys)[number], IDependency[]> = {\n resolutions: [],\n dependencies: [],\n devDependencies: [],\n peerDependencies: []\n };\n public readonly references: IReference[] = [];\n\n public get dependencies(): IDependency[] {\n return this.packages.dependencies.sort(sortByName);\n }\n\n public get devDependencies(): IDependency[] {\n return this.packages.devDependencies.sort(sortByName);\n }\n\n public get peerDependencies(): IDependency[] {\n return this.packages.peerDependencies.sort(sortByName);\n }\n\n public get resolutions(): IDependency[] {\n return this.packages.resolutions.sort(sortByName);\n }\n\n public get duplicates(): IReference[] {\n return this.references\n .filter(reference => {\n return reference.versions.length > 1;\n })\n .sort(sortByName);\n }\n\n public push(params: IDependencyTreePushParams): void {\n const { file, json, ignore } = params;\n for (const key of keys) {\n const dependencies = json[key];\n if (!dependencies) {\n continue;\n }\n\n for (const name in dependencies) {\n if (ignore && name.match(ignore) !== null) {\n continue;\n }\n let version = dependencies[name];\n if (!version) {\n continue;\n }\n\n const semverVersion =\n semver.validRange(version) || version === \"beta\" ? version : null;\n if (!semverVersion) {\n process.env.DEBUG === \"true\" &&\n console.debug(\n `${version} is not a valid SemVer value in ${file}, package ${name}.`\n );\n continue;\n }\n version = version\n .replace(/\\^/g, \"\")\n .replace(/~/g, \"\")\n .replace(/>/g, \"\")\n .replace(/</g, \"\")\n .replace(/=/g, \"\");\n const existing = this.packages[key].find(item => {\n return item.name === name && item.version === version;\n });\n if (existing) {\n existing.files.push(file);\n this.addReference({\n name,\n version,\n file,\n type: key\n });\n continue;\n }\n\n this.packages[key].push({\n name,\n version,\n files: [file]\n });\n this.addReference({\n name,\n version,\n file,\n type: key\n });\n }\n }\n }\n\n private addReference(ref: IAddReferenceParams): void {\n const existing = this.references.find(item => {\n return item.name === ref.name;\n });\n const types = [ref.type];\n if (!existing) {\n this.references.push({\n name: ref.name,\n versions: [\n {\n version: ref.version,\n files: [\n {\n file: ref.file,\n types\n }\n ]\n }\n ]\n });\n return;\n }\n const existingVersion = existing.versions.find(item => {\n return item.version === ref.version;\n });\n if (!existingVersion) {\n existing.versions.push({\n version: ref.version,\n files: [\n {\n file: ref.file,\n types\n }\n ]\n });\n return;\n }\n const existingFile = existingVersion.files.find(item => {\n return item.file === ref.file;\n });\n if (!existingFile) {\n existingVersion.files.push({\n file: ref.file,\n types\n });\n return;\n } else if (existingFile.types.includes(ref.type)) {\n return;\n }\n existingFile.types.push(ref.type);\n }\n}\n"],"mappings":"AAAA,OAAOA,MAAM,MAAM,QAAQ;AAO3B,SAASC,WAAW;AAEpB,MAAMC,IAAI,GAAG,CACTD,WAAW,CAACE,YAAY,EACxBF,WAAW,CAACG,eAAe,EAC3BH,WAAW,CAACI,gBAAgB,EAC5BJ,WAAW,CAACK,WAAW,CAC1B;AAaD,MAAMC,UAAU,GAAGA,CAACC,CAAY,EAAEC,CAAY,KAAK;EAC/C,OAAOD,CAAC,CAACE,IAAI,CAACC,aAAa,CAACF,CAAC,CAACC,IAAI,CAAC;AACvC,CAAC;AAED,OAAO,MAAME,cAAc,CAA4B;EAClCC,QAAQ,GAAiD;IACtEP,WAAW,EAAE,EAAE;IACfH,YAAY,EAAE,EAAE;IAChBC,eAAe,EAAE,EAAE;IACnBC,gBAAgB,EAAE;EACtB,CAAC;EACeS,UAAU,GAAiB,EAAE;EAE7C,IAAWX,YAAYA,CAAA,EAAkB;IACrC,OAAO,IAAI,CAACU,QAAQ,CAACV,YAAY,CAACY,IAAI,CAACR,UAAU,CAAC;EACtD;EAEA,IAAWH,eAAeA,CAAA,EAAkB;IACxC,OAAO,IAAI,CAACS,QAAQ,CAACT,eAAe,CAACW,IAAI,CAACR,UAAU,CAAC;EACzD;EAEA,IAAWF,gBAAgBA,CAAA,EAAkB;IACzC,OAAO,IAAI,CAACQ,QAAQ,CAACR,gBAAgB,CAACU,IAAI,CAACR,UAAU,CAAC;EAC1D;EAEA,IAAWD,WAAWA,CAAA,EAAkB;IACpC,OAAO,IAAI,CAACO,QAAQ,CAACP,WAAW,CAACS,IAAI,CAACR,UAAU,CAAC;EACrD;EAEA,IAAWS,UAAUA,CAAA,EAAiB;IAClC,OAAO,IAAI,CAACF,UAAU,CACjBG,MAAM,CAACC,SAAS,IAAI;MACjB,OAAO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AC,CAAC;IACF,IAAI,CAACiB,eAAe,EAAE;MAClBR,QAAQ,CAAClB,QAAQ,CAACE,IAAI,CAAC;QACnBO,OAAO,EAAEe,GAAG,CAACf,OAAO;QACpBY,KAAK,EAAE,CACH;UACIjB,IAAI,EAAEoB,GAAG,CAACpB,IAAI;UACdqB;QACJ,CAAC;MAET,CAAC,CAAC;MACF;IACJ;IACA,MAAME,YAAY,GAAGD,eAAe,CAACL,KAAK,CAACF,IAAI,CAACC,IAAI,IAAI;MACpD,OAAOA,IAAI,CAAChB,IAAI,KAAKoB,GAAG,CAACpB,IAAI;IACjC,CAAC,CAAC;IACF,IAAI,CAACuB,YAAY,EAAE;MACfD,eAAe,CAACL,KAAK,CAACnB,IAAI,CAAC;QACvBE,IAAI,EAAEoB,GAAG,CAACpB,IAAI;QACdqB;MACJ,CAAC,CAAC;MACF;IACJ,CAAC,MAAM,IAAIE,YAAY,CAACF,KAAK,CAACG,QAAQ,CAACJ,GAAG,CAACD,IAAI,CAAC,EAAE;MAC9C;IACJ;IACAI,YAAY,CAACF,KAAK,CAACvB,IAAI,CAACsB,GAAG,CAACD,IAAI,CAAC;EACrC;AACJ","ignoreList":[]}
1
+ {"version":3,"file":"features/DepsSync/DependencyTree.js","sources":["../../../src/features/DepsSync/DependencyTree.ts"],"sourcesContent":["import semver from \"semver\";\nimport type {\n IDependency,\n IDependencyTree,\n IDependencyTreePushParams,\n IReference\n} from \"./types.js\";\nimport { PackageType } from \"./types.js\";\n\nconst keys = [\n PackageType.dependencies,\n PackageType.devDependencies,\n PackageType.peerDependencies,\n PackageType.resolutions\n];\n\ninterface IAddReferenceParams {\n name: string;\n version: string;\n file: string;\n type: PackageType;\n}\n\ninterface ISortItem {\n name: string;\n}\n\nconst sortByName = (a: ISortItem, b: ISortItem) => {\n return a.name.localeCompare(b.name);\n};\n\nexport class DependencyTree implements IDependencyTree {\n private readonly packages: Record<(typeof keys)[number], IDependency[]> = {\n resolutions: [],\n dependencies: [],\n devDependencies: [],\n peerDependencies: []\n };\n public readonly references: IReference[] = [];\n\n public get dependencies(): IDependency[] {\n return this.packages.dependencies.sort(sortByName);\n }\n\n public get devDependencies(): IDependency[] {\n return this.packages.devDependencies.sort(sortByName);\n }\n\n public get peerDependencies(): IDependency[] {\n return this.packages.peerDependencies.sort(sortByName);\n }\n\n public get resolutions(): IDependency[] {\n return this.packages.resolutions.sort(sortByName);\n }\n\n public get duplicates(): IReference[] {\n return this.references\n .filter(reference => {\n return reference.versions.length > 1;\n })\n .sort(sortByName);\n }\n\n public push(params: IDependencyTreePushParams): void {\n const { file, json, ignore } = params;\n for (const key of keys) {\n const dependencies = json[key];\n if (!dependencies) {\n continue;\n }\n\n for (const name in dependencies) {\n if (ignore && name.match(ignore) !== null) {\n continue;\n }\n let version = dependencies[name];\n if (!version) {\n continue;\n }\n\n const semverVersion =\n semver.validRange(version) || version === \"beta\" ? version : null;\n if (!semverVersion) {\n process.env.DEBUG === \"true\" &&\n console.debug(\n `${version} is not a valid SemVer value in ${file}, package ${name}.`\n );\n continue;\n }\n /**\n * Let's skip if version starts with >= or <=, as those are not exact versions and we can't be sure which version is actually used.\n */\n if (version.startsWith(\">=\") || version.startsWith(\"<=\")) {\n process.env.DEBUG === \"true\" &&\n console.debug(\n `${version} is not an exact version in ${file}, package ${name}. Skipping.`\n );\n continue;\n }\n\n version = version\n .replace(/\\^/g, \"\")\n .replace(/~/g, \"\")\n .replace(/>/g, \"\")\n .replace(/</g, \"\")\n .replace(/=/g, \"\");\n const existing = this.packages[key].find(item => {\n return item.name === name && item.version === version;\n });\n if (existing) {\n existing.files.push(file);\n this.addReference({\n name,\n version,\n file,\n type: key\n });\n continue;\n }\n\n this.packages[key].push({\n name,\n version,\n files: [file]\n });\n this.addReference({\n name,\n version,\n file,\n type: key\n });\n }\n }\n }\n\n private addReference(ref: IAddReferenceParams): void {\n const existing = this.references.find(item => {\n return item.name === ref.name;\n });\n const types = [ref.type];\n if (!existing) {\n this.references.push({\n name: ref.name,\n versions: [\n {\n version: ref.version,\n files: [\n {\n file: ref.file,\n types\n }\n ]\n }\n ]\n });\n return;\n }\n const existingVersion = existing.versions.find(item => {\n return item.version === ref.version;\n });\n if (!existingVersion) {\n existing.versions.push({\n version: ref.version,\n files: [\n {\n file: ref.file,\n types\n }\n ]\n });\n return;\n }\n const existingFile = existingVersion.files.find(item => {\n return item.file === ref.file;\n });\n if (!existingFile) {\n existingVersion.files.push({\n file: ref.file,\n types\n });\n return;\n } else if (existingFile.types.includes(ref.type)) {\n return;\n }\n existingFile.types.push(ref.type);\n }\n}\n"],"names":["keys","PackageType","sortByName","a","b","DependencyTree","reference","params","file","json","ignore","key","dependencies","name","version","semverVersion","semver","process","console","existing","item","ref","types","existingVersion","existingFile"],"mappings":";;AASA,MAAMA,OAAO;IACTC,YAAY,YAAY;IACxBA,YAAY,eAAe;IAC3BA,YAAY,gBAAgB;IAC5BA,YAAY,WAAW;CAC1B;AAaD,MAAMC,aAAa,CAACC,GAAcC,IACvBD,EAAE,IAAI,CAAC,aAAa,CAACC,EAAE,IAAI;AAG/B,MAAMC;IAST,IAAW,eAA8B;QACrC,OAAO,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,IAAI,CAACH;IAC3C;IAEA,IAAW,kBAAiC;QACxC,OAAO,IAAI,CAAC,QAAQ,CAAC,eAAe,CAAC,IAAI,CAACA;IAC9C;IAEA,IAAW,mBAAkC;QACzC,OAAO,IAAI,CAAC,QAAQ,CAAC,gBAAgB,CAAC,IAAI,CAACA;IAC/C;IAEA,IAAW,cAA6B;QACpC,OAAO,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,IAAI,CAACA;IAC1C;IAEA,IAAW,aAA2B;QAClC,OAAO,IAAI,CAAC,UAAU,CACjB,MAAM,CAACI,CAAAA,YACGA,UAAU,QAAQ,CAAC,MAAM,GAAG,GAEtC,IAAI,CAACJ;IACd;IAEO,KAAKK,MAAiC,EAAQ;QACjD,MAAM,EAAEC,IAAI,EAAEC,IAAI,EAAEC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ob from "glob";
2
- const defaultIgnore = ["**/node_modules/**", "**/dist/**", "**/build/**"];
3
- export class ListAllPackageJsonFiles {
4
- list(params) {
5
- const targets = params.targets;
6
- const ignore = defaultIgnore.concat(params.ignore || []);
7
- const results = [];
8
- for (const target of targets) {
9
- const files = glob.sync(`${target}/**/**/{package.json,*.package.json,dependencies.json}`, {
10
- ignore
11
- });
12
- results.push(...files);
1
+ import fast_glob from "fast-glob";
2
+ const defaultIgnore = [
3
+ "**/node_modules/**",
4
+ "**/dist/**",
5
+ "**/build/**"
6
+ ];
7
+ class ListAllPackageJsonFiles {
8
+ list(params) {
9
+ const targets = params.targets;
10
+ const ignore = defaultIgnore.concat(params.ignore || []);
11
+ const results = [];
12
+ for (const target of targets){
13
+ const files = fast_glob.sync(`${target}/**/**/{package.json,*.package.json,dependencies.json}`, {
14
+ ignore
15
+ });
16
+ results.push(...files);
17
+ }
18
+ return results;
13
19
  }
14
- return results;
15
- }
16
20
  }
21
+ export { ListAllPackageJsonFiles };
17
22
 
18
23
  //# sourceMappingURL=ListAllPackageJsonFiles.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["glob","defaultIgnore","ListAllPackageJsonFiles","list","params","targets","ignore","concat","results","target","files","sync","push"],"sources":["ListAllPackageJsonFiles.ts"],"sourcesContent":["import glob from \"glob\";\n\nconst defaultIgnore = [\"**/node_modules/**\", \"**/dist/**\", \"**/build/**\"];\n\nexport interface IListAllPackageJsonFilesListParams {\n targets: string[];\n ignore?: string[];\n}\n\nexport class ListAllPackageJsonFiles {\n public list(params: IListAllPackageJsonFilesListParams): string[] {\n const targets = params.targets;\n const ignore = defaultIgnore.concat(params.ignore || []);\n\n const results: string[] = [];\n\n for (const target of targets) {\n const files = glob.sync(\n `${target}/**/**/{package.json,*.package.json,dependencies.json}`,\n {\n ignore\n }\n );\n results.push(...files);\n }\n\n return results;\n }\n}\n"],"mappings":"AAAA,OAAOA,IAAI,MAAM,MAAM;AAEvB,MAAMC,aAAa,GAAG,CAAC,oBAAoB,EAAE,YAAY,EAAE,aAAa,CAAC;AAOzE,OAAO,MAAMC,uBAAuB,CAAC;EAC1BC,IAAIA,CAACC,MAA0C,EAAY;IAC9D,MAAMC,OAAO,GAAGD,MAAM,CAACC,OAAO;IAC9B,MAAMC,MAAM,GAAGL,aAAa,CAACM,MAAM,CAACH,MAAM,CAACE,MAAM,IAAI,EAAE,CAAC;IAExD,MAAME,OAAiB,GAAG,EAAE;IAE5B,KAAK,MAAMC,MAAM,IAAIJ,OAAO,EAAE;MAC1B,MAAMK,KAAK,GAAGV,IAAI,CAACW,IAAI,CACnB,GAAGF,MAAM,wDAAwD,EACjE;QACIH;MACJ,CACJ,CAAC;MACDE,OAAO,CAACI,IAAI,CAAC,GAAGF,KAAK,CAAC;IAC1B;IAEA,OAAOF,OAAO;EAClB;AACJ","ignoreList":[]}
1
+ {"version":3,"file":"features/DepsSync/ListAllPackageJsonFiles.js","sources":["../../../src/features/DepsSync/ListAllPackageJsonFiles.ts"],"sourcesContent":["import fastGlob from \"fast-glob\";\n\nconst defaultIgnore = [\"**/node_modules/**\", \"**/dist/**\", \"**/build/**\"];\n\nexport interface IListAllPackageJsonFilesListParams {\n targets: string[];\n ignore?: string[];\n}\n\nexport class ListAllPackageJsonFiles {\n public list(params: IListAllPackageJsonFilesListParams): string[] {\n const targets = params.targets;\n const ignore = defaultIgnore.concat(params.ignore || []);\n\n const results: string[] = [];\n\n for (const target of targets) {\n const files = fastGlob.sync(\n `${target}/**/**/{package.json,*.package.json,dependencies.json}`,\n {\n ignore\n }\n );\n results.push(...files);\n }\n\n return results;\n }\n}\n"],"names":["defaultIgnore","ListAllPackageJsonFiles","params","targets","ignore","results","target","files","fastGlob"],"mappings":";AAEA,MAAMA,gBAAgB;IAAC;IAAsB;IAAc;CAAc;AAOlE,MAAMC;IACF,KAAKC,MAA0C,EAAY;QAC9D,MAAMC,UAAUD,OAAO,OAAO;QAC9B,MAAME,SAASJ,cAAc,MAAM,CAACE,OAAO,MAAM,IAAI,EAAE;QAEvD,MAAMG,UAAoB,EAAE;QAE5B,KAAK,MAAMC,UAAUH,QAAS;YAC1B,MAAMI,QAAQC,UAAAA,IAAa,CACvB,GAAGF,OAAO,sDAAsD,CAAC,EACjE;gBACIF;YACJ;YAEJC,QAAQ,IAAI,IAAIE;QACpB;QAEA,OAAOF;IACX;AACJ"}
@@ -1,13 +1,11 @@
1
- // @ts-expect-error
2
- import getPackages from "get-yarn-workspaces";
3
- export class ListAllPackages {
4
- list(paths) {
5
- const results = [];
6
- for (const p of paths) {
7
- results.push(...getPackages(p));
1
+ import get_yarn_workspaces from "get-yarn-workspaces";
2
+ class ListAllPackages {
3
+ list(paths) {
4
+ const results = [];
5
+ for (const p of paths)results.push(...get_yarn_workspaces(p));
6
+ return results;
8
7
  }
9
- return results;
10
- }
11
8
  }
9
+ export { ListAllPackages };
12
10
 
13
11
  //# sourceMappingURL=ListAllPackages.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["getPackages","ListAllPackages","list","paths","results","p","push"],"sources":["ListAllPackages.ts"],"sourcesContent":["// @ts-expect-error\nimport getPackages from \"get-yarn-workspaces\";\n\nexport class ListAllPackages {\n public list(paths: string[]): string[] {\n const results: string[] = [];\n for (const p of paths) {\n results.push(...getPackages(p));\n }\n return results;\n }\n}\n"],"mappings":"AAAA;AACA,OAAOA,WAAW,MAAM,qBAAqB;AAE7C,OAAO,MAAMC,eAAe,CAAC;EAClBC,IAAIA,CAACC,KAAe,EAAY;IACnC,MAAMC,OAAiB,GAAG,EAAE;IAC5B,KAAK,MAAMC,CAAC,IAAIF,KAAK,EAAE;MACnBC,OAAO,CAACE,IAAI,CAAC,GAAGN,WAAW,CAACK,CAAC,CAAC,CAAC;IACnC;IACA,OAAOD,OAAO;EAClB;AACJ","ignoreList":[]}
1
+ {"version":3,"file":"features/DepsSync/ListAllPackages.js","sources":["../../../src/features/DepsSync/ListAllPackages.ts"],"sourcesContent":["// @ts-expect-error\nimport getPackages from \"get-yarn-workspaces\";\n\nexport class ListAllPackages {\n public list(paths: string[]): string[] {\n const results: string[] = [];\n for (const p of paths) {\n results.push(...getPackages(p));\n }\n return results;\n }\n}\n"],"names":["ListAllPackages","paths","results","p","getPackages"],"mappings":";AAGO,MAAMA;IACF,KAAKC,KAAe,EAAY;QACnC,MAAMC,UAAoB,EAAE;QAC5B,KAAK,MAAMC,KAAKF,MACZC,QAAQ,IAAI,IAAIE,oBAAYD;QAEhC,OAAOD;IACX;AACJ"}
@@ -2,31 +2,37 @@ import { createImplementation } from "@webiny/di";
2
2
  import { CliCommandFactory, GetProjectSdkService, UiService } from "../../../abstractions/index.js";
3
3
  import { createDependencyTree } from "../createDependencyTree.js";
4
4
  import { createReferenceFile } from "../createReferenceFile.js";
5
- export class SyncDepsCommand {
6
- constructor(getProjectSdkService, uiService) {
7
- this.getProjectSdkService = getProjectSdkService;
8
- this.uiService = uiService;
9
- }
10
- async execute() {
11
- const projectSdk = await this.getProjectSdkService.execute();
12
- return {
13
- name: "sync-dependencies",
14
- description: "Sync dependencies for all packages.",
15
- examples: ["$0 sync-dependencies"],
16
- handler: async () => {
17
- const project = projectSdk.getProject();
18
- const tree = createDependencyTree(project);
19
- return createReferenceFile(project, tree, {
20
- uiService: this.uiService
21
- });
22
- }
23
- };
24
- }
5
+ class SyncDepsCommand {
6
+ constructor(getProjectSdkService, uiService){
7
+ this.getProjectSdkService = getProjectSdkService;
8
+ this.uiService = uiService;
9
+ }
10
+ async execute() {
11
+ const projectSdk = await this.getProjectSdkService.execute();
12
+ return {
13
+ name: "sync-dependencies",
14
+ description: "Sync dependencies for all packages.",
15
+ examples: [
16
+ "$0 sync-dependencies"
17
+ ],
18
+ handler: async ()=>{
19
+ const project = projectSdk.getProject();
20
+ const tree = createDependencyTree(project);
21
+ return createReferenceFile(project, tree, {
22
+ uiService: this.uiService
23
+ });
24
+ }
25
+ };
26
+ }
25
27
  }
26
- export const syncDepsCommand = createImplementation({
27
- abstraction: CliCommandFactory,
28
- implementation: SyncDepsCommand,
29
- dependencies: [GetProjectSdkService, UiService]
28
+ const syncDepsCommand = createImplementation({
29
+ abstraction: CliCommandFactory,
30
+ implementation: SyncDepsCommand,
31
+ dependencies: [
32
+ GetProjectSdkService,
33
+ UiService
34
+ ]
30
35
  });
36
+ export { SyncDepsCommand, syncDepsCommand };
31
37
 
32
38
  //# sourceMappingURL=SyncDepsCommand.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["createImplementation","CliCommandFactory","GetProjectSdkService","UiService","createDependencyTree","createReferenceFile","SyncDepsCommand","constructor","getProjectSdkService","uiService","execute","projectSdk","name","description","examples","handler","project","getProject","tree","syncDepsCommand","abstraction","implementation","dependencies"],"sources":["SyncDepsCommand.ts"],"sourcesContent":["import { createImplementation } from \"@webiny/di\";\nimport { CliCommandFactory, GetProjectSdkService, UiService } from \"~/abstractions/index.js\";\n\nimport { createDependencyTree } from \"../createDependencyTree.js\";\nimport { createReferenceFile } from \"../createReferenceFile.js\";\n\nexport class SyncDepsCommand implements CliCommandFactory.Interface<unknown> {\n constructor(\n private getProjectSdkService: GetProjectSdkService.Interface,\n private uiService: UiService.Interface\n ) {}\n\n async execute() {\n const projectSdk = await this.getProjectSdkService.execute();\n\n return {\n name: \"sync-dependencies\",\n description: \"Sync dependencies for all packages.\",\n examples: [\"$0 sync-dependencies\"],\n handler: async () => {\n const project = projectSdk.getProject();\n const tree = createDependencyTree(project);\n\n return createReferenceFile(project, tree, { uiService: this.uiService });\n }\n };\n }\n}\n\nexport const syncDepsCommand = createImplementation({\n abstraction: CliCommandFactory,\n implementation: SyncDepsCommand,\n dependencies: [GetProjectSdkService, UiService]\n});\n"],"mappings":"AAAA,SAASA,oBAAoB,QAAQ,YAAY;AACjD,SAASC,iBAAiB,EAAEC,oBAAoB,EAAEC,SAAS;AAE3D,SAASC,oBAAoB;AAC7B,SAASC,mBAAmB;AAE5B,OAAO,MAAMC,eAAe,CAAiD;EACzEC,WAAWA,CACCC,oBAAoD,EACpDC,SAA8B,EACxC;IAAA,KAFUD,oBAAoD,GAApDA,oBAAoD;IAAA,KACpDC,SAA8B,GAA9BA,SAA8B;EACvC;EAEH,MAAMC,OAAOA,CAAA,EAAG;IACZ,MAAMC,UAAU,GAAG,MAAM,IAAI,CAACH,oBAAoB,CAACE,OAAO,CAAC,CAAC;IAE5D,OAAO;MACHE,IAAI,EAAE,mBAAmB;MACzBC,WAAW,EAAE,qCAAqC;MAClDC,QAAQ,EAAE,CAAC,sBAAsB,CAAC;MAClCC,OAAO,EAAE,MAAAA,CAAA,KAAY;QACjB,MAAMC,OAAO,GAAGL,UAAU,CAACM,UAAU,CAAC,CAAC;QACvC,MAAMC,IAAI,GAAGd,oBAAoB,CAACY,OAAO,CAAC;QAE1C,OAAOX,mBAAmB,CAACW,OAAO,EAAEE,IAAI,EAAE;UAAET,SAAS,EAAE,IAAI,CAACA;QAAU,CAAC,CAAC;MAC5E;IACJ,CAAC;EACL;AACJ;AAEA,OAAO,MAAMU,eAAe,GAAGnB,oBAAoB,CAAC;EAChDoB,WAAW,EAAEnB,iBAAiB;EAC9BoB,cAAc,EAAEf,eAAe;EAC/BgB,YAAY,EAAE,CAACpB,oBAAoB,EAAEC,SAAS;AAClD,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"features/DepsSync/commands/SyncDepsCommand.js","sources":["../../../../src/features/DepsSync/commands/SyncDepsCommand.ts"],"sourcesContent":["import { createImplementation } from \"@webiny/di\";\nimport { CliCommandFactory, GetProjectSdkService, UiService } from \"~/abstractions/index.js\";\n\nimport { createDependencyTree } from \"../createDependencyTree.js\";\nimport { createReferenceFile } from \"../createReferenceFile.js\";\n\nexport class SyncDepsCommand implements CliCommandFactory.Interface<unknown> {\n constructor(\n private getProjectSdkService: GetProjectSdkService.Interface,\n private uiService: UiService.Interface\n ) {}\n\n async execute() {\n const projectSdk = await this.getProjectSdkService.execute();\n\n return {\n name: \"sync-dependencies\",\n description: \"Sync dependencies for all packages.\",\n examples: [\"$0 sync-dependencies\"],\n handler: async () => {\n const project = projectSdk.getProject();\n const tree = createDependencyTree(project);\n\n return createReferenceFile(project, tree, { uiService: this.uiService });\n }\n };\n }\n}\n\nexport const syncDepsCommand = createImplementation({\n abstraction: CliCommandFactory,\n implementation: SyncDepsCommand,\n dependencies: [GetProjectSdkService, UiService]\n});\n"],"names":["SyncDepsCommand","getProjectSdkService","uiService","projectSdk","project","tree","createDependencyTree","createReferenceFile","syncDepsCommand","createImplementation","CliCommandFactory","GetProjectSdkService","UiService"],"mappings":";;;;AAMO,MAAMA;IACT,YACYC,oBAAoD,EACpDC,SAA8B,CACxC;aAFUD,oBAAoB,GAApBA;aACAC,SAAS,GAATA;IACT;IAEH,MAAM,UAAU;QACZ,MAAMC,aAAa,MAAM,IAAI,CAAC,oBAAoB,CAAC,OAAO;QAE1D,OAAO;YACH,MAAM;YACN,aAAa;YACb,UAAU;gBAAC;aAAuB;YAClC,SAAS;gBACL,MAAMC,UAAUD,WAAW,UAAU;gBACrC,MAAME,OAAOC,qBAAqBF;gBAElC,OAAOG,oBAAoBH,SAASC,MAAM;oBAAE,WAAW,IAAI,CAAC,SAAS;gBAAC;YAC1E;QACJ;IACJ;AACJ;AAEO,MAAMG,kBAAkBC,qBAAqB;IAChD,aAAaC;IACb,gBAAgBV;IAChB,cAAc;QAACW;QAAsBC;KAAU;AACnD"}
@@ -4,78 +4,77 @@ import { loadJsonFileSync } from "load-json-file";
4
4
  import { getDuplicatesFilePath, getReferencesFilePath } from "../paths.js";
5
5
  import fs from "fs";
6
6
  import { createDependencyTree } from "../createDependencyTree.js";
7
- export class VerifyDepsCommand {
8
- constructor(getProjectSdkService, uiService) {
9
- this.getProjectSdkService = getProjectSdkService;
10
- this.uiService = uiService;
11
- }
12
- async execute() {
13
- return {
14
- name: "verify-dependencies",
15
- description: "Verify dependencies for all packages.",
16
- examples: ["$0 verify-dependencies"],
17
- handler: async () => {
18
- const ui = this.uiService;
19
- const projectSdk = await this.getProjectSdkService.execute();
20
- const project = projectSdk.getProject();
21
- const referencesFile = getReferencesFilePath(project);
22
- const duplicatesFile = getDuplicatesFilePath(project);
23
- const tree = createDependencyTree(project);
24
- const references = {
25
- dependencies: tree.dependencies,
26
- devDependencies: tree.devDependencies,
27
- peerDependencies: tree.peerDependencies,
28
- resolutions: tree.resolutions,
29
- references: tree.references
30
- };
31
- ui.info("Checking references file...");
32
- if (fs.existsSync(referencesFile)) {
33
- const json = loadJsonFileSync(referencesFile);
34
- if (JSON.stringify(references) !== JSON.stringify(json)) {
35
- for (const type in references) {
36
- const refDependencies = references[type];
37
- const fileDependencies = json[type];
38
- for (const dep in refDependencies) {
39
- const refDep = refDependencies[dep];
40
- const fileDep = fileDependencies[dep];
41
- if (!fileDep) {
42
- console.log("Missing dependency:", refDep.name, "in", type);
43
- continue;
44
- }
45
- if (JSON.stringify(refDep) !== JSON.stringify(fileDep)) {
46
- console.log("Mismatch in dependency:", refDep.name, "in", type);
47
- console.log({
48
- refDep: JSON.stringify(refDep),
49
- fileDep: JSON.stringify(fileDep)
50
- });
51
- }
52
- }
7
+ class VerifyDepsCommand {
8
+ constructor(getProjectSdkService, uiService){
9
+ this.getProjectSdkService = getProjectSdkService;
10
+ this.uiService = uiService;
11
+ }
12
+ async execute() {
13
+ return {
14
+ name: "verify-dependencies",
15
+ description: "Verify dependencies for all packages.",
16
+ examples: [
17
+ "$0 verify-dependencies"
18
+ ],
19
+ handler: async ()=>{
20
+ const ui = this.uiService;
21
+ const projectSdk = await this.getProjectSdkService.execute();
22
+ const project = projectSdk.getProject();
23
+ const referencesFile = getReferencesFilePath(project);
24
+ const duplicatesFile = getDuplicatesFilePath(project);
25
+ const tree = createDependencyTree(project);
26
+ const references = {
27
+ dependencies: tree.dependencies,
28
+ devDependencies: tree.devDependencies,
29
+ peerDependencies: tree.peerDependencies,
30
+ resolutions: tree.resolutions,
31
+ references: tree.references
32
+ };
33
+ ui.info("Checking references file...");
34
+ if (fs.existsSync(referencesFile)) {
35
+ const json = loadJsonFileSync(referencesFile);
36
+ if (JSON.stringify(references) !== JSON.stringify(json)) {
37
+ for(const type in references){
38
+ const refDependencies = references[type];
39
+ const fileDependencies = json[type];
40
+ for(const dep in refDependencies){
41
+ const refDep = refDependencies[dep];
42
+ const fileDep = fileDependencies[dep];
43
+ if (!fileDep) {
44
+ console.log("Missing dependency:", refDep.name, "in", type);
45
+ continue;
46
+ }
47
+ if (JSON.stringify(refDep) !== JSON.stringify(fileDep)) {
48
+ console.log("Mismatch in dependency:", refDep.name, "in", type);
49
+ console.log({
50
+ refDep: JSON.stringify(refDep),
51
+ fileDep: JSON.stringify(fileDep)
52
+ });
53
+ }
54
+ }
55
+ }
56
+ throw new Error("References are not in sync. Please run `yarn webiny sync-dependencies` command.");
57
+ }
58
+ } else throw new Error("References file does not exist. Please run `yarn webiny sync-dependencies` command.");
59
+ ui.info("Checking duplicates file...");
60
+ if (fs.existsSync(duplicatesFile)) {
61
+ const json = loadJsonFileSync(duplicatesFile);
62
+ if (JSON.stringify(tree.duplicates) !== JSON.stringify(json)) throw new Error("Duplicates are not in sync. Please run `yarn webiny sync-dependencies` command.");
63
+ if (Array.isArray(json) && json.length > 0) throw new Error("There are still duplicates in the project. Please sort them out and run `yarn webiny sync-dependencies` command to regenerate files.");
64
+ } else throw new Error("Duplicates file does not exist. Please run `yarn webiny sync-dependencies` command.");
65
+ ui.info("✅ All package reference files are in sync.");
53
66
  }
54
- throw new Error("References are not in sync. Please run `yarn webiny sync-dependencies` command.");
55
- }
56
- } else {
57
- throw new Error("References file does not exist. Please run `yarn webiny sync-dependencies` command.");
58
- }
59
- ui.info("Checking duplicates file...");
60
- if (fs.existsSync(duplicatesFile)) {
61
- const json = loadJsonFileSync(duplicatesFile);
62
- if (JSON.stringify(tree.duplicates) !== JSON.stringify(json)) {
63
- throw new Error("Duplicates are not in sync. Please run `yarn webiny sync-dependencies` command.");
64
- } else if (Array.isArray(json) && json.length > 0) {
65
- throw new Error("There are still duplicates in the project. Please sort them out and run `yarn webiny sync-dependencies` command to regenerate files.");
66
- }
67
- } else {
68
- throw new Error("Duplicates file does not exist. Please run `yarn webiny sync-dependencies` command.");
69
- }
70
- ui.info("✅ All package reference files are in sync.");
71
- }
72
- };
73
- }
67
+ };
68
+ }
74
69
  }
75
- export const verifyDepsCommand = createImplementation({
76
- abstraction: CliCommandFactory,
77
- implementation: VerifyDepsCommand,
78
- dependencies: [GetProjectSdkService, UiService]
70
+ const verifyDepsCommand = createImplementation({
71
+ abstraction: CliCommandFactory,
72
+ implementation: VerifyDepsCommand,
73
+ dependencies: [
74
+ GetProjectSdkService,
75
+ UiService
76
+ ]
79
77
  });
78
+ export { VerifyDepsCommand, verifyDepsCommand };
80
79
 
81
80
  //# sourceMappingURL=VerifyDepsCommand.js.map