liftie 4.0.0 → 4.0.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.
package/Makefile CHANGED
@@ -10,11 +10,14 @@ LINT_SRC = app.js bin/generate lib test
10
10
 
11
11
  PLUGINS = lifts weather webcams snow
12
12
 
13
+ ESBUILD_FORMAT = esm
14
+
13
15
  ESBUILD_OPTS += \
14
16
  --bundle \
15
17
  --log-level=warning \
16
18
  --color=false \
17
19
  --tree-shaking=true \
20
+ --format=${ESBUILD_FORMAT} \
18
21
  --target=es2018
19
22
 
20
23
  ESBUILD_MIN_OPTS += \
@@ -57,6 +60,7 @@ all: lint test build
57
60
  --use postcss-cachify \
58
61
  --postcss-cachify.baseUrl /stylesheets \
59
62
  --postcss-cachify.basePath public \
63
+ --postcss-cachify.format name \
60
64
  --output $@ $@
61
65
 
62
66
  %.min.css: %.css
@@ -94,9 +98,11 @@ $(BUILD_DIR)/$(PROJECT).js: lib/client/boot/index.js $(SRC) node_modules | $(BUI
94
98
  $(BUILD_DIR)/$(PROJECT).min.js: lib/client/boot/index.js $(SRC) node_modules | $(BUILD_DIR)
95
99
  $(RUN_ESBUILD_MIN)
96
100
 
101
+ $(BUILD_DIR)/$(PROJECT)-embed.js: ESBUILD_FORMAT=iife
97
102
  $(BUILD_DIR)/$(PROJECT)-embed.js: lib/embed/index.js | $(BUILD_DIR)
98
103
  $(RUN_ESBUILD)
99
104
 
105
+ $(BUILD_DIR)/$(PROJECT)-embed.min.js: ESBUILD_FORMAT=iife
100
106
  $(BUILD_DIR)/$(PROJECT)-embed.min.js: lib/embed/index.js | $(BUILD_DIR)
101
107
  $(RUN_ESBUILD_MIN)
102
108
 
package/app.js CHANGED
@@ -28,7 +28,7 @@ process.env.NODE_ENV ??= 'development';
28
28
  const root = path.join(path.dirname(new URL(import.meta.url).pathname), 'public');
29
29
  const { SITE_URL: siteUrl, LIFTIE_STATIC_HOST: staticHost = '' } = process.env;
30
30
 
31
- const cachify = cachifyStatic(root);
31
+ const cachify = cachifyStatic(root, { format: 'name' });
32
32
 
33
33
  app.locals = {
34
34
  min: '.min',
package/lib/cli/fetch.js CHANGED
@@ -3,22 +3,21 @@ import { program } from 'commander';
3
3
  import curl from './curl.js';
4
4
  import { descriptorPath } from './dirs.js';
5
5
 
6
- let done;
7
-
8
6
  async function fetchExample(resortId) {
9
7
  try {
10
8
  const resort = JSON.parse(readFileSync(descriptorPath(resortId), 'utf8'));
11
- done = true;
12
9
  await curl(resort.dataUrl || resort.api || resort.url, resortId);
13
- } catch (e) {
14
- console.error(resortId, 'is not a valid resort ID', e);
10
+ } catch {
11
+ console.error(`"${resortId}" is not a valid resort ID`);
15
12
  process.exit(1);
16
13
  }
17
14
  }
18
15
 
19
- program.arguments('<resort-id>').action(fetchExample).parse(process.argv);
20
-
21
- if (!done) {
22
- program.outputHelp();
23
- process.exit(1);
24
- }
16
+ program
17
+ .arguments('<resort-id>')
18
+ .action(fetchExample)
19
+ .parseAsync()
20
+ .catch(e => {
21
+ console.error(e);
22
+ process.exit(1);
23
+ });
@@ -1,14 +1,8 @@
1
- import { readdir } from 'node:fs';
1
+ import { readdirSync } from 'node:fs';
2
2
  import { lib } from './dirs.js';
3
3
  export default forEachResort;
4
4
 
5
5
  function forEachResort(fn) {
6
6
  console.log('Reading:', lib);
7
- readdir(lib, { withFileTypes: true }, (err, dirents) => {
8
- if (err) {
9
- console.error(err);
10
- process.exit(1);
11
- }
12
- dirents.filter(dirent => dirent.isDirectory()).forEach(({ name }) => fn(name));
13
- });
7
+ readdirSync(lib, { withFileTypes: true }).forEach(dirent => dirent.isDirectory() && fn(dirent.name));
14
8
  }
@@ -52,7 +52,7 @@ const schema = [
52
52
  }
53
53
  ];
54
54
 
55
- program.option('-j, --json <file>', 'JSON file with resort data', String).parse(process.argv);
55
+ program.option('-j, --json <file>', 'JSON file with resort data', String).parse();
56
56
 
57
57
  if (program.json) {
58
58
  fname = path.resolve(program.json);
package/lib/cli/noaa.js CHANGED
@@ -1,10 +1,8 @@
1
- import { readFileSync, writeFileSync } from 'node:fs';
1
+ import { readFile, writeFile } from 'node:fs/promises';
2
2
  import { program } from 'commander';
3
3
  import { descriptorPath } from './dirs.js';
4
4
  import forEachResort from './for-each-resort.js';
5
5
 
6
- let done = false;
7
-
8
6
  const userAgent = 'Mozilla/5.0 (compatible; Liftie/1.0; +https://liftie.info)';
9
7
 
10
8
  function points([lon, lat]) {
@@ -16,49 +14,47 @@ function points([lon, lat]) {
16
14
  }
17
15
 
18
16
  function fetchNoaa(resortId, options) {
19
- done = true;
20
-
21
17
  if (resortId) {
22
18
  noaaForResort(resortId, options);
23
19
  } else {
24
- forEachResort(resortId => noaaForResort(resortId, options));
20
+ forEachResort(resortId => noaaForResort(resortId, options).catch(e => console.error(resortId, e)));
25
21
  }
26
22
  }
27
23
 
28
- function noaaForResort(resortId, { overwrite }) {
29
- const descriptor = readDescriptor(resortId);
24
+ async function noaaForResort(resortId, { overwrite }) {
25
+ const descriptor = await readDescriptor(resortId);
30
26
 
31
27
  const { ll } = descriptor;
32
- fetch(`https://api.weather.gov/points/${points(ll)}`, {
28
+ const res = await fetch(`https://api.weather.gov/points/${points(ll)}`, {
33
29
  headers: {
34
30
  'User-Agent': userAgent,
35
31
  Accept: 'application/geo+json'
36
32
  }
37
- })
38
- .then(res => res.json())
39
- .then(body => {
40
- const {
41
- properties: { gridId, gridX, gridY }
42
- } = body;
43
- const noaa = `${gridId}/${gridX},${gridY}`;
44
- if (overwrite) {
45
- descriptor.noaa = noaa;
46
- writeDescriptor(resortId, descriptor);
47
- }
48
- console.log(resortId, noaa);
49
- })
50
- .catch(e => console.error('Cannot find NOAA station for:', resortId, e));
33
+ });
34
+ if (res.status !== 200) {
35
+ console.error('Cannot find NOAA station for:', resortId);
36
+ return;
37
+ }
38
+ const {
39
+ properties: { gridId, gridX, gridY }
40
+ } = await res.json();
41
+ const noaa = `${gridId}/${gridX},${gridY}`;
42
+ if (overwrite) {
43
+ descriptor.noaa = noaa;
44
+ await writeDescriptor(resortId, descriptor);
45
+ }
46
+ console.log(resortId, noaa);
51
47
  }
52
48
 
53
49
  function writeDescriptor(resortId, descriptor) {
54
50
  const filename = descriptorPath(resortId);
55
- writeFileSync(filename, `${JSON.stringify(descriptor, null, 2)}\n`);
51
+ return writeFile(filename, `${JSON.stringify(descriptor, null, 2)}\n`);
56
52
  }
57
53
 
58
- function readDescriptor(resortId) {
54
+ async function readDescriptor(resortId) {
59
55
  try {
60
56
  const filename = descriptorPath(resortId);
61
- return JSON.parse(readFileSync(filename, 'utf8'));
57
+ return JSON.parse(await readFile(filename, 'utf8'));
62
58
  } catch {
63
59
  console.error(resortId, 'is not a valid resort ID');
64
60
  process.exit(1);
@@ -69,9 +65,4 @@ program
69
65
  .option('--overwrite', 'overwrite resort descriptor with new value')
70
66
  .arguments('[resort-id]')
71
67
  .action(fetchNoaa)
72
- .parse(process.argv);
73
-
74
- if (!done) {
75
- program.outputHelp();
76
- process.exit(1);
77
- }
68
+ .parse();
@@ -13,5 +13,5 @@
13
13
  ],
14
14
  "twitter": "resortalyeska",
15
15
  "opening": "2017-12-15",
16
- "noaa": "AER/139,227"
16
+ "noaa": "AER/157,227"
17
17
  }
@@ -15,5 +15,5 @@
15
15
  44.077778
16
16
  ],
17
17
  "opening": "2017-12-15",
18
- "noaa": "GYX/39,72"
18
+ "noaa": "GYX/35,71"
19
19
  }
@@ -14,5 +14,5 @@
14
14
  44.077122
15
15
  ],
16
16
  "twitter": "bretton_woods",
17
- "noaa": "GYX/37,71"
17
+ "noaa": "GYX/33,70"
18
18
  }
@@ -14,5 +14,5 @@
14
14
  44.156452
15
15
  ],
