pnpm-catalog-updates 0.5.7 → 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.
Files changed (224) hide show
  1. package/bin/pcu.js +1 -1
  2. package/dist/index.js +9559 -32
  3. package/dist/index.js.map +1 -1
  4. package/package.json +61 -103
  5. package/src/cli/commands/checkCommand.ts +227 -0
  6. package/src/cli/commands/initCommand.ts +394 -0
  7. package/src/cli/commands/securityCommand.ts +569 -0
  8. package/src/cli/commands/updateCommand.ts +245 -0
  9. package/src/cli/formatters/outputFormatter.ts +830 -0
  10. package/src/cli/formatters/progressBar.ts +700 -0
  11. package/src/cli/index.ts +565 -0
  12. package/src/cli/interactive/interactivePrompts.ts +517 -0
  13. package/src/cli/options/globalOptions.ts +380 -0
  14. package/src/cli/options/index.ts +5 -0
  15. package/src/cli/themes/colorTheme.ts +379 -0
  16. package/src/cli/validators/commandValidator.ts +395 -0
  17. package/src/cli/validators/index.ts +5 -0
  18. package/src/index.ts +4 -0
  19. package/LICENSE +0 -21
  20. package/README.ja.md +0 -587
  21. package/README.md +0 -694
  22. package/README.zh-CN.md +0 -634
  23. package/dist/application/services/CatalogUpdateService.d.ts +0 -209
  24. package/dist/application/services/CatalogUpdateService.d.ts.map +0 -1
  25. package/dist/application/services/CatalogUpdateService.js +0 -839
  26. package/dist/application/services/CatalogUpdateService.js.map +0 -1
  27. package/dist/application/services/WorkspaceService.d.ts +0 -139
  28. package/dist/application/services/WorkspaceService.d.ts.map +0 -1
  29. package/dist/application/services/WorkspaceService.js +0 -340
  30. package/dist/application/services/WorkspaceService.js.map +0 -1
  31. package/dist/cli/commands/CheckCommand.d.ts +0 -40
  32. package/dist/cli/commands/CheckCommand.d.ts.map +0 -1
  33. package/dist/cli/commands/CheckCommand.js +0 -177
  34. package/dist/cli/commands/CheckCommand.js.map +0 -1
  35. package/dist/cli/commands/InitCommand.d.ts +0 -53
  36. package/dist/cli/commands/InitCommand.d.ts.map +0 -1
  37. package/dist/cli/commands/InitCommand.js +0 -338
  38. package/dist/cli/commands/InitCommand.js.map +0 -1
  39. package/dist/cli/commands/SecurityCommand.d.ts +0 -113
  40. package/dist/cli/commands/SecurityCommand.d.ts.map +0 -1
  41. package/dist/cli/commands/SecurityCommand.js +0 -410
  42. package/dist/cli/commands/SecurityCommand.js.map +0 -1
  43. package/dist/cli/commands/UpdateCommand.d.ts +0 -44
  44. package/dist/cli/commands/UpdateCommand.d.ts.map +0 -1
  45. package/dist/cli/commands/UpdateCommand.js +0 -189
  46. package/dist/cli/commands/UpdateCommand.js.map +0 -1
  47. package/dist/cli/formatters/OutputFormatter.d.ts +0 -116
  48. package/dist/cli/formatters/OutputFormatter.d.ts.map +0 -1
  49. package/dist/cli/formatters/OutputFormatter.js +0 -664
  50. package/dist/cli/formatters/OutputFormatter.js.map +0 -1
  51. package/dist/cli/formatters/ProgressBar.d.ts +0 -195
  52. package/dist/cli/formatters/ProgressBar.d.ts.map +0 -1
  53. package/dist/cli/formatters/ProgressBar.js +0 -622
  54. package/dist/cli/formatters/ProgressBar.js.map +0 -1
  55. package/dist/cli/index.d.ts +0 -12
  56. package/dist/cli/index.d.ts.map +0 -1
  57. package/dist/cli/index.js +0 -492
  58. package/dist/cli/index.js.map +0 -1
  59. package/dist/cli/interactive/InteractivePrompts.d.ts +0 -85
  60. package/dist/cli/interactive/InteractivePrompts.d.ts.map +0 -1
  61. package/dist/cli/interactive/InteractivePrompts.js +0 -434
  62. package/dist/cli/interactive/InteractivePrompts.js.map +0 -1
  63. package/dist/cli/options/GlobalOptions.d.ts +0 -117
  64. package/dist/cli/options/GlobalOptions.d.ts.map +0 -1
  65. package/dist/cli/options/GlobalOptions.js +0 -278
  66. package/dist/cli/options/GlobalOptions.js.map +0 -1
  67. package/dist/cli/options/index.d.ts +0 -5
  68. package/dist/cli/options/index.d.ts.map +0 -1
  69. package/dist/cli/options/index.js +0 -5
  70. package/dist/cli/options/index.js.map +0 -1
  71. package/dist/cli/themes/ColorTheme.d.ts +0 -211
  72. package/dist/cli/themes/ColorTheme.d.ts.map +0 -1
  73. package/dist/cli/themes/ColorTheme.js +0 -267
  74. package/dist/cli/themes/ColorTheme.js.map +0 -1
  75. package/dist/cli/validators/CommandValidator.d.ts +0 -60
  76. package/dist/cli/validators/CommandValidator.d.ts.map +0 -1
  77. package/dist/cli/validators/CommandValidator.js +0 -319
  78. package/dist/cli/validators/CommandValidator.js.map +0 -1
  79. package/dist/cli/validators/index.d.ts +0 -5
  80. package/dist/cli/validators/index.d.ts.map +0 -1
  81. package/dist/cli/validators/index.js +0 -5
  82. package/dist/cli/validators/index.js.map +0 -1
  83. package/dist/common/config/Config.d.ts +0 -142
  84. package/dist/common/config/Config.d.ts.map +0 -1
  85. package/dist/common/config/Config.js +0 -382
  86. package/dist/common/config/Config.js.map +0 -1
  87. package/dist/common/config/ConfigLoader.d.ts +0 -49
  88. package/dist/common/config/ConfigLoader.d.ts.map +0 -1
  89. package/dist/common/config/ConfigLoader.js +0 -180
  90. package/dist/common/config/ConfigLoader.js.map +0 -1
  91. package/dist/common/config/PackageFilterConfig.d.ts +0 -56
  92. package/dist/common/config/PackageFilterConfig.d.ts.map +0 -1
  93. package/dist/common/config/PackageFilterConfig.js +0 -94
  94. package/dist/common/config/PackageFilterConfig.js.map +0 -1
  95. package/dist/common/config/index.d.ts +0 -8
  96. package/dist/common/config/index.d.ts.map +0 -1
  97. package/dist/common/config/index.js +0 -8
  98. package/dist/common/config/index.js.map +0 -1
  99. package/dist/common/error-handling/ErrorTracker.d.ts +0 -48
  100. package/dist/common/error-handling/ErrorTracker.d.ts.map +0 -1
  101. package/dist/common/error-handling/ErrorTracker.js +0 -93
  102. package/dist/common/error-handling/ErrorTracker.js.map +0 -1
  103. package/dist/common/error-handling/UserFriendlyErrorHandler.d.ts +0 -74
  104. package/dist/common/error-handling/UserFriendlyErrorHandler.d.ts.map +0 -1
  105. package/dist/common/error-handling/UserFriendlyErrorHandler.js +0 -703
  106. package/dist/common/error-handling/UserFriendlyErrorHandler.js.map +0 -1
  107. package/dist/common/error-handling/index.d.ts +0 -11
  108. package/dist/common/error-handling/index.d.ts.map +0 -1
  109. package/dist/common/error-handling/index.js +0 -9
  110. package/dist/common/error-handling/index.js.map +0 -1
  111. package/dist/common/logger/Logger.d.ts +0 -110
  112. package/dist/common/logger/Logger.d.ts.map +0 -1
  113. package/dist/common/logger/Logger.js +0 -289
  114. package/dist/common/logger/Logger.js.map +0 -1
  115. package/dist/common/logger/index.d.ts +0 -6
  116. package/dist/common/logger/index.d.ts.map +0 -1
  117. package/dist/common/logger/index.js +0 -6
  118. package/dist/common/logger/index.js.map +0 -1
  119. package/dist/common/types/cli.d.ts +0 -265
  120. package/dist/common/types/cli.d.ts.map +0 -1
  121. package/dist/common/types/cli.js +0 -5
  122. package/dist/common/types/cli.js.map +0 -1
  123. package/dist/common/types/core.d.ts +0 -270
  124. package/dist/common/types/core.d.ts.map +0 -1
  125. package/dist/common/types/core.js +0 -32
  126. package/dist/common/types/core.js.map +0 -1
  127. package/dist/common/types/index.d.ts +0 -8
  128. package/dist/common/types/index.d.ts.map +0 -1
  129. package/dist/common/types/index.js +0 -8
  130. package/dist/common/types/index.js.map +0 -1
  131. package/dist/common/utils/VersionChecker.d.ts +0 -54
  132. package/dist/common/utils/VersionChecker.d.ts.map +0 -1
  133. package/dist/common/utils/VersionChecker.js +0 -180
  134. package/dist/common/utils/VersionChecker.js.map +0 -1
  135. package/dist/common/utils/async.d.ts +0 -74
  136. package/dist/common/utils/async.d.ts.map +0 -1
  137. package/dist/common/utils/async.js +0 -228
  138. package/dist/common/utils/async.js.map +0 -1
  139. package/dist/common/utils/format.d.ts +0 -32
  140. package/dist/common/utils/format.d.ts.map +0 -1
  141. package/dist/common/utils/format.js +0 -121
  142. package/dist/common/utils/format.js.map +0 -1
  143. package/dist/common/utils/git.d.ts +0 -44
  144. package/dist/common/utils/git.d.ts.map +0 -1
  145. package/dist/common/utils/git.js +0 -147
  146. package/dist/common/utils/git.js.map +0 -1
  147. package/dist/common/utils/index.d.ts +0 -12
  148. package/dist/common/utils/index.d.ts.map +0 -1
  149. package/dist/common/utils/index.js +0 -12
  150. package/dist/common/utils/index.js.map +0 -1
  151. package/dist/common/utils/string.d.ts +0 -56
  152. package/dist/common/utils/string.d.ts.map +0 -1
  153. package/dist/common/utils/string.js +0 -134
  154. package/dist/common/utils/string.js.map +0 -1
  155. package/dist/common/utils/validation.d.ts +0 -88
  156. package/dist/common/utils/validation.d.ts.map +0 -1
  157. package/dist/common/utils/validation.js +0 -308
  158. package/dist/common/utils/validation.js.map +0 -1
  159. package/dist/domain/entities/Catalog.d.ts +0 -117
  160. package/dist/domain/entities/Catalog.d.ts.map +0 -1
  161. package/dist/domain/entities/Catalog.js +0 -240
  162. package/dist/domain/entities/Catalog.js.map +0 -1
  163. package/dist/domain/entities/Package.d.ts +0 -143
  164. package/dist/domain/entities/Package.d.ts.map +0 -1
  165. package/dist/domain/entities/Package.js +0 -272
  166. package/dist/domain/entities/Package.js.map +0 -1
  167. package/dist/domain/entities/Workspace.d.ts +0 -95
  168. package/dist/domain/entities/Workspace.d.ts.map +0 -1
  169. package/dist/domain/entities/Workspace.js +0 -173
  170. package/dist/domain/entities/Workspace.js.map +0 -1
  171. package/dist/domain/repositories/WorkspaceRepository.d.ts +0 -41
  172. package/dist/domain/repositories/WorkspaceRepository.d.ts.map +0 -1
  173. package/dist/domain/repositories/WorkspaceRepository.js +0 -8
  174. package/dist/domain/repositories/WorkspaceRepository.js.map +0 -1
  175. package/dist/domain/value-objects/CatalogCollection.d.ts +0 -106
  176. package/dist/domain/value-objects/CatalogCollection.d.ts.map +0 -1
  177. package/dist/domain/value-objects/CatalogCollection.js +0 -230
  178. package/dist/domain/value-objects/CatalogCollection.js.map +0 -1
  179. package/dist/domain/value-objects/PackageCollection.d.ts +0 -122
  180. package/dist/domain/value-objects/PackageCollection.d.ts.map +0 -1
  181. package/dist/domain/value-objects/PackageCollection.js +0 -263
  182. package/dist/domain/value-objects/PackageCollection.js.map +0 -1
  183. package/dist/domain/value-objects/Version.d.ts +0 -141
  184. package/dist/domain/value-objects/Version.d.ts.map +0 -1
  185. package/dist/domain/value-objects/Version.js +0 -268
  186. package/dist/domain/value-objects/Version.js.map +0 -1
  187. package/dist/domain/value-objects/WorkspaceConfig.d.ts +0 -144
  188. package/dist/domain/value-objects/WorkspaceConfig.d.ts.map +0 -1
  189. package/dist/domain/value-objects/WorkspaceConfig.js +0 -357
  190. package/dist/domain/value-objects/WorkspaceConfig.js.map +0 -1
  191. package/dist/domain/value-objects/WorkspaceId.d.ts +0 -51
  192. package/dist/domain/value-objects/WorkspaceId.d.ts.map +0 -1
  193. package/dist/domain/value-objects/WorkspaceId.js +0 -104
  194. package/dist/domain/value-objects/WorkspaceId.js.map +0 -1
  195. package/dist/domain/value-objects/WorkspacePath.d.ts +0 -75
  196. package/dist/domain/value-objects/WorkspacePath.d.ts.map +0 -1
  197. package/dist/domain/value-objects/WorkspacePath.js +0 -128
  198. package/dist/domain/value-objects/WorkspacePath.js.map +0 -1
  199. package/dist/index.d.ts +0 -25
  200. package/dist/index.d.ts.map +0 -1
  201. package/dist/infrastructure/cache/Cache.d.ts +0 -161
  202. package/dist/infrastructure/cache/Cache.d.ts.map +0 -1
  203. package/dist/infrastructure/cache/Cache.js +0 -398
  204. package/dist/infrastructure/cache/Cache.js.map +0 -1
  205. package/dist/infrastructure/cache/index.d.ts +0 -6
  206. package/dist/infrastructure/cache/index.d.ts.map +0 -1
  207. package/dist/infrastructure/cache/index.js +0 -6
  208. package/dist/infrastructure/cache/index.js.map +0 -1
  209. package/dist/infrastructure/external-services/NpmRegistryService.d.ts +0 -153
  210. package/dist/infrastructure/external-services/NpmRegistryService.d.ts.map +0 -1
  211. package/dist/infrastructure/external-services/NpmRegistryService.js +0 -511
  212. package/dist/infrastructure/external-services/NpmRegistryService.js.map +0 -1
  213. package/dist/infrastructure/file-system/FileSystemService.d.ts +0 -120
  214. package/dist/infrastructure/file-system/FileSystemService.d.ts.map +0 -1
  215. package/dist/infrastructure/file-system/FileSystemService.js +0 -663
  216. package/dist/infrastructure/file-system/FileSystemService.js.map +0 -1
  217. package/dist/infrastructure/repositories/FileWorkspaceRepository.d.ts +0 -57
  218. package/dist/infrastructure/repositories/FileWorkspaceRepository.d.ts.map +0 -1
  219. package/dist/infrastructure/repositories/FileWorkspaceRepository.js +0 -179
  220. package/dist/infrastructure/repositories/FileWorkspaceRepository.js.map +0 -1
  221. package/dist/infrastructure/utils/NpmrcParser.d.ts +0 -40
  222. package/dist/infrastructure/utils/NpmrcParser.d.ts.map +0 -1
  223. package/dist/infrastructure/utils/NpmrcParser.js +0 -157
  224. package/dist/infrastructure/utils/NpmrcParser.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
+ }