stock-weekly-report 0.1.2 → 0.1.4
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/cli.py +2 -2
- package/config_manager.py +1 -0
- package/package.json +5 -3
- package/pyproject.toml +1 -1
- package/scripts/preuninstall.js +48 -0
package/cli.py
CHANGED
|
@@ -28,7 +28,7 @@ import click
|
|
|
28
28
|
|
|
29
29
|
# Project root = directory containing this file
|
|
30
30
|
PROJECT_ROOT = Path(__file__).parent.resolve()
|
|
31
|
-
DEFAULT_CONFIG =
|
|
31
|
+
DEFAULT_CONFIG = Path.home() / ".config" / "swr" / "config.yaml"
|
|
32
32
|
CRON_MARKER = "# swr:stock-weekly-report"
|
|
33
33
|
|
|
34
34
|
|
|
@@ -151,7 +151,7 @@ def init(ctx):
|
|
|
151
151
|
click.echo("\n=== Stock Weekly Report — Setup Wizard ===\n")
|
|
152
152
|
|
|
153
153
|
# 1. Parent folder
|
|
154
|
-
default_folder = cfg.get("parent_folder", str(
|
|
154
|
+
default_folder = cfg.get("parent_folder", str(Path.home() / "swr-data"))
|
|
155
155
|
parent_folder = click.prompt("Data folder path", default=default_folder)
|
|
156
156
|
|
|
157
157
|
# 2. nlm binary path (auto-detect if not already in config)
|
package/config_manager.py
CHANGED
|
@@ -21,6 +21,7 @@ def load_config(path: str | Path) -> dict:
|
|
|
21
21
|
def save_config(path: str | Path, data: dict) -> None:
|
|
22
22
|
"""Atomically write config to path via temp file + rename."""
|
|
23
23
|
path = Path(path)
|
|
24
|
+
path.parent.mkdir(parents=True, exist_ok=True)
|
|
24
25
|
with tempfile.NamedTemporaryFile(
|
|
25
26
|
mode="w", encoding="utf-8", dir=path.parent, delete=False, suffix=".tmp"
|
|
26
27
|
) as tf:
|
package/package.json
CHANGED
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "stock-weekly-report",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"description": "Stock weekly podcast report pipeline — CLI and MCP server",
|
|
5
5
|
"bin": {
|
|
6
6
|
"swr": "bin/swr.js",
|
|
7
7
|
"swr-mcp": "bin/swr-mcp.js"
|
|
8
8
|
},
|
|
9
9
|
"scripts": {
|
|
10
|
-
"postinstall": "node scripts/postinstall.js"
|
|
10
|
+
"postinstall": "node scripts/postinstall.js",
|
|
11
|
+
"preuninstall": "node scripts/preuninstall.js"
|
|
11
12
|
},
|
|
12
13
|
"files": [
|
|
13
14
|
"bin/",
|
|
14
|
-
"scripts/",
|
|
15
|
+
"scripts/postinstall.js",
|
|
16
|
+
"scripts/preuninstall.js",
|
|
15
17
|
"*.py",
|
|
16
18
|
"pyproject.toml",
|
|
17
19
|
"requirements.txt",
|
package/pyproject.toml
CHANGED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
/**
|
|
4
|
+
* preuninstall.js
|
|
5
|
+
*
|
|
6
|
+
* Runs automatically before `npm uninstall -g stock-weekly-report`.
|
|
7
|
+
* Removes the cron job so it doesn't point to deleted files.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
const { execSync } = require("child_process");
|
|
11
|
+
|
|
12
|
+
const CRON_MARKER = "# swr:stock-weekly-report";
|
|
13
|
+
|
|
14
|
+
function removeCronJob() {
|
|
15
|
+
try {
|
|
16
|
+
const current = execSync("crontab -l 2>/dev/null", {
|
|
17
|
+
encoding: "utf8",
|
|
18
|
+
}).trim();
|
|
19
|
+
|
|
20
|
+
if (!current.includes(CRON_MARKER)) {
|
|
21
|
+
return; // nothing to remove
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const cleaned = current
|
|
25
|
+
.split("\n")
|
|
26
|
+
.filter((line) => !line.includes(CRON_MARKER))
|
|
27
|
+
.join("\n")
|
|
28
|
+
.trim();
|
|
29
|
+
|
|
30
|
+
if (cleaned) {
|
|
31
|
+
execSync(`echo "${cleaned}" | crontab -`);
|
|
32
|
+
} else {
|
|
33
|
+
execSync("crontab -r 2>/dev/null || true", { shell: true });
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
console.log("swr: removed cron job.");
|
|
37
|
+
} catch {
|
|
38
|
+
// crontab may not exist — not an error
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
removeCronJob();
|
|
43
|
+
|
|
44
|
+
console.log(
|
|
45
|
+
"\nswr: uninstalled.\n" +
|
|
46
|
+
" If you had Claude Desktop configured, remove the 'stock-weekly-report'\n" +
|
|
47
|
+
" entry from claude_desktop_config.json.\n"
|
|
48
|
+
);
|