From 0f35f1fc79d4542445f6f2d2ef1b49ee33fd98d7 Mon Sep 17 00:00:00 2001 From: Sabine Date: Fri, 21 Aug 2026 12:35:36 +0200 Subject: [PATCH] feat(developer): changes in kmc convert --help; import of ConverterArtifacts, ConverterToKmnArtifacts, ConverterResult, and ConverterToKmnResult --- .../kmc-convert/src/converter-artifacts.ts | 18 +++++++++++++++++ developer/src/kmc-convert/src/converter.ts | 13 ++---------- .../keylayout-to-kmn-converter.ts | 20 ++----------------- developer/src/kmc-convert/src/main.ts | 1 + developer/src/kmc/src/commands/convert.ts | 7 +++++-- 5 files changed, 28 insertions(+), 31 deletions(-) diff --git a/developer/src/kmc-convert/src/converter-artifacts.ts b/developer/src/kmc-convert/src/converter-artifacts.ts index 9752af966c..6697fa38ef 100644 --- a/developer/src/kmc-convert/src/converter-artifacts.ts +++ b/developer/src/kmc-convert/src/converter-artifacts.ts @@ -4,6 +4,7 @@ * Output artifacts available from kmc-convert */ import { KeymanCompilerArtifactOptional, KeymanCompilerArtifacts } from '@keymanapp/developer-utils'; +import { KeymanCompilerResult } from "@keymanapp/developer-utils"; export interface ConverterArtifacts extends KeymanCompilerArtifacts { } @@ -25,3 +26,20 @@ export interface ConverterToKmnArtifacts extends ConverterArtifacts { */ keymanTouchLayout?: KeymanCompilerArtifactOptional; }; + + +export interface ConverterResult extends KeymanCompilerResult { + /** + * Internal in-memory build artifacts from a successful compilation. Caller + * can write these to disk with {@link Converter.write} + */ + artifacts: ConverterArtifacts; +}; + +export interface ConverterToKmnResult extends ConverterResult { + /** + * Internal in-memory build artifacts from a successful compilation to kmn. + * Caller can write these to disk with {@link Converter.write} + */ + artifacts: ConverterToKmnArtifacts; +}; diff --git a/developer/src/kmc-convert/src/converter.ts b/developer/src/kmc-convert/src/converter.ts index ec513db626..88fb342c8d 100644 --- a/developer/src/kmc-convert/src/converter.ts +++ b/developer/src/kmc-convert/src/converter.ts @@ -7,21 +7,12 @@ import { CompilerCallbacks, CompilerOptions, defaultCompilerOptions, - KeymanCompiler, - KeymanCompilerResult, + KeymanCompiler } from "@keymanapp/developer-utils"; import { ConverterClassFactory } from './converter-class-factory.js'; -import { ConverterArtifacts } from "./converter-artifacts.js"; +import { ConverterArtifacts, ConverterResult } from "./main.js"; import { ConverterMessages } from "./converter-messages.js"; -export interface ConverterResult extends KeymanCompilerResult { - /** - * Internal in-memory build artifacts from a successful compilation. Caller - * can write these to disk with {@link Converter.write} - */ - artifacts: ConverterArtifacts; -}; - /** * @public * Converts keyboards between different source file formats. The diff --git a/developer/src/kmc-convert/src/keylayout-to-kmn/keylayout-to-kmn-converter.ts b/developer/src/kmc-convert/src/keylayout-to-kmn/keylayout-to-kmn-converter.ts index 29f2ab47c6..de67865734 100644 --- a/developer/src/kmc-convert/src/keylayout-to-kmn/keylayout-to-kmn-converter.ts +++ b/developer/src/kmc-convert/src/keylayout-to-kmn/keylayout-to-kmn-converter.ts @@ -8,27 +8,11 @@ * */ -import { CompilerCallbacks, CompilerOptions, KeymanCompilerResult, Keylayout } from "@keymanapp/developer-utils"; +import { CompilerCallbacks, CompilerOptions, Keylayout } from "@keymanapp/developer-utils"; import { KmnFileWriter } from './kmn-file-writer.js'; import { KeylayoutFileReader } from './keylayout-file-reader.js'; import { ConverterMessages } from '../converter-messages.js'; -import { ConverterArtifacts, ConverterToKmnArtifacts } from "../converter-artifacts.js"; - -export interface ConverterResult extends KeymanCompilerResult { - /** - * Internal in-memory build artifacts from a successful compilation. Caller - * can write these to disk with {@link Converter.write} - */ - artifacts: ConverterArtifacts; -}; - -interface ConverterToKmnResult extends ConverterResult { - /** - * Internal in-memory build artifacts from a successful compilation. Caller - * can write these to disk with {@link Converter.write} - */ - artifacts: ConverterToKmnArtifacts; -}; +import { ConverterToKmnResult } from "../main.js"; /** * Interface for all data read from a .keylayout file. Also contains all rules processed from input data. diff --git a/developer/src/kmc-convert/src/main.ts b/developer/src/kmc-convert/src/main.ts index 11b56fccc9..0a8987c1e0 100644 --- a/developer/src/kmc-convert/src/main.ts +++ b/developer/src/kmc-convert/src/main.ts @@ -7,3 +7,4 @@ export { Converter } from './converter.js'; export { ConverterOptions } from './converter-options.js'; export { ConverterMessages } from './converter-messages.js'; +export { ConverterArtifacts, ConverterToKmnArtifacts, ConverterResult, ConverterToKmnResult } from './converter-artifacts.js'; diff --git a/developer/src/kmc/src/commands/convert.ts b/developer/src/kmc/src/commands/convert.ts index 2dbbf71c31..018f38afc3 100644 --- a/developer/src/kmc/src/commands/convert.ts +++ b/developer/src/kmc/src/commands/convert.ts @@ -17,9 +17,12 @@ export function declareConvert(program: Command) { BaseOptions.addLogLevel(command); BaseOptions.addLogFormat(command); command - .description('Convert keyboard source files between formats') + // TODO kmc-convert: add more conversions later, then alter text here + //.description('Convert keyboard source files between formats:') + .description('Convert keyboard source files from keylayout -> .kmn:') .option('-p, --out-path ', 'Path for output files') - .requiredOption('-t, --out-type ', 'File extension for output files, e.g. .kmn, required') + // TODO kmc-convert: add more conversions later, then File extension for output files is required + // .requiredOption('-t, --out-type ', 'File extension for output files, e.g. .kmn, required') .action(async (filenames: string[], _options: any, commander: any): Promise => { const options = commander.optsWithGlobals(); const callbacks = new NodeCompilerCallbacks({logLevel: options.logLevel});