Skip to content

Commit

Permalink
feat: Updated the entire codebase to Typescript
Browse files Browse the repository at this point in the history
BREAKING CHANGES:

- **General**: Constructors can no longer be used with JSON string. Parse the JSON before passing it to the constructor
- **General**: A very few type checks have been removed as they became obsolete with Typescript
- **General**: Passing Millisenconds is not supported as a valid date anymore, use one of the supported date formats
- **General**: Some default values changed from undefined to null
- **General**: supported environment set to node >= 10
- **General**: Some error messages were updated, so if your code relies on error message strings, please double check these
- **Calendar**: `domain()` was removed
- **Calendar**: `clear()` method was removed
- **Event**: `repeating.excludeTimezone` was removed and uses the time zone of the event or calendar instead
- **Event**: `repeating.wkst` is now `repeating.startOfWeek`
- **Event**: `geo()` unsupports string parameter, only `{lat: number, lon: number}` objects are now allowed
- **Category**: `Category::name(null)` is not allowed anymore
- **Attendee**: `rsvp()` uses booleans now, invalid arguments are casted to boolean
  • Loading branch information
sebbo2002 committed Feb 22, 2021
1 parent 429c0c7 commit d013dc0
Show file tree
Hide file tree
Showing 57 changed files with 27,593 additions and 11,354 deletions.
61 changes: 39 additions & 22 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,37 +1,54 @@
{
"env": {
"node": true,
"browser": true,
"commonjs": true,
"es6": true,
"node": true,
"mocha": true
},
"extends": "eslint:recommended",
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended"
],
"globals": {
"Atomics": "readonly",
"SharedArrayBuffer": "readonly"
},
"parser": "@typescript-eslint/parser",
"parserOptions": {
"sourceType": "module"
"ecmaVersion": 2018
},
"plugins": [
"@typescript-eslint"
],
"rules": {
"indent": [
"error",
4
],
"linebreak-style": [
"error",
"unix"
],
"semi": "error",
"quotes": [
"error",
"single"
],
"semi": [
"error",
"always"
],
"no-console": [
"indent": [
"error",
{
"allow": ["log"]
}
4
]
}
}
},
"overrides": [
{
"files": [
"src/**/*.ts"
],
"rules": {
"@typescript-eslint/ban-ts-comment": "warn"
}
},
{
"files": [
"test/**/*.ts"
],
"rules": {
"@typescript-eslint/ban-ts-ignore": "off",
"@typescript-eslint/ban-ts-comment": "off"
}
}
]
}
6 changes: 6 additions & 0 deletions .mocharc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
require:
- ts-node/register
- source-map-support/register
full-trace: true
extension:
- ts
7 changes: 0 additions & 7 deletions .npmignore

This file was deleted.

30 changes: 30 additions & 0 deletions .nycrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"cache": false,
"check-coverage": true,
"extension": [
".ts"
],
"include": [
"src/**/*.ts"
],
"exclude": [
"coverage/**",
"node_modules/**"
],
"report-dir": "./doc/coverage/",
"temp-directory": "./.nyc_output",
"sourceMap": true,
"reporter": [
"text",
"text-summary",
"cobertura",
"html"
],
"all": true,
"instrument": true,
"branches": 80,
"lines": 92,
"functions": 90,
"statements": 92,
"per-file": true
}
24 changes: 24 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env bash

echo "########################"
echo "# build.sh"
echo "# Branch = ${BRANCH}"
echo "########################"

npx tsc

if [ "$BRANCH" != "develop" ] && [ "$BRANCH" != "main" ] && [ "$BRANCH" != "" ]; then
echo "Skip documentation as branch is not develop and not main (is: ${BRANCH}).";
exit 0;
fi;


rm -rf ./doc
npx typedoc

npx mocha --reporter mochawesome
mv ./mochawesome-report/mochawesome.html ./mochawesome-report/index.html
mkdir -p ./doc
mv ./mochawesome-report ./doc/tests

npm run coverage
1 change: 0 additions & 1 deletion examples/example-express.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ const moment = require('moment');
const express = require('express');

const cal = ical({
domain: 'example.com',
prodId: '//superman-industries.com//ical-generator//EN',
events: [
{
Expand Down
1 change: 0 additions & 1 deletion examples/example-http.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ const moment = require('moment');
const http = require('http');

const cal = ical({
domain: 'example.com',
prodId: '//superman-industries.com//ical-generator//EN',
events: [
{
Expand Down
1 change: 0 additions & 1 deletion examples/example-koa.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ const moment = require('moment');
const Koa = require('koa');

const cal = ical({
domain: 'example.com',
prodId: '//superman-industries.com//ical-generator//EN',
events: [
{
Expand Down
1 change: 0 additions & 1 deletion examples/example-micro.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ const ical = require('ical-generator');
const moment = require('moment');

const cal = ical({
domain: 'example.com',
prodId: '//superman-industries.com//ical-generator//EN',
events: [
{
Expand Down
5 changes: 1 addition & 4 deletions examples/example-recurrence.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@

const ical = require('../src/index');
const moment = require('moment');
const cal = ical({domain: 'localhost'});

// overwrite domain
cal.domain('example.com');
const cal = ical();

cal.createEvent({
start: moment().add(1, 'hour'),
Expand Down
5 changes: 1 addition & 4 deletions examples/example-repeating.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
'use strict';

const ical = require('ical-generator');
const cal = ical({domain: 'localhost'});

// overwrite domain
cal.domain('example.com');
const cal = ical();

cal.createEvent({
start: new Date(1969, 6, 20, 20),
Expand Down
7 changes: 2 additions & 5 deletions examples/example-runkit.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
const ical = require('ical-generator');
const cal = ical({domain: 'localhost'});

// overwrite domain
cal.domain('example.com');
const cal = ical();

const event = cal.createEvent({
start: new Date(),
Expand All @@ -16,4 +13,4 @@ const event = cal.createEvent({
// update event's description
event.description('It still works ;)');

cal.toString();
cal.toString();
5 changes: 1 addition & 4 deletions examples/example-string.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@

const ical = require('ical-generator');
const moment = require('moment');
const cal = ical({domain: 'localhost'});

// overwrite domain
cal.domain('example.com');
const cal = ical();

const event = cal.createEvent({
start: moment().add(1, 'hour'),
Expand Down
Loading

0 comments on commit d013dc0

Please sign in to comment.