@react-native-windows/cli 0.0.0-canary.200 → 0.0.0-canary.202

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 (74) hide show
  1. package/lib-commonjs/commands/autolinkWindows/autolinkWindows.d.ts +87 -87
  2. package/lib-commonjs/commands/autolinkWindows/autolinkWindows.js +654 -654
  3. package/lib-commonjs/commands/autolinkWindows/autolinkWindowsOptions.d.ts +14 -14
  4. package/lib-commonjs/commands/autolinkWindows/autolinkWindowsOptions.js +32 -32
  5. package/lib-commonjs/commands/codegenWindows/codegenWindows.d.ts +27 -27
  6. package/lib-commonjs/commands/codegenWindows/codegenWindows.js +205 -205
  7. package/lib-commonjs/commands/codegenWindows/codegenWindowsOptions.d.ts +12 -12
  8. package/lib-commonjs/commands/codegenWindows/codegenWindowsOptions.js +22 -22
  9. package/lib-commonjs/commands/config/configUtils.d.ts +123 -123
  10. package/lib-commonjs/commands/config/configUtils.js +380 -380
  11. package/lib-commonjs/commands/config/dependencyConfig.d.ts +37 -37
  12. package/lib-commonjs/commands/config/dependencyConfig.js +227 -227
  13. package/lib-commonjs/commands/config/projectConfig.d.ts +27 -27
  14. package/lib-commonjs/commands/config/projectConfig.js +180 -180
  15. package/lib-commonjs/commands/healthCheck/healthCheckList.d.ts +6 -6
  16. package/lib-commonjs/commands/healthCheck/healthCheckList.js +20 -20
  17. package/lib-commonjs/commands/healthCheck/healthChecks.d.ts +7 -7
  18. package/lib-commonjs/commands/healthCheck/healthChecks.js +123 -123
  19. package/lib-commonjs/commands/initWindows/initWindows.d.ts +46 -46
  20. package/lib-commonjs/commands/initWindows/initWindows.js +243 -243
  21. package/lib-commonjs/commands/initWindows/initWindowsOptions.d.ts +15 -15
  22. package/lib-commonjs/commands/initWindows/initWindowsOptions.js +37 -37
  23. package/lib-commonjs/commands/runWindows/runWindows.d.ts +10 -10
  24. package/lib-commonjs/commands/runWindows/runWindows.js +321 -321
  25. package/lib-commonjs/commands/runWindows/runWindowsOptions.d.ts +56 -56
  26. package/lib-commonjs/commands/runWindows/runWindowsOptions.js +132 -132
  27. package/lib-commonjs/e2etest/autolink.test.d.ts +6 -6
  28. package/lib-commonjs/e2etest/autolink.test.js +366 -366
  29. package/lib-commonjs/e2etest/dependencyConfig.test.d.ts +6 -6
  30. package/lib-commonjs/e2etest/dependencyConfig.test.js +129 -129
  31. package/lib-commonjs/e2etest/healthChecks.test.d.ts +6 -6
  32. package/lib-commonjs/e2etest/healthChecks.test.js +30 -30
  33. package/lib-commonjs/e2etest/initWindows.test.d.ts +6 -6
  34. package/lib-commonjs/e2etest/initWindows.test.js +42 -42
  35. package/lib-commonjs/e2etest/projectConfig.test.d.ts +6 -6
  36. package/lib-commonjs/e2etest/projectConfig.test.js +110 -110
  37. package/lib-commonjs/e2etest/projectConfig.utils.d.ts +8 -8
  38. package/lib-commonjs/e2etest/projectConfig.utils.js +76 -76
  39. package/lib-commonjs/e2etest/runWindows.test.d.ts +6 -6
  40. package/lib-commonjs/e2etest/runWindows.test.js +60 -60
  41. package/lib-commonjs/e2etest/typesUpToDate.test.d.ts +6 -0
  42. package/lib-commonjs/e2etest/typesUpToDate.test.js +21 -0
  43. package/lib-commonjs/e2etest/typesUpToDate.test.js.map +1 -0
  44. package/lib-commonjs/generator-common/index.d.ts +39 -39
  45. package/lib-commonjs/generator-common/index.js +242 -242
  46. package/lib-commonjs/generator-windows/index.d.ts +10 -10
  47. package/lib-commonjs/generator-windows/index.js +316 -316
  48. package/lib-commonjs/index.d.ts +50 -50
  49. package/lib-commonjs/index.js +77 -77
  50. package/lib-commonjs/utils/build.d.ts +12 -12
  51. package/lib-commonjs/utils/build.js +84 -84
  52. package/lib-commonjs/utils/checkRequirements.d.ts +6 -6
  53. package/lib-commonjs/utils/checkRequirements.js +69 -69
  54. package/lib-commonjs/utils/commandWithProgress.d.ts +21 -21
  55. package/lib-commonjs/utils/commandWithProgress.js +149 -149
  56. package/lib-commonjs/utils/deploy.d.ts +12 -12
  57. package/lib-commonjs/utils/deploy.js +353 -353
  58. package/lib-commonjs/utils/info.d.ts +6 -6
  59. package/lib-commonjs/utils/info.js +28 -28
  60. package/lib-commonjs/utils/msbuildtools.d.ts +28 -28
  61. package/lib-commonjs/utils/msbuildtools.js +273 -273
  62. package/lib-commonjs/utils/pathHelpers.d.ts +9 -9
  63. package/lib-commonjs/utils/pathHelpers.js +36 -36
  64. package/lib-commonjs/utils/telemetryHelpers.d.ts +29 -29
  65. package/lib-commonjs/utils/telemetryHelpers.js +120 -120
  66. package/lib-commonjs/utils/version.d.ts +19 -19
  67. package/lib-commonjs/utils/version.js +109 -109
  68. package/lib-commonjs/utils/vsInstalls.d.ts +34 -34
  69. package/lib-commonjs/utils/vsInstalls.js +99 -99
  70. package/lib-commonjs/utils/vstools.d.ts +16 -16
  71. package/lib-commonjs/utils/vstools.js +189 -189
  72. package/lib-commonjs/utils/winappdeploytool.d.ts +24 -24
  73. package/lib-commonjs/utils/winappdeploytool.js +108 -108
  74. package/package.json +14 -14
