@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.
Files changed (86) hide show
  1. package/build/src/commands/analyze.d.ts +22 -22
  2. package/build/src/commands/analyze.js +105 -105
  3. package/build/src/commands/analyze.js.map +1 -1
  4. package/build/src/commands/build.d.ts +12 -12
  5. package/build/src/commands/build.js +154 -154
  6. package/build/src/commands/build.js.map +1 -1
  7. package/build/src/commands/buildClasses/BuildActivity.d.ts +10 -10
  8. package/build/src/commands/buildClasses/BuildActivity.js +30 -30
  9. package/build/src/commands/buildClasses/BuildActivity.js.map +1 -1
  10. package/build/src/commands/buildClasses/BuildKeyboardInfo.d.ts +10 -10
  11. package/build/src/commands/buildClasses/BuildKeyboardInfo.js +46 -46
  12. package/build/src/commands/buildClasses/BuildKeyboardInfo.js.map +1 -1
  13. package/build/src/commands/buildClasses/BuildKmnKeyboard.d.ts +9 -9
  14. package/build/src/commands/buildClasses/BuildKmnKeyboard.js +34 -34
  15. package/build/src/commands/buildClasses/BuildKmnKeyboard.js.map +1 -1
  16. package/build/src/commands/buildClasses/BuildLdmlKeyboard.d.ts +9 -9
  17. package/build/src/commands/buildClasses/BuildLdmlKeyboard.js +18 -18
  18. package/build/src/commands/buildClasses/BuildModel.d.ts +9 -9
  19. package/build/src/commands/buildClasses/BuildModel.js +12 -12
  20. package/build/src/commands/buildClasses/BuildModelInfo.d.ts +20 -20
  21. package/build/src/commands/buildClasses/BuildModelInfo.js +72 -72
  22. package/build/src/commands/buildClasses/BuildModelInfo.js.map +1 -1
  23. package/build/src/commands/buildClasses/BuildPackage.d.ts +9 -9
  24. package/build/src/commands/buildClasses/BuildPackage.js +12 -12
  25. package/build/src/commands/buildClasses/BuildProject.d.ts +10 -10
  26. package/build/src/commands/buildClasses/BuildProject.js +115 -115
  27. package/build/src/commands/buildClasses/BuildProject.js.map +1 -1
  28. package/build/src/commands/buildClasses/buildActivities.d.ts +6 -6
  29. package/build/src/commands/buildClasses/buildActivities.js +20 -20
  30. package/build/src/commands/buildTestData/index.d.ts +1 -1
  31. package/build/src/commands/buildTestData/index.js +38 -38
  32. package/build/src/commands/buildTestData/index.js.map +1 -1
  33. package/build/src/commands/buildWindowsPackageInstaller/index.d.ts +1 -1
  34. package/build/src/commands/buildWindowsPackageInstaller/index.js +42 -42
  35. package/build/src/commands/buildWindowsPackageInstaller/index.js.map +1 -1
  36. package/build/src/commands/messageCommand.d.ts +2 -2
  37. package/build/src/commands/messageCommand.js +208 -208
  38. package/build/src/commands/messageCommand.js.map +1 -1
  39. package/build/src/kmc.d.ts +5 -5
  40. package/build/src/kmc.js +56 -56
  41. package/build/src/kmc.js.map +1 -1
  42. package/build/src/kmlmc.d.ts +5 -5
  43. package/build/src/kmlmc.js +56 -56
  44. package/build/src/kmlmc.js.map +1 -1
  45. package/build/src/kmlmp.d.ts +5 -5
  46. package/build/src/kmlmp.js +45 -45
  47. package/build/src/kmlmp.js.map +1 -1
  48. package/build/src/messages/infrastructureMessages.d.ts +151 -151
  49. package/build/src/messages/infrastructureMessages.js +74 -74
  50. package/build/src/messages/messageNamespaces.d.ts +7 -7
  51. package/build/src/messages/messageNamespaces.js +38 -38
  52. package/build/src/util/NodeCompilerCallbacks.d.ts +43 -43
  53. package/build/src/util/NodeCompilerCallbacks.js +220 -220
  54. package/build/src/util/NodeCompilerCallbacks.js.map +1 -1
  55. package/build/src/util/TestKeymanSentry.d.ts +6 -6
  56. package/build/src/util/TestKeymanSentry.js +50 -50
  57. package/build/src/util/TestKeymanSentry.js.map +1 -1
  58. package/build/src/util/baseOptions.d.ts +20 -20
  59. package/build/src/util/baseOptions.js +23 -23
  60. package/build/src/util/calculateSourcePath.d.ts +10 -10
  61. package/build/src/util/calculateSourcePath.js +17 -17
  62. package/build/src/util/calculateSourcePath.js.map +1 -1
  63. package/build/src/util/extendedCompilerOptions.d.ts +56 -56
  64. package/build/src/util/extendedCompilerOptions.js +122 -122
  65. package/build/src/util/extendedCompilerOptions.js.map +1 -1
  66. package/build/src/util/fileLists.d.ts +15 -15
  67. package/build/src/util/fileLists.js +45 -45
  68. package/build/src/util/fileLists.js.map +1 -1
  69. package/build/src/util/getDeveloperBinPath.d.ts +8 -8
  70. package/build/src/util/getDeveloperBinPath.js +35 -35
  71. package/build/src/util/getDeveloperBinPath.js.map +1 -1
  72. package/build/src/util/getLastGitCommitDate.d.ts +7 -7
  73. package/build/src/util/getLastGitCommitDate.js +43 -43
  74. package/build/src/util/getLastGitCommitDate.js.map +1 -1
  75. package/build/src/util/kmcSentryOptions.d.ts +7 -7
  76. package/build/src/util/kmcSentryOptions.js +19 -19
  77. package/build/src/util/kmcSentryOptions.js.map +1 -1
  78. package/build/src/util/projectLoader.d.ts +3 -3
  79. package/build/src/util/projectLoader.js +50 -50
  80. package/build/src/util/projectLoader.js.map +1 -1
  81. package/build/src/util/projectRunner.d.ts +2 -2
  82. package/build/src/util/projectRunner.js +26 -26
  83. package/build/src/util/projectRunner.js.map +1 -1
  84. package/build/src/util/sysexits.d.ts +9 -9
  85. package/build/src/util/sysexits.js +6 -6
  86. package/package.json +12 -12
