orc-scripts 4.0.5 → 4.0.8

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,6 +1,6 @@
1
1
  {
2
2
  "name": "orc-scripts",
3
- "version": "4.0.5",
3
+ "version": "4.0.8",
4
4
  "description": "Scripts toolbox for Orckestra",
5
5
  "type": "commonjs",
6
6
  "bin": {
@@ -109,6 +109,7 @@
109
109
  "pkg-dir": "^4.0.0",
110
110
  "polished": "^3.4.2",
111
111
  "prettier": "^3.3.2",
112
+ "prettier-plugin-sort-json": "^4.1.1",
112
113
  "react": "^17.0.2",
113
114
  "react-big-calendar": "^1.13.0",
114
115
  "react-datepicker": "^3.0.0",
@@ -6,6 +6,14 @@ const config = {
6
6
  arrowParens: "avoid",
7
7
  endOfLine: "auto",
8
8
  semi: true,
9
+ overrides: [
10
+ {
11
+ files: ["./src/translations/*.json"],
12
+ options: {
13
+ plugins: ["prettier-plugin-sort-json"],
14
+ },
15
+ },
16
+ ],
9
17
  };
10
18
 
11
19
  export default config;
@@ -0,0 +1,101 @@
1
+ const fs = require("fs");
2
+ const https = require("https");
3
+ const jsdom = require("jsdom");
4
+
5
+ let outputFile = "";
6
+ let windowsZonesUrl = "";
7
+
8
+ if (process.argv.includes("--outputFile")) {
9
+ outputFile = process.argv[process.argv.indexOf("--outputFile") + 1];
10
+ }
11
+
12
+ if (!outputFile) {
13
+ throw new Error("Missing --outputFile 'file' argument.");
14
+ }
15
+
16
+ if (process.argv.includes("--windowsZonesUrl")) {
17
+ windowsZonesUrl = process.argv[process.argv.indexOf("--windowsZonesUrl") + 1];
18
+ } else {
19
+ windowsZonesUrl =
20
+ "https://raw.githubusercontent.com/unicode-org/cldr/refs/heads/main/common/supplemental/windowsZones.xml";
21
+ }
22
+
23
+ downloadUrl();
24
+
25
+ function extractTimeZones(timeZones) {
26
+ const result = {
27
+ ianaToWindows: {},
28
+ windowsToIana: {},
29
+ };
30
+
31
+ const dom = new jsdom.JSDOM(timeZones);
32
+ const parser = new dom.window.DOMParser();
33
+
34
+ const xmlDoc = parser.parseFromString(timeZones, "application/xml");
35
+ const mapZones = xmlDoc.getElementsByTagName("mapZone");
36
+
37
+ for (let zone of mapZones) {
38
+ const key = zone.getAttribute("other");
39
+ const type = zone.getAttribute("type");
40
+
41
+ if (!result.windowsToIana[key]) {
42
+ result.windowsToIana[key] = [];
43
+ }
44
+
45
+ const types = type.split(" ");
46
+
47
+ for (let t of types) {
48
+ if (!result.windowsToIana[key].includes(t)) {
49
+ result.windowsToIana[key].push(t);
50
+ }
51
+
52
+ if (!result.ianaToWindows[t]) {
53
+ result.ianaToWindows[t] = [];
54
+ }
55
+
56
+ if (!result.ianaToWindows[t].includes(key)) {
57
+ result.ianaToWindows[t].push(key);
58
+ }
59
+ }
60
+ }
61
+
62
+ return result;
63
+ }
64
+
65
+ function downloadUrl() {
66
+ https
67
+ .get(windowsZonesUrl, {}, resp => {
68
+ let data = "";
69
+ let error = "";
70
+
71
+ if (resp.statusCode !== 200) {
72
+ error = new Error(`Request Failed. Status Code: ${resp.statusCode}`);
73
+ }
74
+ if (error) {
75
+ console.error(error.message);
76
+ // Consume response data to free up memory
77
+ resp.resume();
78
+ return;
79
+ }
80
+
81
+ // A chunk of data has been received.
82
+ resp.on("data", chunk => {
83
+ data += chunk;
84
+ });
85
+
86
+ // The whole response has been received. Print out the result.
87
+ resp.on("end", () => {
88
+ const result = extractTimeZones(data);
89
+
90
+ fs.writeFile(outputFile, JSON.stringify(result, null, 2), function (err) {
91
+ if (err) {
92
+ return console.error(err);
93
+ }
94
+ console.log(`File '${outputFile}' has been created`);
95
+ });
96
+ });
97
+ })
98
+ .on("error", err => {
99
+ console.log("Error: " + err.message);
100
+ });
101
+ }