Skip to content

Commit

Permalink
fix(core): update localization files (#795)
Browse files Browse the repository at this point in the history
  • Loading branch information
AgentEnder authored Oct 31, 2023
1 parent 2225eac commit 7213b67
Show file tree
Hide file tree
Showing 14 changed files with 278 additions and 275 deletions.
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
NODE_OPTIONS="--experimental-modules --experimental-vm-modules"
28 changes: 14 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"@docusaurus/preset-classic": "^2.4.0",
"@docusaurus/theme-search-algolia": "^2.4.0",
"@mdx-js/react": "^1.6.21",
"@nx/devkit": "17.0.0",
"@nx/devkit": "17.0.2",
"@swc/helpers": "0.5.2",
"@trumbitta/nx-plugin-openapi": "^1.12.1",
"@types/xmldoc": "^1.1.6",
Expand Down Expand Up @@ -51,17 +51,17 @@
"@commitlint/config-conventional": "^17.1.0",
"@commitlint/types": "^17.4.4",
"@nx-plus/docusaurus": "15.0.0-rc.0",
"@nx/cypress": "17.0.0",
"@nx/eslint": "17.0.0",
"@nx/eslint-plugin": "17.0.0",
"@nx/jest": "17.0.0",
"@nx/js": "17.0.0",
"@nx/node": "17.0.0",
"@nx/plugin": "17.0.0",
"@nx/react": "17.0.0",
"@nx/web": "17.0.0",
"@nx/webpack": "17.0.0",
"@nx/workspace": "17.0.0",
"@nx/cypress": "17.0.2",
"@nx/eslint": "17.0.2",
"@nx/eslint-plugin": "17.0.2",
"@nx/jest": "17.0.2",
"@nx/js": "17.0.2",
"@nx/node": "17.0.2",
"@nx/plugin": "17.0.2",
"@nx/react": "17.0.2",
"@nx/web": "17.0.2",
"@nx/webpack": "17.0.2",
"@nx/workspace": "17.0.2",
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.7",
"@semantic-release/changelog": "^6.0.3",
"@semantic-release/commit-analyzer": "^9.0.2",
Expand Down Expand Up @@ -109,9 +109,9 @@
"lint-staged": "^13.0.3",
"memfs": "3.4.13",
"node-fetch": "3.3.0",
"nx": "17.0.0",
"nx": "17.0.2",
"openapi-types": "^12.1.0",
"prettier": "2.7.1",
"prettier": "^3.0.3",
"react-refresh": "^0.10.0",
"run-p": "*",
"semantic-release": "^19.0.5",
Expand Down
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"postinstall": "node ./src/tasks/post-install"
},
"dependencies": {
"@nx/devkit": "17.0.0",
"@nx/devkit": "17.0.2",
"@nx-dotnet/dotnet": "2.1.0",
"@nx-dotnet/utils": "2.1.0",
"fast-glob": "3.2.12",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { SwaggerTypescriptGeneratorSchema } from './schema';
import { NormalizedOptions, normalizeOptions } from './utils/normalize-options';

import type { OpenAPIV2, OpenAPIV3, OpenAPIV3_1 } from 'openapi-types';

function generateInterfaceFiles(
tree: Tree,
interfaces: TypeScriptRepresentation[],
Expand Down
2 changes: 1 addition & 1 deletion packages/nxdoc/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"url": "https://github.com/nx-dotnet/nx-dotnet"
},
"dependencies": {
"@nx/devkit": "17.0.0",
"@nx/devkit": "17.0.2",
"tslib": "^2.5.0"
},
"peerDependencies": {},
Expand Down
2 changes: 1 addition & 1 deletion packages/utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"main": "src/index.js",
"private": false,
"dependencies": {
"@nx/devkit": "17.0.0",
"@nx/devkit": "17.0.2",
"fast-glob": "3.2.12",
"rimraf": "^3.0.2",
"xmldoc": "^1.1.2",
Expand Down
4 changes: 2 additions & 2 deletions tools/scripts/patch-package-versions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export async function PatchPackageVersions(
const rootPkg = readJson('package.json');
if (newVersion && prebuild) {
rootPkg.version = newVersion;
writeJson('package.json', rootPkg);
await writeJson('package.json', rootPkg);
} else if (!newVersion) {
newVersion = rootPkg.version;
}
Expand Down Expand Up @@ -57,7 +57,7 @@ export async function PatchPackageVersions(
await patchDependenciesSection('dependencies', pkg, newVersion);
await patchDependenciesSection('devDependencies', pkg, newVersion);

writeJson(pkgPath, pkg);
await writeJson(pkgPath, pkg);
execSync(`yarn prettier --write ${pkgPath}`);
console.log('Updated', pkgPath, 'for', newVersion);

Expand Down
4 changes: 2 additions & 2 deletions tools/utils/fs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ export function readJson(path: string) {
return JSON.parse(readFileSync(path).toString());
}

export function writeJson(path: string, object: any) {
const contents = format(JSON.stringify(object, null, 2), {
export async function writeJson(path: string, object: any) {
const contents = await format(JSON.stringify(object, null, 2), {
parser: 'json',
});
return writeFileSync(path, contents);
Expand Down
3 changes: 1 addition & 2 deletions tools/workspace-plugin/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@
"files": ["./package.json", "./generators.json"],
"parser": "jsonc-eslint-parser",
"rules": {
"@nx/nx-plugin-checks": "error",
"@nx/dependency-checks": "error"
"@nx/nx-plugin-checks": "error"
}
}
]
Expand Down
2 changes: 1 addition & 1 deletion tools/workspace-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "0.0.1",
"dependencies": {
"tslib": "^2.3.0",
"@nx/devkit": "17.0.0",
"@nx/devkit": "17.0.2",
"xmldoc": "^1.1.2",
"node-fetch": "3.3.0"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
names,
} from '@nx/devkit';
import { XmlDocument } from 'xmldoc';
import fetch from 'node-fetch';
import { join } from 'path';

const KeyPropertyMap: Record<string, string> = {
Expand All @@ -29,12 +28,27 @@ type Translation = {
};

export default async function (tree: Tree) {
const { default: fetch } =
await dynamicImport<typeof import('node-fetch')>('node-fetch');
const enXml = await fetch(
`https://raw.githubusercontent.com/dotnet/templating/master/src/Microsoft.TemplateEngine.Cli/LocalizableStrings.resx`,
).then((x) => x.text());
`https://api.github.com/repos/dotnet/sdk/contents/src/Cli/Microsoft.TemplateEngine.Cli/LocalizableStrings.resx?ref=main`,
)
.then((x) => x.json())
.then((x: unknown) =>
typeof x === 'object' &&
x &&
'content' in x &&
typeof x.content === 'string'
? Buffer.from(x.content, 'base64').toString()
: null,
);

if (!enXml) {
throw new Error('Unable to fetch English translation file');
}

const translationDirectoryContents = (await fetch(
`https://api.github.com/repos/dotnet/templating/contents/src/Microsoft.TemplateEngine.Cli/xlf`,
`https://api.github.com/repos/dotnet/sdk/contents/src/Cli/Microsoft.TemplateEngine.Cli/xlf`,
).then((x) => x.json())) as { path: string; download_url: string }[];
const translations: { lang: string; pairs: Translation[] }[] = [
{
Expand Down Expand Up @@ -64,6 +78,7 @@ export default async function (tree: Tree) {

const languages: (ReturnType<typeof names> & { raw: string })[] = [];
for (const translation of translations) {
console.log('Updated language mappings for', translation.lang);
generateFiles(tree, join(__dirname, 'files'), outputDirectory, {
tmpl: '',
language: translation.lang,
Expand All @@ -72,7 +87,7 @@ export default async function (tree: Tree) {
});
languages.push({ ...names(translation.lang), raw: translation.lang });
}
generateFiles(tree, join(__dirname, 'index_tmpl_'), outputDirectory, {
generateFiles(tree, join(__dirname, 'index-template'), outputDirectory, {
tmpl: '',
languages,
});
Expand Down Expand Up @@ -111,3 +126,7 @@ function getTranslationsFromXlf(xml: XmlDocument): Translation[] {
}, [] as Translation[]) ?? []
);
}

function dynamicImport<T = unknown>(mod: string): Promise<T> {
return new Function('p0', 'return import(p0)')(mod);
}
Loading

0 comments on commit 7213b67

Please sign in to comment.