@keymanapp/kmc 18.0.41-alpha → 18.0.45-alpha
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/build/src/commands/analyze.d.ts +22 -22
- package/build/src/commands/analyze.js +105 -105
- package/build/src/commands/analyze.js.map +1 -1
- package/build/src/commands/build.d.ts +12 -12
- package/build/src/commands/build.js +154 -154
- package/build/src/commands/build.js.map +1 -1
- package/build/src/commands/buildClasses/BuildActivity.d.ts +10 -10
- package/build/src/commands/buildClasses/BuildActivity.js +30 -30
- package/build/src/commands/buildClasses/BuildActivity.js.map +1 -1
- package/build/src/commands/buildClasses/BuildKeyboardInfo.d.ts +10 -10
- package/build/src/commands/buildClasses/BuildKeyboardInfo.js +46 -46
- package/build/src/commands/buildClasses/BuildKeyboardInfo.js.map +1 -1
- package/build/src/commands/buildClasses/BuildKmnKeyboard.d.ts +9 -9
- package/build/src/commands/buildClasses/BuildKmnKeyboard.js +34 -34
- package/build/src/commands/buildClasses/BuildKmnKeyboard.js.map +1 -1
- package/build/src/commands/buildClasses/BuildLdmlKeyboard.d.ts +9 -9
- package/build/src/commands/buildClasses/BuildLdmlKeyboard.js +18 -18
- package/build/src/commands/buildClasses/BuildModel.d.ts +9 -9
- package/build/src/commands/buildClasses/BuildModel.js +12 -12
- package/build/src/commands/buildClasses/BuildModelInfo.d.ts +20 -20
- package/build/src/commands/buildClasses/BuildModelInfo.js +72 -72
- package/build/src/commands/buildClasses/BuildModelInfo.js.map +1 -1
- package/build/src/commands/buildClasses/BuildPackage.d.ts +9 -9
- package/build/src/commands/buildClasses/BuildPackage.js +12 -12
- package/build/src/commands/buildClasses/BuildProject.d.ts +10 -10
- package/build/src/commands/buildClasses/BuildProject.js +115 -115
- package/build/src/commands/buildClasses/BuildProject.js.map +1 -1
- package/build/src/commands/buildClasses/buildActivities.d.ts +6 -6
- package/build/src/commands/buildClasses/buildActivities.js +20 -20
- package/build/src/commands/buildTestData/index.d.ts +1 -1
- package/build/src/commands/buildTestData/index.js +38 -38
- package/build/src/commands/buildTestData/index.js.map +1 -1
- package/build/src/commands/buildWindowsPackageInstaller/index.d.ts +1 -1
- package/build/src/commands/buildWindowsPackageInstaller/index.js +42 -42
- package/build/src/commands/buildWindowsPackageInstaller/index.js.map +1 -1
- package/build/src/commands/messageCommand.d.ts +2 -2
- package/build/src/commands/messageCommand.js +208 -208
- package/build/src/commands/messageCommand.js.map +1 -1
- package/build/src/kmc.d.ts +5 -5
- package/build/src/kmc.js +56 -56
- package/build/src/kmc.js.map +1 -1
- package/build/src/kmlmc.d.ts +5 -5
- package/build/src/kmlmc.js +56 -56
- package/build/src/kmlmc.js.map +1 -1
- package/build/src/kmlmp.d.ts +5 -5
- package/build/src/kmlmp.js +45 -45
- package/build/src/kmlmp.js.map +1 -1
- package/build/src/messages/infrastructureMessages.d.ts +151 -151
- package/build/src/messages/infrastructureMessages.js +74 -74
- package/build/src/messages/messageNamespaces.d.ts +7 -7
- package/build/src/messages/messageNamespaces.js +38 -38
- package/build/src/util/NodeCompilerCallbacks.d.ts +43 -43
- package/build/src/util/NodeCompilerCallbacks.js +220 -220
- package/build/src/util/NodeCompilerCallbacks.js.map +1 -1
- package/build/src/util/TestKeymanSentry.d.ts +6 -6
- package/build/src/util/TestKeymanSentry.js +50 -50
- package/build/src/util/TestKeymanSentry.js.map +1 -1
- package/build/src/util/baseOptions.d.ts +20 -20
- package/build/src/util/baseOptions.js +23 -23
- package/build/src/util/calculateSourcePath.d.ts +10 -10
- package/build/src/util/calculateSourcePath.js +17 -17
- package/build/src/util/calculateSourcePath.js.map +1 -1
- package/build/src/util/extendedCompilerOptions.d.ts +56 -56
- package/build/src/util/extendedCompilerOptions.js +122 -122
- package/build/src/util/extendedCompilerOptions.js.map +1 -1
- package/build/src/util/fileLists.d.ts +15 -15
- package/build/src/util/fileLists.js +45 -45
- package/build/src/util/fileLists.js.map +1 -1
- package/build/src/util/getDeveloperBinPath.d.ts +8 -8
- package/build/src/util/getDeveloperBinPath.js +35 -35
- package/build/src/util/getDeveloperBinPath.js.map +1 -1
- package/build/src/util/getLastGitCommitDate.d.ts +7 -7
- package/build/src/util/getLastGitCommitDate.js +43 -43
- package/build/src/util/getLastGitCommitDate.js.map +1 -1
- package/build/src/util/kmcSentryOptions.d.ts +7 -7
- package/build/src/util/kmcSentryOptions.js +19 -19
- package/build/src/util/kmcSentryOptions.js.map +1 -1
- package/build/src/util/projectLoader.d.ts +3 -3
- package/build/src/util/projectLoader.js +50 -50
- package/build/src/util/projectLoader.js.map +1 -1
- package/build/src/util/projectRunner.d.ts +2 -2
- package/build/src/util/projectRunner.js +26 -26
- package/build/src/util/projectRunner.js.map +1 -1
- package/build/src/util/sysexits.d.ts +9 -9
- package/build/src/util/sysexits.js +6 -6
- package/package.json +12 -12
|
@@ -1,39 +1,39 @@
|
|
|
1
|
-
import * as fs from 'fs';
|
|
2
|
-
import * as path from 'path';
|
|
3
|
-
import * as kmcLdml from '@keymanapp/kmc-ldml';
|
|
4
|
-
import { defaultCompilerOptions, LDMLKeyboardXMLSourceFileReader } from '@keymanapp/common-types';
|
|
5
|
-
import { NodeCompilerCallbacks } from '../../util/NodeCompilerCallbacks.js';
|
|
6
|
-
import { fileURLToPath } from 'url';
|
|
7
|
-
import { exitProcess } from '../../util/sysexits.js';
|
|
8
|
-
import { InfrastructureMessages } from '../../messages/infrastructureMessages.js';
|
|
9
|
-
export async function buildTestData(infile, _options, commander) {
|
|
10
|
-
const options = commander.optsWithGlobals();
|
|
11
|
-
let compilerOptions = {
|
|
12
|
-
...defaultCompilerOptions,
|
|
13
|
-
...options,
|
|
14
|
-
saveDebug: false,
|
|
15
|
-
shouldAddCompilerVersion: false,
|
|
16
|
-
readerOptions: {
|
|
17
|
-
importsPath: fileURLToPath(new URL(...LDMLKeyboardXMLSourceFileReader.defaultImportsURL))
|
|
18
|
-
}
|
|
19
|
-
};
|
|
20
|
-
const callbacks = new NodeCompilerCallbacks(options);
|
|
21
|
-
let testData = await loadTestData(infile, callbacks, compilerOptions);
|
|
22
|
-
if (!testData || callbacks.hasFailureMessage()) {
|
|
23
|
-
await exitProcess(1);
|
|
24
|
-
}
|
|
25
|
-
const fileBaseName = options.outFile ?? infile;
|
|
26
|
-
const outFileBase = path.basename(fileBaseName, path.extname(fileBaseName));
|
|
27
|
-
const outFileDir = path.dirname(fileBaseName);
|
|
28
|
-
const outFileJson = path.join(outFileDir, outFileBase + '.json');
|
|
29
|
-
fs.writeFileSync(outFileJson, JSON.stringify(testData, null, ' '));
|
|
30
|
-
callbacks.reportMessage(InfrastructureMessages.Info_FileBuiltSuccessfully({ filename: outFileJson, relativeFilename: infile }));
|
|
31
|
-
}
|
|
32
|
-
async function loadTestData(inputFilename, callbacks, options) {
|
|
33
|
-
const k = new kmcLdml.LdmlKeyboardCompiler();
|
|
34
|
-
if (!await k.init(callbacks, options)) {
|
|
35
|
-
return null;
|
|
36
|
-
}
|
|
37
|
-
return await k.loadTestData(inputFilename);
|
|
38
|
-
}
|
|
1
|
+
import * as fs from 'fs';
|
|
2
|
+
import * as path from 'path';
|
|
3
|
+
import * as kmcLdml from '@keymanapp/kmc-ldml';
|
|
4
|
+
import { defaultCompilerOptions, LDMLKeyboardXMLSourceFileReader } from '@keymanapp/common-types';
|
|
5
|
+
import { NodeCompilerCallbacks } from '../../util/NodeCompilerCallbacks.js';
|
|
6
|
+
import { fileURLToPath } from 'url';
|
|
7
|
+
import { exitProcess } from '../../util/sysexits.js';
|
|
8
|
+
import { InfrastructureMessages } from '../../messages/infrastructureMessages.js';
|
|
9
|
+
export async function buildTestData(infile, _options, commander) {
|
|
10
|
+
const options = commander.optsWithGlobals();
|
|
11
|
+
let compilerOptions = {
|
|
12
|
+
...defaultCompilerOptions,
|
|
13
|
+
...options,
|
|
14
|
+
saveDebug: false,
|
|
15
|
+
shouldAddCompilerVersion: false,
|
|
16
|
+
readerOptions: {
|
|
17
|
+
importsPath: fileURLToPath(new URL(...LDMLKeyboardXMLSourceFileReader.defaultImportsURL))
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
const callbacks = new NodeCompilerCallbacks(options);
|
|
21
|
+
let testData = await loadTestData(infile, callbacks, compilerOptions);
|
|
22
|
+
if (!testData || callbacks.hasFailureMessage()) {
|
|
23
|
+
await exitProcess(1);
|
|
24
|
+
}
|
|
25
|
+
const fileBaseName = options.outFile ?? infile;
|
|
26
|
+
const outFileBase = path.basename(fileBaseName, path.extname(fileBaseName));
|
|
27
|
+
const outFileDir = path.dirname(fileBaseName);
|
|
28
|
+
const outFileJson = path.join(outFileDir, outFileBase + '.json');
|
|
29
|
+
fs.writeFileSync(outFileJson, JSON.stringify(testData, null, ' '));
|
|
30
|
+
callbacks.reportMessage(InfrastructureMessages.Info_FileBuiltSuccessfully({ filename: outFileJson, relativeFilename: infile }));
|
|
31
|
+
}
|
|
32
|
+
async function loadTestData(inputFilename, callbacks, options) {
|
|
33
|
+
const k = new kmcLdml.LdmlKeyboardCompiler();
|
|
34
|
+
if (!await k.init(callbacks, options)) {
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
return await k.loadTestData(inputFilename);
|
|
38
|
+
}
|
|
39
39
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/commands/buildTestData/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,KAAK,OAAO,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAqB,sBAAsB,EAAqC,+BAA+B,EAAE,MAAM,yBAAyB,CAAC;AACxJ,OAAO,EAAE,qBAAqB,EAAE,MAAM,qCAAqC,CAAC;AAC5E,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AAEpC,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,sBAAs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C,IAAG,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,SAAS,EAAE,OAAO,CAAC,EAAE,CAAC;QACrC,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO,MAAM,CAAC,CAAC,YAAY,CAAC,aAAa,CAAC,CAAC;AAC7C,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare function buildWindowsPackageInstaller(infile: string, _options: any, commander: any): Promise<never | void>;
|
|
1
|
+
export declare function buildWindowsPackageInstaller(infile: string, _options: any, commander: any): Promise<never | void>;
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,43 +1,43 @@
|
|
|
1
|
-
import * as fs from 'fs';
|
|
2
|
-
import * as path from 'path';
|
|
3
|
-
import { defaultCompilerOptions } from '@keymanapp/common-types';
|
|
4
|
-
import { NodeCompilerCallbacks } from '../../util/NodeCompilerCallbacks.js';
|
|
5
|
-
import { WindowsPackageInstallerCompiler } from '@keymanapp/kmc-package';
|
|
6
|
-
import { exitProcess } from '../../util/sysexits.js';
|
|
7
|
-
;
|
|
8
|
-
export async function buildWindowsPackageInstaller(infile, _options, commander) {
|
|
9
|
-
// TODO(lowpri): we probably should cleanup the options management here, move
|
|
10
|
-
// translation of command line options to kmc-* options into a separate module
|
|
11
|
-
const options = commander.optsWithGlobals();
|
|
12
|
-
const sources = {
|
|
13
|
-
licenseFilename: options.license,
|
|
14
|
-
msiFilename: options.msi,
|
|
15
|
-
setupExeFilename: options.exe,
|
|
16
|
-
startDisabled: options.startDisabled,
|
|
17
|
-
startWithConfiguration: options.startWithConfiguration,
|
|
18
|
-
appName: options.appName,
|
|
19
|
-
titleImageFilename: options.titleImage
|
|
20
|
-
};
|
|
21
|
-
const outfile = options.outFile;
|
|
22
|
-
// Normalize case for the filename and expand the path; this avoids false
|
|
23
|
-
// positive case mismatches on input filenames and glommed paths
|
|
24
|
-
infile = fs.realpathSync.native(infile);
|
|
25
|
-
const callbacks = new NodeCompilerCallbacks({ ...defaultCompilerOptions, ...options });
|
|
26
|
-
const compiler = new WindowsPackageInstallerCompiler();
|
|
27
|
-
if (!await compiler.init(callbacks, { ...options, sources })) {
|
|
28
|
-
return await exitProcess(1);
|
|
29
|
-
}
|
|
30
|
-
const fileBaseName = outfile ?? infile;
|
|
31
|
-
const outFileBase = path.basename(fileBaseName, path.extname(fileBaseName));
|
|
32
|
-
const outFileDir = path.dirname(fileBaseName);
|
|
33
|
-
const outFileExe = path.join(outFileDir, outFileBase + '.exe');
|
|
34
|
-
const result = await compiler.run(infile, outFileExe);
|
|
35
|
-
if (!result) {
|
|
36
|
-
// errors will have been reported already
|
|
37
|
-
return await exitProcess(1);
|
|
38
|
-
}
|
|
39
|
-
if (!await compiler.write(result.artifacts)) {
|
|
40
|
-
return await exitProcess(1);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
1
|
+
import * as fs from 'fs';
|
|
2
|
+
import * as path from 'path';
|
|
3
|
+
import { defaultCompilerOptions } from '@keymanapp/common-types';
|
|
4
|
+
import { NodeCompilerCallbacks } from '../../util/NodeCompilerCallbacks.js';
|
|
5
|
+
import { WindowsPackageInstallerCompiler } from '@keymanapp/kmc-package';
|
|
6
|
+
import { exitProcess } from '../../util/sysexits.js';
|
|
7
|
+
;
|
|
8
|
+
export async function buildWindowsPackageInstaller(infile, _options, commander) {
|
|
9
|
+
// TODO(lowpri): we probably should cleanup the options management here, move
|
|
10
|
+
// translation of command line options to kmc-* options into a separate module
|
|
11
|
+
const options = commander.optsWithGlobals();
|
|
12
|
+
const sources = {
|
|
13
|
+
licenseFilename: options.license,
|
|
14
|
+
msiFilename: options.msi,
|
|
15
|
+
setupExeFilename: options.exe,
|
|
16
|
+
startDisabled: options.startDisabled,
|
|
17
|
+
startWithConfiguration: options.startWithConfiguration,
|
|
18
|
+
appName: options.appName,
|
|
19
|
+
titleImageFilename: options.titleImage
|
|
20
|
+
};
|
|
21
|
+
const outfile = options.outFile;
|
|
22
|
+
// Normalize case for the filename and expand the path; this avoids false
|
|
23
|
+
// positive case mismatches on input filenames and glommed paths
|
|
24
|
+
infile = fs.realpathSync.native(infile);
|
|
25
|
+
const callbacks = new NodeCompilerCallbacks({ ...defaultCompilerOptions, ...options });
|
|
26
|
+
const compiler = new WindowsPackageInstallerCompiler();
|
|
27
|
+
if (!await compiler.init(callbacks, { ...options, sources })) {
|
|
28
|
+
return await exitProcess(1);
|
|
29
|
+
}
|
|
30
|
+
const fileBaseName = outfile ?? infile;
|
|
31
|
+
const outFileBase = path.basename(fileBaseName, path.extname(fileBaseName));
|
|
32
|
+
const outFileDir = path.dirname(fileBaseName);
|
|
33
|
+
const outFileExe = path.join(outFileDir, outFileBase + '.exe');
|
|
34
|
+
const result = await compiler.run(infile, outFileExe);
|
|
35
|
+
if (!result) {
|
|
36
|
+
// errors will have been reported already
|
|
37
|
+
return await exitProcess(1);
|
|
38
|
+
}
|
|
39
|
+
if (!await compiler.write(result.artifacts)) {
|
|
40
|
+
return await exitProcess(1);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
43
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/commands/buildWindowsPackageInstaller/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAqB,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AACpF,OAAO,EAAE,qBAAqB,EAAE,MAAM,qCAAqC,CAAC;AAC5E,OAAO,EAAE,+BAA+B,EAAkC,MAAM,wBAAwB,CAAC;AAEzG,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAUpD,CAAC;AAEF,MAAM,CAAC,KAAK,UAAU,4BAA4B,CAAC,MAAc,EAAE,QAAa,EAAE,SAAc;IAC9F,6EAA6E;IAC7E,8EAA8E;IAC9E,MAAM,OAAO,GAA8C,SAAS,CAA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AAE,UAAU,CAAC,CAAC;IACtD,IAAG,CAAC,MAAM,EAAE,CAAC;QACX,yCAAyC;QACzC,OAAO,MAAM,WAAW,CAAC,CAAC,CAAC,CAAC;IAC9B,CAAC;IAED,IAAG,CAAC,MAAM,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE,CAAC;QAC3C,OAAO,MAAM,WAAW,CAAC,CAAC,CAAC,CAAC;IAC9B,CAAC;AACH,CAAC"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { Command } from 'commander';
|
|
2
|
-
export declare function declareMessage(program: Command): void;
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
export declare function declareMessage(program: Command): void;
|
|
3
3
|
//# sourceMappingURL=messageCommand.d.ts.map
|
|
@@ -1,151 +1,151 @@
|
|
|
1
|
-
import * as fs from 'fs';
|
|
2
|
-
import * as path from 'path';
|
|
3
|
-
import { CompilerError } from '@keymanapp/common-types';
|
|
4
|
-
import { Option } from 'commander';
|
|
5
|
-
import { messageNamespaceKeys, messageSources } from '../messages/messageNamespaces.js';
|
|
6
|
-
import { NodeCompilerCallbacks } from '../util/NodeCompilerCallbacks.js';
|
|
7
|
-
import { exitProcess } from '../util/sysexits.js';
|
|
8
|
-
import { InfrastructureMessages } from '../messages/infrastructureMessages.js';
|
|
9
|
-
import { findMessageDetails } from '../util/extendedCompilerOptions.js';
|
|
10
|
-
import { escapeMarkdownChar, KeymanUrls } from '@keymanapp/developer-utils';
|
|
11
|
-
;
|
|
12
|
-
export function declareMessage(program) {
|
|
13
|
-
program
|
|
14
|
-
.command('message [messages...]')
|
|
15
|
-
.description(`Describe one or more compiler messages. Note: Markdown format is always written to files on disk.`)
|
|
16
|
-
.addOption(new Option('-f, --format <format>', 'Output format').choices(['text', 'markdown', 'json']).default('text'))
|
|
17
|
-
.option('-o, --out-path <out-path>', 'Output path for Markdown files; output filename for text and json formats')
|
|
18
|
-
.option('-a, --all-messages', 'Emit descriptions for all messages (text, json)')
|
|
19
|
-
.action(messageCommand);
|
|
20
|
-
}
|
|
21
|
-
async function messageCommand(messages, _options, commander) {
|
|
22
|
-
const commanderOptions = commander.optsWithGlobals();
|
|
23
|
-
const options = initialize(commanderOptions);
|
|
24
|
-
if (!options) {
|
|
25
|
-
await exitProcess(1);
|
|
26
|
-
}
|
|
27
|
-
const callbacks = new NodeCompilerCallbacks(options);
|
|
28
|
-
let result = false;
|
|
29
|
-
if (options.format == 'markdown') {
|
|
30
|
-
result = messageCommandMarkdown(messages, options, callbacks);
|
|
31
|
-
}
|
|
32
|
-
else { // json or text format
|
|
33
|
-
if (messages.length == 0 && !options.allMessages) {
|
|
34
|
-
console.error('Must specify at least one message code or -a for all messages');
|
|
35
|
-
callbacks.reportMessage(InfrastructureMessages.Error_MustSpecifyMessageCode());
|
|
36
|
-
await exitProcess(1);
|
|
37
|
-
}
|
|
38
|
-
const messageDetails = messages.length
|
|
39
|
-
? messages.map(message => translateMessageInputToCode(message, callbacks))
|
|
40
|
-
: allMessageDetails();
|
|
41
|
-
if (callbacks.messageCount > 0) {
|
|
42
|
-
await exitProcess(1);
|
|
43
|
-
}
|
|
44
|
-
let text = null;
|
|
45
|
-
if (options.format == 'json') {
|
|
46
|
-
const data = getMessagesAsArrayForJson(messageDetails);
|
|
47
|
-
if (data) {
|
|
48
|
-
text = JSON.stringify(data, null, 2);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
else {
|
|
52
|
-
text = getMessagesAsText(messageDetails);
|
|
53
|
-
}
|
|
54
|
-
result = text != null;
|
|
55
|
-
if (result) {
|
|
56
|
-
if (options.outPath) {
|
|
57
|
-
fs.writeFileSync(options.outPath, text, 'utf-8');
|
|
58
|
-
}
|
|
59
|
-
else {
|
|
60
|
-
process.stdout.write(text);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
if (!result) {
|
|
65
|
-
await exitProcess(1);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
// We have a redirect pattern for kmn.sh/km<#####> to
|
|
69
|
-
// the corresponding compiler message reference document in
|
|
70
|
-
// help.keyman.com/developer/latest-version/reference/errors/km<#####>
|
|
71
|
-
const helpUrl = (code) => KeymanUrls.COMPILER_ERROR_CODE(CompilerError.formatCode(code).toLowerCase());
|
|
72
|
-
const getModuleName = (ms) => `${ms.module}.${ms.class.name}`;
|
|
73
|
-
function translateMessageInputToCode(message, callbacks) {
|
|
74
|
-
const pattern = /^(KM)?([0-9a-f]+)$/i;
|
|
75
|
-
const result = message.match(pattern);
|
|
76
|
-
if (!result) {
|
|
77
|
-
callbacks.reportMessage(InfrastructureMessages.Error_UnrecognizedMessageCode({ message }));
|
|
78
|
-
return null;
|
|
79
|
-
}
|
|
80
|
-
const code = Number.parseInt(result[2], 16);
|
|
81
|
-
return findMessageDetails(code, callbacks);
|
|
82
|
-
}
|
|
83
|
-
function initialize(options) {
|
|
84
|
-
// We don't want to rename command line options to match the precise
|
|
85
|
-
// properties that we have in CompilerOptions, but nor do we want to rename
|
|
86
|
-
// CompilerOptions properties...
|
|
87
|
-
return {
|
|
88
|
-
// CompilerBaseOptions
|
|
89
|
-
logLevel: options.logLevel,
|
|
90
|
-
logFormat: options.logFormat,
|
|
91
|
-
color: options.color,
|
|
92
|
-
// MessageOptions
|
|
93
|
-
format: options.format ?? 'text',
|
|
94
|
-
outPath: options.outPath
|
|
95
|
-
};
|
|
96
|
-
}
|
|
97
|
-
const getMessageIdentifiersSorted = (cls) => Object.keys(cls)
|
|
98
|
-
.filter(id => typeof cls[id] == 'number')
|
|
99
|
-
.sort((a, b) => CompilerError.error(cls[a]) - CompilerError.error(cls[b]));
|
|
100
|
-
function allMessageDetails() {
|
|
101
|
-
let result = [];
|
|
102
|
-
messageNamespaceKeys.forEach((namespace) => {
|
|
103
|
-
const ms = messageSources[namespace];
|
|
104
|
-
const ids = getMessageIdentifiersSorted(ms.class);
|
|
105
|
-
for (const id of ids) {
|
|
106
|
-
const code = ms.class[id];
|
|
107
|
-
if (typeof code != 'number') {
|
|
108
|
-
continue;
|
|
109
|
-
}
|
|
110
|
-
result.push({
|
|
111
|
-
code,
|
|
112
|
-
id,
|
|
113
|
-
class: ms.class,
|
|
114
|
-
module: ms.module
|
|
115
|
-
});
|
|
116
|
-
}
|
|
117
|
-
});
|
|
118
|
-
return result;
|
|
119
|
-
}
|
|
120
|
-
const toTitleCase = (s) => s.substring(0, 1).toUpperCase() + s.substring(1).toLowerCase();
|
|
121
|
-
function getMessageDetail(cls, id, escapeMarkdown) {
|
|
122
|
-
const o = /^(INFO|HINT|WARN|ERROR|FATAL)_([A-Za-z0-9_]+)$/.exec(id);
|
|
123
|
-
if (!o) {
|
|
124
|
-
throw new Error(`Unexpected compiler message ${id}, does not match message error format`);
|
|
125
|
-
}
|
|
126
|
-
const f = toTitleCase(o[1]) + '_' + o[2];
|
|
127
|
-
const event = cls[f]?.({} /* ignore arguments*/);
|
|
128
|
-
if (!event) {
|
|
129
|
-
throw new Error(`Call to ${cls.name}.${f} returned null`);
|
|
130
|
-
}
|
|
131
|
-
event.detail = (event.detail ?? '').replace(/^[ ]+/gm, ''); // TODO(lowpri): dedent may be too naive?
|
|
132
|
-
event.message = event.message ?? '';
|
|
133
|
-
event.message = event?.exceptionVar
|
|
134
|
-
? 'This is an internal error; the message will vary'
|
|
135
|
-
: (escapeMarkdown ? `${escapeMarkdownChar(event.message, false)}` : event.message);
|
|
136
|
-
return event;
|
|
137
|
-
}
|
|
138
|
-
/*---------------------------------------------------------------------------
|
|
139
|
-
* Get messages in text format
|
|
140
|
-
*---------------------------------------------------------------------------*/
|
|
141
|
-
function getMessagesAsText(messages) {
|
|
142
|
-
const result = messages.reduce((prev, message) => {
|
|
143
|
-
return prev + '\n' + formatMessageAsText(getModuleName({ class: message.class, module: message.module }), message.class, message.code, message.id);
|
|
144
|
-
}, '');
|
|
145
|
-
return result;
|
|
146
|
-
}
|
|
147
|
-
function formatMessageAsText(moduleName, cls, code, id) {
|
|
148
|
-
const message = getMessageDetail(cls, id, false);
|
|
1
|
+
import * as fs from 'fs';
|
|
2
|
+
import * as path from 'path';
|
|
3
|
+
import { CompilerError } from '@keymanapp/common-types';
|
|
4
|
+
import { Option } from 'commander';
|
|
5
|
+
import { messageNamespaceKeys, messageSources } from '../messages/messageNamespaces.js';
|
|
6
|
+
import { NodeCompilerCallbacks } from '../util/NodeCompilerCallbacks.js';
|
|
7
|
+
import { exitProcess } from '../util/sysexits.js';
|
|
8
|
+
import { InfrastructureMessages } from '../messages/infrastructureMessages.js';
|
|
9
|
+
import { findMessageDetails } from '../util/extendedCompilerOptions.js';
|
|
10
|
+
import { escapeMarkdownChar, KeymanUrls } from '@keymanapp/developer-utils';
|
|
11
|
+
;
|
|
12
|
+
export function declareMessage(program) {
|
|
13
|
+
program
|
|
14
|
+
.command('message [messages...]')
|
|
15
|
+
.description(`Describe one or more compiler messages. Note: Markdown format is always written to files on disk.`)
|
|
16
|
+
.addOption(new Option('-f, --format <format>', 'Output format').choices(['text', 'markdown', 'json']).default('text'))
|
|
17
|
+
.option('-o, --out-path <out-path>', 'Output path for Markdown files; output filename for text and json formats')
|
|
18
|
+
.option('-a, --all-messages', 'Emit descriptions for all messages (text, json)')
|
|
19
|
+
.action(messageCommand);
|
|
20
|
+
}
|
|
21
|
+
async function messageCommand(messages, _options, commander) {
|
|
22
|
+
const commanderOptions = commander.optsWithGlobals();
|
|
23
|
+
const options = initialize(commanderOptions);
|
|
24
|
+
if (!options) {
|
|
25
|
+
await exitProcess(1);
|
|
26
|
+
}
|
|
27
|
+
const callbacks = new NodeCompilerCallbacks(options);
|
|
28
|
+
let result = false;
|
|
29
|
+
if (options.format == 'markdown') {
|
|
30
|
+
result = messageCommandMarkdown(messages, options, callbacks);
|
|
31
|
+
}
|
|
32
|
+
else { // json or text format
|
|
33
|
+
if (messages.length == 0 && !options.allMessages) {
|
|
34
|
+
console.error('Must specify at least one message code or -a for all messages');
|
|
35
|
+
callbacks.reportMessage(InfrastructureMessages.Error_MustSpecifyMessageCode());
|
|
36
|
+
await exitProcess(1);
|
|
37
|
+
}
|
|
38
|
+
const messageDetails = messages.length
|
|
39
|
+
? messages.map(message => translateMessageInputToCode(message, callbacks))
|
|
40
|
+
: allMessageDetails();
|
|
41
|
+
if (callbacks.messageCount > 0) {
|
|
42
|
+
await exitProcess(1);
|
|
43
|
+
}
|
|
44
|
+
let text = null;
|
|
45
|
+
if (options.format == 'json') {
|
|
46
|
+
const data = getMessagesAsArrayForJson(messageDetails);
|
|
47
|
+
if (data) {
|
|
48
|
+
text = JSON.stringify(data, null, 2);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
text = getMessagesAsText(messageDetails);
|
|
53
|
+
}
|
|
54
|
+
result = text != null;
|
|
55
|
+
if (result) {
|
|
56
|
+
if (options.outPath) {
|
|
57
|
+
fs.writeFileSync(options.outPath, text, 'utf-8');
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
process.stdout.write(text);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
if (!result) {
|
|
65
|
+
await exitProcess(1);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
// We have a redirect pattern for kmn.sh/km<#####> to
|
|
69
|
+
// the corresponding compiler message reference document in
|
|
70
|
+
// help.keyman.com/developer/latest-version/reference/errors/km<#####>
|
|
71
|
+
const helpUrl = (code) => KeymanUrls.COMPILER_ERROR_CODE(CompilerError.formatCode(code).toLowerCase());
|
|
72
|
+
const getModuleName = (ms) => `${ms.module}.${ms.class.name}`;
|
|
73
|
+
function translateMessageInputToCode(message, callbacks) {
|
|
74
|
+
const pattern = /^(KM)?([0-9a-f]+)$/i;
|
|
75
|
+
const result = message.match(pattern);
|
|
76
|
+
if (!result) {
|
|
77
|
+
callbacks.reportMessage(InfrastructureMessages.Error_UnrecognizedMessageCode({ message }));
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
80
|
+
const code = Number.parseInt(result[2], 16);
|
|
81
|
+
return findMessageDetails(code, callbacks);
|
|
82
|
+
}
|
|
83
|
+
function initialize(options) {
|
|
84
|
+
// We don't want to rename command line options to match the precise
|
|
85
|
+
// properties that we have in CompilerOptions, but nor do we want to rename
|
|
86
|
+
// CompilerOptions properties...
|
|
87
|
+
return {
|
|
88
|
+
// CompilerBaseOptions
|
|
89
|
+
logLevel: options.logLevel,
|
|
90
|
+
logFormat: options.logFormat,
|
|
91
|
+
color: options.color,
|
|
92
|
+
// MessageOptions
|
|
93
|
+
format: options.format ?? 'text',
|
|
94
|
+
outPath: options.outPath
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
const getMessageIdentifiersSorted = (cls) => Object.keys(cls)
|
|
98
|
+
.filter(id => typeof cls[id] == 'number')
|
|
99
|
+
.sort((a, b) => CompilerError.error(cls[a]) - CompilerError.error(cls[b]));
|
|
100
|
+
function allMessageDetails() {
|
|
101
|
+
let result = [];
|
|
102
|
+
messageNamespaceKeys.forEach((namespace) => {
|
|
103
|
+
const ms = messageSources[namespace];
|
|
104
|
+
const ids = getMessageIdentifiersSorted(ms.class);
|
|
105
|
+
for (const id of ids) {
|
|
106
|
+
const code = ms.class[id];
|
|
107
|
+
if (typeof code != 'number') {
|
|
108
|
+
continue;
|
|
109
|
+
}
|
|
110
|
+
result.push({
|
|
111
|
+
code,
|
|
112
|
+
id,
|
|
113
|
+
class: ms.class,
|
|
114
|
+
module: ms.module
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
return result;
|
|
119
|
+
}
|
|
120
|
+
const toTitleCase = (s) => s.substring(0, 1).toUpperCase() + s.substring(1).toLowerCase();
|
|
121
|
+
function getMessageDetail(cls, id, escapeMarkdown) {
|
|
122
|
+
const o = /^(INFO|HINT|WARN|ERROR|FATAL)_([A-Za-z0-9_]+)$/.exec(id);
|
|
123
|
+
if (!o) {
|
|
124
|
+
throw new Error(`Unexpected compiler message ${id}, does not match message error format`);
|
|
125
|
+
}
|
|
126
|
+
const f = toTitleCase(o[1]) + '_' + o[2];
|
|
127
|
+
const event = cls[f]?.({} /* ignore arguments*/);
|
|
128
|
+
if (!event) {
|
|
129
|
+
throw new Error(`Call to ${cls.name}.${f} returned null`);
|
|
130
|
+
}
|
|
131
|
+
event.detail = (event.detail ?? '').replace(/^[ ]+/gm, ''); // TODO(lowpri): dedent may be too naive?
|
|
132
|
+
event.message = event.message ?? '';
|
|
133
|
+
event.message = event?.exceptionVar
|
|
134
|
+
? 'This is an internal error; the message will vary'
|
|
135
|
+
: (escapeMarkdown ? `${escapeMarkdownChar(event.message, false)}` : event.message);
|
|
136
|
+
return event;
|
|
137
|
+
}
|
|
138
|
+
/*---------------------------------------------------------------------------
|
|
139
|
+
* Get messages in text format
|
|
140
|
+
*---------------------------------------------------------------------------*/
|
|
141
|
+
function getMessagesAsText(messages) {
|
|
142
|
+
const result = messages.reduce((prev, message) => {
|
|
143
|
+
return prev + '\n' + formatMessageAsText(getModuleName({ class: message.class, module: message.module }), message.class, message.code, message.id);
|
|
144
|
+
}, '');
|
|
145
|
+
return result;
|
|
146
|
+
}
|
|
147
|
+
function formatMessageAsText(moduleName, cls, code, id) {
|
|
148
|
+
const message = getMessageDetail(cls, id, false);
|
|
149
149
|
return `${id}
|
|
150
150
|
* Code: ${CompilerError.formatCode(code)}
|
|
151
151
|
* Module: ${moduleName}
|
|
@@ -153,74 +153,74 @@ function formatMessageAsText(moduleName, cls, code, id) {
|
|
|
153
153
|
* Reference: ${helpUrl(code)}
|
|
154
154
|
|
|
155
155
|
${message.detail}
|
|
156
|
-
`;
|
|
157
|
-
}
|
|
158
|
-
/*---------------------------------------------------------------------------
|
|
159
|
-
* Get messages as array of objects, for export to JSON
|
|
160
|
-
*---------------------------------------------------------------------------*/
|
|
161
|
-
function getMessagesAsArrayForJson(messages) {
|
|
162
|
-
return messages.map(message => ({
|
|
163
|
-
code: CompilerError.formatCode(message.code),
|
|
164
|
-
id: message.id,
|
|
165
|
-
class: message.class.name,
|
|
166
|
-
module: message.module,
|
|
167
|
-
detail: (() => getMessageDetail(message.class, message.id, false).detail)()
|
|
168
|
-
}));
|
|
169
|
-
}
|
|
170
|
-
/*---------------------------------------------------------------------------
|
|
171
|
-
* Export as Markdown
|
|
172
|
-
*---------------------------------------------------------------------------*/
|
|
173
|
-
function messageCommandMarkdown(messages, options, callbacks) {
|
|
174
|
-
if (messages.length) {
|
|
175
|
-
callbacks.reportMessage(InfrastructureMessages.Error_MessagesCannotBeFilteredForMarkdownFormat());
|
|
176
|
-
return false;
|
|
177
|
-
}
|
|
178
|
-
if (!options.outPath) {
|
|
179
|
-
callbacks.reportMessage(InfrastructureMessages.Error_OutputPathMustBeSpecifiedForMarkdownFormat());
|
|
180
|
-
return false;
|
|
181
|
-
}
|
|
182
|
-
if (!fs.existsSync(options.outPath) || !fs.statSync(options.outPath)?.isDirectory()) {
|
|
183
|
-
callbacks.reportMessage(InfrastructureMessages.Error_OutputPathMustExistAndBeADirectory({ outPath: options.outPath }));
|
|
184
|
-
return false;
|
|
185
|
-
}
|
|
186
|
-
exportAllMessagesAsMarkdown(options.outPath);
|
|
187
|
-
return true;
|
|
188
|
-
}
|
|
189
|
-
function exportAllMessagesAsMarkdown(outPath) {
|
|
156
|
+
`;
|
|
157
|
+
}
|
|
158
|
+
/*---------------------------------------------------------------------------
|
|
159
|
+
* Get messages as array of objects, for export to JSON
|
|
160
|
+
*---------------------------------------------------------------------------*/
|
|
161
|
+
function getMessagesAsArrayForJson(messages) {
|
|
162
|
+
return messages.map(message => ({
|
|
163
|
+
code: CompilerError.formatCode(message.code),
|
|
164
|
+
id: message.id,
|
|
165
|
+
class: message.class.name,
|
|
166
|
+
module: message.module,
|
|
167
|
+
detail: (() => getMessageDetail(message.class, message.id, false).detail)()
|
|
168
|
+
}));
|
|
169
|
+
}
|
|
170
|
+
/*---------------------------------------------------------------------------
|
|
171
|
+
* Export as Markdown
|
|
172
|
+
*---------------------------------------------------------------------------*/
|
|
173
|
+
function messageCommandMarkdown(messages, options, callbacks) {
|
|
174
|
+
if (messages.length) {
|
|
175
|
+
callbacks.reportMessage(InfrastructureMessages.Error_MessagesCannotBeFilteredForMarkdownFormat());
|
|
176
|
+
return false;
|
|
177
|
+
}
|
|
178
|
+
if (!options.outPath) {
|
|
179
|
+
callbacks.reportMessage(InfrastructureMessages.Error_OutputPathMustBeSpecifiedForMarkdownFormat());
|
|
180
|
+
return false;
|
|
181
|
+
}
|
|
182
|
+
if (!fs.existsSync(options.outPath) || !fs.statSync(options.outPath)?.isDirectory()) {
|
|
183
|
+
callbacks.reportMessage(InfrastructureMessages.Error_OutputPathMustExistAndBeADirectory({ outPath: options.outPath }));
|
|
184
|
+
return false;
|
|
185
|
+
}
|
|
186
|
+
exportAllMessagesAsMarkdown(options.outPath);
|
|
187
|
+
return true;
|
|
188
|
+
}
|
|
189
|
+
function exportAllMessagesAsMarkdown(outPath) {
|
|
190
190
|
let index = `---
|
|
191
191
|
title: Compiler Messages Reference
|
|
192
192
|
---
|
|
193
193
|
|
|
194
|
-
`;
|
|
195
|
-
messageNamespaceKeys.forEach((namespace) => {
|
|
196
|
-
const ms = messageSources[namespace];
|
|
197
|
-
const moduleName = getModuleName(ms);
|
|
198
|
-
index += `* [${moduleName}](${moduleName.toLowerCase()})\n`;
|
|
199
|
-
exportModuleMessagesAsMarkdown(moduleName, ms, outPath);
|
|
200
|
-
});
|
|
201
|
-
fs.writeFileSync(path.join(outPath, 'index.md'), index, 'utf-8');
|
|
202
|
-
}
|
|
203
|
-
function exportModuleMessagesAsMarkdown(moduleName, ms, outPath) {
|
|
204
|
-
const cls = ms.class;
|
|
194
|
+
`;
|
|
195
|
+
messageNamespaceKeys.forEach((namespace) => {
|
|
196
|
+
const ms = messageSources[namespace];
|
|
197
|
+
const moduleName = getModuleName(ms);
|
|
198
|
+
index += `* [${moduleName}](${moduleName.toLowerCase()})\n`;
|
|
199
|
+
exportModuleMessagesAsMarkdown(moduleName, ms, outPath);
|
|
200
|
+
});
|
|
201
|
+
fs.writeFileSync(path.join(outPath, 'index.md'), index, 'utf-8');
|
|
202
|
+
}
|
|
203
|
+
function exportModuleMessagesAsMarkdown(moduleName, ms, outPath) {
|
|
204
|
+
const cls = ms.class;
|
|
205
205
|
let index = `---
|
|
206
206
|
title: Compiler Messages Reference for @keymanapp/${ms.module}
|
|
207
207
|
---
|
|
208
208
|
|
|
209
209
|
Code | Identifier | Message
|
|
210
210
|
------|------------|---------
|
|
211
|
-
`;
|
|
212
|
-
const ids = getMessageIdentifiersSorted(cls);
|
|
213
|
-
for (const id of ids) {
|
|
214
|
-
const code = cls[id];
|
|
215
|
-
const filename = CompilerError.formatCode(code).toLowerCase();
|
|
216
|
-
const message = getMessageDetail(cls, id, true);
|
|
217
|
-
const content = formatMessageAsMarkdown(moduleName, id, message);
|
|
218
|
-
index += `[${CompilerError.formatCode(code)}](${filename}) | \`${id}\` | ${message.message}\n`;
|
|
219
|
-
fs.writeFileSync(path.join(outPath, filename + '.md'), content, 'utf-8');
|
|
220
|
-
}
|
|
221
|
-
fs.writeFileSync(path.join(outPath, moduleName.toLowerCase() + '.md'), index, 'utf-8');
|
|
222
|
-
}
|
|
223
|
-
function formatMessageAsMarkdown(moduleName, id, message) {
|
|
211
|
+
`;
|
|
212
|
+
const ids = getMessageIdentifiersSorted(cls);
|
|
213
|
+
for (const id of ids) {
|
|
214
|
+
const code = cls[id];
|
|
215
|
+
const filename = CompilerError.formatCode(code).toLowerCase();
|
|
216
|
+
const message = getMessageDetail(cls, id, true);
|
|
217
|
+
const content = formatMessageAsMarkdown(moduleName, id, message);
|
|
218
|
+
index += `[${CompilerError.formatCode(code)}](${filename}) | \`${id}\` | ${message.message}\n`;
|
|
219
|
+
fs.writeFileSync(path.join(outPath, filename + '.md'), content, 'utf-8');
|
|
220
|
+
}
|
|
221
|
+
fs.writeFileSync(path.join(outPath, moduleName.toLowerCase() + '.md'), index, 'utf-8');
|
|
222
|
+
}
|
|
223
|
+
function formatMessageAsMarkdown(moduleName, id, message) {
|
|
224
224
|
return `---
|
|
225
225
|
title: ${CompilerError.formatCode(message.code)}: ${id}
|
|
226
226
|
---
|
|
@@ -232,6 +232,6 @@ title: ${CompilerError.formatCode(message.code)}: ${id}
|
|
|
232
232
|
| Identifier | \`${id}\` |
|
|
233
233
|
|
|
234
234
|
${message.detail}
|
|
235
|
-
`;
|
|
236
|
-
}
|
|
235
|
+
`;
|
|
236
|
+
}
|
|
237
237
|
//# sourceMappingURL=messageCommand.js.map
|