mirror of
https://github.com/pnpm/pnpm.git
synced 2026-04-11 10:40:53 -04:00
Major cleanup of the config system after migrating settings from `.npmrc` to `pnpm-workspace.yaml`.
### Config reader simplification
- Remove `checkUnknownSetting` (dead code, always `false`)
- Trim `npmConfigTypes` from ~127 to ~67 keys (remove unused npm config keys)
- Replace `rcOptions` iteration over all type keys with direct construction from defaults + auth overlay
- Remove `rcOptionsTypes` parameter from `getConfig()` and its assembly chain
### Rename `rawConfig` to `authConfig`
- `rawConfig` was a confusing mix of auth data and general settings
- Non-auth settings are already on the typed `Config` object — stop duplicating them in `rawConfig`
- Rename `rawConfig` → `authConfig` across the codebase to clarify it only contains auth/registry data from `.npmrc`
### Remove `rawConfig` from non-auth consumers
- **Lifecycle hooks**: replace `rawConfig: object` with `userAgent?: string` — only user-agent was read
- **Fetchers**: remove unused `rawConfig` from git fetcher, binary fetcher, tarball fetcher, prepare-package
- **Update command**: use `opts.production/dev/optional` instead of `rawConfig.*`
- **`pnpm init`**: accept typed init properties instead of parsing `rawConfig`
### Add `nodeDownloadMirrors` setting
- New `nodeDownloadMirrors?: Record<string, string>` on `PnpmSettings` and `Config`
- Replaces the `node-mirror:<channel>` pattern that was stored in `rawConfig`
- Configured in `pnpm-workspace.yaml`:
```yaml
nodeDownloadMirrors:
release: https://my-mirror.example.com/download/release/
```
- Remove unused `rawConfig` from deno-resolver and bun-resolver
### Refactor `pnpm config get/list`
- New `configToRecord()` builds display data from typed Config properties on the fly
- Excludes sensitive internals (`authInfos`, `sslConfigs`, etc.)
- Non-types keys (e.g., `package-extensions`) resolve through `configToRecord` instead of direct property access
- Delete `processConfig.ts` (replaced by `configToRecord.ts`)
### Pre-push hook improvement
- Add `compile-only` (`tsgo --build`) to pre-push hook to catch type errors before push
80 lines
2.2 KiB
TypeScript
80 lines
2.2 KiB
TypeScript
import path from 'node:path'
|
|
|
|
import type { HeadlessOptions } from '@pnpm/installing.deps-restorer'
|
|
import { readProjectsContext } from '@pnpm/installing.read-projects-context'
|
|
import { safeReadPackageJsonFromDir } from '@pnpm/pkg-manifest.reader'
|
|
import { REGISTRY_MOCK_PORT } from '@pnpm/registry-mock'
|
|
import { getStorePath } from '@pnpm/store.path'
|
|
import { createTempStore } from '@pnpm/testing.temp-store'
|
|
import { temporaryDirectory } from 'tempy'
|
|
|
|
const registry = `http://localhost:${REGISTRY_MOCK_PORT}/`
|
|
|
|
export async function testDefaults (
|
|
opts?: any, // eslint-disable-line
|
|
resolveOpts?: any, // eslint-disable-line
|
|
fetchOpts?: any, // eslint-disable-line
|
|
storeOpts?: any, // eslint-disable-line
|
|
): Promise<HeadlessOptions> {
|
|
const tmp = temporaryDirectory()
|
|
let storeDir = opts?.storeDir ?? path.join(tmp, 'store')
|
|
const lockfileDir = opts?.lockfileDir ?? process.cwd()
|
|
const { include, pendingBuilds, projects } = await readProjectsContext(
|
|
opts.projects
|
|
? opts.projects.map((rootDir: string) => ({ rootDir }))
|
|
: [
|
|
{
|
|
rootDir: lockfileDir,
|
|
},
|
|
],
|
|
{ lockfileDir }
|
|
)
|
|
storeDir = await getStorePath({
|
|
pkgRoot: lockfileDir,
|
|
storePath: storeDir,
|
|
pnpmHomeDir: '',
|
|
})
|
|
const { storeController } = createTempStore(
|
|
{
|
|
storeDir,
|
|
clientOptions: {
|
|
...resolveOpts,
|
|
...fetchOpts,
|
|
},
|
|
storeOptions: storeOpts,
|
|
}
|
|
)
|
|
return {
|
|
currentEngine: {
|
|
nodeVersion: process.version,
|
|
pnpmVersion: '2.0.0',
|
|
},
|
|
engineStrict: false,
|
|
force: false,
|
|
hoistedDependencies: {},
|
|
hoistPattern: ['*'],
|
|
include,
|
|
lockfileDir,
|
|
packageManager: {
|
|
name: 'pnpm',
|
|
version: '1.0.0',
|
|
},
|
|
pendingBuilds,
|
|
selectedProjectDirs: opts.selectedProjectDirs ?? projects.map((project) => project.rootDir),
|
|
allProjects: Object.fromEntries(
|
|
await Promise.all(projects.map(async (project) => [project.rootDir, { ...project, manifest: await safeReadPackageJsonFromDir(project.rootDir) }]))
|
|
),
|
|
authConfig: {},
|
|
registries: {
|
|
default: registry,
|
|
},
|
|
sideEffectsCache: true,
|
|
skipped: new Set<string>(),
|
|
storeController,
|
|
storeDir,
|
|
unsafePerm: true,
|
|
verifyStoreIntegrity: true,
|
|
...opts,
|
|
}
|
|
}
|