pnpm-catalog-updates 0.5.6 → 0.6.5
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/bin/pcu.js +1 -1
- package/dist/index.js +9559 -32
- package/dist/index.js.map +1 -1
- package/package.json +61 -103
- package/src/cli/commands/checkCommand.ts +227 -0
- package/src/cli/commands/initCommand.ts +394 -0
- package/src/cli/commands/securityCommand.ts +569 -0
- package/src/cli/commands/updateCommand.ts +245 -0
- package/src/cli/formatters/outputFormatter.ts +830 -0
- package/src/cli/formatters/progressBar.ts +700 -0
- package/src/cli/index.ts +565 -0
- package/src/cli/interactive/interactivePrompts.ts +517 -0
- package/src/cli/options/globalOptions.ts +380 -0
- package/src/cli/options/index.ts +5 -0
- package/src/cli/themes/colorTheme.ts +379 -0
- package/src/cli/validators/commandValidator.ts +395 -0
- package/src/cli/validators/index.ts +5 -0
- package/src/index.ts +4 -0
- package/LICENSE +0 -21
- package/README.ja.md +0 -582
- package/README.md +0 -690
- package/README.zh-CN.md +0 -630
- package/dist/application/services/CatalogUpdateService.d.ts +0 -209
- package/dist/application/services/CatalogUpdateService.d.ts.map +0 -1
- package/dist/application/services/CatalogUpdateService.js +0 -836
- package/dist/application/services/CatalogUpdateService.js.map +0 -1
- package/dist/application/services/WorkspaceService.d.ts +0 -139
- package/dist/application/services/WorkspaceService.d.ts.map +0 -1
- package/dist/application/services/WorkspaceService.js +0 -340
- package/dist/application/services/WorkspaceService.js.map +0 -1
- package/dist/cli/commands/CheckCommand.d.ts +0 -40
- package/dist/cli/commands/CheckCommand.d.ts.map +0 -1
- package/dist/cli/commands/CheckCommand.js +0 -177
- package/dist/cli/commands/CheckCommand.js.map +0 -1
- package/dist/cli/commands/InitCommand.d.ts +0 -53
- package/dist/cli/commands/InitCommand.d.ts.map +0 -1
- package/dist/cli/commands/InitCommand.js +0 -338
- package/dist/cli/commands/InitCommand.js.map +0 -1
- package/dist/cli/commands/SecurityCommand.d.ts +0 -113
- package/dist/cli/commands/SecurityCommand.d.ts.map +0 -1
- package/dist/cli/commands/SecurityCommand.js +0 -410
- package/dist/cli/commands/SecurityCommand.js.map +0 -1
- package/dist/cli/commands/UpdateCommand.d.ts +0 -44
- package/dist/cli/commands/UpdateCommand.d.ts.map +0 -1
- package/dist/cli/commands/UpdateCommand.js +0 -189
- package/dist/cli/commands/UpdateCommand.js.map +0 -1
- package/dist/cli/formatters/OutputFormatter.d.ts +0 -116
- package/dist/cli/formatters/OutputFormatter.d.ts.map +0 -1
- package/dist/cli/formatters/OutputFormatter.js +0 -664
- package/dist/cli/formatters/OutputFormatter.js.map +0 -1
- package/dist/cli/formatters/ProgressBar.d.ts +0 -195
- package/dist/cli/formatters/ProgressBar.d.ts.map +0 -1
- package/dist/cli/formatters/ProgressBar.js +0 -622
- package/dist/cli/formatters/ProgressBar.js.map +0 -1
- package/dist/cli/index.d.ts +0 -12
- package/dist/cli/index.d.ts.map +0 -1
- package/dist/cli/index.js +0 -492
- package/dist/cli/index.js.map +0 -1
- package/dist/cli/interactive/InteractivePrompts.d.ts +0 -85
- package/dist/cli/interactive/InteractivePrompts.d.ts.map +0 -1
- package/dist/cli/interactive/InteractivePrompts.js +0 -434
- package/dist/cli/interactive/InteractivePrompts.js.map +0 -1
- package/dist/cli/options/GlobalOptions.d.ts +0 -117
- package/dist/cli/options/GlobalOptions.d.ts.map +0 -1
- package/dist/cli/options/GlobalOptions.js +0 -278
- package/dist/cli/options/GlobalOptions.js.map +0 -1
- package/dist/cli/options/index.d.ts +0 -5
- package/dist/cli/options/index.d.ts.map +0 -1
- package/dist/cli/options/index.js +0 -5
- package/dist/cli/options/index.js.map +0 -1
- package/dist/cli/themes/ColorTheme.d.ts +0 -211
- package/dist/cli/themes/ColorTheme.d.ts.map +0 -1
- package/dist/cli/themes/ColorTheme.js +0 -267
- package/dist/cli/themes/ColorTheme.js.map +0 -1
- package/dist/cli/validators/CommandValidator.d.ts +0 -60
- package/dist/cli/validators/CommandValidator.d.ts.map +0 -1
- package/dist/cli/validators/CommandValidator.js +0 -319
- package/dist/cli/validators/CommandValidator.js.map +0 -1
- package/dist/cli/validators/index.d.ts +0 -5
- package/dist/cli/validators/index.d.ts.map +0 -1
- package/dist/cli/validators/index.js +0 -5
- package/dist/cli/validators/index.js.map +0 -1
- package/dist/common/config/Config.d.ts +0 -142
- package/dist/common/config/Config.d.ts.map +0 -1
- package/dist/common/config/Config.js +0 -382
- package/dist/common/config/Config.js.map +0 -1
- package/dist/common/config/ConfigLoader.d.ts +0 -49
- package/dist/common/config/ConfigLoader.d.ts.map +0 -1
- package/dist/common/config/ConfigLoader.js +0 -180
- package/dist/common/config/ConfigLoader.js.map +0 -1
- package/dist/common/config/PackageFilterConfig.d.ts +0 -56
- package/dist/common/config/PackageFilterConfig.d.ts.map +0 -1
- package/dist/common/config/PackageFilterConfig.js +0 -94
- package/dist/common/config/PackageFilterConfig.js.map +0 -1
- package/dist/common/config/index.d.ts +0 -8
- package/dist/common/config/index.d.ts.map +0 -1
- package/dist/common/config/index.js +0 -8
- package/dist/common/config/index.js.map +0 -1
- package/dist/common/error-handling/ErrorTracker.d.ts +0 -48
- package/dist/common/error-handling/ErrorTracker.d.ts.map +0 -1
- package/dist/common/error-handling/ErrorTracker.js +0 -93
- package/dist/common/error-handling/ErrorTracker.js.map +0 -1
- package/dist/common/error-handling/UserFriendlyErrorHandler.d.ts +0 -74
- package/dist/common/error-handling/UserFriendlyErrorHandler.d.ts.map +0 -1
- package/dist/common/error-handling/UserFriendlyErrorHandler.js +0 -703
- package/dist/common/error-handling/UserFriendlyErrorHandler.js.map +0 -1
- package/dist/common/error-handling/index.d.ts +0 -11
- package/dist/common/error-handling/index.d.ts.map +0 -1
- package/dist/common/error-handling/index.js +0 -9
- package/dist/common/error-handling/index.js.map +0 -1
- package/dist/common/logger/Logger.d.ts +0 -110
- package/dist/common/logger/Logger.d.ts.map +0 -1
- package/dist/common/logger/Logger.js +0 -289
- package/dist/common/logger/Logger.js.map +0 -1
- package/dist/common/logger/index.d.ts +0 -6
- package/dist/common/logger/index.d.ts.map +0 -1
- package/dist/common/logger/index.js +0 -6
- package/dist/common/logger/index.js.map +0 -1
- package/dist/common/types/cli.d.ts +0 -265
- package/dist/common/types/cli.d.ts.map +0 -1
- package/dist/common/types/cli.js +0 -5
- package/dist/common/types/cli.js.map +0 -1
- package/dist/common/types/core.d.ts +0 -270
- package/dist/common/types/core.d.ts.map +0 -1
- package/dist/common/types/core.js +0 -32
- package/dist/common/types/core.js.map +0 -1
- package/dist/common/types/index.d.ts +0 -8
- package/dist/common/types/index.d.ts.map +0 -1
- package/dist/common/types/index.js +0 -8
- package/dist/common/types/index.js.map +0 -1
- package/dist/common/utils/VersionChecker.d.ts +0 -54
- package/dist/common/utils/VersionChecker.d.ts.map +0 -1
- package/dist/common/utils/VersionChecker.js +0 -180
- package/dist/common/utils/VersionChecker.js.map +0 -1
- package/dist/common/utils/async.d.ts +0 -74
- package/dist/common/utils/async.d.ts.map +0 -1
- package/dist/common/utils/async.js +0 -228
- package/dist/common/utils/async.js.map +0 -1
- package/dist/common/utils/format.d.ts +0 -32
- package/dist/common/utils/format.d.ts.map +0 -1
- package/dist/common/utils/format.js +0 -121
- package/dist/common/utils/format.js.map +0 -1
- package/dist/common/utils/git.d.ts +0 -44
- package/dist/common/utils/git.d.ts.map +0 -1
- package/dist/common/utils/git.js +0 -147
- package/dist/common/utils/git.js.map +0 -1
- package/dist/common/utils/index.d.ts +0 -12
- package/dist/common/utils/index.d.ts.map +0 -1
- package/dist/common/utils/index.js +0 -12
- package/dist/common/utils/index.js.map +0 -1
- package/dist/common/utils/string.d.ts +0 -56
- package/dist/common/utils/string.d.ts.map +0 -1
- package/dist/common/utils/string.js +0 -134
- package/dist/common/utils/string.js.map +0 -1
- package/dist/common/utils/validation.d.ts +0 -88
- package/dist/common/utils/validation.d.ts.map +0 -1
- package/dist/common/utils/validation.js +0 -308
- package/dist/common/utils/validation.js.map +0 -1
- package/dist/domain/entities/Catalog.d.ts +0 -117
- package/dist/domain/entities/Catalog.d.ts.map +0 -1
- package/dist/domain/entities/Catalog.js +0 -240
- package/dist/domain/entities/Catalog.js.map +0 -1
- package/dist/domain/entities/Package.d.ts +0 -143
- package/dist/domain/entities/Package.d.ts.map +0 -1
- package/dist/domain/entities/Package.js +0 -272
- package/dist/domain/entities/Package.js.map +0 -1
- package/dist/domain/entities/Workspace.d.ts +0 -95
- package/dist/domain/entities/Workspace.d.ts.map +0 -1
- package/dist/domain/entities/Workspace.js +0 -173
- package/dist/domain/entities/Workspace.js.map +0 -1
- package/dist/domain/repositories/WorkspaceRepository.d.ts +0 -41
- package/dist/domain/repositories/WorkspaceRepository.d.ts.map +0 -1
- package/dist/domain/repositories/WorkspaceRepository.js +0 -8
- package/dist/domain/repositories/WorkspaceRepository.js.map +0 -1
- package/dist/domain/value-objects/CatalogCollection.d.ts +0 -106
- package/dist/domain/value-objects/CatalogCollection.d.ts.map +0 -1
- package/dist/domain/value-objects/CatalogCollection.js +0 -230
- package/dist/domain/value-objects/CatalogCollection.js.map +0 -1
- package/dist/domain/value-objects/PackageCollection.d.ts +0 -122
- package/dist/domain/value-objects/PackageCollection.d.ts.map +0 -1
- package/dist/domain/value-objects/PackageCollection.js +0 -263
- package/dist/domain/value-objects/PackageCollection.js.map +0 -1
- package/dist/domain/value-objects/Version.d.ts +0 -141
- package/dist/domain/value-objects/Version.d.ts.map +0 -1
- package/dist/domain/value-objects/Version.js +0 -268
- package/dist/domain/value-objects/Version.js.map +0 -1
- package/dist/domain/value-objects/WorkspaceConfig.d.ts +0 -144
- package/dist/domain/value-objects/WorkspaceConfig.d.ts.map +0 -1
- package/dist/domain/value-objects/WorkspaceConfig.js +0 -357
- package/dist/domain/value-objects/WorkspaceConfig.js.map +0 -1
- package/dist/domain/value-objects/WorkspaceId.d.ts +0 -51
- package/dist/domain/value-objects/WorkspaceId.d.ts.map +0 -1
- package/dist/domain/value-objects/WorkspaceId.js +0 -104
- package/dist/domain/value-objects/WorkspaceId.js.map +0 -1
- package/dist/domain/value-objects/WorkspacePath.d.ts +0 -75
- package/dist/domain/value-objects/WorkspacePath.d.ts.map +0 -1
- package/dist/domain/value-objects/WorkspacePath.js +0 -128
- package/dist/domain/value-objects/WorkspacePath.js.map +0 -1
- package/dist/index.d.ts +0 -25
- package/dist/index.d.ts.map +0 -1
- package/dist/infrastructure/cache/Cache.d.ts +0 -161
- package/dist/infrastructure/cache/Cache.d.ts.map +0 -1
- package/dist/infrastructure/cache/Cache.js +0 -398
- package/dist/infrastructure/cache/Cache.js.map +0 -1
- package/dist/infrastructure/cache/index.d.ts +0 -6
- package/dist/infrastructure/cache/index.d.ts.map +0 -1
- package/dist/infrastructure/cache/index.js +0 -6
- package/dist/infrastructure/cache/index.js.map +0 -1
- package/dist/infrastructure/external-services/NpmRegistryService.d.ts +0 -145
- package/dist/infrastructure/external-services/NpmRegistryService.d.ts.map +0 -1
- package/dist/infrastructure/external-services/NpmRegistryService.js +0 -466
- package/dist/infrastructure/external-services/NpmRegistryService.js.map +0 -1
- package/dist/infrastructure/file-system/FileSystemService.d.ts +0 -120
- package/dist/infrastructure/file-system/FileSystemService.d.ts.map +0 -1
- package/dist/infrastructure/file-system/FileSystemService.js +0 -663
- package/dist/infrastructure/file-system/FileSystemService.js.map +0 -1
- package/dist/infrastructure/repositories/FileWorkspaceRepository.d.ts +0 -57
- package/dist/infrastructure/repositories/FileWorkspaceRepository.d.ts.map +0 -1
- package/dist/infrastructure/repositories/FileWorkspaceRepository.js +0 -179
- package/dist/infrastructure/repositories/FileWorkspaceRepository.js.map +0 -1
|
@@ -1,308 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Validation Utilities
|
|
3
|
-
*/
|
|
4
|
-
/**
|
|
5
|
-
* Create validation result
|
|
6
|
-
*/
|
|
7
|
-
export function createValidationResult(isValid = true, errors = [], warnings = []) {
|
|
8
|
-
return { isValid, errors, warnings };
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* Validate email address
|
|
12
|
-
*/
|
|
13
|
-
export function isValidEmail(email) {
|
|
14
|
-
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
15
|
-
return emailRegex.test(email);
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Validate URL
|
|
19
|
-
*/
|
|
20
|
-
export function isValidUrl(url) {
|
|
21
|
-
try {
|
|
22
|
-
new URL(url);
|
|
23
|
-
return true;
|
|
24
|
-
}
|
|
25
|
-
catch {
|
|
26
|
-
return false;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Validate semver version
|
|
31
|
-
*/
|
|
32
|
-
export function isValidSemver(version) {
|
|
33
|
-
const semverRegex = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/;
|
|
34
|
-
return semverRegex.test(version);
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Validate package name
|
|
38
|
-
*/
|
|
39
|
-
export function isValidPackageName(name) {
|
|
40
|
-
// NPM package name rules
|
|
41
|
-
const packageNameRegex = /^(?:@[a-z0-9-*~][a-z0-9-*._~]*\/)?[a-z0-9-~][a-z0-9-._~]*$/;
|
|
42
|
-
return packageNameRegex.test(name) && name.length <= 214;
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Validate file path
|
|
46
|
-
*/
|
|
47
|
-
export function isValidPath(path) {
|
|
48
|
-
// Basic path validation (no null bytes, etc.)
|
|
49
|
-
return !path.includes('\0') && path.length > 0 && path.length < 4096;
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* Validate JSON string
|
|
53
|
-
*/
|
|
54
|
-
export function isValidJson(jsonString) {
|
|
55
|
-
try {
|
|
56
|
-
JSON.parse(jsonString);
|
|
57
|
-
return true;
|
|
58
|
-
}
|
|
59
|
-
catch {
|
|
60
|
-
return false;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* Validate YAML string
|
|
65
|
-
*/
|
|
66
|
-
export function isValidYaml(yamlString) {
|
|
67
|
-
try {
|
|
68
|
-
// Simple YAML validation - check for basic structure
|
|
69
|
-
const lines = yamlString.split('\n');
|
|
70
|
-
// let indentLevel = 0; // Reserved for future use
|
|
71
|
-
for (const line of lines) {
|
|
72
|
-
const trimmed = line.trim();
|
|
73
|
-
if (trimmed === '' || trimmed.startsWith('#')) {
|
|
74
|
-
continue; // Skip empty lines and comments
|
|
75
|
-
}
|
|
76
|
-
const currentIndent = line.length - line.trimStart().length;
|
|
77
|
-
if (currentIndent % 2 !== 0) {
|
|
78
|
-
return false; // YAML uses 2-space indentation
|
|
79
|
-
}
|
|
80
|
-
if (trimmed.includes(':') && !trimmed.startsWith('-')) {
|
|
81
|
-
// Key-value pair
|
|
82
|
-
const [key] = trimmed.split(':');
|
|
83
|
-
if (key?.trim() === '') {
|
|
84
|
-
return false;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
return true;
|
|
89
|
-
}
|
|
90
|
-
catch {
|
|
91
|
-
return false;
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
/**
|
|
95
|
-
* Validate glob pattern
|
|
96
|
-
*/
|
|
97
|
-
export function isValidGlob(pattern) {
|
|
98
|
-
try {
|
|
99
|
-
// Basic glob pattern validation
|
|
100
|
-
if (pattern.includes('**/**/**')) {
|
|
101
|
-
return false; // Too many recursive wildcards
|
|
102
|
-
}
|
|
103
|
-
if (pattern.includes('//')) {
|
|
104
|
-
return false; // Double slashes
|
|
105
|
-
}
|
|
106
|
-
// Check for balanced brackets
|
|
107
|
-
let bracketDepth = 0;
|
|
108
|
-
let braceDepth = 0;
|
|
109
|
-
for (const char of pattern) {
|
|
110
|
-
if (char === '[')
|
|
111
|
-
bracketDepth++;
|
|
112
|
-
else if (char === ']')
|
|
113
|
-
bracketDepth--;
|
|
114
|
-
else if (char === '{')
|
|
115
|
-
braceDepth++;
|
|
116
|
-
else if (char === '}')
|
|
117
|
-
braceDepth--;
|
|
118
|
-
if (bracketDepth < 0 || braceDepth < 0) {
|
|
119
|
-
return false;
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
return bracketDepth === 0 && braceDepth === 0;
|
|
123
|
-
}
|
|
124
|
-
catch {
|
|
125
|
-
return false;
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
/**
|
|
129
|
-
* Validate port number
|
|
130
|
-
*/
|
|
131
|
-
export function isValidPort(port) {
|
|
132
|
-
const portNum = typeof port === 'string' ? parseInt(port, 10) : port;
|
|
133
|
-
return !isNaN(portNum) && portNum >= 1 && portNum <= 65535;
|
|
134
|
-
}
|
|
135
|
-
/**
|
|
136
|
-
* Validate timeout value
|
|
137
|
-
*/
|
|
138
|
-
export function isValidTimeout(timeout) {
|
|
139
|
-
return timeout > 0 && timeout <= 300000; // Max 5 minutes
|
|
140
|
-
}
|
|
141
|
-
/**
|
|
142
|
-
* Validate log level
|
|
143
|
-
*/
|
|
144
|
-
export function isValidLogLevel(level) {
|
|
145
|
-
return ['error', 'warn', 'info', 'debug'].includes(level.toLowerCase());
|
|
146
|
-
}
|
|
147
|
-
/**
|
|
148
|
-
* Validate update target
|
|
149
|
-
*/
|
|
150
|
-
export function isValidUpdateTarget(target) {
|
|
151
|
-
return ['latest', 'greatest', 'minor', 'patch', 'newest'].includes(target.toLowerCase());
|
|
152
|
-
}
|
|
153
|
-
/**
|
|
154
|
-
* Validate output format
|
|
155
|
-
*/
|
|
156
|
-
export function isValidOutputFormat(format) {
|
|
157
|
-
return ['table', 'json', 'yaml', 'minimal'].includes(format.toLowerCase());
|
|
158
|
-
}
|
|
159
|
-
/**
|
|
160
|
-
* Validate CLI command options
|
|
161
|
-
*/
|
|
162
|
-
export function validateCliOptions(options) {
|
|
163
|
-
const errors = [];
|
|
164
|
-
const warnings = [];
|
|
165
|
-
// Validate workspace path
|
|
166
|
-
if (options.workspace && !isValidPath(options.workspace)) {
|
|
167
|
-
errors.push('Invalid workspace path');
|
|
168
|
-
}
|
|
169
|
-
// Validate registry URL
|
|
170
|
-
if (options.registry && !isValidUrl(options.registry)) {
|
|
171
|
-
errors.push('Invalid registry URL');
|
|
172
|
-
}
|
|
173
|
-
// Validate timeout
|
|
174
|
-
if (options.timeout !== undefined && !isValidTimeout(options.timeout)) {
|
|
175
|
-
errors.push('Invalid timeout value (must be between 1 and 300000ms)');
|
|
176
|
-
}
|
|
177
|
-
// Validate target
|
|
178
|
-
if (options.target && !isValidUpdateTarget(options.target)) {
|
|
179
|
-
errors.push('Invalid update target (must be: latest, greatest, minor, patch, newest)');
|
|
180
|
-
}
|
|
181
|
-
// Validate format
|
|
182
|
-
if (options.format && !isValidOutputFormat(options.format)) {
|
|
183
|
-
errors.push('Invalid output format (must be: table, json, yaml, minimal)');
|
|
184
|
-
}
|
|
185
|
-
// Validate include patterns
|
|
186
|
-
if (options.include && Array.isArray(options.include)) {
|
|
187
|
-
for (const pattern of options.include) {
|
|
188
|
-
if (typeof pattern === 'string' && !isValidGlob(pattern)) {
|
|
189
|
-
warnings.push(`Invalid include pattern: ${pattern}`);
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
// Validate exclude patterns
|
|
194
|
-
if (options.exclude && Array.isArray(options.exclude)) {
|
|
195
|
-
for (const pattern of options.exclude) {
|
|
196
|
-
if (typeof pattern === 'string' && !isValidGlob(pattern)) {
|
|
197
|
-
warnings.push(`Invalid exclude pattern: ${pattern}`);
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
// Validate catalog name
|
|
202
|
-
if (options.catalog && typeof options.catalog === 'string') {
|
|
203
|
-
if (options.catalog.trim() === '') {
|
|
204
|
-
errors.push('Catalog name cannot be empty');
|
|
205
|
-
}
|
|
206
|
-
if (options.catalog.includes('/') || options.catalog.includes('\\')) {
|
|
207
|
-
errors.push('Catalog name cannot contain path separators');
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
return createValidationResult(errors.length === 0, errors, warnings);
|
|
211
|
-
}
|
|
212
|
-
/**
|
|
213
|
-
* Validate configuration object
|
|
214
|
-
*/
|
|
215
|
-
export function validateConfig(config) {
|
|
216
|
-
const errors = [];
|
|
217
|
-
const warnings = [];
|
|
218
|
-
// Validate registry settings
|
|
219
|
-
if (config.registry) {
|
|
220
|
-
if (config.registry.url && !isValidUrl(config.registry.url)) {
|
|
221
|
-
errors.push('Invalid registry URL in configuration');
|
|
222
|
-
}
|
|
223
|
-
if (config.registry.timeout && !isValidTimeout(config.registry.timeout)) {
|
|
224
|
-
errors.push('Invalid registry timeout in configuration');
|
|
225
|
-
}
|
|
226
|
-
if (config.registry.retries && (config.registry.retries < 0 || config.registry.retries > 10)) {
|
|
227
|
-
warnings.push('Registry retries should be between 0 and 10');
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
// Validate update settings
|
|
231
|
-
if (config.update) {
|
|
232
|
-
if (config.update.target && !isValidUpdateTarget(config.update.target)) {
|
|
233
|
-
errors.push('Invalid update target in configuration');
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
// Validate output settings
|
|
237
|
-
if (config.output) {
|
|
238
|
-
if (config.output.format && !isValidOutputFormat(config.output.format)) {
|
|
239
|
-
errors.push('Invalid output format in configuration');
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
// Validate logging settings
|
|
243
|
-
if (config.logging) {
|
|
244
|
-
if (config.logging.level && !isValidLogLevel(config.logging.level)) {
|
|
245
|
-
errors.push('Invalid log level in configuration');
|
|
246
|
-
}
|
|
247
|
-
if (config.logging.file && !isValidPath(config.logging.file)) {
|
|
248
|
-
errors.push('Invalid log file path in configuration');
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
return createValidationResult(errors.length === 0, errors, warnings);
|
|
252
|
-
}
|
|
253
|
-
/**
|
|
254
|
-
* Sanitize string input
|
|
255
|
-
*/
|
|
256
|
-
export function sanitizeString(input, options = {}) {
|
|
257
|
-
let result = input;
|
|
258
|
-
// Strip HTML tags if requested with comprehensive multi-pass sanitization
|
|
259
|
-
if (options.stripHtml) {
|
|
260
|
-
let previousLength;
|
|
261
|
-
// Multi-pass sanitization to handle nested and complex patterns
|
|
262
|
-
do {
|
|
263
|
-
previousLength = result.length;
|
|
264
|
-
// Remove HTML tags, including malformed ones
|
|
265
|
-
result = result.replace(/<[^>]*>?/g, '');
|
|
266
|
-
// Remove HTML entities
|
|
267
|
-
result = result.replace(/&[a-zA-Z0-9#]+;/g, '');
|
|
268
|
-
// Remove any remaining < or > characters that might be part of incomplete tags
|
|
269
|
-
result = result.replace(/[<>]/g, '');
|
|
270
|
-
// Remove potentially dangerous protocol schemes
|
|
271
|
-
result = result.replace(/javascript:/gi, '');
|
|
272
|
-
result = result.replace(/data:/gi, '');
|
|
273
|
-
result = result.replace(/vbscript:/gi, '');
|
|
274
|
-
result = result.replace(/file:/gi, '');
|
|
275
|
-
result = result.replace(/ftp:/gi, '');
|
|
276
|
-
// Remove event handlers
|
|
277
|
-
result = result.replace(/on\w+\s*=/gi, '');
|
|
278
|
-
// Remove script-related content
|
|
279
|
-
result = result.replace(/script[\s\S]*?\/script/gi, '');
|
|
280
|
-
result = result.replace(/style[\s\S]*?\/style/gi, '');
|
|
281
|
-
// Remove control characters and non-printable characters
|
|
282
|
-
// eslint-disable-next-line no-control-regex
|
|
283
|
-
result = result.replace(/[\x00-\x1F\x7F-\x9F]/g, '');
|
|
284
|
-
// Remove potentially dangerous CSS expressions
|
|
285
|
-
result = result.replace(/expression\s*\(/gi, '');
|
|
286
|
-
result = result.replace(/url\s*\(/gi, '');
|
|
287
|
-
} while (result.length !== previousLength && result.length > 0);
|
|
288
|
-
}
|
|
289
|
-
// Filter allowed characters
|
|
290
|
-
if (options.allowedChars) {
|
|
291
|
-
result = result.replace(new RegExp(`[^${options.allowedChars.source}]`, 'g'), '');
|
|
292
|
-
}
|
|
293
|
-
// Truncate to max length
|
|
294
|
-
if (options.maxLength && result.length > options.maxLength) {
|
|
295
|
-
result = result.substring(0, options.maxLength);
|
|
296
|
-
}
|
|
297
|
-
return result.trim();
|
|
298
|
-
}
|
|
299
|
-
/**
|
|
300
|
-
* Validate and sanitize package name
|
|
301
|
-
*/
|
|
302
|
-
export function sanitizePackageName(name) {
|
|
303
|
-
return sanitizeString(name, {
|
|
304
|
-
maxLength: 214,
|
|
305
|
-
allowedChars: /[a-z0-9@/._~*-]/,
|
|
306
|
-
}).toLowerCase();
|
|
307
|
-
}
|
|
308
|
-
//# sourceMappingURL=validation.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"validation.js","sourceRoot":"","sources":["../../../src/common/utils/validation.ts"],"names":[],"mappings":"AAAA;;GAEG;AAWH;;GAEG;AACH,MAAM,UAAU,sBAAsB,CACpC,UAAmB,IAAI,EACvB,SAAmB,EAAE,EACrB,WAAqB,EAAE;IAEvB,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC;AACvC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,YAAY,CAAC,KAAa;IACxC,MAAM,UAAU,GAAG,4BAA4B,CAAC;IAChD,OAAO,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAChC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,UAAU,CAAC,GAAW;IACpC,IAAI,CAAC;QACH,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;QACb,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,aAAa,CAAC,OAAe;IAC3C,MAAM,WAAW,GACf,qLAAqL,CAAC;IACxL,OA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
|
|
|
1
|
-
/**
|
|
2
|
-
* Catalog Entity
|
|
3
|
-
*
|
|
4
|
-
* Represents a pnpm catalog that manages dependency versions centrally.
|
|
5
|
-
* A catalog contains a collection of dependencies with their version ranges.
|
|
6
|
-
*/
|
|
7
|
-
import { VersionRange } from '../value-objects/Version.js';
|
|
8
|
-
export type CatalogId = string;
|
|
9
|
-
export type PackageName = string;
|
|
10
|
-
export type CatalogName = string;
|
|
11
|
-
export declare class Catalog {
|
|
12
|
-
private readonly id;
|
|
13
|
-
private readonly name;
|
|
14
|
-
private readonly dependencies;
|
|
15
|
-
private readonly mode;
|
|
16
|
-
private constructor();
|
|
17
|
-
/**
|
|
18
|
-
* Create a new Catalog
|
|
19
|
-
*/
|
|
20
|
-
static create(id: CatalogId, name: CatalogName, dependencies?: Record<string, string>, mode?: CatalogMode): Catalog;
|
|
21
|
-
/**
|
|
22
|
-
* Get catalog identifier
|
|
23
|
-
*/
|
|
24
|
-
getId(): CatalogId;
|
|
25
|
-
/**
|
|
26
|
-
* Get catalog name
|
|
27
|
-
*/
|
|
28
|
-
getName(): CatalogName;
|
|
29
|
-
/**
|
|
30
|
-
* Get catalog mode
|
|
31
|
-
*/
|
|
32
|
-
getMode(): CatalogMode;
|
|
33
|
-
/**
|
|
34
|
-
* Get all dependencies in this catalog
|
|
35
|
-
*/
|
|
36
|
-
getDependencies(): ReadonlyMap<PackageName, VersionRange>;
|
|
37
|
-
/**
|
|
38
|
-
* Get all package names in this catalog
|
|
39
|
-
*/
|
|
40
|
-
getPackageNames(): PackageName[];
|
|
41
|
-
/**
|
|
42
|
-
* Check if catalog contains a specific package
|
|
43
|
-
*/
|
|
44
|
-
hasDependency(packageName: PackageName): boolean;
|
|
45
|
-
/**
|
|
46
|
-
* Get version range for a specific package
|
|
47
|
-
*/
|
|
48
|
-
getDependencyVersion(packageName: PackageName): VersionRange | null;
|
|
49
|
-
/**
|
|
50
|
-
* Add or update a dependency
|
|
51
|
-
*/
|
|
52
|
-
updateDependencyVersion(packageName: PackageName, versionRange: string): void;
|
|
53
|
-
/**
|
|
54
|
-
* Remove a dependency from the catalog
|
|
55
|
-
*/
|
|
56
|
-
removeDependency(packageName: PackageName): boolean;
|
|
57
|
-
/**
|
|
58
|
-
* Check version compatibility for a package
|
|
59
|
-
*/
|
|
60
|
-
checkVersionCompatibility(packageName: PackageName, requestedVersion: string): boolean;
|
|
61
|
-
/**
|
|
62
|
-
* Get packages that would be affected by changing a dependency version
|
|
63
|
-
*/
|
|
64
|
-
getAffectedPackagesByDependencyChange(packageName: PackageName, newVersionRange: string): PackageName[];
|
|
65
|
-
/**
|
|
66
|
-
* Validate catalog integrity
|
|
67
|
-
*/
|
|
68
|
-
validate(): CatalogValidationResult;
|
|
69
|
-
/**
|
|
70
|
-
* Convert catalog to plain object for serialization
|
|
71
|
-
*/
|
|
72
|
-
toPlainObject(): CatalogData;
|
|
73
|
-
/**
|
|
74
|
-
* Create catalog from plain object
|
|
75
|
-
*/
|
|
76
|
-
static fromPlainObject(data: CatalogData): Catalog;
|
|
77
|
-
/**
|
|
78
|
-
* Check if a package name is valid
|
|
79
|
-
*/
|
|
80
|
-
private isValidPackageName;
|
|
81
|
-
/**
|
|
82
|
-
* Check equality with another catalog
|
|
83
|
-
*/
|
|
84
|
-
equals(other: Catalog): boolean;
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* Catalog Mode Enum
|
|
88
|
-
*/
|
|
89
|
-
export declare enum CatalogMode {
|
|
90
|
-
MANUAL = "manual",
|
|
91
|
-
STRICT = "strict",
|
|
92
|
-
PREFER = "prefer"
|
|
93
|
-
}
|
|
94
|
-
/**
|
|
95
|
-
* Catalog Data Interface for serialization
|
|
96
|
-
*/
|
|
97
|
-
export interface CatalogData {
|
|
98
|
-
id: CatalogId;
|
|
99
|
-
name: CatalogName;
|
|
100
|
-
dependencies: Record<string, string>;
|
|
101
|
-
mode: CatalogMode;
|
|
102
|
-
}
|
|
103
|
-
/**
|
|
104
|
-
* Catalog Validation Result
|
|
105
|
-
*/
|
|
106
|
-
export declare class CatalogValidationResult {
|
|
107
|
-
private readonly isValid;
|
|
108
|
-
private readonly errors;
|
|
109
|
-
private readonly warnings;
|
|
110
|
-
constructor(isValid: boolean, errors: string[], warnings: string[]);
|
|
111
|
-
getIsValid(): boolean;
|
|
112
|
-
getErrors(): string[];
|
|
113
|
-
getWarnings(): string[];
|
|
114
|
-
hasErrors(): boolean;
|
|
115
|
-
hasWarnings(): boolean;
|
|
116
|
-
}
|
|
117
|
-
//# sourceMappingURL=Catalog.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Catalog.d.ts","sourceRoot":"","sources":["../../../src/domain/entities/Catalog.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAE3D,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC;AAC/B,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC;AACjC,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC;AAEjC,qBAAa,OAAO;IAClB,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAY;IAC/B,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAc;IACnC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAiC;IAC9D,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAc;IAEnC,OAAO;IAYP;;OAEG;WACW,MAAM,CAClB,EAAE,EAAE,SAAS,EACb,IAAI,EAAE,WAAW,EACjB,YAAY,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAM,EACzC,IAAI,GAAE,WAAgC,GACrC,OAAO;IAgBV;;OAEG;IACI,KAAK,IAAI,SAAS;IAIzB;;OAEG;IACI,OAAO,IAAI,WAAW;IAI7B;;OAEG;IACI,OAAO,IAAI,WAAW;IAI7B;;OAEG;IACI,eAAe,IAAI,WAAW,CAAC,WAAW,EAAE,YAAY,CAAC;IAIhE;;OAEG;IACI,eAAe,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AAQ,EAAE,MAAM,EAAE;IAG9B,UAAU,IAAI,OAAO;IAIrB,SAAS,IAAI,MAAM,EAAE;IAIrB,WAAW,IAAI,MAAM,EAAE;IAIvB,SAAS,IAAI,OAAO;IAIpB,WAAW,IAAI,OAAO;CAG9B"}
|
|
@@ -1,240 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Catalog Entity
|
|
3
|
-
*
|
|
4
|
-
* Represents a pnpm catalog that manages dependency versions centrally.
|
|
5
|
-
* A catalog contains a collection of dependencies with their version ranges.
|
|
6
|
-
*/
|
|
7
|
-
import { VersionRange } from '../value-objects/Version.js';
|
|
8
|
-
export class Catalog {
|
|
9
|
-
id;
|
|
10
|
-
name;
|
|
11
|
-
dependencies;
|
|
12
|
-
mode;
|
|
13
|
-
constructor(id, name, dependencies, mode = CatalogMode.MANUAL) {
|
|
14
|
-
this.id = id;
|
|
15
|
-
this.name = name;
|
|
16
|
-
this.dependencies = new Map(dependencies);
|
|
17
|
-
this.mode = mode;
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Create a new Catalog
|
|
21
|
-
*/
|
|
22
|
-
static create(id, name, dependencies = {}, mode = CatalogMode.MANUAL) {
|
|
23
|
-
const dependencyMap = new Map();
|
|
24
|
-
for (const [packageName, versionRange] of Object.entries(dependencies)) {
|
|
25
|
-
try {
|
|
26
|
-
dependencyMap.set(packageName, VersionRange.fromString(versionRange));
|
|
27
|
-
}
|
|
28
|
-
catch (error) {
|
|
29
|
-
throw new Error(`Invalid version range for package "${packageName}" in catalog "${name}": ${versionRange}`);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
return new Catalog(id, name, dependencyMap, mode);
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Get catalog identifier
|
|
36
|
-
*/
|
|
37
|
-
getId() {
|
|
38
|
-
return this.id;
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Get catalog name
|
|
42
|
-
*/
|
|
43
|
-
getName() {
|
|
44
|
-
return this.name;
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Get catalog mode
|
|
48
|
-
*/
|
|
49
|
-
getMode() {
|
|
50
|
-
return this.mode;
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* Get all dependencies in this catalog
|
|
54
|
-
*/
|
|
55
|
-
getDependencies() {
|
|
56
|
-
return this.dependencies;
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* Get all package names in this catalog
|
|
60
|
-
*/
|
|
61
|
-
getPackageNames() {
|
|
62
|
-
return Array.from(this.dependencies.keys());
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* Check if catalog contains a specific package
|
|
66
|
-
*/
|
|
67
|
-
hasDependency(packageName) {
|
|
68
|
-
return this.dependencies.has(packageName);
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Get version range for a specific package
|
|
72
|
-
*/
|
|
73
|
-
getDependencyVersion(packageName) {
|
|
74
|
-
return this.dependencies.get(packageName) || null;
|
|
75
|
-
}
|
|
76
|
-
/**
|
|
77
|
-
* Add or update a dependency
|
|
78
|
-
*/
|
|
79
|
-
updateDependencyVersion(packageName, versionRange) {
|
|
80
|
-
try {
|
|
81
|
-
const parsedRange = VersionRange.fromString(versionRange);
|
|
82
|
-
this.dependencies.set(packageName, parsedRange);
|
|
83
|
-
}
|
|
84
|
-
catch (error) {
|
|
85
|
-
throw new Error(`Invalid version range for package "${packageName}": ${versionRange}`);
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* Remove a dependency from the catalog
|
|
90
|
-
*/
|
|
91
|
-
removeDependency(packageName) {
|
|
92
|
-
return this.dependencies.delete(packageName);
|
|
93
|
-
}
|
|
94
|
-
/**
|
|
95
|
-
* Check version compatibility for a package
|
|
96
|
-
*/
|
|
97
|
-
checkVersionCompatibility(packageName, requestedVersion) {
|
|
98
|
-
const catalogVersion = this.dependencies.get(packageName);
|
|
99
|
-
if (!catalogVersion) {
|
|
100
|
-
return false;
|
|
101
|
-
}
|
|
102
|
-
try {
|
|
103
|
-
const requestedRange = VersionRange.fromString(requestedVersion);
|
|
104
|
-
return catalogVersion.isCompatibleWith(requestedRange);
|
|
105
|
-
}
|
|
106
|
-
catch {
|
|
107
|
-
return false;
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
/**
|
|
111
|
-
* Get packages that would be affected by changing a dependency version
|
|
112
|
-
*/
|
|
113
|
-
getAffectedPackagesByDependencyChange(packageName, newVersionRange) {
|
|
114
|
-
if (!this.hasDependency(packageName)) {
|
|
115
|
-
return [];
|
|
116
|
-
}
|
|
117
|
-
try {
|
|
118
|
-
const newRange = VersionRange.fromString(newVersionRange);
|
|
119
|
-
const currentRange = this.dependencies.get(packageName);
|
|
120
|
-
// If the ranges are compatible, no packages are affected
|
|
121
|
-
if (currentRange.isCompatibleWith(newRange)) {
|
|
122
|
-
return [];
|
|
123
|
-
}
|
|
124
|
-
// Return all packages that use this catalog (this would typically be resolved
|
|
125
|
-
// at the aggregate level with workspace information)
|
|
126
|
-
return [packageName];
|
|
127
|
-
}
|
|
128
|
-
catch {
|
|
129
|
-
return [packageName];
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
/**
|
|
133
|
-
* Validate catalog integrity
|
|
134
|
-
*/
|
|
135
|
-
validate() {
|
|
136
|
-
const errors = [];
|
|
137
|
-
const warnings = [];
|
|
138
|
-
// Check for empty catalog
|
|
139
|
-
if (this.dependencies.size === 0) {
|
|
140
|
-
warnings.push(`Catalog "${this.name}" is empty`);
|
|
141
|
-
}
|
|
142
|
-
// Validate each dependency
|
|
143
|
-
for (const [packageName, versionRange] of this.dependencies) {
|
|
144
|
-
// Check package name format
|
|
145
|
-
if (!this.isValidPackageName(packageName)) {
|
|
146
|
-
errors.push(`Invalid package name: "${packageName}"`);
|
|
147
|
-
}
|
|
148
|
-
// Check for common issues
|
|
149
|
-
if (versionRange.toString().includes('*')) {
|
|
150
|
-
warnings.push(`Package "${packageName}" uses wildcard version which may be unstable`);
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
return new CatalogValidationResult(errors.length === 0, errors, warnings);
|
|
154
|
-
}
|
|
155
|
-
/**
|
|
156
|
-
* Convert catalog to plain object for serialization
|
|
157
|
-
*/
|
|
158
|
-
toPlainObject() {
|
|
159
|
-
const dependencies = {};
|
|
160
|
-
for (const [packageName, versionRange] of this.dependencies) {
|
|
161
|
-
dependencies[packageName] = versionRange.toString();
|
|
162
|
-
}
|
|
163
|
-
return {
|
|
164
|
-
id: this.id,
|
|
165
|
-
name: this.name,
|
|
166
|
-
dependencies,
|
|
167
|
-
mode: this.mode,
|
|
168
|
-
};
|
|
169
|
-
}
|
|
170
|
-
/**
|
|
171
|
-
* Create catalog from plain object
|
|
172
|
-
*/
|
|
173
|
-
static fromPlainObject(data) {
|
|
174
|
-
return Catalog.create(data.id, data.name, data.dependencies, data.mode);
|
|
175
|
-
}
|
|
176
|
-
/**
|
|
177
|
-
* Check if a package name is valid
|
|
178
|
-
*/
|
|
179
|
-
isValidPackageName(packageName) {
|
|
180
|
-
// Basic npm package name validation
|
|
181
|
-
const validPackageNameRegex = /^(@[a-z0-9-*~][a-z0-9-*._~]*\/)?[a-z0-9-~][a-z0-9-._~]*$/;
|
|
182
|
-
return validPackageNameRegex.test(packageName);
|
|
183
|
-
}
|
|
184
|
-
/**
|
|
185
|
-
* Check equality with another catalog
|
|
186
|
-
*/
|
|
187
|
-
equals(other) {
|
|
188
|
-
if (this.id !== other.id || this.name !== other.name || this.mode !== other.mode) {
|
|
189
|
-
return false;
|
|
190
|
-
}
|
|
191
|
-
if (this.dependencies.size !== other.dependencies.size) {
|
|
192
|
-
return false;
|
|
193
|
-
}
|
|
194
|
-
for (const [packageName, versionRange] of this.dependencies) {
|
|
195
|
-
const otherRange = other.dependencies.get(packageName);
|
|
196
|
-
if (!otherRange || !versionRange.equals(otherRange)) {
|
|
197
|
-
return false;
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
return true;
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
/**
|
|
204
|
-
* Catalog Mode Enum
|
|
205
|
-
*/
|
|
206
|
-
export var CatalogMode;
|
|
207
|
-
(function (CatalogMode) {
|
|
208
|
-
CatalogMode["MANUAL"] = "manual";
|
|
209
|
-
CatalogMode["STRICT"] = "strict";
|
|
210
|
-
CatalogMode["PREFER"] = "prefer";
|
|
211
|
-
})(CatalogMode || (CatalogMode = {}));
|
|
212
|
-
/**
|
|
213
|
-
* Catalog Validation Result
|
|
214
|
-
*/
|
|
215
|
-
export class CatalogValidationResult {
|
|
216
|
-
isValid;
|
|
217
|
-
errors;
|
|
218
|
-
warnings;
|
|
219
|
-
constructor(isValid, errors, warnings) {
|
|
220
|
-
this.isValid = isValid;
|
|
221
|
-
this.errors = errors;
|
|
222
|
-
this.warnings = warnings;
|
|
223
|
-
}
|
|
224
|
-
getIsValid() {
|
|
225
|
-
return this.isValid;
|
|
226
|
-
}
|
|
227
|
-
getErrors() {
|
|
228
|
-
return [...this.errors];
|
|
229
|
-
}
|
|
230
|
-
getWarnings() {
|
|
231
|
-
return [...this.warnings];
|
|
232
|
-
}
|
|
233
|
-
hasErrors() {
|
|
234
|
-
return this.errors.length > 0;
|
|
235
|
-
}
|
|
236
|
-
hasWarnings() {
|
|
237
|
-
return this.warnings.length > 0;
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
//# sourceMappingURL=Catalog.js.map
|