Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Handling Dependencies

Converting latest to a range

By default, all latest versions will be converted to a version range (which can be specified in the config) that starts from the actual latest version for that package.

This means that you can easily use your presets and ensure that they're always going to be updated, without using latest, which is not very good practice.

⚠️ Sketch uses the npm api to fetch the latest version for any given package. Depending on how many requests are made in a given timeframe, you might be rate limited by the api.

typescript:
  # Default
  no_convert_latest_to_range: false

  # Default
  version_range: patch

Adding dependencies to the catalog

If you set up your package manager to be pnpm (which is the default) and set catalog to true, whenever you try to generate a new package that has dependencies marked with catalog: (either the default catalog or a named one), each package that is not present in the target catalog inside pnpm-workspace.yaml will be added automatically to it.

Example

Let's say that we are starting with a basic pnpm-workspace.yaml file, and we generate a package that has catalog dependencies, which are currently absent from their target catalogs:

typescript:
  catalog: true

  package_presets:
    with_catalog:
      name: with_catalog
      dir: packages/with_catalog
      package_json:
        devDependencies:
          # Named catalog
          svelte: catalog:svelte
          # Default catalog
          hono: "catalog:"

After running

sketch ts package --preset with_catalog

We can see that the pnpm-workspace.yaml file has been updated with the new named catalog and dependencies:

packages:
  - 'packages/*'

catalogs:
  "svelte":
    "svelte": ^5.39.2

catalog:
  "hono": ^4.9.8
  "oxlint": ^1.16.0
  "typescript": ^5.9.2
  "vitest": ^3.2.4