@pnpm/plugin-commands-rebuild
Version:
Commands for rebuilding dependencies
100 lines • 3.9 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.commandNames = void 0;
exports.rcOptionsTypes = rcOptionsTypes;
exports.cliOptionsTypes = cliOptionsTypes;
exports.help = help;
exports.handler = handler;
const cli_utils_1 = require("@pnpm/cli-utils");
const common_cli_options_help_1 = require("@pnpm/common-cli-options-help");
const config_1 = require("@pnpm/config");
const store_connection_manager_1 = require("@pnpm/store-connection-manager");
const pick_1 = __importDefault(require("ramda/src/pick"));
const render_help_1 = __importDefault(require("render-help"));
const index_js_1 = require("./implementation/index.js");
const recursive_js_1 = require("./recursive.js");
function rcOptionsTypes() {
return {
...(0, pick_1.default)([
'npm-path',
'reporter',
'scripts-prepend-node-path',
'unsafe-perm',
'store-dir',
], config_1.types),
};
}
function cliOptionsTypes() {
return {
...rcOptionsTypes(),
pending: Boolean,
recursive: Boolean,
};
}
exports.commandNames = ['rebuild', 'rb'];
function help() {
return (0, render_help_1.default)({
aliases: ['rb'],
description: 'Rebuild a package.',
descriptionLists: [
{
title: 'Options',
list: [
{
description: 'Rebuild every package found in subdirectories \
or every workspace package, when executed inside a workspace. \
For options that may be used with `-r`, see "pnpm help recursive"',
name: '--recursive',
shortAlias: '-r',
},
{
description: 'Rebuild packages that were not build during installation. Packages are not build when installing with the --ignore-scripts flag',
name: '--pending',
},
{
description: 'The directory in which all the packages are saved on the disk',
name: '--store-dir <dir>',
},
...common_cli_options_help_1.UNIVERSAL_OPTIONS,
],
},
common_cli_options_help_1.FILTERING,
],
url: (0, cli_utils_1.docsUrl)('rebuild'),
usages: ['pnpm rebuild [<pkg> ...]'],
});
}
async function handler(opts, params) {
if (opts.recursive && (opts.allProjects != null) && (opts.selectedProjectsGraph != null) && opts.workspaceDir) {
await (0, recursive_js_1.recursiveRebuild)(opts.allProjects, params, { ...opts, selectedProjectsGraph: opts.selectedProjectsGraph, workspaceDir: opts.workspaceDir });
return;
}
const store = await (0, store_connection_manager_1.createOrConnectStoreController)(opts);
const rebuildOpts = Object.assign(opts, {
sideEffectsCacheRead: opts.sideEffectsCache ?? opts.sideEffectsCacheReadonly,
sideEffectsCacheWrite: opts.sideEffectsCache,
storeController: store.ctrl,
storeDir: store.dir,
});
if (params.length === 0) {
await (0, index_js_1.rebuildProjects)([
{
buildIndex: 0,
manifest: await (0, cli_utils_1.readProjectManifestOnly)(rebuildOpts.dir, opts),
rootDir: rebuildOpts.dir,
},
], rebuildOpts);
return;
}
await (0, index_js_1.rebuildSelectedPkgs)([
{
buildIndex: 0,
manifest: await (0, cli_utils_1.readProjectManifestOnly)(rebuildOpts.dir, opts),
rootDir: rebuildOpts.dir,
},
], params, rebuildOpts);
}
//# sourceMappingURL=rebuild.js.map