@webiny/cli-core 6.3.0 → 6.4.0-beta.0
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.
- package/Cli.js +12 -11
- package/Cli.js.map +1 -1
- package/abstractions/createAbstraction.js +3 -2
- package/abstractions/createAbstraction.js.map +1 -1
- package/abstractions/features/CliCommand.js +2 -4
- package/abstractions/features/CliCommand.js.map +1 -1
- package/abstractions/features/ErrorHandler.js +2 -1
- package/abstractions/features/ErrorHandler.js.map +1 -1
- package/abstractions/features/GlobalCliOption.js +2 -1
- package/abstractions/features/GlobalCliOption.js.map +1 -1
- package/abstractions/features/IsCi.js +2 -1
- package/abstractions/features/IsCi.js.map +1 -1
- package/abstractions/features/index.js +0 -2
- package/abstractions/features/types.js +0 -3
- package/abstractions/index.js +0 -2
- package/abstractions/services/ArgvParserService.js +2 -1
- package/abstractions/services/ArgvParserService.js.map +1 -1
- package/abstractions/services/CliParamsService.js +2 -1
- package/abstractions/services/CliParamsService.js.map +1 -1
- package/abstractions/services/CommandsRegistryService.js +2 -1
- package/abstractions/services/CommandsRegistryService.js.map +1 -1
- package/abstractions/services/GetArgvService.js +2 -1
- package/abstractions/services/GetArgvService.js.map +1 -1
- package/abstractions/services/GetCliRunnerService.js +2 -1
- package/abstractions/services/GetCliRunnerService.js.map +1 -1
- package/abstractions/services/GetIsCiService.js +2 -1
- package/abstractions/services/GetIsCiService.js.map +1 -1
- package/abstractions/services/GetProjectSdkService.js +2 -1
- package/abstractions/services/GetProjectSdkService.js.map +1 -1
- package/abstractions/services/GlobalOptionsRegistryService.js +2 -1
- package/abstractions/services/GlobalOptionsRegistryService.js.map +1 -1
- package/abstractions/services/LoggerService.js +2 -1
- package/abstractions/services/LoggerService.js.map +1 -1
- package/abstractions/services/RunCliRunnerService.js +2 -1
- package/abstractions/services/RunCliRunnerService.js.map +1 -1
- package/abstractions/services/StdioService.js +2 -1
- package/abstractions/services/StdioService.js.map +1 -1
- package/abstractions/services/UiService.js +2 -1
- package/abstractions/services/UiService.js.map +1 -1
- package/abstractions/services/index.js +0 -2
- package/createCliContainer.js +87 -113
- package/createCliContainer.js.map +1 -1
- package/decorators/CommandsWithGracefulErrorHandling.js +34 -32
- package/decorators/CommandsWithGracefulErrorHandling.js.map +1 -1
- package/decorators/DeployCommandWithTelemetry.js +72 -82
- package/decorators/DeployCommandWithTelemetry.js.map +1 -1
- package/decorators/index.js +0 -2
- package/exports/cli/command.js +0 -2
- package/exports/cli.js +0 -2
- package/extensions/CliCommand.js +15 -18
- package/extensions/CliCommand.js.map +1 -1
- package/extensions/CliCommandDecorator.js +15 -18
- package/extensions/CliCommandDecorator.js.map +1 -1
- package/extensions/index.js +5 -2
- package/extensions/index.js.map +1 -1
- package/features/AboutCommand.js +80 -86
- package/features/AboutCommand.js.map +1 -1
- package/features/BuildCommand/BuildCommand.js +46 -36
- package/features/BuildCommand/BuildCommand.js.map +1 -1
- package/features/BuildCommand/buildRunners/BaseBuildRunner.js +10 -13
- package/features/BuildCommand/buildRunners/BaseBuildRunner.js.map +1 -1
- package/features/BuildCommand/buildRunners/BuildRunner.js +18 -21
- package/features/BuildCommand/buildRunners/BuildRunner.js.map +1 -1
- package/features/BuildCommand/buildRunners/MultipleBuildsRunner.js +20 -19
- package/features/BuildCommand/buildRunners/MultipleBuildsRunner.js.map +1 -1
- package/features/BuildCommand/buildRunners/SingleBuildRunner.js +15 -14
- package/features/BuildCommand/buildRunners/SingleBuildRunner.js.map +1 -1
- package/features/BuildCommand/buildRunners/ZeroBuildsRunner.js +3 -4
- package/features/BuildCommand/buildRunners/ZeroBuildsRunner.js.map +1 -1
- package/features/BuildCommand/index.js +0 -2
- package/features/ConfigCommand.js +55 -56
- package/features/ConfigCommand.js.map +1 -1
- package/features/DeployCommand/DeployCommand.js +162 -156
- package/features/DeployCommand/DeployCommand.js.map +1 -1
- package/features/DeployCommand/deployOutputs/BaseDeployOutput.js +12 -17
- package/features/DeployCommand/deployOutputs/BaseDeployOutput.js.map +1 -1
- package/features/DeployCommand/deployOutputs/DeployOutput.js +16 -17
- package/features/DeployCommand/deployOutputs/DeployOutput.js.map +1 -1
- package/features/DeployCommand/deployOutputs/NoDeploymentLogsDeployOutput.js +89 -54
- package/features/DeployCommand/deployOutputs/NoDeploymentLogsDeployOutput.js.map +1 -1
- package/features/DeployCommand/deployOutputs/WithDeploymentLogsDeployOutput.js +24 -37
- package/features/DeployCommand/deployOutputs/WithDeploymentLogsDeployOutput.js.map +1 -1
- package/features/DeployCommand/index.js +0 -2
- package/features/DepsSync/BuildDependencyTree.js +16 -21
- package/features/DepsSync/BuildDependencyTree.js.map +1 -1
- package/features/DepsSync/DependencyTree.js +108 -126
- package/features/DepsSync/DependencyTree.js.map +1 -1
- package/features/DepsSync/ListAllPackageJsonFiles.js +19 -14
- package/features/DepsSync/ListAllPackageJsonFiles.js.map +1 -1
- package/features/DepsSync/ListAllPackages.js +7 -9
- package/features/DepsSync/ListAllPackages.js.map +1 -1
- package/features/DepsSync/commands/SyncDepsCommand.js +30 -24
- package/features/DepsSync/commands/SyncDepsCommand.js.map +1 -1
- package/features/DepsSync/commands/VerifyDepsCommand.js +69 -70
- package/features/DepsSync/commands/VerifyDepsCommand.js.map +1 -1
- package/features/DepsSync/createDependencyTree.js +25 -18
- package/features/DepsSync/createDependencyTree.js.map +1 -1
- package/features/DepsSync/createReferenceFile.js +21 -25
- package/features/DepsSync/createReferenceFile.js.map +1 -1
- package/features/DepsSync/index.js +0 -2
- package/features/DepsSync/paths.js +3 -6
- package/features/DepsSync/paths.js.map +1 -1
- package/features/DepsSync/types.js +7 -6
- package/features/DepsSync/types.js.map +1 -1
- package/features/DestroyCommand/DestroyCommand.js +71 -67
- package/features/DestroyCommand/DestroyCommand.js.map +1 -1
- package/features/DestroyCommand/index.js +0 -2
- package/features/DisableTelemetryCommand.js +28 -25
- package/features/DisableTelemetryCommand.js.map +1 -1
- package/features/EnableTelemetryCommand.js +28 -25
- package/features/EnableTelemetryCommand.js.map +1 -1
- package/features/ExtensionCommand/ExtensionCommand.js +60 -63
- package/features/ExtensionCommand/ExtensionCommand.js.map +1 -1
- package/features/ExtensionCommand/index.js +0 -2
- package/features/InfoCommand/InfoCommand.js +54 -56
- package/features/InfoCommand/InfoCommand.js.map +1 -1
- package/features/InfoCommand/PrintInfoForEnv.js +31 -47
- package/features/InfoCommand/PrintInfoForEnv.js.map +1 -1
- package/features/InfoCommand/index.js +0 -2
- package/features/IsCi/IsCi.js +14 -11
- package/features/IsCi/IsCi.js.map +1 -1
- package/features/IsCi/index.js +1 -3
- package/features/OpenCommand.js +48 -47
- package/features/OpenCommand.js.map +1 -1
- package/features/OutputCommand.js +56 -69
- package/features/OutputCommand.js.map +1 -1
- package/features/PulumiCommand/PulumiCommand.js +48 -41
- package/features/PulumiCommand/PulumiCommand.js.map +1 -1
- package/features/PulumiCommand/index.js +0 -2
- package/features/RefreshCommand/RefreshCommand.js +42 -36
- package/features/RefreshCommand/RefreshCommand.js.map +1 -1
- package/features/RefreshCommand/index.js +0 -2
- package/features/UpgradeCommand/UpgradeCommand.js +112 -101
- package/features/UpgradeCommand/UpgradeCommand.js.map +1 -1
- package/features/UpgradeCommand/UpgradeCommandHandler.js +90 -101
- package/features/UpgradeCommand/UpgradeCommandHandler.js.map +1 -1
- package/features/UpgradeCommand/abstraction.js +2 -1
- package/features/UpgradeCommand/abstraction.js.map +1 -1
- package/features/UpgradeCommand/feature.js +7 -6
- package/features/UpgradeCommand/feature.js.map +1 -1
- package/features/UpgradeCommand/index.js +0 -2
- package/features/WatchCommand/WatchCommand.js +131 -131
- package/features/WatchCommand/WatchCommand.js.map +1 -1
- package/features/WatchCommand/createPrefixer.js +11 -15
- package/features/WatchCommand/createPrefixer.js.map +1 -1
- package/features/WatchCommand/getRandomColorForString.js +86 -8
- package/features/WatchCommand/getRandomColorForString.js.map +1 -1
- package/features/WatchCommand/index.js +0 -2
- package/features/Wcp/LinkProjectCommand.js +119 -138
- package/features/Wcp/LinkProjectCommand.js.map +1 -1
- package/features/Wcp/LoginCommand.js +104 -118
- package/features/Wcp/LoginCommand.js.map +1 -1
- package/features/Wcp/LogoutCommand.js +29 -23
- package/features/Wcp/LogoutCommand.js.map +1 -1
- package/features/Wcp/WhoAmICommand.js +33 -29
- package/features/Wcp/WhoAmICommand.js.map +1 -1
- package/features/common/index.js +0 -2
- package/features/common/options.js +41 -50
- package/features/common/options.js.map +1 -1
- package/features/globalOptions/LogLevelGlobalOption.js +25 -16
- package/features/globalOptions/LogLevelGlobalOption.js.map +1 -1
- package/features/globalOptions/ShowLogsGlobalOption.js +16 -15
- package/features/globalOptions/ShowLogsGlobalOption.js.map +1 -1
- package/features/globalOptions/StackTraceGlobalOption.js +16 -15
- package/features/globalOptions/StackTraceGlobalOption.js.map +1 -1
- package/features/globalOptions/index.js +0 -2
- package/features/gracefulErrorHandlers/DdbPutItemConditionalCheckFailedGracefulErrorHandler.js +17 -16
- package/features/gracefulErrorHandlers/DdbPutItemConditionalCheckFailedGracefulErrorHandler.js.map +1 -1
- package/features/gracefulErrorHandlers/MissingFilesInBuildGracefulErrorHandler.js +12 -18
- package/features/gracefulErrorHandlers/MissingFilesInBuildGracefulErrorHandler.js.map +1 -1
- package/features/gracefulErrorHandlers/PendingOperationsGracefulErrorHandler.js +19 -19
- package/features/gracefulErrorHandlers/PendingOperationsGracefulErrorHandler.js.map +1 -1
- package/features/gracefulErrorHandlers/index.js +0 -2
- package/features/index.js +0 -2
- package/features/utils/index.js +0 -2
- package/features/utils/measureDuration.js +7 -8
- package/features/utils/measureDuration.js.map +1 -1
- package/index.js +0 -2
- package/package.json +10 -10
- package/services/ArgvParserService/ArgvParserService.js +27 -33
- package/services/ArgvParserService/ArgvParserService.js.map +1 -1
- package/services/ArgvParserService/index.js +0 -2
- package/services/CliParamsService/CliParamsService.js +18 -15
- package/services/CliParamsService/CliParamsService.js.map +1 -1
- package/services/CliParamsService/index.js +0 -2
- package/services/CommandsRegistryService/CommandsRegistryService.js +19 -13
- package/services/CommandsRegistryService/CommandsRegistryService.js.map +1 -1
- package/services/CommandsRegistryService/index.js +0 -2
- package/services/GetArgvService/GetArgvService.js +14 -11
- package/services/GetArgvService/GetArgvService.js.map +1 -1
- package/services/GetArgvService/index.js +0 -2
- package/services/GetCliRunnerService/GetCliRunnerService.js +119 -155
- package/services/GetCliRunnerService/GetCliRunnerService.js.map +1 -1
- package/services/GetCliRunnerService/index.js +0 -2
- package/services/GetIsCiService/GetIsCiService.js +9 -8
- package/services/GetIsCiService/GetIsCiService.js.map +1 -1
- package/services/GetIsCiService/index.js +1 -3
- package/services/GetProjectSdkService/GetProjectSdkService.js +25 -24
- package/services/GetProjectSdkService/GetProjectSdkService.js.map +1 -1
- package/services/GetProjectSdkService/index.js +0 -2
- package/services/GlobalOptionsRegistryService/GlobalOptionsRegistryService.js +19 -13
- package/services/GlobalOptionsRegistryService/GlobalOptionsRegistryService.js.map +1 -1
- package/services/GlobalOptionsRegistryService/index.js +0 -2
- package/services/LoggerService/LoggerService.js +75 -87
- package/services/LoggerService/LoggerService.js.map +1 -1
- package/services/LoggerService/index.js +0 -2
- package/services/RunCliRunnerService/RunCliRunnerService.js +15 -13
- package/services/RunCliRunnerService/RunCliRunnerService.js.map +1 -1
- package/services/RunCliRunnerService/index.js +0 -2
- package/services/StdioService/StdioService.js +15 -14
- package/services/StdioService/StdioService.js.map +1 -1
- package/services/StdioService/index.js +0 -2
- package/services/UiService/UiService.js +55 -58
- package/services/UiService/UiService.js.map +1 -1
- package/services/UiService/index.js +0 -2
- package/services/index.js +0 -2
- package/utils/ManuallyReportedError.js +7 -6
- package/utils/ManuallyReportedError.js.map +1 -1
- package/abstractions/features/index.js.map +0 -1
- package/abstractions/features/types.js.map +0 -1
- package/abstractions/index.js.map +0 -1
- package/abstractions/services/index.js.map +0 -1
- package/decorators/index.js.map +0 -1
- package/exports/cli/command.js.map +0 -1
- package/exports/cli.js.map +0 -1
- package/features/BuildCommand/index.js.map +0 -1
- package/features/DeployCommand/index.js.map +0 -1
- package/features/DepsSync/index.js.map +0 -1
- package/features/DestroyCommand/index.js.map +0 -1
- package/features/ExtensionCommand/index.js.map +0 -1
- package/features/InfoCommand/index.js.map +0 -1
- package/features/IsCi/index.js.map +0 -1
- package/features/PulumiCommand/index.js.map +0 -1
- package/features/RefreshCommand/index.js.map +0 -1
- package/features/UpgradeCommand/index.js.map +0 -1
- package/features/WatchCommand/index.js.map +0 -1
- package/features/common/index.js.map +0 -1
- package/features/globalOptions/index.js.map +0 -1
- package/features/gracefulErrorHandlers/index.js.map +0 -1
- package/features/index.js.map +0 -1
- package/features/utils/index.js.map +0 -1
- package/index.js.map +0 -1
- package/services/ArgvParserService/index.js.map +0 -1
- package/services/CliParamsService/index.js.map +0 -1
- package/services/CommandsRegistryService/index.js.map +0 -1
- package/services/GetArgvService/index.js.map +0 -1
- package/services/GetCliRunnerService/index.js.map +0 -1
- package/services/GetIsCiService/index.js.map +0 -1
- package/services/GetProjectSdkService/index.js.map +0 -1
- package/services/GlobalOptionsRegistryService/index.js.map +0 -1
- package/services/LoggerService/index.js.map +0 -1
- package/services/RunCliRunnerService/index.js.map +0 -1
- package/services/StdioService/index.js.map +0 -1
- package/services/UiService/index.js.map +0 -1
- package/services/index.js.map +0 -1
|
@@ -1,138 +1,120 @@
|
|
|
1
1
|
import semver from "semver";
|
|
2
2
|
import { PackageType } from "./types.js";
|
|
3
|
-
const keys = [
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
this.addReference({
|
|
70
|
-
name,
|
|
71
|
-
version,
|
|
72
|
-
file,
|
|
73
|
-
type: key
|
|
74
|
-
});
|
|
75
|
-
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
|
+
}
|
|
76
69
|
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
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
|
+
]
|
|
81
89
|
});
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
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
|
+
]
|
|
87
99
|
});
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
}
|
|
91
|
-
addReference(ref) {
|
|
92
|
-
const existing = this.references.find(item => {
|
|
93
|
-
return item.name === ref.name;
|
|
94
|
-
});
|
|
95
|
-
const types = [ref.type];
|
|
96
|
-
if (!existing) {
|
|
97
|
-
this.references.push({
|
|
98
|
-
name: ref.name,
|
|
99
|
-
versions: [{
|
|
100
|
-
version: ref.version,
|
|
101
|
-
files: [{
|
|
100
|
+
const existingFile = existingVersion.files.find((item)=>item.file === ref.file);
|
|
101
|
+
if (!existingFile) return void existingVersion.files.push({
|
|
102
102
|
file: ref.file,
|
|
103
103
|
types
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
return;
|
|
108
|
-
}
|
|
109
|
-
const existingVersion = existing.versions.find(item => {
|
|
110
|
-
return item.version === ref.version;
|
|
111
|
-
});
|
|
112
|
-
if (!existingVersion) {
|
|
113
|
-
existing.versions.push({
|
|
114
|
-
version: ref.version,
|
|
115
|
-
files: [{
|
|
116
|
-
file: ref.file,
|
|
117
|
-
types
|
|
118
|
-
}]
|
|
119
|
-
});
|
|
120
|
-
return;
|
|
104
|
+
});
|
|
105
|
+
if (existingFile.types.includes(ref.type)) return;
|
|
106
|
+
existingFile.types.push(ref.type);
|
|
121
107
|
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
return;
|
|
131
|
-
} else if (existingFile.types.includes(ref.type)) {
|
|
132
|
-
return;
|
|
108
|
+
constructor(){
|
|
109
|
+
this.packages = {
|
|
110
|
+
resolutions: [],
|
|
111
|
+
dependencies: [],
|
|
112
|
+
devDependencies: [],
|
|
113
|
+
peerDependencies: []
|
|
114
|
+
};
|
|
115
|
+
this.references = [];
|
|
133
116
|
}
|
|
134
|
-
existingFile.types.push(ref.type);
|
|
135
|
-
}
|
|
136
117
|
}
|
|
118
|
+
export { DependencyTree };
|
|
137
119
|
|
|
138
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","startsWith","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 /**\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"],"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,C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CAACL,QAAQ,EAAE;MACX,IAAI,CAACxB,UAAU,CAACO,IAAI,CAAC;QACjBX,IAAI,EAAEkC,GAAG,CAAClC,IAAI;QACdS,QAAQ,EAAE,CACN;UACIS,OAAO,EAAEgB,GAAG,CAAChB,OAAO;UACpBa,KAAK,EAAE,CACH;YACIlB,IAAI,EAAEqB,GAAG,CAACrB,IAAI;YACdsB;UACJ,CAAC;QAET,CAAC;MAET,CAAC,CAAC;MACF;IACJ;IACA,MAAMC,eAAe,GAAGR,QAAQ,CAACnB,QAAQ,CAACoB,IAAI,CAACC,IAAI,IAAI;MACnD,OAAOA,IAAI,CAACZ,OAAO,KAAKgB,GAAG,CAAChB,OAAO;IACvC,CAAC,CAAC;IACF,IAAI,CAACkB,eAAe,EAAE;MAClBR,QAAQ,CAACnB,QAAQ,CAACE,IAAI,CAAC;QACnBO,OAAO,EAAEgB,GAAG,CAAChB,OAAO;QACpBa,KAAK,EAAE,CACH;UACIlB,IAAI,EAAEqB,GAAG,CAACrB,IAAI;UACdsB;QACJ,CAAC;MAET,CAAC,CAAC;MACF;IACJ;IACA,MAAME,YAAY,GAAGD,eAAe,CAACL,KAAK,CAACF,IAAI,CAACC,IAAI,IAAI;MACpD,OAAOA,IAAI,CAACjB,IAAI,KAAKqB,GAAG,CAACrB,IAAI;IACjC,CAAC,CAAC;IACF,IAAI,CAACwB,YAAY,EAAE;MACfD,eAAe,CAACL,KAAK,CAACpB,IAAI,CAAC;QACvBE,IAAI,EAAEqB,GAAG,CAACrB,IAAI;QACdsB;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,CAACxB,IAAI,CAACuB,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,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AAI,CAACH,CAAAA,OACrCA,KAAK,IAAI,KAAKC,IAAI,IAAI;QAEjC,IAAI,CAACG,cAAc,YACfD,gBAAgB,KAAK,CAAC,IAAI,CAAC;YACvB,MAAMF,IAAI,IAAI;YACdC;QACJ;QAEG,IAAIE,aAAa,KAAK,CAAC,QAAQ,CAACH,IAAI,IAAI,GAC3C;QAEJG,aAAa,KAAK,CAAC,IAAI,CAACH,IAAI,IAAI;IACpC;;aA1JiB,QAAQ,GAAiD;YACtE,aAAa,EAAE;YACf,cAAc,EAAE;YAChB,iBAAiB,EAAE;YACnB,kBAAkB,EAAE;QACxB;aACgB,UAAU,GAAiB,EAAE;;AAqJjD"}
|
|
@@ -1,18 +1,23 @@
|
|
|
1
|
-
import
|
|
2
|
-
const defaultIgnore = [
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
ignore
|
|
11
|
-
|
|
12
|
-
|
|
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,"
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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,"
|
|
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
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
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,"
|
|
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
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
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
|
-
|
|
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
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
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
|