xtra-cli 0.1.9 → 0.1.10
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/dist/commands/init.js +4 -0
- package/dist/commands/run.js +12 -3
- package/package.json +1 -1
package/dist/commands/init.js
CHANGED
|
@@ -181,6 +181,10 @@ exports.initCommand = new commander_1.Command("init")
|
|
|
181
181
|
createdAt: new Date().toISOString(),
|
|
182
182
|
};
|
|
183
183
|
fs.writeFileSync(rcPath, JSON.stringify(rc, null, 2), "utf8");
|
|
184
|
+
// ── Sync global conf store so `xtra run` / `xtra secrets` pick up the new values ──
|
|
185
|
+
(0, config_1.setConfig)("project", project);
|
|
186
|
+
(0, config_1.setConfig)("env", env);
|
|
187
|
+
(0, config_1.setConfig)("branch", branch);
|
|
184
188
|
// Summary
|
|
185
189
|
console.log(chalk_1.default.green(`\n ✅ Initialized! Created ${RC_FILE}:\n`));
|
|
186
190
|
console.log(chalk_1.default.gray(` Project : ${chalk_1.default.white(project)}`));
|
package/dist/commands/run.js
CHANGED
|
@@ -65,16 +65,25 @@ Examples:
|
|
|
65
65
|
.action(async (command, args, options) => {
|
|
66
66
|
// console.log("Run Options:", options);
|
|
67
67
|
let { project, env, branch, shell: useShell } = options;
|
|
68
|
+
// ── Load .xtrarc from current directory (project-local config) ─────────
|
|
69
|
+
const rcPath = path.resolve(process.cwd(), ".xtrarc");
|
|
70
|
+
let rcConfig = {};
|
|
71
|
+
if (fs.existsSync(rcPath)) {
|
|
72
|
+
try {
|
|
73
|
+
rcConfig = JSON.parse(fs.readFileSync(rcPath, "utf8"));
|
|
74
|
+
}
|
|
75
|
+
catch (_) { }
|
|
76
|
+
}
|
|
68
77
|
// Use active branch from config if not specified
|
|
69
78
|
if (!branch) {
|
|
70
|
-
branch = (0, config_1.getConfigValue)("branch") || "main";
|
|
79
|
+
branch = rcConfig.branch || (0, config_1.getConfigValue)("branch") || "main";
|
|
71
80
|
}
|
|
72
81
|
// Normalize Env
|
|
73
82
|
const envMap = { dev: "development", stg: "staging", prod: "production" };
|
|
74
|
-
env = envMap[env] || env;
|
|
83
|
+
env = envMap[env] || env || rcConfig.env || (0, config_1.getConfigValue)("env") || "development";
|
|
75
84
|
// We might want to support default project in config later
|
|
76
85
|
if (!project) {
|
|
77
|
-
project = (0, config_1.getConfigValue)("project");
|
|
86
|
+
project = rcConfig.project || (0, config_1.getConfigValue)("project");
|
|
78
87
|
}
|
|
79
88
|
if (!project) {
|
|
80
89
|
console.error(chalk_1.default.red("Error: Project ID is required. Use -p <id> or checkout a branch."));
|