16
16
  "twitter": "cannonmountain",
17
- "noaa": "GYX/25,73"
17
+ "noaa": "GYX/21,72"
18
18
  }
@@ -14,5 +14,5 @@
14
14
  ],
15
15
  "twitter": "CranmoreMtn",
16
16
  "opening": "2017-12-02",
17
- "noaa": "GYX/45,72"
17
+ "noaa": "GYX/41,71"
18
18
  }
@@ -14,5 +14,5 @@
14
14
  ],
15
15
  "twitter": "Gunstockmtn",
16
16
  "opening": "2017-12-01",
17
- "noaa": "GYX/41,47"
17
+ "noaa": "GYX/37,46"
18
18
  }
@@ -18,5 +18,5 @@
18
18
  ],
19
19
  "twitter": "KingPineSkiarea",
20
20
  "opening": "2017-12-15",
21
- "noaa": "GYX/47,63"
21
+ "noaa": "GYX/43,62"
22
22
  }
@@ -18,5 +18,5 @@
18
18
  ],
19
19
  "twitter": "loonmtn",
20
20
  "opening": "2017-11-22",
21
- "noaa": "GYX/28,69"
21
+ "noaa": "GYX/24,68"
22
22
  }
@@ -14,5 +14,5 @@
14
14
  43.341194
