pcu 0.5.6 → 0.6.3
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 +36 -84
- 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/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
|
@@ -0,0 +1,394 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Init Command
|
|
3
|
+
*
|
|
4
|
+
* CLI command to initialize PCU configuration in a workspace.
|
|
5
|
+
* Creates a basic .pcurc.json configuration file with sensible defaults.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { existsSync, writeFileSync, mkdirSync } from 'fs';
|
|
9
|
+
import { join, dirname } from 'path';
|
|
10
|
+
import { StyledText, ThemeManager } from '../themes/colorTheme.js';
|
|
11
|
+
import { PackageFilterConfig } from '@pcu/utils';
|
|
12
|
+
|
|
13
|
+
export interface InitCommandOptions {
|
|
14
|
+
workspace?: string;
|
|
15
|
+
force?: boolean;
|
|
16
|
+
verbose?: boolean;
|
|
17
|
+
color?: boolean;
|
|
18
|
+
createWorkspace?: boolean;
|
|
19
|
+
full?: boolean;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export class InitCommand {
|
|
23
|
+
/**
|
|
24
|
+
* Execute the init command
|
|
25
|
+
*/
|
|
26
|
+
async execute(options: InitCommandOptions = {}): Promise<void> {
|
|
27
|
+
try {
|
|
28
|
+
// Initialize theme
|
|
29
|
+
ThemeManager.setTheme('default');
|
|
30
|
+
|
|
31
|
+
const workspacePath = options.workspace || process.cwd();
|
|
32
|
+
const configPath = join(workspacePath, '.pcurc.json');
|
|
33
|
+
const packageJsonPath = join(workspacePath, 'package.json');
|
|
34
|
+
const workspaceYamlPath = join(workspacePath, 'pnpm-workspace.yaml');
|
|
35
|
+
|
|
36
|
+
if (options.verbose) {
|
|
37
|
+
console.log(StyledText.iconInfo('Initializing PCU configuration'));
|
|
38
|
+
console.log(StyledText.muted(`Workspace: ${workspacePath}`));
|
|
39
|
+
console.log(StyledText.muted(`Config file: ${configPath}`));
|
|
40
|
+
console.log('');
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// Check if this is a pnpm workspace
|
|
44
|
+
const hasPackageJson = existsSync(packageJsonPath);
|
|
45
|
+
const hasWorkspaceYaml = existsSync(workspaceYamlPath);
|
|
46
|
+
const isWorkspace = hasPackageJson && hasWorkspaceYaml;
|
|
47
|
+
|
|
48
|
+
if (!isWorkspace && options.createWorkspace !== false) {
|
|
49
|
+
if (options.verbose) {
|
|
50
|
+
console.log(StyledText.iconWarning('PNPM workspace structure not detected'));
|
|
51
|
+
if (!hasPackageJson) {
|
|
52
|
+
console.log(StyledText.muted('Missing: package.json'));
|
|
53
|
+
}
|
|
54
|
+
if (!hasWorkspaceYaml) {
|
|
55
|
+
console.log(StyledText.muted('Missing: pnpm-workspace.yaml'));
|
|
56
|
+
}
|
|
57
|
+
console.log('');
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// Create workspace structure
|
|
61
|
+
if (options.verbose) {
|
|
62
|
+
console.log(StyledText.iconInfo('Creating PNPM workspace structure...'));
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
await this.createWorkspaceStructure(
|
|
66
|
+
workspacePath,
|
|
67
|
+
hasPackageJson,
|
|
68
|
+
hasWorkspaceYaml,
|
|
69
|
+
options
|
|
70
|
+
);
|
|
71
|
+
|
|
72
|
+
if (options.verbose) {
|
|
73
|
+
console.log(StyledText.iconSuccess('PNPM workspace structure created'));
|
|
74
|
+
console.log('');
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// Check if config file already exists
|
|
79
|
+
if (existsSync(configPath) && !options.force) {
|
|
80
|
+
console.log(StyledText.iconWarning('Configuration file already exists!'));
|
|
81
|
+
console.log(StyledText.muted(`Found: ${configPath}`));
|
|
82
|
+
console.log(StyledText.muted('Use --force to overwrite existing configuration'));
|
|
83
|
+
process.exit(1);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// Create directory if it doesn't exist
|
|
87
|
+
const configDir = dirname(configPath);
|
|
88
|
+
if (!existsSync(configDir)) {
|
|
89
|
+
mkdirSync(configDir, { recursive: true });
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// Generate basic configuration
|
|
93
|
+
const basicConfig = this.generateBasicConfig(options.full);
|
|
94
|
+
|
|
95
|
+
// Write configuration file
|
|
96
|
+
writeFileSync(configPath, JSON.stringify(basicConfig, null, 2), 'utf-8');
|
|
97
|
+
|
|
98
|
+
// Success message
|
|
99
|
+
console.log(StyledText.iconSuccess('PCU configuration initialized successfully!'));
|
|
100
|
+
console.log(StyledText.muted(`Created: ${configPath}`));
|
|
101
|
+
console.log('');
|
|
102
|
+
|
|
103
|
+
// Show next steps
|
|
104
|
+
this.showNextSteps(configPath);
|
|
105
|
+
|
|
106
|
+
process.exit(0);
|
|
107
|
+
} catch (error) {
|
|
108
|
+
console.error(StyledText.iconError('Error initializing configuration:'));
|
|
109
|
+
console.error(StyledText.error(String(error)));
|
|
110
|
+
|
|
111
|
+
if (options.verbose && error instanceof Error) {
|
|
112
|
+
console.error(StyledText.muted('Stack trace:'));
|
|
113
|
+
console.error(StyledText.muted(error.stack || 'No stack trace available'));
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
process.exit(1);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Create PNPM workspace structure
|
|
122
|
+
*/
|
|
123
|
+
private async createWorkspaceStructure(
|
|
124
|
+
workspacePath: string,
|
|
125
|
+
hasPackageJson: boolean,
|
|
126
|
+
hasWorkspaceYaml: boolean,
|
|
127
|
+
options: InitCommandOptions
|
|
128
|
+
): Promise<void> {
|
|
129
|
+
// Create package.json if it doesn't exist
|
|
130
|
+
if (!hasPackageJson) {
|
|
131
|
+
const packageJsonPath = join(workspacePath, 'package.json');
|
|
132
|
+
const packageJson = this.generateWorkspacePackageJson();
|
|
133
|
+
writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2), 'utf-8');
|
|
134
|
+
|
|
135
|
+
if (options.verbose) {
|
|
136
|
+
console.log(StyledText.muted('Created: package.json'));
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// Create pnpm-workspace.yaml if it doesn't exist
|
|
141
|
+
if (!hasWorkspaceYaml) {
|
|
142
|
+
const workspaceYamlPath = join(workspacePath, 'pnpm-workspace.yaml');
|
|
143
|
+
const workspaceYaml = this.generateWorkspaceYaml();
|
|
144
|
+
writeFileSync(workspaceYamlPath, workspaceYaml, 'utf-8');
|
|
145
|
+
|
|
146
|
+
if (options.verbose) {
|
|
147
|
+
console.log(StyledText.muted('Created: pnpm-workspace.yaml'));
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
// Create basic directories structure
|
|
152
|
+
const packagesDir = join(workspacePath, 'packages');
|
|
153
|
+
if (!existsSync(packagesDir)) {
|
|
154
|
+
mkdirSync(packagesDir, { recursive: true });
|
|
155
|
+
|
|
156
|
+
if (options.verbose) {
|
|
157
|
+
console.log(StyledText.muted('Created: packages/ directory'));
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Generate workspace package.json
|
|
164
|
+
*/
|
|
165
|
+
private generateWorkspacePackageJson(): any {
|
|
166
|
+
return {
|
|
167
|
+
name: 'my-workspace',
|
|
168
|
+
version: '1.0.0',
|
|
169
|
+
private: true,
|
|
170
|
+
description: 'PNPM workspace with catalog dependency management',
|
|
171
|
+
scripts: {
|
|
172
|
+
'check-updates': 'pcu check',
|
|
173
|
+
'update-deps': 'pcu update --interactive',
|
|
174
|
+
'security-audit': 'pcu security',
|
|
175
|
+
},
|
|
176
|
+
devDependencies: {
|
|
177
|
+
'pnpm-catalog-updates': 'latest',
|
|
178
|
+
},
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* Generate pnpm-workspace.yaml
|
|
184
|
+
*/
|
|
185
|
+
private generateWorkspaceYaml(): string {
|
|
186
|
+
return `# PNPM Workspace Configuration
|
|
187
|
+
# Learn more: https://pnpm.io/pnpm-workspace_yaml
|
|
188
|
+
|
|
189
|
+
packages:
|
|
190
|
+
# Include all packages in packages directory
|
|
191
|
+
- 'packages/*'
|
|
192
|
+
|
|
193
|
+
# Include apps directory if you have applications
|
|
194
|
+
# - 'apps/*'
|
|
195
|
+
|
|
196
|
+
# Include tools directory if you have development tools
|
|
197
|
+
# - 'tools/*'
|
|
198
|
+
|
|
199
|
+
# Catalog Configuration
|
|
200
|
+
# Centrally manage dependency versions across workspace packages
|
|
201
|
+
# Learn more: https://pnpm.io/catalogs
|
|
202
|
+
catalogs:
|
|
203
|
+
# Default catalog for common dependencies
|
|
204
|
+
default:
|
|
205
|
+
# React ecosystem
|
|
206
|
+
# react: ^18.2.0
|
|
207
|
+
# react-dom: ^18.2.0
|
|
208
|
+
# '@types/react': ^18.2.0
|
|
209
|
+
# '@types/react-dom': ^18.2.0
|
|
210
|
+
|
|
211
|
+
# TypeScript and Node.js
|
|
212
|
+
# typescript: ^5.0.0
|
|
213
|
+
# '@types/node': ^20.0.0
|
|
214
|
+
|
|
215
|
+
# Development tools
|
|
216
|
+
# eslint: ^8.0.0
|
|
217
|
+
# prettier: ^3.0.0
|
|
218
|
+
# vitest: ^1.0.0
|
|
219
|
+
`;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* Generate basic configuration with sensible defaults
|
|
224
|
+
*/
|
|
225
|
+
private generateBasicConfig(full?: boolean): PackageFilterConfig {
|
|
226
|
+
if (full) {
|
|
227
|
+
return this.generateFullConfig();
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
// Minimal configuration
|
|
231
|
+
return {
|
|
232
|
+
defaults: {
|
|
233
|
+
target: 'latest',
|
|
234
|
+
createBackup: true,
|
|
235
|
+
format: 'table',
|
|
236
|
+
},
|
|
237
|
+
exclude: [],
|
|
238
|
+
include: [],
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* Generate full configuration with all options
|
|
244
|
+
*/
|
|
245
|
+
private generateFullConfig(): PackageFilterConfig {
|
|
246
|
+
return {
|
|
247
|
+
defaults: {
|
|
248
|
+
target: 'latest',
|
|
249
|
+
includePrerelease: false,
|
|
250
|
+
interactive: false,
|
|
251
|
+
dryRun: false,
|
|
252
|
+
createBackup: true,
|
|
253
|
+
format: 'table',
|
|
254
|
+
},
|
|
255
|
+
packageRules: [
|
|
256
|
+
{
|
|
257
|
+
patterns: ['react', 'react-dom'],
|
|
258
|
+
target: 'minor',
|
|
259
|
+
autoUpdate: false,
|
|
260
|
+
requireConfirmation: true,
|
|
261
|
+
groupUpdate: true,
|
|
262
|
+
relatedPackages: ['@types/react', '@types/react-dom'],
|
|
263
|
+
},
|
|
264
|
+
{
|
|
265
|
+
patterns: ['@types/*'],
|
|
266
|
+
target: 'latest',
|
|
267
|
+
autoUpdate: true,
|
|
268
|
+
requireConfirmation: false,
|
|
269
|
+
groupUpdate: false,
|
|
270
|
+
},
|
|
271
|
+
{
|
|
272
|
+
patterns: ['eslint*', 'prettier', '@typescript-eslint/*'],
|
|
273
|
+
target: 'minor',
|
|
274
|
+
autoUpdate: false,
|
|
275
|
+
requireConfirmation: false,
|
|
276
|
+
groupUpdate: true,
|
|
277
|
+
},
|
|
278
|
+
],
|
|
279
|
+
security: {
|
|
280
|
+
autoFixVulnerabilities: true,
|
|
281
|
+
allowMajorForSecurity: true,
|
|
282
|
+
notifyOnSecurityUpdate: false,
|
|
283
|
+
},
|
|
284
|
+
advanced: {
|
|
285
|
+
concurrency: 5,
|
|
286
|
+
timeout: 30000,
|
|
287
|
+
retries: 3,
|
|
288
|
+
cacheValidityMinutes: 60,
|
|
289
|
+
checkForUpdates: true,
|
|
290
|
+
},
|
|
291
|
+
monorepo: {
|
|
292
|
+
syncVersions: [],
|
|
293
|
+
catalogPriority: ['default'],
|
|
294
|
+
},
|
|
295
|
+
exclude: [],
|
|
296
|
+
include: [],
|
|
297
|
+
};
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
/**
|
|
301
|
+
* Show next steps to the user
|
|
302
|
+
*/
|
|
303
|
+
private showNextSteps(configPath: string): void {
|
|
304
|
+
const lines: string[] = [];
|
|
305
|
+
|
|
306
|
+
lines.push(StyledText.iconInfo('Next steps:'));
|
|
307
|
+
lines.push('');
|
|
308
|
+
lines.push(StyledText.muted('1. Review and customize the configuration:'));
|
|
309
|
+
lines.push(StyledText.muted(` ${configPath}`));
|
|
310
|
+
lines.push('');
|
|
311
|
+
lines.push(StyledText.muted('2. Add packages to your workspace:'));
|
|
312
|
+
lines.push(StyledText.muted(' mkdir packages/my-app && cd packages/my-app'));
|
|
313
|
+
lines.push(StyledText.muted(' pnpm init'));
|
|
314
|
+
lines.push('');
|
|
315
|
+
lines.push(StyledText.muted('3. Install dependencies and check for updates:'));
|
|
316
|
+
lines.push(StyledText.muted(' pnpm install'));
|
|
317
|
+
lines.push(StyledText.muted(' pcu check'));
|
|
318
|
+
lines.push('');
|
|
319
|
+
lines.push(StyledText.muted('4. Update dependencies interactively:'));
|
|
320
|
+
lines.push(StyledText.muted(' pcu update --interactive'));
|
|
321
|
+
lines.push('');
|
|
322
|
+
lines.push(StyledText.muted('5. Learn more about PNPM workspace and PCU:'));
|
|
323
|
+
lines.push(StyledText.muted(' https://pnpm.io/workspaces'));
|
|
324
|
+
lines.push(
|
|
325
|
+
StyledText.muted(' https://github.com/your-repo/pnpm-catalog-updates#configuration')
|
|
326
|
+
);
|
|
327
|
+
|
|
328
|
+
console.log(lines.join('\n'));
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
/**
|
|
332
|
+
* Validate command options
|
|
333
|
+
*/
|
|
334
|
+
static validateOptions(options: InitCommandOptions): string[] {
|
|
335
|
+
const errors: string[] = [];
|
|
336
|
+
|
|
337
|
+
// Validate workspace path exists if provided
|
|
338
|
+
if (options.workspace && !existsSync(options.workspace)) {
|
|
339
|
+
errors.push(`Workspace directory does not exist: ${options.workspace}`);
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
return errors;
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
/**
|
|
346
|
+
* Get command help text
|
|
347
|
+
*/
|
|
348
|
+
static getHelpText(): string {
|
|
349
|
+
return `
|
|
350
|
+
Initialize PCU configuration and PNPM workspace
|
|
351
|
+
|
|
352
|
+
Usage:
|
|
353
|
+
pcu init [options]
|
|
354
|
+
|
|
355
|
+
Options:
|
|
356
|
+
--workspace <path> Workspace directory (default: current directory)
|
|
357
|
+
--force Overwrite existing configuration file
|
|
358
|
+
--full Generate full configuration with all options
|
|
359
|
+
--create-workspace Create PNPM workspace structure if missing (default: true)
|
|
360
|
+
--no-create-workspace Skip creating PNPM workspace structure
|
|
361
|
+
--verbose Show detailed information
|
|
362
|
+
--no-color Disable colored output
|
|
363
|
+
|
|
364
|
+
Description:
|
|
365
|
+
Creates a complete PNPM workspace environment with:
|
|
366
|
+
- Basic .pcurc.json configuration file with sensible defaults
|
|
367
|
+
- package.json for workspace root (if missing)
|
|
368
|
+
- pnpm-workspace.yaml configuration (if missing)
|
|
369
|
+
- packages/ directory structure (if missing)
|
|
370
|
+
|
|
371
|
+
By default, creates a minimal configuration. Use --full to generate
|
|
372
|
+
a complete configuration with package rules for React, TypeScript,
|
|
373
|
+
ESLint, and other common dependencies with security settings.
|
|
374
|
+
|
|
375
|
+
Examples:
|
|
376
|
+
pcu init # Initialize with minimal configuration
|
|
377
|
+
pcu init --full # Initialize with full configuration
|
|
378
|
+
pcu init --workspace ./my-project # Initialize in specific directory
|
|
379
|
+
pcu init --force # Overwrite existing configuration
|
|
380
|
+
pcu init --no-create-workspace # Only create .pcurc.json configuration
|
|
381
|
+
|
|
382
|
+
Files Created:
|
|
383
|
+
.pcurc.json PCU configuration (minimal by default, full with --full)
|
|
384
|
+
package.json Workspace root package.json (if missing)
|
|
385
|
+
pnpm-workspace.yaml PNPM workspace configuration (if missing)
|
|
386
|
+
packages/ Directory for workspace packages (if missing)
|
|
387
|
+
|
|
388
|
+
Exit Codes:
|
|
389
|
+
0 Configuration initialized successfully
|
|
390
|
+
1 Configuration already exists (use --force to overwrite)
|
|
391
|
+
2 Error occurred
|
|
392
|
+
`;
|
|
393
|
+
}
|
|
394
|
+
}
|