@keymanapp/kmc 17.0.293-beta → 17.0.294-beta
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.js +106 -108
- package/build/src/commands/analyze.js.map +1 -1
- package/build/src/commands/build.js +166 -168
- package/build/src/commands/build.js.map +1 -1
- package/build/src/commands/buildClasses/BuildActivity.js +31 -33
- package/build/src/commands/buildClasses/BuildActivity.js.map +1 -1
- package/build/src/commands/buildClasses/BuildKeyboardInfo.js +47 -49
- package/build/src/commands/buildClasses/BuildKeyboardInfo.js.map +1 -1
- package/build/src/commands/buildClasses/BuildKmnKeyboard.js +35 -37
- package/build/src/commands/buildClasses/BuildKmnKeyboard.js.map +1 -1
- package/build/src/commands/buildClasses/BuildLdmlKeyboard.js +19 -21
- package/build/src/commands/buildClasses/BuildLdmlKeyboard.js.map +1 -1
- package/build/src/commands/buildClasses/BuildModel.js +13 -15
- package/build/src/commands/buildClasses/BuildModel.js.map +1 -1
- package/build/src/commands/buildClasses/BuildModelInfo.js +73 -75
- package/build/src/commands/buildClasses/BuildModelInfo.js.map +1 -1
- package/build/src/commands/buildClasses/BuildPackage.js +13 -15
- package/build/src/commands/buildClasses/BuildPackage.js.map +1 -1
- package/build/src/commands/buildClasses/BuildProject.js +116 -118
- package/build/src/commands/buildClasses/BuildProject.js.map +1 -1
- package/build/src/commands/buildClasses/buildActivities.js +21 -23
- package/build/src/commands/buildClasses/buildActivities.js.map +1 -1
- package/build/src/commands/buildTestData/index.js +39 -41
- package/build/src/commands/buildTestData/index.js.map +1 -1
- package/build/src/commands/buildWindowsPackageInstaller/index.js +43 -45
- package/build/src/commands/buildWindowsPackageInstaller/index.js.map +1 -1
- package/build/src/commands/messageCommand.js +237 -239
- package/build/src/commands/messageCommand.js.map +1 -1
- package/build/src/kmc.js +57 -58
- package/build/src/kmc.js.map +1 -1
- package/build/src/kmlmc.js +57 -59
- package/build/src/kmlmc.js.map +1 -1
- package/build/src/kmlmp.js +46 -48
- package/build/src/kmlmp.js.map +1 -1
- package/build/src/messages/infrastructureMessages.js +75 -77
- package/build/src/messages/infrastructureMessages.js.map +1 -1
- package/build/src/messages/messageNamespaces.js +39 -41
- package/build/src/messages/messageNamespaces.js.map +1 -1
- package/build/src/util/NodeCompilerCallbacks.js +221 -223
- package/build/src/util/NodeCompilerCallbacks.js.map +1 -1
- package/build/src/util/TestKeymanSentry.d.ts +3 -2
- package/build/src/util/TestKeymanSentry.d.ts.map +1 -1
- package/build/src/util/TestKeymanSentry.js +51 -53
- package/build/src/util/TestKeymanSentry.js.map +1 -1
- package/build/src/util/baseOptions.js +24 -26
- package/build/src/util/baseOptions.js.map +1 -1
- package/build/src/util/calculateSourcePath.js +18 -20
- package/build/src/util/calculateSourcePath.js.map +1 -1
- package/build/src/util/extendedCompilerOptions.js +123 -125
- package/build/src/util/extendedCompilerOptions.js.map +1 -1
- package/build/src/util/fileLists.js +46 -48
- package/build/src/util/fileLists.js.map +1 -1
- package/build/src/util/getDeveloperBinPath.js +36 -38
- package/build/src/util/getDeveloperBinPath.js.map +1 -1
- package/build/src/util/getLastGitCommitDate.js +44 -46
- package/build/src/util/getLastGitCommitDate.js.map +1 -1
- package/build/src/util/kmcSentryOptions.d.ts +8 -0
- package/build/src/util/kmcSentryOptions.d.ts.map +1 -0
- package/build/src/util/kmcSentryOptions.js +20 -0
- package/build/src/util/kmcSentryOptions.js.map +1 -0
- package/build/src/util/projectLoader.js +51 -53
- package/build/src/util/projectLoader.js.map +1 -1
- package/build/src/util/projectRunner.js +27 -29
- package/build/src/util/projectRunner.js.map +1 -1
- package/build/src/util/sysexits.js +7 -9
- package/build/src/util/sysexits.js.map +1 -1
- package/package.json +12 -12
|
@@ -1,108 +1,106 @@
|
|
|
1
|
-
|
|
2
|
-
import * as
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
.
|
|
22
|
-
.option('-
|
|
23
|
-
.option('--
|
|
24
|
-
.
|
|
25
|
-
.
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
//
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
.
|
|
43
|
-
.
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
//
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
const
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
const
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
//# debugId=078e8c9d-263b-500d-84d0-b15f0385ab21
|
|
108
|
-
//# sourceMappingURL=analyze.js.map
|
|
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
|
+
//# sourceMappingURL=analyze.js.map
|
|
@@ -1 +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;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AAoB,EAAE;QACzF,IAAG,CAAC,MAAM,QAAQ,CAAC,OAAO,CAAC,QAAQ,EAAE,OAAO,CAAC,EAAE;YAC7C,OAAO,KAAK,CAAC;SACd;QACD,MAAM,eAAe,GAAG,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QACnD,KAAI,IAAI,QAAQ,IAAI,eAAe,EAAE;YACnC,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;YACnC,MAAM,cAAc,GAAG,QAAQ,CAAC,SAAS,CAAC,CAAC,EAAE,QAAQ,CAAC,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,GAAG,MAAM,GAAG,GAAG,CAAC;YAC1F,EAAE,CAAC,aAAa,CAAC,cAAc,EAAE,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;SAC3D;QACD,OAAO,IAAI,CAAC;IACd,CAAC,CAAC,CAAC;AACL,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG;IACtC,iBAAiB;CAClB,CAAC"}
|
|
@@ -1,168 +1,166 @@
|
|
|
1
|
-
|
|
2
|
-
import * as
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
.
|
|
20
|
-
.option('--color', '
|
|
21
|
-
|
|
22
|
-
//
|
|
23
|
-
|
|
24
|
-
.option('-
|
|
25
|
-
.option('-
|
|
26
|
-
.option('-
|
|
27
|
-
.option('-
|
|
28
|
-
.option('--no-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
.
|
|
33
|
-
.
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
*
|
|
37
|
-
* .
|
|
38
|
-
* .
|
|
39
|
-
* .
|
|
40
|
-
* .
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
.
|
|
49
|
-
.
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
.
|
|
53
|
-
.
|
|
54
|
-
.option('--
|
|
55
|
-
.option('--
|
|
56
|
-
.option('--
|
|
57
|
-
.option('--
|
|
58
|
-
.option('--
|
|
59
|
-
.option('--start-
|
|
60
|
-
.
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
//
|
|
65
|
-
|
|
66
|
-
const
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
const
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
//
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
//
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
//
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
//
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
const
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
//# debugId=ab2a34a4-83b9-5736-a47d-69510e091fd9
|
|
168
|
-
//# sourceMappingURL=build.js.map
|
|
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
|
+
.addHelpText('after', `
|
|
34
|
+
Supported file types:
|
|
35
|
+
* folder: Keyman project in folder
|
|
36
|
+
* .kpj: Keyman project
|
|
37
|
+
* .kmn: Keyman keyboard
|
|
38
|
+
* .xml: LDML keyboard
|
|
39
|
+
* .model.ts: Keyman lexical model
|
|
40
|
+
* .kps: Keyman keyboard or lexical model package
|
|
41
|
+
|
|
42
|
+
File lists can be referenced with @filelist.txt.
|
|
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
|
+
};
|
|
166
|
+
//# sourceMappingURL=build.js.map
|