pnpm-catalog-updates 0.5.7 → 0.6.6
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/README.md +70 -634
- package/bin/pcu.js +1 -1
- package/dist/index.js +9559 -32
- package/dist/index.js.map +1 -1
- package/package.json +59 -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 -587
- package/README.zh-CN.md +0 -634
- 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 -839
- 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 -153
- package/dist/infrastructure/external-services/NpmRegistryService.d.ts.map +0 -1
- package/dist/infrastructure/external-services/NpmRegistryService.js +0 -511
- 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
- package/dist/infrastructure/utils/NpmrcParser.d.ts +0 -40
- package/dist/infrastructure/utils/NpmrcParser.d.ts.map +0 -1
- package/dist/infrastructure/utils/NpmrcParser.js +0 -157
- package/dist/infrastructure/utils/NpmrcParser.js.map +0 -1
|
@@ -0,0 +1,517 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Interactive Prompts
|
|
3
|
+
*
|
|
4
|
+
* Provides smart prompts and auto-completion for CLI commands
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import chalk from 'chalk';
|
|
8
|
+
import inquirer from 'inquirer';
|
|
9
|
+
import { FileSystemService } from '@pcu/core';
|
|
10
|
+
import { StyledText } from '../themes/colorTheme.js';
|
|
11
|
+
|
|
12
|
+
export interface AutoCompleteOption {
|
|
13
|
+
name: string;
|
|
14
|
+
value: string;
|
|
15
|
+
description?: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export class InteractivePrompts {
|
|
19
|
+
private fsService: FileSystemService;
|
|
20
|
+
|
|
21
|
+
constructor() {
|
|
22
|
+
this.fsService = new FileSystemService();
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Interactive package selection with search
|
|
27
|
+
*/
|
|
28
|
+
async selectPackages(
|
|
29
|
+
packages: Array<{ name: string; current: string; latest: string; type: string }>
|
|
30
|
+
): Promise<string[]> {
|
|
31
|
+
if (packages.length === 0) {
|
|
32
|
+
return [];
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const choices = packages.map((pkg) => ({
|
|
36
|
+
name: this.formatPackageChoice(pkg),
|
|
37
|
+
value: pkg.name,
|
|
38
|
+
checked: false,
|
|
39
|
+
}));
|
|
40
|
+
|
|
41
|
+
const answers = await inquirer.prompt({
|
|
42
|
+
type: 'checkbox',
|
|
43
|
+
name: 'selectedPackages',
|
|
44
|
+
message: StyledText.iconPackage('Select packages to update:'),
|
|
45
|
+
choices,
|
|
46
|
+
pageSize: 15,
|
|
47
|
+
validate: (input: unknown) => {
|
|
48
|
+
const selected = input as string[];
|
|
49
|
+
return selected.length > 0 || 'Please select at least one package';
|
|
50
|
+
},
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
return answers.selectedPackages;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Interactive catalog selection
|
|
58
|
+
*/
|
|
59
|
+
async selectCatalog(catalogs: string[]): Promise<string | null> {
|
|
60
|
+
if (catalogs.length === 0) {
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (catalogs.length === 1) {
|
|
65
|
+
return catalogs[0] ?? null;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const choices = [
|
|
69
|
+
{ name: 'All catalogs', value: 'all' },
|
|
70
|
+
...catalogs.map((name) => ({ name, value: name })),
|
|
71
|
+
];
|
|
72
|
+
|
|
73
|
+
const answers = await inquirer.prompt([
|
|
74
|
+
{
|
|
75
|
+
type: 'list',
|
|
76
|
+
name: 'catalog',
|
|
77
|
+
message: StyledText.iconCatalog('Select catalog to update:'),
|
|
78
|
+
choices,
|
|
79
|
+
pageSize: 10,
|
|
80
|
+
},
|
|
81
|
+
]);
|
|
82
|
+
|
|
83
|
+
return answers.catalog === 'all' ? null : answers.catalog;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Update strategy selection
|
|
88
|
+
*/
|
|
89
|
+
async selectUpdateStrategy(): Promise<string> {
|
|
90
|
+
const strategies = [
|
|
91
|
+
{ name: 'Latest (recommended)', value: 'latest' },
|
|
92
|
+
{ name: 'Greatest (highest version)', value: 'greatest' },
|
|
93
|
+
{ name: 'Minor (non-breaking)', value: 'minor' },
|
|
94
|
+
{ name: 'Patch (bug fixes only)', value: 'patch' },
|
|
95
|
+
{ name: 'Newest (latest release)', value: 'newest' },
|
|
96
|
+
];
|
|
97
|
+
|
|
98
|
+
const answers = await inquirer.prompt([
|
|
99
|
+
{
|
|
100
|
+
type: 'list',
|
|
101
|
+
name: 'strategy',
|
|
102
|
+
message: StyledText.iconUpdate('Select update strategy:'),
|
|
103
|
+
choices: strategies,
|
|
104
|
+
},
|
|
105
|
+
]);
|
|
106
|
+
|
|
107
|
+
return answers.strategy;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Confirm dangerous operations
|
|
112
|
+
*/
|
|
113
|
+
async confirmDangerousOperation(operation: string, details?: string): Promise<boolean> {
|
|
114
|
+
console.log('');
|
|
115
|
+
if (details) {
|
|
116
|
+
console.log(chalk.yellow('⚠️ Warning:'), details);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
const answers = await inquirer.prompt([
|
|
120
|
+
{
|
|
121
|
+
type: 'confirm',
|
|
122
|
+
name: 'confirmed',
|
|
123
|
+
message: StyledText.warning(`Are you sure you want to ${operation}?`),
|
|
124
|
+
default: false,
|
|
125
|
+
},
|
|
126
|
+
]);
|
|
127
|
+
|
|
128
|
+
return answers.confirmed;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Auto-complete for package names (using list as fallback)
|
|
133
|
+
*/
|
|
134
|
+
async autoCompletePackage(
|
|
135
|
+
packages: string[],
|
|
136
|
+
message: string = 'Select package:'
|
|
137
|
+
): Promise<string> {
|
|
138
|
+
const answers = await inquirer.prompt([
|
|
139
|
+
{
|
|
140
|
+
type: 'list',
|
|
141
|
+
name: 'package',
|
|
142
|
+
message,
|
|
143
|
+
choices: packages.map((pkg) => ({ name: pkg, value: pkg })),
|
|
144
|
+
pageSize: 10,
|
|
145
|
+
},
|
|
146
|
+
]);
|
|
147
|
+
|
|
148
|
+
return answers.package;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Workspace path selection with auto-complete
|
|
153
|
+
*/
|
|
154
|
+
async selectWorkspacePath(): Promise<string> {
|
|
155
|
+
const currentDir = process.cwd();
|
|
156
|
+
const choices = [
|
|
157
|
+
{ name: `Current directory (${currentDir})`, value: currentDir },
|
|
158
|
+
{ name: 'Browse for directory...', value: 'browse' },
|
|
159
|
+
];
|
|
160
|
+
|
|
161
|
+
const answers = await inquirer.prompt([
|
|
162
|
+
{
|
|
163
|
+
type: 'list',
|
|
164
|
+
name: 'path',
|
|
165
|
+
message: StyledText.icon('📁', 'Select workspace directory:'),
|
|
166
|
+
choices,
|
|
167
|
+
},
|
|
168
|
+
]);
|
|
169
|
+
|
|
170
|
+
if (answers.path === 'browse') {
|
|
171
|
+
return this.browseDirectory();
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
return answers.path;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Browse directory structure
|
|
179
|
+
*/
|
|
180
|
+
private async browseDirectory(currentPath = process.cwd()): Promise<string> {
|
|
181
|
+
const directoryNames = await this.fsService.listDirectories(currentPath);
|
|
182
|
+
const choices = [
|
|
183
|
+
{ name: '.. (parent directory)', value: '..' },
|
|
184
|
+
{ name: `. (current: ${currentPath})`, value: '.' },
|
|
185
|
+
...directoryNames.map((name: string) => ({
|
|
186
|
+
name: `📁 ${name}`,
|
|
187
|
+
value: `${currentPath}/${name}`,
|
|
188
|
+
})),
|
|
189
|
+
];
|
|
190
|
+
|
|
191
|
+
const answers = await inquirer.prompt([
|
|
192
|
+
{
|
|
193
|
+
type: 'list',
|
|
194
|
+
name: 'selected',
|
|
195
|
+
message: `Browse: ${currentPath}`,
|
|
196
|
+
choices,
|
|
197
|
+
pageSize: 15,
|
|
198
|
+
},
|
|
199
|
+
]);
|
|
200
|
+
|
|
201
|
+
if (answers.selected === '.') {
|
|
202
|
+
return currentPath;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
if (answers.selected === '..') {
|
|
206
|
+
const parent = currentPath.split('/').slice(0, -1).join('/') || '/';
|
|
207
|
+
return this.browseDirectory(parent);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
// Check if this directory contains a pnpm workspace
|
|
211
|
+
const workspaceFiles = ['pnpm-workspace.yaml', 'pnpm-workspace.yml'];
|
|
212
|
+
let hasWorkspace = false;
|
|
213
|
+
for (const file of workspaceFiles) {
|
|
214
|
+
if (await this.fsService.exists(`${answers.selected}/${file}`)) {
|
|
215
|
+
hasWorkspace = true;
|
|
216
|
+
break;
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
if (hasWorkspace) {
|
|
221
|
+
const confirm = await inquirer.prompt([
|
|
222
|
+
{
|
|
223
|
+
type: 'confirm',
|
|
224
|
+
name: 'useThis',
|
|
225
|
+
message: `Use ${answers.selected} as workspace?`,
|
|
226
|
+
default: true,
|
|
227
|
+
},
|
|
228
|
+
]);
|
|
229
|
+
|
|
230
|
+
if (confirm.useThis) {
|
|
231
|
+
return answers.selected;
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
return this.browseDirectory(answers.selected);
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* Multi-step configuration wizard
|
|
240
|
+
*/
|
|
241
|
+
async configurationWizard(): Promise<any> {
|
|
242
|
+
console.log(chalk.bold.blue('\n🧙♂️ Configuration Wizard\n'));
|
|
243
|
+
|
|
244
|
+
const themeAnswer = await inquirer.prompt({
|
|
245
|
+
type: 'list',
|
|
246
|
+
name: 'theme',
|
|
247
|
+
message: 'Select color theme:',
|
|
248
|
+
choices: [
|
|
249
|
+
{ name: 'Default - Balanced colors', value: 'default' },
|
|
250
|
+
{ name: 'Modern - Vibrant colors', value: 'modern' },
|
|
251
|
+
{ name: 'Minimal - Clean and simple', value: 'minimal' },
|
|
252
|
+
{ name: 'Neon - High contrast', value: 'neon' },
|
|
253
|
+
],
|
|
254
|
+
default: 'default',
|
|
255
|
+
});
|
|
256
|
+
|
|
257
|
+
const interactiveAnswer = await inquirer.prompt({
|
|
258
|
+
type: 'confirm',
|
|
259
|
+
name: 'interactive',
|
|
260
|
+
message: 'Enable interactive mode by default?',
|
|
261
|
+
default: true,
|
|
262
|
+
});
|
|
263
|
+
|
|
264
|
+
const backupAnswer = await inquirer.prompt({
|
|
265
|
+
type: 'confirm',
|
|
266
|
+
name: 'backup',
|
|
267
|
+
message: 'Create backups before updates?',
|
|
268
|
+
default: true,
|
|
269
|
+
});
|
|
270
|
+
|
|
271
|
+
const strategyAnswer = await inquirer.prompt({
|
|
272
|
+
type: 'list',
|
|
273
|
+
name: 'updateStrategy',
|
|
274
|
+
message: 'Default update strategy:',
|
|
275
|
+
choices: [
|
|
276
|
+
{ name: 'Latest stable versions', value: 'latest' },
|
|
277
|
+
{ name: 'Minor updates (non-breaking)', value: 'minor' },
|
|
278
|
+
{ name: 'Patch updates (bug fixes)', value: 'patch' },
|
|
279
|
+
],
|
|
280
|
+
default: 'latest',
|
|
281
|
+
});
|
|
282
|
+
|
|
283
|
+
const timeoutAnswer = await inquirer.prompt({
|
|
284
|
+
type: 'number',
|
|
285
|
+
name: 'timeout',
|
|
286
|
+
message: 'Network timeout (seconds):',
|
|
287
|
+
default: 30,
|
|
288
|
+
validate: (input: number | undefined) => {
|
|
289
|
+
if (input === undefined) return 'Timeout is required';
|
|
290
|
+
return input > 0 || 'Timeout must be positive';
|
|
291
|
+
},
|
|
292
|
+
});
|
|
293
|
+
|
|
294
|
+
const answers = {
|
|
295
|
+
...themeAnswer,
|
|
296
|
+
...interactiveAnswer,
|
|
297
|
+
...backupAnswer,
|
|
298
|
+
...strategyAnswer,
|
|
299
|
+
...timeoutAnswer,
|
|
300
|
+
};
|
|
301
|
+
|
|
302
|
+
return answers;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
/**
|
|
306
|
+
* Impact preview before update
|
|
307
|
+
*/
|
|
308
|
+
async previewImpact(impact: any): Promise<boolean> {
|
|
309
|
+
console.log(chalk.bold.blue('\n📊 Impact Preview\n'));
|
|
310
|
+
|
|
311
|
+
// Display impact summary
|
|
312
|
+
console.log(`Packages to update: ${impact.totalUpdates}`);
|
|
313
|
+
console.log(`Risk level: ${impact.riskLevel}`);
|
|
314
|
+
console.log(`Affected packages: ${impact.affectedCount}`);
|
|
315
|
+
|
|
316
|
+
if (impact.securityUpdates > 0) {
|
|
317
|
+
console.log(StyledText.iconSecurity(`${impact.securityUpdates} security updates`));
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
console.log('');
|
|
321
|
+
|
|
322
|
+
const answers = await inquirer.prompt([
|
|
323
|
+
{
|
|
324
|
+
type: 'confirm',
|
|
325
|
+
name: 'proceed',
|
|
326
|
+
message: 'Proceed with update?',
|
|
327
|
+
default: true,
|
|
328
|
+
},
|
|
329
|
+
]);
|
|
330
|
+
|
|
331
|
+
return answers.proceed;
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
/**
|
|
335
|
+
* Error recovery options
|
|
336
|
+
*/
|
|
337
|
+
async errorRecoveryOptions(error: string): Promise<string> {
|
|
338
|
+
const options = [
|
|
339
|
+
{ name: 'Retry operation', value: 'retry' },
|
|
340
|
+
{ name: 'Skip this package', value: 'skip' },
|
|
341
|
+
{ name: 'Continue with remaining', value: 'continue' },
|
|
342
|
+
{ name: 'Abort operation', value: 'abort' },
|
|
343
|
+
];
|
|
344
|
+
|
|
345
|
+
const answers = await inquirer.prompt([
|
|
346
|
+
{
|
|
347
|
+
type: 'list',
|
|
348
|
+
name: 'action',
|
|
349
|
+
message: StyledText.iconError(`Error: ${error}`),
|
|
350
|
+
choices: options,
|
|
351
|
+
},
|
|
352
|
+
]);
|
|
353
|
+
|
|
354
|
+
return answers.action;
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
/**
|
|
358
|
+
* Confirm tool update
|
|
359
|
+
*/
|
|
360
|
+
async confirmUpdate(message: string): Promise<boolean> {
|
|
361
|
+
const answers = await inquirer.prompt([
|
|
362
|
+
{
|
|
363
|
+
type: 'confirm',
|
|
364
|
+
name: 'update',
|
|
365
|
+
message: StyledText.iconUpdate(message),
|
|
366
|
+
default: true,
|
|
367
|
+
},
|
|
368
|
+
]);
|
|
369
|
+
|
|
370
|
+
return answers.update;
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
/**
|
|
374
|
+
* Format package choice for display
|
|
375
|
+
*/
|
|
376
|
+
private formatPackageChoice(pkg: any): string {
|
|
377
|
+
const updateTypeColor: Record<string, any> = {
|
|
378
|
+
major: chalk.red,
|
|
379
|
+
minor: chalk.yellow,
|
|
380
|
+
patch: chalk.green,
|
|
381
|
+
};
|
|
382
|
+
|
|
383
|
+
const typeColor = updateTypeColor[pkg.type] || chalk.gray;
|
|
384
|
+
|
|
385
|
+
return `${pkg.name} ${chalk.dim(pkg.current)} → ${typeColor(pkg.latest)} ${chalk.dim(`(${pkg.type})`)}`;
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
/**
|
|
390
|
+
* Auto-completion utilities
|
|
391
|
+
*/
|
|
392
|
+
export class AutoCompleteManager {
|
|
393
|
+
static async suggestWorkspaces(current: string): Promise<string[]> {
|
|
394
|
+
const suggestions: string[] = [];
|
|
395
|
+
|
|
396
|
+
// Common workspace patterns
|
|
397
|
+
const patterns = [
|
|
398
|
+
'pnpm-workspace.yaml',
|
|
399
|
+
'pnpm-workspace.yml',
|
|
400
|
+
'**/*/pnpm-workspace.yaml',
|
|
401
|
+
'**/*/pnpm-workspace.yml',
|
|
402
|
+
];
|
|
403
|
+
|
|
404
|
+
for (const pattern of patterns) {
|
|
405
|
+
try {
|
|
406
|
+
const { glob } = await import('glob');
|
|
407
|
+
const matches = await glob(pattern);
|
|
408
|
+
matches.forEach((match: string) => {
|
|
409
|
+
const dir = match.replace(/\/pnpm-workspace\.ya?ml$/, '');
|
|
410
|
+
if (!suggestions.includes(dir)) {
|
|
411
|
+
suggestions.push(dir);
|
|
412
|
+
}
|
|
413
|
+
});
|
|
414
|
+
} catch {
|
|
415
|
+
// Ignore errors
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
return suggestions.filter((s) => s.toLowerCase().includes(current.toLowerCase()));
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
static async suggestCatalogs(): Promise<string[]> {
|
|
423
|
+
return [];
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
static async suggestPackages(): Promise<string[]> {
|
|
427
|
+
return [];
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
/**
|
|
432
|
+
* Interactive command builder
|
|
433
|
+
*/
|
|
434
|
+
export class InteractiveCommandBuilder {
|
|
435
|
+
static async buildCommand(): Promise<{
|
|
436
|
+
command: string;
|
|
437
|
+
options: Record<string, any>;
|
|
438
|
+
}> {
|
|
439
|
+
const baseCommand = await inquirer.prompt([
|
|
440
|
+
{
|
|
441
|
+
type: 'list',
|
|
442
|
+
name: 'command',
|
|
443
|
+
message: 'What would you like to do?',
|
|
444
|
+
choices: [
|
|
445
|
+
{ name: 'Check for updates', value: 'check' },
|
|
446
|
+
{ name: 'Update dependencies', value: 'update' },
|
|
447
|
+
{ name: 'Analyze impact', value: 'analyze' },
|
|
448
|
+
{ name: 'Show workspace info', value: 'workspace' },
|
|
449
|
+
],
|
|
450
|
+
},
|
|
451
|
+
]);
|
|
452
|
+
|
|
453
|
+
const options: Record<string, any> = {};
|
|
454
|
+
|
|
455
|
+
// Common options
|
|
456
|
+
const common = await inquirer.prompt([
|
|
457
|
+
{
|
|
458
|
+
type: 'list',
|
|
459
|
+
name: 'format',
|
|
460
|
+
message: 'Output format:',
|
|
461
|
+
choices: [
|
|
462
|
+
{ name: 'Table (rich)', value: 'table' },
|
|
463
|
+
{ name: 'JSON', value: 'json' },
|
|
464
|
+
{ name: 'YAML', value: 'yaml' },
|
|
465
|
+
{ name: 'Minimal', value: 'minimal' },
|
|
466
|
+
],
|
|
467
|
+
default: 'table',
|
|
468
|
+
},
|
|
469
|
+
]);
|
|
470
|
+
|
|
471
|
+
options.format = common.format;
|
|
472
|
+
|
|
473
|
+
// Command-specific options
|
|
474
|
+
switch (baseCommand.command) {
|
|
475
|
+
case 'update':
|
|
476
|
+
const updateOpts = await inquirer.prompt([
|
|
477
|
+
{
|
|
478
|
+
type: 'confirm',
|
|
479
|
+
name: 'interactive',
|
|
480
|
+
message: 'Interactive mode?',
|
|
481
|
+
default: true,
|
|
482
|
+
},
|
|
483
|
+
{
|
|
484
|
+
type: 'confirm',
|
|
485
|
+
name: 'dryRun',
|
|
486
|
+
message: 'Dry run mode?',
|
|
487
|
+
default: false,
|
|
488
|
+
},
|
|
489
|
+
{
|
|
490
|
+
type: 'confirm',
|
|
491
|
+
name: 'backup',
|
|
492
|
+
message: 'Create backup?',
|
|
493
|
+
default: true,
|
|
494
|
+
},
|
|
495
|
+
]);
|
|
496
|
+
Object.assign(options, updateOpts);
|
|
497
|
+
break;
|
|
498
|
+
|
|
499
|
+
case 'check':
|
|
500
|
+
const checkOpts = await inquirer.prompt([
|
|
501
|
+
{
|
|
502
|
+
type: 'confirm',
|
|
503
|
+
name: 'includePrerelease',
|
|
504
|
+
message: 'Include pre-release versions?',
|
|
505
|
+
default: false,
|
|
506
|
+
},
|
|
507
|
+
]);
|
|
508
|
+
options.prerelease = checkOpts.includePrerelease;
|
|
509
|
+
break;
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
return {
|
|
513
|
+
command: baseCommand.command,
|
|
514
|
+
options,
|
|
515
|
+
};
|
|
516
|
+
}
|
|
517
|
+
}
|