Skip to content

Commit 8c99829

Browse files
authored
chore(vCard): deprecate vcalendar format (#53)
* docs(VCard): Update comments and deprecate buildVCalendar method * refactor(constants): Mark VCALENDAR in ContentTypes and Formats as deprecated * refactor(VCard): Add deprecation warnings for 'vcalendar' format * "fix(test): Redirect stderr to null in test-functional script" * docs(README): Mark iCalendar format as deprecated * refactor(VCard): Update deprecation warning message in buildVCalendar method
1 parent 3b9f4db commit 8c99829

File tree

4 files changed

+18
-4
lines changed

4 files changed

+18
-4
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ vCard.addPhoto(image, 'JPEG')
102102

103103
Include the proper [MIME type][mime-types] (defaults to `JPEG`).
104104

105-
### iCalendar format
105+
### [DEPRECATED] iCalendar format
106106

107107
For Apple devices that don't support the `vcf` file format, there is a
108108
workaround. Specify the format of the output as `vcalendar` and then save it

lib/VCard.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,10 @@ export default class VCard {
8787
*/
8888
public setFormat(format: Format = constants.DEFAULT_FORMAT): void {
8989
if (format === constants.Formats.VCALENDAR) {
90+
// eslint-disable-next-line no-console
91+
console.warn(
92+
`The format 'vcalendar' is deprecated and will be removed in the next major or minor release. Use 'vcard' instead.`,
93+
)
9094
this.contentType = constants.ContentTypes.VCALENDAR
9195
this.useVCalendar = true
9296
} else if (format === constants.Formats.VCARD) {
@@ -479,12 +483,20 @@ ${lastName};${firstName};${additional};${prefix};${suffix}\
479483
}
480484

481485
/**
482-
* Build VCalender (.ics) - Safari (< iOS 8) can not open .vcf files, so we
483-
* have build a workaround.
486+
* Build VCalender (.ics) - Safari (< iOS 7) can not open .vcf files, so we
487+
* built a workaround.
484488
*
489+
* @deprecated This method is deprecated and will be removed in the next major
490+
* or minor release. Use `buildVCard` instead. For more information, see
491+
* https://stackoverflow.com/a/11405271/8713532.
485492
* @return {string}
486493
*/
487494
public buildVCalendar(): string {
495+
// eslint-disable-next-line no-console
496+
console.warn(
497+
`The method 'buildVCalendar' is deprecated and will be removed in the next major or minor release. Use 'buildVCard' instead.`,
498+
)
499+
488500
const nowISO = new Date().toISOString()
489501
const nowBase = nowISO.replace(/-/g, '').replace(/:/g, '').substring(0, 13)
490502
const dtstart = `${nowBase}00`

lib/utils/constants.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
import { Element } from '../types/VCard'
22

33
export enum ContentTypes {
4+
/** @deprecated */
45
VCALENDAR = 'text/x-vcalendar',
56
VCARD = 'text/x-vcard',
67
}
78

89
export enum Formats {
10+
/** @deprecated */
911
VCALENDAR = 'vcalendar',
1012
VCARD = 'vcard',
1113
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"preinstall": "npx only-allow pnpm",
2323
"pretty:fix": "prettier --write .",
2424
"pretty": "prettier --check .",
25-
"test:functional": "(./test-functional/test-vcard.js | tee vcard.vcf) && (./test-functional/test-vcalendar.js | tee vcard.ics)",
25+
"test:functional": "(./test-functional/test-vcard.js | tee vcard.vcf) && (./test-functional/test-vcalendar.js 2>/dev/null | tee vcard.ics)",
2626
"test:unit": "jest",
2727
"test:web-build": "NODE_ENV=development webpack --mode development && open ./test-functional/test-build.html",
2828
"test:web-export": "open ./test-functional/test-export.html",

0 commit comments

Comments
 (0)