Skip to content

Commit c2552bd

Browse files
committed
Merge remote-tracking branch 'origin/deps'
2 parents 32622c3 + 223ae3a commit c2552bd

9 files changed

Lines changed: 141 additions & 26 deletions

File tree

.github/workflows/check.yaml

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
name: check
2-
on: [push]
2+
on:
3+
push:
4+
tags-ignore:
5+
- '[0-9]+.[0-9]+.[0-9]+'
6+
branches:
7+
- '**'
8+
39
jobs:
410
build:
511
runs-on: ubuntu-latest
612
steps:
7-
- uses: actions/checkout@v4
8-
- uses: actions/setup-node@v4
13+
- uses: actions/checkout@v5
14+
- uses: actions/setup-node@v6
915
with:
10-
node-version: 'lts/*'
11-
- run: yarn install
16+
node-version: lts/*
17+
- run: npm install
1218
- run: make check

.github/workflows/publish.yaml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: publish
2+
3+
on:
4+
push:
5+
tags:
6+
- '[0-9]+.[0-9]+.[0-9]+'
7+
8+
permissions:
9+
id-token: write # Required for OIDC
10+
contents: read
11+
12+
jobs:
13+
publish:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v5
17+
- uses: actions/setup-node@v6
18+
with:
19+
node-version: 'lts/*'
20+
21+
# Ensure npm 11.5.1 or later is installed
22+
- name: update npm
23+
run: npm install -g npm@latest
24+
- run: npm install
25+
- run: make check
26+
- run: npm publish

biome.json

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
11
{
2-
"$schema": "https://biomejs.dev/schemas/1.9.4/schema.json",
3-
"organizeImports": {
4-
"enabled": true
2+
"$schema": "./node_modules/@biomejs/biome/configuration_schema.json",
3+
"assist": {
4+
"actions": {
5+
"source": {
6+
"organizeImports": "on"
7+
}
8+
}
59
},
610
"vcs": {
11+
"enabled": true,
12+
"clientKind": "git",
713
"useIgnoreFile": true
814
},
915
"files": {
10-
"ignoreUnknown": true,
11-
"ignore": ["package.json"]
16+
"ignoreUnknown": true
1217
},
1318
"formatter": {
1419
"enabled": true,
@@ -22,22 +27,35 @@
2227
"arrowParentheses": "asNeeded"
2328
}
2429
},
30+
"json": {
31+
"formatter": {
32+
"expand": "always"
33+
}
34+
},
2535
"linter": {
2636
"enabled": true,
37+
"domains": {
38+
"project": "recommended"
39+
},
2740
"rules": {
2841
"recommended": true,
2942
"correctness": {
43+
"noUndeclaredDependencies": "error",
3044
"noUndeclaredVariables": "error",
31-
"noUnusedVariables": "error"
45+
"noUnusedVariables": "error",
46+
"useImportExtensions": "error",
47+
"useJsonImportAttributes": "error"
3248
},
3349
"complexity": {
34-
"noForEach": "off",
35-
"useArrowFunction": "off",
36-
"useLiteralKeys": "off"
50+
"noForEach": "off"
3751
},
3852
"style": {
39-
"noParameterAssign": "off",
40-
"useTemplate": "off"
53+
"noUnusedTemplateLiteral": "error",
54+
"noUselessElse": "error",
55+
"useBlockStatements": "error",
56+
"useDefaultParameterLast": "error",
57+
"useNumberNamespace": "error",
58+
"useSingleVarDeclarator": "error"
4159
},
4260
"performance": {
4361
"noDelete": "off"

lib/ical.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,19 @@ function id2uuid(id, day) {
1111
if (day) {
1212
id += day;
1313
}
14-
return uuid(id, NAMESPACE) + '@furkot.com';
14+
return `${uuid(id, NAMESPACE)}@furkot.com`;
1515
}
1616

1717
function ts2date(ts) {
1818
// remove dashes and colons and strip milliseconds
1919
return new Date(ts).toISOString().replace(/[-:]/g, '').slice(0, -5);
2020
}
2121

22-
export default function* ical({ metadata, routes }) {
22+
function tzid(property, tz) {
23+
return tz ? `${property};TZID=${tz}` : property;
24+
}
25+
26+
export default function* ical({ metadata, routes, options = {} }) {
2327
const dtstamp = ts2date(Date.now());
2428

2529
yield* property('BEGIN', 'VCALENDAR');
@@ -40,8 +44,9 @@ export default function* ical({ metadata, routes }) {
4044
yield* property('URL', step.url);
4145
yield* property('LOCATION', step.address);
4246
yield* property('GEO', [step.coordinates.lat, step.coordinates.lon], formatArray);
43-
yield* property('DTSTART', ts2date(step.arrival_time));
44-
yield* property('DTEND', ts2date(step.departure_time));
47+
const tz = options.tzid && step.timezone?.name;
48+
yield* property(tzid('DTSTART', tz), ts2date(step.arrival_time));
49+
yield* property(tzid('DTEND', tz), ts2date(step.departure_time));
4550
yield* property('END', 'VEVENT');
4651
}
4752
yield* property('END', 'VCALENDAR');

lib/property.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export default function* property(name, value, format = formatText) {
1010
return;
1111
}
1212
value = format(value);
13-
const line = name + ':' + value;
13+
const line = `${name}:${value}`;
1414
const ab = encoder.encode(line);
1515

1616
const buffer = new Uint8Array(ab);

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@
2525
"iCal"
2626
],
2727
"dependencies": {
28-
"uuid": "~11"
28+
"uuid": "~13"
2929
},
3030
"devDependencies": {
31-
"@biomejs/biome": "^1.9.4"
31+
"@biomejs/biome": "2.3.13"
3232
},
3333
"scripts": {
3434
"test": "make check"

test/fixtures/simple-trip.json

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,10 @@
3434
"visit_duration": 0,
3535
"nights": 0,
3636
"arrival_time": 1373274000000,
37-
"departure_time": 1373274000000
37+
"departure_time": 1373274000000,
38+
"timezone": {
39+
"name": "America/Los_Angeles"
40+
}
3841
},
3942
{
4043
"id": "5144f7cbd6e4d26079000009",
@@ -58,7 +61,10 @@
5861
"driving": 11580,
5962
"nights": 0,
6063
"arrival_time": 1373285580000,
61-
"departure_time": 1373286480000
64+
"departure_time": 1373286480000,
65+
"timezone": {
66+
"name": "America/Los_Angeles"
67+
}
6268
},
6369
{
6470
"id": "5144f7dfd6e4d2607900000a",
@@ -84,6 +90,9 @@
8490
"nights": 0,
8591
"arrival_time": 1373304660000,
8692
"departure_time": 1373305560000,
93+
"timezone": {
94+
"name": "America/Los_Angeles"
95+
},
8796
"symbol": "Gas Station"
8897
},
8998
{
@@ -108,7 +117,10 @@
108117
"driving": 6595,
109118
"nights": 0,
110119
"arrival_time": 1373312155000,
111-
"departure_time": 1373312155000
120+
"departure_time": 1373312155000,
121+
"timezone": {
122+
"name": "America/Los_Angeles"
123+
}
112124
}
113125
],
114126
"name": ""

test/fixtures/simple_tz.ics

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
BEGIN:VCALENDAR
2+
VERSION:2.0
3+
PRODID:-//code42day//Furkot - road trip planner//EN
4+
BEGIN:VEVENT
5+
DTSTAMP:20220529T071758
6+
UID:50d1b16d-3cc5-501a-9ab1-fa68286a011f@furkot.com
7+
SUMMARY:San Francisco
8+
LOCATION:San Francisco\, CA
9+
GEO:37.7749295;-122.41941550000001
10+
DTSTART;TZID=America/Los_Angeles:20130708T090000
11+
DTEND;TZID=America/Los_Angeles:20130708T090000
12+
END:VEVENT
13+
BEGIN:VEVENT
14+
DTSTAMP:20220529T071758
15+
UID:d2a184cf-7264-570f-9880-003054b10222@furkot.com
16+
SUMMARY:Redding
17+
LOCATION:1510 Gordon Lane\, Redding\, CA 96002\, USA
18+
GEO:40.54720023441049;-122.34375
19+
DTSTART;TZID=America/Los_Angeles:20130708T121300
20+
DTEND;TZID=America/Los_Angeles:20130708T122800
21+
END:VEVENT
22+
BEGIN:VEVENT
23+
DTSTAMP:20220529T071758
24+
UID:b66792fd-6bd2-5c84-91e7-27c6cd532a54@furkot.com
25+
SUMMARY:Lane
26+
LOCATION:51-559 Walnut Place\, Springfield\, OR 97477\, USA
27+
GEO:44.04811573082351;-123.046875
28+
DTSTART;TZID=America/Los_Angeles:20130708T173100
29+
DTEND;TZID=America/Los_Angeles:20130708T174600
30+
END:VEVENT
31+
BEGIN:VEVENT
32+
DTSTAMP:20220529T071758
33+
UID:924fc5db-ab1d-5406-8a50-af6943d1c2f1@furkot.com
34+
SUMMARY:Portland
35+
DESCRIPTION:Trip notes for first stop
36+
LOCATION:Portland\, OR
37+
GEO:45.5234515;-122.6762071
38+
DTSTART;TZID=America/Los_Angeles:20130708T193555
39+
DTEND;TZID=America/Los_Angeles:20130708T193555
40+
END:VEVENT
41+
END:VCALENDAR

test/ical.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,13 @@ describe('ical', () => {
4646
compareLines(generated, expected);
4747
});
4848

49+
it('simple trip with TZID', () => {
50+
const generated = ical({ ...simpleTrip, options: { tzid: true } });
51+
const expected = readFileSync('fixtures/simple_tz.ics');
52+
53+
compareLines(generated, expected);
54+
});
55+
4956
it('multi trip', () => {
5057
const generated = ical(multiTrip);
5158
const expected = readFileSync('fixtures/multi.ics');

0 commit comments

Comments
 (0)