gtx-cli 2.3.2 → 2.3.4
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/CHANGELOG.md +15 -0
- package/dist/api/checkFileTranslations.d.ts +1 -1
- package/dist/api/checkFileTranslations.js +12 -7
- package/dist/cli/commands/translate.js +3 -2
- package/dist/utils/addExplicitAnchorIds.js +1 -1
- package/dist/utils/localizeStaticUrls.js +1 -1
- package/package.json +2 -1
- package/dist/utils/escapeHtml.d.ts +0 -8
- package/dist/utils/escapeHtml.js +0 -34
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# gtx-cli
|
|
2
2
|
|
|
3
|
+
## 2.3.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#671](https://github.com/generaltranslation/gt/pull/671) [`b8c19d1`](https://github.com/generaltranslation/gt/commit/b8c19d13c0ab18a3f9376ebb940d9985cee6d961) Thanks [@fernando-aviles](https://github.com/fernando-aviles)! - Fixing --force command in gtx-cli
|
|
8
|
+
|
|
9
|
+
## 2.3.3
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [#665](https://github.com/generaltranslation/gt/pull/665) [`814cb12`](https://github.com/generaltranslation/gt/commit/814cb122e68a51ea1a513e9f6e51249af345db64) Thanks [@fernando-aviles](https://github.com/fernando-aviles)! - Migrating CLI to gt-remark plugin, updating plugin
|
|
14
|
+
|
|
15
|
+
- Updated dependencies [[`814cb12`](https://github.com/generaltranslation/gt/commit/814cb122e68a51ea1a513e9f6e51249af345db64)]:
|
|
16
|
+
- gt-remark@1.0.1
|
|
17
|
+
|
|
3
18
|
## 2.3.2
|
|
4
19
|
|
|
5
20
|
### Patch Changes
|
|
@@ -20,4 +20,4 @@ export declare function checkFileTranslations(data: {
|
|
|
20
20
|
versionId: string;
|
|
21
21
|
fileName: string;
|
|
22
22
|
};
|
|
23
|
-
}, locales: string[], timeoutDuration: number, resolveOutputPath: (sourcePath: string, locale: string) => string | null, options: Settings): Promise<boolean>;
|
|
23
|
+
}, locales: string[], timeoutDuration: number, resolveOutputPath: (sourcePath: string, locale: string) => string | null, options: Settings, forceRetranslation?: boolean): Promise<boolean>;
|
|
@@ -14,11 +14,14 @@ import { TEMPLATE_FILE_NAME } from '../cli/commands/stage.js';
|
|
|
14
14
|
* @param timeoutDuration - The timeout duration for the wait in seconds
|
|
15
15
|
* @returns True if all translations are deployed, false otherwise
|
|
16
16
|
*/
|
|
17
|
-
export async function checkFileTranslations(data, locales, timeoutDuration, resolveOutputPath, options) {
|
|
17
|
+
export async function checkFileTranslations(data, locales, timeoutDuration, resolveOutputPath, options, forceRetranslation) {
|
|
18
18
|
const startTime = Date.now();
|
|
19
19
|
console.log();
|
|
20
20
|
const spinner = await createOraSpinner();
|
|
21
|
-
|
|
21
|
+
const spinnerMessage = forceRetranslation
|
|
22
|
+
? 'Waiting for retranslation...'
|
|
23
|
+
: 'Waiting for translation...';
|
|
24
|
+
spinner.start(spinnerMessage);
|
|
22
25
|
// Initialize the query data
|
|
23
26
|
const fileQueryData = prepareFileQueryData(data, locales);
|
|
24
27
|
const downloadStatus = {
|
|
@@ -26,11 +29,13 @@ export async function checkFileTranslations(data, locales, timeoutDuration, reso
|
|
|
26
29
|
failed: new Set(),
|
|
27
30
|
skipped: new Set(),
|
|
28
31
|
};
|
|
29
|
-
// Do first check immediately
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
// Do first check immediately, but skip if force retranslation is enabled
|
|
33
|
+
if (!forceRetranslation) {
|
|
34
|
+
const initialCheck = await checkTranslationDeployment(fileQueryData, downloadStatus, spinner, resolveOutputPath, options);
|
|
35
|
+
if (initialCheck) {
|
|
36
|
+
spinner.succeed(chalk.green('Files translated!'));
|
|
37
|
+
return true;
|
|
38
|
+
}
|
|
34
39
|
}
|
|
35
40
|
// Calculate time until next 5-second interval since startTime
|
|
36
41
|
const msUntilNextInterval = Math.max(0, 5000 - ((Date.now() - startTime) % 5000));
|
|
@@ -15,7 +15,7 @@ export async function handleTranslate(options, settings, filesTranslationRespons
|
|
|
15
15
|
const fileMapping = createFileMapping(resolvedPaths, placeholderPaths, transformPaths, settings.locales, settings.defaultLocale);
|
|
16
16
|
const { data } = filesTranslationResponse;
|
|
17
17
|
// Check for remaining translations
|
|
18
|
-
await checkFileTranslations(data, settings.locales, options.timeout, (sourcePath, locale) => fileMapping[locale][sourcePath] ?? null, settings);
|
|
18
|
+
await checkFileTranslations(data, settings.locales, options.timeout, (sourcePath, locale) => fileMapping[locale][sourcePath] ?? null, settings, options.force);
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
// Downloads translations that were originally staged
|
|
@@ -33,7 +33,8 @@ export async function handleDownload(options, settings) {
|
|
|
33
33
|
const fileMapping = createFileMapping(resolvedPaths, placeholderPaths, transformPaths, settings.locales, settings.defaultLocale);
|
|
34
34
|
const stagedVersionData = await getStagedVersions(settings.configDirectory);
|
|
35
35
|
// Check for remaining translations
|
|
36
|
-
await checkFileTranslations(stagedVersionData, settings.locales, options.timeout, (sourcePath, locale) => fileMapping[locale][sourcePath] ?? null, settings
|
|
36
|
+
await checkFileTranslations(stagedVersionData, settings.locales, options.timeout, (sourcePath, locale) => fileMapping[locale][sourcePath] ?? null, settings, false // force is not applicable for downloading staged translations
|
|
37
|
+
);
|
|
37
38
|
}
|
|
38
39
|
export async function postProcessTranslations(settings) {
|
|
39
40
|
// Localize static urls (/docs -> /[locale]/docs) and preserve anchor IDs for non-default locales
|
|
@@ -5,7 +5,7 @@ import remarkFrontmatter from 'remark-frontmatter';
|
|
|
5
5
|
import remarkStringify from 'remark-stringify';
|
|
6
6
|
import { visit } from 'unist-util-visit';
|
|
7
7
|
import { logWarning } from '../console/logging.js';
|
|
8
|
-
import
|
|
8
|
+
import escapeHtmlInTextNodes from 'gt-remark';
|
|
9
9
|
/**
|
|
10
10
|
* Generates a slug from heading text
|
|
11
11
|
*/
|
|
@@ -7,7 +7,7 @@ import remarkMdx from 'remark-mdx';
|
|
|
7
7
|
import remarkFrontmatter from 'remark-frontmatter';
|
|
8
8
|
import remarkStringify from 'remark-stringify';
|
|
9
9
|
import { visit } from 'unist-util-visit';
|
|
10
|
-
import
|
|
10
|
+
import escapeHtmlInTextNodes from 'gt-remark';
|
|
11
11
|
const { isMatch } = micromatch;
|
|
12
12
|
/**
|
|
13
13
|
* Localizes static urls in content files.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gtx-cli",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.4",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"bin": "dist/main.js",
|
|
6
6
|
"files": [
|
|
@@ -88,6 +88,7 @@
|
|
|
88
88
|
"fast-glob": "^3.3.3",
|
|
89
89
|
"form-data": "^4.0.4",
|
|
90
90
|
"generaltranslation": "^7.6.2",
|
|
91
|
+
"gt-remark": "^1.0.1",
|
|
91
92
|
"json-pointer": "^0.6.2",
|
|
92
93
|
"jsonpath-plus": "^10.3.0",
|
|
93
94
|
"jsonpointer": "^5.0.1",
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { Plugin } from 'unified';
|
|
2
|
-
import type { Root } from 'mdast';
|
|
3
|
-
/**
|
|
4
|
-
* Escape HTML-sensitive characters ('{', '}', `&`, `<`, `>`, `"`, `'`) in text nodes,
|
|
5
|
-
* leaving code, math, MDX expressions, and front-matter untouched.
|
|
6
|
-
* Ensures literals render safely without altering already-escaped entities.
|
|
7
|
-
*/
|
|
8
|
-
export declare const escapeHtmlInTextNodes: Plugin<[], Root>;
|
package/dist/utils/escapeHtml.js
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { findAndReplace } from 'mdast-util-find-and-replace';
|
|
2
|
-
const IGNORE_PARENTS = [
|
|
3
|
-
'code',
|
|
4
|
-
'inlineCode',
|
|
5
|
-
'mdxFlowExpression',
|
|
6
|
-
'mdxTextExpression',
|
|
7
|
-
'mdxjsEsm',
|
|
8
|
-
'heading',
|
|
9
|
-
'yaml',
|
|
10
|
-
'toml',
|
|
11
|
-
'math',
|
|
12
|
-
'inlineMath',
|
|
13
|
-
];
|
|
14
|
-
// & that is NOT already an entity: &word; { ᨫ
|
|
15
|
-
const AMP_NOT_ENTITY = /&(?![a-zA-Z][a-zA-Z0-9]*;|#\d+;|#x[0-9A-Fa-f]+;)/g;
|
|
16
|
-
/**
|
|
17
|
-
* Escape HTML-sensitive characters ('{', '}', `&`, `<`, `>`, `"`, `'`) in text nodes,
|
|
18
|
-
* leaving code, math, MDX expressions, and front-matter untouched.
|
|
19
|
-
* Ensures literals render safely without altering already-escaped entities.
|
|
20
|
-
*/
|
|
21
|
-
export const escapeHtmlInTextNodes = function () {
|
|
22
|
-
return (tree) => {
|
|
23
|
-
findAndReplace(tree, [
|
|
24
|
-
// Order matters: & first (idempotency), then the rest
|
|
25
|
-
[AMP_NOT_ENTITY, '&'],
|
|
26
|
-
[/\{/g, '{'],
|
|
27
|
-
[/\}/g, '}'],
|
|
28
|
-
[/</g, '<'],
|
|
29
|
-
[/>/g, '>'],
|
|
30
|
-
[/"/g, '"'],
|
|
31
|
-
[/'/g, '''],
|
|
32
|
-
], { ignore: IGNORE_PARENTS });
|
|
33
|
-
};
|
|
34
|
-
};
|