|
1 | | -import * as fs from 'node:fs/promises' |
2 | 1 | import * as path from 'node:path' |
3 | 2 | import * as core from '@actions/core' |
4 | 3 | import * as exec from '@actions/exec' |
5 | 4 | import * as github from '@actions/github' |
6 | | -import { updateWorkspaceManifest } from '@pnpm/workspace.manifest-writer' |
7 | | -import { readWorkspaceManifest } from '@pnpm/workspace.read-manifest' |
8 | 5 | import { GitHelper, GithubHelper } from '@workflows/utils' |
9 | 6 |
|
10 | 7 | function getBranchName(deps: Array<{ name: string, version: string }>): string { |
@@ -44,86 +41,6 @@ interface DependencyInfo { |
44 | 41 | version: string |
45 | 42 | } |
46 | 43 |
|
47 | | -function getUpdatedVersion(currentVersion: string, newVersion: string): string { |
48 | | - const prefix = currentVersion[0] |
49 | | - if (prefix && (prefix === '^' || prefix === '~')) { |
50 | | - return `${prefix}${newVersion}` |
51 | | - } |
52 | | - return newVersion |
53 | | -} |
54 | | - |
55 | | -// async function updatePnpmCatalog(deps: DependencyInfo[], repo: string, targetDir: string): Promise<void> { |
56 | | -// let repoPath = repo |
57 | | -// if (targetDir) { |
58 | | -// repoPath = path.join(repo, targetDir) |
59 | | -// } |
60 | | -// const workspaceFile = path.join(repoPath, 'pnpm-workspace.yaml') |
61 | | -// core.info(`Looking for pnpm-workspace.yaml at: ${workspaceFile}`) |
62 | | - |
63 | | -// let manifestContent: string |
64 | | -// try { |
65 | | -// manifestContent = await fs.readFile(workspaceFile, 'utf-8') |
66 | | -// core.info(`Successfully read pnpm-workspace.yaml (${manifestContent.length} bytes)`) |
67 | | -// } |
68 | | -// catch (error) { |
69 | | -// core.info(`pnpm-workspace.yaml not found in ${repoPath}, skipping catalog update`) |
70 | | -// core.info(`Error: ${error}`) |
71 | | -// return |
72 | | -// } |
73 | | - |
74 | | -// const manifest = await readWorkspaceManifest(manifestContent) |
75 | | -// if (!manifest) { |
76 | | -// core.info(`Failed to read pnpm-workspace.yaml, skipping catalog update`) |
77 | | -// core.info(`File content preview: ${manifestContent.substring(0, 200)}...`) |
78 | | -// return |
79 | | -// } |
80 | | -// core.info(`Successfully parsed pnpm-workspace.yaml`) |
81 | | -// if (manifest.catalog) { |
82 | | -// core.info(`Found default catalog with ${Object.keys(manifest.catalog).length} entries`) |
83 | | -// } |
84 | | -// if (manifest.catalogs) { |
85 | | -// core.info(`Found ${Object.keys(manifest.catalogs).length} named catalogs: ${Object.keys(manifest.catalogs).join(', ')}`) |
86 | | -// } |
87 | | - |
88 | | -// const updatedCatalogs: Record<string, Record<string, string>> = {} |
89 | | - |
90 | | -// if (manifest.catalog) { |
91 | | -// const defaultCatalogUpdates: Record<string, string> = {} |
92 | | -// for (const dep of deps) { |
93 | | -// if (dep.name in manifest.catalog) { |
94 | | -// defaultCatalogUpdates[dep.name] = getUpdatedVersion(manifest.catalog[dep.name] as string, dep.version) |
95 | | -// } |
96 | | -// } |
97 | | -// if (Object.keys(defaultCatalogUpdates).length > 0) { |
98 | | -// updatedCatalogs[''] = defaultCatalogUpdates |
99 | | -// } |
100 | | -// } |
101 | | - |
102 | | -// if (manifest.catalogs) { |
103 | | -// for (const [catalogName, catalog] of Object.entries(manifest.catalogs)) { |
104 | | -// const catalogUpdates: Record<string, string> = {} |
105 | | -// const typedCatalog = catalog as Record<string, string> |
106 | | -// for (const dep of deps) { |
107 | | -// if (dep.name in typedCatalog) { |
108 | | -// catalogUpdates[dep.name] = getUpdatedVersion(typedCatalog[dep.name], dep.version) |
109 | | -// } |
110 | | -// } |
111 | | -// if (Object.keys(catalogUpdates).length > 0) { |
112 | | -// updatedCatalogs[catalogName] = catalogUpdates |
113 | | -// } |
114 | | -// } |
115 | | -// } |
116 | | - |
117 | | -// const hasUpdates = Object.keys(updatedCatalogs).length > 0 |
118 | | -// if (!hasUpdates) { |
119 | | -// core.info(`No matching dependencies found in catalog, skipping update`) |
120 | | -// return |
121 | | -// } |
122 | | - |
123 | | -// await updateWorkspaceManifest(workspaceFile, { updatedCatalogs }) |
124 | | -// core.info(`Updated pnpm catalog in pnpm-workspace.yaml`) |
125 | | -// } |
126 | | - |
127 | 44 | async function getPkgLatestVersion(pkgNames: string[]): Promise<DependencyInfo[]> { |
128 | 45 | const results: DependencyInfo[] = [] |
129 | 46 | for (const pkg of pkgNames) { |
|
0 commit comments