@@ -1,23 +1,23 @@
1
- import { Command } from 'commander';
2
- import { CompilerCallbacks, CompilerLogLevel } from '@keymanapp/common-types';
3
- interface AnalysisActivityOptions {
4
- /**
5
- * Reporting level to console, used by NodeCompilerCallbacks (not used in compiler modules;
6
- * all messages are still reported to the internal log)
7
- */
8
- logLevel?: CompilerLogLevel;
9
- base?: string;
10
- stripDottedCircle?: boolean;
11
- includeCounts?: boolean;
12
- mappingFile?: string;
13
- }
14
- export declare function declareAnalyze(program: Command): void;
15
- declare function analyzeOskCharUse(callbacks: CompilerCallbacks, filenames: string[], options: AnalysisActivityOptions): Promise<boolean>;
16
- /**
17
- * these are exported only for unit tests, do not use
18
- */
19
- export declare const analyzeUnitTestEndpoints: {
20
- analyzeOskCharUse: typeof analyzeOskCharUse;
21
- };
22
- export {};
1
+ import { Command } from 'commander';
2
+ import { CompilerCallbacks, CompilerLogLevel } from '@keymanapp/common-types';
3
+ interface AnalysisActivityOptions {
4
+ /**
5
+ * Reporting level to console, used by NodeCompilerCallbacks (not used in compiler modules;
6
+ * all messages are still reported to the internal log)
7
+ */
8
+ logLevel?: CompilerLogLevel;
9
+ base?: string;
10
+ stripDottedCircle?: boolean;
11
+ includeCounts?: boolean;
12
+ mappingFile?: string;
13
+ }
14
+ export declare function declareAnalyze(program: Command): void;
15
+ declare function analyzeOskCharUse(callbacks: CompilerCallbacks, filenames: string[], options: AnalysisActivityOptions): Promise<boolean>;
16
+ /**
17
+ * these are exported only for unit tests, do not use
18
+ */
19
+ export declare const analyzeUnitTestEndpoints: {
20
+ analyzeOskCharUse: typeof analyzeOskCharUse;
21
+ };
22
+ export {};
23
23
  //# sourceMappingURL=analyze.d.ts.map
