-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat:
@yarn-tool/fix-ws-pkgs-link
修正 node_modules 內的連結
- Loading branch information
1 parent
f642c0e
commit f1af663
Showing
14 changed files
with
602 additions
and
160 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. | ||
|
||
# dependencies | ||
/node_modules | ||
/.pnp | ||
.pnp.js | ||
|
||
# testing | ||
/coverage | ||
|
||
# next.js | ||
/.next/ | ||
/out/ | ||
|
||
# production | ||
/build | ||
|
||
# misc | ||
.DS_Store | ||
*.pem | ||
|
||
# debug | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
|
||
# local env files | ||
.env.local | ||
.env.development.local | ||
.env.test.local | ||
.env.production.local | ||
|
||
# vercel | ||
.vercel | ||
|
||
/.*/ | ||
.idea | ||
node_modules | ||
~ci.list.txt | ||
~ci.log.txt | ||
~ci.errors.txt | ||
*.stackdump | ||
*.bak | ||
*.old | ||
package-lock.json | ||
test/**/*.js | ||
test/**/*.d.ts | ||
test/*.js | ||
test/*.d.ts | ||
test/temp* | ||
test/**/*.map | ||
tests/**/*.js | ||
tests/**/*.d.ts | ||
tests/*.js | ||
tests/*.d.ts | ||
tests/temp* | ||
tests/**/*.map | ||
bin/*.d.ts | ||
bin/**/*.d.ts | ||
/packages/*/bin/*.d.ts | ||
/packages/*/test/**/*.js | ||
/packages/*/test/**/*.d.ts | ||
/packages/*/test/*.js | ||
/packages/*/test/*.d.ts | ||
/packages/*/test/temp* | ||
/packages/*/tests/**/*.js | ||
/packages/*/tests/**/*.d.ts | ||
/packages/*/tests/*.js | ||
/packages/*/tests/*.d.ts | ||
/packages/*/tests/temp* | ||
**/node_modules | ||
*.tgz | ||
/tsconfig.json.tpl | ||
/.eslintrc.json.tpl | ||
!tsconfig.json | ||
!.eslintrc.json | ||
yarn-error.log | ||
*.log | ||
.git | ||
yarn.lock | ||
.env.local | ||
.env.*.local | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
.vscode | ||
*.suo | ||
*.ntvs* | ||
*.njsproj | ||
*.sln | ||
*.sw? | ||
*.vue.js | ||
*.vue.d.ts | ||
*.vue.js.map | ||
vue.config.d.ts | ||
vue.config.js.map | ||
.nyc_output | ||
coverage | ||
/*.tpl | ||
!.forestry | ||
!.vuepress | ||
!.github | ||
!.gitee | ||
!.gitlab | ||
.git | ||
|
||
*.tsbuildinfo | ||
tsconfig.esm.json.tpl | ||
|
||
.browserslistrc | ||
.nvmrc | ||
|
||
/.eslintignore | ||
/package.d.ts | ||
.nycrc | ||
.mocharc.yml | ||
#jest.config.js | ||
node_modules/.cache | ||
.yarn-integrity | ||
jest.config.d.ts | ||
jest.config.js.map | ||
/report.*.json | ||
*.js.map | ||
/now.json | ||
.nyc_output | ||
.coverage-cache | ||
.reify-cache | ||
*.spec.d.ts | ||
*.spec.js | ||
.nowignore | ||
*/**/.github | ||
!/.github | ||
!npm-shrinkwrap.json | ||
*.stat | ||
.vercel | ||
/test/tsconfig.json.tpl | ||
/tsconfig.json.tpl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
/.pnp | ||
.pnp.js | ||
.idea | ||
~ci.list.txt | ||
~ci.log.txt | ||
~ci.errors.txt | ||
*.stackdump | ||
*.bak | ||
*.old | ||
*.log | ||
tsconfig.json | ||
package-lock.json | ||
test | ||
.github | ||
.gitkeep | ||
/.*/ | ||
/.* | ||
tests | ||
/~* | ||
__test__ | ||
__tests__ | ||
node_modules | ||
/node_modules/ | ||
**/node_modules/ | ||
*.ts | ||
!*.d.ts | ||
/bin/**/*.d.ts | ||
/bin/*.d.ts | ||
*.tgz | ||
/tsconfig.json.tpl | ||
yarn-error.log | ||
.git | ||
yarn.lock | ||
.env.local | ||
.env.*.local | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
.vscode | ||
*.suo | ||
*.ntvs* | ||
*.njsproj | ||
*.sln | ||
*.sw? | ||
*.vue.js | ||
*.vue.d.ts | ||
*.vue.js.map | ||
.nyc_output | ||
coverage | ||
/*.tpl | ||
webpack.config.js | ||
vue.config.js | ||
/jestconfig.json | ||
/tslint.json | ||
.git | ||
webpack.*.config.js | ||
webpack.*.config.d.ts | ||
webpack.*.config.js.map | ||
webpack.*.config.ts | ||
karma.conf.js | ||
/_config.yml | ||
intellij-style-guide.xml | ||
jest.config.js | ||
*.tsbuildinfo | ||
tsconfig.*.json | ||
tsconfig.esm.json.tpl | ||
/package.d.ts | ||
.mocharc.yml | ||
jest.config.js | ||
jest.config.* | ||
/report.*.json | ||
now.json | ||
/Makefile | ||
*.spec.d.ts | ||
*.spec.js | ||
*.spec.ts | ||
*.spec.tsx | ||
__mocks__ | ||
__tests__ | ||
__snapshots__ | ||
*.snap | ||
npm-shrinkwrap.json | ||
/example/ | ||
*.stat | ||
.vercel | ||
tsdx.config.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# README.md | ||
|
||
|
||
|
||
## install | ||
|
||
```bash | ||
yarn add @yarn-tool/fix-ws-pkgs-link | ||
yarn-tool add @yarn-tool/fix-ws-pkgs-link | ||
yt add @yarn-tool/fix-ws-pkgs-link | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export declare function fixWorkspacesPackageLinks(cwd?: string): import("ws-pkg-list").IListableRow[]; | ||
export default fixWorkspacesPackageLinks; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { wsPkgListable } from 'ws-pkg-list/lib/listable'; | ||
import { findRootLazy } from '@yarn-tool/find-root'; | ||
import { getModulesDir } from '@yarn-tool/node-modules/lib/util'; | ||
import { ensureSymlinkSync, lstatSync, pathExists, pathExistsSync, realpathSync, unlinkSync, renameSync } from 'fs-extra'; | ||
import { join } from 'path'; | ||
import { fsSameRealpath } from 'path-is-same'; | ||
import { isSymbolicLinkSync } from 'fs-stat'; | ||
|
||
export function fixWorkspacesPackageLinks(cwd?: string) | ||
{ | ||
const rootData = findRootLazy({ | ||
cwd, | ||
}); | ||
|
||
const node_modules = getModulesDir(rootData.root); | ||
|
||
const listable = wsPkgListable(rootData.root); | ||
|
||
return listable.filter((entry) => { | ||
|
||
let target = join(node_modules, entry.name); | ||
|
||
if (!isSymbolicLinkSync(target) && !fsSameRealpath(target, entry.location)) | ||
{ | ||
if (pathExistsSync(target)) | ||
{ | ||
renameSync(target, target + '.old_' + Math.random()) | ||
} | ||
|
||
ensureSymlinkSync(entry.location, target); | ||
|
||
return true | ||
} | ||
}) | ||
} | ||
|
||
export default fixWorkspacesPackageLinks |
Oops, something went wrong.