snowymoon 1.0.0 → 1.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/README.md CHANGED
@@ -6,10 +6,16 @@ each mod, and downloads/extracts them for you.
6
6
 
7
7
  Requires [Bun](https://bun.sh) installed.
8
8
 
9
+ ## Install
10
+
11
+ ```
12
+ bun install -g snowymoon
13
+ ```
14
+
9
15
  ## Usage
10
16
 
11
17
  ```
12
- bunx snowymoon
18
+ snowymoon
13
19
  ```
14
20
 
15
21
  First run asks for your ETS2/ATS `bin/win_x64` path (auto-detects the default Steam
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "snowymoon",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "CLI updater that downloads the latest Snowymoon lighting/DLSS mods into your ETS2/ATS bin/win_x64 folder",
5
5
  "type": "module",
6
6
  "bin": {
7
- "snowymoon": "./src/index.ts"
7
+ "snowymoon": "src/index.ts"
8
8
  },
9
9
  "files": [
10
10
  "src"
package/src/index.ts CHANGED
@@ -65,15 +65,28 @@ function getBinPath(): string {
65
65
  if (saved?.binPath) return saved.binPath;
66
66
 
67
67
  const detected = DEFAULT_CANDIDATES.find((p) => existsSync(p));
68
- const binPath = prompt("Where is your ETS2 bin path?", detected ?? "");
69
68
 
70
- if (!binPath) {
71
- log.error("No path provided.");
72
- process.exit(1);
73
- }
69
+ while (true) {
70
+ const binPath = prompt("Where is your ETS2 bin path?", detected ?? "");
71
+
72
+ if (!binPath) {
73
+ log.error("No path provided.");
74
+ process.exit(1);
75
+ }
74
76
 
75
- saveConfig({ binPath });
76
- return binPath;
77
+ if (
78
+ !existsSync(join(binPath, "eurotrucks2.exe")) &&
79
+ !existsSync(join(binPath, "amtrucks.exe"))
80
+ ) {
81
+ log.error(
82
+ `That doesn't look like a bin\\win_x64 folder (no eurotrucks2.exe/amtrucks.exe found in ${binPath})`,
83
+ );
84
+ continue;
85
+ }
86
+
87
+ saveConfig({ binPath });
88
+ return binPath;
89
+ }
77
90
  }
78
91
 
79
92
  const SITE_URL = "https://snowymoon.io/";
@@ -232,9 +245,13 @@ async function syncPackages(binPath: string) {
232
245
  const tmpDir = join(CONFIG_DIR, "downloads");
233
246
  mkdirSync(tmpDir, { recursive: true });
234
247
 
248
+ // All questions are asked up front (no downloads/extraction in between),
249
+ // because interleaving async I/O with sync prompt() calls on piped stdin
250
+ // corrupts the next read.
251
+ const toUpdate: { pkg: (typeof PACKAGES)[number]; url: string; version: string }[] = [];
252
+
235
253
  for (const pkg of PACKAGES) {
236
254
  const { url, version } = findLatest(html, pkg);
237
- const filename = filenameFromUrl(url);
238
255
 
239
256
  // The cached version only counts if the files it refers to are still
240
257
  // actually there -- otherwise someone deleted them and we need to redo it.
@@ -253,10 +270,21 @@ async function syncPackages(binPath: string) {
253
270
  `${pkg.name}: ${installedVersion ? `old version ${installedVersion} found, ` : ""}latest is ${version}`,
254
271
  );
255
272
 
273
+ const answer = prompt(`Update ${pkg.name} to ${version} now? [y/N]`, "n");
274
+ if (answer?.trim().toLowerCase()[0] !== "y") {
275
+ log.warn(`${pkg.name}: skipped`);
276
+ continue;
277
+ }
278
+
279
+ toUpdate.push({ pkg, url, version });
280
+ }
281
+
282
+ for (const { pkg, url, version } of toUpdate) {
283
+ const filename = filenameFromUrl(url);
256
284
  const zipPath = join(tmpDir, filename);
257
285
  await downloadFile(url, zipPath, pkg.name);
258
286
 
259
- if (installedVersion) removeOldFiles(binPath, pkg.files);
287
+ removeOldFiles(binPath, pkg.files);
260
288
 
261
289
  await withSpinner(
262
290
  `${pkg.name}: extracting into ${binPath}`,