Merge pull request #11162 from StorytellerCZ/feature/package-deprecation

Deprecation flag for packages
This commit is contained in:
Filipe Névola
2021-04-07 15:25:25 -04:00
committed by GitHub
8 changed files with 60 additions and 6 deletions

View File

@@ -762,6 +762,8 @@ _.extend(PackageQuery.prototype, {
// - exports: a PkgExports object, representing package exports.
// - exports: a PkgImplies object, representing package implies.
// - dependencies: a PkgDependencies object, representing dependencies.
// - deprecated: If the package has been deprecated or not.
// - deprecatedMessage: Optional message from the deprecated package for the users.
_displayVersion: function (data) {
var self = this;
Console.info(
@@ -823,6 +825,16 @@ _.extend(PackageQuery.prototype, {
Console.command("'meteor show " + data.name + "@" + data.version + "'"),
"from outside the project.");
}
// Display deprecation message
if (data.deprecated) {
Console.info();
if (data.deprecatedMessage) {
Console.info(data.deprecatedMessage);
} else {
Console.info('This packages has been DEPRECATED.');
}
}
},
// Returns a user-friendly object from this PackageQuery to the caller. Takes
// in a data object with the same keys as _displayVersion.
@@ -1124,7 +1136,7 @@ _.extend(ReleaseQuery.prototype, {
recommended: versionRecord.recommended,
orderKey: versionRecord.orderKey,
publishedBy: versionRecord.publishedBy["username"],
pubishedOn: publishDate,
publishedOn: publishDate,
packages: versionRecord.packages,
tool: versionRecord.tool
};

View File

@@ -1953,6 +1953,7 @@ main.registerCommand({
var nonlatestDirectDeps = [];
var nonlatestIndirectDeps = [];
var deprecatedDeps = [];
projectContext.packageMap.eachPackage(function (name, info) {
var selectedVersion = info.version;
var catalog = projectContext.projectCatalog;
@@ -1966,6 +1967,13 @@ main.registerCommand({
nonlatestIndirectDeps.push(rec);
}
}
if (info.packageSource && info.packageSource.deprecated) {
deprecatedDeps.push({
name: name,
selectedVersion: selectedVersion,
deprecatedMessage: info.packageSource.deprecatedMessage
})
}
});
var printItem = function (rec) {
Console.info(" * " + rec.name + " " + rec.selectedVersion +
@@ -1974,12 +1982,18 @@ main.registerCommand({
if (nonlatestDirectDeps.length) {
Console.info("\nThe following top-level dependencies were not updated " +
"to the very latest version available:");
_.each(nonlatestDirectDeps, printItem);
nonlatestDirectDeps.forEach(printItem);
}
if(deprecatedDeps.length) {
Console.info("\nThe following packages have been DEPRECATED. Please consider finding replacements for them.");
deprecatedDeps.forEach(function (item) {
Console.info(" * " + item.name + " " + item.selectedVersion + " " + (item.deprecatedMessage ? "(" + item.deprecatedMessage + ")" : ""));
})
}
if (nonlatestIndirectDeps.length) {
Console.info("\nNewer versions of the following indirect dependencies" +
" are available:");
_.each(nonlatestIndirectDeps, printItem);
nonlatestIndirectDeps.forEach(printItem);
Console.info([
"These versions may not be compatible with your project.",
"To update one or more of these packages to their latest",

View File

@@ -1086,7 +1086,7 @@ class Console extends ConsoleBase {
// level with Console.LEVEL_INFO, Console.LEVEL_ERROR, etc.
// - ignoreWidth: ignore the width of the terminal, and go over the
// character limit instead of trailing off with '...'. Useful for
// printing directories, for examle.
// printing directories, for example.
// - indent: indent the entire table by a given number of spaces.
printTwoColumns(rows, options) {
options = options || Object.create(null);

View File

@@ -53,6 +53,8 @@ export class PackageNamespace {
* will ONLY be bundled into production builds.
* @param {Boolean} options.testOnly A package with this flag set to true
* will ONLY be bundled as part of `meteor test`.
* @param {Boolean|String} options.deprecated A flag that will mark the
* package as deprecated. Provide string to override the default message.
*/
describe(options) {
const source = this._packageSource;
@@ -128,7 +130,7 @@ export class PackageNamespace {
// * These flags CAN cause different package load orders in
// development and production! We should probably fix this.
// Basically, packages that are excluded from the build using
// these flags are also excluded fro the build order calculation,
// these flags are also excluded from the build order calculation,
// and that's the problem
//
// * We should consider publicly documenting these flags, since they
@@ -139,6 +141,11 @@ export class PackageNamespace {
source.prodOnly = !!value;
} else if (key === "testOnly") {
source.testOnly = !!value;
} else if (key === "deprecated") {
if (typeof(value) === "string") {
source.deprecatedMessage = value;
}
source.deprecated = !!value;
} else {
// Do nothing. We might want to add some keys later, and we should err
// on the side of backwards compatibility.

View File

@@ -74,7 +74,7 @@ var loadOrderSort = function (sourceProcessorSet, arch) {
return false;
default:
throw Error(`surprising type ${classification.type} for ${filename}`);
throw Error(`Surprising type ${classification.type} for ${filename}`);
}
});
@@ -379,6 +379,11 @@ var PackageSource = function () {
// specify the correct restrictions at 0.90.
// XXX: 0.90 package versions.
self.isCore = false;
// Flags for Atmosphere and developers to mark if deprecated packages
// and provide additional info.
self.deprecated = false;
self.deprecatedMessage = undefined;
};

View File

@@ -389,6 +389,10 @@ _.extend(LocalCatalog.prototype, {
debugOnly: packageSource.debugOnly,
prodOnly: packageSource.prodOnly,
testOnly: packageSource.testOnly,
deprecated: packageSource.deprecated,
deprecatedMessage: packageSource.deprecatedMessage,
containsPlugins: packageSource.containsPlugins()
}
};

View File

@@ -792,6 +792,10 @@ exports.publishPackage = function (options) {
debugOnly: packageSource.debugOnly,
prodOnly: packageSource.prodOnly,
testOnly: packageSource.testOnly,
deprecated: packageSource.deprecated,
deprecatedMessage: packageSource.deprecatedMessage,
exports: packageSource.getExports(),
releaseName: release.current.name,
dependencies: packageDeps

View File

@@ -267,6 +267,14 @@ _.extend(exports.PackageMapDelta.prototype, {
description =
"downgraded from " + info.oldVersion + " to " + info.newVersion;
}
if (info.deprecated) {
name += ' - DEPRECATED';
if (info.deprecatedMessage) {
description += ' - ' + info.deprecatedMessage;
}
}
displayItems.push({ name: name, description: description });
});