15
15
  ],
16
16
  "opening": "2017-12-05",
17
- "noaa": "GYX/19,34"
17
+ "noaa": "GYX/15,33"
18
18
  }
@@ -18,5 +18,5 @@
18
18
  ],
19
19
  "twitter": "patspeak",
20
20
  "opening": "2017-12-09",
21
- "noaa": "GYX/28,28"
21
+ "noaa": "GYX/24,27"
22
22
  }
@@ -18,5 +18,5 @@
18
18
  ],
19
19
  "twitter": "pleasantmtnme",
20
20
  "opening": "2022-09-02",
21
- "noaa": "GYX/55,73"
21
+ "noaa": "GYX/51,72"
22
22
  }
@@ -14,5 +14,5 @@
14
14
  ],
15
15
  "twitter": "raggedmtnNH",
16
16
  "opening": "2017-12-07",
17
- "noaa": "GYX/25,42"
17
+ "noaa": "GYX/21,41"
18
18
  }
@@ -13,5 +13,5 @@
13
13
  44.983387
14
14
  ],
15
15
  "twitter": "SaddlebackMaine",
16
- "noaa": "GYX/53,117"
16
+ "noaa": "GYX/49,116"
17
17
  }
@@ -18,5 +18,5 @@
18
18
  ],
19
19
  "twitter": "SugarloafMaine",
20
20
  "opening": "2017-11-23",
21
- "noaa": "GYX/63,123"
21
+ "noaa": "GYX/59,122"
22
22
  }
@@ -18,5 +18,5 @@
18
18
  ],
19
19
  "twitter": "sundayriver",
20
20
  "opening": "2017-11-22",
21
- "noaa": "GYX/48,96"
21
+ "noaa": "GYX/44,95"
22
22
  }
@@ -18,5 +18,5 @@
18
18
  43.961613
19
19
  ],
20
20
  "twitter": "waterville",
21
- "noaa": "GYX/32,65"
21
+ "noaa": "GYX/28,64"
22
22
  }
@@ -15,5 +15,5 @@
15
15
  ],
16
16
  "twitter": "skiwildcat",
17
17
  "opening": "2017-11-25",
18
- "noaa": "GYX/39,81"
18
+ "noaa": "GYX/35,80"
19
19
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "liftie",
3
- "version": "4.0.0",
3
+ "version": "4.0.2",
4
4
  "description": "Clean, simple, easy to read, fast ski resort lift status",
5
5
  "type": "module",
6
6
  "keywords": [
@@ -60,9 +60,9 @@
60
60
  "devDependencies": {
61
61
  "@biomejs/biome": "2.2.6",
62
62
  "@pirxpilot/stylus": "^1.2.0",
63
- "commander": "~13",
63
+ "commander": "~14",
64
64
  "postcss": "~8",
65
- "postcss-cachify": "^4.0.0",
65
+ "postcss-cachify": "^5.0.0",
66
66
  "postcss-cli-simple": "~4.0.0",
67
67
  "prompt": "~1",
68
68
  "undici": "^7.10.0"