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 +4 -1
- package/package.json +1 -1
- package/pyproject.toml +1 -1
- package/scripts/postinstall.js +19 -0
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 =
|
|
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
package/pyproject.toml
CHANGED
package/scripts/postinstall.js
CHANGED
|
@@ -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);
|