@@ -1,106 +1,106 @@
1
- import * as fs from 'fs';
2
- import * as path from 'path';
3
- import { Option } from 'commander';
4
- import { NodeCompilerCallbacks } from '../util/NodeCompilerCallbacks.js';
5
- import { InfrastructureMessages } from '../messages/infrastructureMessages.js';
6
- import { AnalyzeOskCharacterUse, AnalyzeOskRewritePua } from '@keymanapp/kmc-analyze';
7
- import { BaseOptions } from '../util/baseOptions.js';
8
- import { runOnFiles } from '../util/projectRunner.js';
9
- import { exitProcess } from '../util/sysexits.js';
10
- ;
11
- export function declareAnalyze(program) {
12
- let command = program.command('analyze');
13
- declareOskCharUse(command);
14
- declareOskRewrite(command);
15
- }
16
- function declareOskCharUse(command) {
17
- let subCommand = command.command('osk-char-use [infile...]');
18
- BaseOptions.addLogLevel(subCommand);
19
- subCommand
20
- .description('Analyze On Screen Keyboards for character usage')
21
- .option('-b, --base', 'First PUA codepoint to use, in hexadecimal (default F100)', 'F100')
22
- .option('--include-counts', 'Include number of times each character is referenced', false)
23
- .option('--strip-dotted-circle', 'Strip U+25CC (dotted circle base) from results', false)
24
- .addOption(new Option('-m, --mapping-file <filename>', 'Result file to write to (.json, .md, or .txt)').makeOptionMandatory())
25
- .action(async (filenames, _options, commander) => {
26
- const options = commander.optsWithGlobals();
27
- if (!filenames.length) {
28
- // If there are no filenames provided, then we are building the current
29
- // folder ('.') as a project-style build
30
- filenames.push('.');
31
- }
32
- if (!await analyze(analyzeOskCharUse, filenames, options)) {
33
- // Once a file fails to build, we bail on subsequent builds
34
- return await exitProcess(1);
35
- }
36
- });
37
- }
38
- function declareOskRewrite(command) {
39
- let subCommand = command.command('osk-rewrite-from-char-use [infile...]');
40
- subCommand
41
- .description('Rewrite On Screen Keyboard files from source mapping; given file.ext, output is written to file-pua.ext')
42
- .addOption(new Option('-m, --mapping-file <filename>', 'JSON mapping file to read from').makeOptionMandatory())
43
- .action(async (filenames, options) => {
44
- if (!filenames.length) {
45
- // If there are no filenames provided, then we are building the current
46
- // folder ('.') as a project-style build
47
- filenames.push('.');
48
- }
49
- if (!await analyze(analyzeOskRewritePua, filenames, options)) {
50
- // Once a file fails to build, we bail on subsequent builds
51
- return await exitProcess(1);
52
- }
53
- return null;
54
- });
55
- }
56
- async function analyze(action, filenames, options) {
57
- let callbacks = new NodeCompilerCallbacks({ logLevel: options.logLevel });
58
- try {
59
- return await action(callbacks, filenames, options);
60
- }
61
- catch (e) {
62
- callbacks.reportMessage(InfrastructureMessages.Fatal_UnexpectedException({ e }));
63
- return false;
64
- }
65
- }
66
- async function analyzeOskCharUse(callbacks, filenames, options) {
67
- const format = path.extname(options.mappingFile);
68
- if (format != '.txt' && format != '.json' && format != '.md') {
69
- callbacks.reportMessage(InfrastructureMessages.Error_UnknownFileFormat({ format }));
70
- return false;
71
- }
72
- const analyzer = new AnalyzeOskCharacterUse(callbacks, {
73
- puaBase: parseInt(options.base, 16),
74
- stripDottedCircle: options.stripDottedCircle,
75
- includeCounts: options.includeCounts,
76
- });
77
- if (!await runOnFiles(callbacks, filenames, analyzer.analyze.bind(analyzer))) {
78
- return false;
79
- }
80
- const output = analyzer.getStrings(format).join('\n');
81
- fs.writeFileSync(options.mappingFile, output, 'utf8');
82
- return true;
83
- }
84
- async function analyzeOskRewritePua(callbacks, filenames, options) {
85
- const analyzer = new AnalyzeOskRewritePua(callbacks);
86
- const mapping = JSON.parse(fs.readFileSync(options.mappingFile, 'utf-8'));
87
- return await runOnFiles(callbacks, filenames, async (filename) => {
88
- if (!await analyzer.analyze(filename, mapping)) {
89
- return false;
90
- }
91
- const mappedFilenames = Object.keys(analyzer.data);
92
- for (let filename of mappedFilenames) {
93
- const ext = path.extname(filename);
94
- const outputFilename = filename.substring(0, filename.length - ext.length) + '-pua' + ext;
95
- fs.writeFileSync(outputFilename, analyzer.data[filename]);
96
- }
97
- return true;
98
- });
99
- }
100
- /**
101
- * these are exported only for unit tests, do not use
102
- */
103
- export const analyzeUnitTestEndpoints = {
104
- analyzeOskCharUse
105
- };
1
+ import * as fs from 'fs';
2
+ import * as path from 'path';
3
+ import { Option } from 'commander';
4
+ import { NodeCompilerCallbacks } from '../util/NodeCompilerCallbacks.js';
5
+ import { InfrastructureMessages } from '../messages/infrastructureMessages.js';
6
+ import { AnalyzeOskCharacterUse, AnalyzeOskRewritePua } from '@keymanapp/kmc-analyze';
7
+ import { BaseOptions } from '../util/baseOptions.js';
8
+ import { runOnFiles } from '../util/projectRunner.js';
9
+ import { exitProcess } from '../util/sysexits.js';
10
+ ;
11
+ export function declareAnalyze(program) {
12
+ let command = program.command('analyze');
13
+ declareOskCharUse(command);
14
+ declareOskRewrite(command);
15
+ }
16
+ function declareOskCharUse(command) {
17
+ let subCommand = command.command('osk-char-use [infile...]');
18
+ BaseOptions.addLogLevel(subCommand);
19
+ subCommand
20
+ .description('Analyze On Screen Keyboards for character usage')
21
+ .option('-b, --base', 'First PUA codepoint to use, in hexadecimal (default F100)', 'F100')
22
+ .option('--include-counts', 'Include number of times each character is referenced', false)
23
+ .option('--strip-dotted-circle', 'Strip U+25CC (dotted circle base) from results', false)
24
+ .addOption(new Option('-m, --mapping-file <filename>', 'Result file to write to (.json, .md, or .txt)').makeOptionMandatory())
25
+ .action(async (filenames, _options, commander) => {
26
+ const options = commander.optsWithGlobals();
27
+ if (!filenames.length) {
28
+ // If there are no filenames provided, then we are building the current
29
+ // folder ('.') as a project-style build
30
+ filenames.push('.');
31
+ }
32
+ if (!await analyze(analyzeOskCharUse, filenames, options)) {
33
+ // Once a file fails to build, we bail on subsequent builds
34
+ return await exitProcess(1);
35
+ }
36
+ });
37
+ }
38
+ function declareOskRewrite(command) {
39
+ let subCommand = command.command('osk-rewrite-from-char-use [infile...]');
40
+ subCommand
41
+ .description('Rewrite On Screen Keyboard files from source mapping; given file.ext, output is written to file-pua.ext')
42
+ .addOption(new Option('-m, --mapping-file <filename>', 'JSON mapping file to read from').makeOptionMandatory())
43
+ .action(async (filenames, options) => {
44
+ if (!filenames.length) {
45
+ // If there are no filenames provided, then we are building the current
46
+ // folder ('.') as a project-style build
47
+ filenames.push('.');
48
+ }
49
+ if (!await analyze(analyzeOskRewritePua, filenames, options)) {
50
+ // Once a file fails to build, we bail on subsequent builds
51
+ return await exitProcess(1);
52
+ }
53
+ return null;
54
+ });
55
+ }
56
+ async function analyze(action, filenames, options) {
57
+ let callbacks = new NodeCompilerCallbacks({ logLevel: options.logLevel });
58
+ try {
59
+ return await action(callbacks, filenames, options);
60
+ }
61
+ catch (e) {
62
+ callbacks.reportMessage(InfrastructureMessages.Fatal_UnexpectedException({ e }));
63
+ return false;
64
+ }
65
+ }
66
+ async function analyzeOskCharUse(callbacks, filenames, options) {
67
+ const format = path.extname(options.mappingFile);
68
+ if (format != '.txt' && format != '.json' && format != '.md') {
69
+ callbacks.reportMessage(InfrastructureMessages.Error_UnknownFileFormat({ format }));
70
+ return false;
71
+ }
72
+ const analyzer = new AnalyzeOskCharacterUse(callbacks, {
73
+ puaBase: parseInt(options.base, 16),
74
+ stripDottedCircle: options.stripDottedCircle,
75
+ includeCounts: options.includeCounts,
76
+ });
77
+ if (!await runOnFiles(callbacks, filenames, analyzer.analyze.bind(analyzer))) {
78
+ return false;
79
+ }
80
+ const output = analyzer.getStrings(format).join('\n');
81
+ fs.writeFileSync(options.mappingFile, output, 'utf8');
82
+ return true;
83
+ }
84
+ async function analyzeOskRewritePua(callbacks, filenames, options) {
85
+ const analyzer = new AnalyzeOskRewritePua(callbacks);
86
+ const mapping = JSON.parse(fs.readFileSync(options.mappingFile, 'utf-8'));
87
+ return await runOnFiles(callbacks, filenames, async (filename) => {
88
+ if (!await analyzer.analyze(filename, mapping)) {
89
+ return false;
90
+ }
91
+ const mappedFilenames = Object.keys(analyzer.data);
92
+ for (let filename of mappedFilenames) {
93
+ const ext = path.extname(filename);
94
+ const outputFilename = filename.substring(0, filename.length - ext.length) + '-pua' + ext;
95
+ fs.writeFileSync(outputFilename, analyzer.data[filename]);
96
+ }
97
+ return true;
98
+ });
99
+ }
100
+ /**
101
+ * these are exported only for unit tests, do not use
102
+ */
103
+ export const analyzeUnitTestEndpoints = {
104
+ analyzeOskCharUse
105
+ };
106
106
  //# sourceMappingURL=analyze.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"analyze.js","sourceRoot":"","sources":["../../../src/commands/analyze.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAW,MAAM,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAC;AACzE,OAAO,EAAE,sBAAsB,EAAE,MAAM,uCAAuC,CAAC;AAE/E,OAAO,EAAE,sBAAsB,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AACtF,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAYjD,CAAC;AAEF,MAAM,UAAU,cAAc,CAAC,OAAgB;IAC7C,IAAI,OAAO,GAA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AAC,QAAQ,CAAC,CAAC,CAAC;QAC5D,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC,CAAC,CAAC;AACL,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG;IACtC,iBAAiB;CAClB,CAAC"}
