@lerna/publish
Version:
Publish packages in the current project
107 lines (106 loc) • 4.88 kB
JavaScript
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var deprecate_config_exports = {};
__export(deprecate_config_exports, {
deprecateConfig: () => deprecateConfig
});
module.exports = __toCommonJS(deprecate_config_exports);
var import_dot_prop = __toESM(require("dot-prop"));
var import_npmlog = __toESM(require("npmlog"));
var import_path = __toESM(require("path"));
const deprecateConfig = compose(
// add new predicates HERE
remap("command.add.includeFilteredDependencies", "command.add.includeDependencies", { alsoRoot: true }),
remap("command.add.includeFilteredDependents", "command.add.includeDependents", { alsoRoot: true }),
remap("command.bootstrap.includeFilteredDependencies", "command.bootstrap.includeDependencies"),
remap("command.bootstrap.includeFilteredDependents", "command.bootstrap.includeDependents"),
remap("command.clean.includeFilteredDependencies", "command.clean.includeDependencies"),
remap("command.clean.includeFilteredDependents", "command.clean.includeDependents"),
remap("command.exec.includeFilteredDependencies", "command.exec.includeDependencies"),
remap("command.exec.includeFilteredDependents", "command.exec.includeDependents"),
remap("command.list.includeFilteredDependencies", "command.list.includeDependencies"),
remap("command.list.includeFilteredDependents", "command.list.includeDependents"),
remap("command.run.includeFilteredDependencies", "command.run.includeDependencies"),
remap("command.run.includeFilteredDependents", "command.run.includeDependents"),
remap("command.version.githubRelease", "command.version.createRelease", {
toValue: (value) => value && "github"
}),
remap("command.publish.githubRelease", "command.version.createRelease", {
alsoRoot: true,
toValue: (value) => value && "github"
}),
remap("command.publish.npmTag", "command.publish.distTag", { alsoRoot: true }),
remap("command.publish.cdVersion", "command.publish.bump", { alsoRoot: true }),
remap("command.publish.ignore", "command.publish.ignoreChanges"),
remap("commands", "command"),
(config, filepath) => ({ config, filepath })
);
function remap(search, target, { alsoRoot, toValue } = {}) {
const pathsToSearch = [search];
if (alsoRoot) {
pathsToSearch.unshift(search.split(".").pop());
}
return (obj) => {
for (const searchPath of pathsToSearch) {
if (import_dot_prop.default.has(obj.config, searchPath)) {
const fromVal = import_dot_prop.default.get(obj.config, searchPath);
const toVal = toValue ? toValue(fromVal) : fromVal;
import_npmlog.default.warn("project", deprecationMessage(obj, target, searchPath, fromVal, toVal));
import_dot_prop.default.set(obj.config, target, toVal);
import_dot_prop.default.delete(obj.config, searchPath);
}
}
return obj;
};
}
function deprecationMessage(obj, target, searchPath, fromVal, toVal) {
const localPath = import_path.default.relative(".", obj.filepath);
let from;
let to;
if (toVal === fromVal) {
from = `"${searchPath}"`;
to = `"${target}"`;
} else {
from = stringify({ [searchPath]: fromVal });
to = stringify({ [target]: toVal });
}
return `Deprecated key "${searchPath}" found in ${localPath}
Please update ${from} => ${to}`;
}
function stringify(obj) {
return JSON.stringify(obj).slice(1, -1);
}
function compose(...funcs) {
return funcs.reduce(
(a, b) => (...args) => a(b(...args))
);
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
deprecateConfig
});