xtra-cli 0.2.6 → 0.2.7

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.
@@ -56,22 +56,33 @@ const updateConfigs = (projectId, projectName) => {
56
56
  if (oldProject !== projectId) {
57
57
  (0, config_1.setConfig)("branch", "main"); // Reset to main or clear? Projects have different branches.
58
58
  }
59
- // Update local .xtrarc if exists
59
+ // Update/Create local .xtrarc to make project context "sticky" to the directory
60
60
  const rcPath = path.join(process.cwd(), ".xtrarc");
61
+ let rc = {};
61
62
  if (fs.existsSync(rcPath)) {
62
63
  try {
63
- const rc = JSON.parse(fs.readFileSync(rcPath, "utf-8"));
64
- rc.project = projectId;
65
- if (oldProject !== projectId) {
66
- rc.branch = "main"; // Sync local branch too
67
- }
68
- fs.writeFileSync(rcPath, JSON.stringify(rc, null, 2), "utf8");
69
- console.log(chalk_1.default.gray(` ✔ Updated local .xtrarc`));
64
+ rc = JSON.parse(fs.readFileSync(rcPath, "utf-8"));
70
65
  }
71
66
  catch (e) {
72
- console.error(chalk_1.default.yellow(` ⚠ Could not update local .xtrarc: ${e instanceof Error ? e.message : 'Unknown error'}`));
67
+ console.error(chalk_1.default.yellow(` ⚠ Could not parse existing local .xtrarc: ${e instanceof Error ? e.message : 'Unknown error'}`));
73
68
  }
74
69
  }
70
+ rc.project = projectId;
71
+ if (oldProject !== projectId) {
72
+ rc.branch = "main"; // Reset branch on project change
73
+ }
74
+ // Add other relevant defaults if it's a new file
75
+ if (!rc.env)
76
+ rc.env = "development";
77
+ if (!rc.apiUrl)
78
+ rc.apiUrl = (0, config_1.getConfigValue)("apiUrl") || "https://xtra-security.vercel.app/api";
79
+ try {
80
+ fs.writeFileSync(rcPath, JSON.stringify(rc, null, 2), "utf8");
81
+ console.log(chalk_1.default.gray(` ✔ Updated local .xtrarc (Project context locked to this folder)`));
82
+ }
83
+ catch (e) {
84
+ console.error(chalk_1.default.yellow(` ⚠ Could not write local .xtrarc: ${e instanceof Error ? e.message : 'Unknown error'}`));
85
+ }
75
86
  console.log(chalk_1.default.green(`✔ Default project set to '${projectName}'`));
76
87
  const currentBranch = (0, config_1.getConfigValue)("branch");
77
88
  if (currentBranch) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xtra-cli",
3
- "version": "0.2.6",
3
+ "version": "0.2.7",
4
4
  "description": "CLI for XtraSecurity Platform",
5
5
  "main": "dist/index.js",
6
6
  "bin": {