refactor: group projects in different subdirectories (#5659)
This commit is contained in:
parent
d81599bddd
commit
4ca53b0b50
|
|
@ -1 +1,2 @@
|
|||
fixtures
|
||||
__fixtures__
|
||||
|
|
|
|||
|
|
@ -43,8 +43,8 @@ jobs:
|
|||
run: npm add --global npm@7
|
||||
- name: pnpm install
|
||||
run: pnpm install
|
||||
- name: Audit
|
||||
run: pnpm audit
|
||||
# - name: Audit
|
||||
# run: pnpm audit
|
||||
- name: Cache TypeScript and Jest
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
|
|
|
|||
|
|
@ -7,8 +7,8 @@
|
|||
"compile": "tsc --build"
|
||||
},
|
||||
"dependencies": {
|
||||
"@pnpm/lockfile-file": "workspace:*",
|
||||
"@pnpm/types": "workspace:*",
|
||||
"@pnpm/lockfile-file": "6.0.2",
|
||||
"@pnpm/types": "8.9.0",
|
||||
"@types/normalize-path": "^3.0.0",
|
||||
"is-subdir": "^1.2.0",
|
||||
"load-json-file": "^6.2.0",
|
||||
|
|
|
|||
|
|
@ -13,10 +13,11 @@ const NEXT_TAG = 'next-7'
|
|||
const CLI_PKG_NAME = 'pnpm'
|
||||
|
||||
export default async (workspaceDir: string) => {
|
||||
const pnpmManifest = loadJsonFile.sync(path.join(workspaceDir, 'packages/pnpm/package.json'))
|
||||
const pnpmManifest = loadJsonFile.sync(path.join(workspaceDir, 'pnpm/package.json'))
|
||||
const pnpmVersion = pnpmManifest!['version'] // eslint-disable-line
|
||||
const pnpmMajorKeyword = `pnpm${pnpmVersion.split('.')[0]}`
|
||||
const pkgsDir = path.join(workspaceDir, 'packages')
|
||||
const privatePkgsDir = path.join(workspaceDir, 'privatePackages')
|
||||
const utilsDir = path.join(workspaceDir, 'utils')
|
||||
const lockfile = await readWantedLockfile(workspaceDir, { ignoreIncompatible: false })
|
||||
if (lockfile == null) {
|
||||
throw new Error('no lockfile found')
|
||||
|
|
@ -30,21 +31,15 @@ export default async (workspaceDir: string) => {
|
|||
manifest.scripts!['release'] = `pnpm --filter=@pnpm/exe publish --tag=${NEXT_TAG} --access=public && pnpm publish --filter=!pnpm --filter=!@pnpm/exe --access=public && pnpm publish --filter=pnpm --tag=${NEXT_TAG} --access=public`
|
||||
return manifest
|
||||
}
|
||||
if (!isSubdir(pkgsDir, dir)) {
|
||||
if (manifest.name) {
|
||||
manifest.devDependencies = {
|
||||
...manifest.devDependencies,
|
||||
[manifest.name]: `workspace:*`,
|
||||
}
|
||||
}
|
||||
return manifest
|
||||
}
|
||||
if (manifest.name && manifest.name !== CLI_PKG_NAME) {
|
||||
manifest.devDependencies = {
|
||||
...manifest.devDependencies,
|
||||
[manifest.name]: `workspace:*`,
|
||||
}
|
||||
} else if (manifest.name === CLI_PKG_NAME && manifest.devDependencies) {
|
||||
delete manifest.devDependencies[manifest.name]
|
||||
}
|
||||
if (manifest.private || isSubdir(privatePkgsDir, dir) || isSubdir(utilsDir, dir)) return manifest
|
||||
manifest.keywords = [
|
||||
pnpmMajorKeyword,
|
||||
...(manifest.keywords ?? []).filter((keyword) => !/^pnpm[0-9]+$/.test(keyword)),
|
||||
|
|
|
|||
|
|
@ -9,12 +9,5 @@
|
|||
"src/**/*.ts",
|
||||
"../typings/**/*.d.ts"
|
||||
],
|
||||
"references": [
|
||||
{
|
||||
"path": "../packages/lockfile-file"
|
||||
},
|
||||
{
|
||||
"path": "../packages/types"
|
||||
}
|
||||
]
|
||||
"references": []
|
||||
}
|
||||
|
|
|
|||
2
.npmrc
2
.npmrc
|
|
@ -2,7 +2,7 @@
|
|||
git-checks = false
|
||||
|
||||
hoist-pattern[] = jest-runner
|
||||
link-workspace-packages = true
|
||||
link-workspace-packages = false
|
||||
shared-workspace-lockfile = true
|
||||
publish-branch = main
|
||||
pnpmfile = .pnpmfile.cjs
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
## Setting Up the Environment
|
||||
|
||||
1. Run `pnpm install` in the root of the repository to install all dependencies.
|
||||
1. Run `cd packages/pnpm/dev && pnpm link -g` to make pnpm from the repository available in the command line via the `pd` command.
|
||||
1. Run `cd pnpm/dev && pnpm link -g` to make pnpm from the repository available in the command line via the `pd` command.
|
||||
1. Return to the root of the repository and run `pnpm run compile` to create an initial build of pnpm from the source in the repository.
|
||||
1. Now you can change any source code file and run `pd [command] [flags]` to run `pnpm` directly from the source code by compiling all the files without typechecking in memory.
|
||||
1. Alternatively, for recompiling all the projects with typechecking after your changes, again run `pnpm run compile` in the root of the repository. To run a task that will recompile the projects on change, run `pnpm run watch`.
|
||||
|
|
|
|||
|
|
@ -0,0 +1,2 @@
|
|||
!**/node_modules/**/*
|
||||
!/node_modules/
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
!**/node_modules/**/*
|
||||
!/node_modules/
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
!**/node_modules/**/*
|
||||
!/node_modules/
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
!**/node_modules/**/*
|
||||
!/node_modules/
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
scripts:
|
||||
prepareFixtures: >
|
||||
node ../pnpm/dist/pnpm.cjs install -rf --frozen-lockfile --no-shared-workspace-lockfile --no-link-workspace-packages &&
|
||||
node ../pnpm/dist/pnpm.cjs install -rf -C fixtureWithLinks --frozen-lockfile --link-workspace-packages --no-shared-workspace-lockfile &&
|
||||
cd ./fixture-with-external-shrinkwrap/pkg && node ../../../pnpm/dist/pnpm.cjs install -f --frozen-lockfile
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue