![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
@npmcli/map-workspaces
Advanced tools
Retrieves a name:pathname Map for a given workspaces config
The @npmcli/map-workspaces package is designed to assist with managing and interacting with npm workspaces. It provides functionality to map and iterate over workspaces in a project, allowing for operations such as executing scripts or installing dependencies in each workspace. This can be particularly useful in monorepo setups where multiple packages are managed within a single repository.
Mapping Workspaces
This feature allows you to map all the workspaces defined in your project. The code sample demonstrates how to use @npmcli/map-workspaces to retrieve a list of workspaces based on the configuration in your package.json. This is useful for scripts that need to perform actions on each workspace.
const mapWorkspaces = require('@npmcli/map-workspaces');
const { workspaces } = await mapWorkspaces({
cwd: process.cwd(),
pkg: {
workspaces: [
'packages/*'
]
}
});
console.log(workspaces);
Lerna is a tool for managing JavaScript projects with multiple packages, known as a monorepo. It provides similar functionalities to @npmcli/map-workspaces by allowing you to run scripts, publish packages, and more across multiple workspaces. However, Lerna is more feature-rich and can handle complex workflows, including versioning and publishing.
Yarn Workspaces is a feature built into Yarn that automatically manages the installation of dependencies and linking of packages in a monorepo. It offers similar workspace mapping functionalities but is tightly integrated with Yarn's package management capabilities. Unlike @npmcli/map-workspaces, Yarn Workspaces is not a separate package but a feature of Yarn itself.
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.
npm install @npmcli/map-workspaces
const mapWorkspaces = require('@npmcli/map-workspaces')
await mapWorkspaces({
cwd,
pkg: {
workspaces: {
packages: [
"a",
"b"
]
}
}
})
// ->
// Map {
// 'a': '<cwd>/a'
// 'b': '<cwd>/b'
// }
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'
// }
mapWorkspaces(opts) -> Promise<Map>
opts
:
pkg
: A valid package.json
Objectcwd
: 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.A Map in which keys are package names and values are the pathnames for each found workspace.
FAQs
Retrieves a name:pathname Map for a given workspaces config
We found that @npmcli/map-workspaces demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 6 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.