一些检查失败了
automerge / automerge (push) Has been cancelled
react-native-android-build-apk / AssembleRelease (push) Has been cancelled
Build macOS M1 / Main (push) Has been cancelled
Joplin Continuous Integration / Main (macos-15-intel) (push) Has been cancelled
Joplin Continuous Integration / Main (ubuntu-22.04) (push) Has been cancelled
Joplin Continuous Integration / Main (ubuntu-22.04-arm) (push) Has been cancelled
Joplin Continuous Integration / Main (windows-11-vs2026-arm) (push) Has been cancelled
Joplin Continuous Integration / Main (windows-2025) (push) Has been cancelled
Joplin Continuous Integration / ServerDockerImage (ubuntu-22.04) (push) Has been cancelled
Joplin Continuous Integration / ServerDockerImage (ubuntu-22.04-arm) (push) Has been cancelled
Joplin UI tests / Main (ubuntu-22.04) (push) Has been cancelled
Joplin UI tests / Main (windows-2025) (push) Has been cancelled
Joplin UI tests / Mobile (push) Has been cancelled
Close stale issues / ProcessStaleIssues (push) Has been cancelled
68 行
2.0 KiB
TypeScript
68 行
2.0 KiB
TypeScript
import * as path from 'path';
|
|
import { readJsonFile } from './utils';
|
|
import { PluginManifest } from '@joplin/lib/services/plugins/utils/types';
|
|
|
|
export interface ManifestOverride {
|
|
_obsolete?: boolean;
|
|
_recommended?: boolean;
|
|
_superseded_package?: string;
|
|
}
|
|
|
|
export type ManifestOverrides = Record<string, ManifestOverride>;
|
|
type PluginManifests = Record<string, PluginManifest>;
|
|
|
|
export function applyManifestOverrides(manifests: PluginManifests, overrides: ManifestOverrides) {
|
|
for (const [pluginId, override] of Object.entries(overrides)) {
|
|
const manifest = manifests[pluginId] as PluginManifest & Record<string, unknown>;
|
|
|
|
if (!manifest) {
|
|
// If the manifest does not exist in the destination, it means the
|
|
// plugin has been taken out, so the obsolete property should be set
|
|
// to `true`. If not, it's an error.
|
|
if (!override._obsolete) {
|
|
console.error(`Could not find manifest for plugin ${pluginId} when applying override`);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
for (const [propName, propValue] of Object.entries(override)) {
|
|
manifest[propName] = propValue;
|
|
}
|
|
}
|
|
|
|
return manifests;
|
|
}
|
|
|
|
export function getObsoleteManifests<T extends { _obsolete?: boolean }>(overrides: Record<string, T>): Record<string, T> {
|
|
const output: Record<string, T> = {};
|
|
|
|
for (const [pluginId, override] of Object.entries(overrides)) {
|
|
if (override._obsolete) {
|
|
output[pluginId] = override;
|
|
}
|
|
}
|
|
|
|
return output;
|
|
}
|
|
|
|
function pluginManifestOverridesPath(repoDir: string): string {
|
|
return path.resolve(repoDir, 'manifestOverrides.json');
|
|
}
|
|
|
|
export async function readManifestOverrides(repoDir: string): Promise<ManifestOverrides> {
|
|
return readJsonFile(pluginManifestOverridesPath(repoDir), {});
|
|
}
|
|
|
|
export const getSupersededPackages = (manifestOverrides: ManifestOverrides): string[] => {
|
|
const supersededPackages = [];
|
|
|
|
for (const id in manifestOverrides) {
|
|
const supersededPackage = manifestOverrides[id]._superseded_package;
|
|
if (supersededPackage) {
|
|
supersededPackages.push(supersededPackage);
|
|
}
|
|
}
|
|
|
|
return supersededPackages;
|
|
};
|