@twin.org/merge-locales 0.0.2-next.8 → 0.0.2

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.md CHANGED
@@ -1,16 +1,16 @@
1
1
  # TWIN Merge Locales
2
2
 
3
- This tool will read the locale files from all the dependencies and create a combined one.
3
+ This application is part of the framework workspace and provides merge locale files from all dependencies to support consistent development workflows across the ecosystem.
4
4
 
5
5
  ## Installation
6
6
 
7
7
  ```shell
8
- npm install @twin.org/merge-locales
8
+ npm install -D @twin.org/merge-locales
9
9
  ```
10
10
 
11
- ## Examples
11
+ ## Usage
12
12
 
13
- Usage of the tool is shown in the examples [docs/examples.md](docs/examples.md)
13
+ Usage of the tool is shown in the examples [docs/usage.md](docs/usage.md)
14
14
 
15
15
  ## Reference
16
16
 
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.2", // 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,OAAO,EAAE,2BAA2B;YAC7C,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.2\", // 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.8", // 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/mergeLocales.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EACN,YAAY,EACZ,IAAI,EACJ,EAAE,EACF,YAAY,EAGZ,MAAM,gBAAgB,CAAC;AAKxB;;;GAGG;AACH,MAAM,UAAU,wBAAwB,CAAC,OAAgB;IACxD,OAAO;SACL,MAAM,CACN,IAAI,CAAC,aAAa,CAAC,6CAA6C,CAAC,EACjE,IAAI,CAAC,aAAa,CAAC,mDAAmD,CAAC,CACvE;SACA,MAAM,CAAC,KAAK,EAAC,IAAI,EAAC,EAAE;QACpB,MAAM,yBAAyB,CAAC,IAAI,CAAC,CAAC;IACvC,CAAC,CAAC,CAAC;AACL,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,yBAAyB,CAAC,IAAyB;IACxE,IAAI,MAAuC,CAAC;IAC5C,IAAI,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;QACjC,IAAI,CAAC;YACJ,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,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AEtB,MAAM,WAAW,GAAG,MAAM,QAAQ,CAAC,YAAY,CAAe,eAAe,CAAC,CAAC;IAE/E,IAAI,EAAE,CAAC,WAAW,CAAC,WAAW,EAAE,YAAY,CAAC,EAAE,CAAC;QAC/C,KAAK,MAAM,GAAG,IAAI,WAAW,CAAC,YAAY,EAAE,CAAC;YAC5C,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,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}\"",
@@ -86,10 +83,8 @@
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
85
  "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}"
86
+ "uuidV7": "Property \"{property}\" must be a UUIDv7 formatted string, it is \"{value}\"",
87
+ "uuidV7Compact": "Property \"{property}\" must be a UUIDv7 formatted string in compact mode, it is \"{value}\""
93
88
  },
94
89
  "objectHelper": {
95
90
  "failedBytesToJSON": "Failed converting bytes to JSON",
@@ -102,10 +97,11 @@
102
97
  },
103
98
  "factory": {
104
99
  "noUnregister": "There is no {typeName} registered with the name \"{name}\"",
105
- "noGet": "The requested {typeName} \"{name}\" does not exist in the factory"
100
+ "noGet": "The requested {typeName} \"{name}\" does not exist in the factory",
101
+ "noCreate": "The requested {typeName} \"{name}\" cannot be created by the factory, with params \"{params}\""
106
102
  },
107
103
  "bitString": {
108
- "outOfRange": "The index should be >= 0 and less than the length of the bit string"
104
+ "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
105
  },
110
106
  "base32": {
111
107
  "invalidCharacter": "Data contains a character \"{invalidCharacter}\" which is not in the charset"
@@ -118,68 +114,6 @@
118
114
  },
119
115
  "jsonHelper": {
120
116
  "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
117
  }
184
118
  },
185
119
  "warn": {
@@ -239,7 +173,8 @@
239
173
  "alreadyExistsError": "Already Exists",
240
174
  "notImplementedError": "Not Implemented",
241
175
  "validationError": "Validation",
242
- "unprocessableError": "Unprocessable"
176
+ "unprocessableError": "Unprocessable",
177
+ "unauthorizedError": "Unauthorized"
243
178
  },
244
179
  "validation": {
245
180
  "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";