@zentered/issue-forms-body-parser 1.1.2 → 1.1.3

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/dist/index.js CHANGED
@@ -51888,9 +51888,25 @@ function getDateTimeFormat(timeZone) {
51888
51888
  return dtfCache[timeZone]
51889
51889
  }
51890
51890
 
51891
+ ;// CONCATENATED MODULE: ./node_modules/date-fns-tz/esm/_lib/newDateUTC/index.js
51892
+ /**
51893
+ * Use instead of `new Date(Date.UTC(...))` to support years below 100 which doesn't work
51894
+ * otherwise due to the nature of the
51895
+ * [`Date` constructor](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date#interpretation_of_two-digit_years.
51896
+ *
51897
+ * For `Date.UTC(...)`, use `newDateUTC(...).getTime()`.
51898
+ */
51899
+ function newDateUTC(fullYear, month, day, hour, minute, second, millisecond) {
51900
+ var utcDate = new Date(0)
51901
+ utcDate.setUTCFullYear(fullYear, month, day)
51902
+ utcDate.setUTCHours(hour, minute, second, millisecond)
51903
+ return utcDate
51904
+ }
51905
+
51891
51906
  ;// CONCATENATED MODULE: ./node_modules/date-fns-tz/esm/_lib/tzParseTimezone/index.js
51892
51907
 
51893
51908
 
51909
+
51894
51910
  var MILLISECONDS_IN_HOUR = 3600000
51895
51911
  var MILLISECONDS_IN_MINUTE = 60000
51896
51912
 
@@ -51961,23 +51977,30 @@ function tzParseTimezone(timezoneString, date, isUtcDate) {
51961
51977
  }
51962
51978
 