@@ -1,29 +1,29 @@
1
- /**
2
- * Copyright (c) Microsoft Corporation.
3
- * Licensed under the MIT License.
4
- * @format
5
- */
6
- import { Config, CommandOption } from '@react-native-community/cli-types';
7
- import { CommanderOptionsType, OptionSanitizer } from '@react-native-windows/telemetry';
8
- /**
9
- * Calculates a the default values of a given react-native CLI command's options.
10
- * @param config Config passed from react-native CLI.
11
- * @param commandOptions The options definition for the command.
12
- * @returns The default options for the command.
13
- */
14
- export declare function getDefaultOptions(config: Config, commandOptions: CommandOption[]): CommanderOptionsType;
15
- /**
16
- * Sets up and starts the telemetry gathering for the CLI command.
17
- * @param commandName The name of the CLI command.
18
- * @param config Config passed from react-native CLI.
19
- * @param options Options passed from react-native CLI.
20
- * @param defaultOptions Default options for the command.
21
- * @param optionSanitizer Function to sanitize the option values for telemetry.
22
- */
23
- export declare function startTelemetrySession(commandName: string, config: Config, options: CommanderOptionsType, defaultOptions: CommanderOptionsType, optionSanitizer: OptionSanitizer): Promise<void>;
24
- /**
25
- * Ends the gathering of telemetry for the CLI command.
26
- * @param error The error (if any) thrown during the command.
27
- * @param getExtraProps Function to get any extra command-specific telemetry properties.
28
- */
29
- export declare function endTelemetrySession(error?: Error, getExtraProps?: () => Promise<Record<string, any>>): Promise<void>;
1
+ /**
2
+ * Copyright (c) Microsoft Corporation.
3
+ * Licensed under the MIT License.
4
+ * @format
5
+ */
6
+ import { Config, CommandOption } from '@react-native-community/cli-types';
7
+ import { CommanderOptionsType, OptionSanitizer } from '@react-native-windows/telemetry';
8
+ /**
9
+ * Calculates a the default values of a given react-native CLI command's options.
10
+ * @param config Config passed from react-native CLI.
11
+ * @param commandOptions The options definition for the command.
12
+ * @returns The default options for the command.
13
+ */
14
+ export declare function getDefaultOptions(config: Config, commandOptions: CommandOption[]): CommanderOptionsType;
15
+ /**
16
+ * Sets up and starts the telemetry gathering for the CLI command.
17
+ * @param commandName The name of the CLI command.
18
+ * @param config Config passed from react-native CLI.
19
+ * @param options Options passed from react-native CLI.
20
+ * @param defaultOptions Default options for the command.
21
+ * @param optionSanitizer Function to sanitize the option values for telemetry.
22
+ */
23
+ export declare function startTelemetrySession(commandName: string, config: Config, options: CommanderOptionsType, defaultOptions: CommanderOptionsType, optionSanitizer: OptionSanitizer): Promise<void>;
24
+ /**
25
+ * Ends the gathering of telemetry for the CLI command.
26
+ * @param error The error (if any) thrown during the command.
27
+ * @param getExtraProps Function to get any extra command-specific telemetry properties.
28
+ */
29
+ export declare function endTelemetrySession(error?: Error, getExtraProps?: () => Promise<Record<string, any>>): Promise<void>;
@@ -1,121 +1,121 @@
1
- "use strict";
2
- /**
3
- * Copyright (c) Microsoft Corporation.
4
- * Licensed under the MIT License.
5
- * @format
6
- */
7
- Object.defineProperty(exports, "__esModule", { value: true });
8
- exports.endTelemetrySession = exports.startTelemetrySession = exports.getDefaultOptions = void 0;
9
- const lodash_1 = require("lodash");
10
- const telemetry_1 = require("@react-native-windows/telemetry");
11
- const commandWithProgress_1 = require("./commandWithProgress");
12
- /**
13
- * Calculates a the default values of a given react-native CLI command's options.
14
- * @param config Config passed from react-native CLI.
15
- * @param commandOptions The options definition for the command.
16
- * @returns The default options for the command.
17
- */
18
- function getDefaultOptions(config, commandOptions) {
19
- const result = {
20
- logging: false,
21
- };
22
- for (const option of commandOptions) {
23
- let key = option.name.startsWith('--')
24
- ? option.name.slice('--'.length)
25
- : option.name;
26
- key = key.trim();
27
- let value = option.default;
28
- if (value !== undefined && value.name) {
29
- value = value(config);
30
- }
31
- if (key.endsWith(' [string]')) {
32
- // Option is a string
33
- key = key.slice(0, -' [string]'.length);
34
- // Option is a number
35
- }
36
- else if (key.endsWith(' [number]')) {
37
- key = key.slice(0, -' [number]'.length);
38
- }
39
- else {
40
- // Option is a boolean
41
- // Note: Commander ignores the default property for booleans
42
- if (key.startsWith('no-')) {
43
- key = key.slice('no-'.length);
44
- // Commander always defaults to true for flags that start with --no
45
- value = true;
46
- }
47
- else {
48
- // Commander always defaults to undefined for flags
49
- value = undefined;
50
- }
51
- }
52
- key = (0, lodash_1.camelCase)(key);
53
- result[key] = value;
54
- }
55
- return result;
56
- }
57
- exports.getDefaultOptions = getDefaultOptions;
58
- /**
59
- * Sets up and starts the telemetry gathering for the CLI command.
60
- * @param commandName The name of the CLI command.
61
- * @param config Config passed from react-native CLI.
62
- * @param options Options passed from react-native CLI.
63
- * @param defaultOptions Default options for the command.
64
- * @param optionSanitizer Function to sanitize the option values for telemetry.
65
- */
66
- async function startTelemetrySession(commandName, config, options, defaultOptions, optionSanitizer) {
67
- const verbose = options.logging === true;
68
- if (!options.telemetry) {
69
- if (verbose) {
70
- (0, commandWithProgress_1.newInfo)('Telemetry is disabled');
71
- }
72
- return;
73
- }
74
- if (verbose) {
75
- (0, commandWithProgress_1.newInfo)(`Running ${(0, telemetry_1.nodeArchitecture)()} node on a ${(0, telemetry_1.deviceArchitecture)()} machine`);
76
- }
77
- if ((0, telemetry_1.deviceArchitecture)() !== (0, telemetry_1.nodeArchitecture)()) {
78
- (0, commandWithProgress_1.newWarn)('This version of node was built for a different architecture than this machine and may cause unintended behavior');
79
- }
80
- await telemetry_1.Telemetry.setup();
81
- const sanitizedOptions = (0, telemetry_1.commanderOptionsToOptions)(options, optionSanitizer);
82
- const sanitizedDefaultOptions = (0, telemetry_1.commanderOptionsToOptions)(defaultOptions, optionSanitizer);
83
- const sanitizedArgs = (0, telemetry_1.optionsToArgs)(sanitizedOptions, process.argv);
84
- const startInfo = {
85
- commandName,
86
- args: sanitizedArgs,
87
- options: sanitizedOptions,
88
- defaultOptions: sanitizedDefaultOptions,
89
- };
90
- telemetry_1.Telemetry.startCommand(startInfo);
91
- const projectInfo = await (0, telemetry_1.configToProjectInfo)(config);
92
- if (projectInfo) {
93
- telemetry_1.Telemetry.setProjectInfo(projectInfo);
94
- }
95
- const projectFile = (0, telemetry_1.getProjectFileFromConfig)(config);
96
- if (projectFile) {
97
- await telemetry_1.Telemetry.populateNuGetPackageVersions(projectFile);
98
- }
99
- }
100
- exports.startTelemetrySession = startTelemetrySession;
101
- /**
102
- * Ends the gathering of telemetry for the CLI command.
103
- * @param error The error (if any) thrown during the command.
104
- * @param getExtraProps Function to get any extra command-specific telemetry properties.
105
- */
106
- async function endTelemetrySession(error, getExtraProps) {
107
- if (!telemetry_1.Telemetry.isEnabled()) {
108
- // Bail early so don't waste time here
109
- return;
110
- }
111
- const endInfo = {
112
- resultCode: 'Success',
113
- };
114
- if (error) {
115
- endInfo.resultCode =
116
- error instanceof telemetry_1.CodedError ? error.type : 'Unknown';
117
- }
118
- telemetry_1.Telemetry.endCommand(endInfo, getExtraProps ? await getExtraProps() : undefined);
119
- }
120
- exports.endTelemetrySession = endTelemetrySession;
1
+ "use strict";
2
+ /**
3
+ * Copyright (c) Microsoft Corporation.
4
+ * Licensed under the MIT License.
5
+ * @format
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.endTelemetrySession = exports.startTelemetrySession = exports.getDefaultOptions = void 0;
9
+ const lodash_1 = require("lodash");
10
+ const telemetry_1 = require("@react-native-windows/telemetry");
11
+ const commandWithProgress_1 = require("./commandWithProgress");
12
+ /**
13
+ * Calculates a the default values of a given react-native CLI command's options.
14
+ * @param config Config passed from react-native CLI.
15
+ * @param commandOptions The options definition for the command.
16
+ * @returns The default options for the command.
17
+ */
18
+ function getDefaultOptions(config, commandOptions) {
19
+ const result = {
20
+ logging: false,
21
+ };
22
+ for (const option of commandOptions) {
23
+ let key = option.name.startsWith('--')
24
+ ? option.name.slice('--'.length)
25
+ : option.name;
26
+ key = key.trim();
27
+ let value = option.default;
28
+ if (value !== undefined && value.name) {
29
+ value = value(config);
30
+ }
31
+ if (key.endsWith(' [string]')) {
32
+ // Option is a string
33
+ key = key.slice(0, -' [string]'.length);
34
+ // Option is a number
35
+ }
36
+ else if (key.endsWith(' [number]')) {
37
+ key = key.slice(0, -' [number]'.length);
38
+ }
39
+ else {
40
+ // Option is a boolean
41
+ // Note: Commander ignores the default property for booleans
42
+ if (key.startsWith('no-')) {
43
+ key = key.slice('no-'.length);
44
+ // Commander always defaults to true for flags that start with --no
45
+ value = true;
46
+ }
47
+ else {
48
+ // Commander always defaults to undefined for flags
49
+ value = undefined;
50
+ }
51
+ }
52
+ key = (0, lodash_1.camelCase)(key);
53
+ result[key] = value;
54
+ }
55
+ return result;
56
+ }
57
+ exports.getDefaultOptions = getDefaultOptions;
58
+ /**
59
+ * Sets up and starts the telemetry gathering for the CLI command.
60
+ * @param commandName The name of the CLI command.
61
+ * @param config Config passed from react-native CLI.
62
+ * @param options Options passed from react-native CLI.
63
+ * @param defaultOptions Default options for the command.
64
+ * @param optionSanitizer Function to sanitize the option values for telemetry.
65
+ */
66
+ async function startTelemetrySession(commandName, config, options, defaultOptions, optionSanitizer) {
67
+ const verbose = options.logging === true;
68
+ if (!options.telemetry) {
69
+ if (verbose) {
70
+ (0, commandWithProgress_1.newInfo)('Telemetry is disabled');
71
+ }
72
+ return;
73
+ }
74
+ if (verbose) {
75
+ (0, commandWithProgress_1.newInfo)(`Running ${(0, telemetry_1.nodeArchitecture)()} node on a ${(0, telemetry_1.deviceArchitecture)()} machine`);
76
+ }
77
+ if ((0, telemetry_1.deviceArchitecture)() !== (0, telemetry_1.nodeArchitecture)()) {
78
+ (0, commandWithProgress_1.newWarn)('This version of node was built for a different architecture than this machine and may cause unintended behavior');
79
+ }
80
+ await telemetry_1.Telemetry.setup();
81
+ const sanitizedOptions = (0, telemetry_1.commanderOptionsToOptions)(options, optionSanitizer);
82
+ const sanitizedDefaultOptions = (0, telemetry_1.commanderOptionsToOptions)(defaultOptions, optionSanitizer);
83
+ const sanitizedArgs = (0, telemetry_1.optionsToArgs)(sanitizedOptions, process.argv);
84
+ const startInfo = {
85
+ commandName,
86
+ args: sanitizedArgs,
87
+ options: sanitizedOptions,
88
+ defaultOptions: sanitizedDefaultOptions,
89
+ };
90
+ telemetry_1.Telemetry.startCommand(startInfo);
91
+ const projectInfo = await (0, telemetry_1.configToProjectInfo)(config);
92
+ if (projectInfo) {
93
+ telemetry_1.Telemetry.setProjectInfo(projectInfo);
94
+ }
95
+ const projectFile = (0, telemetry_1.getProjectFileFromConfig)(config);
96
+ if (projectFile) {
97
+ await telemetry_1.Telemetry.populateNuGetPackageVersions(projectFile);
98
+ }
99
+ }
100
+ exports.startTelemetrySession = startTelemetrySession;
101
+ /**
102
+ * Ends the gathering of telemetry for the CLI command.
103
+ * @param error The error (if any) thrown during the command.
104
+ * @param getExtraProps Function to get any extra command-specific telemetry properties.
105
+ */
106
+ async function endTelemetrySession(error, getExtraProps) {
107
+ if (!telemetry_1.Telemetry.isEnabled()) {
108
+ // Bail early so don't waste time here
109
+ return;
110
+ }
111
+ const endInfo = {
112
+ resultCode: 'Success',
113
+ };
114
+ if (error) {
115
+ endInfo.resultCode =
116
+ error instanceof telemetry_1.CodedError ? error.type : 'Unknown';
117
+ }
118
+ telemetry_1.Telemetry.endCommand(endInfo, getExtraProps ? await getExtraProps() : undefined);
119
+ }
120
+ exports.endTelemetrySession = endTelemetrySession;
121
121
  //# sourceMappingURL=telemetryHelpers.js.map
