19 changed files with 41 additions and 140 deletions
@ -1,48 +0,0 @@ |
|||||
import fs from 'node:fs'; |
|
||||
import { dirname, extname, resolve } from 'node:path'; |
|
||||
|
|
||||
import { findUpSync } from 'find-up'; |
|
||||
|
|
||||
/** |
|
||||
* 查找 package.json 文件所在的目录 |
|
||||
* @param pathname |
|
||||
*/ |
|
||||
function findUpPackageDir(pathname: string = '') { |
|
||||
const file = findUpSync('package.json', { |
|
||||
cwd: dirname(pathname), |
|
||||
type: 'file', |
|
||||
}); |
|
||||
return dirname(file || ''); |
|
||||
} |
|
||||
|
|
||||
/** |
|
||||
* 根据给定的扩展名数组来查找文件是否存在,并返回对应文件路径 |
|
||||
* @param pathname 文件路径 |
|
||||
* @param extensions 扩展名数组 |
|
||||
* @returns 对应文件路径,如果未找到则返回 null |
|
||||
*/ |
|
||||
function findFileByExtension( |
|
||||
pathname: string = '', |
|
||||
extensions: string[] = ['.ts'], |
|
||||
): string { |
|
||||
if (extname(pathname)) { |
|
||||
return pathname; |
|
||||
} |
|
||||
|
|
||||
for (const ext of extensions) { |
|
||||
const fullpath = resolve(pathname); |
|
||||
if (fs.existsSync(fullpath + ext) && fs.statSync(fullpath + ext).isFile()) { |
|
||||
return fullpath + ext; |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
for (const ext of extensions) { |
|
||||
const resultPath = resolve(pathname, `index${ext}`); |
|
||||
if (fs.existsSync(resultPath)) { |
|
||||
return resultPath; |
|
||||
} |
|
||||
} |
|
||||
return pathname; |
|
||||
} |
|
||||
|
|
||||
export { findFileByExtension, findUpPackageDir }; |
|
||||
@ -1,28 +0,0 @@ |
|||||
// #!/bin/bash |
|
||||
|
|
||||
// #/ Usage: script/update-dependencies |
|
||||
// #/ Create a branch to update a dependency. |
|
||||
|
|
||||
// # Delete update-dependencies branch if it exists |
|
||||
// if git branch | grep -q "update-dependencies"; then |
|
||||
// echo "Deleting update-dependencies branch 🗑" |
|
||||
// git branch -D update-dependencies |
|
||||
// echo "Branch deleted 🎉" |
|
||||
// fi |
|
||||
|
|
||||
// # Create update-dependencies branch |
|
||||
// echo "Creating update-dependencies branch 🌱" |
|
||||
// git checkout -b update-dependencies |
|
||||
// echo "Branch created 🎉" |
|
||||
|
|
||||
// # Update dependencies in package.json |
|
||||
// echo "Updating dependencies in package.json 📦" |
|
||||
// pnpm update --interactive --recursive --latest |
|
||||
// # Clean up pnpm-lock.yaml file and install dependencies |
|
||||
// script/clean && pnpm install |
|
||||
// # Git operations |
|
||||
// git add -A |
|
||||
// git commit -am "chore: update dependencies 📦" |
|
||||
// git push origin update-dependencies |
|
||||
// gh pr create --fill |
|
||||
// echo "Dependencies updated 🎉" |
|
||||
Loading…
Reference in new issue