refactor: rootProjectManifestDir is a required option

This commit is contained in:
Zoltan Kochan
2023-10-24 15:14:33 +03:00
parent d2dc2e66ab
commit d6592964f0
27 changed files with 51 additions and 5 deletions

View File

@@ -0,0 +1,5 @@
---
"@pnpm/plugin-commands-installation": patch
---
`pnpm fetch` read settings from root project manifest.

View File

@@ -0,0 +1,14 @@
---
"@pnpm/plugin-commands-installation": major
"@pnpm/plugin-commands-script-runners": major
"@pnpm/plugin-commands-licenses": major
"@pnpm/plugin-commands-outdated": major
"@pnpm/plugin-commands-patching": major
"@pnpm/plugin-commands-listing": major
"@pnpm/plugin-commands-deploy": major
"@pnpm/plugin-commands-audit": major
"@pnpm/plugin-commands-rebuild": major
"@pnpm/config": minor
---
`rootProjectManifestDir` is a required field.

View File

@@ -169,7 +169,7 @@ export interface Config {
testPattern?: string[]
changedFilesIgnorePattern?: string[]
rootProjectManifestDir?: string
rootProjectManifestDir: string
rootProjectManifest?: ProjectManifest
userConfig: Record<string, string>
}

View File

@@ -101,7 +101,7 @@ export async function extendRebuildOptions (
...defaultOpts,
...opts,
storeDir: defaultOpts.storeDir,
...(opts.rootProjectManifest ? getOptionsFromRootManifest(opts.rootProjectManifestDir!, opts.rootProjectManifest) : {}),
...(opts.rootProjectManifest ? getOptionsFromRootManifest(opts.rootProjectManifestDir, opts.rootProjectManifest) : {}),
}
extendedOpts.registries = normalizeRegistries(extendedOpts.registries)
return extendedOpts

View File

