@twin.org/merge-locales 0.0.2-next.9 → 0.0.3-next.1

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/bin/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  // Copyright 2024 IOTA Stiftung.
3
3
  // SPDX-License-Identifier: Apache-2.0.
4
- import { CLI } from '../dist/esm/index.mjs';
4
+ import { CLI } from '../dist/es/index.js';
5
5
 
6
6
  const cli = new CLI();
7
7
  const result = await cli.run(process.argv);
package/dist/es/cli.js ADDED
@@ -0,0 +1,37 @@
1
+ // Copyright 2024 IOTA Stiftung.
2
+ // SPDX-License-Identifier: Apache-2.0.
3
+ import path from "node:path";
4
+ import { fileURLToPath } from "node:url";
5
+ import { CLIBase } from "@twin.org/cli-core";
6
+ import { buildCommandMergeLocales } from "./commands/mergeLocales.js";
7
+ /**
8
+ * The main entry point for the CLI.
9
+ */
10
+ export class CLI extends CLIBase {
11
+ /**
12
+ * Run the app.
13
+ * @param argv The process arguments.
14
+ * @param localesDirectory The directory for the locales, default to relative to the script.
15
+ * @param options Additional options.
16
+ * @param options.overrideOutputWidth Override the output width.
17
+ * @returns The exit code.
18
+ */
19
+ async run(argv, localesDirectory, options) {
20
+ return this.execute({
21
+ title: "TWIN Merge Locales",
22
+ appName: "merge-locales",
23
+ version: "0.0.3-next.1", // x-release-please-version
24
+ icon: "⚙️ ",
25
+ supportsEnvFiles: false,
26
+ overrideOutputWidth: options?.overrideOutputWidth
27
+ }, localesDirectory ?? path.join(path.dirname(fileURLToPath(import.meta.url)), "../locales"), argv);
28
+ }
29
+ /**
30
+ * Configure any options or actions at the root program level.
31
+ * @param program The root program command.
32
+ */
33
+ configureRoot(program) {
34
+ buildCommandMergeLocales(program);
35
+ }
36
+ }
37
+ //# sourceMappingURL=cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../../src/cli.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAE7C,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AAEtE;;GAEG;AACH,MAAM,OAAO,GAAI,SAAQ,OAAO;IAC/B;;;;;;;OAOG;IACI,KAAK,CAAC,GAAG,CACf,IAAc,EACd,gBAAyB,EACzB,OAA0C;QAE1C,OAAO,IAAI,CAAC,OAAO,CAClB;YACC,KAAK,EAAE,oBAAoB;YAC3B,OAAO,EAAE,eAAe;YACxB,OAAO,EAAE,cAAc,EAAE,2BAA2B;YACpD,IAAI,EAAE,KAAK;YACX,gBAAgB,EAAE,KAAK;YACvB,mBAAmB,EAAE,OAAO,EAAE,mBAAmB;SACjD,EACD,gBAAgB,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,YAAY,CAAC,EACzF,IAAI,CACJ,CAAC;IACH,CAAC;IAED;;;OAGG;IACO,aAAa,CAAC,OAAgB;QACvC,wBAAwB,CAAC,OAAO,CAAC,CAAC;IACnC,CAAC;CACD","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport { CLIBase } from \"@twin.org/cli-core\";\nimport type { Command } from \"commander\";\nimport { buildCommandMergeLocales } from \"./commands/mergeLocales.js\";\n\n/**\n * The main entry point for the CLI.\n */\nexport class CLI extends CLIBase {\n\t/**\n\t * Run the app.\n\t * @param argv The process arguments.\n\t * @param localesDirectory The directory for the locales, default to relative to the script.\n\t * @param options Additional options.\n\t * @param options.overrideOutputWidth Override the output width.\n\t * @returns The exit code.\n\t */\n\tpublic async run(\n\t\targv: string[],\n\t\tlocalesDirectory?: string,\n\t\toptions?: { overrideOutputWidth?: number }\n\t): Promise<number> {\n\t\treturn this.execute(\n\t\t\t{\n\t\t\t\ttitle: \"TWIN Merge Locales\",\n\t\t\t\tappName: \"merge-locales\",\n\t\t\t\tversion: \"0.0.3-next.1\", // x-release-please-version\n\t\t\t\ticon: \"⚙️ \",\n\t\t\t\tsupportsEnvFiles: false,\n\t\t\t\toverrideOutputWidth: options?.overrideOutputWidth\n\t\t\t},\n\t\t\tlocalesDirectory ?? path.join(path.dirname(fileURLToPath(import.meta.url)), \"../locales\"),\n\t\t\targv\n\t\t);\n\t}\n\n\t/**\n\t * Configure any options or actions at the root program level.\n\t * @param program The root program command.\n\t */\n\tprotected configureRoot(program: Command): void {\n\t\tbuildCommandMergeLocales(program);\n\t}\n}\n"]}
@@ -1,16 +1,14 @@
1
- import path from 'node:path';
2
- import { fileURLToPath } from 'node:url';
3
- import { CLIDisplay, CLIUtils, CLIBase } from '@twin.org/cli-core';
4
- import { rm, mkdir, writeFile } from 'node:fs/promises';
5
- import { I18n, Is, GeneralError, ObjectHelper } from '@twin.org/core';
6
-
7
1
  // Copyright 2024 IOTA Stiftung.
8
2
  // SPDX-License-Identifier: Apache-2.0.
3
+ import { mkdir, rm, writeFile } from "node:fs/promises";
4
+ import path from "node:path";
5
+ import { CLIDisplay, CLIUtils } from "@twin.org/cli-core";
6
+ import { GeneralError, I18n, Is, ObjectHelper } from "@twin.org/core";
9
7
  /**
10
8
  * Build the root command to be consumed by the CLI.
11
9
  * @param program The command to build on.
12
10
  */
