tools-core

v1.4.0-beta360.1•Published 2 weeks ago

tools-core

The tools-core package exposes helpers for managing modern tools in Meteor, providing modules for npm, log, process management, and so on; and exporting them from a Meteor package rather than being directly tied to the Meteor tool.

These helpers will be useful to integrate a modern bundler like Rspack and a native solution like CapacitorJS.

Declaring required npm dependencies

Atmosphere packages that need the host app to install (or stay above a minimum version of) one or more npm packages can use the shared engine in lib/deps.js. The engine handles both meteor.autoInstallDeps=true (default) and meteor.autoInstallDeps=false paths, so consumers ship only data. When automatic installation is disabled, the warning includes both the manual install command and the setting to re-enable automatic management.

The engine detects npm, Yarn, and pnpm from the workspace manifest and lockfiles. Installs run from the Meteor app directory so the package manager updates the app's dependencies and the workspace's lockfile. Manual guidance includes both paths and commands for the detected manager; unsupported managers are left for the user to run. Dependencies declared with file:, link:, portal:, or workspace: are checked against their installed version.

1const { ensurePackageDependencies } = require('meteor/tools-core/lib/deps');
2
3await ensurePackageDependencies({
4  packageId: 'my-tool-core',          // stable id, used for dedup
5  packageLabel: 'My Tool',            // shown in logs
6  dependencies: [
7    { name: 'my-tool-runtime', version: '2.0.0', dev: false },
8    { name: 'my-tool-cli',     version: '2.0.0', dev: true },
9  ],
10  docUrl: 'https://docs.meteor.com/about/my-tool#auto-install-deps',
11});

Do not gate the call on hasMeteorAppConfigAutoInstallDeps(). The engine owns that decision, decides whether to install or warn, prints the correct log, and dedups within the process. See packages/rspack/lib/dependencies.js for a reference integration.