@@ -1,13 +1,13 @@
1
- import { Command } from 'commander';
2
- import { NodeCompilerCallbacks } from '../util/NodeCompilerCallbacks.js';
3
- import { CompilerOptions } from '@keymanapp/common-types';
4
- export declare function declareBuild(program: Command): void;
5
- declare function build(filename: string, outfile: string, parentCallbacks: NodeCompilerCallbacks, options: CompilerOptions): Promise<boolean>;
6
- /**
7
- * these are exported only for unit tests, do not use
8
- */
9
- export declare const unitTestEndpoints: {
10
- build: typeof build;
11
- };
12
- export {};
1
+ import { Command } from 'commander';
2
+ import { NodeCompilerCallbacks } from '../util/NodeCompilerCallbacks.js';
3
+ import { CompilerOptions } from '@keymanapp/common-types';
4
+ export declare function declareBuild(program: Command): void;
5
+ declare function build(filename: string, outfile: string, parentCallbacks: NodeCompilerCallbacks, options: CompilerOptions): Promise<boolean>;
6
+ /**
7
+ * these are exported only for unit tests, do not use
8
+ */
9
+ export declare const unitTestEndpoints: {
10
+ build: typeof build;
11
+ };
12
+ export {};
13
13
  //# sourceMappingURL=build.d.ts.map