13
- function buildCommandMergeLocales(program) {
11
+ export function buildCommandMergeLocales(program) {
14
12
  program
15
13
  .option(I18n.formatMessage("commands.merge-locales.options.config.param"), I18n.formatMessage("commands.merge-locales.options.config.description"))
16
14
  .action(async (opts) => {
@@ -22,7 +20,7 @@ function buildCommandMergeLocales(program) {
22
20
  * @param opts The options for the command.
23
21
  * @param opts.config The optional configuration file.
24
22
  */
25
- async function actionCommandMergeLocales(opts) {
23
+ export async function actionCommandMergeLocales(opts) {
26
24
  let config;
27
25
  if (Is.stringValue(opts.config)) {
28
26
  try {
@@ -49,7 +47,7 @@ async function actionCommandMergeLocales(opts) {
49
47
  * @param workingDirectory The folder the app was run from.
50
48
  * @param config The configuration for the app.
51
49
  */
52
- async function mergeLocales(workingDirectory, config) {
50
+ export async function mergeLocales(workingDirectory, config) {
53
51
  CLIDisplay.value(I18n.formatMessage("commands.merge-locales.labels.workingDirectory"), workingDirectory);
54
52
  const outputDirectory = path.resolve(config.outputDirectory ?? "./dist/locales");
55
53
  const locales = config.locales ?? [];
@@ -151,38 +149,4 @@ async function findDependencies(npmRoot, packageJsonPath, packageNames) {
151
149
  }
152
150
  return packageJson ?? {};
153
151
  }
154
-
155
- // Copyright 2024 IOTA Stiftung.
156
- // SPDX-License-Identifier: Apache-2.0.
157
- /**
158
- * The main entry point for the CLI.
159
- */
160
- class CLI extends CLIBase {
161
- /**
162
- * Run the app.
163
- * @param argv The process arguments.
164
- * @param localesDirectory The directory for the locales, default to relative to the script.
165
- * @param options Additional options.
166
- * @param options.overrideOutputWidth Override the output width.
167
- * @returns The exit code.
168
- */
169
- async run(argv, localesDirectory, options) {
170
- return this.execute({
171
- title: "TWIN Merge Locales",
172
- appName: "merge-locales",
173
- version: "0.0.2-next.9", // x-release-please-version
174
- icon: "⚙️ ",
175
- supportsEnvFiles: false,
176
- overrideOutputWidth: options?.overrideOutputWidth
177
- }, localesDirectory ?? path.join(path.dirname(fileURLToPath(import.meta.url)), "../locales"), argv);
178
- }
179
- /**
180
- * Configure any options or actions at the root program level.
181
- * @param program The root program command.
182
- */
183
- configureRoot(program) {
184
- buildCommandMergeLocales(program);
185
- }
186
- }
187
-
188
- export { CLI, actionCommandMergeLocales, buildCommandMergeLocales, mergeLocales };
152
+ //# sourceMappingURL=mergeLocales.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mergeLocales.js","sourceRoot":"","sources":["../../../src/commands/m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AAW,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,EAAE,cAAc,CAAC,CAAC;gBAC5D,MAAM,gBAAgB,CAAC,OAAO,EAAE,WAAW,EAAE,YAAY,CAAC,CAAC;YAC5D,CAAC;QACF,CAAC;IACF,CAAC;IAED,IAAI,EAAE,CAAC,WAAW,CAAC,WAAW,EAAE,gBAAgB,CAAC,EAAE,CAAC;QACnD,KAAK,MAAM,GAAG,IAAI,WAAW,CAAC,gBAAgB,EAAE,CAAC;YAChD,IAAI,GAAG,CAAC,UAAU,CAAC,WAAW,CAAC,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;gBAChE,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;gBACvB,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,EAAE,cAAc,CAAC,CAAC;gBAC5D,MAAM,gBAAgB,CAAC,OAAO,EAAE,WAAW,EAAE,YAAY,CAAC,CAAC;YAC5D,CAAC;QACF,CAAC;IACF,CAAC;IAED,OAAO,WAAW,IAAI,EAAE,CAAC;AAC1B,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { mkdir, rm, writeFile } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { CLIDisplay, CLIUtils } from \"@twin.org/cli-core\";\nimport {\n\tGeneralError,\n\tI18n,\n\tIs,\n\tObjectHelper,\n\ttype ILocale,\n\ttype ILocaleDictionary\n} from \"@twin.org/core\";\nimport type { Command } from \"commander\";\nimport type { IMergeLocalesConfig } from \"../models/IMergeLocalesConfig.js\";\nimport type { IPackageJson } from \"../models/IPackageJson.js\";\n\n/**\n * Build the root command to be consumed by the CLI.\n * @param program The command to build on.\n */\nexport function buildCommandMergeLocales(program: Command): void {\n\tprogram\n\t\t.option(\n\t\t\tI18n.formatMessage(\"commands.merge-locales.options.config.param\"),\n\t\t\tI18n.formatMessage(\"commands.merge-locales.options.config.description\")\n\t\t)\n\t\t.action(async opts => {\n\t\t\tawait actionCommandMergeLocales(opts);\n\t\t});\n}\n\n/**\n * Action the root command.\n * @param opts The options for the command.\n * @param opts.config The optional configuration file.\n */\nexport async function actionCommandMergeLocales(opts: { config?: string }): Promise<void> {\n\tlet config: IMergeLocalesConfig | undefined;\n\tif (Is.stringValue(opts.config)) {\n\t\ttry {\n\t\t\tconst configJson = path.resolve(opts.config);\n\t\t\tCLIDisplay.value(I18n.formatMessage(\"commands.merge-locales.labels.configJson\"), configJson);\n\t\t\tCLIDisplay.break();\n\n\t\t\tCLIDisplay.task(I18n.formatMessage(\"commands.merge-locales.progress.loadingConfigJson\"));\n\t\t\tCLIDisplay.break();\n\n\t\t\tconfig = await CLIUtils.readJsonFile<IMergeLocalesConfig>(configJson);\n\t\t\tCLIDisplay.break();\n\t\t} catch (err) {\n\t\t\tthrow new GeneralError(\"commands\", \"commands.merge-locales.configFailed\", undefined, err);\n\t\t}\n\n\t\tif (Is.empty(config)) {\n\t\t\tthrow new GeneralError(\"commands\", \"commands.merge-locales.configFailed\");\n\t\t}\n\t}\n\n\tawait mergeLocales(process.cwd(), config ?? {});\n\n\tCLIDisplay.done();\n}\n\n/**\n * Merge the locales.\n * @param workingDirectory The folder the app was run from.\n * @param config The configuration for the app.\n */\nexport async function mergeLocales(\n\tworkingDirectory: string,\n\tconfig: IMergeLocalesConfig\n): Promise<void> {\n\tCLIDisplay.value(\n\t\tI18n.formatMessage(\"commands.merge-locales.labels.workingDirectory\"),\n\t\tworkingDirectory\n\t);\n\n\tconst outputDirectory = path.resolve(config.outputDirectory ?? \"./dist/locales\");\n\tconst locales = config.locales ?? [];\n\tconst includePackages = config.includePackages ?? [];\n\tconst excludePackages = config.excludePackages ?? [];\n\n\tif (locales.length === 0) {\n\t\tlocales.push({ label: \"English\", code: \"en\" });\n\t}\n\tCLIDisplay.value(\n\t\tI18n.formatMessage(\"commands.merge-locales.labels.outputDirectory\"),\n\t\toutputDirectory\n\t);\n\n\tconst npmRoot = await CLIUtils.findNpmRoot(workingDirectory);\n\tCLIDisplay.value(I18n.formatMessage(\"commands.merge-locales.labels.npmRoot\"), npmRoot);\n\tCLIDisplay.break();\n\n\tCLIDisplay.task(\n\t\tI18n.formatMessage(\"commands.merge-locales.progress.creatingOutputDirectory\"),\n\t\toutputDirectory\n\t);\n\n\ttry {\n\t\tawait rm(outputDirectory, { recursive: true });\n\t} catch {}\n\tawait mkdir(outputDirectory, { recursive: true });\n\n\tlet packageNames: string[] = [];\n\n\tconst packageJson = await findDependencies(\n\t\tnpmRoot,\n\t\tpath.join(workingDirectory, \"package.json\"),\n\t\tpackageNames\n\t);\n\n\texcludePackages.push(\"@twin.org/merge-locales\");\n\texcludePackages.push(\"@twin.org/nameof\");\n\texcludePackages.push(\"@twin.org/nameof-transformer\");\n\n\tpackageNames = packageNames.filter(pkg => !excludePackages.includes(pkg));\n\tpackageNames.push(...includePackages);\n\n\tCLIDisplay.break();\n\tCLIDisplay.section(I18n.formatMessage(\"commands.merge-locales.labels.sourcePackages\"));\n\tfor (const packageName of packageNames) {\n\t\tCLIDisplay.value(\"\", packageName, 1);\n\t}\n\tCLIDisplay.break();\n\n\tconst localeDictionaries: { [locale: string]: ILocaleDictionary } = {};\n\n\tfor (const packageName of packageNames) {\n\t\tconst packageLocalDirectory = path.join(npmRoot, packageName, \"locales\");\n\t\tawait mergePackageLocales(packageLocalDirectory, packageName, locales, localeDictionaries);\n\t}\n\n\t// Merge the main package last so that it can override any other packages.\n\tif (Is.stringValue(packageJson.name)) {\n\t\tawait mergePackageLocales(\n\t\t\tpath.join(workingDirectory, \"locales\"),\n\t\t\tpackageJson.name,\n\t\t\tlocales,\n\t\t\tlocaleDictionaries\n\t\t);\n\t}\n\n\tCLIDisplay.break();\n\tCLIDisplay.task(I18n.formatMessage(\"commands.merge-locales.progress.writingMergedLocales\"));\n\n\tfor (const localeDictionary in localeDictionaries) {\n\t\tconst localeFile = path.join(outputDirectory, `${localeDictionary}.json`);\n\t\tCLIDisplay.value(\n\t\t\tI18n.formatMessage(\"commands.merge-locales.labels.writingLocale\"),\n\t\t\tlocaleFile,\n\t\t\t1\n\t\t);\n\t\tawait writeFile(\n\t\t\tlocaleFile,\n\t\t\t`${JSON.stringify(localeDictionaries[localeDictionary], undefined, \"\\t\")}\\n`,\n\t\t\t\"utf8\"\n\t\t);\n\t}\n\tCLIDisplay.break();\n}\n\n/**\n * Merge the locales for a package.\n * @param packageLocalDirectory The root of the NPM packages.\n * @param packageName The name of the package.\n * @param locales The locales to merge.\n * @internal\n */\nasync function mergePackageLocales(\n\tpackageLocalDirectory: string,\n\tpackageName: string,\n\tlocales: ILocale[],\n\tlocaleDictionaries: { [locale: string]: ILocaleDictionary }\n): Promise<void> {\n\tCLIDisplay.task(\n\t\tI18n.formatMessage(\"commands.merge-locales.progress.mergingLocalesForPackage\"),\n\t\tpackageName\n\t);\n\n\tif (await CLIUtils.dirExists(packageLocalDirectory)) {\n\t\tfor (const locale of locales) {\n\t\t\tconst localeFile = path.join(packageLocalDirectory, `${locale.code}.json`);\n\t\t\tif (await CLIUtils.dirExists(localeFile)) {\n\t\t\t\tCLIDisplay.value(\n\t\t\t\t\tI18n.formatMessage(\"commands.merge-locales.labels.mergingLocale\"),\n\t\t\t\t\tlocale.code,\n\t\t\t\t\t1\n\t\t\t\t);\n\n\t\t\t\tconst localeDictionary = await CLIUtils.readJsonFile<ILocaleDictionary>(localeFile);\n\t\t\t\tlocaleDictionaries[locale.code] ??= {};\n\t\t\t\tlocaleDictionaries[locale.code] = ObjectHelper.merge(\n\t\t\t\t\tlocaleDictionaries[locale.code],\n\t\t\t\t\tlocaleDictionary\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\tCLIDisplay.break();\n}\n\n/**\n * Find dependencies for the package.\n * @param npmRoot The root of the NPM packages.\n * @param packageJsonPath The path to the package.json.\n * @param packageNames The package names to add to.\n * @returns The package details.\n * @internal\n */\nasync function findDependencies(\n\tnpmRoot: string,\n\tpackageJsonPath: string,\n\tpackageNames: string[]\n): Promise<IPackageJson> {\n\tconst packageJson = await CLIUtils.readJsonFile<IPackageJson>(packageJsonPath);\n\n\tif (Is.objectValue(packageJson?.dependencies)) {\n\t\tfor (const pkg in packageJson.dependencies) {\n\t\t\tif (pkg.startsWith(\"@twin.org\") && !packageNames.includes(pkg)) {\n\t\t\t\tpackageNames.push(pkg);\n\t\t\t\tconst packagePath = path.join(npmRoot, pkg, \"package.json\");\n\t\t\t\tawait findDependencies(npmRoot, packagePath, packageNames);\n\t\t\t}\n\t\t}\n\t}\n\n\tif (Is.objectValue(packageJson?.peerDependencies)) {\n\t\tfor (const pkg in packageJson.peerDependencies) {\n\t\t\tif (pkg.startsWith(\"@twin.org\") && !packageNames.includes(pkg)) {\n\t\t\t\tpackageNames.push(pkg);\n\t\t\t\tconst packagePath = path.join(npmRoot, pkg, \"package.json\");\n\t\t\t\tawait findDependencies(npmRoot, packagePath, packageNames);\n\t\t\t}\n\t\t}\n\t}\n\n\treturn packageJson ?? {};\n}\n"]}
@@ -0,0 +1,6 @@
1
+ // Copyright 2024 IOTA Stiftung.
2
+ // SPDX-License-Identifier: Apache-2.0.
3
+ export * from "./cli.js";
4
+ export * from "./commands/mergeLocales.js";
5
+ export * from "./models/IMergeLocalesConfig.js";
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,cAAc,UAAU,CAAC;AACzB,cAAc,4BAA4B,CAAC;AAC3C,cAAc,iCAAiC,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nexport * from \"./cli.js\";\nexport * from \"./commands/mergeLocales.js\";\nexport * from \"./models/IMergeLocalesConfig.js\";\n"]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=IMergeLocalesConfig.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IMergeLocalesConfig.js","sourceRoot":"","sources":["../../../src/models/IMergeLocalesConfig.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { ILocale } from \"@twin.org/core\";\n\n/**\n * Configuration for the CLI.\n */\nexport interface IMergeLocalesConfig {\n\t/**\n\t * The languages to include while merging, if none are supplied only English will be included.\n\t */\n\tlocales?: ILocale[];\n\n\t/**\n\t * Additional packages to add locales for, which are not part of the dependencies.\n\t */\n\tincludePackages?: string[];\n\n\t/**\n\t * Packages to exclude from the locales.\n\t */\n\texcludePackages?: string[];\n\n\t/**\n\t * Output directory for the merged locales.\n\t */\n\toutputDirectory?: string;\n}\n"]}
@@ -0,0 +1,4 @@
1
+ // Copyright 2024 IOTA Stiftung.
2
+ // SPDX-License-Identifier: Apache-2.0.
3
+ export {};
4
+ //# sourceMappingURL=IPackageJson.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IPackageJson.js","sourceRoot":"","sources":["../../../src/models/IPackageJson.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\n\n/**\n * Configuration for each individual package.\n */\nexport interface IPackageJson {\n\t/**\n\t * The name of the package.\n\t */\n\tname?: string;\n\n\t/**\n\t * The dependencies for the package.\n\t */\n\tdependencies?: { [id: string]: string };\n\n\t/**\n\t * The peer dependencies for the package.\n\t */\n\tpeerDependencies?: { [id: string]: string };\n}\n"]}
@@ -6,7 +6,6 @@
6
6
  "optionInvalidHex": "The \"{option}\" does not appear to be hex. \"{value}\"",
7
7
  "optionInvalidBase64": "The \"{option}\" does not appear to be base64. \"{value}\"",
8
8
  "optionInvalidHexBase64": "The \"{option}\" does not appear to be hex or base64. \"{value}\"",
9
- "optionInvalidBech32": "The \"{option}\" does not appear to be bech32. \"{value}\"",
10
9
  "optionMinValue": "The \"{option}\" option must be greater than or equal to {minValue}, it is {value}.",
11
10
  "optionMaxValue": "The \"{option}\" option must be less than or equal to {maxValue}, it is {value}."
12
11
  },
@@ -52,9 +51,7 @@
52
51
  "beUrn": "{fieldName} must be a correctly formatted urn",
53
52
  "beUrl": "{fieldName} must be a correctly formatted url",
54
53
  "beJSON": "{fieldName} must be correctly formatted JSON",
55
- "beEmail": "{fieldName} must be a correctly formatted e-mail address",
56
- "failed": "Validation failed",
57
- "failedObject": "Validation of \"{objectName}\" failed"
54
+ "beEmail": "{fieldName} must be a correctly formatted e-mail address"
58
55
  },
59
56
  "guard": {
60
57
  "undefined": "Property \"{property}\" must be defined, it is \"{value}\"",
@@ -85,11 +82,7 @@
85
82
  "function": "Property \"{property}\" must be a function, it is \"{value}\"",
86
83
  "urn": "Property \"{property}\" must be a Urn formatted string, it is \"{value}\"",
87
84
  "url": "Property \"{property}\" must be a Url formatted string, it is \"{value}\"",
88
- "email": "Property \"{property}\" must be string in e-mail format, it is \"{value}\"",
89
- "length32Multiple": "Property \"{property}\" should be a multiple of 32, it is {value}",
90
- "lengthEntropy": "Property \"{property}\" should be a multiple of 4, >=16 and <= 32, it is {value}",
91
- "length3Multiple": "Property \"{property}\" should be a multiple of 3, it is {value}",
92
- "greaterThan0": "Property \"{property}\" must be greater than zero, it is {value}"
85
+ "email": "Property \"{property}\" must be string in e-mail format, it is \"{value}\""
93
86
  },
94
87
  "objectHelper": {
95
88
  "failedBytesToJSON": "Failed converting bytes to JSON",
@@ -105,7 +98,7 @@
105
98
  "noGet": "The requested {typeName} \"{name}\" does not exist in the factory"
106
99
  },
107
100
  "bitString": {
108
- "outOfRange": "The index should be >= 0 and less than the length of the bit string"
101
+ "outOfRange": "The index should be >= 0 and less than the length of the bit string, the index is \"{index}\" and the number of bit is \"{numberBits}\""
109
102
  },
110
103
  "base32": {
111
104
  "invalidCharacter": "Data contains a character \"{invalidCharacter}\" which is not in the charset"
@@ -118,68 +111,6 @@
118
111
  },
119
112
  "jsonHelper": {
120
113
  "failedPatch": "Failed to patch the JSON object, patch index \"{index}\" failed"
121
- },
122
- "bip39": {
123
- "missingMnemonicWord": "The mnemonic contains a word not in the wordlist, \"{value}\"",
124
- "checksumMismatch": "The checksum does not match \"{newChecksum}\" != \"{checksumBits}\""
125
- },
126
- "ed25519": {
127
- "privateKeyLength": "The private key length is incorrect, it should be \"{requiredSize}\" but is \"{actualSize}\"",
128
- "publicKeyLength": "The public key length is incorrect, it should be \"{requiredSize}\" but is \"{actualSize}\""
129
- },
130
- "secp256k1": {
131
- "privateKeyLength": "The private key length is incorrect, it should be \"{requiredSize}\" but is \"{actualSize}\"",
132
- "publicKeyLength": "The public key length is incorrect, it should be \"{requiredSize}\" but is \"{actualSize}\""
133
- },
134
- "x25519": {
135
- "invalidPublicKey": "Invalid Ed25519 Public Key"
136
- },
137
- "blake2b": {
138
- "outputLength64": "The output length should be between 1 and 64, it is \"{outputLength}\"",
139
- "keyLength64": "The key length should be between 1 and 64, it is \"{keyLength}\""
140
- },
141
- "sha512": {
142
- "bitSize": "Only 224, 256, 384 or 512 bits are supported, it is \"{bitSize}\""
143
- },
144
- "sha256": {
145
- "bitSize": "Only 224 or 256 bits are supported, it is \"{bitSize}\""
146
- },
147
- "sha3": {
148
- "bitSize": "Only 224, 256, 384 or 512 bits are supported, it is \"{bitSize}\""
149
- },
150
- "hmacSha256": {
151
- "bitSize": "Only 224 or 256 bits are supported, it is \"{bitSize}\""
152
- },
153
- "hmacSha512": {
154
- "bitSize": "Only 224, 256, 384 or 512 bits are supported, it is \"{bitSize}\""
155
- },
156
- "bech32": {
157
- "decodeFailed": "The address contains decoding failed for address \"{bech32}\"",
158
- "invalidChecksum": "The address contains an invalid checksum in address, \"{bech32}\"",
159
- "separatorMisused": "The separator character '1' should only be used between hrp and data, \"{bech32}\"",
160
- "lowerUpper": "The address my use either lowercase or uppercase, \"{bech32}\"",
161
- "dataTooShort": "The address does not contain enough data to decode, \"{bech32}\""
162
- },
163
- "pbkdf2": {
164
- "keyTooLong": "The requested key length \"{keyLength}\" is too long, based on the \"{macLength}\""
165
- },
166
- "chaCha20Poly1305": {
167
- "noAadWithData": "You can not set the aad when there is already data",
168
- "noAuthTag": "Can not finalise when the auth tag is not set",
169
- "authenticationFailed": "The data could not be authenticated",
170
- "authTagDecrypting": "Can not get the auth tag when decrypting",
171
- "authTagEncrypting": "Can not set the auth tag when encrypting",
172
- "noAuthTagSet": "The auth tag has not been set"
173
- },
174
- "bip44": {
175
- "unsupportedKeyType": "The key type \"{keyType}\" is not supported"
176
- },
177
- "slip0010": {
178
- "invalidSeed": "The seed is invalid \"{seed}\""
179
- },
180
- "rsa": {
181
- "noPrivateKey": "Private key is required for this operation",
182
- "invalidKeySize": "Invalid RSA key size"
183
114
  }
184
115
  },
185
116
  "warn": {
@@ -239,7 +170,8 @@
239
170
  "alreadyExistsError": "Already Exists",
240
171
  "notImplementedError": "Not Implemented",
241
172
  "validationError": "Validation",
242
- "unprocessableError": "Unprocessable"
173
+ "unprocessableError": "Unprocessable",
174
+ "unauthorizedError": "Unauthorized"
243
175
  },
244
176
  "validation": {
245
177
  "defaultFieldName": "The field"
@@ -1,5 +1,5 @@
1
1
  import type { Command } from "commander";
2
- import type { IMergeLocalesConfig } from "../models/IMergeLocalesConfig";
2
+ import type { IMergeLocalesConfig } from "../models/IMergeLocalesConfig.js";
3
3
  /**
4
4
  * Build the root command to be consumed by the CLI.
5
5
  * @param program The command to build on.
@@ -1,3 +1,3 @@
1
- export * from "./cli";
2
- export * from "./commands/mergeLocales";
3
- export * from "./models/IMergeLocalesConfig";
1
+ export * from "./cli.js";
2
+ export * from "./commands/mergeLocales.js";
3
+ export * from "./models/IMergeLocalesConfig.js";
package/docs/changelog.md CHANGED
@@ -1,4 +1,280 @@
1
- # @twin.org/ts-to-openapi - Changelog
1
+ # @twin.org/merge-locales - Changelog
2
+
3
+ ## [0.0.3-next.1](https://github.com/twinfoundation/framework/compare/merge-locales-v0.0.3-next.0...merge-locales-v0.0.3-next.1) (2025-11-10)
4
+
5
+
6
+ ### Features
7
+
8
+ * add context id features ([#206](https://github.com/twinfoundation/framework/issues/206)) ([ef0d4ee](https://github.com/twinfoundation/framework/commit/ef0d4ee11a4f5fc6cc6f52a4958ce905c04ee13b))
9
+ * eslint migration to flat config ([74427d7](https://github.com/twinfoundation/framework/commit/74427d78d342167f7850e49ab87269326355befe))
10
+ * locales validation ([#197](https://github.com/twinfoundation/framework/issues/197)) ([55fdadb](https://github.com/twinfoundation/framework/commit/55fdadb13595ce0047f787bd1d4135d429a99f12))
11
+ * relocate core packages from tools ([bcab8f3](https://github.com/twinfoundation/framework/commit/bcab8f3160442ea4fcaf442947462504f3d6a17d))
12
+ * update dependencies ([f3bd015](https://github.com/twinfoundation/framework/commit/f3bd015efd169196b7e0335f5cab876ba6ca1d75))
13
+ * use cause instead of inner for errors ([1f4acc4](https://github.com/twinfoundation/framework/commit/1f4acc4d7a6b71a134d9547da9bf40de1e1e49da))
14
+
15
+
16
+ ### Bug Fixes
17
+
18
+ * repo urls in package.json for moved packages ([31ae463](https://github.com/twinfoundation/framework/commit/31ae463095dfa8c0e48bb5bb12316f1e8abb9a4c))
19
+
20
+
21
+ ### Dependencies
22
+
23
+ * The following workspace dependencies were updated
24
+ * dependencies
25
+ * @twin.org/cli-core bumped from 0.0.3-next.0 to 0.0.3-next.1
26
+ * @twin.org/core bumped from 0.0.3-next.0 to 0.0.3-next.1
27
+ * @twin.org/nameof bumped from 0.0.3-next.0 to 0.0.3-next.1
28
+ * devDependencies
29
+ * @twin.org/nameof-transformer bumped from 0.0.3-next.0 to 0.0.3-next.1
30
+ * @twin.org/nameof-vitest-plugin bumped from 0.0.3-next.0 to 0.0.3-next.1
31
+
32
+ ## [0.0.2-next.22](https://github.com/twinfoundation/framework/compare/merge-locales-v0.0.2-next.21...merge-locales-v0.0.2-next.22) (2025-10-10)
33
+
34
+
35
+ ### Miscellaneous Chores
36
+
37
+ * **merge-locales:** Synchronize repo versions
38
+
39
+
40
+ ### Dependencies
41
+
42
+ * The following workspace dependencies were updated
43
+ * dependencies
44
+ * @twin.org/cli-core bumped from 0.0.2-next.21 to 0.0.2-next.22
45
+ * @twin.org/core bumped from 0.0.2-next.21 to 0.0.2-next.22
46
+ * @twin.org/nameof bumped from 0.0.2-next.21 to 0.0.2-next.22
47
+ * devDependencies
48
+ * @twin.org/nameof-transformer bumped from 0.0.2-next.21 to 0.0.2-next.22
49
+ * @twin.org/nameof-vitest-plugin bumped from 0.0.2-next.21 to 0.0.2-next.22
50
+
51
+ ## [0.0.2-next.21](https://github.com/twinfoundation/framework/compare/merge-locales-v0.0.2-next.20...merge-locales-v0.0.2-next.21) (2025-10-09)
52
+
53
+
54
+ ### Features
55
+
56
+ * locales validation ([#197](https://github.com/twinfoundation/framework/issues/197)) ([55fdadb](https://github.com/twinfoundation/framework/commit/55fdadb13595ce0047f787bd1d4135d429a99f12))
57
+
58
+
59
+ ### Dependencies
60
+
61
+ * The following workspace dependencies were updated
62
+ * dependencies
63
+ * @twin.org/cli-core bumped from 0.0.2-next.20 to 0.0.2-next.21
64
+ * @twin.org/core bumped from 0.0.2-next.20 to 0.0.2-next.21
65
+ * @twin.org/nameof bumped from 0.0.2-next.20 to 0.0.2-next.21
66
+ * devDependencies
67
+ * @twin.org/nameof-transformer bumped from 0.0.2-next.20 to 0.0.2-next.21
68
+ * @twin.org/nameof-vitest-plugin bumped from 0.0.2-next.20 to 0.0.2-next.21
69
+
70
+ ## [0.0.2-next.20](https://github.com/twinfoundation/framework/compare/merge-locales-v0.0.2-next.19...merge-locales-v0.0.2-next.20) (2025-10-02)
71
+
72
+
73
+ ### Miscellaneous Chores
74
+
75
+ * **merge-locales:** Synchronize repo versions
76
+
77
+
78
+ ### Dependencies
79
+
80
+ * The following workspace dependencies were updated
81
+ * dependencies
82
+ * @twin.org/cli-core bumped from 0.0.2-next.19 to 0.0.2-next.20
83
+ * @twin.org/core bumped from 0.0.2-next.19 to 0.0.2-next.20
84
+ * @twin.org/nameof bumped from 0.0.2-next.19 to 0.0.2-next.20
85
+ * devDependencies
86
+ * @twin.org/nameof-transformer bumped from 0.0.2-next.19 to 0.0.2-next.20
87
+ * @twin.org/nameof-vitest-plugin bumped from 0.0.2-next.19 to 0.0.2-next.20
88
+
89
+ ## [0.0.2-next.19](https://github.com/twinfoundation/framework/compare/merge-locales-v0.0.2-next.18...merge-locales-v0.0.2-next.19) (2025-09-30)
90
+
91
+
92
+ ### Miscellaneous Chores
93
+
94
+ * **merge-locales:** Synchronize repo versions
95
+
96
+
97
+ ### Dependencies
98
+
99
+ * The following workspace dependencies were updated
100
+ * dependencies
101
+ * @twin.org/cli-core bumped from 0.0.2-next.18 to 0.0.2-next.19
102
+ * @twin.org/core bumped from 0.0.2-next.18 to 0.0.2-next.19
103
+ * @twin.org/nameof bumped from 0.0.2-next.18 to 0.0.2-next.19
104
+ * devDependencies
105
+ * @twin.org/nameof-transformer bumped from 0.0.2-next.18 to 0.0.2-next.19
106
+ * @twin.org/nameof-vitest-plugin bumped from 0.0.2-next.18 to 0.0.2-next.19
107
+
108
+ ## [0.0.2-next.18](https://github.com/twinfoundation/framework/compare/merge-locales-v0.0.2-next.17...merge-locales-v0.0.2-next.18) (2025-09-29)
109
+
110
+
111
+ ### Miscellaneous Chores
112
+
113
+ * **merge-locales:** Synchronize repo versions
114
+
115
+
116
+ ### Dependencies
117
+
118
+ * The following workspace dependencies were updated
119
+ * dependencies
120
+ * @twin.org/cli-core bumped from 0.0.2-next.17 to 0.0.2-next.18
121
+ * @twin.org/core bumped from 0.0.2-next.17 to 0.0.2-next.18
122
+ * @twin.org/nameof bumped from 0.0.2-next.17 to 0.0.2-next.18
123
+ * devDependencies
124
+ * @twin.org/nameof-transformer bumped from 0.0.2-next.17 to 0.0.2-next.18
125
+ * @twin.org/nameof-vitest-plugin bumped from 0.0.2-next.17 to 0.0.2-next.18
126
+
127
+ ## [0.0.2-next.17](https://github.com/twinfoundation/framework/compare/merge-locales-v0.0.2-next.16...merge-locales-v0.0.2-next.17) (2025-09-29)
128
+
129
+
130
+ ### Miscellaneous Chores
131
+
132
+ * **merge-locales:** Synchronize repo versions
133
+
134
+
135
+ ### Dependencies
136
+
137
+ * The following workspace dependencies were updated
138
+ * dependencies
139
+ * @twin.org/cli-core bumped from 0.0.2-next.16 to 0.0.2-next.17
140
+ * @twin.org/core bumped from 0.0.2-next.16 to 0.0.2-next.17
141
+ * @twin.org/nameof bumped from 0.0.2-next.16 to 0.0.2-next.17
142
+ * devDependencies
143
+ * @twin.org/nameof-transformer bumped from 0.0.2-next.16 to 0.0.2-next.17
144
+ * @twin.org/nameof-vitest-plugin bumped from 0.0.2-next.16 to 0.0.2-next.17
145
+
146
+ ## [0.0.2-next.16](https://github.com/twinfoundation/framework/compare/merge-locales-v0.0.2-next.15...merge-locales-v0.0.2-next.16) (2025-09-28)
147
+
148
+
149
+ ### Miscellaneous Chores
150
+
151
+ * **merge-locales:** Synchronize repo versions
152
+
153
+
154
+ ### Dependencies
155
+
156
+ * The following workspace dependencies were updated
157
+ * dependencies
158
+ * @twin.org/cli-core bumped from 0.0.2-next.15 to 0.0.2-next.16
159
+ * @twin.org/core bumped from 0.0.2-next.15 to 0.0.2-next.16
160
+ * @twin.org/nameof bumped from 0.0.2-next.15 to 0.0.2-next.16
161
+ * devDependencies
162
+ * @twin.org/nameof-transformer bumped from 0.0.2-next.15 to 0.0.2-next.16
163
+ * @twin.org/nameof-vitest-plugin bumped from 0.0.2-next.15 to 0.0.2-next.16
164
+
165
+ ## [0.0.2-next.15](https://github.com/twinfoundation/framework/compare/merge-locales-v0.0.2-next.14...merge-locales-v0.0.2-next.15) (2025-09-22)
166
+
167
+
168
+ ### Miscellaneous Chores
169
+
170
+ * **merge-locales:** Synchronize repo versions
171
+
172
+
173
+ ### Dependencies
174
+
175
+ * The following workspace dependencies were updated
176
+ * dependencies
177
+ * @twin.org/cli-core bumped from 0.0.2-next.14 to 0.0.2-next.15
178
+ * @twin.org/core bumped from 0.0.2-next.14 to 0.0.2-next.15
179
+ * @twin.org/nameof bumped from 0.0.2-next.14 to 0.0.2-next.15
180
+ * devDependencies
181
+ * @twin.org/nameof-transformer bumped from 0.0.2-next.14 to 0.0.2-next.15
182
+ * @twin.org/nameof-vitest-plugin bumped from 0.0.2-next.14 to 0.0.2-next.15
183
+
184
+ ## [0.0.2-next.14](https://github.com/twinfoundation/framework/compare/merge-locales-v0.0.2-next.13...merge-locales-v0.0.2-next.14) (2025-09-22)
185
+
186
+
187
+ ### Miscellaneous Chores
188
+
189
+ * **merge-locales:** Synchronize repo versions
190
+
191
+
192
+ ### Dependencies
193
+
194
+ * The following workspace dependencies were updated
195
+ * dependencies
196
+ * @twin.org/cli-core bumped from 0.0.2-next.13 to 0.0.2-next.14
197
+ * @twin.org/core bumped from 0.0.2-next.13 to 0.0.2-next.14
198
+ * @twin.org/nameof bumped from 0.0.2-next.13 to 0.0.2-next.14
199
+ * devDependencies
200
+ * @twin.org/nameof-transformer bumped from 0.0.2-next.13 to 0.0.2-next.14
201
+ * @twin.org/nameof-vitest-plugin bumped from 0.0.2-next.13 to 0.0.2-next.14
202
+
203
+ ## [0.0.2-next.13](https://github.com/twinfoundation/framework/compare/merge-locales-v0.0.2-next.12...merge-locales-v0.0.2-next.13) (2025-09-22)
204
+
205
+
206
+ ### Miscellaneous Chores
207
+
208
+ * **merge-locales:** Synchronize repo versions
209
+
210
+
211
+ ### Dependencies
212
+
213
+ * The following workspace dependencies were updated
214
+ * dependencies
215
+ * @twin.org/cli-core bumped from 0.0.2-next.12 to 0.0.2-next.13
216
+ * @twin.org/core bumped from 0.0.2-next.12 to 0.0.2-next.13
217
+ * @twin.org/nameof bumped from 0.0.2-next.12 to 0.0.2-next.13
218
+ * devDependencies
219
+ * @twin.org/nameof-transformer bumped from 0.0.2-next.12 to 0.0.2-next.13
220
+ * @twin.org/nameof-vitest-plugin bumped from 0.0.2-next.12 to 0.0.2-next.13
221
+
222
+ ## [0.0.2-next.12](https://github.com/twinfoundation/framework/compare/merge-locales-v0.0.2-next.11...merge-locales-v0.0.2-next.12) (2025-09-15)
223
+
224
+
225
+ ### Miscellaneous Chores
226
+
227
+ * **merge-locales:** Synchronize repo versions
228
+
229
+
230
+ ### Dependencies
231
+
232
+ * The following workspace dependencies were updated
233
+ * dependencies
234
+ * @twin.org/cli-core bumped from 0.0.2-next.11 to 0.0.2-next.12
235
+ * @twin.org/core bumped from 0.0.2-next.11 to 0.0.2-next.12
236
+ * @twin.org/nameof bumped from 0.0.2-next.11 to 0.0.2-next.12
237
+ * devDependencies
238
+ * @twin.org/nameof-transformer bumped from 0.0.2-next.11 to 0.0.2-next.12
239
+ * @twin.org/nameof-vitest-plugin bumped from 0.0.2-next.11 to 0.0.2-next.12
240
+
241
+ ## [0.0.2-next.11](https://github.com/twinfoundation/framework/compare/merge-locales-v0.0.2-next.10...merge-locales-v0.0.2-next.11) (2025-09-15)
242
+
243
+
244
+ ### Miscellaneous Chores
245
+
246
+ * **merge-locales:** Synchronize repo versions
247
+
248
+
249
+ ### Dependencies
250
+
251
+ * The following workspace dependencies were updated
252
+ * dependencies
253
+ * @twin.org/cli-core bumped from 0.0.2-next.10 to 0.0.2-next.11
254
+ * @twin.org/core bumped from 0.0.2-next.10 to 0.0.2-next.11
255
+ * @twin.org/nameof bumped from 0.0.2-next.10 to 0.0.2-next.11
256
+ * devDependencies
257
+ * @twin.org/nameof-transformer bumped from 0.0.2-next.10 to 0.0.2-next.11
258
+ * @twin.org/nameof-vitest-plugin bumped from 0.0.2-next.10 to 0.0.2-next.11
259
+
260
+ ## [0.0.2-next.10](https://github.com/twinfoundation/framework/compare/merge-locales-v0.0.2-next.9...merge-locales-v0.0.2-next.10) (2025-09-11)
261
+
262
+
263
+ ### Miscellaneous Chores
264
+
265
+ * **merge-locales:** Synchronize repo versions
266
+
267
+
268
+ ### Dependencies
269
+
270
+ * The following workspace dependencies were updated
271
+ * dependencies
272
+ * @twin.org/cli-core bumped from 0.0.2-next.9 to 0.0.2-next.10
273
+ * @twin.org/core bumped from 0.0.2-next.9 to 0.0.2-next.10
274
+ * @twin.org/nameof bumped from 0.0.2-next.9 to 0.0.2-next.10
275
+ * devDependencies
276
+ * @twin.org/nameof-transformer bumped from 0.0.2-next.9 to 0.0.2-next.10
277
+ * @twin.org/nameof-vitest-plugin bumped from 0.0.2-next.9 to 0.0.2-next.10
2
278
 
3
279
  ## [0.0.2-next.9](https://github.com/twinfoundation/framework/compare/merge-locales-v0.0.2-next.8...merge-locales-v0.0.2-next.9) (2025-09-08)
4
280
 
@@ -0,0 +1,5 @@
1
+ # These are included as they are normally merged from other locales, but in the case of the merge-locales tool this is not possible
2
+ ^cli.progress.done$
3
+ ^cli.progress.error$
4
+ ^cli.options.lang.param$
5
+ ^cli.options.lang.description$
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twin.org/merge-locales",
3
- "version": "0.0.2-next.9",
3
+ "version": "0.0.3-next.1",
4
4
  "description": "Tool to merge locale files from all dependencies",
5
5
  "repository": {
6
6
  "type": "git",
@@ -14,26 +14,24 @@
14
14
  "node": ">=20.0.0"
15
15
  },
16
16
  "dependencies": {
17
- "@twin.org/cli-core": "0.0.2-next.9",
18
- "@twin.org/core": "0.0.2-next.9",
19
- "@twin.org/nameof": "0.0.2-next.9",
20
- "commander": "14.0.0",
17
+ "@twin.org/cli-core": "0.0.3-next.1",
18
+ "@twin.org/core": "0.0.3-next.1",
19
+ "@twin.org/nameof": "0.0.3-next.1",
20
+ "commander": "14.0.2",
21
21
  "glob": "11.0.3"
22
22
  },
23
- "main": "./dist/cjs/index.cjs",
24
- "module": "./dist/esm/index.mjs",
23
+ "main": "./dist/es/index.js",
25
24
  "types": "./dist/types/index.d.ts",
26
25
  "exports": {
27
26
  ".": {
28
27
  "types": "./dist/types/index.d.ts",
29
- "require": "./dist/cjs/index.cjs",
30
- "import": "./dist/esm/index.mjs"
28
+ "import": "./dist/es/index.js",
29
+ "default": "./dist/es/index.js"
31
30
  }
32
31
  },
33
32
  "files": [
34
33
  "bin",
35
- "dist/cjs",
36
- "dist/esm",
34
+ "dist/es",
37
35
  "dist/locales",
38
36
  "dist/types",
39
37
  "locales",
@@ -47,7 +45,14 @@
47
45
  "test": "tests"
48
46
  },
49
47
  "bugs": {
50
- "url": "git+https://github.com/twinfoundation/tools/issues"
48
+ "url": "git+https://github.com/twinfoundation/framework/issues"
51
49
  },
52
- "homepage": "https://github.com/twinfoundation/tools#readme"
50
+ "homepage": "https://twindev.org",
51
+ "keywords": [
52
+ "twin",
53
+ "trade",
54
+ "iota",
55
+ "framework",
56
+ "blockchain"
57
+ ]
53
58
  }
@@ -1,194 +0,0 @@
1
- 'use strict';
2
-
3
- var path = require('node:path');
4
- var node_url = require('node:url');
5
- var cliCore = require('@twin.org/cli-core');
6
- var promises = require('node:fs/promises');
7
- var core = require('@twin.org/core');
8
-
9
- var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
10
- // Copyright 2024 IOTA Stiftung.
11
- // SPDX-License-Identifier: Apache-2.0.
12
- /**
13
- * Build the root command to be consumed by the CLI.
14
- * @param program The command to build on.
15
- */
16
- function buildCommandMergeLocales(program) {
17
- program
18
- .option(core.I18n.formatMessage("commands.merge-locales.options.config.param"), core.I18n.formatMessage("commands.merge-locales.options.config.description"))
19
- .action(async (opts) => {
20
- await actionCommandMergeLocales(opts);
21
- });
22
- }
23
- /**
24
- * Action the root command.
25
- * @param opts The options for the command.
26
- * @param opts.config The optional configuration file.
27
- */
28
- async function actionCommandMergeLocales(opts) {
29
- let config;
30
- if (core.Is.stringValue(opts.config)) {
31
- try {
32
- const configJson = path.resolve(opts.config);
33
- cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.merge-locales.labels.configJson"), configJson);
34
- cliCore.CLIDisplay.break();
35
- cliCore.CLIDisplay.task(core.I18n.formatMessage("commands.merge-locales.progress.loadingConfigJson"));
36
- cliCore.CLIDisplay.break();
37
- config = await cliCore.CLIUtils.readJsonFile(configJson);
38
- cliCore.CLIDisplay.break();
39
- }
40
- catch (err) {
41
- throw new core.GeneralError("commands", "commands.merge-locales.configFailed", undefined, err);
42
- }
43
- if (core.Is.empty(config)) {
44
- throw new core.GeneralError("commands", "commands.merge-locales.configFailed");
45
- }
46
- }
47
- await mergeLocales(process.cwd(), config ?? {});
48
- cliCore.CLIDisplay.done();
49
- }
50
- /**
51
- * Merge the locales.
52
- * @param workingDirectory The folder the app was run from.
53
- * @param config The configuration for the app.
54
- */
55
- async function mergeLocales(workingDirectory, config) {
56
- cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.merge-locales.labels.workingDirectory"), workingDirectory);
57
- const outputDirectory = path.resolve(config.outputDirectory ?? "./dist/locales");
58
- const locales = config.locales ?? [];
59
- const includePackages = config.includePackages ?? [];
60
- const excludePackages = config.excludePackages ?? [];
61
- if (locales.length === 0) {
62
- locales.push({ label: "English", code: "en" });
63
- }
64
- cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.merge-locales.labels.outputDirectory"), outputDirectory);
65
- const npmRoot = await cliCore.CLIUtils.findNpmRoot(workingDirectory);
66
- cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.merge-locales.labels.npmRoot"), npmRoot);
67
- cliCore.CLIDisplay.break();
68
- cliCore.CLIDisplay.task(core.I18n.formatMessage("commands.merge-locales.progress.creatingOutputDirectory"), outputDirectory);
69
- try {
70
- await promises.rm(outputDirectory, { recursive: true });
71
- }
72
- catch { }
73
- await promises.mkdir(outputDirectory, { recursive: true });
74
- let packageNames = [];
75
- const packageJson = await findDependencies(npmRoot, path.join(workingDirectory, "package.json"), packageNames);
76
- excludePackages.push("@twin.org/merge-locales");
77
- excludePackages.push("@twin.org/nameof");
78
- excludePackages.push("@twin.org/nameof-transformer");
79
- packageNames = packageNames.filter(pkg => !excludePackages.includes(pkg));
80
- packageNames.push(...includePackages);
81
- cliCore.CLIDisplay.break();
82
- cliCore.CLIDisplay.section(core.I18n.formatMessage("commands.merge-locales.labels.sourcePackages"));
83
- for (const packageName of packageNames) {
84
- cliCore.CLIDisplay.value("", packageName, 1);
85
- }
86
- cliCore.CLIDisplay.break();
87
- const localeDictionaries = {};
88
- for (const packageName of packageNames) {
89
- const packageLocalDirectory = path.join(npmRoot, packageName, "locales");
90
- await mergePackageLocales(packageLocalDirectory, packageName, locales, localeDictionaries);
91
- }
92
- // Merge the main package last so that it can override any other packages.
93
- if (core.Is.stringValue(packageJson.name)) {
94
- await mergePackageLocales(path.join(workingDirectory, "locales"), packageJson.name, locales, localeDictionaries);
95
- }
96
- cliCore.CLIDisplay.break();
97
- cliCore.CLIDisplay.task(core.I18n.formatMessage("commands.merge-locales.progress.writingMergedLocales"));
98
- for (const localeDictionary in localeDictionaries) {
99
- const localeFile = path.join(outputDirectory, `${localeDictionary}.json`);
100
- cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.merge-locales.labels.writingLocale"), localeFile, 1);
101
- await promises.writeFile(localeFile, `${JSON.stringify(localeDictionaries[localeDictionary], undefined, "\t")}\n`, "utf8");
102
- }
103
- cliCore.CLIDisplay.break();
104
- }
105
- /**
106
- * Merge the locales for a package.
107
- * @param packageLocalDirectory The root of the NPM packages.
108
- * @param packageName The name of the package.
109
- * @param locales The locales to merge.
110
- * @internal
111
- */
112
- async function mergePackageLocales(packageLocalDirectory, packageName, locales, localeDictionaries) {
113
- cliCore.CLIDisplay.task(core.I18n.formatMessage("commands.merge-locales.progress.mergingLocalesForPackage"), packageName);
114
- if (await cliCore.CLIUtils.dirExists(packageLocalDirectory)) {
115
- for (const locale of locales) {
116
- const localeFile = path.join(packageLocalDirectory, `${locale.code}.json`);
117
- if (await cliCore.CLIUtils.dirExists(localeFile)) {
118
- cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.merge-locales.labels.mergingLocale"), locale.code, 1);
119
- const localeDictionary = await cliCore.CLIUtils.readJsonFile(localeFile);
120
- localeDictionaries[locale.code] ??= {};
121
- localeDictionaries[locale.code] = core.ObjectHelper.merge(localeDictionaries[locale.code], localeDictionary);
122
- }
123
- }
124
- }
125
- cliCore.CLIDisplay.break();
126
- }
127
- /**
128
- * Find dependencies for the package.
129
- * @param npmRoot The root of the NPM packages.
130
- * @param packageJsonPath The path to the package.json.
131
- * @param packageNames The package names to add to.
132
- * @returns The package details.
133
- * @internal
134
- */
135
- async function findDependencies(npmRoot, packageJsonPath, packageNames) {
136
- const packageJson = await cliCore.CLIUtils.readJsonFile(packageJsonPath);
137
- if (core.Is.objectValue(packageJson?.dependencies)) {
138
- for (const pkg in packageJson.dependencies) {
139
- if (pkg.startsWith("@twin.org") && !packageNames.includes(pkg)) {
140
- packageNames.push(pkg);
141
- const packagePath = path.join(npmRoot, pkg, "package.json");
142
- await findDependencies(npmRoot, packagePath, packageNames);
143
- }
144
- }
145
- }
146
- if (core.Is.objectValue(packageJson?.peerDependencies)) {
147
- for (const pkg in packageJson.peerDependencies) {
148
- if (pkg.startsWith("@twin.org") && !packageNames.includes(pkg)) {
149
- packageNames.push(pkg);
150
- const packagePath = path.join(npmRoot, pkg, "package.json");
151
- await findDependencies(npmRoot, packagePath, packageNames);
152
- }
153
- }
154
- }
155
- return packageJson ?? {};
156
- }
157
-
158
- // Copyright 2024 IOTA Stiftung.
159
- // SPDX-License-Identifier: Apache-2.0.
160
- /**
161
- * The main entry point for the CLI.
162
- */
163
- class CLI extends cliCore.CLIBase {
164
- /**
165
- * Run the app.
166
- * @param argv The process arguments.
167
- * @param localesDirectory The directory for the locales, default to relative to the script.
168
- * @param options Additional options.
169
- * @param options.overrideOutputWidth Override the output width.
170
- * @returns The exit code.
171
- */
172
- async run(argv, localesDirectory, options) {
173
- return this.execute({
174
- title: "TWIN Merge Locales",
175
- appName: "merge-locales",
176
- version: "0.0.2-next.9", // x-release-please-version
177
- icon: "⚙️ ",
178
- supportsEnvFiles: false,
179
- overrideOutputWidth: options?.overrideOutputWidth
180
- }, localesDirectory ?? path.join(path.dirname(node_url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href)))), "../locales"), argv);
181
- }
182
- /**
183
- * Configure any options or actions at the root program level.
184
- * @param program The root program command.
185
- */
186
- configureRoot(program) {
187
- buildCommandMergeLocales(program);
188
- }
189
- }
190
-
191
- exports.CLI = CLI;
192
- exports.actionCommandMergeLocales = actionCommandMergeLocales;
193
- exports.buildCommandMergeLocales = buildCommandMergeLocales;
194
- exports.mergeLocales = mergeLocales;