51963
51979
  function toUtcDate(date) {
51964
- return new Date(
51965
- Date.UTC(
51966
- date.getFullYear(),
51967
- date.getMonth(),
51968
- date.getDate(),
51969
- date.getHours(),
51970
- date.getMinutes(),
51971
- date.getSeconds(),
51972
- date.getMilliseconds()
51973
- )
51980
+ return newDateUTC(
51981
+ date.getFullYear(),
51982
+ date.getMonth(),
51983
+ date.getDate(),
51984
+ date.getHours(),
51985
+ date.getMinutes(),
51986
+ date.getSeconds(),
51987
+ date.getMilliseconds()
51974
51988
  )
51975
51989
  }
51976
51990
 
51977
51991
  function calcOffset(date, timezoneString) {
51978
51992
  var tokens = tzTokenizeDate(date, timezoneString)
51979
51993
 
51980
- var asUTC = Date.UTC(tokens[0], tokens[1] - 1, tokens[2], tokens[3] % 24, tokens[4], tokens[5])
51994
+ // ms dropped because it's not provided by tzTokenizeDate
51995
+ var asUTC = newDateUTC(
51996
+ tokens[0],
51997
+ tokens[1] - 1,
51998
+ tokens[2],
51999
+ tokens[3] % 24,
52000
+ tokens[4],
52001
+ tokens[5],
52002
+ 0
52003
+ ).getTime()
51981
52004
 
51982
52005
  var asTS = date.getTime()
51983
52006
  var over = asTS % 1000
@@ -52013,10 +52036,7 @@ function fixOffset(date, offset, timezoneString) {
52013
52036
  }
52014
52037
 
52015
52038
  function validateTimezone(hours, minutes) {
52016
- return (
52017
- (hours === 12 && (minutes == null || minutes === 0)) ||
52018
- (-11 <= hours && hours <= 11 && (minutes == null || (0 <= minutes && minutes < 59)))
52019
- )
52039
+ return -23 <= hours && hours <= 23 && (minutes == null || (0 <= minutes && minutes <= 59))
52020
52040
  }
52021
52041
 
52022
52042
  var validIANATimezoneCache = {}
@@ -52497,6 +52517,7 @@ function validateTime(hours, minutes, seconds) {
52497
52517
 
52498
52518
 
52499
52519
 
52520
+
52500
52521
  /**
52501
52522
  * @name zonedTimeToUtc
52502
52523
  * @category Time Zone Helpers
@@ -52530,7 +52551,7 @@ function zonedTimeToUtc(date, timeZone, options) {
52530
52551
 
52531
52552
  var d = toDate(date, options)
52532
52553
 
52533
- var utc = Date.UTC(
52554
+ var utc = newDateUTC(
52534
52555
  d.getFullYear(),
52535
52556
  d.getMonth(),
52536
52557
  d.getDate(),
@@ -52538,7 +52559,7 @@ function zonedTimeToUtc(date, timeZone, options) {
52538
52559
  d.getMinutes(),
52539
52560
  d.getSeconds(),
52540
52561
  d.getMilliseconds()
52541
- )
52562
+ ).getTime()
52542
52563
 
52543
52564
  var offsetMilliseconds = tzParseTimezone(timeZone, new Date(utc))
52544
52565
 
@@ -52705,7 +52726,7 @@ function formatTimezone(offset, dirtyDelimeter) {
52705
52726
  var sign = offset > 0 ? '-' : '+'
52706
52727
  var absOffset = Math.abs(offset)
52707
52728
  var hours = addLeadingZeros(Math.floor(absOffset / 60), 2)
52708
- var minutes = addLeadingZeros(absOffset % 60, 2)
52729
+ var minutes = addLeadingZeros(Math.floor(absOffset % 60), 2)
52709
52730
  return sign + hours + delimeter + minutes
52710
52731
  }
52711
52732
 
@@ -53252,10 +53273,12 @@ async function parseMD(body) {
53252
53273
  const current = tokens.children[idx]
53253
53274
  const hasNext = idx + 1 < tokens.children.length
53254
53275
 
53255
- const obj = {}
53256
53276
  if (current.type === 'heading') {
53257
- obj.id = slugify(current.children[0].value)
53258
- obj.title = current.children[0].value
53277
+ // issue-form answers start with a h3 heading, ignore everything else
53278
+ const obj = {
53279
+ id: slugify(current.children[0].value),
53280
+ title: current.children[0].value
53281
+ }
53259
53282
  if (hasNext) {
53260
53283
  const next = tokens.children[idx + 1]
53261
53284
  if (next.type === 'list') {
@@ -53274,8 +53297,8 @@ async function parseMD(body) {
53274
53297
  obj.time = time
53275
53298
  }
53276
53299
  }
53300
+ r.push(obj)
53277
53301
  }
53278
- r.push(obj)
53279
53302
  }
53280
53303
 
53281
53304
  return r
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zentered/issue-forms-body-parser",
3
- "version": "1.1.2",
3
+ "version": "1.1.3",
4
4
  "private": false,
5
5
  "description": "Parser for GitHub Issue Form body, also available as GitHub Action",
6
6
  "keywords": [
@@ -55,10 +55,10 @@
55
55
  },
56
56
  "dependencies": {
57
57
  "@actions/core": "^1.6.0",
58
- "@actions/github": "^5.0.0",
58
+ "@actions/github": "^5.0.1",
59
59
  "@sindresorhus/slugify": "^2.1.0",
60
60
  "date-fns": "^2.28.0",
61
- "date-fns-tz": "^1.3.0",
61
+ "date-fns-tz": "^1.3.3",
62
62
  "remark-gfm": "^3.0.1",
63
63
  "remark-parse": "^10.0.1",
64
64
  "remark-stringify": "^10.0.2",
@@ -68,15 +68,15 @@
68
68
  "@commitlint/config-conventional": "^16.2.1",
69
69
  "@vercel/ncc": "^0.33.3",
70
70
  "commitlint": "^16.2.3",
71
- "eslint": "^8.11.0",
71
+ "eslint": "^8.12.0",
72
72
  "eslint-plugin-json": "^3.1.0",
73
73
  "eslint-plugin-node": "^11.1.0",
74
74
  "husky": "^7.0.4",
75
75
  "license-checker": "^25.0.1",
76
76
  "npm-run-all": "^4.1.5",
77
77
  "pinst": "^3.0.0",
78
- "prettier": "^2.6.0",
79
- "tap": "^16.0.0"
78
+ "prettier": "^2.6.2",
79
+ "tap": "^16.0.1"
80
80
  },
81
81
  "release": {
82
82
  "branches": [
package/src/parse.js CHANGED
@@ -92,10 +92,12 @@ export default async function parseMD(body) {
92
92
  const current = tokens.children[idx]
93
93
  const hasNext = idx + 1 < tokens.children.length
94
94
 
95
- const obj = {}
96
95
  if (current.type === 'heading') {
97
- obj.id = slugify(current.children[0].value)
98
- obj.title = current.children[0].value
96
+ // issue-form answers start with a h3 heading, ignore everything else
97
+ const obj = {
98
+ id: slugify(current.children[0].value),
99
+ title: current.children[0].value
100
+ }
99
101
  if (hasNext) {
100
102
  const next = tokens.children[idx + 1]
101
103
  if (next.type === 'list') {
@@ -114,8 +116,8 @@ export default async function parseMD(body) {
114
116
  obj.time = time
115
117
  }
116
118
  }
119
+ r.push(obj)
117
120
  }
118
- r.push(obj)
119
121
  }
120
122
 
121
123
  return r
@@ -90,3 +90,15 @@ test('parse(md) should parse GitHub Issue Form data into useful, structured data
90
90
  // console.log(JSON.stringify(actual, null, 0))
91
91
  t.deepEqual(actual, expected)
92
92
  })
93
+
94
+ test('parse(md) return nothing', async (t) => {
95
+ const expected = []
96
+
97
+ const md = await readFile(
98
+ join(process.cwd(), 'test', 'test-issue-2.md'),
99
+ 'utf8'
100
+ )
101
+ const actual = await fn(md)
102
+ // console.log(JSON.stringify(actual, null, 0))
103
+ t.deepEqual(actual, expected)
104
+ })
@@ -0,0 +1,10 @@
1
+ ---
2
+ startDate: 10.03.2022
3
+ startTime: 10.00
4
+ duration: 1h
5
+ location: online
6
+ ---
7
+
8
+ Let's chat about tech, coding and Cyprus.
9
+
10
+ https://discord.gg/qA7wHjbs?event=948887583507755048