@@ -1,35 +1,35 @@
1
- import * as fs from 'fs';
2
- import * as path from 'path';
3
- import { buildActivities } from './buildClasses/buildActivities.js';
4
- import { BuildProject } from './buildClasses/BuildProject.js';
5
- import { NodeCompilerCallbacks } from '../util/NodeCompilerCallbacks.js';
6
- import { InfrastructureMessages } from '../messages/infrastructureMessages.js';
7
- import { CompilerFileCallbacks } from '@keymanapp/common-types';
8
- import { BaseOptions } from '../util/baseOptions.js';
9
- import { expandFileLists } from '../util/fileLists.js';
10
- import { isProject } from '../util/projectLoader.js';
11
- import { buildTestData } from './buildTestData/index.js';
12
- import { buildWindowsPackageInstaller } from './buildWindowsPackageInstaller/index.js';
13
- import { commandOptionsToCompilerOptions } from '../util/extendedCompilerOptions.js';
14
- import { exitProcess } from '../util/sysexits.js';
15
- export function declareBuild(program) {
16
- // TODO: localization?
17
- const buildCommand = program
18
- .command('build')
19
- .option('--color', 'Force colorization for log messages')
20
- .option('--no-color', 'No colorization for log messages; if both omitted, detects from console')
21
- // These options are only used with build file but are included here so that
22
- // they are visible in `kmc build --help`
23
- .option('-d, --debug', 'Include debug information in output')
24
- .option('-w, --compiler-warnings-as-errors', 'Causes warnings to fail the build; overrides project-level warnings-as-errors option')
25
- .option('-W, --no-compiler-warnings-as-errors', 'Warnings do not fail the build; overrides project-level warnings-as-errors option')
26
- .option('-m, --message <number>', 'Adjust severity of info, hint or warning message to Disable (default), Info, Hint, Warn or Error (option can be repeated)', (value, previous) => previous.concat([value]), [])
27
- .option('--no-compiler-version', 'Exclude compiler version metadata from output')
28
- .option('--no-warn-deprecated-code', 'Turn off warnings for deprecated code styles');
29
- BaseOptions.addAll(buildCommand);
30
- buildCommand.command('file [infile...]', { isDefault: true })
31
- .description(`Compile one or more source files or projects ('file' subcommand is default).`)
32
- .option('--for-publishing', 'Verify that project meets @keymanapp repository requirements')
1
+ import * as fs from 'fs';
2
+ import * as path from 'path';
3
+ import { buildActivities } from './buildClasses/buildActivities.js';
4
+ import { BuildProject } from './buildClasses/BuildProject.js';
5
+ import { NodeCompilerCallbacks } from '../util/NodeCompilerCallbacks.js';
6
+ import { InfrastructureMessages } from '../messages/infrastructureMessages.js';
7
+ import { CompilerFileCallbacks } from '@keymanapp/common-types';
8
+ import { BaseOptions } from '../util/baseOptions.js';
9
+ import { expandFileLists } from '../util/fileLists.js';
10
+ import { isProject } from '../util/projectLoader.js';
11
+ import { buildTestData } from './buildTestData/index.js';
12
+ import { buildWindowsPackageInstaller } from './buildWindowsPackageInstaller/index.js';
13
+ import { commandOptionsToCompilerOptions } from '../util/extendedCompilerOptions.js';
14
+ import { exitProcess } from '../util/sysexits.js';
15
+ export function declareBuild(program) {
16
+ // TODO: localization?
17
+ const buildCommand = program
18
+ .command('build')
19
+ .option('--color', 'Force colorization for log messages')
20
+ .option('--no-color', 'No colorization for log messages; if both omitted, detects from console')
21
+ // These options are only used with build file but are included here so that
22
+ // they are visible in `kmc build --help`
23
+ .option('-d, --debug', 'Include debug information in output')
24
+ .option('-w, --compiler-warnings-as-errors', 'Causes warnings to fail the build; overrides project-level warnings-as-errors option')
25
+ .option('-W, --no-compiler-warnings-as-errors', 'Warnings do not fail the build; overrides project-level warnings-as-errors option')
26
+ .option('-m, --message <number>', 'Adjust severity of info, hint or warning message to Disable (default), Info, Hint, Warn or Error (option can be repeated)', (value, previous) => previous.concat([value]), [])
27
+ .option('--no-compiler-version', 'Exclude compiler version metadata from output')
28
+ .option('--no-warn-deprecated-code', 'Turn off warnings for deprecated code styles');
29
+ BaseOptions.addAll(buildCommand);
30
+ buildCommand.command('file [infile...]', { isDefault: true })
31
+ .description(`Compile one or more source files or projects ('file' subcommand is default).`)
32
+ .option('--for-publishing', 'Verify that project meets @keymanapp repository requirements')
33
33
  .addHelpText('after', `
34
34
  Supported file types:
35
35
  * folder: Keyman project in folder
@@ -41,126 +41,126 @@ Supported file types:
41
41
 
42
42
  File lists can be referenced with @filelist.txt.
43
43
 
44
- If no input file is supplied, kmc will build the current folder.`)
45
- .action(buildFile);
46
- buildCommand
47
- .command('ldml-test-data <infile>')
48
- .description('Convert LDML keyboard test .xml to .json')
49
- .action(buildTestData);
50
- buildCommand
51
- .command('windows-package-installer <infile>')
52
- .description('Build an executable installer for Windows for a Keyman package')
53
- .option('--msi <msiFilename>', 'Location of keymandesktop.msi')
54
- .option('--exe <exeFilename>', 'Location of setup.exe')
55
- .option('--license <licenseFilename>', 'Location of license.txt')
56
- .option('--title-image [titleImageFilename]', 'Location of title image')
57
- .option('--app-name [applicationName]', 'Installer property: name of the application to be installed', 'Keyman')
58
- .option('--start-disabled', 'Installer property: do not enable keyboards after installation completes')
59
- .option('--start-with-configuration', 'Installer property: start Keyman Configuration after installation completes')
60
- .action(buildWindowsPackageInstaller);
61
- }
62
- function initialize(commanderOptions) {
63
- // We use a default callback instance when validating command line, but throw
64
- // it away once we have completed initialization
65
- const initializationCallbacks = new NodeCompilerCallbacks({});
66
- const options = commandOptionsToCompilerOptions(commanderOptions, initializationCallbacks);
67
- return options;
68
- }
69
- async function buildFile(filenames, _options, commander) {
70
- const commanderOptions /*:{TODO?} CommandLineCompilerOptions*/ = commander.optsWithGlobals();
71
- const options = initialize(commanderOptions);
72
- if (!options) {
73
- return await exitProcess(1);
74
- }
75
- const callbacks = new NodeCompilerCallbacks(options);
76
- if (!filenames.length) {
77
- // If there are no filenames provided, then we are building the current
78
- // folder ('.') as a project-style build
79
- filenames.push('.');
80
- }
81
- /* c8 ignore next 6 */
82
- // full test on console log of error message not justified; check with user test recommended
83
- if (filenames.length > 1 && commanderOptions.outFile) {
84
- // -o can only be specified with a single input file
85
- callbacks.reportMessage(InfrastructureMessages.Error_OutFileCanOnlyBeSpecifiedWithSingleInfile());
86
- return await exitProcess(1);
87
- }
88
- if (!expandFileLists(filenames, callbacks)) {
89
- return await exitProcess(1);
90
- }
91
- for (let filename of filenames) {
92
- if (!await build(filename, commanderOptions.outFile, callbacks, options)) {
93
- // Once a file fails to build, we bail on subsequent builds
94
- return await exitProcess(1);
95
- }
96
- }
97
- }
98
- async function build(filename, outfile, parentCallbacks, options) {
99
- try {
100
- // TEST: allow command-line simulation of infrastructure fatal errors, and
101
- // also for unit tests
102
- if (process.env.SENTRY_CLIENT_TEST_BUILD_EXCEPTION == '1') {
103
- throw new Error('Test exception from SENTRY_CLIENT_TEST_BUILD_EXCEPTION');
104
- }
105
- if (!fs.existsSync(filename)) {
106
- parentCallbacks.reportMessage(InfrastructureMessages.Error_FileDoesNotExist({ filename }));
107
- return false;
108
- }
109
- // Normalize case for the filename and expand the path; this avoids false
110
- // positive case mismatches on input filenames and glommed paths
111
- filename = fs.realpathSync.native(filename);
112
- let builder = null;
113
- // If infile is a directory, then we treat that as a project and build it
114
- if (isProject(filename)) {
115
- builder = new BuildProject();
116
- }
117
- else {
118
- // Otherwise, if it's one of our known file extensions, we build it
119
- let extensions = [];
120
- builder = buildActivities.find(build => {
121
- extensions.push(build.sourceExtension);
122
- return filename.toLowerCase().endsWith(build.sourceExtension);
123
- });
124
- if (!builder) {
125
- parentCallbacks.reportMessage(InfrastructureMessages.Error_FileTypeNotRecognized({ filename, extensions: extensions.join(', ') }));
126
- return false;
127
- }
128
- }
129
- // For builds which refer to a project folder, we'll imply a build of the
130
- // .kpj, even if it doesn't actually exist, just for clarity.
131
- let buildFilename = path.resolve(filename);
132
- if (fs.statSync(filename).isDirectory()) {
133
- buildFilename = path.join(buildFilename, path.basename(buildFilename) + ".kpj" /* KeymanFileTypes.Source.Project */);
134
- }
135
- const relativeFilename = path.relative(process.cwd(), buildFilename).replace(/\\/g, '/');
136
- const callbacks = new CompilerFileCallbacks(buildFilename, options, parentCallbacks);
137
- callbacks.reportMessage(InfrastructureMessages.Info_BuildingFile({ filename: buildFilename, relativeFilename }));
138
- let result = await builder.build(filename, outfile, callbacks, options);
139
- result = result && !callbacks.hasFailureMessage();
140
- if (result) {
141
- callbacks.reportMessage(builder instanceof BuildProject
142
- ? InfrastructureMessages.Info_ProjectBuiltSuccessfully({ filename: buildFilename, relativeFilename })
143
- : InfrastructureMessages.Info_FileBuiltSuccessfully({ filename: buildFilename, relativeFilename }));
144
- }
145
- else {
146
- if (!callbacks.hasFailureMessage(false)) { // false == check only for error+fatal messages
147
- callbacks.reportMessage(InfrastructureMessages.Info_WarningsHaveFailedBuild());
148
- }
149
- callbacks.reportMessage(builder instanceof BuildProject
150
- ? InfrastructureMessages.Info_ProjectNotBuiltSuccessfully({ filename: buildFilename, relativeFilename })
151
- : InfrastructureMessages.Info_FileNotBuiltSuccessfully({ filename: buildFilename, relativeFilename }));
152
- }
153
- return result;
154
- }
155
- catch (e) {
156
- parentCallbacks.reportMessage(InfrastructureMessages.Fatal_UnexpectedException({ e }));
157
- return false;
158
- }
159
- }
160
- /**
161
- * these are exported only for unit tests, do not use
162
- */
163
- export const unitTestEndpoints = {
164
- build,
165
- };
44
+ If no input file is supplied, kmc will build the current folder.`)
45
+ .action(buildFile);
46
+ buildCommand
47
+ .command('ldml-test-data <infile>')
48
+ .description('Convert LDML keyboard test .xml to .json')
49
+ .action(buildTestData);
50
+ buildCommand
51
+ .command('windows-package-installer <infile>')
52
+ .description('Build an executable installer for Windows for a Keyman package')
53
+ .option('--msi <msiFilename>', 'Location of keymandesktop.msi')
54
+ .option('--exe <exeFilename>', 'Location of setup.exe')
55
+ .option('--license <licenseFilename>', 'Location of license.txt')
56
+ .option('--title-image [titleImageFilename]', 'Location of title image')
57
+ .option('--app-name [applicationName]', 'Installer property: name of the application to be installed', 'Keyman')
58
+ .option('--start-disabled', 'Installer property: do not enable keyboards after installation completes')
59
+ .option('--start-with-configuration', 'Installer property: start Keyman Configuration after installation completes')
60
+ .action(buildWindowsPackageInstaller);
61
+ }
62
+ function initialize(commanderOptions) {
63
+ // We use a default callback instance when validating command line, but throw
64
+ // it away once we have completed initialization
65
+ const initializationCallbacks = new NodeCompilerCallbacks({});
66
+ const options = commandOptionsToCompilerOptions(commanderOptions, initializationCallbacks);
67
+ return options;
68
+ }
69
+ async function buildFile(filenames, _options, commander) {
70
+ const commanderOptions /*:{TODO?} CommandLineCompilerOptions*/ = commander.optsWithGlobals();
71
+ const options = initialize(commanderOptions);
72
+ if (!options) {
73
+ return await exitProcess(1);
74
+ }
75
+ const callbacks = new NodeCompilerCallbacks(options);
76
+ if (!filenames.length) {
77
+ // If there are no filenames provided, then we are building the current
78
+ // folder ('.') as a project-style build
79
+ filenames.push('.');
80
+ }
81
+ /* c8 ignore next 6 */
82
+ // full test on console log of error message not justified; check with user test recommended
83
+ if (filenames.length > 1 && commanderOptions.outFile) {
84
+ // -o can only be specified with a single input file
85
+ callbacks.reportMessage(InfrastructureMessages.Error_OutFileCanOnlyBeSpecifiedWithSingleInfile());
86
+ return await exitProcess(1);
87
+ }
88
+ if (!expandFileLists(filenames, callbacks)) {
89
+ return await exitProcess(1);
90
+ }
91
+ for (let filename of filenames) {
92
+ if (!await build(filename, commanderOptions.outFile, callbacks, options)) {
93
+ // Once a file fails to build, we bail on subsequent builds
94
+ return await exitProcess(1);
95
+ }
96
+ }
97
+ }
98
+ async function build(filename, outfile, parentCallbacks, options) {
99
+ try {
100
+ // TEST: allow command-line simulation of infrastructure fatal errors, and
101
+ // also for unit tests
102
+ if (process.env.SENTRY_CLIENT_TEST_BUILD_EXCEPTION == '1') {
103
+ throw new Error('Test exception from SENTRY_CLIENT_TEST_BUILD_EXCEPTION');
104
+ }
105
+ if (!fs.existsSync(filename)) {
106
+ parentCallbacks.reportMessage(InfrastructureMessages.Error_FileDoesNotExist({ filename }));
107
+ return false;
108
+ }
109
+ // Normalize case for the filename and expand the path; this avoids false
110
+ // positive case mismatches on input filenames and glommed paths
111
+ filename = fs.realpathSync.native(filename);
112
+ let builder = null;
113
+ // If infile is a directory, then we treat that as a project and build it
114
+ if (isProject(filename)) {
115
+ builder = new BuildProject();
116
+ }
117
+ else {
118
+ // Otherwise, if it's one of our known file extensions, we build it
119
+ let extensions = [];
120
+ builder = buildActivities.find(build => {
121
+ extensions.push(build.sourceExtension);
122
+ return filename.toLowerCase().endsWith(build.sourceExtension);
123
+ });
124
+ if (!builder) {
125
+ parentCallbacks.reportMessage(InfrastructureMessages.Error_FileTypeNotRecognized({ filename, extensions: extensions.join(', ') }));
126
+ return false;
127
+ }
128
+ }
129
+ // For builds which refer to a project folder, we'll imply a build of the
130
+ // .kpj, even if it doesn't actually exist, just for clarity.
131
+ let buildFilename = path.resolve(filename);
132
+ if (fs.statSync(filename).isDirectory()) {
133
+ buildFilename = path.join(buildFilename, path.basename(buildFilename) + ".kpj" /* KeymanFileTypes.Source.Project */);
134
+ }
135
+ const relativeFilename = path.relative(process.cwd(), buildFilename).replace(/\\/g, '/');
136
+ const callbacks = new CompilerFileCallbacks(buildFilename, options, parentCallbacks);
137
+ callbacks.reportMessage(InfrastructureMessages.Info_BuildingFile({ filename: buildFilename, relativeFilename }));
138
+ let result = await builder.build(filename, outfile, callbacks, options);
139
+ result = result && !callbacks.hasFailureMessage();
140
+ if (result) {
141
+ callbacks.reportMessage(builder instanceof BuildProject
142
+ ? InfrastructureMessages.Info_ProjectBuiltSuccessfully({ filename: buildFilename, relativeFilename })
143
+ : InfrastructureMessages.Info_FileBuiltSuccessfully({ filename: buildFilename, relativeFilename }));
144
+ }
145
+ else {
146
+ if (!callbacks.hasFailureMessage(false)) { // false == check only for error+fatal messages
147
+ callbacks.reportMessage(InfrastructureMessages.Info_WarningsHaveFailedBuild());
148
+ }
149
+ callbacks.reportMessage(builder instanceof BuildProject
150
+ ? InfrastructureMessages.Info_ProjectNotBuiltSuccessfully({ filename: buildFilename, relativeFilename })
151
+ : InfrastructureMessages.Info_FileNotBuiltSuccessfully({ filename: buildFilename, relativeFilename }));
152
+ }
153
+ return result;
154
+ }
155
+ catch (e) {
156
+ parentCallbacks.reportMessage(InfrastructureMessages.Fatal_UnexpectedException({ e }));
157
+ return false;
158
+ }
159
+ }
160
+ /**
161
+ * these are exported only for unit tests, do not use
162
+ */
163
+ export const unitTestEndpoints = {
164
+ build,
165
+ };
166
166
  //# sourceMappingURL=build.js.map