xtra-cli 0.1.8 → 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/dist/lib/config.js +9 -2
- 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."));
|
package/dist/lib/config.js
CHANGED
|
@@ -5,15 +5,22 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.getProjectConfig = exports.getAuthToken = exports.clearConfig = exports.setConfig = exports.getConfigValue = exports.getConfig = void 0;
|
|
7
7
|
const conf_1 = __importDefault(require("conf"));
|
|
8
|
+
const PRODUCTION_API_URL = "https://xtra-security.vercel.app/api";
|
|
8
9
|
const config = new conf_1.default({
|
|
9
10
|
projectName: "xtra-cli",
|
|
10
11
|
defaults: {
|
|
11
|
-
apiUrl:
|
|
12
|
+
apiUrl: PRODUCTION_API_URL,
|
|
12
13
|
},
|
|
13
14
|
});
|
|
15
|
+
// Auto-heal: if an old localhost value was persisted, clear it so we use production.
|
|
16
|
+
// Users who intentionally want localhost should set XTRA_API_URL env var instead.
|
|
17
|
+
const _storedApiUrl = config.get("apiUrl");
|
|
18
|
+
if (_storedApiUrl && _storedApiUrl.includes("localhost") && !process.env.XTRA_API_URL) {
|
|
19
|
+
config.set("apiUrl", PRODUCTION_API_URL);
|
|
20
|
+
}
|
|
14
21
|
const getConfig = () => ({
|
|
15
22
|
...config.store,
|
|
16
|
-
apiUrl: process.env.XTRA_API_URL || config.get("apiUrl") ||
|
|
23
|
+
apiUrl: process.env.XTRA_API_URL || config.get("apiUrl") || PRODUCTION_API_URL
|
|
17
24
|
});
|
|
18
25
|
exports.getConfig = getConfig;
|
|
19
26
|
const getConfigValue = (key) => config.get(key);
|