From 1d5b6a4d9fca7e8716490a578fa703f9fa7c9248 Mon Sep 17 00:00:00 2001 From: Ifiok Jr Date: Tue, 4 Feb 2020 03:27:24 +0100 Subject: [PATCH 1/2] Add `workspaces` to `PackageJson` type --- source/package-json.d.ts | 34 ++++++++++++++++++++++++++++++++++ test-d/package-json.ts | 1 + 2 files changed, 35 insertions(+) diff --git a/source/package-json.d.ts b/source/package-json.d.ts index 61a467a76..d3a64e567 100644 --- a/source/package-json.d.ts +++ b/source/package-json.d.ts @@ -257,7 +257,41 @@ declare namespace PackageJson { typings?: string; } + /** + An alternative configuration for Yarn workspaces. + */ + export interface WorkspaceConfig { + /** + An array of workspace pattern strings which contain the workspace packages. + */ + packages?: WorkspacePattern[]; + /** + `nohoist` is designed to solve the problem of packages which break when their node_modules are moved to the root workspace directory - a process known as hoisting. For these packages both within your workspace and also some that have been installed via node_modules it is important to have a mechanism for preventing the default Yarn workspace behavior. By adding workspace pattern strings here, Yarn will resume non-workspace behavior for any package which matches the patterns defined. + + More information can be found via this blog posthttps://classic.yarnpkg.com/blog/2018/02/15/nohoist/ + */ + nohoist?: WorkspacePattern[]; + } + + /** + A workspace pattern points to a folder or group of folders which contain packages that should be included in the workspace installation process. The patterns are handled with minimatch https://github.com/isaacs/minimatch + + @example + `docs` -> Include the docs folder and install it's dependencies. + `packages/*` -> Include all nested folders within the packages folder like `packages/cli` and `packages/core`. + */ + type WorkspacePattern = string; + export interface YarnConfiguration { + /** + Used to configure Yarn workspaces (https://classic.yarnpkg.com/docs/workspaces/). + + Workspaces allow you to manage multiple packages within the same repository in such a way that you only need to run `yarn install` once to install all of them in a single pass. + + Please note the top level `private` property of the `package.json` **must** be set to true in order to use workspaces. + */ + workspaces?: WorkspacePattern[] | WorkspaceConfig; + /** If your package only allows one version of a given dependency, and you’d like to enforce the same behavior as `yarn install --flat` on the command line, set this to `true`. diff --git a/test-d/package-json.ts b/test-d/package-json.ts index 470d6e29e..d007fb05c 100644 --- a/test-d/package-json.ts +++ b/test-d/package-json.ts @@ -35,6 +35,7 @@ expectType(packageJson.peerDependencies); expectType(packageJson.bundleDependencies); expectType(packageJson.bundledDependencies); expectType(packageJson.resolutions); +expectType(packageJson.workspaces); expectType<{[engineName: string]: string} | undefined>(packageJson.engines); expectType(packageJson.engineStrict); expectType< From 08db294b0ea63068bf22b2eb0055f906b5a559e0 Mon Sep 17 00:00:00 2001 From: Sindre Sorhus Date: Tue, 11 Feb 2020 03:24:36 +0700 Subject: [PATCH 2/2] Update package-json.d.ts --- source/package-json.d.ts | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/source/package-json.d.ts b/source/package-json.d.ts index d3a64e567..648169da1 100644 --- a/source/package-json.d.ts +++ b/source/package-json.d.ts @@ -265,37 +265,40 @@ declare namespace PackageJson { An array of workspace pattern strings which contain the workspace packages. */ packages?: WorkspacePattern[]; + /** - `nohoist` is designed to solve the problem of packages which break when their node_modules are moved to the root workspace directory - a process known as hoisting. For these packages both within your workspace and also some that have been installed via node_modules it is important to have a mechanism for preventing the default Yarn workspace behavior. By adding workspace pattern strings here, Yarn will resume non-workspace behavior for any package which matches the patterns defined. + Designed to solve the problem of packages which break when their `node_modules` are moved to the root workspace directory - a process known as hoisting. For these packages, both within your workspace, and also some that have been installed via `node_modules`, it is important to have a mechanism for preventing the default Yarn workspace behavior. By adding workspace pattern strings here, Yarn will resume non-workspace behavior for any package which matches the defined patterns. - More information can be found via this blog posthttps://classic.yarnpkg.com/blog/2018/02/15/nohoist/ + [Read more](https://classic.yarnpkg.com/blog/2018/02/15/nohoist/) */ nohoist?: WorkspacePattern[]; } /** - A workspace pattern points to a folder or group of folders which contain packages that should be included in the workspace installation process. The patterns are handled with minimatch https://github.com/isaacs/minimatch + A workspace pattern points to a directory or group of directories which contain packages that should be included in the workspace installation process. + + The patterns are handled with [minimatch](https://github.com/isaacs/minimatch). @example - `docs` -> Include the docs folder and install it's dependencies. - `packages/*` -> Include all nested folders within the packages folder like `packages/cli` and `packages/core`. + `docs` → Include the docs directory and install its dependencies. + `packages/*` → Include all nested directories within the packages directory, like `packages/cli` and `packages/core`. */ type WorkspacePattern = string; export interface YarnConfiguration { /** - Used to configure Yarn workspaces (https://classic.yarnpkg.com/docs/workspaces/). + Used to configure [Yarn workspaces](https://classic.yarnpkg.com/docs/workspaces/). Workspaces allow you to manage multiple packages within the same repository in such a way that you only need to run `yarn install` once to install all of them in a single pass. - Please note the top level `private` property of the `package.json` **must** be set to true in order to use workspaces. + Please note that the top-level `private` property of `package.json` **must** be set to `true` in order to use workspaces. */ workspaces?: WorkspacePattern[] | WorkspaceConfig; /** - If your package only allows one version of a given dependency, and you’d like to enforce the same behavior as `yarn install --flat` on the command line, set this to `true`. + If your package only allows one version of a given dependency, and you’d like to enforce the same behavior as `yarn install --flat` on the command-line, set this to `true`. - Note that if your `package.json` contains `"flat": true` and other packages depend on yours (e.g. you are building a library rather than an application), those other packages will also need `"flat": true` in their `package.json` or be installed with `yarn install --flat` on the command-line. + Note that if your `package.json` contains `"flat": true` and other packages depend on yours (e.g. you are building a library rather than an app), those other packages will also need `"flat": true` in their `package.json` or be installed with `yarn install --flat` on the command-line. */ flat?: boolean;