Detalhes do pacote

@npmcli/map-workspaces

npm14.5mISC4.0.2

Retrieves a name:pathname Map for a given workspaces config

npm, npmcli, libnpm, cli

readme (leia-me)

@npmcli/map-workspaces

NPM version Build Status License

Retrieves a name:pathname Map for a given workspaces config.

Long version: Reads the workspaces property from a valid workspaces configuration object and traverses the paths and globs defined there in order to find valid nested packages and return a Map of all found packages where keys are package names and values are folder locations.

Install

npm install @npmcli/map-workspaces

Usage:

const mapWorkspaces = require('@npmcli/map-workspaces')
await mapWorkspaces({
  cwd,
  pkg: {
    workspaces: {
      packages: [
        "a",
        "b"
      ]
    }
  }
})
// ->
// Map {
//   'a': '<cwd>/a'
//   'b': '<cwd>/b'
// }

Examples:

Glob usage:

Given a folder structure such as:

├── package.json
└── apps
   ├── a
   │   └── package.json
   ├── b
   │   └── package.json
   └── c
       └── package.json
const mapWorkspaces = require('@npmcli/map-workspaces')
await mapWorkspaces({
  cwd,
  pkg: {
    workspaces: [
      "apps/*"
    ]
  }
})
// ->
// Map {
//   'a': '<cwd>/apps/a'
//   'b': '<cwd>/apps/b'
//   'c': '<cwd>/apps/c'
// }

API:

mapWorkspaces(opts) -> Promise<Map>

  • opts:
    • pkg: A valid package.json Object
    • cwd: A String defining the base directory to use when reading globs and paths.
    • ignore: An Array of paths to be ignored when using globs to look for nested package.
    • ...Also support all other glob options

Returns

A Map in which keys are package names and values are the pathnames for each found workspace.

LICENSE

ISC

changelog (log de mudanças)

Changelog

4.0.2 (2024-11-20)

Bug Fixes

  • ae9cd9e #176 ignore ENOTDIR errors (#176) (@brianlenz)

    Chores

  • 84d179f #174 bump @npmcli/template-oss from 4.23.3 to 4.23.4 (#174) (@dependabot[bot], @npm-cli-bot)

4.0.1 (2024-10-02)

Dependencies

4.0.0 (2024-09-26)

⚠️ BREAKING CHANGES

  • @npmcli/map-workspaces now supports node ^18.17.0 || >=20.5.0

    Bug Fixes

  • 211aef3 #153 use @npmcli/package-json to parse packages (@wraithgar)
  • 3959800 #168 align to npm 10 node engine range (@reggi)

    Dependencies

  • 044b3a8 #153 @npmcli/package-json@5.2.0
  • a493618 #153 remove read-package-json-fast
  • e52dd76 #168 read-package-json-fast@4.0.0
  • 2ec2a15 #168 @npmcli/name-from-folder@3.0.0

    Chores

  • f066c79 #166 bump @npmcli/eslint-config from 4.0.5 to 5.0.0 (#166) (@dependabot[bot])
  • 888c87c #168 run template-oss-apply (@reggi)
  • d1b3556 #150 bump @npmcli/template-oss to 4.22.0 (@lukekarrys)
  • 938d94c #162 bump @npmcli/template-oss from 4.22.0 to 4.23.3 (#162) (@dependabot[bot])
  • c5cb12c #150 postinstall for dependabot template-oss PR (@lukekarrys)

3.0.6 (2024-04-10)

Bug Fixes

  • e2a803b #145 allow for workspace patterns to start with ./ (#145) (@wraithgar)

3.0.5 (2024-04-10)

Bug Fixes

  • c89a529 #143 faster workspace mapping (#143) (@wraithgar, @thecodrr)

Documentation

  • 304c345 #141 readme: fix broken badge URLs (#141) (@10xLaCroixDrinker)

Chores

  • 2c3d889 #137 postinstall for dependabot template-oss PR (@lukekarrys)
  • 1e78272 #137 bump @npmcli/template-oss from 4.21.1 to 4.21.3 (@dependabot[bot])
  • a5b6bf5 #134 postinstall for dependabot template-oss PR (@lukekarrys)
  • 797d0a0 #134 bump @npmcli/template-oss from 4.19.0 to 4.21.1 (@dependabot[bot])
  • 4017779 #115 postinstall for dependabot template-oss PR (@lukekarrys)
  • 803e42f #115 bump @npmcli/template-oss from 4.18.1 to 4.19.0 (@dependabot[bot])
  • b214753 #114 postinstall for dependabot template-oss PR (@lukekarrys)
  • 17747a7 #114 bump @npmcli/template-oss from 4.18.0 to 4.18.1 (@dependabot[bot])
  • ff82968 #113 postinstall for dependabot template-oss PR (@lukekarrys)
  • f38ff1e #113 bump @npmcli/template-oss from 4.17.0 to 4.18.0 (@dependabot[bot])
  • cf234ce #112 postinstall for dependabot template-oss PR (@lukekarrys)
  • 414331d #112 bump @npmcli/template-oss from 4.15.1 to 4.17.0 (@dependabot[bot])
  • 003893e #110 postinstall for dependabot template-oss PR (@lukekarrys)
  • 8fcd7ee #110 bump @npmcli/template-oss from 4.14.1 to 4.15.1 (@dependabot[bot])

3.0.4 (2023-04-27)

Dependencies

3.0.3 (2023-03-21)

Dependencies

  • f37aeb1 #96 bump glob from 8.1.0 to 9.3.1 (#96)
  • 98d3b80 #92 bump minimatch from 6.2.0 to 7.4.2 (#92)

3.0.2 (2023-02-06)

Dependencies

3.0.1 (2022-12-14)

Dependencies

  • 15c752f #75 bump @npmcli/name-from-folder from 1.0.1 to 2.0.0

3.0.0 (2022-10-12)

⚠️ BREAKING CHANGES

  • @npmcli/map-workspaces is now compatible with the following semver range for node: ^14.17.0 || ^16.13.0 || >=18.0.0

Features

  • d018d85 #60 postinstall for dependabot template-oss PR (@lukekarrys)

Documentation

  • 2f9abc7 #64 update readme install package name (#64) (@wraithgar)

Dependencies

  • 8f3fcce #68 bump read-package-json-fast from 2.0.3 to 3.0.0

2.0.4 (2022-06-29)

Bug Fixes

  • replace deprecated String.prototype.substr() (#41) (1452a05)

2.0.3 (2022-04-20)

Dependencies

2.0.2 (2022-03-10)

Bug Fixes

  • evaluate all patterns before throwing EDUPLICATEWORKSPACE (#32) (ca0bf18)

Dependencies

  • update minimatch requirement from ^5.0.0 to ^5.0.1 (#28) (5c4fd0d)

2.0.1 (2022-02-17)

Bug Fixes

Dependencies

  • bump minimatch from 3.1.1 to 4.1.1 (305629e)
  • bump minimatch from 4.2.1 to 5.0.0 (2098531)
  • update glob requirement from ^7.1.6 to ^7.2.0 (588b229)
  • update read-package-json-fast requirement from ^2.0.1 to ^2.0.3 (0eeb67d)

0.0.0-pre.0

  • Initial pre-release.