stock-weekly-report 0.1.9 → 0.2.0

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 CHANGED
@@ -151,12 +151,15 @@ def init(ctx):
151
151
 
152
152
  # 0. Project root (where pipeline.py and venv/ live)
153
153
  cwd = Path.cwd()
154
+ saved_root = cfg.get("project_root", "")
154
155
  if (cwd / "pipeline.py").exists():
155
156
  suggested_root = str(cwd)
157
+ elif saved_root and (Path(saved_root) / "pipeline.py").exists():
158
+ suggested_root = saved_root
156
159
  elif (PROJECT_ROOT / "pipeline.py").exists():
157
160
  suggested_root = str(PROJECT_ROOT)
158
161
  else:
159
- suggested_root = cfg.get("project_root", str(PROJECT_ROOT))
162
+ suggested_root = saved_root or ""
160
163
  project_root_input = click.prompt("Project root [required]", default=suggested_root)
161
164
  project_root_path = Path(project_root_input).expanduser().resolve()
162
165
  if not (project_root_path / "pipeline.py").exists():
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "stock-weekly-report",
3
- "version": "0.1.9",
3
+ "version": "0.2.0",
4
4
  "description": "Stock weekly podcast report pipeline — CLI and MCP server",
5
5
  "bin": {
6
6
  "swr": "bin/swr.js",
package/pyproject.toml CHANGED
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "stock-weekly-report"
7
- version = "0.1.9"
7
+ version = "0.2.0"
8
8
  requires-python = ">=3.10"
9
9
  authors = [
10
10
  { name = "Chang Yu Chuan", email = "changyuchuanmicron@gmail.com" },
@@ -74,6 +74,25 @@ try {
74
74
  execFileSync(pip, ["install", "."], { stdio: "inherit", cwd: ROOT });
75
75
 
76
76
  fs.writeFileSync(VERSION_FILE, CURRENT_VER + "\n", "utf8");
77
+
78
+ // ── Set project_root in config if not already pointing to a valid location ─
79
+ const configPath = path.join(SWR_DIR, "config.yaml");
80
+ let needsProjectRoot = true;
81
+ if (fs.existsSync(configPath)) {
82
+ const content = fs.readFileSync(configPath, "utf8");
83
+ const match = content.match(/^project_root:\s*(.+)$/m);
84
+ if (match) {
85
+ const existing = match[1].trim().replace(/^['"]|['"]$/g, "");
86
+ if (fs.existsSync(path.join(existing, "pipeline.py"))) {
87
+ needsProjectRoot = false;
88
+ }
89
+ }
90
+ }
91
+ if (needsProjectRoot) {
92
+ execFileSync(SWR_BIN, ["config", "set", "project_root", ROOT], { stdio: "inherit" });
93
+ console.log(`swr: Set project_root to ${ROOT}`);
94
+ }
95
+
77
96
  console.log(`\nswr: Setup complete (v${CURRENT_VER}). Run \`swr --help\` to get started.\n`);
78
97
  } catch (err) {
79
98
  console.error("\nswr postinstall failed:", err.message);