@tolgee/cli 2.1.5 → 2.1.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/dist/client/ApiClient.js +7 -9
- package/dist/client/ImportClient.js +9 -8
- package/dist/commands/extract/check.js +3 -2
- package/dist/commands/extract/print.js +4 -3
- package/dist/commands/push.js +2 -1
- package/dist/config/tolgeerc.js +1 -1
- package/dist/extractor/parserReact/ParserReact.js +1 -1
- package/dist/extractor/runner.js +2 -2
- package/dist/extractor/warnings.js +5 -3
- package/dist/utils/moduleLoader.js +9 -10
- package/dist/utils/pathToPosix.js +4 -0
- package/extractor.d.ts +2 -5
- package/package.json +43 -32
- package/textmate/HTML.tmLanguage +1 -2650
- package/textmate/Svelte.tmLanguage +1 -1164
- package/textmate/TypeScript.tmLanguage +1 -5888
- package/textmate/TypeScriptReact.tmLanguage +1 -6137
- package/textmate/Vue.tmLanguage +1 -1263
package/dist/client/ApiClient.js
CHANGED
@@ -47,17 +47,15 @@ export function createApiClient({ baseUrl, apiKey, projectId, autoThrow = false,
|
|
47
47
|
},
|
48
48
|
});
|
49
49
|
apiClient.use({
|
50
|
-
onRequest: (
|
51
|
-
debug(`[HTTP] Requesting: ${
|
52
|
-
return undefined;
|
50
|
+
onRequest: ({ request }) => {
|
51
|
+
debug(`[HTTP] Requesting: ${request.method} ${request.url}`);
|
53
52
|
},
|
54
|
-
onResponse: async (
|
55
|
-
debug(`[HTTP] Response: ${
|
56
|
-
if (autoThrow && !
|
57
|
-
const loadable = await parseResponse(
|
58
|
-
throw new Error(`Tolgee request error ${
|
53
|
+
onResponse: async ({ response, options }) => {
|
54
|
+
debug(`[HTTP] Response: ${response.url} [${response.status}]`);
|
55
|
+
if (autoThrow && !response.ok) {
|
56
|
+
const loadable = await parseResponse(response, options.parseAs);
|
57
|
+
throw new Error(`Tolgee request error ${response.url} ${errorFromLoadable(loadable)}`);
|
59
58
|
}
|
60
|
-
return undefined;
|
61
59
|
},
|
62
60
|
});
|
63
61
|
return {
|
@@ -1,21 +1,22 @@
|
|
1
|
-
import
|
1
|
+
import { pathToPosix } from '../utils/pathToPosix.js';
|
2
2
|
export const createImportClient = ({ apiClient }) => {
|
3
3
|
return {
|
4
4
|
async import(data) {
|
5
5
|
const body = new FormData();
|
6
6
|
for (const file of data.files) {
|
7
|
-
|
7
|
+
// converting paths to posix style, so it's correctly matched on the server
|
8
|
+
body.append('files', new Blob([file.data]), pathToPosix(file.name));
|
8
9
|
}
|
10
|
+
data.params.fileMappings = data.params.fileMappings.map((i) => ({
|
11
|
+
...i,
|
12
|
+
// converting paths to posix style, so it's correctly matched on the server
|
13
|
+
fileName: pathToPosix(i.fileName),
|
14
|
+
}));
|
9
15
|
body.append('params', JSON.stringify(data.params));
|
10
16
|
return apiClient.POST('/v2/projects/{projectId}/single-step-import', {
|
11
17
|
params: { path: { projectId: apiClient.getProjectId() } },
|
12
18
|
body: body,
|
13
|
-
bodySerializer: (r) =>
|
14
|
-
return r.getBuffer();
|
15
|
-
},
|
16
|
-
headers: {
|
17
|
-
'content-type': `multipart/form-data; boundary=${body.getBoundary()}`,
|
18
|
-
},
|
19
|
+
bodySerializer: (r) => r,
|
19
20
|
});
|
20
21
|
},
|
21
22
|
};
|
@@ -9,14 +9,15 @@ const lintHandler = (config) => async function () {
|
|
9
9
|
let warningCount = 0;
|
10
10
|
let filesCount = 0;
|
11
11
|
for (const [file, { warnings }] of extracted) {
|
12
|
-
if (warnings
|
12
|
+
if (warnings?.length) {
|
13
13
|
warningCount += warnings.length;
|
14
14
|
filesCount++;
|
15
15
|
const relFile = relative(process.cwd(), file);
|
16
16
|
console.log('%s:', relFile);
|
17
17
|
for (const warning of warnings) {
|
18
18
|
if (warning.warning in WarningMessages) {
|
19
|
-
const
|
19
|
+
const warn = warning.warning;
|
20
|
+
const { name } = WarningMessages[warn];
|
20
21
|
console.log('\tline %d: %s', warning.line, name);
|
21
22
|
}
|
22
23
|
else {
|
@@ -23,12 +23,13 @@ const printHandler = (config) => async function () {
|
|
23
23
|
}
|
24
24
|
}
|
25
25
|
}
|
26
|
-
if (warnings
|
26
|
+
if (warnings?.length) {
|
27
27
|
warningCount += warnings.length;
|
28
28
|
console.log('%d warning%s %s emitted during extraction:', warnings.length, warnings.length !== 1 ? 's' : '', warnings.length !== 1 ? 'were' : 'was');
|
29
29
|
for (const warning of warnings) {
|
30
30
|
if (warning.warning in WarningMessages) {
|
31
|
-
const
|
31
|
+
const warn = warning.warning;
|
32
|
+
const { name } = WarningMessages[warn];
|
32
33
|
console.log('\tline %d: %s', warning.line, name);
|
33
34
|
}
|
34
35
|
else {
|
@@ -36,7 +37,7 @@ const printHandler = (config) => async function () {
|
|
36
37
|
}
|
37
38
|
}
|
38
39
|
}
|
39
|
-
if (keys.length || warnings
|
40
|
+
if (keys.length || warnings?.length) {
|
40
41
|
console.log();
|
41
42
|
}
|
42
43
|
}
|
package/dist/commands/push.js
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
import { extname, join } from 'path';
|
2
2
|
import { readdir, readFile, stat } from 'fs/promises';
|
3
3
|
import { Command, Option } from 'commander';
|
4
|
-
import
|
4
|
+
import glob from 'fast-glob';
|
5
5
|
import { loading, success, error, warn, exitWithError, } from '../utils/logger.js';
|
6
6
|
import { askString } from '../utils/ask.js';
|
7
7
|
import { mapImportFormat } from '../utils/mapImportFormat.js';
|
@@ -91,6 +91,7 @@ const pushHandler = (config) => async function () {
|
|
91
91
|
return;
|
92
92
|
}
|
93
93
|
const params = {
|
94
|
+
createNewKeys: true,
|
94
95
|
forceMode: opts.forceMode,
|
95
96
|
overrideKeyDescriptions: opts.overrideKeyDescriptions,
|
96
97
|
convertPlaceholdersToIcu: opts.convertPlaceholdersToIcu,
|
package/dist/config/tolgeerc.js
CHANGED
package/dist/extractor/runner.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import
|
1
|
+
import glob from 'fast-glob';
|
2
2
|
import { extname } from 'path';
|
3
3
|
import { callWorker } from './worker.js';
|
4
4
|
import { exitWithError } from '../utils/logger.js';
|
@@ -44,7 +44,7 @@ export async function extractKeysOfFiles(opts) {
|
|
44
44
|
if (!opts.patterns?.length) {
|
45
45
|
exitWithError("Missing '--patterns' or 'config.patterns' option");
|
46
46
|
}
|
47
|
-
const files = await glob(opts.patterns, {
|
47
|
+
const files = await glob(opts.patterns, { onlyFiles: true });
|
48
48
|
if (files.length === 0) {
|
49
49
|
exitWithError('No files were matched for extraction');
|
50
50
|
}
|
@@ -50,14 +50,15 @@ export const WarningMessages = {
|
|
50
50
|
export function dumpWarnings(extractionResult) {
|
51
51
|
let warningCount = 0;
|
52
52
|
for (const [file, { warnings }] of extractionResult.entries()) {
|
53
|
-
if (warnings
|
53
|
+
if (warnings?.length) {
|
54
54
|
if (!warningCount) {
|
55
55
|
console.error('Warnings were emitted during extraction.');
|
56
56
|
}
|
57
57
|
console.error(file);
|
58
58
|
for (const warning of warnings) {
|
59
59
|
const warnText = warning.warning in WarningMessages
|
60
|
-
? WarningMessages[warning.warning]
|
60
|
+
? WarningMessages[warning.warning]
|
61
|
+
.name
|
61
62
|
: warning.warning;
|
62
63
|
console.error('\tline %d: %s', warning.line, warnText);
|
63
64
|
emitGitHubWarning(warning.warning, file, warning.line);
|
@@ -75,7 +76,8 @@ export function emitGitHubWarning(warning, file, line) {
|
|
75
76
|
return;
|
76
77
|
file = relative(process.env.GITHUB_WORKSPACE ?? process.cwd(), file);
|
77
78
|
if (warning in WarningMessages) {
|
78
|
-
const
|
79
|
+
const warn = warning;
|
80
|
+
const { name, description } = WarningMessages[warn];
|
79
81
|
const encodedDescription = description
|
80
82
|
.replaceAll('%', '%25')
|
81
83
|
.replaceAll('\r', '%0D')
|
@@ -2,16 +2,15 @@ import { extname } from 'path';
|
|
2
2
|
let tsService;
|
3
3
|
async function registerTsNode() {
|
4
4
|
if (!tsService) {
|
5
|
-
try {
|
6
|
-
|
7
|
-
|
8
|
-
}
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
}
|
5
|
+
// try {
|
6
|
+
// const tsNode = await import('ts-node');
|
7
|
+
// tsService = tsNode.register({ compilerOptions: { module: 'CommonJS' } });
|
8
|
+
// } catch (e: any) {
|
9
|
+
// if (e.code === 'ERR_MODULE_NOT_FOUND') {
|
10
|
+
// throw new Error('ts-node is required to load TypeScript files.');
|
11
|
+
// }
|
12
|
+
// throw e;
|
13
|
+
// }
|
15
14
|
}
|
16
15
|
}
|
17
16
|
async function importTypeScript(file) {
|
package/extractor.d.ts
CHANGED
@@ -22,9 +22,6 @@ export type ParserType = 'react' | 'vue' | 'svelte';
|
|
22
22
|
export type Extractor = (fileContents: string, fileName: string, options: ExtractOptions) => ExtractionResult;
|
23
23
|
export type ExtractionResult = {
|
24
24
|
keys: ExtractedKey[];
|
25
|
-
warnings
|
25
|
+
warnings?: Warning[];
|
26
26
|
};
|
27
|
-
export type ExtractionResults = Map<string,
|
28
|
-
keys: ExtractedKey[];
|
29
|
-
warnings: Warning[];
|
30
|
-
}>;
|
27
|
+
export type ExtractionResults = Map<string, ExtractionResult>;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@tolgee/cli",
|
3
|
-
"version": "2.1.
|
3
|
+
"version": "2.1.7",
|
4
4
|
"type": "module",
|
5
5
|
"description": "A tool to interact with the Tolgee Platform through CLI",
|
6
6
|
"repository": {
|
@@ -11,57 +11,63 @@
|
|
11
11
|
"tolgee": "./dist/cli.js"
|
12
12
|
},
|
13
13
|
"scripts": {
|
14
|
-
"
|
14
|
+
"prepack": "npm run build",
|
15
|
+
"build": "premove dist dist-types && tsc -p tsconfig.prod.json && tsx scripts/copyExtractorTypes.ts",
|
15
16
|
"test": "vitest run",
|
16
|
-
"test:unit": "vitest run -c unit.vitest.config.ts --dir ./
|
17
|
-
"test:e2e": "vitest run --dir ./
|
18
|
-
"test:package": "
|
19
|
-
"
|
17
|
+
"test:unit": "vitest run -c unit.vitest.config.ts --dir ./test/unit",
|
18
|
+
"test:e2e": "vitest run --dir ./test/e2e",
|
19
|
+
"test:package": "tsx ./scripts/validatePackage.ts",
|
20
|
+
"test:types": "tsc --noEmit",
|
21
|
+
"tolgee:start": "tsx ./scripts/startDocker.ts",
|
20
22
|
"tolgee:stop": "docker stop tolgee_cli_e2e",
|
21
|
-
"eslint": "eslint --max-warnings 0
|
22
|
-
"
|
23
|
-
"run-dev": "
|
23
|
+
"eslint": "eslint --max-warnings 0",
|
24
|
+
"format": "eslint --fix",
|
25
|
+
"run-dev": "tsx ./src/cli.ts",
|
24
26
|
"schema": "openapi-typescript http://localhost:22222/v3/api-docs/All%20Internal%20-%20for%20Tolgee%20Web%20application --output src/client/internal/schema.generated.ts",
|
25
27
|
"release": "semantic-release",
|
26
|
-
"config:type": "
|
28
|
+
"config:type": "tsx scripts/configType.ts"
|
27
29
|
},
|
28
30
|
"author": "Jan Cizmar",
|
29
31
|
"license": "MIT",
|
30
32
|
"dependencies": {
|
31
33
|
"ansi-colors": "^4.1.3",
|
32
34
|
"base32-decode": "^1.0.0",
|
33
|
-
"commander": "^12.
|
34
|
-
"cosmiconfig": "^
|
35
|
-
"
|
36
|
-
"glob": "^10.3.3",
|
35
|
+
"commander": "^12.1.0",
|
36
|
+
"cosmiconfig": "^9.0.0",
|
37
|
+
"fast-glob": "^3.3.2",
|
37
38
|
"json5": "^2.2.3",
|
38
39
|
"jsonschema": "^1.4.1",
|
39
|
-
"openapi-fetch": "^0.
|
40
|
+
"openapi-fetch": "^0.10.6",
|
40
41
|
"unescape-js": "^1.1.4",
|
41
|
-
"vscode-oniguruma": "^
|
42
|
-
"vscode-textmate": "^9.
|
43
|
-
"yauzl": "^
|
42
|
+
"vscode-oniguruma": "^2.0.1",
|
43
|
+
"vscode-textmate": "^9.1.0",
|
44
|
+
"yauzl": "^3.1.3"
|
44
45
|
},
|
45
46
|
"devDependencies": {
|
47
|
+
"@eslint/js": "^9.8.0",
|
46
48
|
"@semantic-release/changelog": "^6.0.3",
|
47
49
|
"@semantic-release/git": "^10.0.1",
|
48
|
-
"@
|
49
|
-
"@
|
50
|
-
"@
|
51
|
-
"@
|
50
|
+
"@tsconfig/node18": "^18.2.4",
|
51
|
+
"@tsconfig/recommended": "^1.0.7",
|
52
|
+
"@types/eslint__js": "^8.42.3",
|
53
|
+
"@types/js-yaml": "^4.0.9",
|
54
|
+
"@types/node": "^22.1.0",
|
55
|
+
"@types/yauzl": "^2.10.3",
|
52
56
|
"cross-env": "^7.0.3",
|
53
|
-
"eslint": "^8.
|
54
|
-
"eslint-
|
57
|
+
"eslint": "^9.8.0",
|
58
|
+
"eslint-config-prettier": "^9.1.0",
|
59
|
+
"eslint-plugin-prettier": "^5.2.1",
|
55
60
|
"js-yaml": "^4.1.0",
|
56
|
-
"json-schema-to-typescript": "^
|
57
|
-
"openapi-typescript": "^
|
58
|
-
"
|
59
|
-
"
|
60
|
-
"semantic-release": "^
|
61
|
+
"json-schema-to-typescript": "^15.0.0",
|
62
|
+
"openapi-typescript": "^7.3.0",
|
63
|
+
"premove": "^4.0.0",
|
64
|
+
"prettier": "^3.3.3",
|
65
|
+
"semantic-release": "^24.0.0",
|
61
66
|
"tree-cli": "^0.6.7",
|
62
|
-
"
|
63
|
-
"typescript": "^5.4
|
64
|
-
"
|
67
|
+
"tsx": "^4.17.0",
|
68
|
+
"typescript": "^5.5.4",
|
69
|
+
"typescript-eslint": "^8.0.1",
|
70
|
+
"vitest": "^2.0.5"
|
65
71
|
},
|
66
72
|
"engines": {
|
67
73
|
"node": ">= 18"
|
@@ -102,5 +108,10 @@
|
|
102
108
|
"@semantic-release/npm",
|
103
109
|
"@semantic-release/github"
|
104
110
|
]
|
111
|
+
},
|
112
|
+
"imports": {
|
113
|
+
"#cli/*.js": "./src/*.js",
|
114
|
+
"#tests/*.js": "./test/*.js",
|
115
|
+
"#tests/*.json": "./test/*.json"
|
105
116
|
}
|
106
117
|
}
|