@localheroai/cli 0.0.5 → 0.0.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.
- package/{README → README.md} +28 -10
- package/dist/api/auth.d.ts +2 -0
- package/dist/api/auth.js +28 -0
- package/dist/api/auth.js.map +1 -0
- package/dist/api/client.d.ts +3 -0
- package/dist/api/client.js +80 -0
- package/dist/api/client.js.map +1 -0
- package/dist/api/imports.d.ts +5 -0
- package/dist/api/imports.js +43 -0
- package/dist/api/imports.js.map +1 -0
- package/dist/api/projects.d.ts +2 -0
- package/dist/api/projects.js +42 -0
- package/dist/api/projects.js.map +1 -0
- package/dist/api/translations.d.ts +15 -0
- package/dist/api/translations.js +71 -0
- package/dist/api/translations.js.map +1 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +79 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands/_sync.js +22 -0
- package/dist/commands/_sync.js.map +1 -0
- package/dist/commands/_translate.js +3 -0
- package/dist/commands/_translate.js.map +1 -0
- package/dist/commands/init.d.ts +1 -0
- package/dist/commands/init.js +439 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/login.d.ts +16 -0
- package/dist/commands/login.js +58 -0
- package/dist/commands/login.js.map +1 -0
- package/dist/commands/pull.js +22 -0
- package/dist/commands/pull.js.map +1 -0
- package/dist/commands/push.js +56 -0
- package/dist/commands/push.js.map +1 -0
- package/dist/commands/sync.d.ts +20 -0
- package/dist/commands/sync.js +22 -0
- package/dist/commands/sync.js.map +1 -0
- package/dist/commands/translate.d.ts +14 -0
- package/dist/commands/translate.js +152 -0
- package/dist/commands/translate.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/dist/types/index.d.ts +75 -0
- package/dist/types/index.js +17 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/translate/index.js +2 -0
- package/dist/types/translate/index.js.map +1 -0
- package/dist/utils/auth.d.ts +2 -0
- package/dist/utils/auth.js +29 -0
- package/dist/utils/auth.js.map +1 -0
- package/dist/utils/common.js +9 -0
- package/dist/utils/common.js.map +1 -0
- package/dist/utils/config.d.ts +23 -0
- package/dist/utils/config.js +137 -0
- package/dist/utils/config.js.map +1 -0
- package/dist/utils/errors.js +37 -0
- package/dist/utils/errors.js.map +1 -0
- package/dist/utils/files.d.ts +32 -0
- package/dist/utils/files.js +355 -0
- package/dist/utils/files.js.map +1 -0
- package/dist/utils/git.d.ts +21 -0
- package/dist/utils/git.js +87 -0
- package/dist/utils/git.js.map +1 -0
- package/dist/utils/github.d.ts +241 -0
- package/dist/utils/github.js +161 -0
- package/dist/utils/github.js.map +1 -0
- package/dist/utils/import-service.d.ts +4 -0
- package/dist/utils/import-service.js +218 -0
- package/dist/utils/import-service.js.map +1 -0
- package/dist/utils/prompt-service.d.ts +44 -0
- package/dist/utils/prompt-service.js +104 -0
- package/dist/utils/prompt-service.js.map +1 -0
- package/dist/utils/sync-service.d.ts +58 -0
- package/dist/utils/sync-service.js +159 -0
- package/dist/utils/sync-service.js.map +1 -0
- package/dist/utils/translation-processor.js +197 -0
- package/dist/utils/translation-processor.js.map +1 -0
- package/dist/utils/translation-updater/common.d.ts +6 -0
- package/{src → dist}/utils/translation-updater/common.js +16 -10
- package/dist/utils/translation-updater/common.js.map +1 -0
- package/dist/utils/translation-updater/index.d.ts +5 -0
- package/{src → dist}/utils/translation-updater/index.js +21 -9
- package/dist/utils/translation-updater/index.js.map +1 -0
- package/dist/utils/translation-updater/json-handler.d.ts +5 -0
- package/dist/utils/translation-updater/json-handler.js +123 -0
- package/dist/utils/translation-updater/json-handler.js.map +1 -0
- package/dist/utils/translation-updater/yaml-handler.d.ts +5 -0
- package/dist/utils/translation-updater/yaml-handler.js +193 -0
- package/dist/utils/translation-updater/yaml-handler.js.map +1 -0
- package/dist/utils/translation-utils.d.ts +30 -0
- package/dist/utils/translation-utils.js +334 -0
- package/dist/utils/translation-utils.js.map +1 -0
- package/dist/utils/updater.js +38 -0
- package/dist/utils/updater.js.map +1 -0
- package/package.json +26 -26
- package/src/api/auth.js +0 -24
- package/src/api/client.js +0 -83
- package/src/api/imports.js +0 -22
- package/src/api/projects.js +0 -24
- package/src/api/translations.js +0 -58
- package/src/cli.js +0 -78
- package/src/commands/init.js +0 -485
- package/src/commands/login.js +0 -80
- package/src/commands/sync.js +0 -28
- package/src/commands/translate.js +0 -267
- package/src/utils/auth.js +0 -23
- package/src/utils/config.js +0 -125
- package/src/utils/files.js +0 -381
- package/src/utils/git.js +0 -72
- package/src/utils/github.js +0 -128
- package/src/utils/import-service.js +0 -128
- package/src/utils/prompt-service.js +0 -67
- package/src/utils/sync-service.js +0 -147
- package/src/utils/translation-updater/json-handler.js +0 -111
- package/src/utils/translation-updater/yaml-handler.js +0 -207
- package/src/utils/translation-utils.js +0 -278
package/{README → README.md}
RENAMED
|
@@ -13,9 +13,9 @@ LocalHero.ai is an AI-powered I18n translation service that seamlessly integrate
|
|
|
13
13
|
|
|
14
14
|
## Getting Started 🏁
|
|
15
15
|
|
|
16
|
-
1. Sign up for a free trial at [localhero.ai](https://localhero.ai/)
|
|
16
|
+
1. Sign up for a free trial at [localhero.ai](https://localhero.ai/).
|
|
17
17
|
2. Get your API key from [localhero.ai/api-keys](https://localhero.ai/api-keys)
|
|
18
|
-
3. Run the init command in your project:
|
|
18
|
+
3. Run the init command in your project to setup the configuration:
|
|
19
19
|
```bash
|
|
20
20
|
npx @localheroai/cli init
|
|
21
21
|
```
|
|
@@ -29,6 +29,7 @@ npx @localheroai/cli init
|
|
|
29
29
|
```
|
|
30
30
|
|
|
31
31
|
The init command helps you set up your project with LocalHero.ai. It will:
|
|
32
|
+
- Setup your API key if it hasn't been done already
|
|
32
33
|
- Detect your project type (Rails, React, or generic)
|
|
33
34
|
- Link to an existing LocalHero.ai project
|
|
34
35
|
- Configure translation paths and file patterns
|
|
@@ -49,7 +50,9 @@ The configuration file is used by the tool to interact with your translations an
|
|
|
49
50
|
npx @localheroai/cli login
|
|
50
51
|
```
|
|
51
52
|
|
|
52
|
-
Authenticate with your
|
|
53
|
+
Authenticate with the API using your API key. This will save your API key to `.localhero_key` and add the file to .gitignore if needed.
|
|
54
|
+
|
|
55
|
+
Use this when:
|
|
53
56
|
- Setting up a new development environment
|
|
54
57
|
- Updating your API key
|
|
55
58
|
- Verifying your authentication status
|
|
@@ -63,10 +66,26 @@ npx @localheroai/cli translate
|
|
|
63
66
|
Translating your missing keys:
|
|
64
67
|
- Automatically detects missing translations and sends them to the Localhero.ai translation API for translation
|
|
65
68
|
- Updates translation files with any new or update translations
|
|
66
|
-
- It's run manually or by GitHub Actions
|
|
69
|
+
- It's run manually or by GitHub Actions. When run as a GitHub action any new translations are automatically committed to git.
|
|
70
|
+
|
|
71
|
+
### Pull / push
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
npx @localheroai/cli pull
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Pull the latest translation updates from LocalHero.ai to your local files. This command will download any new or modified translations from the service to your local files.
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
npx @localheroai/cli push
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
Push updates from your local translation files to LocalHero.ai. This command will upload any new or modified translations from your local files to the service.
|
|
67
84
|
|
|
68
85
|
## Environment Variables ⚙️
|
|
69
86
|
|
|
87
|
+
Typically you don't need to set these. The cli will use `LOCALHERO_API_KEY` if it's set, otherwise it will check the file `.localhero_key` for a API key.
|
|
88
|
+
|
|
70
89
|
Configure the CLI behavior with these environment variables:
|
|
71
90
|
|
|
72
91
|
| Variable | Description | Default |
|
|
@@ -79,19 +98,18 @@ Configure the CLI behavior with these environment variables:
|
|
|
79
98
|
LocalHero.ai automatically translate your I18n files when you push changes. During the `init` command, you'll be prompted to set up GitHub Actions.
|
|
80
99
|
|
|
81
100
|
1. Add your API key to your repository secrets:
|
|
82
|
-
- Go to Settings > Secrets > Actions
|
|
101
|
+
- Go to Settings > Secrets and variables > Actions
|
|
83
102
|
- Create a new secret named `LOCALHERO_API_KEY`
|
|
84
103
|
- Add your API key as the value
|
|
85
104
|
|
|
86
105
|
2. The workflow will:
|
|
87
|
-
- Run on push to
|
|
88
|
-
- Check for missing translations
|
|
89
|
-
- Create a pull request with new translations
|
|
106
|
+
- Run on push to pull requests
|
|
107
|
+
- Check for missing translations and add new/updated translations to the repo.
|
|
90
108
|
|
|
91
109
|
## Support 💬
|
|
92
110
|
|
|
93
|
-
- Documentation: [localhero.ai/docs](https://
|
|
94
|
-
- Email:
|
|
111
|
+
- Documentation: [localhero.ai/docs](https://localhero.ai/docs)
|
|
112
|
+
- Email: hi@localhero.ai
|
|
95
113
|
|
|
96
114
|
## License 📄
|
|
97
115
|
|
package/dist/api/auth.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { apiRequest } from './client.js';
|
|
2
|
+
import { ApiResponseError } from '../types/index.js';
|
|
3
|
+
export async function verifyApiKey(apiKey) {
|
|
4
|
+
try {
|
|
5
|
+
return await apiRequest('/api/v1/auth/verify', {
|
|
6
|
+
apiKey
|
|
7
|
+
});
|
|
8
|
+
}
|
|
9
|
+
catch (error) {
|
|
10
|
+
if (error instanceof ApiResponseError) {
|
|
11
|
+
return {
|
|
12
|
+
error: {
|
|
13
|
+
code: error.code,
|
|
14
|
+
message: error.message
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
return {
|
|
19
|
+
error: {
|
|
20
|
+
code: error.code || 'verification_failed',
|
|
21
|
+
message: error instanceof Error && error.message
|
|
22
|
+
? error.message
|
|
23
|
+
: 'Failed to verify API key'
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=auth.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../src/api/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAWrD,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,MAAc;IAC/C,IAAI,CAAC;QACH,OAAO,MAAM,UAAU,CAAC,qBAAqB,EAAE;YAC7C,MAAM;SACP,CAAC,CAAC;IACL,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,KAAK,YAAY,gBAAgB,EAAE,CAAC;YACtC,OAAO;gBACL,KAAK,EAAE;oBACL,IAAI,EAAE,KAAK,CAAC,IAAI;oBAChB,OAAO,EAAE,KAAK,CAAC,OAAO;iBACvB;aACF,CAAC;QACJ,CAAC;QAED,OAAO;YACL,KAAK,EAAE;gBACL,IAAI,EAAG,KAAa,CAAC,IAAI,IAAI,qBAAqB;gBAClD,OAAO,EAAE,KAAK,YAAY,KAAK,IAAI,KAAK,CAAC,OAAO;oBAC9C,CAAC,CAAC,KAAK,CAAC,OAAO;oBACf,CAAC,CAAC,0BAA0B;aAC/B;SACF,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { ApiResponseError } from '../types/index.js';
|
|
2
|
+
const DEFAULT_API_HOST = 'https://api.localhero.ai';
|
|
3
|
+
export function getApiHost() {
|
|
4
|
+
return process.env.LOCALHERO_API_HOST || DEFAULT_API_HOST;
|
|
5
|
+
}
|
|
6
|
+
function getNetworkErrorMessage(error) {
|
|
7
|
+
if (error.code === 'ECONNREFUSED') {
|
|
8
|
+
return `Unable to connect to ${getApiHost()}. Please check your internet connection and try again.`;
|
|
9
|
+
}
|
|
10
|
+
if (error.cause?.code === 'ENOTFOUND') {
|
|
11
|
+
return `Could not resolve host ${getApiHost()}. Please check your internet connection and try again.`;
|
|
12
|
+
}
|
|
13
|
+
if (error.cause?.code === 'ETIMEDOUT') {
|
|
14
|
+
return `Connection to ${getApiHost()} timed out. Please try again later.`;
|
|
15
|
+
}
|
|
16
|
+
return `Network error while connecting to ${getApiHost()}. Please check your internet connection and try again.`;
|
|
17
|
+
}
|
|
18
|
+
export async function apiRequest(endpoint, options = {}) {
|
|
19
|
+
const apiHost = getApiHost();
|
|
20
|
+
const url = `${apiHost}${endpoint}`;
|
|
21
|
+
const apiKey = process.env.LOCALHERO_API_KEY || options.apiKey;
|
|
22
|
+
const headers = {
|
|
23
|
+
'Content-Type': 'application/json',
|
|
24
|
+
...options.headers
|
|
25
|
+
};
|
|
26
|
+
if (apiKey) {
|
|
27
|
+
headers['Authorization'] = `Bearer ${apiKey}`;
|
|
28
|
+
}
|
|
29
|
+
const fetchOptions = {
|
|
30
|
+
method: options.method || 'GET',
|
|
31
|
+
headers,
|
|
32
|
+
};
|
|
33
|
+
if (options.body) {
|
|
34
|
+
fetchOptions.body = JSON.stringify(options.body);
|
|
35
|
+
}
|
|
36
|
+
let response;
|
|
37
|
+
try {
|
|
38
|
+
response = await fetch(url, fetchOptions);
|
|
39
|
+
}
|
|
40
|
+
catch (error) {
|
|
41
|
+
const networkError = error;
|
|
42
|
+
const message = getNetworkErrorMessage(networkError);
|
|
43
|
+
networkError.message = message;
|
|
44
|
+
networkError.cliErrorMessage = message;
|
|
45
|
+
throw networkError;
|
|
46
|
+
}
|
|
47
|
+
let data;
|
|
48
|
+
try {
|
|
49
|
+
data = await response.json();
|
|
50
|
+
}
|
|
51
|
+
catch (error) {
|
|
52
|
+
const parseError = error;
|
|
53
|
+
const message = 'Failed to parse API response. Error: ' + error;
|
|
54
|
+
parseError.message = message;
|
|
55
|
+
parseError.cliErrorMessage = message;
|
|
56
|
+
throw parseError;
|
|
57
|
+
}
|
|
58
|
+
if (!response.ok) {
|
|
59
|
+
if (response.status === 401 && data?.error?.code === 'invalid_api_key') {
|
|
60
|
+
const message = 'Your API key is invalid or has been revoked. Please run `npx @localheroai/cli login` to update your API key.';
|
|
61
|
+
const error = new ApiResponseError(message);
|
|
62
|
+
error.cliErrorMessage = message;
|
|
63
|
+
error.code = 'invalid_api_key';
|
|
64
|
+
error.data = data;
|
|
65
|
+
error.details = null;
|
|
66
|
+
throw error;
|
|
67
|
+
}
|
|
68
|
+
const message = Array.isArray(data?.errors)
|
|
69
|
+
? data.errors.map((err) => typeof err === 'string' ? err : err.message).join(', ')
|
|
70
|
+
: data?.error?.message || 'API request failed';
|
|
71
|
+
const error = new ApiResponseError(message);
|
|
72
|
+
error.cliErrorMessage = message;
|
|
73
|
+
error.code = data?.error?.code || 'API_ERROR';
|
|
74
|
+
error.details = data?.error?.details || null;
|
|
75
|
+
error.data = data;
|
|
76
|
+
throw error;
|
|
77
|
+
}
|
|
78
|
+
return data;
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/api/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAErD,MAAM,gBAAgB,GAAG,0BAA0B,CAAC;AAEpD,MAAM,UAAU,UAAU;IACxB,OAAO,OAAO,CAAC,GAAG,CAAC,kBAAkB,IAAI,gBAAgB,CAAC;AAC5D,CAAC;AAiBD,SAAS,sBAAsB,CAAC,KAAmB;IACjD,IAAI,KAAK,CAAC,IAAI,KAAK,cAAc,EAAE,CAAC;QAClC,OAAO,wBAAwB,UAAU,EAAE,wDAAwD,CAAC;IACtG,CAAC;IACD,IAAI,KAAK,CAAC,KAAK,EAAE,IAAI,KAAK,WAAW,EAAE,CAAC;QACtC,OAAO,0BAA0B,UAAU,EAAE,wDAAwD,CAAC;IACxG,CAAC;IACD,IAAI,KAAK,CAAC,KAAK,EAAE,IAAI,KAAK,WAAW,EAAE,CAAC;QACtC,OAAO,iBAAiB,UAAU,EAAE,qCAAqC,CAAC;IAC5E,CAAC;IACD,OAAO,qCAAqC,UAAU,EAAE,wDAAwD,CAAC;AACnH,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,UAAU,CAAU,QAA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,IAAI,CAAC;QAClB,MAAM,KAAK,CAAC;IACd,CAAC;IAED,OAAO,IAAS,CAAC;AACnB,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { getApiKey } from '../utils/auth.js';
|
|
2
|
+
import { apiRequest } from './client.js';
|
|
3
|
+
/**
|
|
4
|
+
* Create a new import of translations
|
|
5
|
+
* @param params Import parameters
|
|
6
|
+
* @returns The created import details
|
|
7
|
+
*/
|
|
8
|
+
export async function createImport(params) {
|
|
9
|
+
const apiKey = await getApiKey();
|
|
10
|
+
const response = await apiRequest(`/api/v1/projects/${params.projectId}/imports`, {
|
|
11
|
+
method: 'POST',
|
|
12
|
+
body: {
|
|
13
|
+
translations: params.translations
|
|
14
|
+
},
|
|
15
|
+
apiKey
|
|
16
|
+
});
|
|
17
|
+
return response;
|
|
18
|
+
}
|
|
19
|
+
export async function bulkUpdateTranslations(params) {
|
|
20
|
+
const apiKey = await getApiKey();
|
|
21
|
+
const response = await apiRequest(`/api/v1/projects/${params.projectId}/imports`, {
|
|
22
|
+
method: 'PATCH',
|
|
23
|
+
body: {
|
|
24
|
+
translations: params.translations
|
|
25
|
+
},
|
|
26
|
+
apiKey
|
|
27
|
+
});
|
|
28
|
+
return response;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Check the status of an import
|
|
32
|
+
* @param projectId The ID of the project
|
|
33
|
+
* @param importId The ID of the import to check
|
|
34
|
+
* @returns The import status response
|
|
35
|
+
*/
|
|
36
|
+
export async function checkImportStatus(projectId, importId) {
|
|
37
|
+
const apiKey = await getApiKey();
|
|
38
|
+
const response = await apiRequest(`/api/v1/projects/${projectId}/imports/${importId}`, {
|
|
39
|
+
apiKey
|
|
40
|
+
});
|
|
41
|
+
return response;
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=imports.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"imports.js","sourceRoot":"","sources":["../../src/api/imports.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AA6CzC;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,MAA0B;IAC3D,MAAM,MAAM,GAAG,MAAM,SAAS,EAAE,CAAC;IACjC,MAAM,QAAQ,GAAG,MAAM,UAAU,CAAC,oBAAoB,MAAM,CAAC,SAAS,UAAU,EAAE;QAChF,MAAM,EAAE,MAAM;QACd,IAAI,EAAE;YACJ,YAAY,EAAE,MAAM,CAAC,YAAY;SAClC;QACD,MAAM;KACP,CAAC,CAAC;IACH,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAAC,MAAoC;IAC/E,MAAM,MAAM,GAAG,MAAM,SAAS,EAAE,CAAC;IACjC,MAAM,QAAQ,GAAG,MAAM,UAAU,CAAC,oBAAoB,MAAM,CAAC,SAAS,UAAU,EAAE;QAChF,MAAM,EAAE,OAAO;QACf,IAAI,EAAE;YACJ,YAAY,EAAE,MAAM,CAAC,YAAY;SAClC;QACD,MAAM;KACP,CAAC,CAAC;IACH,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAC,SAAiB,EAAE,QAAgB;IACzE,MAAM,MAAM,GAAG,MAAM,SAAS,EAAE,CAAC;IACjC,MAAM,QAAQ,GAAG,MAAM,UAAU,CAAC,oBAAoB,SAAS,YAAY,QAAQ,EAAE,EAAE;QACrF,MAAM;KACP,CAAC,CAAC;IACH,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { getApiKey } from '../utils/auth.js';
|
|
2
|
+
import { apiRequest } from './client.js';
|
|
3
|
+
/**
|
|
4
|
+
* List all projects the user has access to
|
|
5
|
+
* @returns Array of project details
|
|
6
|
+
*/
|
|
7
|
+
export async function listProjects() {
|
|
8
|
+
const apiKey = await getApiKey();
|
|
9
|
+
const response = await apiRequest('/api/v1/projects', { apiKey });
|
|
10
|
+
return response.projects;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Create a new project
|
|
14
|
+
* @param data Project creation parameters
|
|
15
|
+
* @returns The created project details
|
|
16
|
+
*/
|
|
17
|
+
export async function createProject(data) {
|
|
18
|
+
const apiKey = await getApiKey();
|
|
19
|
+
const response = await apiRequest('/api/v1/projects', {
|
|
20
|
+
method: 'POST',
|
|
21
|
+
body: {
|
|
22
|
+
project: {
|
|
23
|
+
name: data.name,
|
|
24
|
+
source_language: data.sourceLocale,
|
|
25
|
+
target_languages: data.targetLocales
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
apiKey
|
|
29
|
+
});
|
|
30
|
+
return response.project;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Get details for a specific project
|
|
34
|
+
* @param projectId The ID of the project to fetch
|
|
35
|
+
* @returns The project details
|
|
36
|
+
*/
|
|
37
|
+
export async function getProject(projectId) {
|
|
38
|
+
const apiKey = await getApiKey();
|
|
39
|
+
const response = await apiRequest(`/api/v1/projects/${projectId}`, { apiKey });
|
|
40
|
+
return response.project;
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=projects.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"projects.js","sourceRoot":"","sources":["../../src/api/projects.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAczC;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY;IAChC,MAAM,MAAM,GAAG,MAAM,SAAS,EAAE,CAAC;IACjC,MAAM,QAAQ,GAAG,MAAM,UAAU,CAAC,kBAAkB,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC;IAClE,OAAO,QAAQ,CAAC,QAAQ,CAAC;AAC3B,CAAC;AAWD;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,IAAyB;IAC3D,MAAM,MAAM,GAAG,MAAM,SAAS,EAAE,CAAC;IACjC,MAAM,QAAQ,GAAG,MAAM,UAAU,CAAC,kBAAkB,EAAE;QACpD,MAAM,EAAE,MAAM;QACd,IAAI,EAAE;YACJ,OAAO,EAAE;gBACP,IAAI,EAAE,IAAI,CAAC,IAAI;gBACf,eAAe,EAAE,IAAI,CAAC,YAAY;gBAClC,gBAAgB,EAAE,IAAI,CAAC,aAAa;aACrC;SACF;QACD,MAAM;KACP,CAAC,CAAC;IACH,OAAO,QAAQ,CAAC,OAAO,CAAC;AAC1B,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,SAAiB;IAChD,MAAM,MAAM,GAAG,MAAM,SAAS,EAAE,CAAC;IACjC,MAAM,QAAQ,GAAG,MAAM,UAAU,CAAC,oBAAoB,SAAS,EAAE,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC;IAC/E,OAAO,QAAQ,CAAC,OAAO,CAAC;AAC1B,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export function createTranslationJob({ sourceFiles, targetLocales, projectId, targetPaths }: {
|
|
2
|
+
sourceFiles: any;
|
|
3
|
+
targetLocales: any;
|
|
4
|
+
projectId: any;
|
|
5
|
+
targetPaths: any;
|
|
6
|
+
}): Promise<{
|
|
7
|
+
jobs: any;
|
|
8
|
+
totalJobs: any;
|
|
9
|
+
}>;
|
|
10
|
+
export function checkJobStatus(jobId: any, includeTranslations?: boolean): Promise<any>;
|
|
11
|
+
export function getTranslations(jobId: any): Promise<any>;
|
|
12
|
+
export function getUpdates(projectId: any, { since, page }: {
|
|
13
|
+
since: any;
|
|
14
|
+
page?: number | undefined;
|
|
15
|
+
}): Promise<any>;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { getApiKey } from '../utils/auth.js';
|
|
2
|
+
import { apiRequest } from './client.js';
|
|
3
|
+
import { getCurrentBranch } from '../utils/git.js';
|
|
4
|
+
/**
|
|
5
|
+
* Create a new translation job
|
|
6
|
+
* @param params Job parameters
|
|
7
|
+
* @returns The created translation jobs
|
|
8
|
+
*/
|
|
9
|
+
export async function createTranslationJob(params) {
|
|
10
|
+
const apiKey = await getApiKey();
|
|
11
|
+
const branch = await getCurrentBranch();
|
|
12
|
+
const response = await apiRequest(`/api/v1/projects/${params.projectId}/translation_jobs`, {
|
|
13
|
+
method: 'POST',
|
|
14
|
+
body: {
|
|
15
|
+
target_languages: params.targetLocales,
|
|
16
|
+
files: params.sourceFiles.map(file => ({
|
|
17
|
+
path: file.path,
|
|
18
|
+
content: file.content,
|
|
19
|
+
format: file.format,
|
|
20
|
+
target_paths: params.targetPaths
|
|
21
|
+
})),
|
|
22
|
+
...(branch && { branch })
|
|
23
|
+
},
|
|
24
|
+
apiKey
|
|
25
|
+
});
|
|
26
|
+
if (!response.jobs || !response.jobs.length) {
|
|
27
|
+
throw new Error('No translation jobs were created');
|
|
28
|
+
}
|
|
29
|
+
return {
|
|
30
|
+
jobs: response.jobs,
|
|
31
|
+
totalJobs: response.jobs.length
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Check the status of a translation job
|
|
36
|
+
* @param jobId The ID of the job to check
|
|
37
|
+
* @param includeTranslations Whether to include translations in the response
|
|
38
|
+
* @returns The job status
|
|
39
|
+
*/
|
|
40
|
+
export async function checkJobStatus(jobId, includeTranslations = false) {
|
|
41
|
+
const apiKey = await getApiKey();
|
|
42
|
+
const endpoint = `/api/v1/translation_jobs/${jobId}${includeTranslations ? '?include_translations=true' : ''}`;
|
|
43
|
+
return apiRequest(endpoint, { apiKey });
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Get translations for a completed job
|
|
47
|
+
* @param jobId The ID of the job
|
|
48
|
+
* @returns The translations
|
|
49
|
+
*/
|
|
50
|
+
export async function getTranslations(jobId) {
|
|
51
|
+
const apiKey = await getApiKey();
|
|
52
|
+
return apiRequest(`/api/v1/translation_jobs/${jobId}/translations`, { apiKey });
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Get translation updates for a project
|
|
56
|
+
* @param projectId The ID of the project
|
|
57
|
+
* @param params Parameters for the request
|
|
58
|
+
* @returns The updates
|
|
59
|
+
*/
|
|
60
|
+
export async function getUpdates(projectId, { since, page = 1 }) {
|
|
61
|
+
const apiKey = await getApiKey();
|
|
62
|
+
if (!since) {
|
|
63
|
+
throw new Error('Missing required parameter: since (ISO 8601 timestamp)');
|
|
64
|
+
}
|
|
65
|
+
const queryParams = new URLSearchParams({
|
|
66
|
+
since,
|
|
67
|
+
page: page.toString()
|
|
68
|
+
});
|
|
69
|
+
return apiRequest(`/api/v1/projects/${projectId}/updates?${queryParams}`, { apiKey });
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=translations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"translations.js","sourceRoot":"","sources":["../../src/api/translations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AA+BnD;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CAAC,MAAkC;IAC3E,MAAM,MAAM,GAAG,MAAM,SAAS,EAAE,CAAC;IACjC,MAAM,MAAM,GAAG,MAAM,gBAAgB,EAAE,CAAC;IAExC,MAAM,QAAQ,GAAG,MAAM,UAAU,CAAC,oBAAoB,MAAM,CAAC,SAAS,mBAAmB,EAAE;QACzF,MAAM,EAAE,MAAM;QACd,IAAI,EAAE;YACJ,gBAAgB,EAAE,MAAM,CAAC,aAAa;YACtC,KAAK,EAAE,MAAM,CAAC,WAAW,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AoB;IAErC,MAAM,MAAM,GAAG,MAAM,SAAS,EAAE,CAAC;IAEjC,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,MAAM,IAAI,KAAK,CAAC,wDAAwD,CAAC,CAAC;IAC5E,CAAC;IAED,MAAM,WAAW,GAAG,IAAI,eAAe,CAAC;QACtC,KAAK;QACL,IAAI,EAAE,IAAI,CAAC,QAAQ,EAAE;KACtB,CAAC,CAAC;IAEH,OAAO,UAAU,CAAC,oBAAoB,SAAS,YAAY,WAAW,EAAE,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC;AACxF,CAAC"}
|
package/dist/cli.d.ts
ADDED
package/dist/cli.js
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { Command } from 'commander';
|
|
3
|
+
import chalk from 'chalk';
|
|
4
|
+
import { readFileSync } from 'fs';
|
|
5
|
+
import { fileURLToPath } from 'url';
|
|
6
|
+
import { dirname, resolve } from 'path';
|
|
7
|
+
import { login } from './commands/login.js';
|
|
8
|
+
import { pull } from './commands/pull.js';
|
|
9
|
+
import { push } from './commands/push.js';
|
|
10
|
+
import { init } from './commands/init.js';
|
|
11
|
+
import { translate } from './commands/translate.js';
|
|
12
|
+
import { configService } from './utils/config.js';
|
|
13
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
14
|
+
const __dirname = dirname(__filename);
|
|
15
|
+
const program = new Command();
|
|
16
|
+
function getVersion() {
|
|
17
|
+
const packageJson = JSON.parse(readFileSync(resolve(__dirname, '../package.json'), 'utf-8'));
|
|
18
|
+
return packageJson.version;
|
|
19
|
+
}
|
|
20
|
+
function handleApiError(error) {
|
|
21
|
+
console.error(chalk.red(`❌ ${error.cliErrorMessage || error.message}`));
|
|
22
|
+
if (program.opts().debug) {
|
|
23
|
+
console.error(chalk.dim(error.stack || error));
|
|
24
|
+
if (error.cause) {
|
|
25
|
+
console.error(chalk.dim(error.cause.stack || error.cause));
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
console.error(chalk.dim('\nRun with --debug for more information'));
|
|
30
|
+
}
|
|
31
|
+
process.exit(1);
|
|
32
|
+
}
|
|
33
|
+
function wrapCommandAction(action) {
|
|
34
|
+
return function (...args) {
|
|
35
|
+
return Promise.resolve(action(...args)).catch(handleApiError);
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
program
|
|
39
|
+
.name('localhero')
|
|
40
|
+
.description('CLI tool for automatic I18n translations with LocalHero.ai, more info at https://localhero.ai.')
|
|
41
|
+
.version(getVersion())
|
|
42
|
+
.option('--debug', 'Show debug information when errors occur')
|
|
43
|
+
.action(() => {
|
|
44
|
+
console.log('LocalHero.ai is automatic I18n translations service that easily integrates with your dev workflow.');
|
|
45
|
+
console.log(`\nVersion: ${getVersion()}`);
|
|
46
|
+
console.log('\n🔗 Visit https://localhero.ai for more information');
|
|
47
|
+
console.log('👏 Set up your project with `npx @localheroai/cli init`');
|
|
48
|
+
console.log('💡 Use --help to see available commands');
|
|
49
|
+
});
|
|
50
|
+
program
|
|
51
|
+
.command('login')
|
|
52
|
+
.description('Authenticate with LocalHero.ai using an API key')
|
|
53
|
+
.action(wrapCommandAction(() => login()));
|
|
54
|
+
program
|
|
55
|
+
.command('init')
|
|
56
|
+
.description('Initialize a new LocalHero.ai project')
|
|
57
|
+
.action(wrapCommandAction(() => init()));
|
|
58
|
+
program
|
|
59
|
+
.command('translate')
|
|
60
|
+
.description('Translate missing keys in your i18n files')
|
|
61
|
+
.option('-v, --verbose', 'Show detailed progress information')
|
|
62
|
+
.option('-c, --commit', 'Automatically commit changes (useful for CI/CD)')
|
|
63
|
+
.action(wrapCommandAction((options) => translate(options)));
|
|
64
|
+
program
|
|
65
|
+
.command('pull')
|
|
66
|
+
.description('Pull updates from LocalHero.ai to your local files')
|
|
67
|
+
.option('-v, --verbose', 'Show detailed progress information')
|
|
68
|
+
.action(wrapCommandAction((options) => pull(options)));
|
|
69
|
+
program
|
|
70
|
+
.command('push')
|
|
71
|
+
.description('Push updates from your local files to LocalHero.ai')
|
|
72
|
+
.option('-v, --verbose', 'Show detailed progress information')
|
|
73
|
+
.option('-y, --yes', 'Skip confirmation prompt')
|
|
74
|
+
.action(wrapCommandAction(async (options) => {
|
|
75
|
+
const config = await configService.getValidProjectConfig();
|
|
76
|
+
return push(config, options);
|
|
77
|
+
}));
|
|
78
|
+
program.parse();
|
|
79
|
+
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AACxC,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAC5C,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC1C,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC1C,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAsB,MAAM,yBAAyB,CAAC;AACxE,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAElD,MAAM,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAClD,MAAM,SAAS,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AAEtC,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;AAE9B,SAAS,UAAU;IACjB,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAC5B,YAAY,CAAC,OAAO,CAAC,SAAS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C,KAAK,EAAE,OAA6C,EAAE,EAAE;IAChF,MAAM,MAAM,GAAG,MAAM,aAAa,CAAC,qBAAqB,EAAE,CAAC;IAC3D,OAAO,IAAI,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAC/B,CAAC,CAAC,CAAC,CAAC;AAEN,OAAO,CAAC,KAAK,EAAE,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { syncService as defaultSyncService } from '../utils/sync-service.js';
|
|
2
|
+
import chalk from 'chalk';
|
|
3
|
+
export async function sync({ verbose = false } = {}, deps = { syncService: defaultSyncService }) {
|
|
4
|
+
const { syncService } = deps;
|
|
5
|
+
const { hasUpdates, updates } = await syncService.checkForUpdates({ verbose });
|
|
6
|
+
if (!hasUpdates) {
|
|
7
|
+
console.log(chalk.green('✓ All translations are up to date'));
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
const result = await syncService.applyUpdates(updates, { verbose });
|
|
11
|
+
const { totalUpdates = 0, totalDeleted = 0 } = result;
|
|
12
|
+
if (!verbose) {
|
|
13
|
+
if (totalUpdates > 0) {
|
|
14
|
+
console.log(chalk.green(`✓ Updated ${totalUpdates} translations`));
|
|
15
|
+
}
|
|
16
|
+
if (totalDeleted > 0) {
|
|
17
|
+
console.log(chalk.green(`✓ Deleted ${totalDeleted} keys`));
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return result;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=_sync.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_sync.js","sourceRoot":"","sources":["../../src/commands/_sync.js"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,IAAI,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC7E,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,MAAM,CAAC,KAAK,UAAU,IAAI,CAAC,EAAE,OAAO,GAAG,KAAK,EAAE,GAAG,EAAE,EAAE,IAAI,GAAG,EAAE,WAAW,EAAE,kBAAkB,EAAE;IAC7F,MAAM,EAAE,WAAW,EAAE,GAAG,IAAI,CAAC;IAC7B,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,GAAG,MAAM,WAAW,CAAC,eAAe,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC;IAE/E,IAAI,CAAC,UAAU,EAAE,CAAC;QAChB,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,mCAAmC,CAAC,CAAC,CAAC;QAC9D,OAAO;IACT,CAAC;IAED,MAAM,MAAM,GAAG,MAAM,WAAW,CAAC,YAAY,CAAC,OAAO,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC;IAEpE,MAAM,EAAE,YAAY,GAAG,CAAC,EAAE,YAAY,GAAG,CAAC,EAAE,GAAG,MAAM,CAAC;IAEtD,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,IAAI,YAAY,GAAG,CAAC,EAAE,CAAC;YACrB,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,aAAa,YAAY,eAAe,CAAC,CAAC,CAAC;QACrE,CAAC;QAED,IAAI,YAAY,GAAG,CAAC,EAAE,CAAC;YACrB,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,aAAa,YAAY,OAAO,CAAC,CAAC,CAAC;QAC7D,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_translate.js","sourceRoot":"","sources":["../../src/commands/_translate.js"],"names":[],"mappings":"AAAA,oEAAoE;AACpE,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function init(deps?: {}): Promise<void>;
|