@@ -79,6 +79,8 @@ export async function handler (
| 'lockfileDir'
| 'nodeLinker'
| 'rawLocalConfig'
| 'rootProjectManifest'
| 'rootProjectManifestDir'
| 'registries'
| 'scriptShell'
| 'selectedProjectsGraph'

View File

@@ -25,6 +25,8 @@ type RecursiveRebuildOpts = CreateStoreControllerOptions & Pick<Config,
| 'nodeLinker'
| 'rawLocalConfig'
| 'registries'
| 'rootProjectManifest'
| 'rootProjectManifestDir'
| 'sharedWorkspaceLockfile'
> & {
pending?: boolean

View File

@@ -38,6 +38,7 @@ export const DEFAULT_OPTS = {
rawLocalConfig: {},
registries: { default: REGISTRY },
registry: REGISTRY,
rootProjectManifestDir: '',
sort: true,
storeDir: '../store',
strictSsl: false,

View File

@@ -90,10 +90,11 @@ export async function handler (
await add.handler({
// Ideally the config reader should ignore these settings when the dlx command is executed.
// This is a temporary solution until "@pnpm/config" is refactored.
...omit(['workspaceDir', 'rootProjectManifest', 'rootProjectManifestDir'], opts),
...omit(['workspaceDir', 'rootProjectManifest'], opts),
bin: binsDir,
dir: prefix,
lockfileDir: prefix,
rootProjectManifestDir: prefix, // This property won't be used as rootProjectManifest will be undefined
}, pkgs)
const binName = opts.package
? command

View File

@@ -40,6 +40,7 @@ export const DEFAULT_OPTS = {
proxy: undefined,
rawConfig: { registry: REGISTRY_URL },
rawLocalConfig: {},
rootProjectManifestDir: '',
registries: { default: REGISTRY_URL },
registry: REGISTRY_URL,
sort: true,
@@ -74,6 +75,7 @@ export const DLX_DEFAULT_OPTS = {
registries: {
default: REGISTRY_URL,
},
rootProjectManifestDir: '',
sort: true,
storeDir: path.join(tmp, 'store'),
userConfig: {},

View File

@@ -50,6 +50,7 @@ export const DEFAULT_OPTS = {
rawConfig,
rawLocalConfig: {},
registries,
rootProjectManifestDir: '',
// registry: REGISTRY,
sort: true,
storeDir: '../store',

View File

@@ -39,6 +39,7 @@ export const DEFAULT_OPTS = {
rawLocalConfig: {},
registries: { default: REGISTRY },
registry: REGISTRY,
rootProjectManifestDir: '',
sort: true,
storeDir: '../store',
strictSsl: false,

View File

@@ -1,6 +1,6 @@
import { docsUrl } from '@pnpm/cli-utils'
import { UNIVERSAL_OPTIONS } from '@pnpm/common-cli-options-help'
import { type Config } from '@pnpm/config'
import { type Config, getOptionsFromRootManifest } from '@pnpm/config'
import { createOrConnectStoreController, type CreateStoreControllerOptions } from '@pnpm/store-connection-manager'
import { type InstallOptions, mutateModulesInSingleProject } from '@pnpm/core'
import renderHelp from 'render-help'
@@ -45,7 +45,7 @@ export function help () {
}
export async function handler (
opts: Pick<Config, 'production' | 'dev'> & CreateStoreControllerOptions
opts: Pick<Config, 'production' | 'dev' | 'rootProjectManifest' | 'rootProjectManifestDir'> & CreateStoreControllerOptions
) {
const store = await createOrConnectStoreController(opts)
const include = {
@@ -61,6 +61,7 @@ export async function handler (
rootDir: process.cwd(),
}, {
...opts,
...getOptionsFromRootManifest(opts.rootProjectManifestDir, opts.rootProjectManifest ?? {}),
ignorePackageManifest: true,
include,
modulesCacheMaxAge: 0,

View File

@@ -271,6 +271,7 @@ export type InstallCommandOptions = Pick<Config,
| 'production'
| 'registries'
| 'rootProjectManifest'
| 'rootProjectManifestDir'
| 'save'
| 'saveDev'
| 'saveExact'

View File

@@ -32,6 +32,7 @@ const DEFAULT_OPTIONS = {
registries: {
default: REGISTRY_URL,
},
rootProjectManifestDir: '',
sort: true,
storeDir: path.join(tmp, 'store'),
userConfig: {},

View File

@@ -28,6 +28,7 @@ const DEFAULT_OPTIONS = {
registries: {
default: REGISTRY_URL,
},
rootProjectManifestDir: '',
sort: true,
userConfig: {},
workspaceConcurrency: 1,

View File

@@ -31,6 +31,7 @@ const DEFAULT_OPTIONS = {
registries: {
default: REGISTRY_URL,
},
rootProjectManifestDir: '',
sort: true,
storeDir: path.join(tmp, 'store'),
userConfig: {},

View File

@@ -33,6 +33,7 @@ const DEFAULT_OPTS = {
rawConfig: { registry: REGISTRY },
registries: { default: REGISTRY },
registry: REGISTRY,
rootProjectManifestDir: '',
storeDir: path.join(TMP, 'store'),
strictSsl: false,
userAgent: 'pnpm',

View File

@@ -31,6 +31,7 @@ const DEFAULT_OPTS = {
rawConfig: { registry: REGISTRY },
registries: { default: REGISTRY },
registry: REGISTRY,
rootProjectManifestDir: '',
storeDir: path.join(TMP, 'store'),
strictSsl: false,
userAgent: 'pnpm',

View File

@@ -30,6 +30,7 @@ const DEFAULT_OPTIONS = {
registries: {
default: REGISTRY_URL,
},
rootProjectManifestDir: '',
sort: true,
storeDir: path.join(TMP, 'store'),
userConfig: {},

View File

@@ -30,6 +30,7 @@ const DEFAULT_OPTIONS = {
registries: {
default: REGISTRY_URL,
},
rootProjectManifestDir: '',
sort: true,
userConfig: {},
workspaceConcurrency: 1,

View File

@@ -37,6 +37,7 @@ const DEFAULT_OPTIONS = {
registries: {
default: REGISTRY_URL,
},
rootProjectManifestDir: '',
sort: true,
userConfig: {},
workspaceConcurrency: 1,

View File

@@ -40,6 +40,7 @@ export const DEFAULT_OPTS = {
rawLocalConfig: {},
registries: { default: REGISTRY },
registry: REGISTRY,
rootProjectManifestDir: '',
sort: true,
storeDir: '../store',
strictSsl: false,

View File

@@ -40,6 +40,7 @@ export const DEFAULT_OPTS = {
rawLocalConfig: {},
registries: { default: REGISTRY },
registry: REGISTRY,
rootProjectManifestDir: '',
sort: true,
storeDir: '../store',
strictSsl: false,

View File

@@ -25,6 +25,8 @@ Config,
| 'modulesDir'
| 'pnpmHomeDir'
| 'selectedProjectsGraph'
| 'rootProjectManifest'
| 'rootProjectManifestDir'
> &
Partial<Pick<Config, 'userConfig'>>

View File

@@ -36,6 +36,7 @@ export const DEFAULT_OPTS = {
rawConfig: { registry: REGISTRY },
rawLocalConfig: {},
registries: { default: REGISTRY },
rootProjectManifestDir: '',
// registry: REGISTRY,
sort: true,
storeDir: '../store',

View File

@@ -38,6 +38,7 @@ export const DEFAULT_OPTS = {
rawLocalConfig: {},
registries: { default: REGISTRY },
registry: REGISTRY,
rootProjectManifestDir: '',
sort: true,
storeDir: '../store',
strictSsl: false,

View File

@@ -41,6 +41,7 @@ export const DEFAULT_OPTS = {
rawLocalConfig: {},
registries: { default: REGISTRY },
registry: REGISTRY,
rootProjectManifestDir: '',
sort: true,
storeDir: '../store',
strictSsl: false,