timezones-ical-library 1.11.0 ā 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Readme.md +92 -76
- package/dist/cjs/index.js +7 -209
- package/dist/cjs/package.json +3 -1
- package/dist/mjs/index.js +7 -209
- package/dist/mjs/package.json +3 -1
- package/dist/tzlib.js +8 -208
- package/package.json +12 -19
- package/test/load-commonjs.cjs +32 -3
- package/test/load-module.mjs +32 -3
- package/test/tests.js +55 -14
- package/dist/cjs/.eslintrc.json +0 -1
- package/test/.eslintrc.json +0 -7
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "timezones-ical-library",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"engines": {
|
|
5
|
-
"node": ">=
|
|
6
|
-
"npm": ">=
|
|
5
|
+
"node": ">=24.11.1",
|
|
6
|
+
"npm": ">=11.6.2"
|
|
7
7
|
},
|
|
8
8
|
"description": "Easy direct access to the most recent official timezone information for iCalendar files via JavaScript",
|
|
9
9
|
"main": "dist/cjs/index.js",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"jsdelivr": "./dist/tzlib.js",
|
|
25
25
|
"repository": {
|
|
26
26
|
"type": "git",
|
|
27
|
-
"url": "https://github.com/add2cal/timezones-ical-library.git"
|
|
27
|
+
"url": "git+https://github.com/add2cal/timezones-ical-library.git"
|
|
28
28
|
},
|
|
29
29
|
"keywords": [
|
|
30
30
|
"ical",
|
|
@@ -60,33 +60,26 @@
|
|
|
60
60
|
},
|
|
61
61
|
"homepage": "https://tz.add-to-calendar-technology.com/",
|
|
62
62
|
"scripts": {
|
|
63
|
-
"
|
|
64
|
-
"
|
|
65
|
-
"
|
|
63
|
+
"build": "node scripts/build.js && cd demo && npm ci && npm run build",
|
|
64
|
+
"build:lib-only": "node scripts/build.js",
|
|
65
|
+
"dev": "cd demo && npm run dev",
|
|
66
66
|
"eslint": "npx eslint .",
|
|
67
67
|
"eslint:fix": "npm run eslint -- --fix",
|
|
68
68
|
"prettier": "npx prettier . --check",
|
|
69
69
|
"prettier:fix": "npm run prettier -- --write",
|
|
70
|
-
"format": "npm run eslint:fix && npm run prettier:fix && npm run
|
|
71
|
-
"test": "node test/tests.js"
|
|
72
|
-
"build": "npx grunt"
|
|
70
|
+
"format": "npm run eslint:fix && npm run prettier:fix && cd demo && npm run format",
|
|
71
|
+
"test": "node test/tests.js"
|
|
73
72
|
},
|
|
74
73
|
"devDependencies": {
|
|
74
|
+
"esbuild": "^0.27.2",
|
|
75
75
|
"eslint": "^9.39.2",
|
|
76
76
|
"eslint-config-prettier": "^10.1.8",
|
|
77
77
|
"eslint-plugin-commonjs": "^1.0.2",
|
|
78
|
+
"eslint-plugin-prettier": "^5.5.5",
|
|
79
|
+
"eslint-plugin-regexp": "^2.10.0",
|
|
78
80
|
"eslint-plugin-security": "^3.0.1",
|
|
79
81
|
"glob": "^13.0.0",
|
|
80
|
-
"grunt": ">=1.6.1",
|
|
81
|
-
"grunt-contrib-clean": "^2.0.1",
|
|
82
|
-
"grunt-contrib-copy": "^1.0.0",
|
|
83
|
-
"grunt-contrib-cssmin": "^5.0.0",
|
|
84
|
-
"grunt-contrib-uglify": "^5.2.2",
|
|
85
|
-
"grunt-file-creator": "^0.1.3",
|
|
86
|
-
"grunt-version": "^3.0.2",
|
|
87
82
|
"prettier": "^3.7.4",
|
|
88
|
-
"stylelint": "^16.26.1",
|
|
89
|
-
"stylelint-config-standard": "^39.0.1",
|
|
90
83
|
"typescript-eslint": "^8.52.0"
|
|
91
84
|
}
|
|
92
85
|
}
|
package/test/load-commonjs.cjs
CHANGED
|
@@ -1,5 +1,34 @@
|
|
|
1
1
|
// simple check to see if we can require the commonJS script
|
|
2
2
|
const requireTest = require('../dist/cjs/index.js');
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
requireTest.tzlib_get_timezones();
|
|
3
|
+
|
|
4
|
+
const testCases = process.argv[2] ? JSON.parse(process.argv[2]) : ['Europe/Berlin'];
|
|
5
|
+
const availableTimezones = requireTest.tzlib_get_timezones();
|
|
6
|
+
const dayAfterTomorrow = new Date();
|
|
7
|
+
dayAfterTomorrow.setDate(dayAfterTomorrow.getDate() + 2);
|
|
8
|
+
let counter = 1;
|
|
9
|
+
|
|
10
|
+
console.log('\nā· Running Tests in CommonJS require environment:\n');
|
|
11
|
+
testCases.forEach((tz) => {
|
|
12
|
+
console.log(` ${counter}/${testCases.length} Testing time zone: ${tz}, CommonJS require`);
|
|
13
|
+
try {
|
|
14
|
+
const block = requireTest.tzlib_get_ical_block(tz);
|
|
15
|
+
if (!block || block === '') {
|
|
16
|
+
throw new Error(`š“ iCal block invalid`);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const offset = requireTest.tzlib_get_offset(tz, dayAfterTomorrow.toISOString().split('T')[0], '15:45');
|
|
20
|
+
if (!offset || offset === '') {
|
|
21
|
+
throw new Error(`š“ Offset is invalid`);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if (!availableTimezones.includes(tz)) {
|
|
25
|
+
throw new Error(`š“ Time zone missing in time zones list`);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
console.log(`š¢ Time zone ${tz} passed all tests\n`);
|
|
29
|
+
} catch (e) {
|
|
30
|
+
console.log(e.message + '\n');
|
|
31
|
+
console.error(e.message + '\n');
|
|
32
|
+
}
|
|
33
|
+
counter += 1;
|
|
34
|
+
});
|
package/test/load-module.mjs
CHANGED
|
@@ -1,5 +1,34 @@
|
|
|
1
1
|
// simple check to see if we can import the ES Module
|
|
2
2
|
import { tzlib_get_ical_block, tzlib_get_offset, tzlib_get_timezones } from '../dist/mjs/index.js';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
tzlib_get_timezones();
|
|
3
|
+
|
|
4
|
+
const testCases = process.argv[2] ? JSON.parse(process.argv[2]) : ['Europe/Berlin'];
|
|
5
|
+
const availableTimezones = tzlib_get_timezones();
|
|
6
|
+
const dayAfterTomorrow = new Date();
|
|
7
|
+
dayAfterTomorrow.setDate(dayAfterTomorrow.getDate() + 2);
|
|
8
|
+
let counter = 1;
|
|
9
|
+
|
|
10
|
+
console.log('\nā¶ Running Tests in ES Module import environment:\n');
|
|
11
|
+
testCases.forEach((tz) => {
|
|
12
|
+
console.log(` ${counter}/${testCases.length} Testing time zone: ${tz}, ES Module import`);
|
|
13
|
+
try {
|
|
14
|
+
const block = tzlib_get_ical_block(tz);
|
|
15
|
+
if (!block || block === '') {
|
|
16
|
+
throw new Error(`š“ iCal block invalid`);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const offset = tzlib_get_offset(tz, dayAfterTomorrow.toISOString().split('T')[0], '15:45');
|
|
20
|
+
if (!offset || offset === '') {
|
|
21
|
+
throw new Error(`š“ Offset is invalid`);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if (!availableTimezones.includes(tz)) {
|
|
25
|
+
throw new Error(`š“ Time zone missing in time zones list`);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
console.log(`š¢ Time zone ${tz} passed all tests\n`);
|
|
29
|
+
} catch (e) {
|
|
30
|
+
console.log(e.message + '\n');
|
|
31
|
+
console.error(e.message + '\n');
|
|
32
|
+
}
|
|
33
|
+
counter += 1;
|
|
34
|
+
});
|
package/test/tests.js
CHANGED
|
@@ -1,23 +1,64 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const
|
|
1
|
+
const { execSync, spawnSync } = require('child_process');
|
|
2
|
+
|
|
3
|
+
const testCases = [
|
|
4
|
+
'CST6CDT',
|
|
5
|
+
'GMT0',
|
|
6
|
+
'Europe/Berlin',
|
|
7
|
+
'America/New_York',
|
|
8
|
+
'America/Argentina/Buenos_Aires',
|
|
9
|
+
'Antarctica/Casey',
|
|
10
|
+
'Africa/Bangui',
|
|
11
|
+
];
|
|
4
12
|
|
|
5
13
|
try {
|
|
6
|
-
execSync('npm run build', { stdio: [0, 1, 2] });
|
|
14
|
+
execSync('npm run build:lib-only', { stdio: [0, 1, 2] });
|
|
15
|
+
|
|
16
|
+
const testCasesString = JSON.stringify(testCases);
|
|
17
|
+
|
|
18
|
+
console.log('\nšļø Running Tests...');
|
|
19
|
+
|
|
20
|
+
// Test ES Module import
|
|
21
|
+
try {
|
|
22
|
+
const result = spawnSync('node', ['test/load-module.mjs', testCasesString], { encoding: 'utf8' });
|
|
23
|
+
if (result.stdout) process.stdout.write(result.stdout);
|
|
24
|
+
if (result.status !== 0 || (result.stderr && result.stderr.length > 0)) {
|
|
25
|
+
throw new Error('Test script passed with errors');
|
|
26
|
+
}
|
|
27
|
+
console.log('ā
Importing the script as module and running tests\n');
|
|
28
|
+
} catch (error) {
|
|
29
|
+
console.error('ā Something went wrong with testing the ES Module setup\n');
|
|
30
|
+
throw error;
|
|
31
|
+
}
|
|
7
32
|
|
|
33
|
+
// Test CommonJS require
|
|
8
34
|
try {
|
|
9
|
-
|
|
10
|
-
|
|
35
|
+
const result = spawnSync('node', ['test/load-commonjs.cjs', testCasesString], { encoding: 'utf8' });
|
|
36
|
+
if (result.stdout) process.stdout.write(result.stdout);
|
|
37
|
+
if (result.status !== 0 || (result.stderr && result.stderr.length > 0)) {
|
|
38
|
+
throw new Error('Test script passed with errors');
|
|
39
|
+
}
|
|
40
|
+
console.log('ā
CommonJS init via require and running tests\n');
|
|
11
41
|
} catch (error) {
|
|
12
|
-
console.
|
|
42
|
+
console.error('ā Something went wrong with testing the CommonJS setup\n');
|
|
13
43
|
throw error;
|
|
14
44
|
}
|
|
15
45
|
|
|
46
|
+
// Test whether there is an ics file per test case in the api folder
|
|
47
|
+
console.log('\nāļø Testing for ics files in the API folder:\n');
|
|
16
48
|
try {
|
|
17
|
-
|
|
18
|
-
|
|
49
|
+
testCases.forEach((tz) => {
|
|
50
|
+
const fs = require('fs');
|
|
51
|
+
const path = `api/${tz}.ics`;
|
|
52
|
+
// eslint-disable-next-line security/detect-non-literal-fs-filename
|
|
53
|
+
if (!fs.existsSync(path)) {
|
|
54
|
+
throw new Error(`š“ Missing file for time zone ${tz} at API folder`);
|
|
55
|
+
}
|
|
56
|
+
console.log(`š¢ Found ics file for time zone ${tz} at API folder`);
|
|
57
|
+
});
|
|
58
|
+
console.log('ā
All time zones have a corresponding ics file in the API folder\n');
|
|
19
59
|
} catch (error) {
|
|
20
|
-
console.
|
|
60
|
+
console.error(error.message);
|
|
61
|
+
console.error('ā Could not find all ics files in the API folder\n');
|
|
21
62
|
throw error;
|
|
22
63
|
}
|
|
23
64
|
|
|
@@ -27,10 +68,10 @@ try {
|
|
|
27
68
|
if (error) {
|
|
28
69
|
throw error;
|
|
29
70
|
}
|
|
30
|
-
console.log(
|
|
31
|
-
console.log('All Tests SUCCESSFUL!\n');
|
|
71
|
+
console.log(`... ${dirToDrop} directory deleted again`);
|
|
72
|
+
console.log('\nš All Tests SUCCESSFUL!\n');
|
|
32
73
|
});
|
|
74
|
+
// eslint-disable-next-line no-unused-vars
|
|
33
75
|
} catch (error) {
|
|
34
|
-
console.
|
|
35
|
-
throw error;
|
|
76
|
+
console.error('\nš FAILED: Tests did not pass unfortunately.\n');
|
|
36
77
|
}
|
package/dist/cjs/.eslintrc.json
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{ "extends": "../../.eslintrc.json", "env": { "node": true }, "plugins": ["commonjs"] }
|