Options
All
  • Public
  • Public/Protected
  • All
Menu

Package yarnpkg-types

Type aliases

Config

Config: object

Type declaration

  • constraints: function

    Called each time the constraints engine runs. You can then use the methods from the provided context to assert values on any of your workspaces' definitions.

    The constraints engine is declarative, and you don't need to compare values yourself except in some specific situations. For instance, if you wish to ensure that all workspaces define a specific license, you would write something like this:

    // Yes: declarative
    for (const w of Yarn.workspaces()) {
      w.set(`license`, `MIT`);
    }
    
    // No: imperative
    for (const w of Yarn.workspaces()) {
      if (w.manifest.license !== `MIT`) {
        w.set(`license`, `MIT`);
      }
    }

    Note that the presence of this field will disable any evaluation of the constraints.pro file, although no warning is currently emitted.

    The constraints engine is declarative, and you don't need to compare values yourself except in some specific situations. For instance, if you wish to ensure that all workspaces define a specific license, you would write something like this:

    // Yes: declarative
    for (const w of Yarn.workspaces()) {
      w.set(`license`, `MIT`);
    }
    
    // No: imperative
    for (const w of Yarn.workspaces()) {
      if (w.manifest.license !== `MIT`) {
        w.set(`license`, `MIT`);
      }
    }

    Note that the presence of this field will disable any evaluation of the constraints.pro file, although no warning is currently emitted.

    param

    Context

    returns
      • (ctx: Constraints.Context): Promise<void>
      • Parameters

        • ctx: Constraints.Context

        Returns Promise<void>

Context

Context: object

Type declaration

Dependency

Dependency: object

Type declaration

  • ident: string

    Dependency name.

  • range: string

    Dependency range. Note that it doesn't have to be a semver value - it can also be a git repository, and http url, etc.

  • type: DependencyType

    Name of the field under which this dependency can be found.

  • workspace: Workspace

    Reference to the owning workspace.

  • delete: function
    • delete(): void
    • Report an error (useful when you want to forbid a specific package from being added to the dependencies). If --fix is set, Yarn will silently remove the dependency from the package.json instead of reporting an error.

      Returns void

  • error: function
    • error(message: string): void
  • update: function
    • update(range: string | undefined): void
    • Report an error unless the dependency has the expected range. If --fix is set, Yarn will silently update the package.json instead of reporting an error.

      Parameters

      • range: string | undefined

        New range for the dependency.

      Returns void

DependencyFilter

DependencyFilter: object

Type declaration

  • Optional ident?: undefined | string

    Only return dependencies with the given name.

DependencyType

DependencyType: "dependencies" | "devDependencies" | "peerDependencies"

PartialObject

PartialObject: object | string | number | null

Workspace

Workspace: object

Type declaration

  • cwd: string

    Relative path from the project root to the workspace. The root workspace always has a cwd equal to ..

  • ident: string | null

    Workspace name.

  • manifest: PartialObject

    Raw manifest object for the workspace.

  • error: function
    • error(message: string): void
  • set: function
    • set(path: Array<string> | string, value: any): void
    • Report an error unless the workspace lists the specified property with the specified value. If --fix is set, Yarn will silently update the package.json instead of reporting an error.

      Parameters

      • path: Array<string> | string

        Property path

      • value: any

        Expected value

      Returns void

  • unset: function
    • unset(path: Array<string> | string): void
    • Report an error if the workspace lists the specified property. If --fix is set, Yarn will silently remove the field from the package.json instead of reporting an error.

      Parameters

      • path: Array<string> | string

        Property path

      Returns void

WorkspaceFilter

WorkspaceFilter: object

Type declaration

  • Optional cwd?: undefined | string

    Only return the workspace with the given relative path.

    Note: This doesn't currently support glob patterns. Help welcome!

    Note: This doesn't currently support glob patterns. Help welcome!

  • Optional ident?: undefined | string

    Only return the workspace with the given package name.

    Note: This doesn't currently support glob patterns. Help welcome!

    Note: This doesn't currently support glob patterns. Help welcome!

Yarn

Yarn: object

Type declaration

Functions

defineConfig

  • defineConfig(config: Yarn.Config): object
  • Parameters

    • config: Yarn.Config

    Returns object

    • constraints: function

      Called each time the constraints engine runs. You can then use the methods from the provided context to assert values on any of your workspaces' definitions.

      The constraints engine is declarative, and you don't need to compare values yourself except in some specific situations. For instance, if you wish to ensure that all workspaces define a specific license, you would write something like this:

      // Yes: declarative
      for (const w of Yarn.workspaces()) {
        w.set(`license`, `MIT`);
      }
      
      // No: imperative
      for (const w of Yarn.workspaces()) {
        if (w.manifest.license !== `MIT`) {
          w.set(`license`, `MIT`);
        }
      }

      Note that the presence of this field will disable any evaluation of the constraints.pro file, although no warning is currently emitted.

      The constraints engine is declarative, and you don't need to compare values yourself except in some specific situations. For instance, if you wish to ensure that all workspaces define a specific license, you would write something like this:

      // Yes: declarative
      for (const w of Yarn.workspaces()) {
        w.set(`license`, `MIT`);
      }
      
      // No: imperative
      for (const w of Yarn.workspaces()) {
        if (w.manifest.license !== `MIT`) {
          w.set(`license`, `MIT`);
        }
      }

      Note that the presence of this field will disable any evaluation of the constraints.pro file, although no warning is currently emitted.

      param

      Context

      returns
        • (ctx: Constraints.Context): Promise<void>
        • Parameters

          • ctx: Constraints.Context

          Returns Promise<void>

Generated using TypeDoc