@@ -1,19 +1,19 @@
1
- /**
2
- * Copyright (c) Microsoft Corporation.
3
- * Licensed under the MIT License.
4
- * @format
5
- */
6
- export default class Version {
7
- private readonly major;
8
- private readonly minor;
9
- private readonly build;
10
- private readonly qfe;
11
- constructor(major: number, minor?: number, build?: number, qfe?: number);
12
- eq(other: Version): boolean;
13
- gt(other: Version): boolean;
14
- gte(other: Version): boolean;
15
- toString(): string;
16
- static compare(x: Version, y: Version): number;
17
- static fromString(str: string): Version;
18
- static tryParse(str: string): Version | null;
19
- }
1
+ /**
2
+ * Copyright (c) Microsoft Corporation.
3
+ * Licensed under the MIT License.
4
+ * @format
5
+ */
6
+ export default class Version {
7
+ private readonly major;
8
+ private readonly minor;
9
+ private readonly build;
10
+ private readonly qfe;
11
+ constructor(major: number, minor?: number, build?: number, qfe?: number);
12
+ eq(other: Version): boolean;
13
+ gt(other: Version): boolean;
14
+ gte(other: Version): boolean;
15
+ toString(): string;
16
+ static compare(x: Version, y: Version): number;
17
+ static fromString(str: string): Version;
18
+ static tryParse(str: string): Version | null;
19
+ }
@@ -1,110 +1,110 @@
1
- "use strict";
2
- /**
3
- * Copyright (c) Microsoft Corporation.
4
- * Licensed under the MIT License.
5
- * @format
6
- */
7
- Object.defineProperty(exports, "__esModule", { value: true });
8
- const VERSION_EXPRESSION = /^\d{1,8}(\.\d{1,8}){0,3}$/;
9
- class Version {
10
- constructor(major, minor = 0, build = 0, qfe = 0) {
11
- this.major = major;
12
- this.minor = minor;
13
- this.build = build;
14
- this.qfe = qfe;
15
- }
16
- eq(other) {
17
- if (other.constructor !== Version) {
18
- throw new TypeError('other must be a Version instance');
19
- }
20
- return (this.major === other.major &&
21
- this.minor === other.minor &&
22
- this.build === other.build &&
23
- this.qfe === other.qfe);
24
- }
25
- gt(other) {
26
- if (other.constructor !== Version) {
27
- throw new TypeError('other must be a Version instance');
28
- }
29
- if (this.major > other.major) {
30
- return true;
31
- }
32
- if (this.major < other.major) {
33
- return false;
34
- }
35
- if (this.minor > other.minor) {
36
- return true;
37
- }
38
- if (this.minor < other.minor) {
39
- return false;
40
- }
41
- if (this.build > other.build) {
42
- return true;
43
- }
44
- if (this.build < other.build) {
45
- return false;
46
- }
47
- if (this.qfe > other.qfe) {
48
- return true;
49
- }
50
- if (this.qfe < other.qfe) {
51
- return false;
52
- }
53
- return false;
54
- }
55
- gte(other) {
56
- if (other.constructor !== Version) {
57
- throw new TypeError('other must be a Version instance');
58
- }
59
- if (this.major > other.major) {
60
- return true;
61
- }
62
- if (this.major < other.major) {
63
- return false;
64
- }
65
- if (this.minor > other.minor) {
66
- return true;
67
- }
68
- if (this.minor < other.minor) {
69
- return false;
70
- }
71
- if (this.build > other.build) {
72
- return true;
73
- }
74
- if (this.build < other.build) {
75
- return false;
76
- }
77
- if (this.qfe > other.qfe) {
78
- return true;
79
- }
80
- if (this.qfe < other.qfe) {
81
- return false;
82
- }
83
- return true;
84
- }
85
- toString() {
86
- return `${this.major}.${this.minor}.${this.build}.${this.qfe}`;
87
- }
88
- static compare(x, y) {
89
- if (x.constructor !== Version || y.constructor !== Version) {
90
- throw new TypeError('Only can compare Version objects');
91
- }
92
- return x.gt(y) ? 1 : x.eq(y) ? 0 : -1;
93
- }
94
- static fromString(str) {
95
- const version = Version.tryParse(str);
96
- if (!version) {
97
- throw new TypeError('Cannot construct a version from "' + str + '".');
98
- }
99
- return version;
100
- }
101
- static tryParse(str) {
102
- if (VERSION_EXPRESSION.test(str)) {
103
- const versionArray = str.split('.').map(x => parseInt(x, 10));
104
- return new Version(versionArray[0], versionArray[1], versionArray[2], versionArray[3]);
105
- }
106
- return null;
107
- }
108
- }
109
- exports.default = Version;
1
+ "use strict";
2
+ /**
3
+ * Copyright (c) Microsoft Corporation.
4
+ * Licensed under the MIT License.
5
+ * @format
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ const VERSION_EXPRESSION = /^\d{1,8}(\.\d{1,8}){0,3}$/;
9
+ class Version {
10
+ constructor(major, minor = 0, build = 0, qfe = 0) {
11
+ this.major = major;
12
+ this.minor = minor;
13
+ this.build = build;
14
+ this.qfe = qfe;
15
+ }
16
+ eq(other) {
17
+ if (other.constructor !== Version) {
18
+ throw new TypeError('other must be a Version instance');
19
+ }
20
+ return (this.major === other.major &&
21
+ this.minor === other.minor &&
22
+ this.build === other.build &&
23
+ this.qfe === other.qfe);
24
+ }
25
+ gt(other) {
26
+ if (other.constructor !== Version) {
27
+ throw new TypeError('other must be a Version instance');
28
+ }
29
+ if (this.major > other.major) {
30
+ return true;
31
+ }
32
+ if (this.major < other.major) {
33
+ return false;
34
+ }
35
+ if (this.minor > other.minor) {
36
+ return true;
37
+ }
38
+ if (this.minor < other.minor) {
39
+ return false;
40
+ }
41
+ if (this.build > other.build) {
42
+ return true;
43
+ }
44
+ if (this.build < other.build) {
45
+ return false;
46
+ }
47
+ if (this.qfe > other.qfe) {
48
+ return true;
49
+ }
50
+ if (this.qfe < other.qfe) {
51
+ return false;
52
+ }
53
+ return false;
54
+ }
55
+ gte(other) {
56
+ if (other.constructor !== Version) {
57
+ throw new TypeError('other must be a Version instance');
58
+ }
59
+ if (this.major > other.major) {
60
+ return true;
61
+ }
62
+ if (this.major < other.major) {
63
+ return false;
64
+ }
65
+ if (this.minor > other.minor) {
66
+ return true;
67
+ }
68
+ if (this.minor < other.minor) {
69
+ return false;
70
+ }
71
+ if (this.build > other.build) {
72
+ return true;
73
+ }
74
+ if (this.build < other.build) {
75
+ return false;
76
+ }
77
+ if (this.qfe > other.qfe) {
78
+ return true;
79
+ }
80
+ if (this.qfe < other.qfe) {
81
+ return false;
82
+ }
83
+ return true;
84
+ }
85
+ toString() {
86
+ return `${this.major}.${this.minor}.${this.build}.${this.qfe}`;
87
+ }
88
+ static compare(x, y) {
89
+ if (x.constructor !== Version || y.constructor !== Version) {
90
+ throw new TypeError('Only can compare Version objects');
91
+ }
92
+ return x.gt(y) ? 1 : x.eq(y) ? 0 : -1;
93
+ }
94
+ static fromString(str) {
95
+ const version = Version.tryParse(str);
96
+ if (!version) {
97
+ throw new TypeError('Cannot construct a version from "' + str + '".');
98
+ }
99
+ return version;
100
+ }
101
+ static tryParse(str) {
102
+ if (VERSION_EXPRESSION.test(str)) {
103
+ const versionArray = str.split('.').map(x => parseInt(x, 10));
104
+ return new Version(versionArray[0], versionArray[1], versionArray[2], versionArray[3]);
105
+ }
106
+ return null;
107
+ }
108
+ }
109
+ exports.default = Version;
110
110
  //# sourceMappingURL=version.js.map
@@ -1,34 +1,34 @@
1
- /**
2
- * Copyright (c) Microsoft Corporation.
3
- * Licensed under the MIT License.
4
- * @format
5
- */
6
- /**
7
- * A subset of the per-instance properties returned by vswhere
8
- */
9
- interface VisualStudioInstallation {
10
- instanceId: string;
11
- installationPath: string;
12
- installationVersion: string;
13
- prerelease: string;
14
- }
15
- /**
16
- * Enumerate the installed versions of Visual Studio
17
- */
18
- export declare function enumerateVsInstalls(opts: {
19
- requires?: string[];
20
- minVersion?: string;
21
- verbose?: boolean;
22
- latest?: boolean;
23
- prerelease?: boolean;
24
- }): VisualStudioInstallation[];
25
- /**
26
- * Find the latest available VS installation that matches the given constraints
27
- */
28
- export declare function findLatestVsInstall(opts: {
29
- requires?: string[];
30
- minVersion?: string;
31
- verbose?: boolean;
32
- prerelease?: boolean;
33
- }): VisualStudioInstallation | null;
34
- export {};
1
+ /**
2
+ * Copyright (c) Microsoft Corporation.
3
+ * Licensed under the MIT License.
4
+ * @format
5
+ */
6
+ /**
7
+ * A subset of the per-instance properties returned by vswhere
8
+ */
9
+ interface VisualStudioInstallation {
10
+ instanceId: string;
11
+ installationPath: string;
12
+ installationVersion: string;
13
+ prerelease: string;
14
+ }
15
+ /**
16
+ * Enumerate the installed versions of Visual Studio
17
+ */
18
+ export declare function enumerateVsInstalls(opts: {
19
+ requires?: string[];
20
+ minVersion?: string;
21
+ verbose?: boolean;
22
+ latest?: boolean;
23
+ prerelease?: boolean;
24
+ }): VisualStudioInstallation[];
25
+ /**
26
+ * Find the latest available VS installation that matches the given constraints
27
+ */
28
+ export declare function findLatestVsInstall(opts: {
29
+ requires?: string[];
30
+ minVersion?: string;
31
+ verbose?: boolean;
32
+ prerelease?: boolean;
33
+ }): VisualStudioInstallation | null;
34
+ export {};