fitzroy 1.4.1 → 1.4.2

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.
Files changed (2) hide show
  1. package/dist/cli.js +41 -46
  2. package/package.json +2 -1
package/dist/cli.js CHANGED
@@ -3910,14 +3910,8 @@ var init_flags = __esm({
3910
3910
  }
3911
3911
  });
3912
3912
 
3913
- // src/cli/formatters/csv.ts
3914
- function escapeField(value) {
3915
- if (value.includes(",") || value.includes('"') || value.includes("\n") || value.includes("\r")) {
3916
- return `"${value.replace(/"/g, '""')}"`;
3917
- }
3918
- return value;
3919
- }
3920
- function dateToAestIso(date) {
3913
+ // src/cli/formatters/date-format.ts
3914
+ function toAestIso(date) {
3921
3915
  const parts = AEST_ISO_FORMATTER.formatToParts(date);
3922
3916
  const get = (type) => parts.find((p) => p.type === type)?.value ?? "";
3923
3917
  const offset = get("timeZoneName");
@@ -3925,9 +3919,34 @@ function dateToAestIso(date) {
3925
3919
  const offsetHours = offset.replace(/[^0-9]/g, "").padStart(2, "0");
3926
3920
  return `${get("year")}-${get("month")}-${get("day")}T${get("hour")}:${get("minute")}:${get("second")}${sign}${offsetHours}:00`;
3927
3921
  }
3922
+ var AEST_ISO_FORMATTER;
3923
+ var init_date_format = __esm({
3924
+ "src/cli/formatters/date-format.ts"() {
3925
+ "use strict";
3926
+ AEST_ISO_FORMATTER = new Intl.DateTimeFormat("en-AU", {
3927
+ timeZone: "Australia/Melbourne",
3928
+ year: "numeric",
3929
+ month: "2-digit",
3930
+ day: "2-digit",
3931
+ hour: "2-digit",
3932
+ minute: "2-digit",
3933
+ second: "2-digit",
3934
+ hour12: false,
3935
+ timeZoneName: "shortOffset"
3936
+ });
3937
+ }
3938
+ });
3939
+
3940
+ // src/cli/formatters/csv.ts
3941
+ function escapeField(value) {
3942
+ if (value.includes(",") || value.includes('"') || value.includes("\n") || value.includes("\r")) {
3943
+ return `"${value.replace(/"/g, '""')}"`;
3944
+ }
3945
+ return value;
3946
+ }
3928
3947
  function toStringValue(value) {
3929
3948
  if (value === null || value === void 0) return "";
3930
- if (value instanceof Date) return dateToAestIso(value);
3949
+ if (value instanceof Date) return toAestIso(value);
3931
3950
  if (typeof value === "object") return JSON.stringify(value);
3932
3951
  return String(value);
3933
3952
  }
@@ -3943,57 +3962,33 @@ function formatCsv(data) {
3943
3962
  }
3944
3963
  return lines.join("\n");
3945
3964
  }
3946
- var AEST_ISO_FORMATTER;
3947
3965
  var init_csv = __esm({
3948
3966
  "src/cli/formatters/csv.ts"() {
3949
3967
  "use strict";
3950
- AEST_ISO_FORMATTER = new Intl.DateTimeFormat("en-AU", {
3951
- timeZone: "Australia/Melbourne",
3952
- year: "numeric",
3953
- month: "2-digit",
3954
- day: "2-digit",
3955
- hour: "2-digit",
3956
- minute: "2-digit",
3957
- second: "2-digit",
3958
- hour12: false,
3959
- timeZoneName: "shortOffset"
3960
- });
3968
+ init_date_format();
3961
3969
  }
3962
3970
  });
3963
3971
 
3964
3972
  // src/cli/formatters/json.ts
3965
- function dateToAestIso2(date) {
3966
- const parts = AEST_ISO_FORMATTER2.formatToParts(date);
3967
- const get = (type) => parts.find((p) => p.type === type)?.value ?? "";
3968
- const offset = get("timeZoneName");
3969
- const sign = offset.includes("-") ? "-" : "+";
3970
- const offsetHours = offset.replace(/[^0-9]/g, "").padStart(2, "0");
3971
- return `${get("year")}-${get("month")}-${get("day")}T${get("hour")}:${get("minute")}:${get("second")}${sign}${offsetHours}:00`;
3972
- }
3973
- function jsonReplacer(_key, value) {
3974
- if (typeof value === "string" && /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d{3}Z$/.test(value)) {
3975
- return dateToAestIso2(new Date(value));
3973
+ function convertDates(value) {
3974
+ if (value instanceof Date) return toAestIso(value);
3975
+ if (Array.isArray(value)) return value.map(convertDates);
3976
+ if (value !== null && typeof value === "object") {
3977
+ const out = {};
3978
+ for (const [k, v] of Object.entries(value)) {
3979
+ out[k] = convertDates(v);
3980
+ }
3981
+ return out;
3976
3982
  }
3977
3983
  return value;
3978
3984
  }
3979
3985
  function formatJson(data) {
3980
- return JSON.stringify(data, jsonReplacer, 2);
3986
+ return JSON.stringify(convertDates(data), null, 2);
3981
3987
  }
3982
- var AEST_ISO_FORMATTER2;
3983
3988
  var init_json = __esm({
3984
3989
  "src/cli/formatters/json.ts"() {
3985
3990
  "use strict";
3986
- AEST_ISO_FORMATTER2 = new Intl.DateTimeFormat("en-AU", {
3987
- timeZone: "Australia/Melbourne",
3988
- year: "numeric",
3989
- month: "2-digit",
3990
- day: "2-digit",
3991
- hour: "2-digit",
3992
- minute: "2-digit",
3993
- second: "2-digit",
3994
- hour12: false,
3995
- timeZoneName: "shortOffset"
3996
- });
3991
+ init_date_format();
3997
3992
  }
3998
3993
  });
3999
3994
 
@@ -5279,7 +5274,7 @@ resolveAliases();
5279
5274
  var main = defineCommand11({
5280
5275
  meta: {
5281
5276
  name: "fitzroy",
5282
- version: "1.4.1",
5277
+ version: "1.4.2",
5283
5278
  description: "TypeScript port of the fitzRoy R package \u2014 fetch AFL data from the command line"
5284
5279
  },
5285
5280
  subCommands: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fitzroy",
3
- "version": "1.4.1",
3
+ "version": "1.4.2",
4
4
  "description": "TypeScript port of the fitzRoy R package — programmatic access to AFL data including match results, player stats, fixtures, ladders, and more",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -45,6 +45,7 @@
45
45
  "@clack/prompts": "^1.1.0",
46
46
  "cheerio": "^1.0.0",
47
47
  "citty": "^0.2.1",
48
+ "fitzroy": "^1.4.1",
48
49
  "picocolors": "^1.1.1",
49
50
  "zod": "^4.3.6"
50
51
  },