Skip to content

Commit

Permalink
Beta (#31)
Browse files Browse the repository at this point in the history
  • Loading branch information
harunkelesoglu authored Oct 1, 2023
2 parents 046fcd9 + 090aa40 commit a6b541a
Show file tree
Hide file tree
Showing 11 changed files with 257 additions and 201 deletions.
57 changes: 37 additions & 20 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@celsus-ai/localize",
"version": "2.1.1",
"version": "2.2.0-beta.1",
"description": "The LocalizeAI is an npm package that enables easy localization of your applications using OpenAI. It provides seamless integration with OpenAI's language models, allowing you to localize and adapt your applications to different languages and regions effortlessly",
"main": "dist/index.js",
"private": false,
Expand All @@ -10,6 +10,9 @@
"release": "semantic-release",
"start": "node dist/index.js"
},
"bin": {
"localize": "node dist/index.js"
},
"repository": {
"type": "git",
"url": "https://github.com/celsus-ai/localize.git"
Expand All @@ -26,7 +29,6 @@
},
"homepage": "https://github.com/celsus-ai/localize#readme",
"dependencies": {
"openai": "^3.3.0",
"winston": "^3.9.0"
},
"devDependencies": {
Expand All @@ -37,7 +39,9 @@
"@semantic-release/github": "^9.0.3",
"@semantic-release/npm": "^10.0.4",
"@types/node": "^20.3.1",
"axios": "^1.5.1",
"husky": "^8.0.0",
"reflect-metadata": "^0.1.13",
"semantic-release": "^21.0.5"
},
"release": {
Expand Down
52 changes: 32 additions & 20 deletions src/config/index.ts
Original file line number Diff line number Diff line change
@@ -1,52 +1,64 @@
import { Parser } from '../utils';
import { BitbucketAPI, ConfigConstants, GithubAPI, LanguageCodes, Platform, SortBy } from "../constants";
import { BitbucketAPI, ConfigConstants, GithubAPI, LanguageCodes, OpenAIAPI, OpenAIModels, Platform, SortBy } from "../constants";

export interface IAPIConfig {
baseUrl: string;
token: string;
};

export interface ICIConfig extends IAPIConfig {
platform: Platform | undefined;
owner: string;
repo: string;
};

export interface IAIConfig extends IAPIConfig {
model: OpenAIModels | string,
organization?: string,
};

export interface IBaseConfig {
baseLanguage: LanguageCodes;
localesDir: string;
targetLanguages: LanguageCodes[];
apiKey: string;
email: string;
sortBy: SortBy
}
export interface ICIConfig {
platform: Platform | undefined,
owner: string,
repo: string,
apiBaseUrl: string,
apiToken: string
}

export interface ILibConfig extends ICIConfig, IBaseConfig {}
sortBy: SortBy;
ai: IAIConfig;
ci?: ICIConfig;
};

export const baseConfig: IBaseConfig = {
baseLanguage: LanguageCodes.English,
localesDir: ConfigConstants.localesDir,
targetLanguages: [LanguageCodes.English, LanguageCodes.Turkish],
apiKey: ConfigConstants.openAIKey,
email: ConfigConstants.email,
sortBy: SortBy.asceding
sortBy: SortBy.asceding,
ai: {
baseUrl: OpenAIAPI.baseUrl,
token: OpenAIAPI.token,
model: OpenAIAPI.model
},
};


export function loadConfig(configPath: string, packageJsonPath: string): ILibConfig {
export function loadConfig(configPath: string, packageJsonPath: string): IBaseConfig {

const configuration = require(configPath);
const pkg = require(packageJsonPath);

if(!pkg.repository?.url) {
throw new Error(`[Localize AI][Config] repository information not found in ${packageJsonPath}`);
throw new Error(`[Localize AI][loadConfig] repository information not found in ${packageJsonPath}`);
}
const { platform, owner, repo } = Parser.parseRepositoryUrl(pkg.repository.url);

const ciConfig: ICIConfig = {
platform,
owner,
repo,
apiBaseUrl: (platform === Platform.github) ? GithubAPI.baseUrl || '' : (platform === Platform.bitbucket) ? BitbucketAPI.baseUrl || '' : '',
apiToken: (platform === Platform.github) ? GithubAPI.token || '' : (platform === Platform.bitbucket) ? BitbucketAPI.token || '' : ''
baseUrl: (platform === Platform.github) ? GithubAPI.baseUrl || '' : (platform === Platform.bitbucket) ? BitbucketAPI.baseUrl || '' : '',
token: (platform === Platform.github) ? GithubAPI.token || '' : (platform === Platform.bitbucket) ? BitbucketAPI.token || '' : ''
};


return { ...baseConfig, ...ciConfig, ...configuration };
return { ...baseConfig, ci: { ...ciConfig }, ...configuration };
};
Loading

0 comments on commit a6b541a

Please sign in to comment.