Skip to content

Commit 7f52532

Browse files
committed
refactor: 移除未使用的pnpm工作区相关依赖
1 parent bf0de4e commit 7f52532

6 files changed

Lines changed: 58 additions & 10290 deletions

File tree

packages/upgrade-deps/dist/index.mjs

Lines changed: 55 additions & 10008 deletions
Large diffs are not rendered by default.

packages/upgrade-deps/main.ts

Lines changed: 0 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
1-
import * as fs from 'node:fs/promises'
21
import * as path from 'node:path'
32
import * as core from '@actions/core'
43
import * as exec from '@actions/exec'
54
import * as github from '@actions/github'
6-
import { updateWorkspaceManifest } from '@pnpm/workspace.manifest-writer'
7-
import { readWorkspaceManifest } from '@pnpm/workspace.read-manifest'
85
import { GitHelper, GithubHelper } from '@workflows/utils'
96

107
function getBranchName(deps: Array<{ name: string, version: string }>): string {
@@ -44,86 +41,6 @@ interface DependencyInfo {
4441
version: string
4542
}
4643

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-
12744
async function getPkgLatestVersion(pkgNames: string[]): Promise<DependencyInfo[]> {
12845
const results: DependencyInfo[] = []
12946
for (const pkg of pkgNames) {

packages/upgrade-deps/package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
"@actions/core": "catalog:",
1111
"@actions/exec": "catalog:",
1212
"@actions/github": "catalog:",
13-
"@pnpm/workspace.manifest-writer": "catalog:",
14-
"@pnpm/workspace.read-manifest": "catalog:",
1513
"@workflows/utils": "workspace:*"
1614
},
1715
"devDependencies": {

packages/upgrade-deps/tsdown.config.ts

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@ export default defineConfig({
88
'@actions/core',
99
'@actions/exec',
1010
'@actions/github',
11-
'@workflows/utils',
12-
'@pnpm/workspace.manifest-writer',
13-
'@pnpm/workspace.read-manifest',
11+
'@workflows/utils'
1412
],
1513
onlyBundle: [
1614
'@actions/core',
@@ -26,28 +24,11 @@ export default defineConfig({
2624
'@octokit/plugin-rest-endpoint-methods',
2725
'@octokit/request',
2826
'@octokit/request-error',
29-
'@pnpm/constants',
30-
'@pnpm/error',
31-
'@pnpm/object.key-sorting',
32-
'@pnpm/ramda',
33-
'@pnpm/util.lex-comparator',
34-
'@pnpm/workspace.manifest-writer',
35-
'@pnpm/workspace.read-manifest',
36-
'@pnpm/yaml.document-sync',
3727
'before-after-hook',
3828
'fast-content-type-parse',
39-
'imurmurhash',
40-
'is-plain-obj',
41-
'js-yaml',
42-
'read-yaml-file',
43-
'signal-exit',
44-
'sort-keys',
45-
'strip-bom',
4629
'tunnel',
4730
'undici',
4831
'universal-user-agent',
49-
'write-file-atomic',
50-
'yaml',
5132
],
5233
},
5334
})

0 commit comments

Comments
 (0)