Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
jairad26 committed Oct 23, 2024
1 parent faedab3 commit 83be0e5
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 19 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ In previous releases, the name "Hypermode" was used for all three._
- Improve dev first use log messages [#489](https://github.com/hypermodeinc/modus/pull/489)
- Highlight endpoints when running in dev [#490](https://github.com/hypermodeinc/modus/pull/490)
- Fix data race in logging adapter [#491](https://github.com/hypermodeinc/modus/pull/491)
- move hyp settings for local model invocation to env variables [#495](https://github.com/hypermodeinc/modus/pull/495)
- Move hyp settings for local model invocation to env variables [#495](https://github.com/hypermodeinc/modus/pull/495)

## 2024-10-02 - Version 0.12.7

Expand Down
8 changes: 4 additions & 4 deletions cli/src/commands/dev/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,14 +144,14 @@ export default class DevCommand extends Command {
await BuildCommand.run([appPath, "--no-logo"]);

// read from settings.json if it exists, load env vars into env
const settings = readSettingsJson();
const settings = await readSettingsJson();

const env = {
...process.env,
MODUS_ENV: "dev",
HYP_EMAIL: settings.email || "",
HYP_JWT: settings.jwt || "",
HYP_ORG_ID: settings.orgId || "",
HYP_EMAIL: settings.email,
HYP_JWT: settings.jwt,
HYP_ORG_ID: settings.orgId,
};

const runtime = spawn(runtimePath, ["-appPath", path.join(appPath, "build")], {
Expand Down
31 changes: 17 additions & 14 deletions cli/src/util/hypermode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

import * as path from "node:path";
import * as fs from "node:fs";
import * as utils from "./fs.js";
import chalk from "chalk";

function getHypEnvDir(): string {
return path.join(process.env.HOME || "", ".hypermode");
Expand All @@ -18,25 +20,26 @@ function getSettingsFilePath(): string {
return path.join(getHypEnvDir(), "settings.json");
}

export function readSettingsJson(): {
email: null | string;
jwt: null | string;
orgId: null | string;
} {
const content = fs.readFileSync(getSettingsFilePath(), "utf-8");
type HypSettings = {
email?: string;
jwt?: string;
orgId?: string;
};

let email: null | string = null;
let jwt: null | string = null;
let orgId: null | string = null;
export async function readSettingsJson(): Promise<HypSettings> {
const path = getSettingsFilePath();
const content = await utils.readFile(path, "utf-8");

const settings: HypSettings = {};

try {
const jsonContent = JSON.parse(content);
email = jsonContent.HYP_EMAIL || null;
jwt = jsonContent.HYP_JWT || null;
orgId = jsonContent.HYP_ORG_ID || null;
settings.email = jsonContent.email;
settings.jwt = jsonContent.jwt;
settings.orgId = jsonContent.orgId;
} catch (e) {
console.error("Error reading settings.json", e);
console.warn(chalk.yellow("Error reading " + path), e);
}

return { email, jwt, orgId };
return settings;
}

0 comments on commit 83be0e5

Please sign in to comment.