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/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "timezones-ical-library",
3
- "version": "1.11.0",
3
+ "version": "2.0.0",
4
4
  "engines": {
5
- "node": ">=18.17.0",
6
- "npm": ">=9.6.7"
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
- "release": "node set-release.js",
64
- "stylelint": "npx stylelint demo_assets/css/*.css",
65
- "stylelint:fix": "npm run stylelint -- --fix",
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 stylelint:fix",
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
  }
@@ -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
- requireTest.tzlib_get_ical_block('Europe/Berlin');
4
- requireTest.tzlib_get_offset('Europe/Berlin', '2023-04-15', '15:45');
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
+ });
@@ -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
- tzlib_get_ical_block('Europe/Berlin');
4
- tzlib_get_offset('Europe/Berlin', '2023-04-15', '15:45');
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
- /* eslint-disable @typescript-eslint/no-var-requires */
2
- // eslint-disable-next-line security/detect-child-process
3
- const execSync = require('child_process').execSync;
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
- execSync('node test/load-module.mjs', { stdio: [0, 1, 2] });
10
- console.log('TEST SUCCESSFUL: importing the script as module\n');
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.log('FAILED: Something went wrong with testing the ES Module setup\n');
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
- execSync('node test/load-commonjs.cjs', { stdio: [0, 1, 2] });
18
- console.log('TEST SUCCESSFUL: commonJS init via require\n');
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.log('FAILED: Something went wrong with testing the commonJS setup\n');
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(`${dirToDrop} deleted again`);
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.log('FAILED: Something went wrong with the npm build script while testing\n');
35
- throw error;
76
+ console.error('\n😭 FAILED: Tests did not pass unfortunately.\n');
36
77
  }
@@ -1 +0,0 @@
1
- { "extends": "../../.eslintrc.json", "env": { "node": true }, "plugins": ["commonjs"] }
@@ -1,7 +0,0 @@
1
- {
2
- "extends": "../.eslintrc.json",
3
- "env": {
4
- "node": true
5
- },
6
- "plugins": ["commonjs"]
7
- }