pnpm-catalog-updates 0.7.18 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/bin/pcu.js +3 -1
- package/dist/index.js +10212 -6761
- package/dist/index.js.map +1 -1
- package/package.json +14 -14
- package/src/cli/commands/checkCommand.ts +62 -62
- package/src/cli/commands/initCommand.ts +90 -90
- package/src/cli/commands/securityCommand.ts +172 -172
- package/src/cli/commands/updateCommand.ts +227 -68
- package/src/cli/formatters/outputFormatter.ts +500 -280
- package/src/cli/formatters/progressBar.ts +228 -228
- package/src/cli/index.ts +407 -167
- package/src/cli/interactive/interactivePrompts.ts +100 -98
- package/src/cli/options/globalOptions.ts +143 -86
- package/src/cli/options/index.ts +1 -1
- package/src/cli/themes/colorTheme.ts +70 -70
- package/src/cli/validators/commandValidator.ts +118 -122
- package/src/cli/validators/index.ts +1 -1
- package/src/index.ts +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pnpm-catalog-updates",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "CLI application for pnpm-catalog-updates",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -25,27 +25,25 @@
|
|
|
25
25
|
"test": "vitest --run --passWithNoTests",
|
|
26
26
|
"test:watch": "vitest --watch",
|
|
27
27
|
"test:coverage": "vitest --run --coverage --passWithNoTests",
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
"format": "prettier --write src",
|
|
31
|
-
"format:check": "prettier --check src",
|
|
28
|
+
"check": "biome check src",
|
|
29
|
+
"check:fix": "biome check --write src",
|
|
32
30
|
"typecheck": "tsc --noEmit",
|
|
33
31
|
"clean": "rimraf dist bin/*.js"
|
|
34
32
|
},
|
|
35
33
|
"dependencies": {
|
|
36
|
-
"chalk": "^5.
|
|
34
|
+
"chalk": "^5.6.2",
|
|
37
35
|
"cli-table3": "^0.6.5",
|
|
38
|
-
"commander": "^14.0.
|
|
39
|
-
"fs-extra": "^11.3.
|
|
40
|
-
"glob": "^11.0
|
|
41
|
-
"inquirer": "^12.
|
|
36
|
+
"commander": "^14.0.2",
|
|
37
|
+
"fs-extra": "^11.3.3",
|
|
38
|
+
"glob": "^11.1.0",
|
|
39
|
+
"inquirer": "^12.11.1",
|
|
42
40
|
"lodash": "^4.17.21",
|
|
43
41
|
"npm-registry-fetch": "^18.0.2",
|
|
44
42
|
"ora": "^8.2.0",
|
|
45
|
-
"pacote": "^21.0.
|
|
43
|
+
"pacote": "^21.0.4",
|
|
46
44
|
"rxjs": "^7.8.2",
|
|
47
|
-
"semver": "^7.7.
|
|
48
|
-
"yaml": "^2.8.
|
|
45
|
+
"semver": "^7.7.3",
|
|
46
|
+
"yaml": "^2.8.2"
|
|
49
47
|
},
|
|
50
48
|
"devDependencies": {
|
|
51
49
|
"@types/inquirer": "catalog:",
|
|
@@ -77,5 +75,7 @@
|
|
|
77
75
|
"type": "git",
|
|
78
76
|
"url": "https://github.com/houko/pnpm-catalog-updates.git",
|
|
79
77
|
"directory": "apps/cli"
|
|
80
|
-
}
|
|
78
|
+
},
|
|
79
|
+
"peerDependencies": {},
|
|
80
|
+
"optionalDependencies": {}
|
|
81
81
|
}
|
|
@@ -5,21 +5,21 @@
|
|
|
5
5
|
* Provides detailed information about available updates.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import { CatalogUpdateService, CheckOptions } from '@pcu/core'
|
|
9
|
-
import { ConfigLoader } from '@pcu/utils'
|
|
10
|
-
import { OutputFormat, OutputFormatter } from '../formatters/outputFormatter.js'
|
|
11
|
-
import { StyledText, ThemeManager } from '../themes/colorTheme.js'
|
|
8
|
+
import type { CatalogUpdateService, CheckOptions } from '@pcu/core'
|
|
9
|
+
import { ConfigLoader } from '@pcu/utils'
|
|
10
|
+
import { type OutputFormat, OutputFormatter } from '../formatters/outputFormatter.js'
|
|
11
|
+
import { StyledText, ThemeManager } from '../themes/colorTheme.js'
|
|
12
12
|
|
|
13
13
|
export interface CheckCommandOptions {
|
|
14
|
-
workspace?: string
|
|
15
|
-
catalog?: string
|
|
16
|
-
format?: OutputFormat
|
|
17
|
-
target?: 'latest' | 'greatest' | 'minor' | 'patch' | 'newest'
|
|
18
|
-
prerelease?: boolean
|
|
19
|
-
include?: string[]
|
|
20
|
-
exclude?: string[]
|
|
21
|
-
verbose?: boolean
|
|
22
|
-
color?: boolean
|
|
14
|
+
workspace?: string
|
|
15
|
+
catalog?: string
|
|
16
|
+
format?: OutputFormat
|
|
17
|
+
target?: 'latest' | 'greatest' | 'minor' | 'patch' | 'newest'
|
|
18
|
+
prerelease?: boolean
|
|
19
|
+
include?: string[]
|
|
20
|
+
exclude?: string[]
|
|
21
|
+
verbose?: boolean
|
|
22
|
+
color?: boolean
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
export class CheckCommand {
|
|
@@ -31,34 +31,34 @@ export class CheckCommand {
|
|
|
31
31
|
async execute(options: CheckCommandOptions = {}): Promise<void> {
|
|
32
32
|
try {
|
|
33
33
|
// Initialize theme
|
|
34
|
-
ThemeManager.setTheme('default')
|
|
34
|
+
ThemeManager.setTheme('default')
|
|
35
35
|
|
|
36
36
|
if (options.verbose) {
|
|
37
|
-
console.log(StyledText.iconAnalysis('Checking for outdated catalog dependencies'))
|
|
38
|
-
console.log(StyledText.muted(`Workspace: ${options.workspace || process.cwd()}`))
|
|
37
|
+
console.log(StyledText.iconAnalysis('Checking for outdated catalog dependencies'))
|
|
38
|
+
console.log(StyledText.muted(`Workspace: ${options.workspace || process.cwd()}`))
|
|
39
39
|
|
|
40
40
|
if (options.catalog) {
|
|
41
|
-
console.log(StyledText.muted(`Catalog: ${options.catalog}`))
|
|
41
|
+
console.log(StyledText.muted(`Catalog: ${options.catalog}`))
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
if (options.target && options.target !== 'latest') {
|
|
45
|
-
console.log(StyledText.muted(`Target: ${options.target}`))
|
|
45
|
+
console.log(StyledText.muted(`Target: ${options.target}`))
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
console.log('')
|
|
48
|
+
console.log('')
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
// Load configuration file first
|
|
52
|
-
const config = ConfigLoader.loadConfig(options.workspace || process.cwd())
|
|
52
|
+
const config = ConfigLoader.loadConfig(options.workspace || process.cwd())
|
|
53
53
|
|
|
54
54
|
// Use format from CLI options first, then config file, then default
|
|
55
|
-
const effectiveFormat = options.format || config.defaults?.format || 'table'
|
|
55
|
+
const effectiveFormat = options.format || config.defaults?.format || 'table'
|
|
56
56
|
|
|
57
57
|
// Create output formatter with effective format
|
|
58
58
|
const formatter = new OutputFormatter(
|
|
59
59
|
effectiveFormat as OutputFormat,
|
|
60
60
|
options.color !== false
|
|
61
|
-
)
|
|
61
|
+
)
|
|
62
62
|
|
|
63
63
|
// Merge CLI options with configuration file settings
|
|
64
64
|
const checkOptions: CheckOptions = {
|
|
@@ -69,33 +69,33 @@ export class CheckCommand {
|
|
|
69
69
|
// CLI include/exclude options take priority over config file
|
|
70
70
|
include: options.include?.length ? options.include : config.include,
|
|
71
71
|
exclude: options.exclude?.length ? options.exclude : config.exclude,
|
|
72
|
-
}
|
|
72
|
+
}
|
|
73
73
|
|
|
74
74
|
// Execute check
|
|
75
|
-
const report = await this.catalogUpdateService.checkOutdatedDependencies(checkOptions)
|
|
75
|
+
const report = await this.catalogUpdateService.checkOutdatedDependencies(checkOptions)
|
|
76
76
|
|
|
77
77
|
// Format and display results
|
|
78
|
-
const formattedOutput = formatter.formatOutdatedReport(report)
|
|
79
|
-
console.log(formattedOutput)
|
|
78
|
+
const formattedOutput = formatter.formatOutdatedReport(report)
|
|
79
|
+
console.log(formattedOutput)
|
|
80
80
|
|
|
81
81
|
// Show summary
|
|
82
82
|
if (options.verbose || options.format === 'table') {
|
|
83
|
-
this.showSummary(report, options)
|
|
83
|
+
this.showSummary(report, options)
|
|
84
84
|
}
|
|
85
85
|
|
|
86
86
|
// Always exit with 0 since this is just a check command
|
|
87
87
|
// and finding updates is not an error condition
|
|
88
|
-
process.exit(0)
|
|
88
|
+
process.exit(0)
|
|
89
89
|
} catch (error) {
|
|
90
|
-
console.error(StyledText.iconError('Error checking dependencies:'))
|
|
91
|
-
console.error(StyledText.error(String(error)))
|
|
90
|
+
console.error(StyledText.iconError('Error checking dependencies:'))
|
|
91
|
+
console.error(StyledText.error(String(error)))
|
|
92
92
|
|
|
93
93
|
if (options.verbose && error instanceof Error) {
|
|
94
|
-
console.error(StyledText.muted('Stack trace:'))
|
|
95
|
-
console.error(StyledText.muted(error.stack || 'No stack trace available'))
|
|
94
|
+
console.error(StyledText.muted('Stack trace:'))
|
|
95
|
+
console.error(StyledText.muted(error.stack || 'No stack trace available'))
|
|
96
96
|
}
|
|
97
97
|
|
|
98
|
-
process.exit(1)
|
|
98
|
+
process.exit(1)
|
|
99
99
|
}
|
|
100
100
|
}
|
|
101
101
|
|
|
@@ -103,70 +103,70 @@ export class CheckCommand {
|
|
|
103
103
|
* Show command summary
|
|
104
104
|
*/
|
|
105
105
|
private showSummary(report: any, _options: CheckCommandOptions): void {
|
|
106
|
-
const lines: string[] = []
|
|
107
|
-
const theme = ThemeManager.getTheme()
|
|
106
|
+
const lines: string[] = []
|
|
107
|
+
const theme = ThemeManager.getTheme()
|
|
108
108
|
|
|
109
109
|
if (!report.hasUpdates) {
|
|
110
|
-
lines.push(StyledText.iconSuccess('All catalog dependencies are up to date!'))
|
|
110
|
+
lines.push(StyledText.iconSuccess('All catalog dependencies are up to date!'))
|
|
111
111
|
} else {
|
|
112
|
-
lines.push(StyledText.iconInfo('Summary:'))
|
|
113
|
-
lines.push(` • ${report.totalOutdated} outdated dependencies found`)
|
|
114
|
-
lines.push(` • ${report.catalogs.length} catalogs checked`)
|
|
112
|
+
lines.push(StyledText.iconInfo('Summary:'))
|
|
113
|
+
lines.push(` • ${report.totalOutdated} outdated dependencies found`)
|
|
114
|
+
lines.push(` • ${report.catalogs.length} catalogs checked`)
|
|
115
115
|
|
|
116
116
|
const totalPackages = report.catalogs.reduce(
|
|
117
117
|
(sum: number, cat: any) => sum + cat.totalPackages,
|
|
118
118
|
0
|
|
119
|
-
)
|
|
120
|
-
lines.push(` • ${totalPackages} total catalog entries`)
|
|
119
|
+
)
|
|
120
|
+
lines.push(` • ${totalPackages} total catalog entries`)
|
|
121
121
|
|
|
122
122
|
// Show breakdown by update type
|
|
123
|
-
const updateTypes = { major: 0, minor: 0, patch: 0 }
|
|
123
|
+
const updateTypes = { major: 0, minor: 0, patch: 0 }
|
|
124
124
|
|
|
125
125
|
for (const catalog of report.catalogs) {
|
|
126
126
|
for (const dep of catalog.outdatedDependencies) {
|
|
127
|
-
updateTypes[dep.updateType as keyof typeof updateTypes]
|
|
127
|
+
updateTypes[dep.updateType as keyof typeof updateTypes]++
|
|
128
128
|
}
|
|
129
129
|
}
|
|
130
130
|
|
|
131
131
|
if (updateTypes.major > 0) {
|
|
132
|
-
lines.push(theme.major(` • ${updateTypes.major} major updates`))
|
|
132
|
+
lines.push(theme.major(` • ${updateTypes.major} major updates`))
|
|
133
133
|
}
|
|
134
134
|
if (updateTypes.minor > 0) {
|
|
135
|
-
lines.push(theme.minor(` • ${updateTypes.minor} minor updates`))
|
|
135
|
+
lines.push(theme.minor(` • ${updateTypes.minor} minor updates`))
|
|
136
136
|
}
|
|
137
137
|
if (updateTypes.patch > 0) {
|
|
138
|
-
lines.push(theme.patch(` • ${updateTypes.patch} patch updates`))
|
|
138
|
+
lines.push(theme.patch(` • ${updateTypes.patch} patch updates`))
|
|
139
139
|
}
|
|
140
140
|
|
|
141
141
|
// Security updates
|
|
142
142
|
const securityUpdates = report.catalogs.reduce((sum: number, cat: any) => {
|
|
143
|
-
return sum + cat.outdatedDependencies.filter((dep: any) => dep.isSecurityUpdate).length
|
|
144
|
-
}, 0)
|
|
143
|
+
return sum + cat.outdatedDependencies.filter((dep: any) => dep.isSecurityUpdate).length
|
|
144
|
+
}, 0)
|
|
145
145
|
|
|
146
146
|
if (securityUpdates > 0) {
|
|
147
|
-
lines.push(StyledText.iconSecurity(`${securityUpdates} security updates`))
|
|
147
|
+
lines.push(StyledText.iconSecurity(`${securityUpdates} security updates`))
|
|
148
148
|
}
|
|
149
149
|
|
|
150
|
-
lines.push('')
|
|
151
|
-
lines.push(StyledText.iconUpdate('Run with --update to apply updates'))
|
|
150
|
+
lines.push('')
|
|
151
|
+
lines.push(StyledText.iconUpdate('Run with --update to apply updates'))
|
|
152
152
|
|
|
153
153
|
if (updateTypes.major > 0) {
|
|
154
|
-
lines.push(StyledText.iconWarning('Major updates may contain breaking changes'))
|
|
154
|
+
lines.push(StyledText.iconWarning('Major updates may contain breaking changes'))
|
|
155
155
|
}
|
|
156
156
|
}
|
|
157
157
|
|
|
158
|
-
console.log(lines.join('\n'))
|
|
158
|
+
console.log(lines.join('\n'))
|
|
159
159
|
}
|
|
160
160
|
|
|
161
161
|
/**
|
|
162
162
|
* Validate command options
|
|
163
163
|
*/
|
|
164
164
|
static validateOptions(options: CheckCommandOptions): string[] {
|
|
165
|
-
const errors: string[] = []
|
|
165
|
+
const errors: string[] = []
|
|
166
166
|
|
|
167
167
|
// Validate format
|
|
168
168
|
if (options.format && !['table', 'json', 'yaml', 'minimal'].includes(options.format)) {
|
|
169
|
-
errors.push('Invalid format. Must be one of: table, json, yaml, minimal')
|
|
169
|
+
errors.push('Invalid format. Must be one of: table, json, yaml, minimal')
|
|
170
170
|
}
|
|
171
171
|
|
|
172
172
|
// Validate target
|
|
@@ -174,19 +174,19 @@ export class CheckCommand {
|
|
|
174
174
|
options.target &&
|
|
175
175
|
!['latest', 'greatest', 'minor', 'patch', 'newest'].includes(options.target)
|
|
176
176
|
) {
|
|
177
|
-
errors.push('Invalid target. Must be one of: latest, greatest, minor, patch, newest')
|
|
177
|
+
errors.push('Invalid target. Must be one of: latest, greatest, minor, patch, newest')
|
|
178
178
|
}
|
|
179
179
|
|
|
180
180
|
// Validate include/exclude patterns
|
|
181
|
-
if (options.include
|
|
182
|
-
errors.push('Include patterns cannot be empty')
|
|
181
|
+
if (options.include?.some((pattern) => !pattern.trim())) {
|
|
182
|
+
errors.push('Include patterns cannot be empty')
|
|
183
183
|
}
|
|
184
184
|
|
|
185
|
-
if (options.exclude
|
|
186
|
-
errors.push('Exclude patterns cannot be empty')
|
|
185
|
+
if (options.exclude?.some((pattern) => !pattern.trim())) {
|
|
186
|
+
errors.push('Exclude patterns cannot be empty')
|
|
187
187
|
}
|
|
188
188
|
|
|
189
|
-
return errors
|
|
189
|
+
return errors
|
|
190
190
|
}
|
|
191
191
|
|
|
192
192
|
/**
|
|
@@ -222,6 +222,6 @@ Exit Codes:
|
|
|
222
222
|
0 All dependencies are up to date
|
|
223
223
|
1 Updates are available
|
|
224
224
|
2 Error occurred
|
|
225
|
-
|
|
225
|
+
`
|
|
226
226
|
}
|
|
227
227
|
}
|
|
@@ -5,18 +5,18 @@
|
|
|
5
5
|
* Creates a basic .pcurc.json configuration file with sensible defaults.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import { StyledText, ThemeManager } from '../themes/colorTheme.js'
|
|
8
|
+
import { existsSync, mkdirSync, writeFileSync } from 'node:fs'
|
|
9
|
+
import { dirname, join } from 'node:path'
|
|
10
|
+
import type { PackageFilterConfig } from '@pcu/utils'
|
|
11
|
+
import { StyledText, ThemeManager } from '../themes/colorTheme.js'
|
|
12
12
|
|
|
13
13
|
export interface InitCommandOptions {
|
|
14
|
-
workspace?: string
|
|
15
|
-
force?: boolean
|
|
16
|
-
verbose?: boolean
|
|
17
|
-
color?: boolean
|
|
18
|
-
createWorkspace?: boolean
|
|
19
|
-
full?: boolean
|
|
14
|
+
workspace?: string
|
|
15
|
+
force?: boolean
|
|
16
|
+
verbose?: boolean
|
|
17
|
+
color?: boolean
|
|
18
|
+
createWorkspace?: boolean
|
|
19
|
+
full?: boolean
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
export class InitCommand {
|
|
@@ -26,40 +26,40 @@ export class InitCommand {
|
|
|
26
26
|
async execute(options: InitCommandOptions = {}): Promise<void> {
|
|
27
27
|
try {
|
|
28
28
|
// Initialize theme
|
|
29
|
-
ThemeManager.setTheme('default')
|
|
29
|
+
ThemeManager.setTheme('default')
|
|
30
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')
|
|
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
35
|
|
|
36
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('')
|
|
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
41
|
}
|
|
42
42
|
|
|
43
43
|
// Check if this is a pnpm workspace
|
|
44
|
-
const hasPackageJson = existsSync(packageJsonPath)
|
|
45
|
-
const hasWorkspaceYaml = existsSync(workspaceYamlPath)
|
|
46
|
-
const isWorkspace = hasPackageJson && hasWorkspaceYaml
|
|
44
|
+
const hasPackageJson = existsSync(packageJsonPath)
|
|
45
|
+
const hasWorkspaceYaml = existsSync(workspaceYamlPath)
|
|
46
|
+
const isWorkspace = hasPackageJson && hasWorkspaceYaml
|
|
47
47
|
|
|
48
48
|
if (!isWorkspace && options.createWorkspace !== false) {
|
|
49
49
|
if (options.verbose) {
|
|
50
|
-
console.log(StyledText.iconWarning('PNPM workspace structure not detected'))
|
|
50
|
+
console.log(StyledText.iconWarning('PNPM workspace structure not detected'))
|
|
51
51
|
if (!hasPackageJson) {
|
|
52
|
-
console.log(StyledText.muted('Missing: package.json'))
|
|
52
|
+
console.log(StyledText.muted('Missing: package.json'))
|
|
53
53
|
}
|
|
54
54
|
if (!hasWorkspaceYaml) {
|
|
55
|
-
console.log(StyledText.muted('Missing: pnpm-workspace.yaml'))
|
|
55
|
+
console.log(StyledText.muted('Missing: pnpm-workspace.yaml'))
|
|
56
56
|
}
|
|
57
|
-
console.log('')
|
|
57
|
+
console.log('')
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
// Create workspace structure
|
|
61
61
|
if (options.verbose) {
|
|
62
|
-
console.log(StyledText.iconInfo('Creating PNPM workspace structure...'))
|
|
62
|
+
console.log(StyledText.iconInfo('Creating PNPM workspace structure...'))
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
await this.createWorkspaceStructure(
|
|
@@ -67,53 +67,53 @@ export class InitCommand {
|
|
|
67
67
|
hasPackageJson,
|
|
68
68
|
hasWorkspaceYaml,
|
|
69
69
|
options
|
|
70
|
-
)
|
|
70
|
+
)
|
|
71
71
|
|
|
72
72
|
if (options.verbose) {
|
|
73
|
-
console.log(StyledText.iconSuccess('PNPM workspace structure created'))
|
|
74
|
-
console.log('')
|
|
73
|
+
console.log(StyledText.iconSuccess('PNPM workspace structure created'))
|
|
74
|
+
console.log('')
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
77
|
|
|
78
78
|
// Check if config file already exists
|
|
79
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)
|
|
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
84
|
}
|
|
85
85
|
|
|
86
86
|
// Create directory if it doesn't exist
|
|
87
|
-
const configDir = dirname(configPath)
|
|
87
|
+
const configDir = dirname(configPath)
|
|
88
88
|
if (!existsSync(configDir)) {
|
|
89
|
-
mkdirSync(configDir, { recursive: true })
|
|
89
|
+
mkdirSync(configDir, { recursive: true })
|
|
90
90
|
}
|
|
91
91
|
|
|
92
92
|
// Generate basic configuration
|
|
93
|
-
const basicConfig = this.generateBasicConfig(options.full)
|
|
93
|
+
const basicConfig = this.generateBasicConfig(options.full)
|
|
94
94
|
|
|
95
95
|
// Write configuration file
|
|
96
|
-
writeFileSync(configPath, JSON.stringify(basicConfig, null, 2), 'utf-8')
|
|
96
|
+
writeFileSync(configPath, JSON.stringify(basicConfig, null, 2), 'utf-8')
|
|
97
97
|
|
|
98
98
|
// Success message
|
|
99
|
-
console.log(StyledText.iconSuccess('PCU configuration initialized successfully!'))
|
|
100
|
-
console.log(StyledText.muted(`Created: ${configPath}`))
|
|
101
|
-
console.log('')
|
|
99
|
+
console.log(StyledText.iconSuccess('PCU configuration initialized successfully!'))
|
|
100
|
+
console.log(StyledText.muted(`Created: ${configPath}`))
|
|
101
|
+
console.log('')
|
|
102
102
|
|
|
103
103
|
// Show next steps
|
|
104
|
-
this.showNextSteps(configPath)
|
|
104
|
+
this.showNextSteps(configPath)
|
|
105
105
|
|
|
106
|
-
process.exit(0)
|
|
106
|
+
process.exit(0)
|
|
107
107
|
} catch (error) {
|
|
108
|
-
console.error(StyledText.iconError('Error initializing configuration:'))
|
|
109
|
-
console.error(StyledText.error(String(error)))
|
|
108
|
+
console.error(StyledText.iconError('Error initializing configuration:'))
|
|
109
|
+
console.error(StyledText.error(String(error)))
|
|
110
110
|
|
|
111
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'))
|
|
112
|
+
console.error(StyledText.muted('Stack trace:'))
|
|
113
|
+
console.error(StyledText.muted(error.stack || 'No stack trace available'))
|
|
114
114
|
}
|
|
115
115
|
|
|
116
|
-
process.exit(1)
|
|
116
|
+
process.exit(1)
|
|
117
117
|
}
|
|
118
118
|
}
|
|
119
119
|
|
|
@@ -128,33 +128,33 @@ export class InitCommand {
|
|
|
128
128
|
): Promise<void> {
|
|
129
129
|
// Create package.json if it doesn't exist
|
|
130
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')
|
|
131
|
+
const packageJsonPath = join(workspacePath, 'package.json')
|
|
132
|
+
const packageJson = this.generateWorkspacePackageJson()
|
|
133
|
+
writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2), 'utf-8')
|
|
134
134
|
|
|
135
135
|
if (options.verbose) {
|
|
136
|
-
console.log(StyledText.muted('Created: package.json'))
|
|
136
|
+
console.log(StyledText.muted('Created: package.json'))
|
|
137
137
|
}
|
|
138
138
|
}
|
|
139
139
|
|
|
140
140
|
// Create pnpm-workspace.yaml if it doesn't exist
|
|
141
141
|
if (!hasWorkspaceYaml) {
|
|
142
|
-
const workspaceYamlPath = join(workspacePath, 'pnpm-workspace.yaml')
|
|
143
|
-
const workspaceYaml = this.generateWorkspaceYaml()
|
|
144
|
-
writeFileSync(workspaceYamlPath, workspaceYaml, 'utf-8')
|
|
142
|
+
const workspaceYamlPath = join(workspacePath, 'pnpm-workspace.yaml')
|
|
143
|
+
const workspaceYaml = this.generateWorkspaceYaml()
|
|
144
|
+
writeFileSync(workspaceYamlPath, workspaceYaml, 'utf-8')
|
|
145
145
|
|
|
146
146
|
if (options.verbose) {
|
|
147
|
-
console.log(StyledText.muted('Created: pnpm-workspace.yaml'))
|
|
147
|
+
console.log(StyledText.muted('Created: pnpm-workspace.yaml'))
|
|
148
148
|
}
|
|
149
149
|
}
|
|
150
150
|
|
|
151
151
|
// Create basic directories structure
|
|
152
|
-
const packagesDir = join(workspacePath, 'packages')
|
|
152
|
+
const packagesDir = join(workspacePath, 'packages')
|
|
153
153
|
if (!existsSync(packagesDir)) {
|
|
154
|
-
mkdirSync(packagesDir, { recursive: true })
|
|
154
|
+
mkdirSync(packagesDir, { recursive: true })
|
|
155
155
|
|
|
156
156
|
if (options.verbose) {
|
|
157
|
-
console.log(StyledText.muted('Created: packages/ directory'))
|
|
157
|
+
console.log(StyledText.muted('Created: packages/ directory'))
|
|
158
158
|
}
|
|
159
159
|
}
|
|
160
160
|
}
|
|
@@ -176,7 +176,7 @@ export class InitCommand {
|
|
|
176
176
|
devDependencies: {
|
|
177
177
|
'pnpm-catalog-updates': 'latest',
|
|
178
178
|
},
|
|
179
|
-
}
|
|
179
|
+
}
|
|
180
180
|
}
|
|
181
181
|
|
|
182
182
|
/**
|
|
@@ -216,7 +216,7 @@ catalogs:
|
|
|
216
216
|
# eslint: ^8.0.0
|
|
217
217
|
# prettier: ^3.0.0
|
|
218
218
|
# vitest: ^1.0.0
|
|
219
|
-
|
|
219
|
+
`
|
|
220
220
|
}
|
|
221
221
|
|
|
222
222
|
/**
|
|
@@ -224,7 +224,7 @@ catalogs:
|
|
|
224
224
|
*/
|
|
225
225
|
private generateBasicConfig(full?: boolean): PackageFilterConfig {
|
|
226
226
|
if (full) {
|
|
227
|
-
return this.generateFullConfig()
|
|
227
|
+
return this.generateFullConfig()
|
|
228
228
|
}
|
|
229
229
|
|
|
230
230
|
// Minimal configuration
|
|
@@ -236,7 +236,7 @@ catalogs:
|
|
|
236
236
|
},
|
|
237
237
|
exclude: [],
|
|
238
238
|
include: [],
|
|
239
|
-
}
|
|
239
|
+
}
|
|
240
240
|
}
|
|
241
241
|
|
|
242
242
|
/**
|
|
@@ -294,52 +294,52 @@ catalogs:
|
|
|
294
294
|
},
|
|
295
295
|
exclude: [],
|
|
296
296
|
include: [],
|
|
297
|
-
}
|
|
297
|
+
}
|
|
298
298
|
}
|
|
299
299
|
|
|
300
300
|
/**
|
|
301
301
|
* Show next steps to the user
|
|
302
302
|
*/
|
|
303
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'))
|
|
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
324
|
lines.push(
|
|
325
325
|
StyledText.muted(' https://github.com/your-repo/pnpm-catalog-updates#configuration')
|
|
326
|
-
)
|
|
326
|
+
)
|
|
327
327
|
|
|
328
|
-
console.log(lines.join('\n'))
|
|
328
|
+
console.log(lines.join('\n'))
|
|
329
329
|
}
|
|
330
330
|
|
|
331
331
|
/**
|
|
332
332
|
* Validate command options
|
|
333
333
|
*/
|
|
334
334
|
static validateOptions(options: InitCommandOptions): string[] {
|
|
335
|
-
const errors: string[] = []
|
|
335
|
+
const errors: string[] = []
|
|
336
336
|
|
|
337
337
|
// Validate workspace path exists if provided
|
|
338
338
|
if (options.workspace && !existsSync(options.workspace)) {
|
|
339
|
-
errors.push(`Workspace directory does not exist: ${options.workspace}`)
|
|
339
|
+
errors.push(`Workspace directory does not exist: ${options.workspace}`)
|
|
340
340
|
}
|
|
341
341
|
|
|
342
|
-
return errors
|
|
342
|
+
return errors
|
|
343
343
|
}
|
|
344
344
|
|
|
345
345
|
/**
|
|
@@ -389,6 +389,6 @@ Exit Codes:
|
|
|
389
389
|
0 Configuration initialized successfully
|
|
390
390
|
1 Configuration already exists (use --force to overwrite)
|
|
391
391
|
2 Error occurred
|
|
392
|
-
|
|
392
|
+
`
|
|
393
393
|
}
|
|
394
394
|
}
|