-
-
Notifications
You must be signed in to change notification settings - Fork 729
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
30efc55
commit a9d413d
Showing
4 changed files
with
75 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,28 @@ | ||
import { deprecatedLogger } from "./utils"; | ||
import type { SitemapOptions } from "../../shared"; | ||
|
||
/** @deprecated */ | ||
export const covertOptions = ( | ||
options: SitemapOptions & Record<string, unknown> | ||
): void => { | ||
deprecatedLogger({ | ||
options, | ||
deprecatedOption: "urls", | ||
newOption: "extraUrls", | ||
}); | ||
deprecatedLogger({ | ||
options, | ||
deprecatedOption: "exclude", | ||
newOption: "excludeUrls", | ||
}); | ||
deprecatedLogger({ | ||
options, | ||
deprecatedOption: "outFile", | ||
newOption: "sitemapFilename", | ||
}); | ||
deprecatedLogger({ | ||
options, | ||
deprecatedOption: "dateFormatter", | ||
newOption: "modifyTimeGetter", | ||
}); | ||
}; |
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,41 @@ | ||
import { logger } from "../utils"; | ||
|
||
export interface DeprecatedLoggerOptions { | ||
options: Record<string, unknown>; | ||
deprecatedOption: string; | ||
newOption: string; | ||
msg?: string; | ||
scope?: string; | ||
} | ||
|
||
export const deprecatedLogger = ({ | ||
options, | ||
deprecatedOption, | ||
newOption, | ||
msg = "", | ||
scope = "", | ||
}: DeprecatedLoggerOptions): void => { | ||
if (deprecatedOption in options) { | ||
logger.warn( | ||
`"${deprecatedOption}" is deprecated${ | ||
scope ? ` in ${scope}` : "" | ||
}, 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]; | ||
} | ||
}; |
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