This repository has been archived by the owner on Apr 24, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3bb666e
commit 1d66e6c
Showing
4 changed files
with
98 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { droppedLogger } from "./utils"; | ||
|
||
import type { FeedOptions } from "../../types"; | ||
|
||
/** @deprecated */ | ||
export const covertOptions = ( | ||
options: FeedOptions & Record<string, unknown> | ||
): void => { | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore | ||
// eslint-disable-next-line | ||
options.atom = options["output"]?.atom?.enable ?? true; | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore | ||
// eslint-disable-next-line | ||
options.json = options["output"]?.json?.enable ?? true; | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore | ||
// eslint-disable-next-line | ||
options.rss = options["output"]?.rss?.enable ?? true; | ||
|
||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore | ||
// eslint-disable-next-line | ||
options.atomOutputFilename = options["output"]?.atom?.path ?? "atom.xml"; | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore | ||
// eslint-disable-next-line | ||
options.jsonOutputFilename = options["output"]?.json?.path ?? "feed.json"; | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore | ||
// eslint-disable-next-line | ||
options.jsonOutputFilename = options["output"]?.rss?.path ?? "rss.xml"; | ||
|
||
droppedLogger(options, "output"); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from "./convert"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
export interface DeprecatedLoggerOptions { | ||
options: Record<string, unknown>; | ||
deprecatedOption: string; | ||
newOption: string; | ||
msg?: string; | ||
scope?: string; | ||
} | ||
|
||
export const deprecatedLogger = ({ | ||
options, | ||
deprecatedOption, | ||
newOption, | ||
msg = "", | ||
}: DeprecatedLoggerOptions): void => { | ||
if (deprecatedOption in options) { | ||
console.warn( | ||
`"${deprecatedOption}" is deprecate in feed plugin, please use "${newOption}" instead.${ | ||
msg ? `\n${msg}` : "" | ||
}` | ||
); | ||
|
||
if (newOption.includes(".")) { | ||
const keys = newOption.split("."); | ||
let temp = options; | ||
|
||
keys.forEach((key, index) => { | ||
if (index !== keys.length - 1) { | ||
// ensure level exists | ||
temp[key] = temp[key] || {}; | ||
|
||
temp = temp[key] as Record<string, unknown>; | ||
} else temp[key] = options[deprecatedOption]; | ||
}); | ||
} else options[newOption] = options[deprecatedOption]; | ||
|
||
delete options[deprecatedOption]; | ||
} | ||
}; | ||
|
||
export const droppedLogger = ( | ||
options: Record<string, unknown>, | ||
droppedOption: string, | ||
hint = "", | ||
newOption = "" | ||
): void => { | ||
if (droppedOption in options) { | ||
console.error( | ||
`"${droppedOption}" is removed${ | ||
newOption | ||
? `, please use ${newOption} instead.` | ||
: " and no longer supported" | ||
}${hint ? `\n${hint}` : ""}` | ||
); | ||
|
||
if (!newOption) delete options[droppedOption]; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters